Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\memcontrol.c Create Date:2022-07-28 16:10:47
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:try_charge

Proto:static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, unsigned int nr_pages)

Type:int

Parameter:

TypeParameterName
struct mem_cgroup *memcg
gfp_tgfp_mask
unsigned intnr_pages
2390  batch = max - return maximum of two values of the same or compatible types*@x: first value*@y: second value(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  If mem_cgroup_is_root(memcg) Then Return 0
2401  retry :
2402  If 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 Then Return 0
2405  If Not 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 Then
2407  If 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 Then Go to done_restock
2409  If Whether legacy memory+swap accounting is active Then 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  Else
2413  mem_over_limit = mem_cgroup_from_counter(counter, memsw)
2414  may_swap = false
2417  If batch > nr_pages Then
2418  batch = nr_pages
2419  Go to retry
2428  If gfp_mask & DOC: Watermark modifiers* Watermark modifiers -- controls access to emergency reserves* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* %__GFP_HIGH indicates that the caller is high-priority and that granting Then Go to force
2437  If Value for the false possibility is greater at compile time(should_force_charge()) Then Go to force
2446  If Value for the false possibility is greater at compile time(flags & Allocating memory ) Then Go to force
2449  If Value for the false possibility is greater at compile time(task_in_memcg_oom(current process)) Then Go to nomem
2452  If Not gfpflags_allow_blocking(gfp_mask) Then Go to 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  If 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 Then Go to retry
2463  If Not drained Then
2464  Drains all per-CPU charge caches for given root_memcg resp. subtree* of the hierarchy under it.
2465  drained = true
2466  Go to retry
2469  If gfp_mask & __GFP_NORETRY Then Go to nomem
2480  If nr_reclaimed && nr_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. Then Go to retry
2486  If mem_cgroup_wait_acct_move(mem_over_limit) Then Go to retry
2489  If nr_retries-- Then Go to retry
2492  If gfp_mask & __GFP_RETRY_MAYFAIL Then Go to nomem
2495  If gfp_mask & __GFP_NOFAIL Then Go to force
2498  If fatal_signal_pending(current process) Then Go to 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  Case oom_status == OOM_SUCCESS
2510  nr_retries = MEM_CGROUP_RECLAIM_RETRIES
2511  Go to retry
2512  Case oom_status == OOM_FAILED
2513  Go to force
2514  Default
2515  Go to nomem
2517  nomem :
2518  If Not (gfp_mask & __GFP_NOFAIL) Then Return -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  If Whether legacy memory+swap accounting is active Then 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  ss_get_many - obtain references on the specified css*@css: target css*@n: number of references to get* The caller must already have a reference.
2531  Return 0
2533  done_restock :
2534  ss_get_many - obtain references on the specified css*@css: target css*@n: number of references to get* The caller must already have a reference.
2535  If batch > nr_pages Then Cache charges(val) to local per_cpu area.* This will be consumed by consume_stock() function, later.
2547  Do
2550  If in_interrupt() Then
2556  Break
2558  When 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. cycle
2560  Return 0
Caller
NameDescribe
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.