[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201008092627.399131-1-aneesh.kumar@linux.ibm.com>
Date: Thu, 8 Oct 2020 14:56:27 +0530
From: "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
To: linuxppc-dev@...ts.ozlabs.org, mpe@...erman.id.au
Cc: npiggin@...il.com, "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
Peter Xu <peterx@...hat.com>, Jason Gunthorpe <jgg@...pe.ca>,
John Hubbard <jhubbard@...dia.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Jan Kara <jack@...e.cz>, Michal Hocko <mhocko@...e.com>,
Kirill Shutemov <kirill@...temov.name>,
Hugh Dickins <hughd@...gle.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: [RFC PATCH] mm: Fetch the dirty bit before we reset the pte
In copy_present_page, after we mark the pte non-writable, we should
check for previous dirty bit updates and make sure we don't lose the dirty
bit on reset.
Also, avoid marking the pte write-protected again if copy_present_page
already marked it write-protected.
Cc: Peter Xu <peterx@...hat.com>
Cc: Jason Gunthorpe <jgg@...pe.ca>
Cc: John Hubbard <jhubbard@...dia.com>
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jan Kara <jack@...e.cz>
Cc: Michal Hocko <mhocko@...e.com>
Cc: Kirill Shutemov <kirill@...temov.name>
Cc: Hugh Dickins <hughd@...gle.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@...ux.ibm.com>
---
mm/memory.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/mm/memory.c b/mm/memory.c
index bfe202ef6244..f57b1f04d50a 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -848,6 +848,9 @@ copy_present_page(struct mm_struct *dst_mm, struct mm_struct *src_mm,
if (likely(!page_maybe_dma_pinned(page)))
return 1;
+ if (pte_dirty(*src_pte))
+ pte = pte_mkdirty(pte);
+
/*
* Uhhuh. It looks like the page might be a pinned page,
* and we actually need to copy it. Now we can set the
@@ -904,6 +907,11 @@ copy_present_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
if (retval <= 0)
return retval;
+ /*
+ * Fetch the src pte value again, copy_present_page
+ * could modify it.
+ */
+ pte = *src_pte;
get_page(page);
page_dup_rmap(page, false);
rss[mm_counter(page)]++;
--
2.26.2
Powered by blists - more mailing lists