tree: https://github.com/ammarfaizi2/linux-block akpm/mm/mm-unstable head: a2765ca8c916591ebc9af48b4e545922c0bd3c3b commit: 95000286ff794d0195bb2ed4d3c7c92b5636caef [185/223] mm: switch vma_merge(), split_vma(), and __split_vma to vma iterator config: arm-randconfig-r004-20230106 compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 8d9828ef5aa9688500657d36cd2aefbe12bbd162) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # https://github.com/ammarfaizi2/linux-block/commit/95000286ff794d0195bb2ed4d3c7c92b5636caef git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block git fetch --no-tags ammarfaizi2-block akpm/mm/mm-unstable git checkout 95000286ff794d0195bb2ed4d3c7c92b5636caef # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All errors (new ones prefixed by >>): >> mm/nommu.c:1337:5: error: conflicting types for 'split_vma' int split_vma(struct mm_struct *mm, struct vm_area_struct *vma, ^ include/linux/mm.h:2826:12: note: previous declaration is here extern int split_vma(struct vma_iterator *vmi, struct vm_area_struct *, ^ >> mm/nommu.c:1502:20: error: incompatible pointer types passing 'struct mm_struct *' to parameter of type 'struct vma_iterator *' [-Werror,-Wincompatible-pointer-types] ret = split_vma(mm, vma, start, 1); ^~ include/linux/mm.h:2826:43: note: passing argument to parameter 'vmi' here extern int split_vma(struct vma_iterator *vmi, struct vm_area_struct *, ^ 2 errors generated. vim +/split_vma +1337 mm/nommu.c a4679373cf4ee0 Christoph Hellwig 2010-03-10 1332 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1333 /* 8feae13110d60c David Howells 2009-01-08 1334 * split a vma into two pieces at address 'addr', a new vma is allocated either 8feae13110d60c David Howells 2009-01-08 1335 * for the first part or the tail. ^1da177e4c3f41 Linus Torvalds 2005-04-16 1336 */ 8feae13110d60c David Howells 2009-01-08 @1337 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma, 8feae13110d60c David Howells 2009-01-08 1338 unsigned long addr, int new_below) ^1da177e4c3f41 Linus Torvalds 2005-04-16 1339 { 8feae13110d60c David Howells 2009-01-08 1340 struct vm_area_struct *new; 8feae13110d60c David Howells 2009-01-08 1341 struct vm_region *region; 8feae13110d60c David Howells 2009-01-08 1342 unsigned long npages; 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1343) MA_STATE(mas, &mm->mm_mt, vma->vm_start, vma->vm_end); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1344 779c10232ceb11 David Howells 2010-01-15 1345 /* we're only permitted to split anonymous regions (these should have 779c10232ceb11 David Howells 2010-01-15 1346 * only a single usage on the region) */ 779c10232ceb11 David Howells 2010-01-15 1347 if (vma->vm_file) 8feae13110d60c David Howells 2009-01-08 1348 return -ENOMEM; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1349 8feae13110d60c David Howells 2009-01-08 1350 if (mm->map_count >= sysctl_max_map_count) 8feae13110d60c David Howells 2009-01-08 1351 return -ENOMEM; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1352 8feae13110d60c David Howells 2009-01-08 1353 region = kmem_cache_alloc(vm_region_jar, GFP_KERNEL); 8feae13110d60c David Howells 2009-01-08 1354 if (!region) 8feae13110d60c David Howells 2009-01-08 1355 return -ENOMEM; 8feae13110d60c David Howells 2009-01-08 1356 3928d4f5ee37cd Linus Torvalds 2018-07-21 1357 new = vm_area_dup(vma); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1358) if (!new) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1359) goto err_vma_dup; 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1360) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1361) if (mas_preallocate(&mas, vma, GFP_KERNEL)) { 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1362) pr_warn("Allocation of vma tree for process %d failed\n", 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1363) current->pid); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1364) goto err_mas_preallocate; 925d1c401fa6cf Matt Helsley 2008-04-29 1365 } 8feae13110d60c David Howells 2009-01-08 1366 8feae13110d60c David Howells 2009-01-08 1367 /* most fields are the same, copy all, and then fixup */ 8feae13110d60c David Howells 2009-01-08 1368 *region = *vma->vm_region; 8feae13110d60c David Howells 2009-01-08 1369 new->vm_region = region; 8feae13110d60c David Howells 2009-01-08 1370 8feae13110d60c David Howells 2009-01-08 1371 npages = (addr - vma->vm_start) >> PAGE_SHIFT; 8feae13110d60c David Howells 2009-01-08 1372 8feae13110d60c David Howells 2009-01-08 1373 if (new_below) { dd8632a12e500a Paul Mundt 2009-01-08 1374 region->vm_top = region->vm_end = new->vm_end = addr; 8feae13110d60c David Howells 2009-01-08 1375 } else { 8feae13110d60c David Howells 2009-01-08 1376 region->vm_start = new->vm_start = addr; 8feae13110d60c David Howells 2009-01-08 1377 region->vm_pgoff = new->vm_pgoff += npages; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1378 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1379 8feae13110d60c David Howells 2009-01-08 1380 if (new->vm_ops && new->vm_ops->open) 8feae13110d60c David Howells 2009-01-08 1381 new->vm_ops->open(new); 8feae13110d60c David Howells 2009-01-08 1382 8feae13110d60c David Howells 2009-01-08 1383 down_write(&nommu_region_sem); 8feae13110d60c David Howells 2009-01-08 1384 delete_nommu_region(vma->vm_region); 8feae13110d60c David Howells 2009-01-08 1385 if (new_below) { 8feae13110d60c David Howells 2009-01-08 1386 vma->vm_region->vm_start = vma->vm_start = addr; 8feae13110d60c David Howells 2009-01-08 1387 vma->vm_region->vm_pgoff = vma->vm_pgoff += npages; 8feae13110d60c David Howells 2009-01-08 1388 } else { 8feae13110d60c David Howells 2009-01-08 1389 vma->vm_region->vm_end = vma->vm_end = addr; dd8632a12e500a Paul Mundt 2009-01-08 1390 vma->vm_region->vm_top = addr; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1391 } 8feae13110d60c David Howells 2009-01-08 1392 add_nommu_region(vma->vm_region); 8feae13110d60c David Howells 2009-01-08 1393 add_nommu_region(new->vm_region); 8feae13110d60c David Howells 2009-01-08 1394 up_write(&nommu_region_sem); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1395) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1396) setup_vma_to_mm(vma, mm); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1397) setup_vma_to_mm(new, mm); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1398) mas_set_range(&mas, vma->vm_start, vma->vm_end - 1); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1399) mas_store(&mas, vma); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1400) vma_mas_store(new, &mas); 8feae13110d60c David Howells 2009-01-08 1401 return 0; 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1402) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1403) err_mas_preallocate: 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1404) vm_area_free(new); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1405) err_vma_dup: 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1406) kmem_cache_free(vm_region_jar, region); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1407) return -ENOMEM; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1408 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1409 3034097a5017dd David Howells 2006-09-27 1410 /* 8feae13110d60c David Howells 2009-01-08 1411 * shrink a VMA by removing the specified chunk from either the beginning or 8feae13110d60c David Howells 2009-01-08 1412 * the end 3034097a5017dd David Howells 2006-09-27 1413 */ 8feae13110d60c David Howells 2009-01-08 1414 static int shrink_vma(struct mm_struct *mm, 8feae13110d60c David Howells 2009-01-08 1415 struct vm_area_struct *vma, 8feae13110d60c David Howells 2009-01-08 1416 unsigned long from, unsigned long to) ^1da177e4c3f41 Linus Torvalds 2005-04-16 1417 { 8feae13110d60c David Howells 2009-01-08 1418 struct vm_region *region; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1419 8feae13110d60c David Howells 2009-01-08 1420 /* adjust the VMA's pointers, which may reposition it in the MM's tree 8feae13110d60c David Howells 2009-01-08 1421 * and list */ 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1422) if (delete_vma_from_mm(vma)) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1423) return -ENOMEM; 8feae13110d60c David Howells 2009-01-08 1424 if (from > vma->vm_start) 8feae13110d60c David Howells 2009-01-08 1425 vma->vm_end = from; 8feae13110d60c David Howells 2009-01-08 1426 else 8feae13110d60c David Howells 2009-01-08 1427 vma->vm_start = to; 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1428) if (add_vma_to_mm(mm, vma)) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1429) return -ENOMEM; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1430 8feae13110d60c David Howells 2009-01-08 1431 /* cut the backing region down to size */ 8feae13110d60c David Howells 2009-01-08 1432 region = vma->vm_region; 1e2ae599d37e60 David Howells 2010-01-15 1433 BUG_ON(region->vm_usage != 1); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1434 8feae13110d60c David Howells 2009-01-08 1435 down_write(&nommu_region_sem); 8feae13110d60c David Howells 2009-01-08 1436 delete_nommu_region(region); dd8632a12e500a Paul Mundt 2009-01-08 1437 if (from > region->vm_start) { dd8632a12e500a Paul Mundt 2009-01-08 1438 to = region->vm_top; dd8632a12e500a Paul Mundt 2009-01-08 1439 region->vm_top = region->vm_end = from; dd8632a12e500a Paul Mundt 2009-01-08 1440 } else { 8feae13110d60c David Howells 2009-01-08 1441 region->vm_start = to; dd8632a12e500a Paul Mundt 2009-01-08 1442 } 8feae13110d60c David Howells 2009-01-08 1443 add_nommu_region(region); 8feae13110d60c David Howells 2009-01-08 1444 up_write(&nommu_region_sem); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1445 8feae13110d60c David Howells 2009-01-08 1446 free_page_series(from, to); 8feae13110d60c David Howells 2009-01-08 1447 return 0; 8feae13110d60c David Howells 2009-01-08 1448 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1449 8feae13110d60c David Howells 2009-01-08 1450 /* 8feae13110d60c David Howells 2009-01-08 1451 * release a mapping 8feae13110d60c David Howells 2009-01-08 1452 * - under NOMMU conditions the chunk to be unmapped must be backed by a single 8feae13110d60c David Howells 2009-01-08 1453 * VMA, though it need not cover the whole VMA 8feae13110d60c David Howells 2009-01-08 1454 */ 897ab3e0c49e24 Mike Rapoport 2017-02-24 1455 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf) 8feae13110d60c David Howells 2009-01-08 1456 { 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1457) MA_STATE(mas, &mm->mm_mt, start, start); 8feae13110d60c David Howells 2009-01-08 1458 struct vm_area_struct *vma; f67d9b1576c1c6 Bob Liu 2011-05-24 1459 unsigned long end; 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1460) int ret = 0; 365e9c87a982c0 Hugh Dickins 2005-10-29 1461 f67d9b1576c1c6 Bob Liu 2011-05-24 1462 len = PAGE_ALIGN(len); 8feae13110d60c David Howells 2009-01-08 1463 if (len == 0) 8feae13110d60c David Howells 2009-01-08 1464 return -EINVAL; 8feae13110d60c David Howells 2009-01-08 1465 f67d9b1576c1c6 Bob Liu 2011-05-24 1466 end = start + len; f67d9b1576c1c6 Bob Liu 2011-05-24 1467 8feae13110d60c David Howells 2009-01-08 1468 /* find the first potentially overlapping VMA */ 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1469) vma = mas_find(&mas, end - 1); 8feae13110d60c David Howells 2009-01-08 1470 if (!vma) { ac7149045d9fcc Choi Gi-yong 2014-04-07 1471 static int limit; 33e5d76979cf01 David Howells 2009-04-02 1472 if (limit < 5) { 22cc877b32202b Leon Romanovsky 2015-06-24 1473 pr_warn("munmap of memory not mmapped by process %d (%s): 0x%lx-0x%lx\n", 33e5d76979cf01 David Howells 2009-04-02 1474 current->pid, current->comm, 33e5d76979cf01 David Howells 2009-04-02 1475 start, start + len - 1); 33e5d76979cf01 David Howells 2009-04-02 1476 limit++; 33e5d76979cf01 David Howells 2009-04-02 1477 } 8feae13110d60c David Howells 2009-01-08 1478 return -EINVAL; 8feae13110d60c David Howells 2009-01-08 1479 } 8feae13110d60c David Howells 2009-01-08 1480 8feae13110d60c David Howells 2009-01-08 1481 /* we're allowed to split an anonymous VMA but not a file-backed one */ 8feae13110d60c David Howells 2009-01-08 1482 if (vma->vm_file) { 8feae13110d60c David Howells 2009-01-08 1483 do { 22cc877b32202b Leon Romanovsky 2015-06-24 1484 if (start > vma->vm_start) 8feae13110d60c David Howells 2009-01-08 1485 return -EINVAL; 8feae13110d60c David Howells 2009-01-08 1486 if (end == vma->vm_end) 8feae13110d60c David Howells 2009-01-08 1487 goto erase_whole_vma; 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1488) vma = mas_next(&mas, end - 1); d75a310c42c616 Namhyung Kim 2011-05-24 1489 } while (vma); 8feae13110d60c David Howells 2009-01-08 1490 return -EINVAL; 8feae13110d60c David Howells 2009-01-08 1491 } else { 8feae13110d60c David Howells 2009-01-08 1492 /* the chunk must be a subset of the VMA found */ 8feae13110d60c David Howells 2009-01-08 1493 if (start == vma->vm_start && end == vma->vm_end) 8feae13110d60c David Howells 2009-01-08 1494 goto erase_whole_vma; 22cc877b32202b Leon Romanovsky 2015-06-24 1495 if (start < vma->vm_start || end > vma->vm_end) 8feae13110d60c David Howells 2009-01-08 1496 return -EINVAL; 1824cb753354e0 Alexander Kuleshov 2015-11-05 1497 if (offset_in_page(start)) 8feae13110d60c David Howells 2009-01-08 1498 return -EINVAL; 1824cb753354e0 Alexander Kuleshov 2015-11-05 1499 if (end != vma->vm_end && offset_in_page(end)) 8feae13110d60c David Howells 2009-01-08 1500 return -EINVAL; 8feae13110d60c David Howells 2009-01-08 1501 if (start != vma->vm_start && end != vma->vm_end) { 8feae13110d60c David Howells 2009-01-08 @1502 ret = split_vma(mm, vma, start, 1); 22cc877b32202b Leon Romanovsky 2015-06-24 1503 if (ret < 0) 8feae13110d60c David Howells 2009-01-08 1504 return ret; 8feae13110d60c David Howells 2009-01-08 1505 } 8feae13110d60c David Howells 2009-01-08 1506 return shrink_vma(mm, vma, start, end); 8feae13110d60c David Howells 2009-01-08 1507 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1508 8feae13110d60c David Howells 2009-01-08 1509 erase_whole_vma: 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1510) if (delete_vma_from_mm(vma)) 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1511) ret = -ENOMEM; 8feae13110d60c David Howells 2009-01-08 1512 delete_vma(mm, vma); 8220543df1489e Matthew Wilcox (Oracle 2022-09-06 1513) return ret; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1514 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1515 :::::: The code at line 1337 was first introduced by commit :::::: 8feae13110d60cc6287afabc2887366b0eb226c2 NOMMU: Make VMAs per MM as for MMU-mode linux :::::: TO: David Howells :::::: CC: David Howells -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests