Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4845852imm; Tue, 19 Jun 2018 00:26:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLsi9eCJeZ9mFGltPtx56t1h5tkphFiECLRk2KnQ0SqjRwbqAiZvj+fDCg23l+M9TFpc30q X-Received: by 2002:a62:da59:: with SMTP id w25-v6mr16845666pfl.161.1529393183962; Tue, 19 Jun 2018 00:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529393183; cv=none; d=google.com; s=arc-20160816; b=mNK5pjWc1qbD9UGjXM8rjQleCPOW3rTWUYbm/eShT0zvnXNz6++Aha9OhX8mcOcZj/ xd2gzVZ0ysJOWIvzuJ8ZPBpdNYebw0okIjl+ag9UknklqC7Ns44ur/tGMwPJ+8uWY182 IJr2ApHs+N/DoMFGu7nLt/OShKPUHSRcforEkyX2/WKP8N0boM1qn6EMKRTs/MVQRqzr 9lYnqu863iZzKSBiBG4dsq8tUtdCTLy+GqKxkmuBTSE3ygU5CcN4LQssH8BSXsE/OfEu Jj1zMSWYZIkoYTEhbwGgVTHP3xrpQs6C6vdfq3TysYgfWxeQp6XXQt+dI9qrzC/USJnh qsSw== 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=kugTBI2qhpGPoAyK3gKzJ2hrZKKJxq3F385mSc5qHAw=; b=vW5FwCKN+QqOfY477qqE8BP2w/dWaEjGZmTrFTqJdLGgKl8GpjpLZOGam+w51eOQ80 Yz0OhOVDMq0J7KMtVA2yU6MSXPKrjEbOumx3tFmkvIO/ufAUsMPxUJYb+r5OWe+YUiUG YtACV2p2kdTASe3lq61HsHt9Pvz+1LZjqCMVeihFToqzRkgk+ipuGfSwdVZy+y+sIVeo JnwL3skpO7zrE74wXQjXwg0kQakp8PUwiEDPEs+5dzqFoUdw9WfkUdBJj6Zqwaa2/Avv 4y05wiLT1PnyY5ZJZZbe/m4vKw8OzPXyod4GTwIgu8iMCQUhPSMFNS53/EOXzQjs2GWO Wsvw== 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 e7-v6si13622737pgp.386.2018.06.19.00.26.09; Tue, 19 Jun 2018 00:26:23 -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 S964999AbeFSHZQ (ORCPT + 99 others); Tue, 19 Jun 2018 03:25:16 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36003 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755663AbeFSHZO (ORCPT ); Tue, 19 Jun 2018 03:25:14 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5J7P2iZ3005728 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jun 2018 00:25:02 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5J7P2563005725; Tue, 19 Jun 2018 00:25:02 -0700 Date: Tue, 19 Jun 2018 00:25:02 -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: jdorfman@google.com, hpa@zytor.com, edumazet@google.com, eric.dumazet@gmail.com, mingo@kernel.org, willemb@google.com, linux-kernel@vger.kernel.org, tglx@linutronix.de Reply-To: eric.dumazet@gmail.com, edumazet@google.com, hpa@zytor.com, jdorfman@google.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, willemb@google.com, mingo@kernel.org In-Reply-To: <20180618125612.155057-1-edumazet@google.com> References: <20180618125612.155057-1-edumazet@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq: Use rcu in kstat_irqs_usr() Git-Commit-ID: 4a5f4d2f891bcff7285b5f7490ed5a7a5d516049 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=-0.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FORGED_REPLYTO,T_DATE_IN_FUTURE_96_Q autolearn=no 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: 4a5f4d2f891bcff7285b5f7490ed5a7a5d516049 Gitweb: https://git.kernel.org/tip/4a5f4d2f891bcff7285b5f7490ed5a7a5d516049 Author: Eric Dumazet AuthorDate: Mon, 18 Jun 2018 05:56:12 -0700 Committer: Thomas Gleixner CommitDate: Tue, 19 Jun 2018 09:19:40 +0200 genirq: Use rcu in kstat_irqs_usr() Jeremy Dorfman identified mutex contention when multiple threads parse /proc/stat concurrently. Since commit 425a5072dcd1 ("genirq: Free irq_desc with rcu"), kstat_irqs_usr() can be switched to rcu locking, which removes this mutex contention. show_interrupts() case will be handled in a separate patch. Reported-by: Jeremy Dorfman Signed-off-by: Eric Dumazet Signed-off-by: Thomas Gleixner Cc: Eric Dumazet Cc: Willem de Bruijn Link: https://lkml.kernel.org/r/20180618125612.155057-1-edumazet@google.com --- kernel/irq/irqdesc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index afc7f902d74a..578d0e5f1b5b 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -443,6 +443,7 @@ static void free_desc(unsigned int irq) * We free the descriptor, masks and stat fields via RCU. That * allows demultiplex interrupts to do rcu based management of * the child interrupts. + * This also allows us to use rcu in kstat_irqs_usr(). */ call_rcu(&desc->rcu, delayed_free_desc); } @@ -928,17 +929,17 @@ unsigned int kstat_irqs(unsigned int irq) * kstat_irqs_usr - Get the statistics for an interrupt * @irq: The interrupt number * - * Returns the sum of interrupt counts on all cpus since boot for - * @irq. Contrary to kstat_irqs() this can be called from any - * preemptible context. It's protected against concurrent removal of - * an interrupt descriptor when sparse irqs are enabled. + * Returns the sum of interrupt counts on all cpus since boot for @irq. + * Contrary to kstat_irqs() this can be called from any context. + * It uses rcu since a concurrent removal of an interrupt descriptor is + * observing an rcu grace period before delayed_free_desc()/irq_kobj_release(). */ unsigned int kstat_irqs_usr(unsigned int irq) { unsigned int sum; - irq_lock_sparse(); + rcu_read_lock(); sum = kstat_irqs(irq); - irq_unlock_sparse(); + rcu_read_unlock(); return sum; }