aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorThomas Gschwantner <tharre3@gmail.com>2018-07-04 23:11:26 +0200
committerThomas Gschwantner <tharre3@gmail.com>2018-07-04 23:11:40 +0200
commit6f909b2abc055ecb17dbf4d80f93e2ed84b264d5 (patch)
treeec991ebb4a2d1c675c2e927bd4c032a518453171
parentDisable preemption in produce() (diff)
downloadWireGuard-tg/mpmc-benchmark.tar.xz
WireGuard-tg/mpmc-benchmark.zip
uint64_t and need_resched()tg/mpmc-benchmark
-rw-r--r--src/selftest/mpmc_ring.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/selftest/mpmc_ring.h b/src/selftest/mpmc_ring.h
index 624ce22..f9666d2 100644
--- a/src/selftest/mpmc_ring.h
+++ b/src/selftest/mpmc_ring.h
@@ -30,8 +30,8 @@ struct worker_producer {
struct worker_consumer {
struct work_struct work;
int thread_num;
- long total;
- long count;
+ uint64_t total;
+ uint64_t count;
};
static __init void producer_function(struct work_struct *work)
@@ -41,7 +41,8 @@ static __init void producer_function(struct work_struct *work)
for (; count <= (td->thread_num + 1) * PER_PRODUCER; ++count) {
while (mpmc_ptr_ring_produce(ring, (void *) count))
- schedule();
+ if (need_resched())
+ schedule();
}
}
@@ -54,7 +55,8 @@ static __init void consumer_function(struct work_struct *work)
uintptr_t value;
while (!(value = (uintptr_t) mpmc_ptr_ring_consume(ring)))
- schedule();
+ if (need_resched())
+ schedule();
td->total += value;
++(td->count);
@@ -113,8 +115,8 @@ bool __init mpmc_ring_selftest(void)
}
pr_info("mpmc_ring self-test failed:");
- pr_info("Count: %lu, expected: %lu", count, ELEMENT_COUNT);
- pr_info("Total: %lu, expected: %lu", total, EXPECTED_TOTAL);
+ pr_info("Count: %llu, expected: %llu", count, ELEMENT_COUNT);
+ pr_info("Total: %llu, expected: %llu", total, EXPECTED_TOTAL);
return false;
}