kernel/rcu/refscale.c:614:24: sparse: sparse: incompatible types in comparison expression (different address spaces):

From: kernel test robot
Date: Fri Feb 24 2023 - 09:13:37 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d2980d8d826554fa6981d621e569a453787472f8
commit: a6889becb05394255c80b62103677e3b095726a9 refscale: Add tests using SLAB_TYPESAFE_BY_RCU
date: 7 weeks ago
config: parisc-randconfig-s052-20230222 (https://download.01.org/0day-ci/archive/20230224/202302242216.C9zAq2tw-lkp@xxxxxxxxx/config)
compiler: hppa-linux-gcc (GCC) 12.1.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-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a6889becb05394255c80b62103677e3b095726a9
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout a6889becb05394255c80b62103677e3b095726a9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc SHELL=/bin/bash kernel/rcu/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202302242216.C9zAq2tw-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> kernel/rcu/refscale.c:614:24: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> kernel/rcu/refscale.c:614:24: sparse: struct refscale_typesafe [noderef] __rcu *
>> kernel/rcu/refscale.c:614:24: sparse: struct refscale_typesafe *
kernel/rcu/refscale.c:569:13: sparse: sparse: context imbalance in 'typesafe_lock_acquire' - wrong count at exit
kernel/rcu/refscale.c:576:13: sparse: sparse: context imbalance in 'typesafe_lock_release' - unexpected unlock

vim +614 kernel/rcu/refscale.c

595
596 // Do a read-side critical section with the specified delay in
597 // microseconds and nanoseconds inserted so as to increase probability
598 // of failure.
599 static void typesafe_delay_section(const int nloops, const int udl, const int ndl)
600 {
601 unsigned int a;
602 unsigned int b;
603 int i;
604 long idx;
605 struct refscale_typesafe *rtsp;
606 unsigned int start;
607
608 for (i = nloops; i >= 0; i--) {
609 preempt_disable();
610 idx = torture_random(this_cpu_ptr(&refscale_rand)) % rtsarray_size;
611 preempt_enable();
612 retry:
613 rcu_read_lock();
> 614 rtsp = rcu_dereference(rtsarray[idx]);
615 a = READ_ONCE(rtsp->a);
616 if (!rts_acquire(rtsp, &start)) {
617 rcu_read_unlock();
618 goto retry;
619 }
620 if (a != READ_ONCE(rtsp->a)) {
621 (void)rts_release(rtsp, start);
622 rcu_read_unlock();
623 goto retry;
624 }
625 un_delay(udl, ndl);
626 // Remember, seqlock read-side release can fail.
627 if (!rts_release(rtsp, start)) {
628 rcu_read_unlock();
629 goto retry;
630 }
631 b = READ_ONCE(rtsp->a);
632 WARN_ONCE(a != b, "Re-read of ->a changed from %u to %u.\n", a, b);
633 b = rtsp->b;
634 rcu_read_unlock();
635 WARN_ON_ONCE(a * a != b);
636 }
637 }
638

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