All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] net-sysfs: remove the rtnl_trylock/restart_syscall construction
@ 2025-01-17 10:26 Antoine Tenart
  2025-01-17 10:26 ` [PATCH net-next 1/4] net-sysfs: remove rtnl_trylock from device attributes Antoine Tenart
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Antoine Tenart @ 2025-01-17 10:26 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet; +Cc: Antoine Tenart, stephen, gregkh, netdev

Hi,

The series initially aimed at improving spins (and thus delays) while
accessing net sysfs under rtnl lock contention[1]. The culprit was the
trylock/restart_syscall constructions. There wasn't much interest at the
time but it got traction recently for other reasons (lowering the rtnl
lock pressure).

Since the RFC[1]:

- Limit the breaking of the sysfs protection to sysfs_rtnl_lock() only
  as this is not needed in the whole rtnl locking section thanks to the
  additional check on dev_isalive(). This simplifies error handling as
  well as the unlocking path.
- Used an interruptible version of rtnl_lock, as done by Jakub in
  his experiments.
- Removed a WARN_ONCE_ONCE call [Greg].
- Removed explicit inline markers [Stephen].

Most of the reasoning is explained in comments added in patch 1. This
was tested by stress-testing net sysfs attributes (read/write ops) while
adding/removing queues and adding/removing veths, all in parallel. I
also used an OCP single node cluster, spawning lots of pods.

Thanks,
Antoine

[1] https://lore.kernel.org/all/20231018154804.420823-1-atenart@kernel.org/T/

---

Not sending this as an RFC as I believe this is ready for proper review,
but also note rc7 is there already and we might want this to live for a
bit in net-next before getting to Linus' tree.

Antoine Tenart (4):
  net-sysfs: remove rtnl_trylock from device attributes
  net-sysfs: move queue attribute groups outside the default groups
  net-sysfs: prevent uncleared queues from being re-added
  net-sysfs: remove rtnl_trylock from queue attributes

 include/linux/netdevice.h     |   1 +
 include/linux/rtnetlink.h     |   1 +
 include/net/netdev_rx_queue.h |   1 +
 net/core/net-sysfs.c          | 388 ++++++++++++++++++++++++----------
 net/core/rtnetlink.c          |   6 +
 5 files changed, 280 insertions(+), 117 deletions(-)

-- 
2.48.0


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH net-next 3/4] net-sysfs: prevent uncleared queues from being re-added
@ 2025-01-22 13:52 kernel test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2025-01-22 13:52 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250117102612.132644-4-atenart@kernel.org>
References: <20250117102612.132644-4-atenart@kernel.org>
TO: Antoine Tenart <atenart@kernel.org>

Hi Antoine,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Antoine-Tenart/net-sysfs-remove-rtnl_trylock-from-device-attributes/20250117-182859
base:   net-next/main
patch link:    https://lore.kernel.org/r/20250117102612.132644-4-atenart%40kernel.org
patch subject: [PATCH net-next 3/4] net-sysfs: prevent uncleared queues from being re-added
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: openrisc-randconfig-r072-20250122 (https://download.01.org/0day-ci/archive/20250122/202501222127.IpSq0NYU-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202501222127.IpSq0NYU-lkp@intel.com/

smatch warnings:
net/core/net-sysfs.c:1260 rx_queue_add_kobject() warn: Calling kobject_put|get with state->initialized unset from line: 1224
net/core/net-sysfs.c:1957 netdev_queue_add_kobject() warn: Calling kobject_put|get with state->initialized unset from line: 1926

vim +1260 net/core/net-sysfs.c

50bcfe8df7c73c Paolo Abeni       2023-02-17  1206  
6b53dafe23fd1f WANG Cong         2014-07-23  1207  static int rx_queue_add_kobject(struct net_device *dev, int index)
0a9627f2649a02 Tom Herbert       2010-03-16  1208  {
6b53dafe23fd1f WANG Cong         2014-07-23  1209  	struct netdev_rx_queue *queue = dev->_rx + index;
0a9627f2649a02 Tom Herbert       2010-03-16  1210  	struct kobject *kobj = &queue->kobj;
0a9627f2649a02 Tom Herbert       2010-03-16  1211  	int error = 0;
0a9627f2649a02 Tom Herbert       2010-03-16  1212  
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1213  	/* Rx queues are cleared in rx_queue_release to allow later
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1214  	 * re-registration. This is triggered when their kobj refcount is
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1215  	 * dropped.
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1216  	 *
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1217  	 * If a queue is removed while both a read (or write) operation and a
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1218  	 * the re-addition of the same queue are pending (waiting on rntl_lock)
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1219  	 * it might happen that the re-addition will execute before the read,
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1220  	 * making the initial removal to never happen (queue's kobj refcount
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1221  	 * won't drop enough because of the pending read). In such rare case,
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1222  	 * return to allow the removal operation to complete.
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1223  	 */
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1224  	if (unlikely(kobj->state_initialized))
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1225  		return -EAGAIN;
a5f9a5063bfab8 Antoine Tenart    2025-01-17  1226  
ddd9b5e3e765d8 Jouni Hogander    2019-12-17  1227  	/* Kobject_put later will trigger rx_queue_release call which
ddd9b5e3e765d8 Jouni Hogander    2019-12-17  1228  	 * decreases dev refcount: Take that reference here
ddd9b5e3e765d8 Jouni Hogander    2019-12-17  1229  	 */
d62607c3fe4591 Jakub Kicinski    2022-06-07  1230  	netdev_hold(queue->dev, &queue->dev_tracker, GFP_KERNEL);
ddd9b5e3e765d8 Jouni Hogander    2019-12-17  1231  
6b53dafe23fd1f WANG Cong         2014-07-23  1232  	kobj->kset = dev->queues_kset;
0a9627f2649a02 Tom Herbert       2010-03-16  1233  	error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL,
0a9627f2649a02 Tom Herbert       2010-03-16  1234  				     "rx-%u", index);
a953be53ce4044 Michael Dalton    2014-01-16  1235  	if (error)
b8eb718348b8fb Jouni Hogander    2019-11-20  1236  		goto err;
a953be53ce4044 Michael Dalton    2014-01-16  1237  
3ffe913d2a224b Antoine Tenart    2025-01-17  1238  	queue->groups = rx_queue_default_groups;
3ffe913d2a224b Antoine Tenart    2025-01-17  1239  	error = sysfs_create_groups(kobj, queue->groups);
3ffe913d2a224b Antoine Tenart    2025-01-17  1240  	if (error)
3ffe913d2a224b Antoine Tenart    2025-01-17  1241  		goto err;
3ffe913d2a224b Antoine Tenart    2025-01-17  1242  
6b53dafe23fd1f WANG Cong         2014-07-23  1243  	if (dev->sysfs_rx_queue_group) {
6b53dafe23fd1f WANG Cong         2014-07-23  1244  		error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group);
b8eb718348b8fb Jouni Hogander    2019-11-20  1245  		if (error)
3ffe913d2a224b Antoine Tenart    2025-01-17  1246  			goto err_default_groups;
0a9627f2649a02 Tom Herbert       2010-03-16  1247  	}
0a9627f2649a02 Tom Herbert       2010-03-16  1248  
50bcfe8df7c73c Paolo Abeni       2023-02-17  1249  	error = rx_queue_default_mask(dev, queue);
605cfa1b1090b5 Paolo Abeni       2023-02-07  1250  	if (error)
3ffe913d2a224b Antoine Tenart    2025-01-17  1251  		goto err_default_groups;
50bcfe8df7c73c Paolo Abeni       2023-02-17  1252  
0a9627f2649a02 Tom Herbert       2010-03-16  1253  	kobject_uevent(kobj, KOBJ_ADD);
0a9627f2649a02 Tom Herbert       2010-03-16  1254  
0a9627f2649a02 Tom Herbert       2010-03-16  1255  	return error;
b8eb718348b8fb Jouni Hogander    2019-11-20  1256  
3ffe913d2a224b Antoine Tenart    2025-01-17  1257  err_default_groups:
3ffe913d2a224b Antoine Tenart    2025-01-17  1258  	sysfs_remove_groups(kobj, queue->groups);
b8eb718348b8fb Jouni Hogander    2019-11-20  1259  err:
b8eb718348b8fb Jouni Hogander    2019-11-20 @1260  	kobject_put(kobj);
b8eb718348b8fb Jouni Hogander    2019-11-20  1261  	return error;
0a9627f2649a02 Tom Herbert       2010-03-16  1262  }
d755407d4444c3 Christian Brauner 2020-02-27  1263  

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

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

end of thread, other threads:[~2025-01-22 13:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 10:26 [PATCH net-next 0/4] net-sysfs: remove the rtnl_trylock/restart_syscall construction Antoine Tenart
2025-01-17 10:26 ` [PATCH net-next 1/4] net-sysfs: remove rtnl_trylock from device attributes Antoine Tenart
2025-01-17 17:03   ` Stephen Hemminger
2025-01-17 18:35     ` Antoine Tenart
2025-01-17 10:26 ` [PATCH net-next 2/4] net-sysfs: move queue attribute groups outside the default groups Antoine Tenart
2025-01-17 10:26 ` [PATCH net-next 3/4] net-sysfs: prevent uncleared queues from being re-added Antoine Tenart
2025-01-20 19:44   ` Jakub Kicinski
2025-01-21  9:33     ` Antoine Tenart
2025-01-21 17:09       ` Jakub Kicinski
2025-01-22  8:34         ` Antoine Tenart
2025-01-17 10:26 ` [PATCH net-next 4/4] net-sysfs: remove rtnl_trylock from queue attributes Antoine Tenart
2025-01-20 19:40 ` [PATCH net-next 0/4] net-sysfs: remove the rtnl_trylock/restart_syscall construction Jakub Kicinski
2025-01-21  9:38   ` Antoine Tenart
2025-01-22  8:50 ` Maxime Chevallier
2025-01-22  9:09   ` Antoine Tenart
  -- strict thread matches above, loose matches on Subject: below --
2025-01-22 13:52 [PATCH net-next 3/4] net-sysfs: prevent uncleared queues from being re-added kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.