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 <qun-wei.lin@mediatek.com>
Link: https://lore.kernel.org/lkml/20241011091133.28173-1-qun-wei.lin@mediatek.com/
This commit is contained in:
Qun-Wei Lin
2024-10-01 10:12:53 +08:00
committed by Kalesh Singh
parent 349fdbe6af
commit 0258c527fb
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -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 */
};
+2 -2
View File
@@ -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);