Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
6c9fcaf2
Commit
6c9fcaf2
authored
Jul 15, 2008
by
Ingo Molnar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'core/rcu' into core/rcu-for-linus
parents
b9d2252c
199a9528
Changes
33
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1341 additions
and
524 deletions
+1341
-524
Documentation/RCU/NMI-RCU.txt
Documentation/RCU/NMI-RCU.txt
+3
-0
Documentation/RCU/RTFP.txt
Documentation/RCU/RTFP.txt
+108
-0
Documentation/RCU/checklist.txt
Documentation/RCU/checklist.txt
+60
-29
Documentation/RCU/torture.txt
Documentation/RCU/torture.txt
+33
-15
Documentation/RCU/whatisRCU.txt
Documentation/RCU/whatisRCU.txt
+39
-19
arch/ia64/sn/kernel/irq.c
arch/ia64/sn/kernel/irq.c
+1
-0
crypto/async_tx/async_tx.c
crypto/async_tx/async_tx.c
+1
-0
drivers/infiniband/hw/ipath/ipath_verbs.c
drivers/infiniband/hw/ipath/ipath_verbs.c
+1
-0
drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
+1
-2
drivers/net/macvlan.c
drivers/net/macvlan.c
+1
-1
include/linux/dcache.h
include/linux/dcache.h
+1
-0
include/linux/list.h
include/linux/list.h
+0
-367
include/linux/rcuclassic.h
include/linux/rcuclassic.h
+3
-0
include/linux/rculist.h
include/linux/rculist.h
+368
-1
include/linux/rcupdate.h
include/linux/rcupdate.h
+24
-2
include/linux/rcupreempt.h
include/linux/rcupreempt.h
+36
-6
init/main.c
init/main.c
+1
-0
kernel/pid.c
kernel/pid.c
+1
-0
kernel/rcuclassic.c
kernel/rcuclassic.c
+33
-1
kernel/rcupdate.c
kernel/rcupdate.c
+49
-22
kernel/rcupreempt.c
kernel/rcupreempt.c
+371
-47
kernel/rcupreempt_trace.c
kernel/rcupreempt_trace.c
+0
-1
kernel/rcutorture.c
kernel/rcutorture.c
+166
-8
kernel/sysctl.c
kernel/sysctl.c
+13
-0
lib/Kconfig.debug
lib/Kconfig.debug
+19
-1
lib/textsearch.c
lib/textsearch.c
+1
-0
net/802/psnap.c
net/802/psnap.c
+1
-0
net/8021q/vlan.c
net/8021q/vlan.c
+1
-0
net/bridge/br_fdb.c
net/bridge/br_fdb.c
+1
-0
net/bridge/br_stp.c
net/bridge/br_stp.c
+1
-0
net/netfilter/nf_conntrack_helper.c
net/netfilter/nf_conntrack_helper.c
+1
-0
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_netlink.c
+1
-0
net/netlabel/netlabel_domainhash.c
net/netlabel/netlabel_domainhash.c
+1
-2
No files found.
Documentation/RCU/NMI-RCU.txt
View file @
6c9fcaf2
...
...
@@ -93,6 +93,9 @@ Since NMI handlers disable preemption, synchronize_sched() is guaranteed
not to return until all ongoing NMI handlers exit. It is therefore safe
to free up the handler's data as soon as synchronize_sched() returns.
Important note: for this to work, the architecture in question must
invoke irq_enter() and irq_exit() on NMI entry and exit, respectively.
Answer to Quick Quiz
...
...
Documentation/RCU/RTFP.txt
View file @
6c9fcaf2
...
...
@@ -52,6 +52,10 @@ of each iteration. Unfortunately, chaotic relaxation requires highly
structured data, such as the matrices used in scientific programs, and
is thus inapplicable to most data structures in operating-system kernels.
In 1992, Henry (now Alexia) Massalin completed a dissertation advising
parallel programmers to defer processing when feasible to simplify
synchronization. RCU makes extremely heavy use of this advice.
In 1993, Jacobson [Jacobson93] verbally described what is perhaps the
simplest deferred-free technique: simply waiting a fixed amount of time
before freeing blocks awaiting deferred free. Jacobson did not describe
...
...
@@ -138,6 +142,13 @@ blocking in read-side critical sections appeared [PaulEMcKenney2006c],
Robert Olsson described an RCU-protected trie-hash combination
[RobertOlsson2006a].
2007 saw the journal version of the award-winning RCU paper from 2006
[ThomasEHart2007a], as well as a paper demonstrating use of Promela
and Spin to mechanically verify an optimization to Oleg Nesterov's
QRCU [PaulEMcKenney2007QRCUspin], a design document describing
preemptible RCU [PaulEMcKenney2007PreemptibleRCU], and the three-part
LWN "What is RCU?" series [PaulEMcKenney2007WhatIsRCUFundamentally,
PaulEMcKenney2008WhatIsRCUUsage, and PaulEMcKenney2008WhatIsRCUAPI].
Bibtex Entries
...
...
@@ -202,6 +213,20 @@ Bibtex Entries
,Year="1991"
}
@phdthesis{HMassalinPhD
,author="H. Massalin"
,title="Synthesis: An Efficient Implementation of Fundamental Operating
System Services"
,school="Columbia University"
,address="New York, NY"
,year="1992"
,annotation="
Mondo optimizing compiler.
Wait-free stuff.
Good advice: defer work to avoid synchronization.
"
}
@unpublished{Jacobson93
,author="Van Jacobson"
,title="Avoid Read-Side Locking Via Delayed Free"
...
...
@@ -635,3 +660,86 @@ Revised:
"
}
@unpublished{PaulEMcKenney2007PreemptibleRCU
,Author="Paul E. McKenney"
,Title="The design of preemptible read-copy-update"
,month="October"
,day="8"
,year="2007"
,note="Available:
\url{http://lwn.net/Articles/253651/}
[Viewed October 25, 2007]"
,annotation="
LWN article describing the design of preemptible RCU.
"
}
########################################################################
#
# "What is RCU?" LWN series.
#
@unpublished{PaulEMcKenney2007WhatIsRCUFundamentally
,Author="Paul E. McKenney and Jonathan Walpole"
,Title="What is {RCU}, Fundamentally?"
,month="December"
,day="17"
,year="2007"
,note="Available:
\url{http://lwn.net/Articles/262464/}
[Viewed December 27, 2007]"
,annotation="
Lays out the three basic components of RCU: (1) publish-subscribe,
(2) wait for pre-existing readers to complete, and (2) maintain
multiple versions.
"
}
@unpublished{PaulEMcKenney2008WhatIsRCUUsage
,Author="Paul E. McKenney"
,Title="What is {RCU}? Part 2: Usage"
,month="January"
,day="4"
,year="2008"
,note="Available:
\url{http://lwn.net/Articles/263130/}
[Viewed January 4, 2008]"
,annotation="
Lays out six uses of RCU:
1. RCU is a Reader-Writer Lock Replacement
2. RCU is a Restricted Reference-Counting Mechanism
3. RCU is a Bulk Reference-Counting Mechanism
4. RCU is a Poor Man's Garbage Collector
5. RCU is a Way of Providing Existence Guarantees
6. RCU is a Way of Waiting for Things to Finish
"
}
@unpublished{PaulEMcKenney2008WhatIsRCUAPI
,Author="Paul E. McKenney"
,Title="{RCU} part 3: the {RCU} {API}"
,month="January"
,day="17"
,year="2008"
,note="Available:
\url{http://lwn.net/Articles/264090/}
[Viewed January 10, 2008]"
,annotation="
Gives an overview of the Linux-kernel RCU API and a brief annotated RCU
bibliography.
"
}
@article{DinakarGuniguntala2008IBMSysJ
,author="D. Guniguntala and P. E. McKenney and J. Triplett and J. Walpole"
,title="The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with {Linux}"
,Year="2008"
,Month="April"
,journal="IBM Systems Journal"
,volume="47"
,number="2"
,pages="@@-@@"
,annotation="
RCU, realtime RCU, sleepable RCU, performance.
"
}
Documentation/RCU/checklist.txt
View file @
6c9fcaf2
...
...
@@ -13,10 +13,13 @@ over a rather long period of time, but improvements are always welcome!
detailed performance measurements show that RCU is nonetheless
the right tool for the job.
The other exception would be where performance is not an issue,
and RCU provides a simpler implementation. An example of this
situation is the dynamic NMI code in the Linux 2.6 kernel,
at least on architectures where NMIs are rare.
Another exception is where performance is not an issue, and RCU
provides a simpler implementation. An example of this situation
is the dynamic NMI code in the Linux 2.6 kernel, at least on
architectures where NMIs are rare.
Yet another exception is where the low real-time latency of RCU's
read-side primitives is critically important.
1. Does the update code have proper mutual exclusion?
...
...
@@ -39,9 +42,10 @@ over a rather long period of time, but improvements are always welcome!
2. Do the RCU read-side critical sections make proper use of
rcu_read_lock() and friends? These primitives are needed
to suppress preemption (or bottom halves, in the case of
rcu_read_lock_bh()) in the read-side critical sections,
and are also an excellent aid to readability.
to prevent grace periods from ending prematurely, which
could result in data being unceremoniously freed out from
under your read-side code, which can greatly increase the
actuarial risk of your kernel.
As a rough rule of thumb, any dereference of an RCU-protected
pointer must be covered by rcu_read_lock() or rcu_read_lock_bh()
...
...
@@ -54,15 +58,30 @@ over a rather long period of time, but improvements are always welcome!
be running while updates are in progress. There are a number
of ways to handle this concurrency, depending on the situation:
a. Make updates appear atomic to readers. For example,
a. Use the RCU variants of the list and hlist update
primitives to add, remove, and replace elements on an
RCU-protected list. Alternatively, use the RCU-protected
trees that have been added to the Linux kernel.
This is almost always the best approach.
b. Proceed as in (a) above, but also maintain per-element
locks (that are acquired by both readers and writers)
that guard per-element state. Of course, fields that
the readers refrain from accessing can be guarded by the
update-side lock.
This works quite well, also.
c. Make updates appear atomic to readers. For example,
pointer updates to properly aligned fields will appear
atomic, as will individual atomic primitives. Operations
performed under a lock and sequences of multiple atomic
primitives will -not- appear to be atomic.
This
is almost always the best approach
.
This
can work, but is starting to get a bit tricky
.
b
. Carefully order the updates and the reads so that
d
. Carefully order the updates and the reads so that
readers see valid data at all phases of the update.
This is often more difficult than it sounds, especially
given modern CPUs' tendency to reorder memory references.
...
...
@@ -123,18 +142,22 @@ over a rather long period of time, but improvements are always welcome!
when publicizing a pointer to a structure that can
be traversed by an RCU read-side critical section.
5. If call_rcu(), or a related primitive such as call_rcu_bh(),
is used, the callback function must be written to be called
from softirq context. In particular, it cannot block.
5. If call_rcu(), or a related primitive such as call_rcu_bh() or
call_rcu_sched(), is used, the callback function must be
written to be called from softirq context. In particular,
it cannot block.
6. Since synchronize_rcu() can block, it cannot be called from
any sort of irq context.
any sort of irq context. Ditto for synchronize_sched() and
synchronize_srcu().
7. If the updater uses call_rcu(), then the corresponding readers
must use rcu_read_lock() and rcu_read_unlock(). If the updater
uses call_rcu_bh(), then the corresponding readers must use
rcu_read_lock_bh() and rcu_read_unlock_bh(). Mixing things up
will result in confusion and broken kernels.
rcu_read_lock_bh() and rcu_read_unlock_bh(). If the updater
uses call_rcu_sched(), then the corresponding readers must
disable preemption. Mixing things up will result in confusion
and broken kernels.
One exception to this rule: rcu_read_lock() and rcu_read_unlock()
may be substituted for rcu_read_lock_bh() and rcu_read_unlock_bh()
...
...
@@ -143,9 +166,9 @@ over a rather long period of time, but improvements are always welcome!
such cases is a must, of course! And the jury is still out on
whether the increased speed is worth it.
8. Although synchronize_rcu() is
a bit slower than is call_rcu(),
it usually results in simpler code. So, unless updat
e
performance
is critically important or the updaters cannot block,
8. Although synchronize_rcu() is
slower than is call_rcu(), it
usually results in simpler code. So, unless update performanc
e
is critically important or the updaters cannot block,
synchronize_rcu() should be used in preference to call_rcu().
An especially important property of the synchronize_rcu()
...
...
@@ -187,23 +210,23 @@ over a rather long period of time, but improvements are always welcome!
number of updates per grace period.
9. All RCU list-traversal primitives, which include
list_for_each_rcu(), list_for_each_entry_rcu(),
rcu_dereference(),
list_for_each_rcu(), list_for_each_entry_rcu(),
list_for_each_continue_rcu(), and list_for_each_safe_rcu(),
must be within an RCU read-side critical section. RCU
must be either within an RCU read-side critical section or
must be protected by appropriate update-side locks. RCU
read-side critical sections are delimited by rcu_read_lock()
and rcu_read_unlock(), or by similar primitives such as
rcu_read_lock_bh() and rcu_read_unlock_bh().
Use of the _rcu() list-traversal primitives outside of an
RCU read-side critical section causes no harm other than
a slight performance degradation on Alpha CPUs. It can
also be quite helpful in reducing code bloat when common
code is shared between readers and updaters.
The reason that it is permissible to use RCU list-traversal
primitives when the update-side lock is held is that doing so
can be quite helpful in reducing code bloat when common code is
shared between readers and updaters.
10. Conversely, if you are in an RCU read-side critical section,
you -must- use the "_rcu()" variants of the list macros.
Failing to do so will break Alpha and confuse people reading
your code.
and you don't hold the appropriate update-side lock, you -must-
use the "_rcu()" variants of the list macros. Failing to do so
will break Alpha and confuse people reading
your code.
11. Note that synchronize_rcu() -only- guarantees to wait until
all currently executing rcu_read_lock()-protected RCU read-side
...
...
@@ -230,6 +253,14 @@ over a rather long period of time, but improvements are always welcome!
must use whatever locking or other synchronization is required
to safely access and/or modify that data structure.
RCU callbacks are -usually- executed on the same CPU that executed
the corresponding call_rcu(), call_rcu_bh(), or call_rcu_sched(),
but are by -no- means guaranteed to be. For example, if a given
CPU goes offline while having an RCU callback pending, then that
RCU callback will execute on some surviving CPU. (If this was
not the case, a self-spawning RCU callback would prevent the
victim CPU from ever going offline.)
14. SRCU (srcu_read_lock(), srcu_read_unlock(), and synchronize_srcu())
may only be invoked from process context. Unlike other forms of
RCU, it -is- permissible to block in an SRCU read-side critical
...
...
Documentation/RCU/torture.txt
View file @
6c9fcaf2
...
...
@@ -10,23 +10,30 @@ status messages via printk(), which can be examined via the dmesg
command (perhaps grepping for "torture"). The test is started
when the module is loaded, and stops when the module is unloaded.
However, actually setting this config option to "y" results in the system
running the test immediately upon boot, and ending only when the system
is taken down. Normally, one will instead want to build the system
with CONFIG_RCU_TORTURE_TEST=m and to use modprobe and rmmod to control
the test, perhaps using a script similar to the one shown at the end of
this document. Note that you will need CONFIG_MODULE_UNLOAD in order
to be able to end the test.
CONFIG_RCU_TORTURE_TEST_RUNNABLE
It is also possible to specify CONFIG_RCU_TORTURE_TEST=y, which will
result in the tests being loaded into the base kernel. In this case,
the CONFIG_RCU_TORTURE_TEST_RUNNABLE config option is used to specify
whether the RCU torture tests are to be started immediately during
boot or whether the /proc/sys/kernel/rcutorture_runnable file is used
to enable them. This /proc file can be used to repeatedly pause and
restart the tests, regardless of the initial state specified by the
CONFIG_RCU_TORTURE_TEST_RUNNABLE config option.
You will normally -not- want to start the RCU torture tests during boot
(and thus the default is CONFIG_RCU_TORTURE_TEST_RUNNABLE=n), but doing
this can sometimes be useful in finding boot-time bugs.
MODULE PARAMETERS
This module has the following parameters:
nreaders This is the number of RCU reading threads supported.
The default is twice the number of CPUs. Why twice?
To properly exercise RCU implementations with preemptible
read-side critical sections.
irqreaders Says to invoke RCU readers from irq level. This is currently
done via timers. Defaults to "1" for variants of RCU that
permit this. (Or, more accurately, variants of RCU that do
-not- permit this know to ignore this variable.)
nfakewriters This is the number of RCU fake writer threads to run. Fake
writer threads repeatedly use the synchronous "wait for
...
...
@@ -37,6 +44,16 @@ nfakewriters This is the number of RCU fake writer threads to run. Fake
to trigger special cases caused by multiple writers, such as
the synchronize_srcu() early return optimization.
nreaders This is the number of RCU reading threads supported.
The default is twice the number of CPUs. Why twice?
To properly exercise RCU implementations with preemptible
read-side critical sections.
shuffle_interval
The number of seconds to keep the test threads affinitied
to a particular subset of the CPUs, defaults to 3 seconds.
Used in conjunction with test_no_idle_hz.
stat_interval The number of seconds between output of torture
statistics (via printk()). Regardless of the interval,
statistics are printed when the module is unloaded.
...
...
@@ -44,10 +61,11 @@ stat_interval The number of seconds between output of torture
be printed -only- when the module is unloaded, and this
is the default.
shuffle_interval
The number of seconds to keep the test threads affinitied
to a particular subset of the CPUs, defaults to 5 seconds.
Used in conjunction with test_no_idle_hz.
stutter The length of time to run the test before pausing for this
same period of time. Defaults to "stutter=5", so as
to run and pause for (roughly) five-second intervals.
Specifying "stutter=0" causes the test to run continuously
without pausing, which is the old default behavior.
test_no_idle_hz Whether or not to test the ability of RCU to operate in
a kernel that disables the scheduling-clock interrupt to
...
...
Documentation/RCU/whatisRCU.txt
View file @
6c9fcaf2
Please note that the "What is RCU?" LWN series is an excellent place
to start learning about RCU:
1. What is RCU, Fundamentally? http://lwn.net/Articles/262464/
2. What is RCU? Part 2: Usage http://lwn.net/Articles/263130/
3. RCU part 3: the RCU API http://lwn.net/Articles/264090/
What is RCU?
RCU is a synchronization mechanism that was added to the Linux kernel
...
...
@@ -772,26 +780,18 @@ Linux-kernel source code, but it helps to have a full list of the
APIs, since there does not appear to be a way to categorize them
in docbook. Here is the list, by category.
Markers for RCU read-side critical sections:
rcu_read_lock
rcu_read_unlock
rcu_read_lock_bh
rcu_read_unlock_bh
srcu_read_lock
srcu_read_unlock
RCU pointer/list traversal:
rcu_dereference
list_for_each_entry_rcu
hlist_for_each_entry_rcu
list_for_each_rcu (to be deprecated in favor of
list_for_each_entry_rcu)
list_for_each_entry_rcu
list_for_each_continue_rcu (to be deprecated in favor of new
list_for_each_entry_continue_rcu)
hlist_for_each_entry_rcu
RCU pointer update:
RCU pointer
/list
update:
rcu_assign_pointer
list_add_rcu
...
...
@@ -799,16 +799,36 @@ RCU pointer update:
list_del_rcu
list_replace_rcu
hlist_del_rcu
hlist_add_after_rcu
hlist_add_before_rcu
hlist_add_head_rcu
hlist_replace_rcu
list_splice_init_rcu()
RCU
grace period:
RCU
: Critical sections Grace period Barrier
synchronize_net
synchronize_sched
synchronize_rcu
synchronize_srcu
rcu_read_lock synchronize_net rcu_barrier
rcu_read_unlock synchronize_rcu
call_rcu
call_rcu_bh
bh: Critical sections Grace period Barrier
rcu_read_lock_bh call_rcu_bh rcu_barrier_bh
rcu_read_unlock_bh
sched: Critical sections Grace period Barrier
[preempt_disable] synchronize_sched rcu_barrier_sched
[and friends] call_rcu_sched
SRCU: Critical sections Grace period Barrier
srcu_read_lock synchronize_srcu N/A
srcu_read_unlock
See the comment headers in the source code (or the docbook generated
from them) for more information.
...
...
arch/ia64/sn/kernel/irq.c
View file @
6c9fcaf2
...
...
@@ -11,6 +11,7 @@
#include <linux/irq.h>
#include <linux/spinlock.h>
#include <linux/init.h>
#include <linux/rculist.h>
#include <asm/sn/addrs.h>
#include <asm/sn/arch.h>
#include <asm/sn/intr.h>
...
...
crypto/async_tx/async_tx.c
View file @
6c9fcaf2
...
...
@@ -23,6 +23,7 @@
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <linux/rculist.h>
#include <linux/kernel.h>
#include <linux/async_tx.h>
...
...
drivers/infiniband/hw/ipath/ipath_verbs.c
View file @
6c9fcaf2
...
...
@@ -35,6 +35,7 @@
#include <rdma/ib_user_verbs.h>
#include <linux/io.h>
#include <linux/utsname.h>
#include <linux/rculist.h>
#include "ipath_kernel.h"
#include "ipath_verbs.h"
...
...
drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
View file @
6c9fcaf2
...
...
@@ -31,8 +31,7 @@
* SOFTWARE.
*/
#include <linux/list.h>
#include <linux/rcupdate.h>
#include <linux/rculist.h>
#include "ipath_verbs.h"
...
...
drivers/net/macvlan.c
View file @
6c9fcaf2
...
...
@@ -20,7 +20,7 @@
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/
rcu
list.h>
#include <linux/notifier.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
...
...
include/linux/dcache.h
View file @
6c9fcaf2
...
...
@@ -3,6 +3,7 @@
#include <asm/atomic.h>
#include <linux/list.h>
#include <linux/rculist.h>
#include <linux/spinlock.h>
#include <linux/cache.h>
#include <linux/rcupdate.h>
...
...
include/linux/list.h
View file @
6c9fcaf2
This diff is collapsed.
Click to expand it.
include/linux/rcuclassic.h
View file @
6c9fcaf2
...
...
@@ -151,7 +151,10 @@ extern struct lockdep_map rcu_lock_map;
#define __synchronize_sched() synchronize_rcu()
#define call_rcu_sched(head, func) call_rcu(head, func)
extern
void
__rcu_init
(
void
);
#define rcu_init_sched() do { } while (0)
extern
void
rcu_check_callbacks
(
int
cpu
,
int
user
);
extern
void
rcu_restart_cpu
(
int
cpu
);
...
...
include/linux/rculist.h
View file @
6c9fcaf2
This diff is collapsed.
Click to expand it.
include/linux/rcupdate.h
View file @
6c9fcaf2
...
...
@@ -40,6 +40,7 @@
#include <linux/cpumask.h>
#include <linux/seqlock.h>
#include <linux/lockdep.h>
#include <linux/completion.h>
/**
* struct rcu_head - callback structure for use with RCU
...
...
@@ -168,6 +169,27 @@ struct rcu_head {
(p) = (v); \
})
/* Infrastructure to implement the synchronize_() primitives. */
struct
rcu_synchronize
{
struct
rcu_head
head
;
struct
completion
completion
;
};
extern
void
wakeme_after_rcu
(
struct
rcu_head
*
head
);
#define synchronize_rcu_xxx(name, func) \
void name(void) \
{ \
struct rcu_synchronize rcu; \
\
init_completion(&rcu.completion); \
/* Will wake me after RCU finished. */
\
func(&rcu.head, wakeme_after_rcu); \
/* Wait for it. */
\
wait_for_completion(&rcu.completion); \
}
/**
* synchronize_sched - block until all CPUs have exited any non-preemptive
* kernel code sequences.
...
...
@@ -224,8 +246,8 @@ extern void call_rcu_bh(struct rcu_head *head,
/* Exported common interfaces */
extern
void
synchronize_rcu
(
void
);
extern
void
rcu_barrier
(
void
);
extern
long
rcu_batches_completed
(
void
);
extern
long
rcu_batches_completed_bh
(
void
);
extern
void
rcu_barrier_bh
(
void
);
extern
void
rcu_barrier_sched
(
void
);
/* Internal to kernel */
extern
void
rcu_init
(
void
);
...
...
include/linux/rcupreempt.h
View file @
6c9fcaf2
...
...
@@ -40,10 +40,39 @@
#include <linux/cpumask.h>
#include <linux/seqlock.h>
#define rcu_qsctr_inc(cpu)
struct
rcu_dyntick_sched
{
int
dynticks
;
int
dynticks_snap
;
int
sched_qs
;
int
sched_qs_snap
;
int
sched_dynticks_snap
;
};
DECLARE_PER_CPU
(
struct
rcu_dyntick_sched
,
rcu_dyntick_sched
);
static
inline
void
rcu_qsctr_inc
(
int
cpu
)
{
struct
rcu_dyntick_sched
*
rdssp
=
&
per_cpu
(
rcu_dyntick_sched
,
cpu
);
rdssp
->
sched_qs
++
;
}
#define rcu_bh_qsctr_inc(cpu)
#define call_rcu_bh(head, rcu) call_rcu(head, rcu)
/**
* call_rcu_sched - Queue RCU callback for invocation after sched grace period.
* @head: structure to be used for queueing the RCU updates.
* @func: actual update function to be invoked after the grace period
*
* The update function will be invoked some time after a full
* synchronize_sched()-style grace period elapses, in other words after
* all currently executing preempt-disabled sections of code (including
* hardirq handlers, NMI handlers, and local_irq_save() blocks) have
* completed.
*/
extern
void
call_rcu_sched
(
struct
rcu_head
*
head
,
void
(
*
func
)(
struct
rcu_head
*
head
));
extern
void
__rcu_read_lock
(
void
)
__acquires
(
RCU
);
extern
void
__rcu_read_unlock
(
void
)
__releases
(
RCU
);
extern
int
rcu_pending
(
int
cpu
);
...
...
@@ -55,6 +84,7 @@ extern int rcu_needs_cpu(int cpu);
extern
void
__synchronize_sched
(
void
);
extern
void
__rcu_init
(
void
);
extern
void
rcu_init_sched
(
void
);
extern
void
rcu_check_callbacks
(
int
cpu
,
int
user
);
extern
void
rcu_restart_cpu
(
int
cpu
);
extern
long
rcu_batches_completed
(
void
);
...
...
@@ -81,20 +111,20 @@ extern struct rcupreempt_trace *rcupreempt_trace_cpu(int cpu);
struct
softirq_action
;
#ifdef CONFIG_NO_HZ
DECLARE_PER_CPU
(
long
,
dynticks_progress_counter
);
DECLARE_PER_CPU
(
struct
rcu_dyntick_sched
,
rcu_dyntick_sched
);
static
inline
void
rcu_enter_nohz
(
void
)
{
smp_mb
();
/* CPUs seeing ++ must see prior RCU read-side crit sects */
__get_cpu_var
(
dynticks_progress_counter
)
++
;
WARN_ON
(
__get_cpu_var
(
dynticks_progress_counter
)
&
0x1
);
__get_cpu_var
(
rcu_dyntick_sched
).
dynticks
++
;
WARN_ON
(
__get_cpu_var
(
rcu_dyntick_sched
).
dynticks
&
0x1
);
}
static
inline
void
rcu_exit_nohz
(
void
)
{
__get_cpu_var
(
dynticks_progress_counter
)
++
;
smp_mb
();
/* CPUs seeing ++ must see later RCU read-side crit sects */
WARN_ON
(
!
(
__get_cpu_var
(
dynticks_progress_counter
)
&
0x1
));
__get_cpu_var
(
rcu_dyntick_sched
).
dynticks
++
;
WARN_ON
(
!
(
__get_cpu_var
(
rcu_dyntick_sched
).
dynticks
&
0x1
));
}
#else
/* CONFIG_NO_HZ */
...
...
init/main.c
View file @
6c9fcaf2
...
...
@@ -758,6 +758,7 @@ static void __init do_initcalls(void)
*/
static
void
__init
do_basic_setup
(
void
)
{
rcu_init_sched
();
/* needed by module_init stage. */
/* drivers will send hotplug events */
init_workqueues
();
usermodehelper_init
();
...
...
kernel/pid.c
View file @
6c9fcaf2
...
...
@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/rculist.h>
#include <linux/bootmem.h>
#include <linux/hash.h>
#include <linux/pid_namespace.h>
...
...
kernel/rcuclassic.c
View file @
6c9fcaf2
...
...
@@ -387,6 +387,10 @@ static void __rcu_offline_cpu(struct rcu_data *this_rdp,
rcu_move_batch
(
this_rdp
,
rdp
->
donelist
,
rdp
->
donetail
);
rcu_move_batch
(
this_rdp
,
rdp
->
curlist
,
rdp
->
curtail
);
rcu_move_batch
(
this_rdp
,
rdp
->
nxtlist
,
rdp
->
nxttail
);
local_irq_disable
();
this_rdp
->
qlen
+=
rdp
->
qlen
;
local_irq_enable
();
}
static
void
rcu_offline_cpu
(
int
cpu
)
...
...
@@ -516,10 +520,38 @@ void rcu_check_callbacks(int cpu, int user)
if
(
user
||
(
idle_cpu
(
cpu
)
&&
!
in_softirq
()
&&
hardirq_count
()
<=
(
1
<<
HARDIRQ_SHIFT
)))
{
/*
* Get here if this CPU took its interrupt from user
* mode or from the idle loop, and if this is not a
* nested interrupt. In this case, the CPU is in
* a quiescent state, so count it.
*
* Also do a memory barrier. This is needed to handle
* the case where writes from a preempt-disable section
* of code get reordered into schedule() by this CPU's
* write buffer. The memory barrier makes sure that
* the rcu_qsctr_inc() and rcu_bh_qsctr_inc() are see
* by other CPUs to happen after any such write.
*/
smp_mb
();
/* See above block comment. */
rcu_qsctr_inc
(
cpu
);
rcu_bh_qsctr_inc
(
cpu
);
}
else
if
(
!
in_softirq
())
}
else
if
(
!
in_softirq
())
{
/*
* Get here if this CPU did not take its interrupt from
* softirq, in other words, if it is not interrupting
* a rcu_bh read-side critical section. This is an _bh
* critical section, so count it. The memory barrier
* is needed for the same reason as is the above one.
*/
smp_mb
();
/* See above block comment. */
rcu_bh_qsctr_inc
(
cpu
);
}
raise_rcu_softirq
();
}
...
...
kernel/rcupdate.c
View file @
6c9fcaf2
...
...
@@ -39,16 +39,16 @@
#include <linux/sched.h>
#include <asm/atomic.h>
#include <linux/bitops.h>
#include <linux/completion.h>
#include <linux/percpu.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/mutex.h>
#include <linux/module.h>
struct
rcu_synchronize
{
struct
rcu_head
head
;
struct
completion
completion
;
enum
rcu_barrier
{
RCU_BARRIER_STD
,
RCU_BARRIER_BH
,
RCU_BARRIER_SCHED
,
};
static
DEFINE_PER_CPU
(
struct
rcu_head
,
rcu_barrier_head
)
=
{
NULL
};
...
...
@@ -60,7 +60,7 @@ static struct completion rcu_barrier_completion;
* Awaken the corresponding synchronize_rcu() instance now that a
* grace period has elapsed.
*/
static
void
wakeme_after_rcu
(
struct
rcu_head
*
head
)
void
wakeme_after_rcu
(
struct
rcu_head
*
head
)
{
struct
rcu_synchronize
*
rcu
;
...
...
@@ -77,17 +77,7 @@ static void wakeme_after_rcu(struct rcu_head *head)
* sections are delimited by rcu_read_lock() and rcu_read_unlock(),
* and may be nested.
*/
void
synchronize_rcu
(
void
)
{
struct
rcu_synchronize
rcu
;
init_completion
(
&
rcu
.
completion
);
/* Will wake me after RCU finished */
call_rcu
(
&
rcu
.
head
,
wakeme_after_rcu
);
/* Wait for it */
wait_for_completion
(
&
rcu
.
completion
);
}
synchronize_rcu_xxx
(
synchronize_rcu
,
call_rcu
)
EXPORT_SYMBOL_GPL
(
synchronize_rcu
);
static
void
rcu_barrier_callback
(
struct
rcu_head
*
notused
)
...
...
@@ -99,19 +89,30 @@ static void rcu_barrier_callback(struct rcu_head *notused)
/*
* Called with preemption disabled, and from cross-cpu IRQ context.
*/
static
void
rcu_barrier_func
(
void
*
notused
)
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
);
switch
((
enum
rcu_barrier
)
type
)
{
case
RCU_BARRIER_STD
:
call_rcu
(
head
,
rcu_barrier_callback
);
break
;
case
RCU_BARRIER_BH
:
call_rcu_bh
(
head
,
rcu_barrier_callback
);
break
;
case
RCU_BARRIER_SCHED
:
call_rcu_sched
(
head
,
rcu_barrier_callback
);
break
;
}
}
/**
* rcu_barrier - Wait until all the in-flight RCUs are complete.
/*
* Orchestrate the specified type of RCU barrier, waiting for all
* RCU callbacks of the specified type to complete.
*/
void
rcu_barrier
(
void
)
static
void
_rcu_barrier
(
enum
rcu_barrier
type
)
{
BUG_ON
(
in_interrupt
());
/* Take cpucontrol mutex to protect against CPU hotplug */
...
...
@@ -127,13 +128,39 @@ void rcu_barrier(void)
* until all the callbacks are queued.
*/
rcu_read_lock
();
on_each_cpu
(
rcu_barrier_func
,
NULL
,
0
,
1
);
on_each_cpu
(
rcu_barrier_func
,
(
void
*
)
type
,
0
,
1
);
rcu_read_unlock
();
wait_for_completion
(
&
rcu_barrier_completion
);
mutex_unlock
(
&
rcu_barrier_mutex
);
}
/**
* rcu_barrier - Wait until all in-flight call_rcu() callbacks complete.
*/
void
rcu_barrier
(
void
)
{
_rcu_barrier
(
RCU_BARRIER_STD
);
}
EXPORT_SYMBOL_GPL
(
rcu_barrier
);
/**
* rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete.
*/
void
rcu_barrier_bh
(
void
)
{
_rcu_barrier
(
RCU_BARRIER_BH
);
}
EXPORT_SYMBOL_GPL
(
rcu_barrier_bh
);
/**
* rcu_barrier_sched - Wait for in-flight call_rcu_sched() callbacks.
*/
void
rcu_barrier_sched
(
void
)
{
_rcu_barrier
(
RCU_BARRIER_SCHED
);
}
EXPORT_SYMBOL_GPL
(
rcu_barrier_sched
);
void
__init
rcu_init
(
void
)
{
__rcu_init
();
...
...
kernel/rcupreempt.c
View file @
6c9fcaf2
This diff is collapsed.
Click to expand it.
kernel/rcupreempt_trace.c
View file @
6c9fcaf2
...
...
@@ -38,7 +38,6 @@
#include <linux/moduleparam.h>
#include <linux/percpu.h>
#include <linux/notifier.h>
#include <linux/rcupdate.h>
#include <linux/cpu.h>
#include <linux/mutex.h>
#include <linux/rcupreempt_trace.h>
...
...
kernel/rcutorture.c
View file @
6c9fcaf2
This diff is collapsed.
Click to expand it.
kernel/sysctl.c
View file @
6c9fcaf2
...
...
@@ -83,6 +83,9 @@ extern int maps_protect;
extern
int
sysctl_stat_interval
;
extern
int
latencytop_enabled
;
extern
int
sysctl_nr_open_min
,
sysctl_nr_open_max
;
#ifdef CONFIG_RCU_TORTURE_TEST
extern
int
rcutorture_runnable
;
#endif
/* #ifdef CONFIG_RCU_TORTURE_TEST */
/* Constants used for minimum and maximum */
#if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM)
...
...
@@ -820,6 +823,16 @@ static struct ctl_table kern_table[] = {
.
child
=
key_sysctls
,
},
#endif
#ifdef CONFIG_RCU_TORTURE_TEST
{
.
ctl_name
=
CTL_UNNUMBERED
,
.
procname
=
"rcutorture_runnable"
,
.
data
=
&
rcutorture_runnable
,
.
maxlen
=
sizeof
(
int
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec
,
},
#endif
/*
* NOTE: do not add new entries to this table unless you have read
* Documentation/sysctl/ctl_unnumbered.txt
...
...
lib/Kconfig.debug
View file @
6c9fcaf2
...
...
@@ -530,16 +530,34 @@ config BOOT_PRINTK_DELAY
config RCU_TORTURE_TEST
tristate "torture tests for RCU"
depends on DEBUG_KERNEL
depends on m
default n
help
This option provides a kernel module that runs torture tests
on the RCU infrastructure. The kernel module may be built
after the fact on the running kernel to be tested, if desired.
Say Y here if you want RCU torture tests to be built into
the kernel.
Say M if you want the RCU torture tests to build as a module.
Say N if you are unsure.
config RCU_TORTURE_TEST_RUNNABLE
bool "torture tests for RCU runnable by default"
depends on RCU_TORTURE_TEST = y
default n
help
This option provides a way to build the RCU torture tests
directly into the kernel without them starting up at boot
time. You can use /proc/sys/kernel/rcutorture_runnable
to manually override this setting. This /proc file is
available only when the RCU torture tests have been built
into the kernel.
Say Y here if you want the RCU torture tests to start during
boot (you probably don't).
Say N here if you want the RCU torture tests to start only
after being manually enabled via /proc.
config KPROBES_SANITY_TEST
bool "Kprobes sanity tests"
depends on DEBUG_KERNEL
...
...
lib/textsearch.c
View file @
6c9fcaf2
...
...
@@ -97,6 +97,7 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/err.h>
#include <linux/textsearch.h>
...
...
net/802/psnap.c
View file @
6c9fcaf2
...
...
@@ -20,6 +20,7 @@
#include <linux/mm.h>
#include <linux/in.h>
#include <linux/init.h>
#include <linux/rculist.h>
static
LIST_HEAD
(
snap_list
);
static
DEFINE_SPINLOCK
(
snap_lock
);
...
...
net/8021q/vlan.c
View file @
6c9fcaf2
...
...
@@ -27,6 +27,7 @@
#include <linux/mm.h>
#include <linux/in.h>
#include <linux/init.h>
#include <linux/rculist.h>
#include <net/p8022.h>
#include <net/arp.h>
#include <linux/rtnetlink.h>
...
...
net/bridge/br_fdb.c
View file @
6c9fcaf2
...
...
@@ -15,6 +15,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/rculist.h>
#include <linux/spinlock.h>
#include <linux/times.h>
#include <linux/netdevice.h>
...
...
net/bridge/br_stp.c
View file @
6c9fcaf2
...
...
@@ -13,6 +13,7 @@
* 2 of the License, or (at your option) any later version.
*/
#include <linux/kernel.h>
#include <linux/rculist.h>
#include "br_private.h"
#include "br_private_stp.h"
...
...
net/netfilter/nf_conntrack_helper.c
View file @
6c9fcaf2
...
...
@@ -20,6 +20,7 @@
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/rculist.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_l3proto.h>
...
...
net/netfilter/nf_conntrack_netlink.c
View file @
6c9fcaf2
...
...
@@ -18,6 +18,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/rculist.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/skbuff.h>
...
...
net/netlabel/netlabel_domainhash.c
View file @
6c9fcaf2
...
...
@@ -30,8 +30,7 @@
*/
#include <linux/types.h>
#include <linux/rcupdate.h>
#include <linux/list.h>
#include <linux/rculist.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/string.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment