• Sebastian Andrzej Siewior's avatar
    scsi: fcoe: Use per-CPU API to update per-CPU statistics · a912460e
    Sebastian Andrzej Siewior authored
    The per-CPU statistics (struct fc_stats) is updated by getting a stable
    per-CPU pointer via get_cpu() + per_cpu_ptr() and then performing the
    increment. This can be optimized by using this_cpu_*() which will do
    whatever is needed on the architecture to perform the update safe and
    efficient.  The read out of the individual value (fc_get_host_stats())
    should be done by using READ_ONCE() instead of a plain-C access. The
    difference is that READ_ONCE() will always perform a single access while
    the plain-C access can be split by the compiler into two loads if it
    appears beneficial.  The usage of u64 has the side-effect that it is also
    64bit wide on 32bit architectures and the read is always split into two
    loads. The can lead to strange values if the read happens during an update
    which alters both 32bit parts of the 64bit value. This can be circumvented
    by either using a 32bit variables on 32bit architecures or extending the
    statistics with a sequence counter.
    
    Use this_cpu_*() API to update the statistics and READ_ONCE() to read it.
    
    Link: https://lore.kernel.org/r/20220506105758.283887-3-bigeasy@linutronix.deReviewed-by: default avatarDavidlohr Bueso <dave@stgolabs.net>
    Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    a912460e
bnx2fc_fcoe.c 76.3 KB