From: Shanker Donthineni <sdonthineni@nvidia.com>
To: Thomas Gleixner <tglx@linutronix.de>, Marc Zyngier <maz@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Michael Walle <michael@walle.cc>,
Shanker Donthineni <sdonthineni@nvidia.com>,
<linux-kernel@vger.kernel.org>, Vikram Sethi <vsethi@nvidia.com>,
"Jason Sequeira" <jsequeira@nvidia.com>
Subject: [PATCH v5 2/3] genirq: Encapsulate sparse bitmap handling
Date: Fri, 19 May 2023 08:49:01 -0500 [thread overview]
Message-ID: <20230519134902.1495562-3-sdonthineni@nvidia.com> (raw)
In-Reply-To: <20230519134902.1495562-1-sdonthineni@nvidia.com>
Move the open coded sparse bitmap handling into helper functions as
a preparatory step for converting the sparse interrupt management
to a maple tree.
No functional change.
Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
---
kernel/irq/internals.h | 4 ++--
kernel/irq/irqdesc.c | 30 ++++++++++++++++++++----------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 51fc8c497c22..f3f2090dd2de 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -12,9 +12,9 @@
#include <linux/sched/clock.h>
#ifdef CONFIG_SPARSE_IRQ
-# define IRQ_BITMAP_BITS (NR_IRQS + 8196)
+# define MAX_SPARSE_IRQS (NR_IRQS + 8196)
#else
-# define IRQ_BITMAP_BITS NR_IRQS
+# define MAX_SPARSE_IRQS NR_IRQS
#endif
#define istate core_internal_state__do_not_mess_with_it
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index b401b89b226a..e0d9dd9b36f9 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -131,7 +131,18 @@ int nr_irqs = NR_IRQS;
EXPORT_SYMBOL_GPL(nr_irqs);
static DEFINE_MUTEX(sparse_irq_lock);
-static DECLARE_BITMAP(allocated_irqs, IRQ_BITMAP_BITS);
+static DECLARE_BITMAP(allocated_irqs, MAX_SPARSE_IRQS);
+
+static int irq_find_free_area(unsigned int from, unsigned int cnt)
+{
+ return bitmap_find_next_zero_area(allocated_irqs, MAX_SPARSE_IRQS,
+ from, cnt, 0);
+}
+
+static unsigned int irq_find_at_or_after(unsigned int offset)
+{
+ return find_next_bit(allocated_irqs, nr_irqs, offset);
+}
#ifdef CONFIG_SPARSE_IRQ
@@ -517,7 +528,7 @@ static int alloc_descs(unsigned int start, unsigned int cnt, int node,
static int irq_expand_nr_irqs(unsigned int nr)
{
- if (nr > IRQ_BITMAP_BITS)
+ if (nr > MAX_SPARSE_IRQS)
return -ENOMEM;
nr_irqs = nr;
return 0;
@@ -535,11 +546,11 @@ int __init early_irq_init(void)
printk(KERN_INFO "NR_IRQS: %d, nr_irqs: %d, preallocated irqs: %d\n",
NR_IRQS, nr_irqs, initcnt);
- if (WARN_ON(nr_irqs > IRQ_BITMAP_BITS))
- nr_irqs = IRQ_BITMAP_BITS;
+ if (WARN_ON(nr_irqs > MAX_SPARSE_IRQS))
+ nr_irqs = MAX_SPARSE_IRQS;
- if (WARN_ON(initcnt > IRQ_BITMAP_BITS))
- initcnt = IRQ_BITMAP_BITS;
+ if (WARN_ON(initcnt > MAX_SPARSE_IRQS))
+ initcnt = MAX_SPARSE_IRQS;
if (initcnt > nr_irqs)
nr_irqs = initcnt;
@@ -812,8 +823,7 @@ __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
mutex_lock(&sparse_irq_lock);
- start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
- from, cnt, 0);
+ start = irq_find_free_area(from, cnt);
ret = -EEXIST;
if (irq >=0 && start != irq)
goto unlock;
@@ -834,11 +844,11 @@ EXPORT_SYMBOL_GPL(__irq_alloc_descs);
* irq_get_next_irq - get next allocated irq number
* @offset: where to start the search
*
- * Returns next irq number after offset or nr_irqs if none is found.
+ * Returns next irq number at or after offset or nr_irqs if none is found.
*/
unsigned int irq_get_next_irq(unsigned int offset)
{
- return find_next_bit(allocated_irqs, nr_irqs, offset);
+ return irq_find_at_or_after(offset);
}
struct irq_desc *
--
2.25.1
next prev parent reply other threads:[~2023-05-19 13:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 13:48 [PATCH v5 0/3] Increase the number of IRQ descriptors for SPARSEIRQ Shanker Donthineni
2023-05-19 13:49 ` [PATCH v5 1/3] genirq: Use hlist for managing resend handlers Shanker Donthineni
2023-05-24 10:01 ` [tip: irq/core] " tip-bot2 for Shanker Donthineni
2023-05-29 7:57 ` [PATCH v5 1/3] " Liao, Chang
2023-05-29 8:48 ` Marc Zyngier
2023-05-30 1:44 ` Liao, Chang
2023-05-30 7:27 ` Marc Zyngier
2023-05-29 21:51 ` Thomas Gleixner
2023-05-30 1:59 ` Liao, Chang
2023-05-30 12:19 ` Thomas Gleixner
2023-06-02 1:36 ` Liao, Chang
2023-05-19 13:49 ` Shanker Donthineni [this message]
2023-05-24 10:01 ` [tip: irq/core] genirq: Encapsulate sparse bitmap handling tip-bot2 for Shanker Donthineni
2023-05-19 13:49 ` [PATCH v5 3/3] genirq: Use the maple tree for IRQ descriptors management Shanker Donthineni
2023-05-24 10:01 ` [tip: irq/core] genirq: Use a maple tree for interrupt descriptor management tip-bot2 for Shanker Donthineni
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=20230519134902.1495562-3-sdonthineni@nvidia.com \
--to=sdonthineni@nvidia.com \
--cc=bigeasy@linutronix.de \
--cc=jsequeira@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=michael@walle.cc \
--cc=tglx@linutronix.de \
--cc=vsethi@nvidia.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