This is the mail archive of the
systemtap@sources.redhat.com
mailing list for the systemtap project.
Re: Hitachi djprobe mechanism
- From: Mathieu Desnoyers <compudj at krystal dot dyndns dot org>
- To: Karim Yaghmour <karim at opersys dot com>
- Cc: Masami Hiramatsu <masami dot hiramatsu at gmail dot com>, "Keshavamurthy, Anil S" <anil dot s dot keshavamurthy at intel dot com>, Masami Hiramatsu <hiramatu at sdl dot hitachi dot co dot jp>, Roland McGrath <roland at redhat dot com>, Richard J Moore <richardj_moore at uk dot ibm dot com>, SystemTAP <systemtap at sources dot redhat dot com>, sugita at sdl dot hitachi dot co dot jp, Satoshi Oshima <soshima at redhat dot com>, michel dot dagenais at polymtl dot ca
- Date: Thu, 28 Jul 2005 13:35:15 -0400
- Subject: Re: Hitachi djprobe mechanism
- References: <44BDAFB888F59F408FAE3CC35AB4704101E506F6@orsmsx409> <42E83895.6070602@opersys.com> <42E83CEC.8040702@opersys.com> <f86b20530507280922819d927@mail.gmail.com> <42E90600.3040709@opersys.com>
* Karim Yaghmour (karim@opersys.com) wrote:
>
> Masami Hiramatsu wrote:
> > I think so. the size of smallest jmp instruction is 2 bytes on i386,
> > but the smallest instruction is 1byte on i386 (ex. pushl %esi).
> > I will try to add safety check routine in sched() and do_IRQ().
>
> I'm sorry, I'm probably missing something. What will the checks in
> sched() and do_IRQ() do to avoid problems?
>
I suggest this approach :
* Using a landing zone for the probe initially filled with something like :
(for a 5 bytes jmp instruction)
local_irq_save ("pushfl ; popl %0 ; cli")
nop
nop
nop
nop
local_irq_restore ("pushl %0 ; popfl")
It will protect from interruptions (therefore preemption) in the landing zone on
every CPU.
* Let's see what the code alteration function could do :
You may then change the cli instruction from the local_irq_save for an int3
instruction. You then simply check that no other CPU has interrupts disabled
(use an IPI). You are then sure that no other CPU is in the zone you want to
modify (or has an address falling in this zone as a return address from an
interrupt).
The only problem you will have is if an NMI comes in at the middle of the nops.
But hey! The processors won't answer to your low priority IPI until the NMI
handler has finished and interrupts are reenabled.
Once you known that your zone
int3
nop
nop
nop
nop
is protected, you just have to change those 5 bytes for your jmp (make sure that
int3 is the last one to be changed).
* Then int3 handler could simply return to the exact spot at the pushl %0.
The downside of this approach is that it needs a marker in the code and has a
small impact on a system performance when it is not traced.
Any comments ?
Mathieu
OpenPGP public key: http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68