public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb•auug.org.au>
To: Peter Xu <peterx@redhat•com>
Cc: Andrew Morton <akpm@linux-foundation•org>,
	Linux Kernel Mailing List <linux-kernel@vger•kernel.org>,
	Linux Next Mailing List <linux-next@vger•kernel.org>
Subject: Re: linux-next: build warnings after merge of the akpm-current tree
Date: Wed, 7 Oct 2020 09:03:27 +1100	[thread overview]
Message-ID: <20201007090327.385f443e@canb.auug.org.au> (raw)
In-Reply-To: <20201006200138.GA6026@xz-x1>

[-- Attachment #1: Type: text/plain, Size: 3368 bytes --]

Hi all,

On Tue, 6 Oct 2020 16:01:38 -0400 Peter Xu <peterx@redhat•com> wrote:
>
> On Tue, Oct 06, 2020 at 11:05:16PM +1100, Stephen Rothwell wrote:
> > 
> > After merging the akpm-current tree, today's linux-next build (sparc
> > defconfig) produced this warning:
> > 
> > mm/memory.c: In function 'copy_present_page':
> > mm/memory.c:800:20: warning: unused variable 'dst_mm' [-Wunused-variable]
> >   struct mm_struct *dst_mm = dst_vma->vm_mm;
> >                     ^~~~~~
> > mm/memory.c: In function 'copy_present_pte':
> > mm/memory.c:889:20: warning: unused variable 'dst_mm' [-Wunused-variable]
> >   struct mm_struct *dst_mm = dst_vma->vm_mm;
> >                     ^~~~~~
> > 
> > Maybe introduced by commit
> > 
> >   7e6cdccef3df ("mm-remove-src-dst-mm-parameter-in-copy_page_range-v2")  
> 
> Yes it is.  The mm pointer is only used by set_pte_at(), while I just noticed
> that some of the archs do not use the mm pointer at all, hence this warning.
> 
> The required change attached; this is quite special that we only referenced the
> mm once in each of the function, so that temp variable can actually be avoided.
> Ideally there should be some way to only define the variable on archs that need
> this mm pointer (e.g., when set_pte_at() or some similar function is called
> multiple times in some function, it should still be helpful to introduce a
> local variable to keep dst_vma->vm_mm).  However I don't know a good way to do
> this...
> 
> Thanks,
> 
> ------------8<------------
> diff --git a/mm/memory.c b/mm/memory.c
> index 8ade87e8600a..d9b16136014c 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -798,7 +798,6 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
>                   pte_t *dst_pte, pte_t *src_pte, unsigned long addr, int *rss,
>                   struct page **prealloc, pte_t pte, struct page *page)
>  {
> -       struct mm_struct *dst_mm = dst_vma->vm_mm;
>         struct mm_struct *src_mm = src_vma->vm_mm;
>         struct page *new_page;
> 
> @@ -874,7 +873,7 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
>         /* All done, just insert the new page copy in the child */
>         pte = mk_pte(new_page, dst_vma->vm_page_prot);
>         pte = maybe_mkwrite(pte_mkdirty(pte), dst_vma);
> -       set_pte_at(dst_mm, addr, dst_pte, pte);
> +       set_pte_at(dst_vma->vm_mm, addr, dst_pte, pte);
>         return 0;
>  }
> 
> @@ -887,7 +886,6 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
>                  pte_t *dst_pte, pte_t *src_pte, unsigned long addr, int *rss,
>                  struct page **prealloc)
>  {
> -       struct mm_struct *dst_mm = dst_vma->vm_mm;
>         struct mm_struct *src_mm = src_vma->vm_mm;
>         unsigned long vm_flags = src_vma->vm_flags;
>         pte_t pte = *src_pte;
> @@ -932,7 +930,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
>         if (!(vm_flags & VM_UFFD_WP))
>                 pte = pte_clear_uffd_wp(pte);
> 
> -       set_pte_at(dst_mm, addr, dst_pte, pte);
> +       set_pte_at(dst_vma->vm_mm, addr, dst_pte, pte);
>         return 0;
>  }

Thanks, I have applied that to linux-next today.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-10-06 22:03 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 12:05 linux-next: build warnings after merge of the akpm-current tree Stephen Rothwell
2020-10-06 20:01 ` Peter Xu
2020-10-06 22:03   ` Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-09  6:02 Stephen Rothwell
2022-02-09 16:03 ` Hugh Dickins
2022-03-28 23:04   ` Matthew Wilcox
2022-03-29  3:32     ` Hugh Dickins
2022-03-24  7:27 ` Stephen Rothwell
2022-03-28 19:54   ` Hugh Dickins
2022-03-28 22:10     ` Matthew Wilcox
2021-10-11  7:31 Stephen Rothwell
2021-10-11 17:46 ` Kees Cook
2021-06-15 10:50 Stephen Rothwell
2020-01-06  6:14 Stephen Rothwell
2017-08-24  7:41 Stephen Rothwell
2017-08-24  8:15 ` Changwei Ge
2017-08-25 21:23   ` Andrew Morton
2017-08-26  1:23     ` Changwei Ge
2017-03-20  5:22 Stephen Rothwell
2017-03-20  9:05 ` Dmitry Vyukov
2017-03-20 12:30   ` Jan Glauber
2017-03-20 17:06     ` Challa, Mahipal
2015-01-27  8:12 Stephen Rothwell
2015-01-27  8:27 ` Vladimir Davydov
2014-10-03  7:30 Stephen Rothwell
2014-10-03 18:21 ` Andrew Morton
2014-10-03 19:28   ` Michal Nazarewicz
2014-09-23  8:18 Stephen Rothwell
2014-08-26  7:22 Stephen Rothwell
2014-08-26 10:19 ` Xishi Qiu
2013-08-29  9:47 Stephen Rothwell
2013-08-29 11:24 ` Maxim Patlasov
2013-08-29 19:42   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201007090327.385f443e@canb.auug.org.au \
    --to=sfr@canb$(echo .)auug.org.au \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-next@vger$(echo .)kernel.org \
    --cc=peterx@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox