From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E52E8C433EF for ; Thu, 17 Feb 2022 17:04:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FB596B0080; Thu, 17 Feb 2022 12:04:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ABF06B0081; Thu, 17 Feb 2022 12:04:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54CB96B0082; Thu, 17 Feb 2022 12:04:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 456736B0080 for ; Thu, 17 Feb 2022 12:04:04 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DE3F98249980 for ; Thu, 17 Feb 2022 17:04:03 +0000 (UTC) X-FDA: 79152894366.26.4492F66 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf06.hostedemail.com (Postfix) with ESMTP id 40628180008 for ; Thu, 17 Feb 2022 17:04:03 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 037701F383; Thu, 17 Feb 2022 17:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1645117442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pKbc9KvNKps7m3RUOPrYHBO98Vg0WoynWbU0oCx7WKM=; b=p+X6Ad7ZueQiQO+WPDqvruaTR4aOOxHcHhN+1Ief5sJJW0GK3NsxXvjlhtHkXj76j34jkS Wn/zKMe3zI0egSkHawRHGHHqxYgEc0AHQFlp2641EQ2ykAO9hOMSVtuxllf4sPCuacHpiH Lh4WxpXHoIEjqvC5kreIOhneGb3ogZ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1645117442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pKbc9KvNKps7m3RUOPrYHBO98Vg0WoynWbU0oCx7WKM=; b=pEGg0Fx2KoANzummLqbpJryuWYr7cE3rwoZ1HI07fxRz6k7V+Yu5WSAtP6DMn6xbcTH3nv fXaaC//wSlwiE0Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CCB8313C23; Thu, 17 Feb 2022 17:04:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Mvg0MQGADmLHDgAAMHmgww (envelope-from ); Thu, 17 Feb 2022 17:04:01 +0000 Message-ID: <49a1bc35-7505-bc82-2931-e57f7b959cb3@suse.cz> Date: Thu, 17 Feb 2022 18:04:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] mm/slab_common: use helper function is_power_of_2() Content-Language: en-US To: Miaohe Lin Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Christoph Lameter , penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com References: <20220217091609.8214-1-linmiaohe@huawei.com> <8f307e8a-5f97-cf5d-0a77-1c79b05abd60@suse.cz> <5d904bee-3faf-374a-090c-ce7c99c84ea9@huawei.com> From: Vlastimil Babka In-Reply-To: <5d904bee-3faf-374a-090c-ce7c99c84ea9@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 40628180008 X-Stat-Signature: 6777eesn688p7uegtstwefkuts8rhdch X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=p+X6Ad7Z; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=pEGg0Fx2; dmarc=none; spf=pass (imf06.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-HE-Tag: 1645117443-287282 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2/17/22 11:44, Miaohe Lin wrote: > On 2022/2/17 17:23, Vlastimil Babka wrote: >> On 2/17/22 10:16, Miaohe Lin wrote: >>> Use helper function is_power_of_2() to check if KMALLOC_MIN_SIZE is power >>> of two. Minor readability improvement. >>> >>> Signed-off-by: Miaohe Lin >> >> We can try, but in case some compiler will no longer able to perform the >> check at build-time (although is_power_of_2() looks sufficiently trivial >> too), we'll have to revert it. > > I see. I checked the compiler in my env but there might be some compilers can't > perform the check at build-time. I'll add this to the slab tree and linux-next and we'll see if wider testing uncovers such compilers. Should be unlikely. > Many thanks for your reply. > >> >>> --- >>> mm/slab_common.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/mm/slab_common.c b/mm/slab_common.c >>> index 23f2ab0713b7..6ee64d6208b3 100644 >>> --- a/mm/slab_common.c >>> +++ b/mm/slab_common.c >>> @@ -807,7 +807,7 @@ void __init setup_kmalloc_cache_index_table(void) >>> unsigned int i; >>> >>> BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 || >>> - (KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1))); >>> + !is_power_of_2(KMALLOC_MIN_SIZE)); >>> >>> for (i = 8; i < KMALLOC_MIN_SIZE; i += 8) { >>> unsigned int elem = size_index_elem(i); >> >> . >> >