Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Andi Kleen
> We don't need to flush all CPUs. This is my rationale: The debug > exception (single-step trap) will always happen on the same CPU that > the page fault occurred on. Page fault shows the page, debug exception > hides the page again. Between those two operations, nothing else can You're ignoring

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Vegard Nossum
On 29 Nov 2007 11:29:48 +0100, Andi Kleen <[EMAIL PROTECTED]> wrote: > Vegard Nossum <[EMAIL PROTECTED]> writes: > > > > - We properly flush TLB entries that change. This used to not be the case, > > and so we > > For low values of "properly" @) > > > + pte = lookup_address(addr); > > +

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Pekka J Enberg
Hi Vegard, On Thu, 29 Nov 2007, Vegard Nossum wrote: > If I understand you correctly, you only want to be notified if any > memory within an allocation is used before any memory within the > allocation has been initialized. I think that this would be quite > useless compared to tracking all the

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Andi Kleen
Vegard Nossum <[EMAIL PROTECTED]> writes: > > - We properly flush TLB entries that change. This used to not be the case, > and so we For low values of "properly" @) > + pte = lookup_address(addr); > + change_page_attr(page, 1, __pgprot(pte->pte_low | _PAGE_VISIBLE)); > +

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Vegard Nossum
On Nov 29, 2007 10:39 AM, Pekka J Enberg <[EMAIL PROTECTED]> wrote: > Hi, > > On Nov 29, 2007 9:02 AM, Pekka Enberg <[EMAIL PROTECTED]> wrote: > > > Is it really necessary to track every memory address? Tracking slab > > > objects would require far less memory. You might also want to make > > >

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Pekka J Enberg
Hi, On Nov 29, 2007 9:02 AM, Pekka Enberg <[EMAIL PROTECTED]> wrote: > > Is it really necessary to track every memory address? Tracking slab > > objects would require far less memory. You might also want to make > > kzalloc() and GFP_ZERO mark the memory area as initialized to avoid > > some page

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Vegard Nossum
Hi, On Nov 29, 2007 9:02 AM, Pekka Enberg <[EMAIL PROTECTED]> wrote: > Hi Vegard, > > On Nov 27, 2007 5:16 PM, Vegard Nossum <[EMAIL PROTECTED]> wrote: > > +config KMEMCHECK > > + bool "Trap use of uninitialized memory" > > + depends on X86_32 && !CC_OPTIMIZE_FOR_SIZE > > + help

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Pekka Enberg
Hi Vegard, On Nov 27, 2007 5:16 PM, Vegard Nossum <[EMAIL PROTECTED]> wrote: > +config KMEMCHECK > + bool "Trap use of uninitialized memory" > + depends on X86_32 && !CC_OPTIMIZE_FOR_SIZE > + help > + This option enables tracing of dynamically allocated kernel memory > +

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Vegard Nossum
Hi, On Nov 29, 2007 9:02 AM, Pekka Enberg [EMAIL PROTECTED] wrote: Hi Vegard, On Nov 27, 2007 5:16 PM, Vegard Nossum [EMAIL PROTECTED] wrote: +config KMEMCHECK + bool Trap use of uninitialized memory + depends on X86_32 !CC_OPTIMIZE_FOR_SIZE + help + This

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Pekka J Enberg
Hi, On Nov 29, 2007 9:02 AM, Pekka Enberg [EMAIL PROTECTED] wrote: Is it really necessary to track every memory address? Tracking slab objects would require far less memory. You might also want to make kzalloc() and GFP_ZERO mark the memory area as initialized to avoid some page faults.

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Vegard Nossum
On Nov 29, 2007 10:39 AM, Pekka J Enberg [EMAIL PROTECTED] wrote: Hi, On Nov 29, 2007 9:02 AM, Pekka Enberg [EMAIL PROTECTED] wrote: Is it really necessary to track every memory address? Tracking slab objects would require far less memory. You might also want to make kzalloc() and

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Andi Kleen
Vegard Nossum [EMAIL PROTECTED] writes: - We properly flush TLB entries that change. This used to not be the case, and so we For low values of properly @) + pte = lookup_address(addr); + change_page_attr(page, 1, __pgprot(pte-pte_low | _PAGE_VISIBLE)); +

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Pekka J Enberg
Hi Vegard, On Thu, 29 Nov 2007, Vegard Nossum wrote: If I understand you correctly, you only want to be notified if any memory within an allocation is used before any memory within the allocation has been initialized. I think that this would be quite useless compared to tracking all the bytes

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Vegard Nossum
On 29 Nov 2007 11:29:48 +0100, Andi Kleen [EMAIL PROTECTED] wrote: Vegard Nossum [EMAIL PROTECTED] writes: - We properly flush TLB entries that change. This used to not be the case, and so we For low values of properly @) + pte = lookup_address(addr); +

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Andi Kleen
We don't need to flush all CPUs. This is my rationale: The debug exception (single-step trap) will always happen on the same CPU that the page fault occurred on. Page fault shows the page, debug exception hides the page again. Between those two operations, nothing else can You're ignoring

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-29 Thread Pekka Enberg
Hi Vegard, On Nov 27, 2007 5:16 PM, Vegard Nossum [EMAIL PROTECTED] wrote: +config KMEMCHECK + bool Trap use of uninitialized memory + depends on X86_32 !CC_OPTIMIZE_FOR_SIZE + help + This option enables tracing of dynamically allocated kernel memory + to

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-28 Thread Richard Knutsson
Vegard Nossum wrote: Hi, On Nov 28, 2007 7:51 AM, Richard Knutsson <[EMAIL PROTECTED]> wrote: Vegard Nossum wrote: +static int Not 'static bool'? +page_is_tracked(struct page *page) Why not returning 'false' and 'true'? Sorry, I am not used to using bool

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-28 Thread Vegard Nossum
Hi, On Nov 28, 2007 7:51 AM, Richard Knutsson <[EMAIL PROTECTED]> wrote: > Vegard Nossum wrote: > > +static int > Not 'static bool'? > > +page_is_tracked(struct page *page) > Why not returning 'false' and 'true'? Sorry, I am not used to using bool in C :-) I will change this if bool is preferred

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-28 Thread Vegard Nossum
Hi, On Nov 28, 2007 7:51 AM, Richard Knutsson [EMAIL PROTECTED] wrote: Vegard Nossum wrote: +static int Not 'static bool'? +page_is_tracked(struct page *page) Why not returning 'false' and 'true'? Sorry, I am not used to using bool in C :-) I will change this if bool is preferred in

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-28 Thread Richard Knutsson
Vegard Nossum wrote: Hi, On Nov 28, 2007 7:51 AM, Richard Knutsson [EMAIL PROTECTED] wrote: Vegard Nossum wrote: +static int Not 'static bool'? +page_is_tracked(struct page *page) Why not returning 'false' and 'true'? Sorry, I am not used to using bool in

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-27 Thread Richard Knutsson
Vegard Nossum wrote: General description: kmemcheck will trap every read and write to memory that was allocated dynamically (ie. with kmalloc()). If a memory address is read that has not previously been written to, a message is printed to the kernel log. diff --git

[RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-27 Thread Vegard Nossum
General description: kmemcheck will trap every read and write to memory that was allocated dynamically (ie. with kmalloc()). If a memory address is read that has not previously been written to, a message is printed to the kernel log. Changes since v1: - We properly flush TLB entries that

[RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-27 Thread Vegard Nossum
General description: kmemcheck will trap every read and write to memory that was allocated dynamically (ie. with kmalloc()). If a memory address is read that has not previously been written to, a message is printed to the kernel log. Changes since v1: - We properly flush TLB entries that

Re: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-27 Thread Richard Knutsson
Vegard Nossum wrote: General description: kmemcheck will trap every read and write to memory that was allocated dynamically (ie. with kmalloc()). If a memory address is read that has not previously been written to, a message is printed to the kernel log. snip diff --git