Commit 0cb57258 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

swsusp: clean up shrink_all_zones()

Move local variables to innermost possible scopes and use local
variables to cache calculations/reads done more than once.

No change in functionality (intended).
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Reviewed-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Cc: Len Brown <lenb@kernel.org>
Cc: Greg KH <gregkh@suse.de>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3049103d
...@@ -2057,31 +2057,31 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio, ...@@ -2057,31 +2057,31 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
int pass, struct scan_control *sc) int pass, struct scan_control *sc)
{ {
struct zone *zone; struct zone *zone;
unsigned long nr_to_scan, ret = 0; unsigned long ret = 0;
enum lru_list l;
for_each_zone(zone) { for_each_zone(zone) {
enum lru_list l;
if (!populated_zone(zone)) if (!populated_zone(zone))
continue; continue;
if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY) if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY)
continue; continue;
for_each_evictable_lru(l) { for_each_evictable_lru(l) {
enum zone_stat_item ls = NR_LRU_BASE + l;
unsigned long lru_pages = zone_page_state(zone, ls);
/* For pass = 0, we don't shrink the active list */ /* For pass = 0, we don't shrink the active list */
if (pass == 0 && if (pass == 0 && (l == LRU_ACTIVE_ANON ||
(l == LRU_ACTIVE || l == LRU_ACTIVE_FILE)) l == LRU_ACTIVE_FILE))
continue; continue;
zone->lru[l].nr_scan += zone->lru[l].nr_scan += (lru_pages >> prio) + 1;
(zone_page_state(zone, NR_LRU_BASE + l)
>> prio) + 1;
if (zone->lru[l].nr_scan >= nr_pages || pass > 3) { if (zone->lru[l].nr_scan >= nr_pages || pass > 3) {
unsigned long nr_to_scan;
zone->lru[l].nr_scan = 0; zone->lru[l].nr_scan = 0;
nr_to_scan = min(nr_pages, nr_to_scan = min(nr_pages, lru_pages);
zone_page_state(zone,
NR_LRU_BASE + l));
ret += shrink_list(l, nr_to_scan, zone, ret += shrink_list(l, nr_to_scan, zone,
sc, prio); sc, prio);
if (ret >= nr_pages) if (ret >= nr_pages)
...@@ -2089,7 +2089,6 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio, ...@@ -2089,7 +2089,6 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
} }
} }
} }
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment