From patchwork Thu Dec 6 08:46:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 10715437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ECCD13BB for ; Thu, 6 Dec 2018 08:46:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D70B2D656 for ; Thu, 6 Dec 2018 08:46:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E3BA2D6E3; Thu, 6 Dec 2018 08:46:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5571A2D6CB for ; Thu, 6 Dec 2018 08:46:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7712F6B790E; Thu, 6 Dec 2018 03:46:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6F6786B790F; Thu, 6 Dec 2018 03:46:14 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E54E6B7910; Thu, 6 Dec 2018 03:46:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 30CBE6B790E for ; Thu, 6 Dec 2018 03:46:14 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id u20so23321574qtk.6 for ; Thu, 06 Dec 2018 00:46:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=pecwlcL4xJ5IzDWz7thSqGUmhul0BjUTsqgYs+FUzvg=; b=GQ6r3DkfwgQefIfKHi44aw1IEZzEofU7Gwm+8P0XhmE5D0iOFUv5ioIievWPdgqzF+ Cd3m17oGHur/1ZL/N1HIgleSNbrcyoQr/bXujSmLHfN7PrOAvxHTni3DHr68bKX/XTOv m2LplUl7D1L0CeUXOMbWg46R16k9eEnIWswgIFm11VX7+SJHPAcjm7E1V1xjcMDmwjr9 yZGzdWHAtoLZxPX4aKFV/Hw4C/JkjjP/B61YsJtjCJ3qZix548ccDdNFOCGmiUTVgwDm YSuFHuqRB+ID9b8JiVEuoKTdFpWDJh54sCpY7/srPrI3SYE3PAMHHHhQ5DdZLtw+d3bo ilwA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AA+aEWY7RceQT5cHtmeGObUPKHb+sog5dwfgljbwWS/YLuZZ0Ejb6vai gdY6NGqeNIw8XPugfQVBgZtlpQRt+/s3ij2zUeI6MGYK6mW63WR8Kz/YoCma93dJODyVJFefJXg g0RjTUqIFNR1WzJHE2sJ420Ud4k87SjEenrRjyI5CVU/pOjfhJxeprthKWXeSrfQcwA== X-Received: by 2002:ac8:1:: with SMTP id a1mr26363248qtg.366.1544085973956; Thu, 06 Dec 2018 00:46:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/UQXcfbgdFwmcRjYIDuwv9IdgIn7HQ47xEtKwmgbOTjsTitc5WdMcR0KBrrYCGPmFhLU1WA X-Received: by 2002:ac8:1:: with SMTP id a1mr26363233qtg.366.1544085973474; Thu, 06 Dec 2018 00:46:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544085973; cv=none; d=google.com; s=arc-20160816; b=d7/f6Td86Qzwf4lCQnOlzj9IimWQb29D5AC3AlgP58gXhzTGrvUUybGXgB8nlzrE6f o7FjZT2jYaf/YVwNEteyuCM/CKXbPQYHKhjniwEZTZkTWlP+VII7B07MjwlQVE+67DAd J2QoOvVmEypnigHfLRKjHPs/1wZ/Jg8vV92183RWeXGQxsSOxfFyuZKbTwBFmQOP6s/h BxmgwLogw25qnmcWL2RbOEmx03K+A/5xn2iCSJoeOrkAcfRaHNenmtQTZpP11+PlvELL S4yCdRC7VomN6r1AJH2lSHpJZcPIcp4ulRIyQIOS15qt9/e7kSjcpmdnRxoLMdnZDJuU WSYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=pecwlcL4xJ5IzDWz7thSqGUmhul0BjUTsqgYs+FUzvg=; b=GUT5SPi9B+C3tjfx5x7MA90coB7ZJbF0xyF+XObZvd5KovyhHDWJpx8oB7SZ6EJL9r gvP5RDUCi+5o8t7HaXBAbU+aLlIIytlAe6RSkDZ5dOKpg80AI0KnBrit5MjW3aqpQ9cy Jpv4HxD2o4HZjapIyo/3e2FfT8zf3TYPdX1MyjFMvtkloUkp43mRFKqaHf/s7/R4C8dd VqvWGhfxeP0f9PPJ4xPe7Lpo3NeQhXkd6lhwAwSuB6MeEn1zYqw/Dv+W9Py+fPqc3aJa l8vmfglI2AHJqlGNPlExX3fZkBzKepHAZiZGNevvfWA18rRYarO4olmS5qO7eB6LFeIO STgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v17si66868qvi.56.2018.12.06.00.46.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 00:46:13 -0800 (PST) Received-SPF: pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A1E630013B2; Thu, 6 Dec 2018 08:46:12 +0000 (UTC) Received: from xz-x1.nay.redhat.com (dhcp-14-116.nay.redhat.com [10.66.14.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2172D19C7B; Thu, 6 Dec 2018 08:46:05 +0000 (UTC) From: Peter Xu To: linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Andrea Arcangeli , Andrew Morton , "Kirill A. Shutemov" , Matthew Wilcox , Michal Hocko , Dave Jiang , "Aneesh Kumar K.V" , Souptick Joarder , Konstantin Khlebnikov , linux-mm@kvack.org Subject: [PATCH] mm: thp: fix soft dirty for migration when split Date: Thu, 6 Dec 2018 16:46:04 +0800 Message-Id: <20181206084604.17167-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 06 Dec 2018 08:46:12 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When splitting a huge migrating PMD, we'll transfer the soft dirty bit from the huge page to the small pages. However we're possibly using a wrong data since when fetching the bit we're using pmd_soft_dirty() upon a migration entry. Fix it up. CC: Andrea Arcangeli CC: Andrew Morton CC: "Kirill A. Shutemov" CC: Matthew Wilcox CC: Michal Hocko CC: Dave Jiang CC: "Aneesh Kumar K.V" CC: Souptick Joarder CC: Konstantin Khlebnikov CC: linux-mm@kvack.org CC: linux-kernel@vger.kernel.org Signed-off-by: Peter Xu --- I noticed this during code reading. Only compile tested. I'm sending a patch directly for review comments since it's relatively straightforward and not easy to test. Please have a look, thanks. --- mm/huge_memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f2d19e4fe854..fb0787c3dd3b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2161,7 +2161,10 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, SetPageDirty(page); write = pmd_write(old_pmd); young = pmd_young(old_pmd); - soft_dirty = pmd_soft_dirty(old_pmd); + if (unlikely(pmd_migration)) + soft_dirty = pmd_swp_soft_dirty(old_pmd); + else + soft_dirty = pmd_soft_dirty(old_pmd); /* * Withdraw the table only after we mark the pmd entry invalid.