public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] sparse_irq aka dyn_irq
Date: Sun, 9 Nov 2008 08:38:13 +0100	[thread overview]
Message-ID: <20081109073813.GA17180@elte.hu> (raw)
In-Reply-To: <49168BD3.5010204@kernel.org>


General impression: very nice patch!

A lot of the structural problems have been addressed: the descriptor 
lookup is now hashed, the dynarray stuff got cleaned up / eliminated, 
the irq_desc->chip_data binding is very nice as well.

(And the patch needs to be split up like it was in the past, once all 
review feedback has been seen and addressed.)

> +config HAVE_SPARSE_IRQ
> +	bool
> +	default y

i think it should be made user-configurable - at least initially. It 
should not cause extra complications, right?

> +	if (irq < NR_IRQS_LEGACY) {

please s/NR_IRQS_LEGACY/NR_IRQS_X86_LEGACY - this is never used 
outside of x86 code.

> +		cfg_new = desc_new->chip_data;

the chip_data binding is a nice touch.

> -	irq_want = build_irq_for_pci_dev(dev) + 0x100;
> +	irq_want = build_irq_for_pci_dev(dev) + 0xfff;

please replace magic constant with a properly named constant.

> -	if (WARN_ON(nr > NR_IRQS))
> -		nr = NR_IRQS;

this will have to stay for the !SPARSE_IRQ case.

> +++ linux-2.6/arch/x86/mm/init_32.c
> @@ -66,6 +66,7 @@ static unsigned long __meminitdata table
>  static unsigned long __meminitdata table_top;
>  
>  static int __initdata after_init_bootmem;
> +int after_bootmem;
>  
>  static __init void *alloc_low_page(unsigned long *phys)
>  {
> @@ -987,6 +988,8 @@ void __init mem_init(void)
>  
>  	set_highmem_pages_init();
>  
> +	after_bootmem = 1;

this hack can go away once we have a proper percpu_alloc() that can be 
used early enough.

> +#ifndef CONFIG_HAVE_SPARSE_IRQ

i'd suggest s/HAVE_SPARSE_IRQ/SPARSE_IRQ - as the HAVE_* flags are for 
architecture code to signal the presence of a facility.

> +#ifndef CONFIG_HAVE_SPARSE_IRQ
>  	if (irq >= nr_irqs)
>  		return;
> +#endif

we should hide as many ugly #ifdefs as possible, and define nr_irqs to 
NR_IRQS in the !SPARSE_IRQ case.

> +++ linux-2.6/drivers/pci/htirq.c
> @@ -82,6 +82,18 @@ void unmask_ht_irq(unsigned int irq)
>  	write_ht_irq_msg(irq, &msg);
>  }
>  
> +static unsigned int build_irq_for_pci_dev(struct pci_dev *dev)
> +{
> +	unsigned int irq;
> +
> +	irq = dev->bus->number;
> +	irq <<= 8;
> +	irq |= dev->devfn;
> +	irq <<= 12;
> +
> +	return irq;

magic constants should be named.

> +#ifdef CONFIG_HAVE_SPARSE_IRQ
> +	irq = create_irq_nr(irq_want + idx);
> +#else
>  	irq = create_irq();
> +#endif

please eliminate this #ifdef by adding one new API: 
create_irq_nr(idx), which just maps to the create_irq() API in the 
!SPARSE_IRQ case.

>  static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
>  {
> -	return (irq < nr_irqs) ? irq_2_iommuX + irq : NULL;
> +	struct irq_desc *desc;
> +
> +	desc = irq_to_desc(irq);
> +
> +	BUG_ON(!desc);
> +
> +	return desc->irq_2_iommu;

the BUG_ON() is not too friendly, please do something like this 
instead:

	if (WARN_ON_ONCE(!desc))
		return NULL;

> +#ifndef CONFIG_HAVE_SPARSE_IRQ
>  	/* protect irq_2_iommu_alloc later */
>  	if (irq >= nr_irqs)
>  		return -1;
> +#endif

this #ifdef can be eliminated too and turned into straight code via 
the #define nr_irqs NR_IRQS trick in the !SPARSE_IRQ case.

> -	for_each_irq_desc(i, desc)
> +	for_each_irq_desc(i, desc) {
>  		desc->affinity = cpumask_of_cpu(0);
> +	} end_for_each_irq_desc();

Sidenote: later on, once the patch is upstream, we should do a global 
rename:

 s/for_each_irq_desc/do_each_irq_desc
 s/end_for_each_irq_desc/while_each_irq_desc

as it's much harder to miss the "while" in a "do ..." loop, than it is 
to miss the "end" in a "for" loop.

> +#ifdef CONFIG_HAVE_SPARSE_IRQ
> +static struct irq_desc irq_desc_init = {
> +	.irq = -1U,
> +	.status = IRQ_DISABLED,
> +	.chip = &no_irq_chip,
> +	.handle_irq = handle_bad_irq,
> +	.depth = 1,
> +	.lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
> +#ifdef CONFIG_SMP
> +	.affinity = CPU_MASK_ALL
> +#endif
> +};

please align structure fields vertically.

> +static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
> +	[0 ... NR_IRQS_LEGACY-1] = {
> +		.irq = -1U,
> +		.status = IRQ_DISABLED,
> +		.chip = &no_irq_chip,
> +		.handle_irq = handle_bad_irq,
> +		.depth = 1,
> +		.lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
> +#ifdef CONFIG_SMP
> +		.affinity = CPU_MASK_ALL
> +#endif
> +	}
> +};

same here.

> @@ -199,7 +200,6 @@ extern void reinit_intr_remapped_IO_APIC
>  #endif
>  
>  extern int probe_nr_irqs(void);
> -
>  #else  /* !CONFIG_X86_IO_APIC */
>  #define io_apic_assign_pci_irqs 0
>  static const int timer_through_8259 = 0;

that's a spurious removal of a newline.

all in one, i cannot see fundamental problems in this patch.

	Ingo

  reply	other threads:[~2008-11-09  7:38 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 [this message]
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
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=20081109073813.GA17180@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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