All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] PageSlab: eliminate unnecessary compound_head() calls
@ 2021-10-12 18:01 Johannes Weiner
  2021-10-12 18:01 ` [PATCH 01/11] PageSlab: bubble compound_head() into callsites Johannes Weiner
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Johannes Weiner @ 2021-10-12 18:01 UTC (permalink / raw)
  To: linux-mm
  Cc: Matthew Wilcox, Kent Overstreet, Kirill A. Shutemov,
	Vlastimil Babka, Michal Hocko, Roman Gushchin, linux-kernel,
	kernel-team

PageSlab() currently imposes a compound_head() call on all callsites
even though only very few situations encounter tailpages. This short
series bubbles tailpage resolution up to the few sites that need it,
and eliminates it everywhere else.

This is a stand-alone improvement. However, it's inspired by Willy's
patches to split struct slab from struct page. Those patches currently
resolve a slab object pointer to its struct slab as follows:

	slab = virt_to_slab(p);		/* tailpage resolution */
	if (slab_test_cache(slab)) {	/* slab or page alloc bypass? */
		do_slab_stuff(slab);
	} else {
		page = (struct page *)slab;
		do_page_stuff(page);
	}

which makes struct slab an ambiguous type that needs to self-identify
with the slab_test_cache() test (which in turn relies on PG_slab in
the flags field shared between page and slab).

It would be preferable to do:

	page = virt_to_head_page(p);	/* tailpage resolution */
	if (PageSlab(page)) {		/* slab or page alloc bypass? */
		slab = page_slab(page);
		do_slab_stuff(slab);
	} else {
		do_page_stuff(page);
	}

and leave the ambiguity and the need to self-identify with struct
page, so that struct slab is a strong and unambiguous type, and a
non-NULL struct slab encountered in the wild is always a valid object
without the need to check another dedicated flag for validity first.

However, because PageSlab() currently implies tailpage resolution,
writing the virt->slab lookup in the preferred way would add yet more
unnecessary compound_head() call to the hottest MM paths.

The page flag helpers should eventually all be weaned off of those
compound_head() calls for their unnecessary overhead alone. But this
one in particular is now getting in the way of writing code in the
preferred manner, and bleeding page ambiguity into the new types that
are supposed to eliminate specifically that. It's ripe for a cleanup.

Based on v5.15-rc4.

 arch/ia64/kernel/mca_drv.c |  2 +-
 drivers/ata/libata-sff.c   |  2 +-
 fs/proc/page.c             | 12 +++++++-----
 include/linux/net.h        |  2 +-
 include/linux/page-flags.h | 10 +++++-----
 mm/kasan/generic.c         |  2 +-
 mm/kasan/kasan.h           |  2 +-
 mm/kasan/report.c          |  4 ++--
 mm/kasan/report_tags.c     |  2 +-
 mm/memory-failure.c        |  6 +++---
 mm/memory.c                |  3 ++-
 mm/slab.h                  |  2 +-
 mm/slob.c                  |  4 ++--
 mm/slub.c                  |  6 +++---
 mm/util.c                  |  2 +-
 15 files changed, 32 insertions(+), 29 deletions(-)



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-10-25 13:49 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 18:01 [PATCH 00/11] PageSlab: eliminate unnecessary compound_head() calls Johannes Weiner
2021-10-12 18:01 ` [PATCH 01/11] PageSlab: bubble compound_head() into callsites Johannes Weiner
2021-10-12 18:01 ` [PATCH 02/11] PageSlab: eliminate unnecessary compound_head() calls in fs/proc/page Johannes Weiner
2021-10-12 18:01 ` [PATCH 03/11] PageSlab: eliminate unnecessary compound_head() calls in kernel/resource Johannes Weiner
2021-10-12 18:01 ` [PATCH 04/11] PageSlab: eliminate unnecessary compound_head() calls in mm/debug Johannes Weiner
2021-10-12 18:01 ` [PATCH 05/11] PageSlab: eliminate unnecessary compound_head() calls in mm/kasan Johannes Weiner
2021-10-12 18:01 ` [PATCH 06/11] PageSlab: eliminate unnecessary compound_head() call in mm/nommu Johannes Weiner
2021-10-12 18:01 ` [PATCH 07/11] PageSlab: eliminate unnecessary compound_head() call in mm/slab Johannes Weiner
2021-10-12 18:01 ` [PATCH 08/11] PageSlab: eliminate unnecessary compound_head() calls in mm/slab_common Johannes Weiner
2021-10-12 18:01 ` [PATCH 09/11] PageSlab: eliminate unnecessary compound_head() calls in mm/slub Johannes Weiner
2021-10-12 18:01 ` [PATCH 10/11] PageSlab: eliminate unnecessary compound_head() call in mm/usercopy Johannes Weiner
2021-10-12 18:01 ` [PATCH 11/11] PageSlab: eliminate unnecessary compound_head() calls in mm/memcontrol Johannes Weiner
2021-10-12 19:23 ` [PATCH 00/11] PageSlab: eliminate unnecessary compound_head() calls Matthew Wilcox
2021-10-12 20:30   ` Johannes Weiner
2021-10-13  3:19     ` Matthew Wilcox
2021-10-13 13:49       ` Johannes Weiner
2021-10-13 17:55         ` Matthew Wilcox
2021-10-13 19:32           ` Johannes Weiner
2021-10-13 19:57             ` Johannes Weiner
2021-10-14  7:35             ` David Hildenbrand
2021-10-25 13:49 ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.