Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp796855imm; Fri, 22 Jun 2018 05:32:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImEZwphr13GLYoAQboRMCA9TB4oa9D7oVOlZ5s+sgfggFJmPbM2VxmKFmXbatVEvUAPsOF X-Received: by 2002:a62:9385:: with SMTP id r5-v6mr1549356pfk.59.1529670771177; Fri, 22 Jun 2018 05:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529670771; cv=none; d=google.com; s=arc-20160816; b=LnnYlLco1gC6PJmPAb2vDRLwQjFaPiBpKoM01Do2B4v5g97EAvPQQvHHdaKRpI1le6 b9zDVioI9nDZG06NKngs5UiUy9ZYNVpCrRuHIBtlZOWBL5aJ3WS8ZT61gzR9ZT89WdIs 4ELHFJhhzIhnPez9t9bk8ep4cOYWxOZ1RTAkKYtBIrPJ8yFsJyTcEuVhjgK86WvrZWbk TEMK5De98PYiszvrvGmetCdMth0Bs2xXi+xSyI4YOYH3nGMXn8dEdp9/LQ4o5Gmfjgdn K2gl2Dxx1Y7ldhWE8ilYHoZV0Vh46eS1PPKrkIQv6u5d03/ZV++1WFA1N8sJpNEpXgWe sN5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=90YX0kqalqnhAOirfc2omJ8XT8LFmf7L/+6SQcwwG8Q=; b=l5l4f+8+4vBu6TpmmF4vZY4Px/Ocon36BCSEMwWntKwqcta6YWHJ+742cWar7NsruY gHVOwG2bzLKsR+suPJb6zXjdarZtvC0v8hDi8iQ73T3NTn2tUI64hkV9Y8q0C8rRGvsJ Bn1/OPR2hyYz+7FO/xEl75lV4flRQrm2QztAOePbgo8WInr1W8eMH3mR91A0XW8J4d3F pge/aMZF0J4XMU5Ta63hqVVadHX1c9VYkhOhtOwdfZaL5WRxP6taP6AuTo6+C44MW5LQ nbIZCVbItnzI+I/0rg+Z1dgm0cO0pTUdXHbpGPKruqd38K/1CTm8NRv2zgAjO1KSijqX UgMw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si2016822pla.475.2018.06.22.05.32.35; Fri, 22 Jun 2018 05:32:51 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751782AbeFVMa4 (ORCPT + 99 others); Fri, 22 Jun 2018 08:30:56 -0400 Received: from terminus.zytor.com ([198.137.202.136]:51971 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbeFVMay (ORCPT ); Fri, 22 Jun 2018 08:30:54 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5MCUldJ067521 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Jun 2018 05:30:47 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5MCUlEA067518; Fri, 22 Jun 2018 05:30:47 -0700 Date: Fri, 22 Jun 2018 05:30:47 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Eric Dumazet Message-ID: Cc: mingo@kernel.org, edumazet@google.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, eric.dumazet@gmail.com, hpa@zytor.com Reply-To: edumazet@google.com, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, eric.dumazet@gmail.com In-Reply-To: <20180620150332.163320-1-edumazet@google.com> References: <20180620150332.163320-1-edumazet@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq: Speedup show_interrupts() Git-Commit-ID: 74bdf7815dfb3805a37b0bba615814063a227bf5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 74bdf7815dfb3805a37b0bba615814063a227bf5 Gitweb: https://git.kernel.org/tip/74bdf7815dfb3805a37b0bba615814063a227bf5 Author: Eric Dumazet AuthorDate: Wed, 20 Jun 2018 08:03:32 -0700 Committer: Thomas Gleixner CommitDate: Fri, 22 Jun 2018 14:22:58 +0200 genirq: Speedup show_interrupts() Since commit 425a5072dcd1 ("genirq: Free irq_desc with rcu"), show_interrupts() can be switched to rcu locking, which removes possible contention on sparse_irq_lock. The per_cpu count scan and print can be done without holding desc spinlock. And there is no need to call kstat_irqs_cpu() and abuse irq_to_desc() while holding rcu read lock, since desc and desc->kstat_irqs wont disappear or change. Signed-off-by: Eric Dumazet Signed-off-by: Thomas Gleixner Cc: Eric Dumazet Link: https://lkml.kernel.org/r/20180620150332.163320-1-edumazet@google.com --- kernel/irq/proc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 37eda10f5c36..da9addb8d655 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -475,22 +475,24 @@ int show_interrupts(struct seq_file *p, void *v) seq_putc(p, '\n'); } - irq_lock_sparse(); + rcu_read_lock(); desc = irq_to_desc(i); if (!desc) goto outsparse; - raw_spin_lock_irqsave(&desc->lock, flags); - for_each_online_cpu(j) - any_count |= kstat_irqs_cpu(i, j); - action = desc->action; - if ((!action || irq_desc_is_chained(desc)) && !any_count) - goto out; + if (desc->kstat_irqs) + for_each_online_cpu(j) + any_count |= *per_cpu_ptr(desc->kstat_irqs, j); + + if ((!desc->action || irq_desc_is_chained(desc)) && !any_count) + goto outsparse; seq_printf(p, "%*d: ", prec, i); for_each_online_cpu(j) - seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); + seq_printf(p, "%10u ", desc->kstat_irqs ? + *per_cpu_ptr(desc->kstat_irqs, j) : 0); + raw_spin_lock_irqsave(&desc->lock, flags); if (desc->irq_data.chip) { if (desc->irq_data.chip->irq_print_chip) desc->irq_data.chip->irq_print_chip(&desc->irq_data, p); @@ -511,6 +513,7 @@ int show_interrupts(struct seq_file *p, void *v) if (desc->name) seq_printf(p, "-%-8s", desc->name); + action = desc->action; if (action) { seq_printf(p, " %s", action->name); while ((action = action->next) != NULL) @@ -518,10 +521,9 @@ int show_interrupts(struct seq_file *p, void *v) } seq_putc(p, '\n'); -out: raw_spin_unlock_irqrestore(&desc->lock, flags); outsparse: - irq_unlock_sparse(); + rcu_read_unlock(); return 0; } #endif