mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 04:03:23 -04:00
zram: use a custom key for each zram object
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 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. Link: https://lore.kernel.org/20260714141300.3945672-3-bigeasy@linutronix.de Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Tested-by: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Minchan Kim <minchan@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
dbb7ba9c7f
commit
d56a82aa87
@@ -58,13 +58,6 @@ static const struct block_device_operations zram_devops;
|
||||
|
||||
static void slot_free(struct zram *zram, u32 index);
|
||||
|
||||
static void slot_lock_init(struct zram *zram)
|
||||
{
|
||||
static struct lock_class_key __key;
|
||||
|
||||
lockdep_init_map(&zram->table_lock_map, "zram->table[index].lock", &__key, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* entry locking rules:
|
||||
*
|
||||
@@ -1978,6 +1971,7 @@ static void zram_meta_free(struct zram *zram, u64 disksize)
|
||||
zs_destroy_pool(zram->mem_pool);
|
||||
vfree(zram->table);
|
||||
zram->table = NULL;
|
||||
lockdep_unregister_key(&zram->table_lock_key);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ struct zram_stats {
|
||||
struct zram {
|
||||
struct zram_table_entry *table;
|
||||
struct lockdep_map table_lock_map;
|
||||
struct lock_class_key table_lock_key;
|
||||
struct zs_pool *mem_pool;
|
||||
struct zcomp *comps[ZRAM_MAX_COMPS];
|
||||
struct zcomp_params params[ZRAM_MAX_COMPS];
|
||||
|
||||
Reference in New Issue
Block a user