lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 12 Jan 2009 20:46:45 +0900 (JST)
From:	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
To:	"Andrew Morton" <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Hiroshi Shimamoto <h-shimamoto@...jp.nec.com>,
	Ingo Molnar <mingo@...e.hu>,
	Eric Dumazet <dada1@...mosbay.com>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Keika Kobayashi <kobayashi.kk@...s.nec.co.jp>
Cc:	kosaki.motohiro@...fujitsu.com, kobayashi.kk@...s.nec.co.jp
Subject: Re: [PATCH 2/3 v2] proc: Export statistics for softirq to /proc

> >>> 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@...fujitsu.com>
Cc: Keika Kobayashi <kobayashi.kk@...s.nec.co.jp>
Cc: Hiroshi Shimamoto <h-shimamoto@...jp.nec.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Eric Dumazet <dada1@...mosbay.com>
Cc: Alexey Dobriyan <adobriyan@...il.com>
Cc: Andrew Morton <akpm@...ux-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");
 



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ