Received: from eggs.gnu.org ([2001:4830:134:3::10]:51758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bc5wW-0007AK-Ol for qemu-devel@nongnu.org; Tue, 23 Aug 2016 03:16:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bc5wR-000221-N7 for qemu-devel@nongnu.org; Tue, 23 Aug 2016 03:16:15 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:52146 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bc5wR-00021p-Db for qemu-devel@nongnu.org; Tue, 23 Aug 2016 03:16:11 -0400 References: <1471871071-17819-1-git-send-email-pl@kamp.de> <1471871071-17819-2-git-send-email-pl@kamp.de> From: Peter Lieven Message-ID: <899bcd15-ab7a-da2f-0d46-fd39963f85d5@kamp.de> Date: Tue, 23 Aug 2016 09:16:04 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V6 1/6] oslib-posix: add helpers for stack alloc and free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson , qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, mst@redhat.com, dgilbert@redhat.com, peter.maydell@linaro.org, eblake@redhat.com, armbru@redhat.com Am 22.08.2016 um 17:19 schrieb Richard Henderson: > On 08/22/2016 06:04 AM, Peter Lieven wrote: >> +static size_t adjust_stack_size(size_t sz) >> +{ >> +#ifdef _SC_THREAD_STACK_MIN >> + /* avoid stacks smaller than _SC_THREAD_STACK_MIN */ >> + sz = MAX(MAX(sysconf(_SC_THREAD_STACK_MIN), 0), sz); >> +#endif > > You need to place the sysconf result into a local variable. What you have now expands to 4 invocations of the function. okay, I thought it would only be 2 calls and its not critical. but I can change that. > > You might also consider passing in the pagesize, since you've already called getpagesize in one of the two users of this function. I can change this as well, but isn't getpagesize just a macro on most systems? If the call of getpagesize is critical we should cache it somewhere as there are more critical sections that call it repeatly. Peter