* [PATCH] bcache: Use a folio
@ 2025-06-13 19:19 Matthew Wilcox (Oracle)
2025-06-16 6:19 ` Coly Li
2025-06-20 11:58 ` Coly Li
0 siblings, 2 replies; 8+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-06-13 19:19 UTC (permalink / raw)
To: Coly Li; +Cc: Matthew Wilcox (Oracle), linux-bcache, dm-devel
Retrieve a folio from the page cache instead of a page. Removes a
hidden call to compound_head(). Then be sure to call folio_put()
instead of put_page() to release it. That doesn't save any calls
to compound_head(), just moves them around.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
drivers/md/bcache/super.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 1efb768b2890..83c786a5cc47 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -168,14 +168,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
{
const char *err;
struct cache_sb_disk *s;
- struct page *page;
+ struct folio *folio;
unsigned int i;
- page = read_cache_page_gfp(bdev->bd_mapping,
- SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
- if (IS_ERR(page))
+ folio = mapping_read_folio_gfp(bdev->bd_mapping,
+ SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
+ if (IS_ERR(folio))
return "IO error";
- s = page_address(page) + offset_in_page(SB_OFFSET);
+ s = folio_address(folio) + offset_in_folio(folio, SB_OFFSET);
sb->offset = le64_to_cpu(s->offset);
sb->version = le64_to_cpu(s->version);
@@ -272,7 +272,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
*res = s;
return NULL;
err:
- put_page(page);
+ folio_put(folio);
return err;
}
@@ -1366,7 +1366,7 @@ static CLOSURE_CALLBACK(cached_dev_free)
mutex_unlock(&bch_register_lock);
if (dc->sb_disk)
- put_page(virt_to_page(dc->sb_disk));
+ folio_put(virt_to_folio(dc->sb_disk));
if (dc->bdev_file)
fput(dc->bdev_file);
@@ -2215,7 +2215,7 @@ void bch_cache_release(struct kobject *kobj)
free_fifo(&ca->free[i]);
if (ca->sb_disk)
- put_page(virt_to_page(ca->sb_disk));
+ folio_put(virt_to_folio(ca->sb_disk));
if (ca->bdev_file)
fput(ca->bdev_file);
@@ -2592,7 +2592,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
if (!holder) {
ret = -ENOMEM;
err = "cannot allocate memory";
- goto out_put_sb_page;
+ goto out_put_sb_folio;
}
/* Now reopen in exclusive mode with proper holder */
@@ -2666,8 +2666,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
out_free_holder:
kfree(holder);
-out_put_sb_page:
- put_page(virt_to_page(sb_disk));
+out_put_sb_folio:
+ folio_put(virt_to_folio(sb_disk));
out_blkdev_put:
if (bdev_file)
fput(bdev_file);
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] bcache: Use a folio
2025-06-13 19:19 [PATCH] bcache: Use a folio Matthew Wilcox (Oracle)
@ 2025-06-16 6:19 ` Coly Li
2025-06-20 11:58 ` Coly Li
1 sibling, 0 replies; 8+ messages in thread
From: Coly Li @ 2025-06-16 6:19 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: linux-bcache, dm-devel
On Fri, Jun 13, 2025 at 08:19:39PM +0800, Matthew Wilcox (Oracle) wrote:
> Retrieve a folio from the page cache instead of a page. Removes a
> hidden call to compound_head(). Then be sure to call folio_put()
> instead of put_page() to release it. That doesn't save any calls
> to compound_head(), just moves them around.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Hi Matthew,
Overall the patch is fine to me. I will reply you after doing some basic testing.
Thanks.
Coly Li
> ---
> drivers/md/bcache/super.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 1efb768b2890..83c786a5cc47 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -168,14 +168,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
> {
> const char *err;
> struct cache_sb_disk *s;
> - struct page *page;
> + struct folio *folio;
> unsigned int i;
>
> - page = read_cache_page_gfp(bdev->bd_mapping,
> - SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
> - if (IS_ERR(page))
> + folio = mapping_read_folio_gfp(bdev->bd_mapping,
> + SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
> + if (IS_ERR(folio))
> return "IO error";
> - s = page_address(page) + offset_in_page(SB_OFFSET);
> + s = folio_address(folio) + offset_in_folio(folio, SB_OFFSET);
>
> sb->offset = le64_to_cpu(s->offset);
> sb->version = le64_to_cpu(s->version);
> @@ -272,7 +272,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
> *res = s;
> return NULL;
> err:
> - put_page(page);
> + folio_put(folio);
> return err;
> }
>
> @@ -1366,7 +1366,7 @@ static CLOSURE_CALLBACK(cached_dev_free)
> mutex_unlock(&bch_register_lock);
>
> if (dc->sb_disk)
> - put_page(virt_to_page(dc->sb_disk));
> + folio_put(virt_to_folio(dc->sb_disk));
>
> if (dc->bdev_file)
> fput(dc->bdev_file);
> @@ -2215,7 +2215,7 @@ void bch_cache_release(struct kobject *kobj)
> free_fifo(&ca->free[i]);
>
> if (ca->sb_disk)
> - put_page(virt_to_page(ca->sb_disk));
> + folio_put(virt_to_folio(ca->sb_disk));
>
> if (ca->bdev_file)
> fput(ca->bdev_file);
> @@ -2592,7 +2592,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> if (!holder) {
> ret = -ENOMEM;
> err = "cannot allocate memory";
> - goto out_put_sb_page;
> + goto out_put_sb_folio;
> }
>
> /* Now reopen in exclusive mode with proper holder */
> @@ -2666,8 +2666,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>
> out_free_holder:
> kfree(holder);
> -out_put_sb_page:
> - put_page(virt_to_page(sb_disk));
> +out_put_sb_folio:
> + folio_put(virt_to_folio(sb_disk));
> out_blkdev_put:
> if (bdev_file)
> fput(bdev_file);
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] bcache: Use a folio
2025-06-13 19:19 [PATCH] bcache: Use a folio Matthew Wilcox (Oracle)
2025-06-16 6:19 ` Coly Li
@ 2025-06-20 11:58 ` Coly Li
2025-06-23 19:56 ` Matthew Wilcox
1 sibling, 1 reply; 8+ messages in thread
From: Coly Li @ 2025-06-20 11:58 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: linux-bcache, dm-devel
On Fri, Jun 13, 2025 at 08:19:39PM +0800, Matthew Wilcox (Oracle) wrote:
> Retrieve a folio from the page cache instead of a page. Removes a
> hidden call to compound_head(). Then be sure to call folio_put()
> instead of put_page() to release it. That doesn't save any calls
> to compound_head(), just moves them around.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-back: Coly Li <colyli@kernel.org>
The patch looks fine and works well. If you want this patch to go upstream
by your path, please add my Acked-by.
Otherwise I can submit it to Jens with my Signed-off-by.
Thanks.
Coly Li
> ---
> drivers/md/bcache/super.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 1efb768b2890..83c786a5cc47 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -168,14 +168,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
> {
> const char *err;
> struct cache_sb_disk *s;
> - struct page *page;
> + struct folio *folio;
> unsigned int i;
>
> - page = read_cache_page_gfp(bdev->bd_mapping,
> - SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
> - if (IS_ERR(page))
> + folio = mapping_read_folio_gfp(bdev->bd_mapping,
> + SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
> + if (IS_ERR(folio))
> return "IO error";
> - s = page_address(page) + offset_in_page(SB_OFFSET);
> + s = folio_address(folio) + offset_in_folio(folio, SB_OFFSET);
>
> sb->offset = le64_to_cpu(s->offset);
> sb->version = le64_to_cpu(s->version);
> @@ -272,7 +272,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
> *res = s;
> return NULL;
> err:
> - put_page(page);
> + folio_put(folio);
> return err;
> }
>
> @@ -1366,7 +1366,7 @@ static CLOSURE_CALLBACK(cached_dev_free)
> mutex_unlock(&bch_register_lock);
>
> if (dc->sb_disk)
> - put_page(virt_to_page(dc->sb_disk));
> + folio_put(virt_to_folio(dc->sb_disk));
>
> if (dc->bdev_file)
> fput(dc->bdev_file);
> @@ -2215,7 +2215,7 @@ void bch_cache_release(struct kobject *kobj)
> free_fifo(&ca->free[i]);
>
> if (ca->sb_disk)
> - put_page(virt_to_page(ca->sb_disk));
> + folio_put(virt_to_folio(ca->sb_disk));
>
> if (ca->bdev_file)
> fput(ca->bdev_file);
> @@ -2592,7 +2592,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> if (!holder) {
> ret = -ENOMEM;
> err = "cannot allocate memory";
> - goto out_put_sb_page;
> + goto out_put_sb_folio;
> }
>
> /* Now reopen in exclusive mode with proper holder */
> @@ -2666,8 +2666,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>
> out_free_holder:
> kfree(holder);
> -out_put_sb_page:
> - put_page(virt_to_page(sb_disk));
> +out_put_sb_folio:
> + folio_put(virt_to_folio(sb_disk));
> out_blkdev_put:
> if (bdev_file)
> fput(bdev_file);
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] bcache: Use a folio
2025-06-20 11:58 ` Coly Li
@ 2025-06-23 19:56 ` Matthew Wilcox
0 siblings, 0 replies; 8+ messages in thread
From: Matthew Wilcox @ 2025-06-23 19:56 UTC (permalink / raw)
To: Coly Li; +Cc: linux-bcache, dm-devel
On Fri, Jun 20, 2025 at 07:58:56PM +0800, Coly Li wrote:
> On Fri, Jun 13, 2025 at 08:19:39PM +0800, Matthew Wilcox (Oracle) wrote:
> > Retrieve a folio from the page cache instead of a page. Removes a
> > hidden call to compound_head(). Then be sure to call folio_put()
> > instead of put_page() to release it. That doesn't save any calls
> > to compound_head(), just moves them around.
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
>
> Acked-back: Coly Li <colyli@kernel.org>
>
> The patch looks fine and works well. If you want this patch to go upstream
> by your path, please add my Acked-by.
>
> Otherwise I can submit it to Jens with my Signed-off-by.
Please submit it to Jens; it's not part of a specific series at this
point (though obviously I'm working towards killing off all the page
infrastructure). Easiest to work through maintainer trees at this point.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] bcache: Use a folio
@ 2025-07-02 2:48 colyli
2025-07-02 13:49 ` Jens Axboe
2025-07-02 23:20 ` Jens Axboe
0 siblings, 2 replies; 8+ messages in thread
From: colyli @ 2025-07-02 2:48 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-bcache, Matthew Wilcox, Coly Li
From: Matthew Wilcox (Oracle) <willy@infradead.org>
Retrieve a folio from the page cache instead of a page. Removes a
hidden call to compound_head(). Then be sure to call folio_put()
instead of put_page() to release it. That doesn't save any calls
to compound_head(), just moves them around.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Coly Li <colyli@kernel.org>
---
drivers/md/bcache/super.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 2ea490b9d370..1492c8552255 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -168,14 +168,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
{
const char *err;
struct cache_sb_disk *s;
- struct page *page;
+ struct folio *folio;
unsigned int i;
- page = read_cache_page_gfp(bdev->bd_mapping,
- SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
- if (IS_ERR(page))
+ folio = mapping_read_folio_gfp(bdev->bd_mapping,
+ SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
+ if (IS_ERR(folio))
return "IO error";
- s = page_address(page) + offset_in_page(SB_OFFSET);
+ s = folio_address(folio) + offset_in_folio(folio, SB_OFFSET);
sb->offset = le64_to_cpu(s->offset);
sb->version = le64_to_cpu(s->version);
@@ -272,7 +272,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
*res = s;
return NULL;
err:
- put_page(page);
+ folio_put(folio);
return err;
}
@@ -1366,7 +1366,7 @@ static CLOSURE_CALLBACK(cached_dev_free)
mutex_unlock(&bch_register_lock);
if (dc->sb_disk)
- put_page(virt_to_page(dc->sb_disk));
+ folio_put(virt_to_folio(dc->sb_disk));
if (dc->bdev_file)
fput(dc->bdev_file);
@@ -2216,7 +2216,7 @@ void bch_cache_release(struct kobject *kobj)
free_fifo(&ca->free[i]);
if (ca->sb_disk)
- put_page(virt_to_page(ca->sb_disk));
+ folio_put(virt_to_folio(ca->sb_disk));
if (ca->bdev_file)
fput(ca->bdev_file);
@@ -2593,7 +2593,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
if (!holder) {
ret = -ENOMEM;
err = "cannot allocate memory";
- goto out_put_sb_page;
+ goto out_put_sb_folio;
}
/* Now reopen in exclusive mode with proper holder */
@@ -2667,8 +2667,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
out_free_holder:
kfree(holder);
-out_put_sb_page:
- put_page(virt_to_page(sb_disk));
+out_put_sb_folio:
+ folio_put(virt_to_folio(sb_disk));
out_blkdev_put:
if (bdev_file)
fput(bdev_file);
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] bcache: Use a folio
2025-07-02 2:48 colyli
@ 2025-07-02 13:49 ` Jens Axboe
2025-07-02 16:19 ` Coly Li
2025-07-02 23:20 ` Jens Axboe
1 sibling, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2025-07-02 13:49 UTC (permalink / raw)
To: colyli, axboe; +Cc: linux-block, linux-bcache, Matthew Wilcox
On 7/1/25 8:48 PM, colyli@kernel.org wrote:
> From: Matthew Wilcox (Oracle) <willy@infradead.org>
>
> Retrieve a folio from the page cache instead of a page. Removes a
> hidden call to compound_head(). Then be sure to call folio_put()
> instead of put_page() to release it. That doesn't save any calls
> to compound_head(), just moves them around.
Really needs a better subject line... I can do that while applying,
however. How about:
bcache: switch from pages to folios in read_super()
or something like that.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] bcache: Use a folio
2025-07-02 13:49 ` Jens Axboe
@ 2025-07-02 16:19 ` Coly Li
0 siblings, 0 replies; 8+ messages in thread
From: Coly Li @ 2025-07-02 16:19 UTC (permalink / raw)
To: Jens Axboe; +Cc: colyli, axboe, linux-block, linux-bcache, Matthew Wilcox
> 2025年7月2日 21:49,Jens Axboe <axboe@kernel.dk> 写道:
>
> On 7/1/25 8:48 PM, colyli@kernel.org wrote:
>> From: Matthew Wilcox (Oracle) <willy@infradead.org>
>>
>> Retrieve a folio from the page cache instead of a page. Removes a
>> hidden call to compound_head(). Then be sure to call folio_put()
>> instead of put_page() to release it. That doesn't save any calls
>> to compound_head(), just moves them around.
>
> Really needs a better subject line... I can do that while applying,
> however. How about:
>
> bcache: switch from pages to folios in read_super()
Yeah, this subject is good IMHO.
Thanks.
Coly Li
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] bcache: Use a folio
2025-07-02 2:48 colyli
2025-07-02 13:49 ` Jens Axboe
@ 2025-07-02 23:20 ` Jens Axboe
1 sibling, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2025-07-02 23:20 UTC (permalink / raw)
To: axboe, colyli; +Cc: linux-block, linux-bcache, Matthew Wilcox
On Wed, 02 Jul 2025 10:48:48 +0800, colyli@kernel.org wrote:
> Retrieve a folio from the page cache instead of a page. Removes a
> hidden call to compound_head(). Then be sure to call folio_put()
> instead of put_page() to release it. That doesn't save any calls
> to compound_head(), just moves them around.
>
>
Applied, thanks!
[1/1] bcache: Use a folio
commit: 88b4b873551f0901dd0314d37ca2a420ec6c2686
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-07-02 23:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 19:19 [PATCH] bcache: Use a folio Matthew Wilcox (Oracle)
2025-06-16 6:19 ` Coly Li
2025-06-20 11:58 ` Coly Li
2025-06-23 19:56 ` Matthew Wilcox
-- strict thread matches above, loose matches on Subject: below --
2025-07-02 2:48 colyli
2025-07-02 13:49 ` Jens Axboe
2025-07-02 16:19 ` Coly Li
2025-07-02 23:20 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).