Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/819584/?format=api
{ "id": 819584, "url": "http://patchwork.ozlabs.org/api/patches/819584/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/150660344318.2808.10264798458378115347.stgit@firesoul/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/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": "<150660344318.2808.10264798458378115347.stgit@firesoul>", "list_archive_url": null, "date": "2017-09-28T12:57:23", "name": "[net-next,4/5] bpf: cpumap add tracepoints", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f31cec773745f0d6bd444cdce8aaa6c53c21036a", "submitter": { "id": 13625, "url": "http://patchwork.ozlabs.org/api/people/13625/?format=api", "name": "Jesper Dangaard Brouer", "email": "brouer@redhat.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/150660344318.2808.10264798458378115347.stgit@firesoul/mbox/", "series": [ { "id": 5560, "url": "http://patchwork.ozlabs.org/api/series/5560/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=5560", "date": "2017-09-28T12:57:02", "name": "New bpf cpumap type for XDP_REDIRECT", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/5560/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/819584/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/819584/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-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=brouer@redhat.com" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y2vqR5PwZz9tXd\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 28 Sep 2017 22:57:39 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753136AbdI1M52 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 28 Sep 2017 08:57:28 -0400", "from mx1.redhat.com ([209.132.183.28]:40104 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753116AbdI1M5Z (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tThu, 28 Sep 2017 08:57:25 -0400", "from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\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 C5F39C072443;\n\tThu, 28 Sep 2017 12:57:24 +0000 (UTC)", "from firesoul.localdomain (ovpn-200-26.brq.redhat.com\n\t[10.40.200.26])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 2509386E6F;\n\tThu, 28 Sep 2017 12:57:24 +0000 (UTC)", "from [192.168.5.1] (localhost [IPv6:::1])\n\tby firesoul.localdomain (Postfix) with ESMTP id 406B6300006B0;\n\tThu, 28 Sep 2017 14:57:23 +0200 (CEST)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com C5F39C072443", "Subject": "[net-next PATCH 4/5] bpf: cpumap add tracepoints", "From": "Jesper Dangaard Brouer <brouer@redhat.com>", "To": "netdev@vger.kernel.org", "Cc": "jakub.kicinski@netronome.com, \"Michael S. Tsirkin\" <mst@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, mchan@broadcom.com,\n\tJohn Fastabend <john.fastabend@gmail.com>, peter.waskiewicz.jr@intel.com,\n\tJesper Dangaard Brouer <brouer@redhat.com>,\n\tDaniel Borkmann <borkmann@iogearbox.net>,\n\tAlexei Starovoitov <alexei.starovoitov@gmail.com>,\n\tAndy Gospodarek <andy@greyhouse.net>", "Date": "Thu, 28 Sep 2017 14:57:23 +0200", "Message-ID": "<150660344318.2808.10264798458378115347.stgit@firesoul>", "In-Reply-To": "<150660339205.2808.7084136789768233829.stgit@firesoul>", "References": "<150660339205.2808.7084136789768233829.stgit@firesoul>", "User-Agent": "StGit/0.17.1-dirty", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tThu, 28 Sep 2017 12:57:24 +0000 (UTC)", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "This adds two tracepoint to the cpumap. One for the enqueue side\ntrace_xdp_cpumap_enqueue() and one for the kthread dequeue side\ntrace_xdp_cpumap_kthread().\n\nTo mitigate the tracepoint overhead, these are invoked during the\nenqueue/dequeue bulking phases, thus amortizing the cost.\n\nThe obvious use-cases are for debugging and monitoring. The\nnon-intuitive use-case is using these as a feedback loop to know the\nsystem load. One can imagine auto-scaling by reducing, adding or\nactivating more worker CPUs on demand.\n\nSigned-off-by: Jesper Dangaard Brouer <brouer@redhat.com>\n---\n include/trace/events/xdp.h | 70 ++++++++++++++++++++++++++++++++++++++++++++\n kernel/bpf/cpumap.c | 18 +++++++++--\n 2 files changed, 85 insertions(+), 3 deletions(-)", "diff": "diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h\nindex eb2ece96c1a2..bc48c13892c4 100644\n--- a/include/trace/events/xdp.h\n+++ b/include/trace/events/xdp.h\n@@ -150,6 +150,76 @@ DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map_err,\n \t trace_xdp_redirect_map_err(dev, xdp, devmap_ifindex(fwd, map),\t\\\n \t\t\t\t err, map, idx)\n \n+TRACE_EVENT(xdp_cpumap_kthread,\n+\n+\tTP_PROTO(int map_id, unsigned int processed, unsigned int drops,\n+\t\t int time_limit),\n+\n+\tTP_ARGS(map_id, processed, drops, time_limit),\n+\n+\tTP_STRUCT__entry(\n+\t\t__field(int, map_id)\n+\t\t__field(u32, act)\n+\t\t__field(int, cpu)\n+\t\t__field(unsigned int, drops)\n+\t\t__field(unsigned int, processed)\n+\t\t__field(int, time_limit)\n+\t),\n+\n+\tTP_fast_assign(\n+\t\t__entry->map_id\t\t= map_id;\n+\t\t__entry->act\t\t= XDP_REDIRECT;\n+\t\t__entry->cpu\t\t= smp_processor_id();\n+\t\t__entry->drops\t\t= drops;\n+\t\t__entry->processed\t= processed;\n+\t\t__entry->time_limit\t= time_limit;\n+\t),\n+\n+\tTP_printk(\"kthread\"\n+\t\t \" cpu=%d map_id=%d action=%s\"\n+\t\t \" processed=%u drops=%u\"\n+\t\t \" time_limit=%d\",\n+\t\t __entry->cpu, __entry->map_id,\n+\t\t __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),\n+\t\t __entry->processed, __entry->drops,\n+\t\t __entry->time_limit)\n+);\n+\n+TRACE_EVENT(xdp_cpumap_enqueue,\n+\n+\tTP_PROTO(int map_id, unsigned int processed, unsigned int drops,\n+\t\t int to_cpu),\n+\n+\tTP_ARGS(map_id, processed, drops, to_cpu),\n+\n+\tTP_STRUCT__entry(\n+\t\t__field(int, map_id)\n+\t\t__field(u32, act)\n+\t\t__field(int, cpu)\n+\t\t__field(unsigned int, drops)\n+\t\t__field(unsigned int, processed)\n+\t\t__field(int, to_cpu)\n+\t),\n+\n+\tTP_fast_assign(\n+\t\t__entry->map_id\t\t= map_id;\n+\t\t__entry->act\t\t= XDP_REDIRECT;\n+\t\t__entry->cpu\t\t= smp_processor_id();\n+\t\t__entry->drops\t\t= drops;\n+\t\t__entry->processed\t= processed;\n+\t\t__entry->to_cpu\t\t= to_cpu;\n+\t),\n+\n+\tTP_printk(\"enqueue\"\n+\t\t \" cpu=%d map_id=%d action=%s\"\n+\t\t \" processed=%u drops=%u\"\n+\t\t \" to_cpu=%d\",\n+\t\t __entry->cpu, __entry->map_id,\n+\t\t __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),\n+\t\t __entry->processed, __entry->drops,\n+\t\t __entry->to_cpu)\n+);\n+\n #endif /* _TRACE_XDP_H */\n \n #include <trace/define_trace.h>\ndiff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c\nindex 352cc071c9cc..3b0288e4e998 100644\n--- a/kernel/bpf/cpumap.c\n+++ b/kernel/bpf/cpumap.c\n@@ -23,6 +23,7 @@\n #include <linux/sched.h>\n #include <linux/workqueue.h>\n #include <linux/kthread.h>\n+#include <trace/events/xdp.h>\n \n #include <linux/netdevice.h> /* netif_receive_skb */\n #include <linux/etherdevice.h> /* eth_type_trans */\n@@ -294,6 +295,9 @@ static int cpu_map_kthread_run(void *data)\n \t\t\tif (++processed == 8)\n \t\t\t\tbreak;\n \t\t}\n+\t\t/* Feedback loop via tracepoint */\n+\t\ttrace_xdp_cpumap_kthread(rcpu->map_id, processed, drops,\n+\t\t\t\t\t time_after_eq(jiffies, time_limit));\n \t\tlocal_bh_enable();\n \n \t\t__set_current_state(TASK_INTERRUPTIBLE);\n@@ -331,7 +335,10 @@ struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, int map_id)\n \terr = ptr_ring_init(rcpu->queue, qsize, gfp);\n \tif (err)\n \t\tgoto fail;\n-\trcpu->qsize = qsize;\n+\n+\trcpu->cpu = cpu;\n+\trcpu->map_id = map_id;\n+\trcpu->qsize = qsize;\n \n \t/* Setup kthread */\n \trcpu->kthread = kthread_create_on_node(cpu_map_kthread_run, rcpu, numa,\n@@ -555,6 +562,8 @@ const struct bpf_map_ops cpu_map_ops = {\n static int bq_flush_to_queue(struct bpf_cpu_map_entry *rcpu,\n \t\t\t struct xdp_bulk_queue *bq)\n {\n+\tunsigned int processed = 0, drops = 0;\n+\tconst int to_cpu = rcpu->cpu;\n \tstruct ptr_ring *q;\n \tint i;\n \n@@ -570,13 +579,16 @@ static int bq_flush_to_queue(struct bpf_cpu_map_entry *rcpu,\n \n \t\terr = __ptr_ring_produce(q, xdp_pkt);\n \t\tif (err) {\n-\t\t\t/* Free xdp_pkt */\n-\t\t\tpage_frag_free(xdp_pkt);\n+\t\t\tdrops++;\n+\t\t\tpage_frag_free(xdp_pkt); /* Free xdp_pkt */\n \t\t}\n+\t\tprocessed++;\n \t}\n \tbq->count = 0;\n \tspin_unlock(&q->producer_lock);\n \n+\t/* Feedback loop via tracepoints */\n+\ttrace_xdp_cpumap_enqueue(rcpu->map_id, processed, drops, to_cpu);\n \treturn 0;\n }\n \n", "prefixes": [ "net-next", "4/5" ] }