#author("2025-09-11T16:33:51+09:00","default:guest","guest") #author("2025-09-11T17:04:31+09:00","default:guest","guest") *参照元 [#wb9298a6] #backlinks *説明 [#yf3fc2ce] -パス: [[linux-5.15/mm/vmscan.c]] -FIXME: これは何? --説明 **引数 [#kd646170] -pg_data_t *pgdat --メモリノード。 --[[linux-5.15/pg_data_t]] -int order --オーダー。 -int highest_zoneidx -- --メモリを確保する最大のゾーンインデックス値。この値以下のゾーンがチェック対象です。 **返り値 [#d0ef6884] -bool --sleepするならtrue、しないならfalse。 **参考 [#f0d4ed02] *実装 [#uf6ad46c] /* * Prepare kswapd for sleeping. This verifies that there are no processes * waiting in throttle_direct_reclaim() and that watermarks have been met. * * Returns true if kswapd is ready to sleep */ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int highest_zoneidx) { /* * The throttled processes are normally woken up in balance_pgdat() as * soon as allow_direct_reclaim() is true. But there is a potential * race between when kswapd checks the watermarks and a process gets * throttled. There is also a potential race if processes get * throttled, kswapd wakes, a large process exits thereby balancing the * zones, which causes kswapd to exit balance_pgdat() before reaching * the wake up checks. If kswapd is going to sleep, no process should * be sleeping on pfmemalloc_wait, so wake them now if necessary. If * the wake up is premature, processes will wake kswapd and get * throttled again. The difference from wake ups in balance_pgdat() is * that here we are under prepare_to_wait(). */ if (waitqueue_active(&pgdat->pfmemalloc_wait)) wake_up_all(&pgdat->pfmemalloc_wait); -最初にdirect reclaimを待っているプロセスを起こします。 --[[linux-5.15/waitqueue_active()]] --[[linux-5.15/wake_up_all()]] /* Hopeless node, leave it to direct reclaim */ if (pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES) return true; -過去にページ回収を失敗しすぎていたら(今回も成功する可能性が低そうなので)sleepします。 if (pgdat_balanced(pgdat, order, highest_zoneidx)) { clear_pgdat_congested(pgdat); return true; } -ノードがバランス状態であればページ回収は不要なのでsleepします。 --[[linux-5.15/pgdat_balanced()]] --[[linux-5.15/clear_pgdat_congested()]] return false; } *コメント [#t71b4489]