Re: [PATCH RESEND] tracing: Fix overflow in get_free_elt()

From
Steven Rostedt <rostedt@goodmis.org>
Date
2024-08-07 13:28:47
Also in
linux-mediatek, lkml
Reply to
Tze-nan Wu (吳澤南), 2024-08-07
On Wed, 7 Aug 2024 11:34:43 +0000
Tze-nan Wu (吳澤南) [off-list ref] wrote:
quoted
quoted
-idx = atomic_inc_return(&map->next_elt);
+idx = atomic_fetch_add_unless(&map->next_elt, 1, map->max_elts);  
I guess we need to add (with a comment):

idx--;
  
Thanks for reviewing this!

By reference to "/include/linux/atomic/atomic-instrumented.h",
`atomic_fetch_add_unless` will return the original value before the
adding happens on operands.
Ah, right. I haven't used that before and was thinking this was the same as
the inc_return().

-- Steve
Thread (4 messages) 4 messages, 2 authors, last reply 2024-08-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help