Files
linuxkit/kernel/patches-4.14.x-rt/0374-srcu-use-cpu_online-instead-custom-check.patch
Tiejun Chen ef9302bc01 update -rt to 4.14.87-rt50
Signed-off-by: Tiejun Chen <tiejunc@vmware.com>
2019-01-14 20:49:28 -08:00

108 lines
3.1 KiB
Diff

From caaa4d10322908e9a347914745e83e2a55078869 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 13 Sep 2017 14:43:41 +0200
Subject: [PATCH 374/450] srcu: use cpu_online() instead custom check
The current check via srcu_online is slightly racy because after looking
at srcu_online there could be an interrupt that interrupted us long
enough until the CPU we checked against went offline.
An alternative would be to hold the hotplug rwsem (so the CPUs don't
change their state) and then check based on cpu_online() if we queue it
on a specific CPU or not. queue_work_on() itself can handle if something
is enqueued on an offline CPU but a timer which is enqueued on an offline
CPU won't fire until the CPU is back online.
I am not sure if the removal in rcu_init() is okay or not. I assume that
SRCU won't enqueue a work item before SRCU is up and ready.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
kernel/rcu/srcutree.c | 22 ++++------------------
kernel/rcu/tree.c | 6 ------
2 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 6d5880089ff6..b72d8c552604 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -36,6 +36,7 @@
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/srcu.h>
+#include <linux/cpu.h>
#include "rcu.h"
#include "rcu_segcblist.h"
@@ -424,21 +425,6 @@ static void srcu_gp_start(struct srcu_struct *sp)
WARN_ON_ONCE(state != SRCU_STATE_SCAN1);
}
-/*
- * Track online CPUs to guide callback workqueue placement.
- */
-DEFINE_PER_CPU(bool, srcu_online);
-
-void srcu_online_cpu(unsigned int cpu)
-{
- WRITE_ONCE(per_cpu(srcu_online, cpu), true);
-}
-
-void srcu_offline_cpu(unsigned int cpu)
-{
- WRITE_ONCE(per_cpu(srcu_online, cpu), false);
-}
-
/*
* Place the workqueue handler on the specified CPU if online, otherwise
* just run it whereever. This is useful for placing workqueue handlers
@@ -450,12 +436,12 @@ static bool srcu_queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
{
bool ret;
- preempt_disable();
- if (READ_ONCE(per_cpu(srcu_online, cpu)))
+ cpus_read_lock();
+ if (cpu_online(cpu))
ret = queue_delayed_work_on(cpu, wq, dwork, delay);
else
ret = queue_delayed_work(wq, dwork, delay);
- preempt_enable();
+ cpus_read_unlock();
return ret;
}
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index f37d06ec5ee1..9eb9cfc9c9c1 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3784,8 +3784,6 @@ int rcutree_online_cpu(unsigned int cpu)
{
sync_sched_exp_online_cleanup(cpu);
rcutree_affinity_setting(cpu, -1);
- if (IS_ENABLED(CONFIG_TREE_SRCU))
- srcu_online_cpu(cpu);
return 0;
}
@@ -3796,8 +3794,6 @@ int rcutree_online_cpu(unsigned int cpu)
int rcutree_offline_cpu(unsigned int cpu)
{
rcutree_affinity_setting(cpu, cpu);
- if (IS_ENABLED(CONFIG_TREE_SRCU))
- srcu_offline_cpu(cpu);
return 0;
}
@@ -4245,8 +4241,6 @@ void __init rcu_init(void)
for_each_online_cpu(cpu) {
rcutree_prepare_cpu(cpu);
rcu_cpu_starting(cpu);
- if (IS_ENABLED(CONFIG_TREE_SRCU))
- srcu_online_cpu(cpu);
}
}
--
2.19.2