Skip to content

Commit

Permalink
selftests/bpf: revert iter test subprog precision workaround
Browse files Browse the repository at this point in the history
Now that precision propagation is supported fully in the presence of
subprogs, there is no need to work around iter test. Revert original
workaround.

This reverts be7dbd2 ("selftests/bpf: avoid mark_all_scalars_precise() trigger in one of iter tests").

Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
anakryiko authored and Alexei Starovoitov committed May 5, 2023
1 parent 3ef3d21 commit c91ab90
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions tools/testing/selftests/bpf/progs/iters.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,29 +651,25 @@ int iter_stack_array_loop(const void *ctx)
return sum;
}

#define ARR_SZ 16

static __noinline void fill(struct bpf_iter_num *it, int *arr, int mul)
static __noinline void fill(struct bpf_iter_num *it, int *arr, __u32 n, int mul)
{
int *t;
__u64 i;
int *t, i;

while ((t = bpf_iter_num_next(it))) {
i = *t;
if (i >= ARR_SZ)
if (i >= n)
break;
arr[i] = i * mul;
}
}

static __noinline int sum(struct bpf_iter_num *it, int *arr)
static __noinline int sum(struct bpf_iter_num *it, int *arr, __u32 n)
{
int *t, sum = 0;;
__u64 i;
int *t, i, sum = 0;;

while ((t = bpf_iter_num_next(it))) {
i = *t;
if (i >= ARR_SZ)
if (i >= n)
break;
sum += arr[i];
}
Expand All @@ -685,7 +681,7 @@ SEC("raw_tp")
__success
int iter_pass_iter_ptr_to_subprog(const void *ctx)
{
int arr1[ARR_SZ], arr2[ARR_SZ];
int arr1[16], arr2[32];
struct bpf_iter_num it;
int n, sum1, sum2;

Expand All @@ -694,25 +690,25 @@ int iter_pass_iter_ptr_to_subprog(const void *ctx)
/* fill arr1 */
n = ARRAY_SIZE(arr1);
bpf_iter_num_new(&it, 0, n);
fill(&it, arr1, 2);
fill(&it, arr1, n, 2);
bpf_iter_num_destroy(&it);

/* fill arr2 */
n = ARRAY_SIZE(arr2);
bpf_iter_num_new(&it, 0, n);
fill(&it, arr2, 10);
fill(&it, arr2, n, 10);
bpf_iter_num_destroy(&it);

/* sum arr1 */
n = ARRAY_SIZE(arr1);
bpf_iter_num_new(&it, 0, n);
sum1 = sum(&it, arr1);
sum1 = sum(&it, arr1, n);
bpf_iter_num_destroy(&it);

/* sum arr2 */
n = ARRAY_SIZE(arr2);
bpf_iter_num_new(&it, 0, n);
sum2 = sum(&it, arr2);
sum2 = sum(&it, arr2, n);
bpf_iter_num_destroy(&it);

bpf_printk("sum1=%d, sum2=%d", sum1, sum2);
Expand Down

0 comments on commit c91ab90

Please sign in to comment.