Blame SOURCES/0021-Use-page-size-as-alignment-value.patch

2eb93d
From fe831b526b88f6ca7a27fdb149b8a7d2ecddbc55 Mon Sep 17 00:00:00 2001
2eb93d
From: Santosh Sivaraj <santosh@fossix.org>
2eb93d
Date: Thu, 13 May 2021 11:42:18 +0530
2eb93d
Subject: [PATCH 021/217] Use page size as alignment value
8afcf0
2eb93d
The alignment sizes passed to ndctl in the tests are all hardcoded to 4k,
2eb93d
the default page size on x86. Change those to the default page size on that
2eb93d
architecture (sysconf/getconf). No functional changes otherwise.
8afcf0
2eb93d
Link: https://lore.kernel.org/r/20210513061218.760322-4-santosh@fossix.org
2eb93d
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 test/dpa-alloc.c    | 15 ++++++++-------
2eb93d
 test/multi-dax.sh   |  6 ++++--
2eb93d
 test/sector-mode.sh |  4 +++-
2eb93d
 3 files changed, 15 insertions(+), 10 deletions(-)
8afcf0
2eb93d
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
2eb93d
index 0b3bb7a..59185cf 100644
2eb93d
--- a/test/dpa-alloc.c
2eb93d
+++ b/test/dpa-alloc.c
2eb93d
@@ -38,12 +38,13 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
8afcf0
 	struct ndctl_region *region, *blk_region = NULL;
8afcf0
 	struct ndctl_namespace *ndns;
8afcf0
 	struct ndctl_dimm *dimm;
8afcf0
-	unsigned long size;
8afcf0
+	unsigned long size, page_size;
8afcf0
 	struct ndctl_bus *bus;
8afcf0
 	char uuid_str[40];
8afcf0
 	int round;
8afcf0
 	int rc;
8afcf0
 
8afcf0
+	page_size = sysconf(_SC_PAGESIZE);
8afcf0
 	/* disable nfit_test.1, not used in this test */
8afcf0
 	bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
8afcf0
 	if (!bus)
2eb93d
@@ -124,11 +125,11 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
8afcf0
 			return rc;
8afcf0
 		}
8afcf0
 		ndctl_namespace_disable_invalidate(ndns);
8afcf0
-		rc = ndctl_namespace_set_size(ndns, SZ_4K);
8afcf0
+		rc = ndctl_namespace_set_size(ndns, page_size);
8afcf0
 		if (rc) {
8afcf0
-			fprintf(stderr, "failed to init %s to size: %d\n",
8afcf0
+			fprintf(stderr, "failed to init %s to size: %lu\n",
8afcf0
 					ndctl_namespace_get_devname(ndns),
8afcf0
-					SZ_4K);
8afcf0
+					page_size);
8afcf0
 			return rc;
8afcf0
 		}
8afcf0
 		namespaces[i].ndns = ndns;
2eb93d
@@ -150,7 +151,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
8afcf0
 		ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
8afcf0
 		if (i % ARRAY_SIZE(namespaces) == 0)
8afcf0
 			round++;
8afcf0
-		size = SZ_4K * round;
8afcf0
+		size = page_size * round;
8afcf0
 		rc = ndctl_namespace_set_size(ndns, size);
8afcf0
 		if (rc) {
8afcf0
 			fprintf(stderr, "%s: set_size: %lx failed: %d\n",
2eb93d
@@ -166,7 +167,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
8afcf0
 	i--;
8afcf0
 	round++;
8afcf0
 	ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
8afcf0
-	size = SZ_4K * round;
8afcf0
+	size = page_size * round;
8afcf0
 	rc = ndctl_namespace_set_size(ndns, size);
8afcf0
 	if (rc) {
8afcf0
 		fprintf(stderr, "%s failed to update while labels full\n",
2eb93d
@@ -175,7 +176,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
8afcf0
 	}
8afcf0
 
8afcf0
 	round--;
8afcf0
-	size = SZ_4K * round;
8afcf0
+	size = page_size * round;
8afcf0
 	rc = ndctl_namespace_set_size(ndns, size);
8afcf0
 	if (rc) {
8afcf0
 		fprintf(stderr, "%s failed to reduce size while labels full\n",
2eb93d
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
2eb93d
index 8496619..b343a38 100755
2eb93d
--- a/test/multi-dax.sh
2eb93d
+++ b/test/multi-dax.sh
2eb93d
@@ -13,6 +13,8 @@ check_prereq "jq"
8afcf0
 
8afcf0
 trap 'err $LINENO' ERR
8afcf0
 
8afcf0
+ALIGN_SIZE=`getconf PAGESIZE`
8afcf0
+
8afcf0
 # setup (reset nfit_test dimms)
8afcf0
 modprobe nfit_test
8afcf0
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
2eb93d
@@ -23,9 +25,9 @@ rc=1
8afcf0
 query=". | sort_by(.available_size) | reverse | .[0].dev"
8afcf0
 region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query")
8afcf0
 
8afcf0
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
8afcf0
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
8afcf0
 chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
8afcf0
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
8afcf0
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
8afcf0
 chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
8afcf0
 
8afcf0
 _cleanup
2eb93d
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
2eb93d
index 54fa806..7a2faea 100755
2eb93d
--- a/test/sector-mode.sh
2eb93d
+++ b/test/sector-mode.sh
2eb93d
@@ -11,6 +11,8 @@ check_prereq "jq"
8afcf0
 set -e
8afcf0
 trap 'err $LINENO' ERR
8afcf0
 
8afcf0
+ALIGN_SIZE=`getconf PAGESIZE`
8afcf0
+
8afcf0
 # setup (reset nfit_test dimms)
8afcf0
 modprobe nfit_test
8afcf0
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
2eb93d
@@ -27,7 +29,7 @@ NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query")
8afcf0
 REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev")
8afcf0
 echo 0 > /sys/bus/nd/devices/$REGION/read_only
8afcf0
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
8afcf0
-$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a 4K
8afcf0
+$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE
8afcf0
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
8afcf0
 
8afcf0
 _cleanup
2eb93d
-- 
2eb93d
2.27.0
2eb93d