All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@zytor.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] sparseirq: Increase nr_irqs if needed
Date: Tue, 23 Nov 2010 01:21:01 -0800	[thread overview]
Message-ID: <4CEB877D.9060709@kernel.org> (raw)


only do that when we need more.

For x86_64 system:
when we have 128 cpus with 5 ioapics, will have nr_irqs = 3064
	120 + 8 * 128 + 120 * 16
systems could take 20 pcie,  when intel 10g are used with
sriov and ixgbevf, every vf will need 3 irqs, and one device
have 64 vf. so will need 20 * 3 * 64 = 3840.
some 6 ports Intel 10gb may need more.

with this patch, nr_irqs will increase 25% every time if nr_irqs is not
big enough.

Also later We could change nr_irqs initial value to
	 min(nr_irqs_gsi, 224*nr_cpu_ids).
for x86.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 kernel/irq/irqdesc.c |   29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/irq/irqdesc.c
===================================================================
--- linux-2.6.orig/kernel/irq/irqdesc.c
+++ linux-2.6/kernel/irq/irqdesc.c
@@ -301,6 +301,27 @@ void irq_free_descs(unsigned int from, u
 	mutex_unlock(&sparse_irq_lock);
 }
 
+static bool increase_nr_irqs(void)
+{
+#ifdef CONFIG_SPARSE_IRQ
+	int new;
+
+	if (nr_irqs == NR_IRQS)
+		return false;
+
+	new = nr_irqs;
+	new += nr_irqs >> 2;
+	if (new > NR_IRQS)
+		new = NR_IRQS;
+	if (new > nr_irqs) {
+		nr_irqs = new;
+		printk(KERN_INFO "nr_irqs increase to %d\n", nr_irqs);
+		return true;
+	}
+#endif
+	return false;
+}
+
 /**
  * irq_alloc_descs - allocate and initialize a range of irq descriptors
  * @irq:	Allocate for specific irq number if irq >= 0
@@ -320,14 +341,16 @@ irq_alloc_descs(int irq, unsigned int fr
 
 	mutex_lock(&sparse_irq_lock);
 
-	start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
+	start = bitmap_find_next_zero_area(allocated_irqs, NR_IRQS, from, cnt, 0);
 	ret = -EEXIST;
 	if (irq >=0 && start != irq)
 		goto err;
 
 	ret = -ENOMEM;
-	if (start >= nr_irqs)
-		goto err;
+	while ((start + cnt) >= nr_irqs) {
+		if (!increase_nr_irqs())
+			goto err;
+	}
 
 	bitmap_set(allocated_irqs, start, cnt);
 	mutex_unlock(&sparse_irq_lock);

             reply	other threads:[~2010-11-23  9:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23  9:21 Yinghai Lu [this message]
     [not found] ` <4CF75626.6000306@kernel.org>
     [not found]   ` <alpine.LFD.2.00.1012021019060.2653@localhost6.localdomain6>
     [not found]     ` <4CF7FA58.8070803@kernel.org>
     [not found]       ` <alpine.LFD.2.00.1012022112400.2653@localhost6.localdomain6>
     [not found]         ` <4CF7FF66.3010802@kernel.org>
     [not found]           ` <alpine.LFD.2.00.1012022125401.2653@localhost6.localdomain6>
     [not found]             ` <20101222125711.GI10809@elte.hu>
2010-12-28  0:54               ` [PATCH] x86, sparseirq: let nr_irqs equal to NR_IRQS Yinghai Lu
2010-12-28 17:42                 ` Konrad Rzeszutek Wilk
2010-12-28 21:24                   ` Yinghai Lu

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=4CEB877D.9060709@kernel.org \
    --to=yinghai@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.