From patchwork Mon Sep 24 18:01:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 974034 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="XbyvTdlx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42JsT41DMXz9s2P for ; Tue, 25 Sep 2018 04:01:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731387AbeIYAEa (ORCPT ); Mon, 24 Sep 2018 20:04:30 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33310 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728679AbeIYAEa (ORCPT ); Mon, 24 Sep 2018 20:04:30 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8OHrkAe127242 for ; Mon, 24 Sep 2018 18:01:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=qBG3FIk3L7f2/ON8VoczhMMrstl4sQ2+tsDC4QkiKn4=; b=XbyvTdlx8CILMBhZ+kupXUp4Vvq4O/k8pXmMaFCu1fk7esjrs7eKPgZly1LfNWcMr5vh 0HdkT+aR6Cfz2K+AU4yt4beJdUd9jMEmMS821l7jpUE5vsuG2Tl3ppfcSmkQcMqolN53 W6O3+GU3BFC/iC+rNGdY2xyUqjFAhmDPXH5yhSHlHuXPe+PQEkNh4jRgcp6ijeaB8Rhe FiTeRwyakAJERH/p25Dg0uL1eORcdekohq9xeJkL0n26UhMJwAyb8PdfLgrnKhTldNde 2ecQ5xTwv2nWiwuBKpReUG+DkKP5OeslWIYXp4ckDkGsCxC57cqQ78aCf2aBInYez4P+ Aw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mndpp7dqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 24 Sep 2018 18:01:09 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8OI17Nu012474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 24 Sep 2018 18:01:08 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8OI174A030335 for ; Mon, 24 Sep 2018 18:01:07 GMT Received: from slnelson-mint18.us.oracle.com (/10.159.145.127) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 24 Sep 2018 11:01:07 -0700 From: Shannon Nelson To: netdev@vger.kernel.org Cc: silviu.smarandache@oracle.com Subject: [PATCH RFC net-next] net: enable RPS on vlan devices Date: Mon, 24 Sep 2018 11:01:00 -0700 Message-Id: <1537812060-22388-1-git-send-email-shannon.nelson@oracle.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9026 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809240172 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch modifies the RPS processing code so that it searches for a matching vlan interface on the packet and then uses the RPS settings of the vlan interface.  If no vlan interface is found or the vlan interface does not have RPS enabled, it will fall back to the RPS settings of the underlying device. In supporting VMs where we can't control the OS being used, we'd like to separate the VM cpu processing from the host's cpus as a way to help mitigate the impact of the L1TF issue. When running the VM's traffic on a vlan we can stick the Rx processing on one set of cpus separate from the VM's cpus. Yes, choosing to use this may cause a bit of throughput pain when the packets are actually passed into the VM and have to move from one cache to another. Orabug: 28645929 Signed-off-by: Silviu Smarandache Signed-off-by: Shannon Nelson --- net/core/dev.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 559a912..28b12d1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3735,8 +3735,8 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb, * CPU from the RPS map of the receiving queue for a given skb. * rcu_read_lock must be held on entry. */ -static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, - struct rps_dev_flow **rflowp) +static int __get_rps_cpu(struct net_device *dev, struct sk_buff *skb, + struct rps_dev_flow **rflowp) { const struct rps_sock_flow_table *sock_flow_table; struct netdev_rx_queue *rxqueue = dev->_rx; @@ -3830,6 +3830,35 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, return cpu; } +static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, + struct rps_dev_flow **rflowp) +{ + /* Check for a vlan device with RPS settings */ + if (skb_vlan_tag_present(skb)) { + struct net_device *vdev; + u16 vid; + + vid = skb_vlan_tag_get_id(skb); + vdev = __vlan_find_dev_deep_rcu(dev, skb->vlan_proto, vid); + if (vdev) { + /* recorded queue is not referring to the vlan device. + * Save and restore it + */ + int cpu; + u16 queue_mapping = skb_get_queue_mapping(skb); + + skb_set_queue_mapping(skb, 0); + cpu = __get_rps_cpu(vdev, skb, rflowp); + skb_set_queue_mapping(skb, queue_mapping); + if (cpu != -1) + return cpu; + } + } + + /* Fall back to RPS settings of original device */ + return __get_rps_cpu(dev, skb, rflowp); +} + #ifdef CONFIG_RFS_ACCEL /** @@ -4201,12 +4230,23 @@ static int netif_rx_internal(struct sk_buff *skb) preempt_disable(); rcu_read_lock(); + /* strip any vlan tag before calling get_rps_cpu() */ + if (skb->protocol == cpu_to_be16(ETH_P_8021Q) || + skb->protocol == cpu_to_be16(ETH_P_8021AD)) { + skb = skb_vlan_untag(skb); + if (unlikely(!skb)) { + ret = NET_RX_DROP; + goto unlock; + } + } + cpu = get_rps_cpu(skb->dev, skb, &rflow); if (cpu < 0) cpu = smp_processor_id(); ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail); +unlock: rcu_read_unlock(); preempt_enable(); } else @@ -4755,8 +4795,19 @@ static int netif_receive_skb_internal(struct sk_buff *skb) #ifdef CONFIG_RPS if (static_key_false(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; - int cpu = get_rps_cpu(skb->dev, skb, &rflow); + int cpu; + + /* strip any vlan tag before calling get_rps_cpu() */ + if (skb->protocol == cpu_to_be16(ETH_P_8021Q) || + skb->protocol == cpu_to_be16(ETH_P_8021AD)) { + skb = skb_vlan_untag(skb); + if (unlikely(!skb)) { + ret = NET_RX_DROP; + goto out; + } + } + cpu = get_rps_cpu(skb->dev, skb, &rflow); if (cpu >= 0) { ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail); rcu_read_unlock(); @@ -4765,6 +4816,8 @@ static int netif_receive_skb_internal(struct sk_buff *skb) } #endif ret = __netif_receive_skb(skb); + +out: rcu_read_unlock(); return ret; }