get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/68882/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 68882,
    "url": "https://patches.dpdk.org/api/patches/68882/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200419100133.3232316-11-jerinj@marvell.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": "<20200419100133.3232316-11-jerinj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200419100133.3232316-11-jerinj@marvell.com",
    "date": "2020-04-19T10:01:10",
    "name": "[v6,10/33] eal/trace: implement trace memory allocation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "faed846776653dec4710553745f16733b2e2fe11",
    "submitter": {
        "id": 1188,
        "url": "https://patches.dpdk.org/api/people/1188/?format=api",
        "name": "Jerin Jacob Kollanukkaran",
        "email": "jerinj@marvell.com"
    },
    "delegate": {
        "id": 24651,
        "url": "https://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200419100133.3232316-11-jerinj@marvell.com/mbox/",
    "series": [
        {
            "id": 9495,
            "url": "https://patches.dpdk.org/api/series/9495/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9495",
            "date": "2020-04-19T10:01:02",
            "name": "DPDK Trace support",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/9495/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/68882/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/68882/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D8243A0561;\n\tSun, 19 Apr 2020 12:05:44 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D3B3E1D5DD;\n\tSun, 19 Apr 2020 12:02:42 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id B49491D5B6\n for <dev@dpdk.org>; Sun, 19 Apr 2020 12:02:26 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n 03JA18BG020144; Sun, 19 Apr 2020 03:02:19 -0700",
            "from sc-exch01.marvell.com ([199.233.58.181])\n by mx0b-0016f401.pphosted.com with ESMTP id 30g12njxah-2\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Sun, 19 Apr 2020 03:02:19 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Sun, 19 Apr 2020 03:02:17 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Sun, 19 Apr 2020 03:02:16 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Sun, 19 Apr 2020 03:02:16 -0700",
            "from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14])\n by maili.marvell.com (Postfix) with ESMTP id 318D33F703F;\n Sun, 19 Apr 2020 03:02:13 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0818;\n bh=N6YU3a9SE19syceiFqz9r9DLUjJ1i1wcCYnufOKo0og=;\n b=sXbKVgYLZWBdoNoRW3Zl7jQ53tXJWKScNZ3RD4QiZ/BauDLDSS+tv7A1R4skccfJsoSW\n Dl7wuxekf3MKbJSLmOb1DU5k63DcC9LPZ+sPWCKKQha0nFsph5KAV6129jI5Nv4oqHHy\n IxCqJRsnOMk70cIgUU07UUGKSJHYrCrq/HEYyHIiiFld+d9tW6Bxd9YhV0vc7Ki1Akw6\n JGtsmacAzTzZzNEsvsEmRrOXX/5pNm+ay3/TttkGR1IqPWyr9hBcZqbFHfrdyKIi1DEb\n gXSMcaAc14/jK8Zl3sPCi0A7ew43IgxnlYtdpyF+JwSNpepc4cLOk2gPHvV+zrHhJtyf ig==",
        "From": "<jerinj@marvell.com>",
        "To": "Jerin Jacob <jerinj@marvell.com>, Sunil Kumar Kori <skori@marvell.com>",
        "CC": "<dev@dpdk.org>, <thomas@monjalon.net>, <bruce.richardson@intel.com>,\n <david.marchand@redhat.com>, <mattias.ronnblom@ericsson.com>",
        "Date": "Sun, 19 Apr 2020 15:31:10 +0530",
        "Message-ID": "<20200419100133.3232316-11-jerinj@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200419100133.3232316-1-jerinj@marvell.com>",
        "References": "<20200413150116.734047-1-jerinj@marvell.com>\n <20200419100133.3232316-1-jerinj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676\n definitions=2020-04-19_02:2020-04-17,\n 2020-04-19 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v6 10/33] eal/trace: implement trace memory\n\tallocation",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Jerin Jacob <jerinj@marvell.com>\n\nTrace memory will be allocated per thread to enable lockless trace\nevents updates to the memory. The allocator will first attempt to\nallocate from hugepage, if not available from hugepage then\nfallback to malloc memory.\n\nLater in the patches series, This API will be hooked to DPDK fastpath\nand control plane thread creation API. It is possible for non\nDPDK thread to use trace events, in that case, trace memory\nwill be allocated on the first event emission.\n\nSigned-off-by: Jerin Jacob <jerinj@marvell.com>\n---\n lib/librte_eal/common/eal_common_trace.c      | 97 +++++++++++++++++++\n .../common/eal_common_trace_utils.c           | 20 ++++\n lib/librte_eal/common/eal_trace.h             | 28 ++++++\n lib/librte_eal/include/rte_trace_point.h      |  9 ++\n .../include/rte_trace_point_provider.h        | 20 ++++\n lib/librte_eal/rte_eal_version.map            |  2 +\n 6 files changed, 176 insertions(+)",
    "diff": "diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c\nindex 8bbc07c03..4c03a676a 100644\n--- a/lib/librte_eal/common/eal_common_trace.c\n+++ b/lib/librte_eal/common/eal_common_trace.c\n@@ -16,6 +16,7 @@\n #include \"eal_trace.h\"\n \n RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz);\n+RTE_DEFINE_PER_LCORE(void *, trace_mem);\n static RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]);\n static RTE_DEFINE_PER_LCORE(int, ctf_count);\n \n@@ -37,6 +38,9 @@ trace_list_head_get(void)\n int\n eal_trace_init(void)\n {\n+\t/* Trace memory should start with 8B aligned for natural alignment */\n+\tRTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0);\n+\n \t/* One of the Trace registration failed */\n \tif (trace.register_errno) {\n \t\trte_errno = trace.register_errno;\n@@ -83,6 +87,7 @@ eal_trace_fini(void)\n {\n \tif (rte_trace_is_enabled() == false)\n \t\treturn;\n+\ttrace_mem_per_thread_free();\n \ttrace_metadata_destroy();\n }\n \n@@ -231,6 +236,98 @@ rte_trace_point_lookup(const char *name)\n \treturn NULL;\n }\n \n+static inline size_t\n+list_sz(uint32_t index)\n+{\n+\treturn sizeof(struct thread_mem_meta) * (index + 1);\n+}\n+\n+void\n+__rte_trace_mem_per_thread_alloc(void)\n+{\n+\tstruct trace *trace = trace_obj_get();\n+\tstruct __rte_trace_header *header;\n+\tuint32_t count;\n+\n+\tif (rte_trace_is_enabled() == false)\n+\t\treturn;\n+\n+\tif (RTE_PER_LCORE(trace_mem))\n+\t\treturn;\n+\n+\trte_spinlock_lock(&trace->lock);\n+\n+\tcount = trace->nb_trace_mem_list;\n+\n+\t/* Allocate room for storing the thread trace mem meta */\n+\ttrace->lcore_meta = realloc(trace->lcore_meta, list_sz(count));\n+\n+\t/* Provide dummy space for fastpath to consume */\n+\tif (trace->lcore_meta == NULL) {\n+\t\ttrace_crit(\"trace mem meta memory realloc failed\");\n+\t\theader = NULL; goto fail;\n+\t}\n+\n+\t/* First attempt from huge page */\n+\theader = rte_malloc(NULL, trace_mem_sz(trace->buff_len), 8);\n+\tif (header) {\n+\t\ttrace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;\n+\t\tgoto found;\n+\t}\n+\n+\t/* Second attempt from heap */\n+\theader = malloc(trace_mem_sz(trace->buff_len));\n+\tif (header == NULL) {\n+\t\ttrace_crit(\"trace mem malloc attempt failed\");\n+\t\theader = NULL; goto fail;\n+\n+\t}\n+\n+\t/* Second attempt from heap is success */\n+\ttrace->lcore_meta[count].area = TRACE_AREA_HEAP;\n+\n+\t/* Initialize the trace header */\n+found:\n+\theader->offset = 0;\n+\theader->len = trace->buff_len;\n+\theader->stream_header.magic = TRACE_CTF_MAGIC;\n+\trte_uuid_copy(header->stream_header.uuid, trace->uuid);\n+\theader->stream_header.lcore_id = rte_lcore_id();\n+\n+\t/* Store the thread name */\n+\tchar *name = header->stream_header.thread_name;\n+\tmemset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX);\n+\trte_thread_getname(pthread_self(), name,\n+\t\t\t   __RTE_TRACE_EMIT_STRING_LEN_MAX);\n+\n+\ttrace->lcore_meta[count].mem = header;\n+\ttrace->nb_trace_mem_list++;\n+fail:\n+\tRTE_PER_LCORE(trace_mem) = header;\n+\trte_spinlock_unlock(&trace->lock);\n+}\n+\n+void\n+trace_mem_per_thread_free(void)\n+{\n+\tstruct trace *trace = trace_obj_get();\n+\tuint32_t count;\n+\tvoid *mem;\n+\n+\tif (rte_trace_is_enabled() == false)\n+\t\treturn;\n+\n+\trte_spinlock_lock(&trace->lock);\n+\tfor (count = 0; count < trace->nb_trace_mem_list; count++) {\n+\t\tmem = trace->lcore_meta[count].mem;\n+\t\tif (trace->lcore_meta[count].area == TRACE_AREA_HUGEPAGE)\n+\t\t\trte_free(mem);\n+\t\telse if (trace->lcore_meta[count].area == TRACE_AREA_HEAP)\n+\t\t\tfree(mem);\n+\t}\n+\trte_spinlock_unlock(&trace->lock);\n+}\n+\n int\n __rte_trace_point_register(rte_trace_point_t *handle, const char *name,\n \t\t\t   void (*register_fn)(void))\ndiff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c\nindex f7700934b..de8d43661 100644\n--- a/lib/librte_eal/common/eal_common_trace_utils.c\n+++ b/lib/librte_eal/common/eal_common_trace_utils.c\n@@ -14,6 +14,26 @@\n #include \"eal_filesystem.h\"\n #include \"eal_trace.h\"\n \n+const char *\n+trace_mode_to_string(enum rte_trace_mode mode)\n+{\n+\tswitch (mode) {\n+\tcase RTE_TRACE_MODE_OVERWRITE: return \"overwrite\";\n+\tcase RTE_TRACE_MODE_DISCARD: return \"discard\";\n+\tdefault: return \"unknown\";\n+\t}\n+}\n+\n+const char *\n+trace_area_to_string(enum trace_area_e area)\n+{\n+\tswitch (area) {\n+\tcase TRACE_AREA_HEAP: return \"heap\";\n+\tcase TRACE_AREA_HUGEPAGE: return \"hugepage\";\n+\tdefault: return \"unknown\";\n+\t}\n+}\n+\n static bool\n trace_entry_compare(const char *name)\n {\ndiff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_trace.h\nindex 8e8d1160e..e2538d24a 100644\n--- a/lib/librte_eal/common/eal_trace.h\n+++ b/lib/librte_eal/common/eal_trace.h\n@@ -6,11 +6,16 @@\n #define __EAL_TRACE_H\n \n #include <rte_cycles.h>\n+#include <rte_log.h>\n+#include <rte_malloc.h>\n #include <rte_spinlock.h>\n #include <rte_trace.h>\n #include <rte_trace_point.h>\n #include <rte_uuid.h>\n \n+#include \"eal_private.h\"\n+#include \"eal_thread.h\"\n+\n #define trace_err(fmt, args...)\\\n \tRTE_LOG(ERR, EAL, \"%s():%u \" fmt \"\\n\",\\\n \t\t__func__, __LINE__, ## args)\n@@ -23,6 +28,8 @@\n #define TRACE_DIR_STR_LEN (sizeof(\"YYYY-mm-dd-AM-HH-MM-SS\") + TRACE_PREFIX_LEN)\n #define TRACE_CTF_FIELD_SIZE 384\n #define TRACE_POINT_NAME_SIZE 64\n+#define TRACE_CTF_MAGIC 0xC1FC1FC1\n+\n \n struct trace_point {\n \tSTAILQ_ENTRY(trace_point) next;\n@@ -31,6 +38,16 @@ struct trace_point {\n \tchar ctf_field[TRACE_CTF_FIELD_SIZE];\n };\n \n+enum trace_area_e {\n+\tTRACE_AREA_HEAP,\n+\tTRACE_AREA_HUGEPAGE,\n+};\n+\n+struct thread_mem_meta {\n+\tvoid *mem;\n+\tenum trace_area_e area;\n+};\n+\n struct trace {\n \tchar dir[PATH_MAX];\n \tint dir_offset;\n@@ -40,6 +57,8 @@ struct trace {\n \trte_uuid_t uuid;\n \tuint32_t buff_len;\n \tuint32_t nb_trace_points;\n+\tuint32_t nb_trace_mem_list;\n+\tstruct thread_mem_meta *lcore_meta;\n \tuint64_t epoch_sec;\n \tuint64_t epoch_nsec;\n \tuint64_t uptime_ticks;\n@@ -59,6 +78,12 @@ trace_id_get(rte_trace_point_t *trace)\n \t\t__RTE_TRACE_FIELD_ID_SHIFT;\n }\n \n+static inline size_t\n+trace_mem_sz(uint32_t len)\n+{\n+\treturn len + sizeof(struct __rte_trace_header);\n+}\n+\n /* Trace object functions */\n struct trace *trace_obj_get(void);\n \n@@ -67,12 +92,15 @@ STAILQ_HEAD(trace_point_head, trace_point);\n struct trace_point_head *trace_list_head_get(void);\n \n /* Util functions */\n+const char *trace_mode_to_string(enum rte_trace_mode mode);\n+const char *trace_area_to_string(enum trace_area_e area);\n bool trace_has_duplicate_entry(void);\n void trace_uuid_generate(void);\n int trace_metadata_create(void);\n void trace_metadata_destroy(void);\n int trace_mkdir(void);\n int trace_epoch_time_save(void);\n+void trace_mem_per_thread_free(void);\n \n /* EAL interface */\n int eal_trace_init(void);\ndiff --git a/lib/librte_eal/include/rte_trace_point.h b/lib/librte_eal/include/rte_trace_point.h\nindex f9924225a..8e37f971e 100644\n--- a/lib/librte_eal/include/rte_trace_point.h\n+++ b/lib/librte_eal/include/rte_trace_point.h\n@@ -227,6 +227,15 @@ __rte_trace_point_fp_is_enabled(void)\n #endif\n }\n \n+/**\n+ * @internal\n+ *\n+ * Allocate trace memory buffer per thread.\n+ *\n+ */\n+__rte_experimental\n+void __rte_trace_mem_per_thread_alloc(void);\n+\n /**\n  * @internal\n  *\ndiff --git a/lib/librte_eal/include/rte_trace_point_provider.h b/lib/librte_eal/include/rte_trace_point_provider.h\nindex 45a113c0d..b8d727387 100644\n--- a/lib/librte_eal/include/rte_trace_point_provider.h\n+++ b/lib/librte_eal/include/rte_trace_point_provider.h\n@@ -9,6 +9,10 @@\n #ifndef _RTE_TRACE_POINT_PROVIDER_H_\n #define _RTE_TRACE_POINT_PROVIDER_H_\n \n+#include <rte_per_lcore.h>\n+#include <rte_string_fns.h>\n+#include <rte_uuid.h>\n+\n #define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48)\n \n #define __RTE_TRACE_FIELD_SIZE_SHIFT 0\n@@ -18,4 +22,20 @@\n #define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)\n #define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)\n \n+struct __rte_trace_stream_header {\n+\tuint32_t magic;\n+\trte_uuid_t uuid;\n+\tuint32_t lcore_id;\n+\tchar thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];\n+} __rte_packed;\n+\n+struct __rte_trace_header {\n+\tuint32_t offset;\n+\tuint32_t len;\n+\tstruct __rte_trace_stream_header stream_header;\n+\tuint8_t mem[];\n+};\n+\n+RTE_DECLARE_PER_LCORE(void *, trace_mem);\n+\n #endif /* _RTE_TRACE_POINT_PROVIDER_H_ */\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 2e6aacc17..98e0f8413 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -337,7 +337,9 @@ EXPERIMENTAL {\n \trte_thread_is_intr;\n \n \t# added in 20.05\n+\t__rte_trace_mem_per_thread_alloc;\n \t__rte_trace_point_register;\n+\tper_lcore_trace_mem;\n \tper_lcore_trace_point_sz;\n \trte_log_can_log;\n \trte_thread_getname;\n",
    "prefixes": [
        "v6",
        "10/33"
    ]
}