* [PATCH] sparseirq: Enable early irq_desc allocation.
@ 2009-05-21 16:56 Paul Mundt
2009-05-21 20:26 ` Yinghai Lu
0 siblings, 1 reply; 5+ messages in thread
From: Paul Mundt @ 2009-05-21 16:56 UTC (permalink / raw)
To: Ingo Molnar, Yinghai Lu; +Cc: linux-kernel
Presently non-legacy IRQs have their irq_desc allocated with
kzalloc_node(). This assumes that all callers of irq_to_desc_cpu_alloc()
will be sufficiently late in the boot process that kmalloc is available.
While porting sparseirq support to sh this blew up immediately, as at the
time that we register the CPU's interrupt vector map only bootmem is
available.
This adds in a simple after_bootmem check to see where the allocation
needs to come from, which is likewise provided by all of the platforms
that support sparse irq today. :-)
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
---
kernel/irq/handle.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index d82142b..5fb3a5c 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -19,7 +19,7 @@
#include <linux/hash.h>
#include <trace/irq.h>
#include <linux/bootmem.h>
-
+#include <linux/mm.h>
#include "internals.h"
/*
@@ -81,13 +81,17 @@ static struct irq_desc irq_desc_init = {
.lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
};
-void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
+void __ref init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
{
int node;
void *ptr;
node = cpu_to_node(cpu);
- ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
+ if (after_bootmem)
+ ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
+ else
+ ptr = alloc_bootmem_node(NODE_DATA(node),
+ nr * sizeof(*desc->kstat_irqs));
/*
* don't overwite if can not get new one
@@ -187,7 +191,7 @@ struct irq_desc *irq_to_desc(unsigned int irq)
return NULL;
}
-struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
+struct irq_desc * __ref irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
{
struct irq_desc *desc;
unsigned long flags;
@@ -211,7 +215,10 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
goto out_unlock;
node = cpu_to_node(cpu);
- desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
+ if (after_bootmem)
+ desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
+ else
+ desc = alloc_bootmem_node(NODE_DATA(node), sizeof(*desc));
printk(KERN_DEBUG " alloc irq_desc for %d on cpu %d node %d\n",
irq, cpu, node);
if (!desc) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] sparseirq: Enable early irq_desc allocation.
2009-05-21 16:56 [PATCH] sparseirq: Enable early irq_desc allocation Paul Mundt
@ 2009-05-21 20:26 ` Yinghai Lu
2009-05-22 1:40 ` Paul Mundt
0 siblings, 1 reply; 5+ messages in thread
From: Yinghai Lu @ 2009-05-21 20:26 UTC (permalink / raw)
To: Paul Mundt, Ingo Molnar, Yinghai Lu, Andrew Morton, Mel Gorman
Cc: linux-kernel
Paul Mundt wrote:
> Presently non-legacy IRQs have their irq_desc allocated with
> kzalloc_node(). This assumes that all callers of irq_to_desc_cpu_alloc()
> will be sufficiently late in the boot process that kmalloc is available.
>
> While porting sparseirq support to sh this blew up immediately, as at the
> time that we register the CPU's interrupt vector map only bootmem is
> available.
>
> This adds in a simple after_bootmem check to see where the allocation
> needs to come from, which is likewise provided by all of the platforms
> that support sparse irq today. :-)
>
> Cc: Yinghai Lu <yinghai@kernel.org>
> Cc: Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
>
> ---
>
> kernel/irq/handle.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
> index d82142b..5fb3a5c 100644
> --- a/kernel/irq/handle.c
> +++ b/kernel/irq/handle.c
> @@ -19,7 +19,7 @@
> #include <linux/hash.h>
> #include <trace/irq.h>
> #include <linux/bootmem.h>
> -
> +#include <linux/mm.h>
> #include "internals.h"
>
> /*
> @@ -81,13 +81,17 @@ static struct irq_desc irq_desc_init = {
> .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
> };
>
> -void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
> +void __ref init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
> {
> int node;
> void *ptr;
>
> node = cpu_to_node(cpu);
> - ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
> + if (after_bootmem)
> + ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
> + else
> + ptr = alloc_bootmem_node(NODE_DATA(node),
> + nr * sizeof(*desc->kstat_irqs));
>
> /*
> * don't overwite if can not get new one
> @@ -187,7 +191,7 @@ struct irq_desc *irq_to_desc(unsigned int irq)
> return NULL;
> }
>
> -struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
> +struct irq_desc * __ref irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
> {
> struct irq_desc *desc;
> unsigned long flags;
> @@ -211,7 +215,10 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
> goto out_unlock;
>
> node = cpu_to_node(cpu);
> - desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
> + if (after_bootmem)
> + desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
> + else
> + desc = alloc_bootmem_node(NODE_DATA(node), sizeof(*desc));
> printk(KERN_DEBUG " alloc irq_desc for %d on cpu %d node %d\n",
> irq, cpu, node);
> if (!desc) {
can you check tip?
we change _cpu to node already.
also only sh have after_bootmem now.
arch/sh/mm/init.c:int after_bootmem = 0;
arch/sh/mm/init.c: after_bootmem = 1;
arch/sh/mm/ioremap_64.c: extern int after_bootmem;
arch/sh/mm/ioremap_64.c: if (after_bootmem) {
include/linux/mm.h:extern int after_bootmem;
for x86 we have bootmem_state ...
arch/x86/include/asm/page_types.h:enum bootmem_state {
arch/x86/include/asm/page_types.h:extern enum bootmem_state bootmem_state;
arch/x86/kernel/setup.c: bootmem_state = DURING_BOOTMEM;
arch/x86/mm/init.c:enum bootmem_state bootmem_state = BEFORE_BOOTMEM;
arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM && !start) {
arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM &&
arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
Andrew,
do we need to move bootmem_state back to linux/mm.h?
YH
YH
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sparseirq: Enable early irq_desc allocation.
2009-05-21 20:26 ` Yinghai Lu
@ 2009-05-22 1:40 ` Paul Mundt
2009-05-23 12:57 ` Ingo Molnar
2009-05-23 12:57 ` [tip:irq/numa] sparseirq: Allow " tip-bot for Paul Mundt
0 siblings, 2 replies; 5+ messages in thread
From: Paul Mundt @ 2009-05-22 1:40 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Ingo Molnar, Andrew Morton, Mel Gorman, linux-kernel
On Thu, May 21, 2009 at 01:26:26PM -0700, Yinghai Lu wrote:
> can you check tip?
> we change _cpu to node already.
>
> also only sh have after_bootmem now.
> arch/sh/mm/init.c:int after_bootmem = 0;
> arch/sh/mm/init.c: after_bootmem = 1;
> arch/sh/mm/ioremap_64.c: extern int after_bootmem;
> arch/sh/mm/ioremap_64.c: if (after_bootmem) {
> include/linux/mm.h:extern int after_bootmem;
>
> for x86 we have bootmem_state ...
> arch/x86/include/asm/page_types.h:enum bootmem_state {
> arch/x86/include/asm/page_types.h:extern enum bootmem_state bootmem_state;
> arch/x86/kernel/setup.c: bootmem_state = DURING_BOOTMEM;
> arch/x86/mm/init.c:enum bootmem_state bootmem_state = BEFORE_BOOTMEM;
> arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
> arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
> arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM && !start) {
> arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM &&
> arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
>
> Andrew,
> do we need to move bootmem_state back to linux/mm.h?
No need, I just switched to slab_is_available() in the respin. Here is
v2, against -tip:
--
sparseirq: Enable early irq_desc allocation, v2.
Presently non-legacy IRQs have their irq_desc allocated with
kzalloc_node(). This assumes that all callers of irq_to_desc_node_alloc()
will be sufficiently late in the boot process that kmalloc is available.
While porting sparseirq support to sh this blew up immediately, as at the
time that we register the CPU's interrupt vector map only bootmem is
available. Check slab_is_available() to work out which path to use.
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
---
V2 updated for -tip, and switched to slab_is_available().
kernel/irq/handle.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 33ff8f5..b5a47d6 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -18,8 +18,8 @@
#include <linux/rculist.h>
#include <linux/hash.h>
#include <linux/bootmem.h>
+#include <linux/slab.h>
#include <trace/events/irq.h>
-
#include "internals.h"
/*
@@ -81,11 +81,16 @@ static struct irq_desc irq_desc_init = {
.lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
};
-void init_kstat_irqs(struct irq_desc *desc, int node, int nr)
+void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
{
void *ptr;
- ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
+ if (slab_is_available())
+ ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs),
+ GFP_ATOMIC, node);
+ else
+ ptr = alloc_bootmem_node(NODE_DATA(node),
+ nr * sizeof(*desc->kstat_irqs));
/*
* don't overwite if can not get new one
@@ -186,7 +191,7 @@ struct irq_desc *irq_to_desc(unsigned int irq)
return NULL;
}
-struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
+struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
{
struct irq_desc *desc;
unsigned long flags;
@@ -208,7 +213,11 @@ struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
if (desc)
goto out_unlock;
- desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
+ if (slab_is_available())
+ desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
+ else
+ desc = alloc_bootmem_node(NODE_DATA(node), sizeof(*desc));
+
printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node);
if (!desc) {
printk(KERN_ERR "can not alloc irq_desc\n");
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] sparseirq: Enable early irq_desc allocation.
2009-05-22 1:40 ` Paul Mundt
@ 2009-05-23 12:57 ` Ingo Molnar
2009-05-23 12:57 ` [tip:irq/numa] sparseirq: Allow " tip-bot for Paul Mundt
1 sibling, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-05-23 12:57 UTC (permalink / raw)
To: Paul Mundt, Yinghai Lu, Andrew Morton, Mel Gorman, linux-kernel,
Pekka Enberg
* Paul Mundt <lethal@linux-sh.org> wrote:
> On Thu, May 21, 2009 at 01:26:26PM -0700, Yinghai Lu wrote:
> > can you check tip?
> > we change _cpu to node already.
> >
> > also only sh have after_bootmem now.
> > arch/sh/mm/init.c:int after_bootmem = 0;
> > arch/sh/mm/init.c: after_bootmem = 1;
> > arch/sh/mm/ioremap_64.c: extern int after_bootmem;
> > arch/sh/mm/ioremap_64.c: if (after_bootmem) {
> > include/linux/mm.h:extern int after_bootmem;
> >
> > for x86 we have bootmem_state ...
> > arch/x86/include/asm/page_types.h:enum bootmem_state {
> > arch/x86/include/asm/page_types.h:extern enum bootmem_state bootmem_state;
> > arch/x86/kernel/setup.c: bootmem_state = DURING_BOOTMEM;
> > arch/x86/mm/init.c:enum bootmem_state bootmem_state = BEFORE_BOOTMEM;
> > arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
> > arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
> > arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM && !start) {
> > arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM &&
> > arch/x86/mm/init.c: if (bootmem_state == BEFORE_BOOTMEM)
> >
> > Andrew,
> > do we need to move bootmem_state back to linux/mm.h?
>
> No need, I just switched to slab_is_available() in the respin. Here is
> v2, against -tip:
thanks.
I'm a bit unhappy about allocators here (and this is not your
fault). There's not two but _three_ states for allocation: bootmem,
pagealloc, kmalloc. There is a (short) stage during bootup where
kmalloc is not enabled yet and bootmem is already deactivated. If we
ever use slab_is_available() in such a state it will blow up.
Fixing all this allocator bootstrapping mess we have in Linux is a
lot larger project though.
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:irq/numa] sparseirq: Allow early irq_desc allocation
2009-05-22 1:40 ` Paul Mundt
2009-05-23 12:57 ` Ingo Molnar
@ 2009-05-23 12:57 ` tip-bot for Paul Mundt
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Paul Mundt @ 2009-05-23 12:57 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, yinghai, mel, lethal, akpm, tglx, mingo
Commit-ID: 948cd52906baf1f92aeea2f9b5c515db1b2e592a
Gitweb: http://git.kernel.org/tip/948cd52906baf1f92aeea2f9b5c515db1b2e592a
Author: Paul Mundt <lethal@linux-sh.org>
AuthorDate: Fri, 22 May 2009 10:40:09 +0900
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sat, 23 May 2009 14:55:24 +0200
sparseirq: Allow early irq_desc allocation
Presently non-legacy IRQs have their irq_desc allocated with
kzalloc_node(). This assumes that all callers of irq_to_desc_node_alloc()
will be sufficiently late in the boot process that kmalloc is available.
While porting sparseirq support to sh this blew up immediately, as at the
time that we register the CPU's interrupt vector map only bootmem is
available. Check slab_is_available() to work out which path to use.
[ Impact: fix SH early boot crash with sparseirq enabled ]
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mel@csn.ul.ie>
LKML-Reference: <20090522014008.GA2806@linux-sh.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/irq/handle.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index a3c671e..18041a2 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -11,6 +11,7 @@
*/
#include <linux/irq.h>
+#include <linux/slab.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/interrupt.h>
@@ -81,11 +82,16 @@ static struct irq_desc irq_desc_init = {
.lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
};
-void init_kstat_irqs(struct irq_desc *desc, int node, int nr)
+void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
{
void *ptr;
- ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
+ if (slab_is_available())
+ ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs),
+ GFP_ATOMIC, node);
+ else
+ ptr = alloc_bootmem_node(NODE_DATA(node),
+ nr * sizeof(*desc->kstat_irqs));
/*
* don't overwite if can not get new one
@@ -186,7 +192,7 @@ struct irq_desc *irq_to_desc(unsigned int irq)
return NULL;
}
-struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
+struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
{
struct irq_desc *desc;
unsigned long flags;
@@ -208,7 +214,11 @@ struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
if (desc)
goto out_unlock;
- desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
+ if (slab_is_available())
+ desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
+ else
+ desc = alloc_bootmem_node(NODE_DATA(node), sizeof(*desc));
+
printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node);
if (!desc) {
printk(KERN_ERR "can not alloc irq_desc\n");
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-05-23 12:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-21 16:56 [PATCH] sparseirq: Enable early irq_desc allocation Paul Mundt
2009-05-21 20:26 ` Yinghai Lu
2009-05-22 1:40 ` Paul Mundt
2009-05-23 12:57 ` Ingo Molnar
2009-05-23 12:57 ` [tip:irq/numa] sparseirq: Allow " tip-bot for Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox