[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210522150900.39d6832a03c5f772911c5b6d@linux-foundation.org>
Date: Sat, 22 May 2021 15:09:00 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Naoya Horiguchi <nao.horiguchi@...il.com>
Cc: linux-mm@...ck.org, Tony Luck <tony.luck@...el.com>,
Aili Yao <yaoaili@...gsoft.com>,
Oscar Salvador <osalvador@...e.de>,
David Hildenbrand <david@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Andy Lutomirski <luto@...nel.org>,
Naoya Horiguchi <naoya.horiguchi@....com>,
Jue Wang <juew@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 1/3] mm/memory-failure: Use a mutex to avoid
memory_failure() races
On Fri, 21 May 2021 12:01:54 +0900 Naoya Horiguchi <nao.horiguchi@...il.com> wrote:
> There can be races when multiple CPUs consume poison from the same
> page. The first into memory_failure() atomically sets the HWPoison
> page flag and begins hunting for tasks that map this page. Eventually
> it invalidates those mappings and may send a SIGBUS to the affected
> tasks.
>
> But while all that work is going on, other CPUs see a "success"
> return code from memory_failure() and so they believe the error
> has been handled and continue executing.
>
> Fix by wrapping most of the internal parts of memory_failure() in
> a mutex.
We can reduce the scope of that mutex, which helps readability at least.
--- a/mm/memory-failure.c~mm-memory-failure-use-a-mutex-to-avoid-memory_failure-races-fix
+++ a/mm/memory-failure.c
@@ -1397,8 +1397,6 @@ out:
return rc;
}
-static DEFINE_MUTEX(mf_mutex);
-
/**
* memory_failure - Handle memory failure of a page.
* @pfn: Page Number of the corrupted page
@@ -1425,6 +1423,7 @@ int memory_failure(unsigned long pfn, in
int res = 0;
unsigned long page_flags;
bool retry = true;
+ static DEFINE_MUTEX(mf_mutex);
if (!sysctl_memory_failure_recovery)
panic("Memory failure on page %lx", pfn);
_
Powered by blists - more mailing lists