Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
oom_kill.c File Reference
#include <linux/oom.h>
#include <linux/mm.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/sched.h>
#include <linux/swap.h>
#include <linux/timex.h>
#include <linux/jiffies.h>
#include <linux/cpuset.h>
#include <linux/export.h>
#include <linux/notifier.h>
#include <linux/memcontrol.h>
#include <linux/mempolicy.h>
#include <linux/security.h>
#include <linux/ptrace.h>
#include <linux/freezer.h>
#include <linux/ftrace.h>
#include <linux/ratelimit.h>
#include <trace/events/oom.h>

Go to the source code of this file.


#define K(x)   ((x) << (PAGE_SHIFT-10))


void compare_swap_oom_score_adj (int old_val, int new_val)
int test_set_oom_score_adj (int new_val)
struct task_structfind_lock_task_mm (struct task_struct *p)
unsigned long oom_badness (struct task_struct *p, struct mem_cgroup *memcg, const nodemask_t *nodemask, unsigned long totalpages)
enum oom_scan_t oom_scan_process_thread (struct task_struct *task, unsigned long totalpages, const nodemask_t *nodemask, bool force_kill)
void oom_kill_process (struct task_struct *p, gfp_t gfp_mask, int order, unsigned int points, unsigned long totalpages, struct mem_cgroup *memcg, nodemask_t *nodemask, const char *message)
void check_panic_on_oom (enum oom_constraint constraint, gfp_t gfp_mask, int order, const nodemask_t *nodemask)
int register_oom_notifier (struct notifier_block *nb)
 EXPORT_SYMBOL_GPL (register_oom_notifier)
int unregister_oom_notifier (struct notifier_block *nb)
 EXPORT_SYMBOL_GPL (unregister_oom_notifier)
int try_set_zonelist_oom (struct zonelist *zonelist, gfp_t gfp_mask)
void clear_zonelist_oom (struct zonelist *zonelist, gfp_t gfp_mask)
void out_of_memory (struct zonelist *zonelist, gfp_t gfp_mask, int order, nodemask_t *nodemask, bool force_kill)
void pagefault_out_of_memory (void)


int sysctl_panic_on_oom
int sysctl_oom_kill_allocating_task
int sysctl_oom_dump_tasks = 1

Macro Definition Documentation


Definition at line 39 of file oom_kill.c.

#define K (   x)    ((x) << (PAGE_SHIFT-10))

Definition at line 443 of file oom_kill.c.

Function Documentation

void check_panic_on_oom ( enum oom_constraint  constraint,
gfp_t  gfp_mask,
int  order,
const nodemask_t nodemask 

Definition at line 559 of file oom_kill.c.

void clear_zonelist_oom ( struct zonelist zonelist,
gfp_t  gfp_mask 

Definition at line 630 of file oom_kill.c.

void compare_swap_oom_score_adj ( int  old_val,
int  new_val 

Definition at line 56 of file oom_kill.c.

EXPORT_SYMBOL_GPL ( register_oom_notifier  )
EXPORT_SYMBOL_GPL ( unregister_oom_notifier  )
struct task_struct* find_lock_task_mm ( struct task_struct p)

Definition at line 140 of file oom_kill.c.

unsigned long oom_badness ( struct task_struct p,
struct mem_cgroup memcg,
const nodemask_t nodemask,
unsigned long  totalpages 

oom_badness - heuristic function to determine which candidate task to kill : task struct of which task we should calculate : total present RAM allowed for page allocation

The heuristic for determining which task to kill is made to be as simple and predictable as possible. The goal is to return the highest value for the task consuming the most memory to avoid subsequent oom failures.

Definition at line 183 of file oom_kill.c.

void oom_kill_process ( struct task_struct p,
gfp_t  gfp_mask,
int  order,
unsigned int  points,
unsigned long  totalpages,
struct mem_cgroup memcg,
nodemask_t nodemask,
const char message 

Definition at line 448 of file oom_kill.c.

enum oom_scan_t oom_scan_process_thread ( struct task_struct task,
unsigned long  totalpages,
const nodemask_t nodemask,
bool  force_kill 

Definition at line 291 of file oom_kill.c.

void out_of_memory ( struct zonelist zonelist,
gfp_t  gfp_mask,
int  order,
nodemask_t nodemask,
bool  force_kill 

out_of_memory - kill the "best" process when we run out of memory : zonelist pointer : memory allocation flags : amount of memory being requested as a power of 2 : nodemask passed to page allocator : true if a task must be killed, even if others are exiting

If we run out of memory, we have the choice between either killing a random task (bad), letting the system crash (worse) OR try to be smart about which process to kill. Note that we don't have to be perfect here, we just have to be good.

Definition at line 692 of file oom_kill.c.

void pagefault_out_of_memory ( void  )

Definition at line 763 of file oom_kill.c.

int register_oom_notifier ( struct notifier_block nb)

Definition at line 580 of file oom_kill.c.

int test_set_oom_score_adj ( int  new_val)

test_set_oom_score_adj() - set current's oom_score_adj and return old value : new oom_score_adj value

Sets the oom_score_adj value for current to with proper synchronization and returns the old value. Usually used to temporarily set a value, save the old value in the caller, and then reinstate it later.

Definition at line 75 of file oom_kill.c.

int try_set_zonelist_oom ( struct zonelist zonelist,
gfp_t  gfp_mask 

Definition at line 597 of file oom_kill.c.

int unregister_oom_notifier ( struct notifier_block nb)

Definition at line 586 of file oom_kill.c.

Variable Documentation

int sysctl_oom_dump_tasks = 1

Definition at line 44 of file oom_kill.c.

int sysctl_oom_kill_allocating_task

Definition at line 43 of file oom_kill.c.

int sysctl_panic_on_oom

Definition at line 42 of file oom_kill.c.