Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] cpuset_memory_spread: make result_check() robust to page-cache noise
@ 2026-09-04  3:13 Changwei Zou via ltp
  2026-09-04  5:34 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 2+ messages in thread
From: Changwei Zou via ltp @ 2026-09-04  3:13 UTC (permalink / raw)
  To: ltp; +Cc: Li Wang, Changwei Zou

The cpuset_memory_spread test uses empirical values that were
established in 2009. It consists of cpuset_mem_hog.c and
cpuset_memory_spread_testset.sh. cpuset_mem_hog.c reads a 100 MB file
(./DATAFILE) into memory, while cpuset_memory_spread_testset.sh compares
the global per-node FilePages counters in
/sys/devices/system/node/nodeX/meminfo.

On the expected NUMA node where the test case is running, the observed
change in FilePages should be larger than the preset upper limit
(i.e., 10000 KB). On the unexpected NUMA node where it is quiet, the
delta in FilePages should be smaller than the preset lower limit
(i.e., 2048 KB when PAGE_SIZE is 4 KB).

However, the global per-node FilePages counters also account for
unrelated page-cache activity on the system, which makes the test flaky
on large or heavily loaded NUMA machines. Some failures are listed
below.

  cpuset_memory_spread 1 TFAIL: hog the memory on the unexpected
  node(FilePages_For_Nodes(KB): _0: 106384 _1: 2248, Expect Nodes: 0).

  cpuset_memory_spread 5 TFAIL: hog the memory on the unexpected
  node(FilePages_For_Nodes(KB): _0: 7592 _1: 108328, Expect Nodes: 1).

  cpuset_memory_spread 7 TFAIL: hog the memory on the unexpected
  node(FilePages_For_Nodes(KB): _0: 2080 _1: 102788, Expect Nodes: 1).

For example, 108328 KB is much larger than the empirical upper limit of
10000 KB in cpuset_memory_spread_testset.sh, while 7592 KB is larger
than the lower limit of 2048 KB. Interestingly, 108328 KB is itself
larger than the actual file size (100 MB = 102,400 KB). This
demonstrates that the global per-node FilePages counters account for
unrelated page-cache activity elsewhere on the system.

To make the test more robust, add the following rule in result_check():

  Find the smallest get_memsinfo_val min_upper in $nodelist, and the
  largest get_memsinfo_val max_lower in $othernodelist. When their ratio
  min_upper / max_lower (in floating format) is not less than
  (upperlimit / lowerlimit), return 0 (the test passes). Otherwise
  return 1 (the test fails).

On non-NUMA machines, this test case always succeeds because it is
skipped.

Signed-off-by: Changwei Zou <changwei.zou@canonical.com>
---
 .../cpuset_memory_spread_testset.sh           | 29 +++++++++++++++++--
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
index 4c49bb8fd..70d04ac8d 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
@@ -170,12 +170,19 @@ result_check()
 {
 	local nodelist="`echo $1 | sed -e 's/,/ /g'`"
 	local i=
+	local val=
 
+	# find the smallest value in $nodelist while checking upperlimit
+	local min_upper=0
 	for i in $nodelist
 	do
-		if [ $(get_memsinfo_val $i) -le $upperlimit ]; then
+		val=$(get_memsinfo_val $i)
+		if [ $val -le $upperlimit ]; then
 			return 1
 		fi
+		if [ $min_upper -eq 0 ] || [ $val -lt $min_upper ]; then
+			min_upper=$val
+		fi
 	done
 
 	local allnodelist="`echo $mems_all | sed -e 's/,/ /g'`"
@@ -188,12 +195,28 @@ result_check()
 		othernodelist=`echo "$othernodelist" | sed -e "s/ $i / /g"`
 	done
 
+	# find the largest value in $othernodelist
+	local max_lower=0
 	for i in $othernodelist
 	do
-		if [ $(get_memsinfo_val $i) -gt $lowerlimit ]; then
-			return 1
+		val=$(get_memsinfo_val $i)
+		if [ $val -gt $max_lower ]; then
+			max_lower=$val
 		fi
 	done
+
+	# when min_upper / max_lower (floating) is not less than
+	# upperlimit / lowerlimit, the test passes.
+	if awk -v mu="$min_upper" -v xl="$max_lower" \
+	       -v ul="$upperlimit" -v ll="$lowerlimit" \
+	       'BEGIN {
+	                if (xl == 0) { exit !(mu > 0) }
+	                exit !((mu / xl) >= (ul / ll))
+	        }'; then
+		return 0
+	fi
+
+	return 1
 }
 
 # general_memory_spread_test <cpusetpath> <is_spread> <cpu_list> <node_list> \
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] cpuset_memory_spread: make result_check() robust to page-cache noise
  2026-09-04  3:13 [LTP] [PATCH v1] cpuset_memory_spread: make result_check() robust to page-cache noise Changwei Zou via ltp
@ 2026-09-04  5:34 ` linuxtestproject.agent
  0 siblings, 0 replies; 2+ messages in thread
From: linuxtestproject.agent @ 2026-09-04  5:34 UTC (permalink / raw)
  To: Changwei Zou; +Cc: ltp

Hi Changwei,

On Fri, Sep 4, 2026, Changwei Zou wrote:
> cpuset_memory_spread: make result_check() robust to page-cache noise

> +	# when min_upper / max_lower (floating) is not less than
> +	# upperlimit / lowerlimit, the test passes.
> +	if awk -v mu="$min_upper" -v xl="$max_lower" \
> +	       -v ul="$upperlimit" -v ll="$lowerlimit" \
> +	       'BEGIN {
> +	                if (xl == 0) { exit !(mu > 0) }
> +	                exit !((mu / xl) >= (ul / ll))
> +	        }'; then

This ratio can accept genuine unexpected-node allocations when unrelated
activity inflates an expected node. With 4 KiB pages, 500000/100000 passes;
with 64 KiB pages, even 20000/60000 passes because 10000/32768 is below one.
Retain an absolute cap for max_lower or isolate the test file's cache pages.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-04  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  3:13 [LTP] [PATCH v1] cpuset_memory_spread: make result_check() robust to page-cache noise Changwei Zou via ltp
2026-09-04  5:34 ` [LTP] " linuxtestproject.agent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox