Commit 09024348 authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Sasha Levin

ring-buffer: Remove duplicate use of '&' in recursive code

[ Upstream commit d631c8cc ]

A clean up of the recursive protection code changed

  val = this_cpu_read(current_context);
  val--;
  val &= this_cpu_read(current_context);

to

  val = this_cpu_read(current_context);
  val &= val & (val - 1);

Which has a duplicate use of '&' as the above is the same as

  val = val & (val - 1);

Actually, it would be best to remove that line altogether and
just add it to where it is used.

And Christoph even mentioned that it can be further compacted to
just a single line:

  __this_cpu_and(current_context, __this_cpu_read(current_context) - 1);

Link: http://lkml.kernel.org/alpine.DEB.2.11.1503271423580.23114@gentwo.orgSuggested-by: default avatarChristoph Lameter <cl@linux.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 4baf9733
......@@ -2708,10 +2708,7 @@ static __always_inline int trace_recursive_lock(void)
static __always_inline void trace_recursive_unlock(void)
{
unsigned int val = __this_cpu_read(current_context);
val &= val & (val - 1);
__this_cpu_write(current_context, val);
__this_cpu_and(current_context, __this_cpu_read(current_context) - 1);
}
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment