Received: by 10.223.164.202 with SMTP id h10csp3647696wrb; Sat, 25 Nov 2017 13:32:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMZuTdkjnY1kDqAz8yKx9W3Pxkq9HA0HFVPwDdclgxS5oZj+cfHM2WnOHFCVpwkx438ciDCz X-Received: by 10.84.179.3 with SMTP id a3mr33387963plc.25.1511645524489; Sat, 25 Nov 2017 13:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511645524; cv=none; d=google.com; s=arc-20160816; b=AzGu8atjHGZdQiYHHDmFOtzpUVeKYr6K/OH++1z+Xy6fQ++x6SvMftujZPq+898kmY yLh31xg77zkrXAEriylZq1/Wh13uBlBbgAUdKbktnJucG5n1q9XLH0Wgnm6qdtsjXRl8 OzzbQL0gLboSu5+Lncwr3gW6KxrDWd2Lha85uzILidqSsZPDMae7K17/JdZgfAxgiHsr gpWTI4D1dIlBIrwVVokGQoZJo6u2MyCh2vzt3ZFPhUde6dAwiJ3ju5Ww7wMYCHVHEoui tJJ3f4J1BFHLyrR4HxK0lslETlqc7xpdoiQXo7Xkz3P65bsUelx8wijKKDdyivYdykQU 5T4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=I2sOykThWI7Jto9suxw8cwb0j5sQCr10CPbB4NJtsmU=; b=KrDzjd7Dk/TBcOTqp++7DcWk4W9zu12di28JaUMigSoF28FR4iJ30I4iGJ35cuXz+Y FqiucrVvVlI1bUdEhwoG51lum+49Nj+XZJYXa6dA/JNqImo5+nvBCbMQX00YWiDHNANR dQbE72Fv3Olb+fqw1Vzwqul94pjZEgOgNxVu+rn8Eb6OWb0crXKjcyFbVM+hHzEPexpo jv7cVZEpajL7CO62IbBgEDT2dACV8dU55rIfYacQ3qPHxH+9y3lwG0taje1NH18jNApT RsswegzSlYVa7yCcxRX6AZjukv+4ISRBN2ZzZ0XcXO+SGcY7wrDOF4IR6cAZ1Eg/sxo0 s//g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e68si20518614pgc.143.2017.11.25.13.31.52; Sat, 25 Nov 2017 13:32:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbdKYVbS (ORCPT + 81 others); Sat, 25 Nov 2017 16:31:18 -0500 Received: from mga09.intel.com ([134.134.136.24]:56342 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbdKYVbR (ORCPT ); Sat, 25 Nov 2017 16:31:17 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2017 13:31:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,455,1505804400"; d="scan'208";a="180147019" Received: from liscon3-vm1-ub16.jf.intel.com ([10.54.83.117]) by fmsmga005.fm.intel.com with ESMTP; 25 Nov 2017 13:31:16 -0800 From: Solio Sarabia To: netdev@vger.kernel.org, davem@davemloft.net, stephen@networkplumber.org, eric.dumazet@gmail.com, dsahern@gmail.com Cc: kys@microsoft.com, shiny.sebastian@intel.com, solio.sarabia@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH RFC] veth: make veth aware of gso buffer size Date: Sat, 25 Nov 2017 13:26:52 -0800 Message-Id: <1511645212-18600-1-git-send-email-solio.sarabia@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GSO buffer size supported by underlying devices is not propagated to veth. In high-speed connections with hw TSO enabled, veth sends buffers bigger than lower device's maximum GSO, forcing sw TSO and increasing system CPU usage. Signed-off-by: Solio Sarabia --- Exposing gso_max_size via sysfs is not advised [0]. This patch queries available interfaces get this value. Reading dev_list is O(n), since it can be large (e.g. hundreds of containers), only a subset of interfaces is inspected. _Please_ advise pointers how to make veth aware of lower device's GSO value. In a test scenario with Hyper-V, Ubuntu VM, Docker inside VM, and NTttcp microworkload sending 40 Gbps from one container, this fix reduces 3x sender host CPU overhead, since now all TSO is done on physical NIC. Savings in CPU cycles benefit other use cases where veth is used, and the GSO buffer size is properly set. [0] https://lkml.org/lkml/2017/11/24/512 drivers/net/veth.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index f5438d0..e255b51 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -298,6 +298,34 @@ static const struct net_device_ops veth_netdev_ops = { NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | \ NETIF_F_HW_VLAN_STAG_TX | NETIF_F_HW_VLAN_STAG_RX ) +static void veth_set_gso(struct net_device *dev) +{ + struct net_device *nd; + unsigned int size = GSO_MAX_SIZE; + u16 segs = GSO_MAX_SEGS; + unsigned int count = 0; + const unsigned int limit = 10; + + /* Set default gso based on available physical/synthetic devices, + * ignore virtual interfaces, and limit looping through dev_list + * as the total number of interfaces can be large. + */ + read_lock(&dev_base_lock); + for_each_netdev(&init_net, nd) { + if (count >= limit) + break; + if (nd->dev.parent && nd->flags & IFF_UP) { + size = min(size, nd->gso_max_size); + segs = min(segs, nd->gso_max_segs); + } + count++; + } + + read_unlock(&dev_base_lock); + netif_set_gso_max_size(dev, size); + dev->gso_max_segs = size ? size - 1 : 0; +} + static void veth_setup(struct net_device *dev) { ether_setup(dev); @@ -323,6 +351,8 @@ static void veth_setup(struct net_device *dev) dev->hw_features = VETH_FEATURES; dev->hw_enc_features = VETH_FEATURES; dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE; + + veth_set_gso(dev); } /* -- 2.7.4 From 1584872915487897620@xxx Thu Nov 23 15:56:34 +0000 2017 X-GM-THRID: 1584872915487897620 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread