lkml.org 
[lkml]   [2024]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectWhether is the race for SWP_SYNCHRONOUS_IO possible? (was Re: [PATCH v3 6/7] mm/swap, shmem: use unified swapin helper for shmem)
Date
Hi, Minchan,

When I review the patchset from Kairui, I checked the code to skip swap
cache in do_swap_page() for swap device with SWP_SYNCHRONOUS_IO. Is the
following race possible? Where a page is swapped out to a swap device
with SWP_SYNCHRONOUS_IO and the swap count is 1. Then 2 threads of the
process runs on CPU0 and CPU1 as below. CPU0 is running do_swap_page().

CPU0 CPU1
---- ----
swap_cache_get_folio()
check sync io and swap count
alloc folio
swap_readpage()
folio_lock_or_retry()
swap in the swap entry
write page
swap out to same swap entry
pte_offset_map_lock()
check pte_same()
swap_free() <-- new content lost!
set_pte_at() <-- stale page!
folio_unlock()
pte_unmap_unlock()


Do I miss anything?

--
Best Regards,
Huang, Ying

\
 
 \ /
  Last update: 2024-05-27 14:41    [W:0.128 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site