mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last.patch added to -mm tree
@ 2022-01-25  6:22 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2022-01-25  6:22 UTC (permalink / raw)
  To: andreyknvl, mgorman, mm-commits, pcc, peterz


The patch titled
     Subject: mm/mmzone.c: use try_cmpxchg() in page_cpupid_xchg_last()
has been added to the -mm tree.  Its filename is
     mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Peter Collingbourne <pcc@google.com>
Subject: mm/mmzone.c: use try_cmpxchg() in page_cpupid_xchg_last()

This will let us avoid an additional read from page->flags when retrying
the compare-exchange on some architectures.

Link: https://lkml.kernel.org/r/20220120011200.1322836-1-pcc@google.com
Link: https://linux-review.googlesource.com/id/I2e1f5b5b080ac9c4e0eb7f98768dba6fd7821693
Signed-off-by: Peter Collingbourne <pcc@google.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/mmzone.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/mm/mmzone.c~mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last
+++ a/mm/mmzone.c
@@ -89,13 +89,14 @@ int page_cpupid_xchg_last(struct page *p
 	unsigned long old_flags, flags;
 	int last_cpupid;
 
+	old_flags = READ_ONCE(page->flags);
 	do {
-		old_flags = flags = page->flags;
-		last_cpupid = page_cpupid_last(page);
+		flags = old_flags;
+		last_cpupid = (flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK;
 
 		flags &= ~(LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT);
 		flags |= (cpupid & LAST_CPUPID_MASK) << LAST_CPUPID_PGSHIFT;
-	} while (unlikely(cmpxchg(&page->flags, old_flags, flags) != old_flags));
+	} while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags)));
 
 	return last_cpupid;
 }
_

Patches currently in -mm which might be from pcc@google.com are

mm-use-compare-exchange-operation-to-set-kasan-page-tag.patch
mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-25  6:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25  6:22 + mm-mmzonec-use-try_cmpxchg-in-page_cpupid_xchg_last.patch added to -mm tree akpm

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