Re: [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Hi Peter, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) kernel/locking/locktorture.c:444:9: sparse: undefined identifier 'rt_mutex_lock' kernel/locking/locktorture.c:586:6: sparse: symbol 'torture_percpu_rwsem_init' was not declared. Should it be static? kernel/locking/locktorture.c:331:12: sparse: context imbalance in 'torture_mutex_lock' - wrong count at exit kernel/locking/locktorture.c:351:13: sparse: context imbalance in 'torture_mutex_unlock' - wrong count at exit kernel/locking/locktorture.c:373:12: sparse: context imbalance in 'torture_ww_mutex_lock' - wrong count at exit kernel/locking/locktorture.c:418:13: sparse: context imbalance in 'torture_ww_mutex_unlock' - wrong count at exit >> kernel/locking/locktorture.c:444:22: sparse: call with no type! kernel/locking/locktorture.c:442:12: sparse: context imbalance in 'torture_rtmutex_lock' - wrong count at exit kernel/locking/locktorture.c:504:13: sparse: context imbalance in 'torture_rtmutex_unlock' - wrong count at exit kernel/locking/locktorture.c:522:12: sparse: context imbalance in 'torture_rwsem_down_write' - wrong count at exit kernel/locking/locktorture.c:542:13: sparse: context imbalance in 'torture_rwsem_up_write' - wrong count at exit kernel/locking/locktorture.c:547:12: sparse: context imbalance in 'torture_rwsem_down_read' - wrong count at exit kernel/locking/locktorture.c:567:13: sparse: context imbalance in 'torture_rwsem_up_read' - wrong count at exit kernel/locking/locktorture.c:591:12: sparse: context imbalance in 'torture_percpu_rwsem_down_write' - wrong count at exit kernel/locking/locktorture.c:597:13: sparse: context imbalance in 'torture_percpu_rwsem_up_write' - wrong count at exit include/linux/percpu-rwsem.h:50:9: sparse: context imbalance in 'torture_percpu_rwsem_down_read' - wrong count at exit include/linux/percpu-rwsem.h:100:9: sparse: context imbalance in 'torture_percpu_rwsem_up_read' - wrong count at exit kernel/locking/locktorture.c: In function 'torture_rtmutex_lock': kernel/locking/locktorture.c:444:2: error: implicit declaration of function 'rt_mutex_lock'; did you mean 'ww_mutex_lock'? [-Werror=implicit-function-declaration] rt_mutex_lock(_rtmutex); ^ ww_mutex_lock cc1: some warnings being treated as errors -- drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c:4225:9: sparse: undefined identifier 'rt_mutex_lock' >> drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c:4225:22: >> sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c: In function 'atomisp_css_wait_acc_finish': drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c:4225:2: error: implicit declaration of function 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? [-Werror=implicit-function-declaration] rt_mutex_lock(>mutex); ^ rt_mutex_unlock cc1: some warnings being treated as errors -- drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:774:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:910:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1174:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1265:9: sparse: undefined identifier 'rt_mutex_lock' >> drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:774:22: sparse: >> call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:910:22: sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1174:22: sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1265:22: sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c: In function 'atomisp_open': drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:774:2: error: implicit declaration of function 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? [-Werror=implicit-function-declaration] rt_mutex_lock(>mutex); ^ rt_mutex_unlock cc1: some warnings being treated as errors -- drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:663:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:680:9: sparse: undefined identifier 'rt_mutex_lock'
Re: [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Hi Peter, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) kernel/locking/locktorture.c:444:9: sparse: undefined identifier 'rt_mutex_lock' kernel/locking/locktorture.c:586:6: sparse: symbol 'torture_percpu_rwsem_init' was not declared. Should it be static? kernel/locking/locktorture.c:331:12: sparse: context imbalance in 'torture_mutex_lock' - wrong count at exit kernel/locking/locktorture.c:351:13: sparse: context imbalance in 'torture_mutex_unlock' - wrong count at exit kernel/locking/locktorture.c:373:12: sparse: context imbalance in 'torture_ww_mutex_lock' - wrong count at exit kernel/locking/locktorture.c:418:13: sparse: context imbalance in 'torture_ww_mutex_unlock' - wrong count at exit >> kernel/locking/locktorture.c:444:22: sparse: call with no type! kernel/locking/locktorture.c:442:12: sparse: context imbalance in 'torture_rtmutex_lock' - wrong count at exit kernel/locking/locktorture.c:504:13: sparse: context imbalance in 'torture_rtmutex_unlock' - wrong count at exit kernel/locking/locktorture.c:522:12: sparse: context imbalance in 'torture_rwsem_down_write' - wrong count at exit kernel/locking/locktorture.c:542:13: sparse: context imbalance in 'torture_rwsem_up_write' - wrong count at exit kernel/locking/locktorture.c:547:12: sparse: context imbalance in 'torture_rwsem_down_read' - wrong count at exit kernel/locking/locktorture.c:567:13: sparse: context imbalance in 'torture_rwsem_up_read' - wrong count at exit kernel/locking/locktorture.c:591:12: sparse: context imbalance in 'torture_percpu_rwsem_down_write' - wrong count at exit kernel/locking/locktorture.c:597:13: sparse: context imbalance in 'torture_percpu_rwsem_up_write' - wrong count at exit include/linux/percpu-rwsem.h:50:9: sparse: context imbalance in 'torture_percpu_rwsem_down_read' - wrong count at exit include/linux/percpu-rwsem.h:100:9: sparse: context imbalance in 'torture_percpu_rwsem_up_read' - wrong count at exit kernel/locking/locktorture.c: In function 'torture_rtmutex_lock': kernel/locking/locktorture.c:444:2: error: implicit declaration of function 'rt_mutex_lock'; did you mean 'ww_mutex_lock'? [-Werror=implicit-function-declaration] rt_mutex_lock(_rtmutex); ^ ww_mutex_lock cc1: some warnings being treated as errors -- drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c:4225:9: sparse: undefined identifier 'rt_mutex_lock' >> drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c:4225:22: >> sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c: In function 'atomisp_css_wait_acc_finish': drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c:4225:2: error: implicit declaration of function 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? [-Werror=implicit-function-declaration] rt_mutex_lock(>mutex); ^ rt_mutex_unlock cc1: some warnings being treated as errors -- drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:774:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:910:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1174:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1265:9: sparse: undefined identifier 'rt_mutex_lock' >> drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:774:22: sparse: >> call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:910:22: sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1174:22: sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:1265:22: sparse: call with no type! drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c: In function 'atomisp_open': drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c:774:2: error: implicit declaration of function 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? [-Werror=implicit-function-declaration] rt_mutex_lock(>mutex); ^ rt_mutex_unlock cc1: some warnings being treated as errors -- drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:663:9: sparse: undefined identifier 'rt_mutex_lock' drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c:680:9: sparse: undefined identifier 'rt_mutex_lock'
Re: [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Hi Peter, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 config: x86_64-randconfig-x003-201820 (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 Note: the linux-review/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 HEAD e9f3abe10927b5d6e565ac45d0814e6198b49649 builds fine. It only hurts bisectibility. All errors (new ones prefixed by >>): drivers/i2c/i2c-core-base.c: In function 'i2c_adapter_lock_bus': >> drivers/i2c/i2c-core-base.c:618:2: error: implicit declaration of function >> 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? >> [-Werror=implicit-function-declaration] rt_mutex_lock(>bus_lock); ^ rt_mutex_unlock cc1: some warnings being treated as errors -- drivers/i2c/i2c-mux.c: In function 'i2c_mux_lock_bus': >> drivers/i2c/i2c-mux.c:147:2: error: implicit declaration of function >> 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? >> [-Werror=implicit-function-declaration] rt_mutex_lock(>mux_lock); ^ rt_mutex_unlock cc1: some warnings being treated as errors vim +618 drivers/i2c/i2c-core-base.c 3b5f794b drivers/i2c/i2c-core.c Jean Delvare 2010-06-03 608 9c1600ed drivers/i2c/i2c-core.c David Brownell 2007-05-01 609 /** 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 610 * i2c_adapter_lock_bus - Get exclusive access to an I2C bus segment fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 611 * @adapter: Target I2C bus segment 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 612 * @flags: I2C_LOCK_ROOT_ADAPTER locks the root i2c adapter, I2C_LOCK_SEGMENT 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 613 * locks only this branch in the adapter tree fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 614 */ 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 615 static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 616 unsigned int flags) fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 617 { fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 @618 rt_mutex_lock(>bus_lock); fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 619 } fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 620 :: The code at line 618 was first introduced by commit :: fe61e07e9ebc890c70d97a1f72ddaad4bee2d848 i2c: Move adapter locking helpers to i2c-core :: TO: Jean Delvare:: CC: Jean Delvare --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Hi Peter, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 config: x86_64-randconfig-x003-201820 (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 Note: the linux-review/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 HEAD e9f3abe10927b5d6e565ac45d0814e6198b49649 builds fine. It only hurts bisectibility. All errors (new ones prefixed by >>): drivers/i2c/i2c-core-base.c: In function 'i2c_adapter_lock_bus': >> drivers/i2c/i2c-core-base.c:618:2: error: implicit declaration of function >> 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? >> [-Werror=implicit-function-declaration] rt_mutex_lock(>bus_lock); ^ rt_mutex_unlock cc1: some warnings being treated as errors -- drivers/i2c/i2c-mux.c: In function 'i2c_mux_lock_bus': >> drivers/i2c/i2c-mux.c:147:2: error: implicit declaration of function >> 'rt_mutex_lock'; did you mean 'rt_mutex_unlock'? >> [-Werror=implicit-function-declaration] rt_mutex_lock(>mux_lock); ^ rt_mutex_unlock cc1: some warnings being treated as errors vim +618 drivers/i2c/i2c-core-base.c 3b5f794b drivers/i2c/i2c-core.c Jean Delvare 2010-06-03 608 9c1600ed drivers/i2c/i2c-core.c David Brownell 2007-05-01 609 /** 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 610 * i2c_adapter_lock_bus - Get exclusive access to an I2C bus segment fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 611 * @adapter: Target I2C bus segment 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 612 * @flags: I2C_LOCK_ROOT_ADAPTER locks the root i2c adapter, I2C_LOCK_SEGMENT 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 613 * locks only this branch in the adapter tree fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 614 */ 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 615 static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, 8320f495 drivers/i2c/i2c-core.c Peter Rosin2016-05-04 616 unsigned int flags) fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 617 { fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 @618 rt_mutex_lock(>bus_lock); fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 619 } fe61e07e drivers/i2c/i2c-core.c Jean Delvare 2010-08-11 620 :: The code at line 618 was first introduced by commit :: fe61e07e9ebc890c70d97a1f72ddaad4bee2d848 i2c: Move adapter locking helpers to i2c-core :: TO: Jean Delvare :: CC: Jean Delvare --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Hi Peter, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 config: x86_64-randconfig-i0-201820 (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): kernel/locking/locktorture.c: In function 'torture_rtmutex_lock': >> kernel/locking/locktorture.c:444:2: error: implicit declaration of function >> 'rt_mutex_lock'; did you mean 'ww_mutex_lock'? >> [-Werror=implicit-function-declaration] rt_mutex_lock(_rtmutex); ^ ww_mutex_lock cc1: some warnings being treated as errors vim +444 kernel/locking/locktorture.c 095777c4 Davidlohr Bueso 2015-07-22 441 095777c4 Davidlohr Bueso 2015-07-22 442 static int torture_rtmutex_lock(void) __acquires(torture_rtmutex) 095777c4 Davidlohr Bueso 2015-07-22 443 { 095777c4 Davidlohr Bueso 2015-07-22 @444rt_mutex_lock(_rtmutex); 095777c4 Davidlohr Bueso 2015-07-22 445return 0; 095777c4 Davidlohr Bueso 2015-07-22 446 } 095777c4 Davidlohr Bueso 2015-07-22 447 :: The code at line 444 was first introduced by commit :: 095777c417db142970adeb776fa0cb10810b8122 locktorture: Support rtmutex torturing :: TO: Davidlohr Bueso:: CC: Paul E. McKenney --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Hi Peter, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.17-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Peter-Rosin/rtmutex-allow-specifying-a-subclass-for-nested-locking/20180526-140421 config: x86_64-randconfig-i0-201820 (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): kernel/locking/locktorture.c: In function 'torture_rtmutex_lock': >> kernel/locking/locktorture.c:444:2: error: implicit declaration of function >> 'rt_mutex_lock'; did you mean 'ww_mutex_lock'? >> [-Werror=implicit-function-declaration] rt_mutex_lock(_rtmutex); ^ ww_mutex_lock cc1: some warnings being treated as errors vim +444 kernel/locking/locktorture.c 095777c4 Davidlohr Bueso 2015-07-22 441 095777c4 Davidlohr Bueso 2015-07-22 442 static int torture_rtmutex_lock(void) __acquires(torture_rtmutex) 095777c4 Davidlohr Bueso 2015-07-22 443 { 095777c4 Davidlohr Bueso 2015-07-22 @444rt_mutex_lock(_rtmutex); 095777c4 Davidlohr Bueso 2015-07-22 445return 0; 095777c4 Davidlohr Bueso 2015-07-22 446 } 095777c4 Davidlohr Bueso 2015-07-22 447 :: The code at line 444 was first introduced by commit :: 095777c417db142970adeb776fa0cb10810b8122 locktorture: Support rtmutex torturing :: TO: Davidlohr Bueso :: CC: Paul E. McKenney --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Needed for annotating rt_mutex locks. Signed-off-by: Peter Rosin--- include/linux/rtmutex.h | 6 ++ kernel/locking/rtmutex.c | 29 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 1b92a28dd672..32e18527be64 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -106,7 +106,13 @@ static inline int rt_mutex_is_locked(struct rt_mutex *lock) extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); extern void rt_mutex_destroy(struct rt_mutex *lock); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass); +#else extern void rt_mutex_lock(struct rt_mutex *lock); +# define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock) +#endif + extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); extern int rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout); diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4f014be7a4b8..d33bc45b9d64 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1465,6 +1465,29 @@ rt_mutex_fastunlock(struct rt_mutex *lock, rt_mutex_postunlock(_q); } +static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass) +{ + might_sleep(); + + mutex_acquire(>dep_map, subclass, 0, _RET_IP_); + rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); +} + +#ifdef CONFIG_DEBUG_LOCK_ALLOC +/** + * rt_mutex_lock_nested - lock a rt_mutex + * + * @lock: the rt_mutex to be locked + * @subclass: the lockdep subclass + */ +void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass) +{ + __rt_mutex_lock(lock, subclass); +} +EXPORT_SYMBOL_GPL(mutex_lock_nested); +#endif + +#ifndef CONFIG_DEBUG_LOCK_ALLOC /** * rt_mutex_lock - lock a rt_mutex * @@ -1472,12 +1495,10 @@ rt_mutex_fastunlock(struct rt_mutex *lock, */ void __sched rt_mutex_lock(struct rt_mutex *lock) { - might_sleep(); - - mutex_acquire(>dep_map, 0, 0, _RET_IP_); - rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); + __rt_mutex_lock(lock, 0); } EXPORT_SYMBOL_GPL(rt_mutex_lock); +#endif /** * rt_mutex_lock_interruptible - lock a rt_mutex interruptible -- 2.11.0
[PATCH 1/2] rtmutex: allow specifying a subclass for nested locking
Needed for annotating rt_mutex locks. Signed-off-by: Peter Rosin --- include/linux/rtmutex.h | 6 ++ kernel/locking/rtmutex.c | 29 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 1b92a28dd672..32e18527be64 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -106,7 +106,13 @@ static inline int rt_mutex_is_locked(struct rt_mutex *lock) extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); extern void rt_mutex_destroy(struct rt_mutex *lock); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass); +#else extern void rt_mutex_lock(struct rt_mutex *lock); +# define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock) +#endif + extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); extern int rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout); diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4f014be7a4b8..d33bc45b9d64 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1465,6 +1465,29 @@ rt_mutex_fastunlock(struct rt_mutex *lock, rt_mutex_postunlock(_q); } +static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass) +{ + might_sleep(); + + mutex_acquire(>dep_map, subclass, 0, _RET_IP_); + rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); +} + +#ifdef CONFIG_DEBUG_LOCK_ALLOC +/** + * rt_mutex_lock_nested - lock a rt_mutex + * + * @lock: the rt_mutex to be locked + * @subclass: the lockdep subclass + */ +void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass) +{ + __rt_mutex_lock(lock, subclass); +} +EXPORT_SYMBOL_GPL(mutex_lock_nested); +#endif + +#ifndef CONFIG_DEBUG_LOCK_ALLOC /** * rt_mutex_lock - lock a rt_mutex * @@ -1472,12 +1495,10 @@ rt_mutex_fastunlock(struct rt_mutex *lock, */ void __sched rt_mutex_lock(struct rt_mutex *lock) { - might_sleep(); - - mutex_acquire(>dep_map, 0, 0, _RET_IP_); - rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); + __rt_mutex_lock(lock, 0); } EXPORT_SYMBOL_GPL(rt_mutex_lock); +#endif /** * rt_mutex_lock_interruptible - lock a rt_mutex interruptible -- 2.11.0