Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp14166iog; Tue, 28 Jun 2022 13:49:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uXsXNVXc3qiqbf/uBQCTlMkYb3YmAGS+8McivP9zc3Ji0dLvyvD7zxct4Ytma03pUkuCEc X-Received: by 2002:a05:6402:1f02:b0:435:4a90:ec8e with SMTP id b2-20020a0564021f0200b004354a90ec8emr25597803edb.131.1656449340590; Tue, 28 Jun 2022 13:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656449340; cv=none; d=google.com; s=arc-20160816; b=VBmYDMhDnzdHM+/IlvN0bacMlDZK0UH8HYuEkZtlIiJldfXnjNDrj0rxDWcFATCCZs 4nSla4YDjNAD25cXeKHCylJZYhwI5mzHwbEDqnKtYcbOrEgdzy3CV25z3ExAzEFCpPYg Q4WjIPwVnaLVMwV+3pJD2Btblj9HNa/6x0BGGXsLXVc9uB3/30P06AGCDjrTJl9IJPOE PCOvTfZjKcP/jYxaq1bnwMo4JJrzzYQwQ5uOczUKi7rUrPH7io0g1m6bzDDdFVkZxcpO 5X7Pgh+kVWsuEiSYRrRyHkPUfCpexF8z+ryL4QOzd+M5R/mXWTLM68UnFSfaHVWO7qte rRzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=96xhbYiTU/KE791cPv1Ec34DiphPIV0a/3KLjf6U6CU=; b=boh0uVAVSRwBkPyCj+/m5KFaNtV/2uQRNNwkoL8SBzSFu0CPMPhOk3de2NEm+MWGT1 6RXm6q0fpZA7k5hLRPMOV4VIKwr4OlYhvDia1w6s6BBPG+kwkcMGpHthXMjiufZeLf7p /G/xXgfRHtSDS9BUVqoQbVQcESM52MEHMXzXVtshU7bRxs7YT8SJaEv3iRmqX9vARTfO rS0sTz3637vrDcavapmcykKmKkCmAdlpo4ArMU8IboyrGgUHB1O4D37Lh6jYj+tn64kO 7DAh+nh5LgnQYlkCzinKl0kKim++Fr9pdfVpzw74NO3EeAPQONQTYTEzzg6VqvS0ROs7 Ugew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pJdg7Xil; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a170906915500b00711f5c9d6bdsi14808408ejw.284.2022.06.28.13.48.32; Tue, 28 Jun 2022 13:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pJdg7Xil; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbiF1Udg (ORCPT + 99 others); Tue, 28 Jun 2022 16:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiF1Udd (ORCPT ); Tue, 28 Jun 2022 16:33:33 -0400 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6152619C2C for ; Tue, 28 Jun 2022 13:33:32 -0700 (PDT) Received: by mail-vs1-xe2a.google.com with SMTP id z66so13162944vsb.3 for ; Tue, 28 Jun 2022 13:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=96xhbYiTU/KE791cPv1Ec34DiphPIV0a/3KLjf6U6CU=; b=pJdg7XilXTxEPJguu4B1V6t1yFrgRPJzgTB0zzXha1C0GXvPImTaTne5Zzeo0FeO/X 8T98FE9DmEc7nU6//lotpccvFw+/0RR1fnbOxgJQoOr1Y3U6ouyJOrn1EDUAWehotCSx L1ReCZAm7nyaboEl+krLn/tXxHQ1nYzVpDyvDBkYS8gt59GGHCQahyjA76hMGmvVZGma CI9704uPQwIqsRGyqxBNg4Vsd1+c8AkXgPFMDN/vkiNrtHBmpoN6c/ILQXw8FtTDOS+g BQnwIkKVjlosjhxBA/69lY+KXRf3Ne96YenH4qA/kirD8hVWx3oXZB6bSnv6UROwPy5v 0+lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=96xhbYiTU/KE791cPv1Ec34DiphPIV0a/3KLjf6U6CU=; b=r8Isa2/60z7QWkz88vX+FxjCMuJLTJ/kX/nCFuIA4bvQ3JSVPOiW97Cdn2yGRwqLdh b59/SLfAubKS0TAf2SeRPN6NgSkCjvcTUYzTTd4syaTqQkg4ukVYxthwJdP/0Fy2QLwZ VDuAd/IJkUgM2UhD22Um9QgLocVXkliI7jN6fwAGTcmYXNdQVJbtsPe0a3q20TMwKXUY iBsSWZOO7E5iChGTfP7lC3AThJnRuTEp6ATXFTeCRHYrPNhy+BqeFeipT4WpHQ5YSIq4 3p3wETtCuPw4wd10ky9ObQO94VDpTODE3pwlibGGsI51eKXQLL8vAGqfcBmF8r7Xj4nS sLJA== X-Gm-Message-State: AJIora/FIG3OjLNt1MOrTLrw5ighbJkCIiBqhqIBA/HR4b/YwQe+/QC9 0bO7XrwlibT/RPWEdQ0jQGHV/DybcrhJN7Bth17fEA== X-Received: by 2002:a05:6102:f81:b0:354:3967:118a with SMTP id e1-20020a0561020f8100b003543967118amr2549996vsv.67.1656448411327; Tue, 28 Jun 2022 13:33:31 -0700 (PDT) MIME-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-10-jthoughton@google.com> In-Reply-To: <20220624173656.2033256-10-jthoughton@google.com> From: Mina Almasry Date: Tue, 28 Jun 2022 13:33:19 -0700 Message-ID: Subject: Re: [RFC PATCH 09/26] hugetlb: add hugetlb_hgm_enabled To: James Houghton Cc: Mike Kravetz , Muchun Song , Peter Xu , David Hildenbrand , David Rientjes , Axel Rasmussen , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 24, 2022 at 10:37 AM James Houghton wrote: > > Currently, this is always true if the VMA is shared. In the future, it's > possible that private mappings will get some or all HGM functionality. > > Signed-off-by: James Houghton Reviewed-by: Mina Almasry > --- > include/linux/hugetlb.h | 10 ++++++++++ > mm/hugetlb.c | 8 ++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index 33ba48fac551..e7a6b944d0cc 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -1174,6 +1174,16 @@ static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, > } > #endif /* CONFIG_HUGETLB_PAGE */ > > +#ifdef CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING > +/* If HugeTLB high-granularity mappings are enabled for this VMA. */ > +bool hugetlb_hgm_enabled(struct vm_area_struct *vma); > +#else > +static inline bool hugetlb_hgm_enabled(struct vm_area_struct *vma) > +{ > + return false; > +} > +#endif > + > static inline spinlock_t *huge_pte_lock(struct hstate *h, > struct mm_struct *mm, pte_t *pte) > { > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index a2d2ffa76173..8b10b941458d 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6983,6 +6983,14 @@ pte_t *huge_pte_offset(struct mm_struct *mm, > > #endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ > > +#ifdef CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING > +bool hugetlb_hgm_enabled(struct vm_area_struct *vma) > +{ > + /* All shared VMAs have HGM enabled. */ Personally I find the comment redundant; the next line does just that. What about VM_MAYSHARE? Should those also have HGM enabled? Is it possible to get some docs with this series for V1? This would be something to highlight in the docs. > + return vma->vm_flags & VM_SHARED; > +} > +#endif /* CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING */ > + > /* > * These functions are overwritable if your architecture needs its own > * behavior. > -- > 2.37.0.rc0.161.g10f37bed90-goog >