[PATCH 1/1] mm: Fix struct page layout on 32-bit systems
Jesper Dangaard Brouer
brouer at redhat.com
Wed Apr 14 18:10:44 AEST 2021
On Mon, 12 Apr 2021 02:15:32 +0100
Matthew Wilcox <willy at infradead.org> wrote:
> On Sun, Apr 11, 2021 at 11:33:18AM +0100, Matthew Wilcox wrote:
> > Basically, we have three aligned dwords here. We can either alias with
> > @flags and the first word of @lru, or the second word of @lru and @mapping,
> > or @index and @private. @flags is a non-starter. If we use @mapping,
> > then you have to set it to NULL before you free it, and I'm not sure
> > how easy that will be for you. If that's trivial, then we could use
> > the layout:
> >
> > unsigned long _pp_flags;
> > unsigned long pp_magic;
> > union {
> > dma_addr_t dma_addr; /* might be one or two words */
> > unsigned long _pp_align[2];
> > };
> > unsigned long pp_pfmemalloc;
> > unsigned long xmi;
>
> I forgot about the munmap path. That calls zap_page_range() which calls
> set_page_dirty() which calls page_mapping(). If we use page->mapping,
> that's going to get interpreted as an address_space pointer.
>
> *sigh*. Foiled at every turn.
Yes, indeed! - And very frustrating. It's keeping me up at night.
I'm dreaming about 32 vs 64 bit data structures. My fitbit stats tell
me that I don't sleep well with these kind of dreams ;-)
> I'm kind of inclined towards using two (or more) bits for PageSlab as
> we discussed here:
>
> https://lore.kernel.org/linux-mm/01000163efe179fe-d6270c58-eaba-482f-a6bd-334667250ef7-000000@email.amazonses.com/
>
> so we have PageKAlloc that's true for PageSlab, PagePool, PageDMAPool,
> PageVMalloc, PageFrag and maybe a few other kernel-internal allocations.
I actually like this idea a lot. I also think it will solve or remove
Matteo/Ilias'es[2] need to introduce the pp_magic signature. Ilias do
say[1] that page_pool pages could be used for TCP RX zerocopy, but I
don't think we should "allow" that (meaning page_pool should drop the
DMA-mapping and give up recycling). I should argue why in that thread.
That said, I think we need to have a quicker fix for the immediate
issue with 64-bit bit dma_addr on 32-bit arch and the misalignment hole
it leaves[3] in struct page. In[3] you mention ppc32, does it only
happens on certain 32-bit archs?
I'm seriously considering removing page_pool's support for doing/keeping
DMA-mappings on 32-bit arch's. AFAIK only a single driver use this.
> (see also here:)
> https://lore.kernel.org/linux-mm/20180518194519.3820-18-willy@infradead.org/
[1] https://lore.kernel.org/netdev/YHHuE7g73mZNrMV4@enceladus/
[2] https://patchwork.kernel.org/project/netdevbpf/patch/20210409223801.104657-3-mcroce@linux.microsoft.com/
[3] https://lore.kernel.org/linux-mm/20210410024313.GX2531743@casper.infradead.org/
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
More information about the Linuxppc-dev
mailing list