linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: David Hildenbrand <david@redhat.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm/page_alloc: remove prefetchw() on freeing page to buddy system
Date: Thu, 4 Jul 2024 04:30:50 +0100	[thread overview]
Message-ID: <ZoYXaoJ-vebtEPEy@casper.infradead.org> (raw)
In-Reply-To: <fdfc990b-0191-49c8-9d12-9f44ad5444d6@redhat.com>

On Tue, Jul 02, 2024 at 08:57:57AM +0200, David Hildenbrand wrote:
> > I did 10 round bootup tests before and after this change, the data
> > doesn't prove prefetchw() help speeding up bootmem freeing. The sum of
> > the 10 round bootmem freeing time after prefetchw() removal even 5.2%
> > faster than before.
> 
> I suspect this is noise, though.

I think it's real, though small.  Each prefetchw() is an instruction,
and if we can avoid issuing an instruction, we should.

> Something like:
> 
> for (;;) {
> 	...
> 	if (++loop >= nr_pages)
> 		break;
> 	p++;
> }
> 
> 
> Might generate slightly better code, because we know that we execute the
> loop body at least once. We use that in set_ptes(), for example.

I don't think it's worth doing.  Keep the loop simple and obvious.
set_ptes() is different because we actually expect to execute the loop
exactly once (ie most folios are small).  So two compares per call to
set_ptes() instead of one makes a difference.  Here, we're expecting
to execute this loop, what, a million times?  Doing a million-and-one
compares instead of a million makes no observable difference.

I would like to see v2 of this patch dropped, please Andrew.


  parent reply	other threads:[~2024-07-04  3:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02  2:09 [PATCH] mm/page_alloc: remove prefetchw() on freeing page to buddy system Wei Yang
2024-07-02  6:22 ` Andrew Morton
2024-07-03  0:01   ` Wei Yang
2024-07-03  0:49     ` Andrew Morton
2024-07-03  0:55       ` Wei Yang
2024-07-02  6:57 ` David Hildenbrand
2024-07-03  0:12   ` Wei Yang
2024-07-03  8:40     ` David Hildenbrand
2024-07-04  3:30   ` Matthew Wilcox [this message]
2024-07-04  3:37     ` Andrew Morton
2024-07-04  3:39       ` Matthew Wilcox
2024-07-04  3:43         ` Andrew Morton

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=ZoYXaoJ-vebtEPEy@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=richard.weiyang@gmail.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;
as well as URLs for NNTP newsgroup(s).