From patchwork Tue Jun 25 17:25:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CA22C2BBCA for ; Tue, 25 Jun 2024 17:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=b7ECvVM76J7SjPTuMx+E49kSe7sOGF6/frBYY9GRvbA=; b=s0jnCkp+dk6kuZguRLKyCdgAsu QHa23evcAzrBNydhpQeAOCF1dlvpVuU6GsLTn2HmICo6PhqjqsEinDC8IY0D7sABb7B5QWuECo+T4 Gz99oFCHfvim4fLMy/NKloDoOD4wlViPkPNo4uyxtW/auu3rdE+TM+hxGdjjaVnvAHkD/AAgQRSjF U/fKUg6IA3RJJT3lhF/vNHVTP8/AKTm0pHaRuacjcV7FE7YdDlhumyZ8Mdy3Yf7HFKcsfgkLlMmBO 2EPsv7Cajm0XQJRJtAR0M7fexmq2SpkFIzqDV4EDkdBvU+FNF6aSww1JkNpfUCPUYwA0dbSG+m91h cIbNZMXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w1-00000003sWZ-2qSQ; Tue, 25 Jun 2024 17:26:25 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9vp-00000003sRL-3waQ for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:16 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6452f8f2942so49297257b3.1 for ; Tue, 25 Jun 2024 10:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336372; x=1719941172; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=b7ECvVM76J7SjPTuMx+E49kSe7sOGF6/frBYY9GRvbA=; b=3OTNzqQ+sj9eFDHi/vRXLY2l90YegJPmAVJuzr0VOfd88OD/DR5Jhaly9pOxMYU/Mc ZP8NYEC4CvFOWTcACEQ5tcsezQUuJOi8fVw487kKepr/1ioVAUFYbcvlZl6/rOBoSRIQ xefDgBwMvU3WvtTjmT/zuNEQic5MqHfaHNTgPjVpL2tBitTCQ0Esc66KTn6PUkoVPCCL WjrPgBxewxNkbuGFVq2L0ZxQrZRkFjOs1uq2GJ85pFXkZNncA/i0wh9MvPU4f/HSag/c ay5Rp37r5gne9ZlF0kuiiNzEFFi+rl7j7afENipNopM/LjvdcDwHzdrvZgXJX+D2tYhu k69A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336372; x=1719941172; 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=b7ECvVM76J7SjPTuMx+E49kSe7sOGF6/frBYY9GRvbA=; b=DJ/6TvJ7ua4htSMAN1JGgqtNWX5AvXqtrOuIKCtLn0yWNLW/9azzeKQvVViFMjQWOi Vb2m8w3v3mlKAmoqPkf8F2w4Z27p4dWYyEZS3vNIehr2mRStkTfyEuy/aitJO1FTle2Y D+5cW721vorlXUiIcvrXOkxp9PC3myYdNFcnHsBPCjI2ItAYXKrL0E7DQqBq502m3EY6 WFPLyTc+ceqkt2bMeRsln+DELt54YRNzLBuGGVX5lS9oUpBNP0p9gIyRhXLjt47Meafc 6ydyryyHG9Idrquj4tmaNsDnhflk6ef1ia1q7ioCVMwsNmJyi4angT9tjZ01Po52kkkq Izmw== X-Forwarded-Encrypted: i=1; AJvYcCXLHwWVFN2OA6xrJNxDFtSAa9WNOIBf590QYmLMUWKz6JoZOE/U8cGxcSzkmU6IqueDOgNt9NSha96qqPFjF6NXQOlHrmDyRPWnbsTaKZ6SiHXqYyI= X-Gm-Message-State: AOJu0YyVTeHzgwOgjG+5WHsx4rjHrg3HHMJOd9WnZHd3D5rG5qXKuBz0 IhcOvqY8S0lkQXDny5TFUajY3kUfZZUHHZO2gWY2t1FSym83A/zS/pVGAM4o9dJEULi3HBbUMoi Et1RYZQ== X-Google-Smtp-Source: AGHT+IE3rJr9Kn5K91WVWRFlI0uWgYSfpZlX+rzBvoxlY0q4w8vNL1YsA1d3Dp6Qk56wSldOEQE/tf8A2zsJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:1081:b0:dff:3096:85e1 with SMTP id 3f1490d57ef6-e030104fe43mr62523276.10.1719336372422; Tue, 25 Jun 2024 10:26:12 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:39 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-3-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 02/26] perf tool: Move fill defaults into tool.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102614_066029_3D00A001 X-CRM114-Status: GOOD ( 19.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The aim here is to eventually make perf_tool__fill_defaults an init function so that the tools struct is more const. Create a tool.c to go along with tool.h. Move perf_tool__fill_defaults out of session.c into tool.c along with the default stub values. Add perf_tool__compressed_is_stub for a test in perf_session__process_user_event. perf_session__process_compressed_event is only used from being default initialized so migrate into tool.c. Signed-off-by: Ian Rogers --- tools/perf/util/Build | 1 + tools/perf/util/session.c | 310 +----------------------------------- tools/perf/util/session.h | 2 - tools/perf/util/tool.c | 325 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 4 + 5 files changed, 331 insertions(+), 311 deletions(-) create mode 100644 tools/perf/util/tool.c diff --git a/tools/perf/util/Build b/tools/perf/util/Build index da64efd8718f..b412a17bae6b 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -65,6 +65,7 @@ perf-y += map.o perf-y += maps.o perf-y += pstack.o perf-y += session.o +perf-y += tool.o perf-y += sample-raw.o perf-y += s390-sample-raw.o perf-y += amd-sample-raw.o diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index bef5967baeb1..4febff1db5b3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -38,68 +38,6 @@ #include "units.h" #include -#ifdef HAVE_ZSTD_SUPPORT -static int perf_session__process_compressed_event(struct perf_session *session, - union perf_event *event, u64 file_offset, - const char *file_path) -{ - void *src; - size_t decomp_size, src_size; - u64 decomp_last_rem = 0; - size_t mmap_len, decomp_len = session->header.env.comp_mmap_len; - struct decomp *decomp, *decomp_last = session->active_decomp->decomp_last; - - if (decomp_last) { - decomp_last_rem = decomp_last->size - decomp_last->head; - decomp_len += decomp_last_rem; - } - - mmap_len = sizeof(struct decomp) + decomp_len; - decomp = mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); - if (decomp == MAP_FAILED) { - pr_err("Couldn't allocate memory for decompression\n"); - return -1; - } - - decomp->file_pos = file_offset; - decomp->file_path = file_path; - decomp->mmap_len = mmap_len; - decomp->head = 0; - - if (decomp_last_rem) { - memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); - decomp->size = decomp_last_rem; - } - - src = (void *)event + sizeof(struct perf_record_compressed); - src_size = event->pack.header.size - sizeof(struct perf_record_compressed); - - decomp_size = zstd_decompress_stream(session->active_decomp->zstd_decomp, src, src_size, - &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); - if (!decomp_size) { - munmap(decomp, mmap_len); - pr_err("Couldn't decompress data\n"); - return -1; - } - - decomp->size += decomp_size; - - if (session->active_decomp->decomp == NULL) - session->active_decomp->decomp = decomp; - else - session->active_decomp->decomp_last->next = decomp; - - session->active_decomp->decomp_last = decomp; - - pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size); - - return 0; -} -#else /* !HAVE_ZSTD_SUPPORT */ -#define perf_session__process_compressed_event perf_session__process_compressed_event_stub -#endif - static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, const struct perf_tool *tool, @@ -319,251 +257,6 @@ void perf_session__delete(struct perf_session *session) free(session); } -static int process_event_synth_tracing_data_stub(struct perf_session *session - __maybe_unused, - union perf_event *event - __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_synth_attr_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct evlist **pevlist - __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_synth_event_update_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct evlist **pevlist - __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_event_update(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_finished_round_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct ordered_events *oe __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int skipn(int fd, off_t n) -{ - char buf[4096]; - ssize_t ret; - - while (n > 0) { - ret = read(fd, buf, min(n, (off_t)sizeof(buf))); - if (ret <= 0) - return ret; - n -= ret; - } - - return 0; -} - -static s64 process_event_auxtrace_stub(struct perf_session *session __maybe_unused, - union perf_event *event) -{ - dump_printf(": unhandled!\n"); - if (perf_data__is_pipe(session->data)) - skipn(perf_data__fd(session->data), event->auxtrace.size); - return event->auxtrace.size; -} - -static int process_event_op2_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - - -static -int process_event_thread_map_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_thread_map(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static -int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_cpu_map(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static -int process_event_stat_config_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_stat_config(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_stat_stub(struct perf_session *perf_session __maybe_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_stat(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_stat_round_stub(struct perf_session *perf_session __maybe_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_stat_round(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_time_conv_stub(struct perf_session *perf_session __maybe_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_time_conv(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int perf_session__process_compressed_event_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused, - u64 file_offset __maybe_unused, - const char *file_path __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample == NULL) - tool->sample = process_event_sample_stub; - if (tool->mmap == NULL) - tool->mmap = process_event_stub; - if (tool->mmap2 == NULL) - tool->mmap2 = process_event_stub; - if (tool->comm == NULL) - tool->comm = process_event_stub; - if (tool->namespaces == NULL) - tool->namespaces = process_event_stub; - if (tool->cgroup == NULL) - tool->cgroup = process_event_stub; - if (tool->fork == NULL) - tool->fork = process_event_stub; - if (tool->exit == NULL) - tool->exit = process_event_stub; - if (tool->lost == NULL) - tool->lost = perf_event__process_lost; - if (tool->lost_samples == NULL) - tool->lost_samples = perf_event__process_lost_samples; - if (tool->aux == NULL) - tool->aux = perf_event__process_aux; - if (tool->itrace_start == NULL) - tool->itrace_start = perf_event__process_itrace_start; - if (tool->context_switch == NULL) - tool->context_switch = perf_event__process_switch; - if (tool->ksymbol == NULL) - tool->ksymbol = perf_event__process_ksymbol; - if (tool->bpf == NULL) - tool->bpf = perf_event__process_bpf; - if (tool->text_poke == NULL) - tool->text_poke = perf_event__process_text_poke; - if (tool->aux_output_hw_id == NULL) - tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; - if (tool->read == NULL) - tool->read = process_event_sample_stub; - if (tool->throttle == NULL) - tool->throttle = process_event_stub; - if (tool->unthrottle == NULL) - tool->unthrottle = process_event_stub; - if (tool->attr == NULL) - tool->attr = process_event_synth_attr_stub; - if (tool->event_update == NULL) - tool->event_update = process_event_synth_event_update_stub; - if (tool->tracing_data == NULL) - tool->tracing_data = process_event_synth_tracing_data_stub; - if (tool->build_id == NULL) - tool->build_id = process_event_op2_stub; - if (tool->finished_round == NULL) { - if (tool->ordered_events) - tool->finished_round = perf_event__process_finished_round; - else - tool->finished_round = process_finished_round_stub; - } - if (tool->id_index == NULL) - tool->id_index = process_event_op2_stub; - if (tool->auxtrace_info == NULL) - tool->auxtrace_info = process_event_op2_stub; - if (tool->auxtrace == NULL) - tool->auxtrace = process_event_auxtrace_stub; - if (tool->auxtrace_error == NULL) - tool->auxtrace_error = process_event_op2_stub; - if (tool->thread_map == NULL) - tool->thread_map = process_event_thread_map_stub; - if (tool->cpu_map == NULL) - tool->cpu_map = process_event_cpu_map_stub; - if (tool->stat_config == NULL) - tool->stat_config = process_event_stat_config_stub; - if (tool->stat == NULL) - tool->stat = process_stat_stub; - if (tool->stat_round == NULL) - tool->stat_round = process_stat_round_stub; - if (tool->time_conv == NULL) - tool->time_conv = process_event_time_conv_stub; - if (tool->feature == NULL) - tool->feature = process_event_op2_stub; - if (tool->compressed == NULL) - tool->compressed = perf_session__process_compressed_event; - if (tool->finished_init == NULL) - tool->finished_init = process_event_op2_stub; -} - static void swap_sample_id_all(union perf_event *event, void *data) { void *end = (void *) event + event->header.size; @@ -1672,8 +1365,7 @@ static s64 perf_session__process_user_event(struct perf_session *session, int fd = perf_data__fd(session->data); int err; - if (event->header.type != PERF_RECORD_COMPRESSED || - tool->compressed == perf_session__process_compressed_event_stub) + if (event->header.type != PERF_RECORD_COMPRESSED || perf_tool__compressed_is_stub(tool)) dump_event(session->evlist, event, file_offset, &sample, file_path); /* These events are processed right away */ diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index b069f491f121..5cdef3e95c08 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -92,8 +92,6 @@ int perf_session__process_events(struct perf_session *session); int perf_session__queue_event(struct perf_session *s, union perf_event *event, u64 timestamp, u64 file_offset, const char *file_path); -void perf_tool__fill_defaults(struct perf_tool *tool); - int perf_session__resolve_callchain(struct perf_session *session, struct evsel *evsel, struct thread *thread, diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c new file mode 100644 index 000000000000..17219ecb8fa6 --- /dev/null +++ b/tools/perf/util/tool.c @@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "data.h" +#include "debug.h" +#include "header.h" +#include "session.h" +#include "stat.h" +#include "tool.h" +#include "tsc.h" +#include +#include + +#ifdef HAVE_ZSTD_SUPPORT +static int perf_session__process_compressed_event(struct perf_session *session, + union perf_event *event, u64 file_offset, + const char *file_path) +{ + void *src; + size_t decomp_size, src_size; + u64 decomp_last_rem = 0; + size_t mmap_len, decomp_len = session->header.env.comp_mmap_len; + struct decomp *decomp, *decomp_last = session->active_decomp->decomp_last; + + if (decomp_last) { + decomp_last_rem = decomp_last->size - decomp_last->head; + decomp_len += decomp_last_rem; + } + + mmap_len = sizeof(struct decomp) + decomp_len; + decomp = mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (decomp == MAP_FAILED) { + pr_err("Couldn't allocate memory for decompression\n"); + return -1; + } + + decomp->file_pos = file_offset; + decomp->file_path = file_path; + decomp->mmap_len = mmap_len; + decomp->head = 0; + + if (decomp_last_rem) { + memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); + decomp->size = decomp_last_rem; + } + + src = (void *)event + sizeof(struct perf_record_compressed); + src_size = event->pack.header.size - sizeof(struct perf_record_compressed); + + decomp_size = zstd_decompress_stream(session->active_decomp->zstd_decomp, src, src_size, + &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); + if (!decomp_size) { + munmap(decomp, mmap_len); + pr_err("Couldn't decompress data\n"); + return -1; + } + + decomp->size += decomp_size; + + if (session->active_decomp->decomp == NULL) + session->active_decomp->decomp = decomp; + else + session->active_decomp->decomp_last->next = decomp; + + session->active_decomp->decomp_last = decomp; + + pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size); + + return 0; +} +#endif + +static int process_event_synth_tracing_data_stub(struct perf_session *session + __maybe_unused, + union perf_event *event + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_synth_attr_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct evlist **pevlist + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_synth_event_update_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct evlist **pevlist + __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_event_update(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct machine *machine __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_finished_round_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct ordered_events *oe __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int skipn(int fd, off_t n) +{ + char buf[4096]; + ssize_t ret; + + while (n > 0) { + ret = read(fd, buf, min(n, (off_t)sizeof(buf))); + if (ret <= 0) + return ret; + n -= ret; + } + + return 0; +} + +static s64 process_event_auxtrace_stub(struct perf_session *session __maybe_unused, + union perf_event *event) +{ + dump_printf(": unhandled!\n"); + if (perf_data__is_pipe(session->data)) + skipn(perf_data__fd(session->data), event->auxtrace.size); + return event->auxtrace.size; +} + +static int process_event_op2_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + + +static +int process_event_thread_map_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_thread_map(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static +int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_cpu_map(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static +int process_event_stat_config_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_stat_config(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_stat_stub(struct perf_session *perf_session __maybe_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_stat(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_stat_round_stub(struct perf_session *perf_session __maybe_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_stat_round(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_time_conv_stub(struct perf_session *perf_session __maybe_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_time_conv(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int perf_session__process_compressed_event_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused, + u64 file_offset __maybe_unused, + const char *file_path __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +void perf_tool__fill_defaults(struct perf_tool *tool) +{ + if (tool->sample == NULL) + tool->sample = process_event_sample_stub; + if (tool->mmap == NULL) + tool->mmap = process_event_stub; + if (tool->mmap2 == NULL) + tool->mmap2 = process_event_stub; + if (tool->comm == NULL) + tool->comm = process_event_stub; + if (tool->namespaces == NULL) + tool->namespaces = process_event_stub; + if (tool->cgroup == NULL) + tool->cgroup = process_event_stub; + if (tool->fork == NULL) + tool->fork = process_event_stub; + if (tool->exit == NULL) + tool->exit = process_event_stub; + if (tool->lost == NULL) + tool->lost = perf_event__process_lost; + if (tool->lost_samples == NULL) + tool->lost_samples = perf_event__process_lost_samples; + if (tool->aux == NULL) + tool->aux = perf_event__process_aux; + if (tool->itrace_start == NULL) + tool->itrace_start = perf_event__process_itrace_start; + if (tool->context_switch == NULL) + tool->context_switch = perf_event__process_switch; + if (tool->ksymbol == NULL) + tool->ksymbol = perf_event__process_ksymbol; + if (tool->bpf == NULL) + tool->bpf = perf_event__process_bpf; + if (tool->text_poke == NULL) + tool->text_poke = perf_event__process_text_poke; + if (tool->aux_output_hw_id == NULL) + tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; + if (tool->read == NULL) + tool->read = process_event_sample_stub; + if (tool->throttle == NULL) + tool->throttle = process_event_stub; + if (tool->unthrottle == NULL) + tool->unthrottle = process_event_stub; + if (tool->attr == NULL) + tool->attr = process_event_synth_attr_stub; + if (tool->event_update == NULL) + tool->event_update = process_event_synth_event_update_stub; + if (tool->tracing_data == NULL) + tool->tracing_data = process_event_synth_tracing_data_stub; + if (tool->build_id == NULL) + tool->build_id = process_event_op2_stub; + if (tool->finished_round == NULL) { + if (tool->ordered_events) + tool->finished_round = perf_event__process_finished_round; + else + tool->finished_round = process_finished_round_stub; + } + if (tool->id_index == NULL) + tool->id_index = process_event_op2_stub; + if (tool->auxtrace_info == NULL) + tool->auxtrace_info = process_event_op2_stub; + if (tool->auxtrace == NULL) + tool->auxtrace = process_event_auxtrace_stub; + if (tool->auxtrace_error == NULL) + tool->auxtrace_error = process_event_op2_stub; + if (tool->thread_map == NULL) + tool->thread_map = process_event_thread_map_stub; + if (tool->cpu_map == NULL) + tool->cpu_map = process_event_cpu_map_stub; + if (tool->stat_config == NULL) + tool->stat_config = process_event_stat_config_stub; + if (tool->stat == NULL) + tool->stat = process_stat_stub; + if (tool->stat_round == NULL) + tool->stat_round = process_stat_round_stub; + if (tool->time_conv == NULL) + tool->time_conv = process_event_time_conv_stub; + if (tool->feature == NULL) + tool->feature = process_event_op2_stub; + if (tool->compressed == NULL) { +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed = perf_session__process_compressed_event; +#else + tool->compressed = perf_session__process_compressed_event_stub; +#endif + } + if (tool->finished_init == NULL) + tool->finished_init = process_event_op2_stub; +} + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool) +{ + return tool->compressed == perf_session__process_compressed_event_stub; +} diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index b192d44fe91f..7913b698033a 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -88,4 +88,8 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; +void perf_tool__fill_defaults(struct perf_tool *tool); + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool); + #endif /* __PERF_TOOL_H */ From patchwork Tue Jun 25 17:25:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A34DAC2BBCA for ; Tue, 25 Jun 2024 17:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AFiPugBk+wYhM4/j4Jlr9h9+wpX8LHXAYZExjKx1mqU=; b=xCfk/MPbkmD+4RbSF93VqD+3HC E2ROpms5sQpS3yTMg6sKQ2WsA3JQWa32AQfU3Nb7iPVOZS8uUbJq1gKgvkXcwa2DtITQvcD/XvQee UEtmb3kNazG4i9j8u3cwWE0I/Ku34X3g2hINA7TLrKBhrRpp5v2kQLzSs6+vqEugQmQQqhhSdeb+a gnGvDuiefbqB/S8UrWule73DCEp26XEtzJgM6h1nfyaXvFcM+2xhCvEkW4LxbmYPaavOLpKh0bX8M eHCLlXruXjpABkV0Guv4tXtqoTWY/0briwEAumZZcwQgEKpO4ZKEmGLx6JsKc/4S267OpuIsw7oV7 Mkyj86iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w5-00000003sZC-3Sqm; Tue, 25 Jun 2024 17:26:29 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9vs-00000003sRk-0CSK for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:17 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02b58759c2so11525519276.3 for ; Tue, 25 Jun 2024 10:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336375; x=1719941175; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AFiPugBk+wYhM4/j4Jlr9h9+wpX8LHXAYZExjKx1mqU=; b=cR29aaBmLSxedKyxLiHhISddEQ/NG2p+G0r/XR2a+xL37sV6TlpLbUfl55wie6TJ/n gvpY4YcoIITlZP5ATA382hxoPqftk+OiAzLGAcAoQ8Df++X/jmC3+g3qIVzm8B0iXDwL uCJYE3KgQ9QMVnFfeV6KAOnvJPdhT/+1or0cH32jt5Tcnclvs71PYYXFWkUUeGNS1M86 0Do8U3zGISYvsc+rdBOV+JIw/Ma3E6/aB+WiRxZbmOneSzDDAMr/k7vzZykQlSFe6Uti YXj1i1/eG6wIwdDRamHua1lFujAXljxM6HSliJjhWiXjbAQrYtaIviCY6r3Ll3wBEQPZ eUeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336375; x=1719941175; 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=AFiPugBk+wYhM4/j4Jlr9h9+wpX8LHXAYZExjKx1mqU=; b=YrMZyCDbhnUwxFaOGlmAeG62XqUU4Kt9ZY/zCX2BWFfgr60rdplqvHjiDK8cynAOyY JQ00yBVZ6x5yYZ0IfE0/YrnIvTX9o06nMUzR7gzeQxFgw2XnFBhbRmNaRT5IDlDj0FCq YTNb2pFJfzawBexg5l0tKxYGWlQTRkrnbfzqJI7hCCoQETwpSuQqo9ci5fYl5dAx/HUo LZmEofgwDzpuKya9A3CbawtDaQ3DbNGpD8lNBy8bXSpnAHUrLvv71Cxhd5U9ZUK8LwJI 8R9N6OthNu+7N2P7IENJRhlNFyt3/r0LkKrNJVQgjgCC6u8rhA0dzfhWsyR3160cTft+ lwUg== X-Forwarded-Encrypted: i=1; AJvYcCU7r/c4Ci8dKJ5v21a1E05hP4/RLk2kb7Jhztn2aNT3ZicjxasymDRK+PK1eu1cU47UB8uezpyfiOikYQ/Hxisr1B3FIPS4AMTLgrOeRhGoGtoyuC0= X-Gm-Message-State: AOJu0Ywr+hskUkF9SWnDSW/fIgOQWpCwc2YaDe5bm6za03buZeL1dvBA FN0Xae7HbLWTbzs6fg6oLwXNKNdLDaKo0MblUMksrHwyvgmX1euctJ45MB1chAVIXHlYJ0vac06 CPN9aow== X-Google-Smtp-Source: AGHT+IFByilFik/CPNWQ170WVhkuObe+y3OLlOyaUqrpnCTLZdKDJxvfXmIvyNn3iqiG0VAtu17jUVZamArn X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:154e:b0:dff:4a8d:3c70 with SMTP id 3f1490d57ef6-e0303edb6edmr30835276.3.1719336374702; Tue, 25 Jun 2024 10:26:14 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:40 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-4-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 03/26] perf tool: Add perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102616_220832_1AFB3427 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add init function that behaves like perf_tool__fill_defaults but assumes all values haven't been initialized. Signed-off-by: Ian Rogers --- tools/perf/util/tool.c | 58 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 1 + 2 files changed, 59 insertions(+) diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 17219ecb8fa6..cbd9b888bd73 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -230,6 +230,64 @@ static int perf_session__process_compressed_event_stub(struct perf_session *sess return 0; } +void perf_tool__init(struct perf_tool *tool, bool ordered_events) +{ + tool->ordered_events = ordered_events; + tool->ordering_requires_timestamps = false; + tool->namespace_events = false; + tool->cgroup_events = false; + tool->no_warn = false; + tool->show_feat_hdr = SHOW_FEAT_NO_HEADER; + + tool->sample = process_event_sample_stub; + tool->mmap = process_event_stub; + tool->mmap2 = process_event_stub; + tool->comm = process_event_stub; + tool->namespaces = process_event_stub; + tool->cgroup = process_event_stub; + tool->fork = process_event_stub; + tool->exit = process_event_stub; + tool->lost = perf_event__process_lost; + tool->lost_samples = perf_event__process_lost_samples; + tool->aux = perf_event__process_aux; + tool->itrace_start = perf_event__process_itrace_start; + tool->context_switch = perf_event__process_switch; + tool->ksymbol = perf_event__process_ksymbol; + tool->bpf = perf_event__process_bpf; + tool->text_poke = perf_event__process_text_poke; + tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; + tool->read = process_event_sample_stub; + tool->throttle = process_event_stub; + tool->unthrottle = process_event_stub; + tool->attr = process_event_synth_attr_stub; + tool->event_update = process_event_synth_event_update_stub; + tool->tracing_data = process_event_synth_tracing_data_stub; + tool->build_id = process_event_op2_stub; + + if (ordered_events) + tool->finished_round = perf_event__process_finished_round; + else + tool->finished_round = process_finished_round_stub; + + tool->id_index = process_event_op2_stub; + tool->auxtrace_info = process_event_op2_stub; + tool->auxtrace = process_event_auxtrace_stub; + tool->auxtrace_error = process_event_op2_stub; + tool->thread_map = process_event_thread_map_stub; + tool->cpu_map = process_event_cpu_map_stub; + tool->stat_config = process_event_stat_config_stub; + tool->stat = process_stat_stub; + tool->stat_round = process_stat_round_stub; + tool->time_conv = process_event_time_conv_stub; + tool->feature = process_event_op2_stub; +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed = perf_session__process_compressed_event; +#else + tool->compressed = perf_session__process_compressed_event_stub; +#endif + tool->finished_init = process_event_op2_stub; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool->sample == NULL) diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 7913b698033a..897c6c44b6b2 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -88,6 +88,7 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; +void perf_tool__init(struct perf_tool *tool, bool ordered_events); void perf_tool__fill_defaults(struct perf_tool *tool); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); From patchwork Tue Jun 25 17:25:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E1FAC3064D for ; Tue, 25 Jun 2024 17:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=EmUdbLBZ4rEWdi1vhhQBZym3Yc lhYJ1A2jpdiQNKleGfnED2qjZfkeCztx5tIkhgP7SXqh1fArBSF1HLL6PvG/6Qtm4PeatXQhc6/ts WmP6O8za1MM6t3qqpeuWi4qLZc0qdPRRaOYRnf/qyf8vfwoNaWV6/ZBqS1PeG68+dxWOsfFWp9+89 9LtyfpRc1Tf+jObiAkzEipxm2E8a8edU4+vWn5pbPXkoE3gnKpZdBQUQrE4eTL2W5jnOaiW/CVhVj FoWQNau5G6PuVpmwYMiuvJqgOlBO3fWsrR5IT7A9KfsxeqSlZUdwMtyybufKSDS3tvkcr6bwygh55 seJ4lZxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wA-00000003sc5-3k4Y; Tue, 25 Jun 2024 17:26:34 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9vu-00000003sSh-3uRS for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:20 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e02b7adfb95so12993678276.2 for ; Tue, 25 Jun 2024 10:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336377; x=1719941177; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=AU2b1gV7FS8IN160nN1lvsO+O+WfcCvN7XllISpduijC0HKeIMyfL0EG27F/9OMQN0 ReNIqgn2zHxjcy+aH/l1prqLBO63dHtukaFAAjOInaYr7TBgNSRKDeU4TlwYdxcSY/mo 6iKALDnj8VLtniwrAdgomRaBbHSNf7fXuRR0MTUxg0NGFC/Cv8aVlNANaPuN1znAgpDb 6COtL6Y9VZa6X8vhVC+11q2gOePnnN6TjScr8SBUV/aw/T7ngv+d5/+s306qD+Cj+My/ 6WCIYYNAXuYrtTKBnTG87EAkIMb3u23MyJ5JsM3tiR8poJNUS9uG2LO0la24+DhJB4S4 8k1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336377; x=1719941177; 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=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=AUkiQPvqJ9C5NObMIN54+pv3HwCK11g6ceDIQTeQcgzukascVRj7y7mqj2AQ+ruCQ5 Zwfe14LRUatrcSJKzQuzXei3HHFoaCxMwayyM29w5A1XnORfshdO7uDxU0RaxcHZhG55 C380eeFkv9e4fkPt16xdRVnyZ6V140ycSfMmQ0qEu4Vimy8JOV697lLetMu4dUzfLXdJ h2f/Vc+2dHb/45Xq53jFGaJ2OksBmVQ89rOpUUL0y+R8osYpXBrr027qEUXbGL9pUNSU NE+Avo66BsZHdJgPcyk3vMauTxt6rGrDGb+MPIoqkOBZbBF8TTFD5pDGehzlLa+Ki9G4 jidQ== X-Forwarded-Encrypted: i=1; AJvYcCWAs5MX6n4IAa2Yo3e9QY9kCoMctCet2cBxAVU7kLuPF0+tKthfu6Red6rjLUk6Lh7sCqLiIphOVC9Bg8KuY9wPtCmHUIpXH4TPf1l1GbgI8bJ0W6Y= X-Gm-Message-State: AOJu0Yxx+1X2unT+oDl11ocAaAH0wfrWL7gcjzCP/fGiMkBK6BCjrrnQ KLhikcUOiPJxjaq+xLLOYcQl265h/0IHFRSQSXU3wR4xZ+TTSIdWDl5G+dfjqtg2sNqXe+Fa6Gm 2PIzQrA== X-Google-Smtp-Source: AGHT+IEug2riBjyQ5J5/zm+p50Ba9JZYc7CfD/IFxeRNPwpJVP3SLj0aXwP/kplaHWhb2QQb7pyYEG7HBm6P X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:f84:b0:e03:31ec:8a24 with SMTP id 3f1490d57ef6-e0331ec8aa0mr2108276.8.1719336377155; Tue, 25 Jun 2024 10:26:17 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:41 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-5-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 04/26] perf kmem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102619_162611_F6954229 X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce the scope of the tool from global/static to just that of the cmd_kmem function where the session is scoped. Use the perf_tool__init to initialize default values. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 859ff018eace..b3cbac40b8c7 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -986,15 +986,6 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused, return err; } -static struct perf_tool perf_kmem = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, -}; - static double fragmentation(unsigned long n_req, unsigned long n_alloc) { if (n_alloc == 0) @@ -1971,6 +1962,7 @@ int cmd_kmem(int argc, const char **argv) NULL }; struct perf_session *session; + struct perf_tool perf_kmem; static const char errmsg[] = "No %s allocation events found. Have you run 'perf kmem record --%s'?\n"; int ret = perf_config(kmem_config, NULL); @@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) data.path = input_name; + perf_tool__init(&perf_kmem, /*ordered_events=*/true); + perf_kmem.sample = process_sample_event; + perf_kmem.comm = perf_event__process_comm; + perf_kmem.mmap = perf_event__process_mmap; + perf_kmem.mmap2 = perf_event__process_mmap2; + perf_kmem.namespaces = perf_event__process_namespaces; + kmem_session = session = perf_session__new(&data, &perf_kmem); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Tue Jun 25 17:25:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7CC0C2BBCA for ; Tue, 25 Jun 2024 17:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GBBi2BhFlB8lzPr0QxAvcmIjepeVZAePgHWd4re5Qfg=; b=wcDRWwJbW/j9NJovYTc9IT88An 0PcQbboCVItR8rcJozmPlWcnRWtCBzUmrSdrT4eZWJN8jXrfrsIaKvf+Nj4caOTsyAt9+8Md1Fqjj gTMxzqQ4BaIdGaqvjlwXR4ns6UKzGsN1Xyj6DV+xuRTpgGoyhLA9+m5MPaIZI51nOvKiSIBVJl6cl /aQtZsL7Suxhy3I/j+aQJFYMOkaQy8R2cAwLiBySnLhKd9fBJCs1i9m9x6SGC2Ic2viIeJ2eg6gkk 0ZBDNDBNM/I+3uL8iKmUKXFqMQfKmeijPgcm3F4oxGoQyTdckTjW1iHfa9Ey7WdARqpAYGMGW+NCE lZZQGr7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wG-00000003sfq-1raT; Tue, 25 Jun 2024 17:26:40 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9vx-00000003sTb-2rSK for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:23 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64501d163b4so56795077b3.1 for ; Tue, 25 Jun 2024 10:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336379; x=1719941179; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GBBi2BhFlB8lzPr0QxAvcmIjepeVZAePgHWd4re5Qfg=; b=pQvaqbeuxXQ8u7fnff0UJcXlhmw6vzXvbfU/qZfRoYk6oAsJQo7SnFRhNTgFRvDBdK iy+yc0ruI+pApHBoIZ3WQCBOXbOfwShcWYkztQb1pdvCF+G/4xUZ/f1UnIwB+u8J1Il2 f5n5C/EEnQJjjuXtkjqmZwAGEtMC7cqZJmG7fQm9SGx6jCuvrr2anCm2NT2HUpV7mWsz V9aYXrxi7m0J0KHs2DxgIC6AKpoDmEBVEwWm8NNOC2aDMDoUam97WUiTMgNfAhgR1lBd g2TZj5Kpc0VUot9Cr1ui+XMLQWfW17snZLAwcBHiEvdHTMAKj7vgS82y4EDQgALh6VEE Xalw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336379; x=1719941179; 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=GBBi2BhFlB8lzPr0QxAvcmIjepeVZAePgHWd4re5Qfg=; b=l2sZv/Lmq/WhSH3CNYYOTp45ZTGbbys5WNY21c4sYKM5rdEBZsBNtFX6JOcI2DbNdb 6kHmUmU0CffFSrNM+ZRXp5I1c3+1W0npV9rr13lyBQPDj2Lpk8dOjVx6Byt7R1Gx50BF c0dbfjYD7YYtuDKqFoPQzzJ+bfTpAcdmqGlEHe8zRRfhim/RbgFJ5PKe4D1WHUHsXbie TYRonrdJv2q9TNtMf0qZnpIz6JHrG4gm32RP4vQ+Ro0Rl37wli1h8O0G8TQG1Kvj2d9d u3El0VLEUK3G6xHwCWoCWhc87a8QIb65z/2imp+MLk+SZA9k4x4YH18UbayTivGzp5rG s8KA== X-Forwarded-Encrypted: i=1; AJvYcCUB4Q/QSx7P/DvL3UC5mg6K92fthSCD/sLmI0dOqlKnrRxjY4BlaMDLyywQlogJudVrHEteVEa1QI9wo1dXXcTOCsPOUPEqgjuMJtgBaLukETctE5U= X-Gm-Message-State: AOJu0YyvtZ9/Tu6poQRz5FBnNEmqpci6sRlrkXnzd6Fu5UQMlTT7vmqf Z2rn1S2jxwotZZwF9ardHIPHcmOqJj6/hVp8e9+ij4o3GLGiF1odl0r1DtQM5PoqTY1PEFXYBMC NJYOsdw== X-Google-Smtp-Source: AGHT+IH3xURcUFh3IT94S8610CPB/kJYX47BxDXnoWu3+iWBw+bBvzAF+MqOxV6WXWw2nzO2TBS/LwBZCFFl X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a25:6885:0:b0:e02:ba8f:2bd2 with SMTP id 3f1490d57ef6-e0303ff5b8dmr152939276.11.1719336379521; Tue, 25 Jun 2024 10:26:19 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:42 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-6-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 05/26] perf buildid-list: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102621_752627_80EF896A X-CRM114-Status: GOOD ( 17.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce scope of build_id__mark_dso_hit_ops to the scope of function perf_session__list_build_ids, its only use, and use perf_tool__init for the default values. Move perf_event__exit_del_thread to event.[ch] so it can be used in builtin-buildid-list.c. Signed-off-by: Ian Rogers --- tools/perf/builtin-buildid-list.c | 10 ++++++++++ tools/perf/util/build-id.c | 32 ------------------------------- tools/perf/util/build-id.h | 4 +--- tools/perf/util/event.c | 20 +++++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 383d5de36ce4..52dfacaff8e3 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -89,6 +89,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits) .mode = PERF_DATA_MODE_READ, .force = force, }; + struct perf_tool build_id__mark_dso_hit_ops; symbol__elf_init(); /* @@ -97,6 +98,15 @@ static int perf_session__list_build_ids(bool force, bool with_hits) if (filename__fprintf_build_id(input_name, stdout) > 0) goto out; + perf_tool__init(&build_id__mark_dso_hit_ops, /*ordered_events=*/true); + build_id__mark_dso_hit_ops.sample = build_id__mark_dso_hit; + build_id__mark_dso_hit_ops.mmap = perf_event__process_mmap; + build_id__mark_dso_hit_ops.mmap2 = perf_event__process_mmap2; + build_id__mark_dso_hit_ops.fork = perf_event__process_fork; + build_id__mark_dso_hit_ops.exit = perf_event__exit_del_thread; + build_id__mark_dso_hit_ops.attr = perf_event__process_attr; + build_id__mark_dso_hit_ops.build_id = perf_event__process_build_id; + session = perf_session__new(&data, &build_id__mark_dso_hit_ops); if (IS_ERR(session)) return PTR_ERR(session); diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 098fcc625d91..451d145fa4ed 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -67,38 +67,6 @@ int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, return 0; } -static int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused, - union perf_event *event, - struct perf_sample *sample - __maybe_unused, - struct machine *machine) -{ - struct thread *thread = machine__findnew_thread(machine, - event->fork.pid, - event->fork.tid); - - dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, - event->fork.ppid, event->fork.ptid); - - if (thread) { - machine__remove_thread(machine, thread); - thread__put(thread); - } - - return 0; -} - -struct perf_tool build_id__mark_dso_hit_ops = { - .sample = build_id__mark_dso_hit, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .fork = perf_event__process_fork, - .exit = perf_event__exit_del_thread, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .ordered_events = true, -}; - int build_id__sprintf(const struct build_id *build_id, char *bf) { char *bid = bf; diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index ae87c4c58d5b..a212497bfdb0 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -16,11 +16,9 @@ struct build_id { size_t size; }; -struct nsinfo; - -extern struct perf_tool build_id__mark_dso_hit_ops; struct dso; struct feat_fd; +struct nsinfo; void build_id__init(struct build_id *bid, const u8 *data, size_t size); int build_id__sprintf(const struct build_id *build_id, char *bf); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c2f0e7f40ad5..aac96d5d1917 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -426,6 +426,26 @@ int perf_event__process_exit(const struct perf_tool *tool __maybe_unused, return machine__process_exit_event(machine, event, sample); } +int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample __maybe_unused, + struct machine *machine) +{ + struct thread *thread = machine__findnew_thread(machine, + event->fork.pid, + event->fork.tid); + + dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, + event->fork.ppid, event->fork.ptid); + + if (thread) { + machine__remove_thread(machine, thread); + thread__put(thread); + } + + return 0; +} + size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp) { return fprintf(fp, " offset: %#"PRI_lx64" size: %#"PRI_lx64" flags: %#"PRI_lx64" [%s%s%s]\n", diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 4b24f1c580fd..f8742e6230a5 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -319,6 +319,10 @@ int perf_event__process_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); +int perf_event__exit_del_thread(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, From patchwork Tue Jun 25 17:25:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDD69C30658 for ; Tue, 25 Jun 2024 17:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0D3Ll4YJxFSzRg0DxL5KKZwtYxMwAkaxOfW7jAWfCz0=; b=qeysIkIfKHnJMvZ7i+E2fqlXhG cRxw2Jl2OZWgqIvLys2f9bJt7LoM60WNVeqygsdSX+oehNZQxjFCEKMo+K/WPmfWdsgb8ejDnFGMs CIgCg//6VoP+kYHGMDGzQR0v7t4WAJfjq3zG5rBAhAXbXekPnf8GW9ZsyZaqkaKXZW/nxM21/XfJV WPrnSy4nSSnpCHsHq7Ks6/09zpBYjCIVMEVrL0Jx3yqlU7uM1LYp0KaM1PxN9i+zbX8iH1TB1YSSc k/F9/YWlTLwOCnUafsxIuhsuSMDRCRfhZ1wicuCe+gl+Lq+Rhj8fmliG/jF/BOygHlKSj+lPfHhT1 lKMEsLyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wN-00000003slK-26NV; Tue, 25 Jun 2024 17:26:47 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w0-00000003sVB-3YpC for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:26 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-63bf44b87d4so65856187b3.0 for ; Tue, 25 Jun 2024 10:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336382; x=1719941182; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=0D3Ll4YJxFSzRg0DxL5KKZwtYxMwAkaxOfW7jAWfCz0=; b=GbW9Y/6m6BBw0ijdidjB8M1DzoABhc0UQTT/QiKUvMKpcBr69x6vkiHwAkoLUaPJyj qkapUnY/AoZLUDNUM9F2VqeFyyt6X5GnSzNDV7uiISoA+1j6m+Fqgqitdcl8wbrnRWTY tLwx8uITxnyOXW3AGfbrVsUN6FqtntZtDek6qxgtY3FUmt7AWwKGS/c2XmVQ2lnbM3Oi ZCAV4Kr4eQffwk+K17GmA4AWwLYHRLBXSDfOpjOkBjzwDL+DNkWV3JQXpuwQtFOJNsQs FaPLyHkn+MAncpUqtmAYJppLs1hR2Mj5jg6KpLm0o61aQToheR32vvuYV1/tZzz+2icG 4LsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336382; x=1719941182; 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=0D3Ll4YJxFSzRg0DxL5KKZwtYxMwAkaxOfW7jAWfCz0=; b=T46GX2W8i+z9bj5s8WEi4KckPjeguXgRVhdq31dEaE2WDtrXz7e49FuyXcs3Q5zYvX NtVHjrWxF/+qUQF+X80draljK3/Okbf+rBD1lyON8BOSHcyRckmn+vsL8KrftfEBV8ZV YYQ7HSr8bwy3nfzrvs8vmckVIb9y8zGH29bVDRO77qcQ/qlghnBR6m2F23/HAQmc6UJ6 W3mb712veFVP+/RLOYFUdki1RbbsYxcRo79d+732HrASgmTmwDK279MXOQAF2iyotsZo NhPNK/hsV1oqusfAu3Aejx9qilR2jScysJqDEcZ/DS7Yhfk5RrHH5lfooYi/Opvu5Of3 0tkg== X-Forwarded-Encrypted: i=1; AJvYcCX503wrdLy+cfJBBnKzkhITe/Af/gTG74lzRFlngkvmtwZpA3GbifjlkRKA21LvLpMtA+mlRMnGqMvZqaVlifR7Sia4b/AyDxXu2pVrAab59WI7QIU= X-Gm-Message-State: AOJu0YwpZ5Ux5NZgLv/Lmq+CSm9aO3zCeXcYKb/cvj9wNEZhi7M0xF+a s7f7GruBjyIgPHzzVqs7fCIf39iREi/1vZ1qtglAEOCdfb2oXV793cQsy9lDtK9nOVGK6bw4gKs hMvDuYA== X-Google-Smtp-Source: AGHT+IHTa5kZKd9h8ifXYMe2T99DgFi/uV4x8OfhUXLRdl9AjprPNPjesq9BkyxfvYvf643IgrcWtu2wbIrp X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:f09:b0:62f:1f93:939e with SMTP id 00721157ae682-642544fa2a5mr2623767b3.2.1719336381892; Tue, 25 Jun 2024 10:26:21 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:43 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-7-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 06/26] perf kvm: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102624_916996_283AE60E X-CRM114-Status: GOOD ( 13.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-kvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index a3b903cf4311..692267b1b7e8 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1603,19 +1603,17 @@ static int read_events(struct perf_kvm_stat *kvm) { int ret; - struct perf_tool eops = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - }; struct perf_data file = { .path = kvm->file_name, .mode = PERF_DATA_MODE_READ, .force = kvm->force, }; - kvm->tool = eops; + perf_tool__init(&kvm->tool, /*ordered_events=*/true); + kvm->tool.sample = process_sample_event; + kvm->tool.comm = perf_event__process_comm; + kvm->tool.namespaces = perf_event__process_namespaces; + kvm->session = perf_session__new(&file, &kvm->tool); if (IS_ERR(kvm->session)) { pr_err("Initializing perf session failed\n"); @@ -1919,14 +1917,13 @@ static int kvm_events_live(struct perf_kvm_stat *kvm, /* event handling */ + perf_tool__init(&kvm->tool, /*ordered_events=*/true); kvm->tool.sample = process_sample_event; kvm->tool.comm = perf_event__process_comm; kvm->tool.exit = perf_event__process_exit; kvm->tool.fork = perf_event__process_fork; kvm->tool.lost = process_lost_event; kvm->tool.namespaces = perf_event__process_namespaces; - kvm->tool.ordered_events = true; - perf_tool__fill_defaults(&kvm->tool); /* set defaults */ kvm->display_time = 1; From patchwork Tue Jun 25 17:25:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71938C2BBCA for ; Tue, 25 Jun 2024 17:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=W+G0HGMTQoy+2+TKDBA5eg+niEy3wMk5iRiA3dPthGE=; b=wBo69axQkbOZgJr5FTyptlmTaQ XxwhdBYA898G+GlA4n/ZcQwraDBODAkHKWAR9DaMnFgkE+i5eb22fdG7baaEiuxzZmE6aGUmLmy5e TAYx9aX4ykt9mEIe9nI21+Dt69Kr0WXzBRa+AP8sLLIoKSsVmtbhrgFiCtd1RXs3lLQLQrD6nGXG+ kpMdIjYSk8Aui1omLh23bUiOriX99H8tSwRWG1afU9+LO/4OftxjfWVFgZfvVc9D5ys2UZjcr9CqM FjEb6vYqMVlRtfQs9o+JZvBD/eRLwg3h6Wmudl7LicTyAO5aqghAuyuzn0U2PKnWLdygkV2Q8FH8P KG3fhmug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wc-00000003szD-40MN; Tue, 25 Jun 2024 17:27:02 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w2-00000003sWT-24RM for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:27 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1f99cbb8898so61553615ad.2 for ; Tue, 25 Jun 2024 10:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336385; x=1719941185; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=W+G0HGMTQoy+2+TKDBA5eg+niEy3wMk5iRiA3dPthGE=; b=1VVIxjKh0morUEyP4ZwP1vLWxm79VTj/hQU4KUrj6DypognKFG3JCKnOZFuJ7aZ4cD shBvNAaNiExNp3Eeo9hLZXKJf41mvM2YMuresfPHfMzxim4xvIB+2ASe10cnQwRYo8TL 9vc+GNIi7WXebvinSCVBK3cJjB+QatxFojSGwqQkSrPl1lracmdDdWYpzyWS7MlpRrAc 7zfedjBR7b3Cwuquz9oM1S7ztGhIX1lLgS8LwWeFlYHIPpfdaZyw1f8P1Gz6nnQojHT/ CYhdFE2ozSKoaE27IxD56THFhPh5SMeDEAwL5By5EUmv0vBoHdOcwgl7nDCcPtf7GVlO JAqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336385; x=1719941185; 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=W+G0HGMTQoy+2+TKDBA5eg+niEy3wMk5iRiA3dPthGE=; b=mujtnL+IbR4SLQwLccL8Y4snGJ53vMvHONLtqC/dDB2hHr2ZbvAM8ovrdIjCfbXcRj qco16+aL0N67UCysenV+jKc0SHY45OAF7wU4pD0bO+ESoey/FH5vMKRfjFBqpwPpNWMd 6p6gnr7kJA/Fc6wHFtl7qkCpGwh0Bpiv/Y9zcaLg++eXG6afvxlNSeUNE1NCQGBig0Bh UG4hN6xEeR2/vVthgd75O9Tq8FUnTH7LlISIJODsCRTxGCOizqYGUICtkBw0VKyfsMsd E7lN8XM0+k3oER7I0qBHyYNwV8cTmVtWLXCu3aq50PReHnPghFfNSAJeCgNs7MFJclWB 6jZw== X-Forwarded-Encrypted: i=1; AJvYcCUI5Eu+AiEePJtAJ7y9/L5HomOMQgmvf3PaNHUEvbXqtvBXm4BbiZr6xuZxhHZnoXhPDcveCNWPjJ3tvWug/iJrlbJdHpDtCQVLJas176FCk8qyVqE= X-Gm-Message-State: AOJu0YyYD5A66pzlRM6B8V38JYIhBeLvqqSG+WuFQ1vGl/3kzdWjn4c1 NqMDnwHMt5U9brcd62FTwGJBeQhf4YjlP50SGIvHL4lK8oRkSd61/4+pg+09WB1MAAkROIHh14R Djchcqw== X-Google-Smtp-Source: AGHT+IHOTIs1TEWUF2nY5PaBtklSJ7BTMufz9SMTvG0c7ZGwua7i2kerndcI2mz9IJ9qz0PZ44pVysp4aUve X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a17:902:ea11:b0:1f7:2f46:8bfa with SMTP id d9443c01a7336-1fa23f00860mr2545505ad.9.1719336384865; Tue, 25 Jun 2024 10:26:24 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:44 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-8-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 07/26] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102626_587103_6F447E5E X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 6efa9d646637..2c216427e929 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1933,22 +1933,21 @@ static bool force; static int __cmd_report(bool display_info) { int err = -EINVAL; - struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .namespaces = perf_event__process_namespaces, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; + struct perf_tool eops; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, .force = force, }; + perf_tool__init(&eops, /*ordered_events=*/true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.namespaces = perf_event__process_namespaces; + eops.tracing_data = perf_event__process_tracing_data; session = perf_session__new(&data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); @@ -2069,15 +2068,7 @@ static int check_lock_contention_options(const struct option *options, static int __cmd_contention(int argc, const char **argv) { int err = -EINVAL; - struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; + struct perf_tool eops; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, @@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **argv) con.result = &lockhash_table[0]; + perf_tool__init(&eops, /*ordered_events=*/true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.tracing_data = perf_event__process_tracing_data; + session = perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); From patchwork Tue Jun 25 17:25:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF959C3064D for ; Tue, 25 Jun 2024 17:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D7OMHNdMQjRxTIzl2tG5KSezF1r+KBWLgOtS9uud1dY=; b=TlFO2PXKpZdP4FnlVY8DAJUfzM snzYaer0A9c36SuI+y0iZL49RD91InPvI/vCaK1eO4+u/h3qCBfFTBF1gcl/oeOJXOOmy4CuVQ4gP r6ZAOw7kDgcGeCq1GNVOMS/5s0DIg0Or4pAo5iPOnw7pvmHgbE61LH0dfIzXB4BlQne0+s61zl7t5 bnk68GLLL85UVKv56NvBBEd5KeB1dLPBk8dkaPO17lsMbA1CQNijIrKkLhbBMpa/oPWYHS2P/J8TE QENUvZ8sVnuZIoW6vcBGkVqhm+U80c+8XFAz3iEH2y9X22NDtugw4pYAHlYuExWx4YabQaQOdgu07 nAVl8uTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wq-00000003tAM-3KEI; Tue, 25 Jun 2024 17:27:16 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w5-00000003sYI-07Kr for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:30 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6452f8f2942so49303437b3.1 for ; Tue, 25 Jun 2024 10:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336387; x=1719941187; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=D7OMHNdMQjRxTIzl2tG5KSezF1r+KBWLgOtS9uud1dY=; b=p9ROi/c9hiThWcC+20P78A53AdfoAiYpTdc6SKJ+68yzFUJ9dAasz741X2BYPNR/lF WJqYNxky8qsM4FvubzVwBJk6MMDxL+V2hgA/huGk8Roz5FKPQ3Fe54Gw3J69N1qpzxou +OwCKbPUph6kFpHBJ2yn8wja2z52NBdgK1Dyqs+ALeU3ogKHWApOaZcTqAACcHuhIiON sJ+y6V5Jid8lpCm8zFf/j7SHGzMLTbwgoBlL6ch74CM0IQGvHFUZz4J3AJiP5wAsilUO Zy3F3noDmBF6Kimk/hJDju8EV8OHzIjXuMezYzNY0quzBi5i6jjPwyH6vf+B+kqOxt1K QbXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336387; x=1719941187; 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=D7OMHNdMQjRxTIzl2tG5KSezF1r+KBWLgOtS9uud1dY=; b=tet1yA+TD4HELqeiBmyMoVYSV4uOdg2+DXwboe83W/+Qdsn17oOgWcWHj6y5x7MZw6 ikbUPuBLvUhuyFOFhjhaI55IfzjSsNJksyMvAZ/iligYIydjMY44GzaW3ZLZ7pCAhm/t 7tDq/KWSg7UTr41bnrK+qIAZbfQxlZEVTzex/6R3VI6UA7Y/Gr5Jf67HbOd1UR2DmCpy H2Nzj3FwNXM8YJHmJRXy7tCMflElizPQcBR2Q52RJFbqY2e2oX+m/VNQ5GKQydc0wSwT hn4CZliJa41lI6JDv46e1+wHcNLh5WOCFsAN4YldJ8Dwy8lvpjp4IamP2FjHFCWWwvDD ajYw== X-Forwarded-Encrypted: i=1; AJvYcCXRorv+NO6nZq92mL/K+0igDZ48i8j7fUjCnrUT3c5FncolgqtCyt2Fu3ecJFJuzj9MVPetqVdhJsdqVNP+1kXTnsQFwZD0lCNAhUifwDZZhRi6amM= X-Gm-Message-State: AOJu0Yz3LRNJ5ZMLXoA8OnslIaaaV7zi6wYppiHJjGr6oPDkJ3p9+M1x h+uZMN5OFhl7tMi8y+WprrB99EpHYWEsbdRrvZkNSq0gao5ibe0xO45Fo++5dzJfckwKf5eio4+ IK2ihhg== X-Google-Smtp-Source: AGHT+IH5h+dU+rx5/EzkOoL79J/aVaZxf4gqHCwS5PQ8xku91EOiUh0yDtxvx/LFGnUXXUyGm4vqfn586d+V X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a25:2d10:0:b0:e02:7b18:fd6b with SMTP id 3f1490d57ef6-e0300f19e7bmr58675276.4.1719336387272; Tue, 25 Jun 2024 10:26:27 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:45 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-9-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 08/26] perf evlist: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102629_099821_3CD5F9E8 X-CRM114-Status: GOOD ( 14.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-evlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 7117656939e7..818ab21c3f73 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -35,13 +35,13 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details .mode = PERF_DATA_MODE_READ, .force = details->force, }; - struct perf_tool tool = { - /* only needed for pipe mode */ - .attr = perf_event__process_attr, - .feature = process_header_feature, - }; + struct perf_tool tool; bool has_tracepoint = false; + perf_tool__init(&tool, /*ordered_events=*/false); + /* only needed for pipe mode */ + tool.attr = perf_event__process_attr; + tool.feature = process_header_feature; session = perf_session__new(&data, &tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Tue Jun 25 17:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B666AC2BBCA for ; Tue, 25 Jun 2024 17:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0i4pVqwbk0skHdH7qbkMIerLJTSVfnhcqEk1r/vEHks=; b=Eud0aVGTZY+64c0Bv0zwfgdETb 8Sbe47hjVJyFWL5OW2KjPWyvaCqgcDieB00gRrASP5PYcZAO6v2v3hYLO4gBenG6zTXKVLo3jJl1R /XiOFNmunrn/rFVrrmIu5n6AwRGLG7DcSTNd9CYp0ogYunW6h44UZ22n1Op32ps0aVkEfVCF5cEpu 6Gu4zCIHoXUzxzccuPLEuvCBlAJAXcF85jMPCc/QgfpTY3/wlzJaKwE7ryeFSKq4pDqqZb9VDtf1S ulZBE35jkmy0nyJf3jJp8ezxLsaiKBHoCftN890Ybuo/OyArlU4JD0UDxfZNJuSOfAaC/uhRCKvil maJSpZAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wu-00000003tBx-0E7h; Tue, 25 Jun 2024 17:27:20 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w7-00000003sZG-06av for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:32 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dfab38b7f6bso10644666276.0 for ; Tue, 25 Jun 2024 10:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336390; x=1719941190; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=0i4pVqwbk0skHdH7qbkMIerLJTSVfnhcqEk1r/vEHks=; b=UavXbU0ba62117BfBjo/T4qGhp8UVn9lEc0xwon5dX2Hea7YTr5OYFM5bWwqTpLHzb Q7usXX6/CuSMYcdvU12UphRBHjrLyqAJcGYax8I4KjWc/8V8kam5HwNqfFTpPIQdPraD oKEkG3JxcOTfcd8Chy3Mx8dsISDgcwx38SYjBxX0YZmhurIvehI+LKX6xeadvnFioOHA iHl5DuGtHk7SGghbjUL/ZovJtAH7PrlgSuynnG1/zsRLD5krQ+zBysBRfqv77HtngNQg HTUMQ0fjU8edlvHf0uL8gLMJjzxOvSkebNiUrTkrt2I2mncuHJ6diXjwHl8dtIe9U5/E vcZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336390; x=1719941190; 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=0i4pVqwbk0skHdH7qbkMIerLJTSVfnhcqEk1r/vEHks=; b=tZ/CV01eIVTqPD/LM8c0q3AABCeqmHrdzL7d9ZBUmPa1bez4kuKgcN99gjFNs3KOyL 8EziLMIA9J2L2fQo2p2lkFvk4zmotMLInd3+i8d0Qz6ebR4nakuXJv0LTrySn2ohTuok nB6HQUSeKaDpp6mX1e31+SmFTHBgdd2uyLlXTPpKW0Uaunvhan76vyBtRlhIMbwdlxsE HGdzlEXEJZUjF8g8/up/v+Ln2pzcKk8HP0Py03mwXnJOYGDn17IKf4roZjbyU04qpaFf 8cgpFL34+i6i4ehTHDtOStVpiICSnHvgVJB2L4rH32F/ItyIdzPtXC26J+yyEWVxoJOS F6xg== X-Forwarded-Encrypted: i=1; AJvYcCV8BuziUkf9yCJPX84blf6Plo3w648b9Ffuhs9LZYsm7NIrjMTCTZgv5EmGr4QVZMPBA11eJvXSA68z29PfFGKuO9fs1lARVIk4DnG66Wss9fKbrNE= X-Gm-Message-State: AOJu0YzgApkeYfjZKvjEVeJy2JQdktejaxn2L/mQySiJ7IM+bj93ZjZ2 AiKBgsFzgYrVUg6rsfZPWrxIGoD/vy5zv9Avc535KCFaJARQ0GkngJcxRLIIKX4DQhx2T2twhDq XDmNU1A== X-Google-Smtp-Source: AGHT+IHNZBdjbRKy77cEdS+R0hAtjYvzJglBq5vgHL8qU1wiMivtXiT+B4vfJOWsL+Br8ihI8B+CKHjdllSj X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:2b8d:b0:e02:c619:73d with SMTP id 3f1490d57ef6-e030403de41mr241333276.5.1719336389625; Tue, 25 Jun 2024 10:26:29 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:46 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-10-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 09/26] perf record: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102631_099940_1A89ECA4 X-CRM114-Status: GOOD ( 16.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-record.c | 33 ++++++++++++++++++++------------- tools/perf/util/tool.c | 10 +++++----- tools/perf/util/tool.h | 6 ++++++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 21793c170dbf..f7db7be562b0 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -193,6 +193,15 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = { "SYS", "NODE", "CPU" }; +static int build_id__process_mmap(const struct perf_tool *tool, union perf_event *event, + struct perf_sample *sample, struct machine *machine); +static int build_id__process_mmap2(const struct perf_tool *tool, union perf_event *event, + struct perf_sample *sample, struct machine *machine); +static int process_timestamp_boundary(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); + #ifndef HAVE_GETTID static inline pid_t gettid(void) { @@ -1458,7 +1467,7 @@ static int process_buildids(struct record *rec) * first/last samples. */ if (rec->buildid_all && !rec->timestamp_boundary) - rec->tool.sample = NULL; + rec->tool.sample = process_event_sample_stub; return perf_session__process_events(session); } @@ -2402,6 +2411,16 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) signal(SIGUSR2, SIG_IGN); } + perf_tool__init(tool, /*ordered_events=*/true); + tool->sample = process_sample_event; + tool->fork = perf_event__process_fork; + tool->exit = perf_event__process_exit; + tool->comm = perf_event__process_comm; + tool->namespaces = perf_event__process_namespaces; + tool->mmap = build_id__process_mmap; + tool->mmap2 = build_id__process_mmap2; + tool->itrace_start = process_timestamp_boundary; + tool->aux = process_timestamp_boundary; session = perf_session__new(data, tool); if (IS_ERR(session)) { pr_err("Perf session creation failed.\n"); @@ -3342,18 +3361,6 @@ static struct record record = { .ctl_fd_ack = -1, .synth = PERF_SYNTH_ALL, }, - .tool = { - .sample = process_sample_event, - .fork = perf_event__process_fork, - .exit = perf_event__process_exit, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .mmap = build_id__process_mmap, - .mmap2 = build_id__process_mmap2, - .itrace_start = process_timestamp_boundary, - .aux = process_timestamp_boundary, - .ordered_events = true, - }, }; const char record_callchain_help[] = CALLCHAIN_RECORD_HELP diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index cbd9b888bd73..a4ca16e5eefe 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -99,11 +99,11 @@ static int process_event_synth_event_update_stub(const struct perf_tool *tool __ return 0; } -static int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) +int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) { dump_printf(": unhandled!\n"); return 0; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 897c6c44b6b2..fb7e32d98dda 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -93,4 +93,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); +int process_event_sample_stub(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct evsel *evsel, + struct machine *machine); + #endif /* __PERF_TOOL_H */ From patchwork Tue Jun 25 17:25:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8496BC3064D for ; Tue, 25 Jun 2024 17:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6guPMXmcdW65GtfPCYKyOHBofbB3BqlsDiMCqc1Wqps=; b=RL1zBB9rPj4d4rg6zuIEPLdJZq hKuBYDSy+wTubsR5Z9cqHNmasRJI8Ik61l+2PUlOAZCHTaCFN/47Ncjjvm+Xo+lHFVSQSH5/yV6GE hmMPo8HfinZ9ZEns35oUMH12xCcUxgiPEsyjfbsiBm0bYqObsxdjcPqLw5dV0bQc+GrjtITrb7WFS 6FrYDPZB5/sn5/iXiMVfq64pHKb+F1+ibRvy9yc4MzRLhECsFVbJXm1nlpR+nYbEL/VhxC60MqpzI RGqbD1X3ymDZQDj5t511piIXh+UjIJMb/TZtfK6MDgnKURmLvkvkX5JEpmK+x6JY0nyt0LKkoMMu2 e42FVoHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9x0-00000003tFj-00Hv; Tue, 25 Jun 2024 17:27:26 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9w9-00000003sau-2a9T for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:35 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-632588b1bdeso110174847b3.2 for ; Tue, 25 Jun 2024 10:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336392; x=1719941192; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=6guPMXmcdW65GtfPCYKyOHBofbB3BqlsDiMCqc1Wqps=; b=IU8sguivNMHhGm/gHiQYXAFPs1qzcOcHz6RckGMn19Lw94JLSa3dY0t0XjYWzjaWf3 PImlcydeXTMVE4DqbzUnZRRbQDLi1XBM9LowR1xAu4sxrpCDS0fLDkCWJH0T1FIR9dyi ws1xSn+XFRe5DElCoTnn2DV2VMSe+eFZbOQCHjvnzgDcbWKEkijE5aczDSzcP3gqa8Zm wxIHCpcdPHvkV1II8puncgjvFj+TvsKe3t1tVvvH4FXsfxPjj0Oi0Leza4TTX8sEwerd pkPFoEub117lWQrk12BxMRYgTMHf7YJscVT3/Vm+Ce9WBo8Gb/15OLWgPmk43yCgyz+e NZTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336392; x=1719941192; 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=6guPMXmcdW65GtfPCYKyOHBofbB3BqlsDiMCqc1Wqps=; b=M2cWvQBNfUnU/Q9/IK/MiSVz9Vyb6Q1TJA7siIyjvoZt7GavA7EJ0s6L5Vun/W6vG7 RdFQ28WkpFBfxHHocgduHA+kuWbMr7xgf/tO38xpDPrJhuZTQlob0MtniMonRcEHZbfB lTQAKbpZDai7p388gAqa9kvCFO71xCqZwiTS++RvHTfdlAC9XuuPZ73SEJdbDi4Di4HP 3OlCIxvZvcCYD9TOjvCIdvbGgbfxerISLTb704+lK+0hCywaqI/2Hh5He8sOh/ATPF3L MI/kI4CK+RLkS1EZRDSYuPFdugaH/5muL0IOolp7Iq2Y74TduJYGIUL3rpxePd1JRmaM r0Aw== X-Forwarded-Encrypted: i=1; AJvYcCVJCE9jSCUvC6IGCxLB2xqjM+XApyfF3tAsTGeUH2d3n2D1XIa3qOf/70CM4CrIHK+AZQkFrYXNbg31n/etXo0x1YaP6WMTtP/F1S5tSsne8ab975k= X-Gm-Message-State: AOJu0Yy7pVgFtIJDL/itak7ub2PHXbXVSc7kQOquWtlV0eOgpyCpn25C pdsOUx6Iym4NZv1bVL+Aeov4PhsqJ54faBlRkOVwMlfLWl0vfyLVdRADsUT1/rfTAz/5vvLTDHV HupwpTQ== X-Google-Smtp-Source: AGHT+IFV8nFgbzCmqp5624khLyjgblB+C7PSMAG99rhpEHx97+eQXMZPvyVLcBZvUnoqdEaw5LZAWS/mgVDn X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:fcf:b0:627:7563:95b1 with SMTP id 00721157ae682-6429c6dcf91mr317197b3.5.1719336392078; Tue, 25 Jun 2024 10:26:32 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:47 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-11-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 10/26] perf c2c: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102633_858687_7FC55792 X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-c2c.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 88c131d05186..cd2bd573bfc3 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -385,24 +385,6 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused, goto out; } -static struct perf_c2c c2c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .attr = perf_event__process_attr, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, -}; - static const char * const c2c_usage[] = { "perf c2c {record|report}", NULL @@ -3070,6 +3052,19 @@ static int perf_c2c__report(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; + perf_tool__init(&c2c.tool, /*ordered_events=*/true); + c2c.tool.sample = process_sample_event; + c2c.tool.mmap = perf_event__process_mmap; + c2c.tool.mmap2 = perf_event__process_mmap2; + c2c.tool.comm = perf_event__process_comm; + c2c.tool.exit = perf_event__process_exit; + c2c.tool.fork = perf_event__process_fork; + c2c.tool.lost = perf_event__process_lost; + c2c.tool.attr = perf_event__process_attr; + c2c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c2c.tool.auxtrace = perf_event__process_auxtrace; + c2c.tool.auxtrace_error = perf_event__process_auxtrace_error; + c2c.tool.ordering_requires_timestamps = true; session = perf_session__new(&data, &c2c.tool); if (IS_ERR(session)) { err = PTR_ERR(session); From patchwork Tue Jun 25 17:25:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DE1AC2BBCA for ; Tue, 25 Jun 2024 17:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XrweehdAa2tkZxz5Zxp9wFN4gNwYxCO/FheTIJk34FQ=; b=bSxdFg8hkdPoQOq9WVyENTZRT9 WNr3QoqMNHkGdvqxkODZAFYaBkqjZ5AP2ZsY/ntMFb09cbiQyQNqdd9tuXN6rQG3UF3n+z8GDoUYR NOgqUs6YmAoB/jw0fGX4QOnzpNX/YiXdyxEwXIaAYrr1BVdwuR6D779oJQPumnSz6TGpOFuECB5FH c8GapZYdHfFdw6b3sxf1ZG3sTjYCSGekWpF2K9t7lh5d59RdNHhhFZi0Xdbdf7uupVb07vXNEoR1r 7AtkQjN6BP77BYhlq0pLUmcHsYJ8p1d5ihcsqP22hFFdiA+ObvCUzVUnVU6IR6jkemJhylaLKHeGo lRwPS9cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9x8-00000003tLG-0R1J; Tue, 25 Jun 2024 17:27:34 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wB-00000003sc4-2lJy for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:37 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e032d4cf26aso871974276.3 for ; Tue, 25 Jun 2024 10:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336394; x=1719941194; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XrweehdAa2tkZxz5Zxp9wFN4gNwYxCO/FheTIJk34FQ=; b=c+gnYcCvJvd4Cldh1Pj+d+WupvgTsxqxXyaq1qyFknCSn9+4mTmX0e+pscicH5YmZb elDwDpRnymUxq1BDJl9Eo6pmBSUYGwy8tF5/P0Jw4DM37UE4vqfDg/LAu5Mo/oiOpGID O5iF8swSmQDtJDQcIJ/a6dwzHNKgpaOgoNnjPX/kdC8BqqNmAOfyNBjg+PCZ/ahd7iAH 8J0q0wUFfTltof0GKwI3KLd3rrEb7Ez9MR0eGkkluWr/R+jbI7ZVQWmexMZHTv9dbjLE Ysmii5kQDQE326PyxMp+Sj1fbEahfMSyEIpbqXDYNg+XVioh7GfVen1ie/yP7dX6IsMe 5xqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336394; x=1719941194; 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=XrweehdAa2tkZxz5Zxp9wFN4gNwYxCO/FheTIJk34FQ=; b=lGjwYKZSjsLhrKRS+yjxIgyQU5BySmlFhJdijgD37CvUiFNNq54cJlDNiyxqVldkzo qwIT2/XX8NvlEMQJGfJ1y7D+Zs0Sy7nIrlevAgs64wXI9OQ88f/6w+y3FlRS58UvquJy ELYCdKmFkKn3g9UDPyAP0HNhq5DVBYlhzkG+V4oc1i6E6bB4/tQAQ29pxSBnAmmPqVqA RAw2h94Ezz+XsNnk0iBT7THgm7ga26/ijrl0K8W7qPmPjBPFYNMFYc1MEtDGQZ6V1xN+ bhuP3EGms3fDu+z9tAgRhWVv5NnJSGdG1DLNnDHiO4L0KCx4WJkSqJaPDv1IebVqSr4E SiKA== X-Forwarded-Encrypted: i=1; AJvYcCV7OJZwmVEj4Q/YvdTEE3DC102K2C+7127nh2lfAz79VOumUwtCWtvalDk0uOQBGZyUV4Fj5lvKZvs10D8LknQ2e96/YA403Of+RNBH/2vMPr7IYA8= X-Gm-Message-State: AOJu0YzONLhoqg+LiERsuqh4gx3XNIXrwOflXVJeHWcObLffclRwI9lB xnNkpeIycXeTC2/9SKXVWaRXFkliS/jaJ8dwxh7RQaBS259/cwIY8heIOtl88Eyfjd+peF8FFqn zGb2TXg== X-Google-Smtp-Source: AGHT+IEUAqxicES2UtcaEb6UDQ+bDldZC47HTYRjmbObzHA40nFed+1pv/51vSijPeWYxPRv8nv6BqF9dCbq X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0a:b0:dff:83e:b259 with SMTP id 3f1490d57ef6-e0304040464mr259080276.6.1719336394399; Tue, 25 Jun 2024 10:26:34 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:48 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-12-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 11/26] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102635_798401_3A083E87 X-CRM114-Status: GOOD ( 13.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-script.c | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 394bce9f5338..b4fc2971335b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3899,38 +3899,7 @@ int cmd_script(int argc, const char **argv) const char *dlfilter_file = NULL; const char **__argv; int i, j, err = 0; - struct perf_script script = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .attr = process_attr, - .event_update = perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .feature = process_feature_event, - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_script__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - .stat_config = process_stat_config_event, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .throttle = process_throttle_event, - .unthrottle = process_throttle_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct perf_script script = {}; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; @@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; - if (unsorted_dump) { + if (unsorted_dump) dump_trace = true; - script.tool.ordered_events = false; - } if (symbol__validate_sym_arguments()) return -1; @@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser = 0; } + perf_tool__init(&script.tool, !unsorted_dump); + script.tool.sample = process_sample_event; + script.tool.mmap = perf_event__process_mmap; + script.tool.mmap2 = perf_event__process_mmap2; + script.tool.comm = perf_event__process_comm; + script.tool.namespaces = perf_event__process_namespaces; + script.tool.cgroup = perf_event__process_cgroup; + script.tool.exit = perf_event__process_exit; + script.tool.fork = perf_event__process_fork; + script.tool.attr = process_attr; + script.tool.event_update = perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data = perf_event__process_tracing_data; +#endif + script.tool.feature = process_feature_event; + script.tool.build_id = perf_event__process_build_id; + script.tool.id_index = perf_event__process_id_index; + script.tool.auxtrace_info = perf_script__process_auxtrace_info; + script.tool.auxtrace = perf_event__process_auxtrace; + script.tool.auxtrace_error = perf_event__process_auxtrace_error; + script.tool.stat = perf_event__process_stat_event; + script.tool.stat_round = process_stat_round_event; + script.tool.stat_config = process_stat_config_event; + script.tool.thread_map = process_thread_map_event; + script.tool.cpu_map = process_cpu_map_event; + script.tool.throttle = process_throttle_event; + script.tool.unthrottle = process_throttle_event; + script.tool.ordering_requires_timestamps = true; session = perf_session__new(&data, &script.tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Tue Jun 25 17:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2E5AC2BBCA for ; Tue, 25 Jun 2024 17:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=j4wPLxjotcBveIZ/B9wKVxXKe3+485cgtRlewbIxK0o=; b=YgiofWGgNR5lwiD0J60EsxllPd x59Wply2qfci2G69d86z0/9ac/AAOOY/BzmsMptM6aGkHyU/ddGo0q6hP8qC74mlodp/GV65eDKwD YK3BYD2gyRgAFU/KfY9wG3rcxFcgLlcB0fdiXz8s0BBdHECU5Ut1MqFFKjZA6+toKfTicng6D7lxw KZI/079rHSQm/FoIpgni2M98lMJ0S3Kqfj+xzjBpLzfT9Dw3CPXh+08H2+K4bB73/FDbdZ6QHCR8r a/Ggtk9Plc3TgowHts1TS3tK+9xruZ8563foJAXsalCQ4FSargpU+OzNY26BNgjFJEZ8bHB85Znko t5oVFSNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xF-00000003tQW-2Eu1; Tue, 25 Jun 2024 17:27:41 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wD-00000003sds-41L1 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:40 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02bb412435so12327268276.1 for ; Tue, 25 Jun 2024 10:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336397; x=1719941197; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=j4wPLxjotcBveIZ/B9wKVxXKe3+485cgtRlewbIxK0o=; b=h3rvzWEqbXJKgrGBrrFz6/9ou8RjATbzEpVlpyFEJehtb0uSKjo9xZSZMgqaW0bU1s s6ejVXvMauz0iKxjOMSf5W8d3CddhLtde2FQ/OkHSBfdRAjPVmqJZ3y5zu1UjRhZfKI2 30Zo2fCkVvgSjWiItQFQ8cy4jXT59+Jp/1ziEXvbL0uYeG6hqbz6teJv0WJcT0SQClmN DYAgKwD8PZ3dfbCSyyNyR3crcGwOFAOVKxoWNEfO72yU9INn6RPbt7X9LKIG3ugOwy3h ZhnJhRTn0GC4LiBRS3Ml7eKVPqIvdGUIpzSdKOaA1M+GAq1rykPx3zbrOhiZx64QLAwK ebug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336397; x=1719941197; 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=j4wPLxjotcBveIZ/B9wKVxXKe3+485cgtRlewbIxK0o=; b=ZAGnboXdpHRsQGkUNXLLEl2tjky5Rd8MOQp6jQLY5EETOfqAkUbASYC6NS/t2gknOc sV3GqFr4eFKX9mi71Lry5hUQOkKIT0d71Rrs43RepsCkIFeINaauqRekC3/LDPJ/z2En JmBTvDGJzQqpgys5RoqJf0MOjJbTv+rkrahV9ChI9eeVszl7fkAaJL3IdQ7rPQS0suU8 Aqp3OHtWwu1MaeSMaWufF9lc3LdkqKS/5yZzZ6agHIQyAb3zd3vcU3t6ZbEu2JaURUUJ vbyvfuH987Wan88k6g7UA8jZPVM99klOQRh9ErE3O6oC/0j45yJZCX07tL6AM8BYZ2Es CnXQ== X-Forwarded-Encrypted: i=1; AJvYcCUE15o90D/hiuWshobyyyw9g73rpxPeXkNh4tj+z6seeaUcmTho+6kPL728oOq0kIcc0/WptnbQKY0SG2zpB3St2N4st0/MhRPFG+zHIoPltXuVHas= X-Gm-Message-State: AOJu0Yzf/BmRfkTubhyeR9Y1/2WT01aqwTTAgi9tNg721GRoLIjZZzcW yHQkQzwZAx8fmB+TGCQbTodZDwjBHszSSs9M9hCsmkFjwF16IMteWej7SfCB0Gj1Wp494hhnN7v AHMk32Q== X-Google-Smtp-Source: AGHT+IG1LH1Wzd13OXLryDCkXIp0QO65FA6sHkcaT1c56e9vUmU0cereuwsdgRV57P6W/jf6IPK1ZiLkhtxS X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:1205:b0:dfa:8ed1:8f1b with SMTP id 3f1490d57ef6-e0303fd438amr451158276.1.1719336396822; Tue, 25 Jun 2024 10:26:36 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:49 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-13-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 12/26] perf inject: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102638_176390_27AE0735 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 89 +++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index be74e2bf1f00..2866756d5060 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -2165,46 +2165,6 @@ static int __cmd_inject(struct perf_inject *inject) int cmd_inject(int argc, const char **argv) { struct perf_inject inject = { - .tool = { - .sample = perf_event__repipe_sample, - .read = perf_event__repipe_sample, - .mmap = perf_event__repipe, - .mmap2 = perf_event__repipe, - .comm = perf_event__repipe, - .namespaces = perf_event__repipe, - .cgroup = perf_event__repipe, - .fork = perf_event__repipe, - .exit = perf_event__repipe, - .lost = perf_event__repipe, - .lost_samples = perf_event__repipe, - .aux = perf_event__repipe, - .itrace_start = perf_event__repipe, - .aux_output_hw_id = perf_event__repipe, - .context_switch = perf_event__repipe, - .throttle = perf_event__repipe, - .unthrottle = perf_event__repipe, - .ksymbol = perf_event__repipe, - .bpf = perf_event__repipe, - .text_poke = perf_event__repipe, - .attr = perf_event__repipe_attr, - .event_update = perf_event__repipe_event_update, - .tracing_data = perf_event__repipe_op2_synth, - .finished_round = perf_event__repipe_oe_synth, - .build_id = perf_event__repipe_op2_synth, - .id_index = perf_event__repipe_op2_synth, - .auxtrace_info = perf_event__repipe_op2_synth, - .auxtrace_error = perf_event__repipe_op2_synth, - .time_conv = perf_event__repipe_op2_synth, - .thread_map = perf_event__repipe_op2_synth, - .cpu_map = perf_event__repipe_op2_synth, - .stat_config = perf_event__repipe_op2_synth, - .stat = perf_event__repipe_op2_synth, - .stat_round = perf_event__repipe_op2_synth, - .feature = perf_event__repipe_op2_synth, - .finished_init = perf_event__repipe_op2_synth, - .compressed = perf_event__repipe_op4_synth, - .auxtrace = perf_event__repipe_auxtrace, - }, .input_name = "-", .samples = LIST_HEAD_INIT(inject.samples), .output = { @@ -2269,6 +2229,7 @@ int cmd_inject(int argc, const char **argv) "perf inject []", NULL }; + bool ordered_events; if (!inject.itrace_synth_opts.set) { /* Disable eager loading of kernel symbols that adds overhead to perf inject. */ @@ -2333,7 +2294,47 @@ int cmd_inject(int argc, const char **argv) if (strcmp(inject.input_name, "-")) repipe = false; } - + ordered_events = inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); + perf_tool__init(&inject.tool, ordered_events); + inject.tool.sample = perf_event__repipe_sample; + inject.tool.read = perf_event__repipe_sample; + inject.tool.mmap = perf_event__repipe; + inject.tool.mmap2 = perf_event__repipe; + inject.tool.comm = perf_event__repipe; + inject.tool.namespaces = perf_event__repipe; + inject.tool.cgroup = perf_event__repipe; + inject.tool.fork = perf_event__repipe; + inject.tool.exit = perf_event__repipe; + inject.tool.lost = perf_event__repipe; + inject.tool.lost_samples = perf_event__repipe; + inject.tool.aux = perf_event__repipe; + inject.tool.itrace_start = perf_event__repipe; + inject.tool.aux_output_hw_id = perf_event__repipe; + inject.tool.context_switch = perf_event__repipe; + inject.tool.throttle = perf_event__repipe; + inject.tool.unthrottle = perf_event__repipe; + inject.tool.ksymbol = perf_event__repipe; + inject.tool.bpf = perf_event__repipe; + inject.tool.text_poke = perf_event__repipe; + inject.tool.attr = perf_event__repipe_attr; + inject.tool.event_update = perf_event__repipe_event_update; + inject.tool.tracing_data = perf_event__repipe_op2_synth; + inject.tool.finished_round = perf_event__repipe_oe_synth; + inject.tool.build_id = perf_event__repipe_op2_synth; + inject.tool.id_index = perf_event__repipe_op2_synth; + inject.tool.auxtrace_info = perf_event__repipe_op2_synth; + inject.tool.auxtrace_error = perf_event__repipe_op2_synth; + inject.tool.time_conv = perf_event__repipe_op2_synth; + inject.tool.thread_map = perf_event__repipe_op2_synth; + inject.tool.cpu_map = perf_event__repipe_op2_synth; + inject.tool.stat_config = perf_event__repipe_op2_synth; + inject.tool.stat = perf_event__repipe_op2_synth; + inject.tool.stat_round = perf_event__repipe_op2_synth; + inject.tool.feature = perf_event__repipe_op2_synth; + inject.tool.finished_init = perf_event__repipe_op2_synth; + inject.tool.compressed = perf_event__repipe_op4_synth; + inject.tool.auxtrace = perf_event__repipe_auxtrace; inject.session = __perf_session__new(&data, repipe, output_fd(&inject), &inject.tool); @@ -2372,7 +2373,6 @@ int cmd_inject(int argc, const char **argv) * mmaps. We cannot generate the buildid hit list and * inject the jit mmaps at the same time for now. */ - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true; if (known_build_ids != NULL) { inject.known_build_ids = @@ -2385,15 +2385,10 @@ int cmd_inject(int argc, const char **argv) } } - if (inject.sched_stat) { - inject.tool.ordered_events = true; - } - #ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 = perf_event__jit_repipe_mmap2; inject.tool.mmap = perf_event__jit_repipe_mmap; - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true; /* * JIT MMAP injection injects all MMAP events in one go, so it From patchwork Tue Jun 25 17:25:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EA2AC2BBCA for ; Tue, 25 Jun 2024 17:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C5w4cInp1XYHivC3iE3132v8D/BZptpjRVHJFu6J7bU=; b=lyPfQqE1ROR8Jq0fxPAZiHu8e7 0hZKo8rmG1t0a8rFefJ8IzpDrb6xmrhb+gnjQqi3SMKXrFVHZ4QMHVpvvyPwejgpJQFF7mbL/d3bK tVNR2HOO1PljbmrvY+6oHZSD+19WMlRyuGLe/rPU+ewrb6CAaBHNSzaNNlX7gC1pY+O8JMvTBHWeM H7Mts6iqfhfI28Aq5qyK/QPkyd/z4nvynvupDPjIfZtvZdPg1ZMZxMbWsEgVGviCvQ13SdSSgNwtn YSVISHlt8/S0zIIoNIO/FmnwBjo8FP9NMtJmm6Fa9nplIM7XrkO+X/3ji9waRR6ifnSc6EC8y28yU VUDkLlPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xM-00000003tUw-12cL; Tue, 25 Jun 2024 17:27:48 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wH-00000003sfP-04WJ for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:42 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-646f6df9683so21170217b3.2 for ; Tue, 25 Jun 2024 10:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336399; x=1719941199; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=C5w4cInp1XYHivC3iE3132v8D/BZptpjRVHJFu6J7bU=; b=LIWGvf61vvQ3qpLFs6T0krBGnf1V6+kZxG7Jnncpca0ixKlLUwyAibLWO7NkL1dLKr 1ehplZxP9AmKzY9ED1/BzGnt4L751USJn3c9RsyPwSF0iWWavl5w/cjT8MzEPCaVCIf7 3KuSQMXD4QiwA40Io3XL+xLJ7oNWkG4B3zhf/fdn6Fr63nYFgfEAeT/JbEZPN6YJKMCj TT+B0NCz2A59hFg2w5rjsEVKHCS4au3sYSVQNRm5hM4HqwwuqaFjRshgijbT2eAUX4w7 Y1uLG136sc8MAxu32CaOBjlGezh6FnVwEueCy2954ypsdcK2+NmylaV2/MXFhM/75AmS AUqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336399; x=1719941199; 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=C5w4cInp1XYHivC3iE3132v8D/BZptpjRVHJFu6J7bU=; b=XSs0yAriO+2Ir+WzNXlMWh3XgDc/A05L3waQY56PTESDzWkVGNtx8+1d6Gbsu4hCZ+ 3Y3L9iqmVcbRne0uONRhGsB6zNSNJW3w4+GGnUiKBsyqQBoO5WdrqDnLEiCVIrhHE8rI biCM3cC+vPdTqm8xJL8U/wHej//dmt78CDec0y0WEwpjGQEqKPqbuxM3nmqSnUIcFyyv lmGKYWNwuKQDBiKV1ri74oJHLBV/xXeN40wo+ootovhGsp02blaLDFQ6SWBthiJEe3va rM7K8KOLlkkoe5FwP069yZ+t6DtTbWfJEuniuJdm/VSphN+YQytTJs0UqKkXVnk97uEW iWmQ== X-Forwarded-Encrypted: i=1; AJvYcCVAfkdY5O5/sSheNp9EQufUy7DWg7ZtCBfJXj0M9s5kTmCUYjUmRPD68ITkGxYrArShH2qK4ErtTmf2K2/b349MDq6/V8zm17p9oGOqAnmUWjL15Fs= X-Gm-Message-State: AOJu0Yy50lQUTVYKylqEOiXphPZnr16wYvUiCpXY5x8ldMPzMHznJ3oA DtgALoyuiwux7A61DACp+TH/uRFdoSyO03du71haUD6ffqM8N3IiYrD9WD/I6hG7yuEyPH5fkNN rG+9cag== X-Google-Smtp-Source: AGHT+IGkNnzupWAe2VlADESO5lg2+CTiWH+MH2liE+/EBrEEqIPx7BnFuqYzgLszQiwG21XCiljDeffYYpww X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:1885:b0:dff:49d2:ac42 with SMTP id 3f1490d57ef6-e03040be235mr417284276.8.1719336399148; Tue, 25 Jun 2024 10:26:39 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:50 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-14-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 13/26] perf report: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102641_147298_6A7A1BA2 X-CRM114-Status: GOOD ( 13.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-report.c | 55 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 947d4a9c9f66..029e5c35632f 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -799,7 +799,7 @@ static int process_attr(const struct perf_tool *tool __maybe_unused, static void stats_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); + perf_tool__init(&rep->tool, /*ordered_events=*/false); rep->tool.attr = process_attr; rep->tool.sample = count_sample_event; rep->tool.lost_samples = count_lost_samples_event; @@ -817,8 +817,7 @@ static int stats_print(struct report *rep) static void tasks_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); - rep->tool.ordered_events = true; + perf_tool__init(&rep->tool, /*ordered_events=*/true); if (rep->mmaps_mode) { rep->tool.mmap = perf_event__process_mmap; rep->tool.mmap2 = perf_event__process_mmap2; @@ -1275,30 +1274,6 @@ int cmd_report(int argc, const char **argv) NULL }; struct report report = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .read = process_read_event, - .attr = process_attr, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .max_stack = PERF_MAX_STACK_DEPTH, .pretty_printing_style = "normal", .socket_filter = -1, @@ -1480,6 +1455,7 @@ int cmd_report(int argc, const char **argv) }; int ret = hists__init(); char sort_tmp[128]; + bool ordered_events = true; if (ret < 0) goto exit; @@ -1534,7 +1510,7 @@ int cmd_report(int argc, const char **argv) report.tasks_mode = true; if (dump_trace && report.disable_order) - report.tool.ordered_events = false; + ordered_events = false; if (quiet) perf_quiet_option(); @@ -1563,6 +1539,29 @@ int cmd_report(int argc, const char **argv) data.force = symbol_conf.force; repeat: + perf_tool__init(&report.tool, ordered_events); + report.tool.sample = process_sample_event; + report.tool.mmap = perf_event__process_mmap; + report.tool.mmap2 = perf_event__process_mmap2; + report.tool.comm = perf_event__process_comm; + report.tool.namespaces = perf_event__process_namespaces; + report.tool.cgroup = perf_event__process_cgroup; + report.tool.exit = perf_event__process_exit; + report.tool.fork = perf_event__process_fork; + report.tool.lost = perf_event__process_lost; + report.tool.read = process_read_event; + report.tool.attr = process_attr; +#ifdef HAVE_LIBTRACEEVENT + report.tool.tracing_data = perf_event__process_tracing_data; +#endif + report.tool.build_id = perf_event__process_build_id; + report.tool.id_index = perf_event__process_id_index; + report.tool.auxtrace_info = perf_event__process_auxtrace_info; + report.tool.auxtrace = perf_event__process_auxtrace; + report.tool.event_update = perf_event__process_event_update; + report.tool.feature = process_feature_event; + report.tool.ordering_requires_timestamps = true; + session = perf_session__new(&data, &report.tool); if (IS_ERR(session)) { ret = PTR_ERR(session); From patchwork Tue Jun 25 17:25:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DBDAC2BBCA for ; Tue, 25 Jun 2024 17:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m0zVM37WL2jQNln7xrBKCslp+8pFTT04OTNtW91i/Qc=; b=ZJYKhFOD73hwOnTZf/LcZLmPXo gsCMJ/8m8Sti/XG/jAQnTns9THTmPPkd9wrPeZZWVX/cIgxl4K97/NGhUonq/XCOtJsc9iynekJJN Wat/nCHX0lD1NXEksn4SkGT7Fb6DBgn3yO8Ol9JMNHYEb+kz/A08DSdxXgfJXReAduCIyNDM5lk5m RdwDZaoRRBgmR7Xv0nxyyE5yO0CgpHULFuF4+71e+98fI32n8i3OaylybvlgPcU/lVve/z6kRrmDH lOANTt+MQREKLRRdXdhitMAO3g448PqHBwRj0WMx2G1Aw6EfZrlWcQK6OxT2k+zgK+oPYmb1nhfW2 XMe5/jTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xQ-00000003tXr-3tyV; Tue, 25 Jun 2024 17:27:52 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wJ-00000003shf-0Gpx for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:45 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6311e0f4db4so128405387b3.3 for ; Tue, 25 Jun 2024 10:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336401; x=1719941201; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=m0zVM37WL2jQNln7xrBKCslp+8pFTT04OTNtW91i/Qc=; b=XO1SIOLBarSvbLXx4tGUt7LkeuChKLED47FwBaVnBKC6pgn813FnyQ0W48Xz+VlyBL QZO5zgVXRhWVM2F0aLfm+G4lbSgkDGcvAd0DfICn925pdGVNqiuHXLARVkvYeRiJzHSC KHOLwqhO2jTQcyXKZqbBglhdjZvminQvQ47H3mZjjUWoxnnG53NaQH+Q9IsHDQYUtfJE vDfApErLhrCSFZ/i2EWimvcpIir1aSxfeOndF0AjuUKvgPpoRhBCikjFNZR/pHSRxDiR x3Qoal7/vhOPhxMdXxUa/Vjq63/RmpX2LnYi+EewAgczAmLs5tDDrs6zJSlfwL/UdhjL xWaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336401; x=1719941201; 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=m0zVM37WL2jQNln7xrBKCslp+8pFTT04OTNtW91i/Qc=; b=fs7wX8twRupsciz2vlGPioR/VPMFIaU5V/yFtncHJV2z/g90+Yvgi/QL3Rbu6kdCW+ eGvb2fQ5OEHsa8dw0FSU8s1So/DL+DshPv33cZyR140Av6mjINfF9zEsfBe/7gsU5z20 FA7Xp6Yr57fU4oNqS1HguS9lsOMagizrNdPiDqkBqosdEMkI4W0hXed0jCH3/4HxQg7v HYAsrP4an1wEfGQRDUpav8eAk6JcamKvECkArtE5ItCAm+xkuF1pR5EePchQ/WYTZe5P JdHzMPe7sXvbzdoT5ZzDYK9JpFmcZbpzmA62ZrFnuRu8xRb7V0ppK69InMzHkvmKQOVL 7giw== X-Forwarded-Encrypted: i=1; AJvYcCWU+p0H6k+HzsZzC56ohJ1TUXhdhuLkbfMkGMd/vVOmI1oFQJLWLKihZRkj70phUQ6R1GgYM4wQTRZnzkwdCqi/2BIL9rdAU+OnVS75hHf1IjYgKjc= X-Gm-Message-State: AOJu0Yw/34z7nzIXL/IFOAURngJEq9AWMp9eeuWsAu7TmBz9GX20Gfgo SHEyl16fVcSS6WhinnuMQ7AtTo2XmalSVqZOC6HFsj3STcG/fCV0uaJEBW9hx76FnFFxzCzf0i8 Dtz5QYQ== X-Google-Smtp-Source: AGHT+IFvDkg7Os7n6xpJOjx9/jstK5lqUN/rfGvGweJEa9x1d/tx4A52g63ZVLlFVQ0ULV4tujWDGTNgrxUA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:6e0d:b0:62c:67f4:4f5 with SMTP id 00721157ae682-643ae44f5e5mr4148627b3.9.1719336401598; Tue, 25 Jun 2024 10:26:41 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:51 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-15-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 14/26] perf stat: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102643_227970_0C49F96D X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d460c46f15fd..a3d77a55d17f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2271,15 +2271,6 @@ static const char * const stat_report_usage[] = { }; static struct perf_stat perf_stat = { - .tool = { - .attr = perf_event__process_attr, - .event_update = perf_event__process_event_update, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .stat_config = process_stat_config_event, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - }, .aggr_mode = AGGR_UNSET, .aggr_level = 0, }; @@ -2322,6 +2313,15 @@ static int __cmd_report(int argc, const char **argv) perf_stat.data.path = input_name; perf_stat.data.mode = PERF_DATA_MODE_READ; + perf_tool__init(&perf_stat.tool, /*ordered_events=*/false); + perf_stat.tool.attr = perf_event__process_attr; + perf_stat.tool.event_update = perf_event__process_event_update; + perf_stat.tool.thread_map = process_thread_map_event; + perf_stat.tool.cpu_map = process_cpu_map_event; + perf_stat.tool.stat_config = process_stat_config_event; + perf_stat.tool.stat = perf_event__process_stat_event; + perf_stat.tool.stat_round = process_stat_round_event; + session = perf_session__new(&perf_stat.data, &perf_stat.tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Tue Jun 25 17:25:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8702FC3064D for ; Tue, 25 Jun 2024 17:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IMpGpliqYqiRoqn4cN7c6adPMyNbVkdw3pW74xYyguE=; b=jOKDELmaCDXH6kdZPhfwv600KZ aRyk8KnQRb1rUDQFznWv/uzkDnsrf/DEPq02uNlNbX1AFbsucunPLbl5RXM1EJ94SgyMygUZMWaJL 4mffbaPPgARQjmGeQFVX0/gYSzFL0ppYzGM8uLv/rMpp7aI9eOfsq/byY4/Oq/ZAiU13ZTWfclhHQ QFdKLY6uCF5RdDWuC4CUnwPEu+RlX/X25tCTq5fKjIvFIIgmElnTdi7ty4yF6tzin8ROLzeYPuip5 tDT3gFCKdtl2yoOPZIS8RZipK1N8f8h8dAlszGyeVZ80USfCySTLGLy970c+r3Zftjfoex+wHAmnx 2sVs2oCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xY-00000003tcm-1aDz; Tue, 25 Jun 2024 17:28:00 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wM-00000003sjX-35ty for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:48 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64507372362so61446147b3.1 for ; Tue, 25 Jun 2024 10:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336404; x=1719941204; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=IMpGpliqYqiRoqn4cN7c6adPMyNbVkdw3pW74xYyguE=; b=kD+2RUanxqb/ouOIOtSYSE14jWXAZpkfC2SZn56YoaMP1B4tB1NpkOX6tm25RFlOFH yDr+UJGR04vjCWUKpd7PH14b7HJVvlNXu0MTyZDgqDvZCnmQFZ9L5oBoedf9N82MQPrT Xcn/iNOpwtuE0yoBcfnCvM07f1RZLjbTp2Q8bBuhQPvQwL2DxUwidKCHegQJrQQetqZu 4cybRKaIYlph47/azdw5MJQOWXEVsVnLJXgLLbT9rfcYrofItU7aGIYvMIRw+Xe5Bf0l XwkFqg06AlNz/URDwixg3Cmj+gNDOjcKZDpdTG3qjBW8RasxF4U15dJmX4FIJa+LPdh0 +R7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336404; x=1719941204; 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=IMpGpliqYqiRoqn4cN7c6adPMyNbVkdw3pW74xYyguE=; b=pWrmv0FEY5zYPKzgyMl8xapb4IVJ7OFQuwM2D6XyfCDCiNc37A31+myzzBGrjKuTnq Am3foJFicj+xBzeUnWZEoRRCN88omuutg+Rsla1QeFlIeBxwDn64MEb5Gq4FA5USyNVp wbSwngmj6xsbXASngrI+DLd5vZ/fnp5QoCxe0xmESLnsmTD7cHNsQZABc/3ypLvay/xi 7gJYbkOjQeNvy/qH07eM5WDJ7yBNxouOUgecMA+lsINHwAcxtxHqv6ZsO+8TeA70OFIp /8VyrFi3XANYo+2LQ9lF61kjZnf1z33fTiURynTbek1lL8EtvDQTRJsuv/yyFve8BBiV i32g== X-Forwarded-Encrypted: i=1; AJvYcCUQ0djzLrD6vnFVpiTyO16nZJTiZwUIkpj/2qenJI/me5q7Ue0a3Jol5Nt6+Ui4gToqi5pIsqrC1IHl60Ihyzz3ZNDtDOBcoi99FNgbv32JA0by6Gs= X-Gm-Message-State: AOJu0YxOUE3TKrmRajIiIJ6hr5V3Q40TIw8NbrJEJGz7rcbNZRWv8XTA 7M6buUPAnAGfqzN9/hhzP56RffQ18eLFteBPQitD5rtdMMFbE3bCe0w76/p3e3Zazy5lUsDJ4dm jNU5I/g== X-Google-Smtp-Source: AGHT+IH7+5ZWTBKKbbXiYf9Ov/UKvq0gkd8VKcekY3d+qTX2IBw8lJ9SfVOmE3ieuJ+wxA4bu4ed7gUqIOcD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:ec4:b0:61b:e689:7347 with SMTP id 00721157ae682-64298a5efd3mr300097b3.2.1719336404050; Tue, 25 Jun 2024 10:26:44 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:52 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-16-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 15/26] perf annotate: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102646_911057_6CF88294 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index e2d784c5fdd6..0a96656fee46 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -686,28 +686,7 @@ static const char * const annotate_usage[] = { int cmd_annotate(int argc, const char **argv) { - struct perf_annotate annotate = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .namespaces = perf_event__process_namespaces, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct perf_annotate annotate = {}; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; @@ -864,6 +843,25 @@ int cmd_annotate(int argc, const char **argv) data.path = input_name; + perf_tool__init(&annotate.tool, /*ordered_events=*/true); + annotate.tool.sample = process_sample_event; + annotate.tool.mmap = perf_event__process_mmap; + annotate.tool.mmap2 = perf_event__process_mmap2; + annotate.tool.comm = perf_event__process_comm; + annotate.tool.exit = perf_event__process_exit; + annotate.tool.fork = perf_event__process_fork; + annotate.tool.namespaces = perf_event__process_namespaces; + annotate.tool.attr = perf_event__process_attr; + annotate.tool.build_id = perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data = perf_event__process_tracing_data; +#endif + annotate.tool.id_index = perf_event__process_id_index; + annotate.tool.auxtrace_info = perf_event__process_auxtrace_info; + annotate.tool.auxtrace = perf_event__process_auxtrace; + annotate.tool.feature = process_feature_event; + annotate.tool.ordering_requires_timestamps = true; + annotate.session = perf_session__new(&data, &annotate.tool); if (IS_ERR(annotate.session)) return PTR_ERR(annotate.session); From patchwork Tue Jun 25 17:25:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BC2AC2BBCA for ; Tue, 25 Jun 2024 17:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tFS5Ls/8uEdl/uKj99agh7Vw5SW/HlvZFMCUW5Ei1+o=; b=LCjAX8wdE4wjcIpSt4B6fSd029 Dx1/L62z4uguyk+j7ssEdGVdFnFKDaU/7WGpWtYKGBqNLwDt10m3w+rQDPTgddBJ99vmnaRLPh2GK G/Y83hSA7tssAJuVuuzIcdvgg2iJfUKHwvQGg1+P5PUkbDD//Z88+cmAFnhfBev4ZEKKPG6TjpC9V X7v0sNc0a2ETpOArmSy0rQDXrWiEbBp8GaZZu7SxDazCP8PBMDIdH8wSriUnDEZzmv2+MLqY2UbZo 8jMEIW6qfMZg0OoEww8P/8LKb2zlWaGC4IyKctmktqjdeSDc6ttSMa2GmBFrj1kbTHut+IGZVQvvR aKtZ0ahA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xh-00000003ti1-0ZXg; Tue, 25 Jun 2024 17:28:09 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wN-00000003sky-2exG for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:51 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-62fb4a1f7bfso138905767b3.3 for ; Tue, 25 Jun 2024 10:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336406; x=1719941206; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=tFS5Ls/8uEdl/uKj99agh7Vw5SW/HlvZFMCUW5Ei1+o=; b=ZaVjErz810R1UUadZeFoTEoNDlVKVKJI7C4a1Pic3odeuBvpSuTNjNsck2gqEPFg0f xBh9z/ri0SS5gOwwshmUhdEWzpXae8RcZIGOziaepZeMWNZ8gi+3DgUUWO/Al39pay6T Otne1MNODgDwe7Q46jIyC2tb1zd6trSEheUH3BEREHHkcAWBAetj8JidDwEEGmDWV8Yf GrE3LAbP54se6hzspP+Tqqz6VzUGvdR2LcO+FdBGFkXNfPSeYksJYl0H+oVVTOq/Ugg2 eip1f8/zsRu3Xmv3iKzZ6GJzuQEG6pIHhKJRwE//AxeArAdygrHUu8I/Br2jFF0X442k cMBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336406; x=1719941206; 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=tFS5Ls/8uEdl/uKj99agh7Vw5SW/HlvZFMCUW5Ei1+o=; b=KFzqhTT3Fr3qCJfrQTk31mdalrf7mvYz7NRgBdCoQgv9A/bV4sOEBHYTCnLa7m1JwB IRNTB2/6ED5s3LLflK7/qeip2p9zaXttdtE0gKLA4lOZftAu0m1KFzOSMRZjMwADIG/T KFqh9BtoI9ve4O1ldKCj2rIVmMO8ML5nvCRK6nAEiDOQ9VOOJ+meoYslfss6zmNklKyg 0OLPdSFskyoQT4nPDDtPC3WOwFSNa2k1LWvU2glLZJaTjrCSToORq5EIjyeulDqNmBMC da0ggbCv7GJ0PvVKvkdiXoHRUwDnmb37xlrl7Xk06TwKchUMMAPIRZzN12XtR5ELJKWZ fo5A== X-Forwarded-Encrypted: i=1; AJvYcCWIJFoZAn6qFJuBX+nf9zO+44HyJ6vYC4iU7zI6qgiH91TISA2fi7Dxqf5Zsl+CUGG6CNK7KDRMjD+oXnmCNssVmsxVyhypTMMnX+OlGKobq2Fg6A4= X-Gm-Message-State: AOJu0Ywmls2ELtm0ieDVCKGU51KGfhti/oex2Y0Cf6/yj77NbzBhV6oT q3b+b4f2NfASE5Ee//7fLzt4n+q7gNUJevMxUhuY+plztW++gM8F0WSddY2dSF9St2FebzINUPs te5cVMA== X-Google-Smtp-Source: AGHT+IF2BBEzG8n4Im5E24amspFsISbhyUmDqM3EEW8J7qrGP6Z7MGgO5UpQnw4ikMBEFLJs2umKcM9K/jt4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:7201:b0:62d:a29:537e with SMTP id 00721157ae682-643abe4101fmr5489867b3.4.1719336406177; Tue, 25 Jun 2024 10:26:46 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:53 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-17-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 16/26] perf sched: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102647_869909_2BA9C8A4 X-CRM114-Status: GOOD ( 12.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index ad6c6d2ce149..84cd6a013e42 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3010,7 +3010,6 @@ static int perf_sched__timehist(struct perf_sched *sched) sched->tool.tracing_data = perf_event__process_tracing_data; sched->tool.build_id = perf_event__process_build_id; - sched->tool.ordered_events = true; sched->tool.ordering_requires_timestamps = true; symbol_conf.use_callchain = sched->show_callchain; @@ -3508,14 +3507,6 @@ int cmd_sched(int argc, const char **argv) { static const char default_sort_order[] = "avg, max, switch, runtime"; struct perf_sched sched = { - .tool = { - .sample = perf_sched__process_tracepoint_sample, - .comm = perf_sched__process_comm, - .namespaces = perf_event__process_namespaces, - .lost = perf_event__process_lost, - .fork = perf_sched__process_fork_event, - .ordered_events = true, - }, .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid), .sort_list = LIST_HEAD_INIT(sched.sort_list), .sort_order = default_sort_order, @@ -3632,6 +3623,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; + perf_tool__init(&sched.tool, /*ordered_events=*/true); + sched.tool.sample = perf_sched__process_tracepoint_sample; + sched.tool.comm = perf_sched__process_comm; + sched.tool.namespaces = perf_event__process_namespaces; + sched.tool.lost = perf_event__process_lost; + sched.tool.fork = perf_sched__process_fork_event; + argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) From patchwork Tue Jun 25 17:25:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17DE7C3064D for ; Tue, 25 Jun 2024 17:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6FKqc617GU6y9EZBzym/gHkh1HBEMH2nzxihyAHq3eE=; b=D6Ztk86+063QJm706cwBhn6Pq0 Y7VrQrxei/5lgQBgk7EcX3RaLzukds+mZtGqaMwgAlReSpi7g/gN0CCDGZtw6WO59GzgERCqk7Kg6 3Ucku8Uh0ixiBZcy4KEHYq2c/oMT1O40ZYsGMfmGguU+SlyLZvYs5uD3uIBIoDCMFZZUcoLO3XTRn gHN1Ro5XEXVrI8OaOT04U5A/NDSfw7ZWWzJdyPcDEVTeyvH9AHFLuvOjE2rWdMujUAKhkz3wrVgSo BlvqIwBCSgx3P8aB8l31VJrz23yia9hxMbIhoUtXpLOf3j+8CkxW6/66DsUfTehPC/aXGmwZxnD5Q bqJD/eFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xm-00000003tmS-3feb; Tue, 25 Jun 2024 17:28:14 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wQ-00000003snE-0b6H for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:55 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-63bab20b9f4so105683457b3.3 for ; Tue, 25 Jun 2024 10:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336408; x=1719941208; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=6FKqc617GU6y9EZBzym/gHkh1HBEMH2nzxihyAHq3eE=; b=SgPjEYjM6HKMIU3iHSjC3SaeS4hC6qZmesCExwsA0oUE/OhtznI6hrVhQ9Dl1FC6WU i3xZEnvlun3pm2ggZUurU+4ccnDqmMgA+L3KsBe0aWTa0GGe7Ac6hDlyMaP/cVrJ/xCr nILjuuZnNX6D6G4MUgdOKfeqtlYRSeZZ9jUgCuaJS2dgQM17+Vbc+5hTaI/YkxaN73/Q V403e7GECflN5BhQjXOht5jCs9vikB6BKC0vAoZ65M0I1VuJj+FGtSnxiQbQ3aIwI2Wa Z8Sem9cB8dbABccrIknDXNfc9JyIIvAv2DgC0CrJfN9Gq2hcsK8A1Bj6YJb/SkLak6y3 23kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336408; x=1719941208; 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=6FKqc617GU6y9EZBzym/gHkh1HBEMH2nzxihyAHq3eE=; b=d/BJm65ghZfCWkmBviX3yX2kKOUhXT48aEz4AQa3PA0KpW2rna+YTQ9xSA/9uZYIyj giH6d4IP9QjjloaU48Fpntpr++Bho0XFHSiF7WtUmABS07n38VZle6cxbEpSxwZE0Nnt 0KCp3N8tm6HLJDLSvpVTYC0uadgASgh1by2aypmjB0+OlK+GGdrLE3ZVib+JZICAl3kX Xs+rz/PdxAclZKe9ekYMvTzrr40K5x1lqOrV2kaAlMP7+7rrBuv5Num2fg1sCNCH6BKd 1jEJIPmwPPeCyB33yJ+jSDh/Cqgsvin/+XNfvacaB0+xLhrfDtl6f6b8+7ZomBpEQyHZ 9F1Q== X-Forwarded-Encrypted: i=1; AJvYcCVYU+WZ91ks0GCOpg54m+le1ZBKWStgKFSyAhnRCdF6SkmE/mTkQlGY0Jf7VYdGaEkHFZ9UQCdxgRmIt6ddpRZ2A0ejrLxMOLHvjMg4n1FtXRNtJ3I= X-Gm-Message-State: AOJu0YzA1wd44rkIZTS8LI6ArGAhPn9wh5lz2pwjI8I4cL1K/KhitIcT JHkE/kBS3rrZzw1B5A+rxQ3sJdOM2ngCKCXJjZplMro1ebmweNTtDmSCvQuB+AJH5XYowcry2Jh rJKBbUg== X-Google-Smtp-Source: AGHT+IHvID5MqiYuIdDZtsB0PM+VSxrqQRo84zi8LvlxFkQG16oOJVmUwBr7Nyqswk+S8IE/3vFBpBPetX8T X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:6086:b0:62c:fa1a:21e7 with SMTP id 00721157ae682-643adb94892mr2966057b3.6.1719336408291; Tue, 25 Jun 2024 10:26:48 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:54 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-18-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 17/26] perf mem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102650_388247_2F5DF05B X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-mem.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index c2038a32543c..c12ca0ec1237 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -285,7 +285,23 @@ static int report_raw_events(struct perf_mem *mem) .force = mem->force, }; int ret; - struct perf_session *session = perf_session__new(&data, &mem->tool); + struct perf_session *session; + + perf_tool__init(&mem->tool, /*ordered_events=*/true); + mem->tool.sample = process_sample_event; + mem->tool.mmap = perf_event__process_mmap; + mem->tool.mmap2 = perf_event__process_mmap2; + mem->tool.comm = perf_event__process_comm; + mem->tool.lost = perf_event__process_lost; + mem->tool.fork = perf_event__process_fork; + mem->tool.attr = perf_event__process_attr; + mem->tool.build_id = perf_event__process_build_id; + mem->tool.namespaces = perf_event__process_namespaces; + mem->tool.auxtrace_info = perf_event__process_auxtrace_info; + mem->tool.auxtrace = perf_event__process_auxtrace; + mem->tool.auxtrace_error = perf_event__process_auxtrace_error; + + session = perf_session__new(&data, &mem->tool); if (IS_ERR(session)) return PTR_ERR(session); @@ -449,21 +465,6 @@ int cmd_mem(int argc, const char **argv) { struct stat st; struct perf_mem mem = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .lost = perf_event__process_lost, - .fork = perf_event__process_fork, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - }, .input_name = "perf.data", /* * default to both load an store sampling From patchwork Tue Jun 25 17:25:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54B1AC2BBCA for ; Tue, 25 Jun 2024 17:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ygd9VSeBzmgIFn0KNDzBnTE+heYOe9Db6FtOSFvMpYw=; b=q8Cm0xn2+oKThqil4rbd7+pSE3 wO4IW0tKu1jkm6r7/nGB1NxPyODmAstO0EAVIPkL6rboRsrvKP94rT3y04DPBdlN249Z5uj8b3YZ/ meftj2Fu8D1/z9H7fuszHHaNuwDnzC5E935L/C0jQ3NBDdeReaNFkGmcw2NbxvNUbRAZgrbCgc/0J mX6iArcK52K9br8LpcHvfE5U1KNa2AbQl04POamaFNHEFX5wp2O7jvGWhr7MeF7RcEPhMpS46SMlr h6TYy98P280R9qO/wt3o1BTZLo9Cnd+HavUwnrny6FiFY74klw5SAT9ttbZGu+zkEYs5akj4KLRyD nHmtlxRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9xu-00000003trc-2qGU; Tue, 25 Jun 2024 17:28:22 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wS-00000003spw-1t7O for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:26:57 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e02f7e5be48so7202122276.1 for ; Tue, 25 Jun 2024 10:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336411; x=1719941211; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Ygd9VSeBzmgIFn0KNDzBnTE+heYOe9Db6FtOSFvMpYw=; b=UAFplC5x0HumObjHP/ijCkCNo2pEc3iMeolLThp/jzCBQJRAwbU8rLCxpg4Xjxoowy tEg/ELshR7SgEQcK+t9G5EiQQxB0q8Rg6O4i30mJTJQpr9CbDPnjRSEU/NZJQEqRn7R3 owHOQ2czUk5+FpOpKeuGfyYjTDRhdqlLrMTZdjYXytHSVczDvzUXfdkGpiSLNM8MDWcx jXMbE8HljPO/QwMeeHA0vfNTiBmLLrvMLYouxInkYnIWK11fxIQ0Q9siqYZ98QZXtkVV ZRwM06qTD0QBEsj6ErUlcOTFSvb2XYQtMKdUl2oM+msHY07d6lQlytsOn+JcVcDHZKsn OzLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336411; x=1719941211; 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=Ygd9VSeBzmgIFn0KNDzBnTE+heYOe9Db6FtOSFvMpYw=; b=Rw41EiT1UeIYUj8aPHemE6EIjyKY3m8xr7wuKrO+m1wERPl+IZPTzeF8CP4JHUymSg MvszqWwBizbrcH9xnzMIkNBLNzVXnkfmxK3SQRCV79+Oa/bsogAtqt2zcv4QkgqsIzn2 h0U7KYyt5GCGCwoRNvHl5WnCXMbGfU9ZqeDAHKes03iTwjH1gomR9ux+Eih0u6hxy6yp cDxiMqoV0WioKUcDDWZYotzhX2MAenXRyGGK7TN5jLwmVzZWrrtatCk2+u3wvsjfUGe/ FPD394J21PZ022kR2D6AuWBDchyrFbnVm6aLATVSQAUeBZxtFQ77YkEoojJEAOlpo1A8 REaQ== X-Forwarded-Encrypted: i=1; AJvYcCWjRSVTcv8HHOxaDXLbBY6cPDAXy1bTeDH5BQSS8DFMRg/zha27h0mDWBU78EJWIuNcYF6adIAy9Chx7HnCnn0BjupUVTyCdS9gA7XHS9SGV/XkgF4= X-Gm-Message-State: AOJu0YzW778o6QlUytBmkJ+EiexkMURiV/Ym9VCMxvfYPpsuaJSS6+o+ ym13o5wZ4jojtC2iKp2LVXMvYD93QlWSfOmk5FmN2qx6Ui/noUAJH5JcF2ejcW3Krwlr/sL3gG7 dMkogdg== X-Google-Smtp-Source: AGHT+IGJqb768geaJ/+3Dza1yAwPrymkaebPJuzakVPlvvTG4c9cKDtVCh89RfUHal9utqfZd1Pqsy6N9wKe X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:704:b0:e02:b093:dc1f with SMTP id 3f1490d57ef6-e0303edb60emr31284276.1.1719336410683; Tue, 25 Jun 2024 10:26:50 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:55 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-19-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 18/26] perf timechart: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102652_667083_D5729354 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 5bf818baa662..218c8b44d7be 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -1606,10 +1606,16 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name) .mode = PERF_DATA_MODE_READ, .force = tchart->force, }; - - struct perf_session *session = perf_session__new(&data, &tchart->tool); + struct perf_session *session; int ret = -EINVAL; + perf_tool__init(&tchart->tool, /*ordered_events=*/true); + tchart->tool.comm = process_comm_event; + tchart->tool.fork = process_fork_event; + tchart->tool.exit = process_exit_event; + tchart->tool.sample = process_sample_event; + + session = perf_session__new(&data, &tchart->tool); if (IS_ERR(session)) return PTR_ERR(session); @@ -1924,13 +1930,6 @@ parse_time(const struct option *opt, const char *arg, int __maybe_unused unset) int cmd_timechart(int argc, const char **argv) { struct timechart tchart = { - .tool = { - .comm = process_comm_event, - .fork = process_fork_event, - .exit = process_exit_event, - .sample = process_sample_event, - .ordered_events = true, - }, .proc_num = 15, .min_time = NSEC_PER_MSEC, .merge_dist = 1000, From patchwork Tue Jun 25 17:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B34C9C3064D for ; Tue, 25 Jun 2024 17:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g+eUWDVM6QBZsAa2Jo8FHym45eB780ogdLDPw0XzQlM=; b=oy1lZNEKzN3s6JRybgU56Z770F I5Mw/uGw7O5Fzb/fNq5BbRDeU7hOVlItF7PI43VEatuFvTGldPA2qpt2/nG1+Spv7m4+OOFk2qbw7 mwQNTFhNfBBhWpCsg84tB1I2Tppb8yOhMfiLXwAnsWDo+Mvcum+LN26KVVm3AgoRzXLWPz88ITTYW 3Fjr6r7XMRtooTsMNwn1hDcIoLXUAseHkEOq/1Ya+dGq/ED/mVu4Ufq+47fNpgEPPPetluqH0v6kA OQFG7BureQujb5wOZu3qLq56l2jSPXo33k1B5lmcLI2CbRyKck2fPFfAjPgpH9NRozfCmB3tsMRrl t3a9ScLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9y3-00000003txf-39Mj; Tue, 25 Jun 2024 17:28:31 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wV-00000003ssN-22sH for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:00 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e032d4cf26aso872688276.3 for ; Tue, 25 Jun 2024 10:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336413; x=1719941213; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=g+eUWDVM6QBZsAa2Jo8FHym45eB780ogdLDPw0XzQlM=; b=FL8MXM+iyN9ifIOsRJDH7cVqv5mBdJ8hYv1YC/bO6+ZMZ1Tc0gvnV24TdRh56MTZ9F qHx1JLJvrbJaRD1UFKSmCrQByJX5cukOR9FUePIEIK7BSoq2f4xPK3c0CcH++yMNpZMG +f+Y9YojO7TKkNjbdO+HRuUeUmvimPfaMY2BzNTHmtVKY3l3wEFP/VgBuIpBrx7u1/70 c8PTN7SK/8+23MyyNNgg1n4rwcblE2TYCFU0BTR8lwjB8Bct84t4YlRRBpow2tnu/dnp 5Yh+LE1+eAi3bN7NzxEPk/IkU3Va2aJjKeydRyNYbe9n9Azmr+jgXCjx6cfC1o6hiS7B 7eNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336413; x=1719941213; 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=g+eUWDVM6QBZsAa2Jo8FHym45eB780ogdLDPw0XzQlM=; b=MupUlZ+9WI3jFEbqzIWQcPHGh40dSX0jihOLy7YyGm14LHggCA9eq+zqO/ZKZufSkW IZywt3WVxgo9DdWmpsTE5cEyx9AKluFyaxa5gh5s89aGWq7dW69+yf7dstt83d54ir7n XTOfy7FuTvkDiK1zVI7TM8MbuMB1nuHxIC9/RcZhsz3qhMwCqKXkeWQmXWCsEW0h75Nc WPDc7CIaEfzh05j7Je2TWyGMINdORzhgHZPU65yIFaB4zQRB7Mecydc0j3DTvqAeQ5Gc KCSJkBLkiZpW0aAsBZgZ5s0hoXHzlDbZeNigTzmwJWHRAE9L2en/GODFA9fEfE6Ag1I+ el/g== X-Forwarded-Encrypted: i=1; AJvYcCU989+u1xEo4i87hcNyrpBFpMVrPuQ40QPE8lg4A5zcIXDP7f6aetKe8F6MF5kVmDCrPMvtE3VChj9yheIuM5eS6PjRA6/uSoQQfCdaI6h4516a2V0= X-Gm-Message-State: AOJu0YzCSPO+qKVDI5agHUVzpSduTdTRhF62SLHLg+b/Jlks811ljBKQ fnKEcLPX/VGAlUwUz/JjvCBIO7ETJTjboI0P7sdM66l6GJtpNJuXGxjUl3x24BP7p1N0FlgQ12c cGCc/ZQ== X-Google-Smtp-Source: AGHT+IGYUWAk7sz5e9sFF7M41smXZ1CEVHp2Cz1P5m1lWGWU877bLmIa5jj7HXTTuyGtmfk+3jtWIxnjSAp/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a5b:609:0:b0:df7:d31b:7a29 with SMTP id 3f1490d57ef6-e030412398amr101841276.12.1719336413209; Tue, 25 Jun 2024 10:26:53 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:56 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-20-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 19/26] perf diff: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102655_906953_E858E295 X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-diff.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 4c0567882a7a..28c5208fcdc9 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -467,21 +467,7 @@ static int diff__process_sample_event(const struct perf_tool *tool, return ret; } -static struct perf_diff pdiff = { - .tool = { - .sample = diff__process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, -}; +static struct perf_diff pdiff; static struct evsel *evsel_match(struct evsel *evsel, struct evlist *evlist) @@ -1959,6 +1945,18 @@ int cmd_diff(int argc, const char **argv) if (ret < 0) return ret; + perf_tool__init(&pdiff.tool, /*ordered_events=*/true); + pdiff.tool.sample = diff__process_sample_event; + pdiff.tool.mmap = perf_event__process_mmap; + pdiff.tool.mmap2 = perf_event__process_mmap2; + pdiff.tool.comm = perf_event__process_comm; + pdiff.tool.exit = perf_event__process_exit; + pdiff.tool.fork = perf_event__process_fork; + pdiff.tool.lost = perf_event__process_lost; + pdiff.tool.namespaces = perf_event__process_namespaces; + pdiff.tool.cgroup = perf_event__process_cgroup; + pdiff.tool.ordering_requires_timestamps = true; + perf_config(diff__config, NULL); argc = parse_options(argc, argv, options, diff_usage, 0); From patchwork Tue Jun 25 17:25:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86350C2BBCA for ; Tue, 25 Jun 2024 17:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tAjCLL/ftZfBFw5cOoLeSIWi0+JxdIhk3yYIclIyM/M=; b=be5AWB1Pt/JoVt6uD9qJD0dOxs kwtER5T/MyxJyc3ddgWzN93MBYZPSgs0YhlO2KzLXAvm0Z9SGP5PUxLPmRP/VrE/zxDE4Y4GIgs+m pPptWilKtv/MSXZ9E1MGaL1OSRKKfEGCgff2lk9zaoUPFr+QxCEXkOiaPyFyWi70IfX8rDdLNvgET ShwJCnADPuWIbKAk61vuVKKX/5oSfHBUqlkq70utE4PSZOmntmB5xra8CPWPQnGVqgiz6LKW3yYEv z9v0ISVsMVajHXmVy2HWYMazvAXJPWo5TRin8WwXI14Hh43GUWwwQiYqUKFgplWX90ReW3jiHYXDd k/3JRXPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9y9-00000003u1h-38ha; Tue, 25 Jun 2024 17:28:37 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wX-00000003su2-4ACc for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:02 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-63bf44b87d4so65863207b3.0 for ; Tue, 25 Jun 2024 10:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336415; x=1719941215; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=tAjCLL/ftZfBFw5cOoLeSIWi0+JxdIhk3yYIclIyM/M=; b=T34u3loKge4RcUc1vFukndBWmv7nb2+F1pVAv6aCDQFMlAsdSDVTvQ0Hxu9GbH/RCw 409OZFFwrRujEN6CDu91Kd/Yid6wQLyCTK8BWY5ZzxHpFaqsNDIzRgyuKuzxZt5ps1dy OHv49mm6i737JTIcq5PNV5PRYwNwugc0hoHMgUm/vOAX79+TmIohOpVQmbZRXzNl9ZFx EJXjgO87HKEV2T7Yq71ve7wRxnyIBoqnB0arnqEbOvNeXBSh5e1J4aB2rOyjt6wyPumE c77lbqsLgf27KA9XIn5GYQQNG7F6TIOvP8khsFEJ1w7FanPsO5zovEgPzqqHmJKYAtt4 DBng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336415; x=1719941215; 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=tAjCLL/ftZfBFw5cOoLeSIWi0+JxdIhk3yYIclIyM/M=; b=twmg1Y4s7qm0AlyZPJ+7H/ogBUZv6wZgk1keWrO3V1YFOc2zIXQc3OFpCJQmvmfMCc 0MROFSNwBWA2DT607DsoM0Xq28FEHZGlMFQn07UjG9Tjje0ZtbU+LVXbbQAacUQrKvU0 yLkOu8hpAlh3pB8EhT7nrc+6BcBPsM6xwzF17gE06uY7exshd7grLS38L5JU8GWZQyvs LhO0RKqLZc1nGQl8nRu+dfz0S/gG640FGvcQcb74oNAs0THTOTRn+XDC1HnWOww9iPIF MtWdm2/pTwzAIeEJOpE13p6ItiGtGRlQ17r6zdxDWoI5CXD0XKGJ3sU+TnZRDkK10RAN UrxA== X-Forwarded-Encrypted: i=1; AJvYcCV+Rxeowf00nT6Gz0jMlngcyjZgIlwsifKhDlQUuKP3v1LWZ3h/FjrlVvH3m+O68h50fJwcVyNCvrxTG4MpaBdGSGpMBy3wZhw84QJuvhfa7rQ6dAU= X-Gm-Message-State: AOJu0YyOXURhiwo5xPJTpHUeLLzchglYDcTA3dQr7vS6Hkz7rQ+1D40V g6X2o4Pq+igsgzwH1KG13AbmOHGIGN2q4ElIzr2mF5MKskhd+FcsfC46hasEOBp5eLaXm1scoXB icsDCow== X-Google-Smtp-Source: AGHT+IHrK3RRi7tycrRZAYc2YvJzBlzr7KTEgMOmkpv40UHUsdr9SHfnbmoDqJX2YXdlS2m1S71lhIGMfr6U X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a81:9208:0:b0:631:4588:4acc with SMTP id 00721157ae682-64242491f26mr559437b3.0.1719336415369; Tue, 25 Jun 2024 10:26:55 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:57 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-21-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 20/26] perf data convert json: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102658_299558_F0297BDE X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-json.c | 43 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c index 905ea9823f9d..20bfb0884e9e 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -316,39 +316,36 @@ int bt_convert__perf2json(const char *input_name, const char *output_name, struct perf_session *session; int fd; int ret = -1; - struct convert_json c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .first = true, .events_count = 0, }; - struct perf_data data = { .mode = PERF_DATA_MODE_READ, .path = input_name, .force = opts->force, }; + perf_tool__init(&c.tool, /*ordered_events=*/true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.cgroup = perf_event__process_cgroup; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data = perf_event__process_tracing_data; +#endif + c.tool.build_id = perf_event__process_build_id; + c.tool.id_index = perf_event__process_id_index; + c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c.tool.auxtrace = perf_event__process_auxtrace; + c.tool.event_update = perf_event__process_event_update; + c.tool.ordering_requires_timestamps = true; + if (opts->all) { pr_err("--all is currently unsupported for JSON output.\n"); goto err; From patchwork Tue Jun 25 17:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85AAFC2BBCA for ; Tue, 25 Jun 2024 17:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gHFcPRP+yhEWi0robOtIeOpLSabhSBGQ4xXRLMmGCaI=; b=gnwW68LlCyFepDX8dWJx0qLqG6 k00t5qNmcc4MvESFKVzbqqMlyvOTK8xoD5GYXJgpMip5YBWZFQZdugkCE6DEn5fQIYuciv03v0ddd GxJSZXWBADSKVS4oP/y9FgsJhS6nQHVOr9pKZ35sC6vPXMJF/so0hqTSpfBlh1l05C5tCq1Fz1jo8 w4S1SIhtaZPOGPFse41y75zltyRvOPiSh92OPnvl9lJW0sGlDO4uiWwhshFGcMRJD8SF1ji4J1ROt hyLSWBSfauSgDKcQgCoaGNN76SYSg905Rn0x4TNZwDoJf+jq/4+5YUAt+IoSs3G720Lf47shw4LsG cL19qU9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9yF-00000003u4w-1SSN; Tue, 25 Jun 2024 17:28:43 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wZ-00000003sva-3Ek6 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:02 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-643acc141cbso32549997b3.1 for ; Tue, 25 Jun 2024 10:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336418; x=1719941218; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=gHFcPRP+yhEWi0robOtIeOpLSabhSBGQ4xXRLMmGCaI=; b=xNlzKTSsemBfS/N9AKRz3mHDjLelJ9Q0K2LrNf9x5FHGMZ4TiGuBeeKzINzNOY+9SY x4J+nI1IUqH4F3icOZWF5iOte8RLkj/lwsMkjIUhGUfMg1QyQ7Sd/blIO/7L8YS5vf4+ wdxVqPgxXs1FgUiA4mnV7GpR1lk2CP9/4qs3KTErb82jPhZMPa5ft5/yHjwNOEc7x58d nk2zk/UGIdnJur8L1mPS2WTHiNojRmy9jJlVTETkGFLaX22zkXyTe7k1a0qOC5hzXfLl DgDIKJ4UnYHET1JbM8TFZ/aIcrdnW/rGkIA5HpArHlPYjvwg6Dw8gvx5afpdanKKbqn5 v7hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336418; x=1719941218; 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=gHFcPRP+yhEWi0robOtIeOpLSabhSBGQ4xXRLMmGCaI=; b=CPeW7NnBAcjij7Xui1djhLLMzUzGl3bKbIHuDRmpd7NNSGHuJ4ijzZeqlziMjMRB83 a5kTlcsLHyGs7Ip84ZErhs9I+NW2vMN8E0aNVbd5X+HgyFIBWhPhQN/NqSnsAyVcXFZu whYRpU4iWgm//gmjltr3DtZi7BiETC/+ehwR9wADuvs2N/GQAuBVCVAW6upufBHWDm7+ KwpjmcOWWFToBw6BBXgP0UlpOb4VGVBQpHezdSMLdh6t3HXkTmM5lsaJHRTVMIl0YQNL lIZE8ihTKobimvJrHvHaU4PS/1ui7bkwNqu4iFvMXwxOIlRpZALjBnBvL7dahHTC9rvB Fylg== X-Forwarded-Encrypted: i=1; AJvYcCXCu05mRdDpN4Q/7cY6JIdet2pFt4UvaZG8VX5Y9Ll7HQPG7CFY1oa/8zf6vv3eGzB2cfZbYx+qYpt/G2IXJoJDRU3YN7zB7TowHcjc9pogrmE/z4k= X-Gm-Message-State: AOJu0YzLg7lICB0TP09buJIwEjQndV5hZDyd287kidHFRnngqHgUaWE5 JDYCr57Bsh5tE+TIzWLYYXWuPXD5zHl652oQDjUmYz5KS2ucXLO5cNNaLGX+k7aMbtnRuI92aWM 2ckCCbw== X-Google-Smtp-Source: AGHT+IHvubIUZhjEok3/V/kgZ7MsIbdXa2+oaKX/HdJ6s7+Z2Phn78YjiEcP/gWbJXNedxraCdMON4nnJvNd X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a81:ad12:0:b0:627:edcb:cbe2 with SMTP id 00721157ae682-6424dc5e95emr531847b3.5.1719336417810; Tue, 25 Jun 2024 10:26:57 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:58 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-22-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 21/26] perf data convert ctf: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102659_999645_5816B957 X-CRM114-Status: GOOD ( 12.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-bt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 9e2170604b66..021e9b1d5cc5 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -1607,25 +1607,23 @@ int bt_convert__perf2ctf(const char *input, const char *path, .mode = PERF_DATA_MODE_READ, .force = opts->force, }; - struct convert c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .tracing_data = perf_event__process_tracing_data, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct convert c = {}; struct ctf_writer *cw = &c.writer; int err; + perf_tool__init(&c.tool, /*ordered_events=*/true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; + c.tool.tracing_data = perf_event__process_tracing_data; + c.tool.build_id = perf_event__process_build_id; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.ordering_requires_timestamps = true; + if (opts->all) { c.tool.comm = process_comm_event; c.tool.exit = process_exit_event; From patchwork Tue Jun 25 17:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D620C2BBCA for ; Tue, 25 Jun 2024 17:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6A7PaqIwyu4CU4GrB89ckL5QJWFy56tGr5i6+q3YuHU=; b=Tch644uj4f6IyX9Y68GC2XsvHy afZNNBrkPR21o+2HM/k4efNCXroxcPhNNDVJRsWEqGUg2glFgN+TxRBRBTyiQShKcq7Mk9J1wGi7R APKQpa2tJKW20TXjrrHRRaSCH4mlbXJmQ73n7o4eCyPQTu1nPoce9U89kPbPwZxQPRKaA+9plA+oP xcpGGTHM8s/aVxNlE5c2VOH+jphWvoemG7/PFN9CaYR+Hdf8fZnMGHUnecexCIISMwWYmxuMV1NMg sOa6NT11UhL/xI2QlJoG1y7dzKQXw4+ETz4JZ23zt3BKe36stzo6oer9kmaHzWd3QCdNp50KTjAQU 95BdDbIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9yP-00000003uCM-0Q69; Tue, 25 Jun 2024 17:28:53 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9we-00000003sxK-203X for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:06 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-643f57e2f0fso72144687b3.0 for ; Tue, 25 Jun 2024 10:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336420; x=1719941220; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=6A7PaqIwyu4CU4GrB89ckL5QJWFy56tGr5i6+q3YuHU=; b=DWeae2yPMHo3axEHPN0ol3N3y5koipanIE2Id5cw+eE3plpL1MmbseZ5Z/mFQ0NrUP 2+uZ8PCR1xBa+RdF10Uw2LNG1+jcJxDtrrbpZldCAQyR1bVPRLRAo8+uYctFl8TZyOcE R9BpsSZIYmh8yA/n+KBS5/DoLKQ7l27lGekSeREvTD2gXuhFiDgRVjnbTGJDRn+z01UE 1z06AJdaq/M5vSzAzgSjimNFXdcl7lniRxbiCGDqe1C4FKl+urdhQL6OBB4tHxs8aZuF +USpKWfoUc+0UlN4lqCsTCF7ExFYR/sJr7g/i35IL9GrbXTKIFKoCwmMEkae1HmX0JTE M33Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336420; x=1719941220; 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=6A7PaqIwyu4CU4GrB89ckL5QJWFy56tGr5i6+q3YuHU=; b=wGDiK8ka4OWEhj3xezHCYabcX+6Ajxl0LLjPZmjz0kTiTG+mypjR8rCfeHAnz7M5I+ LXaJ3VhzxewXZwt02SbefZPOm+0GgWSMTnrPtA53LZxNKyWFuuogbGA9W2Oy9NtbLaa/ hDxZgZ1MfP1ad8+AnXQ4JIKMW+Bc4FWwg9OJhZEzmFsDUiLzYT/3y9dKE5l/8MQmh697 +LzLAYn+nlxS0r6hg/HLIiwmlyBlx0G3IzJvXLeYKAoHn5S0dPNUZiBEgbVeeRD+yby3 7LIdUa1VtkPW7CDxpaKsScrmE18a6+ftAoLTh06x88lVZ83/MrnRAu0KkiG1mEzwlcIq EHMQ== X-Forwarded-Encrypted: i=1; AJvYcCVK+hKixhSAM+LOJifKRsgoOayrU6FPyh1X9N6FdOgxDb/CWjazDkX++ZFcKNp9hFOKwajOUij5GwG8pkyWRM+j5Nw8tUkVNZe7JQogtPGw/UQKk98= X-Gm-Message-State: AOJu0YzboMlw2h3xQ/X7g2m1Y9ivw0+IpPe0oTHTgAWHj+CgtboS6mwy 3UUoXO4HMvWoJEn53KrojK3BpoZ6yai34p+sVPDSjD9UFu777HwpZ1JsTKuX/fnlqiA8PWUsfRT yb8lEww== X-Google-Smtp-Source: AGHT+IGIWKw3wlhnYW+gj5sNzYIaUB7CqGMqyR/kggiKnBfYHZogEyOyafdY5n5VrvSu0dmMoUTAy5u3BnvK X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:7001:b0:62d:a29:537f with SMTP id 00721157ae682-643ac338f18mr3046937b3.4.1719336420093; Tue, 25 Jun 2024 10:27:00 -0700 (PDT) Date: Tue, 25 Jun 2024 10:25:59 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-23-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 22/26] perf auxevent: Add explicit dummy tool initialization From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102704_905189_E0DDF650 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ensure tool is initialized to avoid lazy initialization pattern so that more uses of struct perf_tool can be made const. Signed-off-by: Ian Rogers --- tools/perf/util/arm-spe.c | 1 + tools/perf/util/cs-etm.c | 1 + tools/perf/util/intel-bts.c | 1 + tools/perf/util/intel-pt.c | 2 +- tools/perf/util/s390-cpumsf.c | 1 - 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 70bad18c4a0d..06a198b2f483 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1097,6 +1097,7 @@ static int arm_spe_synth_event(struct perf_session *session, memset(&arm_spe_synth, 0, sizeof(struct arm_spe_synth)); arm_spe_synth.session = session; + perf_tool__init(&arm_spe_synth.dummy_tool, /*ordered_events=*/false); return perf_event__synthesize_attr(&arm_spe_synth.dummy_tool, attr, 1, &id, arm_spe_event_synth); diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 231cd833c012..02eb5b3eed14 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1619,6 +1619,7 @@ static int cs_etm__synth_event(struct perf_session *session, memset(&cs_etm_synth, 0, sizeof(struct cs_etm_synth)); cs_etm_synth.session = session; + perf_tool__init(&cs_etm_synth.dummy_tool, /*ordered_events=*/false); return perf_event__synthesize_attr(&cs_etm_synth.dummy_tool, attr, 1, &id, cs_etm__event_synth); diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 779982c478e0..ae97109542be 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -761,6 +761,7 @@ static int intel_bts_synth_event(struct perf_session *session, memset(&intel_bts_synth, 0, sizeof(struct intel_bts_synth)); intel_bts_synth.session = session; + perf_tool__init(&intel_bts_synth.dummy_tool, /*ordered_events=*/false); return perf_event__synthesize_attr(&intel_bts_synth.dummy_tool, attr, 1, &id, intel_bts_event_synth); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index bed35029e1f6..48ed60e521ed 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3687,7 +3687,7 @@ static int intel_pt_synth_event(struct perf_session *session, const char *name, memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth)); intel_pt_synth.session = session; - + perf_tool__init(&intel_pt_synth.dummy_tool, /*ordered_events=*/false); err = perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, &id, intel_pt_event_synth); if (err) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 5834bad6ac0f..eb835e531cd6 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -953,7 +953,6 @@ s390_cpumsf_process_event(struct perf_session *session, } struct s390_cpumsf_synth { - struct perf_tool cpumsf_tool; struct perf_session *session; }; From patchwork Tue Jun 25 17:26:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13241C2BBCA for ; Tue, 25 Jun 2024 17:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TFHYu3Nth2gR5eivBBGcLrTyqj+GOTAKJL2cvnIsazU=; b=Vbgk61AkZTSSFX/rR8XQmOvgIS eIt/oxCEw0yFOIwEqvpvNKqfrcL9cD4rT9Zct7LC2gaIRHMqxokvb8z41gJ9JfrSB4YRgSlWT2Vp2 ICy+cLqz2Fp8F1ERQky0r9/6uAe246b5/V5ignLiRPOqmcuklfpkoTqjMCGJp4F9Z9KKwr74HrBDJ vY0IH7QklV5uAgozE3o39zB60TvdfHEx7cYehgFzILwa0jXgu2KNp+P5kFP89B0sI802QQLQ3P6LD HkgBrJObBkHO+gUVr7BmuoMmCz9t+W6/5h4OJOP4xzVvoTMhuGjBBwUWGaJPevS2w6dRD9MuAxHVg wSuAfkxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9yU-00000003uFt-21Ur; Tue, 25 Jun 2024 17:28:58 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9we-00000003szV-2AOI for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:07 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02f2c852f3so8412378276.0 for ; Tue, 25 Jun 2024 10:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336423; x=1719941223; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=TFHYu3Nth2gR5eivBBGcLrTyqj+GOTAKJL2cvnIsazU=; b=WzYe/jm35sLY9xcd4KJHkp2xc3anPbbHsbv+Fgo+ZINsSqCykCF56cY0upL8Em1PUM pCDWcxgmhzDRb4QOO7YRazhCGjyeh/qQAc5Kv1crBXBRcQ5FtF7z68zXG0VaGJ5IXEgW M1+WcMNX98IeeXWcpZo0iW9cb3Q8HgUcFvBBT8khRQALIyH6pBjELlf64/io4dpw68b3 IxN+0cexzpsyw71cNNfE8hABz6ZtdNobtbIvKF7kBSLi9GmiRtTyioBrgU/AGo3wJ2vC 4F+Eqa0+UiYIqXBXtTKUFBnz3RydVC9lfsmZUgCtx7WuXvkKQc7tpQybvxJQpKIWGFXy PjpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336423; x=1719941223; 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=TFHYu3Nth2gR5eivBBGcLrTyqj+GOTAKJL2cvnIsazU=; b=fOfypD9l1sqZ1+2mL4NuZWUxCRvp6QjouVDh8Ziwt4BH36STnySn86nQnkEsxr5eAD qCMp+2u0W5ndsH7FCjutGmoAbawxejuI0ELLQtdE13dBFKv0SCH5Vm/QccrE6+sbxCdR 8uCoXRJIhCbF3sZ19+zIZMIsy06y8ITwczsqwn8qojK6WeEGF5E35p/z0V4ib52XPAXG jVHKw7K8WozN2lE8ZeTYmYTIX5+P9Ynn7eCGtLuOGVFtDobbxLnTsVBhkft2Ez6pECVH Kp9byrtvDhqoRRYZVPvUg+jz5ViKRNv6TJOxb3xYjk/guwLaQI8CcGcW1UwvVuKRJFRy yCyw== X-Forwarded-Encrypted: i=1; AJvYcCWvp/cV3zhLhi2ImP61IVP6MuR6ThS0AmyMu9J8jAC6WoapLimn86NR4PRIZw4dv6C/q2DDT1m2ifqUg/4p4geeivhvYHUuZaWur0UWXk0n30Fw8ds= X-Gm-Message-State: AOJu0YxGxvZCYB7dvBrHg0l1sEDyJKBZwioQc4gxpknuovPufoaSe9WD iLlQyiX4AsJddNAaP92FYOHqQ7M1tG1dYJQ9wiIuVj5eWNPWpWqUbW9122aEA0LUoeMISpf4S2n CFrOMDA== X-Google-Smtp-Source: AGHT+IEIJrvS8Di9GHrS7HY7MQGBt42o3442HpJrxb6gkWIG5aRlpvERcLbaC9Aj1Jog8BdPYhFCbRMarycP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:2b8e:b0:dfb:b4e:407a with SMTP id 3f1490d57ef6-e03040c112cmr445932276.9.1719336422541; Tue, 25 Jun 2024 10:27:02 -0700 (PDT) Date: Tue, 25 Jun 2024 10:26:00 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-24-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 23/26] perf test event_update: Ensure tools is initialized From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102704_944455_EACBE5E3 X-CRM114-Status: GOOD ( 10.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ensure tool is initialized to avoid lazy initialization pattern so that more uses of struct perf_tool can be made const. Signed-off-by: Ian Rogers --- tools/perf/tests/event_update.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c index fdecad920f59..d6b4ce3ef4ee 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -103,6 +103,7 @@ static int test__event_update(struct test_suite *test __maybe_unused, int subtes TEST_ASSERT_VAL("failed to synthesize attr update scale", !perf_event__synthesize_event_update_scale(NULL, evsel, process_event_scale)); + perf_tool__init(&tmp.tool, /*ordered_events=*/false); tmp.name = evsel__name(evsel); TEST_ASSERT_VAL("failed to synthesize attr update name", From patchwork Tue Jun 25 17:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBF0AC2BBCA for ; Tue, 25 Jun 2024 17:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wAL+qN5eeqrm/YV9CC2nA0bNTj605bqM/+2MNtl5Dek=; b=37Yd5G87lHLm70GNYxaSUnJU8E Z4zFB7yx3SNkTWJ5NIGFHeazosS9DwJpFdIEEt4lXTjWNB3hqivklj69DWfdM3/3GBBbQ2T2+fpeD HPGcYsC/p2VmrUZByyKREICVDWDHwWmlYOt62ChjbB/rPKi+Y3NHQQvVx9+QS8Q/gaINilIw6OUdF DRdr+7TuApj3LGWFewFONLeTo2kLM5JFTRpBTMdk1ZWfer0GRPLJtMdPc4UaBiqH5UnKfVUPKJTaT 2rs6PrnV0B3EoGdK4h7g2fzHYkaGeG0iSfr5mkEO4ym94p5LFvkbCyb5XLZVZTPLpvu9rL6ov3FzB 1Jg58eCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9ya-00000003uJy-1HlU; Tue, 25 Jun 2024 17:29:04 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wg-00000003t1c-46d7 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:10 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02fff66a83so5932805276.0 for ; Tue, 25 Jun 2024 10:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336425; x=1719941225; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wAL+qN5eeqrm/YV9CC2nA0bNTj605bqM/+2MNtl5Dek=; b=SaqHSS3nyrTqsMUveXA1MKeZ1RUeMX0dpQqqjQznfGffdYvwL5J4nMmz3WbLb3Zaz1 a6Qv8on1wf+lP+FTixIBfrsmQ9mVmY1n6QK2kmcs+XjSPRHiUcDuDNg4DZlFAVsGzftg fEowlEGky5o7qWzxQVSkEX9vkX5AgDUSxb8IwFnvz0Y/l/jBybkS+YiC87imNR1/+kkS 2A5SI6RLy/WFq+1mvNUaUiCJAJduAUTsGYxV2MPzohsDOmGMXUzT9mDN+nVQ35GRgnzV xf4OIGYijLD8KlxSIg26RsFQE0w0gD+H5ifWnYBBs4D6+nOKgmOo03pICzfMvtxcyqIR cbRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336425; x=1719941225; 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=wAL+qN5eeqrm/YV9CC2nA0bNTj605bqM/+2MNtl5Dek=; b=c+FHe1y1A5ajWF+MLGJiAfX8IFQ3gHCZYliPTjGunbIYeimCOHFPwZS+sycJc8Xb1W eM927bcAUk+7FcjvJTo+YZbXb8s2M7kpXrS3U6cxt042MkaZH3WLP7fxpSzFVuVRkOH5 31Vn8v5Vqpd2uBjMziSPkcanCMXHNiYd6/86ZRKfxlTCg0E0UqtLFry7MRqFf4ZyFCLz emoI9NR5Rx/wufdtGm8Agg0OvquELBY0PNqkH0+9ZKdqAmOc1/33G9TLQnpT3Qz7y4Wl MalaDTODPM+cj4rGFAh10G/s3lv4vCsD90h/TN9VsuoEPHyGKO7CCFvnTF8eYZDJVXPO wSqg== X-Forwarded-Encrypted: i=1; AJvYcCU/x/4YB8wybziXYxxOIKxQ9+iBdVC0/L3fQYj5ENQc0tQCEtsPYy+UDXMJ79Hl7dUpVb+gMbuxMrFGTRP2YIQawztSgIZTEOqxAMPONkNLpAgdJf4= X-Gm-Message-State: AOJu0Yy8wBAbW3EMCAYW4CJZeFI+eplRBmnND5KXYssV8SMuGrIt8H1I k8d7FRboxtwhyQIwKYtgqd83CEcJu0SZkd5dP0HSqokYycUZXEGk3MaTnXjGTBm8MEYeyYTe5Lm oxejNIA== X-Google-Smtp-Source: AGHT+IGD6NROzE2EHc5jjqSHDQHS8KekgYNdRcbDS/mIM8HTKqE/Qyr/e8zZMvz4P4dAQ8k6OBlvKbOYHFCe X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:1201:b0:e03:2583:13e4 with SMTP id 3f1490d57ef6-e032583168cmr45685276.8.1719336425108; Tue, 25 Jun 2024 10:27:05 -0700 (PDT) Date: Tue, 25 Jun 2024 10:26:01 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-25-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 24/26] perf kwork: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102707_371277_EF5B3BDE X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 8ffaa80a2d1d..6a4281b8fd10 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -2322,12 +2322,6 @@ int cmd_kwork(int argc, const char **argv) { static struct perf_kwork kwork = { .class_list = LIST_HEAD_INIT(kwork.class_list), - .tool = { - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .sample = perf_kwork__process_tracepoint_sample, - .ordered_events = true, - }, .atom_page_list = LIST_HEAD_INIT(kwork.atom_page_list), .sort_list = LIST_HEAD_INIT(kwork.sort_list), .cmp_id = LIST_HEAD_INIT(kwork.cmp_id), @@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; + perf_tool__init(&kwork.tool, /*ordered_events=*/true); + kwork.tool.mmap = perf_event__process_mmap; + kwork.tool.mmap2 = perf_event__process_mmap2; + kwork.tool.sample = perf_kwork__process_tracepoint_sample; + argc = parse_options_subcommand(argc, argv, kwork_options, kwork_subcommands, kwork_usage, PARSE_OPT_STOP_AT_NON_OPTION); From patchwork Tue Jun 25 17:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B145C3064D for ; Tue, 25 Jun 2024 17:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0iE986kQkDs5/NJBRf4cgh631/et/Bs7ZiXxgZySXLM=; b=IS10DY117Mr9i8fha4z/P6gYzv iUaW2IfT/zIqlB5c7WzZI44yuyE11k2ONwm4Ma7NpektEt32MUTIUUmF2yshQ0nC4uB6N32sEgKQi biO2Q/k07NXfVd+ax9A8AXnIBloLmRwwHIH0zmXoJDVJ4vX3l5ABBt+fIRwsSjxaVNYD+IOHPnJ+5 LzZCtZR49LaHdALFVgselbEns/oRt8OUGUFVOTw39SVmjHOkn5NAybfiNayV6qY0s3sBq6JVKVIvW Yti6TTQGSyKPrmZKiRadre0BLhlbnRxjTjfcnCV18jyw1bMo3daK7kx4G0GiDZD0syuWH6PYTfTVI tI6tuB8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9yi-00000003uPA-1LHP; Tue, 25 Jun 2024 17:29:12 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wj-00000003t3i-2xE4 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:12 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64501d163b4so56812257b3.1 for ; Tue, 25 Jun 2024 10:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336427; x=1719941227; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=0iE986kQkDs5/NJBRf4cgh631/et/Bs7ZiXxgZySXLM=; b=LpO81fPMEY54Dvhtb1aZ7SU7NihdbdC8peilmnOzIpesTHlVKtKhLD0Xg6cv2gS/0n AzF2phtEVsUeDbcd6/hdhSOWIdHq1lO8OZoYq5DkZtuFe5eTNVgGH3WB2fQt46H4iD/d zj/sXw3nycjmYnFPd4XhtX9VVc1Sdx2psSdACtbG9bO0iynHi+66J2kn28BjUEQEh5oG MX8c4eHiO9dRXCHa2jYbx8wAJVELhPrp0SETx3yQyK56Fncmy70zx9ZkBHSaZ0O7SYbN NZ/RBDzxU+gUrqnbDON68x/eb3D0mcejNRX+qvMDsuTe1JMZHymiZzZNadz0ij+CNo/8 FEeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336427; x=1719941227; 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=0iE986kQkDs5/NJBRf4cgh631/et/Bs7ZiXxgZySXLM=; b=xMk0NXTDZ/hB/IxPH3bs9KHbNw4stXBsQecUNkovtvceeof1S6bIHhvPWKRiFrP+uj O2Yh0s24d2YoKIPjomOkM2VcjlIt7UtjDkK7Fm9c8sux0anmu3D1hsQW/3GBkqbWj0+j 1AlphufrHaUy/sAMAfZd7WotrCJyxmIBUizkJhJmWXoZHGCxEyEDLmihJVMuHrY3FduD tyEc1tjEtng2DstzN06ZE0x+v2wctA4w4s6CSLBYbHEsun5ONLD/O8ucmz7VaMq8DdZ/ tousQ78b2SDEsGFyDg1S5mLVYWe7YaCwtpt8/9mrPB/DDjki6e1Y/BVqiL5KD+ZmwVT1 shUw== X-Forwarded-Encrypted: i=1; AJvYcCUaBwZOItQcR2PN0PR9MpK6B8afTEnAyU7e8dAIxuVjc66udjq/f1xovACOoPivnn9eC5d/NZ1rH2ViUzX/JqD7wptouM5omwOuktjG7SXuJcA0d2E= X-Gm-Message-State: AOJu0YxddTXbyythKKUOutALqvfY4eocbuOhJSi3aUiCFzN3Hp3B1DIw V8SErgKJxZPoXwtktOOcAuaW5qK+vAbO+rG5QqBVKOHvzcpmXBKBTu42jRv/sA8hPGEc7ZkQafg MpqDnxQ== X-Google-Smtp-Source: AGHT+IFVccGq12p3z90FxxfCbb9Z1BYcHe+rBZSwJCNoU8cnhklsujvqjEk+IZyJF5UdB6GkIYXsoj+erzAr X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:690c:6c03:b0:627:dad9:bf54 with SMTP id 00721157ae682-643ae545126mr3852307b3.10.1719336427556; Tue, 25 Jun 2024 10:27:07 -0700 (PDT) Date: Tue, 25 Jun 2024 10:26:02 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-26-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 25/26] perf tool: Remove perf_tool__fill_defaults From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102709_915162_465B1C45 X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now all tools are fully initialized prior to use it has no use so remove. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 --- tools/perf/util/tool.c | 89 --------------------------------------- tools/perf/util/tool.h | 1 - 3 files changed, 96 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 4febff1db5b3..c84a060b588d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1750,8 +1750,6 @@ static int __perf_session__process_pipe_events(struct perf_session *session) ssize_t err; void *p; - perf_tool__fill_defaults(tool); - head = 0; cur_size = sizeof(union perf_event); @@ -2159,8 +2157,6 @@ static int __perf_session__process_events(struct perf_session *session) struct ui_progress prog; int err; - perf_tool__fill_defaults(tool); - if (rd.data_size == 0) return -1; @@ -2213,8 +2209,6 @@ static int __perf_session__process_dir_events(struct perf_session *session) u64 total_size = perf_data__size(session->data); struct reader *rd; - perf_tool__fill_defaults(tool); - ui_progress__init_size(&prog, total_size, "Sorting events..."); nr_readers = 1; diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index a4ca16e5eefe..3b7f390f26eb 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -288,95 +288,6 @@ void perf_tool__init(struct perf_tool *tool, bool ordered_events) tool->finished_init = process_event_op2_stub; } -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample == NULL) - tool->sample = process_event_sample_stub; - if (tool->mmap == NULL) - tool->mmap = process_event_stub; - if (tool->mmap2 == NULL) - tool->mmap2 = process_event_stub; - if (tool->comm == NULL) - tool->comm = process_event_stub; - if (tool->namespaces == NULL) - tool->namespaces = process_event_stub; - if (tool->cgroup == NULL) - tool->cgroup = process_event_stub; - if (tool->fork == NULL) - tool->fork = process_event_stub; - if (tool->exit == NULL) - tool->exit = process_event_stub; - if (tool->lost == NULL) - tool->lost = perf_event__process_lost; - if (tool->lost_samples == NULL) - tool->lost_samples = perf_event__process_lost_samples; - if (tool->aux == NULL) - tool->aux = perf_event__process_aux; - if (tool->itrace_start == NULL) - tool->itrace_start = perf_event__process_itrace_start; - if (tool->context_switch == NULL) - tool->context_switch = perf_event__process_switch; - if (tool->ksymbol == NULL) - tool->ksymbol = perf_event__process_ksymbol; - if (tool->bpf == NULL) - tool->bpf = perf_event__process_bpf; - if (tool->text_poke == NULL) - tool->text_poke = perf_event__process_text_poke; - if (tool->aux_output_hw_id == NULL) - tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; - if (tool->read == NULL) - tool->read = process_event_sample_stub; - if (tool->throttle == NULL) - tool->throttle = process_event_stub; - if (tool->unthrottle == NULL) - tool->unthrottle = process_event_stub; - if (tool->attr == NULL) - tool->attr = process_event_synth_attr_stub; - if (tool->event_update == NULL) - tool->event_update = process_event_synth_event_update_stub; - if (tool->tracing_data == NULL) - tool->tracing_data = process_event_synth_tracing_data_stub; - if (tool->build_id == NULL) - tool->build_id = process_event_op2_stub; - if (tool->finished_round == NULL) { - if (tool->ordered_events) - tool->finished_round = perf_event__process_finished_round; - else - tool->finished_round = process_finished_round_stub; - } - if (tool->id_index == NULL) - tool->id_index = process_event_op2_stub; - if (tool->auxtrace_info == NULL) - tool->auxtrace_info = process_event_op2_stub; - if (tool->auxtrace == NULL) - tool->auxtrace = process_event_auxtrace_stub; - if (tool->auxtrace_error == NULL) - tool->auxtrace_error = process_event_op2_stub; - if (tool->thread_map == NULL) - tool->thread_map = process_event_thread_map_stub; - if (tool->cpu_map == NULL) - tool->cpu_map = process_event_cpu_map_stub; - if (tool->stat_config == NULL) - tool->stat_config = process_event_stat_config_stub; - if (tool->stat == NULL) - tool->stat = process_stat_stub; - if (tool->stat_round == NULL) - tool->stat_round = process_stat_round_stub; - if (tool->time_conv == NULL) - tool->time_conv = process_event_time_conv_stub; - if (tool->feature == NULL) - tool->feature = process_event_op2_stub; - if (tool->compressed == NULL) { -#ifdef HAVE_ZSTD_SUPPORT - tool->compressed = perf_session__process_compressed_event; -#else - tool->compressed = perf_session__process_compressed_event_stub; -#endif - } - if (tool->finished_init == NULL) - tool->finished_init = process_event_op2_stub; -} - bool perf_tool__compressed_is_stub(const struct perf_tool *tool) { return tool->compressed == perf_session__process_compressed_event_stub; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index fb7e32d98dda..0874e7924687 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -89,7 +89,6 @@ struct perf_tool { }; void perf_tool__init(struct perf_tool *tool, bool ordered_events); -void perf_tool__fill_defaults(struct perf_tool *tool); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); From patchwork Tue Jun 25 17:26:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13711739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 364EDC2BBCA for ; Tue, 25 Jun 2024 17:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ePwcA0wK3eP96yB3zQLlKRYoL1FvQsP7l/J+ZxdqnIs=; b=XjuJlxKoTqRIXo85JAaDFFkbBw Ve2Pn/3se8pJY7XeFXB9B3V/yHE9EoLMeYhS6Xy4k0JyG1gk3m2WmGIYFgbc+ZW8+IBGoGOV6cr3M DhupzWmttfOpzDvJOcPYYLN3UvBiWgMmSmiaanmwJifaaeAysyvGSdODqIAeL1ehEbAYDkqE2SueG iZDBL2RaNUkYyLxfx8uo7aRBd/oPd8fRrgjWjA29o/4ydvnu0ytCSM+izAQh15GuuceRmuWCJF2D+ tXXzKOlz20BuWN0zOWji6+iORpbVj7dBLSCHC54b9CaS2ttDL3oxsgackYGzJmhqDz86VszRqKZIp K8hGTk8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9yp-00000003uTx-0UJr; Tue, 25 Jun 2024 17:29:19 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM9wl-00000003t5k-2UxL for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 17:27:13 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02b58759c2so11527503276.3 for ; Tue, 25 Jun 2024 10:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719336430; x=1719941230; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ePwcA0wK3eP96yB3zQLlKRYoL1FvQsP7l/J+ZxdqnIs=; b=aqc1n+6ye9fM9DpiRyvuDwjX61hinG4GGXEagu/Q1QU/5mfVmo/osAjJ9PTBfmIBy8 KHpHPtrOXzaV9zYeqp33fgCXmv9KfvnVX9JSZz5Bi2MVqxlX2+KGWoUIxfFAi4JW9A+D qaDH/hFdUsafBgiIrQzeM7EssCAR00oCzhrpLp9J0sCoG53E7wIrLrDWlbgfJvAmCNjs bPrLJIlPPofFTH9U/VVDxulBwO074zLuE7QPc0lc+Y1t5QTBpOk6M30uxSrH3Wxr0+gn e4O1MF16Dqb914EzJoqs/Ouq3Cdc9YrwJNVWff++Kx82JufDoc6K4CP+9WYFd0hceoL1 Qgcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719336430; x=1719941230; 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=ePwcA0wK3eP96yB3zQLlKRYoL1FvQsP7l/J+ZxdqnIs=; b=DkVshtVMlYgDkNEwvrOhi1CV5ybtpTt5covj+MtvcCfPPcCGpcaahc9+gJJZKEECGu f/5Az5k/Z+RzolUfZCFTZODIaEEmpl5l3XsrLSToNbHyRyIX6RvTj5UAqEfSRX8dI7F3 wkvBh3eQ7QDFh+X7s2ahTr76WYtw/i95Ld0WD7hnxSTsl/SWs4MVYow1/foJ1u9IhuKf 20x3txjEj0pL/oh74gO0VrzPWtC6fPwKXOMF1RteAIv+dBpZn5SRbblPOBKjFCAwpw/x yosbKNgp3+ag28AS0IDROyRLsRt/Z3sAGhFs1TJ5VdvU9Q94AQFX1f6qsQetM2KgFpxr pLrA== X-Forwarded-Encrypted: i=1; AJvYcCXTRrq2Y4L0T/78EhZRcFl8K+tGf7zzbwE4P2tFzreuy/3pDpgODpfTs8dyFE37HsyMiIuiElb8y4jesWcJbM0iGxERl3xMQ8bMJI0jn4ajojh3SoM= X-Gm-Message-State: AOJu0YydvLUaPxFSmj2cFj+4WFtHa3xTuc/ep+VDpobsk7o6Hcv/qF4D APDgTiBIIy2TYV5XSSDgmt2Qdsn463CP775wMjr05R08Tz/pqtUQwgTA+gTC8UosVsKtKCp6mPy kG4bnkQ== X-Google-Smtp-Source: AGHT+IE+/1PkjC1dbP/eaOr2B4eDXRhOCZRz2W7LBZe3kC40WE3zktf40ITuetYB9yqxVda8D4GvJJ4iAyQg X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:b4cb:a52b:f9ea:8678]) (user=irogers job=sendgmr) by 2002:a05:6902:704:b0:e02:b093:dc1f with SMTP id 3f1490d57ef6-e0303edb60emr31288276.1.1719336429820; Tue, 25 Jun 2024 10:27:09 -0700 (PDT) Date: Tue, 25 Jun 2024 10:26:03 -0700 In-Reply-To: <20240625172603.900667-1-irogers@google.com> Message-Id: <20240625172603.900667-27-irogers@google.com> Mime-Version: 1.0 References: <20240625172603.900667-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v1 26/26] perf session: Constify tool From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_102711_795558_57D33744 X-CRM114-Status: GOOD ( 14.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make tool const now that all uses are const and perf_tool__fill_defaults won't be used. The aim is to better capture that sessions don't mutate tools. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 +++--- tools/perf/util/session.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c84a060b588d..66142420e497 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1741,7 +1741,7 @@ static int __perf_session__process_decomp_events(struct perf_session *session); static int __perf_session__process_pipe_events(struct perf_session *session) { struct ordered_events *oe = &session->ordered_events; - struct perf_tool *tool = session->tool; + const struct perf_tool *tool = session->tool; union perf_event *event; uint32_t size, cur_size = 0; void *buf = NULL; @@ -2153,7 +2153,7 @@ static int __perf_session__process_events(struct perf_session *session) .in_place_update = session->data->in_place_update, }; struct ordered_events *oe = &session->ordered_events; - struct perf_tool *tool = session->tool; + const struct perf_tool *tool = session->tool; struct ui_progress prog; int err; @@ -2203,7 +2203,7 @@ static int __perf_session__process_events(struct perf_session *session) static int __perf_session__process_dir_events(struct perf_session *session) { struct perf_data *data = session->data; - struct perf_tool *tool = session->tool; + const struct perf_tool *tool = session->tool; int i, ret, readers, nr_readers; struct ui_progress prog; u64 total_size = perf_data__size(session->data); diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 5cdef3e95c08..66a302f16784 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -43,7 +43,7 @@ struct perf_session { u64 one_mmap_offset; struct ordered_events ordered_events; struct perf_data *data; - struct perf_tool *tool; + const struct perf_tool *tool; u64 bytes_transferred; u64 bytes_compressed; struct zstd_data zstd_data;