Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp643785ybh; Sun, 12 Jul 2020 18:58:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3vZjeZjK1D8Dt/8OpNZ7DzDYae+wX9dezXlFM5lVveEOo5x9xdxbK2ekjidOk4gZAadjC X-Received: by 2002:a17:906:26d6:: with SMTP id u22mr38093458ejc.271.1594605520162; Sun, 12 Jul 2020 18:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594605520; cv=none; d=google.com; s=arc-20160816; b=lHjo/VibBM2+rglN+BNroxOqsIPWCsYP/js9EjmNWkrBjAB7c2ewr1MJ6XpIzJ7hvC WBTW1c2xpNvq8ufOqLrsVRTmG6UEUyUwNPGKMzoY4wVY9B3mnbLy9LtpFXoh9PbsXFDl HdO7bdniqynE3qv+H0fpHkXVE/Mom2V03nFEfMAut8g8e7NSMvFXC0fjIapfa7sARojS jdCFWvP7dnZV3fniBiPRzKsdEUouTyKPFkq0ETd5QRE2E1e7VoeiAsqrwAQ5ZBJimlKG Y8QfeeQiUM/8qgOExoP4yBAKhqVQoAPWRaabzaJSlsFX1otpvk1PgaeWN4QLipOy/476 mDxA== 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:date:message-id :from:references:cc:to:dkim-signature:subject; bh=lq1LHb61N5CtM6BGA0q7njRLmpJjLmrCSUF3sEBmWtQ=; b=shSOF2scWuZAGMOL8EWqX3QNtuHLRTPB80mQewvdDL7TPQZ3MuNWupOoVhCovXl1Bj kaC2zNrjMcR0qgiKeivvKtjvjb09uyAedaUvuLhfwZQBVp1UziTiC7e7DfI70Fm+ghhe kxvBAJLE0f+xKMd7x6N0r0Fu0xrdBXpkQd0WUTIwEHjlvc1iMk/LWOPimsiY2QGn675t tfAcck055MAG/A/wS+IjspU8Y5K3inDKL1HFItnKWB6uzweJM5xnI38K3q7j1ocMvNJ/ 8oV+IF/JwaVA0m8FtC0qanwDgAay+0msXFp76Y8AQ/6I6HhpakYmY9K6q2HL+CAs/3no h4Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=PlIuW+Kc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si7992401eds.283.2020.07.12.18.58.17; Sun, 12 Jul 2020 18:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=PlIuW+Kc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbgGMB5Z (ORCPT + 99 others); Sun, 12 Jul 2020 21:57:25 -0400 Received: from mail.synology.com ([211.23.38.101]:33456 "EHLO synology.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726261AbgGMB5Z (ORCPT ); Sun, 12 Jul 2020 21:57:25 -0400 Subject: Re: [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1594605443; bh=dMt+4j48OGNWxlYU555z1xu2wQ1GhECOEHBMhx3gXYc=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=PlIuW+KcQCXbqf+KNuT0az7wI1UjNfW25kD3FT1JxChhMBgqDffloSHQ8PGVw/iKS nF8wf6FNSEVt/U6Mq8eNHkttyvN9i/ySllUUdH8WXHrOS+S/QedOAfybYCdXZ9hhLV ZbpTyC4D0r6dYOqwjOYhtYtkESYfK/CcsDlzzDBM= To: Vlastimil Babka , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org References: <20200709024808.18466-1-robbieko@synology.com> <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> From: Robbie Ko Message-ID: <80b55fcf-def1-8a83-8f53-a22f2be56244@synology.com> Date: Mon, 13 Jul 2020 09:57:23 +0800 MIME-Version: 1.0 In-Reply-To: <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 6, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vlastimil Babka 於 2020/7/10 下午11:31 寫道: > On 7/9/20 4:48 AM, robbieko wrote: >> From: Robbie Ko >> >> When a migrate page occurs, we first create a migration entry >> to replace the original pte, and then go to fallback_migrate_page >> to execute a writeout if the migratepage is not supported. >> >> In the writeout, we will clear the dirty bit of the page and use >> page_mkclean to clear the dirty bit along with the corresponding pte, >> but page_mkclean does not support migration entry. >> >> The page ditry bit is cleared, but the dirty bit of the pte still exists, >> so if mmap continues to write, it will result in data loss. > Curious, did you observe this data loss? What filesystem? If yes, it seems > serious enough to > CC stable and determine a Fixes: tag? Yes, there is data loss. I'm using a btrfs environment, but not the following patch btrfs: implement migratepage callback for data pages https://git.kernel.org/pub/scm/linux/kernel /git/torvalds/linux.git/commit/?h=v5.8-rc5& id=f8e6608180a31cc72a23b74969da428da236dbd1 >> We fix the by first remove the migration entry and then clearing >> the dirty bits of the page, which also clears the pte's dirty bits. >> >> Signed-off-by: Robbie Ko >> --- >> mm/migrate.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index f37729673558..5c407434b9ba 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -875,10 +875,6 @@ static int writeout(struct address_space *mapping, struct page *page) >> /* No write method for the address space */ >> return -EINVAL; >> >> - if (!clear_page_dirty_for_io(page)) >> - /* Someone else already triggered a write */ >> - return -EAGAIN; >> - >> /* >> * A dirty page may imply that the underlying filesystem has >> * the page on some queue. So the page must be clean for >> @@ -889,6 +885,10 @@ static int writeout(struct address_space *mapping, struct page *page) >> */ >> remove_migration_ptes(page, page, false); >> >> + if (!clear_page_dirty_for_io(page)) >> + /* Someone else already triggered a write */ >> + return -EAGAIN; >> + >> rc = mapping->a_ops->writepage(page, &wbc); >> >> if (rc != AOP_WRITEPAGE_ACTIVATE) >> >