linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com,
	christophe.leroy@csgroup.eu, hughd@google.com,
	joel@joelfernandes.org, kaleshsingh@google.com,
	kirill.shutemov@linux.intel.com, kirill@shutemov.name,
	linux-mm@kvack.org, mm-commits@vger.kernel.org,
	mpe@ellerman.id.au, npiggin@gmail.com, sfr@canb.auug.org.au,
	torvalds@linux-foundation.org
Subject: [patch 46/54] selftest/mremap_test: update the test to handle pagesize other than 4K
Date: Wed, 07 Jul 2021 18:09:59 -0700	[thread overview]
Message-ID: <20210708010959.XjqIE74EV%akpm@linux-foundation.org> (raw)
In-Reply-To: <20210707175950.eceddb86c6c555555d4730e2@linux-foundation.org>

From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: selftest/mremap_test: update the test to handle pagesize other than 4K

Patch series "mrermap fixes", v2.


This patch (of 6):

Instead of hardcoding 4K page size fetch it using sysconf().  For the
performance measurements test still assume 2M and 1G are hugepage sizes.

Link: https://lkml.kernel.org/r/20210616045239.370802-1-aneesh.kumar@linux.ibm.com
Link: https://lkml.kernel.org/r/20210616045239.370802-2-aneesh.kumar@linux.ibm.com
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Reviewed-by: Kalesh Singh <kaleshsingh@google.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Hugh Dickins <hughd@google.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 tools/testing/selftests/vm/mremap_test.c |  111 +++++++++++----------
 1 file changed, 60 insertions(+), 51 deletions(-)

--- a/tools/testing/selftests/vm/mremap_test.c~selftest-mremap_test-update-the-test-to-handle-pagesize-other-than-4k
+++ a/tools/testing/selftests/vm/mremap_test.c
@@ -45,14 +45,15 @@ enum {
 	_4MB = 4ULL << 20,
 	_1GB = 1ULL << 30,
 	_2GB = 2ULL << 30,
-	PTE = _4KB,
 	PMD = _2MB,
 	PUD = _1GB,
 };
 
+#define PTE page_size
+
 #define MAKE_TEST(source_align, destination_align, size,	\
 		  overlaps, should_fail, test_name)		\
-{								\
+(struct test){							\
 	.name = test_name,					\
 	.config = {						\
 		.src_alignment = source_align,			\
@@ -252,12 +253,17 @@ static int parse_args(int argc, char **a
 	return 0;
 }
 
+#define MAX_TEST 13
+#define MAX_PERF_TEST 3
 int main(int argc, char **argv)
 {
 	int failures = 0;
 	int i, run_perf_tests;
 	unsigned int threshold_mb = VALIDATION_DEFAULT_THRESHOLD;
 	unsigned int pattern_seed;
+	struct test test_cases[MAX_TEST];
+	struct test perf_test_cases[MAX_PERF_TEST];
+	int page_size;
 	time_t t;
 
 	pattern_seed = (unsigned int) time(&t);
@@ -268,56 +274,59 @@ int main(int argc, char **argv)
 	ksft_print_msg("Test configs:\n\tthreshold_mb=%u\n\tpattern_seed=%u\n\n",
 		       threshold_mb, pattern_seed);
 
-	struct test test_cases[] = {
-		/* Expected mremap failures */
-		MAKE_TEST(_4KB, _4KB, _4KB, OVERLAPPING, EXPECT_FAILURE,
-		  "mremap - Source and Destination Regions Overlapping"),
-		MAKE_TEST(_4KB, _1KB, _4KB, NON_OVERLAPPING, EXPECT_FAILURE,
-		  "mremap - Destination Address Misaligned (1KB-aligned)"),
-		MAKE_TEST(_1KB, _4KB, _4KB, NON_OVERLAPPING, EXPECT_FAILURE,
-		  "mremap - Source Address Misaligned (1KB-aligned)"),
-
-		/* Src addr PTE aligned */
-		MAKE_TEST(PTE, PTE, _8KB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "8KB mremap - Source PTE-aligned, Destination PTE-aligned"),
-
-		/* Src addr 1MB aligned */
-		MAKE_TEST(_1MB, PTE, _2MB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "2MB mremap - Source 1MB-aligned, Destination PTE-aligned"),
-		MAKE_TEST(_1MB, _1MB, _2MB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "2MB mremap - Source 1MB-aligned, Destination 1MB-aligned"),
-
-		/* Src addr PMD aligned */
-		MAKE_TEST(PMD, PTE, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "4MB mremap - Source PMD-aligned, Destination PTE-aligned"),
-		MAKE_TEST(PMD, _1MB, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "4MB mremap - Source PMD-aligned, Destination 1MB-aligned"),
-		MAKE_TEST(PMD, PMD, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "4MB mremap - Source PMD-aligned, Destination PMD-aligned"),
-
-		/* Src addr PUD aligned */
-		MAKE_TEST(PUD, PTE, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "2GB mremap - Source PUD-aligned, Destination PTE-aligned"),
-		MAKE_TEST(PUD, _1MB, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "2GB mremap - Source PUD-aligned, Destination 1MB-aligned"),
-		MAKE_TEST(PUD, PMD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "2GB mremap - Source PUD-aligned, Destination PMD-aligned"),
-		MAKE_TEST(PUD, PUD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "2GB mremap - Source PUD-aligned, Destination PUD-aligned"),
-	};
+	page_size = sysconf(_SC_PAGESIZE);
 
-	struct test perf_test_cases[] = {
-		/*
-		 * mremap 1GB region - Page table level aligned time
-		 * comparison.
-		 */
-		MAKE_TEST(PTE, PTE, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "1GB mremap - Source PTE-aligned, Destination PTE-aligned"),
-		MAKE_TEST(PMD, PMD, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "1GB mremap - Source PMD-aligned, Destination PMD-aligned"),
-		MAKE_TEST(PUD, PUD, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
-		  "1GB mremap - Source PUD-aligned, Destination PUD-aligned"),
-	};
+	/* Expected mremap failures */
+	test_cases[0] =	MAKE_TEST(page_size, page_size, page_size,
+				  OVERLAPPING, EXPECT_FAILURE,
+				  "mremap - Source and Destination Regions Overlapping");
+
+	test_cases[1] = MAKE_TEST(page_size, page_size/4, page_size,
+				  NON_OVERLAPPING, EXPECT_FAILURE,
+				  "mremap - Destination Address Misaligned (1KB-aligned)");
+	test_cases[2] = MAKE_TEST(page_size/4, page_size, page_size,
+				  NON_OVERLAPPING, EXPECT_FAILURE,
+				  "mremap - Source Address Misaligned (1KB-aligned)");
+
+	/* Src addr PTE aligned */
+	test_cases[3] = MAKE_TEST(PTE, PTE, PTE * 2,
+				  NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "8KB mremap - Source PTE-aligned, Destination PTE-aligned");
+
+	/* Src addr 1MB aligned */
+	test_cases[4] = MAKE_TEST(_1MB, PTE, _2MB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "2MB mremap - Source 1MB-aligned, Destination PTE-aligned");
+	test_cases[5] = MAKE_TEST(_1MB, _1MB, _2MB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "2MB mremap - Source 1MB-aligned, Destination 1MB-aligned");
+
+	/* Src addr PMD aligned */
+	test_cases[6] = MAKE_TEST(PMD, PTE, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "4MB mremap - Source PMD-aligned, Destination PTE-aligned");
+	test_cases[7] =	MAKE_TEST(PMD, _1MB, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "4MB mremap - Source PMD-aligned, Destination 1MB-aligned");
+	test_cases[8] = MAKE_TEST(PMD, PMD, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "4MB mremap - Source PMD-aligned, Destination PMD-aligned");
+
+	/* Src addr PUD aligned */
+	test_cases[9] = MAKE_TEST(PUD, PTE, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				  "2GB mremap - Source PUD-aligned, Destination PTE-aligned");
+	test_cases[10] = MAKE_TEST(PUD, _1MB, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				   "2GB mremap - Source PUD-aligned, Destination 1MB-aligned");
+	test_cases[11] = MAKE_TEST(PUD, PMD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				   "2GB mremap - Source PUD-aligned, Destination PMD-aligned");
+	test_cases[12] = MAKE_TEST(PUD, PUD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				   "2GB mremap - Source PUD-aligned, Destination PUD-aligned");
+
+	perf_test_cases[0] =  MAKE_TEST(page_size, page_size, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+					"1GB mremap - Source PTE-aligned, Destination PTE-aligned");
+	/*
+	 * mremap 1GB region - Page table level aligned time
+	 * comparison.
+	 */
+	perf_test_cases[1] = MAKE_TEST(PMD, PMD, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				       "1GB mremap - Source PMD-aligned, Destination PMD-aligned");
+	perf_test_cases[2] = MAKE_TEST(PUD, PUD, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
+				       "1GB mremap - Source PUD-aligned, Destination PUD-aligned");
 
 	run_perf_tests =  (threshold_mb == VALIDATION_NO_THRESHOLD) ||
 				(threshold_mb * _1MB >= _1GB);
_


  parent reply	other threads:[~2021-07-08  1:10 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  0:59 incoming Andrew Morton
2021-07-08  1:07 ` [patch 01/54] lib/test: fix spelling mistakes Andrew Morton
2021-07-08  1:07 ` [patch 02/54] lib: " Andrew Morton
2021-07-08  1:07 ` [patch 03/54] lib: fix spelling mistakes in header files Andrew Morton
2021-07-08  1:07 ` [patch 04/54] hexagon: handle {,SOFT}IRQENTRY_TEXT in linker script Andrew Morton
2021-07-08  1:07 ` [patch 05/54] hexagon: use common DISCARDS macro Andrew Morton
2021-07-08  1:07 ` [patch 06/54] hexagon: select ARCH_WANT_LD_ORPHAN_WARN Andrew Morton
2021-07-08  1:07 ` [patch 07/54] mm/slub: use stackdepot to save stack trace in objects Andrew Morton
2021-07-16  7:39   ` Christoph Hellwig
2021-07-16  8:57     ` Vlastimil Babka
2021-07-16  9:12       ` Christoph Hellwig
2021-07-16 20:12     ` Linus Torvalds
2021-07-16 22:37       ` Vlastimil Babka
2021-07-17 17:34         ` Randy Dunlap
2021-07-18  7:29           ` Vlastimil Babka
2021-07-18 14:17             ` Randy Dunlap
2021-07-08  1:07 ` [patch 08/54] mmap: make mlock_future_check() global Andrew Morton
2021-07-08  1:07 ` [patch 09/54] riscv/Kconfig: make direct map manipulation options depend on MMU Andrew Morton
2021-07-08  1:07 ` [patch 10/54] set_memory: allow querying whether set_direct_map_*() is actually enabled Andrew Morton
2021-07-08  1:08 ` [patch 11/54] mm: introduce memfd_secret system call to create "secret" memory areas Andrew Morton
2021-07-08  3:13   ` Linus Torvalds
2021-07-08  5:21     ` Mike Rapoport
2021-07-08 18:38       ` Linus Torvalds
2021-07-08 20:13         ` Hagen Paul Pfeifer
2021-07-09 15:44           ` Mike Rapoport
2021-07-08  1:08 ` [patch 12/54] PM: hibernate: disable when there are active secretmem users Andrew Morton
2021-07-08  3:15   ` Linus Torvalds
2021-07-08  5:30     ` Mike Rapoport
2021-07-08  1:08 ` [patch 13/54] arch, mm: wire up memfd_secret system call where relevant Andrew Morton
2021-07-08  1:08 ` [patch 14/54] secretmem: test: add basic selftest for memfd_secret(2) Andrew Morton
2021-07-08  1:08 ` [patch 15/54] mm: fix spelling mistakes in header files Andrew Morton
2021-07-08  1:08 ` [patch 16/54] mm: add setup_initial_init_mm() helper Andrew Morton
2021-07-08  1:08 ` [patch 17/54] arc: convert to setup_initial_init_mm() Andrew Morton
2021-07-08  1:08 ` [patch 18/54] arm: " Andrew Morton
2021-07-08  1:08 ` [patch 19/54] arm64: " Andrew Morton
2021-07-08  1:08 ` [patch 20/54] csky: " Andrew Morton
2021-07-08  1:08 ` [patch 21/54] h8300: " Andrew Morton
2021-07-08  1:08 ` [patch 22/54] m68k: " Andrew Morton
2021-07-08  1:08 ` [patch 23/54] nds32: " Andrew Morton
2021-07-08  1:08 ` [patch 24/54] nios2: " Andrew Morton
2021-07-08  1:08 ` [patch 25/54] openrisc: " Andrew Morton
2021-07-08  1:08 ` [patch 26/54] powerpc: " Andrew Morton
2021-07-08  4:46   ` Christophe Leroy
2021-07-08  1:08 ` [patch 27/54] riscv: " Andrew Morton
2021-07-08  1:08 ` [patch 28/54] s390: " Andrew Morton
2021-07-08  1:09 ` [patch 29/54] sh: " Andrew Morton
2021-07-08  1:09 ` [patch 30/54] x86: " Andrew Morton
2021-07-08  1:09 ` [patch 31/54] buildid: only consider GNU notes for build ID parsing Andrew Morton
2021-07-08  1:09 ` [patch 32/54] buildid: add API to parse build ID out of buffer Andrew Morton
2021-07-08  1:09 ` [patch 33/54] buildid: stash away kernels build ID on init Andrew Morton
2021-07-08  1:09 ` [patch 34/54] dump_stack: add vmlinux build ID to stack traces Andrew Morton
2021-07-08  1:09 ` [patch 35/54] module: add printk formats to add module build ID to stacktraces Andrew Morton
2021-07-08  1:09 ` [patch 36/54] arm64: stacktrace: use %pSb for backtrace printing Andrew Morton
2021-07-08  1:09 ` [patch 37/54] x86/dumpstack: use %pSb/%pBb " Andrew Morton
2021-07-08  1:09 ` [patch 38/54] scripts/decode_stacktrace.sh: support debuginfod Andrew Morton
2021-07-08  1:09 ` [patch 39/54] scripts/decode_stacktrace.sh: silence stderr messages from addr2line/nm Andrew Morton
2021-07-08  1:09 ` [patch 40/54] scripts/decode_stacktrace.sh: indicate 'auto' can be used for base path Andrew Morton
2021-07-08  1:09 ` [patch 41/54] buildid: mark some arguments const Andrew Morton
2021-07-08  1:09 ` [patch 42/54] buildid: fix kernel-doc notation Andrew Morton
2021-07-08  1:09 ` [patch 43/54] kdump: use vmlinux_build_id to simplify Andrew Morton
2021-07-08  1:09 ` [patch 44/54] mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t * Andrew Morton
2021-07-08  1:09 ` [patch 45/54] mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t * Andrew Morton
2021-07-08  1:09 ` Andrew Morton [this message]
2021-07-08  1:10 ` [patch 47/54] selftest/mremap_test: avoid crash with static build Andrew Morton
2021-07-08  1:10 ` [patch 48/54] mm/mremap: convert huge PUD move to separate helper Andrew Morton
2021-07-08  1:10 ` [patch 49/54] mm/mremap: don't enable optimized PUD move if page table levels is 2 Andrew Morton
2021-07-08  1:10 ` [patch 50/54] mm/mremap: use pmd/pud_poplulate to update page table entries Andrew Morton
2021-07-08  1:10 ` [patch 51/54] mm/mremap: hold the rmap lock in write mode when moving " Andrew Morton
2021-07-08  1:10 ` [patch 52/54] mm/mremap: allow arch runtime override Andrew Morton
2021-07-08  1:10 ` [patch 53/54] powerpc/book3s64/mm: update flush_tlb_range to flush page walk cache Andrew Morton
2021-07-08  1:10 ` [patch 54/54] powerpc/mm: enable HAVE_MOVE_PMD support Andrew Morton

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=20210708010959.XjqIE74EV%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=hughd@google.com \
    --cc=joel@joelfernandes.org \
    --cc=kaleshsingh@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.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).