Re: [PATCH 4.4 03/16] devres: Align data[] to ARCH_KMALLOC_MINALIGN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi David,

On Wed, May 13, 2020 at 2:37 PM David Laight <David.Laight@xxxxxxxxxx> wrote:
> From: Geert Uytterhoeven
> > On Wed, May 13, 2020 at 1:05 PM Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> > > On Wed, May 13, 2020 at 12:10 PM David Laight <David.Laight@xxxxxxxxxx> wrote:
> > > > From: Geert Uytterhoeven
> > > > > Sent: 13 May 2020 10:49
> > > > ...
> > > > > > I don't want to apply this to older kernels as it could cause extra
> > > > > > memory usage for no good reason.  I have no idea why a non ARC system
> > > > > > would want it :(
> > > > >
> > > > > I think the reference to ARC is a red herring.
> > > > > The real issue is that buffers used for DMA may not have the required
> > > > > alignment, which is not limited to ARC systems.
> > > > >
> > > > > Note that I'm also not super happy with the extra memory usage.
> > > > > But devm_*() conveniences come with their penalties...
> > > >
> > > > Interesting thought.
> > > > Could the devm 'header' be put right at the end of the kmalloc()
> > > > buffer?
> > > >
> > > > Then the driver would be given aligned address.
> > >
> > > Yes, if the header is extended to contain the real start address of the
> > > allocated block.
> >
> > But that would break explicit freeing through devm_kfree(), as that is
> > passed a pointer to the payload, not the header.
>
> There is a function that gives the full size of memory that kmalloc()
> returns.
> That can be used to find the end and hence the header.

Do you know the name of the function?

> I don't think you can find the base/size from an address within the
> buffer - so a length and/or pointer is needed to find the start.

If that's really possible, then we can finally fix this in a more
ememory-efficient
way.

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux