Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40385
b: refs/heads/master
c: 3bb1a85
h: refs/heads/master
i:
  40383: 346ccad
v: v3
  • Loading branch information
Martin Bligh authored and Linus Torvalds committed Oct 28, 2006
1 parent a2b64a2 commit 7bb4183
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2ae88149a27cadf2840e0ab8155bef13be285c03
refs/heads/master: 3bb1a852ab6c9cdf211a2f4a2f502340c8c38eca
6 changes: 1 addition & 5 deletions trunk/include/linux/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,9 @@ struct zone {
* under - it drives the swappiness decision: whether to unmap mapped
* pages.
*
* temp_priority is used to remember the scanning priority at which
* this zone was successfully refilled to free_pages == pages_high.
*
* Access to both these fields is quite racy even on uniprocessor. But
* Access to both this field is quite racy even on uniprocessor. But
* it is expected to average out OK.
*/
int temp_priority;
int prev_priority;


Expand Down
2 changes: 1 addition & 1 deletion trunk/mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
zone->zone_pgdat = pgdat;
zone->free_pages = 0;

zone->temp_priority = zone->prev_priority = DEF_PRIORITY;
zone->prev_priority = DEF_PRIORITY;

zone_pcp_init(zone);
INIT_LIST_HEAD(&zone->active_list);
Expand Down
55 changes: 41 additions & 14 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,20 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
return nr_reclaimed;
}

/*
* We are about to scan this zone at a certain priority level. If that priority
* level is smaller (ie: more urgent) than the previous priority, then note
* that priority level within the zone. This is done so that when the next
* process comes in to scan this zone, it will immediately start out at this
* priority level rather than having to build up its own scanning priority.
* Here, this priority affects only the reclaim-mapped threshold.
*/
static inline void note_zone_scanning_priority(struct zone *zone, int priority)
{
if (priority < zone->prev_priority)
zone->prev_priority = priority;
}

static inline int zone_is_near_oom(struct zone *zone)
{
return zone->pages_scanned >= (zone->nr_active + zone->nr_inactive)*3;
Expand Down Expand Up @@ -972,9 +986,7 @@ static unsigned long shrink_zones(int priority, struct zone **zones,
if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
continue;

zone->temp_priority = priority;
if (zone->prev_priority > priority)
zone->prev_priority = priority;
note_zone_scanning_priority(zone, priority);

if (zone->all_unreclaimable && priority != DEF_PRIORITY)
continue; /* Let kswapd poll it */
Expand Down Expand Up @@ -1024,7 +1036,6 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
continue;

zone->temp_priority = DEF_PRIORITY;
lru_pages += zone->nr_active + zone->nr_inactive;
}

Expand Down Expand Up @@ -1065,13 +1076,22 @@ unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
if (!sc.all_unreclaimable)
ret = 1;
out:
/*
* Now that we've scanned all the zones at this priority level, note
* that level within the zone so that the next thread which performs
* scanning of this zone will immediately start out at this priority
* level. This affects only the decision whether or not to bring
* mapped pages onto the inactive list.
*/
if (priority < 0)
priority = 0;
for (i = 0; zones[i] != 0; i++) {
struct zone *zone = zones[i];

if (!cpuset_zone_allowed(zone, __GFP_HARDWALL))
continue;

zone->prev_priority = zone->temp_priority;
zone->prev_priority = priority;
}
return ret;
}
Expand Down Expand Up @@ -1111,18 +1131,20 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
.swap_cluster_max = SWAP_CLUSTER_MAX,
.swappiness = vm_swappiness,
};
/*
* temp_priority is used to remember the scanning priority at which
* this zone was successfully refilled to free_pages == pages_high.
*/
int temp_priority[MAX_NR_ZONES];

loop_again:
total_scanned = 0;
nr_reclaimed = 0;
sc.may_writepage = !laptop_mode;
count_vm_event(PAGEOUTRUN);

for (i = 0; i < pgdat->nr_zones; i++) {
struct zone *zone = pgdat->node_zones + i;

zone->temp_priority = DEF_PRIORITY;
}
for (i = 0; i < pgdat->nr_zones; i++)
temp_priority[i] = DEF_PRIORITY;

for (priority = DEF_PRIORITY; priority >= 0; priority--) {
int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */
Expand Down Expand Up @@ -1183,10 +1205,9 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
if (!zone_watermark_ok(zone, order, zone->pages_high,
end_zone, 0))
all_zones_ok = 0;
zone->temp_priority = priority;
if (zone->prev_priority > priority)
zone->prev_priority = priority;
temp_priority[i] = priority;
sc.nr_scanned = 0;
note_zone_scanning_priority(zone, priority);
nr_reclaimed += shrink_zone(priority, zone, &sc);
reclaim_state->reclaimed_slab = 0;
nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL,
Expand Down Expand Up @@ -1226,10 +1247,15 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
break;
}
out:
/*
* Note within each zone the priority level at which this zone was
* brought into a happy state. So that the next thread which scans this
* zone will start out at that priority level.
*/
for (i = 0; i < pgdat->nr_zones; i++) {
struct zone *zone = pgdat->node_zones + i;

zone->prev_priority = zone->temp_priority;
zone->prev_priority = temp_priority[i];
}
if (!all_zones_ok) {
cond_resched();
Expand Down Expand Up @@ -1614,6 +1640,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
*/
priority = ZONE_RECLAIM_PRIORITY;
do {
note_zone_scanning_priority(zone, priority);
nr_reclaimed += shrink_zone(priority, zone, &sc);
priority--;
} while (priority >= 0 && nr_reclaimed < nr_pages);
Expand Down
2 changes: 0 additions & 2 deletions trunk/mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,9 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
seq_printf(m,
"\n all_unreclaimable: %u"
"\n prev_priority: %i"
"\n temp_priority: %i"
"\n start_pfn: %lu",
zone->all_unreclaimable,
zone->prev_priority,
zone->temp_priority,
zone->zone_start_pfn);
spin_unlock_irqrestore(&zone->lock, flags);
seq_putc(m, '\n');
Expand Down

0 comments on commit 7bb4183

Please sign in to comment.