• Petr Mladek's avatar
    printk: ringbuffer: Improve prb_next_seq() performance · f244b4dc
    Petr Mladek authored
    
    
    prb_next_seq() always iterates from the first known sequence number.
    In the worst case, it might loop 8k times for 256kB buffer,
    15k times for 512kB buffer, and 64k times for 2MB buffer.
    
    It was reported that polling and reading using syslog interface
    might occupy 50% of CPU.
    
    Speedup the search by storing @id of the last finalized descriptor.
    
    The loop is still needed because the @id is stored and read in the best
    effort way. An atomic variable is used to keep the @id consistent.
    But the stores and reads are not serialized against each other.
    The descriptor could get reused in the meantime. The related sequence
    number will be used only when it is still valid.
    
    An invalid value should be read _only_ when there is a flood of messages
    and the ringbuffer is rapidly reused. The performance is the least
    problem in this case.
    Reported-by: default avatarChunlei Wang <chunlei.wang@mediatek.com>
    Signed-off-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
    Reviewed-by: John Ogness <...
    f244b4dc
printk_ringbuffer.c 67.3 KB