Similar to fbf4dec70277 ("selftests/futex: Order calls to
futex_lock_pi"), which fixed a flake in futex_lock_pi due to racing
between the parent and child threads.
The same issue can occur in the futex_requeue test, because it expects
waiterfn to make progress to futex_wait before the parent starts to
requeue. This is mitigated by the parent sleeping for WAKE_WAIT_US, but
it still fails occasionally. This can be reproduced by adding a sleep in
the waiterfn before futex_wait:
TAP version 13
1..2
not ok 1 futex_requeue simple returned: 0
not ok 2 futex_requeue simple returned: 0
not ok 3 futex_requeue many returned: 0
not ok 4 futex_requeue many returned: 0
Instead, replace the sleep with barriers to make the sequencing
explicit.
Fixes: 7cb5dd8e2c8c ("selftests: futex: Add futex compare requeue test")
Reviewed-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
Signed-off-by: Edward Liaw <edliaw(a)google.com>
---
.../selftests/futex/functional/futex_requeue.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/futex/functional/futex_requeue.c b/tools/testing/selftests/futex/functional/futex_requeue.c
index 51485be6eb2f..8f7d3e8bf32a 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue.c
@@ -12,9 +12,9 @@
#define TEST_NAME "futex-requeue"
#define timeout_ns 30000000
-#define WAKE_WAIT_US 10000
volatile futex_t *f1;
+static pthread_barrier_t barrier;
void usage(char *prog)
{
@@ -32,6 +32,8 @@ void *waiterfn(void *arg)
to.tv_sec = 0;
to.tv_nsec = timeout_ns;
+ pthread_barrier_wait(&barrier);
+
if (futex_wait(f1, *f1, &to, 0))
printf("waiter failed errno %d\n", errno);
@@ -70,13 +72,15 @@ int main(int argc, char *argv[])
ksft_print_msg("%s: Test futex_requeue\n",
basename(argv[0]));
+ pthread_barrier_init(&barrier, NULL, 2);
/*
* Requeue a waiter from f1 to f2, and wake f2.
*/
if (pthread_create(&waiter[0], NULL, waiterfn, NULL))
error("pthread_create failed\n", errno);
- usleep(WAKE_WAIT_US);
+ pthread_barrier_wait(&barrier);
+ pthread_barrier_destroy(&barrier);
info("Requeuing 1 futex from f1 to f2\n");
res = futex_cmp_requeue(f1, 0, &f2, 0, 1, 0);
@@ -99,6 +103,7 @@ int main(int argc, char *argv[])
ksft_test_result_pass("futex_requeue simple succeeds\n");
}
+ pthread_barrier_init(&barrier, NULL, 11);
/*
* Create 10 waiters at f1. At futex_requeue, wake 3 and requeue 7.
@@ -109,7 +114,8 @@ int main(int argc, char *argv[])
error("pthread_create failed\n", errno);
}
- usleep(WAKE_WAIT_US);
+ pthread_barrier_wait(&barrier);
+ pthread_barrier_destroy(&barrier);
info("Waking 3 futexes at f1 and requeuing 7 futexes from f1 to f2\n");
res = futex_cmp_requeue(f1, 0, &f2, 3, 7, 0);
--
2.46.0.469.g59c65b2a67-goog
This is a slight change from the fundamentals of HID-BPF.
In theory, HID-BPF is abstract to the kernel itself, and makes
only changes at the HID level (through report descriptors or
events emitted to/from the device).
However, we have seen a few use cases where HID-BPF might interact with
the running kernel when the target device is already handled by a
specific device.
For example, the XP-Pen/Huion/UC-Logic tablets are handled by
hid-uclogic but this driver is also doing a report descriptor fixup
without checking if the device has already been fixed by HID-BPF.
In the same way, another recent example[0] was when a cheap foot pedal is
used and tricks iPhones and Windows machines by presenting itself as a
known Apple wireless keyboard. The problem is that this fake keyboard is
not presenting a compatible report descriptor and hid-core merges all
device nodes together making libinput ignore the keyboard part for
historical reasons.
Last, there has been a long standing request to allow to disable the
input part of a given gamepad while SDL or Steam opens the device
through hidraw.
This series aims at tackling both of these problems:
- first we had a new hook `hid_bpf_driver_probe` which allows the BPF
program to decide if the curently probed driver should be used or not
- then this same hook can also change the ->driver_data of the struct
hid_device_id argument, and we teach hid-generic to use that field as
the connect mask.
Basically, it means that when we insert a BPF program to fix a device,
we can force hid-generic to handle the device, and thus preventing
any other kernel driver to tamper with our device. We can also
selectively decide to export the hidraw or input nodes when using
hid-generic.
In the SDL/Steam use case, this would means that the gaming application
will load one BPF program per input device it wants to open through
hidraw, that BPF program reassigns the input device to hid-generic and
disables hid-input, then it can open the new hidraw node.
Once that program terminates, the BPF program is removed (either
automatically because no-one has the fd of the links open, or manually
by SDL/Steam), and the normal driver rebinds to the HID device,
restoring full input functionality.
This branch is on top of the for-6.12/hidraw branch of hid.git, mainly
because that branch saw some selftests/hid changes.
[0] https://gitlab.freedesktop.org/libinput/libinput/-/issues/1014
Signed-off-by: Benjamin Tissoires <bentiss(a)kernel.org>
---
Benjamin Tissoires (7):
selftests/hid: add dependency on hid_common.h
selftests/hid: cleanup C tests by adding a common struct uhid_device
selftests/hid: allow to parametrize bus/vid/pid/rdesc on the test device
HID: bpf: allow BPF programs to force using hid-generic
selftests/hid: add test for assigning a given device to hid-generic
HID: bpf: Allow to control the connect mask of hid-generic from BPF
selftests/hid: add test to disable hid-input
Documentation/hid/hid-bpf.rst | 2 +-
drivers/hid/bpf/hid_bpf_dispatch.c | 31 ++++
drivers/hid/bpf/hid_bpf_struct_ops.c | 4 +
drivers/hid/hid-core.c | 18 +-
drivers/hid/hid-generic.c | 5 +-
include/linux/hid_bpf.h | 40 ++++
tools/testing/selftests/hid/Makefile | 2 +-
tools/testing/selftests/hid/hid_bpf.c | 205 ++++++++++++++++-----
tools/testing/selftests/hid/hid_common.h | 112 +++++++----
tools/testing/selftests/hid/hidraw.c | 36 +---
tools/testing/selftests/hid/progs/hid.c | 31 ++++
.../testing/selftests/hid/progs/hid_bpf_helpers.h | 4 +
12 files changed, 372 insertions(+), 118 deletions(-)
---
base-commit: 321f7798cfb8d834ae0ed0d467c8bf46804243f9
change-id: 20240829-hid-bpf-hid-generic-61579f5b5945
Best regards,
--
Benjamin Tissoires <bentiss(a)kernel.org>
Recently, a few issues have been discovered around the creation of
additional subflows. Without these counters, it was difficult to point
out the reason why some subflows were not created as expected.
In patch 3, all error paths from __mptcp_subflow_connect() are covered,
except the one related to the 'fully established mode', because it can
only happen with the userspace PM, which will propagate the error to the
userspace in this case (ENOTCONN).
These new counters are also verified in the MPTCP Join selftest in patch
6.
While at it, a few other patches are improving the MPTCP path-manager
code ...
- Patch 1: 'flush' related helpers are renamed to avoid confusions
- Patch 2: directly pass known ID and flags to create a new subflow,
i/o getting them later by iterating over all endpoints again
... and the MPJoin selftests:
- Patch 4: reduce the number of positional parameters
- Patch 5: only one line for the 'join' checks, instead of 3
- Patch 7: more explicit check names, instead of sometimes too cryptic
ones: rtx, ptx, ftx, ctx, fclzrx, sum
- Patch 8: specify client/server instead of 'invert' for some checks
not suggesting one specific direction
- Patch 9: mute errors of mptcp_connect when ran in the background
- Patch 10: simplify checksum_tests by using a for-loop
- Patch 11: remove 'define' re-definitions
Signed-off-by: Matthieu Baerts (NGI0) <matttbe(a)kernel.org>
---
Geliang Tang (1):
selftests: mptcp: join: simplify checksum_tests
Matthieu Baerts (NGI0) (10):
mptcp: pm: rename helpers linked to 'flush'
mptcp: pm: reduce entries iterations on connect
mptcp: MIB counters for sent MP_JOIN
selftests: mptcp: join: reduce join_nr params
selftests: mptcp: join: one line for join check
selftests: mptcp: join: validate MPJ SYN TX MIB counters
selftests: mptcp: join: more explicit check name
selftests: mptcp: join: specify host being checked
selftests: mptcp: join: mute errors when ran in the background
selftests: mptcp: pm_nl_ctl: remove re-definition
net/mptcp/mib.c | 4 +
net/mptcp/mib.h | 4 +
net/mptcp/pm.c | 11 -
net/mptcp/pm_netlink.c | 78 ++----
net/mptcp/pm_userspace.c | 40 +--
net/mptcp/protocol.h | 16 +-
net/mptcp/subflow.c | 50 +++-
tools/testing/selftests/net/mptcp/mptcp_join.sh | 350 ++++++++++++++----------
tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 10 +-
9 files changed, 309 insertions(+), 254 deletions(-)
---
base-commit: 221f9cce949ac8042f65b71ed1fde13b99073256
change-id: 20240902-net-next-mptcp-mib-mpjtx-misc-d80298438016
Best regards,
--
Matthieu Baerts (NGI0) <matttbe(a)kernel.org>