Re: [PATCH 2/2] zram: Use a custom key for each zram object.

From: Sergey Senozhatsky

Date: Thu Jul 23 2026 - 23:25:19 EST


Hello, sorry for the delay

On (26/07/14 16:13), Sebastian Andrzej Siewior wrote:
> Each struct zram uses the same key for its struct lockdep_map which is
> used for locking analysis.
> According to Sergey the lock chains might be different if zram1 is used
> for and zram2 is for ext4. This might lead to false dead lock reports if

^^ swap (a minor nit)

> it mixes a zram1 chain with a zram2. This can be avoided if each lockmap
> gets its own unique key.c
>
> Use a dynamic lock_class_key for the table_lock_map.
>

[..]

> static bool zram_meta_alloc(struct zram *zram, u64 disksize)
> @@ -1999,7 +1993,8 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
> if (!huge_class_size)
> huge_class_size = zs_huge_class_size(zram->mem_pool);
>
> - slot_lock_init(zram);
> + lockdep_register_key(&zram->table_lock_key);
> + lockdep_init_map(&zram->table_lock_map, "zram->table[index].lock", &zram->table_lock_key, 0);

So I wonder if we can give distinct name, given that it's per-device
now: "zram%d->table[index].lock" and use zram->disk->first_minor (which
is a unique device id).

If you are too busy I can just send a trivial follow up patch.
Let me know what you prefer.


Reviewed-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
Tested-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>