Message ID | 20241210024119.2488608-14-kaleshsingh@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm: Introduce arch_mmap_hint() | expand |
Hi Kalesh,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Kalesh-Singh/mm-Introduce-generic_mmap_hint/20241210-104424
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20241210024119.2488608-14-kaleshsingh%40google.com
patch subject: [PATCH mm-unstable 13/17] mm: sparc64: Introduce arch_mmap_hint()
config: sparc-randconfig-002-20241210 (https://download.01.org/0day-ci/archive/20241210/202412102215.fF34r4Uo-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241210/202412102215.fF34r4Uo-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412102215.fF34r4Uo-lkp@intel.com/
All warnings (new ones prefixed by >>):
arch/sparc/kernel/sys_sparc_64.c: In function 'arch_get_unmapped_area':
>> arch/sparc/kernel/sys_sparc_64.c:135:13: warning: variable 'do_color_align' set but not used [-Wunused-but-set-variable]
135 | int do_color_align;
| ^~~~~~~~~~~~~~
vim +/do_color_align +135 arch/sparc/kernel/sys_sparc_64.c
aef9ae8eac4116 arch/sparc/kernel/sys_sparc_64.c Kalesh Singh 2024-12-09 131
25d4054cc97484 arch/sparc/kernel/sys_sparc_64.c Mark Brown 2024-09-04 132 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags)
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 133 {
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 134 unsigned long task_size = TASK_SIZE;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 @135 int do_color_align;
b80fa3cbb78c0f arch/sparc/kernel/sys_sparc_64.c Rick Edgecombe 2024-03-25 136 struct vm_unmapped_area_info info = {};
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 137 bool file_hugepage = false;
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 138
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 139 if (filp && is_file_hugepages(filp))
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 140 file_hugepage = true;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 141
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 142 if (flags & MAP_FIXED) {
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 143 /* We do not accept a shared mapping if it would violate
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 144 * cache aliasing constraints.
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 145 */
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 146 if (!file_hugepage && (flags & MAP_SHARED) &&
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 147 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 148 return -EINVAL;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 149 return addr;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 150 }
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 151
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 152 if (test_thread_flag(TIF_32BIT))
d61e16df940e02 arch/sparc64/kernel/sys_sparc.c David S. Miller 2006-03-17 153 task_size = STACK_TOP32;
a91690ddd05ab0 arch/sparc64/kernel/sys_sparc.c David S. Miller 2006-03-17 154 if (unlikely(len > task_size || len >= VA_EXCLUDE_START))
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 155 return -ENOMEM;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 156
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 157 do_color_align = 0;
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 158 if ((filp || (flags & MAP_SHARED)) && !file_hugepage)
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 159 do_color_align = 1;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 160
aef9ae8eac4116 arch/sparc/kernel/sys_sparc_64.c Kalesh Singh 2024-12-09 161 addr = arch_mmap_hint(filp, addr, len, pgoff, flags);
aef9ae8eac4116 arch/sparc/kernel/sys_sparc_64.c Kalesh Singh 2024-12-09 162 if (addr)
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 163 return addr;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 164
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 165 info.length = len;
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 166 info.low_limit = TASK_UNMAPPED_BASE;
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 167 info.high_limit = min(task_size, VA_EXCLUDE_START);
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 168 info.align_mask = get_align_mask(filp, flags);
a8d457b29b017a arch/sparc/kernel/sys_sparc_64.c Oscar Salvador 2024-10-07 169 if (!file_hugepage)
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 170 info.align_offset = pgoff << PAGE_SHIFT;
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 171 addr = vm_unmapped_area(&info);
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 172
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 173 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 174 VM_BUG_ON(addr != -ENOMEM);
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 175 info.low_limit = VA_EXCLUDE_END;
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 176 info.high_limit = task_size;
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 177 addr = vm_unmapped_area(&info);
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 178 }
1363c3cd8603a9 arch/sparc64/kernel/sys_sparc.c Wolfgang Wander 2005-06-21 179
bb64f55019c7b0 arch/sparc/kernel/sys_sparc_64.c Michel Lespinasse 2012-12-11 180 return addr;
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 181 }
^1da177e4c3f41 arch/sparc64/kernel/sys_sparc.c Linus Torvalds 2005-04-16 182
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 2b7f358762c1..f24a4eb2777b 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -1148,6 +1148,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write) */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT /* We provide a special get_unmapped_area for framebuffer mmaps to try and use * the largest alignment possible such that larget PTEs can be used. diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index c5a284df7b41..a782696e98e0 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -98,10 +98,39 @@ static unsigned long get_align_mask(struct file *filp, unsigned long flags) return 0; } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + unsigned long task_size = TASK_SIZE; + bool file_hugepage = false; + int do_color_align = 0; + + if (!addr) + return 0; + + if (filp && is_file_hugepages(filp)) + file_hugepage = true; + + if ((filp || (flags & MAP_SHARED)) && !file_hugepage) + do_color_align = 1; + + if (test_thread_flag(TIF_32BIT)) + task_size = STACK_TOP32; + + if (unlikely(len > task_size || len >= VA_EXCLUDE_START)) + return 0; + + if (do_color_align) + addr = COLOR_ALIGN(addr, pgoff); + else + addr = PAGE_ALIGN(addr); + + return generic_mmap_hint(filp, addr, len, pgoff, flags); +} + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { - struct mm_struct *mm = current->mm; - struct vm_area_struct * vma; unsigned long task_size = TASK_SIZE; int do_color_align; struct vm_unmapped_area_info info = {}; @@ -129,17 +158,9 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi if ((filp || (flags & MAP_SHARED)) && !file_hugepage) do_color_align = 1; - if (addr) { - if (do_color_align) - addr = COLOR_ALIGN(addr, pgoff); - else - addr = PAGE_ALIGN(addr); - - vma = find_vma(mm, addr); - if (task_size - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.length = len; info.low_limit = TASK_UNMAPPED_BASE;
Introduce sparc64 arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. This is a preparatory patch, no functional change is introduced. Signed-off-by: Kalesh Singh <kaleshsingh@google.com> --- arch/sparc/include/asm/pgtable_64.h | 1 + arch/sparc/kernel/sys_sparc_64.c | 47 +++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-)