From mboxrd@z Thu Jan 1 00:00:00 1970 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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 DEAF7C2B9F4 for ; Thu, 17 Jun 2021 07:08:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F128611CE for ; Thu, 17 Jun 2021 07:08:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F128611CE 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 EEF906B0070; Thu, 17 Jun 2021 03:08:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC6766B0072; Thu, 17 Jun 2021 03:08:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8E206B0073; Thu, 17 Jun 2021 03:08:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id AB1CB6B0070 for ; Thu, 17 Jun 2021 03:08:54 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 494F410F45 for ; Thu, 17 Jun 2021 07:08:54 +0000 (UTC) X-FDA: 78262338588.40.2677C0B Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf10.hostedemail.com (Postfix) with ESMTP id EBBA24202A07 for ; Thu, 17 Jun 2021 07:08:43 +0000 (UTC) Received: by mail-ot1-f54.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso5145317otu.10 for ; Thu, 17 Jun 2021 00:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MsqYILgAKurijhL/t9Pxm6TteQj8nlU+VZKZOuCyAgE=; b=PzliMFtiv8K08Pxfo0PmDseeXd+8Rv6kuf1m0/BRKy1IbtPJ0C7ZtmipsFCYFJm7v+ 8BpAmnYv6hYFBhc6MJnJWQkv8VkdplslO22TaJmGL4hlifgJfhYqaoPXxeLj59t+GYa8 DwQqabZdrdcpOIwg5a9dbdwhgAYIyjKHpxvD6SXaQJF0NU75Y2M7Oa13V4kib8E10aGq 0u+WIvfiyPKwo/74aXBxOQlyEZAkThSGXtOU1keZaHfx+XKYgT9sI5K/bxb/RW8DOdwr hZG7J0+b42ffm6Jhyz6jwOhDwQ3MUGQhpYX2U6Ujam6eCivPYscRqjK9RaCeirZ3uIfW ZhIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MsqYILgAKurijhL/t9Pxm6TteQj8nlU+VZKZOuCyAgE=; b=EPwIKfhcXZ8Sq1xzJAemfVC+bwlNJqLb0fiGy2DBRBk31O5Shv7yYGofS7L33V5t0j gUGV9/CeZNizKhiOLaK43I2MGT3cZKwMTgJVYvgV+8TzHlYHUlGHufM2UKFaOrg73iGS Q7dDozIlntBGCRdAHcPWg5VMHTJDY2dvGeG2PrASSOnuDrJOgGuIoZmOEvKFaKtNAepg wdXf9IfsgSQf7SOd7AlXfzbT7ln0J3fHyCPjKhf933tuOAE/BjYG7GW3bP2IgT2jFvPx PwlCqoywMyGx84SBYoDruQvtP1hiuruJk63LpYpJ+sxhnTOKuuBp37MkASxmHxuF3n+e qKhQ== X-Gm-Message-State: AOAM5319qpictWXrkMy2wDHSTznM1ojhykKy8znX+7JDI215IauVtwpH Qid4zm0ppwpCOUASvo4Wvjd5IbGpEbvR7S1msu+7ZDYvQkwOBg== X-Google-Smtp-Source: ABdhPJzqEqAk206nhpNPL67OT0Xxgz7/1QCd+nNRElt8NPsvhQsdviKEPqluZO+azBZyRHYyFAXHZ4YUUD6AwJ6AEp0= X-Received: by 2002:a05:6830:93:: with SMTP id a19mr3236836oto.17.1623913733228; Thu, 17 Jun 2021 00:08:53 -0700 (PDT) MIME-Version: 1.0 References: <20210617063956.94061-1-dja@axtens.net> <20210617063956.94061-4-dja@axtens.net> In-Reply-To: <20210617063956.94061-4-dja@axtens.net> From: Marco Elver Date: Thu, 17 Jun 2021 09:08:41 +0200 Message-ID: Subject: Re: [PATCH v14 3/4] mm: define default MAX_PTRS_PER_* in include/pgtable.h To: Daniel Axtens Cc: LKML , Linux Memory Management List , kasan-dev , Andrew Morton , Andrey Konovalov , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , aneesh.kumar@linux.ibm.com, Balbir Singh Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=PzliMFti; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of elver@google.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=elver@google.com X-Rspamd-Server: rspam02 X-Stat-Signature: 4m934djgjkjrzjs11db4g6uf59ye3qc9 X-Rspamd-Queue-Id: EBBA24202A07 X-HE-Tag: 1623913723-50061 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: On Thu, 17 Jun 2021 at 08:40, Daniel Axtens wrote: > > Commit c65e774fb3f6 ("x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable") > made PTRS_PER_P4D variable on x86 and introduced MAX_PTRS_PER_P4D as a > constant for cases which need a compile-time constant (e.g. fixed-size > arrays). > > powerpc likewise has boot-time selectable MMU features which can cause > other mm "constants" to vary. For KASAN, we have some static > PTE/PMD/PUD/P4D arrays so we need compile-time maximums for all these > constants. Extend the MAX_PTRS_PER_ idiom, and place default definitions > in include/pgtable.h. These define MAX_PTRS_PER_x to be PTRS_PER_x unless > an architecture has defined MAX_PTRS_PER_x in its arch headers. > > Clean up pgtable-nop4d.h and s390's MAX_PTRS_PER_P4D definitions while > we're at it: both can just pick up the default now. > > Signed-off-by: Daniel Axtens Reviewed-by: Marco Elver > --- > > s390 was compile tested only. > --- > arch/s390/include/asm/pgtable.h | 2 -- > include/asm-generic/pgtable-nop4d.h | 1 - > include/linux/pgtable.h | 22 ++++++++++++++++++++++ > 3 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h > index 7c66ae5d7e32..cf05954ce013 100644 > --- a/arch/s390/include/asm/pgtable.h > +++ b/arch/s390/include/asm/pgtable.h > @@ -342,8 +342,6 @@ static inline int is_module_addr(void *addr) > #define PTRS_PER_P4D _CRST_ENTRIES > #define PTRS_PER_PGD _CRST_ENTRIES > > -#define MAX_PTRS_PER_P4D PTRS_PER_P4D > - > /* > * Segment table and region3 table entry encoding > * (R = read-only, I = invalid, y = young bit): > diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h > index ce2cbb3c380f..2f6b1befb129 100644 > --- a/include/asm-generic/pgtable-nop4d.h > +++ b/include/asm-generic/pgtable-nop4d.h > @@ -9,7 +9,6 @@ > typedef struct { pgd_t pgd; } p4d_t; > > #define P4D_SHIFT PGDIR_SHIFT > -#define MAX_PTRS_PER_P4D 1 > #define PTRS_PER_P4D 1 > #define P4D_SIZE (1UL << P4D_SHIFT) > #define P4D_MASK (~(P4D_SIZE-1)) > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 9e6f71265f72..69700e3e615f 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -1625,4 +1625,26 @@ typedef unsigned int pgtbl_mod_mask; > #define pte_leaf_size(x) PAGE_SIZE > #endif > > +/* > + * Some architectures have MMUs that are configurable or selectable at boot > + * time. These lead to variable PTRS_PER_x. For statically allocated arrays it > + * helps to have a static maximum value. > + */ > + > +#ifndef MAX_PTRS_PER_PTE > +#define MAX_PTRS_PER_PTE PTRS_PER_PTE > +#endif > + > +#ifndef MAX_PTRS_PER_PMD > +#define MAX_PTRS_PER_PMD PTRS_PER_PMD > +#endif > + > +#ifndef MAX_PTRS_PER_PUD > +#define MAX_PTRS_PER_PUD PTRS_PER_PUD > +#endif > + > +#ifndef MAX_PTRS_PER_P4D > +#define MAX_PTRS_PER_P4D PTRS_PER_P4D > +#endif > + > #endif /* _LINUX_PGTABLE_H */ > -- > 2.30.2 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20210617063956.94061-4-dja%40axtens.net.