* [PATCH] thp: fix data loss when splitting a file pmd
@ 2018-07-12 0:48 Hugh Dickins
2018-07-12 1:40 ` Yang Shi
2018-07-12 13:42 ` Kirill A. Shutemov
0 siblings, 2 replies; 3+ messages in thread
From: Hugh Dickins @ 2018-07-12 0:48 UTC (permalink / raw)
To: Andrew Morton
Cc: Ashwin Chaugule, Kirill A. Shutemov, Huang, Ying, Yang Shi,
linux-kernel, linux-mm
__split_huge_pmd_locked() must check if the cleared huge pmd was dirty,
and propagate that to PageDirty: otherwise, data may be lost when a huge
tmpfs page is modified then split then reclaimed.
How has this taken so long to be noticed? Because there was no problem
when the huge page is written by a write system call (shmem_write_end()
calls set_page_dirty()), nor when the page is allocated for a write fault
(fault_dirty_shared_page() calls set_page_dirty()); but when allocated
for a read fault (which MAP_POPULATE simulates), no set_page_dirty().
Fixes: d21b9e57c74c ("thp: handle file pages in split_huge_pmd()")
Reported-by: Ashwin Chaugule <ashwinch@google.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Cc: <stable@vger.kernel.org> # v4.8+
---
mm/huge_memory.c | 2 ++
1 file changed, 2 insertions(+)
--- 4.18-rc4/mm/huge_memory.c 2018-06-16 18:48:22.029173363 -0700
+++ linux/mm/huge_memory.c 2018-07-10 20:11:29.991011603 -0700
@@ -2084,6 +2084,8 @@ static void __split_huge_pmd_locked(stru
if (vma_is_dax(vma))
return;
page = pmd_page(_pmd);
+ if (!PageDirty(page) && pmd_dirty(_pmd))
+ set_page_dirty(page);
if (!PageReferenced(page) && pmd_young(_pmd))
SetPageReferenced(page);
page_remove_rmap(page, true);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thp: fix data loss when splitting a file pmd
2018-07-12 0:48 [PATCH] thp: fix data loss when splitting a file pmd Hugh Dickins
@ 2018-07-12 1:40 ` Yang Shi
2018-07-12 13:42 ` Kirill A. Shutemov
1 sibling, 0 replies; 3+ messages in thread
From: Yang Shi @ 2018-07-12 1:40 UTC (permalink / raw)
To: Hugh Dickins, Andrew Morton
Cc: Ashwin Chaugule, Kirill A. Shutemov, Huang, Ying, linux-kernel, linux-mm
On 7/11/18 5:48 PM, Hugh Dickins wrote:
> __split_huge_pmd_locked() must check if the cleared huge pmd was dirty,
> and propagate that to PageDirty: otherwise, data may be lost when a huge
> tmpfs page is modified then split then reclaimed.
>
> How has this taken so long to be noticed? Because there was no problem
> when the huge page is written by a write system call (shmem_write_end()
> calls set_page_dirty()), nor when the page is allocated for a write fault
> (fault_dirty_shared_page() calls set_page_dirty()); but when allocated
> for a read fault (which MAP_POPULATE simulates), no set_page_dirty().
Sounds good to me. Reviewed-by: Yang Shi <yang.shi@linux.alibaba.com>
> Fixes: d21b9e57c74c ("thp: handle file pages in split_huge_pmd()")
> Reported-by: Ashwin Chaugule <ashwinch@google.com>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Cc: "Huang, Ying" <ying.huang@intel.com>
> Cc: Yang Shi <yang.shi@linux.alibaba.com>
> Cc: <stable@vger.kernel.org> # v4.8+
> ---
>
> mm/huge_memory.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> --- 4.18-rc4/mm/huge_memory.c 2018-06-16 18:48:22.029173363 -0700
> +++ linux/mm/huge_memory.c 2018-07-10 20:11:29.991011603 -0700
> @@ -2084,6 +2084,8 @@ static void __split_huge_pmd_locked(stru
> if (vma_is_dax(vma))
> return;
> page = pmd_page(_pmd);
> + if (!PageDirty(page) && pmd_dirty(_pmd))
> + set_page_dirty(page);
> if (!PageReferenced(page) && pmd_young(_pmd))
> SetPageReferenced(page);
> page_remove_rmap(page, true);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thp: fix data loss when splitting a file pmd
2018-07-12 0:48 [PATCH] thp: fix data loss when splitting a file pmd Hugh Dickins
2018-07-12 1:40 ` Yang Shi
@ 2018-07-12 13:42 ` Kirill A. Shutemov
1 sibling, 0 replies; 3+ messages in thread
From: Kirill A. Shutemov @ 2018-07-12 13:42 UTC (permalink / raw)
To: Hugh Dickins
Cc: Andrew Morton, Ashwin Chaugule, Huang, Ying, Yang Shi,
linux-kernel, linux-mm
On Thu, Jul 12, 2018 at 12:48:54AM +0000, Hugh Dickins wrote:
> __split_huge_pmd_locked() must check if the cleared huge pmd was dirty,
> and propagate that to PageDirty: otherwise, data may be lost when a huge
> tmpfs page is modified then split then reclaimed.
>
> How has this taken so long to be noticed? Because there was no problem
> when the huge page is written by a write system call (shmem_write_end()
> calls set_page_dirty()), nor when the page is allocated for a write fault
> (fault_dirty_shared_page() calls set_page_dirty()); but when allocated
> for a read fault (which MAP_POPULATE simulates), no set_page_dirty().
Yeah... Sorry.
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-12 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 0:48 [PATCH] thp: fix data loss when splitting a file pmd Hugh Dickins
2018-07-12 1:40 ` Yang Shi
2018-07-12 13:42 ` Kirill A. Shutemov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).