Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3657170imu; Mon, 7 Jan 2019 07:14:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/USht/+n1EZgyH4KpJmDHa1ahAwtKIevdfM/rE95BqLolnUKIYUCxl8+X8rBaI6/YjRp5uO X-Received: by 2002:a62:7dcb:: with SMTP id y194mr63962634pfc.113.1546874085851; Mon, 07 Jan 2019 07:14:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546874085; cv=none; d=google.com; s=arc-20160816; b=zsp4RNOdKYgquoIVkllULmpwX20yfpSWJ2ynJhCVZ48PH7IZkhR05kw231M0vROX1g sqDqvgb+K9aYYGissb+FJzONmS4893EA8+uu5rkXAU9GljDybxv7KVUnWpRU2JyiX3jH KZJ3qXRYPg8gvXg8jLrHKcYuCOJ21iX+ZANJeUl/WEkRrL85wyW0GXwdH5/qUvc3bkEu b6sNCL/qMZevk5Dd+wbdPX+ymkmQPNAg4079RXuDV/jjTnidyjcyaCiETIT3+Keru+x8 h3IhlASPyADmijwJEZe4G+wHBDmusO1skBkaoMsLhmxMydivPMNBjxtjk49XMYfkRXxl qQ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=uvgwivKil/H2inAMnaJIOt1wnNno+kKSPGuLoq5cGpc=; b=o4L4KtAUUZ+OjPxLgQDAE3qsCIkAAa4mocBe5oeABb/3xETJRp1Sqfx6yJDXBueVh2 etFqc7NhYf3miePgLvQctppG1saCY+32YGWDR8n7rGN8T8IXeqBmm/Y4Dh4x1mq2iB9C kC6QpzUGxCXYS1cGGQzUVV4oAjtQQwzklQ9YKkxryN23JQIknyfdAI3zjjvnj+FJozkT VIgmHM0OAMWowpLGSdJ1K+ru/L64G3yRwMNXhLwA8bvKgHrZCx7JtwOLm15o5qzy2qxy UKjE7Cp3NpNB46q0uSlWBT3rwSBEYN74Y5W4dxNTCjuh57cf7lMWaTN5eOvwIyZPJ9Iz IkwA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i190si35059343pfc.116.2019.01.07.07.14.28; Mon, 07 Jan 2019 07:14:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729536AbfAGPNP (ORCPT + 99 others); Mon, 7 Jan 2019 10:13:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55042 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726918AbfAGPNN (ORCPT ); Mon, 7 Jan 2019 10:13:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7E4289ADB; Mon, 7 Jan 2019 15:13:12 +0000 (UTC) Received: from llong.com (dhcp-17-223.bos.redhat.com [10.18.17.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3941E65F71; Mon, 7 Jan 2019 15:13:11 +0000 (UTC) From: Waiman Long To: Andrew Morton , Alexey Dobriyan , Luis Chamberlain , Kees Cook , Jonathan Corbet Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, Davidlohr Bueso , Miklos Szeredi , Daniel Colascione , Dave Chinner , Randy Dunlap , Waiman Long Subject: [PATCH 1/2] /proc/stat: Extract irqs counting code into show_stat_irqs() Date: Mon, 7 Jan 2019 10:12:57 -0500 Message-Id: <1546873978-27797-2-git-send-email-longman@redhat.com> In-Reply-To: <1546873978-27797-1-git-send-email-longman@redhat.com> References: <1546873978-27797-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Jan 2019 15:13:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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