Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Check that a process has enough memory to allocate a new virtual* mapping. 0 means there is enough memory for the allocation to* succeed and -ENOMEM implies there is not.* We currently support three overcommit policies, which are set via the* vm

Proto:int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)

Type:int

Parameter:

TypeParameterName
struct mm_struct *mm
longpages
intcap_sys_admin
801  VM_WARN_ONCE(percpu_counter_read( & Make sure vm_committed_as in one cacheline and not cacheline shared with* other variables. It can be updated by several CPUs frequently.) < - (s64)vm_committed_as_batch * num_online_cpus(), "memory commitment underflow")
805  vm_acct_memory(pages)
810  If sysctl_overcommit_memory == OVERCOMMIT_ALWAYS Then Return 0
813  If sysctl_overcommit_memory == OVERCOMMIT_GUESS Then
814  If pages > totalram_pages() + total_swap_pages Then Go to error
816  Return 0
819  allowed = Committed memory limit enforced when OVERCOMMIT_NEVER policy is used
823  If Not cap_sys_admin Then allowed -= sysctl_admin_reserve_kbytes >> PAGE_SHIFT determines the page size - 10
829  If mm Then
830  reserve = sysctl_user_reserve_kbytes >> PAGE_SHIFT determines the page size - 10
832  allowed -= min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(long, Total pages mapped / 32, reserve)
835  If percpu_counter is intended to track positive numbers. In the UP case the* number should never be negative. < allowed Then Return 0
837  error :
838  vm_unacct_memory(pages)
840  Return -ENOMEM