mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dean Nelson <dcn@sgi.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Jack Steiner <steiner@sgi.com>,
	Alan Mayer <ajm@sgi.com>,
	jeremy@goop.org, rusty@rustcorp.com.au,
	suresh.b.siddha@intel.com, torvalds@linux-foundation.org,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Yinghai Lu <Yinghai.lu@amd.com>
Subject: [PATCH 3/3] switch non-standard SYSCALL_VECTOR allocation to use vector_irq v2
Date: Fri, 19 Sep 2008 15:08:00 -0500	[thread overview]
Message-ID: <20080919200800.GD6528@sgi.com> (raw)
In-Reply-To: <20080919200212.GA6528@sgi.com>

Replace the current use of used_vectors[] for the allocation of a non-standard
SYSCALL_VECTOR by also using the per_cpu variable vector_irq[].

Signed-off-by: Dean Nelson <dcn@sgi.com>

---

 arch/x86/kernel/traps_32.c            |   16 ++++++++++------
 drivers/lguest/interrupts_and_traps.c |   28 ++++++++++++++++++++++------
 include/asm-x86/irq.h                 |    3 ---
 3 files changed, 32 insertions(+), 15 deletions(-)

Index: linux/arch/x86/kernel/traps_32.c
===================================================================
--- linux.orig/arch/x86/kernel/traps_32.c	2008-09-19 11:01:10.000000000 -0500
+++ linux/arch/x86/kernel/traps_32.c	2008-09-19 12:35:32.000000000 -0500
@@ -63,9 +63,6 @@
 
 #include "mach_traps.h"
 
-DECLARE_BITMAP(used_vectors, NR_VECTORS);
-EXPORT_SYMBOL_GPL(used_vectors);
-
 asmlinkage int system_call(void);
 
 /* Do we ignore FPU interrupts ? */
@@ -1185,6 +1182,8 @@ asmlinkage void math_emulate(long arg)
 void __init trap_init(void)
 {
 	int i;
+	int ret;
+	unsigned long flags;
 
 #ifdef CONFIG_EISA
 	void __iomem *p = early_ioremap(0x0FFFD9, 4);
@@ -1232,10 +1231,15 @@ void __init trap_init(void)
 	set_system_gate(SYSCALL_VECTOR, &system_call);
 
 	/* Reserve all the builtin and the syscall vector: */
-	for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
-		set_bit(i, used_vectors);
+	spin_lock_irqsave(&vector_lock, flags);
+	for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++) {
+		ret = grab_irq_vector(NON_IRQ_DESC, i, &cpu_possible_map);
+		BUG_ON(ret != i);
+	}
 
-	set_bit(SYSCALL_VECTOR, used_vectors);
+	ret = grab_irq_vector(NON_IRQ_DESC, SYSCALL_VECTOR, &cpu_possible_map);
+	BUG_ON(ret != SYSCALL_VECTOR);
+	spin_unlock_irqrestore(&vector_lock, flags);
 
 	/*
 	 * Should be a barrier for any external CPU state:
Index: linux/include/asm-x86/irq.h
===================================================================
--- linux.orig/include/asm-x86/irq.h	2008-09-19 11:09:32.000000000 -0500
+++ linux/include/asm-x86/irq.h	2008-09-19 12:35:32.000000000 -0500
@@ -44,9 +44,6 @@ extern unsigned int do_IRQ(struct pt_reg
 extern void init_IRQ(void);
 extern void native_init_IRQ(void);
 
-/* Interrupt vector management */
-extern DECLARE_BITMAP(used_vectors, NR_VECTORS);
-
 struct irq_desc;
 extern int grab_irq_vector(struct irq_desc *desc, unsigned int vector,
 			   cpumask_t *new_domain_mask);
Index: linux/drivers/lguest/interrupts_and_traps.c
===================================================================
--- linux.orig/drivers/lguest/interrupts_and_traps.c	2008-09-19 11:01:10.000000000 -0500
+++ linux/drivers/lguest/interrupts_and_traps.c	2008-09-19 12:41:02.000000000 -0500
@@ -221,19 +221,35 @@ bool check_syscall_vector(struct lguest 
 
 int init_interrupts(void)
 {
+	unsigned long flags;
+	int ret;
+
 	/* If they want some strange system call vector, reserve it now */
-	if (syscall_vector != SYSCALL_VECTOR
-	    && test_and_set_bit(syscall_vector, used_vectors)) {
-		printk("lg: couldn't reserve syscall %u\n", syscall_vector);
-		return -EBUSY;
+	if (syscall_vector != SYSCALL_VECTOR) {
+		spin_lock_irqsave(&vector_lock, flags);
+		ret = grab_irq_vector(NON_IRQ_DESC, syscall_vector,
+				      &cpu_possible_map);
+		spin_unlock_irqrestore(&vector_lock, flags);
+		if (ret != syscall_vector) {
+			printk(KERN_WARNING "lg: couldn't reserve syscall %u\n",
+			       syscall_vector);
+			return ret;
+		}
 	}
 	return 0;
 }
 
 void free_interrupts(void)
 {
-	if (syscall_vector != SYSCALL_VECTOR)
-		clear_bit(syscall_vector, used_vectors);
+	int cpu;
+
+	if (syscall_vector != SYSCALL_VECTOR) {
+		for_each_possible_cpu(cpu) {
+			BUG_ON(per_cpu(vector_irq, cpu)[syscall_vector] !=
+			       NON_IRQ_DESC);
+			per_cpu(vector_irq, cpu)[syscall_vector] = NULL;
+		}
+	}
 }
 
 /*H:220 Now we've got the routines to deliver interrupts, delivering traps like

      parent reply	other threads:[~2008-09-19 20:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19 20:02 [PATCH 0/3] unify the allocation of irq vectors v2 Dean Nelson
2008-09-19 20:04 ` [PATCH 1/3] switch vector_irq[] from irq number to irq_desc pointer v2 Dean Nelson
2008-09-19 20:24   ` Mike Travis
2008-09-19 23:17     ` Dean Nelson
2008-09-22 11:05     ` Ingo Molnar
2008-09-22 15:12       ` Mike Travis
2008-09-22 15:44         ` Mike Travis
2008-09-19 20:40   ` Yinghai Lu
2008-09-19 23:26     ` Dean Nelson
2008-09-19 20:06 ` [PATCH 2/3] switch static system vector allocation to use vector_irq[] v2 Dean Nelson
2008-09-19 20:08 ` Dean Nelson [this message]

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=20080919200800.GD6528@sgi.com \
    --to=dcn@sgi.com \
    --cc=Yinghai.lu@amd.com \
    --cc=ajm@sgi.com \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --cc=steiner@sgi.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome