tools/testing/selftests/bpf/libarena/selftests/test_spmc.bpf.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/libarena/selftests/test_spmc.bpf.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/libarena/selftests/test_spmc.bpf.c
Extension
.c
Size
3052 bytes
Lines
195
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ret) {
			arena_stderr("%s:%d error %d\n", __func__, __LINE__, ret);
			return 1;
		}
	}

	for (i = 0; i < 500 && can_loop; i++) {
		ret = spmc_owned_remove(spmc, &newval);
		if (ret) {
			arena_stderr("%s:%d error %d\n", __func__, __LINE__, ret);
			return 1;
		}

		expected = 500 - 1 - i;
		if (newval != expected) {
			arena_stderr("%s:%d expected %llu found %llu\n", __func__, __LINE__, expected, newval);
			return 1;
		}
	}

	spmc_destroy(spmc);

	return 0;
}

SEC("syscall")
int test_spmc_steal_many(void)
{
	u64 val, newval;
	int ret, i;

	struct spmc __arena *spmc = spmc_create();

	if (!spmc)
		return 1;

	for (i = 0; i < 500 && can_loop; i++) {
		val = i;

		ret = spmc_owned_add(spmc, val);
		if (ret) {
			arena_stderr("%s:%d error %d\n", __func__, __LINE__, ret);
			return 1;
		}
	}

	for (i = 0; i < 500 && can_loop; i++) {
		ret = spmc_steal(spmc, &newval);
		if (ret) {
			arena_stderr("%s:%d error %d\n", __func__, __LINE__, ret);
			return 1;
		}

		if (newval != i) {
			arena_stderr("%s:%d expected %d found %llu\n", __func__, __LINE__, i, newval);
			return 1;
		}
	}

	spmc_destroy(spmc);

	return 0;
}

Annotation

Implementation Notes