函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\vmscan.c Create Date:2022-07-27 15:43:52
Last Modify:2022-05-23 13:41:30 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:For kswapd, balance_pgdat() will reclaim pages across a node from zones* that are eligible for use by the caller until at least one zone is* balanced.* Returns the order kswapd finished reclaiming at.

函数原型:static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)

返回类型:int

参数:

类型参数名称
pg_data_t *pgdat
intorder
intclasszone_idx
3577  unsigned long zone_boosts[MAX_NR_ZONES] = {0, }
3580  struct scan_control sc = { This context's GFP mask = GFP_KERNEL, Allocation order = order, Can mapped pages be reclaimed? = 1, }
3586  set_task_reclaim_state(当前进程, & for recording the reclaimed slab by now )
3587  psi_memstall_enter - mark the beginning of a memory stall section*@flags: flags to handle nested sections* Marks the calling task as being stalled due to a lack of memory,* such as waiting for a refault or performing reclaim.
3588  __fs_reclaim_acquire()
3590  Disable counters
3597  nr_boost_reclaim等于0
3598 i小于等于classzone_idx循环
3599  zone等于包含了结点中各内存域的数据结构i
3600  如果非Returns true if a zone has pages managed by the buddy allocator.* All the reclaim decisions have to use this function rather than* populated_zone(). If the whole zone is reserved then we can easily* end up with populated_zone() && !managed_zone().则继续下一循环
3603  nr_boost_reclaim加等于watermark_boost
3604  zone_boosts[i]等于watermark_boost
3606  boosted等于nr_boost_reclaim
3608  restart :
3609  Scan (total_size >> priority) pages at once 等于The "priority" of VM scanning is how much of the queues we will scan in one* go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the* queues ("queue_length >> 12") during an aging round.
3610  循环
3611  nr_reclaimed等于 Number of pages freed so far during a call to shrink_zones()
3612  bool raise_priority = true
3616  The highest zone to isolate pages for reclaim from 等于classzone_idx
3628  如果buffer_heads_over_limit
3629 i大于等于0循环
3646  balanced等于Returns true if there is an eligible zone balanced for the request order* and classzone_idx
3647  如果非balancednr_boost_reclaim
3648  nr_boost_reclaim等于0
3649  转到:restart
3657  如果非nr_boost_reclaimbalanced则转到:out
3661  如果nr_boost_reclaim Scan (total_size >> priority) pages at once 恒等于The "priority" of VM scanning is how much of the queues we will scan in one* go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the* queues ("queue_length >> 12") during an aging round.减2则raise_priority = false
3670  Writepage batching in laptop mode; RECLAIM_WRITE 等于非Flag that puts the machine in "laptop mode". Doubles as a timeout in jiffies:* a full sync is triggered after this time elapses without any disk activity.且非nr_boost_reclaim
3671  Can pages be swapped as part of reclaim? 等于非nr_boost_reclaim
3679  age_active_anon(pgdat, & sc)
3685  如果 Scan (total_size >> priority) pages at once 小于The "priority" of VM scanning is how much of the queues we will scan in one* go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the* queues ("queue_length >> 12") during an aging round.减2则 Writepage batching in laptop mode; RECLAIM_WRITE 等于1
3689  Incremented by the number of inactive pages that were scanned 等于0
3690  nr_soft_scanned等于0
3691  nr_soft_reclaimed等于mem_cgroup_soft_limit_reclaim(pgdat, Allocation order , This context's GFP mask , & nr_soft_scanned)
3693  Number of pages freed so far during a call to shrink_zones() 加等于nr_soft_reclaimed
3700  如果kswapd shrinks a node of pages that are at or below the highest usable* zone that is currently unbalanced.* Returns true if kswapd scanned at least the requested number of pages to* reclaim or if the lack of progress was due to pages under writeback.raise_priority = false
3708  如果waitqueue_active -- locklessly test for waiters on the queue*@wq_head: the waitqueue to test for waiters* returns true if the wait list is not empty* NOTE: this function is lockless and requires care, incorrect usage _will_allow_direct_reclaim(pgdat)则wake_up_all( & pfmemalloc_wait)
3713  __fs_reclaim_release()
3714  ret等于try_to_freeze()
3715  __fs_reclaim_acquire()
3716  如果retkthread_should_stop - should this kthread return now?* When someone calls kthread_stop() on your kthread, it will be woken* and this will return true. You should then return, and your return* value will be passed through to kthread_stop().退出
3723  nr_reclaimed等于 Number of pages freed so far during a call to shrink_zones() nr_reclaimed
3724  nr_boost_reclaim减等于两数取小(nr_boost_reclaim, nr_reclaimed)
3731  如果nr_boost_reclaim且非nr_reclaimed退出
3734  如果raise_priority或非nr_reclaimed Scan (total_size >> priority) pages at once 自减
3736  Scan (total_size >> priority) pages at once 大于等于1循环
3738  如果非 Number of pages freed so far during a call to shrink_zones() Number of 'reclaimed == 0' runs 自加
3741  out :
3743  如果boosted
3746 i小于等于classzone_idx循环
3747  如果非zone_boosts[i]则继续下一循环
3761  wakeup_kcompactd(pgdat, Huge pages are a constant size , classzone_idx)
3764  snapshot_refaults(NULL, pgdat)
3765  __fs_reclaim_release()
3766  psi_memstall_leave - mark the end of an memory stall section*@flags: flags to handle nested memdelay sections* Marks the calling task as no longer stalled due to lack of memory.
3767  set_task_reclaim_state(当前进程, NULL)
3775  返回: Allocation order
调用者
名称描述
kswapdThe background pageout daemon, started as a kernel thread* from the init process.* This basically trickles out pages so that we have _some_* free memory available even if there is no other activity* that frees anything up