Skip to contentSkip to conversation

docs: a few improvements for atomic_ops.rst

PATCH In review Jonathan Neuschäfer 4 participants 8 messages Mar 8, 2020 – Mar 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover docs: a few improvements for atomic_ops.rst

Hi,

this is a short series of unrelated fixes that make the atomic operations documentation look and read a bit better.

Jonathan Neuschäfer (3):
docs: atomic_ops: Remove colons where they don't make sense
docs: atomic_ops: Move two paragraphs into the warning block above
docs: atomic_ops: Steer readers towards using refcount_t for reference
counts

 Documentation/core-api/atomic_ops.rst         | 24 ++++++++++++-------
 Documentation/core-api/refcount-vs-atomic.rst |  2 ++
 2 files changed, 17 insertions(+), 9 deletions(-)

--
2.20.1

#1 lore raw

PATCH 1/3 docs: atomic_ops: Remove colons where they don't make sense

There are a few cases on atomic_ops.rst, where a end-of-line colon before a code block seems semantically wrong, because the code block is not related to the sentence before it.

End those lines with . :: instead, which is rendered as a period but still formats the next line/block as a code block.

---
 Documentation/core-api/atomic_ops.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/core-api/atomic_ops.rst +2 -2
index 724583453e1f..650b9693469a 100644
@@ -242,13 +242,13 @@ given atomic counter.  They return a boolean indicating whether the
 resulting counter value was zero or not.
 
 Again, these primitives provide explicit memory barrier semantics around
-the atomic operation::
+the atomic operation. ::
 
 	int atomic_sub_and_test(int i, atomic_t *v);
 
 This is identical to atomic_dec_and_test() except that an explicit
 decrement is given instead of the implicit "1".  This primitive must
-provide explicit memory barrier semantics around the operation::
+provide explicit memory barrier semantics around the operation. ::
 
 	int atomic_add_negative(int i, atomic_t *v);
 

--
2.20.1

#2 lore raw

PATCH 2/3 docs: atomic_ops: Move two paragraphs into the warning block above

In reply to Jonathan Neuschäfer

These two paragraphs seem to be semantically part of the warning text, so let's adjust the formatting accordingly.

---
 Documentation/core-api/atomic_ops.rst | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Documentation/core-api/atomic_ops.rst +8 -8
index 650b9693469a..73033fc954ad 100644
@@ -473,14 +473,14 @@ operation.
         above to return "long" and just returning something like "old_val &
         mask" because that will not work.
 
-For one thing, this return value gets truncated to int in many code
-paths using these interfaces, so on 64-bit if the bit is set in the
-upper 32-bits then testers will never see that.
-
-One great example of where this problem crops up are the thread_info
-flag operations.  Routines such as test_and_set_ti_thread_flag() chop
-the return value into an int.  There are other places where things
-like this occur as well.
+        For one thing, this return value gets truncated to int in many code
+        paths using these interfaces, so on 64-bit if the bit is set in the
+        upper 32-bits then testers will never see that.
+
+        One great example of where this problem crops up are the thread_info
+        flag operations.  Routines such as test_and_set_ti_thread_flag() chop
+        the return value into an int.  There are other places where things
+        like this occur as well.
 
 These routines, like the atomic_t counter operations returning values,
 must provide explicit memory barrier semantics around their execution.

--
2.20.1

#3 lore raw

PATCH 3/3 docs: atomic_ops: Steer readers towards using refcount_t for reference counts

In reply to Jonathan Neuschäfer
---
 Documentation/core-api/atomic_ops.rst         | 6 ++++++
 Documentation/core-api/refcount-vs-atomic.rst | 2 ++
 2 files changed, 8 insertions(+)
Documentation/core-api/atomic_ops.rst +6 -0
index 73033fc954ad..37a0ffe1a9f1 100644
@@ -392,6 +392,12 @@ be guaranteed that no other entity can be accessing the object::
 	memory barriers in kfree_skb() that exposed the atomic_t memory barrier
 	requirements quite clearly.
 
+.. note::
+
+        More recently, reference counts are implement using the
+        :ref:`refcount_t <refcount_t_vs_atomic_t>` type, which works like
+        atomic_t but protects against wraparound.
+
 Given the above scheme, it must be the case that the obj->active
 update done by the obj list deletion be visible to other processors
 before the atomic counter decrement is performed.
Documentation/core-api/refcount-vs-atomic.rst +2 -0
index 79a009ce11df..d979ff5166ae 100644
@@ -1,3 +1,5 @@
+.. _refcount_t_vs_atomic_t:
+
 ===================================
 refcount_t API compared to atomic_t
 ===================================

--
2.20.1

reviewer
#4 lore raw

Re: [PATCH 3/3] docs: atomic_ops: Steer readers towards using refcount_t for reference counts

Quoted 11 lines · Jonathan Neuschäfer
---
 Documentation/core-api/atomic_ops.rst         | 6 ++++++
 Documentation/core-api/refcount-vs-atomic.rst | 2 ++
 2 files changed, 8 insertions(+)
Documentation/core-api/atomic_ops.rst +0 -0
index 73033fc954ad..37a0ffe1a9f1 100644

Documentation/core-api/atomic_ops.rst be guaranteed that no other entity can be accessing the object:: · line 397

Quoted 6 lines
Documentation/core-api/atomic_ops.rst +3 -0
@@ -392,6 +392,12 @@ be guaranteed that no other entity can be accessing the object::
 	memory barriers in kfree_skb() that exposed the atomic_t memory barrier
 	requirements quite clearly.
 
+.. note::
+
+        More recently, reference counts are implement using the

implemented

Quoted 6 lines
Documentation/core-api/atomic_ops.rst +3 -0
+        :ref:`refcount_t <refcount_t_vs_atomic_t>` type, which works like
+        atomic_t but protects against wraparound.
+
 Given the above scheme, it must be the case that the obj->active
 update done by the obj list deletion be visible to other processors
 before the atomic counter decrement is performed.
Signature · 1 line
~Randy
#5 lore raw

Re: [PATCH 3/3] docs: atomic_ops: Steer readers towards using refcount_t for reference counts

Quoted 1 line · Randy Dunlap

On 3/8/20 1:00 PM, Jonathan Neuschäfer wrote:

[...]

Quoted 3 lines
Quoted 1 line

+ More recently, reference counts are implement using the

implemented

Indeed, good catch.

Thanks,
Jonathan Neuschäfer

maintainer
#6 lore raw
In reply to Jonathan Neuschäfer
Quoted 5 lines · Jonathan Neuschäfer

Hi,

this is a short series of unrelated fixes that make the atomic operations documentation look and read a bit better.

Quoted 7 lines

Jonathan Neuschäfer (3):
docs: atomic_ops: Remove colons where they don't make sense
docs: atomic_ops: Move two paragraphs into the warning block above
docs: atomic_ops: Steer readers towards using refcount_t for reference
counts

 Documentation/core-api/atomic_ops.rst         | 24 ++++++++++++-------

FWIW, I consider this a dead document. I've written Documentation/atomic_t.txt and Documentation/atomic_bitops.txt as a replacement. If there is anything in atomic_ops you feel is missing from those two, please tell as I'm planing to delete atomic_ops soon.

maintainer Acked-by
#7 lore raw
Quoted 12 lines · Peter Zijlstra
Quoted 11 lines · Jonathan Neuschäfer

Hi,

this is a short series of unrelated fixes that make the atomic operations documentation look and read a bit better.

Jonathan Neuschäfer (3):
docs: atomic_ops: Remove colons where they don't make sense
docs: atomic_ops: Move two paragraphs into the warning block above
docs: atomic_ops: Steer readers towards using refcount_t for reference
counts

Quoted 6 lines
Quoted 1 line
 Documentation/core-api/atomic_ops.rst         | 24 ++++++++++++-------

FWIW, I consider this a dead document. I've written Documentation/atomic_t.txt and Documentation/atomic_bitops.txt as a replacement. If there is anything in atomic_ops you feel is missing from those two, please tell as I'm planing to delete atomic_ops soon.

For the deletion:

Will