[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180904075510.22338-1-peterx@redhat.com>
Date: Tue, 4 Sep 2018 15:55:10 +0800
From: Peter Xu <peterx@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: peterx@...hat.com, Andrea Arcangeli <aarcange@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Michal Hocko <mhocko@...e.com>, Zi Yan <zi.yan@...rutgers.edu>,
Huang Ying <ying.huang@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Naoya Horiguchi <n-horiguchi@...jp.nec.com>,
Jérôme Glisse <jglisse@...hat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
Souptick Joarder <jrdr.linux@...il.com>, linux-mm@...ck.org
Subject: [PATCH] mm: hugepage: mark splitted page dirty when needed
When splitting a huge page, we should set all small pages as dirty if
the original huge page has the dirty bit set before. Otherwise we'll
lose the original dirty bit.
CC: Andrea Arcangeli <aarcange@...hat.com>
CC: Andrew Morton <akpm@...ux-foundation.org>
CC: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
CC: Michal Hocko <mhocko@...e.com>
CC: Zi Yan <zi.yan@...rutgers.edu>
CC: Huang Ying <ying.huang@...el.com>
CC: Dan Williams <dan.j.williams@...el.com>
CC: Naoya Horiguchi <n-horiguchi@...jp.nec.com>
CC: "Jérôme Glisse" <jglisse@...hat.com>
CC: "Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
CC: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
CC: Souptick Joarder <jrdr.linux@...il.com>
CC: linux-mm@...ck.org
CC: linux-kernel@...r.kernel.org
Signed-off-by: Peter Xu <peterx@...hat.com>
---
To the reviewers: I'm new to the mm world so sorry if this patch is
making silly mistakes, however it did solve a problem for me when
testing with a customized Linux tree mostly based on Andrea's userfault
write-protect work. Without the change, my customized QEMU/tcg tree
will not be able to do correct UFFDIO_WRITEPROTECT and then QEMU will
get a SIGBUS when faulting multiple times. With the change (or of
course disabling THP) then UFFDIO_WRITEPROTECT will be able to correctly
resolve the write protections then it runs well. Any comment would be
welcomed. TIA.
---
mm/huge_memory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index c3bc7e9c9a2a..0754a16923d5 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2176,6 +2176,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
entry = pte_mkold(entry);
if (soft_dirty)
entry = pte_mksoft_dirty(entry);
+ if (dirty)
+ entry = pte_mkdirty(entry);
}
pte = pte_offset_map(&_pmd, addr);
BUG_ON(!pte_none(*pte));
--
2.17.1
Powered by blists - more mailing lists