From patchwork Mon Oct 24 13:41:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13017697 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 5267CC38A2D for ; Mon, 24 Oct 2022 15:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbiJXPGf (ORCPT ); Mon, 24 Oct 2022 11:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbiJXPGO (ORCPT ); Mon, 24 Oct 2022 11:06:14 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E1E0B2750 for ; Mon, 24 Oct 2022 06:43:04 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 186-20020a1c02c3000000b003c6c154d528so9980089wmc.4 for ; Mon, 24 Oct 2022 06:43:04 -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=ZkUJrCIKvThAgKZGz5Nmk5tYp7f9bDPfsqQ9duzNt3+A1hF45mQJJjC2cDr+dqRtnB C4smfHnANACxUZB5hjiybJWgyPCH6aIqRbc0nMtQfvNMYakU/KD4aRNaFbqVb1NsKX74 lNYKW6ajphcp6Ftiq0N5VrrxfGLgUTZHshZIIVfUYf+s9aKzg3cEQrAolqlzNXr5KF5f W7yZbxiS6Rqevf6zw1qRPpjIWDe5lDpqCRG0IXXIX/YbssJCnAqpT2pOIrabkF+47Ev5 TWYiLjSMeCE43ohh9muWEKGexpFSoY7l+FatVOeiCaUid78G1ihsyrCed+HBb7RdNdDM rqrQ== 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=PwVkE0n1QiEx8nGiBKQEc64hc/NDN+JrPWeleg5nwCYTgn6EGVHKtSrtkJtAUOrap/ NpO0b5f5alVTwffilnGDBDu6aC/Td+qkcoNMYKNGDyxe0QoFrVXYDc6U/bl2hOUBaWLh mjHSTClABNxPQVOqM19LA4z1bTEy9ATdmcGkGoHgx9jrzoYOjqaydO1Ds7flZrV4N42F yg6EmAzFMkpgCzhtcptIm/Mbpiv6a0U21ab7EePUEHCtm94nRnKKHXjd7DGMEbVgP/fV Yh8rZ3d5Q0J/cDHzOoCaTXoJ74zLXIXcvmAHMq9hbJ285s8+c3rpy2mG6Ne8L8uVqrjl gkuw== X-Gm-Message-State: ACrzQf2M7tIYNKvRnx+OKemHpLEuPZ+0VaBUYYFhXNUiR3Y/dcuJMzw9 vBg5nOcVc2Q1B52ASpHNaS1wbilXTEE= X-Google-Smtp-Source: AMsMyM7im5GoFoBIJdsiw8pShtTgSWYWgWQOWbMbRmeQxS8NnTCH8Ab2BOzlWJ/H2ZYS0fgl4TAyag== X-Received: by 2002:a05:600c:224c:b0:3c6:ec76:89bd with SMTP id a12-20020a05600c224c00b003c6ec7689bdmr33869665wmm.74.1666618870976; Mon, 24 Oct 2022 06:41:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m64-20020a1c2643000000b003c5490ed8a6sm8329976wmm.8.2022.10.24.06.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:41:10 -0700 (PDT) Message-Id: <6e7e4f3187e2fbbbb54bb1cf5793bf6e981a5a94.1666618868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 24 Oct 2022 13:41:00 +0000 Subject: [PATCH v4 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 Mon Oct 24 13:41:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13017702 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 444BCC38A2D for ; Mon, 24 Oct 2022 15:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232670AbiJXPQQ (ORCPT ); Mon, 24 Oct 2022 11:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiJXPPs (ORCPT ); Mon, 24 Oct 2022 11:15:48 -0400 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1791FCC1 for ; Mon, 24 Oct 2022 06:54:40 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id m29-20020a05600c3b1d00b003c6bf423c71so10056859wms.0 for ; Mon, 24 Oct 2022 06:54:39 -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=J4Hp+A2g1RUZcYIYSEwBU5j2Qdt8Iuv+RbfvwYk9w7X9W7hbz/qU67j0uH4l/4u8o3 IwhNrYhdc/PuWP7VFKoyq/k3zwJjyYsa6Splp5FrbEZx2RZoDJxuco9KxFU+G2A1IXL+ Z1sUiPOkawQMPW6NWtPRp3U3w+m6wfEBzLObP0EX+VmCu7/HvuaeMvq07L0KoRM672uR uOg6Rfk3yg9/SMOyxJrsJlvrAy0g5YdCeczhfHWXu4sRJrwR1pP6fRKheipWz6CYunhj ktl7ukMVtq8y9ofEgnTLd5dAvKu3pZUS1c9QftWqqB4XiITkpfQSEeSK+ye738RnfoNl GdEA== 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=rPX2aFtOybZKbOj8miF2TToy/wJfYlR8NW6ArtEaAU2C6j3R08AR7vJJnajnJzoT5h hWcwZJiu5JECv2oNwTb8JxPeFEsRyADjXKCJvJzfRNrwAN7AxKYv+6ryUAeb+/bXroa1 4MoQ1w26Nge5suWNigCP80h1jfKoq7DitjfsBMc8tslMuWKVVpwlAMXSpKgqEQIp6Tqf akjFOdbFoPs5I6OYoF9Go4MccHxc4QMHH8jmFyOegzrWf0e2FaavoCO58HHKPUYejJia XYHZhC/eyqCGgBfQj3DkgCdQuVquG/ea8E2n5nCr0h4PXVHDTvu0+fo975Bl2VezYhqH ktdg== X-Gm-Message-State: ACrzQf0X8SnG752OcQhbW7D3123K6d72iuC48WFX2cQEmbdpLXCI6lfp wfEqYtelo8t2/9DGDhml7kiIgrfLENs= X-Google-Smtp-Source: AMsMyM5gwZ9uh5EoRRAj7lp9TctpykVX/fuROLSZDHRKXY3DLziBz+AbET4IfI1QPHW0SveUiBdu9A== X-Received: by 2002:a1c:5446:0:b0:3c4:1854:abc0 with SMTP id p6-20020a1c5446000000b003c41854abc0mr22908279wmi.7.1666618872039; Mon, 24 Oct 2022 06:41:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y15-20020a056000108f00b0023647841c5bsm11166657wrw.60.2022.10.24.06.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:41:11 -0700 (PDT) Message-Id: <9dee7a75903936f086d97580441c776978d70b43.1666618868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 24 Oct 2022 13:41:01 +0000 Subject: [PATCH v4 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 Mon Oct 24 13:41: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: 13017698 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 3B579C38A2D for ; Mon, 24 Oct 2022 15:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232120AbiJXPG6 (ORCPT ); Mon, 24 Oct 2022 11:06:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbiJXPG0 (ORCPT ); Mon, 24 Oct 2022 11:06:26 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63778152C47 for ; Mon, 24 Oct 2022 06:43:20 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id r8-20020a1c4408000000b003c47d5fd475so9996177wma.3 for ; Mon, 24 Oct 2022 06:43:20 -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=fHEK8FggXuUTfir1aMCJU4QUFfXTz86H8pGNq8jQQF+xb5Qg8EibNXnEp1C06N8kTG CFfAycSpd+RaWqlzM9RtrgxtDYyOTduj6oIamd++J0JEJBaXuxGowFg9RhPqDUSOc1hT HvZhYYJGgW9VJ9iivKPKSHqY6h0Sm5dHguoIlF5onuN31MySGalSILfd4XsBthxLvd4v 00dinxEVe99R5ah55LYvFuSqK39u7fHU86BWG/xX8mK6pIaad9nuESmwmwX+yl0AZ9w4 Bl1ak+vp7MvF/DKn4Qry5NHY/LNd1OsLFeCuigHeQNV1rXjZApz6bwjRz6WjJL3tgBxW xeeg== 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=wDvQFFidxUthof2jZfItKZvPTyu4r0lpS+zQo4TOJIJEnKEKDLwDM4/U69ffFX31/s awvyDBn98Wku1GnEJSVGBCAPwpfjkqPBZa1Qtw4Vtk2i2G157eI6l257YMoVcl/OjTu/ SOpWSSfilJvrHl5g/HoMolaqoUnhUCKF/YXlJfmVlZbb7HvSPuTZkRQPlMLkS3NhCeCC QrbWJXgzXtX4HXTYzYy5SSPR2xGaOjgdoF56QyFpxbrxCCaJ7xyX0snxoF4JEqqeVyhx MKNTmyCqnMuW9N7kDyZMeRg1xso0AONDgrMZZAYDrmn2VfJWmv1SYBs34BqtNgI7aq71 jXog== X-Gm-Message-State: ACrzQf3kHMM0PXKmIAIBUJ6fRBazsTo7Sblv5K90HJ9l7qOaVao/ysNx oRnzLelpOglFEDJ0NjP3vQHLKc7g3iA= X-Google-Smtp-Source: AMsMyM72ecd8DJjq63fkXAxi9irqlYJxcqD4++evPSnUDzva70tGsQMyHjh7P4ef9XEnkML3RcrEbg== X-Received: by 2002:a05:600c:3556:b0:3ca:771d:701a with SMTP id i22-20020a05600c355600b003ca771d701amr7515134wmq.61.1666618872861; Mon, 24 Oct 2022 06:41:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f8-20020a0560001b0800b0023677fd2657sm1472184wrz.52.2022.10.24.06.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:41:12 -0700 (PDT) Message-Id: <804dab9e1a7fa1cea9355bac92ada16332f1194e.1666618868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 24 Oct 2022 13:41:02 +0000 Subject: [PATCH v4 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 Mon Oct 24 13:41: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: 13017973 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 7C757ECAAA1 for ; Mon, 24 Oct 2022 18:53:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbiJXSxE (ORCPT ); Mon, 24 Oct 2022 14:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232927AbiJXSwh (ORCPT ); Mon, 24 Oct 2022 14:52:37 -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 7A5FC20C9BE for ; Mon, 24 Oct 2022 10:34:06 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id y10so7030186wma.0 for ; Mon, 24 Oct 2022 10:34:05 -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=EB4XNIYz4vqYdXDDGalCAQGA2yGeOKCtOjmcShBgxLzj1RQn6iSaRQUI5ahw1KPiYx Lnol9UzLubsDX2+0I35h8r0nG4pHHsEEE0asMoQBOwxtfeVVl6bHBC1/X2yb+dYlaucf FlangIHTEwUbTRanfCL02HbMcZO5wpAKffBx+EnDv9jSTwquPK4hlp36ew/HagHnLRQn a/XgeGty8W6GOTlIRVSAkj56ohCmx+CZk19Oi9utMQi8bPib3iEBi+3yQ+xr8pYBlMYS Vb9fj7rJ6jr8yll/ZWsgk4y7qb0F884fq6Xppl5SUn0Y0nG1bYRIkf1MsbCdvxFPsCAq dWFQ== 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=5sG2Xjj0nL0C7ymGnRlHQMxxnKKvvdK3bgIUa4Ysn0FDBxBsyCtvZOWABkz28/2qkY XUb4fax/qrtxZmVdNoYK/u0+ZWbLDvx5Yep9IH1xL33l2vjGVBiGOYakuGwZAKQk75Lq JBZJKEG2bh5pIzU1lYiHAGj7xRKlPEuVfC49TVogl4nhguX/hjXly6/2m8kWuOkiQdn0 tDK7+RJkjZ5UhR6UXJauCHkKhpKPmXa1wpmbPyIj4tWKt5Ru8uRrs3fQKA9LMTfTkcwj /nAO05Jtbl72YbTgVuGCZbuRXkjwE9Ozi2t+3pJ3rBwhx733C9kEWMaGDunefQjMJBO3 Y9ZA== X-Gm-Message-State: ACrzQf2iPxO7FBspwvIOTnSH/HBrvqQc8wFYfKFehQPq85IKrAIhwpTs ko4eaoaufANe7BaX2go+iybFCa3LBu8= X-Google-Smtp-Source: AMsMyM5lYyFck0Z/ilIJ7GQj2G4xewn4ReTfWoEpEewidlJHbWdHWrHhFjgiwX9an5mO98DuyBpyog== X-Received: by 2002:a1c:35c9:0:b0:3c3:d9a:385f with SMTP id c192-20020a1c35c9000000b003c30d9a385fmr22089495wma.139.1666618873947; Mon, 24 Oct 2022 06:41:13 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i4-20020a05600011c400b002365cd93d05sm7122157wrx.102.2022.10.24.06.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:41:13 -0700 (PDT) Message-Id: <9adf9cee1a96211cc4c2a305997079c7d6492aea.1666618868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 24 Oct 2022 13:41:03 +0000 Subject: [PATCH v4 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 Mon Oct 24 13:41: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: 13017782 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 7A6EAECAAA1 for ; Mon, 24 Oct 2022 16:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231936AbiJXQUI (ORCPT ); Mon, 24 Oct 2022 12:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231204AbiJXQSs (ORCPT ); Mon, 24 Oct 2022 12:18:48 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56D240E1E for ; Mon, 24 Oct 2022 08:04:32 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id k8so8035751wrh.1 for ; Mon, 24 Oct 2022 08:04:32 -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=hx8MTcO9qtJ2RzEoDcJrkdJfjD3/h3bxqdijd6mxO+Q=; b=Wu0Ktj1aN4WHdtAt6xPmGWiFZXBVapp3KD2XljuEzH8WL/fdp4egKfKM6NICTF6KSV YekVTMlSgyahJMvLJLTo8HQFfb3qKzHeXkLk5xjL/ngaEXBFej9ESwAXb+xSKd6IofD6 9qpf+pReS2tF2wIa4vp9rRm+MG8I1uPxRoYEuZhxa4YxYVQJSPYA8QXXKyf3l8pBb2Ka PQQ8ubZ30vGP9WjsyoHgVPcM/5W1SYZChH8jej1fe38zRZMxJHBZythYcv6SHfBX0MVf 5eAGVu0zgTkQZk7BwpllmLOk6HpxmrXb7j1CrTKga1zcyiuV9AHvFghYyjJe685LQxbT S5EQ== 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=hx8MTcO9qtJ2RzEoDcJrkdJfjD3/h3bxqdijd6mxO+Q=; b=iqv1jLLPOsQPXdIRZkZQkpQ5J2+vU7fUYfDhDRIcvONckAXd5FUbOPOpLKUoUx0AJ+ IQbe0+rpkMXA8AijbtJXtFtj+cSSj82xW3FPu35zDMK5sM48ZuteLFKmiE6zsqBYqhfZ YImMR4BpYOoXYn3i7LWBBVTzW+JQY1D9qfQ0MPMAxZ5K+pOnuYTirky9zA8F+aj9aAAX hf0QYwjOBR8Q15kxXtkMd7VXlTzgl3o6eE9JfbOyNAutoQ59E/NVqMfwu7xDkyWP6njv dbOGPRgj3pnz96ptRbp4x3oUoQqjNwO1TCoUQdgsbaBTAL10tOc+WChrjWGJC2/MNAuJ E1Pw== X-Gm-Message-State: ACrzQf1FMIiaKB0odj9FhEqyg/oR65MM/AxE5txvNmZPdcN3MdZmPOfn YljtyfQDidHwSEogF39ODp71vIiB9Ng= X-Google-Smtp-Source: AMsMyM6YTXMOIBpugJvfnUR8cioYASID1Px7rcx/tNkOlYRNNiGvXPf6Mdo/YNnZyqVdxqagGEycPQ== X-Received: by 2002:adf:e198:0:b0:22e:ab4d:935b with SMTP id az24-20020adfe198000000b0022eab4d935bmr21825517wrb.306.1666618875016; Mon, 24 Oct 2022 06:41:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m22-20020a056000025600b00231ed902a4esm12207238wrz.5.2022.10.24.06.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:41:14 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 24 Oct 2022 13:41:04 +0000 Subject: [PATCH v4 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..3ac4380d829 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="th10:fsm-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 Mon Oct 24 13:41: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: 13017763 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 D61BEFA373F for ; Mon, 24 Oct 2022 16:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233172AbiJXQKh (ORCPT ); Mon, 24 Oct 2022 12:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233745AbiJXQJJ (ORCPT ); Mon, 24 Oct 2022 12:09:09 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9622E9F5 for ; Mon, 24 Oct 2022 07:59:42 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id m29-20020a05600c3b1d00b003c6bf423c71so10191115wms.0 for ; Mon, 24 Oct 2022 07:59:42 -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=t70zD9u4QyJOFLJtAsQtNnnx/aU1oF7oKkTWzJZ/sKw=; b=nCoe0cKjncFUMcEu8yOLvYN/Vce63i/dIvNNFeCznj8BqYJ54QGzOrWNXXB+jTMd7T RqEvvTrNQTmM8SdIQHn9mZoVcb4I77xTYF7MGRDRn4Op93xxAaw6CYgo9fK3HV1T8frs 3h7ML/sUAWiEzPTvPeDbDCE2gcpKEHphYPbf94ycPeYBFcBWbOzh/ZjfOetS6NAGthzV tojDJV9NP4pP8vZ9lXj/8awAsjmfdY8UYp0hZnwek/IEVtxqbnIfKkhdji66ff/xyX/t 4Xvv24oJvVUnYb1TtZrt17MzSUqtLJog/RTU3SGzPSTL2E5AIiIZLqhHOVcPtzBZbenY D+Nw== 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=t70zD9u4QyJOFLJtAsQtNnnx/aU1oF7oKkTWzJZ/sKw=; b=OD4THFFFhZfB1xk94mIiPQ53luysWOUTD8I4JKbXPmrljqe+SXTte8evItOEoN+tit hVRbNMwI6AC4cqgAt+07+ol50m/Gz1gkq14++FGwg3geapVCC2yQekWvgPn/mCmm9ExV H4WznJlYEjAQ8PaGSMTOWoVbM09Oxw6d57M4xBC7KtCKijyeYQJl69lJWgP8HNmXJT99 lamYy7oJdn54XMoQRan81nSFVCdWHZUHVL244JgsKFpYVbok+UpCGt6v0dC22maPzBxP HdFqIZncYWoABUp0SpZRW3ssoCooqUryckiMRDhMEYnvc0NXKElQbzDN/8g0vjhjvgMe 4fQQ== X-Gm-Message-State: ACrzQf2+FqsZtYAzg0J2eUrqwYJONebkVb1Ml3Y9FuCic/KOuWTnRJbJ SeDJvtNTPMo5v47YEZBiEeGShoiETDU= X-Google-Smtp-Source: AMsMyM4FvHk3T/Y8FQNcOkOMS9Dkw2fLxboQaKwc4ekQ2TUdLVwkDlKCHzPMQnkDvy3tzMqwTpyktA== X-Received: by 2002:a05:600c:35cf:b0:3c6:e957:b403 with SMTP id r15-20020a05600c35cf00b003c6e957b403mr36494890wmq.162.1666618875814; Mon, 24 Oct 2022 06:41:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m10-20020adffa0a000000b002305cfb9f3dsm25829703wrr.89.2022.10.24.06.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:41:15 -0700 (PDT) Message-Id: <79c6406d492ab629d5d042edaf1507888d5378c0.1666618868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 24 Oct 2022 13:41:05 +0000 Subject: [PATCH v4 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