lkml.org 
[lkml]   [2009]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: Warning from ring buffer code (Was: Re: linux-next: tip tree build warning)
    From
    Date
    On Mon, 2009-09-14 at 10:09 -0700, Christopher Li wrote:
    > On Mon, Sep 14, 2009 at 8:16 AM, Steven Rostedt <srostedt@redhat.com> wrote:
    > > static void func(int size_me) {
    > > char array[size_me];
    > >
    > > memcpy(array, "hello", size);
    > > };
    > >
    > > and sparse failed on it as well. Note, you need to have something call
    > > func, or sparse will ignore it.
    >
    > Gcc allows variable size. Sparse expects the size of an array is constant.
    > For the kernel using variable array size is consider bad. Because the kernel
    > has very limited stack size. (8K if I remember correctly). Using dynamic array
    > is very easy to overflow the stack without realizing it.
    >
    > It deserves a warning. I agree the warning message can use a better description
    > though.

    Good point!

    I've added Frederic to the Cc list, since he wrote the code.

    Frederic, how big can one of those events get. The ring buffer (and
    TRACE_EVENT) allow up to almost a page size, which is very hefty for the
    stack. This code needs to either be rewritten or we need to set a limit
    to the size of a profile entry.

    We could add:

    if (__entry_size > 256)
    return;

    Thoughts?

    -- Steve





    \
     
     \ /
      Last update: 2009-09-14 20:57    [W:0.037 / U:0.396 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site