linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Raghav <p.raghav@samsung.com>
To: Minchan Kim <minchan@kernel.org>
Cc: <martin@omnibond.com>, <axboe@kernel.dk>,
	<akpm@linux-foundation.org>, <hubcap@omnibond.com>,
	<willy@infradead.org>, <viro@zeniv.linux.org.uk>,
	<senozhatsky@chromium.org>, <brauner@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	<mcgrof@kernel.org>, <linux-block@vger.kernel.org>,
	<gost.dev@samsung.com>, <linux-mm@kvack.org>,
	<devel@lists.orangefs.org>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 1/5] zram: remove the call to page_endio in the bio end_io handler
Date: Fri, 31 Mar 2023 13:19:49 +0200	[thread overview]
Message-ID: <3b116359-d346-a63c-1a78-f95ad1912dfe@samsung.com> (raw)
In-Reply-To: <ZCYSincU0FlULyWJ@google.com>

On 2023-03-31 00:51, Minchan Kim wrote:
> On Tue, Mar 28, 2023 at 01:27:12PM +0200, Pankaj Raghav wrote:
>> zram_page_end_io function is called when alloc_page is used (for
>> partial IO) to trigger writeback from the user space. The pages used for
> 
> No, it was used with zram_rw_page since rw_page didn't carry the bio.
> 
>> this operation is never locked or have the writeback set. So, it is safe
> 
> VM had the page lock and wait to unlock.
> 
>> to remove the call to page_endio() function that unlocks or marks
>> writeback end on the page.
>>
>> Rename the endio handler from zram_page_end_io to zram_read_end_io as
>> the call to page_endio() is removed and to associate the callback to the
>> operation it is used in.
> 

I revisited the code again. Let me know if I got it right.

When we trigger writeback, we will always call zram_bvec_read() only if
ZRAM_WB is not set. That means we will only call zram_read_from_zspool() in
__zram_bvec_read when parent bio set to NULL.

static ssize_t writeback_store(struct device *dev, ...
{
if (zram_test_flag(zram, index, ZRAM_WB) ||
                   zram_test_flag(zram, index, ZRAM_SAME) ||
                   zram_test_flag(zram, index, ZRAM_UNDER_WB))
           goto next;
...
if (zram_bvec_read(zram, &bvec, index, 0, NULL)) {
...
}

static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index,
			    struct bio *bio, bool partial_io)
{
....
if (!zram_test_flag(zram, index, ZRAM_WB)) {
        /* Slot should be locked through out the function call */
        ret = zram_read_from_zspool(zram, page, index);
        zram_slot_unlock(zram, index);
} else {
        /* Slot should be unlocked before the function call */
        zram_slot_unlock(zram, index);

        ret = zram_bvec_read_from_bdev(zram, page, index, bio,
                                       partial_io);
}
....
}

> Since zram removed the rw_page and IO comes with bio from now on,
> IIUC, we are fine since every IO will go with chained-IO. Right?
>

We will never call zram_bvec_read_from_bdev() with parent bio set to NULL. IOW, we will always
only hit the bio_chain case in read_from_bdev_async. So we could do the following?:

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index b7bb52f8dfbd..2341f4009b0f 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -606,15 +606,6 @@ static void free_block_bdev(struct zram *zram, unsigned long blk_idx)
 	atomic64_dec(&zram->stats.bd_count);
 }

-static void zram_page_end_io(struct bio *bio)
-{
-	struct page *page = bio_first_page_all(bio);
-
-	page_endio(page, op_is_write(bio_op(bio)),
-			blk_status_to_errno(bio->bi_status));
-	bio_put(bio);
-}
-
 /*
  * Returns 1 if the submission is successful.
  */
@@ -634,9 +625,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
 		return -EIO;
 	}

-	if (!parent)
-		bio->bi_end_io = zram_page_end_io;
-	else
+	if (parent)
 		bio_chain(bio, parent);

 	submit_bio(bio);


  parent reply	other threads:[~2023-03-31 11:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230328112717eucas1p2eb9395b7e3334c08aa28740b0af46fe9@eucas1p2.samsung.com>
2023-03-28 11:27 ` [PATCH 0/5] remove page_endio() Pankaj Raghav
     [not found]   ` <CGME20230328112718eucas1p214a859cfb3d7b45523356bcc16c373b1@eucas1p2.samsung.com>
2023-03-28 11:27     ` [PATCH 1/5] zram: remove the call to page_endio in the bio end_io handler Pankaj Raghav
2023-03-28 15:19       ` Matthew Wilcox
2023-03-28 16:17         ` Pankaj Raghav
2023-03-29 23:53           ` Christoph Hellwig
2023-03-30 22:51       ` Minchan Kim
2023-03-30 23:16         ` Christoph Hellwig
2023-03-31  1:42           ` Minchan Kim
2023-03-31 11:19         ` Pankaj Raghav [this message]
     [not found]   ` <CGME20230328112718eucas1p263dacecb2a59f5fce510f81685f9d497@eucas1p2.samsung.com>
2023-03-28 11:27     ` [PATCH 2/5] orangefs: use folios in orangefs_readahead Pankaj Raghav
2023-03-28 15:21       ` Matthew Wilcox
2023-03-28 16:02         ` Pankaj Raghav
2023-03-29 19:10           ` Mike Marshall
     [not found]   ` <CGME20230328112719eucas1p2b0f94ad7b06990203081d2b125dfc6ac@eucas1p2.samsung.com>
2023-03-28 11:27     ` [PATCH 3/5] mpage: split bi_end_io callback for reads and writes Pankaj Raghav
     [not found]   ` <CGME20230328112720eucas1p1148c03b8664f6c212c7189454a36b796@eucas1p1.samsung.com>
2023-03-28 11:27     ` [PATCH 4/5] mpage: use folios in bio end_io handler Pankaj Raghav
     [not found]   ` <CGME20230328112720eucas1p2bbb42b49da00b4f2299049bf6bafce48@eucas1p2.samsung.com>
2023-03-28 11:27     ` [PATCH 5/5] filemap: remove page_endio() Pankaj Raghav

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=3b116359-d346-a63c-1a78-f95ad1912dfe@samsung.com \
    --to=p.raghav@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=devel@lists.orangefs.org \
    --cc=gost.dev@samsung.com \
    --cc=hch@lst.de \
    --cc=hubcap@omnibond.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=martin@omnibond.com \
    --cc=mcgrof@kernel.org \
    --cc=minchan@kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox