From patchwork Sun Mar 13 10:00:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lamparter X-Patchwork-Id: 12779123 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3369C433FE for ; Sun, 13 Mar 2022 10:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232536AbiCMKY2 (ORCPT ); Sun, 13 Mar 2022 06:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231672AbiCMKYZ (ORCPT ); Sun, 13 Mar 2022 06:24:25 -0400 Received: from eidolon.nox.tf (eidolon.nox.tf [IPv6:2a07:2ec0:2185::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 039A22DA97 for ; Sun, 13 Mar 2022 03:23:17 -0700 (PDT) Received: from [178.197.200.96] (helo=areia) by eidolon.nox.tf with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nTLHz-003JVp-GB; Sun, 13 Mar 2022 11:17:27 +0100 Received: from equinox by areia with local (Exim 4.95) (envelope-from ) id 1nTL1s-001aBP-BC; Sun, 13 Mar 2022 11:00:48 +0100 From: David Lamparter To: netdev@vger.kernel.org Cc: David Lamparter Subject: [PATCH net-next 2/2] net/packet: use synchronize_net_expedited() Date: Sun, 13 Mar 2022 11:00:33 +0100 Message-Id: <20220313100033.343442-3-equinox@diac24.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220313100033.343442-1-equinox@diac24.net> References: <20220313100033.343442-1-equinox@diac24.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since these locations don't have RTNL held, synchronize_net() uses synchronize_rcu(), which takes its time. Unfortunately, this is user visible on bind() and close() calls from userspace. With a good amount of network interfaces, this sums up to Wireshark (dumpcap) taking several seconds to start for no good reason. Signed-off-by: David Lamparter Reported-by: kernel test robot --- net/packet/af_packet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 1b93ce1a5600..559e72149110 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -379,7 +379,7 @@ static void __unregister_prot_hook(struct sock *sk, bool sync) if (sync) { spin_unlock(&po->bind_lock); - synchronize_net(); + synchronize_net_expedited(); spin_lock(&po->bind_lock); } } @@ -1578,7 +1578,7 @@ static void __fanout_set_data_bpf(struct packet_fanout *f, struct bpf_prog *new) spin_unlock(&f->lock); if (old) { - synchronize_net(); + synchronize_net_expedited(); bpf_prog_destroy(old); } } @@ -3137,7 +3137,7 @@ static int packet_release(struct socket *sock) f = fanout_release(sk); - synchronize_net(); + synchronize_net_expedited(); kfree(po->rollover); if (f) { @@ -4453,7 +4453,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, } spin_unlock(&po->bind_lock); - synchronize_net(); + synchronize_net_expedited(); err = -EBUSY; mutex_lock(&po->pg_vec_lock);