linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: linux-mm@kvack.org
Cc: Yu Zhao <yuzhao@google.com>
Subject: Next steps towards shrinking stuct page
Date: Wed, 25 Sep 2024 18:39:24 +0100	[thread overview]
Message-ID: <ZvRKzKizOfEWBtJp@casper.infradead.org> (raw)

Yu Zhao asked what useful steps he could take towards shrinking struct
page.  I outlined them in the THP Cabal meeting today, and here's the
"next level" of detail.

As mentioned in https://kernelnewbies.org/MatthewWilcox/Memdescs/Path
we want to get struct page from 64 to 32 bytes, at least for common
configurations.

I'm currently working on getting rid of references to page->index and
page->mapping.  I have some commits that I haven't sent out yet (we're
still in the merge window, after all).  So here are some things other
people could do:

1. KMSAN

Someone needs to figure out if KMSAN is really per-page or
per-allocation.  Do kmsan_shadow and kmsan_origin need to live in
struct page, or do they need to live in each memdesc?  And do we care
about KMSAN overhead for production builds?  (does Android turn it on?)

2. Bump allocator

This chunk needs to be pulled out of struct page:

                struct {        /* page_pool used by netstack */
                        /**
                         * @pp_magic: magic value to avoid recycling non
                         * page_pool allocated pages.
                         */
                        unsigned long pp_magic;
                        struct page_pool *pp;
                        unsigned long _pp_mapping_pad;
                        unsigned long dma_addr;
                        atomic_long_t pp_ref_count;
                };

Similarly to struct slab, it needs to become its own struct.  DavidH
and I talked about it at Plumbers and decided that it needs to be:

struct bump {
	unsigned long _page_flags;
	unsigned long bump_magic;
	struct page_pool *bump_pp;
	unsigned long _page_mapping_pad;
	unsigned long dma_addr;
	atomic_long_t bump_ref_count;
	unsigned int _page_type;
	atomic_t _refcount;
};

Some collaboration with the networking people would be good here, since
they're the primary user today.  In particular Ilias Apalodimas has a
lot of history with this code.

I did some work on this (at the time I called it netmem; the networking
people have subsequently used the name netmem for their own purposes)
https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/

3. Reviewing the zpdesc series

https://lore.kernel.org/lkml/20240902072136.578720-1-alexs@kernel.org/
is the latest version

4. Make sure that we're good with memcg_data.  I think we are (it's only
used in folios and slabs today, I _think_), but it'll be good to be
sure.  Someone who understands memcg better than I do can probably find
some stuff to clean up.

There are probably other things that can be done to move us towards a
shrunken page, but these are the ones which come to mind.  Happy to
elaborate on any points.


             reply	other threads:[~2024-09-25 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 17:39 Matthew Wilcox [this message]
2024-10-08 14:16 ` David Hildenbrand
2024-10-18 10:46   ` Matthew Wilcox
2024-10-18 11:07     ` David Hildenbrand
2024-10-18 12:44       ` Matthew Wilcox

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=ZvRKzKizOfEWBtJp@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=yuzhao@google.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