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 F0D20C43334 for ; Fri, 24 Jun 2022 19:01:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9059C8E026B; Fri, 24 Jun 2022 15:01:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B7028E0244; Fri, 24 Jun 2022 15:01:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77D768E026B; Fri, 24 Jun 2022 15:01:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 684FB8E0244 for ; Fri, 24 Jun 2022 15:01:23 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3322D20CAF for ; Fri, 24 Jun 2022 19:01:23 +0000 (UTC) X-FDA: 79614047646.02.1261C61 Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) by imf03.hostedemail.com (Postfix) with ESMTP id 335EE200BB for ; Fri, 24 Jun 2022 19:01:21 +0000 (UTC) Received: by mail-vs1-f50.google.com with SMTP id t127so3140568vsb.8 for ; Fri, 24 Jun 2022 12:01:20 -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=ZIrc9o3Ym8mlgL0ZplaC2RFgVj5LySwYy0WilhgT4MM=; b=F5jEel+WZ/H/X0hplayi8ELMjTc+MXk1RcXV0sVvB5tLsPXC7BSWQoqp62PsXz58J0 D95G8oOOfNVDnb62ka8Ji3GuiXOpjy9seJiA+8UESEwLQuz+s3RJ5+AgBWJU4KOiBy9W KBL5pb8qcwHIhwNXsamyqjU5En70koEkiMaoyWRBd1tMc7ma/jJktKoLWe4q/bt2lEJ+ wVpkQATTfIgsECfn1EoNN4niUc+Sgcw+M7Kr6bvD7lKabGlYl+jCSuYBJYdvfCajUKF7 aiyFmPguWbBZ9K1mf1ciYWoaD2SiiSANMyT2/6QttCCOmghe73hxOgVtMC1nBjBjcLqL c6TA== 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=ZIrc9o3Ym8mlgL0ZplaC2RFgVj5LySwYy0WilhgT4MM=; b=7H/4OkTXg16h34DOoMVPHVR/LPZChHPPl++2TCGDDUIr2sifCJQy0VW8EWzsozM1AY QST36Xs119fvNmprG0wm8iV/XHob7vvjKuxatEjVuSXMdbD6/C6jr1ZMLSmuSkR+8vmp o1gnLVU38MRXzW76IstqM26FsJ3NarhOKjnLPKUQ5UrowiZOs+rAQ7yVs3BIervszJ8V HlAtzMNXLr+hv4gQE4PYt1DrJ4dhcqfqs91zjPKWT/vxoAB0kO2t699hhnsm5vYrtf8G ML3xQw/2B/1V4NSF9zhzPMMNWatx4EzHOTLyQYKezcmL7RZVzV2OI156iq6RfjEHdYAt szEA== X-Gm-Message-State: AJIora9rZWP66UdkoM/8PSltCAkUAR+2p0ze8AIB488ojzDoPhtSX0R/ byTRCqimRWu7pMl0qmsO1PaUyImKXLCebUUQKxh71Q== X-Google-Smtp-Source: AGRyM1vHljBh2oZBpNEDzgqpR40r2mOS+tZza5CCpAx5hr4z3f8PC2854wSd/r2sAFQBMkqppy8MfmI2w2O75WMngOk= X-Received: by 2002:a05:6102:f81:b0:354:3967:118a with SMTP id e1-20020a0561020f8100b003543967118amr243458vsv.67.1656097280288; Fri, 24 Jun 2022 12:01:20 -0700 (PDT) MIME-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-4-jthoughton@google.com> In-Reply-To: <20220624173656.2033256-4-jthoughton@google.com> From: Mina Almasry Date: Fri, 24 Jun 2022 12:01:08 -0700 Message-ID: Subject: Re: [RFC PATCH 03/26] hugetlb: add make_huge_pte_with_shift 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=1656097282; a=rsa-sha256; cv=none; b=lF9wZLx7d/iaLWNGp1dUpenuI6ryLfGFjezBfShHEyMt09DdoHXf4sSFRRE2b1dltnayrv irJgYENsoRU1GfQGRg+7iAjYni3eAe6fYeMC8UUIGCfQOPx0Qj/SjPBzskVq+3pUZ+I6YJ Uf4/3pWS90ZR0cu/kyrfhDtpjtkArek= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=F5jEel+W; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of almasrymina@google.com designates 209.85.217.50 as permitted sender) smtp.mailfrom=almasrymina@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656097282; 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=ZIrc9o3Ym8mlgL0ZplaC2RFgVj5LySwYy0WilhgT4MM=; b=CkY/9C1+t/sz6C17IhEdeacW5/PXgamInvBYSSlf9jrhCKFOwkd2ynnb3S/4knSrSok9KJ f7npeFL6hngkc4fz3UzY3HMWDXvg5KE/pZRZVMDnk+Ij3rXNlam1Wwc+wUNfoLciWyB5z3 B5dwuQc7QkiQpNOvJoDdF6rSRRehm5U= X-Stat-Signature: 99a3tkc9xd3kzgu9juewatngsxgfpa4r X-Rspamd-Queue-Id: 335EE200BB Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=F5jEel+W; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of almasrymina@google.com designates 209.85.217.50 as permitted sender) smtp.mailfrom=almasrymina@google.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656097281-557301 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: > > This allows us to make huge PTEs at shifts other than the hstate shift, > which will be necessary for high-granularity mappings. > Can you elaborate on why? > Signed-off-by: James Houghton > --- > mm/hugetlb.c | 33 ++++++++++++++++++++------------- > 1 file changed, 20 insertions(+), 13 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 5df838d86f32..0eec34edf3b2 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -4686,23 +4686,30 @@ const struct vm_operations_struct hugetlb_vm_ops = { > .pagesize = hugetlb_vm_op_pagesize, > }; > > +static pte_t make_huge_pte_with_shift(struct vm_area_struct *vma, > + struct page *page, int writable, > + int shift) > +{ > + bool huge = shift > PAGE_SHIFT; > + pte_t entry = huge ? mk_huge_pte(page, vma->vm_page_prot) > + : mk_pte(page, vma->vm_page_prot); > + > + if (writable) > + entry = huge ? huge_pte_mkwrite(entry) : pte_mkwrite(entry); > + else > + entry = huge ? huge_pte_wrprotect(entry) : pte_wrprotect(entry); > + pte_mkyoung(entry); > + if (huge) > + entry = arch_make_huge_pte(entry, shift, vma->vm_flags); > + return entry; > +} > + > static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, > - int writable) > + int writable) Looks like an unnecessary diff? > { > - pte_t entry; > unsigned int shift = huge_page_shift(hstate_vma(vma)); > > - if (writable) { > - entry = huge_pte_mkwrite(huge_pte_mkdirty(mk_huge_pte(page, > - vma->vm_page_prot))); In this case there is an intermediate call to huge_pte_mkdirty() that is not done in make_huge_pte_with_shift(). Why was this removed? > - } else { > - entry = huge_pte_wrprotect(mk_huge_pte(page, > - vma->vm_page_prot)); > - } > - entry = pte_mkyoung(entry); > - entry = arch_make_huge_pte(entry, shift, vma->vm_flags); > - > - return entry; > + return make_huge_pte_with_shift(vma, page, writable, shift); I think this is marginally cleaner to calculate the shift inline: return make_huge_pte_with_shift(vma, page, writable, huge_page_shift(hstate_vma(vma))); > } > > static void set_huge_ptep_writable(struct vm_area_struct *vma, > -- > 2.37.0.rc0.161.g10f37bed90-goog >