From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756731AbbGGJ6g (ORCPT ); Tue, 7 Jul 2015 05:58:36 -0400 Received: from terminus.zytor.com ([198.137.202.10]:59358 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755502AbbGGJ60 (ORCPT ); Tue, 7 Jul 2015 05:58:26 -0400 Date: Tue, 7 Jul 2015 02:57:55 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, yanmin_zhang@linux.intel.com, bp@suse.de, jin.xiao@intel.com, peterz@infradead.org, jroedel@suse.de, mingo@kernel.org Reply-To: jin.xiao@intel.com, bp@suse.de, hpa@zytor.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, yanmin_zhang@linux.intel.com, mingo@kernel.org, peterz@infradead.org, jroedel@suse.de In-Reply-To: <20150705171102.236544164@linutronix.de> References: <20150705171102.236544164@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/irq: Use proper locking in check_irq_vectors_for_cpu_disable() Git-Commit-ID: cbb24dc761d95fe39a7a122bb1b298e9604cae15 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: cbb24dc761d95fe39a7a122bb1b298e9604cae15 Gitweb: http://git.kernel.org/tip/cbb24dc761d95fe39a7a122bb1b298e9604cae15 Author: Thomas Gleixner AuthorDate: Sun, 5 Jul 2015 17:12:33 +0000 Committer: Thomas Gleixner CommitDate: Tue, 7 Jul 2015 11:54:04 +0200 x86/irq: Use proper locking in check_irq_vectors_for_cpu_disable() It's unsafe to examine fields in the irq descriptor w/o holding the descriptor lock. Add proper locking. While at it add a comment why the vector check can run lock less Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra Cc: xiao jin Cc: Joerg Roedel Cc: Borislav Petkov Cc: Yanmin Zhang Link: http://lkml.kernel.org/r/20150705171102.236544164@linutronix.de --- arch/x86/kernel/irq.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 88b36648..85ca76e 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -347,14 +347,22 @@ int check_irq_vectors_for_cpu_disable(void) if (!desc) continue; + /* + * Protect against concurrent action removal, + * affinity changes etc. + */ + raw_spin_lock(&desc->lock); data = irq_desc_get_irq_data(desc); cpumask_copy(&affinity_new, data->affinity); cpumask_clear_cpu(this_cpu, &affinity_new); /* Do not count inactive or per-cpu irqs. */ - if (!irq_has_action(irq) || irqd_is_per_cpu(data)) + if (!irq_has_action(irq) || irqd_is_per_cpu(data)) { + raw_spin_unlock(&desc->lock); continue; + } + raw_spin_unlock(&desc->lock); /* * A single irq may be mapped to multiple * cpu's vector_irq[] (for example IOAPIC cluster @@ -385,6 +393,9 @@ int check_irq_vectors_for_cpu_disable(void) * vector. If the vector is marked in the used vectors * bitmap or an irq is assigned to it, we don't count * it as available. + * + * As this is an inaccurate snapshot anyway, we can do + * this w/o holding vector_lock. */ for (vector = FIRST_EXTERNAL_VECTOR; vector < first_system_vector; vector++) {