All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/10] Convert several functions in page_io.c to use a folio
@ 2023-07-21  3:44 Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 01/10] mm/page_io: remove unneeded ClearPageUptodate() Peng Zhang
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

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().

Changelog:

v4:
- add THP ifdefs per kernel test robot (patch 9)

v3:
- introduce bio_first_folio_all(), rather than replacing
  bio_first_page_all() per Matthew (patch 3)
- use a folio in __end_swap_bio_write() (patch 4)
- remove unneeded ifdefs per Matthew (patch 9)

v2:
- remove unneeded ClearPageUptodate() and SetPageError(), suggested by
  Matthew Wilcox
- convert bio_first_page_all() to bio_first_folio_all(), suggested by
  Matthew Wilcox
- convert PageTransHuge to folio_test_pmd_mappable per Matthew Wilcox

ZhangPeng (10):
  mm/page_io: remove unneeded ClearPageUptodate()
  mm/page_io: remove unneeded SetPageError()
  mm/page_io: introduce bio_first_folio_all()
  mm/page_io: use a folio in __end_swap_bio_write()
  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

 Documentation/block/biovecs.rst |  1 +
 include/linux/bio.h             |  5 +++
 mm/page_io.c                    | 61 ++++++++++++++++-----------------
 3 files changed, 35 insertions(+), 32 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v4 01/10] mm/page_io: remove unneeded ClearPageUptodate()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 02/10] mm/page_io: remove unneeded SetPageError() Peng Zhang
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

The VM_BUG_ON_FOLIO in swap_readpage() ensures that the page is already
!uptodate in __end_swap_bio_read() and sio_read_complete().
Just remove unneeded ClearPageUptodate().

Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/page_io.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 8741d3a0d48a..3087a69a014b 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -62,7 +62,6 @@ static void __end_swap_bio_read(struct bio *bio)
 
 	if (bio->bi_status) {
 		SetPageError(page);
-		ClearPageUptodate(page);
 		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);
@@ -417,7 +416,6 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
 			struct page *page = sio->bvec[p].bv_page;
 
 			SetPageError(page);
-			ClearPageUptodate(page);
 			unlock_page(page);
 		}
 		pr_alert_ratelimited("Read-error on swap-device\n");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 02/10] mm/page_io: remove unneeded SetPageError()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 01/10] mm/page_io: remove unneeded ClearPageUptodate() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 03/10] mm/page_io: introduce bio_first_folio_all() Peng Zhang
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Nobody checks the PageError()/folio_test_error() for the page/folio in
__end_swap_bio_read/write() and sio_write_complete(). Therefore, we
don't need to set the error flag. Just drop it.

Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/page_io.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 3087a69a014b..5ddb5d9c5013 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -32,7 +32,6 @@ static void __end_swap_bio_write(struct bio *bio)
 	struct page *page = bio_first_page_all(bio);
 
 	if (bio->bi_status) {
-		SetPageError(page);
 		/*
 		 * We failed to write the page out to swap-space.
 		 * Re-dirty the page in order to avoid it being reclaimed.
@@ -61,7 +60,6 @@ static void __end_swap_bio_read(struct bio *bio)
 	struct page *page = bio_first_page_all(bio);
 
 	if (bio->bi_status) {
-		SetPageError(page);
 		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);
@@ -415,7 +413,6 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
 		for (p = 0; p < sio->pages; p++) {
 			struct page *page = sio->bvec[p].bv_page;
 
-			SetPageError(page);
 			unlock_page(page);
 		}
 		pr_alert_ratelimited("Read-error on swap-device\n");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 03/10] mm/page_io: introduce bio_first_folio_all()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 01/10] mm/page_io: remove unneeded ClearPageUptodate() Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 02/10] mm/page_io: remove unneeded SetPageError() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 04/10] mm/page_io: use a folio in __end_swap_bio_write() Peng Zhang
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Introduce bio_first_folio_all() to return a folio, which makes it easier
to use.

Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 Documentation/block/biovecs.rst | 1 +
 include/linux/bio.h             | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/block/biovecs.rst b/Documentation/block/biovecs.rst
index ddb867e0185b..b9dc0c9dbee4 100644
--- a/Documentation/block/biovecs.rst
+++ b/Documentation/block/biovecs.rst
@@ -134,6 +134,7 @@ Usage of helpers:
 	bio_for_each_bvec_all()
 	bio_first_bvec_all()
 	bio_first_page_all()
+	bio_first_folio_all()
 	bio_last_bvec_all()
 
 * The following helpers iterate over single-page segment. The passed 'struct
diff --git a/include/linux/bio.h b/include/linux/bio.h
index c4f5b5228105..027ff9ab5d12 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -253,6 +253,11 @@ static inline struct page *bio_first_page_all(struct bio *bio)
 	return bio_first_bvec_all(bio)->bv_page;
 }
 
+static inline struct folio *bio_first_folio_all(struct bio *bio)
+{
+	return page_folio(bio_first_page_all(bio));
+}
+
 static inline struct bio_vec *bio_last_bvec_all(struct bio *bio)
 {
 	WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 04/10] mm/page_io: use a folio in __end_swap_bio_write()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (2 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 03/10] mm/page_io: introduce bio_first_folio_all() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 05/10] mm/page_io: use a folio in __end_swap_bio_read() Peng Zhang
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Saves two implicit call to compound_head().

Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/page_io.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 5ddb5d9c5013..d9f5fa5b7281 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -29,7 +29,7 @@
 
 static void __end_swap_bio_write(struct bio *bio)
 {
-	struct page *page = bio_first_page_all(bio);
+	struct folio *folio = bio_first_folio_all(bio);
 
 	if (bio->bi_status) {
 		/*
@@ -40,13 +40,13 @@ static void __end_swap_bio_write(struct bio *bio)
 		 *
 		 * Also clear PG_reclaim to avoid folio_rotate_reclaimable()
 		 */
-		set_page_dirty(page);
+		folio_mark_dirty(folio);
 		pr_alert_ratelimited("Write-error on swap-device (%u:%u:%llu)\n",
 				     MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
 				     (unsigned long long)bio->bi_iter.bi_sector);
-		ClearPageReclaim(page);
+		folio_clear_reclaim(folio);
 	}
-	end_page_writeback(page);
+	folio_end_writeback(folio);
 }
 
 static void end_swap_bio_write(struct bio *bio)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 05/10] mm/page_io: use a folio in __end_swap_bio_read()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (3 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 04/10] mm/page_io: use a folio in __end_swap_bio_write() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 06/10] mm/page_io: use a folio in sio_read_complete() Peng Zhang
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Saves one implicit call to compound_head().

Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/page_io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index d9f5fa5b7281..3b97289153f9 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -57,16 +57,16 @@ 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 = bio_first_folio_all(bio);
 
 	if (bio->bi_status) {
 		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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 06/10] mm/page_io: use a folio in sio_read_complete()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (4 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 05/10] mm/page_io: use a folio in __end_swap_bio_read() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 07/10] mm/page_io: use a folio in swap_writepage_bdev_sync() Peng Zhang
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Saves one implicit call to compound_head().

Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/page_io.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 3b97289153f9..7e7a9f67b9ad 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -403,17 +403,17 @@ 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);
 		}
 		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);
 
-			unlock_page(page);
+			folio_unlock(folio);
 		}
 		pr_alert_ratelimited("Read-error on swap-device\n");
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 07/10] mm/page_io: use a folio in swap_writepage_bdev_sync()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (5 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 06/10] mm/page_io: use a folio in sio_read_complete() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 08/10] mm/page_io: use a folio in swap_writepage_bdev_async() Peng Zhang
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

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>
---
 mm/page_io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 7e7a9f67b9ad..9df2a85e31b1 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -331,6 +331,7 @@ static void swap_writepage_bdev_sync(struct page *page,
 {
 	struct bio_vec bv;
 	struct bio bio;
+	struct folio *folio = page_folio(page);
 
 	bio_init(&bio, sis->bdev, &bv, 1,
 		 REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc));
@@ -340,8 +341,8 @@ static void swap_writepage_bdev_sync(struct page *page,
 	bio_associate_blkg_from_page(&bio, page);
 	count_swpout_vm_event(page);
 
-	set_page_writeback(page);
-	unlock_page(page);
+	folio_start_writeback(folio);
+	folio_unlock(folio);
 
 	submit_bio_wait(&bio);
 	__end_swap_bio_write(&bio);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 08/10] mm/page_io: use a folio in swap_writepage_bdev_async()
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (6 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 07/10] mm/page_io: use a folio in swap_writepage_bdev_sync() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 09/10] mm/page_io: convert count_swpout_vm_event() to take in a folio Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 10/10] mm/page_io: convert bio_associate_blkg_from_page() " Peng Zhang
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

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>
---
 mm/page_io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 9df2a85e31b1..07bad3a4b701 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -352,6 +352,7 @@ static void swap_writepage_bdev_async(struct page *page,
 		struct writeback_control *wbc, struct swap_info_struct *sis)
 {
 	struct bio *bio;
+	struct folio *folio = page_folio(page);
 
 	bio = bio_alloc(sis->bdev, 1,
 			REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc),
@@ -362,8 +363,8 @@ static void swap_writepage_bdev_async(struct page *page,
 
 	bio_associate_blkg_from_page(bio, page);
 	count_swpout_vm_event(page);
-	set_page_writeback(page);
-	unlock_page(page);
+	folio_start_writeback(folio);
+	folio_unlock(folio);
 	submit_bio(bio);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 09/10] mm/page_io: convert count_swpout_vm_event() to take in a folio
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (7 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 08/10] mm/page_io: use a folio in swap_writepage_bdev_async() Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  2023-07-21  3:44 ` [PATCH v4 10/10] mm/page_io: convert bio_associate_blkg_from_page() " Peng Zhang
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Convert count_swpout_vm_event() to take in a folio. We can remove five
implicit calls to compound_head() by taking in a folio.

Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
 mm/page_io.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 07bad3a4b701..f575c0bf545e 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -205,13 +205,13 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
 	return 0;
 }
 
-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_pmd_mappable(folio)))
 		count_vm_event(THP_SWPOUT);
 #endif
-	count_vm_events(PSWPOUT, thp_nr_pages(page));
+	count_vm_events(PSWPOUT, folio_nr_pages(folio));
 }
 
 #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
@@ -280,7 +280,7 @@ static void sio_write_complete(struct kiocb *iocb, long ret)
 		}
 	} else {
 		for (p = 0; p < sio->pages; p++)
-			count_swpout_vm_event(sio->bvec[p].bv_page);
+			count_swpout_vm_event(page_folio(sio->bvec[p].bv_page));
 	}
 
 	for (p = 0; p < sio->pages; p++)
@@ -339,7 +339,7 @@ static void swap_writepage_bdev_sync(struct page *page,
 	__bio_add_page(&bio, page, thp_size(page), 0);
 
 	bio_associate_blkg_from_page(&bio, page);
-	count_swpout_vm_event(page);
+	count_swpout_vm_event(folio);
 
 	folio_start_writeback(folio);
 	folio_unlock(folio);
@@ -362,7 +362,7 @@ static void swap_writepage_bdev_async(struct page *page,
 	__bio_add_page(bio, page, thp_size(page), 0);
 
 	bio_associate_blkg_from_page(bio, page);
-	count_swpout_vm_event(page);
+	count_swpout_vm_event(folio);
 	folio_start_writeback(folio);
 	folio_unlock(folio);
 	submit_bio(bio);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4 10/10] mm/page_io: convert bio_associate_blkg_from_page() to take in a folio
  2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
                   ` (8 preceding siblings ...)
  2023-07-21  3:44 ` [PATCH v4 09/10] mm/page_io: convert count_swpout_vm_event() to take in a folio Peng Zhang
@ 2023-07-21  3:44 ` Peng Zhang
  9 siblings, 0 replies; 11+ messages in thread
From: Peng Zhang @ 2023-07-21  3:44 UTC (permalink / raw)
  To: linux-mm, linux-kernel, willy
  Cc: hch, sidhartha.kumar, akpm, wangkefeng.wang, sunnanyong, ZhangPeng

From: ZhangPeng <zhangpeng362@huawei.com>

Convert bio_associate_blkg_from_page() to take in a folio. We can remove
two implicit calls to compound_head() by taking in a folio.

Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/page_io.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index f575c0bf545e..fe4c21af23f2 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -215,12 +215,12 @@ static inline void count_swpout_vm_event(struct folio *folio)
 }
 
 #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
-static void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
+static void bio_associate_blkg_from_page(struct bio *bio, struct folio *folio)
 {
 	struct cgroup_subsys_state *css;
 	struct mem_cgroup *memcg;
 
-	memcg = page_memcg(page);
+	memcg = folio_memcg(folio);
 	if (!memcg)
 		return;
 
@@ -230,7 +230,7 @@ static void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
 	rcu_read_unlock();
 }
 #else
-#define bio_associate_blkg_from_page(bio, page)		do { } while (0)
+#define bio_associate_blkg_from_page(bio, folio)		do { } while (0)
 #endif /* CONFIG_MEMCG && CONFIG_BLK_CGROUP */
 
 struct swap_iocb {
@@ -338,7 +338,7 @@ static void swap_writepage_bdev_sync(struct page *page,
 	bio.bi_iter.bi_sector = swap_page_sector(page);
 	__bio_add_page(&bio, page, thp_size(page), 0);
 
-	bio_associate_blkg_from_page(&bio, page);
+	bio_associate_blkg_from_page(&bio, folio);
 	count_swpout_vm_event(folio);
 
 	folio_start_writeback(folio);
@@ -361,7 +361,7 @@ static void swap_writepage_bdev_async(struct page *page,
 	bio->bi_end_io = end_swap_bio_write;
 	__bio_add_page(bio, page, thp_size(page), 0);
 
-	bio_associate_blkg_from_page(bio, page);
+	bio_associate_blkg_from_page(bio, folio);
 	count_swpout_vm_event(folio);
 	folio_start_writeback(folio);
 	folio_unlock(folio);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-21  3:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21  3:44 [PATCH v4 00/10] Convert several functions in page_io.c to use a folio Peng Zhang
2023-07-21  3:44 ` [PATCH v4 01/10] mm/page_io: remove unneeded ClearPageUptodate() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 02/10] mm/page_io: remove unneeded SetPageError() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 03/10] mm/page_io: introduce bio_first_folio_all() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 04/10] mm/page_io: use a folio in __end_swap_bio_write() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 05/10] mm/page_io: use a folio in __end_swap_bio_read() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 06/10] mm/page_io: use a folio in sio_read_complete() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 07/10] mm/page_io: use a folio in swap_writepage_bdev_sync() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 08/10] mm/page_io: use a folio in swap_writepage_bdev_async() Peng Zhang
2023-07-21  3:44 ` [PATCH v4 09/10] mm/page_io: convert count_swpout_vm_event() to take in a folio Peng Zhang
2023-07-21  3:44 ` [PATCH v4 10/10] mm/page_io: convert bio_associate_blkg_from_page() " Peng Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.