summaryrefslogtreecommitdiff
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
authorGaurav Kohli <gkohli@codeaurora.org>2018-04-24 12:13:34 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2018-09-07 04:49:36 -0700
commita5e204282a8c65f3d810ba03414c436a292b695d (patch)
treeb9501723bfd40f35a8dac1bdbe204855a1e50eb0 /fs/btrfs/dev-replace.c
parentab3dba93ceea12d3498d522a5459631f518894ae (diff)
kthread/smpboot: Serialize kthread parking against wakeup
The control cpu thread which initiates hotplug calls kthread_park() for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control thread wakes up the hotplug thread. There is a chance that wakeup code sees the hotplug thread (running on AP core) in INTERRUPTIBLE state, but sets its state to RUNNING after hotplug thread has entered kthread_parkme() and changed its state to TASK_PARKED. This can result in panic later on in kthread_unpark(), as it sees KTHREAD_IS_PARKED flag set but fails to rebind the kthread, due to it being not in TASK_PARKED state. Fix this, by serializing wakeup state change, against state change before parking the kthread. Below is the possible race: Control thread Hotplug Thread kthread_park() set KTHREAD_SHOULD_PARK smpboot_thread_fn set_current_state(TASK_INTERRUPTIBLE); kthread_parkme wake_up_process() raw_spin_lock_irqsave(&p->pi_lock, flags); if (!(p->state & state)) -> this will fail goto out; __kthread_parkme __set_current_state(TASK_PARKED); if (p->on_rq && ttwu_remote(p, wake_flags)) ttwu_remote() p->state = TASK_RUNNING; schedule(); So to avoid this race, take pi_lock to serial state changes. Change-Id: Ie71645d37046f7ee74df880dbead29efbaad199a Suggested-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org> Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
0 files changed, 0 insertions, 0 deletions