diff options
author | Paul Jackson <pj@sgi.com> | 2006-01-14 16:21:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-14 21:27:10 -0500 |
commit | 505970b96e3b7d22177c38e03435a68376628e7a (patch) | |
tree | 5508317e391961355bf3d946a6aac05bb21569eb /mm | |
parent | ed68cb3676bb179768529aeb808403d57295af56 (diff) |
[PATCH] cpuset oom lock fix
The problem, reported in:
http://bugzilla.kernel.org/show_bug.cgi?id=5859
and by various other email messages and lkml posts is that the cpuset hook
in the oom (out of memory) code can try to take a cpuset semaphore while
holding the tasklist_lock (a spinlock).
One must not sleep while holding a spinlock.
The fix seems easy enough - move the cpuset semaphore region outside the
tasklist_lock region.
This required a few lines of mechanism to implement. The oom code where
the locking needs to be changed does not have access to the cpuset locks,
which are internal to kernel/cpuset.c only. So I provided a couple more
cpuset interface routines, available to the rest of the kernel, which
simple take and drop the lock needed here (cpusets callback_sem).
Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/oom_kill.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 4748b906aff2..14bd4ec79597 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -274,6 +274,7 @@ void out_of_memory(gfp_t gfp_mask, int order) | |||
274 | show_mem(); | 274 | show_mem(); |
275 | } | 275 | } |
276 | 276 | ||
277 | cpuset_lock(); | ||
277 | read_lock(&tasklist_lock); | 278 | read_lock(&tasklist_lock); |
278 | retry: | 279 | retry: |
279 | p = select_bad_process(); | 280 | p = select_bad_process(); |
@@ -284,6 +285,7 @@ retry: | |||
284 | /* Found nothing?!?! Either we hang forever, or we panic. */ | 285 | /* Found nothing?!?! Either we hang forever, or we panic. */ |
285 | if (!p) { | 286 | if (!p) { |
286 | read_unlock(&tasklist_lock); | 287 | read_unlock(&tasklist_lock); |
288 | cpuset_unlock(); | ||
287 | panic("Out of memory and no killable processes...\n"); | 289 | panic("Out of memory and no killable processes...\n"); |
288 | } | 290 | } |
289 | 291 | ||
@@ -293,6 +295,7 @@ retry: | |||
293 | 295 | ||
294 | out: | 296 | out: |
295 | read_unlock(&tasklist_lock); | 297 | read_unlock(&tasklist_lock); |
298 | cpuset_unlock(); | ||
296 | if (mm) | 299 | if (mm) |
297 | mmput(mm); | 300 | mmput(mm); |
298 | 301 | ||