From patchwork Wed Jun 26 20:36: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: 13713394 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 94A34C27C4F for ; Wed, 26 Jun 2024 20:37: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=bnGIHHkhF2Y479Oo/otGWrEFafXUa7WO1wDvauktO0o=; b=hTdazJNtswb7ZcwGgHv32Xoats 63Ow5zHZ5pZG6+M/Lkfati5ZsIRBEFo/rewdYXRuddeZJI2Nm4qQcplJb2w2zU11pXabI400pzQr7 N3C8DA9mWAHPexPBSBsv5GXx+fMkiBNkAR18ebkMos1gWPjnVm9iL+JBZ1cMpJbjoqdetwTGREk8U LkqMaFl5lJ9pPkW6X2zqNuKBrx5y3Z35MM+8er6j+c6fdtRhRPeuFng+2dDyFD0tGb0QjPkUVeoNe e6PqUpdm0dcWzgENH+bNV4CATScKZBzHNHI5Lxk/CsleVhL0IEOr6EnpqNbu3tx7r/Mk2yIQV9Q9G 6f1BX0sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZNv-00000008FAV-0fmd; Wed, 26 Jun 2024 20:36:55 +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 1sMZNi-00000008F5f-3XwN for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:36:44 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-63bab20bf5fso164068667b3.0 for ; Wed, 26 Jun 2024 13:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434201; x=1720039001; 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=bnGIHHkhF2Y479Oo/otGWrEFafXUa7WO1wDvauktO0o=; b=Gb1Y912XCD6FmSjVREyfsUILTfnjHsb0YS2afVIchag5GF2bncmI363bmO0qkQGtjh nvVCq2LZ+8WZY5wZPKRO/ie1GvDs4f3eJCoOPz2jaykl/kQX6ZrHonTU/7X73bxlwdhM nW2msVoNW88lwrOdnQz7tTlLVP8San4crRduldNaO7F8HTnQ/5RI9uENPc71uB/GGN0a MiHKENQWt+k+AQnYklZVhaIRdVBxj8xMfwsBXeFiwPokToBcJq7WXVH/gCrvrw3k7+CS 03kdvQRaNmkAomIxkMlDkhq+NRFWRGzkvgff3fu2ZNrobIbBJJ9eEeYVTbVnTHgj3X5b XNYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434201; x=1720039001; 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=bnGIHHkhF2Y479Oo/otGWrEFafXUa7WO1wDvauktO0o=; b=A7ORSNlr64NAOwYeC43f2cg0A4agreLwRLhCjPQjzz6hQdldEpsGeRg1BPZNZ5KCa6 T3AHGcpXVbEo7QmIr26w5bAUHlT7bKo/CpPGViDJY9EnT4MAJn/dM42jrcKRwcswxHwH /2Wnm7pFg+kRYqPKCqEcXaUO0KV4yvEjNpgJCekFNddNl5V/YXUk8TQBU+46cIGIrU7D CXpcJ5wNCCVzPkS6Z7tMAAbxIrUAplU4mYAX5OpzlTJ6UOxtiXSXdIwdyS2+BOcic3ED pFYUViBL1rZaiPdGMPeSf36dmd+5PTjBO4gQi9OzuZ+w/uAxXT4Niyt3KI0bJpFj5rW1 1SxA== X-Forwarded-Encrypted: i=1; AJvYcCUCntITkTSfGX1ep1GNPib3hFOwlLxjeSJTBpK2aolJswSV1X/CGiDUZwJter+aB/vyYS6utZF8fIKrN21g7lRfSnZd2GxykB3muOz3LZAiSfRarOo= X-Gm-Message-State: AOJu0YyTLbBiCtLWzUQ3wTM9XzHXe/2nRK2mE9ehr47Be0wlF2bUZX9j hiB6VAZdQgRjex2lRTEA6Blp+NNR0fBJQOEMpyi114Wvb8SyvliCHlXm262zMZlUE25jjAjmtd2 PEnoK4A== X-Google-Smtp-Source: AGHT+IGj/mCO4jEzm9rd9xMT3ci6YrkO+sYryFdaNeAGcFh7StHBleb0kVfx0rV3JI7j9YEgpazJzR0VNbWs X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:f0b:b0:61b:e524:f91a with SMTP id 00721157ae682-64341c235b3mr1708607b3.10.1719434201082; Wed, 26 Jun 2024 13:36:41 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:03 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-2-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 01/27] perf auxevent: Zero size dummy 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-20240626_133642_922952_9394D666 X-CRM114-Status: GOOD ( 13.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 The dummy tool is passed as a placeholder to allow a container_of to get additional parameters. As the tool isn't used, make it a zero sized array saving 320 bytes on an x86_64 build. s390-cpumsf's dummy tool struct was unused, so remove. Signed-off-by: Ian Rogers --- tools/perf/util/arm-spe.c | 6 +++--- tools/perf/util/cs-etm.c | 6 +++--- tools/perf/util/intel-bts.c | 6 +++--- tools/perf/util/intel-pt.c | 7 +++---- tools/perf/util/s390-cpumsf.c | 5 ----- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index afbd5869f6bf..ee0d5064ddd4 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1074,8 +1074,8 @@ static void arm_spe_print_info(__u64 *arr) } struct arm_spe_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; static int arm_spe_event_synth(struct perf_tool *tool, @@ -1084,7 +1084,7 @@ static int arm_spe_event_synth(struct perf_tool *tool, struct machine *machine __maybe_unused) { struct arm_spe_synth *arm_spe_synth = - container_of(tool, struct arm_spe_synth, dummy_tool); + container_of(tool, struct arm_spe_synth, dummy_tool[0]); return perf_session__deliver_synth_event(arm_spe_synth->session, event, NULL); @@ -1098,7 +1098,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; - return perf_event__synthesize_attr(&arm_spe_synth.dummy_tool, attr, 1, + 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 32818bd7cd17..9fd2967d4e3f 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1596,8 +1596,8 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq, } struct cs_etm_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; static int cs_etm__event_synth(struct perf_tool *tool, @@ -1606,7 +1606,7 @@ static int cs_etm__event_synth(struct perf_tool *tool, struct machine *machine __maybe_unused) { struct cs_etm_synth *cs_etm_synth = - container_of(tool, struct cs_etm_synth, dummy_tool); + container_of(tool, struct cs_etm_synth, dummy_tool[0]); return perf_session__deliver_synth_event(cs_etm_synth->session, event, NULL); @@ -1620,7 +1620,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; - return perf_event__synthesize_attr(&cs_etm_synth.dummy_tool, attr, 1, + 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 ec1b3bd9f530..fb8fec3a3c36 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -738,8 +738,8 @@ static bool intel_bts_evsel_is_auxtrace(struct perf_session *session, } struct intel_bts_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; static int intel_bts_event_synth(struct perf_tool *tool, @@ -748,7 +748,7 @@ static int intel_bts_event_synth(struct perf_tool *tool, struct machine *machine __maybe_unused) { struct intel_bts_synth *intel_bts_synth = - container_of(tool, struct intel_bts_synth, dummy_tool); + container_of(tool, struct intel_bts_synth, dummy_tool[0]); return perf_session__deliver_synth_event(intel_bts_synth->session, event, NULL); @@ -762,7 +762,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; - return perf_event__synthesize_attr(&intel_bts_synth.dummy_tool, attr, 1, + 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 d6d7b7512505..b8b90773baa2 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3660,8 +3660,8 @@ static int intel_pt_queue_data(struct perf_session *session, } struct intel_pt_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; static int intel_pt_event_synth(struct perf_tool *tool, @@ -3670,7 +3670,7 @@ static int intel_pt_event_synth(struct perf_tool *tool, struct machine *machine __maybe_unused) { struct intel_pt_synth *intel_pt_synth = - container_of(tool, struct intel_pt_synth, dummy_tool); + container_of(tool, struct intel_pt_synth, dummy_tool[0]); return perf_session__deliver_synth_event(intel_pt_synth->session, event, NULL); @@ -3687,8 +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; - - err = perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, + err = perf_event__synthesize_attr(intel_pt_synth.dummy_tool, attr, 1, &id, intel_pt_event_synth); if (err) pr_err("%s: failed to synthesize '%s' event type\n", diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 6fe478b0b61b..4ec583e511af 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session, return err; } -struct s390_cpumsf_synth { - struct perf_tool cpumsf_tool; - struct perf_session *session; -}; - static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, From patchwork Wed Jun 26 20:36:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713395 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 A07E2C27C4F for ; Wed, 26 Jun 2024 20:37:19 +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=lcJ2tbGh1Yfs0OJM6bkJDG9fBvcliigGM1tYWqZJmL4=; b=xUfjO5yKI1DymFViCGGBZBT1hD sJHVwu3ngOl6oYgTx7x6gwN/jbT7CLH7c9MZ1XaGUw3Jg/a2yda83+cE0hkHp5FUXyfQCzKfblgzZ x7OVMDPHuXKAlfEKMytUNYy7CBlOQzbn5UrC5gpEfJDyCnffD8zQs7wMTk7hElQtdT4DKuOfzS1Cz XlBeOgeMaiGbBIQIftYauRsdvAgcz0ojCJtsW3SfFiEvJbCpwAZBZDsDAPtyZ6yOrqOusFNtZinF6 a/xjLPezq7hhZYMIzAiTJXNZxzE3SLtwA/9TS7xyqKSDw6UAcb5OYGfubH+jl0LsLQGpTSNDEcmPh 2JVigNcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZO3-00000008FGc-3x6F; Wed, 26 Jun 2024 20:37:03 +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 1sMZNk-00000008F6c-3GoR for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:36:46 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dfa73db88dcso13883227276.0 for ; Wed, 26 Jun 2024 13:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434203; x=1720039003; 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=lcJ2tbGh1Yfs0OJM6bkJDG9fBvcliigGM1tYWqZJmL4=; b=NEqPLW19iwSJh4GN51SKY/NBPaoZlNSwp/qZjfiyhXm6aUHtfcQwMjnl2oFHq5ue2q aK2Aggml4YEhzdjHWH1bDFUksHFhJv5ussAPzr1AQrzR7qn7rlVq1wVg4T7lR4JCqdVE prpNcERyjKpGG+daUapLwU3kP/rAympxPrI8uVz0qgdESOHtgMOcmbjOSOLVApXmBNHc exB/X6VdoGifMY+g9g777sAgvrtZR1papfk5z8X74NQRtmx/ts+UuT6OmOkAKHJfzDl1 5/QTuUJFo9JgljVV0RTxsWXNVj1duUjj65e6dtmKWRbBkTzzPcWXCby8iGh5+hSZ8aRr fCDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434203; x=1720039003; 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=lcJ2tbGh1Yfs0OJM6bkJDG9fBvcliigGM1tYWqZJmL4=; b=uFi3Qkzw7XFWHbTVueMAOSUVrJhM0pI8NW5X9XU7a11k35HXH1r+AL7hVoL2YjHtNK jJMSol3pKfIGROCFld7i/EHmUPau/tczPZ2Mx0GN+VXq+A/w/zywhL40EOFGLQF2ptmd YaINFPLQnDpH0ZhhRWcr6D+jljfPL2biFHGCIP/gLUMFDaUXgPDolum9kct8iFZuw8d2 GeCZl+uknVvHsc3W78wYW/p4DqcOEoBF9MQe5sOkFarXufesv+6QWapSAp6QluO43zeZ P2ldpGJZDE42QjCZ6JMI5ejr7VEXWhmq9gYydMkloE94+EYafa4EuWVzkwQBsZT0uKcg rvKw== X-Forwarded-Encrypted: i=1; AJvYcCW6GB1Evs5hNU+zlXUEIi1VH99ELvVlVoKHMR/Pbs8EWXLeWdvMvdSuVjywuE9EIj689af/QhmRmZ9MihguoCnj1e9QV+Bb1vLVx/8YeDrjOPyeUWo= X-Gm-Message-State: AOJu0Yy0ibWOp33G0Co90ro+IQImTvzxfRBNbyeVWh6g0nm/Wm4iuM9n 2SuUDt/guIhdSTrlxNvmwsTvX4UZHgYD6xmt2OvgeFytSYUZaR/VWh2Z6R+CR24xhTwYfjABu3U LCnjw1Q== X-Google-Smtp-Source: AGHT+IF1ujd8fnaq1c9+yRQXwV8wiVuEn0TIgaMmQb8DJtqM0t0gj5rgMA3or/ZxmEcUAkhmByF2yBScwXbC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:f84:b0:e03:31ec:8a25 with SMTP id 3f1490d57ef6-e0331ec8b21mr6829276.10.1719434203172; Wed, 26 Jun 2024 13:36:43 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:04 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-3-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 02/27] perf cs-etm: Fix address sanitizer dso build failure 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-20240626_133644_914601_0DAD170D X-CRM114-Status: GOOD ( 15.24 ) 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 cs-etm.c had been missed from having accessor functions added for the sake of reference count checking. Add the function calls and missing dso accessor functions. Fixes: ee756ef7491e ("perf dso: Add reference count checking and accessor functions") Signed-off-by: Ian Rogers --- tools/perf/util/cs-etm.c | 10 +++++----- tools/perf/util/dso.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 9fd2967d4e3f..e1a7eebbb15f 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1013,7 +1013,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, if (!dso) goto out; - if (dso->data.status == DSO_DATA_STATUS_ERROR && + if (dso__data(dso)->status == DSO_DATA_STATUS_ERROR && dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE)) goto out; @@ -1027,11 +1027,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, if (len <= 0) { ui__warning_once("CS ETM Trace: Missing DSO. Use 'perf archive' or debuginfod to export data from the traced system.\n" " Enable CONFIG_PROC_KCORE or use option '-k /path/to/vmlinux' for kernel symbols.\n"); - if (!dso->auxtrace_warned) { + if (!dso__auxtrace_warned(dso)) { pr_err("CS ETM Trace: Debug data not found for address %#"PRIx64" in %s\n", - address, - dso->long_name ? dso->long_name : "Unknown"); - dso->auxtrace_warned = true; + address, + dso__long_name(dso) ? dso__long_name(dso) : "Unknown"); + dso__set_auxtrace_warned(dso); } goto out; } diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index d72f3b8c37f6..878c1f441868 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -280,6 +280,16 @@ static inline void dso__set_annotate_warned(struct dso *dso) RC_CHK_ACCESS(dso)->annotate_warned = 1; } +static inline bool dso__auxtrace_warned(const struct dso *dso) +{ + return RC_CHK_ACCESS(dso)->auxtrace_warned; +} + +static inline void dso__set_auxtrace_warned(struct dso *dso) +{ + RC_CHK_ACCESS(dso)->auxtrace_warned = 1; +} + static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso) { return RC_CHK_ACCESS(dso)->auxtrace_cache; From patchwork Wed Jun 26 20:36:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713399 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 89C43C27C4F for ; Wed, 26 Jun 2024 20:38:26 +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=rfG2WYmeDLtN+34chinyjKQUHIa82B2o0vCuY2npW1g=; b=zLa4wwJ9i8mB6wvelZNItp+tQ0 tOvNxbrfCaEjA5dzgs+4fiIwo31VO3Cnxeg+RB3t94s4u25HMUmJCkQNAF2+zr4gTDbUB6jflA/AH +5A0fQgFxTX9TU+OjCtHVHsOEW86/NZGLRr7jo9IdDBFTZnxlzvWaGVV5hRpz26OpF9CwcU/aySVG 4CjXg4jCgsOMOEgTc5vsIfrN6oiOLpyQxbJL+pCAE6EbsjlD9l2FwhT54jWRjq6TY/kS9Ug/G7Dap kmpFEOdTqIlL7N8RxJbExjsxDNLYicOiPHv9+zMfDyOeovz3IL0ILjqModE/hfAmSp1VaJdHnafqj o9SUI9pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPA-00000008FtN-2jPN; Wed, 26 Jun 2024 20:38:12 +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 1sMZNp-00000008F83-1aL7 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:36:53 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-632588b1bdeso134319517b3.2 for ; Wed, 26 Jun 2024 13:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434208; x=1720039008; 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=rfG2WYmeDLtN+34chinyjKQUHIa82B2o0vCuY2npW1g=; b=GdqACaEXpz9aPGWx7UHz8Aifl71I9+NkfDh3UTqx8kWkVKPl48VNwK5BWwq+G8qrtO RZP02ueQCD4pV00MKaIBjbzRlQ+rXWvCkwvG37Zwsryx8//lzzQQjhDV3YtigaVbKhQo qTsEyCuAfCIvRr2zHsZ6KtdvQtFnWkZ5Z8vpiTY7tFyWIterqtqDBvIslf+LCQBzSf6O G+Y+PVPAoBG2oslVM+3nzj4TU1/xbxjHVMzQ/VnophGvcIMc8ZFj+YqWQHHJT7bU8fbt EDq1f0/rwcJWdXsrWqf2HQWT6Y/3Cl6hLMXiVPsnInDAj6qTWhJIf1BOdYHCSwrITQm7 FsOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434208; x=1720039008; 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=rfG2WYmeDLtN+34chinyjKQUHIa82B2o0vCuY2npW1g=; b=aubS18a3Qr5h7BhrT3sXrp8CSWko7/ZgmLf32g9dgvaYbWa/xiU+YsreavxnNe6Jrm w8D+cooEaF8Y8XpdbnpE+87sD0Zx+F6e99K8fEz1YJIxm0R32F9QIKeAvjOEdzaBp86D htYu9x1VGiRUHgM4JHowmPrXkVUOOgnagKJfKLOFVsUWtwigpqzok6mw59kRH7yi3dUP L16tYln2bU7jJ3WZwWeH5l5mcgSShsZ74I7GSB/ywVSM9YOsTYrCBfRDPQWaA5JrxcPr uJ8OLATFp4MlziQs8IvNpw3mYxMg/jUxBvZTLqJEnkp2IWsGU0RKJO38QZJSQAum8eOv n80g== X-Forwarded-Encrypted: i=1; AJvYcCWGVvAAbZgfA4bqKbjNec6MX2hGzntv+uDUfDc525u/uypHirNJEseJan5EwxT9hNO+PkuxRjgsmVhiKGy+H1/bePIvm3SnVTHdeXHIN81+f7JFY0g= X-Gm-Message-State: AOJu0YxBztAFUKHjadg5l+/NE/Z5+0SRtb0EUPc/+2mDY+rOi3mZVtRm LgTqbp8v3V4egdX4LKRMxEaMh0TDTgXtPFsUppM0/QJNNdW5jL2HOxEQE2jPRp/mJpvJAaLUHwK hVfBoAQ== X-Google-Smtp-Source: AGHT+IEkp2yaZ/d/lqoPmm5Xo17WAvc0CLH2LVlPpd6GVeWqJi0FCVKRcD9AEqusi9l6roNYlpCp3ny6E/gC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:25c7:b0:62a:45ce:a268 with SMTP id 00721157ae682-6429db2094cmr405537b3.9.1719434207976; Wed, 26 Jun 2024 13:36:47 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:06 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-5-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 04/27] 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-20240626_133649_555719_2776D574 X-CRM114-Status: GOOD ( 19.57 ) 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 278955b8e73a..e1d38d91a1b6 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 a298de3c85d8..9c9c531052fd 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 Wed Jun 26 20:36:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713400 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 4C3B2C30659 for ; Wed, 26 Jun 2024 20:38: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=AFiPugBk+wYhM4/j4Jlr9h9+wpX8LHXAYZExjKx1mqU=; b=J3qoV7ywBJ6sq7dZXSlaz7/vGH h9rVVJi5AA2V6X76/vCMB6/Wg+bx/b7yJLF0XRvKm6AGVo5WRE0KVev+tbw2MR6UiwmUZ927mPxNG j1rpyrmN9vtGMxRzPXfrsyzDSJqusxYf6nLOGm8AWFTYZ09sfTNffdF4TI5xsPCSNDy6UNz+MkJJP w8++TOj58t7qXzcP/CaEPMiR0561d5LH4bt/XzrLAq3149ZZGQcHBs0JPBlbqbEGEi1VdoLQEiO/P dN3uH+Q7AJ/5SuglZaSbTpectMtQN3/iuAJ7rib+ipR2BTxcbMCMN3UpC7DPfnMaDocP2Bw7vSjjl 84dBQ+PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPH-00000008Fwx-2V2Z; Wed, 26 Jun 2024 20:38: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 1sMZNu-00000008F8k-1OFb for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:36:55 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e032e254319so3380753276.3 for ; Wed, 26 Jun 2024 13:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434210; x=1720039010; 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=M+GWNYK4Q0ZZ8Igq1J8zA7GsZPJyNihrxg/TyTjNxFhY18kUPkeXqqiUw11aUpghHD RNq5cqppxU1diqV37Rpsyv4862oDxm0EErhL5EkLCPDSGFcjdTByg9/AbztKopPCAk2B 9iHhkwlsCUtfekK+iyzI25dZQ+Ppw7UpdLN0IShGHHtLI+smiRSBFOaBb+6bLPcKY9pv +75rdkXJ97HP22uWqNbR1MlgnO/CJVg/tyWUdpCtWSiNy4REwDLpvNPrSqWpkc+4+QvJ njaTkUZpiqP2bDjt5qO2Uk+c12pWTeSCZFInmi+5cdTwUJ/wQVxp25oehg7/3mUC5xt1 XSQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434210; x=1720039010; 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=m2vlMOdxE6VqkiGKM52U7gAPWSblQgT2H91jM4TzwTz8XVY6PWL+GKukdwaXfDinHz 2hTZkuIf7Pqyf+OECkDkpf+dYeF+7Ut3jCtBB6pH62jroKO0IuJBA64uQnkCQUK4GjFV EvPQUcJxLbuMLpVS5Tjo2pjHmz5dOoEeGx8uHzWwjsDEcJ7vlSawRXV2vBQilnQcUe4v +eX6/sKYiGHVAuNWdFpetPA/91VHcskF2ALUTO2vGWTVJQ62G9JMm7B/IN9xjQMOgRlf 1N1ZW4AxRc1QzvUsx1GSepWwLTE4HbR4ufYim3emCGqmrN31RJsiHOlqIJwxgWRtaSG0 1Y8w== X-Forwarded-Encrypted: i=1; AJvYcCVQVy8nIMPt9QM9PxtqT3sVeswXd+MdDy4sRSDNMjq+71WgIhdskGLORpl7e8ZBcUnk80wxyALnJTnINUmJF15zhtXpABd9Se+ggwK881c/DujCoW8= X-Gm-Message-State: AOJu0Yz2nih+wQFpq1r5QKBMxe7ZbRJCASM6vCEsYbvG37QtVR4h5ck7 L6dCP7iFB01eva7iIqp7ZNT59/wuTZTTbWbOTPpkyTrTqN4eMCaNs2HcSTCOyd5/GI8I2uU26An aqiO5UA== X-Google-Smtp-Source: AGHT+IHT6UsLLgb3WeR5Tle1hXNSZKCOcstdTB0LxqaxWb7lVdJw/IMWJFFV90Y6uJl5XDW/2Jn5RtufdKfJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:154b:b0:dff:12d0:2072 with SMTP id 3f1490d57ef6-e0303fd4396mr704257276.2.1719434210053; Wed, 26 Jun 2024 13:36:50 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:07 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-6-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 05/27] 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-20240626_133654_395191_7BA1899A X-CRM114-Status: GOOD ( 12.24 ) 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 Wed Jun 26 20:36:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713396 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 17DF2C27C4F for ; Wed, 26 Jun 2024 20:37: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=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=H3L4TbiiIeya6ja68wqDZB6mAB OP80nuW3WMl2mVP3XIGsm1U9Nr7tDLEn2uXm7kTFYidPQ2y3VAOseVDgBmdwG1BcqmWeNnMoaxguk HrEOF/ONhbfeaJedQzcNyTQrI9Bq0RETwryQ7ISEjXKl4NNgfDiBs3HOQ7UV1HkQasmPNdknzePAc M0Yo+1PFEAAWUCs5h+66I/gOld/xIMfAtQJd7SXuhqKCENjkPOWygTJ+t2zM2m0HKqeWRiGPciNfe unpRi5QYZrkFH9C7etL93YQBXxf718AWvmZkDCOfgVYT5+BoSHvkT2gtfa9U3BRXaa+DXRXHH7Z92 UsXo9bFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZOh-00000008FfP-1m1p; Wed, 26 Jun 2024 20:37:43 +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 1sMZNu-00000008F8w-34lT for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:36:58 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dfeff1ae480so13556521276.2 for ; Wed, 26 Jun 2024 13:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434212; x=1720039012; 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=Hay+oN6/K6L8FDTP2ofGb1SalYTrVcwvvb3xaE9HP8w8y2uPhJMLlwWsYuOJ5rji2T eO/UnbkYG4Vtdi6LF6tzLRq3Uta5bAvKoBrySe1HcpXfJQqfCsiSzDiGccY2ryae+Pzk UdYAc0VG+TgsIt4Im0GNkrPiGclvS54PP3SYhn4wCq0urXktSAct7WGtE1ugt5dmOvpg T7G4hXF4YkJ8ADl4a3QqIdXzJWmpPl5ShBvafjgTiBLOyubp14FeTqfjzJZF6Xq2EM+M mxshaLZSsKFaLKxm9gS162i6wosr3B9FVdvqk4HvlQBXwLG/N4Xq6kWMqQMCkecZy07Y a+Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434212; x=1720039012; 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=VczbVk2TKLrpL+kqfWqhnB/KSF9jUHWlp6gVHlU8XI9qjzJ+n6qIPv7mF6wvUm1RK5 MLbq5AKCpaA6Jq1UX909cO0LIkhvMG3k8hTQxZZOOgtE2WwXKTK9SAe0wSMO61VFt5vx 9FtaZnpEFhuwr4QePExp82hziMcmCTbh/EiTlpxOCBRP3Cic3jcygBw6VUOOnUIZY/ib x1UH1H0zjGwc4AsPIsG2pxtKeqQfh33Q3y+OcHAic6a+IJ12EQW69nKtGlbBzf7eUbHH OmcGHO0CfdDD0PFn8Buz4dVWbr+Kt+pjYjzAWDl/WzuI3xnpaCzSchwRnUO7pm6lPP8j WU7Q== X-Forwarded-Encrypted: i=1; AJvYcCVU/xXmNhJbuudTdrLV+uhSc5O8v3Pv1d/T5+CMYHzS2uV0T3DDuw68nC6ku9DXKWqVxt5r69QCjy+agDIlGhi+JjNXCmheZH/4YII3hlvLZlqyKh0= X-Gm-Message-State: AOJu0YzD+nKhlhSTfrELocj+rkyiZ2mfuYLqKe1z6B1TOGdHbvN9lZPo GHjnr8LV/aqTyKb9D31zAY6M74MT/6kYMtRK8pp8B5AIQG1YkMocCk84GpgKAcPW1RJhzWxi+3D h0v5DhA== X-Google-Smtp-Source: AGHT+IFkDSWMucqUyPP/weWWjzyS2QYWG8qQwQFISbqoPdxZMm5/69UxoFZkkGsqMZ6C+gcONv53ELx2EAOp X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:1241:b0:dff:3ec0:71c1 with SMTP id 3f1490d57ef6-e0303fbf483mr458676276.8.1719434212285; Wed, 26 Jun 2024 13:36:52 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:08 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-7-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 06/27] 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-20240626_133654_843300_97521B02 X-CRM114-Status: GOOD ( 14.74 ) 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 Wed Jun 26 20:36:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713397 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 4F6C9C30653 for ; Wed, 26 Jun 2024 20:38:06 +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=KDf+x6OX3nC4zh1kEqSdqZHH1v iFYcXtdyUnqxT8iOm6B2UQwaWJjKvHvHydfFe7vRIif72b1RGEQahH0j1o2fvKdqaQAMvSsFuaXGm wddmH4OHRXXdU6+xQMeGV+ltgOCfMSkAA/ztbRjb+ir/H07GGq/1eFO9B6hqcrWLaLJrNg+mSCauG paO7wr21T6rrbdHoQVgMKWtOEskMuGqbkeKrkYzuC63jVgE3XcFl8OVF3GRErrxAhpBatoJhWE2VL 8sWamndZS1yq3TAM308l6RTabo11IVYeftQE9bFtwzfaQBbwPs69cRzI2I72xqT9NRuAavWsXYaC4 K/fJHzcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZOq-00000008Fk1-1J55; Wed, 26 Jun 2024 20:37: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 1sMZNw-00000008FB4-3vyL for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:00 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64507372362so92714757b3.1 for ; Wed, 26 Jun 2024 13:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434215; x=1720039015; 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=nk9F5bVQH/YOGbCxONQ+SP+73WI9bRQAiRl7043jypvu9svz6ndK4VP9wC6Fg+cWYq rW5wtuun3RecDMZhbk2kmXSPOud3ozwl5c1BRfPiody5ITNGYNyAL37y+1mhsDdElhTa aWGIxo1pkP4sBdJU35nuNNhZktnxd+5Ve3HmWZhREFKEuayPzVWoflBEtc+H6w69iDnU FXGHTNrC7azK5Va8BJnEpkLzfeZnFC2UKSS/UFeSQg/9im2kdYR/3mwZJDPhiLeghX2k 86Avf5OASY1zsMEeDNGnZ6TVflVf4OIvLB+xh62w6qRTg9H0JAPrvGjaqlgW/6QdcXf9 FjSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434215; x=1720039015; 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=K5MmoJlI9kVL4YxawjZyjSGxUvf6sOzkHYS9XTcMRI+gvHmUQr4Z9SBlJ5eqjd6Get RGJzEqExV6/FE8HoC5bhhNec5T4PokQ1+jK8kVPJJpvz6K/9Xpj9frA3mxXsI3/lUPRO uwoV005Bq5QHF19V2+/Bww1xH8b+dxDHDZV1EATzcMV0h+62bW3dZEqxAlOEZgtuV3OD I1TVgrjXIBtSWVJ0gt22/AYHKJX/G61xWU7LTJVzSBF0M9ZbjsfOzBDCJ3XhoYH5SlWm Hk7ZISM3UdsTbqeRO2vyKRKb7HnJxSOgrsQ0t1B0z9/KEKwls65WySjwESx+BG+B4BWG EhHw== X-Forwarded-Encrypted: i=1; AJvYcCVFSiVakjzOfImGIlg6yH3Z/vRQ/NUEBHJ7A8qhjKRPP9eWjSmz2QvfxD9FxfL425ESyuZT/+2kqKC4x+nF8wE0vVSeDTRHxgdh+XhlEgB4kq52MSY= X-Gm-Message-State: AOJu0YzPfMR89FqEHT1mqnzp1vB1nyRpBFENF9aUIt5aYcISxT8hnrAA 2xasVvWgFbzi30OIAwZthQD+fIWIxojAEWudS2bZinGF/n2BMF5McueE1LHxCxW0dNc1AsPPzX7 7UuVfbA== X-Google-Smtp-Source: AGHT+IGT+gvtwDggFBDqG46JcZNI+OF6C4ySEcnFu5BTJCBB89+ztHE/sDy0qagvNq8yW7dfnywqTmFE/0AO X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:c16:b0:631:9b3b:525d with SMTP id 00721157ae682-642997c4d57mr410297b3.4.1719434214542; Wed, 26 Jun 2024 13:36:54 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:09 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-8-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 07/27] 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-20240626_133657_152514_22A23C79 X-CRM114-Status: GOOD ( 17.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 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 Wed Jun 26 20:36:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713398 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 2C475C27C4F for ; Wed, 26 Jun 2024 20:38:16 +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=tCaWPauD9DYnL2p41QgtYliLPX lBBnOaGKyb+9TKxWvi2NqzGJtT09Yb2u2ne7mRALhJX6GmKVgMa9jc05acDUS3NomeSBeBJomGNU9 IJnVUL9EWXgLUsBdRzd4CqaNwZ982daqXrpqUs9hDlOdb6aHl/CM9x0csOwMfab6YP1eqSNcnl5Pv N6/wyyqcoDCjJR0uoSP0HjV9uuxlUR9mpYF12C5Sz8Upr3iWAuXF34BspkOmYEodZckDS/tRJ5WeP cdh+Wz1ATkcT4fwtiVayP/fG/lTVBzMSGXlF+VHB9zpd74+CwdiDVBBITTrPsuF2mtzjz+BD1SFNy 3o/nfhEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZOy-00000008Fo1-3og0; Wed, 26 Jun 2024 20:38:03 +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 1sMZNy-00000008FCH-3ggH for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:01 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-646f73e4354so44112737b3.1 for ; Wed, 26 Jun 2024 13:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434217; x=1720039017; 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=S5aH8amcxbW9gZIq3orgT4ctT+hHC6S2V8qppK9jnb1Lw1myhJHJsQqZ+oHH9E8zE+ bXh3IC2gWnQbBGI1VVw6nbRAKsXA3bjT1A5LnF4TuAdg0F1G0D3NvgCXIXJEGofSY+hJ zNoOiX9ZHZO4ggN9agHDrE51KNklY8EqKDQImuFlOln9dclor86F3qvN0d1PcftLGjmB XsqpBCfMGraA2rQ2EEPL2UorCrWi9m2epBieWMW+qLH88NTclijgEwqbUfjKJrSBUCBO oxmG2mu9DUcA2a+TZu8U/VegHbdED7o66TLgExbcNF0pC6uQt2IFD9haGw2KucHFxzHy jMMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434217; x=1720039017; 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=FsjFFMi4ZK+lW8LO0+/aRFiKfxVLVXG7edYWR0fEEl+gTw9BNxks0aNuVf7LJWFIxB 3laa+CLNORSbMUrNyacF8VYFVF6mBcxIwW0TMUudv8yIY7Y1Tv71PkTCtlA6WUUCgeKw cevbV8chPCyDG4U4qkK+acr/V7XbJAS8iZdRJ1uupZt76Ql5i8RwRSNGdSTo6dUlalb8 8u9LZ2VhyUPk2YlfyMCXMC6OqmHXs+Ybr0yo2QOVT8LMyktjbzGvhM+IZ6unGMjDa9Hd mZ+8BbPrpnQvovXjMge2bBG63vOru/VPck0++WHCzTJOwdeVE8LbNvsrX8iEK9RHiY14 X9hw== X-Forwarded-Encrypted: i=1; AJvYcCU3jNEzkN4rA0TQQ1mIuYjYCaHF+nhZ1GoKqH4e3fuR25g5wSS4jNwjl2q2IXqm9AkfetUQ4NvbhzocOBd1efs6Dqwrd2hiFcwyN5yI7JmZ3wkzyvg= X-Gm-Message-State: AOJu0Yz+skng4ntqeVvkuoERxLiIwqnlbD5188zOZR9RcRN8815oKw+q L2/0+hLH28NH8zyugpIgXdWreQyxkX8XMPn2C6JjzjXakDAEVL8xt1dH1BOtGHadiu4eDYnQzVb 1ow35gQ== X-Google-Smtp-Source: AGHT+IFuUkZI1xUb4dQtuVFreG6sSaXi+9c/mJnE0USxl2dca1+VIZOjUXTn6HLYlU8i1RaN2vfEqGJqEkiE X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:3602:b0:62d:a29:53a0 with SMTP id 00721157ae682-6434041982bmr1581297b3.7.1719434217307; Wed, 26 Jun 2024 13:36:57 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:10 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-9-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 08/27] 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-20240626_133659_034679_6D796876 X-CRM114-Status: GOOD ( 12.86 ) 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 Wed Jun 26 20:36: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: 13713401 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 D435BC30653 for ; Wed, 26 Jun 2024 20:38: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=W+G0HGMTQoy+2+TKDBA5eg+niEy3wMk5iRiA3dPthGE=; b=1swmSXkzW33suuL4IIW1bHs6zy cHUrGvx2WSnJDdenE2kc2PiS6i1eEgju1PGn6Bs5bfxZTF3PYpWhY1DyCCAS/F2lA5a4UnuHWrxIg nW/+6MQtxJpJJTlCGKDqtW0V2gsU0cKwumKpApcu/Xa2fbdtzHmFAEkkjuwX2tLWOWX2iTdOgmlsQ C4JKV6vW+ki/K21CfShtCi8d8HcQVCkFYAkr00UhbBmEaiS1zqemy9J7qyKPUAcJvcqXHXQqwbGmc Wj01cfufkYL12MOFMAzsKMZkhP2dMV3x1NaPXbLKxUhVPqPmoJ286JVQf3481Twc6PYlADvleRR5G Qg2eiBKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPM-00000008FzU-2pis; Wed, 26 Jun 2024 20:38:24 +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 1sMZO1-00000008FE1-2DfA for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:03 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e02bb412435so14996341276.1 for ; Wed, 26 Jun 2024 13:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434220; x=1720039020; 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=i+/WRgFYCK6fVGF6IPPE3pVFZzbCqsz/GbmAUwO0IGS1A40Y17+o6sVQXe/+jqshGY K0l7N6YBtyr48DyMuMOSvoKlVIv//qqGT2H1VpkQYTW5e7AILdevJh2pg0vvX9DFzDUX DYbqsZbebqizzDLogumOhEWftvFkHWfXbjIuqc9bOSxxKolcKVSOZchRPQZbv1nQ7BKB QcJ6aJ/n08+L1UdvxmO2jN6apAOVjAs1+7waxmLqppgux0290kAAf3cS/GRAh+zOQqdz 4ejhmTKOMjFLQh7CLtT7iqfbSw1FuJZXEtLtViTILWpsCjkxHVfIrWkPyX1NoPC2tABm 5kNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434220; x=1720039020; 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=gTpoGKFELJMHmJUU8GTUY5F0y/aGNMEvoafZsbZVeMwzznhlfxgW3IzlA3wMHQQpgq PVCBdLUr4htlVzvWoEsbeC4vkYk338QQkObLyQ7nqHTrt88RXLVxYGRF53h+eA1iJ5Li Ebm4w90HGqvxFg32MTxNiExFerh8xKfv7P995tIWzVqptdcpVCMblF761Jdo+Zb4GRkF RK23FokDClF3QqqqJIibOwCM1qUObiZ61ss1YDWTclgdIT7amrIwIxeA8pQPwPd1gBKt K6ZO7uCEOlyOrIjiEuXTryOz34ABbCiSLvEN3bphsS6YaiIvKrtZoh9773I3iLSkZDZi POew== X-Forwarded-Encrypted: i=1; AJvYcCWeD+sZ9A9c/rmgB/OjaigP2X1HtL3o9m2gm20EPwGJFSWa/A/PNxgrfHHDXkSpmSsPG5zx5LGDj4P3VkhwaV9xLBjFOY6AZ+YJAEkrX/gbWEfbsV8= X-Gm-Message-State: AOJu0YwCVF5Zaj2+a8LQWMpU8klAXlEa0myY7q2YnVFGwk3UVUDnm3Tz 024rmS7bSjbFZMwVXrcRa30PcxBFw1APTk41F6hb6jj0jw7wh8AqgRA8pYx0lNCSs0uZ7bkzs6A ufSUAog== X-Google-Smtp-Source: AGHT+IGFNPE1mTzElJCJfk3y8lPhljBftC9JeXwX2Xh4efoZ4u/33kjM0V9SfLs8rKr6O0JpSXmbu4IU89Bx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:c591:0:b0:e02:d71e:87b5 with SMTP id 3f1490d57ef6-e0304009b41mr375405276.6.1719434219631; Wed, 26 Jun 2024 13:36:59 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:11 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-10-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 09/27] 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-20240626_133701_797651_15AA0C89 X-CRM114-Status: GOOD ( 13.57 ) 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 Wed Jun 26 20:36:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713402 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 0801CC27C4F for ; Wed, 26 Jun 2024 20:38:43 +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=P4VX/U5UlFnbX3l7O5Gt2rIEcV 9yIRKiOS0i7dozLGht/Jgh7R0YxhWenlQqH7vGpIF6EIghPf5m6vPTpGKCCKVPU7DgYhV5fDvh3Ip 6rlEUgQlAoA4eg5hAp/flkJ/gZ2EldY64FvtI/ajH2dX+JNTmOQQPAqMwHaGL1E+9gvBD1COzolfd sGOQ/iQK7rYGHRt6TwrZ7CKAhUrunYFkklzcvSDD4FqN5EsuB2NPyjYIoPX1j+0P2/BlYXej2NhDH /kx8tv1c9hBEH99Mel8VkWoSLmCuGZCKzUOXPTe2f7suxCNg6teVALpivYphhuThRE/xc3btMAZqO 6913nbEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPV-00000008G5t-3XoH; Wed, 26 Jun 2024 20:38:33 +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 1sMZO3-00000008FFZ-2ybk for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:05 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-63bab20bf5fso164076717b3.0 for ; Wed, 26 Jun 2024 13:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434222; x=1720039022; 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=d8jK3y4HAi5Puv0l6V/0W7DzZ1HIejRmMoGn6vittdkxsvAhK2sWlzWKZvNqIkok// 5iFq+qtc6OqE9xO5u5py2vr3fnqPfk3lUDxw+az+IEkW9hW6GkSyMAcpXAlZQs9ORd8L UED+PrqYfpZVY1bNzunzfXPjenHw/iML07N17MQSX0avWO7kYgwEtehnCnKN9OYFBP3U Wj7Tt1LPAjGvu6u6x3tni9K8tb61DywNRG9Kk2GpkBYgD8WyCi85W6AKsKw4sTNPoICU hmaoWsB4Ej+zwR9zuAwCeheiVPqukVRg7u0/SKJEzeIntdtqibcERyrJPZxDAqDotlEf wQTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434222; x=1720039022; 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=xVQeFWb8MvBGeP41/8RH/bB9zybGxx7S1EsNh62m17kLqM3jU/NIxTrtqEZ4IBVhJ3 XfStD6Skv8ekrPwFINBem9IVMbVwvqeYelopcRbWvX6OpJs/lBiW4z0+Q7xFfLhM2zyb naQVKnEOGFDpN6c3+AUrwh6iU/N1iIrf34tXbpdGaxdWvoiZepAMF3YRqSKdFica7pWx IETgLueQILsaL2UmN9g9cTbmSerCObDsyC4GhkeZpBzH+drTsFGLw84117NsRJlXMIo8 44+okVfR2OI5kEof3uLegIY+abzI+13MrjqHl0gNTqXZMUkyOdCly5Sop29qrAQQa+H8 fDLw== X-Forwarded-Encrypted: i=1; AJvYcCXdxjYME1GtRkFAoYpz9JbAmPM+hKmCSdiyHzYvjv0tOKr0Wl2IGBzlllB8+GAjhnwTCUMiPsVlhjocWjOQ+k42Kv1vdhiMKWOnmjqWX4T5iiANY8A= X-Gm-Message-State: AOJu0YzcTvZ3vMw/MiuGW/xWee79ra6oepwwQWjpEt+NioWLHp6+ZmRH TRXKmwQZ1lvbipQLBdJQCrlNNy7OO4TF78pdGZg5r7SrIKgtPPQHWYYJcjy3indoUkLteFcnZMJ kgc9T4w== X-Google-Smtp-Source: AGHT+IGZVnE+Fch70MEK4rYQnkRBHIJ52T6vwPjRKNsQDQ2mlZBvGgRLnTbFrcJmRq10ailgH9nGrqLTUmBR X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:aa6b:0:b0:e02:c478:c8b9 with SMTP id 3f1490d57ef6-e03010e732amr25868276.12.1719434221944; Wed, 26 Jun 2024 13:37:01 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:12 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-11-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 10/27] 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-20240626_133703_768645_33CCC76C X-CRM114-Status: GOOD ( 14.79 ) 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 Wed Jun 26 20:36:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713403 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 71900C27C4F for ; Wed, 26 Jun 2024 20:38: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=vrdMNoiFFUZEExlDYLQu2XN7mf/7jGflPKRAGmMgvbw=; b=mFdEn9cXktdyK56mkouiMBFwuj 9YZ8+m4EdyX5qQcT3l3a4qFRiYpTbpHhOcqZl3IKi0flOvi9g9xWV6p0/BApgZbBWGkIlCN8aqm2O YEkWg0R1ywb5D5PYMasONdCIVNb0u79+JgbvUxdak2Gfnx7oeoZkGC7LGlKveifGWRcyog/hVGCA5 dzlfYY4ZC/F0XIf4Vi4dEwLincjhqbYkxZSVSVo0hJSj1vL8LwqQ42Pdi442TBYzE8EaXrg3em29h WTmLUmMfFY60AdG+IhMu60iDxDImeerSyxwsgwx/qOWnWqaJAC5AuK+drAmburgONp7VXzXHdtw2z eTUE141Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPd-00000008GAX-1xG8; Wed, 26 Jun 2024 20:38:41 +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 1sMZO5-00000008FHM-2WV5 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:07 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6485051924fso18517177b3.1 for ; Wed, 26 Jun 2024 13:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434224; x=1720039024; 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=vrdMNoiFFUZEExlDYLQu2XN7mf/7jGflPKRAGmMgvbw=; b=Kqd7+8MFRKUJlI+YT4fX1FYlsgJlC5EA2jbhOEQGsrKOsTb1m5FWecIgZwhxTLwd3P F3cNRCx6WTkxCLi8+dkXGeSifhT/2bmAhlZq3B8FyXD97BTEVbxJsWTFZbpOVRV+5nHx NFYij75cbil3RM2Fwqsgl6E0tI6Gns6qFmOBsh4Ra0jgFFAe2oGjWXlLt5tZ6O6mxNW7 9SBsZiY81BLCIZGc9/ubGyKiNxeUMmrI/fwvG6cBb/HbYMhdsdhHUMfmrEcG6XdHqbbT gBHge9mSO/hLG5vrAin7HlkfF4jZUTH2JCrJ8fX13tPn/XbSsVJn3GAioPcIGEBFhavP 66mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434224; x=1720039024; 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=vrdMNoiFFUZEExlDYLQu2XN7mf/7jGflPKRAGmMgvbw=; b=v7rh7SQhzec4MeL/0FwPhSBwxbHr1PDsovR6pVSQQOMIf8vos1gmYbQ5GPaIXxxPpv FqB51Diq/mPRuc7B59s8Z6XmbR/a/48zt14Cgkm5yuXKXtBlaVnOF7+4K3eI/3u0il58 lrNhoa6TSIRYNvd10sWcte4g3jDxe+SLW1sEaeXE9lRtBGKb1dz8Jy3vSmMZemBGamIT cD3mxcfsDX8ZlsElYTxNew9P0btZ5YAAZLx6KuKZEE5bTTYOVL04Y7iSlOE3l1lDl/No uGZOo+6z3Ze8K6PGO/wOpbh0pghunVt3yG+CnUP2lBlFACtRHjoMQaLB1r19YCINrB/D om5Q== X-Forwarded-Encrypted: i=1; AJvYcCWo/8x+JN+VkuY3hYwXIQwqyBA1Oa9m2ImyletiI3dXdCHabcMfMlOQ8CRuaCsiHvh1qlk+9Gs/CGcCg/40rKOdGyJxhG+D2365QQ/2iPHJkV/KYGk= X-Gm-Message-State: AOJu0Yw99RjP1ZdfnXcqfDqOlx2RjnWNEWdT0Qw9FfzBh5Dkc3bGhw1w S71Hnh1RgJ8ySBPnCarJOK87glXEUWESdIQOILqj5QLRHJyCaGE3AVcwFwKrQrXX+iGX2weoCTE eFzY+ww== X-Google-Smtp-Source: AGHT+IFJNfUbOLTOw4W+ifqZL1EPRWAknY5XU63OBzUVNvhQfs6vw/sK5MXeWYhyTs1Q3k7ti40koZYKHOMj X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:2b13:b0:e03:31ec:8a1d with SMTP id 3f1490d57ef6-e0331ec8a7cmr236269276.3.1719434224345; Wed, 26 Jun 2024 13:37:04 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:13 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-12-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 11/27] 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-20240626_133705_814042_5B5B5CB3 X-CRM114-Status: GOOD ( 15.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-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 e8677f9e1ccb..4b9309b4c07e 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); } @@ -2386,6 +2395,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"); @@ -3326,18 +3345,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 Wed Jun 26 20:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713404 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 19E94C27C4F for ; Wed, 26 Jun 2024 20:38: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=6guPMXmcdW65GtfPCYKyOHBofbB3BqlsDiMCqc1Wqps=; b=AfurLxILtprvK6IpBoKD6ZbRKJ lY2p1au448Xe+bHZJUxK0L2GsIRhfyDJ0c/J4eneIACM7kzgoJwB4h/as0AVIhjDmtbDpKpIlr87I uvLc2kZrQn74p/Djn3XEjrnxZUc/Zb1DdStyOoJcHagOkxZsLAhJgPqmj43ogG0jggUET6X0UwNWo yxfzgDHyzTok2cUiYUVqQXn5qd6JiE1+P60QXKyxt4sffb5HZXx251nQdzBYl39LjaL8es8jRg19X WyZdwdWkILEsymJkMkvSzqFT0XFNBNgpYkPpjV07q048MzRaZkp8wFn8AsLXo4eszvztajU5qnH7b 9lssbqXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPk-00000008GFH-34UJ; Wed, 26 Jun 2024 20:38:48 +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 1sMZO8-00000008FIw-0i6f for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:10 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dfe4f388d33so15129134276.2 for ; Wed, 26 Jun 2024 13:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434226; x=1720039026; 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=MQw4otd7khX415PneFpylo9R1sWvvo48AR3PGHMVdVei0wWo/G4lwtw3ULv53WMymu zOsatQ5RlkFrcsj+s5b2RdjwREGwcOZtdtnQmSuwZizQJJFpMDQziJz47InWoVh7l/dB euLqRxheVGAyV72ty0OjCwcSMrqklr1q4v54d9RNBvstVo+ONwk664qS4QU4bffoAx4X RYBySQxo7+xZ0kXS02B/4OKIa/etOWQZKGGXN1DvKGNALq+CkA2usdzs4hNFD+bSdheY zE13AcHPaMUzoU6X7YTQUbBVeyUGVPBS4FY2jzhvqZNiAkq5MK9iSdV+ce+xxCv++ZWE hv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434226; x=1720039026; 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=wr4dwS0JuuOay/rvTuVw4P5FASQa5gy1xAi8ma1hDFdHHc4YrMb1G0JdXY6o/Fa/mR kc+Kj4A0CQezPYWmURXCaXuj6pbat92vjdyJrGsHFtfQ1BOom7UO+JpyyzFG1UmiHT8U USJLBL5sbhvM6tAxClY7QOJaGYDTGCZdGHB+Hz39eKgn/+tuQmjnu1DgA2D6LW8gW3Vb qb3Jkbg6Xvu2Vv0QO7LTT8Qp2XKaaxxqc0F5iMKk2MQPM5J6zWYyVQsL4NnG5LE5R+sQ YD3imKXRn4ACK1EfbKHO/F6WW952jWxhQqA+j5gYGZ4Nj0ziW21pJTD9PF3XzF+EIZKs 7Mig== X-Forwarded-Encrypted: i=1; AJvYcCXvYq7rLDYk/TpV6KbYdsR9Nt2odVurmTfI4wMxFmueviqdvhh5fpO0gYqkwlJGnxTj2GFO9aFNSPPEV2Zjh3dImQHePtOpc6Z2wjmvprV7EmT4jQ8= X-Gm-Message-State: AOJu0Yzi2qBVYS+smxXk+ySTm8IqqtMj6pnE2zOeYdArlxq8padDG2JS WwjFixAcy5Mu29YaU8+PIluGJjlzrurW9JPLVNesqfsm/y8t1kWBltm4r5weQ1KUMR2t4p49vfI tU3aHSQ== X-Google-Smtp-Source: AGHT+IE4+2WDwaOh4Ud+JjaxVM0mGpm4/Kn91LBXC8OyTMn8BlzeCAAbjSSYQBawrYF1H1vHwId3MHU2iRRz X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:e056:0:b0:e02:bdcd:3bd4 with SMTP id 3f1490d57ef6-e03040e5ea3mr359356276.12.1719434226584; Wed, 26 Jun 2024 13:37:06 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:14 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-13-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 12/27] 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-20240626_133708_278633_BA67BB25 X-CRM114-Status: GOOD ( 12.23 ) 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 Wed Jun 26 20:36:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713405 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 2B403C30653 for ; Wed, 26 Jun 2024 20:39:10 +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=Fmb8yI2B8WBERn5wouC6ZpVEED UxMy3LnnLh6A/dlh8IaZ4ubkqkD3HEtU9X5HiDIkKgR8nsmgPea0ULKmC085t++VS4j6OtK0jIUXj sXYPeJue6cp6ll/BDOKm6UerrPp25tMn0qiqQkrrTJRgfF6ELXFBSiBCu2MBZonBvT7vmuz59S0fK k0MvVcGnUqRRYxbfKbEItrq9SljcstjEnw180/JDpeV6jwQRMKe4GXK8c4ct7Jx/ECJklFgxh1Kbq FNyt7TtiP+blkpw7zqSo8NEIJg5+3PpylVz3+oLVSwECkj8CeqJJgVTH9lyxForsC56cFKF6TaC2J tZ7v2GJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZPs-00000008GKP-2uDj; Wed, 26 Jun 2024 20:38:56 +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 1sMZOA-00000008FKX-15WK for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:11 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-645eb1025b5so59916297b3.2 for ; Wed, 26 Jun 2024 13:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434229; x=1720039029; 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=xFzFsIRsDDmW7rBnPRZHgTVtpm9GHTN3x3kWQay4a0sTgm71XGAb4xTGoafTGmxKwE 9KiVTkOU+8hUzzH+bssqv1mpxbFKp1Iod2+TCPP/QbVwmspb/i/DPmfUVZvXH/Xohv0m 13k0eRMjHeowIbljccQjST/3uBDj7+aIPUPK7yCZ2ShOzcrDJ91egzLBE55c+GNymhCH Eg+21+b0zogacrnWQsh3jmk00ILtmQI87iEiUfTksJxOOSWSFBdFKfsztSVFxg5Cp2Je ZcuyOmCLgY1fhI3UwdWeYVRkHcFnwZEQv/cqilZnSAd4gMf1+YSb4u13aX7OTSJT3Z90 +AVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434229; x=1720039029; 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=oUMHuZpgJZvFRwycoW3cm/X3m7wP1B/n8q960dXRMTmAGhzHGyjkiw5/M5/KTvxWqI vkXKUnCBbyrrNlHwcHeiCckdGCdUuiVlVtb8JuibL+9BTqyE9Il6ufNrAfqqT3owfvg7 5gc/JNS/jj8YJCvCcadR1IPI1d7lw7EpTaoQNgSrFwjfJIYWtvtIHfqO9+Wud2gD65so 7+GJy3XdYkgwaRxHWfg2HMCbDAMyEpXwxEKRRiEhLfOKf/ebc8fnK9wPBmHPi5UuHac4 davRk4cBIwH8UdVGm5dJvNCcWLU7sJMlL0FQT2Hyrdk/EqDVxx8iSVuv44UTBnyqsmyL huxg== X-Forwarded-Encrypted: i=1; AJvYcCUfrKiDn20yY0NMRtZ/29xcdDItkoiKii0NVwLisSTQVP2LcxK5PFeyaypO+wrao/M9rkDDXWh1MfREi5r4FW5KaTLSU6X08Qd4lMM/K/Oyu02A0SQ= X-Gm-Message-State: AOJu0YxGjHjY5irJO9cjpS2kXrVmOFEKMp9AfYXlqgy+4CKO+mpiSV8P 3l7Xxu33dY3rNWqnKOStg2zjCuOo20cjs22DvNZ6S/KYLsdfAy51GqzaCrSLYwqGGgM9ir4xvCA bcvOzgA== X-Google-Smtp-Source: AGHT+IH1b3uFlZAh7FTc/51pAkYfxg51uKntN5OfGNVc33hFT9YDlTkQu0cV0WTSjlTWeCeXHSLPMoyx/Wog X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:6ac2:b0:627:a961:caee with SMTP id 00721157ae682-6433f0e2122mr405277b3.4.1719434228939; Wed, 26 Jun 2024 13:37:08 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:15 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-14-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 13/27] 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-20240626_133710_372619_ADCD106B X-CRM114-Status: GOOD ( 13.57 ) 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 Wed Jun 26 20:36:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713406 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 58529C30653 for ; Wed, 26 Jun 2024 20:39: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=j4wPLxjotcBveIZ/B9wKVxXKe3+485cgtRlewbIxK0o=; b=nzpOQqVdxaAMXqnSqdlGniyoxU HIxiNIdMSuQqOsTNoM4Ay9E3F3/mCy/ihTHI5SaNMCu02KCZf64WxrHHpEd04PvJoAlBL8x7VxM5W 1yOrBvrE+LYsKGuxVIr3eAzNHkM1rqJmRtRtw/K/nCHGsV9z0h4m1+uowCDC7SQ+5zE6F8m7unzeo YudFMpednYHLXXxW53uvnn11Uvm6vecZQwAGoI5HYi5qrNRwZclLof6DGWfGptlgUEEaibXgPZxjJ E02PlbOeA0eJmh6PSRLWkMNH5atpzKcL6x65IF4R283VJ0zZb3ejPzy3+LiYOCObpzrtq5slJvMz4 +CTQVfBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZQ3-00000008GRX-39g4; Wed, 26 Jun 2024 20:39:07 +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 1sMZOD-00000008FMI-0SF5 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:15 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03334bffe1so2492681276.3 for ; Wed, 26 Jun 2024 13:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434231; x=1720039031; 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=4kxEfMUl4cPRpv8vzWwcvwtyEx5e0n1GuAxfh0XorbvflY1qSDq2gJT8hj+a4iaEWu huX66XXtbRCiCxaxwnncU3T8Ykm+QXqdUXn5l3awzp7gEJzXJRbkyOJjvouTIpzhlxgA 4b1H1Ub3BIrJ7Mwg74bfBsCWtB79HucYxgOJNmM39J9yv+J5TnGmAaJ6HmdpTs+rdbyd EcylB3Up7kB5YPyf+45CXayYvvmjZ2kTyFjnodIXcsCf41l+CCBNgwX0lbHlCGADZqML uoeTIeT6IwXpWdcS7OejrIERyXIe0bbPtTUHMqAY9oyYYB+O7T90f73AeYSeHfRmDuFP 3xmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434231; x=1720039031; 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=G76vAKKMJcJ8xSUnNLwUAUOD0sUKoIrtnPPcvP6oPr6OZ7fKtgZ+naAVtPcMlyb+tb DYq3X5Dm9i+lRIq32HTIkIhEbonyAvKUd6Cl6+va88zUEnQWIF7YyQkWvWSw6v9rfK74 K5hivUNGZo8mPJ1onh+I3WU7RbuDZlz3nJsM/oSt3FoQbLrpvg0Uqug7ysfiNIsIkTfq JGG6aH41Oy7GGYjOqbmwCFop3ReELNGJaXDhmxJyGAxeg0/Vj+ZWBHzXKjoTi1N0t7c/ x2aCAnarI7qcDIUfmzmw3c9WWIDurRfMBvoa7LwCMlTZljMBUfWeuaX3YolzRCkQjA/E JfTw== X-Forwarded-Encrypted: i=1; AJvYcCXS28xfSNxUby366F7FA31tdXK3bz59UWoneHZiIhwWuUvHSqplz6/z3ACaI/xWvkbWZPTr6gkwDXo9+hCXbD8PCl+lGafciL0A86rXAujy/LkV5fo= X-Gm-Message-State: AOJu0Yy1EPKPrLPKxIA9rSEQ7MEtuO6VMrMcIi4ZSZN1H1t5z2d52KyY ryr67JjQs/Intz0g7XP1bGn/Xzst4nqf48Vm29U/2w/pgCWOGIgHhTLtu3XutrMCOQRJwh/6+qS a/nebTA== X-Google-Smtp-Source: AGHT+IGPfi1PO7t0XGbWbxngOFq0MaPkUk0iJpl9zjrh2VspzdbzoBzW0jjJ3NT/5NDBPsUdOFazPjdYhKKD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:bc89:0:b0:dff:7d1:33a7 with SMTP id 3f1490d57ef6-e0303ffba8fmr92216276.12.1719434231357; Wed, 26 Jun 2024 13:37:11 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:16 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-15-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 14/27] 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-20240626_133713_256591_FB160054 X-CRM114-Status: GOOD ( 15.20 ) 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 Wed Jun 26 20:36:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713407 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 63CEAC30653 for ; Wed, 26 Jun 2024 20:39:37 +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=/glFNS8XgikFm2z1yC/0AkpB2sfHIN5dEG3tYazcbCw=; b=ebwvebaFW65wnr6Cg0L+ZMhLK8 NQVH5/Vh0HjeRFOeNcDmBBiCgnMydDLhXpNBwsSB8JbpYwgROg3b4tOj2OCCe6ZTLOzLAWD+YiTy7 ig7I45m/Xl2kpEj18SBd9y6HII18aO3D9nVCs+xMEJnMtmnBLldpR7SrTvOAM0SHS4+T097lxhEwu 23TqO8rC+yx1bHyqE5N7A4yr8PUoSd8FlY5oRaYA3qfcZtQGgakODHSF4hoedjxLeJ10y+IjtN6eX TLGUWoRLWuBwN++vz7J+akyGV3Or2kfufyj6LGL+lTSrtAzW0qt3sSPTsPoBTr4ZzC8DLPflnhPlc MFarzAxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZQK-00000008GWf-01wg; Wed, 26 Jun 2024 20:39:24 +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 1sMZOF-00000008FOJ-1J3g for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:17 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03334bffe1so2492766276.3 for ; Wed, 26 Jun 2024 13:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434234; x=1720039034; 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=/glFNS8XgikFm2z1yC/0AkpB2sfHIN5dEG3tYazcbCw=; b=2saZEIHRn1c/20RQvlgAgcupUGaDlxF6WxkKL4blWy8XTcJaOtg3UjgF3a4ftAE3Bt XSryOplV1S1jwpTRzRfrYvwyG8tw1XbxvKqJwe4qTBOuDHVfrfuTsIgZ2keJcXqP32W2 nnNrLGa4gIO5zuZKp5ImbGVE+71gi/xrp/hQsNv+M8a3P2p0R0bEWiW8qaKAUWnI8QgN uSrHA5hvEFV4GTSbmCqWGYwW9lau6V4oGh7RCtv9QfRI3fNn7elAXcLc3myQWg48UwkG CliPgHdBhDG8gzUSKTmd41xLC1fsI/rFJUmvC5og1E0ZNucc7SWCj//inH8+uUxuXP0s Rq0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434234; x=1720039034; 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=/glFNS8XgikFm2z1yC/0AkpB2sfHIN5dEG3tYazcbCw=; b=rnZ2c4zWn1lXnbi8Sqy6H8XKKpyzLC4cLw2177nfuNca4hBWvSFBpXr8ofCQr9U88t cpegED9iu3KzrbI9dmQS+g5CdRIP4wuzyf9R/GLRuPXUHN5Bj3L0VkwxTqi80ZuPFzj2 2fhwkXzwvMOM6vDa1fHWb8Ogvw/clwjTq7NSvWiOt9JpvhpewGKHOL5+lXgCgJNE1MR6 p0zt4AbhCs28Er6AB8xYp6f/N1nDMvjir6/VMJ3qtkRv3ElvQab8Jq3VKMiEXnMY5L1R iwinC3iLwNkHwKVR3zzJvWnXErJHPMwN6Y+3QR60O864x0xrQeH5h52hcOvFvrlEMeo0 GGrw== X-Forwarded-Encrypted: i=1; AJvYcCUI4RiAYzujomXLD9cuoKIBTZCZFm4yEPIjWo6I1dUzl3eCIeotwD01NeP2GyBghlWnzCz3KP7rbYMuNS6x4ugAX8mkD6AuCtFEOHSMyx+EeOutHvk= X-Gm-Message-State: AOJu0Yx8FSaqwoXeURISwN3R60HPn5ggdDcgA10DGOZhdajxAauzylaz 3iDmZ7/haI7WDt894gdU0bEL6m/pTYSdQU1aoHcCkFDBKmbH9r5/EXx1SxejG3ZO/Po6vm5EDie MGtu3pw== X-Google-Smtp-Source: AGHT+IH7xWjVfQ6FHHEhPxwNW11DF2T5pKfJxSXy/6lYJ9C2XxhVZeGCRnAlj0G2V0YLxBcrHW6+1vNR/qYQ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:9742:0:b0:e02:bdcd:d68c with SMTP id 3f1490d57ef6-e0303f474c7mr96082276.7.1719434233758; Wed, 26 Jun 2024 13:37:13 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:17 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-16-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 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 , 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-20240626_133715_504829_EE85BA16 X-CRM114-Status: GOOD ( 13.74 ) 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 2313bacea0d2..86501edd5a7d 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; @@ -1273,30 +1272,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, @@ -1478,6 +1453,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; @@ -1532,7 +1508,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) 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); From patchwork Wed Jun 26 20:36:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713410 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 86D60C30659 for ; Wed, 26 Jun 2024 20:41:45 +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=Dn2pshFtINakPenryLRUsTor27 xD5LPY/SlFVEgaNfCb1VMDFnXR4bx1mPYSNVkqVbYrY/Rnuc0SM8QYRNqHJkTvDsT5EFB1h6Ve40d Px3HLN5PlZDHk6u7lZgLrn2SuGc97BMrH6D+JZRnqQg2PWQPf/U8tAYnncPfs3CmP3lTiVwYVD/1n n6UYm2HFRGmHh6zFrUyGG/pErEsdvEFc4oJdS0RGUBQdjf9JjxFoxOr4iIuMVAp+w0llpSghpCyem OTlly57MiOKbCDY8TLdQYIWvSSgf4B63nrTm2JshucaNDpdBFl8gohWhF2LAITWVOv0g0KziJPDB2 M7SMpjxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSS-00000008HHZ-00wu; Wed, 26 Jun 2024 20:41:36 +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 1sMZOI-00000008FQ0-2lnJ for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:21 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-63bf44b87d4so11060787b3.0 for ; Wed, 26 Jun 2024 13:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434236; x=1720039036; 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=LZTy0vOZbAqZedNlOZpRp0yyG4b/MIm7ZMaSGQsewHhPi5DSIqDAG+yo7UNkyfWKPQ 4BUB6iecrnwEH0UR1foPW7fWu6dXuN9e6GQFqNYh+NEmp2s5gAJIqlcO4RqFUp9gP950 77mx49XkxTT3SL8IXZTnC8A8yJEJmmsl+9YSqpVFdeZTVHizKpkvzqopEA1FSf+Aqckr c9NiYo3kh4pjHqMku4vjMR4OacBRhGLz7EZC0q5veyVWIRQkbUsaLU0X/GNPeBminfjk YOXQrbG0QsoXLZi0aqpGk7jb6VxA6k0OiZasS6bV646LLvOo5E3mNj6CuHXvsK8eUi0F hr/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434236; x=1720039036; 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=HBbxVIwogXn6mTH6h/hbgs+de2bc5boZvOoXpED1mFG0n7EoZ9c9FyBUMil5jaJabG 8tkMnTr6ZRl2Scj3Ig7SAigx3JHVgQaPfYUe/OTO/Vd6oLQArpxTPsc1ruhamwYP9hUY 5uORURu3BMzJHLd5BO6C0u82eXuMqke0adXNzQ6l8XBPzN5B7+z5wSsX6IcGusjn2hft SI5kaGBOgVjYCv+lhh9OfYyTSf6B0euy7rv25cTPrQPWwhKbhfPZlBvRhBkaQA+S465k n+g5021GHzKhqlldHlkmXXl6RKDIe2uN2QSEto4fkd11yeU/arZSZOtJHVxkwQ7WhVrd F/GQ== X-Forwarded-Encrypted: i=1; AJvYcCViEkww6gkArW6NK7sU1Mz7PBvF9H+O2spy92VEFkqAP0O72JI7HDPqnK34q0UU1kPLzn/Ckkh1e6kAR+CYgcJEzGtKdLy42Qb485uFTfpNcnFydEM= X-Gm-Message-State: AOJu0Yym2yelGcPuD7LMHtQBAF6/aqUmdo2vgPkv00PXgOCWOxNgVcvd BveIuq/yn5+pCSlFkTVkv/X9WjCwGi08O0J/FMAdszxhTfMYxlfXdpCZxOLoPW+NimcDTWwUjBr L+UkK0A== X-Google-Smtp-Source: AGHT+IEdvjzHXQRmiTPCVocpPSkdF6uIWaJjq0GRNCNUep0zQF7CpSWTKGCjbHc0CcZZYOIBveH+JUOt7qyE X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:727:b0:dfb:b1d:a16f with SMTP id 3f1490d57ef6-e03423f3a92mr38602276.3.1719434236037; Wed, 26 Jun 2024 13:37:16 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:18 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-17-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 16/27] 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-20240626_133718_733590_7DDD650C X-CRM114-Status: GOOD ( 12.69 ) 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 Wed Jun 26 20:36:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713411 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 D972BC27C4F for ; Wed, 26 Jun 2024 20:41:55 +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=7raeEbJAcH5XWE73572v5WMgPlRiFhcFGuQbVqprDZI=; b=FsFF0BcKDs557HCpIvFbB4GCVe nXD91nxwdqdy0dQAdpPbWY0QHStcl/8BJy78BgLHHrdaudr8XsJI0zv6S+cF2yh/NYC+HVgbVzW7P ABrcpOD2EhBY0SKWbtviHKXoJNeT0Rv0JzU3ZDMrZ4yaBEwdQLrp7W+YHZWnjFSovlV4MQQ7NPvkh ALv6AC7S6G0Y/mmbhAaPvsG7tA18En/KHIpQBHi2j2rPUaYC4864f3Ujs5nURicL07l7s7Y4nJ2/S IxH/s8oO8h5OSg3wrrbbfnIidXG/kZYpY1M8okVOA5jjxulPaBsSdDlXd2nE57+hh3oLnS+X1T3OJ iFw3TQOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSX-00000008HKB-3Y8m; Wed, 26 Jun 2024 20:41:41 +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 1sMZOJ-00000008FR1-3riT for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:22 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-62d054b1ceeso146323857b3.2 for ; Wed, 26 Jun 2024 13:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434238; x=1720039038; 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=7raeEbJAcH5XWE73572v5WMgPlRiFhcFGuQbVqprDZI=; b=vj99qSr0Zjl8db24BDLOWhj9d+RHjYHMCXkFwA+CILnv9pT8ilJ6n8sO3AYEODqeap N6QtMuOduIymim+6I83900e5+9IXCPUMlFlkLXeQ1NXNUhrXuCQRet7VvnsyWSy4vJXj Y7YbpqvGQQZdW3odcYVqMHX8PaQQs+qNIvC5TydW2vIoTU+cJoXDLhv9BW/Aq496ncS7 B4gCqS+AQV0H5Hl4gGdB6Nbph7X5tPubRkPMYCMBOYQ03dfdbPNj9S30FXxuXpukvPzx hEPPCf1YEdDxw8hHrkebFE2EVmeVLHYIn96qNSvOrLhg6X1BUMjJs/Bx02ePUc4JdSb/ 0fjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434238; x=1720039038; 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=7raeEbJAcH5XWE73572v5WMgPlRiFhcFGuQbVqprDZI=; b=UEHTHZtL5G4kQMAdeF1ivQlyRI+VmITwGcVwArZ0amdUvxkPwXVGZ5eaoz3kA0tTcX +ZtTDyzH+8dibbvx92eSsxNulfQZa8DXPWYQB6vktysXiGN5GEwn6n81ZmIaq1NRsGPG VJHmQb07+WtCspfBbwpf3l4QVJIIvnXFPbEsSbFJO/GvGGTmMvtM8Z7f7vgzbd3qkhHF aBnO6hFDELJhcNK3MJ54/lcuBaxP4Vu9Z0ThtoqpjXHVK81oSAOJPJw01nazNQkZ+t3J FykRFfOiMK00OZ0jxnq9dmXgkdho3amrc8nO2I+5eEe+tD1KDQ+vIUgCmSgodpzno2Ix EqHg== X-Forwarded-Encrypted: i=1; AJvYcCVnA7avqDmLRqtsGa2NtJbUOKoXGXNEftIPumyTB/sZnNLOgGX5hTiQWc/yvzNKiWSlDfYnLDovDFs3K9TqYpDOeCYqME4ni9uH6a3lPW91eib1EpU= X-Gm-Message-State: AOJu0YzK05ifzvuIOSYnv/CacVaCfBKKaZCwGzrQZjCTHyNGJrtVA1sR u55FNoFnFUZtkQv6mGoqRdHoDFcBQOHgTKre9wmObBbfw9uWo0zAh0FW+ethx+0hvwkN/LgjolC KfDwQHQ== X-Google-Smtp-Source: AGHT+IEQSHEY7tmOfYdN6cXOmdDpH3I6AavNANwL4+37KcCIjJ1LiHApcro3TXfK+Qrz2MPoCkZdH20IlOBc X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:b110:0:b0:dff:3c7f:ea9a with SMTP id 3f1490d57ef6-e03040084ebmr30925276.13.1719434238238; Wed, 26 Jun 2024 13:37:18 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:19 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-18-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 17/27] 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-20240626_133720_037542_A0EE7322 X-CRM114-Status: GOOD ( 13.14 ) 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 c0685d2c8de1..598ab854b9f3 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 Wed Jun 26 20:36:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713412 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 80130C30659 for ; Wed, 26 Jun 2024 20:41:57 +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=noJh/0tjGkNOuuOrbqQtPJsWH5lRqwZr7bjDIe61TeY=; b=vOnXxw+rLZCGfHQY/kCVnS91tk h8suwAzyqA49o/meTYZ2T0fbTLgDCdabjlaEUdHevqBOsOWo5+8tcJsGd8l8WYwqoUhxkxh2NXZNB g19TPa7l+jd1rv/P7rhW9l1A5HLVIOGLJJdTghvqoTyrG4GMDUmYUvoUBh8ofVOOdUqS8BYAk5ZXi qv8Lmcuvc6MhNQK6Ks/OZMG0i3IxPaVjocHPuvSV5ECtxS5zP5nQ/V5DPlEwEZXc4EgfeCH+WdLzm iV0QZ0+yq3irpY4RyZt7vl6dEOVqRtRLsOooafdsByR0GR+bXC+FBN9TSuW5/d/ed1JzDcG4t8fQ2 2/89211Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSe-00000008HNi-1aNr; Wed, 26 Jun 2024 20:41:48 +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 1sMZOM-00000008FSk-2Xra for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:25 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e032d3114baso1189432276.0 for ; Wed, 26 Jun 2024 13:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434241; x=1720039041; 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=noJh/0tjGkNOuuOrbqQtPJsWH5lRqwZr7bjDIe61TeY=; b=gTwRSFqQQ5y16AodTr+A1NAsr0bDDHK742pDSzLtJFQCdP3lWCG6m3vE3aM0bGoN6f ylU6DFXepsypSVNdo/1+k0N0KKeUfOY4R4uTRoaGanCDhuUrfugxRzqBtdIwupDMJgqD FMq9xYbRirnrRUxNiyGUdl8KaNIu4GvqUMm+2jjTE6JdtSOr2/ruG/EwPBu1x7MXsWOu raj++xF07/bVfdUitviXYQEYKebiQSl8oP38WXVeHdWuAxUbTEEtECbRbhYzlq3DVT38 yN6zbXT7vj6VRRCDs8zq+maQ+L7RAkK9/OmRMJPwDZhwJ5lOjj5pjqqVF9WQTOEwhSMe aV5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434241; x=1720039041; 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=noJh/0tjGkNOuuOrbqQtPJsWH5lRqwZr7bjDIe61TeY=; b=oe11A5oByYHpOoWl4qWipS3ydrHBm7WAf1wXJc6B/AoF7PAht4qBwT3yZDuRsB834M X9O6pWPyPm3mPT7Nu6dBviQs5zopwm3xH9oPqa3ykIgscpstxt4VO+Ufqjs9+B5bxlGU 6e3VutAFThPGaw6khsj8LdpAIruDWHahTTauRHnJDuaAf3KECY5vf/z71dPB/2rrrCK6 kvgI2Rz4ivnRjykAgchjyrw9J9wd+q7AR1tKn6z+iaVroDFYa0ZmUmRWjFo0aMMY/dSd R4zh+PE4B0qDJgW5y/EJCL0e9fmMwhtZUwGS5Nq2GPCLTyvVClcnDpXTNl2Lg/m71ZUE 6LPw== X-Forwarded-Encrypted: i=1; AJvYcCWyeq2s/aLzwh724Lyt1dxfFB3fqyM32VpyFyPWl6WzNEOn5AnYpDOvmPulPxOnJv96/5SzLVA7HjLWIQ0o3hlW049fqcTe3AZ1l3vseDEcUZuUJ9o= X-Gm-Message-State: AOJu0Yx1VNVHoizZ2aSQjdDcvFYtEAooR2sI36197VGAfvcKTrLpx7Uf cn8IFyUfyKc9Kr7cSj9XyIdEtuFHcOu5f9oiDW6kgvK2AAabS5qJWTXwBthSCz/v9USzKxpclyi C2briQQ== X-Google-Smtp-Source: AGHT+IGiGW+2TJjLsVxDfeBzcOXXY+C6/W3uoEMYOZ3zt3pmoGji/Ifg/sPaursww2GTCUQox0G8p7+0iMLD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:ad0b:0:b0:e02:7c5f:e0d5 with SMTP id 3f1490d57ef6-e03451b46ccmr89276.4.1719434240611; Wed, 26 Jun 2024 13:37:20 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:20 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-19-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 18/27] 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-20240626_133722_908141_6ECAF394 X-CRM114-Status: GOOD ( 11.98 ) 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 2d24250f60fa..2b227b01d64b 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3013,7 +3013,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; @@ -3511,14 +3510,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, @@ -3635,6 +3626,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 Wed Jun 26 20:36:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713415 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 67ED0C27C4F for ; Wed, 26 Jun 2024 20:42: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=6FKqc617GU6y9EZBzym/gHkh1HBEMH2nzxihyAHq3eE=; b=r3PGvwhTD+zV4rLSkIC66Df+Fh OdPE/lpoL7dlEEI8OU1snItkJwGH3Hga3bHgz3zoYS2Rq/KMGCL/t6lRB7mCVHHWnhRE4do7nDToK O5cqccp8TPhBDKkbhJIbcUwzEDfUVHdmKLUKPzGO+JHUJHYW4wRMDSdwVnCOLIyX+iNkzYMDijhoi pfG/+XyhPuqKkBJy11327mgLAGKAjMuPfKkj8V7JANxtaAIPZHOO1iW10Jit3+2+VD4WYJ3jNUM8h FgU7GV1hLj60VCp85qrh4R/rv58A2sHx8jBCP4Qx5BsIKPULDKk+k0PpIBrilxp7M93pkaG5Y8eOv 5WxgUSvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSt-00000008HWq-16fB; Wed, 26 Jun 2024 20:42:03 +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 1sMZOO-00000008FUX-4B8o for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:29 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-63bb7fb3229so153581747b3.2 for ; Wed, 26 Jun 2024 13:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434243; x=1720039043; 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=cZVSwurrOtGiKAjIE7fskoVWYBnB7kl/lnCela0Ia0y4bLZFssw6HhjenX8xQLWvcc Aw0qVU5oiUXE/a6j5Cdp410vqQXlpbRfbwx8km56MDrmmDaCh8oF+6zZ/+U+JRwyQ+jy MCSMVph52okhC7zP3VpFRuwVf7NuXoqGcGn9kSY+kZwsrkFG+V5F5mVNFGgQeJek9XWt oHQLBFsYWBy5HcQnsm1Y2winiCl0xlpv+oCkgJJB8/qxtrN6tsIrHG+TrhF1+iACEvt6 GBt8NSLk9zviQziRteP54916+rIue03URm20JaAxOgkNkQ5asHascx75ugdedneCJnk4 Elpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434243; x=1720039043; 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=H7sz9LZN+9grWigTIXHzuz/+ktgYsDiodWoHTryVzaz1QD0Jj7ID2MIZuQ1STtogBi 70xbaWsizqsW3t280X+dq3DUV4MQLk1X5thIwTVZXgCcf+8xnM2dvmFprDYJVy2gs4DM MAVW1KjluN5pFqdkLQ9MHDfORJyGwT+dbnI5348XoiE/PiSgG0+o4eMW4wSWU5cxXUVM ytS/+jsYdSczig10ZLQPWLZNI/a/5anTM2D0bt4QHG3/jp43lkU/K0bDMSNHZNA6u9yc 4dJgfiQMMyzbQLbnkDQ8kTRi0zupbjalTDJ/zf9pKPpFE12v4nVAkngLtoJ+SoaUDDZr j21Q== X-Forwarded-Encrypted: i=1; AJvYcCXeU9YAbbkhjtH86EcAr5ukuSwurOw9KCoSiI7AajAh/eRkuIEPerz+xgz/QV5uRHcWJPCluq8siBg41EjlZGQkVV7FzhKdPCrdlzMSfXMW+iJdndE= X-Gm-Message-State: AOJu0YynIJkcJ5M34bxQBD/9BjOiSZhqAHK0qjhKlbETex9E8JDfuRMl ju/3Kds7h5liO12HAchM2JkMu2m7dq/ZxjlYiGlE0nQjHO8NPMCC5b2/foKFKHxF4RnV7TaK9lU bdTlepQ== X-Google-Smtp-Source: AGHT+IGZ2cbOs+APOfGf2ySj3i2AIMZztj3b6qdJV0HjjCy2lYFBRVoy2+uVDxJhN+goCOCz1d2W7vXHAT/x X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:704:b0:dfb:22ca:1efd with SMTP id 3f1490d57ef6-e0303fce998mr564006276.9.1719434243104; Wed, 26 Jun 2024 13:37:23 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:21 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-20-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 19/27] 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-20240626_133725_043951_4731FE18 X-CRM114-Status: GOOD ( 13.15 ) 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 Wed Jun 26 20:36:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713414 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 B6B75C30653 for ; Wed, 26 Jun 2024 20:42:06 +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=sl7XDwpRG3F11SZL0IjOlY8k7c UFSLMQxyxg/WQ+Ml8xHVQtuoldkoVduT/rwqYNjSIXDejPaw2Zg5nT/iXcOUXDR/HnoUzar3p//eS f+RaoGbeeozpRjSQGFsfXz+65Mr6pCeEcwq5Oti91Z0pn4hwjt4s7S3z+qZ4khOPzlNbMGEvnL4Un n7J8u36se5ro9hFf5/QFQN2cbKFHQDBFnRbhhzmtUs64hDcpIEvqa1NEM2Ic0rKvt1z/CKb0yP5af 5k9rGUx8JhcqFikJjAc9JoB5JTyu0lILgAtQkf/0df9uCcprmmzsKX519J2vOPSmMC2NBU4X8GJjR mRBNlD7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSk-00000008HQc-3XfC; Wed, 26 Jun 2024 20:41:54 +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 1sMZOQ-00000008FVd-3dx1 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:29 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dfdff0a9f26so13279674276.1 for ; Wed, 26 Jun 2024 13:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434245; x=1720039045; 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=cSnFci3Z8bTSjidXGP61FrhgRmv/IPvT5cwvOjCpa9TdDoTL9581kHqLxwKXW3dNVA cp2jdkdzueDXlhAT91ch9qFbitAo+ZWRZ/hxKe5dESzqrU2pcJEvimVew9HTkDfQ/t4t MLyxrZbndxnmZY1HgkjuGoH9umByOi5UmTStTTyGWRA/gJel7RiQCE3pZhe63vHCwa5Y HsDuxS4LjgzETWmeATDnODIZ0rVCWf3Y61H8DXBORAsFLRrFb6ivV5db0o/Hz339fMaP u2ITjyWrs0ZSIVx22wlqIGCknp3ir7KtQ892pj3xtTAW9npBsjbMW9S8AyCr6PxDFVNy E+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434245; x=1720039045; 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=I2jSmlo/NDAqu+ZSGmNZd+NGxIyCRlkZmqTVdpjcxkhc3GWNXvlEAbKTHPy50Vpj/s OLLanOmtr313mFK1eeNwibF79ntd1aN2pd4WzDoUWG+vjRjetkOmHWExceWgtvrDBeEF pyGzO2dyeF4QijHsWMybab3L1f3Z7ccrFGpeyVqwJt+gDo0pauQn7M3l5W1HzD8QTq7c dSEgAC4+8HBAG7ABP+dynldOQVjOi6yvtKNtDczaPY25R7g6d+U9d3uuV0xwStMtGsCS HTk4NPeeAELkNQxadG/Qf2YKwbBmIDgnHOW8/vJHA6VeV6E1sQW+s4+oiyWZncIpZTvH +wIA== X-Forwarded-Encrypted: i=1; AJvYcCV1316IaUpiIruxZd0AgmZ2fOLZQRUtrfRG2C7njGAxAx8EfAfc0B4Qkmr++Qswg/CwTkEDqA3Tmze6sI3nrbR+RWZSwlbQIqwyuTArRbueMEjLasQ= X-Gm-Message-State: AOJu0YzUDsDJO+if/m3p5gEEC+O5VJo7URBp7R+EFKTB1ccVHqy5afIK zG0rpZY33q0ZBPBckTK39+imA5mfEsRUPVs3igLd9CWB99DLVA3oVqKG6J1uwTv7pD/TEjoNab8 sAqAlQQ== X-Google-Smtp-Source: AGHT+IF/vcrraNGO8BvvwHEaNEI4MnPwEjIw3svMWd/uO2vmBwnso/c7O4FDmbKBdx/YPU/OIZxWVyD57VYv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:1009:b0:e03:252a:f931 with SMTP id 3f1490d57ef6-e03252afca1mr11973276.1.1719434245280; Wed, 26 Jun 2024 13:37:25 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:22 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-21-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 20/27] 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-20240626_133726_980886_64857A90 X-CRM114-Status: GOOD ( 13.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-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 Wed Jun 26 20:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713416 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 7276FC30653 for ; Wed, 26 Jun 2024 20:42:22 +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=hSRE2Mcyvi2lJnUsl2t9X9nIQ1 SetpLqoFnUeyisapXm0cF6Q5MXwrJLIG7fIKvi0ESHZhMw67ZLCU1H+hP4moQJXwLxbMocpXKWfl+ RVADwzmxl+YlD4ylvSni15rKBlppyYgKL21+aVYc2pQYnHEtGysaYtC+Nk04h+WgrWINxcMKm5piO sXZwb/UZ2T+2HFa1pDrTs6B+iS9y5B1nkv16Fwk5powIKlWKhjEHmmqyEy/C2j4BT8YZGaDm+JE2I 5z2KA8DvNAOrT5pDnpurFTDZnzl4ml3GvBxlTBJbFeHIILJj4XlP1B4zk3vpS37Bwgf+zrXvOi7u8 A8TsUsMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSz-00000008Hb6-41N5; Wed, 26 Jun 2024 20:42: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 1sMZOT-00000008FXL-1fyf for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:30 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-63bab20b9f4so127636747b3.3 for ; Wed, 26 Jun 2024 13:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434248; x=1720039048; 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=vMhS1NyR3HLsoLdVPBGt13Yf4vkKHzK3O+xFeqBz0Yj2MDd0PFtm6MPKm/8cTzBcxs kzX/Pn0hq6k2M923h/CWuej+mt3xiQZkKH90BJyJvKNppahbgye1O4o5Tbk9o37KjTEH fLqEvrmbGMFhs7R734+dpuU8EEokvgMBdDpGfVNmmDKNWwVN0pjQmaN8FJbGWFkqZIOh jqg14YjM50TwHvTkXOlhK3j7bfgED6E8jAfN6fQNXpdI3GL/Cu00kFo4S5m2KidI8HZe r+P3RMUyMldSXKmMq1N2Y1kbVo/akgB/3j8KsADdnNtIpN2MwFTENhskpdl4sphuh4Cz Km8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434248; x=1720039048; 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=gagD6KOclaNQwMEtkbtJ3e5UiDn04p2oxKxXmEOAI7p8WA9oHDhZqACGmxgY8zHlzh 0du92BObG3MKBDzClBE6b8YlFjdpbAr9/nTeye5AtFJQkill8p7b8KDeFB7HD1AVL7oW PB9YCPVtyBh1kt56qoc7Gnyey24ZOB7syyES0a+nwdcE1JbEgebruqaDPh5sZztQDx16 Hvi4y1dHOyZIMkmyYkWoWNAOIAf74pIbI5SGcrootGXxspcHyLNlaNMDd1hnEAx9KKdt afsYFIOTbrggkB4LlP0OpxNWM76fuYWoso1fYE2oVcvdlnava7bzy/Kyd2VfPX45vnIN 0M0Q== X-Forwarded-Encrypted: i=1; AJvYcCU5Z0xiwEpxu+J7WSS0qOknjg6DHiWNZwUZwwA/wCgcqv6ROsTu87NnnoT+kEW+/FRbhEbR2GpWQH4YSYpa0Theb2HbjK2xDOZicTluSpeOkEwAANQ= X-Gm-Message-State: AOJu0Yz5bc6ybV4ski5rQTKeai2HIHyFIlC8ao3uJhuHuXF580uiaZRf nW5dSvTE1s7t8foXACcqVdde5yV3pwdEjO47URUbGxhAbXKMxkS62i12E6gRWygmSICg65vBjCg f1EICTA== X-Google-Smtp-Source: AGHT+IGK7lEMZbXEloyFcWkWnNtovrkJgcXd3lNq1ruLQ78TDJ2ALy68c+95Mra/WGL6eiCxX23BeAO5lDBd X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:dc84:0:b0:e02:e1c7:6943 with SMTP id 3f1490d57ef6-e030400522emr31542276.12.1719434247639; Wed, 26 Jun 2024 13:37:27 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:23 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-22-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 21/27] 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-20240626_133729_546785_AE06989F X-CRM114-Status: GOOD ( 12.88 ) 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 Wed Jun 26 20:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713417 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 6AF32C27C4F for ; Wed, 26 Jun 2024 20:42:26 +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=RiqYupFrAGQmOecCg+48Sie/+p 8CIS0XRuZ8ZgXFg806zz6pQ3uVJQPMj1GXEYWFCUeFUJkJkSvLzldVIJ8g6Ffvr+dtjWCUJI5vEMT LittjWzWwXuE6yAOXhie3+gGqVMkiCvpi3avxa3N0qm7Tpj37aU0/ZbBeiX3XwCxoNAdeB5Lt9+g3 LoVB8kytk+Q7+vQ5CQ+d6i57VoKODZuzegoHRoD8aYSUDHaj4jnFxrQ4OJcC02eC/OoiHMWM/PCvo TbmOH1eRSspvMwZey8jZ22gTxZU8YEmK1/YhjAqOp9F6zjECBHAJAcuMpvOs3Yfb75tYt4O0xnZty aGHFjL0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZT6-00000008Hdt-1Czg; Wed, 26 Jun 2024 20:42: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 1sMZOV-00000008FYj-2Iwq for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:33 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-646f73e4354so44122527b3.1 for ; Wed, 26 Jun 2024 13:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434250; x=1720039050; 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=aI6+RlbBdl/kGRirJGXONkHALr9D74FUCMys4l9djGgBxLbyrCadwJwXj7fQlauRse ua3WDBBFZ2EUSz234emPJzMlDJe/xCk4M7K3esF/xOM3jkyqzqDuDRB43uBl5/i3hSO4 6Lw71af1WGR6MllcX4RCjKqGqOlprdbAy5F3/bqvBehAHcJ5q5R4ORTcD0iagdya5rny 5SiM9J+9ZUpe3pQLnZMpPoqQfLkXd15ZxqIAoMzH3NT3CovOs27LfQ88uYWk3L39yoJe EjG96gl/0TpqXuQMHgOrOc6YJFAyLb3p6/Ua4VRpHJpQh8IMLlHzWyqpirQ6E+xEqHUs ffVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434250; x=1720039050; 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=FvUrzH76qBrDQ2HX/hZLdlQncHjSXTismN6anNvvBSssR33LbbnX867xOdffPvVM/r Sca+ncSYKbMKKbc8sAo5+iuRk0lw4fgcMeH7KSXc2HmBa9gELS/F8+cb/f9hfiV9AZYu UjIWFUSWMFc3grK+UykMmZ27/6gB8zGNnfUvNETS1nMtK+IihHWKFY+2gAyZWzVZhVN5 qPZixJCEefaW0FT45q0nNO2fiL62tTLxfVrkd0DFjGE2N1a3g4vseDwJj/cW+fHtUlXz +HfqXLkfhrdi/5LJwzL9IuCP8eC0gGvbhSV/6WiRZEynZKNVXkLeIHtTNbRGmBgQGfLa jJzg== X-Forwarded-Encrypted: i=1; AJvYcCWoJxds3s/Iet9qxbhqByTt9Mq5HC6Z6XBlx4mWjvXKL7wFP0zKsf5sOUvOvE7OY/giv67BNuQ9z9CwZpOpM1OutOSrH3cy3K5iXMdUhuJ32134CXk= X-Gm-Message-State: AOJu0YwFC9LbFT9kNLLCiGrv2DQ50idBAurerZMo0MFZM5oIJOdg7mS9 GdkxJrT/gPlmfNxGWPvsXTlq+Pi3YZ8DCqpMQC1Ts8RmQZGC3ewJa1z2XqrdjNknua8/nVo7PDU 65Wah8w== X-Google-Smtp-Source: AGHT+IGGXFqJD9r3IWjKrWLtrm1hPrgKca2MTAugIoYfk8/8JWlFTTbqc90peurLEErApNOT4jS+EyUzw51J X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:74c9:b0:648:db87:13d8 with SMTP id 00721157ae682-648db8715ddmr35237b3.2.1719434250039; Wed, 26 Jun 2024 13:37:30 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:24 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-23-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 22/27] 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-20240626_133731_673494_8DA73F7C X-CRM114-Status: GOOD ( 12.26 ) 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 Wed Jun 26 20:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713418 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 5B816C27C4F for ; Wed, 26 Jun 2024 20:42:37 +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=cgSQQGuyl/YueyxLoXm403GbVH HHhsCCL9uN7WlZo6RKdEuS2eeBobt8sZHEq/bp0cW5cz6P9RidXDk4gNTybpCOZw+Hob2pfGVYkPX uje90a+MNrX4EkOnAXKXTBbecGWkPsQmup/eQWJMMLodSe1nfd3ZPl+j6gqOUUZC1qTGOCqBb9rTD g1ps50OOiwATvTp8P5qB4CAPN1FwImSyK3vcum2Qm33ihzxh0CJoeNUL1c2v8+w+gUD6p1DqvwRvW Ad70KsAE4tG86PKQCb3EEdMDnpcCMwZEZ/yJY1Cjmo35kOAGyXquGMbuwDK+s+VJWgTwh7SUzc5Ko PYsGO85g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZTG-00000008HlF-0zyD; Wed, 26 Jun 2024 20:42:26 +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 1sMZOX-00000008FZk-1iD7 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:34 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-62d054b1ceeso146328417b3.2 for ; Wed, 26 Jun 2024 13:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434252; x=1720039052; 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=YDGpLj543jRuxaOJBXX+HDxKYaOlbnl+TCENzmPCSSbY0dBtBbUHgPnVYkN6BZ0wIP FsC6uL5WrSsWrPw/rOuXoHdAYL3g5sotQQPay56XO1VzAgsI4jwZuKWQ4mgaqE9QBvn9 1porqCp68RFK+GktRpNtfEktW8OSFvBURIn4EW1v1kVrgRwbMlfp5/5DIBaToOKvdAnD noOz4+GU4dLa/93/VakO2Pnw424a6RYw1W6dUncMYen574ZA2/mZl2M0ClPEVUr48RBA cXzHeklyBm5yoiiDqi5iUQfeyqAWn+4t3AcnwjqPGtjOKaV8iwajrPyl+XfQoEWYbyIT LpsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434252; x=1720039052; 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=pv2MeLttU+ex6UVPsMBH/bTP9EwGcPfhHeGa7TXv6Uolp4bzCYeENVKxeDad82qMJI R0qj3vLDiUAgJlrF20pEsoDOLkW2K/R3jk3iwULUMpQ00oNoI0N1C8NmePLF7EEU75YH izLUYvZTe4PxQehD1lVqkNTQv/3WUOV+A3yBHpZZJPgaWy6hXS9Ola3grIWMD/DVVMTt 56GUJ+Abah3/fsx99w/4lyZA7q8FXP5lGlXOsHQgiDkoDVLzIXHxa6zCdgKb1gT5QZIb nFxrUksNNDM41wD6r7gktIOKQWHprjqXTNadFc43DRgmCGdw+v6vbuoQqvN+KPgaVf2B Pa9Q== X-Forwarded-Encrypted: i=1; AJvYcCVpQ9w3gfXthGQJbK22+MPRWj1DX/IB6GhK7NXHDzMeJk16EGdZGHFVlkRqcdvVZoa3OnKnel3/QTGDFYzPqIx+OL6nMofBIjqxV+aMuBvVmLSd7AM= X-Gm-Message-State: AOJu0YzAdwLAxQS8V2vo/p8BUuZTdmyoBlzsmICPl+JHEVqqIooJ3w8X uBn7ZUgN9tbmH2WRN3vF4RKkKBBA2DHahBl52RzGkwaxWGjpMT4D7DJH6ovb2Sdl6zCz52A5x8t p+JsQIA== X-Google-Smtp-Source: AGHT+IFJh90xA5zR81k/YAgHE8/x6XRCvuJUZgC/JjDthtGxwm0XkkDH8GPDxtXF5TzDpmTRTDcsIafOISw2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:2b12:b0:e02:ce2f:cf07 with SMTP id 3f1490d57ef6-e0303f2a6a8mr38528276.5.1719434252090; Wed, 26 Jun 2024 13:37:32 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:25 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-24-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 23/27] 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-20240626_133733_488377_4CB4EAD9 X-CRM114-Status: GOOD ( 12.32 ) 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 Wed Jun 26 20:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713419 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 E125CC27C4F for ; Wed, 26 Jun 2024 20:42:45 +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=fEtrvCbXU2FS3LWpqxn0X8EG0X 6JSkdALU1tjG31a7+iiFu0G241JSNSaXy7tyjUMVBtyknEhwemFa7EjnNi4cAhav8BydkiaaoFyLQ oU7/gAGacV1hsWOJzD3WDbEM8ObrcTvDOrt2BDIdFkcYq2W3nH8hjj+BydhEFwtwlMKjVZSj9UYfV hwzkGllugqc+vNYwsz+sdhdz6c95g8Fn1TqM4Xv1IyxzR49CN19FBPhis+niYTqVYDL9MDBkBEKOc ihLvmI9wKHv/Sod7IGYMd+qqL/0aGwAwe3FrbP3mHoOrwVGmP/l/syDo8IPcJjOjviVfcN4LfO0zy bEECvzqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZTP-00000008HsZ-3kYM; Wed, 26 Jun 2024 20:42:35 +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 1sMZOZ-00000008Fam-37SH for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:37 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02fff66a83so8551383276.0 for ; Wed, 26 Jun 2024 13:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434254; x=1720039054; 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=NSKSWnwAmioATWjgVGZF6QKqsFbujCUGANxTNSaUYxfImbIcilvBwWL6XEW/stBqZ0 4RmphaC5fZA6pOjMgY8q9oXiOFyUZD6y7tid64/tTTB0pdwf2Ym0mO3462hh0FBYgdV0 /xakD67I4KVXJKoLhU/62069QDAW1iZn0g9nUwnrT0UjBOCEPENKqR4T9B/KamZSZg37 27z7KaCTBKZ61x7KG56S22pkgKOdg96C9vT2pNLoWrRMnY+kUhrNhzEjzaRaFPL40UUR 4BKRdodt4xc/hwAu04nQRR54ETazUw6oE2qzMF6Tdc9dK1SkSEenOjufK7ZYNK/PvJLi 9g1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434254; x=1720039054; 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=mrc8Go8r38eWXbzo5Lh8Pkc2BoYf0G7rzYS99GZYsH+/V+KjcLyKv3qDTzXfUvCHvO GBS10YrMkC1vUCYDyH4meTnf8hG8uyBI4nY8ZA2w4SkUnSwRZinN/ZeCIg6fblw7AN8A cC8cRhduHLfOyjC7fG/FKcgHQXiz+mOlNn4rRun0CN2sNDOfnpOKC5wu+q/XRNMX0TQH QeBHKV9E1xDL0SEgKBfeBGrfQ3oMiF3RMgYvdQSeC5cAjaGhnp7e8Hw8ZWVtVOh5NfQY +7qpKyEaxc8usCCscrrnom15hoHaOxVrr5pRF6t65q4RyNhXBW1v5jgeldeBIi/44xOv TDzw== X-Forwarded-Encrypted: i=1; AJvYcCWSj3QxSYt1RZgLr7PaiS82sRtJUrXy/tq+cUhjDnMMVhawhzaeGE+gvXUCQeNmi8D5lleDrjmRUhpG0BZ4dtZaUdu6vnbXSS4D7NlftCbFzjigtBM= X-Gm-Message-State: AOJu0Ywlqj9n6X98VQI9jApe1N6I3Gb91/AY4cDrgG+HLsojEXwLt1DU Sr7G3LGMipxaGe2Yq+YG0LyoaiGiSj2dvnnt0u0jYNbBcm9pLHGmSMlsLIO/LOHPlCUGIAn+54w CX8OY5Q== X-Google-Smtp-Source: AGHT+IH9TuYO+WiPmgRtSFFWHjHBH655rX65a4zVzk7gaz2aQTP23YgHXVJikjgfAs5bm2nu+W28AwUbyUSL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:1081:b0:dff:3096:85e1 with SMTP id 3f1490d57ef6-e030104fe43mr68452276.10.1719434254286; Wed, 26 Jun 2024 13:37:34 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:26 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-25-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 24/27] 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-20240626_133735_865554_1DB1BE91 X-CRM114-Status: GOOD ( 10.70 ) 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 Wed Jun 26 20:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713420 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 3AB85C27C4F for ; Wed, 26 Jun 2024 20:42:55 +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=menjmBp2rKisbBcDJPIp9r+/L/ Ru2Ss1IdYRI0efSFoHD4cDuvbzDhjV/uPTdKcCW4zCfJHJy2rAW2/17Q07MwvRuxnuZDLCGguUIG7 0zCAsBMXm+5vbCiFDDGGnyPGlSrLyGGHQzumLMcmkjKJxStTTDss7R4Cggz81eF8NjzFaZOFTqJI/ zoU1ycOmz1SMFJdGm98O8DL4ftweH38v2znpi4dpSkXOWs5XHnSd1Yk0zvpU0mvVyqIOW+/AuRirw IMtGW6n2i3PsLmZXPmHbyJbcVefmRgbrLvBsMDql8RBaFpf/tngBcD/aPiUH/dFbhBkXq1NINvJdz gmSaQ4ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZTX-00000008HxJ-2WhP; Wed, 26 Jun 2024 20:42:43 +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 1sMZOc-00000008FcC-2RMm for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:40 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e033554101bso2078916276.2 for ; Wed, 26 Jun 2024 13:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434256; x=1720039056; 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=EibOe9TSUj/DK7M/1AHiNKedoJN/4DNu9WrX1r9jM8ySkvI4Fu/PgT3ulgM+At8tUv weHc159b2/DMeLRUQQkgDaa3FbdQRD1JydpwEJL1i1D4wQYYwO2CVV0MlRdIDT80Jd5V yEQtapxygMMn/0ORp3fOmKJdCY6uxdYEYoNA1v6YDzX4OSbW+ZkVEKGftr6n2V7kST6U J/jkPhrTP/kYD4NIOdPttE5k0FsPCSl3Tf/cirwfcrmxvxaCWDyvrgNH+Y4QOX3UPBNS IwqUyqVwpOKEIGgpamKRNVUljRGgnjtUCTAbaVxkZ/HJ7DlzvmbQhh7Poq0Lpk1VOEHk 55sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434256; x=1720039056; 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=B0pi2OMFHDIdrVPLC+1xv3ks/LWcddD9s3+oO3T4KANZ4mEYErUKW18LmTD8QUoCnj YuT3SGNKBt6O2evFvU3dqFoN0Xfbo5n0BEzlZQ2oEgtyy37jv7zUZuEy3S4GguwnhtMd 7/iOpthGCXCTKpBuWAmYXIVE5+2rM8ZgIDEwbYYzAVedB4CREuUUIcTWDGcbBsNzcAKn ilcYt1WuoUkDqSHr/wcLR7zCoPIRh9Tn7X9mHLDvcD/qaB+rEHBEC25nvvu67I2AelwX R1H0mW2RR86E6BPHyZnUzZu26i7t+GFbZik9S4NoQms920cQAQIHYP7RlFlTNzEn2Y3e +g6A== X-Forwarded-Encrypted: i=1; AJvYcCUN2uWvSZFt7im2n/NTg1j30HzBskimzezWI+AbfhK3VQDxFu0ea6iy8hi15oiQezTPj1jmm0rvNJzHDpJXGv6ke678Cavq7fbi/xweOrExl9OZbZQ= X-Gm-Message-State: AOJu0Yxvoj0pXE8j5GYkWm380cbOyKlEHBGICR+NDtpBpOwlGRt3J+iC yISq89QG2UvxyffqVzpoBcqQMKNm+fHlYQx231+kI1TSUu/yUC1VHCl3HTT3tJFGi5gEfIQ/uAn cc0pI5A== X-Google-Smtp-Source: AGHT+IFNDgaSsvKWEhCLp/cJqqx8LLIcQIa91shbF03zPhK2DmfMDZISVjpcNxywqGfQrHzWLCzDwMoXnqBo X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a25:dcd3:0:b0:e03:40f0:bdcd with SMTP id 3f1490d57ef6-e0340f0bf60mr1486276.4.1719434256549; Wed, 26 Jun 2024 13:37:36 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:27 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-26-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 25/27] 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-20240626_133739_564889_BF6632D1 X-CRM114-Status: GOOD ( 12.32 ) 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 Wed Jun 26 20:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713408 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 C4190C27C4F for ; Wed, 26 Jun 2024 20:41:37 +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=VvdcuIvHOTbN4NA0rBgDWwfYbhOhRSMmjRRTx3dAb4Q=; b=l1ERqisgRxiMgTyPyDznYIT38Y gOaDxZCW3Q3L9d+3bDAAcmaWnvW0QME2PpryAijYejwqQdW6HwXsCXpSZleWjLMfzTL64H/PcGnVU +Jx4pUYaFT1553mHAbFRpcJWQKHGG3PUWD3+LIpkrL9tCd9mrawtF0fmZqU01LzH+/mKdO7h0h29Y YqqVdyo4QHWzTXnlj7hpjW18FVW3qdTlDHft0gTPCp62nv/jrRljtIAqm4YY7D82WUaBEIa+OyiSu gZp8BOIQ9TkBJ5utf1IfK7uXfZ7iSPnZu48VVRWzcv8g42noTSnzZCrxgqG7FWbvQpsPBtyfNE3u6 Z8kK0lEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSG-00000008HD0-41M8; Wed, 26 Jun 2024 20:41:24 +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 1sMZOe-00000008FcQ-0oS7 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:42 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-63c08752872so149778707b3.0 for ; Wed, 26 Jun 2024 13:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434259; x=1720039059; 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=VvdcuIvHOTbN4NA0rBgDWwfYbhOhRSMmjRRTx3dAb4Q=; b=xdl/Z6TLo9jSRXU3I1X3vQj9qhWONBCTuF/U4xiFfQCWa+iqQIcoitiFUbZccE7WJj /10Mxh+G9gsD/ddZphBaKEQxqg1j/Xzvr/Aftd8erKOqG0+GCIFJUjdNpshGf6kDFph7 wY+U9x8uXDPlqkwSLJvSh3nXioqkxO3oaUun8O8/09g3TiQT9qoxpkv+ffEMvYGcjPvp XcaRYIbuSg8lEl5VSrr4e6bVkDc2ZDT1q9P3av8INlQsbVq1vXBjNkwix5CSaIMd3/Va cAq03+QKHLmKzdE9DuZS1eUtSJjfOLqod4LheL9KIoxnJshzB/7Flwx2S469rPAWWBRz MAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434259; x=1720039059; 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=VvdcuIvHOTbN4NA0rBgDWwfYbhOhRSMmjRRTx3dAb4Q=; b=oyBvD9tUf80MoFkq8bvt9lNwmjTvLQbnNBQPIh5mIpNyBdZOaOt18XqRryJvq6eAmP WEABkbZX9tB8C0I2gvW6AoGupg277rMdhLHn6SKkgzKrhfHvco8ImEUfhr0xQoBt9q+N t09he12zBeGPNBdZpAzsEqhSh+d3BgI10DQ8Fk9BbF23XYm/mFZgbOBpnvdtGSOHqHDz t8whXldzapXIA8z7EVQJrYiY41Oxj8wS3uoYI4Odw7XGl5j0xnhXm2+sQZZZkp6qYGuy 2JHfdovW23k/DrxMG50Ao5UNpTwd7jSnAq9d33DK8r8dmUC/0rCjuDjitFjcXs+nz0aJ S4tg== X-Forwarded-Encrypted: i=1; AJvYcCXBEh81Bml2tlDO7gZtlMb4fionw0Kur1ZcLTPfgK/C2no6aZ4PoL78+2S99WopNuZWeFnXnUDK+wRUDB5NtM3bhWtMenTkD5nLOAYLRNlZiRpqNQ8= X-Gm-Message-State: AOJu0YxvElYDuKYN2h5OYYUbW/Z9DoRn0a3tJCHssQ3GBeLsxG/8YZEd uX5mEXBjG4p60+cmKueM+f2/YyuW+Mj4XZqX8XvNWL4RMm3EBdwo5m8vdtWxQQAC2lztgpwGP3K Ai8pGdA== X-Google-Smtp-Source: AGHT+IGDtcxpssxKa5bfLqqp5Vzn7OUbtF04Sj3YluVL/K7/+jI/EtJ6x+K2sSfGKg/ky6LToJZjMKYcK9Dq X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:7201:b0:62c:f01d:3470 with SMTP id 00721157ae682-643ad4ce738mr1556127b3.6.1719434258885; Wed, 26 Jun 2024 13:37:38 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:28 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-27-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 26/27] 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-20240626_133740_269322_BDA9EA2A X-CRM114-Status: GOOD ( 12.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 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 e1d38d91a1b6..54f0ba9b065b 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 Wed Jun 26 20:36:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713409 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 D451FC27C4F for ; Wed, 26 Jun 2024 20:41: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=TdTCsJGRcQ5KEDk5K6+n46WGlbR1BvI2wSbaM6Bk56E=; b=QEoTFDhIvw1jcI3LOro8Jv/b2B OsHFOb3YnOshvu/AtxVcPYnXKhgpZ3ASPLPqmudslyunoVnXJMjXUFhi3SMzjrTFXTkX02QkjEL4y q0+IRQfYedViCeVncn3PkP4+ToxTJVVyz+Jpwytk42h+ldabaL4TrKycjHeNCGl9hpF0lTNHGz4iJ BK54iEhMtapyiOVhnSDLi11Qf9DajZ8sc1B+0g8G1frSEgRgxn/sNcYvkdy1/IqEtJKI9YWsWzQfG v56pSH/WJJnGQrPyXn/yCdC91AQS6Lrdxbo7pgWNWObr+oGve13mXFPm45z+ccOeHf6IbK+B6f4gB sitw/lZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZSL-00000008HEr-40pC; Wed, 26 Jun 2024 20:41:29 +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 1sMZOh-00000008Fdy-0Kxu for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:37:45 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-62f46f56353so123323917b3.3 for ; Wed, 26 Jun 2024 13:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434261; x=1720039061; 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=TdTCsJGRcQ5KEDk5K6+n46WGlbR1BvI2wSbaM6Bk56E=; b=rYBGAvBfOVMaHVUh++VZ1Jcd+DbE4t/0CU53Wy5rnlZv6NgS7kzbzttBE1q1gUaqz4 aXTzVuDh0rLhG7VsFQoIq6OHNsui/49AvBrwVIKOBbGYu6TB182gUjoRhdMw1zC6vl4v CFzwjboqz8iQFY38uAxUL1zoi37rgKEF8Taq5cMojU166OBM9SyL8C5qeMBGeE+XGMBW 4gYSFKn/afFuYCPS6ioc7OZNL55rChKRH7PC4Mgb4akhlfzdFFRLXvyVNnKklosCSQn+ jtgkvagI2esLB1oMaqR70GMRhlxyDV8U0XMfNVfrhagz6Pui3ShEHTlKCLIypLshzz9Q Ho0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434261; x=1720039061; 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=TdTCsJGRcQ5KEDk5K6+n46WGlbR1BvI2wSbaM6Bk56E=; b=o4B1i47JKrI5+nwAEKUmdImDMQLyBfHE5Z2ZVBHTGaG7Le+bBv+LtiEGO7mcKeDaom 3ia/CPuPvjKOCwYa8kuHiHXApRQ+lbJKAyPi+3IZPQK0LfW2Yw2DR9emKuRUo/lT1fQ8 rBO6sB/WEuYJSAzANphlK9WpVj3ycjIo5PcTo2vc0pS1KnMtc4W2rRBIPPsXsTqjRlmV xI87l63FF0Ty9qOv2ObLV2t83PtXvzcIiTA8mGBveODRwUCsl0FFyZyLl7ju7ILJ/4IP AivUI1aWS+CKm1X8W+45kXg0DMsbA9QqYHa5QncSFciK4EyPNt3i+ZjNBiq5/b+V3LWU 1FdA== X-Forwarded-Encrypted: i=1; AJvYcCVns1PvlyI9JuUzpFMEscrRr7HQZYoRZTYDFfuzXNJyyWhvxMk+eH/0xBxxm4kKVB2OWY3etZASwYyt08syNh9ApuQMVsTCoUGkKTgF1Yy4zbPpTWM= X-Gm-Message-State: AOJu0Yxajy/TuOpLbauChJYjnEmgEJzMLzJYYHnUu1U1sW6cpGnJa968 xgYn8Wzrx4RZCLS3UVSW5YXr+fbUFxisjilnHGhJ8GQcEcmLGye5c/RQqzHGfBKtgcMP6GtFj40 62beGLg== X-Google-Smtp-Source: AGHT+IE+TDz0MPCw4fRNjRKEoyr8gpWQlS/FQAQd2Prpi+y2iXax3OXpq7lnsmlMd3V1IIbrXOEA+LsN4GLm X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:3506:b0:61b:e103:804d with SMTP id 00721157ae682-645e60af794mr287967b3.0.1719434261135; Wed, 26 Jun 2024 13:37:41 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:29 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-28-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 27/27] 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-20240626_133743_218902_16E58569 X-CRM114-Status: GOOD ( 14.58 ) 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 54f0ba9b065b..f07ac6dd6762 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 9c9c531052fd..067429d882f4 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;