From 0258c527fb3df645438fad7dd58cc0aa4a3fce2f Mon Sep 17 00:00:00 2001 From: Qun-Wei Lin Date: Tue, 1 Oct 2024 10:12:53 +0800 Subject: [PATCH] FROMLIST: mm: Split SWP_SYNCHRONOUS_IO into separate read and write flags This patch splits the SWP_SYNCHRONOUS_IO flag into __SWP_READ_SYNCHRONOUS_IO and __SWP_WRITE_SYNCHRONOUS_IO. These changes are motivated by the need to better accommodate certain swap devices that support synchronous read operations but asynchronous write operations. The existing SWP_SYNCHRONOUS_IO flag is not sufficient for these devices, as they enforce synchronous behavior for both read and write operations. Bug: 368512254 Change-Id: I778053e7f7d7d8f0d52d66bc1acf44b98ab5c636 Signed-off-by: Qun-Wei Lin Link: https://lore.kernel.org/lkml/20241011091133.28173-1-qun-wei.lin@mediatek.com/ --- include/linux/swap.h | 4 +++- mm/page_io.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 9d7ec92874d3..f5eb65656721 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -217,7 +217,9 @@ enum { SWP_AREA_DISCARD = (1 << 9), /* single-time swap area discards */ SWP_PAGE_DISCARD = (1 << 10), /* freed swap page-cluster discards */ SWP_STABLE_WRITES = (1 << 11), /* no overwrite PG_writeback pages */ - SWP_SYNCHRONOUS_IO = (1 << 12), /* synchronous IO is efficient */ + __SWP_READ_SYNCHRONOUS_IO = (1 << 12), /* synchronous read IO is efficient */ + __SWP_WRITE_SYNCHRONOUS_IO = (1 << 13), /* synchronous write IO is efficient */ + SWP_SYNCHRONOUS_IO = (__SWP_READ_SYNCHRONOUS_IO | __SWP_WRITE_SYNCHRONOUS_IO), /* add others here before... */ SWP_SCANNING = (1 << 14), /* refcount in scan_swap_map */ }; diff --git a/mm/page_io.c b/mm/page_io.c index 01749b99fb54..3880256fb1fd 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -463,10 +463,10 @@ void __swap_writepage(struct folio *folio, struct writeback_control *wbc) swap_writepage_fs(folio, wbc); /* * ->flags can be updated non-atomicially (scan_swap_map_slots), - * but that will never affect SWP_SYNCHRONOUS_IO, so the data_race + * but that will never affect __SWP_WRITE_SYNCHRONOUS_IO, so the data_race * is safe. */ - else if (data_race(sis->flags & SWP_SYNCHRONOUS_IO)) + else if (data_race(sis->flags & __SWP_WRITE_SYNCHRONOUS_IO)) swap_writepage_bdev_sync(folio, wbc, sis); else swap_writepage_bdev_async(folio, wbc, sis);