From: Andrew Morton <akpm@linux-foundation.org>
To: Yinghai Lu <yinghai@kernel.org>
Cc: mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com,
linux-kernel@vger.kernel.org, travis@sgi.com
Subject: Re: [PATCH] sparse_irq aka dyn_irq v14
Date: Thu, 13 Nov 2008 22:46:44 -0800 [thread overview]
Message-ID: <20081113224644.46c376f9.akpm@linux-foundation.org> (raw)
In-Reply-To: <491D1AC1.1000408@kernel.org>
On Thu, 13 Nov 2008 22:29:21 -0800 Yinghai Lu <yinghai@kernel.org> wrote:
> address some Andrew's concerns.
>
> ...
>
> +static struct irq_pin_list *get_one_free_irq_2_pin(int cpu)
> +{
> + struct irq_pin_list *pin;
> + int node;
> +
> + node = cpu_to_node(cpu);
> +
> + pin = kzalloc_node(sizeof(*pin), GFP_ATOMIC, node);
> + printk(KERN_DEBUG " alloc irq_2_pin on cpu %d node %d\n", cpu, node);
> + BUG_ON(!pin);
> +
> + return pin;
> +}
GFP_ATOMIC allocation attempts are unreliable - much more so than
GFP_KERNEL. GFP_ATOMIC allocations can and do fail. With the above
code, such a failure will crash the machine.
The code should handle this error and recover gracefully.
>
> ...
>
> +static struct irq_cfg *get_one_free_irq_cfg(int cpu)
> +{
> + struct irq_cfg *cfg;
> + int node;
> +
> + node = cpu_to_node(cpu);
> +
> + cfg = kzalloc_node(sizeof(*cfg), GFP_ATOMIC, node);
> + printk(KERN_DEBUG " alloc irq_cfg on cpu %d node %d\n", cpu, node);
> + BUG_ON(!cfg);
> +
> + return cfg;
> }
Ditto
> ...
>
> +static struct irq_2_iommu *get_one_free_irq_2_iommu(int cpu)
> +{
> + struct irq_2_iommu *iommu;
> + int node;
> +
> + node = cpu_to_node(cpu);
> +
> + iommu = kzalloc_node(sizeof(*iommu), GFP_ATOMIC, node);
> + printk(KERN_DEBUG "alloc irq_2_iommu on cpu %d node %d\n", cpu, node);
> +
> + return iommu;
> +}
I spent some time trying to work out whether the callers handle failure
here but I got lost in a twisty maze.
> ...
>
> +static void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
> +{
> + unsigned long bytes;
> + char *ptr;
> + int node;
> +
> + /* Compute how many bytes we need per irq and allocate them */
> + bytes = nr * sizeof(unsigned int);
> +
> + node = cpu_to_node(cpu);
> + ptr = kzalloc_node(bytes, GFP_ATOMIC, node);
> + printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n", cpu, node);
> + BUG_ON(!ptr);
> +
> + desc->kstat_irqs = (unsigned int *)ptr;
> +}
Ditto.
>
> ...
>
> +struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
> +{
> + struct irq_desc *desc;
> + struct list_head *hash_head;
> + unsigned long flags;
> + int node;
> +
> + desc = irq_to_desc(irq);
> + if (desc)
> + return desc;
> +
> + hash_head = sparseirqhashentry(irq);
> +
> + spin_lock_irqsave(&sparse_irq_lock, flags);
> +
> + /*
> + * We have to do the hash-walk again, to avoid races
> + * with another CPU:
> + */
> + list_for_each_entry(desc, hash_head, hash_entry) {
> + if (desc->irq == irq)
> + goto out_unlock;
> + }
> +
> + node = cpu_to_node(cpu);
> + desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
> + printk(KERN_DEBUG " alloc irq_desc for %d aka %#x on cpu %d node %d\n",
> + irq, irq, cpu, node);
> + BUG_ON(!desc);
Ditto.
> + init_one_irq_desc(irq, desc, cpu);
> +
> + /*
> + * We use RCU's safe list-add method to make
> + * parallel walking of the hash-list safe:
> + */
> + list_add_tail_rcu(&desc->hash_entry, hash_head);
> + /*
> + * Add it to the global list:
> + */
> + list_add_tail_rcu(&desc->list, &sparse_irqs_head);
> +
> +out_unlock:
> + spin_unlock_irqrestore(&sparse_irq_lock, flags);
> +
> + return desc;
> +}
> +
>
> ...
>
> +static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
> + int cpu)
> +{
> + struct irq_desc *desc;
> + unsigned int irq;
> + struct list_head *hash_head;
> + unsigned long flags;
> + int node;
> +
> + irq = old_desc->irq;
> +
> + hash_head = sparseirqhashentry(irq);
> +
> + spin_lock_irqsave(&sparse_irq_lock, flags);
> + /*
> + * We have to do the hash-walk again, to avoid races
> + * with another CPU:
> + */
> + list_for_each_entry(desc, hash_head, hash_entry) {
> + if (desc->irq == irq && old_desc != desc)
> + goto out_unlock;
> + }
> +
> + node = cpu_to_node(cpu);
> + desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
> + printk(KERN_DEBUG " move irq_desc for %d aka %#x to cpu %d node %d\n",
> + irq, irq, cpu, node);
> + BUG_ON(!desc);
Ditto.
> + init_copy_one_irq_desc(irq, old_desc, desc, cpu);
> +
> + list_replace_rcu(&old_desc->hash_entry, &desc->hash_entry);
> + list_replace_rcu(&old_desc->list, &desc->list);
> +
> + /* free the old one */
> + free_one_irq_desc(old_desc);
> + kfree(old_desc);
> +
> +out_unlock:
> + spin_unlock_irqrestore(&sparse_irq_lock, flags);
> +
> + return desc;
> +}
> +
next prev parent reply other threads:[~2008-11-14 6:47 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081023143721.GA25783@elte.hu>
[not found] ` <49012399.4010100@kernel.org>
[not found] ` <20081027164135.GD19476@elte.hu>
[not found] ` <4912B2FE.7030804@kernel.org>
[not found] ` <20081106101715.GA4022@elte.hu>
[not found] ` <4913B45C.1000009@kernel.org>
[not found] ` <20081107081249.GB4435@elte.hu>
[not found] ` <4913F9AA.80500@kernel.org>
[not found] ` <20081107084240.GG4435@elte.hu>
[not found] ` <491434FB.2050904@kernel.org>
[not found] ` <20081107124957.GA21709@elte.hu>
2008-11-09 7:05 ` [RFC PATCH] sparse_irq aka dyn_irq Yinghai Lu
2008-11-09 7:38 ` Ingo Molnar
2008-11-09 8:03 ` Yinghai Lu
2008-11-10 9:40 ` Ingo Molnar
2008-11-10 9:51 ` [PATCH] sparse_irq aka dyn_irq v10 Yinghai Lu
2008-11-10 9:53 ` Ingo Molnar
2008-11-10 9:55 ` Yinghai Lu
2008-11-10 9:57 ` Ingo Molnar
2008-11-10 9:55 ` [RFC PATCH] sparse_irq aka dyn_irq Andrew Morton
2008-11-10 10:00 ` Yinghai Lu
2008-11-10 10:03 ` Ingo Molnar
2008-11-10 10:05 ` Yinghai Lu
2008-11-10 10:09 ` Ingo Molnar
2008-11-10 19:47 ` Yinghai Lu
2008-11-11 6:28 ` [PATCH] sparse_irq aka dyn_irq v11 Yinghai Lu
[not found] ` <491A9F87.8040403@kernel.org>
[not found] ` <20081112120814.GG11352@elte.hu>
2008-11-13 7:01 ` [PATCH] sparse_irq aka dyn_irq v13 Yinghai Lu
2008-11-13 9:53 ` Ingo Molnar
2008-11-13 20:06 ` Yinghai Lu
2008-11-13 20:16 ` Yinghai Lu
2008-11-13 21:18 ` Andrew Morton
2008-11-13 21:21 ` Ingo Molnar
2008-11-13 22:01 ` Yinghai Lu
2008-11-13 22:05 ` Ingo Molnar
2008-11-13 22:13 ` Andrew Morton
2008-11-13 22:41 ` Yinghai Lu
2008-11-13 22:58 ` Andrew Morton
2008-11-13 23:15 ` Mike Travis
2008-11-13 23:24 ` Yinghai Lu
2008-11-14 0:20 ` Mike Travis
2008-11-14 0:29 ` Yinghai Lu
2008-11-14 6:29 ` [PATCH] sparse_irq aka dyn_irq v14 Yinghai Lu
2008-11-14 6:46 ` Andrew Morton [this message]
2008-11-15 9:05 ` Yinghai Lu
2008-11-13 22:19 ` [PATCH] sparse_irq aka dyn_irq v13 Paul Mackerras
2008-11-13 22:23 ` David Miller
2008-11-13 23:11 ` Mike Travis
2008-11-13 23:14 ` David Miller
2008-11-14 0:15 ` Mike Travis
2008-11-14 0:21 ` David Miller
2008-11-14 0:39 ` Mike Travis
2008-11-14 2:37 ` David Miller
2008-11-14 3:06 ` Mike Travis
2008-11-16 20:58 ` Benjamin Herrenschmidt
2008-11-16 23:44 ` Yinghai Lu
2008-11-16 23:48 ` H. Peter Anvin
2008-11-16 23:54 ` Yinghai Lu
2008-11-16 23:59 ` H. Peter Anvin
2008-11-17 0:21 ` Yinghai Lu
2008-11-17 0:26 ` H. Peter Anvin
2008-11-17 0:36 ` Yinghai Lu
2008-11-17 0:48 ` H. Peter Anvin
2008-11-17 0:58 ` Yinghai Lu
2008-11-17 1:00 ` H. Peter Anvin
2008-11-17 2:03 ` Mike Travis
2008-11-17 4:27 ` Benjamin Herrenschmidt
2008-11-17 4:26 ` Benjamin Herrenschmidt
2008-11-17 20:25 ` Jeremy Fitzhardinge
2008-11-17 4:25 ` Benjamin Herrenschmidt
2008-11-17 4:22 ` Benjamin Herrenschmidt
2008-11-17 1:51 ` Mike Travis
2008-11-17 4:39 ` H. Peter Anvin
2008-11-17 4:22 ` Benjamin Herrenschmidt
2008-11-17 4:42 ` H. Peter Anvin
2008-11-17 6:52 ` Benjamin Herrenschmidt
2008-11-09 8:36 ` [RFC PATCH] sparse_irq aka dyn_irq H. Peter Anvin
2008-11-09 7:50 ` Cyrill Gorcunov
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=20081113224644.46c376f9.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=travis@sgi.com \
--cc=yinghai@kernel.org \
/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
Powered by JetHome