[PATCH 6.12.y] swapfile: call cond_resched() before locking si->lock

Guillaume Morin <[email protected]>
Newsgroups org.kernel.vger.stable
Message-ID <[email protected]>
The 6.12 backport of commit 66366d291f66 ("mm/swap: add cond_resched()
in swap_reclaim_full_clusters to prevent softlockup"),
added a cond_resched() after locking si->lock. Move cond_resched()
before spin_lock().

Signed-off-by: Guillaume Morin <[email protected]>
Fixes: 60cbe67d1342 ("mm/swap: add cond_resched() in swap_reclaim_full_clusters to prevent softlockup")
Link: https://lore.kernel.org/stable/[email protected]/
Cc: [email protected]
Cc: Chris Li <[email protected]>
Cc: Zijiang Huang <[email protected]>
Cc: [email protected]
---
 mm/swapfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 552df432c37f..ed0a5ed25e65 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -770,11 +770,11 @@ static void swap_reclaim_full_clusters(struct swap_info_struct *si, bool force)
 			}
 			offset++;
 		}
+		cond_resched();
 		spin_lock(&si->lock);
 
 		if (to_scan <= 0)
 			break;
-		cond_resched();
 	}
 }
 
-- 
2.39.1


-- 
Guillaume Morin <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.