[nsaenz-rpi:wip 4/5] mm/page_alloc.c:1472:30: sparse: sparse: incorrect type in assignment (different modifiers)

From: kernel test robot
Date: Sun Nov 14 2021 - 09:04:05 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/nsaenz/linux-rpi.git wip
head: a6f29192b1e2bf93a6ab7c25c854307431124b8b
commit: fa796c53bdbc3c8619a6f8d7d2d530e4c2e76ba9 [4/5] mm/page_alloc: Access to lists in 'struct per_cpu_pages' indirectly
config: arm64-randconfig-s031-20211008 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/nsaenz/linux-rpi.git/commit/?id=fa796c53bdbc3c8619a6f8d7d2d530e4c2e76ba9
git remote add nsaenz-rpi https://git.kernel.org/pub/scm/linux/kernel/git/nsaenz/linux-rpi.git
git fetch --no-tags nsaenz-rpi wip
git checkout fa796c53bdbc3c8619a6f8d7d2d530e4c2e76ba9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)
>> mm/page_alloc.c:1472:30: sparse: sparse: incorrect type in assignment (different modifiers) @@ expected struct list_head *list @@ got struct list_head [noderef] * @@
mm/page_alloc.c:1472:30: sparse: expected struct list_head *list
mm/page_alloc.c:1472:30: sparse: got struct list_head [noderef] *
>> mm/page_alloc.c:3383:40: sparse: sparse: incorrect type in argument 2 (different modifiers) @@ expected struct list_head *head @@ got struct list_head [noderef] * @@
mm/page_alloc.c:3383:40: sparse: expected struct list_head *head
mm/page_alloc.c:3383:40: sparse: got struct list_head [noderef] *
mm/page_alloc.c:5987:17: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct per_cpu_pages [noderef] __percpu ** @@
mm/page_alloc.c:5987:17: sparse: expected void const [noderef] __percpu *__vpp_verify
mm/page_alloc.c:5987:17: sparse: got struct per_cpu_pages [noderef] __percpu **
mm/page_alloc.c:5987:17: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct per_cpu_pages [noderef] __percpu ** @@
mm/page_alloc.c:5987:17: sparse: expected void const [noderef] __percpu *__vpp_verify
mm/page_alloc.c:5987:17: sparse: got struct per_cpu_pages [noderef] __percpu **
mm/page_alloc.c:5987:17: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct per_cpu_pages [noderef] __percpu ** @@
mm/page_alloc.c:5987:17: sparse: expected void const [noderef] __percpu *__vpp_verify
mm/page_alloc.c:5987:17: sparse: got struct per_cpu_pages [noderef] __percpu **
mm/page_alloc.c:5987:17: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct per_cpu_pages [noderef] __percpu ** @@
mm/page_alloc.c:5987:17: sparse: expected void const [noderef] __percpu *__vpp_verify
mm/page_alloc.c:5987:17: sparse: got struct per_cpu_pages [noderef] __percpu **
mm/page_alloc.c:5987:17: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct per_cpu_pages [noderef] __percpu ** @@
mm/page_alloc.c:5987:17: sparse: expected void const [noderef] __percpu *__vpp_verify
mm/page_alloc.c:5987:17: sparse: got struct per_cpu_pages [noderef] __percpu **
>> mm/page_alloc.c:6892:47: sparse: sparse: incorrect type in argument 1 (different modifiers) @@ expected struct list_head *list @@ got struct list_head [noderef] * @@
mm/page_alloc.c:6892:47: sparse: expected struct list_head *list
mm/page_alloc.c:6892:47: sparse: got struct list_head [noderef] *
>> mm/page_alloc.c:1457:17: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:1512:9: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3104:13: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3105:42: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3218:29: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3223:37: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3384:9: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3386:13: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3618:14: sparse: sparse: incorrect type in assignment (different modifiers) @@ expected struct list_head *list @@ got struct list_head [noderef] * @@
mm/page_alloc.c:3618:14: sparse: expected struct list_head *list
mm/page_alloc.c:3618:14: sparse: got struct list_head [noderef] *
mm/page_alloc.c:3638:25: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3645:17: sparse: sparse: dereference of noderef expression
mm/page_alloc.c: note: in included file (through include/linux/mm.h):
include/linux/gfp.h:353:27: sparse: sparse: restricted gfp_t degrades to integer
include/linux/gfp.h:353:27: sparse: sparse: restricted gfp_t degrades to integer
mm/page_alloc.c:3618:14: sparse: sparse: incorrect type in assignment (different modifiers) @@ expected struct list_head *list @@ got struct list_head [noderef] * @@
mm/page_alloc.c:3618:14: sparse: expected struct list_head *list
mm/page_alloc.c:3618:14: sparse: got struct list_head [noderef] *
mm/page_alloc.c:3638:25: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:3645:17: sparse: sparse: dereference of noderef expression
include/linux/gfp.h:353:27: sparse: sparse: restricted gfp_t degrades to integer
include/linux/gfp.h:353:27: sparse: sparse: restricted gfp_t degrades to integer
include/linux/gfp.h:353:27: sparse: sparse: restricted gfp_t degrades to integer
include/linux/gfp.h:353:27: sparse: sparse: restricted gfp_t degrades to integer
mm/page_alloc.c:5890:76: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:5984:76: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:5987:17: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:5987:17: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:5987:17: sparse: sparse: dereference of noderef expression
mm/page_alloc.c:5987:17: sparse: sparse: dereference of noderef expression

vim +1472 mm/page_alloc.c

1428
1429 /*
1430 * Frees a number of pages from the PCP lists
1431 * Assumes all pages on list are in same zone, and of same order.
1432 * count is the number of pages to free.
1433 *
1434 * If the zone was previously in an "all pages pinned" state then look to
1435 * see if this freeing clears that state.
1436 *
1437 * And clear the zone's pages_scanned counter, to hold off the "all pages are
1438 * pinned" detection logic.
1439 */
1440 static void free_pcppages_bulk(struct zone *zone, int count,
1441 struct per_cpu_pages *pcp,
1442 struct pcplists *lp)
1443 {
1444 int pindex = 0;
1445 int batch_free = 0;
1446 int nr_freed = 0;
1447 unsigned int order;
1448 int prefetch_nr = READ_ONCE(pcp->batch);
1449 bool isolated_pageblocks;
1450 struct page *page, *tmp;
1451 LIST_HEAD(head);
1452
1453 /*
1454 * Ensure proper count is passed which otherwise would stuck in the
1455 * below while (list_empty(list)) loop.
1456 */
> 1457 count = min(lp->count, count);
1458 while (count > 0) {
1459 struct list_head *list;
1460
1461 /*
1462 * Remove pages from lists in a round-robin fashion. A
1463 * batch_free count is maintained that is incremented when an
1464 * empty list is encountered. This is so more pages are freed
1465 * off fuller lists instead of spinning excessively around empty
1466 * lists
1467 */
1468 do {
1469 batch_free++;
1470 if (++pindex == NR_PCP_LISTS)
1471 pindex = 0;
> 1472 list = &lp->lists[pindex];
1473 } while (list_empty(list));
1474
1475 /* This is the only non-empty list. Free them all. */
1476 if (batch_free == NR_PCP_LISTS)
1477 batch_free = count;
1478
1479 order = pindex_to_order(pindex);
1480 BUILD_BUG_ON(MAX_ORDER >= (1<<NR_PCP_ORDER_WIDTH));
1481 do {
1482 page = list_last_entry(list, struct page, lru);
1483 /* must delete to avoid corrupting pcp list */
1484 list_del(&page->lru);
1485 nr_freed += 1 << order;
1486 count -= 1 << order;
1487
1488 if (bulkfree_pcp_prepare(page))
1489 continue;
1490
1491 /* Encode order with the migratetype */
1492 page->index <<= NR_PCP_ORDER_WIDTH;
1493 page->index |= order;
1494
1495 list_add_tail(&page->lru, &head);
1496
1497 /*
1498 * We are going to put the page back to the global
1499 * pool, prefetch its buddy to speed up later access
1500 * under zone->lock. It is believed the overhead of
1501 * an additional test and calculating buddy_pfn here
1502 * can be offset by reduced memory latency later. To
1503 * avoid excessive prefetching due to large count, only
1504 * prefetch buddy for the first pcp->batch nr of pages.
1505 */
1506 if (prefetch_nr) {
1507 prefetch_buddy(page);
1508 prefetch_nr--;
1509 }
1510 } while (count > 0 && --batch_free && !list_empty(list));
1511 }
1512 lp->count -= nr_freed;
1513
1514 /*
1515 * local_lock_irq held so equivalent to spin_lock_irqsave for
1516 * both PREEMPT_RT and non-PREEMPT_RT configurations.
1517 */
1518 spin_lock(&zone->lock);
1519 isolated_pageblocks = has_isolate_pageblock(zone);
1520
1521 /*
1522 * Use safe version since after __free_one_page(),
1523 * page->lru.next will not point to original list.
1524 */
1525 list_for_each_entry_safe(page, tmp, &head, lru) {
1526 int mt = get_pcppage_migratetype(page);
1527
1528 /* mt has been encoded with the order (see above) */
1529 order = mt & NR_PCP_ORDER_MASK;
1530 mt >>= NR_PCP_ORDER_WIDTH;
1531
1532 /* MIGRATE_ISOLATE page should not go to pcplists */
1533 VM_BUG_ON_PAGE(is_migrate_isolate(mt), page);
1534 /* Pageblock could have been isolated meanwhile */
1535 if (unlikely(isolated_pageblocks))
1536 mt = get_pageblock_migratetype(page);
1537
1538 __free_one_page(page, page_to_pfn(page), zone, order, mt, FPI_NONE);
1539 trace_mm_page_pcpu_drain(page, order, mt);
1540 }
1541 spin_unlock(&zone->lock);
1542 }
1543

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip