public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 03/21] ftrace: Add ftrace_rec_counter() macro to simplify the code
Date: Thu, 03 Jul 2014 12:05:06 -0400	[thread overview]
Message-ID: <20140703161223.916756641@goodmis.org> (raw)
In-Reply-To: 20140703160503.006976702@goodmis.org

[-- Attachment #1: 0003-ftrace-Add-ftrace_rec_counter-macro-to-simplify-the-.patch --]
[-- Type: text/plain, Size: 3065 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

The ftrace dynamic record has a flags element that also has a counter.
Instead of hard coding "rec->flags & ~FTRACE_FL_MASK" all over the
place. Use a macro instead.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/ftrace.h |  2 ++
 kernel/trace/ftrace.c  | 12 ++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index e4e7df422021..e5baa6b2c93f 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -328,6 +328,8 @@ enum {
 #define FTRACE_FL_MASK		(FTRACE_FL_MASKED_BITS << FTRACE_REF_MAX_SHIFT)
 #define FTRACE_REF_MAX		((1UL << FTRACE_REF_MAX_SHIFT) - 1)
 
+#define ftrace_rec_count(rec)	((rec)->flags & ~FTRACE_FL_MASK)
+
 struct dyn_ftrace {
 	unsigned long		ip; /* address of mcount call-site */
 	unsigned long		flags;
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b867c647e5bc..a58d840305c3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1592,7 +1592,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
 
 		if (inc) {
 			rec->flags++;
-			if (FTRACE_WARN_ON((rec->flags & ~FTRACE_FL_MASK) == FTRACE_REF_MAX))
+			if (FTRACE_WARN_ON(ftrace_rec_count(rec) == FTRACE_REF_MAX))
 				return;
 			/*
 			 * If any ops wants regs saved for this function
@@ -1601,7 +1601,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
 			if (ops->flags & FTRACE_OPS_FL_SAVE_REGS)
 				rec->flags |= FTRACE_FL_REGS;
 		} else {
-			if (FTRACE_WARN_ON((rec->flags & ~FTRACE_FL_MASK) == 0))
+			if (FTRACE_WARN_ON(ftrace_rec_count(rec) == 0))
 				return;
 			rec->flags--;
 			/*
@@ -1610,7 +1610,7 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
 			 * still any ops for this record that wants regs.
 			 * If not, we can stop recording them.
 			 */
-			if ((rec->flags & ~FTRACE_FL_MASK) > 0 &&
+			if (ftrace_rec_count(rec) > 0 &&
 			    rec->flags & FTRACE_FL_REGS &&
 			    ops->flags & FTRACE_OPS_FL_SAVE_REGS) {
 				if (!test_rec_ops_needs_regs(rec))
@@ -1700,7 +1700,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update)
 	 * If we are disabling calls, then disable all records that
 	 * are enabled.
 	 */
-	if (enable && (rec->flags & ~FTRACE_FL_MASK))
+	if (enable && ftrace_rec_count(rec))
 		flag = FTRACE_FL_ENABLED;
 
 	/*
@@ -1746,7 +1746,7 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update)
 
 	if (update) {
 		/* If there's no more users, clear all flags */
-		if (!(rec->flags & ~FTRACE_FL_MASK))
+		if (!ftrace_rec_count(rec))
 			rec->flags = 0;
 		else
 			/* Just disable the record (keep REGS state) */
@@ -2685,7 +2685,7 @@ static int t_show(struct seq_file *m, void *v)
 	seq_printf(m, "%ps", (void *)rec->ip);
 	if (iter->flags & FTRACE_ITER_ENABLED)
 		seq_printf(m, " (%ld)%s",
-			   rec->flags & ~FTRACE_FL_MASK,
+			   ftrace_rec_count(rec),
 			   rec->flags & FTRACE_FL_REGS ? " R" : "");
 	seq_printf(m, "\n");
 
-- 
2.0.0



  parent reply	other threads:[~2014-07-03 16:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-03 16:05 [for-next][PATCH 00/21] tracing: Updates for 3.17 Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 01/21] ftrace: Allow no regs if no more callbacks require it Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 02/21] ftrace: Use macros for numbers in ftrace rec shift bits Steven Rostedt
2014-07-03 16:05 ` Steven Rostedt [this message]
2014-07-03 16:05 ` [for-next][PATCH 04/21] ftrace: Optimize function graph to be called directly Steven Rostedt
2014-07-10 17:45   ` Tuomas Tynkkynen
2014-07-10 18:01     ` Steven Rostedt
2014-07-12  3:36     ` Steven Rostedt
2014-07-12  3:37       ` Steven Rostedt
2014-07-14 13:46         ` Tuomas Tynkkynen
2014-07-14 16:14           ` Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 05/21] ftrace: Add trampolines to enabled_functions debug file Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 06/21] tracing: Change trace event sample to use strlcpy instead of strncpy Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 07/21] ftrace: Simplify ftrace_hash_disable/enable path in ftrace_hash_move Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 08/21] tracing: Move the trace_seq_* functions into its own trace_seq.c file Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 09/21] tracing: Clean up trace_seq.c Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 10/21] tracing: Make trace_seq_putmem_hex() more robust Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 11/21] tracing: Remove trace_seq_reserve() Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 12/21] tracing: Remove unnecessary null test before debugfs_remove() Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 13/21] tracing: Add trace_seq_buffer_ptr() helper function Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 14/21] ftrace: Get rid of obsolete global_start_up variable Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 15/21] ftrace: Fix memory leak on failure path in ftrace_allocate_pages() Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 16/21] ftrace: Do not copy hash if O_TRUNC is set Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 17/21] tracing: Convert pr_warning() to pr_warn() in trace_events.c Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 18/21] tracing: Add ftrace_graph_notrace boot parameter Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 19/21] tracing: Improve message of empty set_graph_notrace file Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 20/21] tracing: Improve message of empty set_ftrace_notrace file Steven Rostedt
2014-07-03 16:05 ` [for-next][PATCH 21/21] tracing: Add description of set_graph_notrace to tracing/README 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=20140703161223.916756641@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