Message ID | 20230717132602.2202147-2-zhangpeng362@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1125779vqt; Mon, 17 Jul 2023 06:55:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKArgR1HgwsCf0X1PJfc1hN2T9G+fN/DMITu+oUulc/AQr9S25oe1CTkJhOFeXplXzO+oV X-Received: by 2002:a17:907:96ac:b0:985:259f:6f50 with SMTP id hd44-20020a17090796ac00b00985259f6f50mr11857438ejc.34.1689602139052; Mon, 17 Jul 2023 06:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689602139; cv=none; d=google.com; s=arc-20160816; b=09mlohnjf9Xwnt4oKzubUPJYa2C4vcSy/1fgAKwvcYTnYcRBzeqjeMcX4nY+/gkMLf FEfaV5wvqeeHLju4IY/KaYk1I2pFaXxrKgx2wGmNgdwKFsYNp2ib40O++SQr4wOYf2PN 6JLuHSvQJnZKGEwj+MRsGooVP3aB3pV49L8Yorx0Zl1hDPfNqIgvgoFEJwIfeqqY2SnY gX5qDcvQc09uVUr9jUrxFhQBgVUvv3PQoNcBnjUIpi7/VSPfPbIg6lznUgbHJ2Bj3gYC w/OZmWL8xT2hEOGZj/xEYfU422VV4SLh35ZH9MUhkarxGGKbH/V+s+BiNlfN1JBx6ziL cRMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IYxz/hwKzYk9uuwe3O6nxmJnxJXAWQADQD0MlDZJ4Kw=; fh=VDvXH+NlXsy4uKRcyz6yvnpRC6UQTLJqNZtREhJ4J58=; b=jOlj2Jjql2N5F5tjk1hNF4xfhFJf2Hf0Vc4b6xP0ZfeGbgfMf1PaVZhe+7F51ptjo9 yp/ZH5ycXOBkvlax0gaoS37WyCcE6cE++NM9TD9zfXFo33hEkmhUturlkOCjjarbKUhm VsffipZL4dTNDNrmK0y+/C/AQeE2yOGOOsVinFs4F1dB9uCKwrbOl7OIHD/QskHpah0V 3omI9cjF1VnMhSeNa4uaNjjjF1h4og6INWT4h1vpblxYrhZT5x3KFG0jCwPDPlcgkUzt Pz27FzdoXzVBuzkqYuubX0gyF1bKs0MlQUrHFW09DbfBYkzd/OTpDr4gYQgOFEz5d/fW FdcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a1709062b0a00b00992a9b22b7fsi12905211ejg.668.2023.07.17.06.55.14; Mon, 17 Jul 2023 06:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231701AbjGQN1P (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Mon, 17 Jul 2023 09:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbjGQN07 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 09:26:59 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E186CC for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 06:26:37 -0700 (PDT) Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R4N9z6YCzzrRmJ; Mon, 17 Jul 2023 21:25:27 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 17 Jul 2023 21:26:09 +0800 From: Peng Zhang <zhangpeng362@huawei.com> To: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org> CC: <willy@infradead.org>, <sidhartha.kumar@oracle.com>, <akpm@linux-foundation.org>, <wangkefeng.wang@huawei.com>, <sunnanyong@huawei.com>, ZhangPeng <zhangpeng362@huawei.com> Subject: [PATCH 1/6] mm/page_io: use a folio in __end_swap_bio_read() Date: Mon, 17 Jul 2023 21:25:57 +0800 Message-ID: <20230717132602.2202147-2-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717132602.2202147-1-zhangpeng362@huawei.com> References: <20230717132602.2202147-1-zhangpeng362@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771676252228152299 X-GMAIL-MSGID: 1771676252228152299 |
Series |
Convert several functions in page_io.c to use a folio
|
|
Commit Message
zhangpeng (AS)
July 17, 2023, 1:25 p.m. UTC
From: ZhangPeng <zhangpeng362@huawei.com> Saves three implicit call to compound_head(). Signed-off-by: ZhangPeng <zhangpeng362@huawei.com> --- mm/page_io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Comments
On Mon, Jul 17, 2023 at 09:25:57PM +0800, Peng Zhang wrote: > +++ b/mm/page_io.c > @@ -58,18 +58,18 @@ static void end_swap_bio_write(struct bio *bio) > > static void __end_swap_bio_read(struct bio *bio) > { > - struct page *page = bio_first_page_all(bio); > + struct folio *folio = page_folio(bio_first_page_all(bio)); Should we have a bio_first_folio_all()? It wouldn't save any calls to compound_head(), but it's slightly easier to use. > if (bio->bi_status) { > - SetPageError(page); > - ClearPageUptodate(page); > + folio_set_error(folio); I appreciate this is a 1:1 conversion, but maybe we could think about this a bit. Is there anybody who checks the PageError()/folio_test_error() for this page/folio? > + folio_clear_uptodate(folio); Similarly ... surely the folio is already !uptodate, so we don't need to clear the flag?
On 2023/7/17 21:34, Matthew Wilcox wrote: > On Mon, Jul 17, 2023 at 09:25:57PM +0800, Peng Zhang wrote: >> +++ b/mm/page_io.c >> @@ -58,18 +58,18 @@ static void end_swap_bio_write(struct bio *bio) >> >> static void __end_swap_bio_read(struct bio *bio) >> { >> - struct page *page = bio_first_page_all(bio); >> + struct folio *folio = page_folio(bio_first_page_all(bio)); > Should we have a bio_first_folio_all()? It wouldn't save any calls to > compound_head(), but it's slightly easier to use. Yes, I'll convert bio_first_page_all() to bio_first_folio_all() in a v2. Thanks. >> if (bio->bi_status) { >> - SetPageError(page); >> - ClearPageUptodate(page); >> + folio_set_error(folio); > I appreciate this is a 1:1 conversion, but maybe we could think about > this a bit. Is there anybody who checks the > PageError()/folio_test_error() for this page/folio? Maybe wait_dev_supers() checks the PageError() after write_dev_supers() in fs/btrfs/disk-io.c? >> + folio_clear_uptodate(folio); > Similarly ... surely the folio is already !uptodate, so we don't need to > clear the flag? Indeed, the folio is already !uptodate. I'll drop this line in a v2. Thanks for your feedback.
On Tue, Jul 18, 2023 at 08:56:16PM +0800, zhangpeng (AS) wrote: > > > if (bio->bi_status) { > > > - SetPageError(page); > > > - ClearPageUptodate(page); > > > + folio_set_error(folio); > > I appreciate this is a 1:1 conversion, but maybe we could think about > > this a bit. Is there anybody who checks the > > PageError()/folio_test_error() for this page/folio? > > Maybe wait_dev_supers() checks the PageError() after write_dev_supers() > in fs/btrfs/disk-io.c? How does _this_ folio end up in btrfs's write_dev_supers()? This is a swap read. The only folios which are swapped are anonymous and tmpfs. btrfs takes care of doing its own I/O. wait_dev_supers() is looking for the error set in btrfs_end_super_write() which is the completion routine for write_dev_supers(). The pages involved there are attached to a btrfs address_space, not shmem or anon.
On 2023/7/19 0:16, Matthew Wilcox wrote: > On Tue, Jul 18, 2023 at 08:56:16PM +0800, zhangpeng (AS) wrote: >>>> if (bio->bi_status) { >>>> - SetPageError(page); >>>> - ClearPageUptodate(page); >>>> + folio_set_error(folio); >>> I appreciate this is a 1:1 conversion, but maybe we could think about >>> this a bit. Is there anybody who checks the >>> PageError()/folio_test_error() for this page/folio? >> Maybe wait_dev_supers() checks the PageError() after write_dev_supers() >> in fs/btrfs/disk-io.c? > How does _this_ folio end up in btrfs's write_dev_supers()? This is a > swap read. The only folios which are swapped are anonymous and tmpfs. > btrfs takes care of doing its own I/O. wait_dev_supers() is looking > for the error set in btrfs_end_super_write() which is the completion > routine for write_dev_supers(). The pages involved there are attached > to a btrfs address_space, not shmem or anon. Thanks for your explanation! Then I think nobody checks the PageError()/folio_test_error() for the page in patch 1 and patch 2. I'll delete SetPageError() in a v2.
On Tue, Jul 18, 2023 at 05:16:15PM +0100, Matthew Wilcox wrote: > How does _this_ folio end up in btrfs's write_dev_supers()? This is a > swap read. The only folios which are swapped are anonymous and tmpfs. > btrfs takes care of doing its own I/O. wait_dev_supers() is looking > for the error set in btrfs_end_super_write() which is the completion > routine for write_dev_supers(). The pages involved there are attached > to a btrfs address_space, not shmem or anon. It actually operates on the block_device inode. That does not matter for this series, but complicates things in other ways.
diff --git a/mm/page_io.c b/mm/page_io.c index 684cd3c7b59b..ebf431e5f538 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -58,18 +58,18 @@ static void end_swap_bio_write(struct bio *bio) static void __end_swap_bio_read(struct bio *bio) { - struct page *page = bio_first_page_all(bio); + struct folio *folio = page_folio(bio_first_page_all(bio)); if (bio->bi_status) { - SetPageError(page); - ClearPageUptodate(page); + folio_set_error(folio); + folio_clear_uptodate(folio); pr_alert_ratelimited("Read-error on swap-device (%u:%u:%llu)\n", MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)), (unsigned long long)bio->bi_iter.bi_sector); } else { - SetPageUptodate(page); + folio_mark_uptodate(folio); } - unlock_page(page); + folio_unlock(folio); } static void end_swap_bio_read(struct bio *bio)