From patchwork Fri Nov 16 07:00:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Cover X-Patchwork-Id: 998780 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=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TMrKJwkn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42x8JB47xBz9sBn for ; Fri, 16 Nov 2018 18:00:26 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbeKPRLb (ORCPT ); Fri, 16 Nov 2018 12:11:31 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39412 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727380AbeKPRLb (ORCPT ); Fri, 16 Nov 2018 12:11:31 -0500 Received: by mail-pl1-f194.google.com with SMTP id b5-v6so10710605pla.6 for ; Thu, 15 Nov 2018 23:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=xyxXHW32DXcjQNsrYu72EwK4ejq5tVp94FJyXUL20bU=; b=TMrKJwknCyisimQMRzTZkjZ/DIq//vbHe7akylS9NZfASnZgS/EwJXBKypNGT3YbeW 5k23s4lFD6Bo35tRCCrwBP2B3CgYMFGqKR6dJM84XxXDQ0mTk/fvYYLrDZfn5vyZoczc HsBCdFsjHM3/zrlHfMCc14ntb+G3LkFqWhnPqBKsYJ3oyqe7koCERh6J59L9OJ6NQzxd 3nkgUSmsyxRaJYmcEqd7hopF/6KjFISxhoesVLcvS/vbb96/dAZafFL9vYKeZBqcOA8O liolKwQFXYNMt0VXYyo8GGSFajCZc3qs9jd9s7UaKmPQfalVOV9fVIES2/rdfkyppebF zxrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=xyxXHW32DXcjQNsrYu72EwK4ejq5tVp94FJyXUL20bU=; b=oG8YKCQLT0O0DjhqXC2owq/oDySPNvs7JJhNX1lEuRSoi+FUFBnY+xFqRu3EHZtiBB OwjVgxOFgkmr5zx51RouUXLoC5cgrVrIMpy4Gxj4jluynfb+WXptMBvu/u0p8s0femKm Iv5srEqcUNm/+2gWbPTfc1DOcn8ymdGdWk+4Za6lynGYkKCa0pPkGjIXIOMtSkg+jrhk RV+q5XN5Lgm+ryixsW5Enbv7GAvLVjAoWXlDto/uUDVHf5L8BOtmT2+VN1sr5seFZ7OY OUrUbjwuSqwRcD26nSIkemfixvgFJPhy51LmxP8YSRRdDvcbBVKSjelmiiPT2WbA+geh XZ1g== X-Gm-Message-State: AGRZ1gKPzZufXzkRKh7qnD7WwXQNOHTqRqcPY2kDnZIWo0clEMiE2FoA Ib4xiLepbDWZwcmUxWFqUy0= X-Google-Smtp-Source: AJdET5dMRkYSM1Zj6m7wJUo+s5J5c2+1xP5bsOiItGB4GeZSrxhE1DhEjkE5ayoPqu3Kvc+TiXoDIA== X-Received: by 2002:a17:902:7088:: with SMTP id z8-v6mr9177688plk.329.1542351624281; Thu, 15 Nov 2018 23:00:24 -0800 (PST) Received: from localhost.localdomain (ip24-56-44-135.ph.ph.cox.net. [24.56.44.135]) by smtp.gmail.com with ESMTPSA id c127-v6sm32256651pfa.31.2018.11.15.23.00.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 23:00:23 -0800 (PST) From: Matthew Cover X-Google-Original-From: Matthew Cover To: davem@davemloft.net, jasowang@redhat.com, brouer@redhat.com, mst@redhat.com, edumazet@google.com, sd@queasysnail.net, netdev@vger.kernel.org, matthew.cover@stackpath.com Subject: [PATCH] [PATCH net-next] tun: fix multiqueue rx Date: Fri, 16 Nov 2018 00:00:15 -0700 Message-Id: <20181116070015.1759-1-matthew.cover@stackpath.com> X-Mailer: git-send-email 2.15.2 (Apple Git-101.1) In-Reply-To: <20181116041016.39852-1-matthew.cover@stackpath.com> References: <20181116041016.39852-1-matthew.cover@stackpath.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When writing packets to a descriptor associated with a combined queue, the packets should end up on that queue. Before this change all packets written to any descriptor associated with a tap interface end up on rx-0, even when the descriptor is associated with a different queue. The rx traffic can be generated by either of the following. 1. a simple tap program which spins up multiple queues and writes packets to each of the file descriptors 2. tx from a qemu vm with a tap multiqueue netdev The queue for rx traffic can be observed by either of the following (done on the hypervisor in the qemu case). 1. a simple netmap program which opens and reads from per-queue descriptors 2. configuring RPS and doing per-cpu captures with rxtxcpu Alternatively, if you printk() the return value of skb_get_rx_queue() just before each instance of netif_receive_skb() in tun.c, you will get 65535 for every skb. Calling skb_record_rx_queue() to set the rx queue to the queue_index fixes the association between descriptor and rx queue. Signed-off-by: Matthew Cover Acked-by: Jason Wang Acked-by: Michael S. Tsirkin --- drivers/net/tun.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index a65779c6d72f..ce8620f3ea5e 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1536,6 +1536,7 @@ static void tun_rx_batched(struct tun_struct *tun, struct tun_file *tfile, if (!rx_batched || (!more && skb_queue_empty(queue))) { local_bh_disable(); + skb_record_rx_queue(skb, tfile->queue_index); netif_receive_skb(skb); local_bh_enable(); return; @@ -1555,8 +1556,11 @@ static void tun_rx_batched(struct tun_struct *tun, struct tun_file *tfile, struct sk_buff *nskb; local_bh_disable(); - while ((nskb = __skb_dequeue(&process_queue))) + while ((nskb = __skb_dequeue(&process_queue))) { + skb_record_rx_queue(nskb, tfile->queue_index); netif_receive_skb(nskb); + } + skb_record_rx_queue(skb, tfile->queue_index); netif_receive_skb(skb); local_bh_enable(); } @@ -2452,6 +2456,7 @@ static int tun_xdp_one(struct tun_struct *tun, !tfile->detached) rxhash = __skb_get_hash_symmetric(skb); + skb_record_rx_queue(skb, tfile->queue_index); netif_receive_skb(skb); stats = get_cpu_ptr(tun->pcpu_stats);