All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: David Hildenbrand <david@redhat.com>,
	Wei Yang <richard.weiyang@gmail.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm/page_alloc: remove prefetchw() on freeing page to buddy system
Date: Wed, 3 Jul 2024 20:37:02 -0700	[thread overview]
Message-ID: <20240703203702.36ef41282c91fef8a056a63a@linux-foundation.org> (raw)
In-Reply-To: <ZoYXaoJ-vebtEPEy@casper.infradead.org>

On Thu, 4 Jul 2024 04:30:50 +0100 Matthew Wilcox <willy@infradead.org> wrote:

> > 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.

thud.

Are you supportive of v1?

--- a/mm/page_alloc.c~mm-page_alloc-remove-prefetchw-on-freeing-page-to-buddy-system
+++ a/mm/page_alloc.c
@@ -1236,16 +1236,11 @@ void __free_pages_core(struct page *page
 	 */
 	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG) &&
 	    unlikely(context == MEMINIT_HOTPLUG)) {
-		prefetchw(p);
-		for (loop = 0; loop < (nr_pages - 1); loop++, p++) {
-			prefetchw(p + 1);
+		for (loop = 0; loop < nr_pages; loop++, p++) {
 			VM_WARN_ON_ONCE(PageReserved(p));
 			__ClearPageOffline(p);
 			set_page_count(p, 0);
 		}
-		VM_WARN_ON_ONCE(PageReserved(p));
-		__ClearPageOffline(p);
-		set_page_count(p, 0);
 
 		/*
 		 * Freeing the page with debug_pagealloc enabled will try to
@@ -1255,14 +1250,10 @@ void __free_pages_core(struct page *page
 		debug_pagealloc_map_pages(page, nr_pages);
 		adjust_managed_page_count(page, nr_pages);
 	} else {
-		prefetchw(p);
-		for (loop = 0; loop < (nr_pages - 1); loop++, p++) {
-			prefetchw(p + 1);
+		for (loop = 0; loop < nr_pages; loop++, p++) {
 			__ClearPageReserved(p);
 			set_page_count(p, 0);
 		}
-		__ClearPageReserved(p);
-		set_page_count(p, 0);
 
 		/* memblock adjusts totalram_pages() manually. */
 		atomic_long_add(nr_pages, &page_zone(page)->managed_pages);
_



  reply	other threads:[~2024-07-04  3:37 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
2024-07-04  3:37     ` Andrew Morton [this message]
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=20240703203702.36ef41282c91fef8a056a63a@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=richard.weiyang@gmail.com \
    --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 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.