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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C87DC43334 for ; Tue, 28 Jun 2022 20:33:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BF108E0002; Tue, 28 Jun 2022 16:33:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16F928E0001; Tue, 28 Jun 2022 16:33:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 036608E0002; Tue, 28 Jun 2022 16:33:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E4B648E0001 for ; Tue, 28 Jun 2022 16:33:32 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B255136B96 for ; Tue, 28 Jun 2022 20:33:32 +0000 (UTC) X-FDA: 79628795064.09.FAA3366 Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) by imf01.hostedemail.com (Postfix) with ESMTP id 4245A4002C for ; Tue, 28 Jun 2022 20:33:32 +0000 (UTC) Received: by mail-vs1-f54.google.com with SMTP id t127so13153091vsb.8 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=VNi/1rf59nwrEOvYivXyo+qKJu86gRFmNbxfoPgHT3ayvIBG+Shi67JOSdsS9hJLRr YZoXbwK/quQdH8rABm5zScWAn5tCZ89cj/o1j9bZ6nfMOLiF4o2X8AN68OG95IDOCk9b aPQMbnB/ixvQtMbXv6hQNHEuikAtd86wbR82j/qYmgpnPnS3kh2Ds8YO16Mt5K8YX4Fx o14oePsWE5NxOfG2rpTfJp/6XMAWrjtr3LkNtRvlCIt4oWDglKzXOCKvXxFccMAQocev RifvMYfbuatbf8eJ7SbQx2OtpZLbg9ASi6c6ZUvtznPNiY7CjBJcZXIMH8cYpDQeEDFj 72Wg== X-Gm-Message-State: AJIora+hmRCMMi8f+a4PsRm02cxJ6IGBr9wYdFxqHPgog8z5zaXq+Lly Ywxr7tNNtjwCWLwnE4BvLF5YjJatHBKuwYQ7HRfNuw== X-Google-Smtp-Source: AGRyM1uVlFBAQwA+pYsT/CH8aC8G895Y3mPd0TsSfST3Ox2ZooTS7yCmHDP6hooIdjCk7r0C7q0e1IpezEcsMQUiEgA= 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656448412; a=rsa-sha256; cv=none; b=iSfDf4/AcpsA0ra51Tpc5Cxx8a8Z2M0l6t/Rl+ZzAObfweQbV37uWi3f5rzj6c8RUPZo8g Ay5pSUIWdWpjozUaQtRYgF8dsE/tint8dS3Kw91F3pqWbIwByjj9sfAr35eLZYsIDrYxg1 WrCv1lhSs+4oLJbAoyti90AcMNISSL0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pJdg7Xil; spf=pass (imf01.hostedemail.com: domain of almasrymina@google.com designates 209.85.217.54 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656448412; 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=96xhbYiTU/KE791cPv1Ec34DiphPIV0a/3KLjf6U6CU=; b=mCQhqiSpLTiIDG7eincTYrsSuPXJzzz/DqvNo53IyyMs4b0It/h702Nt52SbDDswdUZ2V/ EmfV0OtaU9f/b3GaPTemPJCygBAWnP2818TO+udA+JLkB9/OCl8XDkNV6GuZHpXjGWmQlO 7C1zT44nxpurGiNw/8tygp5gjEHINIw= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4245A4002C X-Rspam-User: X-Stat-Signature: 8rptu9czf57ici5u64dtnypbfkprw3kx Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pJdg7Xil; spf=pass (imf01.hostedemail.com: domain of almasrymina@google.com designates 209.85.217.54 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1656448412-254725 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 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 >