Messages in this thread | | | Date | Fri, 3 Sep 2021 06:06:24 +0800 | From | kernel test robot <> | Subject | [tip:locking/urgent 3/5] kernel/futex.c:2016:18: warning: variable 'vpid' set but not used |
| |
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/urgent head: 340576590dac4bb58d532a8ad5bfa806d8ab473c commit: 4f07ec0d76f242d4ca0f0c0c6f7293c28254a554 [3/5] futex: Prevent inconsistent state and exit race config: riscv-randconfig-r042-20210903 (attached as .config) compiler: riscv64-linux-gcc (GCC) 11.2.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/tip/tip.git/commit/?id=4f07ec0d76f242d4ca0f0c0c6f7293c28254a554 git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git git fetch --no-tags tip locking/urgent git checkout 4f07ec0d76f242d4ca0f0c0c6f7293c28254a554 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
kernel/futex.c: In function 'futex_proxy_trylock_atomic': >> kernel/futex.c:2016:18: warning: variable 'vpid' set but not used [-Wunused-but-set-variable] 2016 | int ret, vpid; | ^~~~
vim +/vpid +2016 kernel/futex.c
52400ba946759af Darren Hart 2009-04-03 1981 52400ba946759af Darren Hart 2009-04-03 1982 /** 52400ba946759af Darren Hart 2009-04-03 1983 * futex_proxy_trylock_atomic() - Attempt an atomic lock for the top waiter 52400ba946759af Darren Hart 2009-04-03 1984 * @pifutex: the user address of the to futex 52400ba946759af Darren Hart 2009-04-03 1985 * @hb1: the from futex hash bucket, must be locked by the caller 52400ba946759af Darren Hart 2009-04-03 1986 * @hb2: the to futex hash bucket, must be locked by the caller 52400ba946759af Darren Hart 2009-04-03 1987 * @key1: the from futex key 52400ba946759af Darren Hart 2009-04-03 1988 * @key2: the to futex key bab5bc9e8576388 Darren Hart 2009-04-07 1989 * @ps: address to store the pi_state pointer 3ef240eaff36b81 Thomas Gleixner 2019-11-06 1990 * @exiting: Pointer to store the task pointer of the owner task 3ef240eaff36b81 Thomas Gleixner 2019-11-06 1991 * which is in the middle of exiting bab5bc9e8576388 Darren Hart 2009-04-07 1992 * @set_waiters: force setting the FUTEX_WAITERS bit (1) or not (0) 52400ba946759af Darren Hart 2009-04-03 1993 * 52400ba946759af Darren Hart 2009-04-03 1994 * Try and get the lock on behalf of the top waiter if we can do it atomically. bab5bc9e8576388 Darren Hart 2009-04-07 1995 * Wake the top waiter if we succeed. If the caller specified set_waiters, bab5bc9e8576388 Darren Hart 2009-04-07 1996 * then direct futex_lock_pi_atomic() to force setting the FUTEX_WAITERS bit. bab5bc9e8576388 Darren Hart 2009-04-07 1997 * hb1 and hb2 must be held by the caller. 52400ba946759af Darren Hart 2009-04-03 1998 * 3ef240eaff36b81 Thomas Gleixner 2019-11-06 1999 * @exiting is only set when the return value is -EBUSY. If so, this holds 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2000 * a refcount on the exiting task on return and the caller needs to drop it 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2001 * after waiting for the exit to complete. 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2002 * 6c23cbbd5056b15 Randy Dunlap 2013-03-05 2003 * Return: 7b4ff1adb57ad96 Mauro Carvalho Chehab 2017-05-11 2004 * - 0 - failed to acquire the lock atomically; 7b4ff1adb57ad96 Mauro Carvalho Chehab 2017-05-11 2005 * - >0 - acquired the lock, return value is vpid of the top_waiter 7b4ff1adb57ad96 Mauro Carvalho Chehab 2017-05-11 2006 * - <0 - error 52400ba946759af Darren Hart 2009-04-03 2007 */ 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2008 static int 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2009 futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1, 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2010 struct futex_hash_bucket *hb2, union futex_key *key1, 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2011 union futex_key *key2, struct futex_pi_state **ps, 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2012 struct task_struct **exiting, int set_waiters) 52400ba946759af Darren Hart 2009-04-03 2013 { bab5bc9e8576388 Darren Hart 2009-04-07 2014 struct futex_q *top_waiter = NULL; 52400ba946759af Darren Hart 2009-04-03 2015 u32 curval; 866293ee5422758 Thomas Gleixner 2014-05-12 @2016 int ret, vpid; 52400ba946759af Darren Hart 2009-04-03 2017 52400ba946759af Darren Hart 2009-04-03 2018 if (get_futex_value_locked(&curval, pifutex)) 52400ba946759af Darren Hart 2009-04-03 2019 return -EFAULT; 52400ba946759af Darren Hart 2009-04-03 2020 ab51fbab39d864f Davidlohr Bueso 2015-06-29 2021 if (unlikely(should_fail_futex(true))) ab51fbab39d864f Davidlohr Bueso 2015-06-29 2022 return -EFAULT; ab51fbab39d864f Davidlohr Bueso 2015-06-29 2023 bab5bc9e8576388 Darren Hart 2009-04-07 2024 /* bab5bc9e8576388 Darren Hart 2009-04-07 2025 * Find the top_waiter and determine if there are additional waiters. bab5bc9e8576388 Darren Hart 2009-04-07 2026 * If the caller intends to requeue more than 1 waiter to pifutex, bab5bc9e8576388 Darren Hart 2009-04-07 2027 * force futex_lock_pi_atomic() to set the FUTEX_WAITERS bit now, bab5bc9e8576388 Darren Hart 2009-04-07 2028 * as we have means to handle the possible fault. If not, don't set 93d0955e6cf562d Ingo Molnar 2021-05-12 2029 * the bit unnecessarily as it will force the subsequent unlock to enter bab5bc9e8576388 Darren Hart 2009-04-07 2030 * the kernel. bab5bc9e8576388 Darren Hart 2009-04-07 2031 */ 52400ba946759af Darren Hart 2009-04-03 2032 top_waiter = futex_top_waiter(hb1, key1); 52400ba946759af Darren Hart 2009-04-03 2033 52400ba946759af Darren Hart 2009-04-03 2034 /* There are no waiters, nothing for us to do. */ 52400ba946759af Darren Hart 2009-04-03 2035 if (!top_waiter) 52400ba946759af Darren Hart 2009-04-03 2036 return 0; 52400ba946759af Darren Hart 2009-04-03 2037 dc7109aaa233d83 Thomas Gleixner 2021-08-15 2038 /* dc7109aaa233d83 Thomas Gleixner 2021-08-15 2039 * Ensure that this is a waiter sitting in futex_wait_requeue_pi() dc7109aaa233d83 Thomas Gleixner 2021-08-15 2040 * and waiting on the 'waitqueue' futex which is always !PI. dc7109aaa233d83 Thomas Gleixner 2021-08-15 2041 */ dc7109aaa233d83 Thomas Gleixner 2021-08-15 2042 if (!top_waiter->rt_waiter || top_waiter->pi_state) a974b54036f79dd Colin Ian King 2021-08-18 2043 return -EINVAL; dc7109aaa233d83 Thomas Gleixner 2021-08-15 2044 84bc4af59081ee9 Darren Hart 2009-08-13 2045 /* Ensure we requeue to the expected futex. */ 84bc4af59081ee9 Darren Hart 2009-08-13 2046 if (!match_futex(top_waiter->requeue_pi_key, key2)) 84bc4af59081ee9 Darren Hart 2009-08-13 2047 return -EINVAL; 84bc4af59081ee9 Darren Hart 2009-08-13 2048 07d91ef510fb16a Thomas Gleixner 2021-08-15 2049 /* Ensure that this does not race against an early wakeup */ 07d91ef510fb16a Thomas Gleixner 2021-08-15 2050 if (!futex_requeue_pi_prepare(top_waiter, NULL)) 07d91ef510fb16a Thomas Gleixner 2021-08-15 2051 return -EAGAIN; 07d91ef510fb16a Thomas Gleixner 2021-08-15 2052 ^1da177e4c3f415 Linus Torvalds 2005-04-16 2053 /* 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2054 * Try to take the lock for top_waiter and set the FUTEX_WAITERS bit 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2055 * in the contended case or if @set_waiters is true. 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2056 * 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2057 * In the contended case PI state is attached to the lock owner. If 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2058 * the user space lock can be acquired then PI state is attached to 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2059 * the new owner (@top_waiter->task) when @set_waiters is true. 52400ba946759af Darren Hart 2009-04-03 2060 */ 866293ee5422758 Thomas Gleixner 2014-05-12 2061 vpid = task_pid_vnr(top_waiter->task); bab5bc9e8576388 Darren Hart 2009-04-07 2062 ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task, 3ef240eaff36b81 Thomas Gleixner 2019-11-06 2063 exiting, set_waiters); 866293ee5422758 Thomas Gleixner 2014-05-12 2064 if (ret == 1) { 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2065 /* 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2066 * Lock was acquired in user space and PI state was 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2067 * attached to @top_waiter->task. That means state is fully 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2068 * consistent and the waiter can return to user space 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2069 * immediately after the wakeup. 4f07ec0d76f242d Thomas Gleixner 2021-09-02 2070 */ beda2c7ea2c15ed Darren Hart 2009-08-09 2071 requeue_pi_wake_futex(top_waiter, key2, hb2); 07d91ef510fb16a Thomas Gleixner 2021-08-15 2072 } else if (ret < 0) { 07d91ef510fb16a Thomas Gleixner 2021-08-15 2073 /* Rewind top_waiter::requeue_state */ 07d91ef510fb16a Thomas Gleixner 2021-08-15 2074 futex_requeue_pi_complete(top_waiter, ret); 07d91ef510fb16a Thomas Gleixner 2021-08-15 2075 } else { 07d91ef510fb16a Thomas Gleixner 2021-08-15 2076 /* 07d91ef510fb16a Thomas Gleixner 2021-08-15 2077 * futex_lock_pi_atomic() did not acquire the user space 07d91ef510fb16a Thomas Gleixner 2021-08-15 2078 * futex, but managed to establish the proxy lock and pi 07d91ef510fb16a Thomas Gleixner 2021-08-15 2079 * state. top_waiter::requeue_state cannot be fixed up here 07d91ef510fb16a Thomas Gleixner 2021-08-15 2080 * because the waiter is not enqueued on the rtmutex 07d91ef510fb16a Thomas Gleixner 2021-08-15 2081 * yet. This is handled at the callsite depending on the 07d91ef510fb16a Thomas Gleixner 2021-08-15 2082 * result of rt_mutex_start_proxy_lock() which is 07d91ef510fb16a Thomas Gleixner 2021-08-15 2083 * guaranteed to be reached with this function returning 0. 07d91ef510fb16a Thomas Gleixner 2021-08-15 2084 */ 866293ee5422758 Thomas Gleixner 2014-05-12 2085 } 52400ba946759af Darren Hart 2009-04-03 2086 return ret; 52400ba946759af Darren Hart 2009-04-03 2087 } 52400ba946759af Darren Hart 2009-04-03 2088
:::::: The code at line 2016 was first introduced by commit :::::: 866293ee54227584ffcb4a42f69c1f365974ba7f futex: Add another early deadlock detection check
:::::: TO: Thomas Gleixner <tglx@linutronix.de> :::::: CC: Thomas Gleixner <tglx@linutronix.de>
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [unhandled content-type:application/gzip] | |