diff mbox series

[04/13] mm/readahead: add readahead_control->uncached member

Message ID 20241108174505.1214230-5-axboe@kernel.dk (mailing list archive)
State New
Headers show
Series [01/13] mm/filemap: change filemap_create_folio() to take a struct kiocb | expand

Commit Message

Jens Axboe Nov. 8, 2024, 5:43 p.m. UTC
If ractl->uncached is set to true, then folios created are marked as
uncached as well.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/pagemap.h | 1 +
 mm/readahead.c          | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Matthew Wilcox Nov. 8, 2024, 6:21 p.m. UTC | #1
On Fri, Nov 08, 2024 at 10:43:27AM -0700, Jens Axboe wrote:
> +++ b/mm/readahead.c
> @@ -191,7 +191,13 @@ static void read_pages(struct readahead_control *rac)
>  static struct folio *ractl_alloc_folio(struct readahead_control *ractl,
>  				       gfp_t gfp_mask, unsigned int order)
>  {
> -	return filemap_alloc_folio(gfp_mask, order);
> +	struct folio *folio;
> +
> +	folio = filemap_alloc_folio(gfp_mask, order);
> +	if (folio && ractl->uncached)
> +		folio_set_uncached(folio);

If we've just allocated it, it should be safe to use
__folio_set_uncached() here, no?

Not that I'm keen on using a folio flag here, but I'm reserving judgement
on that unti I've got further through this series and see how it's used.
I can see that it might be necessary.
Jens Axboe Nov. 8, 2024, 7:22 p.m. UTC | #2
On 11/8/24 11:21 AM, Matthew Wilcox wrote:
> On Fri, Nov 08, 2024 at 10:43:27AM -0700, Jens Axboe wrote:
>> +++ b/mm/readahead.c
>> @@ -191,7 +191,13 @@ static void read_pages(struct readahead_control *rac)
>>  static struct folio *ractl_alloc_folio(struct readahead_control *ractl,
>>  				       gfp_t gfp_mask, unsigned int order)
>>  {
>> -	return filemap_alloc_folio(gfp_mask, order);
>> +	struct folio *folio;
>> +
>> +	folio = filemap_alloc_folio(gfp_mask, order);
>> +	if (folio && ractl->uncached)
>> +		folio_set_uncached(folio);
> 
> If we've just allocated it, it should be safe to use
> __folio_set_uncached() here, no?

Indeed, we can use __folio_set_uncached() here. I'll make that change.

> Not that I'm keen on using a folio flag here, but I'm reserving judgement
> on that unti I've got further through this series and see how it's used.
> I can see that it might be necessary.

I knew that'd be one of the more contentious items here... On the read
side, we can get by without the flag. But for writeback we do need it.
I just kept it consistent and used folio_*_uncached() throughout
because of that.
diff mbox series

Patch

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 68a5f1ff3301..8afacb7520d4 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1350,6 +1350,7 @@  struct readahead_control {
 	pgoff_t _index;
 	unsigned int _nr_pages;
 	unsigned int _batch_count;
+	bool uncached;
 	bool _workingset;
 	unsigned long _pflags;
 };
diff --git a/mm/readahead.c b/mm/readahead.c
index 003cfe79880d..09cddbbfe28f 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -191,7 +191,13 @@  static void read_pages(struct readahead_control *rac)
 static struct folio *ractl_alloc_folio(struct readahead_control *ractl,
 				       gfp_t gfp_mask, unsigned int order)
 {
-	return filemap_alloc_folio(gfp_mask, order);
+	struct folio *folio;
+
+	folio = filemap_alloc_folio(gfp_mask, order);
+	if (folio && ractl->uncached)
+		folio_set_uncached(folio);
+
+	return folio;
 }
 
 /**