Received: by 10.223.164.202 with SMTP id h10csp1226130wrb; Thu, 23 Nov 2017 13:49:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMZk6F31lUAi67rpJ95PWnf/niF3vzj5W43PorA73G4nk+xBz96S9vk9ndg9+nQyE51BirMn X-Received: by 10.84.131.35 with SMTP id 32mr20957753pld.347.1511473789582; Thu, 23 Nov 2017 13:49:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511473789; cv=none; d=google.com; s=arc-20160816; b=BTQipEVzsxICVUpYkWUh1+JVOhq4BHERnvR4NAqBWoLtcjyKhrTNuMwJ2R9HTmPXMP CEWRfRRnglchO0SSUS+wm2aZ1bjShmd/gzZ7S7tBW8jGqtdj3Au15wViSep7Ppk5Aimh b8S884lup/8PXKzbwi4keTJ42FobxWJMcUZ1AI2miWH3H6S0DwsRVFIXG/2afabG2AsH cfqi5xyvAtAJqbKKBqQfTNSM0pvfU80/M7OOT7tZtNz4I0YVc5Yt2l1AIvQMl+EFPJOi Vi9dvFgOMMec4uvfqSBGJjdtID+TuJi1PCHNrbDAIzXKMR0Ije2KlWPwsTr9MOiyF2nR Z7nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=8o/sbV7+dGgGiPpJqLrYJWb8+qRPtiLwnlbIa9fjoM0=; b=fDX3og1KEiQGEwiMpNcA6TkACWJ36rLPe4LwckUUTZI+8HWYMMzE/mHAcQknZ4Udxm +rZ6zS2BRx/IsjADugeYgQhXe4x2aiiTYRnmiTcswIVHW95Ez3SaS5J0VSu/azQ3VPpj sQgHMmxLgRRS8QI+sstyNonjDNFu6+Nx0FpriEeopJsgpDV+dCqv4DuaLn6zheUUwSVG 6FiU47FwIo6YakFga0dnmDsRy0sykLDSH9w1z5HHlQD5UZTiVgmHBXGHi8rxsE5WaZ61 qm57UHy/C8ZQ2WbP1zt3pnH+1FmUABOib0BwVSWMGkFMXmKbuPDtwDqDzN+ZE3Tt7+hk GRyw== 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 p29si16881862pgn.443.2017.11.23.13.49.37; Thu, 23 Nov 2017 13:49:49 -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 S1753373AbdKWVtB (ORCPT + 73 others); Thu, 23 Nov 2017 16:49:01 -0500 Received: from mga07.intel.com ([134.134.136.100]:15600 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046AbdKWVs7 (ORCPT ); Thu, 23 Nov 2017 16:48:59 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Nov 2017 13:48:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,443,1505804400"; d="scan'208";a="5125645" Received: from ssarabia-mobl7.amr.corp.intel.com (HELO intel.com) ([10.254.21.102]) by FMSMGA003.fm.intel.com with ESMTP; 23 Nov 2017 13:48:58 -0800 Date: Thu, 23 Nov 2017 13:48:57 -0800 From: Solio Sarabia To: netdev@vger.kernel.org, davem@davemloft.net, stephen@networkplumber.org Cc: kys@microsoft.com, shiny.sebastian@intel.com, solio.sarabia@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net-sysfs: export gso_max_size attribute Message-ID: <20171123214857.GA41@intel.com> References: <1511397041-27994-1-git-send-email-solio.sarabia@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1511397041-27994-1-git-send-email-solio.sarabia@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 22, 2017 at 04:30:41PM -0800, Solio Sarabia wrote: > 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; > +} Hindsight, we need to re-evaluate the valid range. As it is now, in a virtualized environment, users could set the gso to a value greater than what NICs expose, which would inflict the original issue: overhead in the host os due to a configuration value in the vm. > + > +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 1584815013675121436@xxx Thu Nov 23 00:36:14 +0000 2017 X-GM-THRID: 1584815013675121436 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread