Thread (59 messages) 59 messages, 6 authors, 2021-01-27

Re: [PATCH v17 11/26] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW

From: Yu, Yu-cheng <hidden>
Date: 2021-01-27 00:20:38
Also in: linux-arch, linux-doc, linux-mm, lkml

On 1/26/2021 1:40 AM, Peter Zijlstra wrote:
On Tue, Jan 26, 2021 at 09:46:36AM +0100, Peter Zijlstra wrote:
quoted
On Mon, Jan 25, 2021 at 07:27:09PM +0100, Borislav Petkov wrote:
quoted
quoted
+		pte_t old_pte, new_pte;
+
+		do {
+			old_pte = READ_ONCE(*ptep);
+			new_pte = pte_wrprotect(old_pte);
Maybe I'm missing something but those two can happen outside of the
loop, no? Or is *ptep somehow changing concurrently while the loop is
doing the CMPXCHG and you need to recreate it each time?

IOW, you can generate upfront and do the empty loop...
quoted
+
+		} while (!try_cmpxchg(&ptep->pte, &old_pte.pte, new_pte.pte));
+
+		return;
+	}
Empty loop would be wrong, but that wants to be written like:

	old_pte = READ_ONCE(*ptep);
	do {
		new_pte = pte_wrprotect(old_pte);
	} while (try_cmpxchg(&ptep->pte, &old_pte.pte, new_pte.pte));
! went missing, too early, moar wake-up juice.
quoted
Since try_cmpxchg() will update old_pte on failure.
Thanks Peter!  I will fix that.

--
Yu-cheng
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help