Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1275595ybv; Thu, 20 Feb 2020 16:56:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxZDogermq01qLoIwghANo7AC7f/KR3Jw4XgqQhdCAp/+tWYAwbxJob1tKstt74RWLUv9s+ X-Received: by 2002:aca:1204:: with SMTP id 4mr4280718ois.143.1582246568395; Thu, 20 Feb 2020 16:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582246568; cv=none; d=google.com; s=arc-20160816; b=ZmmjytzoqXRuHtvq+m1DDeAtjCFATSbBPZ8JyQW6zPEuutPBcpITVWSJmVgtRD2jCL X6dMSAyABYIWvV4XrxvGxj1yQsKfhZvExBPa4Xm6EEHug75/UfnXd8iwwagAttCQPeXj GutfBpXpjKGg6YIzP8OsPONw0bTU1q5yJXJJ3+uuZaku1gmJVb7AfSldKlopzg1xlowE mdUYVMGv7Ify2DZgCd231/BNV5A7dak3nwcsf+DSfw38olICsGTnKV+5iy4YFLBhqt2d T4X2LP5dEafBbZr1YZ5hp9EByiBAHQ+pIa0V8EqylPlaB28zmgJRIQBAoU35ffrGJVlG dEmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=N4tTk/ksnNBVrz/1Dt1Imz4nbDDrFNDl2abhjxcXdMc=; b=XStZD6ZjnN95ctA/wKNcgQRqfrbzSkRt+wFB9K+doB1KuEXM5L/FkIJIy/IGpsdVuo XpJkXvVZC+2M9m0I/oKTX/3aG9l4ahCQQX6koR5lN8ZIm1DcLSIjzmmio4YKgIUUZVZM iyAZJ9P/h3WdIAekrj1XfOsUBJ93FW93FGaqw0hdkQPD+xR7tkbBw1jqVCoz7uTFN3kp LFvmLGPClQ3yAArOWVqM09iYUKMNiGLYq6a9HjTREXhMxbsUCMW7Iyq5/1qykaqTzqJl 5U4qaPUApqBpmtZXRBHSdkVH0G2XpScVzC4n+g9hfC8yoQOeXVaPeW5VJdJMSb+tPOnG AtXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dgccy3Rk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si483679oic.188.2020.02.20.16.55.50; Thu, 20 Feb 2020 16:56:08 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Dgccy3Rk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbgBUAzl (ORCPT + 99 others); Thu, 20 Feb 2020 19:55:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:50040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729365AbgBUAzk (ORCPT ); Thu, 20 Feb 2020 19:55:40 -0500 Received: from X1 (nat-ab2241.sltdut.senawave.net [162.218.216.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE1D1206EF; Fri, 21 Feb 2020 00:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582246540; bh=vAQyARVfu9oqOzLyqVmfAikW+oYvYjWILRZBPPE0B5Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dgccy3Rk/igP1hU3ILpjD5ruzaCS2eOXdWNPdQfYu+xig2CcOl9CHRGvorw3NkwTp Gsq9FRE1D0iWE2sJ7Csk4Yc45w8KIV27VNU2m5cajIvERIpfOpZLMlz0NaTsNejmUf DUDNXapGVQnks4mRAWFYn8I9tn3sNzHYdYN2WX5A= Date: Thu, 20 Feb 2020 16:55:39 -0800 From: Andrew Morton To: "Huang, Ying" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , "Kirill A . Shutemov" , Andrea Arcangeli , Michal Hocko , Vlastimil Babka Subject: Re: [PATCH] mm: Fix possible PMD dirty bit lost in set_pmd_migration_entry() Message-Id: <20200220165539.5082db4b3e97eee474b0dd5d@linux-foundation.org> In-Reply-To: <20200220075220.2327056-1-ying.huang@intel.com> References: <20200220075220.2327056-1-ying.huang@intel.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 20 Feb 2020 15:52:20 +0800 "Huang, Ying" wrote: > From: Huang Ying > > In set_pmd_migration_entry(), pmdp_invalidate() is used to change PMD > atomically. But the PMD is read before that with an ordinary memory > reading. If the THP (transparent huge page) is written between the > PMD reading and pmdp_invalidate(), the PMD dirty bit may be lost, and > cause data corruption. The race window is quite small, but still > possible in theory, so need to be fixed. > > The race is fixed via using the return value of pmdp_invalidate() to > get the original content of PMD, which is a read/modify/write atomic > operation. So no THP writing can occur in between. > > The race has been introduced when the THP migration support is added > in the commit 616b8371539a ("mm: thp: enable thp migration in generic > path"). But this fix depends on the commit d52605d7cb30 ("mm: do not > lose dirty and accessed bits in pmdp_invalidate()"). So it's easy to > be backported after v4.16. But the race window is really small, so it > may be fine not to backport the fix at all. Thanks. I'm inclined to add a cc:stable to this one. Silent data corruption is pretty serious.