linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH v2] drivers: nvme: target: core: Pass lockdep expression to RCU lists
@ 2020-01-10 17:23 Amol Grover
  2020-01-11  5:43 ` kbuild test robot
  2020-01-18 11:06 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Amol Grover @ 2020-01-10 17:23 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
  Cc: Paul E . McKenney, linux-kernel, linux-nvme, Joel Fernandes,
	linux-kernel-mentees

ctrl->subsys->namespaces and subsys->namespaces are traversed with
hlist_for_each_entry_rcu outside an RCU read-side critical section
but under the protection of subsys->lock.

Hence, add the corresponding lockdep expression to the list traversal
primitive to silence false-positive lockdep warnings, and
harden RCU lists.

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Amol Grover <frextrite@gmail.com>
---
v2:
- Fix sparse error
  CHECK: Alignment should match open parenthesis
- Remove global macro and use local lockdep expressions

 drivers/nvme/target/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 28438b833c1b..c2d6c2dd53fa 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -555,7 +555,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
 	} else {
 		struct nvmet_ns *old;
 
-		list_for_each_entry_rcu(old, &subsys->namespaces, dev_link) {
+		list_for_each_entry_rcu(old, &subsys->namespaces, dev_link,
+					lockdep_is_held(&subsys->lock)) {
 			BUG_ON(ns->nsid == old->nsid);
 			if (ns->nsid < old->nsid)
 				break;
@@ -1172,7 +1173,8 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
 
 	ctrl->p2p_client = get_device(req->p2p_client);
 
-	list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link)
+	list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
+				lockdep_is_held(&subsys->lock))
 		nvmet_p2pmem_ns_add_p2p(ctrl, ns);
 }
 
-- 
2.24.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v2] drivers: nvme: target: core: Pass lockdep expression to RCU lists
  2020-01-10 17:23 [Linux-kernel-mentees] [PATCH v2] drivers: nvme: target: core: Pass lockdep expression to RCU lists Amol Grover
@ 2020-01-11  5:43 ` kbuild test robot
  2020-01-18 11:06 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2020-01-11  5:43 UTC (permalink / raw)
  To: Amol Grover
  Cc: kbuild-all, Sagi Grimberg, Chaitanya Kulkarni, Paul E . McKenney,
	linux-kernel, linux-nvme, Joel Fernandes, linux-kernel-mentees,
	Christoph Hellwig

[-- Attachment #1: Type: text/plain, Size: 5671 bytes --]

Hi Amol,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hch-configfs/for-next]
[also build test WARNING on linux/master linus/master v5.5-rc5 next-20200110]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Amol-Grover/drivers-nvme-target-core-Pass-lockdep-expression-to-RCU-lists/20200111-084508
base:   git://git.infradead.org/users/hch/configfs.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/rbtree.h:22:0,
                    from include/linux/mm_types.h:10,
                    from include/linux/mmzone.h:21,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:13,
                    from drivers/nvme/target/core.c:7:
   drivers/nvme/target/core.c: In function 'nvmet_setup_p2p_ns_map':
   drivers/nvme/target/core.c:1179:22: error: 'subsys' undeclared (first use in this function); did you mean 'to_subsys'?
        lockdep_is_held(&subsys->lock))
                         ^
   include/linux/rcupdate.h:263:52: note: in definition of macro 'RCU_LOCKDEP_WARN'
      if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \
                                                       ^
   include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu'
     for (__list_check_rcu(dummy, ## cond, 0),   \
          ^~~~~~~~~~~~~~~~
>> include/linux/rculist.h:371:34: note: in expansion of macro 'lockdep_is_held'
     for (__list_check_rcu(dummy, ## cond, 0),   \
                                     ^~~~
   drivers/nvme/target/core.c:1178:2: note: in expansion of macro 'list_for_each_entry_rcu'
     list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
     ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/target/core.c:1179:22: note: each undeclared identifier is reported only once for each function it appears in
        lockdep_is_held(&subsys->lock))
                         ^
   include/linux/rcupdate.h:263:52: note: in definition of macro 'RCU_LOCKDEP_WARN'
      if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \
                                                       ^
   include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu'
     for (__list_check_rcu(dummy, ## cond, 0),   \
          ^~~~~~~~~~~~~~~~
>> include/linux/rculist.h:371:34: note: in expansion of macro 'lockdep_is_held'
     for (__list_check_rcu(dummy, ## cond, 0),   \
                                     ^~~~
   drivers/nvme/target/core.c:1178:2: note: in expansion of macro 'list_for_each_entry_rcu'
     list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
     ^~~~~~~~~~~~~~~~~~~~~~~

vim +/lockdep_is_held +371 include/linux/rculist.h

ff3c44e6750545 Tom Herbert             2016-03-07  358  
82524746c27fa4 Franck Bui-Huu          2008-05-12  359  /**
82524746c27fa4 Franck Bui-Huu          2008-05-12  360   * list_for_each_entry_rcu	-	iterate over rcu list of given type
82524746c27fa4 Franck Bui-Huu          2008-05-12  361   * @pos:	the type * to use as a loop cursor.
82524746c27fa4 Franck Bui-Huu          2008-05-12  362   * @head:	the head for your list.
3943f42c11896c Andrey Utkin            2014-11-14  363   * @member:	the name of the list_head within the struct.
28875945ba98d1 Joel Fernandes (Google  2019-07-16  364)  * @cond:	optional lockdep expression if called from non-RCU protection.
82524746c27fa4 Franck Bui-Huu          2008-05-12  365   *
82524746c27fa4 Franck Bui-Huu          2008-05-12  366   * This list-traversal primitive may safely run concurrently with
82524746c27fa4 Franck Bui-Huu          2008-05-12  367   * the _rcu list-mutation primitives such as list_add_rcu()
82524746c27fa4 Franck Bui-Huu          2008-05-12  368   * as long as the traversal is guarded by rcu_read_lock().
82524746c27fa4 Franck Bui-Huu          2008-05-12  369   */
28875945ba98d1 Joel Fernandes (Google  2019-07-16  370) #define list_for_each_entry_rcu(pos, head, member, cond...)		\
28875945ba98d1 Joel Fernandes (Google  2019-07-16 @371) 	for (__list_check_rcu(dummy, ## cond, 0),			\
28875945ba98d1 Joel Fernandes (Google  2019-07-16  372) 	     pos = list_entry_rcu((head)->next, typeof(*pos), member);	\
e66eed651fd18a Linus Torvalds          2011-05-19  373  		&pos->member != (head);					\
72c6a9870f9010 Jiri Pirko              2009-04-14  374  		pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
82524746c27fa4 Franck Bui-Huu          2008-05-12  375  

:::::: The code at line 371 was first introduced by commit
:::::: 28875945ba98d1b47a8a706812b6494d165bb0a0 rcu: Add support for consolidated-RCU reader checking

:::::: TO: Joel Fernandes (Google) <joel@joelfernandes.org>
:::::: CC: Paul E. McKenney <paulmck@linux.ibm.com>

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 52217 bytes --]

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v2] drivers: nvme: target: core: Pass lockdep expression to RCU lists
  2020-01-10 17:23 [Linux-kernel-mentees] [PATCH v2] drivers: nvme: target: core: Pass lockdep expression to RCU lists Amol Grover
  2020-01-11  5:43 ` kbuild test robot
@ 2020-01-18 11:06 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2020-01-18 11:06 UTC (permalink / raw)
  To: Amol Grover
  Cc: kbuild-all, Sagi Grimberg, Chaitanya Kulkarni, Paul E . McKenney,
	linux-kernel, linux-nvme, Joel Fernandes, linux-kernel-mentees,
	Christoph Hellwig

[-- Attachment #1: Type: text/plain, Size: 4022 bytes --]

Hi Amol,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on hch-configfs/for-next]
[also build test ERROR on linux/master linus/master v5.5-rc6 next-20200117]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Amol-Grover/drivers-nvme-target-core-Pass-lockdep-expression-to-RCU-lists/20200111-084508
base:   git://git.infradead.org/users/hch/configfs.git for-next
config: i386-randconfig-e001-20200118 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-3) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/rbtree.h:22:0,
                    from include/linux/mm_types.h:10,
                    from include/linux/mmzone.h:21,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:13,
                    from drivers/nvme/target/core.c:7:
   drivers/nvme/target/core.c: In function 'nvmet_setup_p2p_ns_map':
>> drivers/nvme/target/core.c:1179:22: error: 'subsys' undeclared (first use in this function); did you mean 'to_subsys'?
        lockdep_is_held(&subsys->lock))
                         ^
   include/linux/rcupdate.h:263:52: note: in definition of macro 'RCU_LOCKDEP_WARN'
      if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \
                                                       ^
   include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu'
     for (__list_check_rcu(dummy, ## cond, 0),   \
          ^~~~~~~~~~~~~~~~
   include/linux/rculist.h:371:34: note: in expansion of macro 'lockdep_is_held'
     for (__list_check_rcu(dummy, ## cond, 0),   \
                                     ^~~~
   drivers/nvme/target/core.c:1178:2: note: in expansion of macro 'list_for_each_entry_rcu'
     list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
     ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/target/core.c:1179:22: note: each undeclared identifier is reported only once for each function it appears in
        lockdep_is_held(&subsys->lock))
                         ^
   include/linux/rcupdate.h:263:52: note: in definition of macro 'RCU_LOCKDEP_WARN'
      if (debug_lockdep_rcu_enabled() && !__warned && (c)) { \
                                                       ^
   include/linux/rculist.h:371:7: note: in expansion of macro '__list_check_rcu'
     for (__list_check_rcu(dummy, ## cond, 0),   \
          ^~~~~~~~~~~~~~~~
   include/linux/rculist.h:371:34: note: in expansion of macro 'lockdep_is_held'
     for (__list_check_rcu(dummy, ## cond, 0),   \
                                     ^~~~
   drivers/nvme/target/core.c:1178:2: note: in expansion of macro 'list_for_each_entry_rcu'
     list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
     ^~~~~~~~~~~~~~~~~~~~~~~

vim +1179 drivers/nvme/target/core.c

  1164	
  1165	/*
  1166	 * Note: ctrl->subsys->lock should be held when calling this function
  1167	 */
  1168	static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
  1169			struct nvmet_req *req)
  1170	{
  1171		struct nvmet_ns *ns;
  1172	
  1173		if (!req->p2p_client)
  1174			return;
  1175	
  1176		ctrl->p2p_client = get_device(req->p2p_client);
  1177	
  1178		list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
> 1179					lockdep_is_held(&subsys->lock))
  1180			nvmet_p2pmem_ns_add_p2p(ctrl, ns);
  1181	}
  1182	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32548 bytes --]

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-18 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 17:23 [Linux-kernel-mentees] [PATCH v2] drivers: nvme: target: core: Pass lockdep expression to RCU lists Amol Grover
2020-01-11  5:43 ` kbuild test robot
2020-01-18 11:06 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).