Re: [PATCH] Linux Kernel Markers

Masami Hiramatsu
2006-09-20T13:23:40Z

Hi,

Alan Cox wrote:
> Ar Mer, 2006-09-20 am 11:39 +0200, ysgrifennodd Helge Hafting:
>> How about this workaround:
>> 1. Overwrite the start of the function with a hlt, which is atomic.
>> 2. Write that 5-byte jump after the hlt.
>> 3. Overwrite the hlt with nop so things will work
>> 4. interrupt any cpus that got stuck on the hlt - or just wait for the
>> timer.
>
> CPU errata time again. You have to synchronize.

Sure, and the djprobe which I had developed method can treat it as below;
1. Overwrite the 1st instruction with int3. (atomic)
2. Wait until all processes running on every cpus are scheduled.
(I'm using synchronize_sched(). This step ensures no-one exist on
the instructions which will be overwritten by the dest-addr)
3. Write the destination address
4. Interrupt any cpus to serialize those caches (using CPUID).
5. Overwrite the int3 with jmp opcode. (atomic)

In this method, the instructions are updated like below;
0. [ insn1 ][ insn2]
1. [int3]1 ][ insn2]
2. wait
3. [int3][ destaddr]
4. sync
5. [jmp to destaddr]

Actually, #2 is not enough for the preemptive kernel. So, current
djprobe doesn't support CONFIG_PREEMPT. But Ingo proposed some
good ideas (use freeze_processes()). I'll try his ideas.

What would you think about djprobe's method?

Thanks,

--
Masami HIRAMATSU
2nd Research Dept.
Hitachi, Ltd., Systems Development Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com