* [merged mm-stable] swapfile-get-rid-of-volatile-and-avoid-redundant-read.patch removed from -mm tree
@ 2023-01-19 1:14 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-01-19 1:14 UTC (permalink / raw)
To: mm-commits, ying.huang, willy, linmiaohe, hughd, david, kasong,
akpm
The quilt patch titled
Subject: swapfile: get rid of volatile and avoid redundant read
has been removed from the -mm tree. Its filename was
swapfile-get-rid-of-volatile-and-avoid-redundant-read.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Kairui Song <kasong@tencent.com>
Subject: swapfile: get rid of volatile and avoid redundant read
Date: Tue, 20 Dec 2022 02:58:37 +0800
Patch series "Clean up and fixes for swap", v2.
This series cleans up some code paths, saves a few cycles and reduces the
object size by a bit. It also fixes some rare race issue with statistics.
This patch (of 4):
Convert a volatile variable to more readable READ_ONCE. And this actually
avoids the code from reading the variable twice redundantly when it races.
Link: https://lkml.kernel.org/r/20221219185840.25441-1-ryncsn@gmail.com
Link: https://lkml.kernel.org/r/20221219185840.25441-2-ryncsn@gmail.com
Signed-off-by: Kairui Song <kasong@tencent.com>
Reviewed-by: "Huang, Ying" <ying.huang@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/swapfile.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--- a/mm/swapfile.c~swapfile-get-rid-of-volatile-and-avoid-redundant-read
+++ a/mm/swapfile.c
@@ -1835,13 +1835,13 @@ static int unuse_pte_range(struct vm_are
pte_t *pte;
struct swap_info_struct *si;
int ret = 0;
- volatile unsigned char *swap_map;
si = swap_info[type];
pte = pte_offset_map(pmd, addr);
do {
struct folio *folio;
unsigned long offset;
+ unsigned char swp_count;
if (!is_swap_pte(*pte))
continue;
@@ -1852,7 +1852,6 @@ static int unuse_pte_range(struct vm_are
offset = swp_offset(entry);
pte_unmap(pte);
- swap_map = &si->swap_map[offset];
folio = swap_cache_get_folio(entry, vma, addr);
if (!folio) {
struct page *page;
@@ -1869,8 +1868,10 @@ static int unuse_pte_range(struct vm_are
folio = page_folio(page);
}
if (!folio) {
- if (*swap_map == 0 || *swap_map == SWAP_MAP_BAD)
+ swp_count = READ_ONCE(si->swap_map[offset]);
+ if (swp_count == 0 || swp_count == SWAP_MAP_BAD)
goto try_next;
+
return -ENOMEM;
}
_
Patches currently in -mm which might be from kasong@tencent.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-19 1:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-19 1:14 [merged mm-stable] swapfile-get-rid-of-volatile-and-avoid-redundant-read.patch removed from -mm tree Andrew Morton
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.