From 749e605e9d1a058fec6fd07d346bcb791092b230 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Thu, 24 Mar 2016 06:17:06 +0000 Subject: [PATCH] Affinity shared memory area must be at least a page If the system page size is greater than 4kB (or 32kB in the case of BIGNUMA), then the affinity code will fail to initialise. Ensure the shared memory area is at least one page in size. --- driver/others/init.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/driver/others/init.c b/driver/others/init.c index f134f85f7..62b0d5495 100644 --- a/driver/others/init.c +++ b/driver/others/init.c @@ -555,24 +555,24 @@ static inline int is_dead(int id) { } static void open_shmem(void) { + int shm_size = 4096; + +#if defined(BIGNUMA) + // raised to 32768, enough for 128 nodes and 1024 cups + shm_size = 32*1024; +#endif + + // needs to be at least one page + shm_size = MAX(getpagesize(), shm_size); int try = 0; do { -#if defined(BIGNUMA) - // raised to 32768, enough for 128 nodes and 1024 cups - shmid = shmget(SH_MAGIC, 32768, 0666); -#else - shmid = shmget(SH_MAGIC, 4096, 0666); -#endif + shmid = shmget(SH_MAGIC, shm_size, 0666); if (shmid == -1) { -#if defined(BIGNUMA) - shmid = shmget(SH_MAGIC, 32768, IPC_CREAT | 0666); -#else - shmid = shmget(SH_MAGIC, 4096, IPC_CREAT | 0666); -#endif + shmid = shmget(SH_MAGIC, shm_size, IPC_CREAT | 0666); } try ++;