From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 2/3] ftrace: insert in the ftrace_preempt_disable functions
Date: Mon, 03 Nov 2008 23:15:56 -0500 [thread overview]
Message-ID: <20081104042203.362452209@goodmis.org> (raw)
In-Reply-To: 20081104041554.605521183@goodmis.org
[-- Attachment #1: ftrace-preempt-disable-implement.patch --]
[-- Type: text/plain, Size: 5142 bytes --]
This patch replaces the schedule safe preempt disable code with the
ftrace_preempt_disable and ftrace_preempt_enable safe functions.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/ring_buffer.c | 27 +++++++++------------------
kernel/trace/trace.c | 8 ++------
kernel/trace/trace_sched_wakeup.c | 13 ++-----------
kernel/trace/trace_stack.c | 8 ++------
4 files changed, 15 insertions(+), 41 deletions(-)
Index: linux-tip.git/kernel/trace/ring_buffer.c
===================================================================
--- linux-tip.git.orig/kernel/trace/ring_buffer.c 2008-11-03 18:49:30.000000000 -0500
+++ linux-tip.git/kernel/trace/ring_buffer.c 2008-11-03 19:05:24.000000000 -0500
@@ -16,6 +16,8 @@
#include <linux/list.h>
#include <linux/fs.h>
+#include "trace.h"
+
/* Up this if you want to test the TIME_EXTENTS and normalization */
#define DEBUG_SHIFT 0
@@ -1122,8 +1124,7 @@ ring_buffer_lock_reserve(struct ring_buf
return NULL;
/* If we are tracing schedule, we don't want to recurse */
- resched = need_resched();
- preempt_disable_notrace();
+ resched = ftrace_preempt_disable();
cpu = raw_smp_processor_id();
@@ -1154,10 +1155,7 @@ ring_buffer_lock_reserve(struct ring_buf
return event;
out:
- if (resched)
- preempt_enable_notrace();
- else
- preempt_enable_notrace();
+ ftrace_preempt_enable(resched);
return NULL;
}
@@ -1199,12 +1197,9 @@ int ring_buffer_unlock_commit(struct rin
/*
* Only the last preempt count needs to restore preemption.
*/
- if (preempt_count() == 1) {
- if (per_cpu(rb_need_resched, cpu))
- preempt_enable_no_resched_notrace();
- else
- preempt_enable_notrace();
- } else
+ if (preempt_count() == 1)
+ ftrace_preempt_enable(per_cpu(rb_need_resched, cpu));
+ else
preempt_enable_no_resched_notrace();
return 0;
@@ -1237,8 +1232,7 @@ int ring_buffer_write(struct ring_buffer
if (atomic_read(&buffer->record_disabled))
return -EBUSY;
- resched = need_resched();
- preempt_disable_notrace();
+ resched = ftrace_preempt_disable();
cpu = raw_smp_processor_id();
@@ -1264,10 +1258,7 @@ int ring_buffer_write(struct ring_buffer
ret = 0;
out:
- if (resched)
- preempt_enable_no_resched_notrace();
- else
- preempt_enable_notrace();
+ ftrace_preempt_enable(resched);
return ret;
}
Index: linux-tip.git/kernel/trace/trace.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace.c 2008-11-03 18:49:37.000000000 -0500
+++ linux-tip.git/kernel/trace/trace.c 2008-11-03 19:05:24.000000000 -0500
@@ -893,8 +893,7 @@ function_trace_call(unsigned long ip, un
return;
pc = preempt_count();
- resched = need_resched();
- preempt_disable_notrace();
+ resched = ftrace_preempt_disable();
local_save_flags(flags);
cpu = raw_smp_processor_id();
data = tr->data[cpu];
@@ -904,10 +903,7 @@ function_trace_call(unsigned long ip, un
trace_function(tr, data, ip, parent_ip, flags, pc);
atomic_dec(&data->disabled);
- if (resched)
- preempt_enable_no_resched_notrace();
- else
- preempt_enable_notrace();
+ ftrace_preempt_enable(resched);
}
static struct ftrace_ops trace_ops __read_mostly =
Index: linux-tip.git/kernel/trace/trace_sched_wakeup.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace_sched_wakeup.c 2008-11-03 18:49:30.000000000 -0500
+++ linux-tip.git/kernel/trace/trace_sched_wakeup.c 2008-11-03 19:05:24.000000000 -0500
@@ -50,8 +50,7 @@ wakeup_tracer_call(unsigned long ip, uns
return;
pc = preempt_count();
- resched = need_resched();
- preempt_disable_notrace();
+ resched = ftrace_preempt_disable();
cpu = raw_smp_processor_id();
data = tr->data[cpu];
@@ -81,15 +80,7 @@ wakeup_tracer_call(unsigned long ip, uns
out:
atomic_dec(&data->disabled);
- /*
- * To prevent recursion from the scheduler, if the
- * resched flag was set before we entered, then
- * don't reschedule.
- */
- if (resched)
- preempt_enable_no_resched_notrace();
- else
- preempt_enable_notrace();
+ ftrace_preempt_enable(resched);
}
static struct ftrace_ops trace_ops __read_mostly =
Index: linux-tip.git/kernel/trace/trace_stack.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace_stack.c 2008-11-03 18:49:30.000000000 -0500
+++ linux-tip.git/kernel/trace/trace_stack.c 2008-11-03 19:05:24.000000000 -0500
@@ -107,8 +107,7 @@ stack_trace_call(unsigned long ip, unsig
if (unlikely(!ftrace_enabled || stack_trace_disabled))
return;
- resched = need_resched();
- preempt_disable_notrace();
+ resched = ftrace_preempt_disable();
cpu = raw_smp_processor_id();
/* no atomic needed, we only modify this variable by this cpu */
@@ -120,10 +119,7 @@ stack_trace_call(unsigned long ip, unsig
out:
per_cpu(trace_active, cpu)--;
/* prevent recursion in schedule */
- if (resched)
- preempt_enable_no_resched_notrace();
- else
- preempt_enable_notrace();
+ ftrace_preempt_enable(resched);
}
static struct ftrace_ops trace_ops __read_mostly =
--
next prev parent reply other threads:[~2008-11-04 4:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 4:15 [PATCH 0/3] ftrace: code consolidation Steven Rostedt
2008-11-04 4:15 ` [PATCH 1/3] ftrace: ftrace_preempt_disable Steven Rostedt
2008-11-04 9:10 ` Ingo Molnar
2008-11-04 21:48 ` [PATCH] ftrace: ftrace_preempt_disable comment fix Steven Rostedt
2008-11-04 21:52 ` [PATCH v2] " Steven Rostedt
2008-11-04 22:05 ` [PATCH v3] " Steven Rostedt
2008-11-04 4:15 ` Steven Rostedt [this message]
2008-11-04 4:15 ` [PATCH 3/3] ftrace: function tracer with irqs disabled Steven Rostedt
2008-11-04 8:07 ` Ingo Molnar
2008-11-04 8:17 ` Zhang, Yanmin
2008-11-04 9:04 ` Ingo Molnar
2008-11-04 14:44 ` Steven Rostedt
2008-11-04 16:43 ` Ingo Molnar
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=20081104042203.362452209@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.