Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15016
b: refs/heads/master
c: ab4720e
h: refs/heads/master
v: v3
  • Loading branch information
Dipankar Sarma authored and Linus Torvalds committed Dec 12, 2005
1 parent 0e0b727 commit d053488
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 85b872424984e79519be904e7df02a91ba0a9486
refs/heads/master: ab4720ec76b756e1f8705e207a7b392b0453afd6
2 changes: 2 additions & 0 deletions trunk/include/linux/rcupdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct rcu_data {
struct rcu_head *donelist;
struct rcu_head **donetail;
int cpu;
struct rcu_head barrier;
};

DECLARE_PER_CPU(struct rcu_data, rcu_data);
Expand Down Expand Up @@ -285,6 +286,7 @@ extern void FASTCALL(call_rcu_bh(struct rcu_head *head,
extern __deprecated_for_modules void synchronize_kernel(void);
extern void synchronize_rcu(void);
void synchronize_idle(void);
extern void rcu_barrier(void);

#endif /* __KERNEL__ */
#endif /* __LINUX_RCUPDATE_H */
41 changes: 41 additions & 0 deletions trunk/kernel/rcupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ void fastcall call_rcu(struct rcu_head *head,
local_irq_restore(flags);
}

static atomic_t rcu_barrier_cpu_count;
static struct semaphore rcu_barrier_sema;
static struct completion rcu_barrier_completion;

/**
* call_rcu_bh - Queue an RCU for invocation after a quicker grace period.
* @head: structure to be used for queueing the RCU updates.
Expand Down Expand Up @@ -162,6 +166,42 @@ long rcu_batches_completed(void)
return rcu_ctrlblk.completed;
}

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

/*
* Called with preemption disabled, and from cross-cpu IRQ context.
*/
static void rcu_barrier_func(void *notused)
{
int cpu = smp_processor_id();
struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
struct rcu_head *head;

head = &rdp->barrier;
atomic_inc(&rcu_barrier_cpu_count);
call_rcu(head, rcu_barrier_callback);
}

/**
* rcu_barrier - Wait until all the in-flight RCUs are complete.
*/
void rcu_barrier(void)
{
BUG_ON(in_interrupt());
/* Take cpucontrol semaphore to protect against CPU hotplug */
down(&rcu_barrier_sema);
init_completion(&rcu_barrier_completion);
atomic_set(&rcu_barrier_cpu_count, 0);
on_each_cpu(rcu_barrier_func, NULL, 0, 1);
wait_for_completion(&rcu_barrier_completion);
up(&rcu_barrier_sema);
}
EXPORT_SYMBOL_GPL(rcu_barrier);

/*
* Invoke the completed RCU callbacks. They are expected to be in
* a per-cpu list.
Expand Down Expand Up @@ -457,6 +497,7 @@ static struct notifier_block __devinitdata rcu_nb = {
*/
void __init rcu_init(void)
{
sema_init(&rcu_barrier_sema, 1);
rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE,
(void *)(long)smp_processor_id());
/* Register notifier for non-boot CPUs */
Expand Down

0 comments on commit d053488

Please sign in to comment.