Skip to contentSkip to conversation

genirq/irq_sim: misc updates

PATCH RESEND Superseded Bartosz Golaszewski 3 participants 12 messages Nov 15, 2023 – Dec 20, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover genirq/irq_sim: misc updates

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH RESEND v2 1/4 bitmap: define a cleanup function for bitmaps

From: Bartosz Golaszewski <[email protected]>

Add support for autopointers for bitmaps allocated with bitmap_alloc() et al.

---
 include/linux/bitmap.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/bitmap.h +3 -0
index 99451431e4d6..df24c8fb1009 100644
@@ -6,6 +6,7 @@
 
 #include <linux/align.h>
 #include <linux/bitops.h>
+#include <linux/cleanup.h>
 #include <linux/errno.h>
 #include <linux/find.h>
 #include <linux/limits.h>
@@ -127,6 +128,8 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
 unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
 void bitmap_free(const unsigned long *bitmap);
 
+DEFINE_FREE(bitmap, unsigned long *, if (_T) bitmap_free(_T))
+
 /* Managed variants of the above. */
 unsigned long *devm_bitmap_alloc(struct device *dev,
 				 unsigned int nbits, gfp_t flags);
Signature · 1 line
2.40.1
#2 lore raw

PATCH RESEND v2 2/4 genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The irqnum field is unused. Remove it.

---
 kernel/irq/irq_sim.c | 1 -
 1 file changed, 1 deletion(-)
kernel/irq/irq_sim.c +0 -1
index dd76323ea3fd..f5ebb3ba6f9a 100644
@@ -19,7 +19,6 @@ struct irq_sim_work_ctx {
 };
 
 struct irq_sim_irq_ctx {
-	int			irqnum;
 	bool			enabled;
 	struct irq_sim_work_ctx	*work_ctx;
 };
Signature · 1 line
2.40.1
#3 lore raw

PATCH RESEND v2 3/4 genirq/irq_sim: order headers alphabetically

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

For better readability and maintenance keep headers in alphabetical order.

---
 kernel/irq/irq_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/irq/irq_sim.c +1 -1
index f5ebb3ba6f9a..b0d50b48dbd1 100644
@@ -4,10 +4,10 @@
  * Copyright (C) 2020 Bartosz Golaszewski <[email protected]>
  */
 
+#include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/irq_sim.h>
 #include <linux/irq_work.h>
-#include <linux/interrupt.h>
 #include <linux/slab.h>
 
 struct irq_sim_work_ctx {
Signature · 1 line
2.40.1
#4 lore raw

PATCH RESEND v2 4/4 genirq/irq_sim: shrink code by using cleanup helpers

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Use the new __free helper from linux/cleanup.h to remove all gotos and simplify the error paths.

---
 kernel/irq/irq_sim.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)
kernel/irq/irq_sim.c +11 -16
index b0d50b48dbd1..82b7b5051249 100644
@@ -4,6 +4,7 @@
  * Copyright (C) 2020 Bartosz Golaszewski <[email protected]>
  */
 
+#include <linux/cleanup.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/irq_sim.h>
@@ -163,33 +164,27 @@ static const struct irq_domain_ops irq_sim_domain_ops = {
 struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode,
 					 unsigned int num_irqs)
 {
-	struct irq_sim_work_ctx *work_ctx;
-
-	work_ctx = kmalloc(sizeof(*work_ctx), GFP_KERNEL);
+	struct irq_sim_work_ctx *work_ctx __free(kfree) =
+				kmalloc(sizeof(*work_ctx), GFP_KERNEL);
 	if (!work_ctx)
-		goto err_out;
+		return ERR_PTR(-ENOMEM);
 
-	work_ctx->pending = bitmap_zalloc(num_irqs, GFP_KERNEL);
-	if (!work_ctx->pending)
-		goto err_free_work_ctx;
+	unsigned long *pending __free(bitmap) = bitmap_zalloc(num_irqs,
+							      GFP_KERNEL);
+	if (!pending)
+		return ERR_PTR(-ENOMEM);
 
 	work_ctx->domain = irq_domain_create_linear(fwnode, num_irqs,
 						    &irq_sim_domain_ops,
 						    work_ctx);
 	if (!work_ctx->domain)
-		goto err_free_bitmap;
+		return ERR_PTR(-ENOMEM);
 
 	work_ctx->irq_count = num_irqs;
 	work_ctx->work = IRQ_WORK_INIT_HARD(irq_sim_handle_irq);
+	work_ctx->pending = no_free_ptr(pending);
 
-	return work_ctx->domain;
-
-err_free_bitmap:
-	bitmap_free(work_ctx->pending);
-err_free_work_ctx:
-	kfree(work_ctx);
-err_out:
-	return ERR_PTR(-ENOMEM);
+	return no_free_ptr(work_ctx)->domain;
 }
 EXPORT_SYMBOL_GPL(irq_domain_create_sim);
 
Signature · 1 line
2.40.1
#5 lore raw
In reply to Bartosz Golaszewski
Quoted 22 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

Quoted 7 lines
 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)

--
2.40.1

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Bart

maintainer
#6 lore raw
Quoted 27 lines · Bartosz Golaszewski
Quoted 26 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)
Quoted 7 lines
Quoted 3 lines

--
2.40.1

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Hi Bartosz,

I'm the first in the list for this series, but really only 1st patch is related to bitmaps, and I already acked it. If you prefer that, I can pull it in the bitmap tree.

Thanks,
Yury

#7 lore raw
Quoted 37 lines · Yury Norov
Quoted 27 lines · Bartosz Golaszewski
Quoted 26 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)
Quoted 7 lines
Quoted 3 lines

--
2.40.1

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Quoted 8 lines

Hi Bartosz,

I'm the first in the list for this series, but really only 1st patch is related to bitmaps, and I already acked it. If you prefer that, I can pull it in the bitmap tree.

Thanks,
Yury

If there's a risk it will conflict then you can apply it and provide Thomas with an immutable branch against the irq tree, otherwise I think Thomas can pick up all the patches.

Bartosz

#8 lore raw
In reply to Bartosz Golaszewski
Quoted 32 lines · Bartosz Golaszewski
Quoted 22 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

Quoted 7 lines
 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)

--
2.40.1

Quoted 5 lines

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Bart

Another ping...

Bartosz

#9 lore raw
Quoted 38 lines · Bartosz Golaszewski
Quoted 36 lines · Bartosz Golaszewski
Quoted 22 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

Quoted 7 lines
 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)

--
2.40.1

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Quoted 5 lines
Quoted 1 line

Bart

Another ping...

Bartosz

Thomas,

Is there any formal reason why this cannot be processed?

Bartosz

#10 lore raw
Quoted 44 lines · Bartosz Golaszewski
Quoted 42 lines · Bartosz Golaszewski
Quoted 32 lines · Bartosz Golaszewski
Quoted 22 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Here are a couple of updates to the interrupt simulator. Two are minor:
remove an unused field and reorder includes for readability. The third one simplifies the error paths by using new cleanup macros. To that end we also add a cleanup definition for dynamic bitmaps.

Resending rebased on top of v6.7-rc1 and with tags collected.

v1 -> v2:
- add a NULL-pointer check to the bitmap cleanup macro as advised by Peter Zijlstra
- initialize managed pointers when declaring them to create a clear pairing between the type and the cleanup action

Bartosz Golaszewski (4):
bitmap: define a cleanup function for bitmaps genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx genirq/irq_sim: order headers alphabetically genirq/irq_sim: shrink code by using cleanup helpers

Quoted 7 lines
 include/linux/bitmap.h |  3 +++
 kernel/irq/irq_sim.c   | 30 ++++++++++++------------------
 2 files changed, 15 insertions(+), 18 deletions(-)

--
2.40.1

Quoted 5 lines

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Bart

Another ping...

Quoted 7 lines
Quoted 1 line

Bartosz

Thomas,

Is there any formal reason why this cannot be processed?

Bartosz

Ping.

Bartosz

#11 lore raw
Quoted 4 lines · Bartosz Golaszewski
Quoted 3 lines · Bartosz Golaszewski
Quoted 2 lines · Bartosz Golaszewski
Quoted 1 line · Bartosz Golaszewski

On Wed, Nov 15, 2023 at 5:59 PM Bartosz Golaszewski <[email protected]> wrote:

...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

It's been two weeks since this submission and ~2.5 months since the first one so I guess, a gentle ping is in order. This is not a very controversial series - can this be applied?

Another ping...

Is there any formal reason why this cannot be processed?

Ping.

Instead you can now just say that you are going to apply this via your tree, if there won't be objections, e.g., within a week (or two as it's a holiday season).

In the PR to Linus you can explain why it's taken like this.

Signature · 2 lines
With Best Regards,
Andy Shevchenko