From patchwork Thu Jul 11 17:59: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: 13730961 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 B8828C3DA45 for ; Thu, 11 Jul 2024 18:02: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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=PV4lXX4iwcFCrdWdTRC0gdlcjS CwDue4tu6Moh+doWaL03HpTAQdIZRvwBKjxqGbrEBIwvQseYEkAhOOpmPQz1chu8S+wsCD7GKrAJR 1389iy87FuMfpWGbGkGmwuHi2gh/oP7RRE7k+CajYp+GiolCNy5FXznUEpnh48Y9utnXBu7lK0wEE 1BM3gp+mM8yoPDAhnCYBgV7lowIHEc0vpQ6SqfcN+3NOsn92rxQ2TcyqRgeu/xTHSCMxmzoE7psn1 3Z4n6v0lK1RX/DFTZ4gGqg2IeIk0ggqpGrdf0UWyedJidvbKdX7WfW84IUmEYFxDm+vRJIR7M6cUi 7OrtaVfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy7Y-0000000Ex6u-2kPw; Thu, 11 Jul 2024 18:02:20 +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 1sRy5k-0000000Ew8Y-3DSM for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:30 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64a5503e253so19837317b3.0 for ; Thu, 11 Jul 2024 11:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720827; x=1721325627; 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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=UpfxZxaL1TAvoa7EahsUSRk1dE0Pi9tQBj8qBN+G7+zHYGdhmTHWh+1wW3NVnCRNCj M1nGsmGh9kPacKI6d8v+252j2E2IfCC/nqqSopLvX9Xyc2PIzOuZHfdCJqbO5340PmVO Hl+u6w7XWes8GriNeN1orzvffdFiWEkUKaICc02vQNN/ZgFkkZSJca7NZhrVcFVw66nb OrIEsjEk8qHfM9e+e274RYLytBmRkqeZ3oBIC2y+xHs/ldRb5G79mIvMBtfkSWM+16vM J/KKQ/ejuaXKtwNtocL+JCKxMTLtAAqbVToepFb52AQNgPuCtvXCCgIPGsdSUBmi54WX X3ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720827; x=1721325627; 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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=HQ04YpjOXsiBGSDj82PowSeO8r3Dk7O6mPnr4EW3VjXAiELGLjDPeby8YMHyQM4dhZ F/joFi8myvEpFJMUkP0ICZEk+QwnIjDUC9BZv+fTYtZDDkx2hNYZW04BlCWxbMr+aJX6 bcjm5OU2X+WumdI5RC9f9u73ueopK5mbl5nx1L/oynf+GjS7TnZUNYdctkFq6s3v1/YQ +OkoLeepHEyO/CeRoogJDD47dj6R9vC0DxWSKwoEulUoYAcS91osW8bliMAvXC9i3WH5 M37Eg5suPF+8RZ9hKvfqU+yVdAKh60iqsBJSxbePV/Ee1tPciJ2ZIt6/PGxpa2oyVkDG ZVbQ== X-Forwarded-Encrypted: i=1; AJvYcCVmdIojtM8eiHi6ZkD/UPt9PeDqpbN5wU2E1VHUL4JwXWTWiaydwT6QvaN7tnlNqn46VCIEVMTt2C0C0f//EfVRyGsB0nmpT3nq0lxN/7RBX5Pv+TY= X-Gm-Message-State: AOJu0Yxb9PHtoMUJcYWadYK4JAJyCRphF6LfqLo/jGbxf55adbgxV9vA +0OXL37K0ON2lMghgXEUXl8jNZbbZjf+cD8HdYibiPuWonRT0LI8VwauZ3IaNZgXvb7dtk/pH7H 3l0FO/w== X-Google-Smtp-Source: AGHT+IGpjmXnPZG6ET95BcM0LX++X4FSpZehPMsvXd/XHk3OIv4vX9bTses9QahK6eBa9XlUvUAYslXgj71k X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:360d:b0:631:d4ea:3749 with SMTP id 00721157ae682-658eeb6e079mr421397b3.4.1720720826737; Thu, 11 Jul 2024 11:00:26 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:46 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-7-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 06/28] 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 , Athira Rajeev , 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-20240711_110028_864793_678AB4C7 X-CRM114-Status: GOOD ( 12.04 ) 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);