Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/809504/?format=api
{ "id": 809504, "url": "http://patchwork.ozlabs.org/api/1.2/patches/809504/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1504496169-31190-1-git-send-email-jasowang@redhat.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/1.2/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504496169-31190-1-git-send-email-jasowang@redhat.com>", "list_archive_url": null, "date": "2017-09-04T03:36:08", "name": "[net-next,1/2] tun: reserve extra headroom only when XDP is set", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "1d4d70d6f2330660d3641cd6d433967acd06ae4a", "submitter": { "id": 5225, "url": "http://patchwork.ozlabs.org/api/1.2/people/5225/?format=api", "name": "Jason Wang", "email": "jasowang@redhat.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/1.2/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1504496169-31190-1-git-send-email-jasowang@redhat.com/mbox/", "series": [ { "id": 1297, "url": "http://patchwork.ozlabs.org/api/1.2/series/1297/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1297", "date": "2017-09-04T03:36:09", "name": "[net-next,1/2] tun: reserve extra headroom only when XDP is set", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1297/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809504/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809504/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jasowang@redhat.com" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlwWP13Lcz9s82\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 4 Sep 2017 13:36:49 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753249AbdIDDgS (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSun, 3 Sep 2017 23:36:18 -0400", "from mx1.redhat.com ([209.132.183.28]:49128 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753198AbdIDDgR (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tSun, 3 Sep 2017 23:36:17 -0400", "from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id D5D3383F3D;\n\tMon, 4 Sep 2017 03:36:16 +0000 (UTC)", "from jason-ThinkPad-T450s.redhat.com (ovpn-12-84.pek2.redhat.com\n\t[10.72.12.84])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 57F6860462;\n\tMon, 4 Sep 2017 03:36:11 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com D5D3383F3D", "From": "Jason Wang <jasowang@redhat.com>", "To": "netdev@vger.kernel.org, linux-kernel@vger.kernel.org", "Cc": "mst@redhat.com, Jason Wang <jasowang@redhat.com>,\n\tJakub Kicinski <kubakici@wp.pl>", "Subject": "[PATCH net-next 1/2] tun: reserve extra headroom only when XDP is\n\tset", "Date": "Mon, 4 Sep 2017 11:36:08 +0800", "Message-Id": "<1504496169-31190-1-git-send-email-jasowang@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.11", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tMon, 04 Sep 2017 03:36:17 +0000 (UTC)", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "We reserve headroom unconditionally which could cause unnecessary\nstress on socket memory accounting because of increased trusesize. Fix\nthis by only reserve extra headroom when XDP is set.\n\nCc: Jakub Kicinski <kubakici@wp.pl>\nSigned-off-by: Jason Wang <jasowang@redhat.com>\n---\n drivers/net/tun.c | 26 ++++++++++++++++++--------\n 1 file changed, 18 insertions(+), 8 deletions(-)", "diff": "diff --git a/drivers/net/tun.c b/drivers/net/tun.c\nindex 06e8f0b..80ac18f 100644\n--- a/drivers/net/tun.c\n+++ b/drivers/net/tun.c\n@@ -108,7 +108,7 @@ do {\t\t\t\t\t\t\t\t\\\n #endif\n \n #define TUN_HEADROOM 256\n-#define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD + TUN_HEADROOM)\n+#define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD)\n \n /* TUN device flags */\n \n@@ -1272,25 +1272,35 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,\n \tstruct page_frag *alloc_frag = ¤t->task_frag;\n \tstruct sk_buff *skb;\n \tstruct bpf_prog *xdp_prog;\n-\tint buflen = SKB_DATA_ALIGN(len + TUN_RX_PAD) +\n-\t\t SKB_DATA_ALIGN(sizeof(struct skb_shared_info));\n+\tint buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));\n \tunsigned int delta = 0;\n \tchar *buf;\n \tsize_t copied;\n \tbool xdp_xmit = false;\n-\tint err;\n+\tint err, pad = TUN_RX_PAD;\n+\n+\trcu_read_lock();\n+\txdp_prog = rcu_dereference(tun->xdp_prog);\n+\tif (xdp_prog)\n+\t\tpad += TUN_HEADROOM;\n+\tbuflen += SKB_DATA_ALIGN(len + pad);\n+\trcu_read_unlock();\n \n \tif (unlikely(!skb_page_frag_refill(buflen, alloc_frag, GFP_KERNEL)))\n \t\treturn ERR_PTR(-ENOMEM);\n \n \tbuf = (char *)page_address(alloc_frag->page) + alloc_frag->offset;\n \tcopied = copy_page_from_iter(alloc_frag->page,\n-\t\t\t\t alloc_frag->offset + TUN_RX_PAD,\n+\t\t\t\t alloc_frag->offset + pad,\n \t\t\t\t len, from);\n \tif (copied != len)\n \t\treturn ERR_PTR(-EFAULT);\n \n-\tif (hdr->gso_type)\n+\t/* There's a small window that XDP may be set after the check\n+\t * of xdp_prog above, this should be rare and for simplicity\n+\t * we do XDP on skb in case the headroom is not enough.\n+\t */\n+\tif (hdr->gso_type || !xdp_prog)\n \t\t*generic_xdp = 1;\n \telse\n \t\t*generic_xdp = 0;\n@@ -1303,7 +1313,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,\n \t\tu32 act;\n \n \t\txdp.data_hard_start = buf;\n-\t\txdp.data = buf + TUN_RX_PAD;\n+\t\txdp.data = buf + pad;\n \t\txdp.data_end = xdp.data + len;\n \t\torig_data = xdp.data;\n \t\tact = bpf_prog_run_xdp(xdp_prog, &xdp);\n@@ -1339,7 +1349,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,\n \t\treturn ERR_PTR(-ENOMEM);\n \t}\n \n-\tskb_reserve(skb, TUN_RX_PAD - delta);\n+\tskb_reserve(skb, pad - delta);\n \tskb_put(skb, len + delta);\n \tget_page(alloc_frag->page);\n \talloc_frag->offset += buflen;\n", "prefixes": [ "net-next", "1/2" ] }