From patchwork Tue May 24 01:50:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12859616 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 5F6AFC433F5 for ; Tue, 24 May 2022 01:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232322AbiEXBuh (ORCPT ); Mon, 23 May 2022 21:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232782AbiEXBuf (ORCPT ); Mon, 23 May 2022 21:50:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 463EF737A3 for ; Mon, 23 May 2022 18:50:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F2106B8171B for ; Tue, 24 May 2022 01:50:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8B42C34116; Tue, 24 May 2022 01:50:30 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1ntJgr-0015i8-M6; Mon, 23 May 2022 21:50:29 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" Subject: [PATCH 1/2] trace-cmd library: Keep USECS flag if TSC multiplier is set Date: Mon, 23 May 2022 21:50:27 -0400 Message-Id: <20220524015028.260238-2-rostedt@goodmis.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220524015028.260238-1-rostedt@goodmis.org> References: <20220524015028.260238-1-rostedt@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" If the option TSC2NSECS is set, then display as microseconds like it does with trace clock local. This is because even though the x86-tsc is not in nanoseconds, the clock will be shifted and multiplied to be in nanoseconds, so it makes sense to convert it to seconds. Signed-off-by: Steven Rostedt (Google) --- lib/trace-cmd/trace-input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 442b1c5a6724..e2ceff331869 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -3483,6 +3483,8 @@ static int handle_options(struct tracecmd_input *handle) buf + 4, 4); handle->tsc_calc.offset = tep_read_number(handle->pevent, buf + 8, 8); + if (!(handle->flags & TRACECMD_FL_RAW_TS)) + handle->flags |= TRACECMD_FL_IN_USECS; break; case TRACECMD_OPTION_HEADER_INFO: case TRACECMD_OPTION_FTRACE_EVENTS: @@ -3865,6 +3867,10 @@ static void extract_trace_clock(struct tracecmd_input *handle, char *line) if (handle->flags & TRACECMD_FL_RAW_TS) handle->flags &= ~TRACECMD_FL_IN_USECS; + /* tsc_calc is a conversion to nanoseconds */ + if (handle->tsc_calc.mult) + return; + /* Clear usecs if not one of the specified clocks */ if (strcmp(clock, "local") && strcmp(clock, "global") && strcmp(clock, "uptime") && strcmp(clock, "perf") && From patchwork Tue May 24 01:50:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12859617 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 C4433C433FE for ; Tue, 24 May 2022 01:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232782AbiEXBui (ORCPT ); Mon, 23 May 2022 21:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232785AbiEXBuf (ORCPT ); Mon, 23 May 2022 21:50:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D4B3737AB for ; Mon, 23 May 2022 18:50:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 20C11B81729 for ; Tue, 24 May 2022 01:50:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE4FDC34117; Tue, 24 May 2022 01:50:30 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1ntJgr-0015iB-Ml; Mon, 23 May 2022 21:50:29 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" Subject: [PATCH 2/2] trace-cmd record: Set clock to TSC when connecting to a proxy with kvm Date: Mon, 23 May 2022 21:50:28 -0400 Message-Id: <20220524015028.260238-3-rostedt@goodmis.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220524015028.260238-1-rostedt@goodmis.org> References: <20220524015028.260238-1-rostedt@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" If the time synchronization protocol for the recorder to a agent proxy is KVM, then it means that the TSC clock must be used. Force it when this is discovered. Signed-off-by: Steven Rostedt (Google) --- tracecmd/trace-record.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index ce20402af7c2..169836bd493c 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -3849,16 +3849,29 @@ static int open_guest_fifos(const char *guest, int **fds) return i; } +static bool clock_is_supported(struct tracefs_instance *instance, const char *clock); + static int host_tsync(struct common_record_context *ctx, struct buffer_instance *instance, unsigned int tsync_port, char *proto) { + struct buffer_instance *iter_instance; int guest_id = -1; int fd; if (!proto) return -1; + /* If connecting to a proxy, the clock may still need to be set */ + if (strcmp(proto, "kvm") == 0 && + clock_is_supported(NULL, TSC_CLOCK)) { + ctx->clock = TSC_CLOCK; + for_all_instances(iter_instance) { + iter_instance->clock = TSC_CLOCK; + set_clock(ctx, iter_instance); + } + } + if (is_network(instance)) { fd = connect_port(instance->name, tsync_port, instance->port_type);