From patchwork Tue Dec 28 19:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 12700560 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 42A7FC433EF for ; Tue, 28 Dec 2021 19:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237194AbhL1Tgw (ORCPT ); Tue, 28 Dec 2021 14:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237183AbhL1Tgs (ORCPT ); Tue, 28 Dec 2021 14:36:48 -0500 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 BC6B3C061574 for ; Tue, 28 Dec 2021 11:36:47 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id r17so40172527wrc.3 for ; Tue, 28 Dec 2021 11:36:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QPndysMS5d9HtSVD2Y4SedG3uUuo8ie3ZHyRfzHOZ4w=; b=YLB1u/C64wM6mAEKKrVcHLoov2pruFKwbzDN5rkxkvxIFpKAfg02fi+nGwTeKZnhub Zqs2FO9qRoWLIdKui73b4fvrkYzkd6J8kUVI+DRxPO9z5EXewtOyNWwfzsJlWV/RzEOl rytwlV3O00G3EJmC118mx/IZRfnTeei9YOEVXmD23LhPaJiNrRqrxwaIE9U3A2bsyERp QSt0GYWcj2+37tZZReSU3BhdTtQnFp5N6L0ukRKiNoJdRZ9mNoqmP1ROB2s7MkeMf3p8 L8L/nYun2lJA4VC7ix0Y6PplhhwCTgHoQHBHzSKz3aPsk7Iq5atDc9usHkzRlQS785+V nB0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QPndysMS5d9HtSVD2Y4SedG3uUuo8ie3ZHyRfzHOZ4w=; b=5t18jpl9bEwGEFxp4ifJl+OhKV2j+Qj6BnAaQoi2jk+764RZrp8VQGcB7A6mTUVX9q Uh2+mPaAP0g7NZHV0OLqU5KcTYkFGiI4YqM/GCuCaJhPU6mknqt7Obvj93B2tcd/Z8TP i3mUqWZxYwQ+dQO+JMucyxVy4UlBmZVslBZ5nXtzpseohVH40wPziY/eIr6wiyU7t/GN 2BEignDGWp2p8UZuKbfU40IPueWfBIKh2XAF9maLJO9Mzky3k7hWritSjqgDZrF8EyZ0 Wacri8bkedNQDUPoucqVez1k+gkyCUvDDyhgJVBBPsaAxjb+VXihTMSUbtjH2uL73TF3 qx9g== X-Gm-Message-State: AOAM531Hv70sOCEzNHBNzvG7idWWIveZhH2RMtB0b0rphDgFaOKcqjEZ SZ7iExvl5HYBbzecRzCuPokoiJ5/kCU= X-Google-Smtp-Source: ABdhPJyKwryZi8Ckc5QirvABuA3kOs8spBvO5BcYzmaLveFp54nsrEPWjyVvL1+aMIRGWISA2el36w== X-Received: by 2002:a5d:66d2:: with SMTP id k18mr17882988wrw.430.1640720206152; Tue, 28 Dec 2021 11:36:46 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a198sm19074377wmd.42.2021.12.28.11.36.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:36:45 -0800 (PST) Message-Id: <531a1ee45c2ff6dfd61f83ccbafc31465f0d9e80.1640720202.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 28 Dec 2021 19:36:37 +0000 Subject: [PATCH v2 4/9] trace2: add thread-name override to event target Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jeff Hostetler , Derrick Stolee , Matheus Tavares , Johannes Sixt , Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Teach the message formatter in the Trace2 event target to take an optional thread-name argument. This overrides the thread name inherited from the thread local storage data. This will be used in a future commit for global events that should not be tied to a particular thread, such as a global stopwatch timer that aggregates data from all threads. Signed-off-by: Jeff Hostetler --- trace2/tr2_tgt_event.c | 59 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c index ca48d00aebc..4ce50944298 100644 --- a/trace2/tr2_tgt_event.c +++ b/trace2/tr2_tgt_event.c @@ -81,14 +81,17 @@ static void fn_term(void) */ static void event_fmt_prepare(const char *event_name, const char *file, int line, const struct repository *repo, - struct json_writer *jw) + struct json_writer *jw, + const char *thread_name_override) { - struct tr2tls_thread_ctx *ctx = tr2tls_get_self(); struct tr2_tbuf tb_now; jw_object_string(jw, "event", event_name); jw_object_string(jw, "sid", tr2_sid_get()); - jw_object_string(jw, "thread", ctx->thread_name); + jw_object_string(jw, "thread", + ((thread_name_override && *thread_name_override) + ? thread_name_override + : tr2tls_get_self()->thread_name)); /* * In brief mode, only emit