From 6decc40e63e8bfa2fb56ef482817081a20f0a970 Mon Sep 17 00:00:00 2001 From: Paul Jackson Date: Tue, 6 Sep 2005 15:18:13 -0700 Subject: [PATCH] --- yaml --- r: 7423 b: refs/heads/master c: ef08e3b4981aebf2ba9bd7025ef7210e8eec07ce h: refs/heads/master i: 7421: 8643f6f973f79f1bdbfaa1e2b625ed51303a5bf8 7419: bc0d691161f79a4fdbe2fe78b6c28f75736a76e2 7415: 102f3bc2590db2083fd957f8d59904c38a3ec069 7407: 4071ce008d9adfd90bdbb69a6e3ee54873030842 7391: f6f16c17ab7a2ecc3a0afd2fdadb614ef21ec2b0 7359: b1984f21cdfa3d6090cc0157f3001cf5992c9ef4 7295: 94638a80b744a6c22678334f8f6c5b7c69ff6467 7167: 4561ccd15ea6c93158b7673001941c678ccc34da v: v3 --- [refs] | 2 +- trunk/include/linux/cpuset.h | 6 ++++++ trunk/kernel/cpuset.c | 33 +++++++++++++++++++++++++++++++++ trunk/mm/oom_kill.c | 5 +++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 6413d2d86037..32c68abc6fd9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9bf2229f8817677127a60c177aefce1badd22d7b +refs/heads/master: ef08e3b4981aebf2ba9bd7025ef7210e8eec07ce diff --git a/trunk/include/linux/cpuset.h b/trunk/include/linux/cpuset.h index 1fe1c3ebad30..24062a1dbf61 100644 --- a/trunk/include/linux/cpuset.h +++ b/trunk/include/linux/cpuset.h @@ -24,6 +24,7 @@ void cpuset_update_current_mems_allowed(void); void cpuset_restrict_to_mems_allowed(unsigned long *nodes); int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); extern int cpuset_zone_allowed(struct zone *z, unsigned int __nocast gfp_mask); +extern int cpuset_excl_nodes_overlap(const struct task_struct *p); extern struct file_operations proc_cpuset_operations; extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); @@ -54,6 +55,11 @@ static inline int cpuset_zone_allowed(struct zone *z, return 1; } +static inline int cpuset_excl_nodes_overlap(const struct task_struct *p) +{ + return 1; +} + static inline char *cpuset_task_status_allowed(struct task_struct *task, char *buffer) { diff --git a/trunk/kernel/cpuset.c b/trunk/kernel/cpuset.c index 214806deca99..40c6d801dd66 100644 --- a/trunk/kernel/cpuset.c +++ b/trunk/kernel/cpuset.c @@ -1688,6 +1688,39 @@ int cpuset_zone_allowed(struct zone *z, unsigned int __nocast gfp_mask) return allowed; } +/** + * cpuset_excl_nodes_overlap - Do we overlap @p's mem_exclusive ancestors? + * @p: pointer to task_struct of some other task. + * + * Description: Return true if the nearest mem_exclusive ancestor + * cpusets of tasks @p and current overlap. Used by oom killer to + * determine if task @p's memory usage might impact the memory + * available to the current task. + * + * Acquires cpuset_sem - not suitable for calling from a fast path. + **/ + +int cpuset_excl_nodes_overlap(const struct task_struct *p) +{ + const struct cpuset *cs1, *cs2; /* my and p's cpuset ancestors */ + int overlap = 0; /* do cpusets overlap? */ + + down(&cpuset_sem); + cs1 = current->cpuset; + if (!cs1) + goto done; /* current task exiting */ + cs2 = p->cpuset; + if (!cs2) + goto done; /* task p is exiting */ + cs1 = nearest_exclusive_ancestor(cs1); + cs2 = nearest_exclusive_ancestor(cs2); + overlap = nodes_intersects(cs1->mems_allowed, cs2->mems_allowed); +done: + up(&cpuset_sem); + + return overlap; +} + /* * proc_cpuset_show() * - Print tasks cpuset path into seq_file. diff --git a/trunk/mm/oom_kill.c b/trunk/mm/oom_kill.c index 3a1d46502938..5ec8da12cfd9 100644 --- a/trunk/mm/oom_kill.c +++ b/trunk/mm/oom_kill.c @@ -20,6 +20,7 @@ #include #include #include +#include /* #define DEBUG */ @@ -152,6 +153,10 @@ static struct task_struct * select_bad_process(void) continue; if (p->oomkilladj == OOM_DISABLE) continue; + /* If p's nodes don't overlap ours, it won't help to kill p. */ + if (!cpuset_excl_nodes_overlap(p)) + continue; + /* * This is in the process of releasing memory so for wait it * to finish before killing some other task by mistake.