Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812194/?format=api
{ "id": 812194, "url": "http://patchwork.ozlabs.org/api/patches/812194/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/1505091651-55964-3-git-send-email-xiangxia.m.yue@gmail.com/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1505091651-55964-3-git-send-email-xiangxia.m.yue@gmail.com>", "list_archive_url": null, "date": "2017-09-11T01:00:51", "name": "[ovs-dev,2/2] datapath: Optimize operations for OvS flow_stats.", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "080094914cb7705e36d0a737a970089b7bece7ba", "submitter": { "id": 71877, "url": "http://patchwork.ozlabs.org/api/people/71877/?format=api", "name": "Tonghao Zhang", "email": "xiangxia.m.yue@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/1505091651-55964-3-git-send-email-xiangxia.m.yue@gmail.com/mbox/", "series": [ { "id": 2423, "url": "http://patchwork.ozlabs.org/api/series/2423/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=2423", "date": "2017-09-11T01:00:49", "name": "datapath: Optimize operations for OvS flow_stats.", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/2423/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812194/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812194/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "ovs-dev@mail.linuxfoundation.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"O2puW+ZJ\"; dkim-atps=neutral" ], "Received": [ "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xr8m61Kjtz9s76\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 11:02:30 +1000 (AEST)", "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 4BA69910;\n\tMon, 11 Sep 2017 01:01:20 +0000 (UTC)", "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 8F2465A7\n\tfor <dev@openvswitch.org>; Mon, 11 Sep 2017 01:01:17 +0000 (UTC)", "from mail-pf0-f196.google.com (mail-pf0-f196.google.com\n\t[209.85.192.196])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id 24E9341D\n\tfor <dev@openvswitch.org>; Mon, 11 Sep 2017 01:01:17 +0000 (UTC)", "by mail-pf0-f196.google.com with SMTP id g65so4024886pfe.1\n\tfor <dev@openvswitch.org>; Sun, 10 Sep 2017 18:01:17 -0700 (PDT)", "from local.opencloud.tech.localdomain ([106.120.127.10])\n\tby smtp.gmail.com with ESMTPSA id\n\tx28sm13380831pgc.91.2017.09.10.18.01.14\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 10 Sep 2017 18:01:15 -0700 (PDT)" ], "X-Greylist": "whitelisted by SQLgrey-1.7.6", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=w1r34E3rPZukseW6TWG5ow5RAB1uKJgkeDYVUPBu8Kk=;\n\tb=O2puW+ZJTVPculhqmGmxiBvXrGEjl4wzmClzrNfHrAw2edy3kUHpEyfmdHw9zBhCRq\n\tKbC2OuMJMB3W7gfQyGCg2in5jlgfhlh/S0uo0cWYTdSV9K+Yij1/9FfJcnP8OhvrBnMl\n\tUdKjbKvdQxpOBPo9jzMqNtuVPOFc8yGnw1JZXJwO8q5UKBQDVELnVG/J9icPsyzOvCY4\n\t+K3W18RzFjZsX1xPlxzJEUXdXH+vXcZya3lZMSL3BdF2B2k83ki/5X4sv/Yv8yaZ0xVU\n\tgbnoPzt7xmeU9Gk+pck+SZYsWhQzAzD6YGj7ZIsNJaMnUMlQ87hkYqHXKq1YmHZSuM/Q\n\tK+gw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=w1r34E3rPZukseW6TWG5ow5RAB1uKJgkeDYVUPBu8Kk=;\n\tb=NSj/KBodudrEzZGMdDGgaaeoZqc3KU+iTTsOeiQguRdTns5Heo7cKjgvLza5DPoeyE\n\tgqb290aj7hTB+2E8CXssBm8tH3Q+bbvyDT3eKQe3AvTqA2sU3RNfGF1Pb3a6RxzBOCkz\n\t/2EOyEpqz8bnKpNs9rQowldyQpWdJoiylRDDcq+ArqyUzCEwKY90gVIe0bORSH8YwEtI\n\tYB/jmzoHo/NZ+In+nwLjOECv7kY8kKtPsBavCl85xegmRGsWMN5wY6xct7u8+o21Mb+g\n\t77bN5xwgqj3CPKDE018aEhhESL0WBfgpzPykHz5kYeDu0jUOxsU4vSAOF2xKyfxtnC0/\n\tcgyg==", "X-Gm-Message-State": "AHPjjUjqlshCkyvrzXGwAWSsvaCLHH4pr8g7IVUXRQ6KV5p55RmQUV2L\n\t77GN+1oYpYMcbSGZbgA=", "X-Google-Smtp-Source": "ADKCNb4XABxU/gsYgh3rqceSGAyuhi5cxz3u/XuRVMtgYbnqDz7woSp4fUesv4rHMbJxEYXKfRcWNQ==", "X-Received": "by 10.98.60.134 with SMTP id b6mr10142765pfk.41.1505091676568;\n\tSun, 10 Sep 2017 18:01:16 -0700 (PDT)", "From": "Tonghao Zhang <xiangxia.m.yue@gmail.com>", "To": "dev@openvswitch.org", "Date": "Sun, 10 Sep 2017 18:00:51 -0700", "Message-Id": "<1505091651-55964-3-git-send-email-xiangxia.m.yue@gmail.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1505091651-55964-1-git-send-email-xiangxia.m.yue@gmail.com>", "References": "<1505091651-55964-1-git-send-email-xiangxia.m.yue@gmail.com>", "MIME-Version": "1.0", "X-Spam-Status": "No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,\n\tDKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM\n\tautolearn=disabled version=3.3.1", "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org", "Subject": "[ovs-dev] [PATCH 2/2] datapath: Optimize operations for OvS\n\tflow_stats.", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.12", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>", "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>", "List-Post": "<mailto:ovs-dev@openvswitch.org>", "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>", "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Sender": "ovs-dev-bounces@openvswitch.org", "Errors-To": "ovs-dev-bounces@openvswitch.org" }, "content": "Upstream commit:\n\tcommit c4b2bf6b4a35348fe6d1eb06928eb68d7b9d99a9\n\tAuthor: Tonghao Zhang <xiangxia.m.yue@gmail.com>\n\tDate: Mon Jul 17 23:28:06 2017 -0700\n\n\topenvswitch: Optimize operations for OvS flow_stats.\n\n\tWhen calling the flow_free() to free the flow, we call many times\n\t(cpu_possible_mask, eg. 128 as default) cpumask_next(). That will\n\ttake up our CPU usage if we call the flow_free() frequently.\n\tWhen we put all packets to userspace via upcall, and OvS will send\n\tthem back via netlink to ovs_packet_cmd_execute(will call flow_free).\n\n\tThe test topo is shown as below. VM01 sends TCP packets to VM02,\n\tand OvS forward packtets. When testing, we use perf to report the\n\tsystem performance.\n\n\tVM01 --- OvS-VM --- VM02\n\n\tWithout this patch, perf-top show as below: The flow_free() is\n\t3.02% CPU usage.\n\n\t\t4.23% [kernel] [k] _raw_spin_unlock_irqrestore\n\t\t3.62% [kernel] [k] __do_softirq\n\t\t3.16% [kernel] [k] __memcpy\n\t\t3.02% [kernel] [k] flow_free\n\t\t2.42% libc-2.17.so [.] __memcpy_ssse3_back\n\t\t2.18% [kernel] [k] copy_user_generic_unrolled\n\t\t2.17% [kernel] [k] find_next_bit\n\n\tWhen applied this patch, perf-top show as below: Not shown on\n\tthe list anymore.\n\n\t\t4.11% [kernel] [k] _raw_spin_unlock_irqrestore\n\t\t3.79% [kernel] [k] __do_softirq\n\t\t3.46% [kernel] [k] __memcpy\n\t\t2.73% libc-2.17.so [.] __memcpy_ssse3_back\n\t\t2.25% [kernel] [k] copy_user_generic_unrolled\n\t\t1.89% libc-2.17.so [.] _int_malloc\n\t\t1.53% ovs-vswitchd [.] xlate_actions\n\n\tWith this patch, the TCP throughput(we dont use Megaflow Cache\n\t+ Microflow Cache) between VMs is 1.18Gbs/sec up to 1.30Gbs/sec\n\t(maybe ~10% performance improve).\n\n\tThis patch adds cpumask struct, the cpu_used_mask stores the cpu_id\n\tthat the flow used. And we only check the flow_stats on the cpu we\n\tused, and it is unncessary to check all possible cpu when getting,\n\tcleaning, and updating the flow_stats. Adding the cpu_used_mask to\n\tsw_flow struct does’t increase the cacheline number.\n\n\tSigned-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>\n\tAcked-by: Pravin B Shelar <pshelar@ovn.org>\n\tSigned-off-by: David S. Miller <davem@davemloft.net>\n\nSigned-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>\n---\n datapath/flow.c | 7 ++++---\n datapath/flow.h | 2 ++\n datapath/flow_table.c | 4 +++-\n 3 files changed, 9 insertions(+), 4 deletions(-)", "diff": "diff --git a/datapath/flow.c b/datapath/flow.c\nindex 20582df..a23e147 100644\n--- a/datapath/flow.c\n+++ b/datapath/flow.c\n@@ -71,7 +71,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,\n \t\t\t const struct sk_buff *skb)\n {\n \tstruct flow_stats *stats;\n-\tint cpu = smp_processor_id();\n+\tunsigned int cpu = smp_processor_id();\n \tint len = skb->len + (skb_vlan_tag_present(skb) ? VLAN_HLEN : 0);\n \n \tstats = rcu_dereference(flow->stats[cpu]);\n@@ -116,6 +116,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,\n \n \t\t\t\t\trcu_assign_pointer(flow->stats[cpu],\n \t\t\t\t\t\t\t new_stats);\n+\t\t\t\t\tcpumask_set_cpu(cpu, &flow->cpu_used_mask);\n \t\t\t\t\tgoto unlock;\n \t\t\t\t}\n \t\t\t}\n@@ -143,7 +144,7 @@ void ovs_flow_stats_get(const struct sw_flow *flow,\n \tmemset(ovs_stats, 0, sizeof(*ovs_stats));\n \n \t/* We open code this to make sure cpu 0 is always considered */\n-\tfor (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpu_possible_mask)) {\n+\tfor (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, &flow->cpu_used_mask)) {\n \t\tstruct flow_stats *stats = rcu_dereference_ovsl(flow->stats[cpu]);\n \n \t\tif (stats) {\n@@ -167,7 +168,7 @@ void ovs_flow_stats_clear(struct sw_flow *flow)\n \tint cpu;\n \n \t/* We open code this to make sure cpu 0 is always considered */\n-\tfor (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpu_possible_mask)) {\n+\tfor (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, &flow->cpu_used_mask)) {\n \t\tstruct flow_stats *stats = ovsl_dereference(flow->stats[cpu]);\n \n \t\tif (stats) {\ndiff --git a/datapath/flow.h b/datapath/flow.h\nindex 07af912..0796b09 100644\n--- a/datapath/flow.h\n+++ b/datapath/flow.h\n@@ -31,6 +31,7 @@\n #include <linux/jiffies.h>\n #include <linux/time.h>\n #include <linux/flex_array.h>\n+#include <linux/cpumask.h>\n #include <net/inet_ecn.h>\n #include <net/ip_tunnels.h>\n #include <net/dst_metadata.h>\n@@ -218,6 +219,7 @@ struct sw_flow {\n \t\t\t\t\t */\n \tstruct sw_flow_key key;\n \tstruct sw_flow_id id;\n+\tstruct cpumask cpu_used_mask;\n \tstruct sw_flow_mask *mask;\n \tstruct sw_flow_actions __rcu *sf_acts;\n \tstruct flow_stats __rcu *stats[]; /* One for each CPU. First one\ndiff --git a/datapath/flow_table.c b/datapath/flow_table.c\nindex 6fe3739..47057a1 100644\n--- a/datapath/flow_table.c\n+++ b/datapath/flow_table.c\n@@ -104,6 +104,8 @@ struct sw_flow *ovs_flow_alloc(void)\n \n \tRCU_INIT_POINTER(flow->stats[0], stats);\n \n+\tcpumask_set_cpu(0, &flow->cpu_used_mask);\n+\n \treturn flow;\n err:\n \tkmem_cache_free(flow_cache, flow);\n@@ -147,7 +149,7 @@ static void flow_free(struct sw_flow *flow)\n \tif (flow->sf_acts)\n \t\tovs_nla_free_flow_actions((struct sw_flow_actions __force *)flow->sf_acts);\n \t/* We open code this to make sure cpu 0 is always considered */\n-\tfor (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpu_possible_mask))\n+\tfor (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, &flow->cpu_used_mask))\n \t\tif (flow->stats[cpu])\n \t\t\tkmem_cache_free(flow_stats_cache,\n \t\t\t\t\trcu_dereference_raw(flow->stats[cpu]));\n", "prefixes": [ "ovs-dev", "2/2" ] }