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 <[email protected]>
> > > Cc: "Jérôme Glisse" <[email protected]>
> > > Cc: Andrew Morton <[email protected]>
> > > Cc: Mel Gorman <[email protected]>
> > > Cc: Jan Kara <[email protected]>
> > > Cc: "Kirill A. Shutemov" <[email protected]>
> > > Cc: Michal Hocko <[email protected]>
> > > Cc: Mike Kravetz <[email protected]>
> > > Cc: Andrea Arcangeli <[email protected]>
> > > Cc: Matthew Wilcox <[email protected]>
> > > To: [email protected]
> > > Cc: [email protected]
> > > ---
> > > 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