Le 24/07/2012 13:39, Brice Goglin a écrit : > Le 23/07/2012 18:40, Pavan Balaji a écrit : >>>> 3. The changes to config/hwloc.m4 and include/private/private.h are >>>> essentially a warning squash when getpagesize() requires an explicit >>>> prototype declaration. But it's not clear how easy it is for you to >>>> absorb it as it uses an MPICH2 internal m4 macro. Maybe there's a >>>> cleaner way to integrate this patch. >>> I will look at this. On which platform/system did you need this patch? >> On regular x86_64 machines. We use strict builds in mpich2. I can >> figure out the exact flags that trigger it, but my guess is that -Wall >> would. > Looking deeper into this, it looks like the right solution is to use > sysconf(_SC_PAGESIZE) instead of getpagesize(). getpagesize() looks > deprecated, that's why it's getting disabled when modern features are > enabled. I'll send a patch to use sysconf when supported and fallback to > the old getpagesize() otherwise. >
Can you try this patch of some of your platforms? I think I couldn't reproduce your problem because hwloc's AC_USE_SYSTEM_EXTENSIONS defines _GNU_SOURCE, which defines _BSD_SOURCE, which defines __USE_BSD, which makes getpagesize() available without looking at other XOPEN/POSIX defines. Brice Brice
diff --git a/config/hwloc.m4 b/config/hwloc.m4 index b373e2e..80c8bc3 100644 --- a/config/hwloc.m4 +++ b/config/hwloc.m4 @@ -388,6 +388,8 @@ EOF]) _SC_NPROCESSORS_CONF, _SC_NPROC_ONLN, _SC_NPROC_CONF, + _SC_PAGESIZE, + _SC_PAGE_SIZE, _SC_LARGE_PAGESIZE],,[:],[[#include <unistd.h>]]) AC_HAVE_HEADERS([mach/mach_host.h]) diff --git a/include/private/private.h b/include/private/private.h index bc46fdb..1083f61 100644 --- a/include/private/private.h +++ b/include/private/private.h @@ -17,6 +17,9 @@ #include <hwloc/bitmap.h> #include <private/debug.h> #include <sys/types.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #ifdef HAVE_STDINT_H #include <stdint.h> #endif @@ -368,4 +371,14 @@ extern void hwloc_group_by_distances(struct hwloc_topology *topology); #define fabsf(f) fabs((double)(f)) #endif +#if HAVE_DECL__SC_PAGE_SIZE +#define hwloc_getpagesize() sysconf(_SC_PAGE_SIZE) +#elif HAVE_DECL__SC_PAGESIZE +#define hwloc_getpagesize() sysconf(_SC_PAGESIZE) +#elif defined HAVE_GETPAGESIZE +#define hwloc_getpagesize() getpagesize() +#else +#undef hwloc_getpagesize +#endif + #endif /* HWLOC_PRIVATE_H */ diff --git a/src/bind.c b/src/bind.c index a828879..a9ed5aa 100644 --- a/src/bind.c +++ b/src/bind.c @@ -447,12 +447,12 @@ void * hwloc_alloc_heap(hwloc_topology_t topology __hwloc_attribute_unused, size_t len) { void *p; -#if defined(HAVE_GETPAGESIZE) && defined(HAVE_POSIX_MEMALIGN) - errno = posix_memalign(&p, getpagesize(), len); +#if defined(hwloc_getpagesize) && defined(HAVE_POSIX_MEMALIGN) + errno = posix_memalign(&p, hwloc_getpagesize(), len); if (errno) p = NULL; -#elif defined(HAVE_GETPAGESIZE) && defined(HAVE_MEMALIGN) - p = memalign(getpagesize(), len); +#elif defined(hwloc_getpagesize) && defined(HAVE_MEMALIGN) + p = memalign(hwloc_getpagesize(), len); #else p = malloc(len); #endif diff --git a/src/topology-aix.c b/src/topology-aix.c index dd62774..90a3279 100644 --- a/src/topology-aix.c +++ b/src/topology-aix.c @@ -613,7 +613,7 @@ look_rset(int sdl, hwloc_obj_type_t type, struct hwloc_topology *topology, int l obj->memory.page_types_len = 2; obj->memory.page_types = malloc(2*sizeof(*obj->memory.page_types)); memset(obj->memory.page_types, 0, 2*sizeof(*obj->memory.page_types)); - obj->memory.page_types[0].size = getpagesize(); + obj->memory.page_types[0].size = hwloc_getpagesize(); #ifdef HAVE__SC_LARGE_PAGESIZE obj->memory.page_types[1].size = sysconf(_SC_LARGE_PAGESIZE); #endif diff --git a/src/topology-linux.c b/src/topology-linux.c index e56e1bd..5640721 100644 --- a/src/topology-linux.c +++ b/src/topology-linux.c @@ -1313,7 +1313,7 @@ hwloc_linux_get_area_membind(hwloc_topology_t topology, const void *addr, size_t int mixed = 0; int full = 0; int first = 1; - int pagesize = getpagesize(); + int pagesize = hwloc_getpagesize(); char *tmpaddr; int err; unsigned i; @@ -1914,7 +1914,7 @@ hwloc_get_kerrighed_node_meminfo_info(struct hwloc_topology *topology, unsigned #ifdef HAVE__SC_LARGE_PAGESIZE memory->page_types[1].size = sysconf(_SC_LARGE_PAGESIZE); #endif - memory->page_types[0].size = getpagesize(); + memory->page_types[0].size = hwloc_getpagesize(); } snprintf(path, sizeof(path), "/proc/nodes/node%lu/meminfo", node); @@ -1965,7 +1965,7 @@ hwloc_get_procfs_meminfo_info(struct hwloc_topology *topology, struct hwloc_obj_ #ifdef HAVE__SC_LARGE_PAGESIZE memory->page_types[1].size = sysconf(_SC_LARGE_PAGESIZE); #endif - memory->page_types[0].size = getpagesize(); /* might be overwritten later by /proc/meminfo or sysfs */ + memory->page_types[0].size = hwloc_getpagesize(); /* might be overwritten later by /proc/meminfo or sysfs */ } hwloc_parse_meminfo_info(topology, "/proc/meminfo", 0 /* no prefix */, @@ -2057,7 +2057,7 @@ hwloc_sysfs_node_meminfo_info(struct hwloc_topology *topology, } } /* update what's remaining as normal pages */ - memory->page_types[0].size = getpagesize(); + memory->page_types[0].size = hwloc_getpagesize(); memory->page_types[0].count = remaining_local_memory / memory->page_types[0].size; } } diff --git a/src/topology-osf.c b/src/topology-osf.c index 7113eaf..858f36e 100644 --- a/src/topology-osf.c +++ b/src/topology-osf.c @@ -276,11 +276,11 @@ hwloc_look_osf(struct hwloc_topology *topology) indexes[radid] = radid; nodes[radid] = obj = hwloc_alloc_setup_object(HWLOC_OBJ_NODE, radid); obj->cpuset = hwloc_bitmap_alloc(); - obj->memory.local_memory = rad_get_physmem(radid) * getpagesize(); + obj->memory.local_memory = rad_get_physmem(radid) * hwloc_getpagesize(); obj->memory.page_types_len = 2; obj->memory.page_types = malloc(2*sizeof(*obj->memory.page_types)); memset(obj->memory.page_types, 0, 2*sizeof(*obj->memory.page_types)); - obj->memory.page_types[0].size = getpagesize(); + obj->memory.page_types[0].size = hwloc_getpagesize(); #ifdef HAVE__SC_LARGE_PAGESIZE obj->memory.page_types[1].size = sysconf(_SC_LARGE_PAGESIZE); #endif diff --git a/src/topology-solaris.c b/src/topology-solaris.c index a65a5c4..37bc4c0 100644 --- a/src/topology-solaris.c +++ b/src/topology-solaris.c @@ -374,7 +374,7 @@ browse(struct hwloc_topology *topology, lgrp_cookie_t cookie, lgrp_id_t lgrp, hw obj->memory.page_types_len = 2; obj->memory.page_types = malloc(2*sizeof(*obj->memory.page_types)); memset(obj->memory.page_types, 0, 2*sizeof(*obj->memory.page_types)); - obj->memory.page_types[0].size = getpagesize(); + obj->memory.page_types[0].size = hwloc_getpagesize(); #ifdef HAVE__SC_LARGE_PAGESIZE obj->memory.page_types[1].size = sysconf(_SC_LARGE_PAGESIZE); #endif