From patchwork Fri Nov 4 01:10:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13031156 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78352C4332F for ; Fri, 4 Nov 2022 01:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=h2CI7pJzoDUr3iUTKX85fh7gj/p+N95YhVLYN7LR4t8=; b=vrdFmqumEh52WwyFo/k3NAhq2q 46IXpimtFefr5hc4eNbI5ILuhi5FCfNSF7IXmnkTY2Gv8jX1UyFjc9cxfA8WA3Q5zRCymLINHqKDD fdx6K8lAnjx4j3yvqt6vMXVzoluRNLjqEBD+cHtkPsZ1t5k6edOBGoBbxFYSOfU41aEZiZwMLaGeP hLE9mvf52CUR/PicYg8xUxRen0cPjhbNjKNg5QQQHPgjEs2Noz0uRPzyrxCvpqCnLFKiCxn0sFAMe o8/KtLsmPrHHs0Ka5xIVUi8SHf3mBeQbCw6OXKrSJNDNS1gPGAizwYRO61/I29a5G5Be2TAfFAQ5W x1YxCeZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqlEo-0024aH-Bq; Fri, 04 Nov 2022 01:11:14 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqlEh-0024WY-Dp for linux-arm-kernel@lists.infradead.org; Fri, 04 Nov 2022 01:11:08 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3691846091fso33268997b3.9 for ; Thu, 03 Nov 2022 18:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+t0ALZHHA6ZFAi9QaYH6w0GblkExI9N8HBofpI53uEE=; b=coTqk8yN2lIpqf4lZuerdn/huDOzxShTgkUYVz06et76b9CUvnZWNbtYisMo8FAJe+ bHk+un7ojScHCm3ttSHWveijfJgkQQ/jpEW9ZKdZyv5p9OsycrZW1cxlQuscVQzarevk V4p3UgCQesiJYEiFHSXHaD/VrBYJQTObnqJsK/fzbJ4ufyKAjS9D7JJn2vA82q7Wltzt PEQH5DmcP5NluJrA7GoVk2s2O7t3QYXkBouu9I8kK1VinDt230mAoZRqSluKQBeY4bp7 vis3SkJ4xkj0sa2+msOP+yymYx/cL417FhqniDtlLNIh+ro5KCiTLnGXeXAHWGqf5Dee HA9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+t0ALZHHA6ZFAi9QaYH6w0GblkExI9N8HBofpI53uEE=; b=DrxMh/Z7JOTrglE9Mp5jqVORINUuWI0AqtaK3J8A0mADFLmudssThW2xLlCDPPLLan oCgTh588O19hSTvsWhUHB+0CyJFt0hNuf/WDBStW+LsuiVeJZ9bAsayUheBCG12o8dh9 o9xVBcCHl2lIBtQ3HMt6EKdE059wrHxyJQ09XvuswgLNb5OiiGWCBPlv7fx+trP9qKn2 NrLIEs86+KGfRbhpiaI3Z2Y7J99ckxUUtwwrlEvA8Gz/yfGSQBJMPw3sJe+vkML2xYaX Cdk4e+RadRM82TTFxiQMBytfb20hfUjaQfSMGMy5Axgbff4HUHJDG11gMoR+ecQ4KuIM CJlA== X-Gm-Message-State: ACrzQf2fTrBY5bSYDIge2RYCaL5HMbRwpA8SwcQJeZaxUWDQjWK2yZm2 7zdRfxALeYvPZhVnYk+86JfDCYZ+8F11HjImB2meP2QimIhREkKf5zajZcjs7FniZTZaVkz7Lly +IYWxg98Qaj98XpEjUu61unl9YCYxX3R2XUZY1VdMUmcG6TWQ5ai2z90Tg7zRzMCivu5VPHBc X-Google-Smtp-Source: AMsMyM6DSVuK9mNKweU8pz1/m0WgjmOG8tIlqPQ+K5VyNJKxYPnNKrmU1a5ZoZdyX5Qe9xdFOo1rCys= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:2844:b0ec:e556:30d8]) (user=pcc job=sendgmr) by 2002:a05:690c:822:b0:35c:b671:d36a with SMTP id by2-20020a05690c082200b0035cb671d36amr203232ywb.62.1667524262070; Thu, 03 Nov 2022 18:11:02 -0700 (PDT) Date: Thu, 3 Nov 2022 18:10:34 -0700 In-Reply-To: <20221104011041.290951-1-pcc@google.com> Message-Id: <20221104011041.290951-2-pcc@google.com> Mime-Version: 1.0 References: <20221104011041.290951-1-pcc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Subject: [PATCH v5 1/8] mm: Do not enable PG_arch_2 for all 64-bit architectures From: Peter Collingbourne To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Catalin Marinas , Cornelia Huck , Will Deacon , Marc Zyngier , Evgenii Stepanov , kvm@vger.kernel.org, Steven Price , Vincenzo Frascino , Peter Collingbourne , kernel test robot , Andrew Morton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_181107_494898_B605A521 X-CRM114-Status: GOOD ( 17.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Catalin Marinas Commit 4beba9486abd ("mm: Add PG_arch_2 page flag") introduced a new page flag for all 64-bit architectures. However, even if an architecture is 64-bit, it may still have limited spare bits in the 'flags' member of 'struct page'. This may happen if an architecture enables SPARSEMEM without SPARSEMEM_VMEMMAP as is the case with the newly added loongarch. This architecture port needs 19 more bits for the sparsemem section information and, while it is currently fine with PG_arch_2, adding any more PG_arch_* flags will trigger build-time warnings. Add a new CONFIG_ARCH_USES_PG_ARCH_X option which can be selected by architectures that need more PG_arch_* flags beyond PG_arch_1. Select it on arm64. Signed-off-by: Catalin Marinas [pcc@google.com: fix build with CONFIG_ARM64_MTE disabled] Signed-off-by: Peter Collingbourne Reported-by: kernel test robot Cc: Andrew Morton Cc: Steven Price Reviewed-by: Steven Price --- arch/arm64/Kconfig | 1 + fs/proc/page.c | 2 +- include/linux/page-flags.h | 2 +- include/trace/events/mmflags.h | 8 ++++---- mm/Kconfig | 8 ++++++++ mm/huge_memory.c | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 2d505fc0e85e..db6b80752e5d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1966,6 +1966,7 @@ config ARM64_MTE depends on ARM64_PAN select ARCH_HAS_SUBPAGE_FAULTS select ARCH_USES_HIGH_VMA_FLAGS + select ARCH_USES_PG_ARCH_X help Memory Tagging (part of the ARMv8.5 Extensions) provides architectural support for run-time, always-on detection of diff --git a/fs/proc/page.c b/fs/proc/page.c index f2273b164535..882525c8e94c 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -219,7 +219,7 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_PRIVATE_2, PG_private_2); u |= kpf_copy_bit(k, KPF_OWNER_PRIVATE, PG_owner_priv_1); u |= kpf_copy_bit(k, KPF_ARCH, PG_arch_1); -#ifdef CONFIG_64BIT +#ifdef CONFIG_ARCH_USES_PG_ARCH_X u |= kpf_copy_bit(k, KPF_ARCH_2, PG_arch_2); #endif diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 0b0ae5084e60..5dc7977edf9d 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -132,7 +132,7 @@ enum pageflags { PG_young, PG_idle, #endif -#ifdef CONFIG_64BIT +#ifdef CONFIG_ARCH_USES_PG_ARCH_X PG_arch_2, #endif #ifdef CONFIG_KASAN_HW_TAGS diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 11524cda4a95..4673e58a7626 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -90,10 +90,10 @@ #define IF_HAVE_PG_IDLE(flag,string) #endif -#ifdef CONFIG_64BIT -#define IF_HAVE_PG_ARCH_2(flag,string) ,{1UL << flag, string} +#ifdef CONFIG_ARCH_USES_PG_ARCH_X +#define IF_HAVE_PG_ARCH_X(flag,string) ,{1UL << flag, string} #else -#define IF_HAVE_PG_ARCH_2(flag,string) +#define IF_HAVE_PG_ARCH_X(flag,string) #endif #ifdef CONFIG_KASAN_HW_TAGS @@ -129,7 +129,7 @@ IF_HAVE_PG_UNCACHED(PG_uncached, "uncached" ) \ IF_HAVE_PG_HWPOISON(PG_hwpoison, "hwpoison" ) \ IF_HAVE_PG_IDLE(PG_young, "young" ) \ IF_HAVE_PG_IDLE(PG_idle, "idle" ) \ -IF_HAVE_PG_ARCH_2(PG_arch_2, "arch_2" ) \ +IF_HAVE_PG_ARCH_X(PG_arch_2, "arch_2" ) \ IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison") #define show_page_flags(flags) \ diff --git a/mm/Kconfig b/mm/Kconfig index b0b56c33f2ed..8e9e26ca472c 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1005,6 +1005,14 @@ config ARCH_USES_HIGH_VMA_FLAGS config ARCH_HAS_PKEYS bool +config ARCH_USES_PG_ARCH_X + bool + help + Enable the definition of PG_arch_x page flags with x > 1. Only + suitable for 64-bit architectures with CONFIG_FLATMEM or + CONFIG_SPARSEMEM_VMEMMAP enabled, otherwise there may not be + enough room for additional bits in page->flags. + config VM_EVENT_COUNTERS default y bool "Enable VM event counters for /proc/vmstat" if EXPERT diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1d47b3f7b877..5d87dc4611b9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2401,7 +2401,7 @@ static void __split_huge_page_tail(struct page *head, int tail, (1L << PG_workingset) | (1L << PG_locked) | (1L << PG_unevictable) | -#ifdef CONFIG_64BIT +#ifdef CONFIG_ARCH_USES_PG_ARCH_X (1L << PG_arch_2) | #endif (1L << PG_dirty) |