From f31c9f8ad9fbadcc9722b09f180f6d01b2165c97 Mon Sep 17 00:00:00 2001 From: Qiao Nuohan Date: Sat, 23 Aug 2014 15:01:06 +0800 Subject: [PATCH 10/23] x86_64: modify set -c only be available on online cpus With this patch, set -c cannot set to an offline cpu. If so, only a message like below will be printed. set invalid cpu number: cpu xx is offline Signed-off-by: Qiao Nuohan --- kernel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel.c b/kernel.c index 127bf3a..ff1f2e1 100755 --- a/kernel.c +++ b/kernel.c @@ -5469,6 +5469,10 @@ set_cpu(int cpu) if (cpu >= kt->cpus) error(FATAL, "invalid cpu number: system has only %d cpu%s\n", kt->cpus, kt->cpus > 1 ? "s" : ""); + + if (check_offline_cpu(cpu)) + error(FATAL, "invalid cpu number: cpu %d is offline\n", cpu); + if ((task = get_active_task(cpu))) set_context(task, NO_PID); else -- 1.8.5.3