From owner-svn-src-head@FreeBSD.ORG Thu Oct 25 13:26:00 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E2BAC522; Thu, 25 Oct 2012 13:26:00 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail04.syd.optusnet.com.au (mail04.syd.optusnet.com.au [211.29.132.185]) by mx1.freebsd.org (Postfix) with ESMTP id 5D3198FC08; Thu, 25 Oct 2012 13:25:59 +0000 (UTC) Received: from c122-106-175-26.carlnfd1.nsw.optusnet.com.au (c122-106-175-26.carlnfd1.nsw.optusnet.com.au [122.106.175.26]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q9PDPuG9025624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Oct 2012 00:25:57 +1100 Date: Fri, 26 Oct 2012 00:25:56 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov Subject: Re: svn commit: r242029 - head/sys/kern In-Reply-To: <20121025080551.GG35915@deviant.kiev.zoral.com.ua> Message-ID: <20121026001150.Q842@besplex.bde.org> References: <201210250146.q9P1kLi8043704@svn.freebsd.org> <20121025080551.GG35915@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-Cloudmark-Score: 0 X-Optus-Cloudmark-Analysis: v=2.0 cv=F/YP7ddN c=1 sm=1 a=w0_tA2oI8IYA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=M4roAWbnUW4A:10 a=5ygRqN-VXvxw57WzJSIA:9 a=CjuIK1q_8ugA:10 a=bxQHXO5Py4tHmhUgaywp5w==:117 Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, Alfred Perlstein , src-committers@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2012 13:26:01 -0000 On Thu, 25 Oct 2012, Konstantin Belousov wrote: > On Thu, Oct 25, 2012 at 01:46:21AM +0000, Alfred Perlstein wrote: >> ... >> Modified: head/sys/kern/subr_param.c >> ============================================================================== >> --- head/sys/kern/subr_param.c Thu Oct 25 01:27:01 2012 (r242028) >> +++ head/sys/kern/subr_param.c Thu Oct 25 01:46:20 2012 (r242029) >> @@ -278,8 +278,16 @@ init_param2(long physpages) >> maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE); >> if (maxusers < 32) >> maxusers = 32; >> - if (maxusers > 384) >> - maxusers = 384; >> + /* >> + * Clips maxusers to 384 on machines with <= 4GB RAM or 32bit. >> + * Scales it down 6x for large memory machines. >> + */ >> + if (maxusers > 384) { >> + if (sizeof(void *) <= 4) >> + maxusers = 384; >> + else >> + maxusers = 384 + ((maxusers - 384) / 6); >> + } > This is unbelievably weird way to express the '64bit'. The > #ifdef _LP64 is enough there instead of the runtime check. Such runtime checks are well optimized by compilers, giving nicer code than ifdefs. However, there are lots of other style bugs: - comments writtens not in English is - after deciphering the comments, we see that they match the code only in the unbelievably weird ways: (1) <= 4GB RAM isn't necessarily related to the size of void *. In fact, the size of physical memory certainly isn't related. The size of virtual memory is more closely related. But it is the physical memory size that is most relevant here. (2) 32 bitness isn't necessaril related to the size of void *. - after fixing the comments, they would just echo the code, and thus shouldn't be made. No comments are made for the other maxusers initializations, although it would be easy to write ones 10 times longer than this mail to describe all the historical bogus tuning given by maxusers. - half a level of indentation for the maxusers lines - excessive parentheses. Bruce