For this series: Reviewed-by: Bill Fischofer <[email protected]:
On Mon, May 16, 2016 at 1:51 PM, Maxim Uvarov <[email protected]> wrote: > odp_shm_reserve() relays on huge page size to round up > requested size. If 1 Gb pages present than parser takes > it first as first alphabetical file name in sysfs. That > lead to issue where all allocations wants 1 GB HP. This > patch takes system default huge pages which are usually 2Mb, > and has to be enough for existence odp example apps and > validation tests. > > Reported-by: B.Nousilal <[email protected]> > Signed-off-by: Maxim Uvarov <[email protected]> > --- > platform/linux-generic/odp_system_info.c | 43 > +++++++++++--------------------- > 1 file changed, 15 insertions(+), 28 deletions(-) > > diff --git a/platform/linux-generic/odp_system_info.c > b/platform/linux-generic/odp_system_info.c > index 0f1f3c7..8e95e05 100644 > --- a/platform/linux-generic/odp_system_info.c > +++ b/platform/linux-generic/odp_system_info.c > @@ -24,12 +24,9 @@ > #include <sys/types.h> > #include <dirent.h> > > - > #define CACHE_LNSZ_FILE \ > "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size" > > -#define HUGE_PAGE_DIR "/sys/kernel/mm/hugepages" > - > /* > * Report the number of logical CPUs detected at boot time > */ > @@ -77,37 +74,27 @@ static int systemcpu_cache_line_size(void) > #endif > > > -static int huge_page_size(void) > +static uint64_t default_huge_page_size(void) > { > - DIR *dir; > - struct dirent *dirent; > - int size = 0; > + char str[1024]; > + unsigned long sz; > + FILE *file; > > - dir = opendir(HUGE_PAGE_DIR); > - if (dir == NULL) { > - ODP_ERR("%s not found\n", HUGE_PAGE_DIR); > - return 0; > - } > - > - while ((dirent = readdir(dir)) != NULL) { > - int temp = 0; > - > - if (sscanf(dirent->d_name, "hugepages-%i", &temp) != 1) > - continue; > - > - if (temp > size) > - size = temp; > - } > + file = fopen("/proc/meminfo", "rt"); > > - if (closedir(dir)) { > - ODP_ERR("closedir failed\n"); > - return 0; > + while (fgets(str, sizeof(str), file) != NULL) { > + if (sscanf(str, "Hugepagesize: %8lu kB", &sz) == 1) { > + ODP_DBG("defaut hp size is %" PRIu64 " kB\n", sz); > + fclose(file); > + return (uint64_t)sz * 1024; > + } > } > > - return size * 1024; > + ODP_ERR("unable to get default hp size\n"); > + fclose(file); > + return 0; > } > > - > /* > * Analysis of /sys/devices/system/cpu/ files > */ > @@ -137,7 +124,7 @@ static int systemcpu(odp_system_info_t *sysinfo) > return -1; > } > > - sysinfo->huge_page_size = huge_page_size(); > + sysinfo->huge_page_size = default_huge_page_size(); > > return 0; > } > -- > 2.7.1.250.gff4ea60 > > _______________________________________________ > lng-odp mailing list > [email protected] > https://lists.linaro.org/mailman/listinfo/lng-odp > _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
