From: Steven Rostedt <rostedt@goodmis.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] tracing/sched: Check preempt_count() for current when reading task->state
Date: Thu, 11 Dec 2014 09:17:47 -0500 [thread overview]
Message-ID: <20141211091747.6cecf1ef@gandalf.local.home> (raw)
In-Reply-To: <20141211123121.GB18538@gmail.com>
On Thu, 11 Dec 2014 13:31:21 +0100
Ingo Molnar <mingo@kernel.org> wrote:
> > What overhead are you worried about? Note, this is in the
> > schedule tracepoint and does not affect the scheduler itself
> > (as long as the tracepoint is not enabled).
>
> Scheduler tracepoints are pretty popular, so I'm worried about
> their complexity when they are activated.
Understood.
>
> > I'm also thinking that as long as "prev" is always guaranteed
> > to be "current" we can remove the check and just use
> > preempt_count() always. But I'm worried that we can't
> > guaranteed that.
>
> You could add a WARN_ON_ONCE() or so to double check that
> assumption?
I actually thought about that, but that gives us the same overhead as
the branch we want to remove.
But if you are going for simpler, then that would make sense.
>
> > What other ideas do you have? Because wrong data is worse than
> > the overhead of the above code. If Thomas taught me anything,
> > it's that!
>
> My idea is to have simpler, yet correct code. And ponies!
So something like this instead?
-- Steve
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 0a68d5ae584e..782018b135ff 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -97,10 +97,12 @@ static inline long __trace_sched_switch_state(struct task_struct *p)
long state = p->state;
#ifdef CONFIG_PREEMPT
+ WARN_ON_ONCE(p != current);
+
/*
* For all intents and purposes a preempted task is a running task.
*/
- if (task_preempt_count(p) & PREEMPT_ACTIVE)
+ if (preempt_count() & PREEMPT_ACTIVE)
state = TASK_RUNNING | TASK_STATE_MAX;
#endif
next prev parent reply other threads:[~2014-12-11 14:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 22:44 Steven Rostedt
2014-12-11 4:58 ` Steven Rostedt
2014-12-11 6:38 ` Ingo Molnar
2014-12-11 11:37 ` Steven Rostedt
2014-12-11 12:31 ` Ingo Molnar
2014-12-11 14:17 ` Steven Rostedt [this message]
2014-12-11 16:50 ` 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=20141211091747.6cecf1ef@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®