linux-next: build warnings after merge of the akpm-current tree
Subsystems (3)
Hi all,
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")
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 14 lines · Stephen Rothwell
Hi all,
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; ^~~~~~
Quoted 3 lines
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<------------
mm/memory.c +2 -5
@@ -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 ; } ------------8<------------
Signature · 1 line
Peter Xu
Hi all,
Quoted 63 lines · On Tue, 6 Oct 2020 16:01:38 -0400 Peter Xu <[email protected]> wrote:
Quoted 13 lines · Stephen Rothwell
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; ^~~~~~Quoted 3 lines
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 keepdst_vma->vm_mm). However I don't know a good way to do this...Thanks,
------------8<------------
mm/memory.c +1
-3@@ -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;
mm/memory.c copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, · line 935
Quoted 7 lines
mm/memory.c +1
-1@@ -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.
Signature · 2 lines
Cheers, Stephen Rothwell