Skip to content

Commit

Permalink
mm: clear N_CPU from node_states at CPU offline
Browse files Browse the repository at this point in the history
vmstat_cpuup_callback() is a CPU notifier callback, which marks N_CPU to a
node at CPU online event.  However, it does not update this N_CPU info at
CPU offline event.

Changed vmstat_cpuup_callback() to clear N_CPU when the last CPU in the
node is put into offline, i.e.  the node no longer has any online CPU.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Christoph Lameter <cl@linux.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Tested-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Toshi Kani authored and torvalds committed Nov 13, 2013
1 parent d7e0b37 commit 807a1bd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,20 @@ static void start_cpu_timer(int cpu)
schedule_delayed_work_on(cpu, work, __round_jiffies_relative(HZ, cpu));
}

static void vmstat_cpu_dead(int node)
{
int cpu;

get_online_cpus();
for_each_online_cpu(cpu)
if (cpu_to_node(cpu) == node)
goto end;

node_clear_state(node, N_CPU);
end:
put_online_cpus();
}

/*
* Use the cpu notifier to insure that the thresholds are recalculated
* when necessary.
Expand Down Expand Up @@ -1258,6 +1272,7 @@ static int vmstat_cpuup_callback(struct notifier_block *nfb,
case CPU_DEAD:
case CPU_DEAD_FROZEN:
refresh_zone_stat_thresholds();
vmstat_cpu_dead(cpu_to_node(cpu));
break;
default:
break;
Expand Down

0 comments on commit 807a1bd

Please sign in to comment.