linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Minchan Kim <minchan@kernel.org>,
	Brian Geffon <bgeffon@google.com>, Jens Axboe <axboe@kernel.dk>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	linux-mm@kvack.org, Sergey Senozhatsky <senozhatsky@chromium.org>,
	Richard Chang <richardycc@google.com>,
	David Stevens <stevensd@google.com>
Subject: [PATCH] zram: drop slot trylock and miss_free
Date: Tue, 10 Feb 2026 12:50:37 +0900	[thread overview]
Message-ID: <20260210035045.3817297-1-senozhatsky@chromium.org> (raw)

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



             reply	other threads:[~2026-02-10  3:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10  3:50 Sergey Senozhatsky [this message]
2026-02-10  4:10 ` Sergey Senozhatsky
2026-02-10 14:29 ` Matthew Wilcox
2026-02-11  3:07   ` Sergey Senozhatsky

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=20260210035045.3817297-1-senozhatsky@chromium.org \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bgeffon@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=richardycc@google.com \
    --cc=stevensd@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox