Re: [PATCH v2 7/7] zram: Use local lock to protect per-CPU data

From: Ingo Molnar
Date: Mon May 25 2020 - 03:26:54 EST



* Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote:

> --- a/drivers/block/zram/zcomp.h
> +++ b/drivers/block/zram/zcomp.h
> @@ -5,11 +5,13 @@
>
> #ifndef _ZCOMP_H_
> #define _ZCOMP_H_
> +#include <linux/locallock.h>
>
> struct zcomp_strm {
> /* compression/decompression buffer */
> void *buffer;
> struct crypto_comp *tfm;
> + struct local_lock lock;
> };

I believe the general pattern is to put the lock in front of the
fields it protects.

I'd also add a comment documenting that both fields ->buffer and ->tfm
are protected by the lock.

Thanks,

Ingo