Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp649393iog; Fri, 24 Jun 2022 10:57:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sM8IwHJA3zFuBoVbcX8aunbP1bblsRSogNKE1zHfvzNf4WE6qgU3a7CbhjdWJFjPist/Y5 X-Received: by 2002:a05:6402:218:b0:435:dc75:22e with SMTP id t24-20020a056402021800b00435dc75022emr356702edv.3.1656093467293; Fri, 24 Jun 2022 10:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656093467; cv=none; d=google.com; s=arc-20160816; b=wlMSHlSIbFYcVwI1/spZ0EQPqkMUCVBIrHxWL1ifdxBzoBTlNiug52xjn/ugRrZWpR SkZ7nDaiyXmMZHR6A03V6eomBvmeVW/OI179xKvaAr6ieFYTIYlIqce933GS5P53LtPi ro2NCdIZiEtlQtEBubWeb/RC+hoQ/DSCKxYESH0Q14tRjeXd1eiKUu74qjXZ5f6NUXgy KfBNps/KdlCPQ+p5mkBqVBj8mfzhT7ScESlvq6iQj2R0nLUGiB6KFyjmHdULbSHVRcvY 8y7PTReM/50l2XrMY3yvm09fBFeUJdByucKHVWOqQByFZiLbBXmDvGQJMBJC8jaVtPzj jC9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=WX+TLc+c32jY73zAmELqfC7scmTotnHMJPgbPcH9Hag=; b=gS6JjiXL5baTX8SYajh8vWxHO/aAF/CXhquaVdBwQ8UnivkvROCetXhOU/ZzzwX0ay AVmdMB14+1pMK1OJDE4rymeOHh3twgVIONcSFHkuonVaJfxAlVYuO7OE2WQceSacv2St xkgO0MXT18EsqbSJ+SlgsC72uCmNoMYL+s2eW6Y+OdVLnkXDcdDjpr/BEJWs+KIKdTbv GB8tyOJmJ6GiGOfNPxNI/emA8n3ldv/b7HMKHyRZOFACJ7YVgNFCCXiCoHHMqy8M92ir Ub3aAbm6Xv0GYo6Jt4SeB4cdImLWYdD3QSbfM+00FV3AlKdHQY0ALgHBE8OtCGM4BtkL jl8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rmtQIA0R; 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 sb42-20020a1709076daa00b007263fe6c42fsi198277ejc.675.2022.06.24.10.57.21; Fri, 24 Jun 2022 10:57:47 -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=rmtQIA0R; 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 S231940AbiFXRhj (ORCPT + 99 others); Fri, 24 Jun 2022 13:37:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231576AbiFXRhW (ORCPT ); Fri, 24 Jun 2022 13:37:22 -0400 Received: from mail-ua1-x94a.google.com (mail-ua1-x94a.google.com [IPv6:2607:f8b0:4864:20::94a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 444E1609EF for ; Fri, 24 Jun 2022 10:37:22 -0700 (PDT) Received: by mail-ua1-x94a.google.com with SMTP id v14-20020ab0768e000000b0037efa637aeeso1006779uaq.23 for ; Fri, 24 Jun 2022 10:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WX+TLc+c32jY73zAmELqfC7scmTotnHMJPgbPcH9Hag=; b=rmtQIA0RTPQYWEYJ8kZRSAxO4ZWdbskuHARii0tUqF87tsg4HJnPzpTHsKmHhi7YHN szZo8r74Pfgxru6pGunO7KfxJtr6Wzabwa1wcCmLVAdMbm+j8fKHC5fV7wwrJG+ncVrB fWoXECRaKY9gz8ZiGg0zDe612OVnVf2pAh18JbfgZ2OytbBwiZCNN/oOGXrLiF3q3rzH fxFhSCJMn3o5octv4QkArXh3RvJqGO05jZSaGjrL9vscpWTsOFD0x47zLoXDuqUkCgEo PIWSrdAA+02ET/Ct0BrCGPnvyDWs7lIPDo0hPsnRg76cZrOaj70ey7iZ/86fIxktGj4r ckXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WX+TLc+c32jY73zAmELqfC7scmTotnHMJPgbPcH9Hag=; b=fg2uxSb0eIeOx+SwHEUnTeeQ0/mQ7qejyhIJQZ4lkZ1n4jf9eQkvW5M2RrasivKKI6 NYJxFBoJDDEGsZFH9oViVnlhFUAvObZzF9S2LL6HFFGe7HJuEieQfDJ8E1cs0KfEPanG zUJTalnxI10kLm3IthIy2KYcXVo3+KfKvqEBBYvebOY97W1vTvDI1mLFc4QqEhapoWlw 5DH8a/gMDi9elceWE8dWkAhmCM+qDzMyBVuCk49MRbfkMkU1U1uX8DfX9my2lcfadQZ/ h6f6drcPCHRoQH4dglZZOMNoRJBpbsPJwPmeXfInD0Js+wQ/zyL8iI5t5j+NmYCEbtZd 5DUw== X-Gm-Message-State: AJIora8VMsmlJ6zZyoRqImoEEJbryC3gfh4oDt4b/E52fcTjp70ImxeV QyT7G7Y940Z43AR6JJI+lHIzJNscK5LGWSzH X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a67:6e47:0:b0:354:52a0:8ac2 with SMTP id j68-20020a676e47000000b0035452a08ac2mr173638vsc.65.1656092242031; Fri, 24 Jun 2022 10:37:22 -0700 (PDT) Date: Fri, 24 Jun 2022 17:36:39 +0000 In-Reply-To: <20220624173656.2033256-1-jthoughton@google.com> Message-Id: <20220624173656.2033256-10-jthoughton@google.com> Mime-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [RFC PATCH 09/26] hugetlb: add hugetlb_hgm_enabled From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 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 --- 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. */ + 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