linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mprotect: fix compilation warning because of unused 'mm' varaible
@ 2019-05-08  8:50 Mike Rapoport
  2019-05-13 20:51 ` Song Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2019-05-08  8:50 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Mike Rapoport

Since commit 0cbe3e26abe0 ("mm: update ptep_modify_prot_start/commit to
take vm_area_struct as arg") the only place that uses the local 'mm'
variable in change_pte_range() is the call to set_pte_at().

Many architectures define set_pte_at() as macro that does not use the 'mm'
parameter, which generates the following compilation warning:

 CC      mm/mprotect.o
mm/mprotect.c: In function 'change_pte_range':
mm/mprotect.c:42:20: warning: unused variable 'mm' [-Wunused-variable]
  struct mm_struct *mm = vma->vm_mm;
                    ^~

Fix it by passing vma->mm to set_pte_at() and dropping the local 'mm'
variable in change_pte_range().

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 mm/mprotect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 028c724..61bfe24 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 		unsigned long addr, unsigned long end, pgprot_t newprot,
 		int dirty_accountable, int prot_numa)
 {
-	struct mm_struct *mm = vma->vm_mm;
 	pte_t *pte, oldpte;
 	spinlock_t *ptl;
 	unsigned long pages = 0;
@@ -136,7 +135,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 				newpte = swp_entry_to_pte(entry);
 				if (pte_swp_soft_dirty(oldpte))
 					newpte = pte_swp_mksoft_dirty(newpte);
-				set_pte_at(mm, addr, pte, newpte);
+				set_pte_at(vma->mm, addr, pte, newpte);
 
 				pages++;
 			}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/mprotect: fix compilation warning because of unused 'mm' varaible
  2019-05-08  8:50 [PATCH] mm/mprotect: fix compilation warning because of unused 'mm' varaible Mike Rapoport
@ 2019-05-13 20:51 ` Song Liu
  2019-05-13 20:54   ` Song Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Song Liu @ 2019-05-13 20:51 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, Linux-MM

On Wed, May 8, 2019 at 4:50 AM Mike Rapoport <rppt@linux.ibm.com> wrote:
>
> Since commit 0cbe3e26abe0 ("mm: update ptep_modify_prot_start/commit to
> take vm_area_struct as arg") the only place that uses the local 'mm'
> variable in change_pte_range() is the call to set_pte_at().
>
> Many architectures define set_pte_at() as macro that does not use the 'mm'
> parameter, which generates the following compilation warning:
>
>  CC      mm/mprotect.o
> mm/mprotect.c: In function 'change_pte_range':
> mm/mprotect.c:42:20: warning: unused variable 'mm' [-Wunused-variable]
>   struct mm_struct *mm = vma->vm_mm;
>                     ^~
>
> Fix it by passing vma->mm to set_pte_at() and dropping the local 'mm'
> variable in change_pte_range().
>
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
>  mm/mprotect.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 028c724..61bfe24 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
>                 unsigned long addr, unsigned long end, pgprot_t newprot,
>                 int dirty_accountable, int prot_numa)
>  {
> -       struct mm_struct *mm = vma->vm_mm;
>         pte_t *pte, oldpte;
>         spinlock_t *ptl;
>         unsigned long pages = 0;
> @@ -136,7 +135,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
>                                 newpte = swp_entry_to_pte(entry);
>                                 if (pte_swp_soft_dirty(oldpte))
>                                         newpte = pte_swp_mksoft_dirty(newpte);
> -                               set_pte_at(mm, addr, pte, newpte);
> +                               set_pte_at(vma->mm, addr, pte, newpte);

This should be vma->vm_mm.

Thanks,
Song

>
>                                 pages++;
>                         }
> --
> 2.7.4
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/mprotect: fix compilation warning because of unused 'mm' varaible
  2019-05-13 20:51 ` Song Liu
@ 2019-05-13 20:54   ` Song Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Song Liu @ 2019-05-13 20:54 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, Linux-MM

On Mon, May 13, 2019 at 4:51 PM Song Liu <liu.song.a23@gmail.com> wrote:
>
> On Wed, May 8, 2019 at 4:50 AM Mike Rapoport <rppt@linux.ibm.com> wrote:
> >
> > Since commit 0cbe3e26abe0 ("mm: update ptep_modify_prot_start/commit to
> > take vm_area_struct as arg") the only place that uses the local 'mm'
> > variable in change_pte_range() is the call to set_pte_at().
> >
> > Many architectures define set_pte_at() as macro that does not use the 'mm'
> > parameter, which generates the following compilation warning:
> >
> >  CC      mm/mprotect.o
> > mm/mprotect.c: In function 'change_pte_range':
> > mm/mprotect.c:42:20: warning: unused variable 'mm' [-Wunused-variable]
> >   struct mm_struct *mm = vma->vm_mm;
> >                     ^~
> >
> > Fix it by passing vma->mm to set_pte_at() and dropping the local 'mm'
> > variable in change_pte_range().
> >
> > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> > ---
> >  mm/mprotect.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/mm/mprotect.c b/mm/mprotect.c
> > index 028c724..61bfe24 100644
> > --- a/mm/mprotect.c
> > +++ b/mm/mprotect.c
> > @@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
> >                 unsigned long addr, unsigned long end, pgprot_t newprot,
> >                 int dirty_accountable, int prot_numa)
> >  {
> > -       struct mm_struct *mm = vma->vm_mm;
> >         pte_t *pte, oldpte;
> >         spinlock_t *ptl;
> >         unsigned long pages = 0;
> > @@ -136,7 +135,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
> >                                 newpte = swp_entry_to_pte(entry);
> >                                 if (pte_swp_soft_dirty(oldpte))
> >                                         newpte = pte_swp_mksoft_dirty(newpte);
> > -                               set_pte_at(mm, addr, pte, newpte);
> > +                               set_pte_at(vma->mm, addr, pte, newpte);
>
> This should be vma->vm_mm.

And we need to fix another reference to mm:

diff --git i/mm/mprotect.c w/mm/mprotect.c
index 8bdba81685d6..bf38dfbbb4b4 100644
--- i/mm/mprotect.c
+++ w/mm/mprotect.c
@@ -135,7 +135,7 @@ static unsigned long change_pte_range(struct
vm_area_struct *vma, pmd_t *pmd,
                                newpte = swp_entry_to_pte(entry);
                                if (pte_swp_soft_dirty(oldpte))
                                        newpte = pte_swp_mksoft_dirty(newpte);
-                               set_pte_at(vma->mm, addr, pte, newpte);
+                               set_pte_at(vma->vm_mm, addr, pte, newpte);

                                pages++;
                        }
@@ -149,7 +149,7 @@ static unsigned long change_pte_range(struct
vm_area_struct *vma, pmd_t *pmd,
                                 */
                                make_device_private_entry_read(&entry);
                                newpte = swp_entry_to_pte(entry);
-                               set_pte_at(mm, addr, pte, newpte);
+                               set_pte_at(vma->vm_mm, addr, pte, newpte);

                                pages++;
                        }


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-13 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-08  8:50 [PATCH] mm/mprotect: fix compilation warning because of unused 'mm' varaible Mike Rapoport
2019-05-13 20:51 ` Song Liu
2019-05-13 20:54   ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).