Skip to content

Commit

Permalink
oom: convert zone_scan_lock from mutex to spinlock
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Christoph Lameter <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rientjes authored and Linus Torvalds committed Oct 17, 2007
1 parent 9aad369 commit ae74138
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

int sysctl_panic_on_oom;
int sysctl_oom_kill_allocating_task;
static DEFINE_MUTEX(zone_scan_mutex);
static DEFINE_SPINLOCK(zone_scan_mutex);
/* #define DEBUG */

/**
Expand Down Expand Up @@ -396,7 +396,7 @@ int try_set_zone_oom(struct zonelist *zonelist)

z = zonelist->zones;

mutex_lock(&zone_scan_mutex);
spin_lock(&zone_scan_mutex);
do {
if (zone_is_oom_locked(*z)) {
ret = 0;
Expand All @@ -413,7 +413,7 @@ int try_set_zone_oom(struct zonelist *zonelist)
zone_set_flag(*z, ZONE_OOM_LOCKED);
} while (*(++z) != NULL);
out:
mutex_unlock(&zone_scan_mutex);
spin_unlock(&zone_scan_mutex);
return ret;
}

Expand All @@ -428,11 +428,11 @@ void clear_zonelist_oom(struct zonelist *zonelist)

z = zonelist->zones;

mutex_lock(&zone_scan_mutex);
spin_lock(&zone_scan_mutex);
do {
zone_clear_flag(*z, ZONE_OOM_LOCKED);
} while (*(++z) != NULL);
mutex_unlock(&zone_scan_mutex);
spin_unlock(&zone_scan_mutex);
}

/**
Expand Down

0 comments on commit ae74138

Please sign in to comment.