Skip to content

Commit 1ddb9ad

Browse files
kkdwivediAlexei Starovoitov
authored andcommitted
selftests/bpf: Make res_spin_lock AA test condition stronger
Let's make sure that we see a EDEADLK and ETIMEDOUT whenever checking for the AA tests (in case of simple AA and AA after exhausting 31 entries). Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7bbb38f commit 1ddb9ad

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/testing/selftests/bpf/progs/res_spin_lock.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ int res_spin_lock_test(struct __sk_buff *ctx)
3838
r = bpf_res_spin_lock(&elem1->lock);
3939
if (r)
4040
return r;
41-
if (!bpf_res_spin_lock(&elem2->lock)) {
41+
r = bpf_res_spin_lock(&elem2->lock);
42+
if (!r) {
4243
bpf_res_spin_unlock(&elem2->lock);
4344
bpf_res_spin_unlock(&elem1->lock);
4445
return -1;
4546
}
4647
bpf_res_spin_unlock(&elem1->lock);
47-
return 0;
48+
return r != -EDEADLK;
4849
}
4950

5051
SEC("tc")
@@ -124,12 +125,15 @@ int res_spin_lock_test_held_lock_max(struct __sk_buff *ctx)
124125
/* Trigger AA, after exhausting entries in the held lock table. This
125126
* time, only the timeout can save us, as AA detection won't succeed.
126127
*/
127-
if (!bpf_res_spin_lock(locks[34])) {
128+
ret = bpf_res_spin_lock(locks[34]);
129+
if (!ret) {
128130
bpf_res_spin_unlock(locks[34]);
129131
ret = 1;
130132
goto end;
131133
}
132134

135+
ret = ret != -ETIMEDOUT ? 2 : 0;
136+
133137
end:
134138
for (i = i - 1; i >= 0; i--)
135139
bpf_res_spin_unlock(locks[i]);

0 commit comments

Comments
 (0)