[lkml]   [2019]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v8 15/19] locking/rwsem: Adaptive disabling of reader optimistic spinning
On Wed, Jun 05, 2019 at 01:52:15PM -0700, Linus Torvalds wrote:
> On Wed, Jun 5, 2019 at 1:19 PM Peter Zijlstra <> wrote:
> >
> > Urgh, that's another things that's been on the TODO list for a long long
> > time, write code to verify the alignment of allocations :/ I'm
> > suspecting quite a lot of that goes wrong all over the place.
> On x86, we only guarantee 8-byte alignment from things like kmalloc(), iirc.

Oh sure, and I'm not proposing to change that. I was more thinking of
having a GCC plugin that verifies, for every ptr assignment:

ptr = foo;

that the actual alignment maches:

assert(!(uintptr_t)ptr % __alignof(*ptr));

That would catch bugs like:

struct bar {
int ponies;
int peaches __smp_cacheline_aligned;

struct bar *barp = kmalloc(sizeof(barp, GFP_KERNEL);

Blatantly violating alignment can't be right; either the alignment
constraints put on the data structures are not important and they should
be fixed, or we should respect them and fix the allocation, either way,
we should not silently violate things like we do today.

 \ /
  Last update: 2019-06-06 10:04    [W:0.073 / U:5.652 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site