From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Jens Axboe <axboe@kernel.dk>, Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 7.2.y 1/2] zram: move lockmap to be per-zram instead per table
Date: Fri, 4 Sep 2026 14:49:49 -0400 [thread overview]
Message-ID: <20260904184950.1353771-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090337-onshore-thermos-9127@gregkh>
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
[ Upstream commit dbb7ba9c7fa81a48ed2a108ad684cf3655f3ae4b ]
Patch series "zram: lockmap tweaks".
This patch (of 2):
The zram object contains an array zram_table_entry. Each one has a `lock'
variable and each has a matching struct lockdep_map. This mimics a struct
mutex.
It uses always the same key for all lockdep_map instances. This makes it
look like the same lock to lockdep. Therefore it could be reduced to have
one lockdep_map per struct zram.
Use only one struct lockdep_map per struct zram.
Link: https://lore.kernel.org/20260714141300.3945672-1-bigeasy@linutronix.de
Link: https://lore.kernel.org/20260714141300.3945672-2-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>
Stable-dep-of: a8b5875741d4 ("zram: fix slot lock bit position on big-endian 64-bit")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/block/zram/zram_drv.c | 21 +++++++++------------
drivers/block/zram/zram_drv.h | 2 +-
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index ace65c586072b..4223002d80b41 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -57,14 +57,12 @@ static size_t huge_class_size;
static const struct block_device_operations zram_devops;
static void slot_free(struct zram *zram, u32 index);
-#define slot_dep_map(zram, index) (&(zram)->table[(index)].dep_map)
-static void slot_lock_init(struct zram *zram, u32 index)
+static void slot_lock_init(struct zram *zram)
{
static struct lock_class_key __key;
- lockdep_init_map(slot_dep_map(zram, index), "zram->table[index].lock",
- &__key, 0);
+ lockdep_init_map(&zram->table_lock_map, "zram->table[index].lock", &__key, 0);
}
/*
@@ -84,8 +82,8 @@ static __must_check bool slot_trylock(struct zram *zram, u32 index)
unsigned long *lock = &zram->table[index].__lock;
if (!test_and_set_bit_lock(ZRAM_ENTRY_LOCK, lock)) {
- mutex_acquire(slot_dep_map(zram, index), 0, 1, _RET_IP_);
- lock_acquired(slot_dep_map(zram, index), _RET_IP_);
+ mutex_acquire(&zram->table_lock_map, 0, 1, _RET_IP_);
+ lock_acquired(&zram->table_lock_map, _RET_IP_);
return true;
}
@@ -96,16 +94,16 @@ static void slot_lock(struct zram *zram, u32 index)
{
unsigned long *lock = &zram->table[index].__lock;
- mutex_acquire(slot_dep_map(zram, index), 0, 0, _RET_IP_);
+ mutex_acquire(&zram->table_lock_map, 0, 0, _RET_IP_);
wait_on_bit_lock(lock, ZRAM_ENTRY_LOCK, TASK_UNINTERRUPTIBLE);
- lock_acquired(slot_dep_map(zram, index), _RET_IP_);
+ lock_acquired(&zram->table_lock_map, _RET_IP_);
}
static void slot_unlock(struct zram *zram, u32 index)
{
unsigned long *lock = &zram->table[index].__lock;
- mutex_release(slot_dep_map(zram, index), _RET_IP_);
+ mutex_release(&zram->table_lock_map, _RET_IP_);
clear_and_wake_up_bit(ZRAM_ENTRY_LOCK, lock);
}
@@ -1984,7 +1982,7 @@ static void zram_meta_free(struct zram *zram, u64 disksize)
static bool zram_meta_alloc(struct zram *zram, u64 disksize)
{
- size_t num_pages, index;
+ size_t num_pages;
num_pages = disksize >> PAGE_SHIFT;
zram->table = vzalloc(array_size(num_pages, sizeof(*zram->table)));
@@ -2001,8 +1999,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
if (!huge_class_size)
huge_class_size = zs_huge_class_size(zram->mem_pool);
- for (index = 0; index < num_pages; index++)
- slot_lock_init(zram, index);
+ slot_lock_init(zram);
return true;
}
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 08d1774c15db6..8290dc6e23352 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -74,7 +74,6 @@ struct zram_table_entry {
#endif
} attr;
};
- struct lockdep_map dep_map;
};
struct zram_stats {
@@ -107,6 +106,7 @@ struct zram_stats {
struct zram {
struct zram_table_entry *table;
+ struct lockdep_map table_lock_map;
struct zs_pool *mem_pool;
struct zcomp *comps[ZRAM_MAX_COMPS];
struct zcomp_params params[ZRAM_MAX_COMPS];
--
2.53.0
next prev parent reply other threads:[~2026-09-04 18:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 13:01 FAILED: patch "[PATCH] zram: fix slot lock bit position on big-endian 64-bit" failed to apply to 7.2-stable tree gregkh
2026-09-04 18:49 ` Sasha Levin [this message]
2026-09-04 18:49 ` [PATCH 7.2.y 2/2] zram: fix slot lock bit position on big-endian 64-bit Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904184950.1353771-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bigeasy@linutronix.de \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.