Commit c91ab90c authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov
Browse files

selftests/bpf: revert iter test subprog precision workaround



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 be7dbd27 ("selftests/bpf: avoid mark_all_scalars_precise() trigger in one of iter tests").

Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20230505043317.3629845-11-andrii@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 3ef3d217
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -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];
	}
@@ -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;

@@ -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);