Re: [GIT PULL] Driver core fix for 4.20-rc5

From: Linus Torvalds
Date: Fri Nov 30 2018 - 15:41:25 EST


On Fri, Nov 30, 2018 at 8:06 AM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> It resolves an issue with the data alignment in 'struct devres' for the
> ARC platform. The full details are in the commit changelog, but the
> short summary is the change is a single line:
>
> - unsigned long long data[]; /* guarantee ull alignment */
> + u8 __aligned(ARCH_KMALLOC_MINALIGN) data[];

Hmm.

Are you aware that this is up to 128 bytes? Including on common
architectures like ARM64?

I've done the pull, but honestly, that seems a bit excessive, when a
fair amount of devres users seem to have fairly small data (ie looking
at "size", I see things like

p = devres_alloc(dmam_device_release, sizeof(void *), GFP_KERNEL);

or

dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);

that have allocations of a couple of bytes, and the new model means
that those allocations will be aligned to 128-byte boundaries, and
then (because ARCH_KMALLOC_MINALIGN, again) you'll end up actually
wasting 256 bytes for a tiny structure on ARM64.

Maybe it doesn't matter. But it does seem somewhat excessive to do
things like this.

Yeah, on x86, the alignment isn't even noticeable, being just 8 bytes.

Linus