From: David Laight <David.Laight@ACULAB.COM>
To: 'Peter Zijlstra' <peterz@infradead.org>,
Vineet Gupta <vineet.gupta1@synopsys.com>
Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>,
"linux-snps-arc@lists.infradead.org"
<linux-snps-arc@lists.infradead.org>,
Arnd Bergmann <arnd.bergmann@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: RE: [PATCH] ARC: Explicitly set ARCH_SLAB_MINALIGN = 8
Date: Wed, 13 Feb 2019 14:13:08 +0000 [thread overview]
Message-ID: <536eb8d0112b44dc90b9b9a7f670e96d@AcuMS.aculab.com> (raw)
In-Reply-To: <20190213125651.GP32494@hirez.programming.kicks-ass.net>
From: Peter Zijlstra
> Sent: 13 February 2019 12:57
...
...
> In the past I've proposed a GCC plugin / checker that would verify the
> alignment requirements against the various allocators.
>
> For instance:
>
> struct foo {
> spinlock_t a;
> int b;
> } __cacheline_aligned;
>
> struct foo *my_foo = kmalloc(sizeof(struct foo), GFP_KERNEL);
>
> would result in a warning; because obviously kmalloc (as per
> ARCH_SLAB_MINALIGN) doesn't respect the cacheline alignment of the type.
>
> Of course; it appears our kmalloc() function definition doesn't even
> have a __malloc attribute, so there's plenty work to be done here.
We could pass the alignment to the allocator by defining something like:
#define do_malloc(x) ((x) = (typeof(*(x)))_do_malloc(sizeof *(x), __alignof__(*(x))))
Although you probably want to compile-time detect alignments that are smaller
than the normal minimal alignment.
If the allocator needs to add a header it would need to use the byte before
the allocated item to find the header.
OTOH adding a header is horrid for page-sized items.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2019-02-13 14:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 10:55 [PATCH] ARC: Explicitly set ARCH_SLAB_MINALIGN = 8 Alexey Brodkin
2019-02-12 17:17 ` Vineet Gupta
2019-02-12 17:30 ` David Laight
2019-02-12 17:45 ` Vineet Gupta
2019-02-13 12:56 ` Peter Zijlstra
2019-02-13 14:13 ` David Laight [this message]
2019-02-13 23:23 ` Vineet Gupta
2019-02-14 8:50 ` Alexey Brodkin
2019-02-14 10:28 ` Peter Zijlstra
2019-02-15 1:34 ` Vineet Gupta
2019-02-18 8:53 ` Alexey Brodkin
2019-02-19 23:30 ` Vineet Gupta
2019-02-14 10:31 ` Peter Zijlstra
2019-02-14 10:44 ` Alexey Brodkin
2019-02-14 11:08 ` Peter Zijlstra
2019-02-14 12:05 ` Alexey Brodkin
2019-02-14 12:24 ` Peter Zijlstra
2019-02-14 14:14 ` David Laight
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=536eb8d0112b44dc90b9b9a7f670e96d@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=alexey.brodkin@synopsys.com \
--cc=arnd.bergmann@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=vineet.gupta1@synopsys.com \
/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;
as well as URLs for NNTP newsgroup(s).