All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Ricardo Koller <ricarkol@google.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	andrew.jones@linux.dev, pbonzini@redhat.com, maz@kernel.org,
	alexandru.elisei@arm.com, eric.auger@redhat.com,
	oupton@google.com, reijiw@google.com, rananta@google.com,
	bgardon@google.com, dmatlack@google.com,
	axelrasmussen@google.com
Subject: Re: [PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test
Date: Wed, 28 Sep 2022 16:58:53 +0000	[thread overview]
Message-ID: <YzR9TRjVFi+P7UOp@google.com> (raw)
In-Reply-To: <YzPMaEPBtaXguJaT@google.com>

On Tue, Sep 27, 2022, Ricardo Koller wrote:
> On Tue, Sep 27, 2022 at 10:06:23PM +0000, Sean Christopherson wrote:
> > On Mon, Sep 26, 2022, Ricardo Koller wrote:
> > > On Thu, Sep 22, 2022 at 07:32:42PM +0000, Sean Christopherson wrote:
> > > > On Thu, Sep 22, 2022, Ricardo Koller wrote:
> > > > > +	void *hva = (void *)region->region.userspace_addr;
> > > > > +	uint64_t paging_size = region->region.memory_size;
> > > > > +	int ret, fd = region->fd;
> > > > > +
> > > > > +	if (fd != -1) {
> > > > > +		ret = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> > > > > +				0, paging_size);
> > > > > +		TEST_ASSERT(ret == 0, "fallocate failed, errno: %d\n", errno);
> > > > > +	} else {
> > > > > +		if (is_backing_src_hugetlb(region->backing_src_type))
> > > > > +			return false;
> > > > 
> > > > Why is hugetlb disallowed?  I thought anon hugetlb supports MADV_DONTNEED?
> > > > 
> > > 
> > > It fails with EINVAL (only tried on arm) for both the PAGE_SIZE and the huge
> > > page size. And note that the address is aligned as well.
> > > 
> > > madvise(0xffffb7c00000, 2097152, MADV_DONTNEED) = -1 EINVAL (Invalid argument)
> > > 	^^^^^^^^^^^^^^	^^^^^^^
> > > 	2M aligned	2M (hugepage size)
> > > 			
> > > madvise(0xffff9e800000, 4096, MADV_DONTNEED) = -1 EINVAL (Invalid argument)   
> > > 			^^^^
> > > 			PAGE_SIZE
> > 
> > I think this needs to be root caused before merging.  Unless I'm getting turned
> > around, MADV_DONTEED should work, i.e. there is a test bug lurking somewhere.
> 
> Turns out that the failure is documented. Found this in the madvise manpage:
> 
>   MADV_DONTNEED cannot be applied to locked pages, Huge TLB pages, or VM_PFNMAP pages.

The manpages are stale:

   c4b6cb884011 ("selftests/vm: add hugetlb madvise MADV_DONTNEED MADV_REMOVE test")
   90e7e7f5ef3f ("mm: enable MADV_DONTNEED for hugetlb mappings")

The tools/testing/selftests/vm/hugetlb-madvise.c selftest effectively tests what
is being done here, so _something_ is broken.

WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Ricardo Koller <ricarkol@google.com>
Cc: kvm@vger.kernel.org, maz@kernel.org, bgardon@google.com,
	andrew.jones@linux.dev, dmatlack@google.com, pbonzini@redhat.com,
	axelrasmussen@google.com, kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test
Date: Wed, 28 Sep 2022 16:58:53 +0000	[thread overview]
Message-ID: <YzR9TRjVFi+P7UOp@google.com> (raw)
In-Reply-To: <YzPMaEPBtaXguJaT@google.com>

On Tue, Sep 27, 2022, Ricardo Koller wrote:
> On Tue, Sep 27, 2022 at 10:06:23PM +0000, Sean Christopherson wrote:
> > On Mon, Sep 26, 2022, Ricardo Koller wrote:
> > > On Thu, Sep 22, 2022 at 07:32:42PM +0000, Sean Christopherson wrote:
> > > > On Thu, Sep 22, 2022, Ricardo Koller wrote:
> > > > > +	void *hva = (void *)region->region.userspace_addr;
> > > > > +	uint64_t paging_size = region->region.memory_size;
> > > > > +	int ret, fd = region->fd;
> > > > > +
> > > > > +	if (fd != -1) {
> > > > > +		ret = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> > > > > +				0, paging_size);
> > > > > +		TEST_ASSERT(ret == 0, "fallocate failed, errno: %d\n", errno);
> > > > > +	} else {
> > > > > +		if (is_backing_src_hugetlb(region->backing_src_type))
> > > > > +			return false;
> > > > 
> > > > Why is hugetlb disallowed?  I thought anon hugetlb supports MADV_DONTNEED?
> > > > 
> > > 
> > > It fails with EINVAL (only tried on arm) for both the PAGE_SIZE and the huge
> > > page size. And note that the address is aligned as well.
> > > 
> > > madvise(0xffffb7c00000, 2097152, MADV_DONTNEED) = -1 EINVAL (Invalid argument)
> > > 	^^^^^^^^^^^^^^	^^^^^^^
> > > 	2M aligned	2M (hugepage size)
> > > 			
> > > madvise(0xffff9e800000, 4096, MADV_DONTNEED) = -1 EINVAL (Invalid argument)   
> > > 			^^^^
> > > 			PAGE_SIZE
> > 
> > I think this needs to be root caused before merging.  Unless I'm getting turned
> > around, MADV_DONTEED should work, i.e. there is a test bug lurking somewhere.
> 
> Turns out that the failure is documented. Found this in the madvise manpage:
> 
>   MADV_DONTNEED cannot be applied to locked pages, Huge TLB pages, or VM_PFNMAP pages.

The manpages are stale:

   c4b6cb884011 ("selftests/vm: add hugetlb madvise MADV_DONTNEED MADV_REMOVE test")
   90e7e7f5ef3f ("mm: enable MADV_DONTNEED for hugetlb mappings")

The tools/testing/selftests/vm/hugetlb-madvise.c selftest effectively tests what
is being done here, so _something_ is broken.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  reply	other threads:[~2022-09-28 16:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22  3:18 [PATCH v8 00/14] KVM: selftests: Add aarch64/page_fault_test Ricardo Koller
2022-09-22  3:18 ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 01/14] KVM: selftests: Add a userfaultfd library Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 02/14] KVM: selftests: aarch64: Add virt_get_pte_hva() library function Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 03/14] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete() Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 04/14] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 05/14] tools: Copy bitfield.h from the kernel sources Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 06/14] KVM: selftests: Stash backing_src_type in struct userspace_mem_region Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 07/14] KVM: selftests: Add vm->memslots[] and enum kvm_mem_region_type Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22 18:33   ` Sean Christopherson
2022-09-22 18:33     ` Sean Christopherson
2022-09-22  3:18 ` [PATCH v8 08/14] KVM: selftests: Fix alignment in virt_arch_pgd_alloc() and vm_vaddr_alloc() Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 09/14] KVM: selftests: Use the right memslot for code, page-tables, and data allocations Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22 18:36   ` Sean Christopherson
2022-09-22 18:36     ` Sean Christopherson
2022-09-22  3:18 ` [PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22 19:32   ` Sean Christopherson
2022-09-22 19:32     ` Sean Christopherson
2022-09-26 17:22     ` Ricardo Koller
2022-09-26 17:22       ` Ricardo Koller
2022-09-27 22:06       ` Sean Christopherson
2022-09-27 22:06         ` Sean Christopherson
2022-09-28  4:24         ` Ricardo Koller
2022-09-28  4:24           ` Ricardo Koller
2022-09-28 16:58           ` Sean Christopherson [this message]
2022-09-28 16:58             ` Sean Christopherson
2022-09-28 18:10             ` Ricardo Koller
2022-09-28 18:10               ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 11/14] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 12/14] KVM: selftests: aarch64: Add dirty logging " Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 13/14] KVM: selftests: aarch64: Add readonly memslot " Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller
2022-09-22  3:18 ` [PATCH v8 14/14] KVM: selftests: aarch64: Add mix of " Ricardo Koller
2022-09-22  3:18   ` Ricardo Koller

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=YzR9TRjVFi+P7UOp@google.com \
    --to=seanjc@google.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=axelrasmussen@google.com \
    --cc=bgardon@google.com \
    --cc=dmatlack@google.com \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=maz@kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rananta@google.com \
    --cc=reijiw@google.com \
    --cc=ricarkol@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.