The save/restore of nr_hugepages was added to the test itself by using
the atexit() functionality. But it is broken as parent exits after
creating child. Hence calling the atexit() function early. That's not
it. The child exits after creating its child and so on.
The parent cannot wait to get the termination status for its children as
it'll keep on holding the resources until the new pkey allocation fails.
It is impossible to wait for exits of all the grand and great grand
children. Hence the restoring of nr_hugepages value from parent is
wrong.
Let's save/restore the nr_hugepages settings in the launch script
instead of doing it in the test.
Fixes: c52eb6db7b7d ("selftests: mm: restore settings from only parent process")
Reported-by: Joey Gouly <joey.gouly(a)arm.com>
Closes: https://lore.kernel.org/all/20240418125250.GA2941398@e124191.cambridge.arm.…
Signed-off-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
---
tools/testing/selftests/mm/protection_keys.c | 38 --------------------
tools/testing/selftests/mm/run_vmtests.sh | 2 ++
2 files changed, 2 insertions(+), 38 deletions(-)
diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c
index 374a308174d2b..48dc151f8fca8 100644
--- a/tools/testing/selftests/mm/protection_keys.c
+++ b/tools/testing/selftests/mm/protection_keys.c
@@ -54,7 +54,6 @@ int test_nr;
u64 shadow_pkey_reg;
int dprint_in_signal;
char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE];
-char buf[256];
void cat_into_file(char *str, char *file)
{
@@ -1745,42 +1744,6 @@ void pkey_setup_shadow(void)
shadow_pkey_reg = __read_pkey_reg();
}
-pid_t parent_pid;
-
-void restore_settings_atexit(void)
-{
- if (parent_pid == getpid())
- cat_into_file(buf, "/proc/sys/vm/nr_hugepages");
-}
-
-void save_settings(void)
-{
- int fd;
- int err;
-
- if (geteuid())
- return;
-
- fd = open("/proc/sys/vm/nr_hugepages", O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "error opening\n");
- perror("error: ");
- exit(__LINE__);
- }
-
- /* -1 to guarantee leaving the trailing \0 */
- err = read(fd, buf, sizeof(buf)-1);
- if (err < 0) {
- fprintf(stderr, "error reading\n");
- perror("error: ");
- exit(__LINE__);
- }
-
- parent_pid = getpid();
- atexit(restore_settings_atexit);
- close(fd);
-}
-
int main(void)
{
int nr_iterations = 22;
@@ -1788,7 +1751,6 @@ int main(void)
srand((unsigned int)time(NULL));
- save_settings();
setup_handlers();
printf("has pkeys: %d\n", pkeys_supported);
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 223c2304f885c..3157204b90476 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -390,6 +390,7 @@ CATEGORY="ksm_numa" run_test ./ksm_tests -N -m 0
CATEGORY="ksm" run_test ./ksm_functional_tests
# protection_keys tests
+nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)
if [ -x ./protection_keys_32 ]
then
CATEGORY="pkey" run_test ./protection_keys_32
@@ -399,6 +400,7 @@ if [ -x ./protection_keys_64 ]
then
CATEGORY="pkey" run_test ./protection_keys_64
fi
+echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages
if [ -x ./soft-dirty ]
then
--
2.39.2
This test outputs lots of information. Let's conform the core part of
the test to TAP and leave the information printing messages for now.
Include ktap_helpers.sh to print conformed logs. Use KSFT_* macros to
return the correct exit code for the kselftest framework and CIs to
understand the exit status.
Signed-off-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
---
tools/testing/selftests/cpufreq/cpufreq.sh | 3 +-
tools/testing/selftests/cpufreq/main.sh | 47 +++++++++++++---------
tools/testing/selftests/cpufreq/module.sh | 6 +--
3 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/tools/testing/selftests/cpufreq/cpufreq.sh b/tools/testing/selftests/cpufreq/cpufreq.sh
index b583a2fb45042..a8b1dbc0a3a5b 100755
--- a/tools/testing/selftests/cpufreq/cpufreq.sh
+++ b/tools/testing/selftests/cpufreq/cpufreq.sh
@@ -178,8 +178,7 @@ cpufreq_basic_tests()
count=$(count_cpufreq_managed_cpus)
if [ $count = 0 ]; then
- printf "No cpu is managed by cpufreq core, exiting\n"
- exit;
+ ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting\n"
else
printf "CPUFreq manages: $count CPUs\n\n"
fi
diff --git a/tools/testing/selftests/cpufreq/main.sh b/tools/testing/selftests/cpufreq/main.sh
index 60ce18ed06660..a0eb84cf7167f 100755
--- a/tools/testing/selftests/cpufreq/main.sh
+++ b/tools/testing/selftests/cpufreq/main.sh
@@ -7,15 +7,15 @@ source governor.sh
source module.sh
source special-tests.sh
+DIR="$(dirname $(readlink -f "$0"))"
+source "${DIR}"/../kselftest/ktap_helpers.sh
+
FUNC=basic # do basic tests by default
OUTFILE=cpufreq_selftest
SYSFS=
CPUROOT=
CPUFREQROOT=
-# Kselftest framework requirement - SKIP code is 4.
-ksft_skip=4
-
helpme()
{
printf "Usage: $0 [-h] [-todg args]
@@ -32,7 +32,7 @@ helpme()
[-d <driver's module name: only with \"-t modtest>\"]
[-g <governor's module name: only with \"-t modtest>\"]
\n"
- exit 2
+ exit "${KSFT_FAIL}"
}
prerequisite()
@@ -40,8 +40,8 @@ prerequisite()
msg="skip all tests:"
if [ $UID != 0 ]; then
- echo $msg must be run as root >&2
- exit $ksft_skip
+ ktap_skip_all "$msg must be run as root"
+ exit "${KSFT_SKIP}"
fi
taskset -p 01 $$
@@ -49,21 +49,21 @@ prerequisite()
SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
if [ ! -d "$SYSFS" ]; then
- echo $msg sysfs is not mounted >&2
- exit 2
+ ktap_skip_all "$msg sysfs is not mounted"
+ exit "${KSFT_SKIP}"
fi
CPUROOT=$SYSFS/devices/system/cpu
CPUFREQROOT="$CPUROOT/cpufreq"
if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then
- echo $msg cpus not available in sysfs >&2
- exit 2
+ ktap_skip_all "$msg cpus not available in sysfs"
+ exit "${KSFT_SKIP}"
fi
if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
- echo $msg cpufreq directory not available in sysfs >&2
- exit 2
+ ktap_skip_all "$msg cpufreq directory not available in sysfs"
+ exit "${KSFT_SKIP}"
fi
}
@@ -105,8 +105,7 @@ do_test()
count=$(count_cpufreq_managed_cpus)
if [ $count = 0 -a $FUNC != "modtest" ]; then
- echo "No cpu is managed by cpufreq core, exiting"
- exit 2;
+ ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
fi
case "$FUNC" in
@@ -125,8 +124,7 @@ do_test()
"modtest")
# Do we have modules in place?
if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
- echo "No driver or governor module passed with -d or -g"
- exit 2;
+ ktap_exit_fail_msg "No driver or governor module passed with -d or -g"
fi
if [ $DRIVER_MOD ]; then
@@ -137,8 +135,7 @@ do_test()
fi
else
if [ $count = 0 ]; then
- echo "No cpu is managed by cpufreq core, exiting"
- exit 2;
+ ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
fi
module_governor_test $GOVERNOR_MOD
@@ -162,7 +159,7 @@ do_test()
;;
*)
- echo "Invalid [-f] function type"
+ ktap_print_msg "Invalid [-f] function type"
helpme
;;
esac
@@ -186,13 +183,25 @@ dmesg_dumps()
dmesg >> $1.dmesg_full.txt
}
+ktap_print_header
+
# Parse arguments
parse_arguments $@
+ktap_set_plan 1
+
# Make sure all requirements are met
prerequisite
# Run requested functions
clear_dumps $OUTFILE
do_test | tee -a $OUTFILE.txt
+if [ "${PIPESTATUS[0]}" -ne 0 ]; then
+ exit ${PIPESTATUS[0]};
+fi
dmesg_dumps $OUTFILE
+
+ktap_test_pass "Completed successfully"
+
+ktap_print_totals
+exit "${KSFT_PASS}"
diff --git a/tools/testing/selftests/cpufreq/module.sh b/tools/testing/selftests/cpufreq/module.sh
index 22563cd122e7d..7f2667e0ae2da 100755
--- a/tools/testing/selftests/cpufreq/module.sh
+++ b/tools/testing/selftests/cpufreq/module.sh
@@ -24,16 +24,14 @@ test_basic_insmod_rmmod()
# insert module
insmod $1
if [ $? != 0 ]; then
- printf "Insmod $1 failed\n"
- exit;
+ ktap_exit_fail_msg "Insmod $1 failed\n"
fi
printf "Removing $1 module\n"
# remove module
rmmod $1
if [ $? != 0 ]; then
- printf "rmmod $1 failed\n"
- exit;
+ ktap_exit_fail_msg "rmmod $1 failed\n"
fi
printf "\n"
--
2.39.2
Hi!
Implement support for tests which require access to a remote system /
endpoint which can generate traffic.
This series concludes the "groundwork" for upstream driver tests.
I wanted to support the three models which came up in discussions:
- SW testing with netdevsim
- "local" testing with two ports on the same system in a loopback
- "remote" testing via SSH
so there is a tiny bit of an abstraction which wraps up how "remote"
commands are executed. Otherwise hopefully there's nothing surprising.
I'm only adding a ping test. I had a bigger one written but I was
worried we'll get into discussing the details of the test itself
and how I chose to hack up netdevsim, instead of the test infra...
So that test will be a follow up :)
v3:
- first two patches are new
- make Remote::cmd() return Popen() object (patch 3)
- always operate on absolute paths (patch 3)
- last two patches are new
v2: https://lore.kernel.org/all/20240416004556.1618804-1-kuba@kernel.org
- rename endpoint -> remote
- use 2001:db8:: v6 prefix
- add a note about persistent SSH connections
- add the kernel config
v1: https://lore.kernel.org/all/20240412233705.1066444-1-kuba@kernel.org
Jakub Kicinski (8):
selftests: net: fix counting totals when some checks fail
selftests: net: set the exit code correctly in Python tests
selftests: drv-net: define endpoint structures
selftests: drv-net: factor out parsing of the env
selftests: drv-net: construct environment for running tests which
require an endpoint
selftests: drv-net: add a trivial ping test
selftests: net: support matching cases by name prefix
selftests: drv-net: add a TCP ping test case (and useful helpers)
tools/testing/selftests/drivers/net/Makefile | 5 +-
.../testing/selftests/drivers/net/README.rst | 33 ++++
.../selftests/drivers/net/lib/py/__init__.py | 1 +
.../selftests/drivers/net/lib/py/env.py | 141 +++++++++++++++---
.../selftests/drivers/net/lib/py/remote.py | 15 ++
.../drivers/net/lib/py/remote_netns.py | 21 +++
.../drivers/net/lib/py/remote_ssh.py | 39 +++++
tools/testing/selftests/drivers/net/ping.py | 52 +++++++
tools/testing/selftests/drivers/net/stats.py | 4 +-
.../testing/selftests/net/lib/py/__init__.py | 1 +
tools/testing/selftests/net/lib/py/ksft.py | 25 +++-
tools/testing/selftests/net/lib/py/netns.py | 31 ++++
tools/testing/selftests/net/lib/py/utils.py | 50 ++++++-
tools/testing/selftests/net/nl_netdev.py | 4 +-
14 files changed, 391 insertions(+), 31 deletions(-)
create mode 100644 tools/testing/selftests/drivers/net/lib/py/remote.py
create mode 100644 tools/testing/selftests/drivers/net/lib/py/remote_netns.py
create mode 100644 tools/testing/selftests/drivers/net/lib/py/remote_ssh.py
create mode 100755 tools/testing/selftests/drivers/net/ping.py
create mode 100644 tools/testing/selftests/net/lib/py/netns.py
--
2.44.0
Hi,
These two patches fix some minor error path mistakes in the device
module.
Wander Lairson Costa (2):
kunit: unregister the device on error
kunit: avoid memory leak on device register error
lib/kunit/device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.44.0
The atexit() is called from parent process as well as forked processes.
Hence the child restores the settings at exit while the parent is still
executing. Fix this by checking pid of atexit() calling process and only
restore THP number from parent process.
Fixes: c23ea61726d5 ("selftests/mm: protection_keys: save/restore nr_hugepages settings")
Tested-by: Joey Gouly <joey.gouly(a)arm.com>
Signed-off-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
---
tools/testing/selftests/mm/protection_keys.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c
index f822ae31af22e..374a308174d2b 100644
--- a/tools/testing/selftests/mm/protection_keys.c
+++ b/tools/testing/selftests/mm/protection_keys.c
@@ -1745,9 +1745,12 @@ void pkey_setup_shadow(void)
shadow_pkey_reg = __read_pkey_reg();
}
+pid_t parent_pid;
+
void restore_settings_atexit(void)
{
- cat_into_file(buf, "/proc/sys/vm/nr_hugepages");
+ if (parent_pid == getpid())
+ cat_into_file(buf, "/proc/sys/vm/nr_hugepages");
}
void save_settings(void)
@@ -1773,6 +1776,7 @@ void save_settings(void)
exit(__LINE__);
}
+ parent_pid = getpid();
atexit(restore_settings_atexit);
close(fd);
}
--
2.39.2
Hi,
These two patches fix some minor error path mistakes in the device
module.
Changes:
--------
v1->v2:
* Add fixes tag.
* Add an imperative statement in the first commit descripton.
Wander Lairson Costa (2):
kunit: unregister the device on error
kunit: avoid memory leak on device register error
lib/kunit/device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.44.0
This patch series depends on commits in the series submitted to net.
(https://lore.kernel.org/netdev/20240412152120.115067-1-richardbgobert@gmail…)
The fields network_offset and inner_network_offset are added to
napi_gro_cb, and are both set during the receive phase of GRO. This is then
leveraged in the next commit to remove flush_id state from napi_gro_cb, and
stateful code in {ipv6,inet}_gro_receive which may be unnecessarily
complicated due to encapsulation support in GRO.
3rd patch adds tests for different flush_id flows in GRO.
v6 -> v7:
- Moved bug fixes to a separate submission in net
- Added UDP fwd benchmark
- v6:
https://lore.kernel.org/all/20240410153423.107381-1-richardbgobert@gmail.co…
v5 -> v6:
- Write inner_network_offset in vxlan and geneve
- Ignore is_atomic when DF=0
- v5:
https://lore.kernel.org/all/20240408141720.98832-1-richardbgobert@gmail.com/
v4 -> v5:
- Add 1st commit - flush id checks in udp_gro_receive segment which can be
backported by itself
- Add TCP measurements for the 5th commit
- Add flush id tests to ensure flush id logic is preserved in GRO
- Simplify gro_inet_flush by removing a branch
- v4:
https://lore.kernel.org/all/202420325182543.87683-1-richardbgobert@gmail.co…
v3 -> v4:
- Fix code comment and commit message typos
- v3:
https://lore.kernel.org/all/f939c84a-2322-4393-a5b0-9b1e0be8ed8e@gmail.com/
v2 -> v3:
- Use napi_gro_cb instead of skb->{offset}
- v2:
https://lore.kernel.org/all/2ce1600b-e733-448b-91ac-9d0ae2b866a4@gmail.com/
v1 -> v2:
- Pass p_off in *_gro_complete to fix UDP bug
- Remove more conditionals and memory fetches from inet_gro_flush
- v1:
https://lore.kernel.org/netdev/e1d22505-c5f8-4c02-a997-64248480338b@gmail.c…
Richard Gobert (3):
net: gro: add {inner_}network_offset to napi_gro_cb
net: gro: move L3 flush checks to tcp_gro_receive and udp_gro_receive_segment
selftests/net: add flush id selftests
drivers/net/geneve.c | 1 +
drivers/net/vxlan/vxlan_core.c | 1 +
include/net/gro.h | 82 +++++++++++++++--
net/8021q/vlan_core.c | 2 +
net/core/gro.c | 5 +-
net/ethernet/eth.c | 1 +
net/ipv4/af_inet.c | 46 +---------
net/ipv4/gre_offload.c | 1 +
net/ipv4/tcp_offload.c | 15 +---
net/ipv4/udp_offload.c | 16 +---
net/ipv6/ip6_offload.c | 19 +---
tools/testing/selftests/net/gro.c | 144 ++++++++++++++++++++++++++++++
12 files changed, 238 insertions(+), 95 deletions(-)
--
2.36.1
The Linux next building selftests with clang and gcc-13 found these
build warnings.
Reported-by: Linux Kernel Functional Testing <lkft(a)linaro.org>
Build log:
---------
PATH:
Reported build warnings noticed on following test files,
selftests/arm64/mte/
* check_buffer_fill.c
* mte_common_util.c
check_buffer_fill.c: In function 'check_buffer_underflow_by_byte':
check_buffer_fill.c:94:93: warning: format '%lx' expects argument of
type 'long unsigned int', but argument 3 has type 'char *' [-Wformat=]
94 | ksft_print_msg("Buffer is not
filled at index:%d of ptr:0x%lx\n",
|
~~^
|
|
|
long unsigned int
|
%s
95 | j, ptr);
| ~~~
| |
| char *
<trim>
mte_common_util.c: In function 'mte_default_handler':
mte_common_util.c:41:101: warning: format '%lx' expects argument of
type 'long unsigned int', but argument 2 has type 'long long unsigned
int' [-Wformat=]
41 | ksft_print_msg("Got unexpected
SEGV_MTEAERR at pc=$lx, fault addr=%lx\n",
|
~~^
|
|
|
long unsigned int
|
%llx
42 | ((ucontext_t
*)uc)->uc_mcontext.pc,
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
long long unsigned int
mte_common_util.c:41:48: warning: too many arguments for format
[-Wformat-extra-args]
41 | ksft_print_msg("Got unexpected
SEGV_MTEAERR at pc=$lx, fault addr=%lx\n",
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steps to reproduce:
---
tuxmake --runtime podman --target-arch arm64 --toolchain clang-nightly \
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3nAXzFH2GOEle3S3…
\
LLVM=1 LLVM_IAS=1 debugkernel dtbs dtbs-legacy headers kernel
kselftest modules
tuxmake --runtime podman --target-arch arm64 --toolchain gcc-13 \
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3wG8BqWxf0afUI5f…
\
debugkernel dtbs dtbs-legacy headers kernel kselftest modules
Links:
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3nAXzFH2GOEle3S3…
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3wG8BqWxf0afUI5f…
--
Linaro LKFT
https://lkft.linaro.org
The Linux next building selftests with clang-17 and gcc-13 found these
build warnings.
Reported-by: Linux Kernel Functional Testing <lkft(a)linaro.org>
Build log:
---------
PATH:
selftests/arm64/fp
The reported build warnings noticed on following test files.
* sve-ptrace.c
* za-ptrace.c
* zt-ptrace.c
clang-17 warnings:
-----
sve-ptrace.c:85:40: warning: data argument not used by format string
[-Wformat-extra-args]
85 | ksft_exit_fail_msg("PTRACE_TRACEME", strerror(errno));
| ~~~~~~~~~~~~~~~~ ^
sve-ptrace.c:88:40: warning: data argument not used by format string
[-Wformat-extra-args]
88 | ksft_exit_fail_msg("raise(SIGSTOP)", strerror(errno));
| ~~~~~~~~~~~~~~~~ ^
sve-ptrace.c:344:11: warning: format specifies type 'int' but the
argument has type 'size_t' (aka 'unsigned long') [-Wformat]
343 | ksft_test_result_fail("Error allocating %d
byte buffer for %s VL %u\n",
| ~~
| %zu
344 | data_size, type->name, vl);
| ^~~~~~~~~
and more
Gcc-13 warnings:
------
sve-ptrace.c: In function 'do_child':
sve-ptrace.c:85:36: warning: too many arguments for format [-Wformat-extra-args]
85 | ksft_exit_fail_msg("PTRACE_TRACEME", strerror(errno));
| ^~~~~~~~~~~~~~~~
sve-ptrace.c:88:36: warning: too many arguments for format [-Wformat-extra-args]
88 | ksft_exit_fail_msg("raise(SIGSTOP)", strerror(errno));
| ^~~~~~~~~~~~~~~~
sve-ptrace.c: In function 'ptrace_set_sve_get_sve_data':
sve-ptrace.c:343:58: warning: format '%d' expects argument of type
'int', but argument 2 has type 'size_t' {aka 'long unsigned int'}
[-Wformat=]
343 | ksft_test_result_fail("Error allocating %d
byte buffer for %s VL %u\n",
| ~^
| |
| int
| %ld
344 | data_size, type->name, vl);
| ~~~~~~~~~
| |
| size_t {aka long unsigned int}
and more
Steps to reproduce:
---
tuxmake --runtime podman --target-arch arm64 --toolchain clang-nightly \
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3nAXzFH2GOEle3S3…
\
LLVM=1 LLVM_IAS=1 debugkernel dtbs dtbs-legacy headers kernel
kselftest modules
tuxmake --runtime podman --target-arch arm64 --toolchain gcc-13 \
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3wG8BqWxf0afUI5f…
\
debugkernel dtbs dtbs-legacy headers kernel kselftest modules
Links:
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3nAXzFH2GOEle3S3…
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2fDW3wG8BqWxf0afUI5f…
--
Linaro LKFT
https://lkft.linaro.org