函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\memcontrol.c Create Date:2022-07-27 17:45:14
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:try_charge

函数原型:static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, unsigned int nr_pages)

返回类型:int

参数:

类型参数名称
struct mem_cgroup *memcg
gfp_tgfp_mask
unsigned intnr_pages
2390  batch等于两数取大(size of first charge trial. "32" comes from vmscan.c's magic value.* TODO: maybe necessary to use big numbers in big irons., nr_pages)
2391  nr_retries等于MEM_CGROUP_RECLAIM_RETRIES
2395  bool may_swap = true
2396  bool drained = false
2399  如果mem_cgroup_is_root(memcg)则返回:0
2401  retry :
2402  如果sume_stock: Try to consume stocked charge on this cpu.*@memcg: memcg to consume from.*@nr_pages: how many pages to charge.* The charges will only happen if @memcg matches the current cpu's memcg* stock, and at least @nr_pages are available in that stock则返回:0
2405  如果非Whether legacy memory+swap accounting is active page_counter_try_charge - try to hierarchically charge pages*@counter: counter*@nr_pages: number of pages to charge*@fail: points first counter to hit its limit, if any* Returns %true on success, or %false and @fail if the counter or one
2407  如果page_counter_try_charge - try to hierarchically charge pages*@counter: counter*@nr_pages: number of pages to charge*@fail: points first counter to hit its limit, if any* Returns %true on success, or %false and @fail if the counter or one则转到:done_restock
2409  如果Whether legacy memory+swap accounting is active page_counter_uncharge - hierarchically uncharge pages*@counter: counter*@nr_pages: number of pages to uncharge
2411  mem_over_limit等于mem_cgroup_from_counter(counter, memory)
2412  否则
2413  mem_over_limit等于mem_cgroup_from_counter(counter, memsw)
2414  may_swap = false
2417  如果batch大于nr_pages
2418  batch等于nr_pages
2419  转到:retry
2428  如果gfp_mask按位与DOC: Watermark modifiers* Watermark modifiers -- controls access to emergency reserves* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* %__GFP_HIGH indicates that the caller is high-priority and that granting则转到:force
2437  如果此条件成立可能性小(为编译器优化)(should_force_charge())则转到:force
2446  如果此条件成立可能性小(为编译器优化)(flags & Allocating memory )则转到:force
2449  如果此条件成立可能性小(为编译器优化)(task_in_memcg_oom(当前进程))则转到:nomem
2452  如果非gfpflags_allow_blocking(gfp_mask)则转到:nomem
2455  memcg_memory_event(mem_over_limit, MEMCG_MAX)
2457  nr_reclaimed等于try_to_free_mem_cgroup_pages(mem_over_limit, nr_pages, gfp_mask, may_swap)
2460  如果mem_cgroup_margin - calculate chargeable space of a memory cgroup*@memcg: the memory cgroup* Returns the maximum amount of memory @mem can be charged with, in* pages.大于等于nr_pages则转到:retry
2463  如果非drained
2464  Drains all per-CPU charge caches for given root_memcg resp. subtree* of the hierarchy under it.
2465  drained = true
2466  转到:retry
2469  如果gfp_mask按位与__GFP_NORETRY则转到:nomem
2480  如果nr_reclaimednr_pages小于等于1左移PAGE_ALLOC_COSTLY_ORDER is the order at which allocations are deemed* costly to service. That is between allocation orders which should* coalesce naturally under reasonable reclaim pressure and those which* will not.位则转到:retry
2486  如果mem_cgroup_wait_acct_move(mem_over_limit)则转到:retry
2489  如果nr_retries自减则转到:retry
2492  如果gfp_mask按位与__GFP_RETRY_MAYFAIL则转到:nomem
2495  如果gfp_mask按位与__GFP_NOFAIL则转到:force
2498  如果fatal_signal_pending(当前进程)则转到:force
2506  oom_status等于mem_cgroup_oom(mem_over_limit, gfp_mask, get_order - Determine the allocation order of a memory size*@size: The size for which to get the order* Determine the allocation order of a particular sized block of memory)
2509  :oom_status恒等于OOM_SUCCESS
2510  nr_retries等于MEM_CGROUP_RECLAIM_RETRIES
2511  转到:retry
2512  :oom_status恒等于OOM_FAILED
2513  转到:force
2514  默认
2515  转到:nomem
2517  nomem :
2518  如果非gfp_mask按位与__GFP_NOFAIL的值则返回:负ENOMEM
2520  force :
2526  page_counter_charge - hierarchically charge pages*@counter: counter*@nr_pages: number of pages to charge* NOTE: This does not consider any configured counter limits.
2527  如果Whether legacy memory+swap accounting is active page_counter_charge - hierarchically charge pages*@counter: counter*@nr_pages: number of pages to charge* NOTE: This does not consider any configured counter limits.
2529  获取指定CSS参考
2531  返回:0
2533  done_restock :
2534  获取指定CSS参考
2535  如果batch大于nr_pagesCache charges(val) to local per_cpu area.* This will be consumed by consume_stock() function, later.
2547  循环
2550  如果in_interrupt()则
2556  退出
2558 memcg等于parent_mem_cgroup - find the accounting parent of a memcg*@memcg: memcg whose parent to find* Returns the parent memcg, or NULL if this is the root or the memory* controller is in legacy no-hierarchy mode.循环
2560  返回:0
调用者
名称描述
mem_cgroup_do_prechargeHandlers for move charge at task migration.
mem_cgroup_try_chargemem_cgroup_try_charge - try charging a page*@page: page to charge*@mm: mm context of the victim*@gfp_mask: reclaim mode*@memcgp: charged memcg return*@compound: charge the page as compound or small page* Try to charge @page to the memcg that @mm belongs
mem_cgroup_charge_skmemmem_cgroup_charge_skmem - charge socket memory*@memcg: memcg to charge*@nr_pages: number of pages to charge* Charges @nr_pages to @memcg. Returns %true if the charge fit within*@memcg's configured limit, %false if the charge had to be forced.