LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Prarit Bhargava <prarit@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Prarit Bhargava <prarit@redhat.com>,
	Andi Kleen <ak@linux.intel.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Steven Rostedt (Red Hat)" <rostedt@goodmis.org>,
	"Elliott, Robert (Server Storage)" <Elliott@hp.com>
Subject: [PATCH 1/2 v2] x86, irq: get correct available vectors for cpu disable
Date: Thu, 15 May 2014 09:25:04 -0400
Message-ID: <1400160305-17774-2-git-send-email-prarit@redhat.com> (raw)
In-Reply-To: <1400160305-17774-1-git-send-email-prarit@redhat.com>

From: Yinghai Lu <yinghai@kernel.org>

check_irq_vectors_for_cpu_disable() may overestimate the number of
available vectors assigned to a cpu.  This can cause cpu remove to
erroneously fail.

commit da6139e49c7cb0f4251265cb5243b8d220adb48d,  x86: Add check for
number of available vectors before CPU down, introduces a check to see if
there are enough empty vectors in the system to replace a downed cpu's
vectors.  Code inspection shows that the range used in the check
(currently from FIRST_EXTERNAL_VECTOR to NR_VECTORS) is incorrect and
should be FIRST_EXTERNAL_VECTOR to first_system_vector.  The value of
first_system_vector is decremented when system vectors are assigned in
alloc_system_vector().

The check_irq_vectors_for_cpu_disable() check also does not take into
account the first 32 system vectors which are not managed in the per_cpu
vector_irq arrays, including IA32_SYSCALL_VECTOR (0x80) and the
IRQ_MOVE_CLEANUP_VECTOR (0x20).

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: "Elliott, Robert (Server Storage)" <Elliott@hp.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>

[v2]: fixed up typos
---
 arch/x86/kernel/irq.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 283a76a..276b02b 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -17,6 +17,7 @@
 #include <asm/idle.h>
 #include <asm/mce.h>
 #include <asm/hw_irq.h>
+#include <asm/desc.h>
 
 #define CREATE_TRACE_POINTS
 #include <asm/trace/irq_vectors.h>
@@ -334,8 +335,21 @@ int check_irq_vectors_for_cpu_disable(void)
 	for_each_online_cpu(cpu) {
 		if (cpu == this_cpu)
 			continue;
-		for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
-		     vector++) {
+
+		/*
+		 * assign_irq_vector() only scans per_cpu vectors from
+		 * FIRST_EXTERNAL_VECTOR to first_system_vector.
+		 * It also skips vectors that are set in used_vectors bitmask.
+		 * used_vectors could have bits set for
+		 *	IA32_SYSCALL_VECTOR (0x80)
+		 *	IRQ_MOVE_CLEANUP_VECTOR (0x20)
+		 * Don't count those as available vectors.
+		 */
+		for (vector = FIRST_EXTERNAL_VECTOR;
+		     vector < first_system_vector; vector++) {
+			if (test_bit(vector, used_vectors))
+				continue;
+
 			if (per_cpu(vector_irq, cpu)[vector] < 0)
 				count++;
 		}
-- 
1.7.9.3


  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 13:25 [PATCH 0/2 v2] x86, Fix irq exhaustion issues with cpu hotplug Prarit Bhargava
2014-05-15 13:25 ` Prarit Bhargava [this message]
2014-06-04 12:22   ` [tip:x86/urgent] x86: irq: Get correct available vectors for cpu disable tip-bot for Yinghai Lu
2014-05-15 13:25 ` [PATCH 2/2 v2] x86, make check_irq_vectors_for_cpu_disable() aware of numa node irqs Prarit Bhargava
2014-06-04 12:43   ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400160305-17774-2-git-send-email-prarit@redhat.com \
    --to=prarit@redhat.com \
    --cc=Elliott@hp.com \
    --cc=ak@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git