Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\oom_kill.c Create Date:2022-07-28 14:06:29
Last Modify:2022-05-23 13:16:41 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__oom_kill_process

Proto:static void __oom_kill_process(struct task_struct *victim, const char *message)

Type:void

Parameter:

TypeParameterName
struct task_struct *victim
const char *message
860  bool can_oom_reap = true
862  p = The process p may have detached its own ->mm while exiting or through* use_mm(), but one or more of its subthreads may still have a valid* pointer. Return p, or any of its subthreads with a valid ->mm, with* task_lock() held.
863  If Not p Then
864  put_task_struct(victim)
865  Return
866  Else if victim != p Then
867  get_task_struct(p)
868  put_task_struct(victim)
869  victim = p
873  mm = mm
874  mmgrab() - Pin a &struct mm_struct
877  Disable counters
878  memcg_memory_event_mm(mm, MEMCG_OOM_KILL)
885  do_send_sig_info(SIGKILL, SEND_SIG_PRIV, victim, PIDTYPE_TGID)
886  mark_oom_victim - mark the given task as OOM victim*@tsk: task to mark* Has to be called with oom_lock held and never after* oom has been disabled already.* under task_lock or operate on the current).
887  pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n", message, task_pid_nr(victim), comm, K( Total pages mapped ), K(per-process(per-mm_struct) statistics.), K(per-process(per-mm_struct) statistics.), K(per-process(per-mm_struct) statistics.), m_kuid - Create a uid from a kuid user-namespace pair.*@targ: The user namespace we want a uid in.*@kuid: The kernel internal uid to start with.* Map @kuid into the user-namespace specified by @targ and* return the resulting uid., mm_pgtables_bytes(mm) >> 10, oom_score_adj)
894  task_unlock(victim)
905  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
907  If Not ask->mm can be NULL if the task is the exited group leader. So to* determine whether the task is using a particular mm, we examine all the* task's threads: if one of those is using this mm then this task was also* using it. Then Continue
909  If same_thread_group(p, victim) Then Continue
911  If s_global_init - check if a task structure is init. Since init* is free to have sub-threads we need to check tgid.*@tsk: Task structure to be checked.* Check if a task structure is the first user space task the kernel created. Then
912  can_oom_reap = false
913  Atomically set a bit in memory
914  pr_info("oom killer %d (%s) has mm pinned by %d (%s)\n", task_pid_nr(victim), comm, task_pid_nr(p), comm)
917  Continue
923  If Value for the false possibility is greater at compile time(flags & I am a kernel thread ) Then Continue
925  do_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_TGID)
927  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
929  If can_oom_reap Then wake_oom_reaper(victim)
932  mmdrop(mm)
933  put_task_struct(victim)
Caller
NameDescribe
oom_kill_memcg_memberKill provided task unless it's secured by setting* oom_score_adj to OOM_SCORE_ADJ_MIN.
oom_kill_process