Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp246000pxx; Wed, 28 Oct 2020 04:00:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyq8Hrja7VElxfpS3b9F9ZCJnD/kBrCYwcQ4wAJtS+GdFQqh3PYY/h7ncNoVm16Saa+Np1r X-Received: by 2002:a17:906:48a:: with SMTP id f10mr2695387eja.5.1603882849658; Wed, 28 Oct 2020 04:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603882849; cv=none; d=google.com; s=arc-20160816; b=WUMGBkNIMDrlPziS22xu0g99IvzJpjr1/Opt4k517/RZS/W9Pa+KasC30iSuUbtfw9 cO2kiFf0nTOIVlj++rssNk0IWC0m3c3sINqWgPwDSDj5WEV/d/IELEG6kOWVrqbHV1/3 Y3BLbBunGQwcx25uj8F9Xc88ArBug+S5teu9jyKTESNP+IpzFjhrDUHcKrVMuqcYmwZi QZT108caFMJrnCzNZgONl9mN2WMmnq7hbVVwCD14ggC9Gehv/VIzoG4qfnAI4WVNqEa9 umz4ecBXAUvMSRmGhXTdmUkDjsY2VLX0IX+08IG5qYDG2ETLbsM9sq2QqRGFzY9o0W7K 7+XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o/qFknPHCTxs70xAMDxUTaqH5e9nWLfw/SL51dNiFk0=; b=AeXMy8vAzlIXZ//XeOt6Kj9d9c4Uf58PFOxUz9g1q1vEWEK/JWRGt8DPfMamWJLoRJ cp0GHWGw8fi3zETl3EXNo3HG/vFyVQA93nC9hwpsP7SxL0L7dNQHrMa18SRPAnGoctQq JDl66N2g/R1kH1hQc/lL2DSpM8k833JFYK6lZuAqs5DAqD75rv6IMMgJUi/yHNVbZQer zNHBBYM9Qv2LALKyZeDjmTnh1vAKG3rCNEoyeJd1FyNmhqqhiJDVZNTXu7Mq4VR3fGok 74fsb/SnclARzs128OsIihuJ7b7ZbDRFsiK54U7SUAyHkw5qbJ06gvwy2M62dLvZpoD4 7CAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bGQ3aBcm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si2868715ejb.712.2020.10.28.04.00.27; Wed, 28 Oct 2020 04:00:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bGQ3aBcm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1783427AbgJ0O6R (ORCPT + 99 others); Tue, 27 Oct 2020 10:58:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:50518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773048AbgJ0OvE (ORCPT ); Tue, 27 Oct 2020 10:51:04 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B10DE21556; Tue, 27 Oct 2020 14:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810262; bh=bYNbhbqM39yeoVrh7stHZh+bz3NNfwEA99baQdTdKyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGQ3aBcm/GgCPWX5NubEC/pse6FwBkueILP+R+NwjG8AzBMUKyeQ3mWs4FNTwuumG rrNAhhQTDuLXPKpCjpyJIFnBAfvv/xe5rmYsZuJrn141S3EGkjQmlcsEEhqhDjsUTi 2+waSf3V37cHQfR6yokXFtdElGZ2o84FDIOrByoY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Jesse Brandeburg , David Ahern , Nikolay Aleksandrov , Jakub Kicinski Subject: [PATCH 5.8 047/633] nexthop: Fix performance regression in nexthop deletion Date: Tue, 27 Oct 2020 14:46:30 +0100 Message-Id: <20201027135524.912736526@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ido Schimmel [ Upstream commit df6afe2f7c19349de2ee560dc62ea4d9ad3ff889 ] While insertion of 16k nexthops all using the same netdev ('dummy10') takes less than a second, deletion takes about 130 seconds: # time -p ip -b nexthop.batch real 0.29 user 0.01 sys 0.15 # time -p ip link set dev dummy10 down real 131.03 user 0.06 sys 0.52 This is because of repeated calls to synchronize_rcu() whenever a nexthop is removed from a nexthop group: # /usr/share/bcc/tools/offcputime -p `pgrep -nx ip` -K ... b'finish_task_switch' b'schedule' b'schedule_timeout' b'wait_for_completion' b'__wait_rcu_gp' b'synchronize_rcu.part.0' b'synchronize_rcu' b'__remove_nexthop' b'remove_nexthop' b'nexthop_flush_dev' b'nh_netdev_event' b'raw_notifier_call_chain' b'call_netdevice_notifiers_info' b'__dev_notify_flags' b'dev_change_flags' b'do_setlink' b'__rtnl_newlink' b'rtnl_newlink' b'rtnetlink_rcv_msg' b'netlink_rcv_skb' b'rtnetlink_rcv' b'netlink_unicast' b'netlink_sendmsg' b'____sys_sendmsg' b'___sys_sendmsg' b'__sys_sendmsg' b'__x64_sys_sendmsg' b'do_syscall_64' b'entry_SYSCALL_64_after_hwframe' - ip (277) 126554955 Since nexthops are always deleted under RTNL, synchronize_net() can be used instead. It will call synchronize_rcu_expedited() which only blocks for several microseconds as opposed to multiple milliseconds like synchronize_rcu(). With this patch deletion of 16k nexthops takes less than a second: # time -p ip link set dev dummy10 down real 0.12 user 0.00 sys 0.04 Tested with fib_nexthops.sh which includes torture tests that prompted the initial change: # ./fib_nexthops.sh ... Tests passed: 134 Tests failed: 0 Fixes: 90f33bffa382 ("nexthops: don't modify published nexthop groups") Signed-off-by: Ido Schimmel Reviewed-by: Jesse Brandeburg Reviewed-by: David Ahern Acked-by: Nikolay Aleksandrov Link: https://lore.kernel.org/r/20201016172914.643282-1-idosch@idosch.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -842,7 +842,7 @@ static void remove_nexthop_from_groups(s remove_nh_grp_entry(net, nhge, nlinfo); /* make sure all see the newly published array before releasing rtnl */ - synchronize_rcu(); + synchronize_net(); } static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)