From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA602C282D9 for ; Tue, 19 Jan 2021 18:29:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF1F223138 for ; Tue, 19 Jan 2021 18:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390176AbhASR65 (ORCPT ); Tue, 19 Jan 2021 12:58:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:45408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730730AbhASPAY (ORCPT ); Tue, 19 Jan 2021 10:00:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BEC3C207B1; Tue, 19 Jan 2021 14:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611068367; bh=tiqOZbdeRVwIG8uLJZ4PlcIKtaMjPFbMWgzud1ja+8A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tdqef2iIhRh7XgHtM5xZqd8/eNHR04qxIjqU7cp5zKn5NeR7I3hNcl3XmJxLNcllg u3Qb+KenWuPoQ8YHZ9CrzFYmDRaQsTW4j8zlRw+RBKvO51rGoxQnKkGcxOzKmIgE9d ztpA6XQKf+bkqGvtUlJ9Lu0VqeWKK5Q1IwK35fGEAQeLj0OQFLEJjRg3LViHkSNG4Z T7VsSJfqoxqPgDMHq35o7ZNP2PqHHWj4jRlhZuygByjtWcuOqgjZIBgQ/F+Z0o0nhI eBbyCp3lOFxRwsZIV8CuqLR0Dzgn2wIamiBk6g+8glnLZvS5947QLjNWTtnAQMhSm4 sOSVBGeFyho8w== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 4FD1140CE2; Tue, 19 Jan 2021 11:59:22 -0300 (-03) Date: Tue, 19 Jan 2021 11:59:22 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Subject: Re: [PATCH 03/22] perf tools: Add debug_set_display_time function Message-ID: <20210119145922.GL12699@kernel.org> References: <20210102220441.794923-1-jolsa@kernel.org> <20210102220441.794923-4-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210102220441.794923-4-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sat, Jan 02, 2021 at 11:04:22PM +0100, Jiri Olsa escreveu: > Allow to display time in perf debug output via new > debug_set_display_time function. > > It will be used in perf daemon command to get verbose > output into log file. > > The debug time format is: > > [2020-12-03 18:25:31.822152] affinity: SYS > [2020-12-03 18:25:31.822164] mmap flush: 1 > [2020-12-03 18:25:31.822175] comp level: 0 > [2020-12-03 18:25:32.002047] mmap size 528384B > > Signed-off-by: Jiri Olsa > --- > tools/perf/util/debug.c | 34 +++++++++++++++++++++++++++++++--- > tools/perf/util/debug.h | 1 + > 2 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c > index 50fd6a4be4e0..dc148b08814b 100644 > --- a/tools/perf/util/debug.c > +++ b/tools/perf/util/debug.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #ifdef HAVE_BACKTRACE_SUPPORT > #include > #endif > @@ -31,21 +32,48 @@ int debug_ordered_events; > static int redirect_to_stderr; > int debug_data_convert; > static FILE *debug_file; > +bool debug_display_time; > > void debug_set_file(FILE *file) > { > debug_file = file; > } > > +void debug_set_display_time(bool set) > +{ > + debug_display_time = set; > +} > + > +static int fprintf_time(FILE *file) > +{ > + struct timeval tod; > + struct tm ltime; > + char date[64]; > + > + if (!debug_display_time) > + return 0; > + > + if (gettimeofday(&tod, NULL) != 0) > + return 0; > + > + if (localtime_r(&tod.tv_sec, <ime) == NULL) > + return 0; > + > + strftime(date, sizeof(date), "%F %H:%M:%S", <ime); > + return fprintf(file, "[%s.%06lu] ", date, tod.tv_usec); > +} 78 12.70 ubuntu:18.04-x-sparc64 : FAIL sparc64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 util/debug.c: In function 'fprintf_time': util/debug.c:63:32: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__suseconds_t {aka int}' [-Werror=format=] return fprintf(file, "[%s.%06lu] ", date, tod.tv_usec); ~~~~^ ~~~~~~~~~~~ %06u I'll try to fix it. - Arnaldo > + > int veprintf(int level, int var, const char *fmt, va_list args) > { > int ret = 0; > > if (var >= level) { > - if (use_browser >= 1 && !redirect_to_stderr) > + if (use_browser >= 1 && !redirect_to_stderr) { > ui_helpline__vshow(fmt, args); > - else > - ret = vfprintf(debug_file, fmt, args); > + } else { > + ret = fprintf_time(debug_file); > + ret += vfprintf(debug_file, fmt, args); > + } > } > > return ret; > diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h > index 43f712295645..48f631966067 100644 > --- a/tools/perf/util/debug.h > +++ b/tools/perf/util/debug.h > @@ -64,6 +64,7 @@ int veprintf(int level, int var, const char *fmt, va_list args); > > int perf_debug_option(const char *str); > void debug_set_file(FILE *file); > +void debug_set_display_time(bool set); > void perf_debug_setup(void); > int perf_quiet_option(void); > > -- > 2.26.2 > -- - Arnaldo