From patchwork Fri Jun 24 17:36:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 12894934 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60650C433EF for ; Fri, 24 Jun 2022 17:37:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D2338E0247; Fri, 24 Jun 2022 13:37:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B94E8E0244; Fri, 24 Jun 2022 13:37:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E14D8E0247; Fri, 24 Jun 2022 13:37:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1ED408E0244 for ; Fri, 24 Jun 2022 13:37:23 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 00ABB806C5 for ; Fri, 24 Jun 2022 17:37:22 +0000 (UTC) X-FDA: 79613835966.19.5C66043 Received: from mail-ua1-f73.google.com (mail-ua1-f73.google.com [209.85.222.73]) by imf30.hostedemail.com (Postfix) with ESMTP id 78EB88002C for ; Fri, 24 Jun 2022 17:37:22 +0000 (UTC) Received: by mail-ua1-f73.google.com with SMTP id b10-20020ab0238a000000b0037efa0a4ba0so1013217uan.11 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=VCb4b9ldy2YIOsnRtAQ2OHJTXWbeTksJWDsc8cXZx3RT9SXXJetDPR1pKRCOKPrTNP TbWs3v7Q5kI7waDjZ9Q+bgkrqRGGMlgUdFPVmmDgu/k7CEv2lRo5wR74MtyrPypeW3qi 9Jbkquzi786wM+lkmGH5J+fwkH7YQI1A8jhMBlzuC6KomnjGFkttgtexSj+bPZXZll4g 28sDhYImI/9cqMF1Z3KnU+Po1hSOTpnLPp09EG6TrSf2lJ6r4irh/6l43GH8PmyO9Vdr PHSpaPpgGaTC479b10IKc+Jg2vor/6IQsxOdW+MX46fMCj/kI14W6QomWzJ4PVKqrfJA Syqw== X-Gm-Message-State: AJIora+0uMSLlfE3UWBWIaL3TlojWa3REU+1gGUNlibDvdZMbMUCYndF Any4pICmqWnLqzMMK8X2azuNkrNMYQiRebsL X-Google-Smtp-Source: AGRyM1vX/wsU1Y9GWc4aZF68+l300w5Pdum+7CFc6GFKGc4oec+e4PYz/yVOvKtQiR6acb6V/yx2DV4xq/fD/H/b 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656092242; a=rsa-sha256; cv=none; b=Bf23W/yqRwnYbJceaBMMOILi8Uu0Knfn99I+aJpfWS4uB430dCmd4oWVif6dtOfDK8Ybe5 +UvKz8/tnsMgM1ojZLkhNRqkkAAY8TEoo8M4Kyp2P2WEuZWuJLwXY1STr5lD+d+7iYsXr4 h1ZOvoWw17gTxz0cr+aOnsbL0ocJOVY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=rmtQIA0R; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3Uva1YgoKCDMYiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com designates 209.85.222.73 as permitted sender) smtp.mailfrom=3Uva1YgoKCDMYiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656092242; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WX+TLc+c32jY73zAmELqfC7scmTotnHMJPgbPcH9Hag=; b=U/RwMQz1V1aO0JcnzTrMJ88UO/o1yS2IxukSRbMyvo1MFPV+MjDhfuZVTZ/xqyovojtOmt yppqSs4Qw4sUhRXgauJO6amuBcSB5EkIjhAMyl6HH/iwjkEnCXTn8bX5iQL0jobUejGt7T Fs23/ZaEXZih0d51m0+Zx5RUUw6DU5c= X-Stat-Signature: 5fbmkcp189w3k3hfzp3bifhfcsekg77n X-Rspamd-Queue-Id: 78EB88002C Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=rmtQIA0R; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3Uva1YgoKCDMYiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com designates 209.85.222.73 as permitted sender) smtp.mailfrom=3Uva1YgoKCDMYiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656092242-264808 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: 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: manish.mishra@nutanix.com 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. */ + return vma->vm_flags & VM_SHARED; +} +#endif /* CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING */ + /* * These functions are overwritable if your architecture needs its own * behavior.