Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Fix uprobe consumer test (again)

The new uprobe changes bring some new behaviour that we need to reflect
in the consumer test. Now pending uprobe instance in the kernel can
survive longer and thus might call uretprobe consumer callbacks in
some situations in which, previously, such callback would be omitted.
We now need to take that into account in uprobe-multi consumer tests.

The idea being that uretprobe under test either stayed from before to
after (uret_stays + test_bit) or uretprobe instance survived and we
have uretprobe active in after (uret_survives + test_bit).

uret_survives just states that uretprobe survives if there are *any*
uretprobes both before and after (overlapping or not, doesn't matter)
and uprobe was attached before.

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241107094337.3848210-1-jolsa@kernel.org

authored by

Jiri Olsa and committed by
Andrii Nakryiko
dcf04676 5249b164

+8 -6
+8 -6
tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
··· 869 869 fmt = "prog 0/1: uprobe"; 870 870 } else { 871 871 /* 872 - * to trigger uretprobe consumer, the uretprobe needs to be installed, 873 - * which means one of the 'return' uprobes was alive when probe was hit: 874 - * 875 - * idxs: 2/3 uprobe return in 'installed' mask 872 + * To trigger uretprobe consumer, the uretprobe under test either stayed from 873 + * before to after (uret_stays + test_bit) or uretprobe instance survived and 874 + * we have uretprobe active in after (uret_survives + test_bit) 876 875 */ 877 - unsigned long had_uretprobes = before & 0b1100; /* is uretprobe installed */ 878 876 879 - if (had_uretprobes && test_bit(idx, after)) 877 + bool uret_stays = before & after & 0b1100; 878 + bool uret_survives = (before & 0b1100) && (after & 0b1100) && (before & 0b0011); 879 + 880 + if ((uret_stays || uret_survives) && test_bit(idx, after)) 880 881 val++; 882 + 881 883 fmt = "idx 2/3: uretprobe"; 882 884 } 883 885