diff mbox series

[03/13] mm: add PG_uncached page flag

Message ID 20241108174505.1214230-4-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
Add a page flag that file IO can use to indicate that the IO being done
is uncached, as in it should not persist in the page cache after the IO
has been completed.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/page-flags.h     | 5 +++++
 include/trace/events/mmflags.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Kirill A. Shutemov Nov. 8, 2024, 7:25 p.m. UTC | #1
On Fri, Nov 08, 2024 at 10:43:26AM -0700, Jens Axboe wrote:
> Add a page flag that file IO can use to indicate that the IO being done
> is uncached, as in it should not persist in the page cache after the IO
> has been completed.

Flag bits are precious resource. It would be nice to re-use an existing
bit if possible.

PG_reclaim description looks suspiciously close to what you want.
I wounder if it would be valid to re-define PG_reclaim behaviour to drop
the page after writeback instead of moving to the tail of inactive list.
Jens Axboe Nov. 8, 2024, 7:39 p.m. UTC | #2
On 11/8/24 12:25 PM, Kirill A. Shutemov wrote:
> On Fri, Nov 08, 2024 at 10:43:26AM -0700, Jens Axboe wrote:
>> Add a page flag that file IO can use to indicate that the IO being done
>> is uncached, as in it should not persist in the page cache after the IO
>> has been completed.
> 
> Flag bits are precious resource. It would be nice to re-use an existing
> bit if possible.

I knoew, like I mentioned in the reply to willy, I knew this one would
be an interesting discussion in and of itself.

> PG_reclaim description looks suspiciously close to what you want.
> I wounder if it would be valid to re-define PG_reclaim behaviour to drop
> the page after writeback instead of moving to the tail of inactive list.

You're the mm expert - I added the flag since then it has a clearly
defined meaning, and I would not need to worry about any kind of odd
overlap in paths I didn't know about. Would definitely entertain reusing
something else, but I'll leave that in the hands of the people that know
this code and the various intricacies and assumptions a lot better than
I do.
diff mbox series

Patch

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index cc839e4365c1..3c4003495929 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -110,6 +110,7 @@  enum pageflags {
 	PG_reclaim,		/* To be reclaimed asap */
 	PG_swapbacked,		/* Page is backed by RAM/swap */
 	PG_unevictable,		/* Page is "unevictable"  */
+	PG_uncached,		/* uncached read/write IO */
 #ifdef CONFIG_MMU
 	PG_mlocked,		/* Page is vma mlocked */
 #endif
@@ -562,6 +563,10 @@  PAGEFLAG(Reclaim, reclaim, PF_NO_TAIL)
 FOLIO_FLAG(readahead, FOLIO_HEAD_PAGE)
 	FOLIO_TEST_CLEAR_FLAG(readahead, FOLIO_HEAD_PAGE)
 
+FOLIO_FLAG(uncached, FOLIO_HEAD_PAGE)
+	FOLIO_TEST_CLEAR_FLAG(uncached, FOLIO_HEAD_PAGE)
+	__FOLIO_SET_FLAG(uncached, FOLIO_HEAD_PAGE)
+
 #ifdef CONFIG_HIGHMEM
 /*
  * Must use a macro here due to header dependency issues. page_zone() is not
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index bb8a59c6caa2..b60057284102 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -116,7 +116,8 @@ 
 	DEF_PAGEFLAG_NAME(head),					\
 	DEF_PAGEFLAG_NAME(reclaim),					\
 	DEF_PAGEFLAG_NAME(swapbacked),					\
-	DEF_PAGEFLAG_NAME(unevictable)					\
+	DEF_PAGEFLAG_NAME(unevictable),					\
+	DEF_PAGEFLAG_NAME(uncached)					\
 IF_HAVE_PG_MLOCK(mlocked)						\
 IF_HAVE_PG_HWPOISON(hwpoison)						\
 IF_HAVE_PG_IDLE(idle)							\