mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sarthak Sharma <sarthak.sharma@arm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R . Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Jonathan Corbet <corbet@lwn.net>, Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Leon Romanovsky <leon@kernel.org>, Zi Yan <ziy@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <npache@redhat.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	Mark Brown <broonie@kernel.org>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Muhammad Usama Anjum <usama.anjum@arm.com>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Rik van Riel <riel@surriel.com>
Subject: Re: [PATCH v10 6/6] selftests/mm: add a GUP selftest
Date: Tue, 15 Sep 2026 14:09:18 +0530	[thread overview]
Message-ID: <e6caa3e6-084c-442b-8d0e-e851ba75914c@arm.com> (raw)
In-Reply-To: <891915e3-3333-45f3-81a8-1ad38fa7ee37@kernel.org>



On 9/11/26 9:18 PM, David Hildenbrand (Arm) wrote:

[...]

>> +
>> +/* Just the flags we need, copied from the kernel internals. */
>> +#define FOLL_WRITE	0x01	/* check pte is writable */
> 
> BTW, it's odd that we support passing GUP-flags ... we should probably switch at
> some point simpler attributes (bool write) or custom flags (but we don't seem to
> need many ...).

Agreed

> 
>> +
>> +/* Page counts exercising single, THP-batch, partial, and full-mapping GUP. */
>> +static const int nr_pages_list[] = { 1, 512, 123, -1 };
> 
> 
> Would we want to calculate 512 dynamically at runtime using the PMD pagesize?
> Could be something for a follow-up patch.

Yeah this can be done.

> 
>> +
>> +#define GUP_TEST_FILE "/sys/kernel/debug/gup_test"
>> +#define NR_HUGE_PAGES 2
> 
> I'd call this "NR_HUGETLB_PAGES".

Okay.

[...]

>> +static void run_gup_cmd(struct __test_metadata *_metadata,
>> +			 FIXTURE_DATA(gup_test) *self,
>> +			 const FIXTURE_VARIANT(gup_test) *variant,
>> +			 unsigned long command)
> 
> We prefer two tab indents.

Okay.

> 
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < (int)ARRAY_SIZE(nr_pages_list); i++) {
>> +		struct gup_test gup = {
>> +			.addr = (unsigned long)self->addr,
>> +			.size = self->size,
>> +			.nr_pages_per_call = nr_pages_list[i] < 0 ?
>> +				self->size / psize() : nr_pages_list[i],
>> +			.gup_flags = variant->write ? FOLL_WRITE : 0,
>> +		};
>> +
>> +		TH_LOG("nr_pages_per_call=%u", gup.nr_pages_per_call);
>> +		ASSERT_EQ(ioctl(self->gup_fd, command, &gup), 0);
>> +		ASSERT_EQ(gup.size, self->size);
>> +	}
>> +}
>> +
>> +TEST_F(gup_test, get_user_pages)
>> +{
>> +	run_gup_cmd(_metadata, self, variant, GUP_BASIC_TEST);
>> +}
>> +
>> +TEST_F(gup_test, pin_user_pages)
>> +{
>> +	run_gup_cmd(_metadata, self, variant, PIN_BASIC_TEST);
>> +}
>> +
>> +TEST_F(gup_test, get_user_pages_fast)
>> +{
>> +	run_gup_cmd(_metadata, self, variant, GUP_FAST_BENCHMARK);
>> +}
>> +
>> +TEST_F(gup_test, pin_user_pages_fast)
>> +{
>> +	run_gup_cmd(_metadata, self, variant, PIN_FAST_BENCHMARK);
>> +}
>> +
>> +TEST_F(gup_test, pin_user_pages_longterm)
>> +{
>> +	run_gup_cmd(_metadata, self, variant, PIN_LONGTERM_BENCHMARK);
>> +}
> 
> Heh, is there actually a reason why these kernel things are called _BENCHMARK?
> 
> I think they are really just tests that can be used for benchmarking ... the
> measurement logic is entirely in user space.
> 
> We could consider cleaning that up as a follow-up.

Yeah this can be worked on as well.

> 
>> +
>> +int main(int argc, char **argv)
>> +{
>> +	int fd;
>> +
>> +	fd = open(GUP_TEST_FILE, O_RDWR);
> 
> Could do
> 
> const int fd = open(GUP_TEST_FILE, O_RDWR);

Okay.

> 
> 
> Thanks for doing that!
> 
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>

Thank you David!

> 
> 
> I think reasonable extensions will be to execute tests on all available mTHP
> sizes and all available hugetlb sizes, similar to what cow.c already does.
> 
> Can you look into that as part of some follow-up work? mTHP support will be
> interesting for testing some of the patches Rik has been working on.

Yup, I'll take that up.

Apart from the indentation, const int fd and the NR_HUGE_PAGES rename,
is there anything else I should incorporate in a respin? I think other
changes would require a separate series. If you want me to fold any
other change in a respin, please let me know.


      reply	other threads:[~2026-09-15  8:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 11:09 [PATCH v10 0/6] selftests/mm: separate GUP microbenchmarking from functional testing Sarthak Sharma
2026-09-11 11:09 ` [PATCH v10 1/6] selftests/mm: make file helpers return errors Sarthak Sharma
2026-09-11 11:09 ` [PATCH v10 2/6] tools/lib/mm: add shared file helpers Sarthak Sharma
2026-09-11 11:09 ` [PATCH v10 3/6] tools/lib/mm: move hugepage_settings out of selftests Sarthak Sharma
2026-09-11 11:09 ` [PATCH v10 4/6] tools/mm: move gup_test from selftests/mm to tools/mm Sarthak Sharma
2026-09-11 11:09 ` [PATCH v10 5/6] tools/mm: make gup_bench a benchmark only tool Sarthak Sharma
2026-09-11 11:09 ` [PATCH v10 6/6] selftests/mm: add a GUP selftest Sarthak Sharma
2026-09-11 15:48   ` David Hildenbrand (Arm)
2026-09-15  8:39     ` Sarthak Sharma [this message]

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=e6caa3e6-084c-442b-8d0e-e851ba75914c@arm.com \
    --to=sarthak.sharma@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=lance.yang@linux.dev \
    --cc=leon@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=npache@redhat.com \
    --cc=peterx@redhat.com \
    --cc=riel@surriel.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=surenb@google.com \
    --cc=usama.anjum@arm.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.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

all inboxes | Powered by JetHome®