From patchwork Thu Jun 13 19:26:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Ptyv2yzMz9sP1; Fri, 14 Jun 2019 05:26:47 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hbVMx-0002N7-Dg; Thu, 13 Jun 2019 19:26:43 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hbVMu-0002Ke-5K for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:40 +0000 Received: from mail-wr1-f69.google.com ([209.85.221.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMt-00055z-Qw for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:39 +0000 Received: by mail-wr1-f69.google.com with SMTP id n8so23198wrx.14 for ; Thu, 13 Jun 2019 12:26:39 -0700 (PDT) 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=CSMVxnHN7RllsX17fNLjmdSQ/Yfxv0yz4tnABorFc20=; b=LuhPFX1b26UBHZkohM64wN6j5Q6S1VbIS3Ht1wCSnlt0mTzqeaausiBx8cS1bm7qPk /ShUSjsSvr0vAKn9nzC0y+TNQPW3IYM0zCY0eRQLUEGhtYjypOsEGHuB6cWTT+EVzO6H 9xvYxua6QRhhwEAWlg9U8SdOp/JeGuR1R2l/WoYs/7tjTEYHk6bZTTT2XqxsMHES9LuG XOwGOmb/c1keQEYSvyqzPYRfYZ20pOZzXnOBfxlSHSRbRl2Mw1xh+3rGJzM/KFENCjQA msGSwodlNMhk3Op8VVHJ7RN4QE/fvsKpv3w+cof50fswdILCAOFh92BBJq7NVjQhCOYh NLzQ== X-Gm-Message-State: APjAAAXV9EH1drEhiXT5bN9ZoOagbQ0M+CL1fPJnx7Z2GOwZgUx1ql1/ MW5P3ReSINIj0Wf9ebJkq3DZbsOaEHjuZhgL2HaVWU96yVHX3xFWC5tAlZ+RBFnCQPztv/pTiHe RplUwlbjMKq7nfi3csfiembceLeB/mZfpwgNkUgOmsA== X-Received: by 2002:a1c:a186:: with SMTP id k128mr5055800wme.125.1560453999395; Thu, 13 Jun 2019 12:26:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrPCLQ3D3yqSM2ckW5upPd02bnNLldzAc9DXa7YN58Sq7A5ZvvlfbUVXh6WOYGyRc6lzC5Qw== X-Received: by 2002:a1c:a186:: with SMTP id k128mr5055794wme.125.1560453999174; Thu, 13 Jun 2019 12:26:39 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id l4sm767513wmh.18.2019.06.13.12.26.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:38 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 5/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:27 +0100 Message-Id: <20190613192630.31244-6-ioanna-maria.alifieraki@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613192630.31244-1-ioanna-maria.alifieraki@canonical.com> References: <20190613192630.31244-1-ioanna-maria.alifieraki@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Edward Cree BugLink: https://bugs.launchpad.net/bugs/1831254 netif_receive_skb_list_internal() now processes a list and hands it on to the next function. Signed-off-by: Edward Cree Signed-off-by: David S. Miller (cherry picked from commit 7da517a3bc529dc5399e742688b32cafa2ca5ca0) Signed-off-by: Ioanna Alifieraki --- net/core/dev.c | 61 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 2a5eb9810469..e62b3e934db8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4751,6 +4751,14 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp) return ret; } +static void __netif_receive_skb_list(struct list_head *head) +{ + struct sk_buff *skb, *next; + + list_for_each_entry_safe(skb, next, head, list) + __netif_receive_skb(skb); +} + static int netif_receive_skb_internal(struct sk_buff *skb) { int ret; @@ -4791,6 +4799,50 @@ static int netif_receive_skb_internal(struct sk_buff *skb) return ret; } +static void netif_receive_skb_list_internal(struct list_head *head) +{ + struct bpf_prog *xdp_prog = NULL; + struct sk_buff *skb, *next; + + list_for_each_entry_safe(skb, next, head, list) { + net_timestamp_check(netdev_tstamp_prequeue, skb); + if (skb_defer_rx_timestamp(skb)) + /* Handled, remove from list */ + list_del(&skb->list); + } + + if (static_branch_unlikely(&generic_xdp_needed_key)) { + preempt_disable(); + rcu_read_lock(); + list_for_each_entry_safe(skb, next, head, list) { + xdp_prog = rcu_dereference(skb->dev->xdp_prog); + if (do_xdp_generic(xdp_prog, skb) != XDP_PASS) + /* Dropped, remove from list */ + list_del(&skb->list); + } + rcu_read_unlock(); + preempt_enable(); + } + + rcu_read_lock(); +#ifdef CONFIG_RPS + if (static_key_false(&rps_needed)) { + list_for_each_entry_safe(skb, next, head, list) { + struct rps_dev_flow voidflow, *rflow = &voidflow; + int cpu = get_rps_cpu(skb->dev, skb, &rflow); + + if (cpu >= 0) { + enqueue_to_backlog(skb, cpu, &rflow->last_qtail); + /* Handled, remove from list */ + list_del(&skb->list); + } + } + } +#endif + __netif_receive_skb_list(head); + rcu_read_unlock(); +} + /** * netif_receive_skb - process receive buffer from network * @skb: buffer to process @@ -4818,20 +4870,19 @@ EXPORT_SYMBOL(netif_receive_skb); * netif_receive_skb_list - process many receive buffers from network * @head: list of skbs to process. * - * For now, just calls netif_receive_skb() in a loop, ignoring the - * return value. + * Since return value of netif_receive_skb() is normally ignored, and + * wouldn't be meaningful for a list, this function returns void. * * This function may only be called from softirq context and interrupts * should be enabled. */ void netif_receive_skb_list(struct list_head *head) { - struct sk_buff *skb, *next; + struct sk_buff *skb; list_for_each_entry(skb, head, list) trace_netif_receive_skb_list_entry(skb); - list_for_each_entry_safe(skb, next, head, list) - netif_receive_skb_internal(skb); + netif_receive_skb_list_internal(head); } EXPORT_SYMBOL(netif_receive_skb_list);