This is the mail archive of the
mailing list for the systemtap project.
Re: [PATCH] Linux Kernel Markers
- From: Karim Yaghmour <karim at opersys dot com>
- To: Martin Bligh <mbligh at google dot com>
- Cc: prasanna at in dot ibm dot com, Andrew Morton <akpm at osdl dot org>, "Frank Ch. Eigler" <fche at redhat dot com>, Ingo Molnar <mingo at elte dot hu>, Mathieu Desnoyers <mathieu dot desnoyers at polymtl dot ca>, Paul Mundt <lethal at linux-sh dot org>, linux-kernel <linux-kernel at vger dot kernel dot org>, Jes Sorensen <jes at sgi dot com>, Tom Zanussi <zanussi at us dot ibm dot com>, Richard J Moore <richardj_moore at uk dot ibm dot com>, Michel Dagenais <michel dot dagenais at polymtl dot ca>, Christoph Hellwig <hch at infradead dot org>, Greg Kroah-Hartman <gregkh at suse dot de>, Thomas Gleixner <tglx at linutronix dot de>, William Cohen <wcohen at redhat dot com>, ltt-dev at shafik dot org, systemtap at sources dot redhat dot com, Alan Cox <alan at lxorguk dot ukuu dot org dot uk>
- Date: Tue, 19 Sep 2006 17:04:30 -0400
- Subject: Re: [PATCH] Linux Kernel Markers
- Organization: Opersys inc.
- References: <20060918234502.GA197@Krystal> <20060919081124.GA30394@elte.hu> <451008AC.email@example.com> <20060919154612.GU3951@redhat.com> <4510151B.firstname.lastname@example.org> <email@example.com> <45101DBA.firstname.lastname@example.org> <20060919063821.GB23836@in.ibm.com> <email@example.com> <20060919070516.GD23836@in.ibm.com> <451030A6.firstname.lastname@example.org>
- Reply-to: karim at opersys dot com
Martin Bligh wrote:
> be that many? Still doesn't fix the problem Matieu just pointed
> out though. Humpf.
There's one possibility if we're willing to insert a placeholder
at function entry that allows to essentially do what Andrew
suggests without much impact. Specifically, if you need a 5-byte
operation to jump to the alternate instrumented function, you
can then do something like:
1- At build time insert 5-byte unconditional jump to instruction
right after placeholder.
2- At runtime for diverting flow:
- Replace first byte with int3 (atomically)
- Replace next 4 bytes with instrumented function destination
- Replace first byte
3- At runtime for returning flow:
- Do #2 but for the original placeholder jump.
There's not race condition here or fear of interrupt return in
the middle of anything, or any need to stop the kernel from
operating and the likes, or even dependency on kprobes or need
for dprobes, at least in as far as I can see -- so this should
be trivial on m68k ;). The price to pay is an additional
unconditional jump at all times, which should be optimized at
runtime by the CPU. Benchmarks could help show the real impact,
but as Ingo said, these things should be minimal.
In sum, this would work for function pointers and wouldn't
require having to walk the code in search of instances of
"call foo" to replace.
Just a thought.