lkml.org 
[lkml]   [2019]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation
    On (06/25/19 14:03), John Ogness wrote:
    [..]
    > > CPU0 CPU1
    > > printk(...)
    > > sz = vscprintf(NULL, "Comm %s\n", current->comm);
    > > ia64_mca_modify_comm()
    > > snprintf(comm, sizeof(comm), "%s %d", current->comm, previous_current->pid);
    > > memcpy(current->comm, comm, sizeof(current->comm));
    > > if ((buf = prb_reserve(... sz))) {
    > > vscnprintf(buf, "Comm %s\n", current->comm);
    > > ^^^^^^^^^^^^^^ ->comm has changed.
    > > Nothing critical, we
    > > should not corrupt
    > > anything, but we will
    > > truncate ->comm if its
    > > new size is larger than
    > > what it used to be when
    > > we did vscprintf(NULL).
    > > prb_commit(...);
    > > }

    [..]
    > In my v1 rfc series, I avoided this issue by having a separate dedicated
    > ringbuffer (rb_sprintf) that was used to allocate a temporary max-size
    > (2KB) buffer for sprinting to. Then _that_ was used for the real
    > ringbuffer input (strlen, prb_reserve, memcpy, prb_commit). That would
    > still be the approach of my choice.

    In other words per-CPU buffering, AKA printk_safe ;)

    -ss

    \
     
     \ /
      Last update: 2019-06-26 04:09    [W:3.505 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site