Received: by 10.223.164.202 with SMTP id h10csp96839wrb; Wed, 22 Nov 2017 16:36:15 -0800 (PST) X-Google-Smtp-Source: AGs4zMYHLJDxRrOLpEQGMjzqF8cl2A6Y2zJFCZOQMddhUtc5lOmpjxh5CoPQ95wc/SvzllVh3AyJ X-Received: by 10.84.135.3 with SMTP id 3mr23040382pli.147.1511397374977; Wed, 22 Nov 2017 16:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511397374; cv=none; d=google.com; s=arc-20160816; b=U6LxYz0KjQU5MjEVkqNklB5f6VkeRsm9tpRtGl7pZnTOKhRGNpiITUN5v/axMBOZN9 a6kYWrW6d9zgmHlXcuZPSeMbDZgPoCvJ6LxKOOTc1exrdLVYGbG2v0F/RN1KmSCvAH+0 QeNZbndscc5vFU9z0JJa9l1Ig2gpJb6U8XPug0I5rUbMPG67k1ja3Gc2T5eU9B6OmTHu rm4Zr68agPSOLuwHfBKtUrfIAYkMzDiBBaH9hpO0wzllHpHigXQZ8t6BOAE5PmO+2RYs vCWPHxKBBGG8P19HuUfZ9S6iaqNv9BT7UaBlER02SkYbm2mZCOZDnKDMQuIcv3QQeI5i LvfA== 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=1OHAZrQ8CMk1BtwIV3hO7J4+U2jZ0r85GXKBGF3Iaqk=; b=ZesVkBM0vQoOqo7JSvCeiZOIeLfElgL1L+D9no4OGlveBOZO6tMRmEyFvCfiQ3Licp ijAhEaGDl6XhcruZXTXxr7HITtsUKR+s/687JjUMQrI57dCJMLlE0n+Cut+kH/MTXxKh 2qXBcPjAc7QmItsdB9kfWz35xEaLoO07AgrdeWV6r9ZeEEGz1Z7jzjcssOywN5xqhCvk GsBIMmaopN0Klb84ija+rEK02CCgb6BJSZHT3AGmQwUCAd22jLasfOwPLW4cNY6fKZSn iv1ILw5UWqpFBaLGOpPnbTOi7/e2xsPMtQ7byeWFa6zF52y4B1jAeEET265yWoQrS/Ji zj2g== 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 b188si16093832pfb.7.2017.11.22.16.36.03; Wed, 22 Nov 2017 16:36:14 -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 S1751841AbdKWAf3 (ORCPT + 76 others); Wed, 22 Nov 2017 19:35:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:21560 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbdKWAf1 (ORCPT ); Wed, 22 Nov 2017 19:35:27 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2017 16:35:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,438,1505804400"; d="scan'208";a="1247455070" Received: from liscon3-vm1-ub16.jf.intel.com ([10.54.83.117]) by fmsmga002.fm.intel.com with ESMTP; 22 Nov 2017 16:35:26 -0800 From: Solio Sarabia To: netdev@vger.kernel.org, davem@daveloft.net, stephen@networkplumber.org Cc: kys@microsoft.com, shiny.sebastian@intel.com, solio.sarabia@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH] net-sysfs: export gso_max_size attribute Date: Wed, 22 Nov 2017 16:30:41 -0800 Message-Id: <1511397041-27994-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 The netdevice gso_max_size is exposed to allow users fine-control on systems with multiple NICs with different GSO buffer sizes, and where the virtual devices like bridge and veth, need to be aware of the GSO size of the underlying devices. In a virtualized environment, setting the right GSO sizes for physical and virtual devices makes all TSO work to be on physical NIC, improving throughput and reducing CPU util. If virtual devices send buffers greater than what NIC supports, it forces host to do TSO for buffers exceeding the limit, increasing CPU utilization in host. Suggested-by: Shiny Sebastian Signed-off-by: Solio Sarabia --- In one test scenario with Hyper-V host, Ubuntu 16.04 VM, with Docker inside VM, and NTttcp sending 40 Gbps from one container, setting the right gso_max_size values for all network devices in the chain, reduces CPU overhead about 3x (for the sender), since all TSO work is done by physical NIC. net/core/net-sysfs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 799b752..7314bc8 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -376,6 +376,35 @@ static ssize_t gro_flush_timeout_store(struct device *dev, } NETDEVICE_SHOW_RW(gro_flush_timeout, fmt_ulong); +static int change_gso_max_size(struct net_device *dev, unsigned long new_size) +{ + unsigned int orig_size = dev->gso_max_size; + + if (new_size != (unsigned int)new_size) + return -ERANGE; + + if (new_size == orig_size) + return 0; + + if (new_size <= 0 || new_size > GSO_MAX_SIZE) + return -ERANGE; + + dev->gso_max_size = new_size; + return 0; +} + +static ssize_t gso_max_size_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + return netdev_store(dev, attr, buf, len, change_gso_max_size); +} + +NETDEVICE_SHOW_RW(gso_max_size, fmt_dec); + static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { @@ -543,6 +572,7 @@ static struct attribute *net_class_attrs[] __ro_after_init = { &dev_attr_flags.attr, &dev_attr_tx_queue_len.attr, &dev_attr_gro_flush_timeout.attr, + &dev_attr_gso_max_size.attr, &dev_attr_phys_port_id.attr, &dev_attr_phys_port_name.attr, &dev_attr_phys_switch_id.attr, -- 2.7.4 From 1584335838418746224@xxx Fri Nov 17 17:39:57 +0000 2017 X-GM-THRID: 1584269216732974705 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread