[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200402232350.GA1644@smtp.gmail.com>
Date: Thu, 2 Apr 2020 20:23:50 -0300
From: Marcelo Schmitt <marcelo.schmitt1@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-kernel@...r.kernel.org, lars@...afoo.de
Subject: Re: [RFC] genirq: prevent allocated_irqs from being smaller than
NR_IRQS
On 04/02, Thomas Gleixner wrote:
> Marcelo,
>
> Marcelo Schmitt <marcelo.schmitt1@...il.com> writes:
> > #ifdef CONFIG_SPARSE_IRQ
> > # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
> > #else
> > # define IRQ_BITMAP_BITS NR_IRQS
> > #endif
> >
> > The thing I'm troubled about is that BITS_TO_LONGS divides
> > IRQ_BITMAP_BITS by sizeof(long) * 8, which makes it possible for the
> > size of allocated_irqs to be smaller than NR_IRQS.
>
> No. It calculates the number of longs which are required to store
> IRQ_BITMAP_BITS bits. And it does not only divide, it also takes the
> reminder into account.
>
> One byte fits 8 bits. Multiplied with sizeof(long) tells you how many
> bits fit into a long: Unsurprisingly that 32 on 32bit and 64 on 64bit
> systems.
I see. Given that a single bit is enough to mark whether interrupts were
allocated for an IRQ line, the allocated_irqs needs only IRQ_BITMAP_BITS
bits to track how many IRQs have been allocated.
Since BITS_TO_LONGS will calculate the number of longs required to store
at least IRQ_BITMAP_BIT bits, the bitmap will have enough room for the
tracking bits.
Naturally, the number of longs needed to store N bits will depend on the
sizeof(long) in each system. Probably this is why BITS_PER_TYPE(long) is
taken into account to find out how many longs are needed to house
IRQ_BITMAP_BIT bits. Therefore, the initialization of allocated_irqs
shall generalize well for systems with different word sizes. A clever
implementation.
>
> > By the way, is there any mailing list for IRQ related discussions?
> > I couldn't find one at vger.kernel.org.
>
> The MAINTAINERS file tells you:
>
> IRQ SUBSYSTEM
> L: linux-kernel@...r.kernel.org
>
> So you picked the right one.
>
> Thanks,
>
> tglx
Thanks,
Marcelo
Powered by blists - more mailing lists