tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git rtmutex head: 91fb95023a1645acf99daa67e51cc1f5e2bc8b8e commit: c4c28f993851857356b76b7471f74cd154d58b84 [3/65] sched: Reorganize current::__state helpers config: nios2-randconfig-r032-20210804 (attached as .config) compiler: nios2-linux-gcc (GCC) 10.3.0 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 # https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git/commit/?id=c4c28f993851857356b76b7471f74cd154d58b84 git remote add tglx-devel https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git git fetch --no-tags tglx-devel rtmutex git checkout c4c28f993851857356b76b7471f74cd154d58b84 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=nios2 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): In file included from arch/nios2/kernel/asm-offsets.c:7: include/linux/sched.h:147:3: error: invalid preprocessing directive #debug_normal_state_change 147 | # debug_normal_state_change(cond) do { } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/sched.h:148:3: error: invalid preprocessing directive #debug_special_state_change 148 | # debug_special_state_change(cond) do { } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from arch/nios2/kernel/asm-offsets.c:7: include/linux/sched/signal.h: In function 'kernel_signal_stop': >> include/linux/sched.h:211:3: error: implicit declaration of function 'debug_special_state_change' [-Werror=implicit-function-declaration] 211 | debug_special_state_change((state_value)); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/sched/signal.h:296:3: note: in expansion of macro 'set_special_state' 296 | set_special_state(TASK_STOPPED); | ^~~~~~~~~~~~~~~~~ include/linux/rcuwait.h: In function 'finish_rcuwait': >> include/linux/sched.h:190:3: error: implicit declaration of function 'debug_normal_state_change' [-Werror=implicit-function-declaration] 190 | debug_normal_state_change((state_value)); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/rcuwait.h:53:2: note: in expansion of macro '__set_current_state' 53 | __set_current_state(TASK_RUNNING); | ^~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors -- In file included from arch/nios2/kernel/asm-offsets.c:7: include/linux/sched.h:147:3: error: invalid preprocessing directive #debug_normal_state_change 147 | # debug_normal_state_change(cond) do { } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/sched.h:148:3: error: invalid preprocessing directive #debug_special_state_change 148 | # debug_special_state_change(cond) do { } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from arch/nios2/kernel/asm-offsets.c:7: include/linux/sched/signal.h: In function 'kernel_signal_stop': >> include/linux/sched.h:211:3: error: implicit declaration of function 'debug_special_state_change' [-Werror=implicit-function-declaration] 211 | debug_special_state_change((state_value)); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/sched/signal.h:296:3: note: in expansion of macro 'set_special_state' 296 | set_special_state(TASK_STOPPED); | ^~~~~~~~~~~~~~~~~ include/linux/rcuwait.h: In function 'finish_rcuwait': >> include/linux/sched.h:190:3: error: implicit declaration of function 'debug_normal_state_change' [-Werror=implicit-function-declaration] 190 | debug_normal_state_change((state_value)); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/rcuwait.h:53:2: note: in expansion of macro '__set_current_state' 53 | __set_current_state(TASK_RUNNING); | ^~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:117: arch/nios2/kernel/asm-offsets.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1213: prepare0] Error 2 make[1]: Target 'prepare' not remade because of errors. make: *** [Makefile:220: __sub-make] Error 2 make: Target 'prepare' not remade because of errors. vim +/debug_special_state_change +211 include/linux/sched.h 150 151 /* 152 * set_current_state() includes a barrier so that the write of current->state 153 * is correctly serialised wrt the caller's subsequent test of whether to 154 * actually sleep: 155 * 156 * for (;;) { 157 * set_current_state(TASK_UNINTERRUPTIBLE); 158 * if (CONDITION) 159 * break; 160 * 161 * schedule(); 162 * } 163 * __set_current_state(TASK_RUNNING); 164 * 165 * If the caller does not need such serialisation (because, for instance, the 166 * CONDITION test and condition change and wakeup are under the same lock) then 167 * use __set_current_state(). 168 * 169 * The above is typically ordered against the wakeup, which does: 170 * 171 * CONDITION = 1; 172 * wake_up_state(p, TASK_UNINTERRUPTIBLE); 173 * 174 * where wake_up_state()/try_to_wake_up() executes a full memory barrier before 175 * accessing p->state. 176 * 177 * Wakeup will do: if (@state & p->state) p->state = TASK_RUNNING, that is, 178 * once it observes the TASK_UNINTERRUPTIBLE store the waking CPU can issue a 179 * TASK_RUNNING store which can collide with __set_current_state(TASK_RUNNING). 180 * 181 * However, with slightly different timing the wakeup TASK_RUNNING store can 182 * also collide with the TASK_UNINTERRUPTIBLE store. Losing that store is not 183 * a problem either because that will result in one extra go around the loop 184 * and our @cond test will save the day. 185 * 186 * Also see the comments of try_to_wake_up(). 187 */ 188 #define __set_current_state(state_value) \ 189 do { \ > 190 debug_normal_state_change((state_value)); \ 191 WRITE_ONCE(current->__state, (state_value)); \ 192 } while (0) 193 194 #define set_current_state(state_value) \ 195 do { \ 196 debug_normal_state_change((state_value)); \ 197 smp_store_mb(current->__state, (state_value)); \ 198 } while (0) 199 200 /* 201 * set_special_state() should be used for those states when the blocking task 202 * can not use the regular condition based wait-loop. In that case we must 203 * serialize against wakeups such that any possible in-flight TASK_RUNNING 204 * stores will not collide with our state change. 205 */ 206 #define set_special_state(state_value) \ 207 do { \ 208 unsigned long flags; /* may shadow */ \ 209 \ 210 raw_spin_lock_irqsave(¤t->pi_lock, flags); \ > 211 debug_special_state_change((state_value)); \ 212 WRITE_ONCE(current->__state, (state_value)); \ 213 raw_spin_unlock_irqrestore(¤t->pi_lock, flags); \ 214 } while (0) 215 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org