lkml.org 
[lkml]   [2004]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH] oprofile per-cpu buffer overrun
    Hi Andrew,

    In a ring buffer controlled by a read and write positions we
    can't use buffer_size but only buffer_size - 1 entry, the last
    free entry act as a guard to avoid write pos overrun. This bug
    was hidden because the writer, oprofile_add_sample(), request
    one more entry than really needed.

    regards,
    Phil

    Index: drivers/oprofile/cpu_buffer.c
    ===================================================================
    RCS file: /usr/local/cvsroot/linux-2.5/drivers/oprofile/cpu_buffer.c,v
    retrieving revision 1.9
    diff -u -p -r1.9 cpu_buffer.c
    --- drivers/oprofile/cpu_buffer.c 26 May 2003 04:42:54 -0000 1.9
    +++ drivers/oprofile/cpu_buffer.c 24 Jan 2004 21:07:03 -0000
    @@ -86,9 +86,9 @@ static unsigned long nr_available_slots(
    unsigned long tail = b->tail_pos;

    if (tail > head)
    - return tail - head;
    + return (tail - head) - 1;

    - return tail + (b->buffer_size - head);
    + return tail + (b->buffer_size - head) - 1;
    }


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2005-03-22 14:00    [W:0.021 / U:0.448 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site