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] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 21 Apr 2009 09:21:47 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc:	Steven Rostedt <rostedt@...dmis.org>,
	LKML <linux-kernel@...r.kernel.org>, mingo@...dmis.org,
	Frederic Weisbecker <fweisbec@...il.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Jeremy Fitzhardinge <jeremy@...p.org>,
	Masami Hiramatsu <mhiramat@...hat.com>
Subject: Re: [RFC] Stupid tracepoint ideas


* Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca> wrote:

> * Steven Rostedt (rostedt@...dmis.org) wrote:
> > 
> > On Mon, 20 Apr 2009, Mathieu Desnoyers wrote:
> > 
> > > * Steven Rostedt (rostedt@...dmis.org) wrote:
> > > > 
> > > > Mathieu,
> > > > 
> > > > You may have tried this in your creation of tracepoints, but I figured I 
> > > > would ask before wasting too much time on it.
> > > > 
> > > > I'm looking at ways to make tracepoints even lighter weight when disabled. 
> > > > And I thought of doing section code. I'm playing with the following idea 
> > > > (see below patch) but I'm afraid gcc is allowed to think that the code it 
> > > > produces will not move to different sections.
> > > > 
> > > > Any thoughts on how we could do something similar to this.
> > > > 
> > > > Note, this patch is purely proof-of-concept. I'm fully aware that it is an 
> > > > x86 solution only.
> > > > 
> > > > -- Steve
> > > > 
> > > > [ no Signed-off-by: because this patch is crap ]
> > > > 
> > > > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> > > > index 4353f3f..6953f78 100644
> > > > --- a/include/linux/tracepoint.h
> > > > +++ b/include/linux/tracepoint.h
> > > > @@ -65,9 +65,18 @@ struct tracepoint {
> > > >  	extern struct tracepoint __tracepoint_##name;			\
> > > >  	static inline void trace_##name(proto)				\
> > > >  	{								\
> > > > -		if (unlikely(__tracepoint_##name.state))		\
> > > > +		if (unlikely(__tracepoint_##name.state)) {		\
> > > > +			asm volatile ("jmp 43f\n"			\
> > > > +				      "42:\n"				\
> > > > +				      ".section .unlikely,\"ax\"\n"	\
> > > > +				      "43:\n"				\
> > > > +				      ::: "memory");			\
> > > >  			__DO_TRACE(&__tracepoint_##name,		\
> > > > -				TP_PROTO(proto), TP_ARGS(args));	\
> > > > +				   TP_PROTO(proto), TP_ARGS(args));	\
> > > > +			asm volatile ("jmp 42b\n"			\
> > > > +			     ".previous\n"				\
> > > > +			     ::: "memory");				\
> > > > +		}							\
> > > 
> > > You are right, I thought of this.
> > > 
> > > gcc forbids jumping outside of inline assembly statements. Optimisations
> > > done by gcc are not aware of this sort of execution flow modification,
> > > and gcc has every rights to interleave unrelated code between the two
> > > inline assembly statements.
> > 
> > Yeah, I was afraid of that :-/
> > 
> > Would be nice to apply sections to code:
> > 
> > 	__attribute__((section ".unlikely")) {
> > 		/* code for .unlikely section */
> > 	}
> > 
> > And have gcc do the jmps to and from the section.
> > 
> > This should not be too hard to implement.
> > 
> 
> Yes, but for some reason no kernel developer I know seems to be 
> very keen of digging into gcc's internals. :-)

There are some kernel developers who are also GCC developers - but i 
have to say the choice for a good developer is rather obvious: in 
the Linux kernel project the maximum latency until an obviously good 
patch hits upstream is around 3 months. In the GCC space the 
_minimum_ latency until an obviously good feature hits the compiler 
tends to be more like 2-3 years in the typical case.

I think the solution is obvious: the kernel needs its own compiler.

	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