[PATCH] do not free non slab allocated per_cpu_pageset

David Rientjes
2006-09-22T18:20:35Z

On Thu, 21 Sep 2006, David Rientjes wrote:

> The _only_ time zone_pcp is slab allocated is through process_zones(). So
> if we have an error on kmalloc_node for that zone_pcp, all previous
> allocations are freed and process_zones() fails for that cpu.
>
> We are guaranteed that the process_zones() for cpu 0 succeeds, otherwise
> the pageset notifier isn't registered. On CPU_UP_PREPARE for cpu 4 in
> this case, process_zones() fails because we couldn't kmalloc the
> per_cpu_pageset and we return NOTIFY_BAD. This prints the failed message
> in the report and then CPU_UP_CANCELED is sent back to the notifier which
> attempts to kfree the zone that was never kmalloc'd.
>
> The fix will work except for the case that zone_pcp is never set to NULL
> as it should be.
>

As reported by Keith, the following 2.6.18 patch stops the panic
associated with attempting to free a non slab-allocated per_cpu_pageset.

Signed-off-by: David Rientjes <rientjes@cs.washington.edu>
---
mm/page_alloc.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 54a4f53..e16173f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1845,8 +1845,10 @@ static inline void free_zone_pagesets(in
for_each_zone(zone) {
struct per_cpu_pageset *pset = zone_pcp(zone, cpu);

+ /* Free per_cpu_pageset if it is slab allocated */
+ if (pset != &boot_pageset[cpu])
+ kfree(pset);
zone_pcp(zone, cpu) = NULL;
- kfree(pset);
}
}