aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorThomas Gschwantner <tharre3@gmail.com>2018-06-25 01:10:40 +0200
committerThomas Gschwantner <tharre3@gmail.com>2018-06-25 01:10:40 +0200
commit9ced23773059b0e96daba64dd12ac60327d0d14e (patch)
tree2ea12e126b5f3b5d22ad1348a7c5f994911daacd
parentBenchmark (diff)
downloadwireguard-monolithic-historical-9ced23773059b0e96daba64dd12ac60327d0d14e.tar.xz
wireguard-monolithic-historical-9ced23773059b0e96daba64dd12ac60327d0d14e.zip
Disable preemption in produce()
-rw-r--r--src/mpmc_ptr_ring.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mpmc_ptr_ring.h b/src/mpmc_ptr_ring.h
index 9e8b212..a4f8344 100644
--- a/src/mpmc_ptr_ring.h
+++ b/src/mpmc_ptr_ring.h
@@ -82,6 +82,7 @@ static inline int mpmc_ptr_ring_produce(struct mpmc_ptr_ring *r, void *ptr)
unsigned int mask = r->mask;
p = atomic_read(&r->producer_head);
+ preempt_disable();
for (;;) {
/*
@@ -104,8 +105,10 @@ static inline int mpmc_ptr_ring_produce(struct mpmc_ptr_ring *r, void *ptr)
smp_rmb();
new_p = atomic_read(&r->producer_head);
- if (new_p == p)
+ if (new_p == p) {
+ preempt_enable_no_resched();
return -ENOSPC;
+ }
p = new_p;
}
@@ -124,6 +127,7 @@ static inline int mpmc_ptr_ring_produce(struct mpmc_ptr_ring *r, void *ptr)
smp_wmb();
atomic_set(&r->producer_tail, p + 1);
+ preempt_enable_no_resched();
return 0;
}