lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20141211165031.GA29411@gmail.com>
Date:	Thu, 11 Dec 2014 17:50:31 +0100
From:	Ingo Molnar <mingo@...nel.org>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] tracing/sched: Check preempt_count() for current when
 reading task->state


* Steven Rostedt <rostedt@...dmis.org> wrote:

> On Thu, 11 Dec 2014 13:31:21 +0100
> Ingo Molnar <mingo@...nel.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;

Yeah, that looks a lot better IMHO, 'p' is supposed to be the 
current task, at least on a booted up system with a working 
scheduler. Not sure about transient initialization states such as 
very early boot and idle thread initialization - but it might 
work out for them as well.

If the WARN_ON_ONCE() remains silent on your testbox then I'd 
suggest removing the WARN_ON_ONCE(), the change looks good to me:

Acked-by: Ingo Molnar <mingo@...nel.org>

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ