Hi all,
Commit f7d5bcd35d42 ("selftests: kselftest: Mark functions that
unconditionally call exit() as __noreturn") marked functions that call
exit() as __noreturn but it did not change the return type of these
functions from 'void' to 'int' like it should have (since a noreturn
function by definition cannot return an integer because it does not
return...) because there are many tests that return the result of the
ksft_exit function, even though it has never been used due to calling
exit().
Prior to adding __noreturn, the compiler would not know that the functions
that call exit() will not return, so code like
void ksft_exit_fail(void)
{
exit(1);
}
void ksft_exit_pass(void)
{
exit(0);
}
int main(void)
{
int ret;
ret = foo();
if (ret)
ksft_exit_fail();
ksft_exit_pass();
}
would cause the compiler to complain that main() does not return an
integer, even though when ksft_exit_pass() is called, exit() will cause
the program to terminate. So ksft_exit_...() returns int to make the
compiler happy.
int ksft_exit_fail(void)
{
exit(1);
}
int ksft_exit_pass(void)
{
exit(0);
}
int main(void)
{
int ret;
ret = foo();
if (ret)
return ksft_exit_fail();
return ksft_exit_pass();
}
While this results in no warnings, it is weird semantically and it has
issues as noted in the aforementioned __noreturn change. Now that
__noreturn has been added to these functions, it is much cleaner to
change the functions to 'void' and eliminate the return statements, as
it has been made clear to the compiler that these functions terminate
the program. Drop the return before all instances of ksft_exit_...() in
a mostly mechanical way.
---
Changes in v2:
- Split series into individual patches per subsystem at Shuah's
request and CC maintainers for subsystems that have one.
- Rewrite commit messages for new patches and move previous commit
message into cover letter to high level explain all changes.
- Carry forward Thomas and Muhammad's review on patch split, as there
were no functional changes, please holler if this was inappropriate.
- Link to v1: https://lore.kernel.org/r/20240417-ksft-exit-int-to-void-v1-1-eff48fdbab39@…
---
Nathan Chancellor (10):
selftests/clone3: ksft_exit functions do not return
selftests/ipc: ksft_exit functions do not return
selftests: membarrier: ksft_exit_pass() does not return
selftests/mm: ksft_exit functions do not return
selftests: pidfd: ksft_exit functions do not return
selftests/resctrl: ksft_exit_skip() does not return
selftests: sync: ksft_exit_pass() does not return
selftests: timers: ksft_exit functions do not return
selftests: x86: ksft_exit_pass() does not return
selftests: kselftest: Make ksft_exit functions return void instead of int
tools/testing/selftests/clone3/clone3_clear_sighand.c | 2 +-
tools/testing/selftests/clone3/clone3_set_tid.c | 4 +++-
tools/testing/selftests/ipc/msgque.c | 11 +++++------
tools/testing/selftests/kselftest.h | 12 ++++++------
.../selftests/membarrier/membarrier_test_multi_thread.c | 2 +-
.../selftests/membarrier/membarrier_test_single_thread.c | 2 +-
tools/testing/selftests/mm/compaction_test.c | 6 +++---
tools/testing/selftests/mm/cow.c | 2 +-
tools/testing/selftests/mm/gup_longterm.c | 2 +-
tools/testing/selftests/mm/gup_test.c | 4 ++--
tools/testing/selftests/mm/ksm_functional_tests.c | 2 +-
tools/testing/selftests/mm/madv_populate.c | 2 +-
tools/testing/selftests/mm/mkdirty.c | 2 +-
tools/testing/selftests/mm/pagemap_ioctl.c | 4 ++--
tools/testing/selftests/mm/soft-dirty.c | 2 +-
tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 2 +-
tools/testing/selftests/pidfd/pidfd_open_test.c | 4 +++-
tools/testing/selftests/pidfd/pidfd_poll_test.c | 2 +-
tools/testing/selftests/pidfd/pidfd_test.c | 2 +-
tools/testing/selftests/resctrl/resctrl_tests.c | 6 +++---
tools/testing/selftests/sync/sync_test.c | 3 +--
tools/testing/selftests/timers/adjtick.c | 4 ++--
tools/testing/selftests/timers/alarmtimer-suspend.c | 4 ++--
tools/testing/selftests/timers/change_skew.c | 4 ++--
tools/testing/selftests/timers/freq-step.c | 4 ++--
tools/testing/selftests/timers/leap-a-day.c | 10 +++++-----
tools/testing/selftests/timers/leapcrash.c | 4 ++--
tools/testing/selftests/timers/mqueue-lat.c | 4 ++--
tools/testing/selftests/timers/posix_timers.c | 12 ++++++------
tools/testing/selftests/timers/raw_skew.c | 6 +++---
tools/testing/selftests/timers/set-2038.c | 4 ++--
tools/testing/selftests/timers/set-tai.c | 4 ++--
tools/testing/selftests/timers/set-timer-lat.c | 4 ++--
tools/testing/selftests/timers/set-tz.c | 4 ++--
tools/testing/selftests/timers/skew_consistency.c | 4 ++--
tools/testing/selftests/timers/threadtest.c | 2 +-
tools/testing/selftests/timers/valid-adjtimex.c | 6 +++---
tools/testing/selftests/x86/lam.c | 2 +-
38 files changed, 81 insertions(+), 79 deletions(-)
---
base-commit: 0e275f65f3ef9c662b678655c70aca555fbde304
change-id: 20240416-ksft-exit-int-to-void-5aa9db381379
Best regards,
--
Nathan Chancellor <nathan(a)kernel.org>
This is a followup of sleepable bpf_timer[0].
When discussing sleepable bpf_timer, it was thought that we should give
a try to bpf_wq, as the 2 APIs are similar but distinct enough to
justify a new one.
So here it is.
I tried to keep as much as possible common code in kernel/bpf/helpers.c
but I couldn't get away with code duplication in kernel/bpf/verifier.c.
This series introduces a basic bpf_wq support:
- creation is supported
- assignment is supported
- running a simple bpf_wq is also supported.
We will probably need to extend the API further with:
- a full delayed_work API (can be piggy backed on top with a correct
flag)
- bpf_wq_cancel() <- apparently not, this is shooting ourself in the
foot
- bpf_wq_cancel_sync() (for sleepable programs)
- documentation
---
For reference, the use cases I have in mind:
---
Basically, I need to be able to defer a HID-BPF program for the
following reasons (from the aforementioned patch):
1. defer an event:
Sometimes we receive an out of proximity event, but the device can not
be trusted enough, and we need to ensure that we won't receive another
one in the following n milliseconds. So we need to wait those n
milliseconds, and eventually re-inject that event in the stack.
2. inject new events in reaction to one given event:
We might want to transform one given event into several. This is the
case for macro keys where a single key press is supposed to send
a sequence of key presses. But this could also be used to patch a
faulty behavior, if a device forgets to send a release event.
3. communicate with the device in reaction to one event:
We might want to communicate back to the device after a given event.
For example a device might send us an event saying that it came back
from sleeping state and needs to be re-initialized.
Currently we can achieve that by keeping a userspace program around,
raise a bpf event, and let that userspace program inject the events and
commands.
However, we are just keeping that program alive as a daemon for just
scheduling commands. There is no logic in it, so it doesn't really justify
an actual userspace wakeup. So a kernel workqueue seems simpler to handle.
bpf_timers are currently running in a soft IRQ context, this patch
series implements a sleppable context for them.
Cheers,
Benjamin
To: Alexei Starovoitov <ast(a)kernel.org>
To: Daniel Borkmann <daniel(a)iogearbox.net>
To: Andrii Nakryiko <andrii(a)kernel.org>
To: Martin KaFai Lau <martin.lau(a)linux.dev>
To: Eduard Zingerman <eddyz87(a)gmail.com>
To: Song Liu <song(a)kernel.org>
To: Yonghong Song <yonghong.song(a)linux.dev>
To: John Fastabend <john.fastabend(a)gmail.com>
To: KP Singh <kpsingh(a)kernel.org>
To: Stanislav Fomichev <sdf(a)google.com>
To: Hao Luo <haoluo(a)google.com>
To: Jiri Olsa <jolsa(a)kernel.org>
To: Mykola Lysenko <mykolal(a)fb.com>
To: Shuah Khan <shuah(a)kernel.org>
Cc: <bpf(a)vger.kernel.org>
Cc: <linux-kernel(a)vger.kernel.org>
Cc: <linux-kselftest(a)vger.kernel.org>
Signed-off-by: Benjamin Tissoires <bentiss(a)kernel.org>
[0] https://lore.kernel.org/all/20240408-hid-bpf-sleepable-v6-0-0499ddd91b94@ke…
---
Changes in v2:
- took previous review into account
- mainly dropped BPF_F_WQ_SLEEPABLE
- Link to v1: https://lore.kernel.org/r/20240416-bpf_wq-v1-0-c9e66092f842@kernel.org
---
Benjamin Tissoires (16):
bpf: make timer data struct more generic
bpf: replace bpf_timer_init with a generic helper
bpf: replace bpf_timer_set_callback with a generic helper
bpf: replace bpf_timer_cancel_and_free with a generic helper
bpf: add support for bpf_wq user type
tools: sync include/uapi/linux/bpf.h
bpf: verifier: bail out if the argument is not a map
bpf: add support for KF_ARG_PTR_TO_WORKQUEUE
bpf: allow struct bpf_wq to be embedded in arraymaps and hashmaps
selftests/bpf: add bpf_wq tests
bpf: wq: add bpf_wq_init
selftests/bpf: wq: add bpf_wq_init() checks
bpf: wq: add bpf_wq_set_callback_impl
selftests/bpf: add checks for bpf_wq_set_callback()
bpf: add bpf_wq_start
selftests/bpf: wq: add bpf_wq_start() checks
include/linux/bpf.h | 13 +-
include/linux/bpf_verifier.h | 1 +
include/uapi/linux/bpf.h | 4 +
kernel/bpf/arraymap.c | 18 +-
kernel/bpf/btf.c | 17 +
kernel/bpf/hashtab.c | 55 +++-
kernel/bpf/helpers.c | 348 ++++++++++++++++-----
kernel/bpf/syscall.c | 15 +-
kernel/bpf/verifier.c | 154 ++++++++-
tools/include/uapi/linux/bpf.h | 4 +
tools/testing/selftests/bpf/bpf_experimental.h | 7 +
.../selftests/bpf/bpf_testmod/bpf_testmod.c | 5 +
.../selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h | 1 +
tools/testing/selftests/bpf/prog_tests/wq.c | 41 +++
tools/testing/selftests/bpf/progs/wq.c | 186 +++++++++++
tools/testing/selftests/bpf/progs/wq_failures.c | 144 +++++++++
16 files changed, 910 insertions(+), 103 deletions(-)
---
base-commit: ffa6b26b4d8a0520b78636ca9373ab842cb3b1a8
change-id: 20240411-bpf_wq-fe24e8d24f5e
Best regards,
--
Benjamin Tissoires <bentiss(a)kernel.org>
Hi all,
This series does a number of cleanups into resctrl_val() and
generalizes it by removing test name specific handling from the
function.
One of the changes improves MBA/MBM measurement by narrowing down the
period the resctrl FS derived memory bandwidth numbers are measured
over. My feel is it didn't cause noticeable difference into the numbers
because they're generally good anyway except for the small number of
outliers. To see the impact on outliers, I'd need to setup a test to
run large number of replications and do a statistical analysis, which
I've not spent my time on. Even without the statistical analysis, the
new way to measure seems obviously better and makes sense even if I
cannot see a major improvement with the setup I'm using.
This series has some conflicts with SNC series from Maciej (Maciej has
privately agreed to base his series on top of this series) and also
with the MBA/MBM series from Babu.
--
i.
v3:
- Rename init functions to <testname>_init()
- Replace for loops with READ+WRITE statements for clarity
- Don't drop Return: entry from perf_open_imc_mem_bw() func comment
- New patch: Fix closing of IMC fds in case of error
- New patch: Make "bandwidth" consistent in comments & prints
- New patch: Simplify mem bandwidth file code
- Remove wrong comment
- Changed grp_name check to return -1 on fail (internal sanity check)
v2:
- Resolved conflicts with kselftest/next
- Spaces -> tabs correction
Ilpo Järvinen (16):
selftests/resctrl: Open get_mem_bw_imc() fd for loops
selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1)
only
selftests/resctrl: Fix closing IMC fds on error
selftests/resctrl: Make "bandwidth" consistent in comments & prints
selftests/resctrl: Consolidate get_domain_id() into resctrl_val()
selftests/resctrl: Use correct type for pids
selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope
selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() &
document
selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM
tests
selftests/resctrl: Add ->measure() callback to resctrl_val_param
selftests/resctrl: Add ->init() callback into resctrl_val_param
selftests/resctrl: Simplify bandwidth report type handling
selftests/resctrl: Make some strings passed to resctrlfs functions
const
selftests/resctrl: Convert ctrlgrp & mongrp to pointers
selftests/resctrl: Remove mongrp from MBA test
selftests/resctrl: Remove test name comparing from
write_bm_pid_to_resctrl()
tools/testing/selftests/resctrl/cache.c | 6 +-
tools/testing/selftests/resctrl/cat_test.c | 5 +-
tools/testing/selftests/resctrl/cmt_test.c | 21 +-
tools/testing/selftests/resctrl/mba_test.c | 26 +-
tools/testing/selftests/resctrl/mbm_test.c | 25 +-
tools/testing/selftests/resctrl/resctrl.h | 49 ++-
tools/testing/selftests/resctrl/resctrl_val.c | 295 +++++++-----------
tools/testing/selftests/resctrl/resctrlfs.c | 64 ++--
8 files changed, 238 insertions(+), 253 deletions(-)
--
2.39.2
Hi there:
I am probably just doing something wrong, but I tried to run
tools/testing/selftests/drivers/net/stats.py today and hit what is possibly
a bug?
Background info: Python 3.12.3
I'm using net-next at commit 9dd15d5088e9 ("Merge branch
'sparx5-port-mirroring'") with a couple driver modifications added on top
of it that don't seem relevant to the two test failures I'm hitting:
1. "loopback has no stats", and
2. "Try to get stats for lowest unused ifindex but not 0"
Both of these tests expect the ynl library to raise an exception, but I
don't think it does, from tools/net/ynl/lib/ynl.py, the _ops method:
if nl_msg.error:
raise NlError(nl_msg)
if nl_msg.done:
if nl_msg.extack:
print("Netlink warning:")
print(nl_msg)
And the code in net/core/netdev-genl.c seems to set:
else {
NL_SET_BAD_ATTR(info->extack,
info->attrs[NETDEV_A_QSTATS_IFINDEX]);
err = netdev ? -EOPNOTSUPP : -ENODEV;
which is what cli.py says:
$ ./cli.py --spec ../../../Documentation/netlink/specs/netdev.yaml \
--dump qstats-get --json '{"ifindex": "1"}'
Netlink warning:
nl_len = 28 (12) nl_flags = 0x202 nl_type = 3
extack: {'bad-attr': '.ifindex'}
[]
that seems to be the warning print out from the above
tools/net/ynl/lib/ynl.py snippet, not an NlError, which is what you'd get
if you tried ifindex 0 (which is listed as out of range in the YAML spec):
$ ./cli.py --spec ../../../Documentation/netlink/specs/netdev.yaml \
--dump qstats-get --json '{"ifindex": "0"}'
Netlink error: Numerical result out of range
nl_len = 108 (92) nl_flags = 0x300 nl_type = 2
error: -34
extack: {'msg': 'integer out of range', 'policy': {'min-value': 1,
'max-value': 4294967295, 'type': 'u32'}, 'bad-attr': '.ifindex'}
I'm not sure whether:
1. tools/net/ynl/lib/ynl.py should be raising NlError when there is an
extack in this case (I think this is probably the way to go?), or
2. the tests should be changed so that they don't expect an exception to be
raised but (ideally?) hide the warning report from tools/net/ynl/lib/ynl.py
when the warning is expected.
I don't know python at all so this is definitely wrong, but here's a small
change I made to fix the test (a similar change was made for the test which
follows).
The following patch is not intended to be seriously considered for
application, just to highlight the issue I am hitting:
diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py
index 7a7b16b180e2..d9f5d1f3ed34 100755
--- a/tools/testing/selftests/drivers/net/stats.py
+++ b/tools/testing/selftests/drivers/net/stats.py
@@ -115,9 +115,8 @@ def qstat_by_ifindex(cfg) -> None:
ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex')
# loopback has no stats
- with ksft_raises(NlError) as cm:
- netfam.qstats_get({"ifindex": 1}, dump=True)
- ksft_eq(cm.exception.nl_msg.error, -95)
+ stats = netfam.qstats_get({"ifindex": 1}, dump=True)
+ ksft_eq(cm.exception.nl_msg.error, -34)
ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex')
Thanks,
Joe
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 :)
v5:
- fix rand port generation, and wrap it in a helper in case
the random thing proves to be flaky
- reuseaddr
- explicitly select the address family
v4: https://lore.kernel.org/all/20240418233844.2762396-1-kuba@kernel.org
- improve coding style of patch 5
- switch from netcat to socat (patch 6)
- support exit_wait for bkg() in context manager
- add require_XYZ() helpers (patch 7)
- increase timeouts a little (1,3 -> 5 sec)
v3: https://lore.kernel.org/all/20240417231146.2435572-1-kuba@kernel.org
- 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 (7):
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)
selftests: drv-net: add require_XYZ() helpers for validating env
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 | 175 ++++++++++++++++--
.../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 | 51 +++++
.../testing/selftests/net/lib/py/__init__.py | 1 +
tools/testing/selftests/net/lib/py/ksft.py | 13 +-
tools/testing/selftests/net/lib/py/netns.py | 31 ++++
tools/testing/selftests/net/lib/py/utils.py | 60 +++++-
12 files changed, 416 insertions(+), 29 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