Skip to contentSkip to conversation

selftests/sched: add basic test for psi

PATCH In review Pintu Kumar 3 participants 3 messages Oct 22, 2024 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/sched: add basic test for psi

There is a psi module that exists under kernel/sched/psi. Add a basic test to test the psi.
This test just add the basic support to check cpu/memory/io interface. Further test will be added on top of this.

---
 MAINTAINERS                              |  2 +
 tools/testing/selftests/sched/.gitignore |  1 +
 tools/testing/selftests/sched/Makefile   |  4 +-
 tools/testing/selftests/sched/config     |  1 +
 tools/testing/selftests/sched/psi_test.c | 85 ++++++++++++++++++++++++
 tools/testing/selftests/sched/run_psi.sh | 36 ++++++++++
 6 files changed, 127 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/sched/psi_test.c
 create mode 100755 tools/testing/selftests/sched/run_psi.sh
MAINTAINERS +2 -0
index 84a73e90cfe8..d84ff9ca36a9 100644
@@ -18548,10 +18548,12 @@ F:	include/uapi/linux/pps.h
 PRESSURE STALL INFORMATION (PSI)
 M:	Johannes Weiner <[email protected]>
 M:	Suren Baghdasaryan <[email protected]>
+M:	Pintu Kumar <[email protected]>
 R:	Peter Ziljstra <[email protected]>
 S:	Maintained
 F:	include/linux/psi*
 F:	kernel/sched/psi.c
+F:	tools/testing/selftests/sched/psi_test.c
 
 PRINTK
 M:	Petr Mladek <[email protected]>
tools/testing/selftests/sched/.gitignore +1 -0
index 6996d4654d92..2b15c11b93e6 100644
@@ -1 +1,2 @@
 cs_prctl_test
+psi_test
tools/testing/selftests/sched/Makefile +2 -2
index 099ee9213557..795f6613eb2c 100644
@@ -8,7 +8,7 @@ CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -Wl,-rpath=./ \
 	  $(CLANG_FLAGS)
 LDLIBS += -lpthread
 
-TEST_GEN_FILES := cs_prctl_test
-TEST_PROGS := cs_prctl_test
+TEST_GEN_FILES := cs_prctl_test psi_test
+TEST_PROGS := cs_prctl_test run_psi.sh
 
 include ../lib.mk
tools/testing/selftests/sched/config +1 -0
index e8b09aa7c0c4..287cccd434fd 100644
@@ -1 +1,2 @@
 CONFIG_SCHED_DEBUG=y
+CONFIG_PSI=y
tools/testing/selftests/sched/psi_test.c new file +85 -0

85 lines not on this page · raw message

tools/testing/selftests/sched/run_psi.sh new file +36 -0
new file mode 100755
index 000000000000..d0b1c7ae3736
@@ -0,0 +1,36 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+# Just one node check is enough to detect psi
+if [ ! -e /proc/pressure/cpu ]; then
+	echo "PSI not present..."
+	exit $ksft_skip
+fi
+
+echo ""
+./psi_test cpu
+if [ $? -ne 0 ]; then
+	echo "CPU - [FAIL]"
+else
+	echo "CPU - [PASS]"
+fi
+
+echo ""
+./psi_test memory
+if [ $? -ne 0 ]; then
+	echo "MEMORY - [FAIL]"
+else
+	echo "MEMORY - [PASS]"
+fi
+
+echo ""
+./psi_test io
+if [ $? -ne 0 ]; then
+	echo "IO - [FAIL]"
+else
+	echo "IO - [PASS]"
+fi
Signature · 1 line
2.17.1
#1 lore raw
Quoted 2 lines · Pintu Kumar

There is a psi module that exists under kernel/sched/psi. Add a basic test to test the psi.

I'm not sure this is a valuable use of test cycles. The mere existence and basic format of the files is very unlikely to be buggy, and such a bug wouldn't hide for very long either.

MAINTAINERS F: include/uapi/linux/pps.h · line 18551

Quoted 5 lines
MAINTAINERS +1 -0
@@ -18548,10 +18548,12 @@ F:	include/uapi/linux/pps.h
 PRESSURE STALL INFORMATION (PSI)
 M:	Johannes Weiner <[email protected]>
 M:	Suren Baghdasaryan <[email protected]>
+M:	Pintu Kumar <[email protected]>
$ git log --oneline --author='Pintu Kumar' kernel/sched/psi.c | wc -l
0

Really? ;)

Quoted 8 lines
MAINTAINERS +1 -0
 R:	Peter Ziljstra <[email protected]>
 S:	Maintained
 F:	include/linux/psi*
 F:	kernel/sched/psi.c
+F:	tools/testing/selftests/sched/psi_test.c
 
 PRINTK
 M:	Petr Mladek <[email protected]>
#2 lore raw

Hi Johannes,

Quoted 9 lines · Johannes Weiner
Quoted 2 lines · Pintu Kumar

There is a psi module that exists under kernel/sched/psi. Add a basic test to test the psi.

I'm not sure this is a valuable use of test cycles. The mere existence and basic format of the files is very unlikely to be buggy, and such a bug wouldn't hide for very long either.

Yes, I agree this is just a basic version to prepare for the test framework. Once the framework is available more tests can be added, such as trigger poll. If you have any other suggestions for the test please let me know.

Quoted 11 lines

MAINTAINERS F: include/uapi/linux/pps.h · line 18551

Quoted 5 lines
MAINTAINERS +1 -0
@@ -18548,10 +18548,12 @@ F:  include/uapi/linux/pps.h
 PRESSURE STALL INFORMATION (PSI)
 M:   Johannes Weiner <[email protected]>
 M:   Suren Baghdasaryan <[email protected]>
+M:   Pintu Kumar <[email protected]>
$ git log --oneline --author='Pintu Kumar' kernel/sched/psi.c | wc -l
0

Really? ;)

oh sorry.
This maintainer was added for tools/testing/sefttests/sched/psi_test after referring to existing once.
Otherwise, checkpatch was giving below warning:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #51:
new file mode 100644
total: 0 errors, 1 warnings, 134 lines checked

Please let me know what is the correct way.

Thanks,
Pintu