[0/2] kobject: reduce uevent_sock_mutex contention

Message ID 20240214084829.684541-1-edumazet@google.com
Headers
Series kobject: reduce uevent_sock_mutex contention |

Message

Eric Dumazet Feb. 14, 2024, 8:48 a.m. UTC
  This series reduces the (small ?) contention over uevent_sock_mutex,
noticed when creating/deleting many network namespaces/devices.

1) uevent_seqnum becomes an atomic64_t

2) Only acquire uevent_sock_mutex whenever using uevent_sock_list

Eric Dumazet (2):
  kobject: make uevent_seqnum atomic
  kobject: reduce uevent_sock_mutex scope

 include/linux/kobject.h |  2 +-
 kernel/ksysfs.c         |  2 +-
 lib/kobject_uevent.c    | 24 +++++++++++-------------
 3 files changed, 13 insertions(+), 15 deletions(-)
  

Comments

Greg KH Feb. 14, 2024, 10:27 a.m. UTC | #1
On Wed, Feb 14, 2024 at 08:48:27AM +0000, Eric Dumazet wrote:
> This series reduces the (small ?) contention over uevent_sock_mutex,
> noticed when creating/deleting many network namespaces/devices.
> 
> 1) uevent_seqnum becomes an atomic64_t
> 
> 2) Only acquire uevent_sock_mutex whenever using uevent_sock_list

Cool, any boot-time measured speedups from this?  Or is this just tiny
optimizations that you noticed doing reviews?

thanks,

greg k-h
  
Eric Dumazet Feb. 14, 2024, 10:43 a.m. UTC | #2
On Wed, Feb 14, 2024 at 11:34 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Wed, Feb 14, 2024 at 08:48:27AM +0000, Eric Dumazet wrote:
> > This series reduces the (small ?) contention over uevent_sock_mutex,
> > noticed when creating/deleting many network namespaces/devices.
> >
> > 1) uevent_seqnum becomes an atomic64_t
> >
> > 2) Only acquire uevent_sock_mutex whenever using uevent_sock_list
>
> Cool, any boot-time measured speedups from this?  Or is this just tiny
> optimizations that you noticed doing reviews?

No impressive nice numbers yet, the main bottleneck is still rtnl,
which I am working on net-next tree.

Other candidates are : rdma_nets_rwsem, proc_subdir_lock, pcpu_alloc_mutex, ...

Christian made the much needed changes [1], since the last time I took
a look at kobject (this was in 2017 !)

[1]
commit a3498436b3a0f8ec289e6847e1de40b4123e1639
Author: Christian Brauner <brauner@kernel.org>
Date:   Sun Apr 29 12:44:12 2018 +0200

    netns: restrict uevents