Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3467607pxu; Tue, 15 Dec 2020 07:42:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTmU5pdCWrFMCee3oeunN/tJIEeAazEtNDHEZL5G1YbwoiFz7n5G+ZcRWAdkQVcMiR7aWv X-Received: by 2002:a17:906:259a:: with SMTP id m26mr28146409ejb.399.1608046960928; Tue, 15 Dec 2020 07:42:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608046960; cv=none; d=google.com; s=arc-20160816; b=kOFta8y1IXE7xIkaTyVWkEbHJ/wwc+QGaqIf4WdgXRDIMg7SbyXUaiYVRdTuKBdQGM /894YLblOY4/zcoijHjPAD6WvyyyrDL3k14csX41D54n1paqHu5sdDelrLtfBaAM/0wn Wm1L8iFWPNAAirqo4Ts0EfAsQwdpFx4ld4VVhvlMRt3xHr32NKzMaOsP4eAJwel2AtL9 I7jCXZqvTu0xXnqUegThkb0FW5VACSfI7YibLHa4NgHo/LqRQNGPKPhy/o4lFH3t+sIv 0YxJlCJxlnKgQw+YNF7dIPz8uchIFsdb3C3vAwed6J4hv4rSw1EV8WZAPDEbtHCuvfEP qWlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=ZHaVKPFz1nNKVBkc5D1MGBsx3Irg0dkdHKqVHaI6B6Q=; b=ylK7ii3fjpYfrrEctEWiLaplI8bBC3HfVZZl3/7AtMeogI+On5Nujv8r3f7dfoOVNc Ym1eKq4y9K4vx5Nx9OsNj6Xxqy4aBsQ3tcl+uDq/3y7WK6ybQNJ8FGDvBM66tYb3iyrC 0SqhCZIyLOiAZkMVoZkWA8VnD0rRyVmHFBYnoG6X6C+fAxb4r40wAaHMuA1HRQigncrr yehy7AQtNvx+oOhT4apZ6pl5/1DSMQHu1+Jtj6srWDF7XWx3ViLH9BwoAIEloO5/Z6Wu i5AD/2mL2sL3s+8LNx+sJm5X853aOb36mXUVTUPIeaRNwsd2sDfLhj+VY2OQCNKlNDrZ CWRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ENwaXYM+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id en21si1185835ejc.393.2020.12.15.07.42.14; Tue, 15 Dec 2020 07:42:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ENwaXYM+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730149AbgLOPiK (ORCPT + 99 others); Tue, 15 Dec 2020 10:38:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:36732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729699AbgLOPhy (ORCPT ); Tue, 15 Dec 2020 10:37:54 -0500 Date: Tue, 15 Dec 2020 12:37:26 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608046633; bh=J8zqJOxQ4Lq9nBsEUhBucV5x8iBjEoIHADNoS7phfj8=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=ENwaXYM+yONzJfHp2sPqFjgQDeTwtJITIrzxuoocrVpGX7lUGcXx91s9VC4pr2kTI wP7irzcGQDVHO7+1BYwNDf40Irzqw7nNvP0Azmk42TY+mAXLFfxj7uiQnzvpw4eUb1 vM5mXdylbwX1WTkn2Tmjmf2vfzmUL4EXnSzEzrhC9Py6xVwLkg03z2VFs4xVJC5wH4 ghC5BOBFiMwO0T3OmfQzlXa6M41WuH6qoSgC4ZlKt5ERoA+zLrEaxvW7z1oqiS0WM5 dlqbHY3auV2U60ikMCn3V7egh3jgXfQFhQKsHHm+gUWOg+bJ12xDxxq2Xyw2uMCazG 7oHwSKxkj58EQ== 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 2/8] perf tools: Add debug_set_display_time function Message-ID: <20201215153726.GC258566@kernel.org> References: <20201212104358.412065-1-jolsa@kernel.org> <20201212104358.412065-3-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201212104358.412065-3-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sat, Dec 12, 2020 at 11:43:52AM +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 Thanks, applied. - Arnaldo > 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); > +} > + > 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