Re: [PATCH] locking/rwsem: Optionally re-enable reader optimistic spinning

From: kernel test robot
Date: Thu Jun 01 2023 - 03:11:18 EST


Hi Bongkyu,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/locking/core]
[also build test WARNING on linus/master v6.4-rc4 next-20230601]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Bongkyu-Kim/locking-rwsem-Optionally-re-enable-reader-optimistic-spinning/20230531-083658
base: tip/locking/core
patch link: https://lore.kernel.org/r/20230531003436.7082-1-bongkyu7.kim%40samsung.com
patch subject: [PATCH] locking/rwsem: Optionally re-enable reader optimistic spinning
config: x86_64-randconfig-x063-20230531 (https://download.01.org/0day-ci/archive/20230601/202306011420.8opqhG4p-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/8c4098eb89be5b82aded3d17b22f78013454d058
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Bongkyu-Kim/locking-rwsem-Optionally-re-enable-reader-optimistic-spinning/20230531-083658
git checkout 8c4098eb89be5b82aded3d17b22f78013454d058
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/events/ arch/x86/kernel/fpu/ drivers/of/ drivers/usb/host/ kernel/locking/ kernel/sched/

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

All warnings (new ones prefixed by >>):

>> kernel/locking/rwsem.c:1163:24: warning: incompatible pointer to integer conversion passing 'struct rw_semaphore *' to parameter of type 'int' [-Wint-conversion]
rwsem_no_spinners(sem)) {
^~~
kernel/locking/rwsem.c:332:1: warning: unused function 'rwsem_owner_flags' [-Wunused-function]
rwsem_owner_flags(struct rw_semaphore *sem, unsigned long *pflags)
^
2 warnings generated.


vim +1163 kernel/locking/rwsem.c

1133
1134 /*
1135 * Wait for the read lock to be granted
1136 */
1137 static struct rw_semaphore __sched *
1138 rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int state)
1139 {
1140 long owner, adjustment = -RWSEM_READER_BIAS;
1141 long rcnt = (count >> RWSEM_READER_SHIFT);
1142 struct rwsem_waiter waiter;
1143 DEFINE_WAKE_Q(wake_q);
1144
1145 /*
1146 * To prevent a constant stream of readers from starving a sleeping
1147 * waiter, don't attempt optimistic spinning if the lock is currently
1148 * owned by readers.
1149 */
1150 owner = atomic_long_read(&sem->owner);
1151 if ((owner & RWSEM_READER_OWNED) && (rcnt > 1) &&
1152 !(count & RWSEM_WRITER_LOCKED))
1153 goto queue;
1154
1155 /*
1156 * Reader optimistic lock stealing
1157 *
1158 * We can take the read lock directly without doing
1159 * rwsem_optimistic_spin() if the conditions are right.
1160 * Also wake up other readers if it is the first reader.
1161 */
1162 if (!(count & (RWSEM_WRITER_LOCKED | RWSEM_FLAG_HANDOFF)) &&
> 1163 rwsem_no_spinners(sem)) {
1164 rwsem_set_reader_owned(sem);
1165 lockevent_inc(rwsem_rlock_steal);
1166 if (rcnt == 1)
1167 goto wake_readers;
1168 return sem;
1169 }
1170

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