lib/test_context-analysis.c:483:9: sparse: sparse: incorrect type in argument 1 (different base types)

From: kernel test robot

Date: Sat Feb 21 2026 - 17:18:46 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8934827db5403eae57d4537114a9ff88b0a8460f
commit: d3febf16dee28a74b01ba43195ee4965edb6208f locking/local_lock: Support Clang's context analysis
date: 7 weeks ago
config: hexagon-randconfig-r111-20260222 (https://download.01.org/0day-ci/archive/20260222/202602220623.h42T9E7T-lkp@xxxxxxxxx/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project e86750b29fa0ff207cd43213d66dabe565417638)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260222/202602220623.h42T9E7T-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602220623.h42T9E7T-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
lib/test_context-analysis.c: note: in included file (through include/linux/local_lock.h):
include/linux/local_lock_internal.h:332:40: sparse: sparse: multiple definitions for function '__this_cpu_local_lock'
include/linux/local_lock_internal.h:326:37: sparse: the previous one is here
lib/test_context-analysis.c:148:1: sparse: sparse: undefined identifier '__cond_acquire'
>> lib/test_context-analysis.c:483:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:483:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:483:9: sparse: got struct local_lock [noderef] __percpu *
>> lib/test_context-analysis.c:483:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:483:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:483:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:485:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:485:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:485:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:485:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:485:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:485:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:487:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:487:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:487:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:487:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:487:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:487:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:489:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:489:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:489:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:489:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:489:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:489:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:491:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:491:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:491:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:491:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:491:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:491:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:493:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:493:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:493:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:493:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:493:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:493:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:495:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:495:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:495:9: sparse: got struct local_lock [noderef] __percpu *
>> lib/test_context-analysis.c:495:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_lock [usertype] *l @@ got struct local_trylock [usertype] * @@
lib/test_context-analysis.c:495:9: sparse: expected struct local_lock [usertype] *l
lib/test_context-analysis.c:495:9: sparse: got struct local_trylock [usertype] *
lib/test_context-analysis.c:497:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] __percpu * @@
lib/test_context-analysis.c:497:9: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
lib/test_context-analysis.c:497:9: sparse: got struct local_lock [noderef] __percpu *
lib/test_context-analysis.c:497:9: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_lock [usertype] *l @@ got struct local_trylock [usertype] * @@
lib/test_context-analysis.c:497:9: sparse: expected struct local_lock [usertype] *l
lib/test_context-analysis.c:497:9: sparse: got struct local_trylock [usertype] *
lib/test_context-analysis.c:83:1: sparse: sparse: context imbalance in 'test_raw_spinlock_guard' - wrong count at exit
lib/test_context-analysis.c:90:20: sparse: sparse: context imbalance in 'test_raw_spinlock_trylock_extra' - wrong count at exit
lib/test_context-analysis.c:107:1: sparse: sparse: context imbalance in 'test_spinlock_guard' - wrong count at exit
lib/test_context-analysis.c:114:20: sparse: sparse: context imbalance in 'test_spinlock_trylock_extra' - wrong count at exit
lib/test_context-analysis.c:131:1: sparse: sparse: context imbalance in 'test_write_lock_guard' - wrong count at exit
lib/test_context-analysis.c:148:1: sparse: sparse: context imbalance in 'test_read_lock_guard' - wrong count at exit
lib/test_context-analysis.c:188:17: sparse: sparse: context imbalance in 'test_mutex_trylock' - unexpected unlock
lib/test_context-analysis.c:203:20: sparse: sparse: context imbalance in 'test_mutex_guard' - wrong count at exit
lib/test_context-analysis.c:209:20: sparse: sparse: context imbalance in 'test_mutex_cond_guard' - wrong count at exit
lib/test_context-analysis.c:263:9: sparse: sparse: context imbalance in 'test_seqlock_scoped' - wrong count at exit
lib/test_context-analysis.c:286:17: sparse: sparse: context imbalance in 'test_rwsem_reader' - unexpected unlock
lib/test_context-analysis.c:304:17: sparse: sparse: context imbalance in 'test_rwsem_writer' - unexpected unlock
lib/test_context-analysis.c:315:20: sparse: sparse: context imbalance in 'test_rwsem_guard' - wrong count at exit
lib/test_context-analysis.c:321:20: sparse: sparse: context imbalance in 'test_rwsem_cond_guard' - wrong count at exit
lib/test_context-analysis.c: note: in included file:
include/linux/bit_spinlock.h:78:25: sparse: sparse: context imbalance in 'test_bit_spin_lock' - unexpected unlock
lib/test_context-analysis.c:461:53: sparse: sparse: context imbalance in 'test_srcu_guard' - wrong count at exit
lib/test_context-analysis.c: note: in included file:
>> include/linux/local_lock.h:86:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:86:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:86:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
>> include/linux/local_lock.h:86:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:86:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:86:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
include/linux/local_lock.h:89:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:89:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:89:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
include/linux/local_lock.h:89:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:89:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:89:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
include/linux/local_lock.h:92:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:92:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:92:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
include/linux/local_lock.h:92:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:92:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:92:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
include/linux/local_lock.h:103:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_trylock [noderef] [usertype] __percpu *base @@ got struct local_lock [noderef] [usertype] __percpu *[usertype] lock @@
include/linux/local_lock.h:103:1: sparse: expected struct local_trylock [noderef] [usertype] __percpu *base
include/linux/local_lock.h:103:1: sparse: got struct local_lock [noderef] [usertype] __percpu *[usertype] lock
>> include/linux/local_lock.h:103:1: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct local_lock [usertype] *l @@ got struct local_trylock [usertype] * @@
include/linux/local_lock.h:103:1: sparse: expected struct local_lock [usertype] *l
include/linux/local_lock.h:103:1: sparse: got struct local_trylock [usertype] *
lib/test_context-analysis.c:505:68: sparse: sparse: context imbalance in 'test_local_lock_guard' - wrong count at exit
lib/test_context-analysis.c:530:17: sparse: sparse: context imbalance in 'test_local_trylock' - unexpected unlock

vim +483 lib/test_context-analysis.c

478
479 static void __used test_local_lock(void)
480 {
481 unsigned long flags;
482
> 483 local_lock(&test_local_lock_data.lock);
484 this_cpu_add(test_local_lock_data.counter, 1);
485 local_unlock(&test_local_lock_data.lock);
486
487 local_lock_irq(&test_local_lock_data.lock);
488 this_cpu_add(test_local_lock_data.counter, 1);
489 local_unlock_irq(&test_local_lock_data.lock);
490
491 local_lock_irqsave(&test_local_lock_data.lock, flags);
492 this_cpu_add(test_local_lock_data.counter, 1);
> 493 local_unlock_irqrestore(&test_local_lock_data.lock, flags);
494
> 495 local_lock_nested_bh(&test_local_lock_data.lock);
496 this_cpu_add(test_local_lock_data.counter, 1);
497 local_unlock_nested_bh(&test_local_lock_data.lock);
498 }
499

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki