From patchwork Mon Dec 20 15:01:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 12688075 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 7AB9AC433F5 for ; Mon, 20 Dec 2021 15:21:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239359AbhLTPVf (ORCPT ); Mon, 20 Dec 2021 10:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240223AbhLTPTs (ORCPT ); Mon, 20 Dec 2021 10:19: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 7A7F4C0698DB for ; Mon, 20 Dec 2021 07:01:14 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id s1so15285088wra.6 for ; Mon, 20 Dec 2021 07:01:14 -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=0BdkwbvT8/fGDnjb4KnHA2Vi+oykkkyrvK4HCWgqGN4=; b=N0HZbE+LIOZEG5Qtg24ypRnXzArif6iA2bspqj9HJrwVQ+oHZmQ/hq2kaXFQnzm9kw d8workgBCz977sJSjfVhu7fdMFHmql3KBEjgVXVLPptIA0XddW1fdEGOQeQ9EQwxRNoi r41yHelhpzFWQm/PTNZqCGRTew+js/3VjRG5MHohaU/ENfv8UFTKvFmxAFGMtbDlkTXw IrwH6WF8trs2cqoe9rR8P+lo6VcVJJitGzJWPo2hq16Oc8VQlAK2D6pOcYZcR0PZEcyK OfQx7HxQBzId5NKvlcTIgqgnydABp/+O3rrDxkmYyWoXNKoos5et2Edo5GFMZozUzHH4 U7kw== 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=0BdkwbvT8/fGDnjb4KnHA2Vi+oykkkyrvK4HCWgqGN4=; b=SbYFJX3e4zOHMJ6xrtI7vdnpMSfHcmaGmUDFy4a9p5WrA1v1T2E63Wwj15Nxk9n39K UCDUW8wr0WgSR6GeG9w0xVLKl4Py8Bhi70+lNywzsQ4HBcRMcDUJeKKRaT6a+x68TnKk qBxCUs9RMISrVLWV0VqACwPQmfwbiILwtmCEHVEE+Pvkxdg08ql95xEYVVd5sZBIQzAY aG/+95mWCSJFYqjxjFZPkOF/+LFedIEAfI3swmGK+SBAvz4Uebm3la2r+cCILA1s7pgQ A57frwyfb9mjVbwdyVPc9e0ddBvVa7bjwt1cmnVZu6foBB1sSkHTdVy6KuRa9L4kaEJ+ aplQ== X-Gm-Message-State: AOAM5310Nru07xKdozpUA/0V9+Tat5KBVdmHnykalan/LKJZcc3U18p4 gPv0FhcKxKE1Dwu1/47DBCfyQXhHyeQ= X-Google-Smtp-Source: ABdhPJxXDyUbXefQybvwq3ZrpeKXTd4asF6XiZgBNjE01Q08FOdllorZH3YCTykYdE2FRZSb0TkV9g== X-Received: by 2002:a5d:4949:: with SMTP id r9mr12926186wrs.494.1640012472892; Mon, 20 Dec 2021 07:01:12 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c187sm16734909wme.33.2021.12.20.07.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 07:01:12 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 20 Dec 2021 15:01:04 +0000 Subject: [PATCH 4/9] trace2: add thread-name override to event target Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff Hostetler , Jeff Hostetler Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler From: Jeff Hostetler Teach the Trace2 event target to allow the thread-name field to be specified rather than always inherited from the TLS CTX. 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