oom: convert zone_scan_lock from mutex to spinlock

There's no reason to sleep in try_set_zone_oom() or clear_zonelist_oom() if
the lock can't be acquired; it will be available soon enough once the zonelist
scanning is done.  All other threads waiting for the OOM killer are also
contingent on the exiting task being able to acquire the lock in
clear_zonelist_oom() so it doesn't make sense to put it to sleep.

Cc: Andrea Arcangeli <andrea@suse.de>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
David Rientjes 2007-10-16 23:26:00 -07:00 committed by Linus Torvalds
parent 9aad369e56
commit ae74138da6
1 changed files with 5 additions and 5 deletions

View File

@ -28,7 +28,7 @@
int sysctl_panic_on_oom; int sysctl_panic_on_oom;
int sysctl_oom_kill_allocating_task; int sysctl_oom_kill_allocating_task;
static DEFINE_MUTEX(zone_scan_mutex); static DEFINE_SPINLOCK(zone_scan_mutex);
/* #define DEBUG */ /* #define DEBUG */
/** /**
@ -396,7 +396,7 @@ int try_set_zone_oom(struct zonelist *zonelist)
z = zonelist->zones; z = zonelist->zones;
mutex_lock(&zone_scan_mutex); spin_lock(&zone_scan_mutex);
do { do {
if (zone_is_oom_locked(*z)) { if (zone_is_oom_locked(*z)) {
ret = 0; ret = 0;
@ -413,7 +413,7 @@ int try_set_zone_oom(struct zonelist *zonelist)
zone_set_flag(*z, ZONE_OOM_LOCKED); zone_set_flag(*z, ZONE_OOM_LOCKED);
} while (*(++z) != NULL); } while (*(++z) != NULL);
out: out:
mutex_unlock(&zone_scan_mutex); spin_unlock(&zone_scan_mutex);
return ret; return ret;
} }
@ -428,11 +428,11 @@ void clear_zonelist_oom(struct zonelist *zonelist)
z = zonelist->zones; z = zonelist->zones;
mutex_lock(&zone_scan_mutex); spin_lock(&zone_scan_mutex);
do { do {
zone_clear_flag(*z, ZONE_OOM_LOCKED); zone_clear_flag(*z, ZONE_OOM_LOCKED);
} while (*(++z) != NULL); } while (*(++z) != NULL);
mutex_unlock(&zone_scan_mutex); spin_unlock(&zone_scan_mutex);
} }
/** /**