From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Dobriyan Subject: Re: [PATCH] proc: only export statistics of softirqs for online cpus Date: Sat, 12 Jan 2019 02:03:43 +0300 Message-ID: <20190111230343.GA20267@avx2> References: <1547119441-28314-1-git-send-email-tan.hu@zte.com.cn> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: zhong.weidong@zte.com.cn, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Tan Hu Return-path: Content-Disposition: inline In-Reply-To: <1547119441-28314-1-git-send-email-tan.hu@zte.com.cn> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thu, Jan 10, 2019 at 07:24:01PM +0800, Tan Hu wrote: > @@ -12,13 +12,13 @@ static int show_softirqs(struct seq_file *p, void *v) > int i, j; > > seq_puts(p, " "); > - for_each_possible_cpu(i) > + for_each_online_cpu(i) > seq_printf(p, "CPU%-8d", i); > seq_putc(p, '\n'); > > for (i = 0; i < NR_SOFTIRQS; i++) { > seq_printf(p, "%12s:", softirq_to_name[i]); > - for_each_possible_cpu(j) > + for_each_online_cpu(j) > seq_printf(p, " %10u", kstat_softirqs_cpu(i, j)); > seq_putc(p, '\n'); > } This should break userspace: https://sources.debian.org/src/netsniff-ng/0.6.5-1/ifpps.c/#L330 This code gets the number of "possible" CPUs from sysconf(3) and doesn't parse header to find out which CPUs are online.