diff options
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | 2018-05-31 17:36:30 +0200 |
---|---|---|
committer | Thomas Gschwantner <tharre3@gmail.com> | 2018-06-22 14:52:22 +0200 |
commit | 5859eb15a640dc43edc24683479d9efc843c2ce3 (patch) | |
tree | 2ca60cf3a0fe553f9786d9528f8563fc606dbcae | |
parent | mpmc_ptr_ring: Place producer_head and producer_tail in the same cacheline (diff) | |
download | wireguard-monolithic-historical-5859eb15a640dc43edc24683479d9efc843c2ce3.tar.xz wireguard-monolithic-historical-5859eb15a640dc43edc24683479d9efc843c2ce3.zip |
messages: Ensure that there are more queue slots than CPUs
I'm not completely sure about this.
It also doesn't fix all the errors: sometimes the test suite reports
that it fails to send packets.
-rw-r--r-- | src/messages.h | 7 | ||||
-rw-r--r-- | src/mpmc_ptr_ring.h | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/messages.h b/src/messages.h index f3d47ef..e68ce2e 100644 --- a/src/messages.h +++ b/src/messages.h @@ -52,7 +52,12 @@ enum limits { MAX_TIMER_HANDSHAKES = (90 * HZ) / REKEY_TIMEOUT, MAX_QUEUED_INCOMING_HANDSHAKES = 4096, /* TODO: replace this with DQL */ MAX_STAGED_PACKETS = 128, - MAX_QUEUED_PACKETS = 1024 /* TODO: replace this with DQL */ + /* TODO: replace this with DQL */ + MAX_QUEUED_PACKETS_DEFAULT = 1024, + /* The lock-free MPMC queue implementation requires that there are more queue slots than consumers*/ + MAX_QUEUED_PACKETS = (MAX_QUEUED_PACKETS_DEFAULT > CONFIG_NR_CPUS)? + MAX_QUEUED_PACKETS_DEFAULT : + roundup_pow_of_two(CONFIG_NR_CPUS + 1), }; enum message_type { diff --git a/src/mpmc_ptr_ring.h b/src/mpmc_ptr_ring.h index 8c9c28c..267d10d 100644 --- a/src/mpmc_ptr_ring.h +++ b/src/mpmc_ptr_ring.h @@ -134,6 +134,9 @@ static inline void *mpmc_ptr_ring_consume(struct mpmc_ptr_ring *r) return element; } +/* + * Warning: size must be greater than the number of concurrent consumers + */ static inline int mpmc_ptr_ring_init(struct mpmc_ptr_ring *r, int size, gfp_t gfp) { if (WARN_ONCE(!is_power_of_2(size), "size must be a power of two")) |