From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: "Andrew Morton" <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>,
Ingo Molnar <mingo@elte.hu>, Eric Dumazet <dada1@cosmosbay.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Keika Kobayashi <kobayashi.kk@ncos.nec.co.jp>
Cc: kosaki.motohiro@jp.fujitsu.com, kobayashi.kk@ncos.nec.co.jp
Subject: Re: [PATCH 2/3 v2] proc: Export statistics for softirq to /proc
Date: Mon, 12 Jan 2009 20:46:45 +0900 (JST) [thread overview]
Message-ID: <20090112204059.27A8.KOSAKI.MOTOHIRO@jp.fujitsu.com> (raw)
In-Reply-To: <2f11576a0901101144y66c072e9w5da6bde9d000e907@mail.gmail.com>
> >>> You can calcurate per_irq_sum here.
> >>> Typically, # of possible cpu are very big.
> >>>
> >>> So, I don't like unnecessary twrice looping.
> >>
> >> I was about to send these patches to Linus, but it seems that this
> >> optmisation hasn't been addressed?
> >
> > Thanks for your notice, Andrew.
> > Of course, thanks for your advice, Kosaki-san.
> > I didn't check carefully about this point...
> >
> > Now I am on a business trip.
> > So, I'll post the fix next week.
>
> No problem.
> I've made it three hour ago. I'll post soon.
Done.
==
Subject: [PATCH] proc: remove redundunt for_each_possible_cpu() loop
Impact: cleanup
Almost distro set NR_CPUS very large number and at that time for_each_possible_cpu() is
a bit costly.
Therefore, To remove unnecessary twice loop is better.
Note. we can remove softirq's redundunt loop, but we can't remove irq's.
because NR_SOFTIRQS ~= 10, NR_IRQS ~= 4000 (in x86 case).
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Keika Kobayashi <kobayashi.kk@ncos.nec.co.jp>
Cc: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Eric Dumazet <dada1@cosmosbay.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
fs/proc/stat.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index f95d73a..cb839e8 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -27,6 +27,7 @@ static int show_stat(struct seq_file *p, void *v)
cputime64_t guest;
u64 sum = 0;
u64 sum_softirq = 0;
+ unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
struct timespec boottime;
unsigned int per_irq_sum;
@@ -51,8 +52,12 @@ static int show_stat(struct seq_file *p, void *v)
}
sum += arch_irq_stat_cpu(i);
- for (j = 0; j < NR_SOFTIRQS; j++)
- sum_softirq += kstat_softirqs_cpu(j, i);
+ for (j = 0; j < NR_SOFTIRQS; j++) {
+ unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
+
+ per_softirq_sums[j] += softirq_stat;
+ sum_softirq += softirq_stat;
+ }
}
sum += arch_irq_stat();
@@ -118,12 +123,7 @@ static int show_stat(struct seq_file *p, void *v)
seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
for (i = 0; i < NR_SOFTIRQS; i++) {
- per_irq_sum = 0;
-
- for_each_possible_cpu(j)
- per_irq_sum += kstat_softirqs_cpu(i, j);
-
- seq_printf(p, " %u", per_irq_sum);
+ seq_printf(p, " %u", per_softirq_sums[i]);
}
seq_printf(p, "\n");
next prev parent reply other threads:[~2009-01-12 11:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-22 4:22 [PATCH 0/3 v2] softirq: Statistics for softirq Keika Kobayashi
2008-11-22 4:25 ` [PATCH 1/3 v2] softirq: Introduce statistics " Keika Kobayashi
2008-11-22 5:36 ` KOSAKI Motohiro
2008-11-24 23:46 ` Keika Kobayashi
2008-11-26 10:14 ` KOSAKI Motohiro
2008-11-22 4:27 ` [PATCH 2/3 v2] proc: Export statistics for softirq to /proc Keika Kobayashi
2008-11-22 11:36 ` Eric Dumazet
2008-11-26 10:10 ` KOSAKI Motohiro
2009-01-09 22:16 ` Andrew Morton
2009-01-10 18:22 ` kobayashi.kk
2009-01-10 19:44 ` KOSAKI Motohiro
2009-01-12 11:46 ` KOSAKI Motohiro [this message]
2009-01-12 23:53 ` kobayashi.kk
2008-11-22 4:28 ` [PATCH 3/3 v2] proc: Update document for /proc/softirqs and /proc/stat Keika Kobayashi
2008-11-26 10:11 ` KOSAKI Motohiro
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=20090112204059.27A8.KOSAKI.MOTOHIRO@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dada1@cosmosbay.com \
--cc=h-shimamoto@ct.jp.nec.com \
--cc=kobayashi.kk@ncos.nec.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
all inboxes | Powered by JetHome®