From: Andrey Ryabinin <a.ryabinin@samsung.com>
To: David Rientjes <rientjes@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] kernel: irq: use a kmem_cache for allocating struct irq_desc
Date: Thu, 20 Nov 2014 11:53:26 +0300 [thread overview]
Message-ID: <546DAC06.9010700@samsung.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1411191551350.32057@chino.kir.corp.google.com>
On 11/20/2014 02:52 AM, David Rientjes wrote:
> On Mon, 10 Nov 2014, Andrey Ryabinin wrote:
>
>> After enabling alignment checks in UBSan I've noticed a lot of
>> reports like this:
>>
>> UBSan: Undefined behaviour in ../kernel/irq/chip.c:195:14
>> member access within misaligned address ffff88003e80d6f8
>> for type 'struct irq_desc' which requires 16 byte alignment
>>
>> struct irq_desc declared with ____cacheline_internodealigned_in_smp
>> attribute. However in some cases it allocated dynamically via kmalloc().
>> In general case kmalloc() guaranties only sizeof(void *) alignment.
>> We should use a separate slab cache to make struct irq_desc
>> properly aligned on SMP configuration.
>>
>> This also could slightly reduce memory usage on some configurations.
>> E.g. in my setup sizeof(struct irq_desc) == 320. Which means that
>> kmalloc-512 will be used for allocating irg_desc via kmalloc().
>> In that case using separate slab cache will save us 192 bytes per
>> each irq_desc.
>>
>> Note: UBSan reports says that 'struct irq_desc' requires 16 byte alignment.
>> It's wrong, in my setup it should be 64 bytes. This looks like a gcc bug,
>> but it doesn't change the fact that irq_desc is misaligned.
>>
>> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
>
> I think this is just fine, I would just prefer that you do the memset()
I'd rather do kmem_cache_alloc_node(irq_desc_cachep, gfp | __GFP_ZERO, node)
instead of memset.
> explicitly rather than introduce the new slab function for such a
> specialized purpose (unless there's other examples in the kernel where
> this would be useful).
>
I've counted 7 places where kmem_cache_alloc_node(..., gfp | __GFP_ZERO, ...); called.
next prev parent reply other threads:[~2014-11-20 8:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-10 12:06 [PATCH 1/3] mm: sl[aou]b: introduce kmem_cache_zalloc_node() Andrey Ryabinin
2014-11-10 12:06 ` [PATCH 2/3] kernel: irq: use a kmem_cache for allocating struct irq_desc Andrey Ryabinin
2014-11-19 23:52 ` David Rientjes
2014-11-20 8:53 ` Andrey Ryabinin [this message]
2014-11-10 12:06 ` [PATCH 3/3] kernel: irq: use kmem_cache for allocating struct irqaction Andrey Ryabinin
2014-11-19 23:46 ` [PATCH 1/3] mm: sl[aou]b: introduce kmem_cache_zalloc_node() David Rientjes
2014-11-20 8:47 ` Andrey Ryabinin
2014-11-20 20:03 ` Christoph Lameter
2014-11-20 22:31 ` David Rientjes
2014-11-21 6:29 ` Andrey Ryabinin
2014-11-21 9:57 ` David Rientjes
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=546DAC06.9010700@samsung.com \
--to=a.ryabinin@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=tglx@linutronix.de \
/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