Message ID | 20230717132602.2202147-1-zhangpeng362@huawei.com |
---|---|
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 j3csp1125104vqt; Mon, 17 Jul 2023 06:54:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEpjFV9G6j2d5mfvJz+70d3rNvgk52o5q/E/9FmFeAoe59PF0JXoxD1nZDjv+cYwsr3o9+h X-Received: by 2002:a2e:8944:0:b0:2b6:c61c:745b with SMTP id b4-20020a2e8944000000b002b6c61c745bmr8958853ljk.3.1689602047209; Mon, 17 Jul 2023 06:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689602047; cv=none; d=google.com; s=arc-20160816; b=xJxpHG9YU3WisWUwAmZ+28OS1Ks8lwRLXESRDASS+H8p9stFjHUybkH2IVMG9BvoUg 6pR7PdStXzfSi0O/FKnJVHu7VbD1zeS1LmmUTD9fJpm0WS3FTPh0c3rzdiFAf/4hCcHu SVTEJkFsMk8zvGEhf4H29pdjCPZm6WxeassDZXTlZW2V9y3DHz/mlA4qdY6xDq3fLsyW o73rxxpK161Aw6776/DPdZs9I4zWLejCxGHzkToVbYFH4TmJxRWQfVyXhO0r5azm6nVb r7W6yxY3wujBw/zx/RKeomCNA2Ov7hWmWcYrEICwRsVc3axUD46OW2fsck5nmHv3eIj5 zegQ== 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 :message-id:date:subject:cc:to:from; bh=TqXSVbMQWrvzVAqoOB+QsQGKd4OulUArvQxhXkJTJyw=; fh=VDvXH+NlXsy4uKRcyz6yvnpRC6UQTLJqNZtREhJ4J58=; b=Ib7gA41U7J8AcyJK0Xgftet56A5i1hu/YgTCLXKWGPfa1PUYGscptO0DT3OMF3HBYz a/jv1eC7xSg5O9M+bcrAcppwC9kzgjTlpUikZaufS3cRzWp4w6+tb5etU5BATiz1fWji idR5/L9DYIIW3c0XqeWl6mCGJrH4wSNWsKP/4V970p5MKkmBJ6iNDSemwDnIFs3IQ0iy K1VZJ7QJc/R8o0gwOpTIHqQTRSDBErgzRAyQ5YpI1Gt7ZW5GcyVelNIUQh0Z40j7xPsR k/bB6Dx/SqRDm8goT+AikEKlrLJ4CPnXFMfQvd1MyLuCpa7NEyUQRyaruGoJ5lYRlOB2 qr7w== 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 u21-20020a170906951500b00991f4e7f49asi12936975ejx.215.2023.07.17.06.53.42; Mon, 17 Jul 2023 06:54:07 -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 S231239AbjGQN1h (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Mon, 17 Jul 2023 09:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231348AbjGQN1B (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 09:27:01 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD42BD7 for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 06:26:41 -0700 (PDT) Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R4N9D3pmtzVjj6; Mon, 17 Jul 2023 21:24:48 +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:08 +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 0/6] Convert several functions in page_io.c to use a folio Date: Mon, 17 Jul 2023 21:25:56 +0800 Message-ID: <20230717132602.2202147-1-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 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: 1771676156282749734 X-GMAIL-MSGID: 1771676156282749734 |
Series |
Convert several functions in page_io.c to use a folio
|
|
Message
zhangpeng (AS)
July 17, 2023, 1:25 p.m. UTC
From: ZhangPeng <zhangpeng362@huawei.com>
This patch series converts several functions in page_io.c to use a
folio, which can remove several implicit calls to compound_head().
ZhangPeng (6):
mm/page_io: use a folio in __end_swap_bio_read()
mm/page_io: use a folio in sio_read_complete()
mm/page_io: use a folio in swap_writepage_bdev_sync()
mm/page_io: use a folio in swap_writepage_bdev_async()
mm/page_io: convert count_swpout_vm_event() to take in a folio
mm/page_io: convert bio_associate_blkg_from_page() to take in a folio
mm/page_io.c | 56 +++++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 27 deletions(-)
Comments
On Mon, Jul 17, 2023 at 09:25:58PM +0800, Peng Zhang wrote: > +++ b/mm/page_io.c > @@ -406,19 +406,19 @@ static void sio_read_complete(struct kiocb *iocb, long ret) > > if (ret == sio->len) { > for (p = 0; p < sio->pages; p++) { > - struct page *page = sio->bvec[p].bv_page; > + struct folio *folio = page_folio(sio->bvec[p].bv_page); > > - SetPageUptodate(page); > - unlock_page(page); > + folio_mark_uptodate(folio); > + folio_unlock(folio); > } I'm kind of shocked this works today. Usually bvecs coalesce adjacent pages into a single entry, so you need to use a real iterator like bio_for_each_folio_all() to extract individual pages from a bvec. Maybe the sio bvec is constructed inefficiently. I think Kent had some bvec folio iterators in progress? > count_vm_events(PSWPIN, sio->pages); > } else { > for (p = 0; p < sio->pages; p++) { > - struct page *page = sio->bvec[p].bv_page; > + struct folio *folio = page_folio(sio->bvec[p].bv_page); > > - SetPageError(page); > - ClearPageUptodate(page); > - unlock_page(page); > + folio_set_error(folio); > + folio_clear_uptodate(folio); > + folio_unlock(folio); Similar questions to the last patch -- who checks the error flag on this page/folio, and isn't the folio already !uptodate? > } > pr_alert_ratelimited("Read-error on swap-device\n"); > } > -- > 2.25.1 >
On Mon, Jul 17, 2023 at 09:26:01PM +0800, Peng Zhang wrote: > -static inline void count_swpout_vm_event(struct page *page) > +static inline void count_swpout_vm_event(struct folio *folio) > { > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > - if (unlikely(PageTransHuge(page))) > + if (unlikely(folio_test_large(folio))) > count_vm_event(THP_SWPOUT); > #endif Since this is a THP_SWPOUT event, we should do this as: -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (unlikely(PageTransHuge(page))) + if (folio_test_pmd_mappable(folio)) count_vm_event(THP_SWPOUT); -#endif
On Mon, Jul 17, 2023 at 09:26:00PM +0800, Peng Zhang wrote: > From: ZhangPeng <zhangpeng362@huawei.com> > > Saves one implicit call to compound_head(). > > Signed-off-by: ZhangPeng <zhangpeng362@huawei.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>