RE: [PATCH 8/8] mm/zswap: Use local lock to protect per-CPU data

From: Song Bao Hua
Date: Tue May 19 2020 - 17:46:19 EST



> From: "Luis Claudio R. Goncalves" <lgoncalv@xxxxxxxxxx>

> zwap 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.

Hi Luis,
In the below patch, in order to use the acomp APIs to leverage the power of hardware compressors. I have moved to mutex:
https://marc.info/?l=linux-crypto-vger&m=158941285830302&w=2
https://marc.info/?l=linux-crypto-vger&m=158941287930311&w=2

so once we get some progress on that one, I guess we don't need a special patch for RT any more.

> [bigeasy: Use local_lock(), additional hunks, patch description]

> Cc: Seth Jennings <sjenning@xxxxxxxxxx>
> Cc: Dan Streetman <ddstreet@xxxxxxxx>
> Cc: Vitaly Wool <vitaly.wool@xxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: linux-mm@xxxxxxxxx
> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@xxxxxxxxxx>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
> mm/zswap.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)

Thanks
Barry