Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v3)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mathieu Desnoyers
Date: Thursday, April 17, 2008 - 5:05 pm

* Andi Kleen (andi@firstfloor.org) wrote:

oprofile hooks this in the nmi callbacks :

arch/x86/oprofile/nmi_timer_int.c: profile_timer_exceptions_notify()
calls
drivers/oprofile/oprofile_add_sample()
which calls oprofile_add_ext_sample()
where
       if (log_sample(cpu_buf, pc, is_kernel, event))
                oprofile_ops.backtrace(regs, backtrace_depth);

First, log_sample writes into the vmalloc'd cpu buffer. That's for one
possible page fault.

Then, is a kernel backtrace happen, then I am not sure if printk_address
won't try to read any of the module data, which is vmalloc'd.



Isn't vmalloc_sync() an expensive operation ? That would imply doing a
vmalloc_sync() after loading modules and after each buffer allocation I
suppose. And it's also to be able to put a breakpoint there, for the
immediate values.


The fact is that NMIs are very useful and powerful when it comes to try
to understand where code disabling interrupts is stucked, to get
performance counter reads periodically without suffering from IRQ
latency. Also, when trying to figure out what is actually happening in
the kernel timekeeping, having a stable periodic time source can be
pretty useful. Hooking this kind of feature in a tracer seems rather
logical.



That would be one way to do it, except that it would not deal with int3.
Also, it would have to be taken into account at module load time. To me,
that looks like an error-prone design. If the problem is at the lower
end of the architecture, in the interrupt return path, why don't we
simply fix it there for good ?


hmmm ? :) There is no "init" function in marker.c. It depends on the rcu
mechanism though, so I guess we can instrument start_kernel only after
rcu_init(). And yes, boot code is one of the first thing embedded system
developers want to instrument.


LTTng is a lockless tracer which uses the RCU mechanism for control data
structure updates and a lockless cmpxchg_local scheme to manage the
per-cpu buffer space reservation. It has been out there for about 3
years now and is used in the industry.


I wonder if they are used so rarely because the underlying kernel is
buggy with respect with NMIs or because they are useless.


You should have a look at LTTng then. ;) And by the way, the kernel
marker infrastructure also uses RCU-style updates and is designed to be
NMI-safe from the start.

Mathieu



-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Mathieu Desnoyers, (Mon Apr 14, 4:05 pm)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Ingo Molnar, (Wed Apr 16, 6:06 am)
[TEST PATCH] Test NMI kprobe modules, Mathieu Desnoyers, (Wed Apr 16, 6:47 am)
Re: [TEST PATCH] Test NMI kprobe modules, Ingo Molnar, (Wed Apr 16, 7:34 am)
Re: [TEST PATCH] Test NMI kprobe modules, Mathieu Desnoyers, (Wed Apr 16, 7:54 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Ingo Molnar, (Wed Apr 16, 8:10 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), H. Peter Anvin, (Wed Apr 16, 8:18 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Mathieu Desnoyers, (Wed Apr 16, 8:37 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Jeremy Fitzhardinge, (Wed Apr 16, 9:03 am)
[RFC PATCH] x86 NMI-safe INT3 and Page Fault (v3), Mathieu Desnoyers, (Wed Apr 16, 9:28 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v3), Jeremy Fitzhardinge, (Wed Apr 16, 10:57 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v3), Mathieu Desnoyers, (Thu Apr 17, 9:29 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v3), Mathieu Desnoyers, (Thu Apr 17, 5:05 pm)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Mathieu Desnoyers, (Thu Apr 17, 5:48 pm)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v2), Jeremy Fitzhardinge, (Fri Apr 18, 2:49 am)
Re: [RFC PATCH] x86 NMI-safe INT3 and Page Fault (v3), Mathieu Desnoyers, (Sat Apr 19, 2:18 pm)