From patchwork Wed Mar 3 07:16:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12113007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DC66C433DB for ; Wed, 3 Mar 2021 07:16:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1DF3E64EBD for ; Wed, 3 Mar 2021 07:16:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DF3E64EBD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 84B7B8D012F; Wed, 3 Mar 2021 02:16:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FA078D0127; Wed, 3 Mar 2021 02:16:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69BC68D012F; Wed, 3 Mar 2021 02:16:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id 4EF388D0127 for ; Wed, 3 Mar 2021 02:16:14 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0ACA73632 for ; Wed, 3 Mar 2021 07:16:14 +0000 (UTC) X-FDA: 77877704268.27.865BC20 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf30.hostedemail.com (Postfix) with ESMTP id 45A7BE0011C5 for ; Wed, 3 Mar 2021 07:16:12 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id g18so9061388qki.15 for ; Tue, 02 Mar 2021 23:16:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=Mnua9sIpK4opv1bat3S4YMVM0wLz7zG7EDFUzDE8sqE=; b=hrT1ZnLtQU+yhwzRAN83U2EvzE0FXH5gAcsU/4kIr7dt6WlCWitE6Zo4dcHWpT/xfN S8Bksk5PZK8jeiXjD3s91Eplec/+1eTPJGl5rTAqIP5GwQhD7rkPpSDBNy+UEBF+GySd yCQK23q5uHZGpA+bBUBVNvdpdbPfjlK/dAwuAZbwJIikjS6GuWDXmi8wpp/tPT/etAoE b+A8MIprP6qE2T5WH+CIedjotGXMb8fopDkdIz/3vVqc2Eq5EGdfaiiP7woksQ3PNuiy PU0A2wwI+DE+6DCtmliZw9cDO+GMbnlHE1ymcc9olNm474R/F45cdVnbVOLwlAEy37UL nNrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=Mnua9sIpK4opv1bat3S4YMVM0wLz7zG7EDFUzDE8sqE=; b=X5jHL9Y4hQjXLpnW3hVEKOPi/QJF39zeLoDYHJPPPPljjtum0gQlkR+cbz+LAP9p01 sGqxoc4QUxSagFiqHyVE0ouQoK4EnzRYtH51KCq6KYHgczQkLzGoxaAeHe1OCxEGmXzj snxhMKOjN784sT2Qwf6vHdsE0uknoNx9DtlfSZCJMbZArGKfC4pYD25qjmA4aJPKHChK pPL7+qQZs5oYTHWIL95/h1pL+gn1bfGqBBQW/5+bCuuL694+MDo+t+gFJxJKjE3Lo1FH AJlrjhz+t1zlp6l1gYW3EtvrnPzsNYud7jr/pEXuGDnCpX6z/axGXvCVbr6vxtKUtenI uBJQ== X-Gm-Message-State: AOAM531pQXLl9zo4MkNyKiKDnmnfGw+D16g5jcm0KzfchbTrLpEXfcbR jmlZ+N87Rm5mwpgeeDRVPJ/cnVEHp5o= X-Google-Smtp-Source: ABdhPJyGSB4z+pduFim01lG0Bb1doDwpJf2J5Ka4e2MdOhYE45ZwWhwKA0kUzFI/+t2Id2aBe4JXpHo/vKI= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:4877:a627:46e9:4b6]) (user=yuzhao job=sendgmr) by 2002:a0c:e84d:: with SMTP id l13mr7151041qvo.28.1614755772802; Tue, 02 Mar 2021 23:16:12 -0800 (PST) Date: Wed, 3 Mar 2021 00:16:08 -0700 Message-Id: <20210303071609.797782-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH 1/2] mm: correctly determine LAST_CPUPID_WIDTH From: Yu Zhao To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yu Zhao X-Stat-Signature: xzt94npge78r3wacoakidk8iordw4mxb X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 45A7BE0011C5 Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from="<3vDc_YAYKCDElhmUNbTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--yuzhao.bounces.google.com>"; helo=mail-qk1-f201.google.com; client-ip=209.85.222.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614755772-492857 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: The naming convention used in include/linux/page-flags-layout.h: *_SHIFT: the number of bits trying to allocate *_WIDTH: the number of bits successfully allocated So when it comes to LAST_CPUPID_WIDTH, we need to check whether all previous *_WIDTH and LAST_CPUPID_SHIFT can fit into page flags. This means we need to use NODES_WIDTH, not NODES_SHIFT. Signed-off-by: Yu Zhao --- include/linux/page-flags-layout.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags-layout.h b/include/linux/page-flags-layout.h index 7d4ec26d8a3e..295c2c687d2c 100644 --- a/include/linux/page-flags-layout.h +++ b/include/linux/page-flags-layout.h @@ -83,7 +83,7 @@ #define KASAN_TAG_WIDTH 0 #endif -#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT+KASAN_TAG_WIDTH \ +#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_WIDTH+LAST_CPUPID_SHIFT+KASAN_TAG_WIDTH \ <= BITS_PER_LONG - NR_PAGEFLAGS #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT #else From patchwork Wed Mar 3 07:16:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12113009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23CDFC433E0 for ; Wed, 3 Mar 2021 07:16:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D64764EBD for ; Wed, 3 Mar 2021 07:16:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D64764EBD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 16CA28D0130; Wed, 3 Mar 2021 02:16:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11D538D0127; Wed, 3 Mar 2021 02:16:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3CFD8D0130; Wed, 3 Mar 2021 02:16:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id AC8938D0127 for ; Wed, 3 Mar 2021 02:16:15 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6765A363D for ; Wed, 3 Mar 2021 07:16:15 +0000 (UTC) X-FDA: 77877704310.16.AE3BA6B Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) by imf20.hostedemail.com (Postfix) with ESMTP id C5C06E6 for ; Wed, 3 Mar 2021 07:16:13 +0000 (UTC) Received: by mail-qt1-f201.google.com with SMTP id b21so7102845qtr.8 for ; Tue, 02 Mar 2021 23:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ClvpDldXpDZ9EYbyGO2+VfM3Q4fJkR3CmabRdEQwcbc=; b=S93ke0X5VyNloubqrT/61/KsoxXCF1VtWzLmU249W/3N3Xfpbajh/vp0GZP5+H1uh8 lXJEkKkhznxcpPULnJ5IZRFgMVOM5usqOYdlcTe6QDJ1ZWvmqeMGCFqCq42pWgKsdtp4 lP8WqzJ8MlDHg16Gl6tfAkgAyjp4GybEaXm5Kp8mKdNuRa33Vz7zBpD844u/lA5a3jr5 Kus0vSH7Tfrap3j3JHgr0tO/D+N2e/B3Us4QW6mnAiCJmQY3ldKPW8kocslG2JZm7vAI De1ZQ8tElRTGsjXl9Dmpgoczx1HB6xdlUQWltiMX4dn7jKQ2kwrznPZmzSNnt3QaQ9Fz EBGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ClvpDldXpDZ9EYbyGO2+VfM3Q4fJkR3CmabRdEQwcbc=; b=qVVV0Ei34SraybgQj0NgQD743+qcfjSeWrhktxslV0gM/ssCkbhFGjsw40zQNq3AHC 6vH3ofRAqluWnB1sEN8J4j/ZWg0EYHYpFzyHeMdhQ/x1St63hQoKhtQ6P5DTicywHaIP LHC+/kO2cegYHQvkzlQPcjJolYlmoPhOGXlOyYDt8l3Zq6mcRmiewvG+aKtELuDP1jWo 0ZBsGxkS8Yyf3r4XVxWfC6DqoOU33BGTB0Px+LYfojyayC9n7T67VC6uw8t53U6heqmD ibSMoytovh6y9c5gChRLrGYDRxBzQfxsNP8xFW+vtRbqWAGAltPNi1op9Zw7dmdF4S7g Fqow== X-Gm-Message-State: AOAM531cGb+3yWQUforuiT0DEhjG7wwO1iEXRcL7H79vMcjpddGlrvJe IFdARNjk2Shz56txnMKtYz2qxkNAO0g= X-Google-Smtp-Source: ABdhPJxqR9zlDA75+iO4JbN0AuZYmFengDs5FuNzGPkCd1EziC9gx2VPqfm8ZmI7naElTni3RyuaV808qYo= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:4877:a627:46e9:4b6]) (user=yuzhao job=sendgmr) by 2002:a0c:bf12:: with SMTP id m18mr1454169qvi.40.1614755774177; Tue, 02 Mar 2021 23:16:14 -0800 (PST) Date: Wed, 3 Mar 2021 00:16:09 -0700 In-Reply-To: <20210303071609.797782-1-yuzhao@google.com> Message-Id: <20210303071609.797782-2-yuzhao@google.com> Mime-Version: 1.0 References: <20210303071609.797782-1-yuzhao@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH 2/2] mm: clean up include/linux/page-flags-layout.h From: Yu Zhao To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yu Zhao X-Stat-Signature: g3sfadbpooif8esmr4y3tkaax8je3qn3 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C5C06E6 Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from="<3vjc_YAYKCDMnjoWPdVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yuzhao.bounces.google.com>"; helo=mail-qt1-f201.google.com; client-ip=209.85.160.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614755773-318312 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: Tidy things up and delete comments stating the obvious with typos or making no sense. Signed-off-by: Yu Zhao --- include/linux/page-flags-layout.h | 62 +++++++++++++++---------------- mm/mm_init.c | 4 -- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/include/linux/page-flags-layout.h b/include/linux/page-flags-layout.h index 295c2c687d2c..ef1e3e736e14 100644 --- a/include/linux/page-flags-layout.h +++ b/include/linux/page-flags-layout.h @@ -21,16 +21,17 @@ #elif MAX_NR_ZONES <= 8 #define ZONES_SHIFT 3 #else -#error ZONES_SHIFT -- too many zones configured adjust calculation +#error ZONES_SHIFT "Too many zones configured" #endif +#define ZONES_WIDTH ZONES_SHIFT + #ifdef CONFIG_SPARSEMEM #include - -/* SECTION_SHIFT #bits space required to store a section # */ #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS) - -#endif /* CONFIG_SPARSEMEM */ +#else +#define SECTIONS_SHIFT 0 +#endif #ifndef BUILD_VDSO32_64 /* @@ -54,17 +55,28 @@ #define SECTIONS_WIDTH 0 #endif -#define ZONES_WIDTH ZONES_SHIFT - -#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS +#if ZONES_WIDTH + SECTIONS_WIDTH + NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS #define NODES_WIDTH NODES_SHIFT -#else -#ifdef CONFIG_SPARSEMEM_VMEMMAP +#elif defined(CONFIG_SPARSEMEM_VMEMMAP) #error "Vmemmap: No space for nodes field in page flags" -#endif +#else #define NODES_WIDTH 0 #endif +/* + * Note that this #define MUST have a value so that it can be tested with + * the IS_ENABLED() macro. + */ +#if NODES_SHIFT != 0 && NODES_WIDTH == 0 +#define NODE_NOT_IN_PAGE_FLAGS 1 +#endif + +#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) +#define KASAN_TAG_WIDTH 8 +#else +#define KASAN_TAG_WIDTH 0 +#endif + #ifdef CONFIG_NUMA_BALANCING #define LAST__PID_SHIFT 8 #define LAST__PID_MASK ((1 << LAST__PID_SHIFT)-1) @@ -77,37 +89,21 @@ #define LAST_CPUPID_SHIFT 0 #endif -#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) -#define KASAN_TAG_WIDTH 8 -#else -#define KASAN_TAG_WIDTH 0 -#endif - -#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_WIDTH+LAST_CPUPID_SHIFT+KASAN_TAG_WIDTH \ +#if ZONES_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + KASAN_TAG_WIDTH + LAST_CPUPID_SHIFT \ <= BITS_PER_LONG - NR_PAGEFLAGS #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT #else #define LAST_CPUPID_WIDTH 0 #endif -#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH+LAST_CPUPID_WIDTH+KASAN_TAG_WIDTH \ +#if LAST_CPUPID_SHIFT != 0 && LAST_CPUPID_WIDTH == 0 +#define LAST_CPUPID_NOT_IN_PAGE_FLAGS +#endif + +#if ZONES_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + KASAN_TAG_WIDTH + LAST_CPUPID_WIDTH \ > BITS_PER_LONG - NR_PAGEFLAGS #error "Not enough bits in page flags" #endif -/* - * We are going to use the flags for the page to node mapping if its in - * there. This includes the case where there is no node, so it is implicit. - * Note that this #define MUST have a value so that it can be tested with - * the IS_ENABLED() macro. - */ -#if !(NODES_WIDTH > 0 || NODES_SHIFT == 0) -#define NODE_NOT_IN_PAGE_FLAGS 1 -#endif - -#if defined(CONFIG_NUMA_BALANCING) && LAST_CPUPID_WIDTH == 0 -#define LAST_CPUPID_NOT_IN_PAGE_FLAGS -#endif - #endif #endif /* _LINUX_PAGE_FLAGS_LAYOUT */ diff --git a/mm/mm_init.c b/mm/mm_init.c index 8e02e865cc65..9ddaf0e1b0ab 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -19,10 +19,6 @@ #ifdef CONFIG_DEBUG_MEMORY_INIT int __meminitdata mminit_loglevel; -#ifndef SECTIONS_SHIFT -#define SECTIONS_SHIFT 0 -#endif - /* The zonelists are simply reported, validation is manual. */ void __init mminit_verify_zonelist(void) {