Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1237/?format=api
https://patches.dpdk.org/api/patches/1237/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1415623967-52488-3-git-send-email-jigsaw@gmail.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1415623967-52488-3-git-send-email-jigsaw@gmail.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1415623967-52488-3-git-send-email-jigsaw@gmail.com", "date": "2014-11-10T12:52:47", "name": "[dpdk-dev,v2,2/2] Add in_flight_bitmask so as to use full 32 bits of tag.", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": true, "hash": "646a669a98f1ddbfb07da36f537e66d72da7d847", "submitter": { "id": 105, "url": "https://patches.dpdk.org/api/people/105/?format=api", "name": "Qinglai Xiao", "email": "jigsaw@gmail.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1415623967-52488-3-git-send-email-jigsaw@gmail.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/1237/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/1237/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 8F8437F68;\n\tMon, 10 Nov 2014 13:43:16 +0100 (CET)", "from mail-lb0-f176.google.com (mail-lb0-f176.google.com\n\t[209.85.217.176]) by dpdk.org (Postfix) with ESMTP id 5DA997F50\n\tfor <dev@dpdk.org>; Mon, 10 Nov 2014 13:43:12 +0100 (CET)", "by mail-lb0-f176.google.com with SMTP id 10so5808166lbg.35\n\tfor <dev@dpdk.org>; Mon, 10 Nov 2014 04:52:57 -0800 (PST)", "from localhost.localdomain ([194.251.119.201])\n\tby mx.google.com with ESMTPSA id\n\tb4sm5263382lak.28.2014.11.10.04.52.56 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 10 Nov 2014 04:52:56 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=61f5VaIYiH5PVwSD9y3rOPsd/C/2WAH+bEiynUgaadU=;\n\tb=YbO7IpcdmnjBZLzWh7Ho52hGwTPlDAeJp5us4W2COXHZSFYch8JWDRjeu++3pwDk39\n\tiCdV9uiujJXXy1UxaKsIK95MPbNFadFQScmpi+2GNxZWEtQyHJh0WBU3DR41zyi0+hWf\n\tHZXp4I2CNfSLXZaitqwcePXMp+RTPaEL25X2aKxcDB7HcuLraP2NYe9hIDG5WUU7fzQS\n\tLJBWt9lWG1yEs+HuOSAXELckeBUEZBTam2/0pqbp43BQbhpGkRWynRbMF0Kw9s50LSFN\n\tbVVXlh9FmFtiMq8oAspL2eM+49SzSX3CCNHW7YUG7jRIxgabfuK9+PTbXi1aHNigGTXF\n\t4nKA==", "X-Received": "by 10.152.19.133 with SMTP id f5mr2213163lae.87.1415623977472;\n\tMon, 10 Nov 2014 04:52:57 -0800 (PST)", "From": "Qinglai Xiao <jigsaw@gmail.com>", "To": "dev@dpdk.org", "Date": "Mon, 10 Nov 2014 14:52:47 +0200", "Message-Id": "<1415623967-52488-3-git-send-email-jigsaw@gmail.com>", "X-Mailer": "git-send-email 1.7.1", "In-Reply-To": "<1415623967-52488-1-git-send-email-jigsaw@gmail.com>", "References": "<1415623967-52488-1-git-send-email-jigsaw@gmail.com>", "Cc": "Qinglai Xiao <jigsaw@gmail.com>", "Subject": "[dpdk-dev] [PATCH v2 2/2] Add in_flight_bitmask so as to use full\n\t32 bits of tag.", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "With introduction of in_flight_bitmask, the whole 32 bits of tag can be\nused. Further more, this patch fixed the integer overflow when finding\nthe matched tags.\nNote that currently librte_distributor supports up to 64 worker threads.\nIf more workers are needed, the size of in_flight_bitmask and the\nalgorithm of finding matched tag must be revised.\n\nSigned-off-by: Qinglai Xiao <jigsaw@gmail.com>\n---\n lib/librte_distributor/rte_distributor.c | 45 ++++++++++++++++++++++--------\n lib/librte_distributor/rte_distributor.h | 4 ++\n 2 files changed, 37 insertions(+), 12 deletions(-)", "diff": "diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c\nindex 3dfec4a..3dfccae 100644\n--- a/lib/librte_distributor/rte_distributor.c\n+++ b/lib/librte_distributor/rte_distributor.c\n@@ -92,7 +92,13 @@ struct rte_distributor {\n \tunsigned num_workers; /**< Number of workers polling */\n \n \tuint32_t in_flight_tags[RTE_MAX_LCORE];\n-\t\t/**< Tracks the tag being processed per core, 0 == no pkt */\n+\t\t/**< Tracks the tag being processed per core */\n+\tuint64_t in_flight_bitmask;\n+\t\t/**< on/off bits for in-flight tags.\n+\t\t * Note that if RTE_MAX_LCORE is larger than 64 then\n+\t\t * the bitmask has to expand.\n+\t\t */\n+\n \tstruct rte_distributor_backlog backlog[RTE_MAX_LCORE];\n \n \tunion rte_distributor_buffer bufs[RTE_MAX_LCORE];\n@@ -189,6 +195,7 @@ static inline void\n handle_worker_shutdown(struct rte_distributor *d, unsigned wkr)\n {\n \td->in_flight_tags[wkr] = 0;\n+\td->in_flight_bitmask &= ~(1UL << wkr);\n \td->bufs[wkr].bufptr64 = 0;\n \tif (unlikely(d->backlog[wkr].count != 0)) {\n \t\t/* On return of a packet, we need to move the\n@@ -211,7 +218,10 @@ handle_worker_shutdown(struct rte_distributor *d, unsigned wkr)\n \t\t\tpkts[i] = (void *)((uintptr_t)(bl->pkts[idx] >>\n \t\t\t\t\tRTE_DISTRIB_FLAG_BITS));\n \t\t}\n-\t\t/* recursive call */\n+\t\t/* recursive call.\n+\t\t * Note that the tags were set before first level call\n+\t\t * to rte_distributor_process.\n+\t\t */\n \t\trte_distributor_process(d, pkts, i);\n \t\tbl->count = bl->start = 0;\n \t}\n@@ -242,6 +252,7 @@ process_returns(struct rte_distributor *d)\n \t\t\telse {\n \t\t\t\td->bufs[wkr].bufptr64 = RTE_DISTRIB_GET_BUF;\n \t\t\t\td->in_flight_tags[wkr] = 0;\n+\t\t\t\td->in_flight_bitmask &= ~(1UL << wkr);\n \t\t\t}\n \t\t\toldbuf = data >> RTE_DISTRIB_FLAG_BITS;\n \t\t} else if (data & RTE_DISTRIB_RETURN_BUF) {\n@@ -284,14 +295,18 @@ rte_distributor_process(struct rte_distributor *d,\n \t\t\tnext_value = (((int64_t)(uintptr_t)next_mb)\n \t\t\t\t\t<< RTE_DISTRIB_FLAG_BITS);\n \t\t\t/*\n-\t\t\t * Set the low bit on the tag, so we can guarantee that\n-\t\t\t * we never store a tag value of zero. That means we can\n-\t\t\t * use the zero-value to indicate that no packet is\n-\t\t\t * being processed by a worker.\n+\t\t\t * User is advocated to set tag vaue for each\n+\t\t\t * mbuf before calling rte_distributor_process.\n+\t\t\t * User defined tags are used to identify flows,\n+\t\t\t * or sessions.\n \t\t\t */\n-\t\t\tnew_tag = (next_mb->hash.usr | 1);\n+\t\t\tnew_tag = next_mb->hash.usr;\n \n-\t\t\tuint32_t match = 0;\n+\t\t\t/*\n+\t\t\t * Note that if RTE_MAX_LCORE is larger than 64 then\n+\t\t\t * the size of match has to be expanded.\n+\t\t\t */\n+\t\t\tuint64_t match = 0;\n \t\t\tunsigned i;\n \t\t\t/*\n \t\t\t * to scan for a match use \"xor\" and \"not\" to get a 0/1\n@@ -303,9 +318,12 @@ rte_distributor_process(struct rte_distributor *d,\n \t\t\t\tmatch |= (!(d->in_flight_tags[i] ^ new_tag)\n \t\t\t\t\t<< i);\n \n+\t\t\t/* Only turned-on bits are considered as match */\n+\t\t\tmatch &= d->in_flight_bitmask;\n+\n \t\t\tif (match) {\n \t\t\t\tnext_mb = NULL;\n-\t\t\t\tunsigned worker = __builtin_ctz(match);\n+\t\t\t\tunsigned worker = __builtin_ctzl(match);\n \t\t\t\tif (add_to_backlog(&d->backlog[worker],\n \t\t\t\t\t\tnext_value) < 0)\n \t\t\t\t\tnext_idx--;\n@@ -322,6 +340,7 @@ rte_distributor_process(struct rte_distributor *d,\n \t\t\telse {\n \t\t\t\td->bufs[wkr].bufptr64 = next_value;\n \t\t\t\td->in_flight_tags[wkr] = new_tag;\n+\t\t\t\td->in_flight_bitmask |= (1UL << wkr);\n \t\t\t\tnext_mb = NULL;\n \t\t\t}\n \t\t\toldbuf = data >> RTE_DISTRIB_FLAG_BITS;\n@@ -379,11 +398,13 @@ rte_distributor_returned_pkts(struct rte_distributor *d,\n static inline unsigned\n total_outstanding(const struct rte_distributor *d)\n {\n-\tunsigned wkr, total_outstanding = 0;\n+\tunsigned wkr, total_outstanding;\n+\n+\ttotal_outstanding = __builtin_popcountl(d->in_flight_bitmask);\n \n \tfor (wkr = 0; wkr < d->num_workers; wkr++)\n-\t\ttotal_outstanding += d->backlog[wkr].count +\n-\t\t\t\t!!(d->in_flight_tags[wkr]);\n+\t\ttotal_outstanding += d->backlog[wkr].count;\n+\n \treturn total_outstanding;\n }\n \ndiff --git a/lib/librte_distributor/rte_distributor.h b/lib/librte_distributor/rte_distributor.h\nindex ec0d74a..cc1d559 100644\n--- a/lib/librte_distributor/rte_distributor.h\n+++ b/lib/librte_distributor/rte_distributor.h\n@@ -88,6 +88,10 @@ rte_distributor_create(const char *name, unsigned socket_id,\n * packets. The distributor will ensure that no two packets that have the\n * same flow id, or tag, in the mbuf will be procesed at the same time.\n *\n+ * The user is advocated to set tag for each mbuf before calling this function.\n+ * If user doesn't set the tag, the tag value can be various values depending on\n+ * driver implementation and configuration.\n+ *\n * This is not multi-thread safe and should only be called on a single lcore.\n *\n * @param d\n", "prefixes": [ "dpdk-dev", "v2", "2/2" ] }{ "id": 1237, "url": "