Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf timechart: Make large arrays dynamic

Allocate start time and state arrays when command starts rather than
using 114,688 bytes in .bss.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20230526183401.2326121-11-irogers@google.com
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ross Zwisler <zwisler@chromium.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
ddc27bb8 eef4fee5

+39 -9
+39 -9
tools/perf/builtin-timechart.c
··· 315 315 316 316 #define MAX_CPUS 4096 317 317 318 - static u64 cpus_cstate_start_times[MAX_CPUS]; 319 - static int cpus_cstate_state[MAX_CPUS]; 320 - static u64 cpus_pstate_start_times[MAX_CPUS]; 321 - static u64 cpus_pstate_state[MAX_CPUS]; 318 + static u64 *cpus_cstate_start_times; 319 + static int *cpus_cstate_state; 320 + static u64 *cpus_pstate_start_times; 321 + static u64 *cpus_pstate_state; 322 322 323 323 static int process_comm_event(struct perf_tool *tool, 324 324 union perf_event *event, ··· 1981 1981 "perf timechart record [<options>]", 1982 1982 NULL 1983 1983 }; 1984 + int ret; 1985 + 1986 + cpus_cstate_start_times = calloc(MAX_CPUS, sizeof(*cpus_cstate_start_times)); 1987 + if (!cpus_cstate_start_times) 1988 + return -ENOMEM; 1989 + cpus_cstate_state = calloc(MAX_CPUS, sizeof(*cpus_cstate_state)); 1990 + if (!cpus_cstate_state) { 1991 + ret = -ENOMEM; 1992 + goto out; 1993 + } 1994 + cpus_pstate_start_times = calloc(MAX_CPUS, sizeof(*cpus_pstate_start_times)); 1995 + if (!cpus_pstate_start_times) { 1996 + ret = -ENOMEM; 1997 + goto out; 1998 + } 1999 + cpus_pstate_state = calloc(MAX_CPUS, sizeof(*cpus_pstate_state)); 2000 + if (!cpus_pstate_state) { 2001 + ret = -ENOMEM; 2002 + goto out; 2003 + } 2004 + 1984 2005 argc = parse_options_subcommand(argc, argv, timechart_options, timechart_subcommands, 1985 2006 timechart_usage, PARSE_OPT_STOP_AT_NON_OPTION); 1986 2007 1987 2008 if (tchart.power_only && tchart.tasks_only) { 1988 2009 pr_err("-P and -T options cannot be used at the same time.\n"); 1989 - return -1; 2010 + ret = -1; 2011 + goto out; 1990 2012 } 1991 2013 1992 2014 if (argc && strlen(argv[0]) > 2 && strstarts("record", argv[0])) { ··· 2018 1996 2019 1997 if (tchart.power_only && tchart.tasks_only) { 2020 1998 pr_err("-P and -T options cannot be used at the same time.\n"); 2021 - return -1; 1999 + ret = -1; 2000 + goto out; 2022 2001 } 2023 2002 2024 2003 if (tchart.io_only) 2025 - return timechart__io_record(argc, argv); 2004 + ret = timechart__io_record(argc, argv); 2026 2005 else 2027 - return timechart__record(&tchart, argc, argv); 2006 + ret = timechart__record(&tchart, argc, argv); 2007 + goto out; 2028 2008 } else if (argc) 2029 2009 usage_with_options(timechart_usage, timechart_options); 2030 2010 2031 2011 setup_pager(); 2032 2012 2033 - return __cmd_timechart(&tchart, output_name); 2013 + ret = __cmd_timechart(&tchart, output_name); 2014 + out: 2015 + zfree(&cpus_cstate_start_times); 2016 + zfree(&cpus_cstate_state); 2017 + zfree(&cpus_pstate_start_times); 2018 + zfree(&cpus_pstate_state); 2019 + return ret; 2034 2020 }