From patchwork Sat Sep 3 02:12:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12964881 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 52CD8C38145 for ; Sat, 3 Sep 2022 02:12:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD3E48014A; Fri, 2 Sep 2022 22:12:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A83A680120; Fri, 2 Sep 2022 22:12:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94B408014A; Fri, 2 Sep 2022 22:12:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8755380120 for ; Fri, 2 Sep 2022 22:12:33 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5D62040C16 for ; Sat, 3 Sep 2022 02:12:33 +0000 (UTC) X-FDA: 79869150186.30.EB2DAC4 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf15.hostedemail.com (Postfix) with ESMTP id 07CC6A0058 for ; Sat, 3 Sep 2022 02:12:32 +0000 (UTC) Received: by mail-pl1-f202.google.com with SMTP id y9-20020a17090322c900b00174c881abaeso2217730plg.6 for ; Fri, 02 Sep 2022 19:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=PCnXu6Ez0jB+98uMl8AwRDWuGAhomE5ehBJOGe8FkrQ=; b=SI4LV/PWZ5Xuz1apJsXnDcmx6sQ3nbIDwDCjhgXYtc4R3cWcgFY7VaMK/r9w39eDvo 95NivZ58BrPLuk8JubWWpunWnr0pdMgMiyToiYbnFF79vkQqBwh8wCWBOF/90WaCP4ek sefsaqTxUnA/SShD0C9/DcPuJ2KMadbR5RizqU+g6G7RVFzcn8vvISOTdxPZT9QCDcbq XeQZ+FQ4/zyTThU+1efwZZ1yjVAuPE74npNEeZYVUD9X2gYg9gxLFZeCOMsI9WD0SRgJ IHWdVgKyz5mvpcFptgcht3j62eyWSBmnMPe7yJ7uArelCYbXq7avH8wUTQuz30EoObOB UOcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=PCnXu6Ez0jB+98uMl8AwRDWuGAhomE5ehBJOGe8FkrQ=; b=Kuj/GM1+AfdDzzm1J/aVB9TeLwcP+yv6l/WYxPL2GpBC45eMMB6k+Ad4/jKE3ESFB1 A63YKsvvXyreuXhr6Cq2MiiU5AtodtkLVQWFVtkCcej+4oZYbuJZ8rw7n9JspP2ycPjd +BQtQ08qYLfC9DUPKlioyEMkxqIH1Oa4iuJJQ1VDyN16gi+OgsbY+VVOCI0LbQblnKxD FBpXJM3gGUo8K98MXf1PhXdjji270PRzrIqKcPmkBxarFjZoAoWnWuE/dk9B9BY9LjRy 2abdoxgx8uEweWtB0UmWiKWYfZVb3tWNpqf52exq2uBmhYUeXZD00DxDuI4JBmbeivgG LaAw== X-Gm-Message-State: ACgBeo0LopHgJMiwHXSGfcGg9n6eoE36mjlcYev932uYdZq8jtmn9gG6 /34u4TUoHEmrIpNbKapWeNnoP0v9ug8Z X-Google-Smtp-Source: AA6agR6z7Xfd2iH/4+nQDAYuw7UQL+W7rkLMan/SAjtMGGGA8ai3MLycxZ7lUGSKQ/Hwk/HUvKxkmEmV3DfS X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a17:90a:249:b0:1e0:a8a3:3c6c with SMTP id t9-20020a17090a024900b001e0a8a33c6cmr54632pje.0.1662171151478; Fri, 02 Sep 2022 19:12:31 -0700 (PDT) Date: Fri, 2 Sep 2022 19:12:21 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220903021221.1130021-1-zokeefe@google.com> Subject: [PATCH mm-unstable] mm/khugepaged: fix struct collapse_control load_node definition From: "Zach O'Keefe" To: Andrew Morton Cc: linux-mm@kvack.org, Yang Shi , kbuild-all@lists.01.org, "Zach O'Keefe" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662171153; a=rsa-sha256; cv=none; b=BDGIPEosTOQi/nAcjzMMgYqZWxPHlWQWhle6q/6s0Ndmbgv005cnFtP6qffnrje1rNDdQb vmr+wR8DKT/Y0zQiJvSUhg6n+IJdSjF5wA0Jsqql2Ikyd/BxwKQd7UBVvXDjFVHkFEK42R sixt6LADdTbIla8TrKpEgqUe/UN7oDE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="SI4LV/PW"; spf=pass (imf15.hostedemail.com: domain of 3D7gSYwcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3D7gSYwcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662171153; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=PCnXu6Ez0jB+98uMl8AwRDWuGAhomE5ehBJOGe8FkrQ=; b=Lvvz8oQFJfVjqdRNl+ZrDcu4OSA7Ngu/5EQe284jAGSj+CedzFAQ5x/fZtcDLjgAnJjWjS UnDFHqk1KjSCIy9olylWcJUn20+Y0nSGLOBVntaYjP1EE9R8X4B4YLvYxfZvafksPNDfwu wVuOS8HgHqXyA0yszlBvZj5qjo1zKgM= X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="SI4LV/PW"; spf=pass (imf15.hostedemail.com: domain of 3D7gSYwcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3D7gSYwcKCOgjYUOOPOQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam09 X-Stat-Signature: rgb1o133xg3pwrrthdgyoen37jwyr4je X-Rspamd-Queue-Id: 07CC6A0058 X-HE-Tag: 1662171152-181768 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: HPAGE_PMD_ORDER is used to determine a minimal amount of bits needed to store per-node counters in struct collapse_control, defining the array to be either a u16[HPAGE_PMD_ORDER] or u32[HPAGE_PMD_ORDER]. For some architectures/configs, HPAGE_PMD_ORDER isn't resolved at preprocessor time (suitable for resolving preprocessor directives) but rather expands into a compiler built-in that is resolved at compile-time. E.g. for 32-bit MIPS (see link for full config): ---8<-- >> arch/mips/include/asm/pgtable.h:238:26: warning: "__builtin_ffs" is not defined, evaluates to 0 [-Wundef] 238 | #define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1) | ^~~~~~~~~~~~~ arch/mips/include/asm/pgtable-32.h:65:43: note: in expansion of macro 'PTE_T_LOG2' 65 | # define PGDIR_SHIFT (2 * PAGE_SHIFT - PTE_T_LOG2 - 1) | ^~~~~~~~~~ include/asm-generic/pgtable-nop4d.h:11:33: note: in expansion of macro 'PGDIR_SHIFT' 11 | #define P4D_SHIFT PGDIR_SHIFT | ^~~~~~~~~~~ include/asm-generic/pgtable-nopud.h:18:25: note: in expansion of macro 'P4D_SHIFT' 18 | #define PUD_SHIFT P4D_SHIFT | ^~~~~~~~~ include/asm-generic/pgtable-nopmd.h:20:25: note: in expansion of macro 'PUD_SHIFT' 20 | #define PMD_SHIFT PUD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:109:25: note: in expansion of macro 'PMD_SHIFT' 109 | #define HPAGE_PMD_SHIFT PMD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:105:26: note: in expansion of macro 'HPAGE_PMD_SHIFT' 105 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) | ^~~~~~~~~~~~~~~ mm/khugepaged.c:90:5: note: in expansion of macro 'HPAGE_PMD_ORDER' 90 | #if HPAGE_PMD_ORDER < 16 | ^~~~~~~~~~~~~~~ >> arch/mips/include/asm/pgtable.h:238:39: error: missing binary operator before token "(" 238 | #define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1) | ^ arch/mips/include/asm/pgtable-32.h:65:43: note: in expansion of macro 'PTE_T_LOG2' 65 | # define PGDIR_SHIFT (2 * PAGE_SHIFT - PTE_T_LOG2 - 1) | ^~~~~~~~~~ include/asm-generic/pgtable-nop4d.h:11:33: note: in expansion of macro 'PGDIR_SHIFT' 11 | #define P4D_SHIFT PGDIR_SHIFT | ^~~~~~~~~~~ include/asm-generic/pgtable-nopud.h:18:25: note: in expansion of macro 'P4D_SHIFT' 18 | #define PUD_SHIFT P4D_SHIFT | ^~~~~~~~~ include/asm-generic/pgtable-nopmd.h:20:25: note: in expansion of macro 'PUD_SHIFT' 20 | #define PMD_SHIFT PUD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:109:25: note: in expansion of macro 'PMD_SHIFT' 109 | #define HPAGE_PMD_SHIFT PMD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:105:26: note: in expansion of macro 'HPAGE_PMD_SHIFT' 105 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) | ^~~~~~~~~~~~~~~ mm/khugepaged.c:90:5: note: in expansion of macro 'HPAGE_PMD_ORDER' 90 | #if HPAGE_PMD_ORDER < 16 | ^~~~~~~~~~~~~~~ ---8<-- load_node is already special-cased for CONFIG_PPC64 in "mm-khugepaged-add-struct-collapse_control-fix-fix", and we could continue down that path by #define'ing away edge cases, but I think at this point it easier to just let load_node be an array of u32s. If it's ever an issue, we can revisit. This essentially rolls back both: "mm/khugepaged: use minimal bits to store num page < HPAGE_PMD_NR" "mm-khugepaged-add-struct-collapse_control-fix-fix" (though we'll leave it as a u32 vs an int). Link: https://lore.kernel.org/linux-mm/202209021349.F73i5d6X-lkp@intel.com/ Fixes: 5f7bb00bd9cd ("mm/khugepaged: use minimal bits to store num page < HPAGE_PMD_NR") Fixes: 03053c821af2 ("mm-khugepaged-add-struct-collapse_control-fix-fix") Signed-off-by: Zach O'Keefe --- mm/khugepaged.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index af3b07eb2389..29142a35d24c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -93,13 +93,8 @@ struct collapse_control { bool is_khugepaged; /* Num pages scanned per node */ -#if defined(CONFIG_PPC64) u32 node_load[MAX_NUMNODES]; -#elif HPAGE_PMD_ORDER < 16 - u16 node_load[MAX_NUMNODES]; -#else - u32 node_load[MAX_NUMNODES]; -#endif + /* Last target selected in hpage_collapse_find_target_node() */ int last_target_node; };