* [PATCH tip/core/rcu 0/2] Documentation updates for v5.3
@ 2019-05-30 14:55 Paul E. McKenney
2019-05-30 14:55 ` [PATCH tip/core/rcu 1/2] doc/rcuref: Document real world examples in kernel Paul E. McKenney
2019-05-30 14:55 ` [PATCH tip/core/rcu 2/2] doc: Fixup definition of rcupdate.rcu_task_stall_timeout Paul E. McKenney
0 siblings, 2 replies; 3+ messages in thread
From: Paul E. McKenney @ 2019-05-30 14:55 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm,
mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
edumazet, fweisbec, oleg, joel
Hello!
This series provides a couple of documentation updates:
1. Document real world rcuref examples from the Linux kernel,
courtesy of Joel Fernandes.
2. Fixup definition of rcupdate.rcu_task_stall_timeout, courtesy
of Zhenzhong Duan.
Thanx, Paul
------------------------------------------------------------------------
rcuref.txt | 21 ++++++++++++++++++++-
stallwarn.txt | 2 +-
2 files changed, 21 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH tip/core/rcu 1/2] doc/rcuref: Document real world examples in kernel
2019-05-30 14:55 [PATCH tip/core/rcu 0/2] Documentation updates for v5.3 Paul E. McKenney
@ 2019-05-30 14:55 ` Paul E. McKenney
2019-05-30 14:55 ` [PATCH tip/core/rcu 2/2] doc: Fixup definition of rcupdate.rcu_task_stall_timeout Paul E. McKenney
1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2019-05-30 14:55 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm,
mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
edumazet, fweisbec, oleg, joel, jannh, Paul E . McKenney
From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Document similar real world examples in the kernel corresponding to the
second and third code snippets. Also correct an issue in
release_referenced() in the code snippet example.
Cc: oleg@redhat.com
Cc: jannh@google.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
[ paulmck: Do a bit of wordsmithing. ]
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
---
Documentation/RCU/rcuref.txt | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/Documentation/RCU/rcuref.txt b/Documentation/RCU/rcuref.txt
index 613033ff2b9b..5e6429d66c24 100644
--- a/Documentation/RCU/rcuref.txt
+++ b/Documentation/RCU/rcuref.txt
@@ -12,6 +12,7 @@ please read on.
Reference counting on elements of lists which are protected by traditional
reader/writer spinlocks or semaphores are straightforward:
+CODE LISTING A:
1. 2.
add() search_and_reference()
{ {
@@ -28,7 +29,8 @@ add() search_and_reference()
release_referenced() delete()
{ {
... write_lock(&list_lock);
- atomic_dec(&el->rc, relfunc) ...
+ if(atomic_dec_and_test(&el->rc)) ...
+ kfree(el);
... remove_element
} write_unlock(&list_lock);
...
@@ -44,6 +46,7 @@ search_and_reference() could potentially hold reference to an element which
has already been deleted from the list/array. Use atomic_inc_not_zero()
in this scenario as follows:
+CODE LISTING B:
1. 2.
add() search_and_reference()
{ {
@@ -79,6 +82,7 @@ search_and_reference() code path. In such cases, the
atomic_dec_and_test() may be moved from delete() to el_free()
as follows:
+CODE LISTING C:
1. 2.
add() search_and_reference()
{ {
@@ -114,6 +118,17 @@ element can therefore safely be freed. This in turn guarantees that if
any reader finds the element, that reader may safely acquire a reference
without checking the value of the reference counter.
+A clear advantage of the RCU-based pattern in listing C over the one
+in listing B is that any call to search_and_reference() that locates
+a given object will succeed in obtaining a reference to that object,
+even given a concurrent invocation of delete() for that same object.
+Similarly, a clear advantage of both listings B and C over listing A is
+that a call to delete() is not delayed even if there are an arbitrarily
+large number of calls to search_and_reference() searching for the same
+object that delete() was invoked on. Instead, all that is delayed is
+the eventual invocation of kfree(), which is usually not a problem on
+modern computer systems, even the small ones.
+
In cases where delete() can sleep, synchronize_rcu() can be called from
delete(), so that el_free() can be subsumed into delete as follows:
@@ -130,3 +145,7 @@ delete()
kfree(el);
...
}
+
+As additional examples in the kernel, the pattern in listing C is used by
+reference counting of struct pid, while the pattern in listing B is used by
+struct posix_acl.
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH tip/core/rcu 2/2] doc: Fixup definition of rcupdate.rcu_task_stall_timeout
2019-05-30 14:55 [PATCH tip/core/rcu 0/2] Documentation updates for v5.3 Paul E. McKenney
2019-05-30 14:55 ` [PATCH tip/core/rcu 1/2] doc/rcuref: Document real world examples in kernel Paul E. McKenney
@ 2019-05-30 14:55 ` Paul E. McKenney
1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2019-05-30 14:55 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, mingo, jiangshanlai, dipankar, akpm,
mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
edumazet, fweisbec, oleg, joel, Zhenzhong Duan, Paul E . McKenney
From: Zhenzhong Duan <zhenzhong.duan@oracle.com>
A positive value of rcupdate.rcu_task_stall_timeout is an interval
in seconds rather than jiffies.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
---
Documentation/RCU/stallwarn.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/RCU/stallwarn.txt b/Documentation/RCU/stallwarn.txt
index 1ab70c37921f..13e88fc00f01 100644
--- a/Documentation/RCU/stallwarn.txt
+++ b/Documentation/RCU/stallwarn.txt
@@ -153,7 +153,7 @@ rcupdate.rcu_task_stall_timeout
This boot/sysfs parameter controls the RCU-tasks stall warning
interval. A value of zero or less suppresses RCU-tasks stall
warnings. A positive value sets the stall-warning interval
- in jiffies. An RCU-tasks stall warning starts with the line:
+ in seconds. An RCU-tasks stall warning starts with the line:
INFO: rcu_tasks detected stalls on tasks:
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-30 14:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 14:55 [PATCH tip/core/rcu 0/2] Documentation updates for v5.3 Paul E. McKenney
2019-05-30 14:55 ` [PATCH tip/core/rcu 1/2] doc/rcuref: Document real world examples in kernel Paul E. McKenney
2019-05-30 14:55 ` [PATCH tip/core/rcu 2/2] doc: Fixup definition of rcupdate.rcu_task_stall_timeout Paul E. McKenney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.