From: Kees Cook <keescook@chromium.org>
To: Waiman Long <longman@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
LKML <linux-kernel@vger.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Miklos Szeredi <miklos@szeredi.hu>,
Daniel Colascione <dancol@google.com>,
Dave Chinner <david@fromorbit.com>,
Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH 1/2] /proc/stat: Extract irqs counting code into show_stat_irqs()
Date: Mon, 7 Jan 2019 13:42:07 -0800 [thread overview]
Message-ID: <CAGXu5jL_jMM4PaPcrptc-sFA2X0QZM=upr5hqHFXnSkhvqPHLA@mail.gmail.com> (raw)
In-Reply-To: <1546873978-27797-2-git-send-email-longman@redhat.com>
On Mon, Jan 7, 2019 at 7:13 AM Waiman Long <longman@redhat.com> 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 <longman@redhat.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
-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
next prev parent reply other threads:[~2019-01-07 21:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-07 15:12 [PATCH 0/2] /proc/stat: Reduce irqs counting performance overhead Waiman Long
2019-01-07 15:12 ` [PATCH 1/2] /proc/stat: Extract irqs counting code into show_stat_irqs() Waiman Long
2019-01-07 21:42 ` Kees Cook [this message]
2019-01-07 15:12 ` [PATCH 2/2] /proc/stat: Add sysctl parameter to control irq counts latency Waiman Long
2019-01-07 15:58 ` Matthew Wilcox
2019-01-07 16:07 ` Waiman Long
2019-01-07 16:14 ` Matthew Wilcox
2019-01-07 16:19 ` Waiman Long
2019-01-07 16:33 ` Alexey Dobriyan
2019-01-07 16:59 ` Waiman Long
[not found] ` <20190118084456.GA10690@shao2-debian>
2019-01-21 20:02 ` [LKP] [/proc/stat] 3047027b34: reaim.jobs_per_min -4.8% regression Kees Cook
2019-01-21 21:25 ` Alexey Dobriyan
2019-01-07 22:32 ` [PATCH 0/2] /proc/stat: Reduce irqs counting performance overhead Dave Chinner
2019-01-07 22:41 ` Daniel Colascione
2019-01-07 23:49 ` Alexey Dobriyan
2019-01-07 22:41 ` Waiman Long
2019-01-08 2:04 ` Dave Chinner
2019-01-08 16:11 ` Michal Hocko
2019-01-08 17:05 ` Waiman Long
2019-01-08 17:32 ` Waiman Long
2019-01-08 16:58 ` Waiman Long
2019-01-08 22:27 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGXu5jL_jMM4PaPcrptc-sFA2X0QZM=upr5hqHFXnSkhvqPHLA@mail.gmail.com' \
--to=keescook@chromium.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dancol@google.com \
--cc=dave@stgolabs.net \
--cc=david@fromorbit.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mcgrof@kernel.org \
--cc=miklos@szeredi.hu \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).