From patchwork Thu Jun 13 19:26:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115576 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 45Ptyt4kXNz9sNl; Fri, 14 Jun 2019 05:26:46 +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 1hbVMr-0002K6-Iy; Thu, 13 Jun 2019 19:26:37 +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 1hbVMo-0002JY-UM for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:34 +0000 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMo-00055H-Jw for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:34 +0000 Received: by mail-wm1-f72.google.com with SMTP id v125so58817wme.5 for ; Thu, 13 Jun 2019 12:26:34 -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=5lUmZwT9HKdUAGxVxGhM9/sNZYh5qQ2OWFKR8spRO2k=; b=Ym5TILrHSowUXNW10ZOvuTU0HyoWLaZ0ytEVUQ+woPhS3EDzGHGmrmQSHTYmwMiBO6 N8ODZYVxrXxDqlcxOvTuN+f61K8JrIp7PhXI89Uejfv3En6Rl43Z36dcsBcli4LY26oL ahtrvtGYnp/FjnaqCmZwZgxworvcM2xVz+iWnZF+xRg9Jx1hNMlR1ebuv1wEUq8dJCTI Vft/VRKMFFASB0v3G12ivMovgmAoDHLjrJYisvNy3mN56IBsjsMng0MKx1g+3xK5g+i1 pEsbnNYe31j3lT2AjbIlm/LExRYrEs1sZ+HbHKAg6X3IDfMyNB6wTq/3GWWHg7A76zRc B/Lg== X-Gm-Message-State: APjAAAVVLjI92F8J2d/raE5kLCXFz7QBl+3rxfO8HVYgZAFaboTGZCwH 3XgJwuaoWWbgLkNnwdyxO1ZISRiqKdTXjhXPuLExJmadlc/NMsp1qgm/SCGCuaLCZfF1Wh4sp3X SshlxMlTQN4v2RPYK5w75Elv80IjZsLKOTpAvt5K60g== X-Received: by 2002:adf:8044:: with SMTP id 62mr13482022wrk.20.1560453994090; Thu, 13 Jun 2019 12:26:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/TDVuYKJ+/aNxr6ABG9E+tz/4TkztPE3iuo9W/RQaPfn1CDKTHU0HetpFkkMvAmsh2k/F6Q== X-Received: by 2002:adf:8044:: with SMTP id 62mr13482015wrk.20.1560453993939; Thu, 13 Jun 2019 12:26:33 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id o126sm1392976wmo.31.2019.06.13.12.26.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:33 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 1/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:23 +0100 Message-Id: <20190613192630.31244-2-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: Stephen Hemminger BugLink: https://bugs.launchpad.net/bugs/1831254 The netvsc VF skb handler should make sure that skb is not shared. Similar logic already exists in bonding and team device drivers. This is not an issue in practice because the VF devicex does not send up shared skb's. But the netvsc driver should do the right thing if it did. Fixes: 0c195567a8f6 ("netvsc: transparent VF management") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (cherry picked from commit 996ed04741467f6d1552440c92988b132a9487ec) Signed-off-by: Ioanna Alifieraki --- drivers/net/hyperv/netvsc_drv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index c0fc30a1f600..c86c79949097 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1836,6 +1836,12 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct sk_buff **pskb) struct netvsc_vf_pcpu_stats *pcpu_stats = this_cpu_ptr(ndev_ctx->vf_stats); + skb = skb_share_check(skb, GFP_ATOMIC); + if (unlikely(!skb)) + return RX_HANDLER_CONSUMED; + + *pskb = skb; + skb->dev = ndev; u64_stats_update_begin(&pcpu_stats->syncp); From patchwork Thu Jun 13 19:26:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115577 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 45Ptyt5LVtz9sNw; Fri, 14 Jun 2019 05:26:46 +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 1hbVMr-0002KI-NO; Thu, 13 Jun 2019 19:26:37 +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 1hbVMq-0002Je-6B for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:36 +0000 Received: from mail-wr1-f72.google.com ([209.85.221.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMp-00055P-Rs for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:35 +0000 Received: by mail-wr1-f72.google.com with SMTP id i2so25060wrp.12 for ; Thu, 13 Jun 2019 12:26:35 -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=dvCSFENMHYsV+PVo5TogIyeFksKIXnyw+AMrBvedVCg=; b=mCgps4a35++4ZLBKaqpF3Ft7KuCLSGZMPqzILvwsSbRyYRfr4zxNe4ULBLhq8CfFOV J4I0fAQVVCQSv/il4Dy6WICoFLA4e//fSlDk5eGAq0JFgmORUPiVCc0mPl9f+WvAGm4b oZkQjwoiXkkJ0RAQV4zY/3EDGoWu8vOXZKJl2FyfKwMS5C2a95Hhvk5DVPYZI9IY14Lb UcLlvWThdhFywwWf6hNUEN2TOWK08zoUPv8tR/+DotIo1tf0Bs7KRj5HFgD9UMFNP8Lr zGIJuVi1W62Bl6PuvgbZJtwBfIpIsSO0Kwz/fWYSwlI1L51PRR9DNmPe9F5Bk0mrpkM0 PBbQ== X-Gm-Message-State: APjAAAU6DLPrrZQ2+KKylRYp6rJB0MSFujMn/C9B/3pl98iz/JuXHYi+ zPot0d2bKlB59sePYBRispkSBpq4ZFSAIjJopAO5bCkLoRIdYrI3Mxs2qzeWc/7V0dRmw4HcUWf nd140uBEXnZxS1brXSy2bzwuhhi5JdbzsKU7As8rAkA== X-Received: by 2002:adf:e2c8:: with SMTP id d8mr44961903wrj.14.1560453995486; Thu, 13 Jun 2019 12:26:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/XX58yr0qSYmDQABxYZDpRXC8p1xFM/A9bbuUddVEGMgNpMIQXsT4m5t9ZLcT5ilsouKNRw== X-Received: by 2002:adf:e2c8:: with SMTP id d8mr44961890wrj.14.1560453995231; Thu, 13 Jun 2019 12:26:35 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id s3sm428028wmh.27.2019.06.13.12.26.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:34 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 2/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:24 +0100 Message-Id: <20190613192630.31244-3-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" BugLink: https://bugs.launchpad.net/bugs/1831254 This change comes from commit d4546c2509b1e9cd082e368 and is needed for the commits that follow. Since d4546c2509b1e9cd082e368 is quite big we just pick up only what we need. Signed-off-by: Ioanna Alifieraki --- include/linux/skbuff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 610a201126ee..1b86e0748e46 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -679,6 +679,7 @@ struct sk_buff { }; }; struct rb_node rbnode; /* used in netem & tcp stack */ + struct list_head list; }; struct sock *sk; From patchwork Thu Jun 13 19:26:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115574 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 45Ptyt3q6Tz9sNT; Fri, 14 Jun 2019 05:26:46 +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 1hbVMu-0002LO-Tk; Thu, 13 Jun 2019 19:26:40 +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 1hbVMr-0002Jw-DS for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:37 +0000 Received: from mail-wr1-f71.google.com ([209.85.221.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMr-00055Y-35 for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:37 +0000 Received: by mail-wr1-f71.google.com with SMTP id q14so15645wrm.23 for ; Thu, 13 Jun 2019 12:26:37 -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=umtSwf3uFTGXi5etJordmDHjCdZP/A9FnG3LvnEXlNA=; b=kGfPVAJfQiRhvAa1BS5wiCIU+blAKoPiQUEW0PiW6L0tS1T+dBwWGl6NH4F5mvVQ7m BJ+iJXHKDPeCxtfmJfSiTV2TkwP8OOUk0iyfBLMlEpZMAoRfMbnY0KTcJN6v3JZbgJ7Y ZgdlXA9Vje1LYyVntYMOx6X+UXGeXUJlf8HDEhNES4fE8Hl2V2b5zVB0Cpu0aXc4KDWA 3CSQ9vL0Cu4TO5ATC5rp5CnpI73UO0i5eWHybRd70lVO4Ba6xhQywF0djYGMVoBWfTkA OG0hJkat5WAFZLTV6D8LG7ARqmyzF0t5E8KugLBtOMAXQWpLGzVTU95MggHuRkdXtEmg 2tZQ== X-Gm-Message-State: APjAAAXGR6qntt1owtiVKvF+NcYQ7wDu7KShUGLBy5not6ca7HeOjkhs YEbNWwgjzNYMy/8O3EKTsO53HXk5YeO7B8bbOyaFWYfxBxT2eLzo9BqzOz2Ks7f9Ht6vL+TLU8j rELUhha8TwevDVWILcICUHmjJwYqT2oMtnJaAPItewQ== X-Received: by 2002:a1c:b046:: with SMTP id z67mr4634865wme.49.1560453996666; Thu, 13 Jun 2019 12:26:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/ia2FHue8GJmgEMUFBTo3Vvs8rU05BSFw9RZWSKirNO1jJi7tMbrjjCyzzQxPTCP3Qm3CBw== X-Received: by 2002:a1c:b046:: with SMTP id z67mr4634856wme.49.1560453996351; Thu, 13 Jun 2019 12:26:36 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id f26sm651197wmh.8.2019.06.13.12.26.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:36 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 3/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:25 +0100 Message-Id: <20190613192630.31244-4-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 Just calls netif_receive_skb() in a loop. Signed-off-by: Edward Cree Signed-off-by: David S. Miller (cherry picked from commit f6ad8c1bcdf014272d08c55b9469536952a0a771) Signed-off-by: Ioanna Alifieraki --- include/linux/netdevice.h | 1 + net/core/dev.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3045a5cee0d8..ae8797f54850 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3391,6 +3391,7 @@ int netif_rx(struct sk_buff *skb); int netif_rx_ni(struct sk_buff *skb); int netif_receive_skb(struct sk_buff *skb); int netif_receive_skb_core(struct sk_buff *skb); +void netif_receive_skb_list(struct list_head *head); gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb); void napi_gro_flush(struct napi_struct *napi, bool flush_old); struct sk_buff *napi_get_frags(struct napi_struct *napi); diff --git a/net/core/dev.c b/net/core/dev.c index bf669e77f9f3..4977c86b79ad 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4814,6 +4814,25 @@ int netif_receive_skb(struct sk_buff *skb) } 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. + * + * 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; + + list_for_each_entry_safe(skb, next, head, list) + netif_receive_skb(skb); +} +EXPORT_SYMBOL(netif_receive_skb_list); + DEFINE_PER_CPU(struct work_struct, flush_works); /* Network device is going away, flush any packets still pending */ From patchwork Thu Jun 13 19:26:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115579 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 45Ptyw14RSz9sBr; 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-0002Mn-8r; 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 1hbVMs-0002KX-R6 for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:38 +0000 Received: from mail-wr1-f72.google.com ([209.85.221.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMs-00055n-G8 for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:38 +0000 Received: by mail-wr1-f72.google.com with SMTP id b4so31126wrw.4 for ; Thu, 13 Jun 2019 12:26:38 -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=J78tbBtMYzvDvIymsru1aNeyJv6RTihw33Z5xnVSMo8=; b=mD+NpJW2oNgaDHqj+CKOkGA2mXJGw+7gdGn6DmL6hT+VOj41t7FroIPjCbeCKe90+c c4SlnNN6a4jpI0Kt5q2YjHQBUphmLXpVJMcQ07L5IGAJk0/lESxoUaE7JJXhSXS1ICXY UD7Ooov3isXqIkmu9+9e9mO9IMSJZEWYOQJlPOgyUQBC4TBxRrjxLh2qFKlu0BTIzD4E K1Fxn7vvkefs29YaG2nVKsdDfWQZRU8/GVCma5Qk02Qn5QhOgAq/Ue6blmvXKFJKnrl9 zbTiKbYfoZPyg0IHMRrla4A/gfLbgSHbxAD1oFN8j1Ejjp5r9kxOGQEu30OeN3+OqBEq 6NLA== X-Gm-Message-State: APjAAAXJSosZDDxQZBOxgEfJSvcFmWEPtHiQ7w+Zi8xEe/M1OtP2mtFs PWBZJNJ/B2cfmrg4PkVWQM9P3N6mjXWYAy3NioRsOfJ5xwjmz5ycOxrNjs7E3g9X7LIwQwsfAx9 NstN286FHWml5eymzbu6Ts6cWihEkKzzS0PHgVmYFAA== X-Received: by 2002:adf:ce88:: with SMTP id r8mr10003000wrn.42.1560453998098; Thu, 13 Jun 2019 12:26:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSuPWiYwkEiKQ5Rs/v1h6Sc+bgBvTPEpmWCfHp6pynxLjyRGjkP1JOqMubFXVuPqK8U0+8VA== X-Received: by 2002:adf:ce88:: with SMTP id r8mr10002985wrn.42.1560453997817; Thu, 13 Jun 2019 12:26:37 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id z6sm638119wrw.2.2019.06.13.12.26.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:37 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 4/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:26 +0100 Message-Id: <20190613192630.31244-5-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 Signed-off-by: Edward Cree Signed-off-by: David S. Miller (cherry picked from commit 920572b73280a29e3a9f58807a8b90051b19ee60) Signed-off-by: Ioanna Alifieraki --- include/trace/events/net.h | 7 +++++++ net/core/dev.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/trace/events/net.h b/include/trace/events/net.h index 9c886739246a..00aa72ce0e7c 100644 --- a/include/trace/events/net.h +++ b/include/trace/events/net.h @@ -223,6 +223,13 @@ DEFINE_EVENT(net_dev_rx_verbose_template, netif_receive_skb_entry, TP_ARGS(skb) ); +DEFINE_EVENT(net_dev_rx_verbose_template, netif_receive_skb_list_entry, + + TP_PROTO(const struct sk_buff *skb), + + TP_ARGS(skb) +); + DEFINE_EVENT(net_dev_rx_verbose_template, netif_rx_entry, TP_PROTO(const struct sk_buff *skb), diff --git a/net/core/dev.c b/net/core/dev.c index 4977c86b79ad..2a5eb9810469 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4828,8 +4828,10 @@ void netif_receive_skb_list(struct list_head *head) { struct sk_buff *skb, *next; + 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(skb); + netif_receive_skb_internal(skb); } EXPORT_SYMBOL(netif_receive_skb_list); 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); From patchwork Thu Jun 13 19:26:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115580 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 45Ptyz2Vfxz9sDB; Fri, 14 Jun 2019 05:26:51 +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 1hbVN0-0002Ot-2b; Thu, 13 Jun 2019 19:26:46 +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 1hbVMv-0002Lc-Gl for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:41 +0000 Received: from mail-wm1-f69.google.com ([209.85.128.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMv-000569-3s for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:41 +0000 Received: by mail-wm1-f69.google.com with SMTP id b1so60064wme.3 for ; Thu, 13 Jun 2019 12:26:41 -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=CPn2FXF74fYUSDCUf10AoMxQwahY2jIGl15jqtvLKdA=; b=ls8wvsVtudtTbDs0y3oaOqh3+xhP1ovNSPiZSt6TZGjMO6m/seUQCtn4dOMsmiDT4h tktjQSr3mApC/a4b5syejdzjf6GXAqm4KjaHkzRcYp4D+zc6fhYWK9zsAnpz+KLN9gCO K+TPErsfPeVtccrSCS+8OlNAV9LM4lDhvdyBpIxljaX3FNas//umQ5xXBgH0ASP+TRWn YE/1KfXRP2mFvfOxPznBNUro18NRwj+rleIzMKhv8SrtDSpHM9z0pyBGX6OUhJoBGJrA 2Q/LzfNPgyw7PGg4edfMzWMBIzdmS5YDXgmjJP3g5hdRjckxh9VAJ7tKzyQUCn2ohY34 HEMg== X-Gm-Message-State: APjAAAVCIGoisHk1kfiuvFLyHMilFQ/z5YDaxBciydsPGijKBVwWcPdr 5/7RPRnJhFg653M/K4chvivPMeKJCElhb8UP84hhKp0VgeUrtT1Ymx2hMn3rjCkw2trvE4d47lM ktZDjwo7fAfBCG2JPFOOXCSywIHNY9/ZNuYBvWUdNCQ== X-Received: by 2002:a5d:528b:: with SMTP id c11mr11426404wrv.25.1560454000725; Thu, 13 Jun 2019 12:26:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhTIlC+Mni91kya97/8sZ/0OYwkXf4ge/1z7HslnvPxwfm+VY/SZ5HTV4VCCjt0bkKIdL0Ow== X-Received: by 2002:a5d:528b:: with SMTP id c11mr11426396wrv.25.1560454000561; Thu, 13 Jun 2019 12:26:40 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id h1sm514441wrt.20.2019.06.13.12.26.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:40 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 6/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:28 +0100 Message-Id: <20190613192630.31244-7-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 In netif_receive_skb_list_internal(), all of skb_defer_rx_timestamp(), do_xdp_generic() and enqueue_to_backlog() can lead to kfree(skb). Thus, we cannot wait until after they return to remove the skb from the list; instead, we remove it first and, in the pass case, add it to a sublist afterwards. In the case of enqueue_to_backlog() we have already decided not to pass when we call the function, so we do not need a sublist. Fixes: 7da517a3bc52 ("net: core: Another step of skb receive list processing") Reported-by: Dan Carpenter Signed-off-by: Edward Cree Signed-off-by: David S. Miller (cherry picked from commit 8c057efaebb557b60ba514b5e39e8000a1eab0f1) Signed-off-by: Ioanna Alifieraki --- net/core/dev.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index e62b3e934db8..aa5dde35d2a9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4803,25 +4803,30 @@ static void netif_receive_skb_list_internal(struct list_head *head) { struct bpf_prog *xdp_prog = NULL; struct sk_buff *skb, *next; + struct list_head sublist; + INIT_LIST_HEAD(&sublist); 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); + list_del(&skb->list); + if (!skb_defer_rx_timestamp(skb)) + list_add_tail(&skb->list, &sublist); } + list_splice_init(&sublist, head); 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); + list_del(&skb->list); + if (do_xdp_generic(xdp_prog, skb) == XDP_PASS) + list_add_tail(&skb->list, &sublist); } rcu_read_unlock(); preempt_enable(); + /* Put passed packets back on main list */ + list_splice_init(&sublist, head); } rcu_read_lock(); @@ -4832,9 +4837,9 @@ static void netif_receive_skb_list_internal(struct list_head *head) int cpu = get_rps_cpu(skb->dev, skb, &rflow); if (cpu >= 0) { - enqueue_to_backlog(skb, cpu, &rflow->last_qtail); - /* Handled, remove from list */ + /* Will be handled, remove from list */ list_del(&skb->list); + enqueue_to_backlog(skb, cpu, &rflow->last_qtail); } } } From patchwork Thu Jun 13 19:26:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115581 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 45Ptz13N6yz9sND; Fri, 14 Jun 2019 05:26:53 +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 1hbVN1-0002QS-SF; Thu, 13 Jun 2019 19:26:47 +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 1hbVMx-0002Mk-EP for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:43 +0000 Received: from mail-wr1-f72.google.com ([209.85.221.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMw-00056I-Ti for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:42 +0000 Received: by mail-wr1-f72.google.com with SMTP id e6so18289wrv.20 for ; Thu, 13 Jun 2019 12:26:42 -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=wKsRb1MFwRsI6c3y6thJB4MAcx3hLXCiX6x0RSOvbO8=; b=N9ChVlxfNN8NM6LuUDbex+lBWWWbpLainOAIdCofC8nolU2Fd5xDON/5KWhFz8f+jp Wn/BRpo4jiaxp7E/CQIOS4D4nNeGey6ONP2B5vlFmgo4xU/4XgXSF2udKJ+DvuEf2fqg uf0TwlCqWJ5DwTIeJLLwqqoEKdsd2dPkoUS2+TW7HUGO5hx0recXoHquxItDJ+WnHl3S 46lgjxRXkdY74T04LEaB39SoW0y0goqEZAK+ctfRdwlyVh9+V1mW2P96vzbe+bKGCCqo zNMkNu4TYQn+pAM6yv3giu3E7FLWo1sNwpckn/+/JRnspW5MTHQUnzu4Q8QYa5WaTSKY Y0Ag== X-Gm-Message-State: APjAAAWjTZSxc+0iT7yjFRf8EsXiDmXpA/Kzkl3tKd/Z9+Nwd9dIMjVP D9xmloZ1ggTPciM9QOG5858g1przUEZ/UMdM2pGpUJ1w+U4qgeTL8B2wr/PbXvXW6I4KgAdToGW s5mLx177ljWHnJrt+QSGYyQ8DZDCuCRbJilWolKieKA== X-Received: by 2002:a1c:701a:: with SMTP id l26mr4711881wmc.32.1560454002425; Thu, 13 Jun 2019 12:26:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzF69JWoYMxJAdxUpmjtZEoi/zV+RFF+PC7nqWquwshvrV/maepOR+1PoGuj9/28olvBVzMdw== X-Received: by 2002:a1c:701a:: with SMTP id l26mr4711868wmc.32.1560454002070; Thu, 13 Jun 2019 12:26:42 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id a62sm1149691wmf.19.2019.06.13.12.26.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:41 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 7/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:29 +0100 Message-Id: <20190613192630.31244-8-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: Eric Dumazet BugLink: https://bugs.launchpad.net/bugs/1831254 We prefer static_branch_unlikely() over static_key_false() these days. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Acked-by: Willem de Bruijn Signed-off-by: David S. Miller (cherry picked from commit dc05360fee660a9dbe59824b3f7896534210432b) Signed-off-by: Ioanna Alifieraki --- drivers/net/tun.c | 2 +- include/linux/netdevice.h | 4 ++-- include/net/sock.h | 2 +- net/core/dev.c | 10 +++++----- net/core/net-sysfs.c | 4 ++-- net/core/sysctl_net_core.c | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 694a27da7278..1151f7511c1c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1039,7 +1039,7 @@ static int tun_net_close(struct net_device *dev) static void tun_automq_xmit(struct tun_struct *tun, struct sk_buff *skb) { #ifdef CONFIG_RPS - if (tun->numqueues == 1 && static_key_false(&rps_needed)) { + if (tun->numqueues == 1 && static_branch_unlikely(&rps_needed)) { /* Select queue was not called for the skbuff, so we extract the * RPS hash and save it into the flow_table here. */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ae8797f54850..8f6303bd3895 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -194,8 +194,8 @@ struct net_device_stats { #ifdef CONFIG_RPS #include -extern struct static_key rps_needed; -extern struct static_key rfs_needed; +extern struct static_key_false rps_needed; +extern struct static_key_false rfs_needed; #endif struct neighbour; diff --git a/include/net/sock.h b/include/net/sock.h index 762069bb0d8c..6f550817e5d5 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -937,7 +937,7 @@ static inline void sock_rps_record_flow_hash(__u32 hash) static inline void sock_rps_record_flow(const struct sock *sk) { #ifdef CONFIG_RPS - if (static_key_false(&rfs_needed)) { + if (static_branch_unlikely(&rfs_needed)) { /* Reading sk->sk_rxhash might incur an expensive cache line * miss. * diff --git a/net/core/dev.c b/net/core/dev.c index aa5dde35d2a9..ccb01cd5cc77 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3702,9 +3702,9 @@ EXPORT_SYMBOL(rps_sock_flow_table); u32 rps_cpu_mask __read_mostly; EXPORT_SYMBOL(rps_cpu_mask); -struct static_key rps_needed __read_mostly; +struct static_key_false rps_needed __read_mostly; EXPORT_SYMBOL(rps_needed); -struct static_key rfs_needed __read_mostly; +struct static_key_false rfs_needed __read_mostly; EXPORT_SYMBOL(rfs_needed); static struct rps_dev_flow * @@ -4216,7 +4216,7 @@ static int netif_rx_internal(struct sk_buff *skb) } #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; int cpu; @@ -4783,7 +4783,7 @@ static int netif_receive_skb_internal(struct sk_buff *skb) rcu_read_lock(); #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; int cpu = get_rps_cpu(skb->dev, skb, &rflow); @@ -4831,7 +4831,7 @@ static void netif_receive_skb_list_internal(struct list_head *head) rcu_read_lock(); #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&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); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 151e6cd47972..51a2169605f1 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -759,9 +759,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, rcu_assign_pointer(queue->rps_map, map); if (map) - static_key_slow_inc(&rps_needed); + static_branch_inc(&rps_needed); if (old_map) - static_key_slow_dec(&rps_needed); + static_branch_dec(&rps_needed); mutex_unlock(&rps_map_mutex); diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index b1a2c5e38530..4f9a939c51e5 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -84,12 +84,12 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, if (sock_table != orig_sock_table) { rcu_assign_pointer(rps_sock_flow_table, sock_table); if (sock_table) { - static_key_slow_inc(&rps_needed); - static_key_slow_inc(&rfs_needed); + static_branch_inc(&rps_needed); + static_branch_inc(&rfs_needed); } if (orig_sock_table) { - static_key_slow_dec(&rps_needed); - static_key_slow_dec(&rfs_needed); + static_branch_dec(&rps_needed); + static_branch_dec(&rfs_needed); synchronize_rcu(); vfree(orig_sock_table); } From patchwork Thu Jun 13 19:26:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115582 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 45Ptz31Y0cz9sNT; Fri, 14 Jun 2019 05:26:55 +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 1hbVN4-0002TA-JK; Thu, 13 Jun 2019 19:26:50 +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 1hbVMz-0002O5-8w for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:45 +0000 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVMy-00056R-1V for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:44 +0000 Received: by mail-wm1-f72.google.com with SMTP id n25so69853wmc.7 for ; Thu, 13 Jun 2019 12:26:44 -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=LRqmxQbu2/M64LQbsGCu0OQYTxQch8Tsy91srFMBnk8=; b=c8PoMDIGk5Z2sZE6uOVxuH8QhiJTlzkY5yenD0mWnvAoN34ehn4CWE2s/FMXSsfIVs IyuONObHpJ8GWiSNyElm4BnOCl4BVg/6zZOjL+GN0r4KoMkccGPO0CPqt5NfUE8n9atX wEfOk47D5kvphYaf/F+WAhCL73cEBi5eqLc/1n+zQfwuMnCOpwPZhvCotcIYFFBW+5Uf ick0r7wNSHT7GKUFlK0vdoIPcSl4VcisQV27Fbua7q/8v9iA8e09X366nPuO1hRqQPlM 6rOkKHOEn3CCa75PgrljP+HwbiDa1SHdBt73/Y4IrRzHeq7EZHOrtt5+jy/XkK902+JJ 4ZIg== X-Gm-Message-State: APjAAAVwi1INB4k6K/vrz5ZdLrPn47NwSo8+Ga2xUUVbXGTcDAYHshSt XktRTsS0dI41W74MX5Y/kTkaYRhLaB2w90YqjGHqwow3HIscx0urLVcmayJKRmdgGJEQzImxEa+ 7gUQhF5SmOiTND3CbRKp542PKFFapM+P8JMb/u5N96w== X-Received: by 2002:a1c:1c4:: with SMTP id 187mr4451097wmb.87.1560454003606; Thu, 13 Jun 2019 12:26:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJqITrsH+IxvtybAnsEWeI92VsLhMe+tFjrJov9ulqB/00UcyLTRtPp1JVCFwouBww3g5QUw== X-Received: by 2002:a1c:1c4:: with SMTP id 187mr4451089wmb.87.1560454003376; Thu, 13 Jun 2019 12:26:43 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id d3sm435547wrf.87.2019.06.13.12.26.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:43 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 8/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:30 +0100 Message-Id: <20190613192630.31244-9-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: Stephen Hemminger When a device is stacked like (team, bonding, failsafe or netvsc) the XDP generic program for the parent device was not called. Move the call to XDP generic inside __netif_receive_skb_core where it can be done multiple times for stacked case. Fixes: d445516966dc ("net: xdp: support xdp generic on virtual devices") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (backported from commit 458bf2f224f04a513b0be972f8708e78ee2c986e) [hunk 5 does not apply cleanly beacuse of the different skb_list_del_init(skb) vs list_del(&skb->list) lines that is removed] Signed-off-by: Ioanna Alifieraki --- net/core/dev.c | 58 +++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index ccb01cd5cc77..c0d8eeb30b97 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4198,23 +4198,6 @@ static int netif_rx_internal(struct sk_buff *skb) trace_netif_rx(skb); - if (static_branch_unlikely(&generic_xdp_needed_key)) { - int ret; - - preempt_disable(); - rcu_read_lock(); - ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); - rcu_read_unlock(); - preempt_enable(); - - /* Consider XDP consuming the packet a success from - * the netdev point of view we do not want to count - * this as an error. - */ - if (ret != XDP_PASS) - return NET_RX_SUCCESS; - } - #ifdef CONFIG_RPS if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; @@ -4543,6 +4526,18 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc) __this_cpu_inc(softnet_data.processed); + if (static_branch_unlikely(&generic_xdp_needed_key)) { + int ret2; + + preempt_disable(); + ret2 = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); + preempt_enable(); + + if (ret2 != XDP_PASS) + return NET_RX_DROP; + skb_reset_mac_len(skb); + } + if (skb->protocol == cpu_to_be16(ETH_P_8021Q) || skb->protocol == cpu_to_be16(ETH_P_8021AD)) { skb = skb_vlan_untag(skb); @@ -4768,19 +4763,6 @@ static int netif_receive_skb_internal(struct sk_buff *skb) if (skb_defer_rx_timestamp(skb)) return NET_RX_SUCCESS; - if (static_branch_unlikely(&generic_xdp_needed_key)) { - int ret; - - preempt_disable(); - rcu_read_lock(); - ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); - rcu_read_unlock(); - preempt_enable(); - - if (ret != XDP_PASS) - return NET_RX_DROP; - } - rcu_read_lock(); #ifdef CONFIG_RPS if (static_branch_unlikely(&rps_needed)) { @@ -4801,7 +4783,6 @@ static int netif_receive_skb_internal(struct sk_buff *skb) static void netif_receive_skb_list_internal(struct list_head *head) { - struct bpf_prog *xdp_prog = NULL; struct sk_buff *skb, *next; struct list_head sublist; @@ -4814,21 +4795,6 @@ static void netif_receive_skb_list_internal(struct list_head *head) } list_splice_init(&sublist, head); - 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); - list_del(&skb->list); - if (do_xdp_generic(xdp_prog, skb) == XDP_PASS) - list_add_tail(&skb->list, &sublist); - } - rcu_read_unlock(); - preempt_enable(); - /* Put passed packets back on main list */ - list_splice_init(&sublist, head); - } - rcu_read_lock(); #ifdef CONFIG_RPS if (static_branch_unlikely(&rps_needed)) {