atomic_ops.rst: Fix wrong example code
PATCH 1/2 atomic_ops.rst: Fix wrong example code
Example code snippets for necessary of READ_ONCE() and WRITE_ONCE() has an unnecessary line of code and wrong condition. This commit fixes them.
Signed-off-by SeongJae Park <[email protected]>
--- Documentation/core-api/atomic_ops.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Documentation/core-api/atomic_ops.rst +1 -2
@@ -111,7 +111,6 @@ If the compiler can prove that do_something() does not store to the variable a, then the compiler is within its rights transforming this to the following:: - tmp = a; if (a > 0) for (;;) do_something();
@@ -119,7 +118,7 @@ the following:: If you don't want the compiler to do this (and you probably don't), then you should use something like the following:: - while (READ_ONCE(a) < 0) + while (READ_ONCE(a) > 0) do_something(); Alternatively, you could place a barrier() call in the loop.
Signature · 6 lines
2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 atomic_ops.rst: Use `warning` rst directive
One warning message in 'atomic_ops.rst' is not using 'warning' rst directive while others does. This commit modifies the message to use 'warning' rst directive.
Signed-off-by SeongJae Park <[email protected]>
--- Documentation/core-api/atomic_ops.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Documentation/core-api/atomic_ops.rst +6 -4
@@ -466,10 +466,12 @@ Like the above, except that these routines return a boolean which indicates whether the changed bit was set _BEFORE_ the atomic bit operation. -WARNING! It is incredibly important that the value be a boolean, -ie. "0" or "1". Do not try to be fancy and save a few instructions by -declaring the above to return "long" and just returning something like -"old_val & mask" because that will not work. + +.. warning:: + It is incredibly important that the value be a boolean, ie. "0" or "1". + Do not try to be fancy and save a few instructions by declaring the + 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
Signature · 1 line
2.13.0
Quoted 5 lines · SeongJae Park
Example code snippets for necessary of
READ_ONCE()andWRITE_ONCE()has an unnecessary line of code and wrong condition. This commit fixes them.Signed-off-by SeongJae Park <[email protected]>
Good catch!!! I queued and pushed both patches for further review, thank you!
Thanx, Paul
Quoted 28 lines
--- Documentation/core-api/atomic_ops.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Documentation/core-api/atomic_ops.rst +1
-2@@ -111,7 +111,6 @@ If the compiler can prove that do_something() does not store to the variable a, then the compiler is within its rights transforming this to the following:: - tmp = a; if (a > 0) for (;;) do_something();@@ -119,7 +118,7 @@ the following:: If you don't want the compiler to do this (and you probably don't), then you should use something like the following:: - while (READ_ONCE(a) < 0) + while (READ_ONCE(a) > 0) do_something(); Alternatively, you could place a barrier() call in the loop.Signature · 1 line
2.13.0