From patchwork Thu Oct 20 18:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13013928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66912C4332F for ; Thu, 20 Oct 2022 18:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbiJTS2Q (ORCPT ); Thu, 20 Oct 2022 14:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiJTS2O (ORCPT ); Thu, 20 Oct 2022 14:28:14 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9E991F524E for ; Thu, 20 Oct 2022 11:28:13 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v1so387526wrt.11 for ; Thu, 20 Oct 2022 11:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=cTLoZaZ6n+Wz/7kdysCOtNZST9K2cELlvFYvnhYh5CM=; b=quXNb3GatOUDfTvVuA2OQa+AZUu01IrAY9bLoBSwGhMzD6TcCpOTf8WlE5lg8MwasR N2E1qM6mP4eKLzeKVhwpZpsn3ZTeOMVszcmrXiLeomNT91VGtjX3sQiGx3uWZywRvFsb kadkpI401otZAQ2X3Q4JVLyIuLtWHxwmC/iBR3Ep/zvN1G8IW4iAV20k+zu6ekTOQpdI U7BSegkBXqYiyhIUryiYv1Sh/GtxB5o009N/RrQvwge0yhn/xu0WNAApEEIAudOGURJQ 7ShrFxr7JcOxchBKbsxtLbTE1w6koawJxCpsDA1sj//ZCgwhqBnM2R1I4CkBPlQMqJoa sHNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cTLoZaZ6n+Wz/7kdysCOtNZST9K2cELlvFYvnhYh5CM=; b=3/h6Cp+3TO/Zvrx8Jt6OGpUALIv5NV2I7r+PYcw6HmreTxeJOzXrUbiPJr5CFAQaQE jukMdD5w8zF4ZMHWxnrxzoTyBNUuTjIqitM0Q1uf6W/zU5DQXgPT0x4zlPt7HiGjq9pE Z2nxo1P8EcRiokiQ+/966+P+/vAtlk+HSEJx+9rcCzhTFc8lHLbFZNzMTIu7Pn8WCLvI zdDWK/VR36zuSfgv+DMr7gYEyzJaCH2wwii28VY4EQ8KYHbMZfajL7Yk2FYRM+mstvvY z3+V3f35+0aQwZYoEgKtsKxKqlCBAi9bqlzdzoxEtVHa7pUHQrju3WWmmfoqKUARgHcj ZYCg== X-Gm-Message-State: ACrzQf2SlzyqiYdAl5zpsMMgawLh96InBeQ5W1Hrz5OOswpoovffkm7e yYYuMlqTwfXzukUI+WsViX+AZsaW7f0= X-Google-Smtp-Source: AMsMyM6uNewKjWOaoeNedmVduKAR9njmqRz0Wrhskvx8gKfSem4cZ8Jx+k3XrDKwZP0jr/RkHqzhdw== X-Received: by 2002:a5d:6485:0:b0:236:4ed2:409c with SMTP id o5-20020a5d6485000000b002364ed2409cmr1042427wri.110.1666290492151; Thu, 20 Oct 2022 11:28:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d19-20020a05600c4c1300b003a84375d0d1sm404059wmp.44.2022.10.20.11.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:28:11 -0700 (PDT) Message-Id: <6e7e4f3187e2fbbbb54bb1cf5793bf6e981a5a94.1666290489.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 20 Oct 2022 18:28:02 +0000 Subject: [PATCH v3 1/8] trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Use "size_t" rather than "int" for the "alloc" and "nr_open_regions" fields in the "tr2tls_thread_ctx". These are used by ALLOC_GROW(). Signed-off-by: Jeff Hostetler --- trace2/tr2_tls.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h index b1e327a928e..a90bd639d48 100644 --- a/trace2/tr2_tls.h +++ b/trace2/tr2_tls.h @@ -11,8 +11,8 @@ struct tr2tls_thread_ctx { struct strbuf thread_name; uint64_t *array_us_start; - int alloc; - int nr_open_regions; /* plays role of "nr" in ALLOC_GROW */ + size_t alloc; + size_t nr_open_regions; /* plays role of "nr" in ALLOC_GROW */ int thread_id; }; From patchwork Thu Oct 20 18:28:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13013930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65E85C433FE for ; Thu, 20 Oct 2022 18:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbiJTS2S (ORCPT ); Thu, 20 Oct 2022 14:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiJTS2Q (ORCPT ); Thu, 20 Oct 2022 14:28:16 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECBF71F5257 for ; Thu, 20 Oct 2022 11:28:14 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id u10so487390wrq.2 for ; Thu, 20 Oct 2022 11:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=iACA4FL6FLxqM8Gf+IfWNEBZzWlEQwVqQ42PnqkGRwo=; b=bKu7VPFQEkmrCde31+JHtAmOPHswNQAkrNAErRwEKUIdVmmcgh7CFSfONxrLfVgDX4 bMBZIiZz1C5Y8+y/E3uYUr2NassJgdQJUsL2CMJbBWe4DbKLWNEawGcOIMjKx9/+qZGt OSgsB5YIU2GMXMIgfP6q08C4JKeCPXwLos20BUDeQ5d2X8qGRHpDXOhLRhayvkLsSN2p /DOCUAUOYu7PcXlI4jgvRKO/4ItDByWX4S9JRvSGCCbERgn6hUQsXgLZ/KJL/x/wbrjf jZSvqyfrZDhFAUypLLljR9FNoKt16pIyI24oPVfHkpH5FDNxqJmd0RXz8qHiOE/i8UM2 tCjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iACA4FL6FLxqM8Gf+IfWNEBZzWlEQwVqQ42PnqkGRwo=; b=U5LYc/B/zfjGCn2hMLGoTSiV0ABD4oeizp10i9Gz3w2T6PXG3NIR6cSO1FHvkOPIKc dILyEcw2xDV8u4JzexCZ/DhDJNMFPuoWi89vBihIkEQ5/2tQttH9PWtOZP8Jo287l3es Asg6t6sqLzI4qdhTg85xTKsLfv9v+rGmPfDASrCdwY/xnVbsQYVy9PFy0s1rUvYC5fW2 5Dge7l5TCYcn7P4mEugjmRcsy8Lj0XuPprJ9Wl5mwG8derebGfWWNHhSQZNSVCxTgxKr V6D97ZHfqwOWo9v65CaubirW43g7DTRMuqgWmq1wfHhfymPJyN9GXlhmphuoF+xSepiK 9u+A== X-Gm-Message-State: ACrzQf06GCH+ZSBaugkj2mgpdxiLskA0zBlnSDqcAIytpCCsYeKTqj/A WdsAcj5+Wbr6CCtE/1TsZzue/wKYPPM= X-Google-Smtp-Source: AMsMyM7vczraU3XegJakHFB60M/wuMe8JJp4iHY1nId3ppb+IYBAGRpT3f+kjRgykk1T7K6rq8V1KQ== X-Received: by 2002:a5d:5a05:0:b0:235:474c:c12 with SMTP id bq5-20020a5d5a05000000b00235474c0c12mr3945150wrb.659.1666290493152; Thu, 20 Oct 2022 11:28:13 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j9-20020adfd209000000b0022cd6e852a2sm20084523wrh.45.2022.10.20.11.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:28:12 -0700 (PDT) Message-Id: <9dee7a75903936f086d97580441c776978d70b43.1666290489.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 20 Oct 2022 18:28:03 +0000 Subject: [PATCH v3 2/8] tr2tls: clarify TLS terminology Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Reduce or eliminate use of the term "TLS" in the Trace2 code. The term "TLS" has two popular meanings: "thread-local storage" and "transport layer security". In the Trace2 source, the term is associated with the former. There was concern on the mailing list about it refering to the latter. Update the source and documentation to eliminate the use of the "TLS" term or replace it with the phrase "thread-local storage" to reduce ambiguity. Signed-off-by: Jeff Hostetler --- Documentation/technical/api-trace2.txt | 8 ++++---- trace2.c | 2 +- trace2.h | 10 +++++----- trace2/tr2_tls.c | 6 +++--- trace2/tr2_tls.h | 18 +++++++++++------- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt index 2afa28bb5aa..431d424f9d5 100644 --- a/Documentation/technical/api-trace2.txt +++ b/Documentation/technical/api-trace2.txt @@ -685,8 +685,8 @@ The "exec_id" field is a command-unique id and is only useful if the `"thread_start"`:: This event is generated when a thread is started. It is - generated from *within* the new thread's thread-proc (for TLS - reasons). + generated from *within* the new thread's thread-proc (because + it needs to access data in the thread's thread-local storage). + ------------ { @@ -698,7 +698,7 @@ The "exec_id" field is a command-unique id and is only useful if the `"thread_exit"`:: This event is generated when a thread exits. It is generated - from *within* the thread's thread-proc (for TLS reasons). + from *within* the thread's thread-proc. + ------------ { @@ -1206,7 +1206,7 @@ worked on 508 items at offset 2032. Thread "th04" worked on 508 items at offset 508. + This example also shows that thread names are assigned in a racy manner -as each thread starts and allocates TLS storage. +as each thread starts. Config (def param) Events:: diff --git a/trace2.c b/trace2.c index 0c0a11e07d5..c1244e45ace 100644 --- a/trace2.c +++ b/trace2.c @@ -52,7 +52,7 @@ static struct tr2_tgt *tr2_tgt_builtins[] = * Force (rather than lazily) initialize any of the requested * builtin TRACE2 targets at startup (and before we've seen an * actual TRACE2 event call) so we can see if we need to setup - * the TR2 and TLS machinery. + * private data structures and thread-local storage. * * Return the number of builtin targets enabled. */ diff --git a/trace2.h b/trace2.h index 88d906ea830..af3c11694cc 100644 --- a/trace2.h +++ b/trace2.h @@ -73,8 +73,7 @@ void trace2_initialize_clock(void); /* * Initialize TRACE2 tracing facility if any of the builtin TRACE2 * targets are enabled in the system config or the environment. - * This includes setting up the Trace2 thread local storage (TLS). - * Emits a 'version' message containing the version of git + * This emits a 'version' message containing the version of git * and the Trace2 protocol. * * This function should be called from `main()` as early as possible in @@ -302,7 +301,8 @@ void trace2_exec_result_fl(const char *file, int line, int exec_id, int code); /* * Emit a 'thread_start' event. This must be called from inside the - * thread-proc to set up the trace2 TLS data for the thread. + * thread-proc to allow the thread to create its own thread-local + * storage. * * Thread names should be descriptive, like "preload_index". * Thread names will be decorated with an instance number automatically. @@ -315,8 +315,8 @@ void trace2_thread_start_fl(const char *file, int line, /* * Emit a 'thread_exit' event. This must be called from inside the - * thread-proc to report thread-specific data and cleanup TLS data - * for the thread. + * thread-proc so that the thread can access and clean up its + * thread-local storage. */ void trace2_thread_exit_fl(const char *file, int line); diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c index 7da94aba522..8d2182fbdbb 100644 --- a/trace2/tr2_tls.c +++ b/trace2/tr2_tls.c @@ -69,9 +69,9 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void) ctx = pthread_getspecific(tr2tls_key); /* - * If the thread-proc did not call trace2_thread_start(), we won't - * have any TLS data associated with the current thread. Fix it - * here and silently continue. + * If the current thread's thread-proc did not call + * trace2_thread_start(), then the thread will not have any + * thread-local storage. Create it now and silently continue. */ if (!ctx) ctx = tr2tls_create_self("unknown", getnanotime() / 1000); diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h index a90bd639d48..1297509fd23 100644 --- a/trace2/tr2_tls.h +++ b/trace2/tr2_tls.h @@ -3,6 +3,12 @@ #include "strbuf.h" +/* + * Notice: the term "TLS" refers to "thread-local storage" in the + * Trace2 source files. This usage is borrowed from GCC and Windows. + * There is NO relation to "transport layer security". + */ + /* * Arbitry limit for thread names for column alignment. */ @@ -17,9 +23,7 @@ struct tr2tls_thread_ctx { }; /* - * Create TLS data for the current thread. This gives us a place to - * put per-thread data, such as thread start time, function nesting - * and a per-thread label for our messages. + * Create thread-local storage for the current thread. * * We assume the first thread is "main". Other threads are given * non-zero thread-ids to help distinguish messages from concurrent @@ -35,7 +39,7 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name, uint64_t us_thread_start); /* - * Get our TLS data. + * Get the thread-local storage pointer of the current thread. */ struct tr2tls_thread_ctx *tr2tls_get_self(void); @@ -45,7 +49,7 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void); int tr2tls_is_main_thread(void); /* - * Free our TLS data. + * Free the current thread's thread-local storage. */ void tr2tls_unset_self(void); @@ -81,12 +85,12 @@ uint64_t tr2tls_region_elasped_self(uint64_t us); uint64_t tr2tls_absolute_elapsed(uint64_t us); /* - * Initialize the tr2 TLS system. + * Initialize thread-local storage for Trace2. */ void tr2tls_init(void); /* - * Free all tr2 TLS resources. + * Free all Trace2 thread-local storage resources. */ void tr2tls_release(void); From patchwork Thu Oct 20 18:28:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13013932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1FCFC433FE for ; Thu, 20 Oct 2022 18:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbiJTS2X (ORCPT ); Thu, 20 Oct 2022 14:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbiJTS2R (ORCPT ); Thu, 20 Oct 2022 14:28:17 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9861F524D for ; Thu, 20 Oct 2022 11:28:15 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso3139015wma.1 for ; Thu, 20 Oct 2022 11:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=bkJEMJFGS4hSCnUT3RbeMHEA6CGfHK7Uqd4sKFLXPuo=; b=R88CEdwwl9lu+hMckfG3e9Z8qXt0w1fuG7ekQpqDQRv1vzFOBuXrJuDYXkp/QBkQB1 UWjaIG+dsRP3tX00pDCfvFkE/1UtdVbL0VUVdzPd8yvVykvLdmbsInQ04IfDt6PJ+eg/ ZbWUNWa290lL+Jt2HUwmCd+bRZQTWyTwIBoQBw8X98r7RoXNVb3UUvYp94ErpQMb8v7V 7xGSHihkwD78X3+XZ1k3wS/6uUcSE4jhTl2Fr4tEbitxH4Y80jN0vSLhcQIlqtUJm1GW n1JYbtV+REYwMeDCHwMVgUot97L2I0zZzJQGZ3rL28HflEu1qf9eYvOZ2OI58+31Ng1d Ma6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bkJEMJFGS4hSCnUT3RbeMHEA6CGfHK7Uqd4sKFLXPuo=; b=MlRGvhQLDJiTEfNv9GxTsCYpl/gyV0k7IBRMZBSVlEIX/eHu4HTmstshM0kGx5xccd SFhuh7xMwPmsLyyVobabuGMz9mPtnG2O98zLKhSzaaraAP60Kaw36xfGfmUDZfrP2fBa QjXerouyYL1eSo4+oue38IUUIDwzMbbBktl6keLNZSxE9vL2k7CEQFGkeHak1+dkETLG g/7CgNS+s6q9EnXqW5Nx8wBDrFijrUkR6iJu1qKDbvIR6dqDPAR/RFkC6varA9pGF1Az UemwA2woTvXVqzz/nCU1eAsuY1GOK4keLJcOB1V+6pWU35zj8NvG7kbPC/Dt1reKXtIi Ux5g== X-Gm-Message-State: ACrzQf0DqQ5o6iDbh46l+uLyyOfFCKxiIc60ZRa2TapyLuXXo9K2PkBB wmslu8mD5dLPcinDx6zk5eUd52RKkCk= X-Google-Smtp-Source: AMsMyM5iu8/zD3vS0GP83H3vRikzxtgOLuKs0OaFCkvi/1Ve6sTxdNSRDuuHHhZD5N8OM6Yv3PtZcw== X-Received: by 2002:a05:600c:4ec6:b0:3c6:c469:d295 with SMTP id g6-20020a05600c4ec600b003c6c469d295mr31498211wmq.117.1666290493953; Thu, 20 Oct 2022 11:28:13 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z9-20020a5d44c9000000b0022917d58603sm17227473wrr.32.2022.10.20.11.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:28:13 -0700 (PDT) Message-Id: <804dab9e1a7fa1cea9355bac92ada16332f1194e.1666290489.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 20 Oct 2022 18:28:04 +0000 Subject: [PATCH v3 3/8] api-trace2.txt: elminate section describing the public trace2 API Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Eliminate the mostly obsolete `Public API` sub-section from the `Trace2 API` section in the documentation. Strengthen the referral to `trace2.h`. Most of the technical information in this sub-section was moved to `trace2.h` in 6c51cb525d (trace2: move doc to trace2.h, 2019-11-17) to be adjacent to the function prototypes. The remaining text wasn't that useful by itself. Furthermore, the text would need a bit of overhaul to add routines that do not immediately generate a message, such as stopwatch timers. So it seemed simpler to just get rid of it. Signed-off-by: Jeff Hostetler --- Documentation/technical/api-trace2.txt | 61 +++----------------------- 1 file changed, 7 insertions(+), 54 deletions(-) diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt index 431d424f9d5..9d43909d068 100644 --- a/Documentation/technical/api-trace2.txt +++ b/Documentation/technical/api-trace2.txt @@ -148,20 +148,18 @@ filename collisions). == Trace2 API -All public Trace2 functions and macros are defined in `trace2.h` and -`trace2.c`. All public symbols are prefixed with `trace2_`. +The Trace2 public API is defined and documented in `trace2.h`; refer to it for +more information. All public functions and macros are prefixed +with `trace2_` and are implemented in `trace2.c`. There are no public Trace2 data structures. The Trace2 code also defines a set of private functions and data types in the `trace2/` directory. These symbols are prefixed with `tr2_` -and should only be used by functions in `trace2.c`. +and should only be used by functions in `trace2.c` (or other private +source files in `trace2/`). -== Conventions for Public Functions and Macros - -The functions defined by the Trace2 API are declared and documented -in `trace2.h`. It defines the API functions and wrapper macros for -Trace2. +=== Conventions for Public Functions and Macros Some functions have a `_fl()` suffix to indicate that they take `file` and `line-number` arguments. @@ -172,52 +170,7 @@ take a `va_list` argument. Some functions have a `_printf_fl()` suffix to indicate that they also take a `printf()` style format with a variable number of arguments. -There are CPP wrapper macros and `#ifdef`s to hide most of these details. -See `trace2.h` for more details. The following discussion will only -describe the simplified forms. - -== Public API - -All Trace2 API functions send a message to all of the active -Trace2 Targets. This section describes the set of available -messages. - -It helps to divide these functions into groups for discussion -purposes. - -=== Basic Command Messages - -These are concerned with the lifetime of the overall git process. -e.g: `void trace2_initialize_clock()`, `void trace2_initialize()`, -`int trace2_is_enabled()`, `void trace2_cmd_start(int argc, const char **argv)`. - -=== Command Detail Messages - -These are concerned with describing the specific Git command -after the command line, config, and environment are inspected. -e.g: `void trace2_cmd_name(const char *name)`, -`void trace2_cmd_mode(const char *mode)`. - -=== Child Process Messages - -These are concerned with the various spawned child processes, -including shell scripts, git commands, editors, pagers, and hooks. - -e.g: `void trace2_child_start(struct child_process *cmd)`. - -=== Git Thread Messages - -These messages are concerned with Git thread usage. - -e.g: `void trace2_thread_start(const char *thread_name)`. - -=== Region and Data Messages - -These are concerned with recording performance data -over regions or spans of code. e.g: -`void trace2_region_enter(const char *category, const char *label, const struct repository *repo)`. - -Refer to trace2.h for details about all trace2 functions. +CPP wrapper macros are defined to hide most of these details. == Trace2 Target Formats From patchwork Thu Oct 20 18:28:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13013931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7A63C4332F for ; Thu, 20 Oct 2022 18:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbiJTS2W (ORCPT ); Thu, 20 Oct 2022 14:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbiJTS2Q (ORCPT ); Thu, 20 Oct 2022 14:28:16 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8921F525C for ; Thu, 20 Oct 2022 11:28:15 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v1so387830wrt.11 for ; Thu, 20 Oct 2022 11:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=fAlOJTg6iT9VRZtrwsV4BCzjxR+22dkEdOuKsnNwhMw=; b=pRwmkPqo9ULtGpbEeAegCys3OOmCjaDZJyADH2KQUSWWmyQ8G3ft6G0vFuyNHhJyhm PGlAtFlefWu838cA8RR2tmbq/tERHFRmpgxGbfIvr47DzMaEzJ6vnbNoiN7jdXEgnx2C FBXBUyWmDzvzUF2UFsa78wtqC+V/CJXbb7lKQmKUKzXj/j4XMzY7YlH5OiGrKoIuJKIm x+cKuE9HmEQlRmEnJrk1OMpYQsq7IDqnk9NaC1cA4Bl82WFHRv4sd931rgN79ERtzbZZ mK77IPYLtBKuBk20fwRogrYSGyj41A2k65rnItTBY8tCsoMVk3W0by2ac6/a3cmC82vR IybA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fAlOJTg6iT9VRZtrwsV4BCzjxR+22dkEdOuKsnNwhMw=; b=d2p7aGe0rXIP0vByzrc2sJnIy8yVUW6F1nNbXulpZtBKbnMhGaSlFRoQHwA2HeS7bc uJ5+vyEcVPg1cAeSIKvwfQttRzz8FogXnpD/qGmjKhvloR4IH3kAVFbt6VO7tEj+rVRN uAQjyXjvZUPVWKr5Pk1eohKG5BMN+ZoBVYYj98L2VTJi4TzueJhDAAc2wK36XRU89R47 vtWaMZoQK+g12yXPrh0kjjJPilX28my9yl2u4CbkyE5GvXtIVmeRo2QzHBFaVFsfzY+1 I1iqHXJqVU8JR6FoAZctOmJnmppHdiONmQkXTFptE9UM7XxS9Y25Ued3v3xLo5QuHWRi RRvw== X-Gm-Message-State: ACrzQf1kdXH+B3H1mPDHoBXWNwOJPaTYkNbL5gEz/2T335PXGyBTCrL4 EDfnX2zPjO8Ny75a6SLzR9Rl3AgykZ0= X-Google-Smtp-Source: AMsMyM49Hgh/hJfU55pi/LgbLJNBymd4cxdOOpuSjh9DCj+SQ/hjzBf7iDIe927OjO3BhdxB4bjOdg== X-Received: by 2002:a05:6000:1565:b0:22f:1407:9bfd with SMTP id 5-20020a056000156500b0022f14079bfdmr9517859wrz.620.1666290494879; Thu, 20 Oct 2022 11:28:14 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s9-20020adfdb09000000b0022cc6b8df5esm3484466wri.7.2022.10.20.11.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:28:14 -0700 (PDT) Message-Id: <9adf9cee1a96211cc4c2a305997079c7d6492aea.1666290489.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 20 Oct 2022 18:28:05 +0000 Subject: [PATCH v3 4/8] trace2: rename the thread_name argument to trace2_thread_start Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Rename the `thread_name` argument in `tr2tls_create_self()` and `trace2_thread_start()` to be `thread_base_name` to make it clearer that the passed argument is a component used in the construction of the actual `struct tr2tls_thread_ctx.thread_name` variable. The base name will be used along with the thread id to create a unique thread name. This commit does not change how the `thread_name` field is allocated or stored within the `tr2tls_thread_ctx` structure. Signed-off-by: Jeff Hostetler --- trace2.c | 6 +++--- trace2.h | 11 ++++++----- trace2/tr2_tls.c | 4 ++-- trace2/tr2_tls.h | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/trace2.c b/trace2.c index c1244e45ace..165264dc79a 100644 --- a/trace2.c +++ b/trace2.c @@ -466,7 +466,7 @@ void trace2_exec_result_fl(const char *file, int line, int exec_id, int code) file, line, us_elapsed_absolute, exec_id, code); } -void trace2_thread_start_fl(const char *file, int line, const char *thread_name) +void trace2_thread_start_fl(const char *file, int line, const char *thread_base_name) { struct tr2_tgt *tgt_j; int j; @@ -488,14 +488,14 @@ void trace2_thread_start_fl(const char *file, int line, const char *thread_name) */ trace2_region_enter_printf_fl(file, line, NULL, NULL, NULL, "thread-proc on main: %s", - thread_name); + thread_base_name); return; } us_now = getnanotime() / 1000; us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - tr2tls_create_self(thread_name, us_now); + tr2tls_create_self(thread_base_name, us_now); for_each_wanted_builtin (j, tgt_j) if (tgt_j->pfn_thread_start_fl) diff --git a/trace2.h b/trace2.h index af3c11694cc..74cdb1354f7 100644 --- a/trace2.h +++ b/trace2.h @@ -304,14 +304,15 @@ void trace2_exec_result_fl(const char *file, int line, int exec_id, int code); * thread-proc to allow the thread to create its own thread-local * storage. * - * Thread names should be descriptive, like "preload_index". - * Thread names will be decorated with an instance number automatically. + * The thread base name should be descriptive, like "preload_index" or + * taken from the thread-proc function. A unique thread name will be + * created from the given base name and the thread id automatically. */ void trace2_thread_start_fl(const char *file, int line, - const char *thread_name); + const char *thread_base_name); -#define trace2_thread_start(thread_name) \ - trace2_thread_start_fl(__FILE__, __LINE__, (thread_name)) +#define trace2_thread_start(thread_base_name) \ + trace2_thread_start_fl(__FILE__, __LINE__, (thread_base_name)) /* * Emit a 'thread_exit' event. This must be called from inside the diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c index 8d2182fbdbb..4f7c516ecb6 100644 --- a/trace2/tr2_tls.c +++ b/trace2/tr2_tls.c @@ -31,7 +31,7 @@ void tr2tls_start_process_clock(void) tr2tls_us_start_process = getnanotime() / 1000; } -struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name, +struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_base_name, uint64_t us_thread_start) { struct tr2tls_thread_ctx *ctx = xcalloc(1, sizeof(*ctx)); @@ -50,7 +50,7 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name, strbuf_init(&ctx->thread_name, 0); if (ctx->thread_id) strbuf_addf(&ctx->thread_name, "th%02d:", ctx->thread_id); - strbuf_addstr(&ctx->thread_name, thread_name); + strbuf_addstr(&ctx->thread_name, thread_base_name); if (ctx->thread_name.len > TR2_MAX_THREAD_NAME) strbuf_setlen(&ctx->thread_name, TR2_MAX_THREAD_NAME); diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h index 1297509fd23..d4e725f430b 100644 --- a/trace2/tr2_tls.h +++ b/trace2/tr2_tls.h @@ -35,7 +35,7 @@ struct tr2tls_thread_ctx { * In this and all following functions the term "self" refers to the * current thread. */ -struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name, +struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_base_name, uint64_t us_thread_start); /* From patchwork Thu Oct 20 18:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13013933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B72A6C4332F for ; Thu, 20 Oct 2022 18:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbiJTS2e (ORCPT ); Thu, 20 Oct 2022 14:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbiJTS2T (ORCPT ); Thu, 20 Oct 2022 14:28:19 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFBB1F524D for ; Thu, 20 Oct 2022 11:28:17 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id i9so450611wrv.5 for ; Thu, 20 Oct 2022 11:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=yg+qRN/8CZOKtoU9cC0Yaehgw+i7SS3ddOvwOaR7iUQ=; b=dhb1TN4ImfwH+3hJtMyOcdYf3icuakHd3Fz2aYeA2vmOywrZFlxafFSqRftG9OezSO eOcyeDrxG/FyjYTwxHDA/MrL6NnUh/6gy4cZs/R14uOrw4fCeciSMFdrGbejOJ4YJO85 VGlEiF54293r17Cj4qXXG6PAx8onijnIuSz5DhKVpilXtZ14FC2QK59euJ9oDx9xaWzv ynzTYPIlWclqSgIDlFHU94Kmw/89kyUwDFDJshEjX1VJAEgBiyVnoNZFgXgny312rJto 4oPF9GFA6Js02FnL4eKMq0eriLbGICEeXtcCnrUHXXbGSeJvXoIk95/HlaxWgp/u+3+L 8yLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yg+qRN/8CZOKtoU9cC0Yaehgw+i7SS3ddOvwOaR7iUQ=; b=NW6eLna11C+yQq3EcofEtN2YIzTLit7fyq7Ps4K40BAt1EVSl9JZC6i3b3MqVhSv5B dRA6MabNPrVNKH31VzKIDiBjM47aFtV6KcJiLgu0EvH/rB/rEHgUytWqZN1D3Y5RAKU2 uXKrdkY3uO9UOLxH0cl+Omt1TlJQOUUCoR2bbiwKQ2e8PMf7LrHVBqNyXQWlekBrNaMU EJwDa48gk52vAwdUm6wvKjLw7bCPKnu8v9WXJA+rJIuDonN+auxPmON1F9feQhvAY761 TNdcZ3ztXNAEAoSrNIPZpaQC0yHVbImKQzlD5N9+MVQ1rHPtAbMCZjruTEYPn0bcaR7/ t1fQ== X-Gm-Message-State: ACrzQf36rJmSXcN4U/17knZ9MsfnQdDwWmonccaaNTsfG5DxSabNtp3e dHL8k1Wo1xMzNOD+/fAe33wu7p326p8= X-Google-Smtp-Source: AMsMyM7nh4T6Lzwx58qWcjsNSL9Q0IABTBZkfvlmhLi5Rh3TPEe04dtL7+5nF461pv7y/nId9sWr1g== X-Received: by 2002:a5d:4b11:0:b0:22e:3af9:c754 with SMTP id v17-20020a5d4b11000000b0022e3af9c754mr9281163wrq.206.1666290495745; Thu, 20 Oct 2022 11:28:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bi19-20020a05600c3d9300b003c6bd91caa5sm353436wmb.17.2022.10.20.11.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:28:15 -0700 (PDT) Message-Id: <8cb206b76323e14d8e07f6cfb5aa482a47eb54c5.1666290489.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 20 Oct 2022 18:28:06 +0000 Subject: [PATCH v3 5/8] trace2: improve thread-name documentation in the thread-context Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Improve the documentation of the tr2tls_thread_ctx.thread_name field and its relation to the tr2tls_thread_ctx.thread_id field. Signed-off-by: Jeff Hostetler --- trace2/tr2_tls.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h index d4e725f430b..7d1f03a2ea6 100644 --- a/trace2/tr2_tls.h +++ b/trace2/tr2_tls.h @@ -25,12 +25,15 @@ struct tr2tls_thread_ctx { /* * Create thread-local storage for the current thread. * - * We assume the first thread is "main". Other threads are given - * non-zero thread-ids to help distinguish messages from concurrent - * threads. - * - * Truncate the thread name if necessary to help with column alignment - * in printf-style messages. + * The first thread in the process will have: + * { .thread_id=0, .thread_name="main" } + * Subsequent threads are given a non-zero thread_id and a thread_name + * constructed from the id and a thread base name (which is usually just + * the name of the thread-proc function). For example: + * { .thread_id=10, .thread_name="th10fsm-listen" } + * This helps to identify and distinguish messages from concurrent threads. + * The ctx.thread_name field is truncated if necessary to help with column + * alignment in printf-style messages. * * In this and all following functions the term "self" refers to the * current thread. From patchwork Thu Oct 20 18:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13013934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 262E8C433FE for ; Thu, 20 Oct 2022 18:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbiJTS2g (ORCPT ); Thu, 20 Oct 2022 14:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbiJTS2U (ORCPT ); Thu, 20 Oct 2022 14:28:20 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784351F5263 for ; Thu, 20 Oct 2022 11:28:18 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id j7so478987wrr.3 for ; Thu, 20 Oct 2022 11:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=49A0L1wMbmU0RvsqsmDPtIsptTiM40AWpEgBd9ZjT4Y=; b=lI5jqdCSD0SZ0skzA3+nC/K9c1iq49so+jfUKK//ECEjne4+Yc2xrxZp27hZVjDiET a8eKpgAwUkL1dsTTRtUFWHxdqIfsNMXFW9ReSKJwoNVh8OFBuX2E1Eo8Sm9revjJB4ml T+ludZqp5uk1Ybvplm3Zo6beaCFpDD6Cd3JZ/IBIreB9ASRMCCWJv/6QlVFz+8MgLnZV uDXBAAfN/hzamM+Ts1trVYYPHQCw1dwIEqRAk8tv68wcFrVrQe7e5G51en/HTEJv8eC6 bz/HUgokF+rvfupgPQP0Brz09FGgBsgN7Rnd1OBBuNAlNcGjlaXbLhvXFi0S17RQsrzo YUEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=49A0L1wMbmU0RvsqsmDPtIsptTiM40AWpEgBd9ZjT4Y=; b=t1ICD02ZCjrIJNOMfcqC52HayB4brdePUTEENZTqf0K2BR2dEvTh3uNdlE4wT8BW0i TPQRG47tVg332/RVpFYf9gSItalAiXng3cLDG1z3RmPR6Tr7Kq3h2hN0F/ud98P5kQgE 55xvVwatF4XO4aQnH8bPKcWIcGrAuUPynliS9f7uF3MG3/85ifDQ6kp+2e+IaRP6Mzr3 Mi0iaMm8TXIULMUDhd6xWzRERcprvz90oqgF8qO6BHY4Tu5+w/Ny4rBD8h/IGpVEhMwM OGksdGwvkbd4Fy0U9tqpmi/AmcRiBdG2vYm4s0QouzUjaahQ/uLkH3AbClpV3PZLQFuR 7Bag== X-Gm-Message-State: ACrzQf0oDr90gBBXHEQMp3k/mtIK8UR+8hQUIYVePMxQPF9wlL4zyKKh BcFXSv9KPpsn6yx8SOyIfl7E0UWN4k4= X-Google-Smtp-Source: AMsMyM5oMDLEiqWshullOADthCszy4CUufJA3AxAyIwJSiZVir/ywMWggNOu3BPtdc2vJJY/rlDiBA== X-Received: by 2002:adf:d228:0:b0:22e:488d:758f with SMTP id k8-20020adfd228000000b0022e488d758fmr9236394wrh.445.1666290496592; Thu, 20 Oct 2022 11:28:16 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v1-20020adfedc1000000b00228daaa84aesm17220295wro.25.2022.10.20.11.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:28:16 -0700 (PDT) Message-Id: <8a89e1aa238bff874f3fa9a414781e4abc03c526.1666290489.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 20 Oct 2022 18:28:07 +0000 Subject: [PATCH v3 6/8] trace2: convert ctx.thread_name from strbuf to pointer Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Convert the `tr2tls_thread_ctx.thread_name` field from a `strbuf` to a "const char*" pointer. The `thread_name` field is a constant string that is constructed when the context is created. Using a (non-const) `strbuf` structure for it caused some confusion in the past because it implied that someone could rename a thread after it was created. That usage was not intended. Change it to a const pointer to make the intent more clear. Signed-off-by: Jeff Hostetler --- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_perf.c | 2 +- trace2/tr2_tls.c | 16 +++++++++------- trace2/tr2_tls.h | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c index 37a3163be12..52f9356c695 100644 --- a/trace2/tr2_tgt_event.c +++ b/trace2/tr2_tgt_event.c @@ -90,7 +90,7 @@ static void event_fmt_prepare(const char *event_name, const char *file, jw_object_string(jw, "event", event_name); jw_object_string(jw, "sid", tr2_sid_get()); - jw_object_string(jw, "thread", ctx->thread_name.buf); + jw_object_string(jw, "thread", ctx->thread_name); /* * In brief mode, only emit