lkml.org 
[lkml]   [2021]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 10/12] proc/stat: Use unsigned long for "intr" sum
    Date
    Now that all values that are collected into "sum" are unsigned long,
    make the sum itself unsigned int so that it overflows consistently
    with individual components and thus retains the monotonicity.

    Since seq_put_decimal_ull() is a function, we don't have to explicitly
    cast sum into unsigned long long. Integer promotion will take care of
    that (and the compiler will issue warnings if the types don't agree).

    Signed-off-by: Alexei Lozovsky <me@ilammy.net>
    ---
    fs/proc/stat.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/fs/proc/stat.c b/fs/proc/stat.c
    index d9d89d7a959c..3741d671ab0a 100644
    --- a/fs/proc/stat.c
    +++ b/fs/proc/stat.c
    @@ -110,7 +110,7 @@ static int show_stat(struct seq_file *p, void *v)
    int i, j;
    u64 user, nice, system, idle, iowait, irq, softirq, steal;
    u64 guest, guest_nice;
    - u64 sum = 0;
    + unsigned long sum = 0;
    u64 sum_softirq = 0;
    unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
    struct timespec64 boottime;
    @@ -192,7 +192,7 @@ static int show_stat(struct seq_file *p, void *v)
    seq_put_decimal_ull(p, " ", nsec_to_clock_t(guest_nice));
    seq_putc(p, '\n');
    }
    - seq_put_decimal_ull(p, "intr ", (unsigned long long)sum);
    + seq_put_decimal_ull(p, "intr ", sum);

    show_all_irqs(p);

    --
    2.25.1
    \
     
     \ /
      Last update: 2021-09-15 19:59    [W:4.150 / U:0.340 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site