From patchwork Thu Feb 1 17:09:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541465 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B77AE77A1C for ; Thu, 1 Feb 2024 17:09:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807383; cv=none; b=bA7yWrqlMy8zQ+1APC9x32ZBfSkuOc6dYZaRoeMPpzyNa2aFAmeUoH3TdN+970N2jGz34nabFN7dPKjD7UraoFgXuu4RltBI/6j0f8Apga2xMVVRu3SEf6g7la1jsJsAe5flSkXSFG/UMc8vVSCSH7GWCqX+jJNoH6CIfWynsFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807383; c=relaxed/simple; bh=J0/YdDkxHXzm3XWRfN7oa6hvqBBKxPBY9NASLxrsZRM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=o75zbMGwTxsKsT5aD++mT5CG4lkswa/myHQsyqTqtBMW23bpnvwXsPvFu+Zn0Qlp3878JlPhZzRbhC1ikUGbjqEr2+alsQ8T+KuOjE9Ci90vFcDp++9OA8bCuZjGa9+fL4C0uZpUVFAIisFZSBAIUEjZ7tweaooBICfAA39S/xQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IZdK05qO; arc=none smtp.client-ip=209.85.222.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IZdK05qO" Received: by mail-qk1-f202.google.com with SMTP id af79cd13be357-78346521232so147528685a.3 for ; Thu, 01 Feb 2024 09:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807380; x=1707412180; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1VIcw/+J8wok8KHYfmedUaIZ/lcX0VpElt9KvdufhIE=; b=IZdK05qOphEqzibtnSysu6yuvMvthX2GcdYNh32C7ZPjjF+K7kPOiYslTdNyMYPlf4 SOC8PEye+AbOt1oQkNi08RaPw/1AUptTpWL+7WMiW3yqkIDUiOSfnJCFWZDe9VLQlDRR /Zn/DFDwpuQ3AJbxvOhlDliNzcDGEjQb8ga1nRRRwHsMnwK2WFkISZfTQTyn7dPv0iy/ 63BAmJ65M0LKS4RrDVNISAjU5lZeVKY3GJDb4tNin8k7kukDLp2srla8VI7OH/1gPXq8 GGSwWukb6AGddtqwS2sjXYrD3cuM+LNvM3iucficXDV/Dmw6j3aynpp17IPWnC8QsinW luYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807380; x=1707412180; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1VIcw/+J8wok8KHYfmedUaIZ/lcX0VpElt9KvdufhIE=; b=iB9pz6beT38mjwuC5T3P1ss7GiWgAbNUBozx6gKnigMXUF/3SMZNLwTFGBsT1qk6+i fsZTdDRaZ8BEgGVMmqp1cYGyUAOe4PHQ9AG3Rk4aFKH8mJQCyghsrjNFUxLDsmWracr/ n8F2GtRCUGP3J1oHQwWUIST2J7zl/TY7Bgrl4cR7YbhxvGicsv7GvOEeC7hXNcJdbq5l SKjPJNCuHWIwJh6OwqLS/DAQ8DuCHsknuqo48x0LIzgik6dENTcCpBUNHrI1TK/HxF2U dAcOr8bzsDtVsze849sYLldmtaZZfsarQ4TMgrI8R9/OteDjp7wWsXW9w4PCGBBdYo+6 Zk1w== X-Gm-Message-State: AOJu0YxoPUhKZsvC/Phnpg0eHDrQWsNeVcuL2yedu79C4z2hro5a+Hog LG3kA+qdC1Gguv66ODm07906/6dyYvdjk4zN8GdKXmP5BNOj/z5Oh90u/JqX00lRJ0yDHHDvujP Ra15O/Uj4pQ== X-Google-Smtp-Source: AGHT+IERbGzd2Mg0BEq6QahP9EBCaRE7IDXv5uXKFeStcCD35ZC/HIgtf4qJrjUFQ4vVzlZa6W8930+bd9GNNA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:620a:4494:b0:784:3ddc:cd3f with SMTP id x20-20020a05620a449400b007843ddccd3fmr44495qkp.13.1706807380585; Thu, 01 Feb 2024 09:09:40 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:22 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-2-edumazet@google.com> Subject: [PATCH net-next 01/16] net: add exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Many (struct pernet_operations)->exit_batch() methods have to acquire rtnl. In presence of rtnl mutex pressure, this makes cleanup_net() very slow. This patch adds a new exit_batch_rtnl() method to reduce number of rtnl acquisitions from cleanup_net(). exit_batch_rtnl() handlers are called while rtnl is locked, and devices to be killed can be queued in a list provided as their second argument. A single unregister_netdevice_many() is called right before rtnl is released. exit_batch_rtnl() handlers are called before ->exit() and ->exit_batch() handlers. Signed-off-by: Eric Dumazet --- include/net/net_namespace.h | 3 +++ net/core/net_namespace.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 13b3a4e29fdb3b1f37649072ea71181ec1bad256..5e5b522eca88e9e19345792bd5137eb8cf374265 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -450,6 +450,9 @@ struct pernet_operations { void (*pre_exit)(struct net *net); void (*exit)(struct net *net); void (*exit_batch)(struct list_head *net_exit_list); + /* Following method is called with RTNL held. */ + void (*exit_batch_rtnl)(struct list_head *net_exit_list, + struct list_head *dev_kill_list); unsigned int *id; size_t size; }; diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 72799533426b6162256d7c4eef355af96c66e844..233ec0cdd0111d5ca21c6f8a66f4c1f3fbc4657b 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -318,8 +318,9 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns) { /* Must be called with pernet_ops_rwsem held */ const struct pernet_operations *ops, *saved_ops; - int error = 0; LIST_HEAD(net_exit_list); + LIST_HEAD(dev_kill_list); + int error = 0; refcount_set(&net->ns.count, 1); ref_tracker_dir_init(&net->refcnt_tracker, 128, "net refcnt"); @@ -357,6 +358,15 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns) synchronize_rcu(); + ops = saved_ops; + rtnl_lock(); + list_for_each_entry_continue_reverse(ops, &pernet_list, list) { + if (ops->exit_batch_rtnl) + ops->exit_batch_rtnl(&net_exit_list, &dev_kill_list); + } + unregister_netdevice_many(&dev_kill_list); + rtnl_unlock(); + ops = saved_ops; list_for_each_entry_continue_reverse(ops, &pernet_list, list) ops_exit_list(ops, &net_exit_list); @@ -573,6 +583,7 @@ static void cleanup_net(struct work_struct *work) struct net *net, *tmp, *last; struct llist_node *net_kill_list; LIST_HEAD(net_exit_list); + LIST_HEAD(dev_kill_list); /* Atomically snapshot the list of namespaces to cleanup */ net_kill_list = llist_del_all(&cleanup_list); @@ -613,6 +624,14 @@ static void cleanup_net(struct work_struct *work) */ synchronize_rcu(); + rtnl_lock(); + list_for_each_entry_reverse(ops, &pernet_list, list) { + if (ops->exit_batch_rtnl) + ops->exit_batch_rtnl(&net_exit_list, &dev_kill_list); + } + unregister_netdevice_many(&dev_kill_list); + rtnl_unlock(); + /* Run all of the network namespace exit methods */ list_for_each_entry_reverse(ops, &pernet_list, list) ops_exit_list(ops, &net_exit_list); @@ -1193,7 +1212,17 @@ static void free_exit_list(struct pernet_operations *ops, struct list_head *net_ { ops_pre_exit_list(ops, net_exit_list); synchronize_rcu(); + + if (ops->exit_batch_rtnl) { + LIST_HEAD(dev_kill_list); + + rtnl_lock(); + ops->exit_batch_rtnl(net_exit_list, &dev_kill_list); + unregister_netdevice_many(&dev_kill_list); + rtnl_unlock(); + } ops_exit_list(ops, net_exit_list); + ops_free_list(ops, net_exit_list); } From patchwork Thu Feb 1 17:09:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541466 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1980015D5BC for ; Thu, 1 Feb 2024 17:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807384; cv=none; b=qbyELHr/ZHavzvRkH85xQ/OxGUBxR886Bt+r4XlBvCHS/E2zZGmW6RdNEd46G6bTLu46popBDhNMSURi1lXU9ymfypk/nywXnp5FTQs6b/6/sNbsTCkhqHT5ozGISalbQyAKAXtrfUDNK3DHzO1TNXGUYSk0S+R0SX/efa8Bz9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807384; c=relaxed/simple; bh=4yrivkjWSb/hp+LKDR1ukpkhCL5E3cnxmn0j2+kh234=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PkgmOxzN+aFKbuxklay8ZieEVcsb81NMi89D+3dDmDg1DVfOGqtpl4ZtUMY8Q3OToCdv08NsX32ytlwVJAUnn+RP8vRzM9GZTjCOEMa9XUSB0/P3lGcuCtmLucKPLCGHqjc+UfhgHGHNHZbQtwEWFQDBqpnbqRn0oA0IfsZ6XGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=B9FMTTnd; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="B9FMTTnd" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6040ffa60ddso22744347b3.2 for ; Thu, 01 Feb 2024 09:09:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807382; x=1707412182; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6ve0QvbI2bLOC5KjisnhpPU7DG7UJ/BbP8jjLzCWyuo=; b=B9FMTTndwBriTxDp27QGYByjdwvxeE8o8vu2PWhPDyGPD9s4JBihIi7bpBHiFpX2EQ twhp2poImO/nmYucYdTHInwf2YD0MJWYg/OQARhw7YIbklqBPxBNYQDEyDu7h/4lmJBw 29a8AllpVfDazlVAvL7vFKynjGonnguK4VMgO6QQJNRfxwCHVFic0CLAMzayPcmgDOS4 QEoFq6wJaOx5f5skMagO5xwqs1vfEIaNv/0Ro077WlEdnn8UzbXCqg+6NkcRBK+pMvsQ 75U65Ry+Nxxd1g0R/DPiqmNKXf1LR0urWazH20+TAbXxMuA+9FBONtBegq8t8iie4WRF ZuOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807382; x=1707412182; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6ve0QvbI2bLOC5KjisnhpPU7DG7UJ/BbP8jjLzCWyuo=; b=m2Ub+vLMjLvYyy+svptoEKgyxHyX1L5Ev0yF1rCJ0MvFZKBfvTe+w6ywfVEjxS1//D KmoHWcOkWBcoVtmyNrqdpKTQYyIHcHbbLef9wXujoG9lBF+FLG8+csVR9TkM73T2GzLk pT/qVqeaNY05WG79rdkV8BSlKkznPxpW1yX+yUw0UDcIQI7ZGNZS0CgIX9tkQL/Y4NcG zOKPkQFVJNV08kQcU+h4gB5cKQnFkk65p9eHxXTZ1Sif1heLxRAd36tSslNTaFDlL1Sq /84iAAVrfkg5gHut3JCeMwaL2rVL55K07OKsh1GvDVPjvUU502h+CFZU0GIaqsqvPYuf T8dw== X-Gm-Message-State: AOJu0YwUAu39EIWIrRmznlG5kRayXY76eL2Os4Q6ZF8JSfEtNhpam1hS DQuewEu/Z1ofXYEp2XKuKd6nifN2G0LgqR6HV62KYd8Ay4mfwJJidDFrDUoaScG8y7okqX8Ydtg Vg8M3UHGsSg== X-Google-Smtp-Source: AGHT+IFDIo+3BvI9sf8AnlV5t3MuckfpUIPKsYtUeB/0YfX0VvTULPW5aR87e8Qi1LpK4R5eRscy8ga38QRd2Q== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:690c:39c:b0:5fc:d439:4936 with SMTP id bh28-20020a05690c039c00b005fcd4394936mr1204485ywb.8.1706807382098; Thu, 01 Feb 2024 09:09:42 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:23 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-3-edumazet@google.com> Subject: [PATCH net-next 02/16] nexthop: convert nexthop_net_exit_batch to exit_batch_rtnl method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held. This saves one rtnl_lock()/rtnl_unlock() pair. We also need to create nexthop_net_exit() to make sure net->nexthop.devhash is not freed too soon, otherwise we will not be able to unregister netdev from exit_batch_rtnl() methods. Signed-off-by: Eric Dumazet --- net/ipv4/nexthop.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index bbff68b5b5d4a1d835c9785fbe84f4cab32a1db0..7270a8631406c508eebf85c42eb29a5268d7d7cf 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -3737,16 +3737,20 @@ void nexthop_res_grp_activity_update(struct net *net, u32 id, u16 num_buckets, } EXPORT_SYMBOL(nexthop_res_grp_activity_update); -static void __net_exit nexthop_net_exit_batch(struct list_head *net_list) +static void __net_exit nexthop_net_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct net *net; - rtnl_lock(); - list_for_each_entry(net, net_list, exit_list) { + ASSERT_RTNL(); + list_for_each_entry(net, net_list, exit_list) flush_all_nexthops(net); - kfree(net->nexthop.devhash); - } - rtnl_unlock(); +} + +static void __net_exit nexthop_net_exit(struct net *net) +{ + kfree(net->nexthop.devhash); + net->nexthop.devhash = NULL; } static int __net_init nexthop_net_init(struct net *net) @@ -3764,7 +3768,8 @@ static int __net_init nexthop_net_init(struct net *net) static struct pernet_operations nexthop_net_ops = { .init = nexthop_net_init, - .exit_batch = nexthop_net_exit_batch, + .exit = nexthop_net_exit, + .exit_batch_rtnl = nexthop_net_exit_batch_rtnl, }; static int __init nexthop_init(void) From patchwork Thu Feb 1 17:09:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541467 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 723BA1292C4 for ; Thu, 1 Feb 2024 17:09:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807386; cv=none; b=rkS+cExyoaE7g8MvUj9w1QjiWVbPHFWfYhe3hHxyvvO3hTlDwazo4WoPzk5JXloX4u792eiT9xTwLW5ltWKZtEslW9uai4TsFWsIO82wmLCifL79PCCWuwjpgCiEedTg7NIEzKzPKl6TutJ/DBJx9wR3EYqCDMb4u0xalldXdNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807386; c=relaxed/simple; bh=T+99pQGkXBrKdiTr1khPrGndHdX5hT0wcxaOc5AKFNQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WNdD31StbVxTxGBa1bDCkdEYPkUPDcmdJTI+v6DQVhQscxXce2Mu/PTNxsTSYskZQC+NehELAPaqaAbd4EYaav+ZCJdeII0P2yTEGfLT0ZKpS4ci5Hq1E4Qw10B4I20UMR3Lmg9jJaNK5aC1gTZJa6USLnfA+uMC4UBPqc3I4oU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=v7Ra3Uhk; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="v7Ra3Uhk" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6ceade361so1849586276.0 for ; Thu, 01 Feb 2024 09:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807383; x=1707412183; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Y2D5E9Gu3MpPPnV5CXWo8iDsBmuAoodNd9wVAuyaVMs=; b=v7Ra3UhkWP9Ynhzu34YnehVmKJlY0y+muVg+QGWxy57ESFb0eku/+d23M/4wfX4m/6 DtZzbX+u5FsvKOHmHEKAvCEUDasbZ/BNBBpNFj26MpaurdPJGjVx+mlS84tJzS4NDRGg wSYs0fDyCSZfC4htehnIashZ5zoklNJvuW3mG/KmSveBEiwVnw4cV6yb1BclRPHzG5TU 1PQTx/NNMQkQSSPW6Ohw7E3mPDIaCCgussgEqnuJ8UBkv/7ZPcnL1MYzF5lx89/rQEvO uVZYiY+kxevCtM5pU2LC/FFmPGQUaNe1APe7mMhzq5kt+It7TXYMtRz4DtjXNAdcG74p dHGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807383; x=1707412183; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y2D5E9Gu3MpPPnV5CXWo8iDsBmuAoodNd9wVAuyaVMs=; b=ECA3Eh/N7SUQJOfhEWoi01iAp+Co/hPn8sbx1wV+tlN4QFzxjvulXzsfMumnDxM1kj jpxWonz85fzAVqscQE+UgHbRBSK+1bRkChAHBxFxZsVmROcvJkHPhKYtO/0TTgWQrLxB KVd+Ypbvvw3yrScrl0guyLtv2JexLc6tZkSax90+9Ky9IRjT2uxLB4K7nbzGFrUKHGc/ xqsd8bWNFeWqhWb5+zHIrtSf6pSz8XmK1C9e9FZ+3qu6VbGoQ9QxA+zZiNcbNiz8m5/N MTnrRZVg4MnboXkCr0HLW7770iaLnjwhJowyPpF36tadUF1yeUV9VoxUzhfCtwx/7Yku MBzg== X-Gm-Message-State: AOJu0Yy99LGsA2OkkeGR175jZ0fLBBz8crpybsIrAR/pR2dXYYG+b0jZ SVVvQfosl/5mzOh0LuKzjDRSmaeIGu9nSXBOFj24iMneui4bxVOHzZH4ZZz3WMKqH1Mk8bqCHS4 /cK5BdtJFFA== X-Google-Smtp-Source: AGHT+IGgmi6ajeLoG0v9xgL8hWEyB7pET/NlKiHziS/ygcFE7H9bkiWxJ9drA3vaPn3bHDNIkBWAGKf8q7QBZw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:11c3:b0:dc2:398d:a671 with SMTP id n3-20020a05690211c300b00dc2398da671mr1393727ybu.10.1706807383425; Thu, 01 Feb 2024 09:09:43 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:24 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-4-edumazet@google.com> Subject: [PATCH net-next 03/16] net: convert default_device_exit_batch() to exit_batch_rtnl method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair, and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/core/dev.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index b53b9c94de4008aa7e808d58618675425aff0f4c..86107a9c9dd09d5590578923018be56065fbd58c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11596,7 +11596,8 @@ static void __net_exit default_device_exit_net(struct net *net) } } -static void __net_exit default_device_exit_batch(struct list_head *net_list) +static void __net_exit default_device_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_kill_list) { /* At exit all network devices most be removed from a network * namespace. Do this in the reverse order of registration. @@ -11605,9 +11606,7 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list) */ struct net_device *dev; struct net *net; - LIST_HEAD(dev_kill_list); - rtnl_lock(); list_for_each_entry(net, net_list, exit_list) { default_device_exit_net(net); cond_resched(); @@ -11616,17 +11615,15 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list) list_for_each_entry(net, net_list, exit_list) { for_each_netdev_reverse(net, dev) { if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) - dev->rtnl_link_ops->dellink(dev, &dev_kill_list); + dev->rtnl_link_ops->dellink(dev, dev_kill_list); else - unregister_netdevice_queue(dev, &dev_kill_list); + unregister_netdevice_queue(dev, dev_kill_list); } } - unregister_netdevice_many(&dev_kill_list); - rtnl_unlock(); } static struct pernet_operations __net_initdata default_device_ops = { - .exit_batch = default_device_exit_batch, + .exit_batch_rtnl = default_device_exit_batch_rtnl, }; static void __init net_dev_struct_check(void) From patchwork Thu Feb 1 17:09:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541468 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C208415DBCD for ; Thu, 1 Feb 2024 17:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807387; cv=none; b=A9Kw4VjWJL53KbQqbRdWFhtRmoenqknXOxQaafT8HgjXW0x30l8PhTapG9cYRkMqZO0QOq73kg7mvBhy+gHarNvXMTjUTrXyphxxj7WJIHDMxZYEqa1zA19fQyB4pMCDMVpgLHS2Rf2bzLUd69rqbBU/IRFm9l5D5WWwH+Lx9rQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807387; c=relaxed/simple; bh=UyNXHL0AAbquyRryjTWHlEfC9CbwVr85rRbcyASMaUU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=j+/UzdSP63hn/5NJ3Xkyts1Qy9OKAMuNZ0XvJNDX1ZWtws2laSXfmW08CShIAGRpdl7fCuRmYQWptLbvBhJSOXl586OxhtfXYg5ZHa8tY7ReZO81hBsBOOS5QtxsWf6QsWs6CNAgG8RYHZ681nxCNmVO8QsPEW/MF7NkGDakBoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rth1MPtp; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rth1MPtp" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbf618042daso1680641276.0 for ; Thu, 01 Feb 2024 09:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807384; x=1707412184; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/ZHMaqb9bXqw89uowGjnODMeAm3e3dYrZmUj9VUKXTM=; b=rth1MPtprZoXUKcvHNoMQjMuY1JfPBkOldrVSohb8fDpC9GutOb0NDdBt6XsvOY/oo 5UcXIfdkhM7QXep9aJBgc5pFb95M/FErYkvNW4NcRn7DVtEcikfCDGbQukD5TrShJlID c3vKGd0i/AnwiJ368lL7lcgeRm967XDKiZOYmFegB7nFWejnS7t35d9URELrcoTgn5Me wUx7qGLWWj8Wlzv5L9dfw8iH8CzsirNdYW2OGLKsuck5bblGwEfuQOVnfUT/jtUN3bot EU6CZPLR+kRB99ocoMglghTe6sFLBtY8SjfdabkaGM0MNjwJI2tE6hrlpkJRSaOBeVV4 LvtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807384; x=1707412184; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/ZHMaqb9bXqw89uowGjnODMeAm3e3dYrZmUj9VUKXTM=; b=eVcaS3xNL683hjrOKb2D2GlUCBxFlbWJeIPynMph4IakYQGfkPIuqWAJhm+0Ir3Y4J JWgREOrjeyFTxbnv/2GJ7V8sFO5qtsgYWPtgXWkV9F5hgk3unsXrCM8rEgcLAIAN6GqU /yMN7oV9eUrN0M4sL2xlrKg2xo9NjCPqHv3ATS4hzd+hVXkhhyRKjyNYEW+PiuWBX3j3 0cvZon7NDubTqZUCQIFCZaGr65kBqpURmmHKmi9vYdBVQw2xyw3GzwOAPYWhXfYxgOpe XX65zLAIvQjOqCgshj6YiMmDW4bBs62xjpVXzBnp82nh8WlpTFGTNeCmiV6Lm1F9cIvf UHmQ== X-Gm-Message-State: AOJu0Yze7xNtKJimploDgOF5qSykkDddfQZCKsQ/dtt1aUSXsSLaowdW mBIokfvxqSgZbgMdKrc1eaANeoBeVAsnVLKp/w7ZcwKMp4mJgqg7J95Qm3Pw5cgi3Db4xxCmXDk US4lt+TKTSw== X-Google-Smtp-Source: AGHT+IFp2xuPnvmXpomNvkJyYxjGOcXlzNthWRSYoO4U8MQ3r8/BleNS9iPC1R1yDdMSOMKoMkjPKABzoGwezA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:1691:b0:dc2:23db:1bc8 with SMTP id bx17-20020a056902169100b00dc223db1bc8mr95715ybb.3.1706807384698; Thu, 01 Feb 2024 09:09:44 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:25 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-5-edumazet@google.com> Subject: [PATCH net-next 04/16] bareudp: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair, and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- drivers/net/bareudp.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index 31377bb1cc97cba08e02dc7d48761068627af3fb..4db6122c9b43032a36b98916bb4390e3d6f08f68 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -760,23 +760,18 @@ static void bareudp_destroy_tunnels(struct net *net, struct list_head *head) unregister_netdevice_queue(bareudp->dev, head); } -static void __net_exit bareudp_exit_batch_net(struct list_head *net_list) +static void __net_exit bareudp_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_kill_list) { struct net *net; - LIST_HEAD(list); - rtnl_lock(); list_for_each_entry(net, net_list, exit_list) - bareudp_destroy_tunnels(net, &list); - - /* unregister the devices gathered above */ - unregister_netdevice_many(&list); - rtnl_unlock(); + bareudp_destroy_tunnels(net, dev_kill_list); } static struct pernet_operations bareudp_net_ops = { .init = bareudp_init_net, - .exit_batch = bareudp_exit_batch_net, + .exit_batch_rtnl = bareudp_exit_batch_rtnl, .id = &bareudp_net_id, .size = sizeof(struct bareudp_net), }; From patchwork Thu Feb 1 17:09:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541469 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E13CA15DBD9 for ; Thu, 1 Feb 2024 17:09:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807388; cv=none; b=Lka3alvWjavPB7evl2g4pNAIyfHGyMSyKpRtes+T4CfzkqO68MDeETd9iY9gzY8RlrFNHcIphYzrYfLeTt7l9e5zLOrPv1tzGGstLbRFKucEwH7F3s24mGbOJcGfr3O3scxIIJpnRXOWpYjtufw7GzI5A62JU2RoeOpArSG/XZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807388; c=relaxed/simple; bh=2IjWj5gc704KgFLhJvsBP6MeK3+tfEG+6Fy/lxkQj5I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=j4U92Y6OezSW0CvR/s25rn9DUMnuCQwO1yGemNvuHlSI3ciPmbBwGG95o+xs7PQWP18Bt/KmqXsaDAHa5C92OdlhalUPw7t7woPg5W3zupnEke4QDN69NqHy7ZDcv1QBEZZlMTSbjADUleBcfss4h3duC9XmTT79eMVOV70D2oc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Gih1VRv3; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Gih1VRv3" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b26845cdso2022470276.3 for ; Thu, 01 Feb 2024 09:09:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807386; x=1707412186; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AlogTDx9JVj0q6XkK5TUp+YTwNQ9LKK+FD0uPTdeY8E=; b=Gih1VRv33ZhWNuEVBrYflzvQqdWqCpH23BCb5oX/vox5KpHYxTyCJ672VUm056UNeL JUlhk7SEe3oVCBnu9z6Q1RCS1HKmV/LbZGPwgwxKjHIOJajAKqOYUpyFm+gnlqaFtkTF MYPuwqum+emlp0likV3C3vvfXV2/HrDz/V3akaX4wIAUiiB2dr8RdzGaUxOZgZ7Kn4wa 6R8T4p9VCpZytJVRXN5sUGdqQZDvVm57X7XSoTW1GdkDtfUU+HW+HKZM4OQxNDtLgaGn JQDWOSdKmiXIu58tzDA+VWjTJ4LGZGUdup2mcDGckJwM/zleYhMW2Y6ObA8zFFbFlmwe vGvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807386; x=1707412186; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AlogTDx9JVj0q6XkK5TUp+YTwNQ9LKK+FD0uPTdeY8E=; b=G9moxog2aKNo2UZLOJIMvjoZkqnG6prjkSqiBZIWF6BeGU+6HMm46g7ugfsaeZ8oSG hNcyX3XexBfTQYsfUoD1Lasl+E95kYVCiRLI3m8Tz8SJk0oKb+QPrPihyu0/7fiGpQtU ZvXoon13m8/rLAr6y12vwpBZJcKe1tfyQFUZbC1E3YM6UuKHTgUE3qZbWMsYl09o9D4M lEKhDBZPCFfcVS9zt61fPF28hofTa+iVPc9nYF1CNbNJcVogkaFQIka/1kvHAkvR01+c 4G5wxHZNCnoKBvoow7iJ/SActXK8Bo/MCGOAAbWXm6NPJbqJlXiIrkgddFgcnXR/oNZZ tGeQ== X-Gm-Message-State: AOJu0YzrsFl9FlH1w8GN4+0a0CAWwjcBZ/ssHNRbfsTJcHwTkidCRW6H 8uLQc9tSCfddfvZHBsdj5nRzBuMxPYqV6s8VF0liV6dpPGBLK4blEkKyDgTEbijlf7gANeMPVAb 0QVo3eaxScg== X-Google-Smtp-Source: AGHT+IFzOhU/CupJS32HBFgsQZDxnzUcDmYmgP1XGczLg0XwPOxOncNp3Oxx023UlCdg9OCi+Sz9ARQZuINFyA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:e13:b0:dbd:b165:441 with SMTP id df19-20020a0569020e1300b00dbdb1650441mr1361074ybb.0.1706807385893; Thu, 01 Feb 2024 09:09:45 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:26 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-6-edumazet@google.com> Subject: [PATCH net-next 05/16] bonding: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair, and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- drivers/net/bonding/bond_main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 4e0600c7b050f21c82a8862e224bb055e95d5039..181da7ea389312d7c851ca51c35b871c07144b6b 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -6419,34 +6419,34 @@ static void __net_exit bond_net_exit_batch(struct list_head *net_list) { struct bond_net *bn; struct net *net; - LIST_HEAD(list); list_for_each_entry(net, net_list, exit_list) { bn = net_generic(net, bond_net_id); bond_destroy_sysfs(bn); + bond_destroy_proc_dir(bn); } +} + +static void __net_exit bond_net_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_kill_list) +{ + struct bond_net *bn; + struct net *net; /* Kill off any bonds created after unregistering bond rtnl ops */ - rtnl_lock(); list_for_each_entry(net, net_list, exit_list) { struct bonding *bond, *tmp_bond; bn = net_generic(net, bond_net_id); list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) - unregister_netdevice_queue(bond->dev, &list); - } - unregister_netdevice_many(&list); - rtnl_unlock(); - - list_for_each_entry(net, net_list, exit_list) { - bn = net_generic(net, bond_net_id); - bond_destroy_proc_dir(bn); + unregister_netdevice_queue(bond->dev, dev_kill_list); } } static struct pernet_operations bond_net_ops = { .init = bond_net_init, .exit_batch = bond_net_exit_batch, + .exit_batch_rtnl = bond_net_exit_batch_rtnl, .id = &bond_net_id, .size = sizeof(struct bond_net), }; From patchwork Thu Feb 1 17:09:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541470 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3314715F311 for ; Thu, 1 Feb 2024 17:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807389; cv=none; b=MCe3FUWSBMqH9e/j+feXiUJ1SWGYdSPlKZ4nDRS0JXxJSeZytM7xSBS3WIctftflU4U2G1q/V7lSwHW2rcDg7c2lUL5MIschnUOQGNaxEbcVrwDN4U/VIpaFbHkga3hHjyb8BfYvrzyW4jHOlqkWEPXUFIBAKuHXMHajkeGtfh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807389; c=relaxed/simple; bh=q1218h7euvV3oNlID7Q2Agln3B9CZaxoKEXSQDTLv00=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Eqoiky8aZ4k5kd3mEipzMwUnsS8XLcIUsmTIuHMv4dCzASjEWSXTiSgoUx9uEw3VrwhfFirsH9HR7mTa5MCh+Bfd+eio6Rdglw88xsh4+0B4swXFyDyJWxq5gmk6i25PTO/ZQ0zl9r59JhIqXqkXO89xzhghvqx3XP75+aX4yqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IfwSOO8q; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IfwSOO8q" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6cd00633dso1630077276.3 for ; Thu, 01 Feb 2024 09:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807387; x=1707412187; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ATE4F9eHahMFf7jX1oK1J3ZVCxFKAqWpa/8L22+/G8A=; b=IfwSOO8qhn6T2imBjU2zi/+QLMhHejDSh7x5VgoFvM/OA6tM2S+uuU1iRIiSweZ+wi rMhd1/6zOnwNCp9WWiGON0/V4UjhM5MyOojAL9ololPZGiM2xmHSd7B15Iq5pODJZ5qj xjWt/HkKuUcgWfVrLYHUEyR5eK+EsBvfPuIGF9cXte/ZKhS9Ipfx6OhcF3y2IWi02Aov qRR/9Zg5rV4U13I5wWIX2ANdiwdTVH4gAEeaOoxAq4hohQ3RoJ3trN1d2TN4Ktmxmmsb zsMpq+p/nJQyN4qzHjgPeWjJvgcn7lvh20kr+xFScVwm7PKfd5kqMopCV0SRM2NgJURG Sn0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807387; x=1707412187; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ATE4F9eHahMFf7jX1oK1J3ZVCxFKAqWpa/8L22+/G8A=; b=GcyjyU9U9rgvsuak3/k9RblRPBFdPnORz+cMtqovr//9vi2oe8BF4hP0F6eajLT6Qj Nwt9UP2+mnXYsh1y+dADqmsK0Vb+b06UKyBOgml9Pn7LdcHMJiLwJDqNKxH+0GHrO9zY JPCSj4u7gSRbHlagFU0Nb1px8hqC4PNyVVGmbxtyVfhba08BPxNp/Nt2qZsXGWK8arjC uUWLHHbHXLYiyUtoAk4zSH9TfMqwS643U/eLMyvV+0q6xddFqoULvPVZKyjBvicgg9hX jW2iErrmZN6rUqPbltYDW5+KbBo/kARsTgFGxV6agxKVhXDpM8llXyaGXi2+uQf7DlbJ ftbg== X-Gm-Message-State: AOJu0Yz0Q9E8ixu2NfbPpq/vgIVpsv1lqT6OSVlTwyP226Nhk/KljSj8 sm9bliJ02wlCqfW2r75JWqjHTTLly8nz5gqUXWovIDAfynHNVk8cZQXClhd6RisiLsaPIbkrmjm sd3ADrDhxQA== X-Google-Smtp-Source: AGHT+IGMSRbZ7iy9E7J09+ztp0g904LK2YwCFX8S9FxSdElFRfIWGuZf9H6YnSxnyVzEVfkSb8X6wLOoc6EXNA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:248c:b0:dc2:3619:e94e with SMTP id ds12-20020a056902248c00b00dc23619e94emr167243ybb.6.1706807387017; Thu, 01 Feb 2024 09:09:47 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:27 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-7-edumazet@google.com> Subject: [PATCH net-next 06/16] geneve: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair, and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- drivers/net/geneve.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 32c51c244153bd760b9f58001906c04c8b0f37ff..f31fc52ef397dfe0eba854385f783fbcad7e870f 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -1900,18 +1900,13 @@ static void geneve_destroy_tunnels(struct net *net, struct list_head *head) } } -static void __net_exit geneve_exit_batch_net(struct list_head *net_list) +static void __net_exit geneve_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct net *net; - LIST_HEAD(list); - rtnl_lock(); list_for_each_entry(net, net_list, exit_list) - geneve_destroy_tunnels(net, &list); - - /* unregister the devices gathered above */ - unregister_netdevice_many(&list); - rtnl_unlock(); + geneve_destroy_tunnels(net, dev_to_kill); list_for_each_entry(net, net_list, exit_list) { const struct geneve_net *gn = net_generic(net, geneve_net_id); @@ -1922,7 +1917,7 @@ static void __net_exit geneve_exit_batch_net(struct list_head *net_list) static struct pernet_operations geneve_net_ops = { .init = geneve_init_net, - .exit_batch = geneve_exit_batch_net, + .exit_batch_rtnl = geneve_exit_batch_rtnl, .id = &geneve_net_id, .size = sizeof(struct geneve_net), }; From patchwork Thu Feb 1 17:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541471 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A3B215F32F for ; Thu, 1 Feb 2024 17:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807392; cv=none; b=j5HRdlfGzvD2QHjNW282/1RhcRG2kyKV+Yba039OQec3hoU4OEgXaftnTGvYjjgul7UdJiiIp7Bap3Atkfg3w/mb41WbgYCfdX6AspxAWeUmJbt8LzjjSWzOAklORr+xBcb2FWATXBAkIi+7C38gTAGWhve733mEFaGp6Ety8KE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807392; c=relaxed/simple; bh=ySbSnA7KzOFAYo4j/hAxP8kWMkQGj+nzQiBZZakv6DA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oby6nkrpeOMrTCuFlrOuWkeanag0/dS0aOXedhZ7sm+kPFELUeCSrLsDLcN1zItnASwCOYIY2Jqh1kPX1HJXaT+zsKZd2deyapOluBGSrUCqFAHH7e98GwtDsiWVLjP0ZlfBLYcB9FrPMAMzk0TqLAkNxBDG0PGKnDycMpGE8EI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=1pWFm7I/; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1pWFm7I/" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbf618042daso1680752276.0 for ; Thu, 01 Feb 2024 09:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807388; x=1707412188; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8fEa0zyZ5Nlvo8UAtPKoL2jk1fVNbTf74UBHu4EW2F8=; b=1pWFm7I/n0PAtvUmnVHxe0JFw7x7JXl1VQ1Pnix6syF5qXbeZoVfHVjZNomLBb7ks+ Lj1WQ4F69viepZM7q8lJCC1WKI4K1Fk8anvwNXThj1Twe79rOdyrpHNIH55vdWgmfUyb WebEZsZmYDPeBBB3S3/+JhGwkhdA7mkbXtfbu2nBt7XvlGbjYpL0yNKk9pwxWXosVfw2 dqBvtCb45WkHQ05G79zQOv4Sy9MKmKkK2rh96vmR3fqrxDGxMZPRKFApx/uSTAxglg2l gSFPvuvTfMrx6ywBXiWyLaI9KzQtoN47buYkHqJVRblc9AQeKNwDgz64KgJFDcmuZ8IR A4Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807388; x=1707412188; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8fEa0zyZ5Nlvo8UAtPKoL2jk1fVNbTf74UBHu4EW2F8=; b=wpLy0GB4AM+99PdI0TaKiC+4hn7SVE3MsevsawKKsCkmtTVnady+83sMt8S7nsYRJX DrHJbqt6GqM/d5TTmxdJiyDom+pS4dCwXaUTDddpgxsISLbXF51M7b8YzdvaTAaoi4tY x1eNE9ZoH0wcuAGWqtidCIr9zfeaG3+W5U14ofc86t7cfO1EY6wJ0daS/y1EytAK0UfY hnrbG/IPQePbDjC+PHPA7phR4Og0zSVhhlDn6BueNUgGjuSljcffbzxc9r6HgfK84R1Z hJddmwe4JH4y0W3Hxgm7FqScBryK5jSW9TaDGT1cdRp7Jx8Aad7XKI22nbmdemcHDss9 O/zg== X-Gm-Message-State: AOJu0YwjGJp/y9o8r2dDTxOupnjbmm/jY6r12IHo2OcqlxB9jFIdltZq dCTMudqZcaPTFOKV4FZYJX32Hk/2sWA/IvrKxaq7thskp8tpJpAqSMe4p6QVNkXdjTUrO+6usXl f35NpZrkjIQ== X-Google-Smtp-Source: AGHT+IH0xfNtwxswScK0p67TZD5WSLxEqwQgUl8lpXFcc7u1qrHG3kOO0Wc/xyeHwl/pVy+r0xzp7vGCehoYrA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:b21d:0:b0:dc6:db9b:7a6d with SMTP id i29-20020a25b21d000000b00dc6db9b7a6dmr66982ybj.13.1706807388532; Thu, 01 Feb 2024 09:09:48 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:28 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-8-edumazet@google.com> Subject: [PATCH net-next 07/16] gtp: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair per netns and one unregister_netdevice_many() call per netns. Signed-off-by: Eric Dumazet --- drivers/net/gtp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index b1919278e931f4e9fb6b2d2ec2feb2193b2cda61..62c601d9f7528d456dc6695814bf01a4d756d2da 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -1876,23 +1876,23 @@ static int __net_init gtp_net_init(struct net *net) return 0; } -static void __net_exit gtp_net_exit(struct net *net) +static void __net_exit gtp_net_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { - struct gtp_net *gn = net_generic(net, gtp_net_id); - struct gtp_dev *gtp; - LIST_HEAD(list); + struct net *net; - rtnl_lock(); - list_for_each_entry(gtp, &gn->gtp_dev_list, list) - gtp_dellink(gtp->dev, &list); + list_for_each_entry(net, net_list, exit_list) { + struct gtp_net *gn = net_generic(net, gtp_net_id); + struct gtp_dev *gtp; - unregister_netdevice_many(&list); - rtnl_unlock(); + list_for_each_entry(gtp, &gn->gtp_dev_list, list) + gtp_dellink(gtp->dev, dev_to_kill); + } } static struct pernet_operations gtp_net_ops = { .init = gtp_net_init, - .exit = gtp_net_exit, + .exit_batch_rtnl = gtp_net_exit_batch_rtnl, .id = >p_net_id, .size = sizeof(struct gtp_net), }; From patchwork Thu Feb 1 17:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541472 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9612016087B for ; Thu, 1 Feb 2024 17:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807396; cv=none; b=WH1/+SfaPbm7+MTYFxm+wraf7FdKsU63R7bhIDdb13wbN16wnjk4iClPuZcfxENML1jBolNCR9MeiC7X/0Mn4EOQgjxnKVCkVV9NtfVrQPZGablKL5Ow2JQ75b0xZfq334HnabHqDIyfLQRq1IKLziYADaA/L1k8mth1WIAmTgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807396; c=relaxed/simple; bh=xAxp5xFgVrFA1a6U7eL+MrrbMLGuuL5YASrdAZKQgas=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SZqvCCYcYXiQMYoWiIOZE5Y2O21lbvHb/+986jl8zsdluOaNNg/Ja4DZEpbtHbg4pumAE+TnpUl5511SDE67myrGdA55BR/N9jKV1AEoNOqRb4lXlala4cM8Q/zi7JGDJIe+bnx6XP9p0dtN9aHLE4hGmUZMhuNkKtw8SqP5maA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ICJ04jCs; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ICJ04jCs" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b269686aso1749861276.1 for ; Thu, 01 Feb 2024 09:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807389; x=1707412189; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=llOERzv0gIhQLAJyNixoUggH/iIEOzRcK8Ng/jiU/7E=; b=ICJ04jCs7RpBBQBLTpXxVBMjzw9pL+kGIYxCgh26w3usTTb6k/1rsFj0aBnIKRfwaV SQkZqWjBgSru6GmxS4W6saZEu2HEJN+3qrG4TDdRhNYu+0ssyZEUTjJI114ObRMWcatC 9mpK8TwiMYt+i2UzRgmlGbCRjnpYt+tnaLG4CdrgeYpMih4qsUZbYY5rFVEkTLdSvXWL GyCV0ROSUSFZ89aMal+wJwwOxeOw42+QUyqTBeBjseAxi4BCCAVeP0g+IAekMzRqoYhy MKLiC/dR73yNSwDD2SMP13UZCxgoo8ZYZyiOquf6/YvD+YVXjIlra7xC8XOqrYEeDudJ p6Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807389; x=1707412189; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=llOERzv0gIhQLAJyNixoUggH/iIEOzRcK8Ng/jiU/7E=; b=xAz5XNpvIfDLpfLtZfgeA/hNAD0Y94ukKqPt3159uwoHHeK3DjxMGxquRmOUk+dapV OpdGAy3az/zg9BYfQPaWqSAAYxIF/tBEv5fG+9w/0m/uP8Jaq8sqLe8A/R3qGUK4uLaj dcTZJguj/zN4u+fT1m52+3C30OPV1/5Sxp8/615a6Jmqtn/ALI2xmau7JK/fAUGOR5uB Ao0ujhETiU4xmeWn6b2Ok1bMePWKsXIjzNtDqjbn0gthJ241OcQ5Qe1z4nZ7pP9UAqqA lT3sVx/ZcdwUoVrTbTrMJ4fdVMJH3Lx8hKYGnXn3j2xGdm0DMPRJ8ELmHTnQpEJB0eIy Lw6A== X-Gm-Message-State: AOJu0YzHkF7WIGmPHwzAkrgY8/lEy1PU3/wBDYA6NGFXIqKpYe2tQStY JIGmTUzK+Yz+zGZuM/ylTtY3T2c46vT6vGjhkQs6gnF1Imncvuvr2Nx+RHleAzbiSUwjB1TiT/h 2WBaZ8vf7tw== X-Google-Smtp-Source: AGHT+IHNQ5B63wttIgNovCUZnpjrMJsQNt4CuexKJ5mddkPQjDBP6K3NPAairlHoiVTZn5Tqk0+AceLy0RTRdg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:250a:b0:dc2:3247:89d5 with SMTP id dt10-20020a056902250a00b00dc2324789d5mr166922ybb.4.1706807389474; Thu, 01 Feb 2024 09:09:49 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:29 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-9-edumazet@google.com> Subject: [PATCH net-next 08/16] ipv4: add __unregister_nexthop_notifier() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org unregister_nexthop_notifier() assumes the caller does not hold rtnl. We need in the following patch to use it from a context already holding rtnl. Add __unregister_nexthop_notifier(). unregister_nexthop_notifier() becomes a wrapper. Signed-off-by: Eric Dumazet --- include/net/nexthop.h | 1 + net/ipv4/nexthop.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/net/nexthop.h b/include/net/nexthop.h index d92046a4a078250eec528f3cb2c3ab557decad03..6647ad509faa02a9a13d58f3405c4a540abc5077 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h @@ -218,6 +218,7 @@ struct nh_notifier_info { int register_nexthop_notifier(struct net *net, struct notifier_block *nb, struct netlink_ext_ack *extack); +int __unregister_nexthop_notifier(struct net *net, struct notifier_block *nb); int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb); void nexthop_set_hw_flags(struct net *net, u32 id, bool offload, bool trap); void nexthop_bucket_set_hw_flags(struct net *net, u32 id, u16 bucket_index, diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 7270a8631406c508eebf85c42eb29a5268d7d7cf..70509da4f0806d25b3707835c08888d5e57b782e 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -3631,17 +3631,24 @@ int register_nexthop_notifier(struct net *net, struct notifier_block *nb, } EXPORT_SYMBOL(register_nexthop_notifier); -int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb) +int __unregister_nexthop_notifier(struct net *net, struct notifier_block *nb) { int err; - rtnl_lock(); err = blocking_notifier_chain_unregister(&net->nexthop.notifier_chain, nb); - if (err) - goto unlock; - nexthops_dump(net, nb, NEXTHOP_EVENT_DEL, NULL); -unlock: + if (!err) + nexthops_dump(net, nb, NEXTHOP_EVENT_DEL, NULL); + return err; +} +EXPORT_SYMBOL(__unregister_nexthop_notifier); + +int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb) +{ + int err; + + rtnl_lock(); + err = __unregister_nexthop_notifier(net, nb); rtnl_unlock(); return err; } From patchwork Thu Feb 1 17:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541476 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 442F8160886 for ; Thu, 1 Feb 2024 17:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807400; cv=none; b=nvPNJ3DC9WpWvUis07M/GCL4sFgdK93HifB04BJuoHUC8Ni4HiuwJGD2ZwFwycpvcNY4hvcQPx0++9zJEGaj9bddbEhAOSpGC6Oh9VgqBf9sXdsLFna8nMBHJe8wCzKbg0osIdTp9G+Xqt4GdLFCQ6TZ61IjeVBopCFjmNhZ+5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807400; c=relaxed/simple; bh=JG089lsaC9buA+Ubq/D0bZhmAk2945F096bngUZk74k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=LZWJM3i1C+ockthKlTRf5P1htnNGI4cmgfHI//tPztFp7jOaxtD/Skpx6wG5suZpCHZs35g39KFaReLyLw2ABtlQhug7TfIY1rvkNkKY49Rx7OJtoDLArc4QJ6q5CfQEy6BnY6bG79OWbf97hUqq/fGsR7o0kNIY5RSMgT65f1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hHe0zQjV; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hHe0zQjV" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5f0fd486b9aso17993757b3.2 for ; Thu, 01 Feb 2024 09:09:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807391; x=1707412191; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ieLLM0KqgOVOiN6xMg/fWqk86GRumgUkTZ2JXjw3xy4=; b=hHe0zQjVZxrp292ZI+eqTsTNkH/ctnDTJLH4j5v+LxbRYjhmKEKhsw5+v1thJb5CQe 65HZFeU89y2DPGChpXdTseTCTNGmgiarD431d9tQbVCVYhM0A3WJJyXh58upl+rsFp56 k0rHmseaxJtFza7LslJwZCEs//HWrMazg02g78iQKWM6ph/pPMd2phHe7qjjy73hf5do k+374SAfpnhcgAHE0V8V+p0HxzqIagn37wAaCWvg/OGkSaR6gnlErYHYt7X6Bl+5pkVb tb6r9h70THt0893JLVQpx+0Qm0ItCki3clfzufM/ewsMWnU/ohx9Tr+fc9nWoukDscOs IUtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807391; x=1707412191; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ieLLM0KqgOVOiN6xMg/fWqk86GRumgUkTZ2JXjw3xy4=; b=j73nYmdh4/KZfDi5ag+5JygANcJrQmeJxyQ8+y0MsL0VgqcW5CFnYl7cwD6X8IqysO vqkE0i7HoPiaCVK237DJEPRQs7O1RI8nxHH/ZeXKKVses35px7rrhHIR7M+MVPkXnaF4 Kibr660Ru3+LI5FfAInnN6hljHUUZKu54eJU6CNdLmDdRXKulVeALMAH5iV1fBtELoIz F8OeLyDXcpkf+nTw7tMjU3YYe0evfTWJpzlgRr12AutBDS/8yvcve2Ua9TJvbQ3+utt1 7jMOvKRXdBC1vQMqjUIjEHNvhcuteeBVpTMHrBCxIgCEp/wyb8sUMb+EF211GtTnC45t niZA== X-Gm-Message-State: AOJu0YzxWw/wluXcSvsbD84xJdS6zKYvQaKYAY/ogwwcRN33wL3n1JlA BoHEVx6Yq/ahXyt/XCuXSUB/JSFk0GXM4yuW5h94PZnH3fF7BQ2dTLTbXY6FYDWYfcZq+VjDQc7 48YQJU13uTA== X-Google-Smtp-Source: AGHT+IFtTLCRBXv5xx71HuynyZnYfJPQhhkw9ueWJsLimNtcYkBI3HwcGE7p3IkK4Sp0VpLCwlJ8ROGRzXqreg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:98d:b0:dc2:5273:53f9 with SMTP id bv13-20020a056902098d00b00dc2527353f9mr96086ybb.1.1706807390972; Thu, 01 Feb 2024 09:09:50 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:30 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-10-edumazet@google.com> Subject: [PATCH net-next 09/16] vxlan: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair per netns and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- drivers/net/vxlan/vxlan_core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 16106e088c6301d3aaa47dd73985107945735b6e..df664de4b2b6cc361363b804e7ad531d59e2cdfa 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -4846,23 +4846,25 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) } -static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) +static void __net_exit vxlan_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct net *net; - LIST_HEAD(list); - unsigned int h; + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) { struct vxlan_net *vn = net_generic(net, vxlan_net_id); - unregister_nexthop_notifier(net, &vn->nexthop_notifier_block); + __unregister_nexthop_notifier(net, &vn->nexthop_notifier_block); + + vxlan_destroy_tunnels(net, dev_to_kill); } - rtnl_lock(); - list_for_each_entry(net, net_list, exit_list) - vxlan_destroy_tunnels(net, &list); +} - unregister_netdevice_many(&list); - rtnl_unlock(); +static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) +{ + struct net *net; + unsigned int h; list_for_each_entry(net, net_list, exit_list) { struct vxlan_net *vn = net_generic(net, vxlan_net_id); @@ -4875,6 +4877,7 @@ static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) static struct pernet_operations vxlan_net_ops = { .init = vxlan_init_net, .exit_batch = vxlan_exit_batch_net, + .exit_batch_rtnl = vxlan_exit_batch_rtnl, .id = &vxlan_net_id, .size = sizeof(struct vxlan_net), }; From patchwork Thu Feb 1 17:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541473 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40B4E160892 for ; Thu, 1 Feb 2024 17:09:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807399; cv=none; b=EQRKOAhkWfdHeo8IL/D8n3SSoI7cdumahouTw74Q3Rg1HkXZMe6v+lAo1WGgM0wOKFNdlZUrrgJs3NdtLeJzxTcFz9SrVpWxZJ0/nACQVrU3ZxOg3CDxRjf0+RzZOExB/C17uZ4ZU6wJiiTHdk1wz6APzUmVgrUVbtWl9B5sCzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807399; c=relaxed/simple; bh=XTQX//FbLejVAJ/UrzG6/F1227q3/59vUO2Ojo0SXzY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=W9I/BESdjFPv18ZrT+mrnauq3gujd+ZGwGDmAa5dRwmiYYMJP+aA11CKcyklDLjYQhR4rMQNEztFOZZF33L7GNJWNp2frhGNw4bsWiU/hkTN6sRyTw1qnjzp3wAK3652A8idEp8N8fdLMQVqqBGKjdYX06fX9/uEvufoYubk+fc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=f92ZKjCR; arc=none smtp.client-ip=209.85.222.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="f92ZKjCR" Received: by mail-qk1-f201.google.com with SMTP id af79cd13be357-785448c774fso100998385a.2 for ; Thu, 01 Feb 2024 09:09:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807392; x=1707412192; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mVgCkJckaiYEnFkIIAWazyhBNwd6HMYFKCOo6OjV8E8=; b=f92ZKjCRnDbzC2VpOKcfhpsoNDfD+RyawxVfM8JYUuZ3PqWbjyZ44eIChHa4E0kd0j rbMPnmNiJZhHmex+ULt1ylIMb/3sHxE9UTZ8JaZ5ETC6p+VMLhglJyqAN46kKaTkE+B3 3/MC6j2KMEjVtM9LowJsWqUa3AhkX5X05eFsGUp6XwAktvawRA8m1O6UaevWZLUxha2q OBPLHpxvJEW/6jztGkBZZLTRdX2isdGqSBb3UbvUtTj2q0WdnM2iFPLUgkbu14KCFYio vtZrfBeOW1rINgQeoNVzn0TPzkwqqgxDj4vMoe/S5gf4I4XLmBzimnPUaeNPiFqnALTY lpjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807392; x=1707412192; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mVgCkJckaiYEnFkIIAWazyhBNwd6HMYFKCOo6OjV8E8=; b=jYws64ohrAPGMeAYwx3LXe58YPdH2wfHNugkchHnx3Owb+j58QcipN1utWFMG2Yn1A 4PpuBGGbB9phwb8qK7Jrq9TPT93p48nKuzhl9bXR5aFt3qpYxajaM5voUmKL0vJzElk9 b951LMZbJgka/Kv+Vb2t8q0atq2LoQ1KFNP7tnOSQuj/Js1YcLAvU05Fpnr0ByngPC9S 2FimcRq39lpiKFHUR2ai9zG3pBkfTLHeOTDe+PLZfRpkhrCQ+9Lo3BVIyHKU06yQjFbN DIe/NakygbQqtKL2cTJVWLE5JYmZq6XOkyGUFB2PaR9k0QTPSUxgLqJiSVW5lw5vK1Mh F5XA== X-Gm-Message-State: AOJu0Yx26j8oqJT3mE2qqEpC6UdnkotsLNSFio7Sw0kOYYSVVrG+jr3u pKABt6DL+o0ExmEnd/4gQ2OKfj6A3QHconSxMffodiJLpTPAxFdLG47keoXBSANWHVBU7UMIic0 8EaHgAid/hw== X-Google-Smtp-Source: AGHT+IElU1Rfwu4xZGlFhcaHJ7mVMUKL/Bpq9V00Q1mF6buH6knzEw80qy4n2YhaKHL7NOXUezjNqlMDciQ6yA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:620a:3c98:b0:785:4378:3a13 with SMTP id tp24-20020a05620a3c9800b0078543783a13mr81748qkn.9.1706807392054; Thu, 01 Feb 2024 09:09:52 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:31 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-11-edumazet@google.com> Subject: [PATCH net-next 10/16] ip6_gre: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/ipv6/ip6_gre.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 070d87abf7c0284aa23043391aab080534e144a7..428f03e9da45ac323aa357b5a9d299fb7f3d3a5b 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -1632,21 +1632,19 @@ static int __net_init ip6gre_init_net(struct net *net) return err; } -static void __net_exit ip6gre_exit_batch_net(struct list_head *net_list) +static void __net_exit ip6gre_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct net *net; - LIST_HEAD(list); - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) - ip6gre_destroy_tunnels(net, &list); - unregister_netdevice_many(&list); - rtnl_unlock(); + ip6gre_destroy_tunnels(net, dev_to_kill); } static struct pernet_operations ip6gre_net_ops = { .init = ip6gre_init_net, - .exit_batch = ip6gre_exit_batch_net, + .exit_batch_rtnl = ip6gre_exit_batch_rtnl, .id = &ip6gre_net_id, .size = sizeof(struct ip6gre_net), }; From patchwork Thu Feb 1 17:09:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541474 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 496B677A00 for ; Thu, 1 Feb 2024 17:09:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807399; cv=none; b=JngQULa/PY0T5pSW/+aNo/ckohNkTfzJTOf9qN7QjhNwKBmN8z15zq8AUs2s+d4cpwmqajDmLoEVyEc+D4vKrF8q4tQFcJmhj063UV/TukVgNFPBCwNZgtxDjNkb9i7rzeY7ngEtWI9l2mIjWY4O7k8Bl6AhMI+T6xl9RvM77Y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807399; c=relaxed/simple; bh=wdRWmYFd/B/sg55mHWO/kT0DC1cVUEGHXYIUf5sUu/A=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Uu4KbGeotoC/FGmDkZkGZAlDWtzSjgY6INOEIiOBNef0lSHaRBULZdFjOnkjdZRARN7VqiEDuHFi/VOIeKHa5Mh8lN3cCIxOxVVlVyCbyRPRh1wUcxsLngdZp08p0BSsbCNk4grrosodXi99QrdjydWyIMaLkq5KqH4OPf3DIps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wZyuJOgg; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wZyuJOgg" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-604186a5775so14165947b3.1 for ; Thu, 01 Feb 2024 09:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807393; x=1707412193; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0ibB0EoV+cMOFWJnnctDmwb0Z4jS3sETFpm2A5Ydve0=; b=wZyuJOgg5HZNnGB2lT7iA2BXHW8whyN2zpxuZkyjNrsjwLaaoFeEKT2VkATe71G2Oq VXqbQOzEovzS/cJDyFsFGPcJiBm4VyAfJlyQylGU89X2h0IPfNomE3KEcOM1pOfeJjte 9GdKiShs57RUiCV5vn6XMazkQnrk3SHenxqSG+GqBBow0NHxXSB0oKOD42X+XbnQYAxU CbLHVRn9xGlD28bPQDVSzoAz5v8c6azGjuLmz1mXVD9J0w4emncUBkDpKvgEsoAVO2CS CemGC57iIGteh+MBMPBPyMupEEq4aB57QYP1/+EFz7LyO8Yoft92Z9OQp+GLXnRXOEYS NxOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807393; x=1707412193; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0ibB0EoV+cMOFWJnnctDmwb0Z4jS3sETFpm2A5Ydve0=; b=BBqBkYk/8YDR3ZN6isuuhoBFCWU6Aq/Yzfx+YTCrfHQFvJeXS5ZVifigF2Os+E6isu R7Az61KSyr3vhOx+mbLaFoH++Z38ts8gwE8PU5GrJpIm+qC5UfGASKpDsu3+mq6Ml05O drwYOBp5853NlLYPcTz/XGBiUrcXlgfEhb+vP6Xge8UWObpfsAsF/1OLrJsAuFkTf6iy AEkmyXtjLkqk9Qjxg0mpsxC5FuannebtHwhn1hYYuRP/UO9yrzn4Mf71j2Gz3JcaJZff kZPXzLklMJwBkI+SnTIolILeYGN65ujUF7eQekI5aISlLyzULTkkT6uDkNavZmUL1D6M chSA== X-Gm-Message-State: AOJu0YzGSiK1GJGmfl5QoFkJCG5oYA4KgKtr1EBQdP6IOhcpHMSlnFlC Nk5qiedPZ5hsBy/bCeEI9w5q9YqfJGCDG8sUkJXzo5jb8ovgXhO9DuqYpndhlQ2H9f2Y6JlXgnl DkwlhDTcuiw== X-Google-Smtp-Source: AGHT+IFPy3/4ZgaSfoEMN1Nd3CdxfnQ6IY/K/lT0QedPtvIgK6Q1nKrXykrpyNNG5eENmdwYRGaqEqjglpGCNw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a81:ed01:0:b0:602:c1e2:c6f7 with SMTP id k1-20020a81ed01000000b00602c1e2c6f7mr1560814ywm.2.1706807393533; Thu, 01 Feb 2024 09:09:53 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:32 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-12-edumazet@google.com> Subject: [PATCH net-next 11/16] ip6_tunnel: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/ipv6/ip6_tunnel.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 46c19bd4899011d53b4feb84e25013c01ddce701..fd5217e890ecd4281db03cc6e5ca3ac4394f7e7c 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -2267,21 +2267,19 @@ static int __net_init ip6_tnl_init_net(struct net *net) return err; } -static void __net_exit ip6_tnl_exit_batch_net(struct list_head *net_list) +static void __net_exit ip6_tnl_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct net *net; - LIST_HEAD(list); - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) - ip6_tnl_destroy_tunnels(net, &list); - unregister_netdevice_many(&list); - rtnl_unlock(); + ip6_tnl_destroy_tunnels(net, dev_to_kill); } static struct pernet_operations ip6_tnl_net_ops = { .init = ip6_tnl_init_net, - .exit_batch = ip6_tnl_exit_batch_net, + .exit_batch_rtnl = ip6_tnl_exit_batch_rtnl, .id = &ip6_tnl_net_id, .size = sizeof(struct ip6_tnl_net), }; From patchwork Thu Feb 1 17:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541475 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E270E160874 for ; Thu, 1 Feb 2024 17:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807399; cv=none; b=pLoFbOD4fsEiXrt+cKmq5uPR4D90iXdZ/ZuCa0Q+uAhnACBgUH84JXxrGGXxkBKxmTtYEPlKklbvrtiGaEHWplWZt5kGbKOsnIcWgl2lTds3Aq6vpeM80x8povBkLEEz4LKh3Uqxu2m4yhZt/sbis7VAfAqf5FK5suvG4bvOm3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807399; c=relaxed/simple; bh=JMszb2Z5KV9ZDDpIwhxfStIvwhp947l6K/avJlMkHRA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=J3xHSn6EzqkZUKtuFfS+ASw0fmBhssNrwmv7CJ+K2cBR5q72toQagQYdItrIy1NGvF8+SPJuPZATIApvkQXKYRrYewmRjzsmRMR3s8DyNdkcNFkMkPj2ugGb4p9BVXIbmm34kSRpvxkws6ci+asIsyeIISmksbjizZi+dHbLwRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nyX5DPPr; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nyX5DPPr" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc693399655so1839504276.1 for ; Thu, 01 Feb 2024 09:09:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807395; x=1707412195; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=u3H8MHJng4CjO1otVqKpoT61CfOdj4d3Ms+Y4lV+Ros=; b=nyX5DPPrcFQAD/MFO+AN/8+QRNYVKUBAVtuz6BPWxFDf4Q2LHBVJz/nFe62DiEEWMR d2BgWC7d7/T1da3XX7jgDmJqK8xYrfYs8/2qXKj5BtczpfMheNIjZLJhHa2UvkzjAr5F oPOtxVyb48ftAuGFUn1P1DrPtIukgE39CQfYVOsZoVNzXRUKwZEmMEDQVbug/XUMt7+F p3IJyBmRaa1ZndVav4YF0orTeR2P/c6fmadv5RZ0xyCI30714WGypSpQiRdW6BhTN2a1 H9F70XJ5TCgThmqr2cYP40vkRsdaNpxqEGJtGsNx3Vogfc63WoDF5eoFLu5BtJKZCBdp ZtXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807395; x=1707412195; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u3H8MHJng4CjO1otVqKpoT61CfOdj4d3Ms+Y4lV+Ros=; b=l3Tp1DFYlHxY3wKhVUgOK5ce/ihqiCTJous4SG4Kzh6fxWeX7vLD6WZOS/VRthy8ZK NcIDLrCKza4VaplXdlD8ZKvQYan2CoxPcy2wCCnb6MVHrW9Lm974d03ygmyPIy0egcjX 2wAhpi/utzXTw/vZ/kcmUhFVqxgUmQr6cxtifusRQ6+bIhwoEbqoO4S6drD9L82jKkko aEpUihxcyB51KsdXfNBYFSkURN4GKvKBcgMus4EVJQJ50auQOqpYlg4p7Zwz/S2dQ45k XH+5fG9bjZ1ICVF8v+znwgAg0jq/MnHlG0ro4dYK7ABRd/7QhmU/m5Fyy4Oln73GPBYM Fn4Q== X-Gm-Message-State: AOJu0YzlqG8ombF1o4noZ34Bj7q2ULTLMdFz5xCl0spPoC4HlUGU7Uh3 +VbwMUIS7d6XOpe2CfoJ0aAL1+XF83aPxaKH1x0qesJ/mmI/vVcm1Qxi53u1OVA9UWVU+fIgrIz 3Hy3OBbr7SA== X-Google-Smtp-Source: AGHT+IFDb4yt41sYFGR+uza9l2m590wFumDxMGOCzzuvX6EEDWLFi7TnkoBgQ+rk/0KYf8vXY2khWval6JejLg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:f0a:b0:dc6:d3c0:ebe0 with SMTP id et10-20020a0569020f0a00b00dc6d3c0ebe0mr708608ybb.0.1706807395320; Thu, 01 Feb 2024 09:09:55 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:33 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-13-edumazet@google.com> Subject: [PATCH net-next 12/16] ip6_vti: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/ipv6/ip6_vti.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c index e550240c85e1c9f2fe2b835e903de28e1f08b3bc..cfe1b1ad4d85d303597784d5eeb3077383978d95 100644 --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c @@ -1174,24 +1174,22 @@ static int __net_init vti6_init_net(struct net *net) return err; } -static void __net_exit vti6_exit_batch_net(struct list_head *net_list) +static void __net_exit vti6_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct vti6_net *ip6n; struct net *net; - LIST_HEAD(list); - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) { ip6n = net_generic(net, vti6_net_id); - vti6_destroy_tunnels(ip6n, &list); + vti6_destroy_tunnels(ip6n, dev_to_kill); } - unregister_netdevice_many(&list); - rtnl_unlock(); } static struct pernet_operations vti6_net_ops = { .init = vti6_init_net, - .exit_batch = vti6_exit_batch_net, + .exit_batch_rtnl = vti6_exit_batch_rtnl, .id = &vti6_net_id, .size = sizeof(struct vti6_net), }; From patchwork Thu Feb 1 17:09:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541479 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AD3315A486 for ; Thu, 1 Feb 2024 17:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807402; cv=none; b=jfQQLvHsYMTrofIBWEYQkW9CY87rOykAnOvK8m22q5bzyIDdVFeYI0G3bBsaLsJBrELx14Xjfsw97mJ0MCu8WFKouNb7d2nK64gcptgmSqz4zn/eq7kFsWbqqHzy22HWlxxZKvkWjqZxbc8o9yxY7Jye/4RuNjEo8j5u/hEyzxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807402; c=relaxed/simple; bh=X7sSqGkp3yUZ+StfoztG2Rkj2cplEOY2gXyiFaBQs9s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=U8l5fvUH3zARaFhsc7aYO7a5n3+LRBnbI+QRy2a3YrmgIW47KGo/M+IYgIDsQiAzZnt5jE6OEFBiX5MmyA3zbcFLqsgUS8GYjGBfB94BkeamU69AQ6swX+YI8POaUBl9rG6bjGWH/VLFZaxfCxS2JfDJTvKViD2pNpUIB8q9pnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yt63Tc5M; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yt63Tc5M" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc657e9bdc4so1596797276.0 for ; Thu, 01 Feb 2024 09:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807397; x=1707412197; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mq5GottCqbKF6YINfxq0mHy5tSoPsLAfqPz7IIKtkrM=; b=yt63Tc5MXgkRFdQS/dW6tzehkGOYO/23QapXj4m54/yfT3yWi6QYulmhVHnzvwLoig bLQ1B9ZNJzUTy1UpxHv9ywkRMgPv2kylg8Av5EN7+Evz8srX0T9zDR3yGz01HOqqICxR rE4ON9rKoinnfuX3tuLbzGur5sirU+Xaalw4RIYUGywh41w6Cvqxc+iS3Dzu1+u3rB9Z TnyYXrTHygZhxo3bifmNhwg+n4NqoNQXPIgJwloT+5rZ+704Lguoh0Tv0BFbPRoiIcqg fepZzj58U3cjW81TidbMRo/eFuts8RhLq8MH/uadWDwXYWGOQHTU1Si2JJHWtIbMcxkR wiDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807397; x=1707412197; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mq5GottCqbKF6YINfxq0mHy5tSoPsLAfqPz7IIKtkrM=; b=XY7eHQDnkQuSKVTm3Qu/YPINY7mrHBEPs9zS7SCjFI0hRwniYZhDBwLP9CRuXQLfJ9 RxXuSaPPRXqUqvnrtegKy+Ua7ZH4QN5Zjht50jIKifW/1My+t+PAeBJ6AbMIYP6A+xwH IUeNf7MD/ACu0dWuiW0SRGtG0BwCaKWnE4lPFRFowQ7IWOChfD7YCEfRld8pAUwRzt+h qHwpbKILZIYxJzzcCtHeHAGlbQesLToezgztGKI9cq58C+pDV3Fq557eI9Mf/KIqG8Ym Q8Hh1yYN7q0uRXMndcR/I4+72PT8BzjCcPAr1+FGK/PceCf2EDaUO1hCBh0w+da3ZLTy l86g== X-Gm-Message-State: AOJu0Yz4+afkkUX8lDbTIyol1eMt2jdxvdWfpMJV3SE9ariGWf9Nj3RD Gp39r6/hacMijlpJ0XhWPsGuDsP19ueyQHyw3Wiox6PBDIpDuXwaI7MD/GF7uA+3115FiPmhrdX e3VRBOUOiYQ== X-Google-Smtp-Source: AGHT+IEXCz4cGDQioB9JJpQmbKopHn/ajuA/o+pP2NgHp1BT2FwTVxEsrbWAAB6xGdqrI0InAX1W+A5le02Nlg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:db82:0:b0:dc6:d890:1a97 with SMTP id g124-20020a25db82000000b00dc6d8901a97mr71116ybf.9.1706807396820; Thu, 01 Feb 2024 09:09:56 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:34 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-14-edumazet@google.com> Subject: [PATCH net-next 13/16] sit: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/ipv6/sit.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index cc24cefdb85c0944c03c019b1c4214302d18e2c8..61b2b71fa8bedea6d185348ff781356652434b33 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -1875,22 +1875,19 @@ static int __net_init sit_init_net(struct net *net) return err; } -static void __net_exit sit_exit_batch_net(struct list_head *net_list) +static void __net_exit sit_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { - LIST_HEAD(list); struct net *net; - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) - sit_destroy_tunnels(net, &list); - - unregister_netdevice_many(&list); - rtnl_unlock(); + sit_destroy_tunnels(net, dev_to_kill); } static struct pernet_operations sit_net_ops = { .init = sit_init_net, - .exit_batch = sit_exit_batch_net, + .exit_batch_rtnl = sit_exit_batch_rtnl, .id = &sit_net_id, .size = sizeof(struct sit_net), }; From patchwork Thu Feb 1 17:09:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541477 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6121E160880 for ; Thu, 1 Feb 2024 17:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807401; cv=none; b=AXMbfdk382Oq7PtNvKXfTbiUyCMK+BMNjf/RrZZhHSaArG1jwyEvYg6jePeAYlXvNIhMrmPQBEG4YxlAfhzmWRq3KoxG6mWUSm7ZKbquK0S4lzFiyZ2/g0Rkg32pO5taY7CkcT8Bnne5kSpMoKEa5N3pmDuvf5yJcXoKvX68cRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807401; c=relaxed/simple; bh=FOxReezdazBmvEjAJeKZdSJ1BUPrjF2JunNblGdihhg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aXaDMc4SoSbL5BdWp7+m/R05+rTmquQpqg4m5+8eazKt8FG2xj2TXtbKAvo1RntWScxvkbnIuEvpMh0IukhuQbNMx6q3GMDImBP3B8J9vKZEfSoE8mXoY7cYUWSFRtHQDTSDL21wfQHOBhcW436x2K824zycNDDVmni6gCP3qTo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LnP2I4Q+; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LnP2I4Q+" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64b659a9cso1950601276.3 for ; Thu, 01 Feb 2024 09:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807398; x=1707412198; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5PFaOlv58zEocA8NBHCAn/m9vvL2PSKA3vlyhgv0n1k=; b=LnP2I4Q+STjj26TyipXpZ0+W3mxo/1Z3HolExRX8gJ/0GPSP0ZV2S3lyCREvp4Y+DL gd/5itbgSNOcSeGGrV6AlIPnWTXHh798c/MrdWyVQw5VfbvkwXBTdwIG6izeCMb/JJP9 4dY84dFTg9gHSvrMjoqY+ERf5FPv0c0sbT2LE56gdOCbpfZIDRK0Uo1B3ER5CDS77v3n vpUaWiqdD4Ec6RGMqIdndJPHIEXtHxA//T9Nt3esswzfWSlz3koOxxrDvtB8ip2SIPzy 501hFwA6sQtqFLpcohvrrcKG2h5t6zxRw7C19px3Fsc+onxm/BpeyPh3Z7W5fUN+4Vuf t1CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807398; x=1707412198; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5PFaOlv58zEocA8NBHCAn/m9vvL2PSKA3vlyhgv0n1k=; b=lBND+vt2WYY/BH8vEVgX/kqnGSY5rEGqD6B0pNXAnd/rB3Ms6OK3/nXzgEGDoIhNxG EQUUNTkDpGxTe+vE1i2jb+4T82ac9WN3ThOG73icy+imDoxtkmxlcAWjI3vVo3R+mkA1 MWlSyi2qHjbHJLI5lGPBoEvy3svoeZ85x341tjFx5ZxbSd3P2gd99rdthnkmbqlR4SJf 7q94lD2oTk3rjPs+S4oejExYcgrsM5D9d/1sNzQ7GjR2QODBqQ6dZSqpzNdD9x/E22YP aPmD0mlg0znTqPVhQCiLKMgToc8My2qP0dCZ3hKXdN1EeyVI3IctcDlUu+S8uyxFSxRG 2Klg== X-Gm-Message-State: AOJu0YxPC0vu6XESxVKObk5+VQIb/8D2gxBkyimRMs0mBdAlzdtUeh1U 692zdyO4ULePlZeQGQNP+weQxW5HkHNbSmnwyekMzBLKjDBiJegb5JKiXLM7vyMZw8uYHnC0vx7 OMZBWEInavw== X-Google-Smtp-Source: AGHT+IGiA7Rta1tXqZt93uH5KkilFngr37YNS9bKD3EiiqZHQeDh9tOs9QiUp9ufxFl88wxY7AUc7UDOir7R1w== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:1a47:b0:dc2:23d8:722d with SMTP id cy7-20020a0569021a4700b00dc223d8722dmr1344563ybb.13.1706807398256; Thu, 01 Feb 2024 09:09:58 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:35 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-15-edumazet@google.com> Subject: [PATCH net-next 14/16] ip_tunnel: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair and one unregister_netdevice_many() call. This patch takes care of ipip, ip_vti, and ip_gre tunnels. Signed-off-by: Eric Dumazet --- include/net/ip_tunnels.h | 3 ++- net/ipv4/ip_gre.c | 24 +++++++++++++++--------- net/ipv4/ip_tunnel.c | 10 ++++------ net/ipv4/ip_vti.c | 8 +++++--- net/ipv4/ipip.c | 8 +++++--- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 2d746f4c9a0a4792bc16971c107d598190897433..5cd64bb2104df389250fb3c518ba00a3826c53f7 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -284,7 +284,8 @@ int ip_tunnel_init_net(struct net *net, unsigned int ip_tnl_net_id, struct rtnl_link_ops *ops, char *devname); void ip_tunnel_delete_nets(struct list_head *list_net, unsigned int id, - struct rtnl_link_ops *ops); + struct rtnl_link_ops *ops, + struct list_head *dev_to_kill); void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, const struct iphdr *tnl_params, const u8 protocol); diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 5169c3c72cffe49cef613e69889d139db867ff74..aad5125b7a65ecc770f1b962ac5b417bd931e3ba 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1025,14 +1025,16 @@ static int __net_init ipgre_init_net(struct net *net) return ip_tunnel_init_net(net, ipgre_net_id, &ipgre_link_ops, NULL); } -static void __net_exit ipgre_exit_batch_net(struct list_head *list_net) +static void __net_exit ipgre_exit_batch_rtnl(struct list_head *list_net, + struct list_head *dev_to_kill) { - ip_tunnel_delete_nets(list_net, ipgre_net_id, &ipgre_link_ops); + ip_tunnel_delete_nets(list_net, ipgre_net_id, &ipgre_link_ops, + dev_to_kill); } static struct pernet_operations ipgre_net_ops = { .init = ipgre_init_net, - .exit_batch = ipgre_exit_batch_net, + .exit_batch_rtnl = ipgre_exit_batch_rtnl, .id = &ipgre_net_id, .size = sizeof(struct ip_tunnel_net), }; @@ -1697,14 +1699,16 @@ static int __net_init ipgre_tap_init_net(struct net *net) return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0"); } -static void __net_exit ipgre_tap_exit_batch_net(struct list_head *list_net) +static void __net_exit ipgre_tap_exit_batch_rtnl(struct list_head *list_net, + struct list_head *dev_to_kill) { - ip_tunnel_delete_nets(list_net, gre_tap_net_id, &ipgre_tap_ops); + ip_tunnel_delete_nets(list_net, gre_tap_net_id, &ipgre_tap_ops, + dev_to_kill); } static struct pernet_operations ipgre_tap_net_ops = { .init = ipgre_tap_init_net, - .exit_batch = ipgre_tap_exit_batch_net, + .exit_batch_rtnl = ipgre_tap_exit_batch_rtnl, .id = &gre_tap_net_id, .size = sizeof(struct ip_tunnel_net), }; @@ -1715,14 +1719,16 @@ static int __net_init erspan_init_net(struct net *net) &erspan_link_ops, "erspan0"); } -static void __net_exit erspan_exit_batch_net(struct list_head *net_list) +static void __net_exit erspan_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { - ip_tunnel_delete_nets(net_list, erspan_net_id, &erspan_link_ops); + ip_tunnel_delete_nets(net_list, erspan_net_id, &erspan_link_ops, + dev_to_kill); } static struct pernet_operations erspan_net_ops = { .init = erspan_init_net, - .exit_batch = erspan_exit_batch_net, + .exit_batch_rtnl = erspan_exit_batch_rtnl, .id = &erspan_net_id, .size = sizeof(struct ip_tunnel_net), }; diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index beeae624c412d752bd5ee5d459a88f57640445e9..00da0b80320fb514bca58de7cd13894ab49a2ca6 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -1130,19 +1130,17 @@ static void ip_tunnel_destroy(struct net *net, struct ip_tunnel_net *itn, } void ip_tunnel_delete_nets(struct list_head *net_list, unsigned int id, - struct rtnl_link_ops *ops) + struct rtnl_link_ops *ops, + struct list_head *dev_to_kill) { struct ip_tunnel_net *itn; struct net *net; - LIST_HEAD(list); - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) { itn = net_generic(net, id); - ip_tunnel_destroy(net, itn, &list, ops); + ip_tunnel_destroy(net, itn, dev_to_kill, ops); } - unregister_netdevice_many(&list); - rtnl_unlock(); } EXPORT_SYMBOL_GPL(ip_tunnel_delete_nets); diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c index 9ab9b3ebe0cd1a9e95f489d98c5a3d89c7c0edf6..fb1f52d2131128a39ab5bf0482359b7b75989fb6 100644 --- a/net/ipv4/ip_vti.c +++ b/net/ipv4/ip_vti.c @@ -510,14 +510,16 @@ static int __net_init vti_init_net(struct net *net) return 0; } -static void __net_exit vti_exit_batch_net(struct list_head *list_net) +static void __net_exit vti_exit_batch_rtnl(struct list_head *list_net, + struct list_head *dev_to_kill) { - ip_tunnel_delete_nets(list_net, vti_net_id, &vti_link_ops); + ip_tunnel_delete_nets(list_net, vti_net_id, &vti_link_ops, + dev_to_kill); } static struct pernet_operations vti_net_ops = { .init = vti_init_net, - .exit_batch = vti_exit_batch_net, + .exit_batch_rtnl = vti_exit_batch_rtnl, .id = &vti_net_id, .size = sizeof(struct ip_tunnel_net), }; diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 27b8f83c6ea200314f41a29ecfea494b9ddef2ca..0151eea06cc50bec4ae64f08ca6a7161e3cbf9ae 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -592,14 +592,16 @@ static int __net_init ipip_init_net(struct net *net) return ip_tunnel_init_net(net, ipip_net_id, &ipip_link_ops, "tunl0"); } -static void __net_exit ipip_exit_batch_net(struct list_head *list_net) +static void __net_exit ipip_exit_batch_rtnl(struct list_head *list_net, + struct list_head *dev_to_kill) { - ip_tunnel_delete_nets(list_net, ipip_net_id, &ipip_link_ops); + ip_tunnel_delete_nets(list_net, ipip_net_id, &ipip_link_ops, + dev_to_kill); } static struct pernet_operations ipip_net_ops = { .init = ipip_init_net, - .exit_batch = ipip_exit_batch_net, + .exit_batch_rtnl = ipip_exit_batch_rtnl, .id = &ipip_net_id, .size = sizeof(struct ip_tunnel_net), }; From patchwork Thu Feb 1 17:09:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541478 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2248477A00 for ; Thu, 1 Feb 2024 17:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807402; cv=none; b=U7fo12sjx/byAczWy62I7qZgu+Cwbeqv/Hntt4T0wsRstwPI7Qg/ce6Mu0azDddoRpHqmRD4sW5ekfsieQ+4HqZSzvp3T3xJQl8OOT1kw8EUF5t2wgQYmAlU0XhiBtyyVE6GL01P0DJrAdW+ROXSFNau5ciDXKwHXpT2UC9MJSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807402; c=relaxed/simple; bh=Cq9PcObZdqosdaesc4ujaDFLK2u1ADvFxZIUhiyCqeU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kxUTDEBPMIWHbr6a3HLUtv+dtEYSvAnW4BaU3YADSAdcEpmiUQYZFI89KQg2DfMtbpyXwMPmlxmviU90QoHll/i8uluAaKi19BdiOCaFl/s3GvAKdXHk/TBjsilBdAQpiMIgQ9G8VaU3aV682olNfOZ0Q5BieKR4G/SgVkOY//c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VQh1NXce; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VQh1NXce" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6040aaa4e79so18890577b3.3 for ; Thu, 01 Feb 2024 09:10:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807400; x=1707412200; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QC0vfFxLW0KGWFrcZH0YSELGCgQ0d41lb4ijkHsusSU=; b=VQh1NXce8uDYgaElkF/wcE1dcO007KvBBM70nSBz52QDV135jlNauCraaC2c1R2PDa Yv1MQa5PWCQZOq7h9L/TaFKdnHPGvtxTDqSmdTSk/p0OjKwoM+aO/xZFCBJ3bzGuQ8sC X72QraVbHcpiV3hx4BEnQ+HtKovJAOJJywdVGqklr20ISTq2UmlWJr0bTLW9RUWPO2rX z99zF4TuTMoOEZa2vJwSYvR82Q6O5gXhEXMQynIUSEpjOjCm+RnldMOzYN38a8K9A1FB mwS5TTXq3+35rfEqpoXJ64eBA6obkoXJBw6VWWgMWwAajivfAm0qTrQfLxp9vJyv3HE8 lrnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807400; x=1707412200; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QC0vfFxLW0KGWFrcZH0YSELGCgQ0d41lb4ijkHsusSU=; b=JcNeNaUn87LoN/PCrxhox+aSWctQkzPRapoWD1coVxr8nrAPziOZWkG2N+3DxEaqeP WTw6F7gqlVlyvEp1Te2A/i4sBo2OB2TOq6+gVaVKLBpjH7bji5+TJ+xKY5RwRcxssoxx vaUttY5HzZN805SbMzMWRC7EH1wn0VRRtr+0d72Tn99nm7KyTAlPIXfhBDSgOgGQFdrs y5lnsqKCk18mBklnB/Fg9Oztmb/lhNXMYOJBJEhm4nJNUtKGrveMis++4YQBkLHOj0jA Z2KE6s6pKCcdT/UIRAF7rizL/XnT2AOl6Hn3/q/4/0DfS92lpXIoKO+ZfVGIavvetFNh SEaA== X-Gm-Message-State: AOJu0Yydvq64E3nboOCFQNjNGxSU7z0LBqE5zmk9homDFEVjW1nOznxk lkt8ysUA3llZ+vFPAqQrb3ER/LCYB7Wy/pfsrwNF6ml59S/M1zxqp9/CQvtDRGgy4NOaFcjGs4w uPqBK2CQmvA== X-Google-Smtp-Source: AGHT+IGVIZLIKrgl/q5iR6pmG8/9CoKwRkCdKZis1Baaa9eIOX6MHcFedxPwlu9WJerIeGCE8lFAe9p69BZcRg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:690c:d89:b0:5ff:a17b:34d with SMTP id da9-20020a05690c0d8900b005ffa17b034dmr883602ywb.8.1706807400046; Thu, 01 Feb 2024 09:10:00 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:36 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-16-edumazet@google.com> Subject: [PATCH net-next 15/16] bridge: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair per netns and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/bridge/br.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/net/bridge/br.c b/net/bridge/br.c index ac19b797dbece972f236211b9b286c298315df25..2cab878e0a39c99c10952be7d5c732a40c754655 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -356,26 +356,21 @@ void br_opt_toggle(struct net_bridge *br, enum net_bridge_opts opt, bool on) clear_bit(opt, &br->options); } -static void __net_exit br_net_exit_batch(struct list_head *net_list) +static void __net_exit br_net_exit_batch_rtnl(struct list_head *net_list, + struct list_head *dev_to_kill) { struct net_device *dev; struct net *net; - LIST_HEAD(list); - - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_list, exit_list) for_each_netdev(net, dev) if (netif_is_bridge_master(dev)) - br_dev_delete(dev, &list); - - unregister_netdevice_many(&list); - - rtnl_unlock(); + br_dev_delete(dev, dev_to_kill); } static struct pernet_operations br_net_ops = { - .exit_batch = br_net_exit_batch, + .exit_batch_rtnl = br_net_exit_batch_rtnl, }; static const struct stp_proto br_stp_proto = { From patchwork Thu Feb 1 17:09:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13541480 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF4B1161B63 for ; Thu, 1 Feb 2024 17:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807404; cv=none; b=iX4b85ZBcGiBUAYEqzqy+QBdqayJUxxbtR9nS1EECVUH+/30zHAkN4ewsKZL0dU1Ue0LVDFdOf39D22C4LZBqfCcr0WimSsbAzbClJVO+2C4KBX1i45bfM41KOeTmRBXjutjXN7cy47DZYFhqOeJopTMEbbLfaJR2ZPWl6X4Q3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706807404; c=relaxed/simple; bh=tIuUHEiTAyNoogXhr1fPfKvWp3GOsNFmlGQo6c4DLcA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=B8Y2GQcm7S4qZ0+vaQXAqTTIQLyE6uX1qfEI8R6I/PsL1KICA9ttUcxeJKiz12Zlo75koBfsfwcWRtiyoA8XA5XSfhFRFVWNHqH5I6Bo+WdpBUyC2wHh1tGsfK3hJAKRPKwLRBX6+Moj3bgX9Uv/uH+siTcrmcmKcN3Jl0HJ79s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=O350cbXh; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="O350cbXh" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6ba5fdf1aso1580441276.1 for ; Thu, 01 Feb 2024 09:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706807402; x=1707412202; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sYHPXhTKrhLq5KSpWdX/0gb12Fsu7f5tuc69AnEURmI=; b=O350cbXh56CFPUaGVHyMNc3pj2S15o+bMuyWJytz6Ku9qkLFs7Hh6tBFqvzTJ4xip6 szBPVN0OrZkgih3OCuQrctsLWbyryU93ybBLuvaRfBaws3JxWgeShFZa8OemCh64pazC hRNZJxDhlLShhLCjEcneQX9pVDw69UY4PfYqEEEvAn6HpzImwKT1QI1JxSxi/c8mkF6V tJFA51jEeECo8X2CvemLtcd1uieUGpcSVgCXpaDPZ2vQTEicB2Wam7yTY82cFqI1Gr0u k3muDLmFhoGbEIWHA56kLeAHMTwB+Pj/b+ENyzDVPOZXRWLGZTIi3wdAA2GmzBmX7733 Pt/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706807402; x=1707412202; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sYHPXhTKrhLq5KSpWdX/0gb12Fsu7f5tuc69AnEURmI=; b=FBjzA61xyTXsavj4A2IlGzVNXY9iCWHjtX3m/s32MTNDYXVJfTgu7IBJwZa4YL+I0e NeenhRrlzF12P5O+LYr/i7pptWX9ZkQM0BW2Wuh3o4amWJ+1BfScveFf6jPeGh9THm4s k8aynSfio2MTFxms7eaQP1Vo9tz/sm8XsZYHdB9u4TUmUBWeqH3bj8f8WONbGt0rbicx NKRVc1mjmyupcU3xE+V8JLf89hU8QjwPlxEHM6ADHPUXqAXZVTnmeLnUsmcwPyPjC8fI kqiXReD7KONqrHlf19OdF4sYMVxuHx3NlpV5iAOdk5dW0kiM3GQwDHejODfnYxwPeFHO mkgQ== X-Gm-Message-State: AOJu0YxtyJNaaDlIRd2TecAq0NcdhGPNrwNGuobYMrM73xE1eV2JMn5L vEGXbTBSDwWDSy9sx3ocVq9yHIZkQ3EwR1BRPfZJDlpX5eLHXQubR/OARDVC9532QNKYHtX9KAG YxrlnX2jVdQ== X-Google-Smtp-Source: AGHT+IHIzKVQkUClFuD/rDCLjIQW8AK3j+JeSkzVkeoNikvjRS/4fto9Kkhf10IutEsEK4a/ZULGUBNCFCHhLg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:2602:b0:dc2:3426:c9ee with SMTP id dw2-20020a056902260200b00dc23426c9eemr192334ybb.11.1706807401889; Thu, 01 Feb 2024 09:10:01 -0800 (PST) Date: Thu, 1 Feb 2024 17:09:37 +0000 In-Reply-To: <20240201170937.3549878-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240201170937.3549878-1-edumazet@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240201170937.3549878-17-edumazet@google.com> Subject: [PATCH net-next 16/16] xfrm: interface: use exit_batch_rtnl() method From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org exit_batch_rtnl() is called while RTNL is held, and devices to be unregistered can be queued in the dev_kill_list. This saves one rtnl_lock()/rtnl_unlock() pair per netns and one unregister_netdevice_many() call. Signed-off-by: Eric Dumazet --- net/xfrm/xfrm_interface_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c index 21d50d75c26088063538d9b9da5cba93db181a1f..dafefef3cf51a79fd6701a8b78c3f8fcfd10615d 100644 --- a/net/xfrm/xfrm_interface_core.c +++ b/net/xfrm/xfrm_interface_core.c @@ -957,12 +957,12 @@ static struct rtnl_link_ops xfrmi_link_ops __read_mostly = { .get_link_net = xfrmi_get_link_net, }; -static void __net_exit xfrmi_exit_batch_net(struct list_head *net_exit_list) +static void __net_exit xfrmi_exit_batch_rtnl(struct list_head *net_exit_list, + struct list_head *dev_to_kill) { struct net *net; - LIST_HEAD(list); - rtnl_lock(); + ASSERT_RTNL(); list_for_each_entry(net, net_exit_list, exit_list) { struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id); struct xfrm_if __rcu **xip; @@ -973,18 +973,16 @@ static void __net_exit xfrmi_exit_batch_net(struct list_head *net_exit_list) for (xip = &xfrmn->xfrmi[i]; (xi = rtnl_dereference(*xip)) != NULL; xip = &xi->next) - unregister_netdevice_queue(xi->dev, &list); + unregister_netdevice_queue(xi->dev, dev_to_kill); } xi = rtnl_dereference(xfrmn->collect_md_xfrmi); if (xi) - unregister_netdevice_queue(xi->dev, &list); + unregister_netdevice_queue(xi->dev, dev_to_kill); } - unregister_netdevice_many(&list); - rtnl_unlock(); } static struct pernet_operations xfrmi_net_ops = { - .exit_batch = xfrmi_exit_batch_net, + .exit_batch_rtnl = xfrmi_exit_batch_rtnl, .id = &xfrmi_net_id, .size = sizeof(struct xfrmi_net), };