Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4158858ybi; Mon, 29 Jul 2019 20:33:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL9U/xoLM/1q3rvdFdV3RUa5iBRLRN+WT+RK9m2g+mOo9e24u6wha4//Ytk1pAs/PcZ33l X-Received: by 2002:a63:9318:: with SMTP id b24mr96154429pge.31.1564457581675; Mon, 29 Jul 2019 20:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564457581; cv=none; d=google.com; s=arc-20160816; b=FcQo4ctZ9ooZP9EDY9llnEcwBL2yUVCURUKq9xsislm++FgZ9HOENxorOj4O0NoJQa EJoKiskZZxNR9m+h02gSy/Y4DFbHhcESKFi98gCqXJO1W3/QeH1cwHGR6R/5xsmz5HO1 aHJIDDFcpzbZYSd5d0GuazATMxcPW5hDHX+KBreE0j0v1TxnnD4lQwwy6fCg976zZ6Iv UW9R8Mx/KShhCXbL55JVKySBDeJtaXylWot52qHIH/NxH3soyANgu/qRD5w9QaUhc0+u PEbiBY8UrcuEJzUqNeFQShxc+lZpJGYfVtItXGl6dKNRNwUnL+N75c+vzak3Yz5Oix+R kPlw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=5ZWG0QDCxJvv65+JuyyOckXL85oTlI7dOVIPd95tIFw=; b=Hx9YtXKPFVJBGbnVOykNkQE+Lh08z3gUnLjZN85Q08QaTWvIgTEtajmnuWo/rJ/ZdB Wr/CNG+r91N/DgTq97SF0dK7cnHYA7C64HvcuBNq+tlaFnZoqM8YKM38ZDvyTQb8DREi m6FDVBHxUOs5PZtzgoUgqluodjjEqRyDoPBrX6RnwKapPQ9cp0F9umSsy+zGnb6eTyVY MxfC5rQcQt6ZN3eZsWRz5QBlM8ZNNS+NtBmZuYMXwcxaPjHOb13TzNPTFkqA3HzTgC0q aGyNsG+qEiCCnUAHFmmwMbXUDP9KSe7jz6PvLwDRCqrPQVGzHQDUAz4se/pSXrSx+Fwr M9ZQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q206si22108508pgq.483.2019.07.29.20.32.46; Mon, 29 Jul 2019 20:33:01 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729683AbfG2Xaw (ORCPT + 99 others); Mon, 29 Jul 2019 19:30:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46312 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbfG2Xav (ORCPT ); Mon, 29 Jul 2019 19:30:51 -0400 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 72E2E5AFF8; Mon, 29 Jul 2019 23:30:51 +0000 (UTC) Received: from redhat.com (ovpn-112-31.rdu2.redhat.com [10.10.112.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58E1C19C58; Mon, 29 Jul 2019 23:30:48 +0000 (UTC) Date: Mon, 29 Jul 2019 19:30:44 -0400 From: Jerome Glisse To: Christoph Hellwig Cc: Jason Gunthorpe , Ben Skeggs , Ralph Campbell , Bharata B Rao , Andrew Morton , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 9/9] mm: remove the MIGRATE_PFN_WRITE flag Message-ID: <20190729233044.GA7171@redhat.com> References: <20190729142843.22320-1-hch@lst.de> <20190729142843.22320-10-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190729142843.22320-10-hch@lst.de> User-Agent: Mutt/1.12.0 (2019-05-25) 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.39]); Mon, 29 Jul 2019 23:30:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 29, 2019 at 05:28:43PM +0300, Christoph Hellwig wrote: > The MIGRATE_PFN_WRITE is only used locally in migrate_vma_collect_pmd, > where it can be replaced with a simple boolean local variable. > > Signed-off-by: Christoph Hellwig NAK that flag is useful, for instance a anonymous vma might have some of its page read only even if the vma has write permission. It seems that the code in nouveau is wrong (probably lost that in various rebase/rework) as this flag should be use to decide wether to map the device memory with write permission or not. I am traveling right now, i will investigate what happened to nouveau code. Cheers, J?r?me > --- > include/linux/migrate.h | 1 - > mm/migrate.c | 9 +++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/include/linux/migrate.h b/include/linux/migrate.h > index 8b46cfdb1a0e..ba74ef5a7702 100644 > --- a/include/linux/migrate.h > +++ b/include/linux/migrate.h > @@ -165,7 +165,6 @@ static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm, > #define MIGRATE_PFN_VALID (1UL << 0) > #define MIGRATE_PFN_MIGRATE (1UL << 1) > #define MIGRATE_PFN_LOCKED (1UL << 2) > -#define MIGRATE_PFN_WRITE (1UL << 3) > #define MIGRATE_PFN_SHIFT 6 > > static inline struct page *migrate_pfn_to_page(unsigned long mpfn) > diff --git a/mm/migrate.c b/mm/migrate.c > index 74735256e260..724f92dcc31b 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2212,6 +2212,7 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > unsigned long mpfn, pfn; > struct page *page; > swp_entry_t entry; > + bool writable = false; > pte_t pte; > > pte = *ptep; > @@ -2240,7 +2241,7 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > mpfn = migrate_pfn(page_to_pfn(page)) | > MIGRATE_PFN_MIGRATE; > if (is_write_device_private_entry(entry)) > - mpfn |= MIGRATE_PFN_WRITE; > + writable = true; > } else { > if (is_zero_pfn(pfn)) { > mpfn = MIGRATE_PFN_MIGRATE; > @@ -2250,7 +2251,8 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > } > page = vm_normal_page(migrate->vma, addr, pte); > mpfn = migrate_pfn(pfn) | MIGRATE_PFN_MIGRATE; > - mpfn |= pte_write(pte) ? MIGRATE_PFN_WRITE : 0; > + if (pte_write(pte)) > + writable = true; > } > > /* FIXME support THP */ > @@ -2284,8 +2286,7 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > ptep_get_and_clear(mm, addr, ptep); > > /* Setup special migration page table entry */ > - entry = make_migration_entry(page, mpfn & > - MIGRATE_PFN_WRITE); > + entry = make_migration_entry(page, writable); > swp_pte = swp_entry_to_pte(entry); > if (pte_soft_dirty(pte)) > swp_pte = pte_swp_mksoft_dirty(swp_pte); > -- > 2.20.1 >