From patchwork Thu Aug 20 22:49:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1348663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=kbdnvwVD; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BXfyB2PcSz9sPB for ; Fri, 21 Aug 2020 08:50:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id CA213885F2; Thu, 20 Aug 2020 22:50:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aIEaju5FY35o; Thu, 20 Aug 2020 22:50:51 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 6AA8788507; Thu, 20 Aug 2020 22:50:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8E6EEC0051; Thu, 20 Aug 2020 22:50:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6B4E4C0051 for ; Thu, 20 Aug 2020 22:50:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4019388447 for ; Thu, 20 Aug 2020 22:50:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l94Qzwxg1dOF for ; Thu, 20 Aug 2020 22:50:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by whitealder.osuosl.org (Postfix) with ESMTPS id 005CC88404 for ; Thu, 20 Aug 2020 22:50:08 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id ds1so94781pjb.1 for ; Thu, 20 Aug 2020 15:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q7Yy9//Fyi3QNhCVYKvYeHrq+MY1vVHU1fPpl6mtOdA=; b=kbdnvwVDKEpyv7s+c8jyKH8aWyIbYwL7sAww+j70TB33oIXEIOVn8orNeIYvKMRR3o msosTaIe73/muyQKGm6vVWinM2+Iu+zzEuPJ5h0HxdMmRPiAX7uWb79xYvDpuyuEhtHq gyyB4vZOdZsvZuqiiwqBUBehQZwQ0PROZ8SyUrIX7QVfCR/sfVTXubpJ82Ry3Nt1Ymsv qEIwDz4LGATpT0Rrg9D9zVEcJdaUU34H6QY+UqBNufIN0Fql/2n37zqRs/L7HVkq0o5x O2nKadWd+ANtM87YT4OG7Gyg/rbaDEupO4icPzS1e9H73QYavmhA74zzXuYJdUBhdTPJ ftZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q7Yy9//Fyi3QNhCVYKvYeHrq+MY1vVHU1fPpl6mtOdA=; b=d2pVL/J4aEVXK/tOTFCJSq4crrdwFdVQ+ORr6Voz5kYqWnNufBwrKkGSwkQPMQ89NH AWQDlJ86DdFcOrhn7SEICstW4K7s34kuy6JiVZglRWj9lh6YMWP2mCvsB44EtR1zk9+f bzPYQxul9u3RsmUR0CGWh1xWQMpuq9KQt9YNeSv94N5azEpxaBquGBNjif/YzznLKFAr 4Ty6cg87w0d1Am3Vn4AwCZIcH8LAqiz0MTx0JzBqu+PWCK8X9TDOh/AmTQdyVlqYUqNq uDHsxAZxORdM8Vp45s6BNeIM2g0+OZorLSvCAoA/7BLvsZNG9liKyyVYlrXhGgviXAY/ mTdA== X-Gm-Message-State: AOAM530KKIoBhx5r30cps398WXvyn+3qpzcUtjCDi1xxARec1wbZ1swG j7vIPVMFa+dULqDcTrFL66Kko+pgPiRAYA== X-Google-Smtp-Source: ABdhPJyf5VrdIdbj7KUNs5HNVkH2SjZphQIoxtc86aSRzuev3XxHF1pyD18z40p0WUExEOhr6cPnAw== X-Received: by 2002:a17:902:aa8e:: with SMTP id d14mr1137plr.147.1597963807570; Thu, 20 Aug 2020 15:50:07 -0700 (PDT) Received: from gizo.domain (97-115-99-106.ptld.qwest.net. [97.115.99.106]) by smtp.gmail.com with ESMTPSA id y6sm116866pfr.61.2020.08.20.15.50.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 15:50:06 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Thu, 20 Aug 2020 15:49:31 -0700 Message-Id: <1597963790-12362-5-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> References: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH 04/23] datapath: do not update max_headroom if new headroom is equal to old headroom X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Taehee Yoo Upstream commit: commit 6b660c4177aaebdc73df7a3378f0e8b110aa4b51 Author: Taehee Yoo Date: Sat Jul 6 01:08:09 2019 +0900 net: openvswitch: do not update max_headroom if new headroom is equal to old headroom When a vport is deleted, the maximum headroom size would be changed. If the vport which has the largest headroom is deleted, the new max_headroom would be set. But, if the new headroom size is equal to the old headroom size, updating routine is unnecessary. Signed-off-by: Taehee Yoo Tested-by: Greg Rose Reviewed-by: Greg Rose Signed-off-by: David S. Miller Cc: Taehee Yoo Signed-off-by: Greg Rose --- datapath/datapath.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index 4c485c8..2879f24 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -2072,10 +2072,9 @@ static struct vport *lookup_vport(struct net *net, } -/* Called with ovs_mutex */ -static void update_headroom(struct datapath *dp) +static unsigned int ovs_get_max_headroom(struct datapath *dp) { - unsigned dev_headroom, max_headroom = 0; + unsigned int dev_headroom, max_headroom = 0; struct net_device *dev; struct vport *vport; int i; @@ -2089,10 +2088,19 @@ static void update_headroom(struct datapath *dp) } } - dp->max_headroom = max_headroom; + return max_headroom; +} + +/* Called with ovs_mutex */ +static void ovs_update_headroom(struct datapath *dp, unsigned int new_headroom) +{ + struct vport *vport; + int i; + + dp->max_headroom = new_headroom; for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) - netdev_set_rx_headroom(vport->dev, max_headroom); + netdev_set_rx_headroom(vport->dev, new_headroom); } static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) @@ -2103,6 +2111,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) struct sk_buff *reply; struct vport *vport; struct datapath *dp; + unsigned int new_headroom; u32 port_no; int err; @@ -2165,8 +2174,10 @@ restart: OVS_VPORT_CMD_NEW); BUG_ON(err < 0); - if (netdev_get_fwd_headroom(vport->dev) > dp->max_headroom) - update_headroom(dp); + new_headroom = netdev_get_fwd_headroom(vport->dev); + + if (new_headroom > dp->max_headroom) + ovs_update_headroom(dp, new_headroom); else netdev_set_rx_headroom(vport->dev, dp->max_headroom); @@ -2235,11 +2246,12 @@ exit_unlock_free: static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info) { - bool must_update_headroom = false; + bool update_headroom = false; struct nlattr **a = info->attrs; struct sk_buff *reply; struct datapath *dp; struct vport *vport; + unsigned int new_headroom; int err; reply = ovs_vport_cmd_alloc_info(); @@ -2265,13 +2277,17 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info) /* the vport deletion may trigger dp headroom update */ dp = vport->dp; if (netdev_get_fwd_headroom(vport->dev) == dp->max_headroom) - must_update_headroom = true; + update_headroom = true; + netdev_reset_rx_headroom(vport->dev); ovs_dp_detach_port(vport); - if (must_update_headroom) - update_headroom(dp); + if (update_headroom) { + new_headroom = ovs_get_max_headroom(dp); + if (new_headroom < dp->max_headroom) + ovs_update_headroom(dp, new_headroom); + } ovs_unlock(); ovs_notify(&dp_vport_genl_family, &ovs_dp_vport_multicast_group, reply, info);