From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 13/17] ftrace: Clean up the recursion code a bit
Date: Wed, 11 Nov 2020 19:32:57 -0500 [thread overview]
Message-ID: <20201112003335.043100338@goodmis.org> (raw)
In-Reply-To: <20201112003244.764326960@goodmis.org>
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
In trace_test_and_set_recursion(), current->trace_recursion is placed into a
variable, and that variable should be used for the processing, as there's no
reason to dereference current multiple times.
On trace_clear_recursion(), current->trace_recursion is modified and there's
no reason to copy it over to a variable.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
include/linux/trace_recursion.h | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
index 228cc56ed66e..a9f9c5714e65 100644
--- a/include/linux/trace_recursion.h
+++ b/include/linux/trace_recursion.h
@@ -162,7 +162,7 @@ extern void ftrace_record_recursion(unsigned long ip, unsigned long parent_ip);
static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsigned long pip,
int start, int max)
{
- unsigned int val = current->trace_recursion;
+ unsigned int val = READ_ONCE(current->trace_recursion);
int bit;
/* A previous recursion check was made */
@@ -176,18 +176,15 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
* a switch between contexts. Allow for a single recursion.
*/
bit = TRACE_TRANSITION_BIT;
- if (trace_recursion_test(bit)) {
+ if (val & (1 << bit)) {
do_ftrace_record_recursion(ip, pip);
return -1;
}
- trace_recursion_set(bit);
- barrier();
- return bit + 1;
+ } else {
+ /* Normal check passed, clear the transition to allow it again */
+ val &= ~(1 << TRACE_TRANSITION_BIT);
}
- /* Normal check passed, clear the transition to allow it again */
- trace_recursion_clear(TRACE_TRANSITION_BIT);
-
val |= 1 << bit;
current->trace_recursion = val;
barrier();
@@ -197,17 +194,12 @@ static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsign
static __always_inline void trace_clear_recursion(int bit)
{
- unsigned int val = current->trace_recursion;
-
if (!bit)
return;
- bit--;
- bit = 1 << bit;
- val &= ~bit;
-
barrier();
- current->trace_recursion = val;
+ bit--;
+ trace_recursion_clear(bit);
}
/**
--
2.28.0
next prev parent reply other threads:[~2020-11-12 1:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 0:32 [for-next][PATCH 00/17] tracing: Updates for 5.11 Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 01/17] ftrace: Move the recursion testing into global headers Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 02/17] ftrace: Add ftrace_test_recursion_trylock() helper function Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 03/17] ftrace: Optimize testing what context current is in Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 04/17] pstore/ftrace: Add recursion protection to the ftrace callback Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 05/17] kprobes/ftrace: " Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 06/17] livepatch/ftrace: " Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 07/17] livepatch: Trigger WARNING if livepatch function fails due to recursion Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 08/17] perf/ftrace: Add recursion protection to the ftrace callback Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 09/17] perf/ftrace: Check for rcu_is_watching() in callback function Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 10/17] ftrace: Reverse what the RECURSION flag means in the ftrace_ops Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 11/17] ftrace: Add recording of functions that caused recursion Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 12/17] fgraph: Make overruns 4 bytes in graph stack structure Steven Rostedt
2020-11-12 9:18 ` David Laight
2020-11-12 14:39 ` Steven Rostedt
2020-11-12 0:32 ` Steven Rostedt [this message]
2020-11-12 0:32 ` [for-next][PATCH 14/17] ring-buffer: Add recording of ring buffer recursion into recursed_functions Steven Rostedt
2020-11-12 0:32 ` [for-next][PATCH 15/17] ftrace: Remove unused varible ret Steven Rostedt
2020-11-12 0:33 ` [for-next][PATCH 16/17] tracing: Fix some typos in comments Steven Rostedt
2020-11-12 0:33 ` [for-next][PATCH 17/17] MAINTAINERS: assign ./fs/tracefs to TRACING Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201112003335.043100338@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome