zram: Use local lock to protect per-CPU data
authorMike Galbraith <umgwanakikbuti@gmail.com>
Wed, 27 May 2020 20:11:19 +0000 (22:11 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 28 May 2020 08:31:10 +0000 (10:31 +0200)
commit19f545b6e07f753c4dc639c2f0ab52345733b6a8
tree0280ea9f67d39a48f67716bf9fdf4d3554c93cf4
parented19f19256be2949af1ab5634e62178d30a355c2
zram: Use local lock to protect per-CPU data

The zcomp driver uses per-CPU compression. The per-CPU data pointer is
acquired with get_cpu_ptr() which implicitly disables preemption.
It allocates memory inside the preempt disabled region which conflicts
with the PREEMPT_RT semantics.

Replace the implicit preemption control with an explicit local lock.
This allows RT kernels to substitute it with a real per CPU lock, which
serializes the access but keeps the code section preemptible. On non RT
kernels this maps to preempt_disable() as before, i.e. no functional
change.

[bigeasy: Use local_lock(), description, drop reordering]

Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20200527201119.1692513-8-bigeasy@linutronix.de
drivers/block/zram/zcomp.c
drivers/block/zram/zcomp.h