From: Will Deacon <will@kernel.org>
To: Barry Song <21cnbao@gmail.com>, ryan.roberts@arm.com
Cc: David Hildenbrand <david@redhat.com>,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-arm-kernel@lists.infradead.org,
Barry Song <v-songbaohua@oppo.com>,
Ard Biesheuvel <ardb@kernel.org>,
John Hubbard <jhubbard@nvidia.com>,
Mark Rutland <mark.rutland@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>
Subject: Re: [PATCH RFC] mm: arm64: advance pte for contpte_ptep_set_access_flags
Date: Wed, 4 Sep 2024 16:13:04 +0100 [thread overview]
Message-ID: <20240904151304.GB13919@willie-the-truck> (raw)
In-Reply-To: <CAGsJ_4wPCF7zrzW8Kh-8YKr=0MVsJEiOoSPXTLwDHw5sirnyDQ@mail.gmail.com>
(Adding Ryan, since you're asking him a question!)
On Sat, Aug 31, 2024 at 10:06:40PM +1200, Barry Song wrote:
> On Sat, Aug 31, 2024 at 9:54 PM David Hildenbrand <david@redhat.com> wrote:
> >
> > On 31.08.24 10:35, Barry Song wrote:
> > > From: Barry Song <v-songbaohua@oppo.com>
> > >
> > > Hi Ryan, David,
> > > it seems contpte_ptep_set_access_flags() has never advanced
> > > pte pfn, and it is setting all entries' pfn to the first
> > > subpage. But I feel quite strange we never have a bug reported.
> > > Am I missing something?
> > >
> > > Fixes: 4602e5757bcc ("arm64/mm: wire up PTE_CONT for user mappings")
> > > Cc: Ard Biesheuvel <ardb@kernel.org>
> > > Cc: John Hubbard <jhubbard@nvidia.com>
> > > Cc: Mark Rutland <mark.rutland@arm.com>
> > > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > > Cc: David Hildenbrand <david@redhat.com>
> > > Cc: Will Deacon <will@kernel.org>
> > > Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> > > ---
> > > arch/arm64/mm/contpte.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c
> > > index a3edced29ac1..10dcd2641184 100644
> > > --- a/arch/arm64/mm/contpte.c
> > > +++ b/arch/arm64/mm/contpte.c
> > > @@ -421,8 +421,10 @@ int contpte_ptep_set_access_flags(struct vm_area_struct *vma,
> > > ptep = contpte_align_down(ptep);
> > > start_addr = addr = ALIGN_DOWN(addr, CONT_PTE_SIZE);
> > >
> > > - for (i = 0; i < CONT_PTES; i++, ptep++, addr += PAGE_SIZE)
> > > + for (i = 0; i < CONT_PTES; i++, ptep++, addr += PAGE_SIZE) {
> > > __ptep_set_access_flags(vma, addr, ptep, entry, 0);
> > > + entry = pte_advance_pfn(entry, 1);
> > > + }
> > >
> > > if (dirty)
> > > __flush_tlb_range(vma, start_addr, addr,
> >
> > Taking a closer look at __ptep_set_access_flags(), there is:
> >
> > /* only preserve the access flags and write permission *
> > pte_val(entry) &= PTE_RDONLY | PTE_AF | PTE_WRITE | PTE_DIRTY;
> >
> > So it looks like it doesn't need the PFN?
>
> right.
>
> >
> >
> > OTOH, there is the initial:
> >
> >
> > if (pte_same(pte, entry))
> > return 0;
> >
> > check that might accelerate things.
> >
> > So unless I am missing something, this works as expected? (and if the
> > pte_same() would frequently be taken with your change would be worthwile
> > to optimize)
>
>
> Right. From page 1 to page (nr_pages - 1), we consistently get FALSE
> for pte_same().
> This seems quite strange. I think we might need to "fix" it, at least
> for the sake of code
> semantics. on the other hand, if pte_same() is not important, it
> should be dropped.
>
> Hi Ryan,
> what is your take on this?
>
> >
> > --
> > Cheers,
> >
> > David / dhildenb
> >
>
> Thanks
> Barry
next prev parent reply other threads:[~2024-09-04 15:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-31 8:35 Barry Song
2024-08-31 9:54 ` David Hildenbrand
2024-08-31 10:06 ` Barry Song
2024-09-04 15:13 ` Will Deacon [this message]
2024-09-04 15:50 ` Ryan Roberts
2024-09-05 3:27 ` Barry Song
2024-09-05 7:20 ` Ryan Roberts
2024-09-05 8:10 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240904151304.GB13919@willie-the-truck \
--to=will@kernel.org \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=ryan.roberts@arm.com \
--cc=v-songbaohua@oppo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox