From patchwork Thu Jul 18 01:00:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735906 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 E357EC3DA5D for ; Thu, 18 Jul 2024 01:05:54 +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=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=dDYnPBcO5HDXH1LNCb3IMGyeOn FVQjHZLzOYLbdRJi9di/QAhvoOFRi3vzAHwOWBfdxKhZ2bUVeGviU0HzIedcf8Pi6c+08WrjD2gI+ cHl5WMGfTuK9lxcqJaVMrlS9BIGiCyBBDGH4zZQz5QjZMaSUz/0WkWbiRm3y28l1XWiBHlFg5fTED wW7LLYSI62aqzLRdK5IhlMx1OKTKbuzxvPoHprbW4NvPg7cXnEN3umYwh/L573uEKyy+oXRhbUfmy TVaINROYaDNiNryoyGKQeDETzAsXCzK/YQerq5hz0g21eC7AvZBi9aH2GFzllGyBNR1iMw2lDar96 8hXWVuCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFaV-0000000FLVw-3DOm; Thu, 18 Jul 2024 01:05:39 +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 1sUFWD-0000000FJgz-29sr for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:15 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65f94703b89so6288717b3.2 for ; Wed, 17 Jul 2024 18:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264472; x=1721869272; 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=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=RxtwGHcsgTYkmL1WmtxK3aerPuRAXuyU7aLQSre41shb7AMiwMltuc0lROJ0PKsp9u CZKTOWKgVasN+r8q6RYy0/Ya45cfvyueR2lb7d53a1itzDsQnWruzr35L7WefODW2cz6 2Okhvxp5qGlDSk0lUCXoVsLf17eyOpl/knscDfsKGr1sEOKPlTRvXIU0ArpvuOSaNU0b iFUUEdU30xhcVlr0bMWD4jIs5MjaUTuyHJRz0DiyOwtNMDa1Ysue8tukPRqq/B5I6B6N JF7CTLVfJV/Lin9iTr/lKOhJJwQtjCh1xtM2ABytlCJoz4W8Wz+xFzXH/J1xhStUktoA 6tNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264472; x=1721869272; 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=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=Eg7OZlF+Zc4HI/ZsQQluJur2JPZopdcW2fd7xbWGrY+FugboqMfYxjhXTEpcfAE6uz mR4qizoqC0p4R9ZsidsXDs4McDQV68Ktc5Zy9ZB6qnnMkbGDFoSzDNtZgXurFHXs1TbG ECuivwAyHy7LsOEYmp43lIriGYGy8ndM2myOjcvTJ6anc/GoGz8For3ocCypDSc/IX63 8aF/n9DxH2Bi64HhX6V8Hln6ccsyMP5XuA9ZLqkAAjNwZ3MltawYx4cCO/JRx1ZE6Dy0 68QVA7F8WNV/C+AZ4BeCg9PUBAK1DUFrFyQs4s3RtTDSTivKwzg+fDmySCdvraCYd6PP s53w== X-Forwarded-Encrypted: i=1; AJvYcCVc0qSyTFV9VIYJY+1zSDw0mphfbmD6zoVxx8HAEugjhQPJQgE2cW9n00kwpYADOt8AyarPJUHUfbO7N0G/Z7Bw/2XVwl4mNbQD7bGJWdEuEux75cw= X-Gm-Message-State: AOJu0Ywfalp7hmJiJVpydAGzswAWZUyaQJMIL9pgeN6DgLbsAk3p6HAB S/RlMQSq5ApxGo63FciOPySmBQfbmMgCD9iFyZVmY5lm1LJzGkZS0G0DpGA/NGzayyqN5y+HM14 xNHdnUA== X-Google-Smtp-Source: AGHT+IEC7jMCN1PYvXYSFjQ+yMmz4uzntJ34atRdjn0CJuW8F47EslAtvO50ljkTVZhuGVg3mcO9QZPODSju X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1504:b0:e03:510d:3b6e with SMTP id 3f1490d57ef6-e05feb30c26mr8201276.3.1721264471615; Wed, 17 Jul 2024 18:01:11 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:11 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-16-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 15/27] 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 , 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-20240717_180113_694473_67CF8C25 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 Reviewed-by: Adrian Hunter --- 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 c402d9b3dca6..cd5caf1c974c 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; @@ -1272,30 +1271,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, @@ -1477,6 +1452,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; @@ -1531,7 +1507,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(); @@ -1562,6 +1538,29 @@ int cmd_report(int argc, const char **argv) symbol_conf.skip_empty = report.skip_empty; 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);