Commit 7fb2d46d authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

[PATCH] zone_reclaim: additional comments and cleanup

Add some comments to explain how zone reclaim works.  And it fixes the
following issues:

- PF_SWAPWRITE needs to be set for RECLAIM_SWAP to be able to write
  out pages to swap. Currently RECLAIM_SWAP may not do that.

- remove setting nr_reclaimed pages after slab reclaim since the slab shrinking
  code does not use that and the nr_reclaimed pages is just right for the
  intended follow up action.
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1742f19f
...@@ -1887,6 +1887,7 @@ int zone_reclaim_interval __read_mostly = 30*HZ; ...@@ -1887,6 +1887,7 @@ int zone_reclaim_interval __read_mostly = 30*HZ;
*/ */
static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
{ {
/* Minimum pages needed in order to stay on node */
const unsigned long nr_pages = 1 << order; const unsigned long nr_pages = 1 << order;
struct task_struct *p = current; struct task_struct *p = current;
struct reclaim_state reclaim_state; struct reclaim_state reclaim_state;
...@@ -1924,9 +1925,12 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) ...@@ -1924,9 +1925,12 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
if (nr_reclaimed < nr_pages && (zone_reclaim_mode & RECLAIM_SLAB)) { if (nr_reclaimed < nr_pages && (zone_reclaim_mode & RECLAIM_SLAB)) {
/* /*
* shrink_slab does not currently allow us to determine * shrink_slab() does not currently allow us to determine how
* how many pages were freed in the zone. So we just * many pages were freed in this zone. So we just shake the slab
* shake the slab and then go offnode for a single allocation. * a bit and then go off node for this particular allocation
* despite possibly having freed enough memory to allocate in
* this zone. If we freed local memory then the next
* allocations will be local again.
* *
* shrink_slab will free memory on all zones and may take * shrink_slab will free memory on all zones and may take
* a long time. * a long time.
...@@ -1937,8 +1941,14 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) ...@@ -1937,8 +1941,14 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
p->reclaim_state = NULL; p->reclaim_state = NULL;
current->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE); current->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE);
if (nr_reclaimed == 0) if (nr_reclaimed == 0) {
/*
* We were unable to reclaim enough pages to stay on node. We
* now allow off node accesses for a certain time period before
* trying again to reclaim pages from the local zone.
*/
zone->last_unsuccessful_zone_reclaim = jiffies; zone->last_unsuccessful_zone_reclaim = jiffies;
}
return nr_reclaimed >= nr_pages; return nr_reclaimed >= nr_pages;
} }
......
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