From patchwork Thu Sep 27 06:48:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kumar, Rohit via dev" X-Patchwork-Id: 975548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="QpDa51ew"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42LQ9g4J2jz9s1x for ; Thu, 27 Sep 2018 16:38:15 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B0011BD8; Thu, 27 Sep 2018 06:38:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 54AB0BC2 for ; Thu, 27 Sep 2018 06:38:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 848A1F8 for ; Thu, 27 Sep 2018 06:38:11 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id n23-v6so769626wmc.1 for ; Wed, 26 Sep 2018 23:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=K7Y2Nk5S8pc5fMyJVm1gRQOBkuqp3tXOQWSmNDtjWp4=; b=QpDa51ewiMm9hNWWlbZM4vMDqEehzHCjMLjNwJD4xydVZ/R6+QRg5V4pGdIv8rdZOK Ay4z0exmMHxqcF9AWMQE0jwik1NorZCaAtMuIEyNPXKmIGKUup1qQfa3kKEsgDi+I0jG fGWBRTgABwY0NLNxNoOXwjdvwC/YPsrNbwa3c= 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; bh=K7Y2Nk5S8pc5fMyJVm1gRQOBkuqp3tXOQWSmNDtjWp4=; b=HW+pcmzxj5V82Lnkbo/dnd18/d7VQ81HJhtsHBjEYukCAQWZI0ZuHwa6i3/QhZb9Ks pg2Hq0Z4LkPY1OwtpQa4AHdzih8GjqkUumwQS6C3qJtKZHV99PM/wQmN4nKtWd7ZNLR0 9YjxPot3god6X6druxFXoVCgycxx05jx7EeedUOdU+X4lqir5RBNPBTbSltJwCs/re/c qowR4Tid76CiaZSj/vWGImFDzo3WYOY9rgNQtEW/H/Vf6y4YicEVACjkh9oQUIcozno5 bCrZOaVWwsiSjYaGyCL3xNtoIyDK0lUXLQ4jaSb/c52yK1qLwCgDxnCXBuK/pz+TmXz8 0E/g== X-Gm-Message-State: ABuFfoiRKbKaY4/X69DRMQzVun4ErbseCDSivm6bG8MS8w685scdHxi7 m0xWrml3nOSGl5pt84X1FPaQ/rGLSkM= X-Google-Smtp-Source: ACcGV60ylI+s1Q8kx4mjDvCpFgpK8B4HIzaKqsIYyJlsilNedlE69vad8OoAzO0NDq4vJr3Jr1oGCg== X-Received: by 2002:a1c:5f54:: with SMTP id t81-v6mr7023383wmb.67.1538030289378; Wed, 26 Sep 2018 23:38:09 -0700 (PDT) Received: from host-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 64-v6sm1488547wrr.64.2018.09.26.23.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Sep 2018 23:38:08 -0700 (PDT) To: dev@openvswitch.org Date: Thu, 27 Sep 2018 12:18:24 +0530 Message-Id: <20180927064827.26256-1-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.18.0.rc1.1.g6f333ff X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v7 0/3] Support dynamic rebalancing of offloaded flows X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sriharsha Basavapatna via dev From: "Kumar, Rohit via dev" Reply-To: Sriharsha Basavapatna MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org With the current OVS offload design, when an offload-device fails to add a flow rule and returns an error, OVS adds the rule to the kernel datapath. The flow gets processed by the kernel datapath for the entire life of that flow. This is fine when an error is returned by the device due to lack of support for certain keys or actions. But when an error is returned due to temporary conditions such as lack of resources to add a flow rule, the flow continues to be processed by kernel even when resources become available later. That is, those flows never get offloaded again. This problem becomes more pronounced when a flow that has been initially offloaded may have a smaller packet rate than a later flow that could not be offloaded due to lack of resources. This leads to inefficient use of HW resources and wastage of host CPU cycles. This patch-set addresses this issue by providing a way to detect temporary offload resource constraints (Out-Of-Resource or OOR condition) and to selectively and dynamically offload flows with a higher packets-per-second (pps) rate. This dynamic rebalancing is done periodically on netdevs that are in OOR state until resources become available to offload all pending flows. The patch-set involves the following changes at a high level: 1. Detection of Out-Of-Resources (OOR) condition on an offload-capable netdev. 2. Gathering flow offload selection criteria for all flows on an OOR netdev; i.e, packets-per-second (pps) rate of flows for offloaded and non-offloaded (pending) flows. 3. Dynamically replacing offloaded flows with a lower pps-rate, with non-offloaded flows with a higher pps-rate, on an OOR netdev. A new OpenvSwitch configuration option - "offload-rebalance" to enable this policy. Cost/benefits data points: 1. Rough cost of the new rebalancing, in terms of CPU time: Ran a test that replaced 256 low pps-rate flows(pings) with 256 high pps-rate flows(iperf), in a system with 4 cpus (Intel Xeon E5 @ 2.40GHz; 2 cores with hw threads enabled, rest disabled). The data showed that cpu utilization increased by about ~20%. This increase occurs during the specific second in which rebalancing is done. And subsequently (from the next second), cpu utilization decreases significantly due to offloading of higher pps-rate flows. So effectively there's a bump in cpu utilization at the time of rebalancing, that is more than compensated by reduced cpu utilization once the right flows get offloaded. 2. Rough benefits to the user in terms of offload performance: The benefits to the user is reduced cpu utilization in the host, since higher pps-rate flows get offloaded, replacing lower pps-rate flows. Replacing a single offloaded flood ping flow with an iperf flow (multiple connections), shows that the cpu %used that was originally 100% on a single cpu (rebalancing disabled) goes down to 35% (rebalancing enabled). That is, cpu utilization decreased 65% after rebalancing. 3. Circumstances under which the benefits would show up: The rebalancing benefits would show up once offload resources are exhausted and new flows with higher pps-rate are initiated, that would otherwise be handled by kernel datapath costing host cpu cycles. This can be observed using 'ovs appctl dpctl/ dump-flows' command. Prior to rebalancing, any high pps-rate flows that couldn't be offloaded due to resource crunch would show up in the output of 'dump-flows type=ovs' and after rebalancing such flows would appear in the output of 'dump-flows type=offloaded'. ****** v6-->v7: - Fixed comments from Simon Horman. Key changes: - Removed out_netdev and related code which is not needed. - Fixed a potential race between un-offloading and adding a rule to kernel. - Moved config option parameter check to respective patches. - Removed a couple of assertions. - Added a few comments. - Added a workaround to avoid a checkpatch warning for a pre-decrement op. v5-->v6: - Fixed a build error reported by 0-day robot in Patch-2 v4-->v5: - Fixed v4 comments from Ben Pfaff. Key changes: - Updated patch-0 comments to reflect cost/benefit of rebalancing - Release references to netdevs after rebalancing - Reduce ref holding window to rebalancing routine - Avoid collecting all flows before rebalancing (save time/space) - Skip rebalancing when no OOR netdev (new function netdev_any_oor()) - Avoid direct access to netdev members (add new netdev interfaces) - Handle tunnel-netdev as a special case of in-netdev (no separate var) - Remove floating point type for pps-rate (not needed, per-second based) - Simplify ukey_to_flow_netdevs() (remove tmp dpif_flow) - Update skip_offload code to more meaningful offload_type - dpif_operate() should validate offload_types - dpif_netlink_operate() should process all ops and set error if needed - Save time of last rebalancing in udpif (remove static vars) - Declare variables at point of first use where possible - Merged patch-4 into patch-3 - Simplified offload-rebalance config parameter to bool type - Removed feature enable/disable log messages v3-->v4: - Updated parse_flow_put() with the following changes: - Fixed outdev memory leak with multiple output actions - Moved variables closer to their first use - Removed outdev check while setting oor, since indev is sufficient v2-->v3: - Removed some VLOG_DBG() in patches 2 and 3 - Reworded a few VLOG_DBG() in patch 3 - Fixed a comment line in patch 3 v1-->v2: - Fixed build errors reported by 0-day robot - Updated patch prefixes with relevant subsystem names ****** Sriharsha Basavapatna (3): dpif-netlink: Detect Out-Of-Resource condition on a netdev revalidator: Gather packets-per-second rate of flows revalidator: Rebalance offloaded flows based on the pps rate NEWS | 3 + lib/dpif-netdev.c | 3 +- lib/dpif-netlink.c | 47 +++- lib/dpif-provider.h | 9 +- lib/dpif.c | 30 ++- lib/dpif.h | 12 +- lib/flow.c | 25 ++ lib/flow.h | 1 + lib/netdev-provider.h | 14 + lib/netdev.c | 89 ++++++ lib/netdev.h | 4 + ofproto/ofproto-dpif-upcall.c | 494 +++++++++++++++++++++++++++++++++- vswitchd/vswitch.xml | 21 ++ 13 files changed, 729 insertions(+), 23 deletions(-) Acked-by: Simon Horman