Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp95486ybl; Thu, 15 Aug 2019 13:21:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzb3/SoZH2vhZiBx2rT7GnKUyUFC7kPRj+xESMnSjuMs/akEaZC4N66DDnIiGI7MlFITtMK X-Received: by 2002:a63:df06:: with SMTP id u6mr4678902pgg.96.1565900500575; Thu, 15 Aug 2019 13:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565900500; cv=none; d=google.com; s=arc-20160816; b=g/VDmv0cCWz3qzZlGZC7WmZxMhzm7xCLo4ZV1jZ+0b6mQGNzFdgQ1NNFGMzrRn7Zb6 NKSN2fH7e0JPilOuNeTH81wd3RJJaRWdO/5gCqy8ljtT+jKcFQ88SJQRsYKJyRxRcdin dZxnTvmY2/GYSYBooC7jIUgY3RQ4dTLVYluoXhjktLlPCkdovfeYpguAfHm6f8+TxEYY 4mKlXbOSJQd0xjE/uN5Rkj1eekZxvRyXE/QpEW+rqFMYloKRMDczXXrGulAa+/xuidY6 uWiGBFJR+9PgBZt/XvH3L/8yV6ln8TrwtqQ086zlBnJ6sL1OxT2C+L/vw2HL79gKpwsb 2nug== 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=Uql+PmEEYImT0xJ+oH4OUjHNsK+mhpdyYYiFllXcoeI=; b=bLd9QQHEr8qHXZp4o97IsuK4B5SrmcAOCZTL9jZHtpXFKAiDCdbDdlhSnv4/3Zc2zG T1V3Pczst5bZ7voG9aES+iiXyO8Pf35YuOexS8RUbBr1cmvrp8thKtBMA7W/+Rz7chNh 9j9VqH3kMv4Prkl8moEEiN/FkPgFc2JxEJ78s/m82+AV3XyTTKWKpWb0XC3FcP6i7Cx+ zj31XE7/AvKJhCoO0aiRyylEIrdb5LEL1RrxV4i/jnlXAqPZ2q49OkiV8wod+GSfOuZZ OR7JtGTzAKRNJKQQ3m/pIBtGABn9pcGucykuEiNOV+hYCg8lzo8zbPo61MIb0fWAWMCO IZ2A== 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 v4si2384523pgf.470.2019.08.15.13.21.24; Thu, 15 Aug 2019 13:21:40 -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 S1732891AbfHOTkZ (ORCPT + 99 others); Thu, 15 Aug 2019 15:40:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55674 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbfHOTkZ (ORCPT ); Thu, 15 Aug 2019 15:40:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A08F73082E61; Thu, 15 Aug 2019 19:40:24 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.178]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7862A10016E8; Thu, 15 Aug 2019 19:40:23 +0000 (UTC) Date: Thu, 15 Aug 2019 15:40:21 -0400 From: Jerome Glisse To: Ralph Campbell Cc: Pingfan Liu , linux-mm@kvack.org, Andrew Morton , Mel Gorman , Jan Kara , "Kirill A. Shutemov" , Michal Hocko , Mike Kravetz , Andrea Arcangeli , Matthew Wilcox , linux-kernel@vger.kernel.org Subject: Re: [PATCHv2] mm/migrate: clean up useless code in migrate_vma_collect_pmd() Message-ID: <20190815194021.GB9253@redhat.com> References: <20190807052858.GA9749@mypc> <1565167272-21453-1-git-send-email-kernelfans@gmail.com> <20190815171918.GC30916@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 15 Aug 2019 19:40:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 15, 2019 at 12:23:44PM -0700, Ralph Campbell wrote: > > On 8/15/19 10:19 AM, Jerome Glisse wrote: > > On Wed, Aug 07, 2019 at 04:41:12PM +0800, Pingfan Liu wrote: > > > Clean up useless 'pfn' variable. > > > > NAK there is a bug see below: > > > > > > > > Signed-off-by: Pingfan Liu > > > Cc: "J?r?me Glisse" > > > Cc: Andrew Morton > > > Cc: Mel Gorman > > > Cc: Jan Kara > > > Cc: "Kirill A. Shutemov" > > > Cc: Michal Hocko > > > Cc: Mike Kravetz > > > Cc: Andrea Arcangeli > > > Cc: Matthew Wilcox > > > To: linux-mm@kvack.org > > > Cc: linux-kernel@vger.kernel.org > > > --- > > > mm/migrate.c | 9 +++------ > > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > > > diff --git a/mm/migrate.c b/mm/migrate.c > > > index 8992741..d483a55 100644 > > > --- a/mm/migrate.c > > > +++ b/mm/migrate.c > > > @@ -2225,17 +2225,15 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > > > pte_t pte; > > > pte = *ptep; > > > - pfn = pte_pfn(pte); > > > if (pte_none(pte)) { > > > mpfn = MIGRATE_PFN_MIGRATE; > > > migrate->cpages++; > > > - pfn = 0; > > > goto next; > > > } > > > if (!pte_present(pte)) { > > > - mpfn = pfn = 0; > > > + mpfn = 0; > > > /* > > > * Only care about unaddressable device page special > > > @@ -2252,10 +2250,10 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > > > if (is_write_device_private_entry(entry)) > > > mpfn |= MIGRATE_PFN_WRITE; > > > } else { > > > + pfn = pte_pfn(pte); > > > if (is_zero_pfn(pfn)) { > > > mpfn = MIGRATE_PFN_MIGRATE; > > > migrate->cpages++; > > > - pfn = 0; > > > goto next; > > > } > > > page = vm_normal_page(migrate->vma, addr, pte); > > > @@ -2265,10 +2263,9 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > > > /* FIXME support THP */ > > > if (!page || !page->mapping || PageTransCompound(page)) { > > > - mpfn = pfn = 0; > > > + mpfn = 0; > > > goto next; > > > } > > > - pfn = page_to_pfn(page); > > > > You can not remove that one ! Otherwise it will break the device > > private case. > > > > I don't understand. The only use of "pfn" I see is in the "else" > clause above where it is set just before using it. Ok i managed to confuse myself with mpfn and probably with old version of the code. Sorry for reading too quickly. Can we move unsigned long pfn; into the else { branch so that there is no more confusion to its scope. Cheers, J?r?me