smp/hotplug: Hotplug state fail injection
authorPeter Zijlstra <peterz@infradead.org>
Wed, 20 Sep 2017 17:00:21 +0000 (19:00 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 20:11:44 +0000 (22:11 +0200)
commit1db49484f21ed0fcdadd0635a3669f5f386546fa
tree533d9d2c340550a1b60bafcf77eff90fce1fe409
parent5ebe7742fff8be5f1359bc50f5d43fb6ff7bd060
smp/hotplug: Hotplug state fail injection

Add a sysfs file to one-time fail a specific state. This can be used
to test the state rollback code paths.

Something like this (hotplug-up.sh):

  #!/bin/bash

  echo 0 > /debug/sched_debug
  echo 1 > /debug/tracing/events/cpuhp/enable

  ALL_STATES=`cat /sys/devices/system/cpu/hotplug/states | cut -d':' -f1`
  STATES=${1:-$ALL_STATES}

  for state in $STATES
  do
  echo 0 > /sys/devices/system/cpu/cpu1/online
  echo 0 > /debug/tracing/trace
  echo Fail state: $state
  echo $state > /sys/devices/system/cpu/cpu1/hotplug/fail
  cat /sys/devices/system/cpu/cpu1/hotplug/fail
  echo 1 > /sys/devices/system/cpu/cpu1/online

  cat /debug/tracing/trace > hotfail-${state}.trace

  sleep 1
  done

Can be used to test for all possible rollback (barring multi-instance)
scenarios on CPU-up, CPU-down is a trivial modification of the above.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: bigeasy@linutronix.de
Cc: efault@gmx.de
Cc: rostedt@goodmis.org
Cc: max.byungchul.park@gmail.com
Link: https://lkml.kernel.org/r/20170920170546.972581715@infradead.org
include/linux/cpuhotplug.h
kernel/cpu.c