Commit 970308a7 authored by Hou Tao's avatar Hou Tao Committed by Alexei Starovoitov
Browse files

selftests/bpf: Set the default value of consumer_cnt as 0



Considering that only bench_ringbufs.c supports consumer, just set the
default value of consumer_cnt as 0. After that, update the validity
check of consumer_cnt, remove unused consumer_thread code snippets and
set consumer_cnt as 1 in run_bench_ringbufs.sh accordingly.

Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20230613080921.1623219-5-houtao@huaweicloud.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent da77ae2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ struct env env = {
	.duration_sec = 5,
	.affinity = false,
	.quiet = false,
	.consumer_cnt = 1,
	.consumer_cnt = 0,
	.producer_cnt = 1,
};

+2 −12
Original line number Diff line number Diff line
@@ -107,9 +107,9 @@ const struct argp bench_bloom_map_argp = {

static void validate(void)
{
	if (env.consumer_cnt != 1) {
	if (env.consumer_cnt != 0) {
		fprintf(stderr,
			"The bloom filter benchmarks do not support multi-consumer use\n");
			"The bloom filter benchmarks do not support consumer\n");
		exit(1);
	}
}
@@ -421,18 +421,12 @@ static void measure(struct bench_res *res)
	last_false_hits = total_false_hits;
}

static void *consumer(void *input)
{
	return NULL;
}

const struct bench bench_bloom_lookup = {
	.name = "bloom-lookup",
	.argp = &bench_bloom_map_argp,
	.validate = validate,
	.setup = bloom_lookup_setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = hits_drops_report_progress,
	.report_final = hits_drops_report_final,
@@ -444,7 +438,6 @@ const struct bench bench_bloom_update = {
	.validate = validate,
	.setup = bloom_update_setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = hits_drops_report_progress,
	.report_final = hits_drops_report_final,
@@ -456,7 +449,6 @@ const struct bench bench_bloom_false_positive = {
	.validate = validate,
	.setup = false_positive_setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = false_hits_report_progress,
	.report_final = false_hits_report_final,
@@ -468,7 +460,6 @@ const struct bench bench_hashmap_without_bloom = {
	.validate = validate,
	.setup = hashmap_no_bloom_setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = hits_drops_report_progress,
	.report_final = hits_drops_report_final,
@@ -480,7 +471,6 @@ const struct bench bench_hashmap_with_bloom = {
	.validate = validate,
	.setup = hashmap_with_bloom_setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = hits_drops_report_progress,
	.report_final = hits_drops_report_final,
+2 −8
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ static struct ctx {

static void validate(void)
{
	if (env.consumer_cnt != 1) {
		fprintf(stderr, "benchmark doesn't support multi-consumer!\n");
	if (env.consumer_cnt != 0) {
		fprintf(stderr, "benchmark doesn't support consumer!\n");
		exit(1);
	}
}
@@ -30,11 +30,6 @@ static void *producer(void *input)
	return NULL;
}

static void *consumer(void *input)
{
	return NULL;
}

static void measure(struct bench_res *res)
{
}
@@ -88,7 +83,6 @@ const struct bench bench_bpf_hashmap_full_update = {
	.validate = validate,
	.setup = setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = NULL,
	.report_final = hashmap_report_final,
+2 −8
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ const struct argp bench_hashmap_lookup_argp = {

static void validate(void)
{
	if (env.consumer_cnt != 1) {
		fprintf(stderr, "benchmark doesn't support multi-consumer!\n");
	if (env.consumer_cnt != 0) {
		fprintf(stderr, "benchmark doesn't support consumer!\n");
		exit(1);
	}

@@ -134,11 +134,6 @@ static void *producer(void *input)
	return NULL;
}

static void *consumer(void *input)
{
	return NULL;
}

static void measure(struct bench_res *res)
{
}
@@ -276,7 +271,6 @@ const struct bench bench_bpf_hashmap_lookup = {
	.validate = validate,
	.setup = setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = NULL,
	.report_final = hashmap_report_final,
+2 −8
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ const struct argp bench_bpf_loop_argp = {

static void validate(void)
{
	if (env.consumer_cnt != 1) {
		fprintf(stderr, "benchmark doesn't support multi-consumer!\n");
	if (env.consumer_cnt != 0) {
		fprintf(stderr, "benchmark doesn't support consumer!\n");
		exit(1);
	}
}
@@ -62,11 +62,6 @@ static void *producer(void *input)
	return NULL;
}

static void *consumer(void *input)
{
	return NULL;
}

static void measure(struct bench_res *res)
{
	res->hits = atomic_swap(&ctx.skel->bss->hits, 0);
@@ -99,7 +94,6 @@ const struct bench bench_bpf_loop = {
	.validate = validate,
	.setup = setup,
	.producer_thread = producer,
	.consumer_thread = consumer,
	.measure = measure,
	.report_progress = ops_report_progress,
	.report_final = ops_report_final,
Loading