Message ID | 20231127220902.1315692-18-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3502687vqx; Mon, 27 Nov 2023 14:17:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfj/n+UT0yWu2TJVEOboUxqBFYLUhWW+RvuzD65seZbuksSDKnzjHNLiIlblBZ90u2ayM0 X-Received: by 2002:a05:6a00:99e:b0:6c5:e1f:184a with SMTP id u30-20020a056a00099e00b006c50e1f184amr17142596pfg.28.1701123453490; Mon, 27 Nov 2023 14:17:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701123453; cv=none; d=google.com; s=arc-20160816; b=otazpoNiUguyyhqbe7/HreRGyOCwznKXUa7rWVMoWrqzuxlp0iHtNRbB5HVfTVuIPw lykU/EEXV89K4eIkyj31ClkUA7SwrowdoLMgUuAhdSLMMv1hu4Tk32GtpI3hCJhR5geY 0+/UbDY/5+4JeAKSeav4jPPawaoOv1QzljsF15vcPdGrIgXzDVcl0r6FjiwQ/kReFI9b gX858lqfsHZ9VvULqCGPhQFb/PhNv/AH0E6C/UxNpQARH5SP9yFDXag1ZBhm9Bjrf7iL ld/JEBt4WQohM4RM2uMhVrDtsJqUqmjEnSf3yD+DsZht5ckzJ081Q9x9L02J1n42hDhY f3Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=74QLH4lft9zfzlsPq86t9Qk+/WjoI7cS4MoOjhAmrDw=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=uVnsjsCG4+LVnFk+bDJkgixJCRlBkilXNDpQj+PW5/9e4lcQi+++3lNsgYVo/+h6tU Ih4/CynfuPjA57X8iM8cY+Rc/hQ5Smyw4wdKRQ7QWzH/W+QoyPbYjX5nKSRpkMTvNquy V2zGKuDPwBImpdDMiXs3rPXqQL0AzV0nqFJH94d1TjQsaERFMEGLCB5F8knhYPohDYhO r5y7wflFobCbeLmL8SchO0zJb9BvttxkzAgovP5Uv4TSSKXzPAYf+IZLWv0EaBgSOMA9 5CVzHoH+mHDMcYWdkDmYeK+huFYbamSt+/gwXxKcSdfYAGMaqoLOoFt5+QPQRWUNZVlw akhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Y/oR5VbW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id 34-20020a630d62000000b005bddca8236dsi10685304pgn.699.2023.11.27.14.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:17:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Y/oR5VbW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 89F4F809A9B7; Mon, 27 Nov 2023 14:17:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233482AbjK0WQt (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 17:16:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233697AbjK0WKQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 17:10:16 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1805C10F6 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:10:04 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5cd2100f467so60730377b3.1 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701123003; x=1701727803; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=74QLH4lft9zfzlsPq86t9Qk+/WjoI7cS4MoOjhAmrDw=; b=Y/oR5VbWO0lojZUT3goA1EGmqSRbmbnvRdC5dRR4fA2LIeuTr8KZovchCmi8HCXIJG p0hOJ4sAmT86IMx0Wh6/nqK0NpjLnSsaqeZ7tEjEuv8CzDkqY7L0wDqgQQfRQ4MDFOlh jaVN8i7tqYQ0N5NsPdptlwxzllWDeGAr/Z9d69MoEDAjOs7dW42UahVF/nAKmWKpFEdC V7ltwXQQRwlRFGVrzM3rrmk2atXiYJa/xvsOTbnhlPr94u5MmfvXVdQIQMQ1YXvGOrQc YmS5nP9DLTwx8VyIKuGQ5xjMq/IQLAVvJNRAgQKM43jPo4EqRAl5ZauN/HgrBpHoWWZg +/iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701123003; x=1701727803; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=74QLH4lft9zfzlsPq86t9Qk+/WjoI7cS4MoOjhAmrDw=; b=hHWwOmCcclyTYKpTVH1tme+emujQq8tfdUF1AHRwBS533chsk9AV5HtveveB0pxBts KcdrGwTkoiLQXl+IcEor28IVyiXw4dsLG7WcDT9q4sWNZNpEBWIKqQlxRezpzOPqlu2P nYiV6bELkIKW8CMt9d9zOGlLZWgCTyessGcQdUbSvyI6kNlk8GYFN5vIDFjdbnPykjgs Ff6FHsu7YkzquLQMcIkzafJeZN54ZUB+AXZM7PCPP67dLUhAklR5i4DTXZDHCWvL/N+i vlAKFdmEMWTyl2tIr6QrAwdqK+FckWD9PICSu4m0ezA1IHtcUoxoGCPoy9RK6SEc+IhP XbZA== X-Gm-Message-State: AOJu0YxUVIr8gU5HHmwaT0K+IFJjm68IphMadLVL75PxfQX7izP60xAP zkDFNMZarifVADqEx+B5+oILfbcnvha8 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:829:6e77:9093:f39b]) (user=irogers job=sendgmr) by 2002:a05:690c:fcd:b0:5ca:fef:82a4 with SMTP id dg13-20020a05690c0fcd00b005ca0fef82a4mr492696ywb.4.1701123003294; Mon, 27 Nov 2023 14:10:03 -0800 (PST) Date: Mon, 27 Nov 2023 14:08:29 -0800 In-Reply-To: <20231127220902.1315692-1-irogers@google.com> Message-Id: <20231127220902.1315692-18-irogers@google.com> Mime-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v5 17/50] perf debug: Expose debug file From: Ian Rogers <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Nick Terrell <terrelln@fb.com>, Kan Liang <kan.liang@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, Kajol Jain <kjain@linux.ibm.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Huacai Chen <chenhuacai@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com>, "Steinar H. Gunderson" <sesse@google.com>, Liam Howlett <liam.howlett@oracle.com>, Miguel Ojeda <ojeda@kernel.org>, Colin Ian King <colin.i.king@gmail.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Ming Wang <wangming01@loongson.cn>, James Clark <james.clark@arm.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Sean Christopherson <seanjc@google.com>, Leo Yan <leo.yan@linaro.org>, Ravi Bangoria <ravi.bangoria@amd.com>, German Gomez <german.gomez@arm.com>, Changbin Du <changbin.du@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, Li Dong <lidong@vivo.com>, Sandipan Das <sandipan.das@amd.com>, liuwenyu <liuwenyu7@huawei.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio <amadio@gentoo.org> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:17:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783757226721151766 X-GMAIL-MSGID: 1783757226721151766 |
Series |
Improvements to memory use
|
|
Commit Message
Ian Rogers
Nov. 27, 2023, 10:08 p.m. UTC
Some dumping call backs need to be passed a FILE*. Expose debug file
via an accessor API for a consistent way to do this. Catch the
unlikely failure of it not being set. Switch two cases where stderr
was being used instead of debug_file.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/debug.c | 22 +++++++++++++++-------
tools/perf/util/debug.h | 1 +
2 files changed, 16 insertions(+), 7 deletions(-)
Comments
On Mon, Nov 27, 2023 at 2:10 PM Ian Rogers <irogers@google.com> wrote: > > Some dumping call backs need to be passed a FILE*. Expose debug file > via an accessor API for a consistent way to do this. Catch the > unlikely failure of it not being set. Switch two cases where stderr > was being used instead of debug_file. > > Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 88378c4c5dd9..e282b4ceb4d2 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -38,12 +38,21 @@ bool dump_trace = false, quiet = false; int debug_ordered_events; static int redirect_to_stderr; int debug_data_convert; -static FILE *debug_file; +static FILE *_debug_file; bool debug_display_time; +FILE *debug_file(void) +{ + if (!_debug_file) { + pr_warning_once("debug_file not set"); + debug_set_file(stderr); + } + return _debug_file; +} + void debug_set_file(FILE *file) { - debug_file = file; + _debug_file = file; } void debug_set_display_time(bool set) @@ -78,8 +87,8 @@ int veprintf(int level, int var, const char *fmt, va_list args) if (use_browser >= 1 && !redirect_to_stderr) { ui_helpline__vshow(fmt, args); } else { - ret = fprintf_time(debug_file); - ret += vfprintf(debug_file, fmt, args); + ret = fprintf_time(debug_file()); + ret += vfprintf(debug_file(), fmt, args); } } @@ -107,9 +116,8 @@ static int veprintf_time(u64 t, const char *fmt, va_list args) nsecs -= secs * NSEC_PER_SEC; usecs = nsecs / NSEC_PER_USEC; - ret = fprintf(stderr, "[%13" PRIu64 ".%06" PRIu64 "] ", - secs, usecs); - ret += vfprintf(stderr, fmt, args); + ret = fprintf(debug_file(), "[%13" PRIu64 ".%06" PRIu64 "] ", secs, usecs); + ret += vfprintf(debug_file(), fmt, args); return ret; } diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index f99468a7f681..de8870980d44 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -77,6 +77,7 @@ int eprintf_time(int level, int var, u64 t, const char *fmt, ...) __printf(4, 5) int veprintf(int level, int var, const char *fmt, va_list args); int perf_debug_option(const char *str); +FILE *debug_file(void); void debug_set_file(FILE *file); void debug_set_display_time(bool set); void perf_debug_setup(void);