linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, Kent Overstreet <kent.overstreet@gmail.com>,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	Vlastimil Babka <vbabka@suse.cz>, Michal Hocko <mhocko@suse.com>,
	Roman Gushchin <guro@fb.com>,
	linux-kernel@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 00/11] PageSlab: eliminate unnecessary compound_head() calls
Date: Wed, 13 Oct 2021 15:32:59 -0400	[thread overview]
Message-ID: <YWc0a7zlWAdUSCdT@cmpxchg.org> (raw)
In-Reply-To: <YWcdoktn30ofnsPO@casper.infradead.org>

On Wed, Oct 13, 2021 at 06:55:46PM +0100, Matthew Wilcox wrote:
> On Wed, Oct 13, 2021 at 09:49:31AM -0400, Johannes Weiner wrote:
> > On Wed, Oct 13, 2021 at 04:19:18AM +0100, Matthew Wilcox wrote:
> > > For today, testing PageSlab on the tail page helps the test proceed
> > > in parallel with the action.  Looking at slub's kfree() for an example:
> > > 
> > >         page = virt_to_head_page(x);
> > >         if (unlikely(!PageSlab(page))) {
> > >                 free_nonslab_page(page, object);
> > >                 return;
> > >         }
> > >         slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_);
> > > 
> > > Your proposal is certainly an improvement (since gcc doesn't know
> > > that compound_head(compound_head(x)) == compound_head(x)), but I
> > > think checking on the tail page is even better:
> > > 
> > > 	page = virt_to_page(x);
> > > 	if (unlikely(!PageSlab(page))) {
> > > 		free_nonslab_page(compound_head(page), object);
> > > 		return;
> > > 	}
> > > 	slab = page_slab(page);
> > > 	slab_free(slab->slab_cache, slab, object, NULL, 1, _RET_IP_);
> > > 
> > > The compound_head() parts can proceed in parallel with the check of
> > > PageSlab().
> > >
> > > As far as the cost of setting PageSlab, those cachelines are already
> > > dirty because we set compound_head on each of those pages already
> > > (or in the case of freeing, we're about to clear compound_head on
> > > each of those pages).
> > 
> > ... but this is not. I think the performance gains from this would
> > have to be significant to justify complicating page flags further.
> 
> My argument isn't really "this is more efficient", because I think
> the performance gains are pretty minimal.  More that I would like to
> be able to write code in the style which we'll want to use when we're
> using dynamically allocated memory descriptors.  It's all just code,
> and we can change it at any time, but better to change it to something
> that continues to work well in the future.
> 
> I don't think we end up with "virt_to_head_page()" in a dynamically
> allocated memory descriptor world.  The head page contains no different
> information from the tail pages, and indeed the tail pages don't know
> that they're tail pages, or where the head page is.  Or maybe they're
> all tail pages.

I agree with that, but future-provisioning is a tradeoff.

It'll be trivial to replace virt_to_head_page() with virt_to_page()
and remove compound_head() calls when whatever is left of struct page
will unconditionally point to a memory descriptor. And that can be
part of the changes that make it so.

But in today's codebase, maintaining type flags in the tail pages
while having to go through the headpage to find the type descriptor
makes things unnecessarily complicated in an area that already has
accrued too much tech debt.

I don't think that's a sensible thing to do as of today.

> I could see a world where we had a virt_to_memdesc() which returned
> a generic memory descriptor that could be cast to a struct slab if
> the flags within that memdesc said it was a slab.  But I think it works
> out better to tag the memory descriptor pointer with a discriminator
> that defines what the pointer is.  Plus it saves a page flag.
> 
> Maybe that's the best way to approach it -- how would you want to write
> this part of kfree() when memory descriptors are dynamically allocated?

There are still many question marks on how the split out memory
descriptors actually will look like, and which state is tracked
where. 'struct slab' is an excellent trial balloon.

It's good to have common north stars to set the direction of where to
place efforts ("small struct page, dynamically allocated descriptors
etc.") but I don't think it makes sense to take on yet more tech debt
in this area for a future that may not pan out the way we think now.


  reply	other threads:[~2021-10-13 19:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 18:01 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 [this message]
2021-10-13 19:57             ` Johannes Weiner
2021-10-14  7:35             ` David Hildenbrand
2021-10-25 13:49 ` Vlastimil Babka

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=YWc0a7zlWAdUSCdT@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=guro@fb.com \
    --cc=kent.overstreet@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    /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