Re: [PATCH] DM-CRYPT: Scale to multiple CPUs

From: Eric Dumazet
Date: Mon May 31 2010 - 12:57:24 EST


Le lundi 31 mai 2010 Ã 18:04 +0200, Andi Kleen a Ãcrit :
> DM-CRYPT: Scale to multiple CPUs
>
> Currently dm-crypt does all encryption work per dmcrypt mapping in a
> single workqueue. This does not scale well when multiple CPUs
> are submitting IO at a high rate. The single CPU running the single
> thread cannot keep up with the encryption and encrypted IO performance
> tanks.
>
> This patch changes the crypto workqueue to be per CPU. This means
> that as long as the IO submitter (or the interrupt target CPUs
> for reads) runs on different CPUs the encryption work will be also
> parallel.
>
> To avoid a bottleneck on the IO worker I also changed those to be
> per CPU threads.
>
> There is still some shared data, so I suspect some bouncing
> cache lines. But I haven't done a detailed study on that yet.
>
> All the threads are global, not per CPU. That is to avoid a thread
> explosion on systems with a large number of CPUs and a larger
> number of dm-crypt mappings. The code takes care to avoid problems
> with nested mappings.
>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>


> /*
> + * Duplicated per cpu state. Access through
> + * per_cpu_ptr() only.
> + */
> + struct crypt_cpu *cpu;
> +
> + /*
> * Layout of each crypto request:
> *

Since commit e0fdb0e050eae331, we have a __percpu annotation so that
sparse can be augmented. This would also make the comment unnecessary...


We also have this_cpu_ accessors

> + return per_cpu_ptr(cc->cpu, smp_processor_id());

this_cpu_ptr(cc->cpu)

and __thic_cpu_ptr() for the 'raw' version


> + __get_cpu_var(io_wq_cpu) = current;

this_cpu_write(io_wq_cpu, current)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/