Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kswapd: replace try_to_freeze() with kthread_freezable_should_stop()

Instead of using try_to_freeze, use kthread_freezable_should_stop in
kswapd. By this, we can avoid unnecessary freezing when kswapd should
stop.

Link: https://lkml.kernel.org/r/20240126152556.58791-1-ppbuk5246@gmail.com
Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Levi Yun and committed by
Andrew Morton
96200c91 13ef7424

+6 -6
+6 -6
mm/vmscan.c
··· 6796 6796 bool raise_priority = true; 6797 6797 bool balanced; 6798 6798 bool ret; 6799 + bool was_frozen; 6799 6800 6800 6801 sc.reclaim_idx = highest_zoneidx; 6801 6802 ··· 6895 6894 6896 6895 /* Check if kswapd should be suspending */ 6897 6896 __fs_reclaim_release(_THIS_IP_); 6898 - ret = try_to_freeze(); 6897 + ret = kthread_freezable_should_stop(&was_frozen); 6899 6898 __fs_reclaim_acquire(_THIS_IP_); 6900 - if (ret || kthread_should_stop()) 6899 + if (was_frozen || ret) 6901 6900 break; 6902 6901 6903 6902 /* ··· 7103 7102 WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES); 7104 7103 atomic_set(&pgdat->nr_writeback_throttled, 0); 7105 7104 for ( ; ; ) { 7106 - bool ret; 7105 + bool was_frozen; 7107 7106 7108 7107 alloc_order = reclaim_order = READ_ONCE(pgdat->kswapd_order); 7109 7108 highest_zoneidx = kswapd_highest_zoneidx(pgdat, ··· 7120 7119 WRITE_ONCE(pgdat->kswapd_order, 0); 7121 7120 WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES); 7122 7121 7123 - ret = try_to_freeze(); 7124 - if (kthread_should_stop()) 7122 + if (kthread_freezable_should_stop(&was_frozen)) 7125 7123 break; 7126 7124 7127 7125 /* 7128 7126 * We can speed up thawing tasks if we don't call balance_pgdat 7129 7127 * after returning from the refrigerator 7130 7128 */ 7131 - if (ret) 7129 + if (was_frozen) 7132 7130 continue; 7133 7131 7134 7132 /*