linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Gavin Shan <gshan@redhat.com>
Cc: maz@kernel.org, oliver.upton@linux.dev, kvmarm@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, kernel-team@android.com,
	will@kernel.org, willy@infradead.org
Subject: Re: [PATCH v2 1/2] KVM: arm64: Do not transfer page refcount for THP adjustment
Date: Fri, 29 Sep 2023 13:47:23 +0100	[thread overview]
Message-ID: <ZRbHW-kFNSxN9mmJ@google.com> (raw)
In-Reply-To: <3a05f8a1-5759-8744-49eb-e975c5cf129c@redhat.com>

On Fri, Sep 29, 2023 at 04:59:20PM +1000, Gavin Shan wrote:
> On 9/29/23 03:32, Vincent Donnefort wrote:
> > GUP affects a refcount common to all pages forming the THP. There is
> > therefore no need to move the refcount from a tail to the head page.
> > Under the hood it decrements and increments the same counter.
> > 
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> > 
> 
> Reviewed-by: Gavin Shan <gshan@redhat.com>
> 
> > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> > index 587a104f66c3..de5e5148ef5d 100644
> > --- a/arch/arm64/kvm/mmu.c
> > +++ b/arch/arm64/kvm/mmu.c
> > @@ -1295,28 +1295,8 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
> >   		if (sz < PMD_SIZE)
> >   			return PAGE_SIZE;
> > -		/*
> > -		 * The address we faulted on is backed by a transparent huge
> > -		 * page.  However, because we map the compound huge page and
> > -		 * not the individual tail page, we need to transfer the
> > -		 * refcount to the head page.  We have to be careful that the
> > -		 * THP doesn't start to split while we are adjusting the
> > -		 * refcounts.
> > -		 *
> > -		 * We are sure this doesn't happen, because mmu_invalidate_retry
> > -		 * was successful and we are holding the mmu_lock, so if this
> > -		 * THP is trying to split, it will be blocked in the mmu
> > -		 * notifier before touching any of the pages, specifically
> > -		 * before being able to call __split_huge_page_refcount().
> > -		 *
> > -		 * We can therefore safely transfer the refcount from PG_tail
> > -		 * to PG_head and switch the pfn from a tail page to the head
> > -		 * page accordingly.
> > -		 */
> >   		*ipap &= PMD_MASK;
> > -		kvm_release_pfn_clean(pfn);
> >   		pfn &= ~(PTRS_PER_PMD - 1);
> > -		get_page(pfn_to_page(pfn));
> >   		*pfnp = pfn;
> >   		return PMD_SIZE;
> 
> The local variable @pfn can be dropped either.

I would like to keep it for the following patch: pfn_to_folio(pfn);

> 
>                 *pfnp &= ~(PTRS_PER_PMD - 1);
> 
> Thanks,
> Gavin
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-09-29 12:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 17:32 [PATCH v2 0/2] KVM: arm64: Use folio for THP support Vincent Donnefort
2023-09-28 17:32 ` [PATCH v2 1/2] KVM: arm64: Do not transfer page refcount for THP adjustment Vincent Donnefort
2023-09-29  6:59   ` Gavin Shan
2023-09-29 12:47     ` Vincent Donnefort [this message]
2023-09-28 17:32 ` [PATCH v2 2/2] KVM: arm64: Use folio " Vincent Donnefort
2023-09-29  7:24   ` Gavin Shan
2023-09-29 13:07     ` Matthew Wilcox
2023-09-29 23:52       ` Gavin Shan
2023-09-29 23:53   ` Gavin Shan
2023-10-28  9:17   ` Ryan Roberts
2023-10-30 10:40     ` Marc Zyngier
2023-10-30 10:57       ` Ryan Roberts
2023-10-30 10:47     ` Vincent Donnefort
2023-10-30 11:01       ` Ryan Roberts
2023-09-29  9:12 ` [PATCH v2 0/2] KVM: arm64: Use folio for THP support Marc Zyngier
2023-09-30 17:57 ` Oliver Upton
2023-10-30 20:16   ` Oliver Upton

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=ZRbHW-kFNSxN9mmJ@google.com \
    --to=vdonnefort@google.com \
    --cc=gshan@redhat.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).