linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] zram: drop slot trylock and miss_free
@ 2026-02-10  3:50 Sergey Senozhatsky
  2026-02-10  4:10 ` Sergey Senozhatsky
  2026-02-10 14:29 ` Matthew Wilcox
  0 siblings, 2 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2026-02-10  3:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Minchan Kim, Brian Geffon, Jens Axboe, linux-kernel, linux-block,
	linux-mm, Sergey Senozhatsky, Richard Chang, David Stevens

Commit e914d8f00391 ("mm: fix unexpected zeroed page
mapping with zram swap") removed swap_slot_free_notify()
calls from end_io callbacks.  This means that there is
no more slot_free_notify() from IRQ context and hence
slot-free cannot deadlock on slot lock any more.  Drop
slot trylock.

Suggested-by: Richard Chang <richardycc@google.com>
Suggested-by: David Stevens <stevensd@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 drivers/block/zram/zram_drv.c | 34 +++-------------------------------
 drivers/block/zram/zram_drv.h |  1 -
 2 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 61d3e2c74901..c2894023c0cd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -74,23 +74,7 @@ static void slot_lock_init(struct zram *zram, u32 index)
  * 2) lock() function can sleep waiting for the lock
  *
  * 3) Lock owner can sleep
- *
- * 4) Use TRY lock variant when in atomic context
- *    - must check return value and handle locking failers
  */
-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_);
-		return true;
-	}
-
-	return false;
-}
-
 static void slot_lock(struct zram *zram, u32 index)
 {
 	unsigned long *lock = &zram->table[index].__lock;
@@ -1943,15 +1927,9 @@ static ssize_t debug_stat_show(struct device *dev,
 {
 	int version = 1;
 	struct zram *zram = dev_to_zram(dev);
-	ssize_t ret;
 
 	guard(rwsem_read)(&zram->dev_lock);
-	ret = sysfs_emit(buf,
-			"version: %d\n0 %8llu\n",
-			version,
-			(u64)atomic64_read(&zram->stats.miss_free));
-
-	return ret;
+	return sysfs_emit(buf, "version: %d\n0 0\n", version);
 }
 
 static void zram_meta_free(struct zram *zram, u64 disksize)
@@ -2814,16 +2792,10 @@ static void zram_submit_bio(struct bio *bio)
 static void zram_slot_free_notify(struct block_device *bdev,
 				unsigned long index)
 {
-	struct zram *zram;
-
-	zram = bdev->bd_disk->private_data;
+	struct zram *zram = bdev->bd_disk->private_data;
 
 	atomic64_inc(&zram->stats.notify_free);
-	if (!slot_trylock(zram, index)) {
-		atomic64_inc(&zram->stats.miss_free);
-		return;
-	}
-
+	slot_lock(zram, index);
 	slot_free(zram, index);
 	slot_unlock(zram, index);
 }
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 515a72d9c06f..d90d9b6c9575 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -87,7 +87,6 @@ struct zram_stats {
 	atomic64_t huge_pages_since;	/* no. of huge pages since zram set up */
 	atomic64_t pages_stored;	/* no. of pages currently stored */
 	atomic_long_t max_used_pages;	/* no. of maximum pages stored */
-	atomic64_t miss_free;		/* no. of missed free */
 #ifdef	CONFIG_ZRAM_WRITEBACK
 	atomic64_t bd_count;		/* no. of pages in backing device */
 	atomic64_t bd_reads;		/* no. of reads from backing device */
-- 
2.53.0.239.g8d8fc8a987-goog



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-11  3:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-10  3:50 [PATCH] zram: drop slot trylock and miss_free Sergey Senozhatsky
2026-02-10  4:10 ` Sergey Senozhatsky
2026-02-10 14:29 ` Matthew Wilcox
2026-02-11  3:07   ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox