From patchwork Tue Oct 10 14:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13415691 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 C487FCD8C99 for ; Tue, 10 Oct 2023 14:56:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 222488D00BE; Tue, 10 Oct 2023 10:56:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AB8C8D0002; Tue, 10 Oct 2023 10:56:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04BCB8D00BE; Tue, 10 Oct 2023 10:56:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E52B58D0002 for ; Tue, 10 Oct 2023 10:56:01 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B3413A01A5 for ; Tue, 10 Oct 2023 14:56:01 +0000 (UTC) X-FDA: 81329851722.20.0D000B8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id DE82A16000E for ; Tue, 10 Oct 2023 14:55:58 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fdNeQB0C; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696949760; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=vp6teXUVeTaVuntNL+yXUHhW+AagRb8DJbn/Ed9G6Fo=; b=xY0hYStEEtcN6bY9cl3iRVv8OjV5PXlJ0qwx2+EfPGgTHJUWMeNFeWlIioDzjwbsp0VHHk 7i1J/cuckBlxDyP9PTe2pPTMwlng7Q/4ebErn8EwEogeAQ8Pr2ZafZ4wCXHg/3axNoRJ9u Ws7G8/wVKtZN4xJZvKnVr2ko9noSg1A= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fdNeQB0C; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696949760; a=rsa-sha256; cv=none; b=43C+IOdj/+Gna+QNFA7Bk9G6tMAn2a67eES50xVRhaJN6RcPn6ob0SyuroC19jyjaq5blL GmsXa874Nzx7ZecUPC2G36atO4Of7yMZWIhT0BE4k1o7TkgDoJaGQP4I1w1LjPJ8e2kI83 0k8ZQtgG1uLNFkzZHcGTSCVqNH9Owu4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=vp6teXUVeTaVuntNL+yXUHhW+AagRb8DJbn/Ed9G6Fo=; b=fdNeQB0CeUpgr9GoqZ7MTuVH3L u948e+D6m1yQXsjzA24hWFSX9wAD4IwF+jC1FHQbawtGknj9KCuaVIdl79D2/H0jnj5XH4nYagFuA Mnwxa7DvO1Ur62Do0KoErqvWsDQEeTHqIyC94SFFeNv9VvUjT3CULo2PhrfKhLHCEgZuxeMEdgUx9 GFIden08ogGkjv7XgNhG24AwcGYkJb2bb6pHrSxMn+bu16I9RGmgjYqe2BhCd4fME7eDdl9WdC/H+ Mr+woddq90y1e70YM4IbsLkU20BXM258bjyGLD9SLDpyYPUpgUIQ7ePzykRizhxNDCNpkISk3i1/o xz6eLFlw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qqE9K-005DpE-2o; Tue, 10 Oct 2023 14:55:54 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Peter Zijlstra , Mel Gorman , Ingo Molnar , Rik van Riel Subject: [PATCH] bounds: Support non-power-of-two CONFIG_NR_CPUS Date: Tue, 10 Oct 2023 15:55:49 +0100 Message-Id: <20231010145549.1244748-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: DE82A16000E X-Rspam-User: X-Stat-Signature: jdq31gprnngyj6ga3cswrh4jp7w7orr9 X-Rspamd-Server: rspam01 X-HE-Tag: 1696949758-799511 X-HE-Meta: U2FsdGVkX1/G5mZdhVd2V9JS4Pn+mjese1OwyeIaBwqBB54zZZMO4HquNNbx1WW1m5irMy1h/LBbUClfgypv+LxMQz49oeIfpT559IbksnUbzLmaJqlOHkbMJ2TGXLaYeNQJ98PdB4eC99+bmtf3/Ig6QIt8RIjjLi59wp/ZKJGmPZfvVQlLs3cDMn35lyEdtTQhYvmLMU/1MJMtFuEYqXYgVMVSLclctQ1cc6tW4cvDL3pBG9ejnDImLNbUOLt1RS5Omg2Sf3UbxviD7IQA/iQNCec6yqMNEi0Tp4oOWSQhuskbsE1gEff2H7Y19PHQ6med2ka3IJVkb8/xmsHOJgkgXaQQ2qXMPxkgj9W0H55GD/o+e1h2rt6BqU+wEL5qlsexrYglg9KXqBBfa9DK7m0KygT2BZ2a8FKvKBFp8rHWRnQY9WHJ1jRyiGRUXC4Bh2EXarNQ21QnSuXWA9WmIEKHiN7z1dUOnPc0tDXVaYdXPNpHDk25RtUpcaib+PDzuZVzLaKJiHqdc9dfxFV4bBPB+7T5vDL2tKRIWM5ktZxbYlcA0PQskflt+R78sWlIUWGCfqgpu1xYBhiUdYOZeS8iLLH1ZZag1CnRJExUHR8WXzAWxHSxpU3Ch5CLwQTwhp/u+fOZU/ngMR45IcAgDWDMZQXfVhKGy62ZQqblwsc1s1zayWz8nSduuWgXjuzr6Hp+AAfBeQ4016rfBDvf0/f7kMyvnOGp2r9vs9heGPfgJUmDfxw+sOBgrv9X1TjUJoxSGxHwi7whmHxqgF0avYjx42CIhR1kxbD4qC6oHy846Z6jjhScNg4AzYTn+mZl1X8EnwnIuTTHtbvRzKbZpek2DZllcotjY24wVKgDL5oUqBXfHb559MY1Qj8dnNGZTeHKpsZIsviH0Lgtmta+sLx8f7zlKueXkbXyjQkEt0W4tcOOms1osmJA1uOLXmKHOQQTWSzDe8NttXq0jNt G6JDbksb Ft+4eJqp3otMhJgmCV6kGpu3c7b3zAvCmSICTNvDjPDmvgVPoUKSmjb0LVBZKQ6+88JIx4x+0Qao81zAOWfx+1tZVDPoDc0xoaCPybJ5IVl+9IDerMvG6td8mQPvelMgDpDTMYzQKMkJ/1AAS2hz8xksuUCwXQNC6KcWSPM3kCx/uhByScaSn/NwNv3DkWaIVQmPGpN6jk+003cHalCUgdcOBpE8k/Ek5ts/PbZ7xlEGWwr+/svrUm2eVmeDBVCAQy1/B26+qS2lFSXHPNNlhLFYvRgZV9dxw/TmIt+GdAIeIciB65xillTv2mnU1f+/Sdt3PEp1WrqJpgNDWDjdTK/x2NCNkimQg5wxXlMawfIiLZNnO49bFzv3Kxodmiv2rxFVN3Vb5uvlOX0+ckjXIhswcb3gIAn3K3jrWYHOJ9a97LF8= 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: ilog2() rounds down, so for example when PowerPC 85xx sets CONFIG_NR_CPUS to 24, we will only allocate 4 bits to store the number of CPUs instead of 5. Use bits_per() instead, which rounds up. Found by code inspection. The effect of this would probably be a misaccounting when doing NUMA balancing, so to a user, it would only be a performance penalty. The effects may be more wide-spread; it's hard to tell. Signed-off-by: Matthew Wilcox (Oracle) Fixes: 90572890d202 ("mm: numa: Change page last {nid,pid} into {cpu,pid}") Cc: Peter Zijlstra Cc: Mel Gorman Cc: Ingo Molnar Cc: Rik van Riel Reviewed-by: Rik van Riel Acked-by: Mel Gorman --- kernel/bounds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bounds.c b/kernel/bounds.c index b529182e8b04..c5a9fcd2d622 100644 --- a/kernel/bounds.c +++ b/kernel/bounds.c @@ -19,7 +19,7 @@ int main(void) DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS); DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES); #ifdef CONFIG_SMP - DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); + DEFINE(NR_CPUS_BITS, bits_per(CONFIG_NR_CPUS)); #endif DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); #ifdef CONFIG_LRU_GEN