Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Ryan Roberts <ryan.roberts@arm.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 2/2] KVM: arm64: Use folio for THP adjustment
Date: Mon, 30 Oct 2023 10:47:31 +0000	[thread overview]
Message-ID: <ZT-Jw4SVJ6C1E6sc@google.com> (raw)
In-Reply-To: <418313c5-2094-4aaf-ae43-a1f3bf8e936f@arm.com>

[...]

> >  static struct kvm_pgtable_mm_ops kvm_s2_mm_ops = {
> >  	.zalloc_page		= stage2_memcache_zalloc_page,
> >  	.zalloc_pages_exact	= kvm_s2_zalloc_pages_exact,
> > @@ -1274,7 +1229,7 @@ static bool fault_supports_stage2_huge_mapping(struct kvm_memory_slot *memslot,
> >   *
> >   * Returns the size of the mapping.
> >   */
> > -static long
> > +static unsigned long
> >  transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
> >  			    unsigned long hva, kvm_pfn_t *pfnp,
> >  			    phys_addr_t *ipap)
> > @@ -1287,10 +1242,7 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
> >  	 * block map is contained within the memslot.
> >  	 */
> >  	if (fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE)) {
> > -		int sz = get_user_mapping_size(kvm, hva);
> > -
> > -		if (sz < 0)
> > -			return sz;
> > +		size_t sz = folio_size(pfn_folio(pfn));
> 
> Hi,
> 
> Sorry this is an extremely late reply - I just noticed this because Marc
> mentioned it in another thread.
> 
> This doesn't look quite right to me; just because you have a folio of a given
> size, that doesn't mean the whole thing is mapped into this particular address
> space. For example, you could have a (PMD-sized) THP that gets partially
> munmapped - the folio is still PMD-sized but only some of it is mapped and
> should be accessible to the process. Or you could have a large file-backed folio
> (from a filesystem that supports large folios - e.g. XFS) but the application
> only mapped part of the file.

I thought originally this would break the block and the folio with it, but a
quick expriment showed it's not the case.

> 
> Perhaps I've misunderstood and those edge cases can't happen here for some reason?

And fault_supports_stage2_huge_mapping() would probably not be enough. we might
end-up with a portion unmapped at stage-1 but mapped at stage-2. :-( 

> 
> Thanks,
> Ryan
> 
> 

  parent reply	other threads:[~2023-10-30 10:47 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
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 [this message]
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=ZT-Jw4SVJ6C1E6sc@google.com \
    --to=vdonnefort@google.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=ryan.roberts@arm.com \
    --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