Date: Thu, 12 May 2005 16:05:43 -0400 From: John Baldwin <jhb@FreeBSD.org> To: freebsd-hackers@FreeBSD.org Cc: Vladislav Shabanov <vs@rambler-co.ru> Subject: Re: do-nothing code in sysv_shm.c Message-ID: <200505121605.44816.jhb@FreeBSD.org> In-Reply-To: <200504112003.25096.vs@rambler-co.ru> References: <200504112003.25096.vs@rambler-co.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 11 April 2005 12:03 pm, Vladislav Shabanov wrote: > I`ve found the following code in sysv_shm.c : > > ............ > static void > shminit() > { > int i; > > TUNABLE_INT_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall); > for (i = PAGE_SIZE; i > 0; i--) { > shminfo.shmmax = shminfo.shmall * PAGE_SIZE; > if (shminfo.shmmax >= shminfo.shmall) > break; > } > TUNABLE_INT_FETCH("kern.ipc.shmmin", &shminfo.shmmin); > ......... > > IMHO, loop does nothing. Possible variant: > > #define shmall_bits (sizeof(shminfo.shmall)*8) > > if (0 == (shminfo.shmall & (~ ( (1<<(shmall_bits-PAGE_SHIFT-1)) - 1)))) { > /* if high PAGE_SHIFT+1 bits of shminfo.shmall is zero */ > shminfo.shmmax = shminfo.shmall << PAGE_SHIFT; > } else { > shminfo.shmmax = __INT_MAX; > } > > ------------------------------ > previous changes in this part of code: > > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/sysv_shm.c.diff?r1=1.78& >r2=1.79&f=h > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/sysv_shm.c.diff?r1=1.79& >r2=1.80&f=h _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" After talking to Alfred, I just changed it to use 'i' rather than PAGE_SIZE in the loop as it's easy to follow and given that this code only runs once at boot it's not critical that it be fast. Thanks for the report! -- John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505121605.44816.jhb>