Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4009530imu; Mon, 7 Jan 2019 13:44:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN7n0opvLSdUOxwn7y6qHTn9athaD217dXnpXRziC8WQ9NeMeNh5qtlEvpE5AwqCHx88nys7 X-Received: by 2002:a17:902:a40f:: with SMTP id p15mr64336409plq.286.1546897497595; Mon, 07 Jan 2019 13:44:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546897497; cv=none; d=google.com; s=arc-20160816; b=Z9aaz97X0k4wzIamPXkgpI5k4JgHhdc525Brf+/VeJDbnDr+pHtDwTwhWtLTmQem58 WV71JP41+2BgZUtwm8YRw7PP6UhFEhtu+svzoHcVzpwzTT+wxCyZ4AnMk9A9cFpF74mJ uohRvzFu6dJjznTVgZnD2yuFpJN4N2YwKRE/MMBJ+XBE4OYhKDHl7NmVxoiu0ArWm0dw rry/jRVWRZyGPzz4/I/cyJf/Jgtop2936yU4ObMiKQJe5LO7OcfWRwAB6I7/Sv5jFKOk kZ7cu/Veop9lzcoQRkpzbSibumeOvQF+wA+o5DO1oEtCEVbI++geqspbqpEvhphF9Qqk Wexw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hS2gSuvP5ACAtJN0YLQzxg50f6d7JdKFNF6Mv5pVdRc=; b=LQi3/Ji+b2fCi3sOrhJ3ISQp2M4ttPL1DuNF+tnxGAz6gjQIEIHVrYY/3KUBjpjygG LpzjBIrP/zodzTF+4suJrStuYJUB22f/e3Wz29JETloexK/uMFb+1OMgmTmuR1VgAtSK BQ4vgQHDGkdqlWAtFKfMRMJfoq5kYdvL2E9+gJNggaOCHgNzZDJNvpiC9u5G2jbgi2qP /IXmbVpCg0wHkWErwH6IhsPfGTsNCcabp0iLJzCd6DydLl9S1r++Xz0kR6kt8dcGWNbW RtS3cxIF1Ex/TVxknrafpHA0AxCJycN926U0Ci6paHhaBbqoGiqxKvKIcmacrt0Y8tnR B0LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BVEZhsTr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34si208966pld.381.2019.01.07.13.44.42; Mon, 07 Jan 2019 13:44:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BVEZhsTr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727419AbfAGVmZ (ORCPT + 99 others); Mon, 7 Jan 2019 16:42:25 -0500 Received: from mail-vk1-f195.google.com ([209.85.221.195]:40321 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727397AbfAGVmX (ORCPT ); Mon, 7 Jan 2019 16:42:23 -0500 Received: by mail-vk1-f195.google.com with SMTP id v70so429109vkv.7 for ; Mon, 07 Jan 2019 13:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hS2gSuvP5ACAtJN0YLQzxg50f6d7JdKFNF6Mv5pVdRc=; b=BVEZhsTr7Kv3or/6ZyOwbwq6pvKwoZolGI/lgCHlldXD0uEJ20RyOeDuJKjiuFzaug t6SZ4ZCKE5+eJUTUIRDouV+xN4nF1Wasg2TxN8bAtF3lHI738dcu+6soQ2/KZJr3Vt9y 3Ss/T6KKFbSm9bK0yoOMeLon/LFXYHKb2B+no= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hS2gSuvP5ACAtJN0YLQzxg50f6d7JdKFNF6Mv5pVdRc=; b=P1iH5bAB3NqiCZruuw4RS2DQJBrH2FVRjimB+eJN09w1dXNm6+wFlQ3Ksz8Djp16qR FOICvpKjUlTT5EL9wNAcIylzM6KwNniq025wOp+VuOT/GzK4dZlE70nOn+z/UgRN+js9 vD9yk8cDYvl0YFxQHwSpVyd7/yDVUZ5jSRGyVXdGccYSaqJahrH0LQ65GC0E+3TXNNnk G2eL4tD6mMneQllradoBzFtNDWX+c5I3uthIn15TTvsTQsuR6Un5lO5APdhzpjQkdunZ pR0KRYOy+BvG4OYqLh+SQYjvsdRzHj2JqHIlphHnlG6ZxRspUMgm5LplZwqu1XPIzrMW ujgw== X-Gm-Message-State: AJcUukfujADFh3G/CkVT2Y4MzC7ztA+MIlyoAdz50DN1nfPB5iosnBSq boAzZeqVFejGaM/Wmn2kcVrYCIZPhvA= X-Received: by 2002:a1f:bfd6:: with SMTP id p205mr24084467vkf.70.1546897342309; Mon, 07 Jan 2019 13:42:22 -0800 (PST) Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com. [209.85.221.177]) by smtp.gmail.com with ESMTPSA id 67sm19298412uas.1.2019.01.07.13.42.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 13:42:19 -0800 (PST) Received: by mail-vk1-f177.google.com with SMTP id n126so423877vke.12 for ; Mon, 07 Jan 2019 13:42:19 -0800 (PST) X-Received: by 2002:a1f:298e:: with SMTP id p136mr23091757vkp.40.1546897338734; Mon, 07 Jan 2019 13:42:18 -0800 (PST) MIME-Version: 1.0 References: <1546873978-27797-1-git-send-email-longman@redhat.com> <1546873978-27797-2-git-send-email-longman@redhat.com> In-Reply-To: <1546873978-27797-2-git-send-email-longman@redhat.com> From: Kees Cook Date: Mon, 7 Jan 2019 13:42:07 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] /proc/stat: Extract irqs counting code into show_stat_irqs() To: Waiman Long Cc: Andrew Morton , Alexey Dobriyan , Luis Chamberlain , Jonathan Corbet , LKML , "open list:DOCUMENTATION" , "linux-fsdevel@vger.kernel.org" , Davidlohr Bueso , Miklos Szeredi , Daniel Colascione , Dave Chinner , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 7, 2019 at 7:13 AM Waiman Long wrote: > > The code that generates the "intr" line of /proc/stat is now moved > from show_stat() into a new function - show_stat_irqs(). There is no > functional change. > > Signed-off-by: Waiman Long Reviewed-by: Kees Cook -Kees > --- > fs/proc/stat.c | 39 +++++++++++++++++++++++++++++---------- > 1 file changed, 29 insertions(+), 10 deletions(-) > > diff --git a/fs/proc/stat.c b/fs/proc/stat.c > index 535eda7..4b06f1b 100644 > --- a/fs/proc/stat.c > +++ b/fs/proc/stat.c > @@ -79,12 +79,38 @@ static u64 get_iowait_time(int cpu) > > #endif > > +static u64 compute_stat_irqs_sum(void) > +{ > + int i; > + u64 sum = 0; > + > + for_each_possible_cpu(i) { > + sum += kstat_cpu_irqs_sum(i); > + sum += arch_irq_stat_cpu(i); > + } > + sum += arch_irq_stat(); > + return sum; > +} > + > +/* > + * Print out the "intr" line of /proc/stat. > + */ > +static void show_stat_irqs(struct seq_file *p) > +{ > + int i; > + > + seq_put_decimal_ull(p, "intr ", compute_stat_irqs_sum()); > + for_each_irq_nr(i) > + seq_put_decimal_ull(p, " ", kstat_irqs_usr(i)); > + > + seq_putc(p, '\n'); > +} > + > 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; > u64 sum_softirq = 0; > unsigned int per_softirq_sums[NR_SOFTIRQS] = {0}; > struct timespec64 boottime; > @@ -105,8 +131,6 @@ static int show_stat(struct seq_file *p, void *v) > steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL]; > guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST]; > guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE]; > - sum += kstat_cpu_irqs_sum(i); > - sum += arch_irq_stat_cpu(i); > > for (j = 0; j < NR_SOFTIRQS; j++) { > unsigned int softirq_stat = kstat_softirqs_cpu(j, i); > @@ -115,7 +139,6 @@ static int show_stat(struct seq_file *p, void *v) > sum_softirq += softirq_stat; > } > } > - sum += arch_irq_stat(); > > seq_put_decimal_ull(p, "cpu ", nsec_to_clock_t(user)); > seq_put_decimal_ull(p, " ", nsec_to_clock_t(nice)); > @@ -154,14 +177,10 @@ 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); > - > - /* sum again ? it could be updated? */ > - for_each_irq_nr(j) > - seq_put_decimal_ull(p, " ", kstat_irqs_usr(j)); > + show_stat_irqs(p); > > seq_printf(p, > - "\nctxt %llu\n" > + "ctxt %llu\n" > "btime %llu\n" > "processes %lu\n" > "procs_running %lu\n" > -- > 1.8.3.1 > -- Kees Cook