Message ID | 20231102175735.2272696-21-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp533864vqu; Thu, 2 Nov 2023 11:00:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFytSX1fTo2Ep5WWcCoGbZM6gFmWdSXfpyseSoG3eJX1S4QtGEBTkOTFfsAYIPBBIo1Kh7p X-Received: by 2002:a05:6358:60c6:b0:169:845b:343d with SMTP id i6-20020a05635860c600b00169845b343dmr10504148rwi.28.1698948000558; Thu, 02 Nov 2023 11:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698948000; cv=none; d=google.com; s=arc-20160816; b=oOZWyGl2+SVdy2+jL1qk0gPqYJnbZ8Q88yEahLbvA6vZ5zQl6/HQDYsFPYorLjdtyv MJY0UfxieCqGKfgg2D7CZrDLZXJF5JctRBEPB+XhRa1DVEB5bB04jn5WuO1czj5zB1J3 kKNHAQdoiQkfIrh+ydrzGi/h73imX4WtQ3dH9HSsQm0fOy1vbl3kl5A6xs/hgjebS07s jfEoEe2Vjoz9AxJ/g3s597ROR4mh3c4ftwGO8v/PBU405AftLs1iqAqmWIhaRPD7+TLb DCm6tcmIPGpGjDoU6gZvfuKbUoMu0mLAfw+Yxg5g4XP2cJSG2QsdUBTDm5IovBuH+B+e Llyw== 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=vTgDtxbYigIx0l7l8yxmVGmQ3YjDCKbQz5YbC6NLkeU=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=nAhFPwIzDRwvGktDxzE29rjxzsfvj/ZAh1QQsrfKHYvtnLL3HwWkngAci+WxtfVDJN id8I4EW+o3v5wogRTunxVHKcJrycV5NkDy6H7vxYvXh7ynbpdOKNAYbI4KYEnc55LEgs HRanOP+hbkHq2ufJQawWtPe8QhUQOekjXHfym8/gCj+cISIpGE+8+es7TXBlcmEbETcA Rzr9RR6DQZPrMa7wUMEMnflvDgZTZU673ATNIRii+0m4Jhz/dfiiEyhDgxC1B+E0HPHp 99zPBsy+PCB3rAq155RI36aJFy1jd4dTztWpCeXStdoxAJDnj/AStyTNHLRNF4LFLdHz 298A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=x8QRJv9O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bw26-20020a056a02049a00b005b96fdd43d4si61274pgb.330.2023.11.02.11.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:00:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=x8QRJv9O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 276B782B6F48; Thu, 2 Nov 2023 10:59:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbjKBR74 (ORCPT <rfc822;heyuhang3455@gmail.com> + 35 others); Thu, 2 Nov 2023 13:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345505AbjKBR7H (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Nov 2023 13:59:07 -0400 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 332E41728 for <linux-kernel@vger.kernel.org>; Thu, 2 Nov 2023 10:58:43 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5afa071d100so25594797b3.1 for <linux-kernel@vger.kernel.org>; Thu, 02 Nov 2023 10:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947922; x=1699552722; 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=vTgDtxbYigIx0l7l8yxmVGmQ3YjDCKbQz5YbC6NLkeU=; b=x8QRJv9OoUqot16R90umaoBpzuvKCn2FkD3cARBsCcLiL1WeGukknK12Ee9ILa+1qa fD2gOwXocsngaNt8Ar77m4vKAHuqY+kkRVrzeK/pR7liiZtSPSTxzHHFCQnYs0/rnzOf NMGiYXcyymKbs2WjCWrudMoPGweT1XvyO2y67VOrhqxRXRSBbNHdS/mLMHHGc9O++8jp VN5rinyLWaGUE1zoVNAmdFs4D17iNKnfQkm+cly+5hwVHZPPWYCkt4y+MknRFIixVJkN AV8Eo4+msRQ58dSJLKSwnkp/Xf9QxJdygn+UDhWzWmwLm1zGdaEGPXF89XPYdpX/vKnT jIMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947922; x=1699552722; 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=vTgDtxbYigIx0l7l8yxmVGmQ3YjDCKbQz5YbC6NLkeU=; b=L9BlyKDskQMGd/23IjvIVtQEKgNSH4/ReIj8hDLUco01vJoC3amWqwNh2SfHpY9Adb yrvVUoPxzxBEE3Lj7sk9MXfIeWwHl/gvoLV5iaWQKN7cshFRH4s1kjxXSgMiObwVZnc4 uLuRKdgyfNirVCnoFmOIOaNpigdIu5vbLI6/r57zb+dgBdHpKYCZpFaf/FTXi/HIxkSW aUOsI1+6G9ZBx19W7sfVu3ixDUpaaWMjnkUwau1DqgTzMCbD7KPu1hY03gIdsnnqcjRB LdNwc7BPPItL2JFZFB1CUaxfD4Q3ZWHNT07cdPZPVxT0kC6ftHKk1A6gc13Q0aNTkyjp 277A== X-Gm-Message-State: AOJu0Yw3GUV5sMdc4CMoDn6NCFagDzJcj1kIpmCeoZ+V/q5+9uXEp68P VgTbgHa1bI3uRJ/Kx1bASe/zWpWDOk1x X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a81:4f12:0:b0:59b:ebe0:9fcd with SMTP id d18-20020a814f12000000b0059bebe09fcdmr7405ywb.7.1698947922233; Thu, 02 Nov 2023 10:58:42 -0700 (PDT) Date: Thu, 2 Nov 2023 10:57:02 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-21-irogers@google.com> Mime-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Subject: [PATCH v4 20/53] 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 10:59:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781476098530344847 X-GMAIL-MSGID: 1781476098530344847 |
Series |
Improvements to memory use
|
|
Commit Message
Ian Rogers
Nov. 2, 2023, 5:57 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(-)
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);