From c441326a37f5f8e1b237b475844206a8ca693f4d Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Fri, 15 Sep 2017 14:37:26 -0500 Subject: data: avoid running parallel/serial work on the same CPU --- src/data.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/data.c b/src/data.c index 000f035..f30b777 100644 --- a/src/data.c +++ b/src/data.c @@ -98,8 +98,15 @@ static inline bool queue_enqueue_per_peer(struct crypt_queue *queue, struct cryp static inline void queue_enqueue_per_device(struct crypt_queue __percpu *queue, struct crypt_ctx *ctx, struct workqueue_struct *wq, int *next_cpu) { + struct crypt_queue *cpu_queue; int cpu = cpumask_next_online(next_cpu); - struct crypt_queue *cpu_queue = per_cpu_ptr(queue, cpu); + /* Avoid running parallel work on the same CPU as the one handling all + * of the serial work. This improves overall throughput and especially + * throughput stability where we have at least two cores left for + * parallel work. */ + if (cpu == ctx->peer->serial_work_cpu && num_online_cpus() >= 3) + cpu = cpumask_next_online(next_cpu); + cpu_queue = per_cpu_ptr(queue, cpu); queue_enqueue(cpu_queue, &ctx->per_device_head, 0); queue_work_on(cpu, wq, &cpu_queue->work); } -- cgit v1.2.3-59-g8ed1b