Commit 33a7ddaa authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] introduce __drain_pages() to take a CPU number

Extracts core of drain_pages() for hotcpu use.  Trivial.

Hotplug CPU needs to drain pages on a downed CPU (usually it's the
current cpu).  Introduce "__drain_pages", make the CPU an argument,
and expose it if CONFIG_HOTPLUG_CPU as well as CONFIG_PM.
parent 409f3569
......@@ -390,6 +390,27 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
return allocated;
}
#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
static void __drain_pages(unsigned int cpu)
{
struct zone *zone;
int i;
for_each_zone(zone) {
struct per_cpu_pageset *pset;
pset = &zone->pageset[cpu];
for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
struct per_cpu_pages *pcp;
pcp = &pset->pcp[i];
pcp->count -= free_pages_bulk(zone, pcp->count,
&pcp->list, 0);
}
}
}
#endif /* CONFIG_PM || CONFIG_HOTPLUG_CPU */
#ifdef CONFIG_PM
int is_head_of_free_region(struct page *page)
{
......@@ -419,22 +440,9 @@ int is_head_of_free_region(struct page *page)
void drain_local_pages(void)
{
unsigned long flags;
struct zone *zone;
int i;
local_irq_save(flags);
for_each_zone(zone) {
struct per_cpu_pageset *pset;
pset = &zone->pageset[smp_processor_id()];
for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
struct per_cpu_pages *pcp;
pcp = &pset->pcp[i];
pcp->count -= free_pages_bulk(zone, pcp->count,
&pcp->list, 0);
}
}
__drain_pages(smp_processor_id());
local_irq_restore(flags);
}
#endif /* CONFIG_PM */
......
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