Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1208282imm; Wed, 11 Jul 2018 20:11:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdUaSNsHkyf3OB5HnWDSN/0XICHuOp0UZodxGh/XhorX552j1IngUtzc4QTXgzYLPtlaLvl X-Received: by 2002:a17:902:2927:: with SMTP id g36-v6mr444082plb.303.1531365067908; Wed, 11 Jul 2018 20:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531365067; cv=none; d=google.com; s=arc-20160816; b=cv/RVnz2NWohJ2y6JH9gIyOlI0f/ULbfwTTpX/PyaP5PhEZrgFr8lUKZmx46hDBvON J9G0EwGeX3ZLe64stNeVNASZMUL2Mcwen6KkRd6XCPN/GVdAqmxu1JVVgYTXlCzpaLK0 mcrLLfwGPp3FoYWmb4fsG6016MsG2lb74KJSTuHxZX4jklb+qPHvUXAKSMlgXhBOvgvY hGWK7r2WuVeCqHdgsZr2X0TCPh8jB03u6wKer0xIn2LjOIqZokK2VBjKoVqKZEciHGvU fU5hn9UMF5W7SlZ6FwMAZYqBg6qukwoPqiDaFrCsPZZErMsiGhn1oJ6XCMhBRraELWPl QzRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=I4Uxzsgx6BguTfJOWbKxmqdeArZ8pGJbyDPsqODVgmE=; b=KwOuBcQvNrAW6VJW7tvQmAwf/DZ/P8xpIKKs0iPUFBCDUuaQUUunfW9UR+yAGzpm9W 695wx6u3nMPyXU85/0y/xCSMnIHSXsqOy9wnJNIv9udlYiu+8q5e6rkfrIV2Qc7lfi50 yk7kwpSSZvh4VFOgelwa8VWYDSKCnA/GlyTCiTKwBAgfr1IephXKvAgkZ8zF8hlS8C+2 uBL50ojhLmZil0L2IyiQaIb8b2Madoh2vfiCIGD2D8ZppZgIVzH933TH13UTB/aiPyCO ljgU/eLyEthiBkMUG1C9tr5FzWmTgq6xXC4gbr2Ac26QM9BqteN51Po7lp5a6hgVb4eQ Nn3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si20277444plt.149.2018.07.11.20.10.52; Wed, 11 Jul 2018 20:11:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390215AbeGLBtG (ORCPT + 99 others); Wed, 11 Jul 2018 21:49:06 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:49866 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387807AbeGLBtG (ORCPT ); Wed, 11 Jul 2018 21:49:06 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0T4SG70u_1531359620; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T4SG70u_1531359620) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 Jul 2018 09:40:23 +0800 Subject: Re: [PATCH] thp: fix data loss when splitting a file pmd To: Hugh Dickins , Andrew Morton Cc: Ashwin Chaugule , "Kirill A. Shutemov" , "Huang, Ying" , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: From: Yang Shi Message-ID: <769d0c1d-120a-9a0b-28e3-477830b4606a@linux.alibaba.com> Date: Wed, 11 Jul 2018 18:40:20 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Fixes: d21b9e57c74c ("thp: handle file pages in split_huge_pmd()") > Reported-by: Ashwin Chaugule > Signed-off-by: Hugh Dickins > Cc: "Kirill A. Shutemov" > Cc: "Huang, Ying" > Cc: Yang Shi > Cc: # 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);