From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0ACC3D7D83 for ; Tue, 23 Jun 2026 15:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782227494; cv=none; b=lWtTJgQI+L4h5GBvyd1AVQWIOQ0qPoJHY8/6uLhy6d1CBImNbw/if6Zt9htr8zwSmfh4SbtXAWqVE1NSbE+L0p0Lmzr5y1/V8okkIRLBoZPUlsrKA+BkMITE2xKpMcrJiUDjI5OQHtLoUs+tYBhFJG9oR/xzf5afOLjUX1iM1co= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782227494; c=relaxed/simple; bh=KrE18r1pnujfuaglIDxCS1hhUuxePbDk+kE9eQnEvjg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=O4ISLMQxS5ug0g6AqZlVJTyLx8mOUWDqRoYuHiIkcYbb4Q5MtzfRmQIKv8IpdqvaKrh4SV5kh7nIbWn+9G/dNTGEQG8jt9F8aJ5+9GvSP5DSp3R3UoXA44lvYObBr0ZAZA0cqfOQtCVJAJgKvGC8eoQoJtDg+c3YnzEvay/To0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bSLK41f0; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=FIcYQtFd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Ffw27Ijz; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=AFioEuWV; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bSLK41f0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="FIcYQtFd"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Ffw27Ijz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="AFioEuWV" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AA5AA75B3E; Tue, 23 Jun 2026 15:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1782227490; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JUIdX+cuQxmf/QBPQGQf4EzL0EUySkrV1FzpCj/UfNE=; b=bSLK41f0rxnmqtQ+/w6WQ2082btIAJZfXQ7VgHlu5PKnmVmj+JQncaP5U7oeCkEK3Pgtjs hDvG6EQ9vJvJ6Bw3meQHW9BzeLFrzFzVnh43GLQ0iUeRxaak6gFhazlSepo9sULZUMQUTO pz9QGTiiACRKr+uWzsh9LweflKYglUY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1782227490; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JUIdX+cuQxmf/QBPQGQf4EzL0EUySkrV1FzpCj/UfNE=; b=FIcYQtFd0S8oR6YF67FuNFNSt7eiL4hhhWry+Jd66qw/j8hFj90m0/+OLAfHAk6EulMrB0 vui1QlN10Kh0CNBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Ffw27Ijz; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=AFioEuWV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1782227489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JUIdX+cuQxmf/QBPQGQf4EzL0EUySkrV1FzpCj/UfNE=; b=Ffw27Ijz12J5UX23RhlJRP159NiwCpWnox/DJ9Q4rIrd03g+NK/vq4AhRZtjbYxv1VocOu Lo7kCMD1otaKLHsoKJ2CylY11d2fLLiENjSvvme2Tjtb6tYest+ufjZ7GSSHgOYHmPOo4n 8ffM4v2ED171ikU0eM2X0ic+ZGxu/1M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1782227489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JUIdX+cuQxmf/QBPQGQf4EzL0EUySkrV1FzpCj/UfNE=; b=AFioEuWVTEpo7gsfoHjcGnOB3XN5OA160eKJoDk8MtGJw3FTp59hN4wQECiDZRxLjrhynj IY4hFbhB/rtnohCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6DE9A779A8; Tue, 23 Jun 2026 15:11:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id pnawDiGiOmpdWAAAD6G6ig (envelope-from ); Tue, 23 Jun 2026 15:11:29 +0000 From: Gabriel Krisman Bertazi To: Prateek Cc: io-uring@vger.kernel.org, kprateek283@gmail.com Subject: Re: [PATCH] setup: dynamically detect default huge page size In-Reply-To: <20260623110930.910263-1-kprateek283@gmail.com> Organization: SUSE References: <87qzlyy0zd.fsf@mailhost.krisman.be> <20260623110930.910263-1-kprateek283@gmail.com> Date: Tue, 23 Jun 2026 11:11:27 -0400 Message-ID: <87jyrpuw9s.fsf@mailhost.krisman.be> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Flag: NO X-Rspamd-Action: no action X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_TO(0.00)[gmail.com]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; HAS_ORG_HEADER(0.00)[]; ARC_NA(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FREEMAIL_CC(0.00)[vger.kernel.org,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,mailhost.krisman.be:mid,suse.de:dkim] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: AA5AA75B3E X-Spam-Score: -4.51 Prateek writes: > Hi Gabriel, > > Thanks for the review. > > On Mon, Jun 22, 2026 at 16:49 Gabriel Krisman Bertazi wrote: >> > +static size_t get_huge_page_size(void) >> > +{ >> > + static size_t hps; >> >> Please, initialize your static variables to makes it readable. I.e, >> should be initialized it to 2MB. > > hps is left at 0 on purpose as a "not computed yet" flag -- same thing > get_page_size() does in arch/aarch64/lib.h with cache_val. If I set > hps = 2MB upfront, the first call just returns 2MB without ever > reading /proc/meminfo, which defeats the point. Ah, of course. Back to the original point, please initialize hps explicitly (to 0). Yeah, I know the compiler should do that for you in C99. Still, make it explicit. > >> > + size_t ret = 2 * 1024 * 1024; /* fallback: 2MB */ >> >> ret redundant with hps, could go away. > > The local ret is there so I only write to hps once at the end. If two > threads race into this function, neither one sees a half-baked > fallback value in hps. The race itself is harmless since both threads > would compute the same result anyway. No, it is redundant. You don't need to have "half-baked" values in hps either. as you already use val to build your hugepage size. ret is just an extra step that will vanish in compilation. There are many ways around it. For instance: unsigned long val = 0; ... out: hps = (val)?: 2*1024*1024; /* fallback to 2 MB pages */ return hps; -- Gabriel Krisman Bertazi