lkml.org 
[lkml]   [2009]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] rcupdate: use struct ref_completion

Impact: Cleanup

The comment in _rcu_barrier() is a little mysterious,
this fix uses the generic waiting-multi-events APIs instead.


Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 2c7b845..82f1dc4 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -53,9 +53,8 @@ enum rcu_barrier {
};

static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL};
-static atomic_t rcu_barrier_cpu_count;
static DEFINE_MUTEX(rcu_barrier_mutex);
-static struct completion rcu_barrier_completion;
+static struct ref_completion rcu_barrier_completion;
int rcu_scheduler_active __read_mostly;

/*
@@ -96,8 +95,7 @@ EXPORT_SYMBOL_GPL(synchronize_rcu);

static void rcu_barrier_callback(struct rcu_head *notused)
{
- if (atomic_dec_and_test(&rcu_barrier_cpu_count))
- complete(&rcu_barrier_completion);
+ ref_completion_put(&rcu_barrier_completion);
}

/*
@@ -108,7 +106,7 @@ static void rcu_barrier_func(void *type)
int cpu = smp_processor_id();
struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu);

- atomic_inc(&rcu_barrier_cpu_count);
+ ref_completion_get(&rcu_barrier_completion);
switch ((enum rcu_barrier)type) {
case RCU_BARRIER_STD:
call_rcu(head, rcu_barrier_callback);
@@ -133,21 +131,12 @@ static void _rcu_barrier(enum rcu_barrier type)
BUG_ON(in_interrupt());
/* Take cpucontrol mutex to protect against CPU hotplug */
mutex_lock(&rcu_barrier_mutex);
- init_completion(&rcu_barrier_completion);
- /*
- * Initialize rcu_barrier_cpu_count to 1, then invoke
- * rcu_barrier_func() on each CPU, so that each CPU also has
- * incremented rcu_barrier_cpu_count. Only then is it safe to
- * decrement rcu_barrier_cpu_count -- otherwise the first CPU
- * might complete its grace period before all of the other CPUs
- * did their increment, causing this function to return too
- * early.
- */
- atomic_set(&rcu_barrier_cpu_count, 1);
+
+ ref_completion_get_init(&rcu_barrier_completion);
on_each_cpu(rcu_barrier_func, (void *)type, 1);
- if (atomic_dec_and_test(&rcu_barrier_cpu_count))
- complete(&rcu_barrier_completion);
- wait_for_completion(&rcu_barrier_completion);
+ ref_completion_put_init(&rcu_barrier_completion);
+ ref_completion_wait(&rcu_barrier_completion);
+
mutex_unlock(&rcu_barrier_mutex);
wait_migrated_callbacks();
}



\
 
 \ /
  Last update: 2009-04-15 05:25    [W:0.033 / U:15.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site