From patchwork Fri Oct 23 09:18:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Jin X-Patchwork-Id: 534849 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9BE73141321 for ; Fri, 23 Oct 2015 20:18:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830AbbJWJSk (ORCPT ); Fri, 23 Oct 2015 05:18:40 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:42321 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbbJWJSh (ORCPT ); Fri, 23 Oct 2015 05:18:37 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t9N9IS3r018710 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Oct 2015 09:18:28 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t9N9IRdx030004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 23 Oct 2015 09:18:27 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t9N9IRS5007614; Fri, 23 Oct 2015 09:18:27 GMT Received: from dhcp-cn-10-182-71-92.cn.oracle.com (/10.182.71.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Oct 2015 02:18:27 -0700 Subject: [PATCH V2 1/2] xen-netback: limit xen vif max queues number to online cpus To: wei.liu2@citrix.com, Ian Campbell , Boris Ostrovsky , Konrad Rzeszutek Wilk , "David S. Miller" , Jan Beulich References: <5629FB31.5060806@oracle.com> Cc: netdev@vger.kernel.org, xen-devel@lists.xenproject.org From: Joe Jin Message-ID: <5629FB5F.5060301@oracle.com> Date: Fri, 23 Oct 2015 17:18:23 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <5629FB31.5060806@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Should not allocate xen vif queues number more than online cpus. Signed-off-by: Joe Jin Cc: Jan Beulich Cc: Wei Liu Cc: Ian Campbell Cc: Boris Ostrovsky Cc: Konrad Rzeszutek Wilk --- drivers/net/xen-netback/netback.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index ec98d43..021dcb0 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -68,7 +68,9 @@ unsigned int rx_stall_timeout_msecs = 60000; module_param(rx_stall_timeout_msecs, uint, 0444); unsigned int xenvif_max_queues; -module_param_named(max_queues, xenvif_max_queues, uint, 0644); +static int xennet_set_max_queues(const char *val, struct kernel_param *kp); +module_param_call(max_queues, xennet_set_max_queues, param_get_uint, + &xenvif_max_queues, 0644); MODULE_PARM_DESC(max_queues, "Maximum number of queues per virtual interface"); @@ -107,6 +109,20 @@ static struct xen_netif_rx_response *make_rx_response(struct xenvif_queue *queue u16 size, u16 flags); +static int xennet_set_max_queues(const char *val, struct kernel_param *kp) +{ + unsigned int cpus = num_online_cpus(); + unsigned int max_queues = simple_strtoul(val, NULL, 10); + + if (max_queues == 0 || max_queues > cpus) { + pr_info("max_queues %u is out of range [0 - %u]!\n", + max_queues, cpus); + return -ERANGE; + } + + return param_set_uint(val, kp); +} + static inline unsigned long idx_to_pfn(struct xenvif_queue *queue, u16 idx) { @@ -2110,15 +2126,15 @@ int xenvif_dealloc_kthread(void *data) static int __init netback_init(void) { int rc = 0; + unsigned int cpus = num_online_cpus(); if (!xen_domain()) return -ENODEV; - /* Allow as many queues as there are CPUs if user has not - * specified a value. - */ - if (xenvif_max_queues == 0) - xenvif_max_queues = num_online_cpus(); + /* Allow at most as many queues as CPUs. */ + if (xenvif_max_queues == 0 || xenvif_max_queues > cpus) + xenvif_max_queues = cpus; + pr_info("vif max_queues: %u\n", xenvif_max_queues); if (fatal_skb_slots < XEN_NETBK_LEGACY_SLOTS_MAX) { pr_info("fatal_skb_slots too small (%d), bump it to XEN_NETBK_LEGACY_SLOTS_MAX (%d)\n",