From: YoungJun Park <youngjun.park@lge.com>
To: Jianyue Wu <wujianyue000@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christoph Hellwig <hch@lst.de>, Chris Li <chrisl@kernel.org>,
Baoquan He <bhe@redhat.com>, Nhat Pham <nphamcs@gmail.com>,
Barry Song <baohua@kernel.org>, Kairui Song <kasong@tencent.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Jens Axboe <axboe@kernel.dk>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Jan Kara <jack@suse.cz>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-block@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH 2/3] mm/zram: handle swap read/write via swap_ops
Date: Mon, 15 Jun 2026 15:39:23 +0900 [thread overview]
Message-ID: <ai+eG9sFYTn/vTq5@yjaykim-PowerEdge-T330> (raw)
In-Reply-To: <20260614-zram-swap-ops-block-register-v1-2-6c1a6639c222@gmail.com>
On Sun, Jun 14, 2026 at 11:35:30PM +0800, Jianyue Wu wrote:
Hello!
> +static void zram_swap_submit_read(struct swap_io_ctx *ctx)
> +{
> + struct zram *zram = ctx->sis->bdev->bd_disk->private_data;
A passing thought. accessing `zram` here is too indirect. We might
need a `private_data` in the swap device struct someday?
(And If there is a real value like some swap-side only private data really needed.)
> + struct swap_iocb *sio = ctx->sio;
> + int nr = swap_iocb_nr_folios(sio);
> + bool failed = false;
> + int i, j;
> + /*
> + * read_from_zspool() and mark_slot_accessed() must run
> + * under the same slot_lock. zram_read_page() unlocks
> + * before returning, which leaves a window where
> + * writeback can pick an idle slot we just read.
> + */
Regarding the comment about the "window" where writeback can pick an
idle slot. I think this reasoning is a bit of a gray area. Writeback
could just as easily pick the slot right before entering this routine,
so the race condition seems fundamentally the same.
Isn't the actual justification here to separate the non-backend logic
and ensure mark_slot_accessed() is called under the lock, given that
zram_read_page() can call the backend device?
If the "window" mentioned in the comment is indeed a valid issue, then
zram_read_page() has the exact same problem and needs to be fixed as
well?
If not, IMHO I suggest revising or removing this comment to clarify
the true(?) intention. :)
> + slot_lock(zram, idx);
> + ret = read_from_zspool(zram, page, idx);
> + if (!ret)
> + mark_slot_accessed(zram, idx);
> + slot_unlock(zram, idx);
next prev parent reply other threads:[~2026-06-15 6:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 15:35 [PATCH 0/3] mm/zram: route block swap I/O through swap_ops Jianyue Wu
2026-06-14 15:35 ` [PATCH 1/3] mm/page_io: let block drivers register custom swap I/O ops Jianyue Wu
2026-06-15 1:50 ` YoungJun Park
2026-06-15 12:49 ` Jianyue Wu
2026-06-14 15:35 ` [PATCH 2/3] mm/zram: handle swap read/write via swap_ops Jianyue Wu
2026-06-15 6:39 ` YoungJun Park [this message]
2026-06-15 13:19 ` Jianyue Wu
2026-06-14 15:35 ` [PATCH 3/3] mm/swap: route slot free notifications through swap_ops Jianyue Wu
2026-06-15 9:14 ` [PATCH 0/3] mm/zram: route block swap I/O " Barry Song
2026-06-15 13:34 ` Jianyue Wu
2026-06-16 12:36 ` Christoph Hellwig
2026-06-17 3:38 ` Jianyue Wu
2026-06-17 3:46 ` Sergey Senozhatsky
2026-06-17 5:44 ` Jianyue Wu
2026-06-17 6:10 ` Sergey Senozhatsky
2026-06-17 6:19 ` Christoph Hellwig
2026-06-17 6:17 ` Christoph Hellwig
2026-06-17 14:01 ` Jianyue Wu
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=ai+eG9sFYTn/vTq5@yjaykim-PowerEdge-T330 \
--to=youngjun.park@lge.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--cc=chrisl@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=kasong@tencent.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=shikemeng@huaweicloud.com \
--cc=willy@infradead.org \
--cc=wujianyue000@gmail.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
all inboxes | Powered by JetHome®