From patchwork Wed Sep 21 03:51:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12983191 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 A9BDBC32771 for ; Wed, 21 Sep 2022 03:54:13 +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=JNDdc0KQcyjUAp6qr/1pVsrzs3UCuHasTON6vofUOAM=; b=n67NV/akv3MfAuwERiFV29vABw LIa6DYoo2oXyEutDvQlEOaz9nf6Jhq4dEoiXlE4brp1bfrognDjCcJgzDdJ1TUtJWa8CDloPk9o4J 60pbbSjPfl/SF0myHXFV4VUC5k1NHrJAiTl48PMeMiDypF3dOCOGN+AUwh1EQIkSro+u0UuI+QIC9 Se6cOMEliS8P+7WGHY7akofWreHLH9xn1wxPkyaQKEdtjvM13aU6x27+YX5mE1P15Ji2WdX3VmKcZ 7M/G8g1lvIYAM9+Qg7fs/E61fGCc22z9JsW4jAprXkMS6qSQULrCInQBUPGJoCkp4XyYSEWxpxwmY h0rpPbZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaqnQ-008fuu-1K; Wed, 21 Sep 2022 03:53:12 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaqnB-008fmE-GJ for linux-arm-kernel@lists.infradead.org; Wed, 21 Sep 2022 03:52:58 +0000 Received: by mail-yb1-xb49.google.com with SMTP id n85-20020a254058000000b006b0148d96f7so4055690yba.2 for ; Tue, 20 Sep 2022 20:52:56 -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; bh=42cERv183XkdijpZKmHZz40mbcPpqj2SrtFe6QYwGFo=; b=jVQ+bhDPfNgb0Zv4dGdFOtZE7zp+ky3p9ZGgipNye8ZQLu+7IBE2l+m4cx+/S0TDcz l+1yKZjjyNH9ZRtvPSrA64qY0h+2Wv7IKqjVeul9rbOx+ctbvACt40l1MB7ROnMK8V1Y VEblbUVxXjAUhXTFlVGZj3pj1pWElOm6nItK2amAMNiPiMLUd0VjFsYj2ZWy5V5KVrVG GVTA5YpreEksMgvyiavKHtMmgVLBG1/UZmT1XNY5XQfKHPvNDBsvGSlfdn7t1R/mKWwf EiCotOeQ6p6PlDaFGst3cqPTKkMSggxwhEoHTiQepXglqKoEBj/p3y0/nukuvzOitB89 x/+w== 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; bh=42cERv183XkdijpZKmHZz40mbcPpqj2SrtFe6QYwGFo=; b=bnjxnI0hO4wOgd6r1oNwl4cjxknTn9etArADO5Hq9xLmii7aJQlqIrhrN2HmR669mM j8mSnUza02cOYQXTEh9T5VkjIMTvw9TVZnhkGTcjq4R/CSBszULcJdESlMGow08sW1AC uIQrH4jU5duFMyX0avUtYSOnqGaIN9FZ8SK/OiZELNMI1RWMwxWtIEFGntDUj9GlR/vx 5srWcueC06EzaxyEz6zSHLzOqWvYoeqAWGvIR5+qd7zlRQW0ztJTMRRNjwHXKD/LnSAU g3EXOpT4Bkjb3GbLExb/a15h23OHqlApXvo6OFT/6G9O3TnBJ8SdfRioyTf+EFF0LMHH Eu5g== X-Gm-Message-State: ACrzQf3Aso1v3DL/FampGW+RJBQoJsn/1G6Ky//jmGA/VaD2pLi0QlMW azoZTToPiuSo8Vkp/gLAhJm2+PxJfI5d40Ti4aABMK2TrXPLkFl0A/d186TxlO+NYMBWFpmCes7 a3cKf6uxKuxMQjY+gKaRYRWo0GLYj5DSWVMxht2HqfQNDhCXtFe4jxCQeeiG5EMYwfafBeE/C X-Google-Smtp-Source: AMsMyM5jNbWhmU932B8rxoEtdjT72QIvotJbqv2VWYv5z9L9TSsYcgjchE7s/pbH6gd6ko4Ir8CmwwU= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:1b89:96f1:d30:e3c]) (user=pcc job=sendgmr) by 2002:a25:9290:0:b0:6b3:8040:b6e4 with SMTP id y16-20020a259290000000b006b38040b6e4mr16367847ybl.481.1663732375937; Tue, 20 Sep 2022 20:52:55 -0700 (PDT) Date: Tue, 20 Sep 2022 20:51:33 -0700 In-Reply-To: <20220921035140.57513-1-pcc@google.com> Message-Id: <20220921035140.57513-2-pcc@google.com> Mime-Version: 1.0 References: <20220921035140.57513-1-pcc@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Subject: [PATCH v4 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-20220920_205257_565716_0B6D8402 X-CRM114-Status: GOOD ( 17.59 ) 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 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 f6737d2f37b2..f2435b62e0ba 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1948,6 +1948,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 a2873a617ae8..6f4b4bcb9b0d 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -218,7 +218,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 ceec438c0741..a976cbb07bd6 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -999,6 +999,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 1cc4a5f4791e..24974a4ce28f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2444,7 +2444,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) |