mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lu, Yinghai" <yinghai.lu@amd.com>
To: ebiederm@xmission.com
Cc: "Andi Kleen" <ak@muc.de>, "Muli Ben-Yehuda" <muli@il.ibm.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Andrew Morton" <akpm@osdl.org>, "Adrian Bunk" <bunk@stusta.de>
Subject: RE: [PATCH] x86_64 irq: reuse vector for set_xxx_irq_affinity in phys flat mode
Date: Mon, 23 Oct 2006 13:00:23 -0700	[thread overview]
Message-ID: <5986589C150B2F49A46483AC44C7BCA412D747@ssvlexmb2.amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

From: ebiederm@xmission.com [mailto:ebiederm@xmission.com] 

>Beyond that I have a few nits to pick with the patch.
>- We duplicate the code that claims a new vector which makes
>  maintenance a pain.
>- The comments are specific to phys_flat but the code is not.
>- The test for being able to use the old_vector in the new domain
>  should be: ...[old_vector] == vector || ...[old_vector] == -1

Please attached one. This one need to after your patch about irq.

YH


[-- Attachment #2: io_apic_reuse_vector.diff --]
[-- Type: application/octet-stream, Size: 2306 bytes --]

--- arch/x86_64/kernel/io_apic_eric.c	2006-10-23 11:56:36.000000000 -0700
+++ arch/x86_64/kernel/io_apic.c	2006-10-23 11:22:31.000000000 -0700
@@ -613,8 +613,9 @@
 	 * 0x80, because int 0x80 is hm, kind of importantish. ;)
 	 */
 	static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0;
-	int old_vector = -1;
-	int cpu;
+	int vector = -1, old_vector = -1;
+	cpumask_t domain, new_mask;
+	int cpu, new_cpu;
 
 	BUG_ON((unsigned)irq >= NR_IRQ_VECTORS);
 
@@ -628,12 +629,29 @@
 		if (!cpus_empty(*result))
 			return old_vector;
 
+		/* try to reuse vector */
+		for_each_cpu_mask(cpu, mask) {
+			int can_resue = 1;
+			domain = vector_allocation_domain(cpu);
+			cpus_and(new_mask, domain, cpu_online_map);
+			for_each_cpu_mask(new_cpu, new_mask) {
+				int old_irq;
+				old_irq = per_cpu(vector_irq, new_cpu)[old_vector];
+				if ( (old_irq != irq) && (old_irq != -1)) {
+					can_resue = 0;
+					break;
+				}
+			}
+
+			if(!can_resue) continue;
+
+			vector = old_vector;
+			goto found_one;	
+		}
 	}
 
 	for_each_cpu_mask(cpu, mask) {
-		cpumask_t domain, new_mask;
-		int new_cpu;
-		int vector, offset;
+		int offset;
 
 		domain = vector_allocation_domain(cpu);
 		cpus_and(new_mask, domain, cpu_online_map);
@@ -657,21 +675,27 @@
 		/* Found one! */
 		current_vector = vector;
 		current_offset = offset;
-		if (old_vector >= 0) {
-			cpumask_t old_mask;
-			int old_cpu;
-			cpus_and(old_mask, irq_domain[irq], cpu_online_map);
-			for_each_cpu_mask(old_cpu, old_mask)
-				per_cpu(vector_irq, old_cpu)[old_vector] = -1;
-		}
-		for_each_cpu_mask(new_cpu, new_mask)
-			per_cpu(vector_irq, new_cpu)[vector] = irq;
-		irq_vector[irq] = vector;
-		irq_domain[irq] = domain;
-		cpus_and(*result, domain, mask);
-		return vector;
+		
+		goto found_one;
 	}
+
 	return -ENOSPC;
+
+found_one:
+	if (old_vector >= 0) {
+		cpumask_t old_mask;
+		int old_cpu;
+		cpus_and(old_mask, irq_domain[irq], cpu_online_map);
+		for_each_cpu_mask(old_cpu, old_mask)
+			per_cpu(vector_irq, old_cpu)[old_vector] = -1;
+	}
+	for_each_cpu_mask(new_cpu, new_mask)
+		per_cpu(vector_irq, new_cpu)[vector] = irq;
+	irq_vector[irq] = vector;
+	irq_domain[irq] = domain;
+	cpus_and(*result, domain, mask);
+	return vector;
+
 }
 
 static int assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)

             reply	other threads:[~2006-10-23 21:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-23 20:00 Lu, Yinghai [this message]
2006-10-24  5:52 ` Oleg Verych
2006-10-24  6:03   ` yhlu
  -- strict thread matches above, loose matches on Subject: below --
2006-10-23 22:57 Lu, Yinghai
2006-10-23 21:07 Lu, Yinghai
2006-10-23  7:02 Yinghai Lu
2006-10-23  8:15 ` Muli Ben-Yehuda
2006-10-23 15:53   ` yhlu
2006-10-23 15:32 ` Eric W. Biederman
2006-10-23 20:45   ` Adrian Bunk
2006-10-23 21:29     ` Muli Ben-Yehuda
2006-10-23 17:34 ` Muli Ben-Yehuda

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=5986589C150B2F49A46483AC44C7BCA412D747@ssvlexmb2.amd.com \
    --to=yinghai.lu@amd.com \
    --cc=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=bunk@stusta.de \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muli@il.ibm.com \
    /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

all inboxes | Powered by JetHome®