Commit 96200c91 authored by Levi Yun's avatar Levi Yun Committed by Andrew Morton

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.comSigned-off-by: default avatarLevi Yun <ppbuk5246@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 13ef7424
...@@ -6796,6 +6796,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx) ...@@ -6796,6 +6796,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx)
bool raise_priority = true; bool raise_priority = true;
bool balanced; bool balanced;
bool ret; bool ret;
bool was_frozen;
sc.reclaim_idx = highest_zoneidx; sc.reclaim_idx = highest_zoneidx;
...@@ -6894,9 +6895,9 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx) ...@@ -6894,9 +6895,9 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx)
/* Check if kswapd should be suspending */ /* Check if kswapd should be suspending */
__fs_reclaim_release(_THIS_IP_); __fs_reclaim_release(_THIS_IP_);
ret = try_to_freeze(); ret = kthread_freezable_should_stop(&was_frozen);
__fs_reclaim_acquire(_THIS_IP_); __fs_reclaim_acquire(_THIS_IP_);
if (ret || kthread_should_stop()) if (was_frozen || ret)
break; break;
/* /*
...@@ -7102,7 +7103,7 @@ static int kswapd(void *p) ...@@ -7102,7 +7103,7 @@ static int kswapd(void *p)
WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES); WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES);
atomic_set(&pgdat->nr_writeback_throttled, 0); atomic_set(&pgdat->nr_writeback_throttled, 0);
for ( ; ; ) { for ( ; ; ) {
bool ret; bool was_frozen;
alloc_order = reclaim_order = READ_ONCE(pgdat->kswapd_order); alloc_order = reclaim_order = READ_ONCE(pgdat->kswapd_order);
highest_zoneidx = kswapd_highest_zoneidx(pgdat, highest_zoneidx = kswapd_highest_zoneidx(pgdat,
...@@ -7119,15 +7120,14 @@ static int kswapd(void *p) ...@@ -7119,15 +7120,14 @@ static int kswapd(void *p)
WRITE_ONCE(pgdat->kswapd_order, 0); WRITE_ONCE(pgdat->kswapd_order, 0);
WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES); WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES);
ret = try_to_freeze(); if (kthread_freezable_should_stop(&was_frozen))
if (kthread_should_stop())
break; break;
/* /*
* We can speed up thawing tasks if we don't call balance_pgdat * We can speed up thawing tasks if we don't call balance_pgdat
* after returning from the refrigerator * after returning from the refrigerator
*/ */
if (ret) if (was_frozen)
continue; continue;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment