[RFC PATCH] rcu: Change use of __this_cpu ops on a bool type

From: Pranith Kumar
Date: Fri Sep 19 2014 - 13:26:13 EST


__this_cpu_{read/write}() uses sizeof() to determine the size of the variable.
Using this operation on a bool type causes sparse to complain.

I checked the generated code and there is only a slight difference in
instructions generated.

I am not sure this warning by sparse is really valid, but let us silence it
anyways.

Signed-off-by: Pranith Kumar <bobby.prani@xxxxxxxxx>
---
kernel/rcu/tree.c | 12 ++++++++----
kernel/rcu/tree_plugin.h | 6 ++++--
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index bc085e5..85f228a 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -186,21 +186,25 @@ static int rcu_gp_in_progress(struct rcu_state *rsp)
*/
void rcu_sched_qs(void)
{
- if (!__this_cpu_read(rcu_sched_data.passed_quiesce)) {
+ struct rcu_data *rdp = __this_cpu_ptr(&rcu_sched_data);
+
+ if (!rdp->passed_quiesce) {
trace_rcu_grace_period(TPS("rcu_sched"),
__this_cpu_read(rcu_sched_data.gpnum),
TPS("cpuqs"));
- __this_cpu_write(rcu_sched_data.passed_quiesce, 1);
+ rdp->passed_quiesce = true;
}
}

void rcu_bh_qs(void)
{
- if (!__this_cpu_read(rcu_bh_data.passed_quiesce)) {
+ struct rcu_data *rdp = __this_cpu_ptr(&rcu_bh_data);
+
+ if (!rdp->passed_quiesce) {
trace_rcu_grace_period(TPS("rcu_bh"),
__this_cpu_read(rcu_bh_data.gpnum),
TPS("cpuqs"));
- __this_cpu_write(rcu_bh_data.passed_quiesce, 1);
+ rdp->passed_quiesce = true;
}
}

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 77f9376..98de303 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -143,11 +143,13 @@ EXPORT_SYMBOL_GPL(rcu_batches_completed);
*/
static void rcu_preempt_qs(void)
{
- if (!__this_cpu_read(rcu_preempt_data.passed_quiesce)) {
+ struct rcu_data *rdp = __this_cpu_ptr(&rcu_preempt_data);
+
+ if (!rdp->passed_quiesce) {
trace_rcu_grace_period(TPS("rcu_preempt"),
__this_cpu_read(rcu_preempt_data.gpnum),
TPS("cpuqs"));
- __this_cpu_write(rcu_preempt_data.passed_quiesce, 1);
+ rdp->passed_quiesce = true;
barrier(); /* Coordinate with rcu_preempt_check_callbacks(). */
current->rcu_read_unlock_special.b.need_qs = false;
}
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/