* [linux-next:master 3841/3955] mm/memory.c:1678:67: sparse: sparse: incorrect type in initializer (different base types)
@ 2022-04-13 17:16 kernel test robot
2022-04-13 19:00 ` Peter Xu
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2022-04-13 17:16 UTC (permalink / raw)
To: Peter Xu
Cc: kbuild-all, Linux Memory Management List, Mike Kravetz, Andrew Morton
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: c97e430ab5539993ab2afc6e80deea80aef9d799
commit: afbef99a0e4dfb0eda864ae9d3c78c9d9ed750ba [3841/3955] mm/hugetlb: only drop uffd-wp special pte if required
config: i386-randconfig-s002 (https://download.01.org/0day-ci/archive/20220414/202204140108.DeRAhWEn-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=afbef99a0e4dfb0eda864ae9d3c78c9d9ed750ba
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout afbef99a0e4dfb0eda864ae9d3c78c9d9ed750ba
# save the config file to linux build tree
mkdir build_dir
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash fs/hugetlbfs/ mm/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
mm/memory.c:1238:1: sparse: sparse: symbol 'vma_needs_copy' was not declared. Should it be static?
>> mm/memory.c:1678:67: sparse: sparse: incorrect type in initializer (different base types) @@ expected unsigned long zap_flags @@ got restricted zap_flags_t @@
mm/memory.c:1678:67: sparse: expected unsigned long zap_flags
mm/memory.c:1678:67: sparse: got restricted zap_flags_t
mm/memory.c:1031:17: sparse: sparse: context imbalance in 'copy_pte_range' - different lock contexts for basic block
mm/memory.c:1830:16: sparse: sparse: context imbalance in '__get_locked_pte' - different lock contexts for basic block
mm/memory.c:1878:9: sparse: sparse: context imbalance in 'insert_page' - different lock contexts for basic block
mm/memory.c:2380:17: sparse: sparse: context imbalance in 'remap_pte_range' - different lock contexts for basic block
mm/memory.c:2636:17: sparse: sparse: context imbalance in 'apply_to_pte_range' - unexpected unlock
mm/memory.c:2925:9: sparse: sparse: context imbalance in 'wp_page_copy' - different lock contexts for basic block
mm/memory.c:3277:17: sparse: sparse: context imbalance in 'wp_pfn_shared' - unexpected unlock
mm/memory.c:3344:19: sparse: sparse: context imbalance in 'do_wp_page' - different lock contexts for basic block
mm/memory.c:5214:5: sparse: sparse: context imbalance in 'follow_invalidate_pte' - wrong count at exit
mm/memory.c:5335:23: sparse: sparse: context imbalance in 'follow_pfn' - unexpected unlock
mm/memory.c:5365:9: sparse: sparse: context imbalance in 'follow_phys' - unexpected unlock
mm/memory.c:5399:9: sparse: sparse: context imbalance in 'generic_access_phys' - unexpected unlock
--
>> mm/hugetlb.c:5013:43: sparse: sparse: restricted zap_flags_t degrades to integer
mm/hugetlb.c:5047:35: sparse: sparse: restricted zap_flags_t degrades to integer
mm/hugetlb.c:460:12: sparse: sparse: context imbalance in 'allocate_file_region_entries' - wrong count at exit
mm/hugetlb.c:533:13: sparse: sparse: context imbalance in 'region_add' - wrong count at exit
mm/hugetlb.c:600:13: sparse: sparse: context imbalance in 'region_chg' - wrong count at exit
mm/hugetlb.c: note: in included file:
include/linux/mm.h:1304:17: sparse: sparse: context imbalance in 'demote_free_huge_page' - unexpected unlock
mm/hugetlb.c:4896:20: sparse: sparse: context imbalance in 'move_huge_pte' - different lock contexts for basic block
include/linux/mm.h:1165:22: sparse: sparse: context imbalance in 'hugetlb_wp' - unexpected unlock
mm/hugetlb.c:6127:25: sparse: sparse: context imbalance in 'follow_hugetlb_page' - different lock contexts for basic block
--
>> fs/hugetlbfs/inode.c:521:41: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected unsigned long zap_flags @@ got restricted zap_flags_t [usertype] @@
fs/hugetlbfs/inode.c:521:41: sparse: expected unsigned long zap_flags
fs/hugetlbfs/inode.c:521:41: sparse: got restricted zap_flags_t [usertype]
fs/hugetlbfs/inode.c:588:39: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected unsigned long zap_flags @@ got restricted zap_flags_t [usertype] @@
fs/hugetlbfs/inode.c:588:39: sparse: expected unsigned long zap_flags
fs/hugetlbfs/inode.c:588:39: sparse: got restricted zap_flags_t [usertype]
vim +1678 mm/memory.c
1642
1643
1644 static void unmap_single_vma(struct mmu_gather *tlb,
1645 struct vm_area_struct *vma, unsigned long start_addr,
1646 unsigned long end_addr,
1647 struct zap_details *details)
1648 {
1649 unsigned long start = max(vma->vm_start, start_addr);
1650 unsigned long end;
1651
1652 if (start >= vma->vm_end)
1653 return;
1654 end = min(vma->vm_end, end_addr);
1655 if (end <= vma->vm_start)
1656 return;
1657
1658 if (vma->vm_file)
1659 uprobe_munmap(vma, start, end);
1660
1661 if (unlikely(vma->vm_flags & VM_PFNMAP))
1662 untrack_pfn(vma, 0, 0);
1663
1664 if (start != end) {
1665 if (unlikely(is_vm_hugetlb_page(vma))) {
1666 /*
1667 * It is undesirable to test vma->vm_file as it
1668 * should be non-null for valid hugetlb area.
1669 * However, vm_file will be NULL in the error
1670 * cleanup path of mmap_region. When
1671 * hugetlbfs ->mmap method fails,
1672 * mmap_region() nullifies vma->vm_file
1673 * before calling this function to clean up.
1674 * Since no pte has actually been setup, it is
1675 * safe to do nothing in this case.
1676 */
1677 if (vma->vm_file) {
> 1678 unsigned long zap_flags = details ?
1679 details->zap_flags : 0;
1680 i_mmap_lock_write(vma->vm_file->f_mapping);
1681 __unmap_hugepage_range_final(tlb, vma, start, end,
1682 NULL, zap_flags);
1683 i_mmap_unlock_write(vma->vm_file->f_mapping);
1684 }
1685 } else
1686 unmap_page_range(tlb, vma, start, end, details);
1687 }
1688 }
1689
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [linux-next:master 3841/3955] mm/memory.c:1678:67: sparse: sparse: incorrect type in initializer (different base types)
2022-04-13 17:16 [linux-next:master 3841/3955] mm/memory.c:1678:67: sparse: sparse: incorrect type in initializer (different base types) kernel test robot
@ 2022-04-13 19:00 ` Peter Xu
0 siblings, 0 replies; 2+ messages in thread
From: Peter Xu @ 2022-04-13 19:00 UTC (permalink / raw)
To: kernel test robot
Cc: kbuild-all, Linux Memory Management List, Mike Kravetz, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]
On Thu, Apr 14, 2022 at 01:16:26AM +0800, kernel test robot wrote:
> 1664 if (start != end) {
> 1665 if (unlikely(is_vm_hugetlb_page(vma))) {
> 1666 /*
> 1667 * It is undesirable to test vma->vm_file as it
> 1668 * should be non-null for valid hugetlb area.
> 1669 * However, vm_file will be NULL in the error
> 1670 * cleanup path of mmap_region. When
> 1671 * hugetlbfs ->mmap method fails,
> 1672 * mmap_region() nullifies vma->vm_file
> 1673 * before calling this function to clean up.
> 1674 * Since no pte has actually been setup, it is
> 1675 * safe to do nothing in this case.
> 1676 */
> 1677 if (vma->vm_file) {
> > 1678 unsigned long zap_flags = details ?
> 1679 details->zap_flags : 0;
The hugetlb side was overlooked after we re-typed zap_flags into bitmask..
One more patch (attached) needs to be squashed into patch "mm/hugetlb: Only
drop uffd-wp special pte if required" to ease the sparse warning, sorry.
--
Peter Xu
[-- Attachment #2: 0001-fixup-mm-hugetlb-Only-drop-uffd-wp-special-pte-if-re.patch --]
[-- Type: text/plain, Size: 3695 bytes --]
From ebb2908f24a7e2593c84406fe48afcc5923c68c7 Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Wed, 13 Apr 2022 14:50:04 -0400
Subject: [PATCH] fixup! mm/hugetlb: Only drop uffd-wp special pte if required
Signed-off-by: Peter Xu <peterx@redhat.com>
---
fs/hugetlbfs/inode.c | 2 +-
include/linux/hugetlb.h | 6 +++---
mm/hugetlb.c | 6 +++---
mm/memory.c | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 8b5b9df2be7d..c0bf65c70ade 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -405,7 +405,7 @@ static void remove_huge_page(struct page *page)
static void
hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,
- unsigned long zap_flags)
+ zap_flags_t zap_flags)
{
struct vm_area_struct *vma;
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 6df51d23b7ee..3568dec16efb 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -145,11 +145,11 @@ long follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *,
int *);
void unmap_hugepage_range(struct vm_area_struct *,
unsigned long, unsigned long, struct page *,
- unsigned long);
+ zap_flags_t);
void __unmap_hugepage_range_final(struct mmu_gather *tlb,
struct vm_area_struct *vma,
unsigned long start, unsigned long end,
- struct page *ref_page, unsigned long zap_flags);
+ struct page *ref_page, zap_flags_t zap_flags);
void hugetlb_report_meminfo(struct seq_file *);
int hugetlb_report_node_meminfo(char *buf, int len, int nid);
void hugetlb_show_meminfo(void);
@@ -405,7 +405,7 @@ static inline unsigned long hugetlb_change_protection(
static inline void __unmap_hugepage_range_final(struct mmu_gather *tlb,
struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct page *ref_page,
- unsigned long zap_flags)
+ zap_flags_t zap_flags)
{
BUG();
}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e1571179698a..b07a4c6f16f3 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4961,7 +4961,7 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,
static void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
unsigned long start, unsigned long end,
- struct page *ref_page, unsigned long zap_flags)
+ struct page *ref_page, zap_flags_t zap_flags)
{
struct mm_struct *mm = vma->vm_mm;
unsigned long address;
@@ -5095,7 +5095,7 @@ static void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct
void __unmap_hugepage_range_final(struct mmu_gather *tlb,
struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct page *ref_page,
- unsigned long zap_flags)
+ zap_flags_t zap_flags)
{
__unmap_hugepage_range(tlb, vma, start, end, ref_page, zap_flags);
@@ -5114,7 +5114,7 @@ void __unmap_hugepage_range_final(struct mmu_gather *tlb,
void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct page *ref_page,
- unsigned long zap_flags)
+ zap_flags_t zap_flags)
{
struct mmu_gather tlb;
diff --git a/mm/memory.c b/mm/memory.c
index 8e7f39c651c3..63644a7b5287 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1675,7 +1675,7 @@ static void unmap_single_vma(struct mmu_gather *tlb,
* safe to do nothing in this case.
*/
if (vma->vm_file) {
- unsigned long zap_flags = details ?
+ zap_flags_t zap_flags = details ?
details->zap_flags : 0;
i_mmap_lock_write(vma->vm_file->f_mapping);
__unmap_hugepage_range_final(tlb, vma, start, end,
--
2.32.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-13 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 17:16 [linux-next:master 3841/3955] mm/memory.c:1678:67: sparse: sparse: incorrect type in initializer (different base types) kernel test robot
2022-04-13 19:00 ` Peter Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox