* [PATCH v5] mm/page_io: rename swap_iocb fields for clarity
@ 2026-04-02 7:26 David Carlier
2026-04-02 7:29 ` David Hildenbrand (Arm)
2026-04-02 18:32 ` Chris Li
0 siblings, 2 replies; 3+ messages in thread
From: David Carlier @ 2026-04-02 7:26 UTC (permalink / raw)
To: David Hildenbrand, Kairui Song, Chris Li, Andrew Morton,
Kemeng Shi, Nhat Pham, Baoquan He, Youngjun Park, NeilBrown
Cc: linux-kernel, linux-mm, David Carlier, Matthew Wilcox (Oracle),
David Hildenbrand
swap_iocb->pages tracks the number of bvec entries (folios), not base
pages. Rename the array from bvec to bvecs and the counter from pages
to nr_bvecs to accurately reflect their purpose.
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: David Carlier <devnexen@gmail.com>
---
mm/page_io.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/mm/page_io.c b/mm/page_io.c
index 1389cd57ca88..18ff6f559cbd 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -326,8 +326,8 @@ static void bio_associate_blkg_from_page(struct bio *bio, struct folio *folio)
struct swap_iocb {
struct kiocb iocb;
- struct bio_vec bvec[SWAP_CLUSTER_MAX];
- int pages;
+ struct bio_vec bvecs[SWAP_CLUSTER_MAX];
+ int nr_bvecs;
int len;
};
static mempool_t *sio_pool;
@@ -348,7 +348,7 @@ int sio_pool_init(void)
static void sio_write_complete(struct kiocb *iocb, long ret)
{
struct swap_iocb *sio = container_of(iocb, struct swap_iocb, iocb);
- struct page *page = sio->bvec[0].bv_page;
+ struct page *page = sio->bvecs[0].bv_page;
int p;
if (ret != sio->len) {
@@ -362,15 +362,15 @@ static void sio_write_complete(struct kiocb *iocb, long ret)
*/
pr_err_ratelimited("Write error %ld on dio swapfile (%llu)\n",
ret, swap_dev_pos(page_swap_entry(page)));
- for (p = 0; p < sio->pages; p++) {
- page = sio->bvec[p].bv_page;
+ for (p = 0; p < sio->nr_bvecs; p++) {
+ page = sio->bvecs[p].bv_page;
set_page_dirty(page);
ClearPageReclaim(page);
}
}
- for (p = 0; p < sio->pages; p++)
- end_page_writeback(sio->bvec[p].bv_page);
+ for (p = 0; p < sio->nr_bvecs; p++)
+ end_page_writeback(sio->bvecs[p].bv_page);
mempool_free(sio, sio_pool);
}
@@ -397,13 +397,13 @@ static void swap_writepage_fs(struct folio *folio, struct swap_iocb **swap_plug)
init_sync_kiocb(&sio->iocb, swap_file);
sio->iocb.ki_complete = sio_write_complete;
sio->iocb.ki_pos = pos;
- sio->pages = 0;
+ sio->nr_bvecs = 0;
sio->len = 0;
}
- bvec_set_folio(&sio->bvec[sio->pages], folio, folio_size(folio), 0);
+ bvec_set_folio(&sio->bvecs[sio->nr_bvecs], folio, folio_size(folio), 0);
sio->len += folio_size(folio);
- sio->pages += 1;
- if (sio->pages == ARRAY_SIZE(sio->bvec) || !swap_plug) {
+ sio->nr_bvecs += 1;
+ if (sio->nr_bvecs == ARRAY_SIZE(sio->bvecs) || !swap_plug) {
swap_write_unplug(sio);
sio = NULL;
}
@@ -477,7 +477,7 @@ void swap_write_unplug(struct swap_iocb *sio)
struct address_space *mapping = sio->iocb.ki_filp->f_mapping;
int ret;
- iov_iter_bvec(&from, ITER_SOURCE, sio->bvec, sio->pages, sio->len);
+ iov_iter_bvec(&from, ITER_SOURCE, sio->bvecs, sio->nr_bvecs, sio->len);
ret = mapping->a_ops->swap_rw(&sio->iocb, &from);
if (ret != -EIOCBQUEUED)
sio_write_complete(&sio->iocb, ret);
@@ -489,8 +489,8 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
int p;
if (ret == sio->len) {
- for (p = 0; p < sio->pages; p++) {
- struct folio *folio = page_folio(sio->bvec[p].bv_page);
+ for (p = 0; p < sio->nr_bvecs; p++) {
+ struct folio *folio = page_folio(sio->bvecs[p].bv_page);
count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN);
count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
@@ -499,8 +499,8 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
}
count_vm_events(PSWPIN, sio->len >> PAGE_SHIFT);
} else {
- for (p = 0; p < sio->pages; p++) {
- struct folio *folio = page_folio(sio->bvec[p].bv_page);
+ for (p = 0; p < sio->nr_bvecs; p++) {
+ struct folio *folio = page_folio(sio->bvecs[p].bv_page);
folio_unlock(folio);
}
@@ -559,13 +559,13 @@ static void swap_read_folio_fs(struct folio *folio, struct swap_iocb **plug)
init_sync_kiocb(&sio->iocb, sis->swap_file);
sio->iocb.ki_pos = pos;
sio->iocb.ki_complete = sio_read_complete;
- sio->pages = 0;
+ sio->nr_bvecs = 0;
sio->len = 0;
}
- bvec_set_folio(&sio->bvec[sio->pages], folio, folio_size(folio), 0);
+ bvec_set_folio(&sio->bvecs[sio->nr_bvecs], folio, folio_size(folio), 0);
sio->len += folio_size(folio);
- sio->pages += 1;
- if (sio->pages == ARRAY_SIZE(sio->bvec) || !plug) {
+ sio->nr_bvecs += 1;
+ if (sio->nr_bvecs == ARRAY_SIZE(sio->bvecs) || !plug) {
swap_read_unplug(sio);
sio = NULL;
}
@@ -666,7 +666,7 @@ void __swap_read_unplug(struct swap_iocb *sio)
struct address_space *mapping = sio->iocb.ki_filp->f_mapping;
int ret;
- iov_iter_bvec(&from, ITER_DEST, sio->bvec, sio->pages, sio->len);
+ iov_iter_bvec(&from, ITER_DEST, sio->bvecs, sio->nr_bvecs, sio->len);
ret = mapping->a_ops->swap_rw(&sio->iocb, &from);
if (ret != -EIOCBQUEUED)
sio_read_complete(&sio->iocb, ret);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5] mm/page_io: rename swap_iocb fields for clarity
2026-04-02 7:26 [PATCH v5] mm/page_io: rename swap_iocb fields for clarity David Carlier
@ 2026-04-02 7:29 ` David Hildenbrand (Arm)
2026-04-02 18:32 ` Chris Li
1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand (Arm) @ 2026-04-02 7:29 UTC (permalink / raw)
To: David Carlier, Kairui Song, Chris Li, Andrew Morton, Kemeng Shi,
Nhat Pham, Baoquan He, Youngjun Park, NeilBrown
Cc: linux-kernel, linux-mm, Matthew Wilcox (Oracle)
On 4/2/26 09:26, David Carlier wrote:
> swap_iocb->pages tracks the number of bvec entries (folios), not base
> pages. Rename the array from bvec to bvecs and the counter from pages
> to nr_bvecs to accurately reflect their purpose.
>
> Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
Thanks!
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5] mm/page_io: rename swap_iocb fields for clarity
2026-04-02 7:26 [PATCH v5] mm/page_io: rename swap_iocb fields for clarity David Carlier
2026-04-02 7:29 ` David Hildenbrand (Arm)
@ 2026-04-02 18:32 ` Chris Li
1 sibling, 0 replies; 3+ messages in thread
From: Chris Li @ 2026-04-02 18:32 UTC (permalink / raw)
To: David Carlier
Cc: David Hildenbrand, Kairui Song, Andrew Morton, Kemeng Shi,
Nhat Pham, Baoquan He, Youngjun Park, NeilBrown, linux-kernel,
linux-mm, Matthew Wilcox (Oracle), David Hildenbrand
On Thu, Apr 2, 2026 at 12:27 AM David Carlier <devnexen@gmail.com> wrote:
>
> swap_iocb->pages tracks the number of bvec entries (folios), not base
> pages. Rename the array from bvec to bvecs and the counter from pages
> to nr_bvecs to accurately reflect their purpose.
>
> Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: David Carlier <devnexen@gmail.com>
Thank you.
Acked-by: Chris Li <chrisl@kernel.org>
Chris
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-02 18:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 7:26 [PATCH v5] mm/page_io: rename swap_iocb fields for clarity David Carlier
2026-04-02 7:29 ` David Hildenbrand (Arm)
2026-04-02 18:32 ` Chris Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox