All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Sarthak Sharma <sarthak.sharma@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>, Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
Date: Wed, 20 May 2026 11:55:53 +0300	[thread overview]
Message-ID: <ag13GbKcLMIoHOHj@kernel.org> (raw)
In-Reply-To: <20260519120506.184512-2-sarthak.sharma@arm.com>

(added broonie)

Hi,

On Tue, May 19, 2026 at 05:35:05PM +0530, Sarthak Sharma wrote:
> Add a command-line tool for benchmarking get_user_pages fast-path
> (GUP_FAST), pin_user_pages fast-path (PIN_FAST), and pin_user_pages
> longterm (PIN_LONGTERM) via the CONFIG_GUP_TEST debugfs interface.
> 
> When invoked without arguments, gup_bench runs the same matrix of
> configurations as run_gup_matrix() in run_vmtests.sh: all three GUP
> commands across read/write, private/shared mappings, and a range of
> page counts, with THP on/off for regular mappings and hugetlb for huge
> page mappings.
> 
> This tool is a mix of reused and new logic. The mapping/setup path comes
> from selftests/mm/gup_test.c, while the default benchmark matrix matches
> run_gup_matrix() in run_vmtests.sh. The standalone CLI and tools/mm
> integration are added here so tools/mm does not depend on kselftest.
> 
> Add gup_bench to BUILD_TARGETS and INSTALL_TARGETS in tools/mm/Makefile,
> and ignore the resulting binary in tools/mm/.gitignore. While here, also
> add the missing thp_swap_allocator_test entry to .gitignore.
> 
> Add tools/mm/gup_bench.c to the GUP entry in MAINTAINERS.
> 
> Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
> ---
>  MAINTAINERS          |   1 +
>  tools/mm/.gitignore  |   2 +
>  tools/mm/Makefile    |   6 +-
>  tools/mm/gup_bench.c | 491 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 497 insertions(+), 3 deletions(-)
>  create mode 100644 tools/mm/gup_bench.c

...
 
> +/*
> + * Local HugeTLB setup helpers for gup_bench.
> + *
> + * These helpers were copied from tools/testing/selftests/mm/ and adjusted to
> + * remove the ksft formatting. Keep this copy local so tools/mm does not
> + * depend on ksft output behavior.
> + */

It looks like self tests of at least 5 subsystems beside mm use hugetlb:

$ git grep -l "Hugepagesize:" tools/testing/selftests/ | grep -v "selftests/mm"
tools/testing/selftests/arm64/mte/check_hugetlb_options.c
tools/testing/selftests/cgroup/test_hugetlb_memcg.c
tools/testing/selftests/kvm/lib/test_util.c
tools/testing/selftests/memfd/common.c
tools/testing/selftests/net/tcp_mmap.c

It seems that we need to better share the common code in
tools/testing/selftest.

And adding another copy of the hugetlb detection and setup code does not
seem like a great idea.

> +
> +static unsigned int psize(void)
> +{
> +	static unsigned int __page_size;
> +
> +	if (!__page_size)
> +		__page_size = sysconf(_SC_PAGESIZE);
> +	return __page_size;
> +}
> +
> +static unsigned long default_huge_page_size(void)
> +{
> +	FILE *f = fopen("/proc/meminfo", "r");
> +	unsigned long hpage_size = 0;
> +	char buf[256];
> +
> +	if (!f)
> +		return 0;
> +	while (fgets(buf, sizeof(buf), f)) {
> +		if (sscanf(buf, "Hugepagesize:       %lu kB", &hpage_size) == 1)
> +			break;
> +	}
> +	fclose(f);
> +	hpage_size <<= 10;
> +	return hpage_size;
> +}

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2026-05-20  8:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 12:05 [PATCH v2 0/2] selftests/mm: separate GUP microbenchmarking from functional testing Sarthak Sharma
2026-05-19 12:05 ` [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark Sarthak Sharma
2026-05-20  8:55   ` Mike Rapoport [this message]
2026-05-20  9:02     ` Dev Jain
2026-05-20 10:15     ` Sarthak Sharma
2026-05-20 11:58       ` Mark Brown
2026-05-20 12:58         ` Mike Rapoport
2026-05-20 13:06           ` Sarthak Sharma
2026-05-19 12:05 ` [PATCH v2 2/2] selftests/mm: rewrite gup_test as a standalone harness-based selftest Sarthak Sharma
2026-05-19 18:20 ` [PATCH v2 0/2] selftests/mm: separate GUP microbenchmarking from functional testing Andrew Morton
2026-05-20  6:53   ` Sarthak Sharma

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=ag13GbKcLMIoHOHj@kernel.org \
    --to=rppt@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --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=peterx@redhat.com \
    --cc=sarthak.sharma@arm.com \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.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 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.