Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6852248ybi; Mon, 22 Jul 2019 02:49:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyP/9cVfYOFaSnakPCgFvXeE4nXw3ffAcC6JBf85mG60sNLRqht0iLOSOdJS7Tw74iQbzV X-Received: by 2002:a17:90a:d817:: with SMTP id a23mr67966160pjv.54.1563788997170; Mon, 22 Jul 2019 02:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563788997; cv=none; d=google.com; s=arc-20160816; b=CfiaGVPu7LaLa559u5PxbjgXet2lKHJ8YCZFjQ+7G4IFho56nAmS4vFeHCi98Hi0gs eENxbMG1ltq8Uk+oj1Ttr7dQilPwZoKS1xXiEJWOKpOu9dDV/ibx7HNqORbLZjjj52Un mx8z9XVu60syhHyThUnvnRBkHnagloSS0w4oectM20dunRwx1HFbAQrbJ7RldUeHsGkT +Jil0KdgFIUfkpr/IcflwgGH9spByGlns+NzY4oB6GbYXR1CDCVtzoMj/JcTqPGDReUo 0KXtNg6aJUoZWy4z9zvfHs6LyvEDT9hF8c31lpWGfh3kh819akL/1a1m/MOJohSc7bQ6 3T/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CJjf272c4QCg9mLbCqQ0djpoW3m6zPXzbl+Z7jgLL7s=; b=JNedcDRxwrVWbhIIJaaoZtE/FZD5JafJncBVGiJM1yMrURuDZjsrEkzrIey7vuPmd+ D06F8IRpDAOhcxebeki7eh1ui5zp8QAQmQ301XqLvFviYJR0FexaRrrHPaWafL9JrzEW ZlTrPWV3xNXvt9BCE4cKIqCm7+PqY+EwM5l1WgV8OUcbTAxe9SXzgv0mJawPHq7BBRuo 5cCzL9lIvjgb0afJzpayOFVVdnm+wSWTPbFcao8mhzcRsSDCzmk8Cj/yj/cXX9iNzc3j dP95YJ8Zoato/TS46dJMighG/06C1wAR5F1Q8ImZ1AqKmLsPMaW9hdtI1zpqPmUNfmhK WYdQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si10269326pgc.248.2019.07.22.02.49.41; Mon, 22 Jul 2019 02:49:57 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729083AbfGVJiY (ORCPT + 99 others); Mon, 22 Jul 2019 05:38:24 -0400 Received: from verein.lst.de ([213.95.11.211]:58841 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbfGVJiY (ORCPT ); Mon, 22 Jul 2019 05:38:24 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 1925268C4E; Mon, 22 Jul 2019 11:38:23 +0200 (CEST) Date: Mon, 22 Jul 2019 11:38:22 +0200 From: Christoph Hellwig To: Ralph Campbell Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Christoph Hellwig , Dan Williams , Andrew Morton , Jason Gunthorpe , Logan Gunthorpe , Ira Weiny , Matthew Wilcox , Mel Gorman , Jan Kara , "Kirill A. Shutemov" , Michal Hocko , Andrea Arcangeli , Mike Kravetz , =?iso-8859-1?B?Suly9G1l?= Glisse Subject: Re: [PATCH v2 2/3] mm/hmm: fix ZONE_DEVICE anon page mapping reuse Message-ID: <20190722093822.GF29538@lst.de> References: <20190719192955.30462-1-rcampbell@nvidia.com> <20190719192955.30462-3-rcampbell@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190719192955.30462-3-rcampbell@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + /* > + * When a device_private page is freed, the page->mapping field > + * may still contain a (stale) mapping value. For example, the > + * lower bits of page->mapping may still identify the page as > + * an anonymous page. Ultimately, this entire field is just > + * stale and wrong, and it will cause errors if not cleared. > + * One example is: > + * > + * migrate_vma_pages() > + * migrate_vma_insert_page() > + * page_add_new_anon_rmap() > + * __page_set_anon_rmap() > + * ...checks page->mapping, via PageAnon(page) call, > + * and incorrectly concludes that the page is an > + * anonymous page. Therefore, it incorrectly, > + * silently fails to set up the new anon rmap. > + * > + * For other types of ZONE_DEVICE pages, migration is either > + * handled differently or not done at all, so there is no need > + * to clear page->mapping. > + */ > + if (is_device_private_page(page)) > + page->mapping = NULL; > + Thanks, especially for the long comment. Reviewed-by: Christoph Hellwig