From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B920193063 for ; Wed, 26 Jun 2024 20:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434203; cv=none; b=tN+g3YK9fS+j1cazc2zPFPYutNJ5gAZbwgwPJZfNPHqjfANw+aaiCp5sZWsHQWs8o9+zZqTEg4ClN8eT3QYdWNbMvQazu7aNSv00MsspEvfyRZloqJ7tUyc/SAgwXqGMfnLi2r/gSbqClko6MfSomqSm1yS0sLWQ8yVNdFSKwuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434203; c=relaxed/simple; bh=qIVwlBIxBrBE5DJKOsQgRyMq6nkjAIOMt9TVYlLDX4w=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=AnbClLQP57QyigbZN3N/RQ2oIEuiCqnsVQzdi266P9pmwrOG41hL1H2Kelip68XIg34no5yXDt0qvemrJTak6v9WcohcxJPRDQTHLcwsXfcqQgnYgKzeYO4RZGRSSAlthJUbYT5AbTXmXiyC36X3V4qX3vXN1kqB6HW0eDavVG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fP6RiTse; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fP6RiTse" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-63bab20bf5fso164068777b3.0 for ; Wed, 26 Jun 2024 13:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434201; x=1720039001; darn=vger.kernel.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=fP6RiTseiTc7k7S8L4SESvaZjP7AEoBZ61f3xHn9RPiuNEzO87HPai0I+O9AYG6Bv1 WAVIzPp66HKR0hgRITDA3ir/Z1YJmMs5Nc6GbLsbydRoAwMNjkm+/EicSQjIGF73wkBp Q8ilciS+8nD1GW9NmM+bYgTRi9Jwe0Z9q0NRtWamrxyXhtYLQHgb6QGeGN1qqduE3pcu SM/h7EvPuvOGoiA4GTjXCvKy85kFf4Ed6HIaFZbby0BFTe7PhBMAXeLSGMA2rGmfmFnZ qYX5HVhAgKbEWqTE8EQDyus1M3TWNajWnVT3uOuqxAnGWCaMaa0qP9SW6sclO+gexo8f qc4A== 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=NQ/96+kq7S7L1QxiQlkubila74PCFWRezG4wKHa+y+ZCoQmJQJOL53efwXBI4+ZSkm 8ub4tmWon7TmtDC+ZtAk/PmpR6Z+EadG867mdbfBg7xDhojfpRUZybRwXZFofAEb0rga idAsBUuaNvV6pGwCSjjXia2SQELvzx/0lbLKj7KtctHZRPN3ZrAhOeEV8U/GcXOVceLe MSP2Y+j05kIMDPCagFQSqHG5RxdWcT9ZWTmBX8HqbzWOLyfEUhzU+sx2vpiMYcFuW7oc MCaCc44orseMnIveiKtKukv61iMlQw1HO0VlCwggivmmu717qA01CVkmFGLdo32g3+eQ A7/w== X-Forwarded-Encrypted: i=1; AJvYcCX/QxIr0xJ7eRyNpoPHrUaPe3qpjYyxQyUcmUIx8qHvlqlIXcTnndVrJLxupslS1vtsuehz9h1BaG2/uLXF1g6tLrfR4BmNGt74SISv X-Gm-Message-State: AOJu0Yyq08p5CueSU/T60OgOHwc5LiFLZinwZjwkmjX4Kl9UDyWMUC0J kRbM8JzoYRu/7sKesO5mTv+ApEwfVHpsHIL5+aCeXbsE1QLGDbyLgXoKnMrT7BO9BjVCjf0qUCD 96vleVg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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) } =20 struct arm_spe_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; =20 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 =3D - container_of(tool, struct arm_spe_synth, dummy_tool); + container_of(tool, struct arm_spe_synth, dummy_tool[0]); =20 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 *s= ession, memset(&arm_spe_synth, 0, sizeof(struct arm_spe_synth)); arm_spe_synth.session =3D session; =20 - 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); } =20 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, } =20 struct cs_etm_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; =20 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 =3D - container_of(tool, struct cs_etm_synth, dummy_tool); + container_of(tool, struct cs_etm_synth, dummy_tool[0]); =20 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 *s= ession, memset(&cs_etm_synth, 0, sizeof(struct cs_etm_synth)); cs_etm_synth.session =3D session; =20 - 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); } =20 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_ses= sion *session, } =20 struct intel_bts_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; =20 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 =3D - container_of(tool, struct intel_bts_synth, dummy_tool); + container_of(tool, struct intel_bts_synth, dummy_tool[0]); =20 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 *s= ession, memset(&intel_bts_synth, 0, sizeof(struct intel_bts_synth)); intel_bts_synth.session =3D session; =20 - 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); } =20 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 *s= ession, } =20 struct intel_pt_synth { - struct perf_tool dummy_tool; struct perf_session *session; + struct perf_tool dummy_tool[0]; }; =20 static int intel_pt_event_synth(struct perf_tool *tool, @@ -3670,7 +3670,7 @@ static int intel_pt_event_synth(struct perf_tool *too= l, struct machine *machine __maybe_unused) { struct intel_pt_synth *intel_pt_synth =3D - container_of(tool, struct intel_pt_synth, dummy_tool); + container_of(tool, struct intel_pt_synth, dummy_tool[0]); =20 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, =20 memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth)); intel_pt_synth.session =3D session; - - err =3D perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, + err =3D 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; } =20 -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, --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4245A193088 for ; Wed, 26 Jun 2024 20:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434206; cv=none; b=HWoEYlCOHQ9E8RMq2rCep/tUHdRwksJYkLZkrEudwUjNi2DPedTI7eqETy9sfBGyyDzDhVHp1fINvRJd5M+d/D/LDzefENSncl/wmEI/MYVgvTec0uYPs5j+g2lj51Omkm788AWddghXHdPI2433b5OAH9s2S5l45HzHYf0CS0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434206; c=relaxed/simple; bh=qdeanQ8GYgnxi/cu3Zjdli62tKEIwEpZcs71nTkIs/A=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qhnK8IbMgguoeFplmDWNjWrPgQDBP90ov5HsJ6Tq2DwYDK2UdVbj6Zrwz9uy+Cyj31VZOsQRuw2OB9b6EdDAKp5v3b19YQ5Ekgl4Hm0HZUGeovdlv7IY9rSg8EGH/BFtX+q2lIl8fmDlDYn86IeOVEPOrfG/nkSz2uAzhMS++aA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2LCt0nW1; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2LCt0nW1" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-643f57e2f0fso101238217b3.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=vger.kernel.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=2LCt0nW1aCZUIJajkIOdSVXZx7QcXcgXlPSgn2JNhBwbPhSdy8Cul3sVKsTX+rGpgO NyqY0/lK2pvVbM0PIZaOJ06hi/sG0/8ttwyFPlu268LTP0DO+cCxgv3zXADuiJZOpEQn AGmtO3xYsebWldLVPB3lZj/oLnY2UugPke1rAr57v2dKY0f4Lq6l4yANCQ3hO17qs9WX ZhpJl9HDDYjdQdhNXd6NuJ5fXUj266e8KjmWv5z3+o1nXnHAxZNI7Ve8hRRvlHO45K0o MA9df5Dg/DqqAaRvOjBQzGvmLqG3Aqmb7uwNYJDFmJ74ucYAnbgp87pywrNh7P5vIoGC nYLg== 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=jGQqv0yvwSgy8FPzFjSWNyqpLuCO6o8MhYpsAAn2baRU5YFuQ+9QJex/eoEy4iidFy 4kJxA/8P7qxN4WNr9namZhANfZwuzylZDGXY2thIHabIeYtDWAcANCce6shOUApQfWoT aKEyNSM7IVnZGu1hAG7mOw7cMTzmmF6OJ6OHfqb86/Lueih0wGVqm8bwrALg2wT8y+4c oCmllbRzbdzdGAkMG/fG8MpO+YZFBT/KLrY5G/960xbiMlhl7XpT6zDqVCzLMpHQYQ7a 7COyGl4J6dOoe6QL91b6N9jFLq/sco1pSWiSOaHiwtd6xR2mVlRTIpXCRrH22wh9i79N xGkQ== X-Forwarded-Encrypted: i=1; AJvYcCUT0tiwuBtvOsL9ion2HJrenGoNALVkHIYiHhSoFL60UjisRIZxFXLfM1iKJ31+0SWV3C6orlh9ZlbtekIIQeT9QdRTSy0AGfb8WzHP X-Gm-Message-State: AOJu0YwsDo7jqe+f4f22yvcfjREUj2+bcfU0FMMlf6BOVHsAykQNGZEs HCUwytNDKb/a55zM+TD7D2kAA/Vt3c+3XeG55ZhhJtMvJysD2yitUAXJh/9pZG75KgyR/OvKs5V Fhz7UfQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 f= unctions") 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 *et= mq, u8 trace_chan_id, if (!dso) goto out; =20 - if (dso->data.status =3D=3D DSO_DATA_STATUS_ERROR && + if (dso__data(dso)->status =3D=3D DSO_DATA_STATUS_ERROR && dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE)) goto out; =20 @@ -1027,11 +1027,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *= etmq, u8 trace_chan_id, if (len <=3D 0) { ui__warning_once("CS ETM Trace: Missing DSO. Use 'perf archive' or debug= infod to export data from the traced system.\n" " Enable CONFIG_PROC_KCORE or use option '-k /path/to/vm= linux' 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 =3D 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 =3D 1; } =20 +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 =3D 1; +} + static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso) { return RC_CHK_ACCESS(dso)->auxtrace_cache; --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96658194099 for ; Wed, 26 Jun 2024 20:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434211; cv=none; b=kNSoYXbXQSBuK9np1qTljfKOfT16IqCbpK5yfY0WXKt0SvaWVpuaPWDOOF0VDKbe6ScfqfZ+Bzy2IPPjl9YtUqFU5AEWAroNqBDsIcMfNHr2udSY436kKhKFee0DDFn8uuXXZAU91C/U5G/JM/3PboHoL6Qe6JrlymjgcsLq960= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434211; c=relaxed/simple; bh=BKc9orsEeG1TQ+EdT86UAB9tj5yjP/jLXAFLtoZMe94=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Kqgksxc9XltsXqwuVwmdeowiAiLDk3tdN7l+2GfqoLgGLbUar4Fnrg5CciLQAXJNShqUJwr3G41w7ky4EyX1+yt/7YK22YhJsma1pHETkcxg/JTFQEY1a/P9qDgaQDXuEzrp0QP7l+9iG1BsMtU+uzfV8ZMJZroN6WpolqQqlfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cSCO0YGm; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cSCO0YGm" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6479d38bdfaso44402157b3.0 for ; Wed, 26 Jun 2024 13:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434205; x=1720039005; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=onjHt3CsaZyO4FRh5EQqT/VL+3JL5t/8oesx5G1M03A=; b=cSCO0YGmIbMT/7XW7vSwHVzI3ZOhXJuD0LIS+8yf2zEteBcDxVmpAgnfVllyCL9iXl sEBm69HiVU2pkHvMHXzwvrJpJ+R8wsVt2V8Hldxgo+78W9l0BEb98yxWbga1D+V2PuwY eU6ElqSScfHD7xBpnWQFL7ScknRFd+dZsL+gjqXNCML74LOQXCSARcH1gSroVfV8ZKWO PKeQ6KXSmedKvuzC92TY1fgp4mseSTUWRfauW5X974MoE3yc8rv+G1Ulahpxo3ot3auY VG1+wlsXxS/8CiYZckYc5P4O0VepZ3yC/0wWRsyUsNFw/UVR5BS/7zV3miSGNaZNgnBe U4tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434205; x=1720039005; 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=onjHt3CsaZyO4FRh5EQqT/VL+3JL5t/8oesx5G1M03A=; b=bY7ujPEk9Q7cMl390F3O4Gjww/uCb1gVzP7WDl8jpZK5wV4keiKXjUkdyuWA5IYwGz rQg/1/DorwheXI6pfQu2Pu7vfaCugumb9RseU/CmWxAnignxVsRVUaYqo1KKRDRbonv0 sRc/uMWF8rBNq+M7uZ+zAUQtJrQ8/Mnb7dfLxUJyqicGdAQUZ+dDRD4BxxF4WMnniXbu DFGrrMhdRh7uICIuGIpLMOXPSnfBCvJboc6QeLhoiEhmXJsY7cvrp93jnn19eqh2orCJ PGiy5CvvaSydXgfxYHc5JGUuUGfi/z9ax1M7u1RhSqFKpj44ulaYblJ8ZGHNaQVJ5l06 H8dA== X-Forwarded-Encrypted: i=1; AJvYcCW+wjNv9tceinuqcd/XKDtSpxf2Ygt1mfNE2UxwHKbeSnXaz9Y3uWXvRVieqiqbr0BwbUdDA2uF1pzyW2oC325iayYgKqaz4/+prgCY X-Gm-Message-State: AOJu0YyRjeIfeYiHtlbnKiq4L03r2EPuQ2kCD6WutfnEOePu5uErYnp2 sZJoxdOCtI6c6qZ7dD99KcbBWfQFbHYtKulY0oZ9wKEUV3INeEQ8YW5GdltGEh6C+oSdpxXGS5U X9nvNDw== X-Google-Smtp-Source: AGHT+IFY/cp093jL7dSJRLhcnhhLA1mPc9VRVt0WkDx1rg+l9hR8IhLXbYY2obd0RD9U4IwtgE3FF1NFRuXx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:690c:7001:b0:62c:c5ea:66ad with SMTP id 00721157ae682-643ab54d839mr10155087b3.4.1719434205556; Wed, 26 Jun 2024 13:36:45 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:05 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 03/27] perf tool: Constify tool pointers 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The tool pointer (to a struct largely of function pointers) is passed around but is unchanged except at initialization. Change parameter and variable types to be const to lower the possibilities of what could happen with a tool. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/event.c | 4 +- tools/perf/bench/synthesize.c | 2 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 70 ++++++++++++------------- tools/perf/builtin-kmem.c | 3 +- tools/perf/builtin-kvm.c | 4 +- tools/perf/builtin-kwork.c | 22 ++++---- tools/perf/builtin-lock.c | 4 +- tools/perf/builtin-mem.c | 4 +- tools/perf/builtin-record.c | 14 ++--- tools/perf/builtin-report.c | 12 ++--- tools/perf/builtin-sched.c | 34 ++++++------ tools/perf/builtin-script.c | 41 ++++++++------- tools/perf/builtin-stat.c | 8 +-- tools/perf/builtin-timechart.c | 8 +-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 6 +-- tools/perf/tests/dlfilter-test.c | 2 +- tools/perf/tests/dwarf-unwind.c | 2 +- tools/perf/tests/event_update.c | 8 +-- tools/perf/tests/stat.c | 6 +-- tools/perf/tests/thread-map.c | 2 +- tools/perf/util/arm-spe.c | 8 +-- tools/perf/util/auxtrace.c | 12 ++--- tools/perf/util/auxtrace.h | 20 ++++---- tools/perf/util/bpf-event.c | 4 +- tools/perf/util/build-id.c | 4 +- tools/perf/util/build-id.h | 4 +- tools/perf/util/cs-etm.c | 8 +-- tools/perf/util/data-convert-bt.c | 4 +- tools/perf/util/data-convert-json.c | 4 +- tools/perf/util/event.c | 34 ++++++------ tools/perf/util/event.h | 34 ++++++------ tools/perf/util/header.c | 6 +-- tools/perf/util/header.h | 4 +- tools/perf/util/hisi-ptt.c | 6 +-- tools/perf/util/intel-bts.c | 8 +-- tools/perf/util/intel-pt.c | 8 +-- tools/perf/util/jitdump.c | 4 +- tools/perf/util/s390-cpumsf.c | 6 +-- tools/perf/util/session.c | 30 +++++------ tools/perf/util/session.h | 2 +- tools/perf/util/synthetic-events.c | 80 ++++++++++++++--------------- tools/perf/util/synthetic-events.h | 70 ++++++++++++------------- tools/perf/util/tool.h | 8 +-- tools/perf/util/tsc.c | 2 +- 49 files changed, 318 insertions(+), 320 deletions(-) diff --git a/tools/perf/arch/x86/util/event.c b/tools/perf/arch/x86/util/ev= ent.c index e65b7dbe27fb..a0400707180c 100644 --- a/tools/perf/arch/x86/util/event.c +++ b/tools/perf/arch/x86/util/event.c @@ -15,7 +15,7 @@ #if defined(__x86_64__) =20 struct perf_event__synthesize_extra_kmaps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event; @@ -65,7 +65,7 @@ static int perf_event__synthesize_extra_kmaps_cb(struct m= ap *map, void *data) return 0; } =20 -int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, +int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { diff --git a/tools/perf/bench/synthesize.c b/tools/perf/bench/synthesize.c index 7401ebbac100..9b333276cbdb 100644 --- a/tools/perf/bench/synthesize.c +++ b/tools/perf/bench/synthesize.c @@ -49,7 +49,7 @@ static const char *const bench_usage[] =3D { =20 static atomic_t event_count; =20 -static int process_synthesized_event(struct perf_tool *tool __maybe_unused, +static int process_synthesized_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b10b7f005658..c0685d2c8de1 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -279,7 +279,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, return ret; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c157bd31f2e5..88c131d05186 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -273,7 +273,7 @@ static void compute_stats(struct c2c_hist_entry *c2c_he, update_stats(&cstats->load, weight); } =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 57d300d8e570..4c0567882a7a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -388,7 +388,7 @@ struct hist_entry_ops block_hist_ops =3D { .free =3D block_hist_free, }; =20 -static int diff__process_sample_event(struct perf_tool *tool, +static int diff__process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index a212678d47be..be74e2bf1f00 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -134,7 +134,7 @@ struct event_entry { union perf_event event[]; }; =20 -static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, +static int dso__inject_build_id(struct dso *dso, const struct perf_tool *t= ool, struct machine *machine, u8 cpumode, u32 flags); =20 static int output_bytes(struct perf_inject *inject, void *buf, size_t sz) @@ -149,7 +149,7 @@ static int output_bytes(struct perf_inject *inject, voi= d *buf, size_t sz) return 0; } =20 -static int perf_event__repipe_synth(struct perf_tool *tool, +static int perf_event__repipe_synth(const struct perf_tool *tool, union perf_event *event) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, @@ -158,7 +158,7 @@ static int perf_event__repipe_synth(struct perf_tool *t= ool, return output_bytes(inject, event, event->header.size); } =20 -static int perf_event__repipe_oe_synth(struct perf_tool *tool, +static int perf_event__repipe_oe_synth(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe __maybe_unused) { @@ -166,7 +166,7 @@ static int perf_event__repipe_oe_synth(struct perf_tool= *tool, } =20 #ifdef HAVE_JITDUMP -static int perf_event__drop_oe(struct perf_tool *tool __maybe_unused, +static int perf_event__drop_oe(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct ordered_events *oe __maybe_unused) { @@ -188,7 +188,7 @@ static int perf_event__repipe_op4_synth(struct perf_ses= sion *session, return perf_event__repipe_synth(session->tool, event); } =20 -static int perf_event__repipe_attr(struct perf_tool *tool, +static int perf_event__repipe_attr(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist) { @@ -206,7 +206,7 @@ static int perf_event__repipe_attr(struct perf_tool *to= ol, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__repipe_event_update(struct perf_tool *tool, +static int perf_event__repipe_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist __maybe_unused) { @@ -237,7 +237,7 @@ static int copy_bytes(struct perf_inject *inject, struc= t perf_data *data, off_t static s64 perf_event__repipe_auxtrace(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_inject *inject =3D container_of(tool, struct perf_inject, tool); int ret; @@ -284,7 +284,7 @@ perf_event__repipe_auxtrace(struct perf_session *sessio= n __maybe_unused, =20 #endif =20 -static int perf_event__repipe(struct perf_tool *tool, +static int perf_event__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -292,7 +292,7 @@ static int perf_event__repipe(struct perf_tool *tool, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__drop(struct perf_tool *tool __maybe_unused, +static int perf_event__drop(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -300,7 +300,7 @@ static int perf_event__drop(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int perf_event__drop_aux(struct perf_tool *tool, +static int perf_event__drop_aux(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -341,13 +341,13 @@ perf_inject__cut_auxtrace_sample(struct perf_inject *= inject, return ev; } =20 -typedef int (*inject_handler)(struct perf_tool *tool, +typedef int (*inject_handler)(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -static int perf_event__repipe_sample(struct perf_tool *tool, +static int perf_event__repipe_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -372,7 +372,7 @@ static int perf_event__repipe_sample(struct perf_tool *= tool, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__repipe_mmap(struct perf_tool *tool, +static int perf_event__repipe_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -386,7 +386,7 @@ static int perf_event__repipe_mmap(struct perf_tool *to= ol, } =20 #ifdef HAVE_JITDUMP -static int perf_event__jit_repipe_mmap(struct perf_tool *tool, +static int perf_event__jit_repipe_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -455,7 +455,7 @@ static struct dso *findnew_dso(int pid, int tid, const = char *filename, return dso; } =20 -static int perf_event__repipe_buildid_mmap(struct perf_tool *tool, +static int perf_event__repipe_buildid_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -474,7 +474,7 @@ static int perf_event__repipe_buildid_mmap(struct perf_= tool *tool, return perf_event__repipe(tool, event, sample, machine); } =20 -static int perf_event__repipe_mmap2(struct perf_tool *tool, +static int perf_event__repipe_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -500,7 +500,7 @@ static int perf_event__repipe_mmap2(struct perf_tool *t= ool, } =20 #ifdef HAVE_JITDUMP -static int perf_event__jit_repipe_mmap2(struct perf_tool *tool, +static int perf_event__jit_repipe_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -524,7 +524,7 @@ static int perf_event__jit_repipe_mmap2(struct perf_too= l *tool, } #endif =20 -static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, +static int perf_event__repipe_buildid_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -565,7 +565,7 @@ static int perf_event__repipe_buildid_mmap2(struct perf= _tool *tool, return 0; } =20 -static int perf_event__repipe_fork(struct perf_tool *tool, +static int perf_event__repipe_fork(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -578,7 +578,7 @@ static int perf_event__repipe_fork(struct perf_tool *to= ol, return err; } =20 -static int perf_event__repipe_comm(struct perf_tool *tool, +static int perf_event__repipe_comm(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -591,7 +591,7 @@ static int perf_event__repipe_comm(struct perf_tool *to= ol, return err; } =20 -static int perf_event__repipe_namespaces(struct perf_tool *tool, +static int perf_event__repipe_namespaces(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -603,7 +603,7 @@ static int perf_event__repipe_namespaces(struct perf_to= ol *tool, return err; } =20 -static int perf_event__repipe_exit(struct perf_tool *tool, +static int perf_event__repipe_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -712,7 +712,7 @@ static bool perf_inject__lookup_known_build_id(struct p= erf_inject *inject, return false; } =20 -static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, +static int dso__inject_build_id(struct dso *dso, const struct perf_tool *t= ool, struct machine *machine, u8 cpumode, u32 flags) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, @@ -743,7 +743,7 @@ static int dso__inject_build_id(struct dso *dso, struct= perf_tool *tool, return 0; } =20 -int perf_event__inject_buildid(struct perf_tool *tool, union perf_event *e= vent, +int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, struct machine *machine) @@ -776,7 +776,7 @@ int perf_event__inject_buildid(struct perf_tool *tool, = union perf_event *event, return 0; } =20 -static int perf_inject__sched_process_exit(struct perf_tool *tool, +static int perf_inject__sched_process_exit(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused, @@ -796,7 +796,7 @@ static int perf_inject__sched_process_exit(struct perf_= tool *tool, return 0; } =20 -static int perf_inject__sched_switch(struct perf_tool *tool, +static int perf_inject__sched_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -821,7 +821,7 @@ static int perf_inject__sched_switch(struct perf_tool *= tool, } =20 #ifdef HAVE_LIBTRACEEVENT -static int perf_inject__sched_stat(struct perf_tool *tool, +static int perf_inject__sched_stat(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, @@ -866,7 +866,7 @@ static int guest_session__output_bytes(struct guest_ses= sion *gs, void *buf, size return ret < 0 ? ret : 0; } =20 -static int guest_session__repipe(struct perf_tool *tool, +static int guest_session__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1032,7 +1032,7 @@ static struct guest_id *guest_session__lookup_id(stru= ct guest_session *gs, u64 i return NULL; } =20 -static int process_attr(struct perf_tool *tool, union perf_event *event, +static int process_attr(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { @@ -1160,7 +1160,7 @@ static u64 evlist__first_id(struct evlist *evlist) return 0; } =20 -static int process_build_id(struct perf_tool *tool, +static int process_build_id(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1210,7 +1210,7 @@ static int guest_session__add_build_ids(struct guest_= session *gs) gs); } =20 -static int guest_session__ksymbol_event(struct perf_tool *tool, +static int guest_session__ksymbol_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1574,7 +1574,7 @@ static int guest_session__flush_events(struct guest_s= ession *gs) return guest_session__inject_events(gs, -1); } =20 -static int host__repipe(struct perf_tool *tool, +static int host__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1647,7 +1647,7 @@ static int host__finished_init(struct perf_session *s= ession, union perf_event *e * guest events up to the same time. Finally write out the FINISHED_ROUND = event * itself. */ -static int host__finished_round(struct perf_tool *tool, +static int host__finished_round(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe) { @@ -1665,7 +1665,7 @@ static int host__finished_round(struct perf_tool *too= l, return perf_event__repipe_oe_synth(tool, event, oe); } =20 -static int host__context_switch(struct perf_tool *tool, +static int host__context_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1719,7 +1719,7 @@ static int evsel__check_stype(struct evsel *evsel, u6= 4 sample_type, const char * return 0; } =20 -static int drop_sample(struct perf_tool *tool __maybe_unused, +static int drop_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 6fd95be5032b..859ff018eace 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -955,7 +955,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *= sample) typedef int (*tracepoint_handler)(struct evsel *evsel, struct perf_sample *sample); =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -2061,4 +2061,3 @@ int cmd_kmem(int argc, const char **argv) =20 return ret; } - diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 71165036e4ca..a3b903cf4311 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1166,7 +1166,7 @@ static void print_result(struct perf_kvm_stat *kvm) } =20 #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) -static int process_lost_event(struct perf_tool *tool, +static int process_lost_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1187,7 +1187,7 @@ static bool skip_sample(struct perf_kvm_stat *kvm, return false; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 56e3f3a5e03a..8ffaa80a2d1d 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -958,7 +958,7 @@ static int top_sched_switch_event(struct perf_kwork *kw= ork, } =20 static struct kwork_class kwork_irq; -static int process_irq_handler_entry_event(struct perf_tool *tool, +static int process_irq_handler_entry_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -971,7 +971,7 @@ static int process_irq_handler_entry_event(struct perf_= tool *tool, return 0; } =20 -static int process_irq_handler_exit_event(struct perf_tool *tool, +static int process_irq_handler_exit_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1037,7 +1037,7 @@ static struct kwork_class kwork_irq =3D { }; =20 static struct kwork_class kwork_softirq; -static int process_softirq_raise_event(struct perf_tool *tool, +static int process_softirq_raise_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1051,7 +1051,7 @@ static int process_softirq_raise_event(struct perf_to= ol *tool, return 0; } =20 -static int process_softirq_entry_event(struct perf_tool *tool, +static int process_softirq_entry_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1065,7 +1065,7 @@ static int process_softirq_entry_event(struct perf_to= ol *tool, return 0; } =20 -static int process_softirq_exit_event(struct perf_tool *tool, +static int process_softirq_exit_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1167,7 +1167,7 @@ static struct kwork_class kwork_softirq =3D { }; =20 static struct kwork_class kwork_workqueue; -static int process_workqueue_activate_work_event(struct perf_tool *tool, +static int process_workqueue_activate_work_event(const struct perf_tool *t= ool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1181,7 +1181,7 @@ static int process_workqueue_activate_work_event(stru= ct perf_tool *tool, return 0; } =20 -static int process_workqueue_execute_start_event(struct perf_tool *tool, +static int process_workqueue_execute_start_event(const struct perf_tool *t= ool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1195,7 +1195,7 @@ static int process_workqueue_execute_start_event(stru= ct perf_tool *tool, return 0; } =20 -static int process_workqueue_execute_end_event(struct perf_tool *tool, +static int process_workqueue_execute_end_event(const struct perf_tool *too= l, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1266,7 +1266,7 @@ static struct kwork_class kwork_workqueue =3D { }; =20 static struct kwork_class kwork_sched; -static int process_sched_switch_event(struct perf_tool *tool, +static int process_sched_switch_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1945,12 +1945,12 @@ static int perf_kwork__report(struct perf_kwork *kw= ork) return 0; } =20 -typedef int (*tracepoint_handler)(struct perf_tool *tool, +typedef int (*tracepoint_handler)(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_kwork__process_tracepoint_sample(struct perf_tool *tool, +static int perf_kwork__process_tracepoint_sample(const struct perf_tool *t= ool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 0253184b3b58..6efa9d646637 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1501,7 +1501,7 @@ static const struct evsel_str_handler contention_trac= epoints[] =3D { { "lock:contention_end", evsel__process_contention_end, }, }; =20 -static int process_event_update(struct perf_tool *tool, +static int process_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist) { @@ -1520,7 +1520,7 @@ static int process_event_update(struct perf_tool *too= l, typedef int (*tracepoint_handler)(struct evsel *evsel, struct perf_sample *sample); =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 863fcd735dae..c2038a32543c 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -188,7 +188,7 @@ static int __cmd_record(int argc, const char **argv, st= ruct perf_mem *mem) } =20 static int -dump_raw_samples(struct perf_tool *tool, +dump_raw_samples(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -262,7 +262,7 @@ dump_raw_samples(struct perf_tool *tool, return 0; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 019305b94e5f..e8677f9e1ccb 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -608,7 +608,7 @@ static int record__comp_enabled(struct record *rec) return rec->opts.comp_level > 0; } =20 -static int process_synthesized_event(struct perf_tool *tool, +static int process_synthesized_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -619,7 +619,7 @@ static int process_synthesized_event(struct perf_tool *= tool, =20 static struct mutex synth_lock; =20 -static int process_locked_synthesized_event(struct perf_tool *tool, +static int process_locked_synthesized_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -704,7 +704,7 @@ static void record__sig_exit(void) =20 #ifdef HAVE_AUXTRACE_SUPPORT =20 -static int record__process_auxtrace(struct perf_tool *tool, +static int record__process_auxtrace(const struct perf_tool *tool, struct mmap *map, union perf_event *event, void *data1, size_t len1, void *data2, size_t len2) @@ -1416,7 +1416,7 @@ static void set_timestamp_boundary(struct record *rec= , u64 sample_time) rec->evlist->last_sample_time =3D sample_time; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -3243,7 +3243,7 @@ static const char * const __record_usage[] =3D { }; const char * const *record_usage =3D __record_usage; =20 -static int build_id__process_mmap(struct perf_tool *tool, union perf_event= *event, +static int build_id__process_mmap(const struct perf_tool *tool, union perf= _event *event, struct perf_sample *sample, struct machine *machine) { /* @@ -3255,7 +3255,7 @@ static int build_id__process_mmap(struct perf_tool *t= ool, union perf_event *even return perf_event__process_mmap(tool, event, sample, machine); } =20 -static int build_id__process_mmap2(struct perf_tool *tool, union perf_even= t *event, +static int build_id__process_mmap2(const struct perf_tool *tool, union per= f_event *event, struct perf_sample *sample, struct machine *machine) { /* @@ -3268,7 +3268,7 @@ static int build_id__process_mmap2(struct perf_tool *= tool, union perf_event *eve return perf_event__process_mmap2(tool, event, sample, machine); } =20 -static int process_timestamp_boundary(struct perf_tool *tool, +static int process_timestamp_boundary(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 9718770facb5..2313bacea0d2 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -263,7 +263,7 @@ static int process_feature_event(struct perf_session *s= ession, return 0; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -339,7 +339,7 @@ static int process_sample_event(struct perf_tool *tool, return ret; } =20 -static int process_read_event(struct perf_tool *tool, +static int process_read_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct evsel *evsel, @@ -765,7 +765,7 @@ static void report__output_resort(struct report *rep) ui_progress__finish(); } =20 -static int count_sample_event(struct perf_tool *tool __maybe_unused, +static int count_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel, @@ -777,7 +777,7 @@ static int count_sample_event(struct perf_tool *tool __= maybe_unused, return 0; } =20 -static int count_lost_samples_event(struct perf_tool *tool, +static int count_lost_samples_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -793,7 +793,7 @@ static int count_lost_samples_event(struct perf_tool *t= ool, return 0; } =20 -static int process_attr(struct perf_tool *tool __maybe_unused, +static int process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist); =20 @@ -1234,7 +1234,7 @@ parse_percent_limit(const struct option *opt, const c= har *str, return 0; } =20 -static int process_attr(struct perf_tool *tool __maybe_unused, +static int process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist) { diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index aa59f763ca46..2d24250f60fa 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1485,7 +1485,7 @@ static void perf_sched__sort_lat(struct perf_sched *s= ched) } } =20 -static int process_sched_wakeup_event(struct perf_tool *tool, +static int process_sched_wakeup_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1498,7 +1498,7 @@ static int process_sched_wakeup_event(struct perf_too= l *tool, return 0; } =20 -static int process_sched_wakeup_ignore(struct perf_tool *tool __maybe_unus= ed, +static int process_sched_wakeup_ignore(const struct perf_tool *tool __mayb= e_unused, struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1683,7 +1683,7 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, return 0; } =20 -static int process_sched_switch_event(struct perf_tool *tool, +static int process_sched_switch_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1709,7 +1709,7 @@ static int process_sched_switch_event(struct perf_too= l *tool, return err; } =20 -static int process_sched_runtime_event(struct perf_tool *tool, +static int process_sched_runtime_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1722,7 +1722,7 @@ static int process_sched_runtime_event(struct perf_to= ol *tool, return 0; } =20 -static int perf_sched__process_fork_event(struct perf_tool *tool, +static int perf_sched__process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1739,7 +1739,7 @@ static int perf_sched__process_fork_event(struct perf= _tool *tool, return 0; } =20 -static int process_sched_migrate_task_event(struct perf_tool *tool, +static int process_sched_migrate_task_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1752,12 +1752,12 @@ static int process_sched_migrate_task_event(struct = perf_tool *tool, return 0; } =20 -typedef int (*tracepoint_handler)(struct perf_tool *tool, +typedef int (*tracepoint_handler)(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __= maybe_unused, +static int perf_sched__process_tracepoint_sample(const struct perf_tool *t= ool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, @@ -1773,7 +1773,7 @@ static int perf_sched__process_tracepoint_sample(stru= ct perf_tool *tool __maybe_ return err; } =20 -static int perf_sched__process_comm(struct perf_tool *tool __maybe_unused, +static int perf_sched__process_comm(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2419,7 +2419,7 @@ static void timehist_print_wakeup_event(struct perf_s= ched *sched, printf("\n"); } =20 -static int timehist_sched_wakeup_ignore(struct perf_tool *tool __maybe_unu= sed, +static int timehist_sched_wakeup_ignore(const struct perf_tool *tool __may= be_unused, union perf_event *event __maybe_unused, struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused, @@ -2428,7 +2428,7 @@ static int timehist_sched_wakeup_ignore(struct perf_t= ool *tool __maybe_unused, return 0; } =20 -static int timehist_sched_wakeup_event(struct perf_tool *tool, +static int timehist_sched_wakeup_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct evsel *evsel, struct perf_sample *sample, @@ -2512,7 +2512,7 @@ static void timehist_print_migration_event(struct per= f_sched *sched, printf("\n"); } =20 -static int timehist_migrate_task_event(struct perf_tool *tool, +static int timehist_migrate_task_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct evsel *evsel, struct perf_sample *sample, @@ -2540,7 +2540,7 @@ static int timehist_migrate_task_event(struct perf_to= ol *tool, return 0; } =20 -static int timehist_sched_change_event(struct perf_tool *tool, +static int timehist_sched_change_event(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, @@ -2671,7 +2671,7 @@ static int timehist_sched_change_event(struct perf_to= ol *tool, return rc; } =20 -static int timehist_sched_switch_event(struct perf_tool *tool, +static int timehist_sched_switch_event(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, @@ -2680,7 +2680,7 @@ static int timehist_sched_switch_event(struct perf_to= ol *tool, return timehist_sched_change_event(tool, event, evsel, sample, machine); } =20 -static int process_lost(struct perf_tool *tool __maybe_unused, +static int process_lost(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -2923,13 +2923,13 @@ static void timehist_print_summary(struct perf_sche= d *sched, printf(" (x %d)\n", sched->max_cpu.cpu); } =20 -typedef int (*sched_handler)(struct perf_tool *tool, +typedef int (*sched_handler)(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_timehist__process_sample(struct perf_tool *tool, +static int perf_timehist__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index c16224b1fef3..394bce9f5338 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2399,7 +2399,7 @@ static bool filter_cpu(struct perf_sample *sample) return false; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -2486,7 +2486,7 @@ static int process_sample_event(struct perf_tool *too= l, // Used when scr->per_event_dump is not set static struct evsel_script es_stdout; =20 -static int process_attr(struct perf_tool *tool, union perf_event *event, +static int process_attr(const struct perf_tool *tool, union perf_event *ev= ent, struct evlist **pevlist) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); @@ -2552,7 +2552,7 @@ static int process_attr(struct perf_tool *tool, union= perf_event *event, return 0; } =20 -static int print_event_with_time(struct perf_tool *tool, +static int print_event_with_time(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine, @@ -2588,14 +2588,14 @@ static int print_event_with_time(struct perf_tool *= tool, return 0; } =20 -static int print_event(struct perf_tool *tool, union perf_event *event, +static int print_event(const struct perf_tool *tool, union perf_event *eve= nt, struct perf_sample *sample, struct machine *machine, pid_t pid, pid_t tid) { return print_event_with_time(tool, event, sample, machine, pid, tid, 0); } =20 -static int process_comm_event(struct perf_tool *tool, +static int process_comm_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2607,7 +2607,7 @@ static int process_comm_event(struct perf_tool *tool, event->comm.tid); } =20 -static int process_namespaces_event(struct perf_tool *tool, +static int process_namespaces_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2619,7 +2619,7 @@ static int process_namespaces_event(struct perf_tool = *tool, event->namespaces.tid); } =20 -static int process_cgroup_event(struct perf_tool *tool, +static int process_cgroup_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2631,7 +2631,7 @@ static int process_cgroup_event(struct perf_tool *too= l, sample->tid); } =20 -static int process_fork_event(struct perf_tool *tool, +static int process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2643,7 +2643,7 @@ static int process_fork_event(struct perf_tool *tool, event->fork.pid, event->fork.tid, event->fork.time); } -static int process_exit_event(struct perf_tool *tool, +static int process_exit_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2656,7 +2656,7 @@ static int process_exit_event(struct perf_tool *tool, return perf_event__process_exit(tool, event, sample, machine); } =20 -static int process_mmap_event(struct perf_tool *tool, +static int process_mmap_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2668,7 +2668,7 @@ static int process_mmap_event(struct perf_tool *tool, event->mmap.tid); } =20 -static int process_mmap2_event(struct perf_tool *tool, +static int process_mmap2_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2680,7 +2680,7 @@ static int process_mmap2_event(struct perf_tool *tool, event->mmap2.tid); } =20 -static int process_switch_event(struct perf_tool *tool, +static int process_switch_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2712,7 +2712,7 @@ static int process_auxtrace_error(struct perf_session= *session, } =20 static int -process_lost_event(struct perf_tool *tool, +process_lost_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2722,7 +2722,7 @@ process_lost_event(struct perf_tool *tool, } =20 static int -process_throttle_event(struct perf_tool *tool __maybe_unused, +process_throttle_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2733,7 +2733,7 @@ process_throttle_event(struct perf_tool *tool __maybe= _unused, } =20 static int -process_finished_round_event(struct perf_tool *tool __maybe_unused, +process_finished_round_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct ordered_events *oe __maybe_unused) =20 @@ -2743,7 +2743,7 @@ process_finished_round_event(struct perf_tool *tool _= _maybe_unused, } =20 static int -process_bpf_events(struct perf_tool *tool __maybe_unused, +process_bpf_events(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2755,7 +2755,7 @@ process_bpf_events(struct perf_tool *tool __maybe_unu= sed, sample->tid); } =20 -static int process_text_poke_events(struct perf_tool *tool, +static int process_text_poke_events(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -3757,7 +3757,7 @@ static int process_thread_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, too= l); =20 if (dump_trace) @@ -3779,7 +3779,7 @@ static int process_cpu_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, too= l); =20 if (dump_trace) @@ -3809,11 +3809,10 @@ static int process_feature_event(struct perf_sessio= n *session, static int perf_script__process_auxtrace_info(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; - int ret =3D perf_event__process_auxtrace_info(session, event); =20 if (ret =3D=3D 0) { + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, to= ol); =20 ret =3D perf_script__setup_per_event_dump(script); diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 661832756a24..d460c46f15fd 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -248,7 +248,7 @@ static void perf_stat__reset_stats(void) perf_stat__reset_shadow_stats(); } =20 -static int process_synthesized_event(struct perf_tool *tool __maybe_unused, +static int process_synthesized_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -2180,7 +2180,7 @@ static int process_stat_config_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); =20 perf_event__read_stat_config(&stat_config, &event->stat_config); @@ -2229,7 +2229,7 @@ static int process_thread_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); =20 if (st->threads) { @@ -2248,7 +2248,7 @@ static int process_cpu_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); struct perf_cpu_map *cpus; =20 diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 19d4542ea18a..5bf818baa662 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -320,7 +320,7 @@ static int *cpus_cstate_state; static u64 *cpus_pstate_start_times; static u64 *cpus_pstate_state; =20 -static int process_comm_event(struct perf_tool *tool, +static int process_comm_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -330,7 +330,7 @@ static int process_comm_event(struct perf_tool *tool, return 0; } =20 -static int process_fork_event(struct perf_tool *tool, +static int process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -340,7 +340,7 @@ static int process_fork_event(struct perf_tool *tool, return 0; } =20 -static int process_exit_event(struct perf_tool *tool, +static int process_exit_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -571,7 +571,7 @@ typedef int (*tracepoint_handler)(struct timechart *tch= art, struct perf_sample *sample, const char *backtrace); =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e8cbbf10d361..d6fcc6c122da 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -740,7 +740,7 @@ static int hist_iter__top_callback(struct hist_entry_it= er *iter, return 0; } =20 -static void perf_event__process_sample(struct perf_tool *tool, +static void perf_event__process_sample(const struct perf_tool *tool, const union perf_event *event, struct evsel *evsel, struct perf_sample *sample, diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c42bc608954e..503bfb7afe25 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1637,7 +1637,7 @@ static int trace__process_event(struct trace *trace, = struct machine *machine, return ret; } =20 -static int trace__tool_process(struct perf_tool *tool, +static int trace__tool_process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -3009,7 +3009,7 @@ static void trace__set_base_time(struct trace *trace, trace->base_time =3D sample->time; } =20 -static int trace__process_sample(struct perf_tool *tool, +static int trace__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index bd8e396f3e57..2f0168b2a5a9 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -11,7 +11,7 @@ =20 struct machine; =20 -static int process_event_mask(struct perf_tool *tool __maybe_unused, +static int process_event_mask(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -47,7 +47,7 @@ static int process_event_mask(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_cpus(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -73,7 +73,7 @@ static int process_event_cpus(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_range_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_range_cpus(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-t= est.c index da3a9b50b1b1..54f59d1246bc 100644 --- a/tools/perf/tests/dlfilter-test.c +++ b/tools/perf/tests/dlfilter-test.c @@ -62,7 +62,7 @@ static int test_result(const char *msg, int ret) return ret; } =20 -static int process(struct perf_tool *tool, union perf_event *event, +static int process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwin= d.c index d01aa931fe81..f85d391ced98 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -37,7 +37,7 @@ #define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory"); #endif =20 -static int mmap_handler(struct perf_tool *tool __maybe_unused, +static int mmap_handler(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_updat= e.c index d093a9b878d1..fdecad920f59 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -12,7 +12,7 @@ #include "tests.h" #include "debug.h" =20 -static int process_event_unit(struct perf_tool *tool __maybe_unused, +static int process_event_unit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -25,7 +25,7 @@ static int process_event_unit(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_scale(struct perf_tool *tool __maybe_unused, +static int process_event_scale(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -43,7 +43,7 @@ struct event_name { const char *name; }; =20 -static int process_event_name(struct perf_tool *tool, +static int process_event_name(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -57,7 +57,7 @@ static int process_event_name(struct perf_tool *tool, return 0; } =20 -static int process_event_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_cpus(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c index 706780fb5695..6468cc0d0204 100644 --- a/tools/perf/tests/stat.c +++ b/tools/perf/tests/stat.c @@ -21,7 +21,7 @@ static bool has_term(struct perf_record_stat_config *conf= ig, return false; } =20 -static int process_stat_config_event(struct perf_tool *tool __maybe_unused, +static int process_stat_config_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -62,7 +62,7 @@ static int test__synthesize_stat_config(struct test_suite= *test __maybe_unused, return 0; } =20 -static int process_stat_event(struct perf_tool *tool __maybe_unused, +static int process_stat_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -93,7 +93,7 @@ static int test__synthesize_stat(struct test_suite *test = __maybe_unused, int sub return 0; } =20 -static int process_stat_round_event(struct perf_tool *tool __maybe_unused, +static int process_stat_round_event(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c index 74308c1368fe..1fe521466bf4 100644 --- a/tools/perf/tests/thread-map.c +++ b/tools/perf/tests/thread-map.c @@ -60,7 +60,7 @@ static int test__thread_map(struct test_suite *test __may= be_unused, int subtest return 0; } =20 -static int process_event(struct perf_tool *tool __maybe_unused, +static int process_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index ee0d5064ddd4..b16250e260d6 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -899,7 +899,7 @@ static int arm_spe_context_switch(struct arm_spe *spe, = union perf_event *event, static int arm_spe_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { int err =3D 0; u64 timestamp; @@ -947,7 +947,7 @@ static int arm_spe_process_event(struct perf_session *s= ession, =20 static int arm_spe_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct arm_spe *spe =3D container_of(session->auxtrace, struct arm_spe, auxtrace); @@ -985,7 +985,7 @@ static int arm_spe_process_auxtrace_event(struct perf_s= ession *session, } =20 static int arm_spe_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct arm_spe *spe =3D container_of(session->auxtrace, struct arm_spe, auxtrace); @@ -1078,7 +1078,7 @@ struct arm_spe_synth { struct perf_tool dummy_tool[0]; }; =20 -static int arm_spe_event_synth(struct perf_tool *tool, +static int arm_spe_event_synth(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e2f317063eec..cbb773ed6f1a 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1240,7 +1240,7 @@ void auxtrace_synth_error(struct perf_record_auxtrace= _error *auxtrace_error, int } =20 int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, - struct perf_tool *tool, + const struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process) { @@ -1831,7 +1831,7 @@ int __weak compat_auxtrace_mmap__write_tail(struct au= xtrace_mmap *mm, u64 tail) =20 static int __auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, bool snapshot, size_t snapshot_size) { struct auxtrace_mmap *mm =3D &map->auxtrace_mmap; @@ -1942,14 +1942,14 @@ static int __auxtrace_mmap__read(struct mmap *map, } =20 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn) + const struct perf_tool *tool, process_auxtrace_t fn) { return __auxtrace_mmap__read(map, itr, tool, fn, false, 0); } =20 int auxtrace_mmap__read_snapshot(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, size_t snapshot_size) { return __auxtrace_mmap__read(map, itr, tool, fn, true, snapshot_size); @@ -2829,7 +2829,7 @@ int auxtrace_parse_filters(struct evlist *evlist) } =20 int auxtrace__process_event(struct perf_session *session, union perf_event= *event, - struct perf_sample *sample, struct perf_tool *tool) + struct perf_sample *sample, const struct perf_tool *tool) { if (!session->auxtrace) return 0; @@ -2847,7 +2847,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_sessi= on *session, session->auxtrace->dump_auxtrace_sample(session, sample); } =20 -int auxtrace__flush_events(struct perf_session *session, struct perf_tool = *tool) +int auxtrace__flush_events(struct perf_session *session, const struct perf= _tool *tool) { if (!session->auxtrace) return 0; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 8a6ec9565835..d405efcd8708 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -208,17 +208,17 @@ struct auxtrace { int (*process_event)(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool); + const struct perf_tool *tool); int (*process_auxtrace_event)(struct perf_session *session, union perf_event *event, - struct perf_tool *tool); + const struct perf_tool *tool); int (*queue_data)(struct perf_session *session, struct perf_sample *sample, union perf_event *event, u64 data_offset); void (*dump_auxtrace_sample)(struct perf_session *session, struct perf_sample *sample); int (*flush_events)(struct perf_session *session, - struct perf_tool *tool); + const struct perf_tool *tool); void (*free_events)(struct perf_session *session); void (*free)(struct perf_session *session); bool (*evsel_is_auxtrace)(struct perf_session *session, @@ -508,17 +508,17 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mm= ap_params *mp, struct evlist *evlist, struct evsel *evsel, int idx); =20 -typedef int (*process_auxtrace_t)(struct perf_tool *tool, +typedef int (*process_auxtrace_t)(const struct perf_tool *tool, struct mmap *map, union perf_event *event, void *data1, size_t len1, void *data2, size_t len2); =20 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn); + const struct perf_tool *tool, process_auxtrace_t fn); =20 int auxtrace_mmap__read_snapshot(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, size_t snapshot_size); =20 int auxtrace_queues__init_nr(struct auxtrace_queues *queues, int nr_queues= ); @@ -639,10 +639,10 @@ int addr_filters__parse_bare_filter(struct addr_filte= rs *filts, int auxtrace_parse_filters(struct evlist *evlist); =20 int auxtrace__process_event(struct perf_session *session, union perf_event= *event, - struct perf_sample *sample, struct perf_tool *tool); + struct perf_sample *sample, const struct perf_tool *tool); void auxtrace__dump_auxtrace_sample(struct perf_session *session, struct perf_sample *sample); -int auxtrace__flush_events(struct perf_session *session, struct perf_tool = *tool); +int auxtrace__flush_events(struct perf_session *session, const struct perf= _tool *tool); void auxtrace__free_events(struct perf_session *session); void auxtrace__free(struct perf_session *session); bool auxtrace__evsel_is_auxtrace(struct perf_session *session, @@ -809,7 +809,7 @@ static inline int auxtrace__process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } @@ -822,7 +822,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_session= *session __maybe_unused, =20 static inline int auxtrace__flush_events(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 827695cd0408..13608237c50e 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -170,7 +170,7 @@ static int perf_event__synthesize_one_bpf_prog(struct p= erf_session *session, { struct perf_record_ksymbol *ksymbol_event =3D &event->ksymbol; struct perf_record_bpf_event *bpf_event =3D &event->bpf; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct bpf_prog_info_node *info_node; struct perf_bpil *info_linear; struct bpf_prog_info *info; @@ -310,7 +310,7 @@ struct kallsyms_parse { union perf_event *event; perf_event__handler_t process; struct machine *machine; - struct perf_tool *tool; + const struct perf_tool *tool; }; =20 static int diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 83a1581e8cf1..098fcc625d91 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -42,7 +42,7 @@ =20 static bool no_buildid_cache; =20 -int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused, +int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, @@ -67,7 +67,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe= _unused, return 0; } =20 -static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unus= ed, +static int perf_event__exit_del_thread(const struct perf_tool *tool __mayb= e_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 3fa8bffb07ca..ae87c4c58d5b 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -35,11 +35,11 @@ char *dso__build_id_filename(const struct dso *dso, cha= r *bf, size_t size, char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t siz= e, bool is_debug, bool is_kallsyms); =20 -int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, +int build_id__mark_dso_hit(const struct perf_tool *tool, union perf_event = *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -int perf_event__inject_buildid(struct perf_tool *tool, union perf_event *e= vent, +int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index e1a7eebbb15f..3a371873f08e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -788,7 +788,7 @@ static void cs_etm__dump_event(struct cs_etm_queue *etm= q, } =20 static int cs_etm__flush_events(struct perf_session *session, - struct perf_tool *tool) + const struct perf_tool *tool) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, @@ -1600,7 +1600,7 @@ struct cs_etm_synth { struct perf_tool dummy_tool[0]; }; =20 -static int cs_etm__event_synth(struct perf_tool *tool, +static int cs_etm__event_synth(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -2740,7 +2740,7 @@ static int cs_etm__process_switch_cpu_wide(struct cs_= etm_auxtrace *etm, static int cs_etm__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, @@ -2810,7 +2810,7 @@ static void dump_queued_data(struct cs_etm_auxtrace *= etm, =20 static int cs_etm__process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 2b732bccabad..9e2170604b66 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -792,7 +792,7 @@ static bool is_flush_needed(struct ctf_stream *cs) return cs->count >=3D STREAM_FLUSH_COUNT; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, struct evsel *evsel, @@ -871,7 +871,7 @@ do { \ } while(0) =20 #define __FUNC_PROCESS_NON_SAMPLE(_name, body) \ -static int process_##_name##_event(struct perf_tool *tool, \ +static int process_##_name##_event(const struct perf_tool *tool, \ union perf_event *_event, \ struct perf_sample *sample, \ struct machine *machine) \ diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 3cf64f5b23ee..905ea9823f9d 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -118,7 +118,7 @@ static void output_json_key_format(FILE *out, bool comm= a, int depth, va_end(args); } =20 -static void output_sample_callchain_entry(struct perf_tool *tool, +static void output_sample_callchain_entry(const struct perf_tool *tool, u64 ip, struct addr_location *al) { struct convert_json *c =3D container_of(tool, struct convert_json, tool); @@ -146,7 +146,7 @@ static void output_sample_callchain_entry(struct perf_t= ool *tool, output_json_format(out, false, 4, "}"); } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f32f9abf6344..c2f0e7f40ad5 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -216,7 +216,7 @@ size_t perf_event__fprintf_cgroup(union perf_event *eve= nt, FILE *fp) event->cgroup.id, event->cgroup.path); } =20 -int perf_event__process_comm(struct perf_tool *tool __maybe_unused, +int perf_event__process_comm(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -224,7 +224,7 @@ int perf_event__process_comm(struct perf_tool *tool __m= aybe_unused, return machine__process_comm_event(machine, event, sample); } =20 -int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, +int perf_event__process_namespaces(const struct perf_tool *tool __maybe_un= used, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -232,7 +232,7 @@ int perf_event__process_namespaces(struct perf_tool *to= ol __maybe_unused, return machine__process_namespaces_event(machine, event, sample); } =20 -int perf_event__process_cgroup(struct perf_tool *tool __maybe_unused, +int perf_event__process_cgroup(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -240,7 +240,7 @@ int perf_event__process_cgroup(struct perf_tool *tool _= _maybe_unused, return machine__process_cgroup_event(machine, event, sample); } =20 -int perf_event__process_lost(struct perf_tool *tool __maybe_unused, +int perf_event__process_lost(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -248,7 +248,7 @@ int perf_event__process_lost(struct perf_tool *tool __m= aybe_unused, return machine__process_lost_event(machine, event, sample); } =20 -int perf_event__process_aux(struct perf_tool *tool __maybe_unused, +int perf_event__process_aux(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -256,7 +256,7 @@ int perf_event__process_aux(struct perf_tool *tool __ma= ybe_unused, return machine__process_aux_event(machine, event); } =20 -int perf_event__process_itrace_start(struct perf_tool *tool __maybe_unused, +int perf_event__process_itrace_start(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -264,7 +264,7 @@ int perf_event__process_itrace_start(struct perf_tool *= tool __maybe_unused, return machine__process_itrace_start_event(machine, event); } =20 -int perf_event__process_aux_output_hw_id(struct perf_tool *tool __maybe_un= used, +int perf_event__process_aux_output_hw_id(const struct perf_tool *tool __ma= ybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -272,7 +272,7 @@ int perf_event__process_aux_output_hw_id(struct perf_to= ol *tool __maybe_unused, return machine__process_aux_output_hw_id_event(machine, event); } =20 -int perf_event__process_lost_samples(struct perf_tool *tool __maybe_unused, +int perf_event__process_lost_samples(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -280,7 +280,7 @@ int perf_event__process_lost_samples(struct perf_tool *= tool __maybe_unused, return machine__process_lost_samples_event(machine, event, sample); } =20 -int perf_event__process_switch(struct perf_tool *tool __maybe_unused, +int perf_event__process_switch(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -288,7 +288,7 @@ int perf_event__process_switch(struct perf_tool *tool _= _maybe_unused, return machine__process_switch_event(machine, event); } =20 -int perf_event__process_ksymbol(struct perf_tool *tool __maybe_unused, +int perf_event__process_ksymbol(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -296,7 +296,7 @@ int perf_event__process_ksymbol(struct perf_tool *tool = __maybe_unused, return machine__process_ksymbol(machine, event, sample); } =20 -int perf_event__process_bpf(struct perf_tool *tool __maybe_unused, +int perf_event__process_bpf(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -304,7 +304,7 @@ int perf_event__process_bpf(struct perf_tool *tool __ma= ybe_unused, return machine__process_bpf(machine, event, sample); } =20 -int perf_event__process_text_poke(struct perf_tool *tool __maybe_unused, +int perf_event__process_text_poke(const struct perf_tool *tool __maybe_unu= sed, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -387,7 +387,7 @@ size_t perf_event__fprintf_cpu_map(union perf_event *ev= ent, FILE *fp) return ret; } =20 -int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, +int perf_event__process_mmap(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -395,7 +395,7 @@ int perf_event__process_mmap(struct perf_tool *tool __m= aybe_unused, return machine__process_mmap_event(machine, event, sample); } =20 -int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, +int perf_event__process_mmap2(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -410,7 +410,7 @@ size_t perf_event__fprintf_task(union perf_event *event= , FILE *fp) event->fork.ppid, event->fork.ptid); } =20 -int perf_event__process_fork(struct perf_tool *tool __maybe_unused, +int perf_event__process_fork(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -418,7 +418,7 @@ int perf_event__process_fork(struct perf_tool *tool __m= aybe_unused, return machine__process_fork_event(machine, event, sample); } =20 -int perf_event__process_exit(struct perf_tool *tool __maybe_unused, +int perf_event__process_exit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -587,7 +587,7 @@ size_t perf_event__fprintf(union perf_event *event, str= uct machine *machine, FIL return ret; } =20 -int perf_event__process(struct perf_tool *tool __maybe_unused, +int perf_event__process(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index d8bcee2e9b93..4b24f1c580fd 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -267,71 +267,71 @@ struct perf_tool; void perf_event__read_stat_config(struct perf_stat_config *config, struct perf_record_stat_config *event); =20 -int perf_event__process_comm(struct perf_tool *tool, +int perf_event__process_comm(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_lost(struct perf_tool *tool, +int perf_event__process_lost(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_lost_samples(struct perf_tool *tool, +int perf_event__process_lost_samples(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_aux(struct perf_tool *tool, +int perf_event__process_aux(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_itrace_start(struct perf_tool *tool, +int perf_event__process_itrace_start(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_aux_output_hw_id(struct perf_tool *tool, +int perf_event__process_aux_output_hw_id(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_switch(struct perf_tool *tool, +int perf_event__process_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_namespaces(struct perf_tool *tool, +int perf_event__process_namespaces(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_cgroup(struct perf_tool *tool, +int perf_event__process_cgroup(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap(struct perf_tool *tool, +int perf_event__process_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap2(struct perf_tool *tool, +int perf_event__process_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_fork(struct perf_tool *tool, +int perf_event__process_fork(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_exit(struct perf_tool *tool, +int perf_event__process_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_ksymbol(struct perf_tool *tool, +int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_bpf(struct perf_tool *tool, +int perf_event__process_bpf(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_text_poke(struct perf_tool *tool, +int perf_event__process_text_poke(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process(struct perf_tool *tool, +int perf_event__process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 55e9553861d0..3309fe7f1d12 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -4326,7 +4326,7 @@ int perf_session__read_header(struct perf_session *se= ssion, int repipe_fd) int perf_event__process_feature(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct feat_fd ff =3D { .fd =3D 0 }; struct perf_record_header_feature *fe =3D (struct perf_record_header_feat= ure *)event; int type =3D fe->header.type; @@ -4405,7 +4405,7 @@ size_t perf_event__fprintf_event_update(union perf_ev= ent *event, FILE *fp) return ret; } =20 -int perf_event__process_attr(struct perf_tool *tool __maybe_unused, +int perf_event__process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist) { @@ -4444,7 +4444,7 @@ int perf_event__process_attr(struct perf_tool *tool _= _maybe_unused, return 0; } =20 -int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, +int perf_event__process_event_update(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct evlist **pevlist) { diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 7c16a250e738..07ff647197ff 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -156,9 +156,9 @@ int perf_header__fprintf_info(struct perf_session *s, F= ILE *fp, bool full); =20 int perf_event__process_feature(struct perf_session *session, union perf_event *event); -int perf_event__process_attr(struct perf_tool *tool, union perf_event *eve= nt, +int perf_event__process_attr(const struct perf_tool *tool, union perf_even= t *event, struct evlist **pevlist); -int perf_event__process_event_update(struct perf_tool *tool, +int perf_event__process_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp); diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c index 37ea987017f6..e4cc4785f744 100644 --- a/tools/perf/util/hisi-ptt.c +++ b/tools/perf/util/hisi-ptt.c @@ -79,14 +79,14 @@ static void hisi_ptt_dump_event(struct hisi_ptt *ptt, u= nsigned char *buf, static int hisi_ptt_process_event(struct perf_session *session __maybe_unu= sed, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } =20 static int hisi_ptt_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct hisi_ptt *ptt =3D container_of(session->auxtrace, struct hisi_ptt, auxtrace); @@ -123,7 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_= session *session, } =20 static int hisi_ptt_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index fb8fec3a3c36..cf9b89c6665b 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -591,7 +591,7 @@ static int intel_bts_process_queues(struct intel_bts *b= ts, u64 timestamp) static int intel_bts_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -634,7 +634,7 @@ static int intel_bts_process_event(struct perf_session = *session, =20 static int intel_bts_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -675,7 +675,7 @@ static int intel_bts_process_auxtrace_event(struct perf= _session *session, } =20 static int intel_bts_flush(struct perf_session *session, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -742,7 +742,7 @@ struct intel_bts_synth { struct perf_tool dummy_tool[0]; }; =20 -static int intel_bts_event_synth(struct perf_tool *tool, +static int intel_bts_event_synth(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index b8b90773baa2..3c3f53864452 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3449,7 +3449,7 @@ static int intel_pt_text_poke(struct intel_pt *pt, un= ion perf_event *event) static int intel_pt_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3533,7 +3533,7 @@ static int intel_pt_process_event(struct perf_session= *session, return err; } =20 -static int intel_pt_flush(struct perf_session *session, struct perf_tool *= tool) +static int intel_pt_flush(struct perf_session *session, const struct perf_= tool *tool) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3600,7 +3600,7 @@ static bool intel_pt_evsel_is_auxtrace(struct perf_se= ssion *session, =20 static int intel_pt_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3664,7 +3664,7 @@ struct intel_pt_synth { struct perf_tool dummy_tool[0]; }; =20 -static int intel_pt_event_synth(struct perf_tool *tool, +static int intel_pt_event_synth(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 1f657ef8975f..5ce13653512b 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -424,7 +424,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd= , union jr_entry *jr) { struct perf_sample sample; union perf_event *event; - struct perf_tool *tool =3D jd->session->tool; + const struct perf_tool *tool =3D jd->session->tool; uint64_t code, addr; uintptr_t uaddr; char *filename; @@ -543,7 +543,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd= , union jr_entry *jr) { struct perf_sample sample; union perf_event *event; - struct perf_tool *tool =3D jd->session->tool; + const struct perf_tool *tool =3D jd->session->tool; char *filename; size_t size; struct stat st; diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 4ec583e511af..73846b73d0cf 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -912,7 +912,7 @@ static int s390_cpumsf_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct s390_cpumsf *sf =3D container_of(session->auxtrace, struct s390_cpumsf, @@ -955,7 +955,7 @@ s390_cpumsf_process_event(struct perf_session *session, static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct s390_cpumsf *sf =3D container_of(session->auxtrace, struct s390_cpumsf, @@ -998,7 +998,7 @@ static void s390_cpumsf_free_events(struct perf_session= *session __maybe_unused) } =20 static int s390_cpumsf_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 0ec92d47373c..278955b8e73a 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -102,7 +102,7 @@ static int perf_session__process_compressed_event(struc= t perf_session *session, =20 static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool, + const struct perf_tool *tool, u64 file_offset, const char *file_path); =20 @@ -328,7 +328,7 @@ static int process_event_synth_tracing_data_stub(struct= perf_session *session return 0; } =20 -static int process_event_synth_attr_stub(struct perf_tool *tool __maybe_un= used, +static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, union perf_event *event __maybe_unused, struct evlist **pevlist __maybe_unused) @@ -337,7 +337,7 @@ static int process_event_synth_attr_stub(struct perf_to= ol *tool __maybe_unused, return 0; } =20 -static int process_event_synth_event_update_stub(struct perf_tool *tool __= maybe_unused, +static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, union perf_event *event __maybe_unused, struct evlist **pevlist __maybe_unused) @@ -349,7 +349,7 @@ static int process_event_synth_event_update_stub(struct= perf_tool *tool __maybe_ return 0; } =20 -static int process_event_sample_stub(struct perf_tool *tool __maybe_unused, +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, @@ -359,7 +359,7 @@ static int process_event_sample_stub(struct perf_tool *= tool __maybe_unused, return 0; } =20 -static int process_event_stub(struct perf_tool *tool __maybe_unused, +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) @@ -368,7 +368,7 @@ static int process_event_stub(struct perf_tool *tool __= maybe_unused, return 0; } =20 -static int process_finished_round_stub(struct perf_tool *tool __maybe_unus= ed, +static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, union perf_event *event __maybe_unused, struct ordered_events *oe __maybe_unused) { @@ -1076,7 +1076,7 @@ static perf_event__swap_op perf_event__swap_ops[] =3D= { * Flush every events below timestamp 7 * etc... */ -int perf_event__process_finished_round(struct perf_tool *tool __maybe_unus= ed, +int perf_event__process_finished_round(const struct perf_tool *tool __mayb= e_unused, union perf_event *event __maybe_unused, struct ordered_events *oe) { @@ -1470,7 +1470,7 @@ static struct machine *machines__find_for_cpumode(str= uct machines *machines, } =20 static int deliver_sample_value(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct sample_read_value *v, @@ -1502,7 +1502,7 @@ static int deliver_sample_value(struct evlist *evlist, } =20 static int deliver_sample_group(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine, @@ -1521,7 +1521,7 @@ static int deliver_sample_group(struct evlist *evlist, return ret; } =20 -static int evlist__deliver_sample(struct evlist *evlist, struct perf_tool = *tool, +static int evlist__deliver_sample(struct evlist *evlist, const struct perf= _tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine) { @@ -1546,7 +1546,7 @@ static int machines__deliver_event(struct machines *m= achines, struct evlist *evlist, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool, u64 file_offset, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { struct evsel *evsel; @@ -1634,7 +1634,7 @@ static int machines__deliver_event(struct machines *m= achines, =20 static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { @@ -1667,7 +1667,7 @@ static s64 perf_session__process_user_event(struct pe= rf_session *session, const char *file_path) { struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_sample sample =3D { .time =3D 0, }; int fd =3D perf_data__fd(session->data); int err; @@ -1754,7 +1754,7 @@ int perf_session__deliver_synth_event(struct perf_ses= sion *session, struct perf_sample *sample) { struct evlist *evlist =3D session->evlist; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; =20 events_stats__inc(&evlist->stats, event->header.type); =20 @@ -1862,7 +1862,7 @@ static s64 perf_session__process_event(struct perf_se= ssion *session, const char *file_path) { struct evlist *evlist =3D session->evlist; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; int ret; =20 if (session->header.needs_swap) diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4c29dc86956f..a298de3c85d8 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -160,7 +160,7 @@ int perf_session__dsos_hit_all(struct perf_session *ses= sion); int perf_event__process_id_index(struct perf_session *session, union perf_event *event); =20 -int perf_event__process_finished_round(struct perf_tool *tool, +int perf_event__process_finished_round(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe); =20 diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index 5498048f56ea..7f884d70de81 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0-only=20 +// SPDX-License-Identifier: GPL-2.0-only =20 #include "util/cgroup.h" #include "util/data.h" @@ -47,7 +47,7 @@ =20 unsigned int proc_map_timeout =3D DEFAULT_PROC_MAP_PARSE_TIMEOUT; =20 -int perf_tool__process_synth_event(struct perf_tool *tool, +int perf_tool__process_synth_event(const struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process) @@ -187,7 +187,7 @@ static int perf_event__prepare_comm(union perf_event *e= vent, pid_t pid, pid_t ti return 0; } =20 -pid_t perf_event__synthesize_comm(struct perf_tool *tool, +pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine) @@ -218,7 +218,7 @@ static void perf_event__get_ns_link_info(pid_t pid, con= st char *ns, } } =20 -int perf_event__synthesize_namespaces(struct perf_tool *tool, +int perf_event__synthesize_namespaces(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, @@ -257,7 +257,7 @@ int perf_event__synthesize_namespaces(struct perf_tool = *tool, return 0; } =20 -static int perf_event__synthesize_fork(struct perf_tool *tool, +static int perf_event__synthesize_fork(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, pid_t ppid, perf_event__handler_t process, @@ -418,7 +418,7 @@ static void perf_record_mmap2__read_build_id(struct per= f_record_mmap2 *event, dso__put(dso); } =20 -int perf_event__synthesize_mmap_events(struct perf_tool *tool, +int perf_event__synthesize_mmap_events(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, @@ -542,7 +542,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool= *tool, } =20 #ifdef HAVE_FILE_HANDLE -static int perf_event__synthesize_cgroup(struct perf_tool *tool, +static int perf_event__synthesize_cgroup(const struct perf_tool *tool, union perf_event *event, char *path, size_t mount_len, perf_event__handler_t process, @@ -582,7 +582,7 @@ static int perf_event__synthesize_cgroup(struct perf_to= ol *tool, return 0; } =20 -static int perf_event__walk_cgroup_tree(struct perf_tool *tool, +static int perf_event__walk_cgroup_tree(const struct perf_tool *tool, union perf_event *event, char *path, size_t mount_len, perf_event__handler_t process, @@ -630,7 +630,7 @@ static int perf_event__walk_cgroup_tree(struct perf_too= l *tool, return ret; } =20 -int perf_event__synthesize_cgroups(struct perf_tool *tool, +int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { @@ -657,7 +657,7 @@ int perf_event__synthesize_cgroups(struct perf_tool *to= ol, return 0; } #else -int perf_event__synthesize_cgroups(struct perf_tool *tool __maybe_unused, +int perf_event__synthesize_cgroups(const struct perf_tool *tool __maybe_un= used, perf_event__handler_t process __maybe_unused, struct machine *machine __maybe_unused) { @@ -666,7 +666,7 @@ int perf_event__synthesize_cgroups(struct perf_tool *to= ol __maybe_unused, #endif =20 struct perf_event__synthesize_modules_maps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event; @@ -717,7 +717,7 @@ static int perf_event__synthesize_modules_maps_cb(struc= t map *map, void *data) return 0; } =20 -int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__han= dler_t process, +int perf_event__synthesize_modules(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine) { int rc; @@ -763,7 +763,7 @@ static int __event__synthesize_thread(union perf_event = *comm_event, union perf_event *fork_event, union perf_event *namespaces_event, pid_t pid, int full, perf_event__handler_t process, - struct perf_tool *tool, struct machine *machine, + const struct perf_tool *tool, struct machine *machine, bool needs_mmap, bool mmap_data) { char filename[PATH_MAX]; @@ -852,7 +852,7 @@ static int __event__synthesize_thread(union perf_event = *comm_event, return rc; } =20 -int perf_event__synthesize_thread_map(struct perf_tool *tool, +int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, @@ -929,7 +929,7 @@ int perf_event__synthesize_thread_map(struct perf_tool = *tool, return err; } =20 -static int __perf_event__synthesize_threads(struct perf_tool *tool, +static int __perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, @@ -993,7 +993,7 @@ static int __perf_event__synthesize_threads(struct perf= _tool *tool, } =20 struct synthesize_threads_arg { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; bool needs_mmap; @@ -1015,7 +1015,7 @@ static void *synthesize_threads_worker(void *arg) return NULL; } =20 -int perf_event__synthesize_threads(struct perf_tool *tool, +int perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, @@ -1104,14 +1104,14 @@ int perf_event__synthesize_threads(struct perf_tool= *tool, return err; } =20 -int __weak perf_event__synthesize_extra_kmaps(struct perf_tool *tool __may= be_unused, +int __weak perf_event__synthesize_extra_kmaps(const struct perf_tool *tool= __maybe_unused, perf_event__handler_t process __maybe_unused, struct machine *machine __maybe_unused) { return 0; } =20 -static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool, +static int __perf_event__synthesize_kernel_mmap(const struct perf_tool *to= ol, perf_event__handler_t process, struct machine *machine) { @@ -1183,7 +1183,7 @@ static int __perf_event__synthesize_kernel_mmap(struc= t perf_tool *tool, return err; } =20 -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, +int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { @@ -1196,7 +1196,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_to= ol *tool, return perf_event__synthesize_extra_kmaps(tool, process, machine); } =20 -int perf_event__synthesize_thread_map2(struct perf_tool *tool, +int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine) @@ -1346,7 +1346,7 @@ static struct perf_record_cpu_map *cpu_map_event__new= (const struct perf_cpu_map } =20 =20 -int perf_event__synthesize_cpu_map(struct perf_tool *tool, +int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const struct perf_cpu_map *map, perf_event__handler_t process, struct machine *machine) @@ -1364,7 +1364,7 @@ int perf_event__synthesize_cpu_map(struct perf_tool *= tool, return err; } =20 -int perf_event__synthesize_stat_config(struct perf_tool *tool, +int perf_event__synthesize_stat_config(const struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine) @@ -1403,7 +1403,7 @@ int perf_event__synthesize_stat_config(struct perf_to= ol *tool, return err; } =20 -int perf_event__synthesize_stat(struct perf_tool *tool, +int perf_event__synthesize_stat(const struct perf_tool *tool, struct perf_cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handler_t process, @@ -1425,7 +1425,7 @@ int perf_event__synthesize_stat(struct perf_tool *too= l, return process(tool, (union perf_event *) &event, NULL, machine); } =20 -int perf_event__synthesize_stat_round(struct perf_tool *tool, +int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 evtime, u64 type, perf_event__handler_t process, struct machine *machine) @@ -1826,7 +1826,7 @@ int perf_event__synthesize_id_sample(__u64 *array, u6= 4 type, const struct perf_s return (void *)array - (void *)start; } =20 -int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__= handler_t process, +int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_e= vent__handler_t process, struct evlist *evlist, struct machine *machine, size_t from) { union perf_event *ev; @@ -1918,13 +1918,13 @@ int __perf_event__synthesize_id_index(struct perf_t= ool *tool, perf_event__handle return err; } =20 -int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__ha= ndler_t process, +int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_eve= nt__handler_t process, struct evlist *evlist, struct machine *machine) { return __perf_event__synthesize_id_index(tool, process, evlist, machine, = 0); } =20 -int __machine__synthesize_threads(struct machine *machine, struct perf_too= l *tool, +int __machine__synthesize_threads(struct machine *machine, const struct pe= rf_tool *tool, struct target *target, struct perf_thread_map *threads, perf_event__handler_t process, bool needs_mmap, bool data_mmap, unsigned int nr_threads_synthesize) @@ -1985,7 +1985,7 @@ static struct perf_record_event_update *event_update_= event__new(size_t size, u64 return ev; } =20 -int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_unit(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { size_t size =3D strlen(evsel->unit); @@ -2002,7 +2002,7 @@ int perf_event__synthesize_event_update_unit(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_event_update_scale(struct perf_tool *tool, stru= ct evsel *evsel, +int perf_event__synthesize_event_update_scale(const struct perf_tool *tool= , struct evsel *evsel, perf_event__handler_t process) { struct perf_record_event_update *ev; @@ -2019,7 +2019,7 @@ int perf_event__synthesize_event_update_scale(struct = perf_tool *tool, struct evs return err; } =20 -int perf_event__synthesize_event_update_name(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_name(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { struct perf_record_event_update *ev; @@ -2036,7 +2036,7 @@ int perf_event__synthesize_event_update_name(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { struct synthesize_cpu_map_data syn_data =3D { .map =3D evsel->core.own_cp= us }; @@ -2059,7 +2059,7 @@ int perf_event__synthesize_event_update_cpus(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *ev= list, +int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evli= st *evlist, perf_event__handler_t process) { struct evsel *evsel; @@ -2087,7 +2087,7 @@ static bool has_scale(struct evsel *evsel) return evsel->scale !=3D 1; } =20 -int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlis= t *evsel_list, +int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct= evlist *evsel_list, perf_event__handler_t process, bool is_pipe) { struct evsel *evsel; @@ -2143,7 +2143,7 @@ int perf_event__synthesize_extra_attr(struct perf_too= l *tool, struct evlist *evs return 0; } =20 -int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_= attr *attr, +int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_= event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process) { union perf_event *ev; @@ -2177,7 +2177,7 @@ int perf_event__synthesize_attr(struct perf_tool *too= l, struct perf_event_attr * } =20 #ifdef HAVE_LIBTRACEEVENT -int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, st= ruct evlist *evlist, +int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int = fd, struct evlist *evlist, perf_event__handler_t process) { union perf_event ev; @@ -2225,7 +2225,7 @@ int perf_event__synthesize_tracing_data(struct perf_t= ool *tool, int fd, struct e } #endif =20 -int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *po= s, u16 misc, +int perf_event__synthesize_build_id(const struct perf_tool *tool, struct d= so *pos, u16 misc, perf_event__handler_t process, struct machine *machine) { union perf_event ev; @@ -2249,7 +2249,7 @@ int perf_event__synthesize_build_id(struct perf_tool = *tool, struct dso *pos, u16 return process(tool, &ev, NULL, machine); } =20 -int perf_event__synthesize_stat_events(struct perf_stat_config *config, st= ruct perf_tool *tool, +int perf_event__synthesize_stat_events(struct perf_stat_config *config, co= nst struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attr= s) { int err; @@ -2286,7 +2286,7 @@ int perf_event__synthesize_stat_events(struct perf_st= at_config *config, struct p =20 extern const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE]; =20 -int perf_event__synthesize_features(struct perf_tool *tool, struct perf_se= ssion *session, +int perf_event__synthesize_features(const struct perf_tool *tool, struct p= erf_session *session, struct evlist *evlist, perf_event__handler_t process) { struct perf_header *header =3D &session->header; @@ -2349,7 +2349,7 @@ int perf_event__synthesize_features(struct perf_tool = *tool, struct perf_session return ret; } =20 -int perf_event__synthesize_for_pipe(struct perf_tool *tool, +int perf_event__synthesize_for_pipe(const struct perf_tool *tool, struct perf_session *session, struct perf_data *data, perf_event__handler_t process) diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic= -events.h index 53737d1619a4..31df7653677f 100644 --- a/tools/perf/util/synthetic-events.h +++ b/tools/perf/util/synthetic-events.h @@ -40,45 +40,45 @@ enum perf_record_synth { =20 int parse_synth_opt(char *str); =20 -typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_ev= ent *event, +typedef int (*perf_event__handler_t)(const struct perf_tool *tool, union p= erf_event *event, struct perf_sample *sample, struct machine *machine); =20 -int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *ev= list, perf_event__handler_t process); -int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_= attr *attr, u32 ids, u64 *id, perf_event__handler_t process); -int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *po= s, u16 misc, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct pe= rf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_name(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_scale(struct perf_tool *tool, stru= ct evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlis= t *evsel_list, perf_event__handler_t process, bool is_pipe); -int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event_= _handler_t process, struct machine *machine); -int perf_event__synthesize_features(struct perf_tool *tool, struct perf_se= ssion *session, struct evlist *evlist, perf_event__handler_t process); -int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__ha= ndler_t process, struct evlist *evlist, struct machine *machine); -int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__= handler_t process, struct evlist *evlist, struct machine *machine, size_t f= rom); +int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evli= st *evlist, perf_event__handler_t process); +int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_= event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process); +int perf_event__synthesize_build_id(const struct perf_tool *tool, struct d= so *pos, u16 misc, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const str= uct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *mach= ine); +int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_name(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_scale(const struct perf_tool *tool= , struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_unit(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct= evlist *evsel_list, perf_event__handler_t process, bool is_pipe); +int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_= event__handler_t process, struct machine *machine); +int perf_event__synthesize_features(const struct perf_tool *tool, struct p= erf_session *session, struct evlist *evlist, perf_event__handler_t process); +int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_eve= nt__handler_t process, struct evlist *evlist, struct machine *machine); +int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_e= vent__handler_t process, struct evlist *evlist, struct machine *machine, si= ze_t from); int perf_event__synthesize_id_sample(__u64 *array, u64 type, const struct = perf_sample *sample); -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event_= _handler_t process, struct machine *machine); -int perf_event__synthesize_mmap_events(struct perf_tool *tool, union perf_= event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct = machine *machine, bool mmap_data); -int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine); -int perf_event__synthesize_namespaces(struct perf_tool *tool, union perf_e= vent *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct m= achine *machine); -int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine); +int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_= event__handler_t process, struct machine *machine); +int perf_event__synthesize_mmap_events(const struct perf_tool *tool, union= perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, s= truct machine *machine, bool mmap_data); +int perf_event__synthesize_modules(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine); +int perf_event__synthesize_namespaces(const struct perf_tool *tool, union = perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, st= ruct machine *machine); +int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine); int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 r= ead_format, const struct perf_sample *sample); -int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf= _stat_config *config, perf_event__handler_t process, struct machine *machin= e); -int perf_event__synthesize_stat_events(struct perf_stat_config *config, st= ruct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process,= bool attrs); -int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u6= 4 type, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_stat(struct perf_tool *tool, struct perf_cpu cp= u, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handle= r_t process, struct machine *machine); -int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf= _thread_map *threads, perf_event__handler_t process, struct machine *machin= e); -int perf_event__synthesize_thread_map(struct perf_tool *tool, struct perf_= thread_map *threads, perf_event__handler_t process, struct machine *machine= , bool needs_mmap, bool mmap_data); -int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, u= nsigned int nr_threads_synthesize); -int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, st= ruct evlist *evlist, perf_event__handler_t process); -int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, str= uct perf_tool *tool, perf_event__handler_t process, struct machine *machine= ); -pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event= *event, pid_t pid, perf_event__handler_t process, struct machine *machine); - -int perf_tool__process_synth_event(struct perf_tool *tool, union perf_even= t *event, struct machine *machine, perf_event__handler_t process); +int perf_event__synthesize_stat_config(const struct perf_tool *tool, struc= t perf_stat_config *config, perf_event__handler_t process, struct machine *= machine); +int perf_event__synthesize_stat_events(struct perf_stat_config *config, co= nst struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t pr= ocess, bool attrs); +int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 ti= me, u64 type, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_stat(const struct perf_tool *tool, struct perf_= cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__= handler_t process, struct machine *machine); +int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struc= t perf_thread_map *threads, perf_event__handler_t process, struct machine *= machine); +int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct= perf_thread_map *threads, perf_event__handler_t process, struct machine *m= achine, bool needs_mmap, bool mmap_data); +int perf_event__synthesize_threads(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_d= ata, unsigned int nr_threads_synthesize); +int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int = fd, struct evlist *evlist, perf_event__handler_t process); +int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, con= st struct perf_tool *tool, perf_event__handler_t process, struct machine *m= achine); +pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf= _event *event, pid_t pid, perf_event__handler_t process, struct machine *ma= chine); + +int perf_tool__process_synth_event(const struct perf_tool *tool, union per= f_event *event, struct machine *machine, perf_event__handler_t process); =20 size_t perf_event__sample_event_size(const struct perf_sample *sample, u64= type, u64 read_format); =20 -int __machine__synthesize_threads(struct machine *machine, struct perf_too= l *tool, +int __machine__synthesize_threads(struct machine *machine, const struct pe= rf_tool *tool, struct target *target, struct perf_thread_map *threads, perf_event__handler_t process, bool needs_mmap, bool data_mmap, unsigned int nr_threads_synthesize); @@ -87,7 +87,7 @@ int machine__synthesize_threads(struct machine *machine, = struct target *target, unsigned int nr_threads_synthesize); =20 #ifdef HAVE_AUXTRACE_SUPPORT -int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, stru= ct perf_tool *tool, +int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, cons= t struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process); =20 #else // HAVE_AUXTRACE_SUPPORT @@ -96,7 +96,7 @@ int perf_event__synthesize_auxtrace_info(struct auxtrace_= record *itr, struct per =20 static inline int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_u= nused, - struct perf_tool *tool __maybe_unused, + const struct perf_tool *tool __maybe_unused, struct perf_session *session __maybe_unused, perf_event__handler_t process __maybe_unused) { @@ -117,7 +117,7 @@ static inline int perf_event__synthesize_bpf_events(str= uct perf_session *session } #endif // HAVE_LIBBPF_SUPPORT =20 -int perf_event__synthesize_for_pipe(struct perf_tool *tool, +int perf_event__synthesize_for_pipe(const struct perf_tool *tool, struct perf_session *session, struct perf_data *data, perf_event__handler_t process); diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index c957fb849ac6..b192d44fe91f 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -15,14 +15,14 @@ struct perf_tool; struct machine; struct ordered_events; =20 -typedef int (*event_sample)(struct perf_tool *tool, union perf_event *even= t, +typedef int (*event_sample)(const struct perf_tool *tool, union perf_event= *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -typedef int (*event_op)(struct perf_tool *tool, union perf_event *event, +typedef int (*event_op)(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample, struct machine *machine); =20 -typedef int (*event_attr_op)(struct perf_tool *tool, +typedef int (*event_attr_op)(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); =20 @@ -31,7 +31,7 @@ typedef s64 (*event_op3)(struct perf_session *session, un= ion perf_event *event); typedef int (*event_op4)(struct perf_session *session, union perf_event *e= vent, u64 data, const char *str); =20 -typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event, +typedef int (*event_oe)(const struct perf_tool *tool, union perf_event *ev= ent, struct ordered_events *oe); =20 enum show_feature_header { diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index f19791d46e99..2e33a20e1e1b 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c @@ -72,7 +72,7 @@ int perf_read_tsc_conversion(const struct perf_event_mmap= _page *pc, } =20 int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, - struct perf_tool *tool, + const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CBDE194129 for ; Wed, 26 Jun 2024 20:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434212; cv=none; b=XOvSTlbeoQK9/gZeyGQ9WSFYuOwvyPN/9zxVCpE0Uws6QeRNBImMGXUoH57XD2NspguFQi6Jh8wx1Cl83cRRKS4GWhu85ZrZtSwclBlBbxsASEDC8ssd5dONPTsBAvJkm2NTOjiUw2lXZLNm3wMeBsXI+cdvr5ym3OtL+OdtQfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434212; c=relaxed/simple; bh=VKK1AIjHXi4a9HW1orZ4Igmv/qCmECDTDbqF8i0o/hw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=TcSAJun7X+Yk2v1cfHwx29+/rc3To3o2dCE4VS4Y3kTjSD95TqZpnMfqStrg+tLPJp6i1/e8bPmxxFmTj5s8F7bCfgzmLTmc8xpPHyhyWulZsoyJNtrpGlOSheWaCleu7ygrAB9wqS8/N4mFZd3aP0sdtZjMDz7hPMdmnRxKqZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Ojt/3QI8; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ojt/3QI8" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62f43c95de4so160211587b3.3 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=vger.kernel.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=Ojt/3QI86RK8ZgFJYPj3+XWSQn/+KeHiCxnhXnhA92Pnng4nZNAfJD2EcnOybKOpcP 2REkg5HKDP+7oP11XC9mDwkiWQM7B0sYPOGj/YaxPpdSHXnOBQJQbslFanFRKBEWwtt0 8nzZarBLkkkOhmNpM/Z2oXmvicCO/yCylqzR4eGWYuk/YuWZ07Ktcc9N2ek/zlNK16j7 mvk5F/RLvrbVxxsre7eddeID1lGxfc2z3pU5b+/vprTWFbOBjqGwIU4b9rclXnUP1AYy +EFYQh0DrZSC1w5a7FTue2m/OJ/CS9EXBm5+C8BKkXBjahV5im/gfYSaWqUN1vAPAtyY bQLA== 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=N0V4E3V8tNR3F8+9uvXJl1HV5YeG+PYxhNO7QZ5H2IMuRuRRuLFjHvu6Ct+gHzc2TN 6FXXGqXaw1o7mKTi/GG2Lh6DllSgrwQFPiswDrT2doOhxJOnHtk8gT/ciQjJF4ly1G40 6g3cVmqOoCdsV0DmLwM0WHyP8AJg9xj6dW9bgvOhdxZwWW0xpF0ow8xjX8Q1tOAG3xCJ O7Bd/9lTBWpjjmr212gZHsAET+rLFEB9UOR4qVyTqZzLbFm5LgrrwtdhPGiS3Ei1cM6l v/KpayoOe+a55hSxTOfjq9qZ14U6mhiNvZmJyKTOAPp8u5KeAmXtqKidB1pguHcdhF7P xIbQ== X-Forwarded-Encrypted: i=1; AJvYcCU+q0cal1kbAehi15jmklhGrwYwOWxcggklPZrAAcrlyVXxRzQs30CG6y52rjB3JPwSvxouVp9fpPlIGblvgxGtwrusr9Ckrtj4rXBI X-Gm-Message-State: AOJu0Yw5PJ7UtsoDc+VFBquRyyP1qc5/dFbVz4y6KEsBeAH/2cwHASdD Rz8hP1j0aQRjfUNCNMykrg5k6PNKvV3C/DQKV3edvWJlUkNwzk5k15u7MZfq9vBITTTtjNEH/r2 Hwo/bWw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 +=3D map.o perf-y +=3D maps.o perf-y +=3D pstack.o perf-y +=3D session.o +perf-y +=3D tool.o perf-y +=3D sample-raw.o perf-y +=3D s390-sample-raw.o perf-y +=3D 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 =20 -#ifdef HAVE_ZSTD_SUPPORT -static int perf_session__process_compressed_event(struct perf_session *ses= sion, - union perf_event *event, u64 file_offset, - const char *file_path) -{ - void *src; - size_t decomp_size, src_size; - u64 decomp_last_rem =3D 0; - size_t mmap_len, decomp_len =3D session->header.env.comp_mmap_len; - struct decomp *decomp, *decomp_last =3D session->active_decomp->decomp_la= st; - - if (decomp_last) { - decomp_last_rem =3D decomp_last->size - decomp_last->head; - decomp_len +=3D decomp_last_rem; - } - - mmap_len =3D sizeof(struct decomp) + decomp_len; - decomp =3D mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); - if (decomp =3D=3D MAP_FAILED) { - pr_err("Couldn't allocate memory for decompression\n"); - return -1; - } - - decomp->file_pos =3D file_offset; - decomp->file_path =3D file_path; - decomp->mmap_len =3D mmap_len; - decomp->head =3D 0; - - if (decomp_last_rem) { - memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_las= t_rem); - decomp->size =3D decomp_last_rem; - } - - src =3D (void *)event + sizeof(struct perf_record_compressed); - src_size =3D event->pack.header.size - sizeof(struct perf_record_compress= ed); - - decomp_size =3D zstd_decompress_stream(session->active_decomp->zstd_decom= p, 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 +=3D decomp_size; - - if (session->active_decomp->decomp =3D=3D NULL) - session->active_decomp->decomp =3D decomp; - else - session->active_decomp->decomp_last->next =3D decomp; - - session->active_decomp->decomp_last =3D 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_compr= essed_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 *sessio= n) free(session); } =20 -static int process_event_synth_tracing_data_stub(struct perf_session *sess= ion - __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 __ma= ybe_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 *t= ool __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 __mayb= e_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 =3D read(fd, buf, min(n, (off_t)sizeof(buf))); - if (ret <=3D 0) - return ret; - n -=3D ret; - } - - return 0; -} - -static s64 process_event_auxtrace_stub(struct perf_session *session __mayb= e_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_unu= sed, - union perf_event *event __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - - -static -int process_event_thread_map_stub(struct perf_session *session __maybe_unu= sed, - 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_un= used, - 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_unu= sed, - 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 __may= be_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 =3D=3D NULL) - tool->sample =3D process_event_sample_stub; - if (tool->mmap =3D=3D NULL) - tool->mmap =3D process_event_stub; - if (tool->mmap2 =3D=3D NULL) - tool->mmap2 =3D process_event_stub; - if (tool->comm =3D=3D NULL) - tool->comm =3D process_event_stub; - if (tool->namespaces =3D=3D NULL) - tool->namespaces =3D process_event_stub; - if (tool->cgroup =3D=3D NULL) - tool->cgroup =3D process_event_stub; - if (tool->fork =3D=3D NULL) - tool->fork =3D process_event_stub; - if (tool->exit =3D=3D NULL) - tool->exit =3D process_event_stub; - if (tool->lost =3D=3D NULL) - tool->lost =3D perf_event__process_lost; - if (tool->lost_samples =3D=3D NULL) - tool->lost_samples =3D perf_event__process_lost_samples; - if (tool->aux =3D=3D NULL) - tool->aux =3D perf_event__process_aux; - if (tool->itrace_start =3D=3D NULL) - tool->itrace_start =3D perf_event__process_itrace_start; - if (tool->context_switch =3D=3D NULL) - tool->context_switch =3D perf_event__process_switch; - if (tool->ksymbol =3D=3D NULL) - tool->ksymbol =3D perf_event__process_ksymbol; - if (tool->bpf =3D=3D NULL) - tool->bpf =3D perf_event__process_bpf; - if (tool->text_poke =3D=3D NULL) - tool->text_poke =3D perf_event__process_text_poke; - if (tool->aux_output_hw_id =3D=3D NULL) - tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; - if (tool->read =3D=3D NULL) - tool->read =3D process_event_sample_stub; - if (tool->throttle =3D=3D NULL) - tool->throttle =3D process_event_stub; - if (tool->unthrottle =3D=3D NULL) - tool->unthrottle =3D process_event_stub; - if (tool->attr =3D=3D NULL) - tool->attr =3D process_event_synth_attr_stub; - if (tool->event_update =3D=3D NULL) - tool->event_update =3D process_event_synth_event_update_stub; - if (tool->tracing_data =3D=3D NULL) - tool->tracing_data =3D process_event_synth_tracing_data_stub; - if (tool->build_id =3D=3D NULL) - tool->build_id =3D process_event_op2_stub; - if (tool->finished_round =3D=3D NULL) { - if (tool->ordered_events) - tool->finished_round =3D perf_event__process_finished_round; - else - tool->finished_round =3D process_finished_round_stub; - } - if (tool->id_index =3D=3D NULL) - tool->id_index =3D process_event_op2_stub; - if (tool->auxtrace_info =3D=3D NULL) - tool->auxtrace_info =3D process_event_op2_stub; - if (tool->auxtrace =3D=3D NULL) - tool->auxtrace =3D process_event_auxtrace_stub; - if (tool->auxtrace_error =3D=3D NULL) - tool->auxtrace_error =3D process_event_op2_stub; - if (tool->thread_map =3D=3D NULL) - tool->thread_map =3D process_event_thread_map_stub; - if (tool->cpu_map =3D=3D NULL) - tool->cpu_map =3D process_event_cpu_map_stub; - if (tool->stat_config =3D=3D NULL) - tool->stat_config =3D process_event_stat_config_stub; - if (tool->stat =3D=3D NULL) - tool->stat =3D process_stat_stub; - if (tool->stat_round =3D=3D NULL) - tool->stat_round =3D process_stat_round_stub; - if (tool->time_conv =3D=3D NULL) - tool->time_conv =3D process_event_time_conv_stub; - if (tool->feature =3D=3D NULL) - tool->feature =3D process_event_op2_stub; - if (tool->compressed =3D=3D NULL) - tool->compressed =3D perf_session__process_compressed_event; - if (tool->finished_init =3D=3D NULL) - tool->finished_init =3D process_event_op2_stub; -} - static void swap_sample_id_all(union perf_event *event, void *data) { void *end =3D (void *) event + event->header.size; @@ -1672,8 +1365,7 @@ static s64 perf_session__process_user_event(struct pe= rf_session *session, int fd =3D perf_data__fd(session->data); int err; =20 - if (event->header.type !=3D PERF_RECORD_COMPRESSED || - tool->compressed =3D=3D perf_session__process_compressed_event_stub) + if (event->header.type !=3D PERF_RECORD_COMPRESSED || perf_tool__compress= ed_is_stub(tool)) dump_event(session->evlist, event, file_offset, &sample, file_path); =20 /* 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 *ses= sion); int perf_session__queue_event(struct perf_session *s, union perf_event *ev= ent, u64 timestamp, u64 file_offset, const char *file_path); =20 -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 *ses= sion, + union perf_event *event, u64 file_offset, + const char *file_path) +{ + void *src; + size_t decomp_size, src_size; + u64 decomp_last_rem =3D 0; + size_t mmap_len, decomp_len =3D session->header.env.comp_mmap_len; + struct decomp *decomp, *decomp_last =3D session->active_decomp->decomp_la= st; + + if (decomp_last) { + decomp_last_rem =3D decomp_last->size - decomp_last->head; + decomp_len +=3D decomp_last_rem; + } + + mmap_len =3D sizeof(struct decomp) + decomp_len; + decomp =3D mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (decomp =3D=3D MAP_FAILED) { + pr_err("Couldn't allocate memory for decompression\n"); + return -1; + } + + decomp->file_pos =3D file_offset; + decomp->file_path =3D file_path; + decomp->mmap_len =3D mmap_len; + decomp->head =3D 0; + + if (decomp_last_rem) { + memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_las= t_rem); + decomp->size =3D decomp_last_rem; + } + + src =3D (void *)event + sizeof(struct perf_record_compressed); + src_size =3D event->pack.header.size - sizeof(struct perf_record_compress= ed); + + decomp_size =3D zstd_decompress_stream(session->active_decomp->zstd_decom= p, 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 +=3D decomp_size; + + if (session->active_decomp->decomp =3D=3D NULL) + session->active_decomp->decomp =3D decomp; + else + session->active_decomp->decomp_last->next =3D decomp; + + session->active_decomp->decomp_last =3D 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 *sess= ion + __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 __ma= ybe_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 *t= ool __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 __mayb= e_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 =3D read(fd, buf, min(n, (off_t)sizeof(buf))); + if (ret <=3D 0) + return ret; + n -=3D ret; + } + + return 0; +} + +static s64 process_event_auxtrace_stub(struct perf_session *session __mayb= e_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_unu= sed, + union perf_event *event __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + + +static +int process_event_thread_map_stub(struct perf_session *session __maybe_unu= sed, + 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_un= used, + 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_unu= sed, + 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 __may= be_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 =3D=3D NULL) + tool->sample =3D process_event_sample_stub; + if (tool->mmap =3D=3D NULL) + tool->mmap =3D process_event_stub; + if (tool->mmap2 =3D=3D NULL) + tool->mmap2 =3D process_event_stub; + if (tool->comm =3D=3D NULL) + tool->comm =3D process_event_stub; + if (tool->namespaces =3D=3D NULL) + tool->namespaces =3D process_event_stub; + if (tool->cgroup =3D=3D NULL) + tool->cgroup =3D process_event_stub; + if (tool->fork =3D=3D NULL) + tool->fork =3D process_event_stub; + if (tool->exit =3D=3D NULL) + tool->exit =3D process_event_stub; + if (tool->lost =3D=3D NULL) + tool->lost =3D perf_event__process_lost; + if (tool->lost_samples =3D=3D NULL) + tool->lost_samples =3D perf_event__process_lost_samples; + if (tool->aux =3D=3D NULL) + tool->aux =3D perf_event__process_aux; + if (tool->itrace_start =3D=3D NULL) + tool->itrace_start =3D perf_event__process_itrace_start; + if (tool->context_switch =3D=3D NULL) + tool->context_switch =3D perf_event__process_switch; + if (tool->ksymbol =3D=3D NULL) + tool->ksymbol =3D perf_event__process_ksymbol; + if (tool->bpf =3D=3D NULL) + tool->bpf =3D perf_event__process_bpf; + if (tool->text_poke =3D=3D NULL) + tool->text_poke =3D perf_event__process_text_poke; + if (tool->aux_output_hw_id =3D=3D NULL) + tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; + if (tool->read =3D=3D NULL) + tool->read =3D process_event_sample_stub; + if (tool->throttle =3D=3D NULL) + tool->throttle =3D process_event_stub; + if (tool->unthrottle =3D=3D NULL) + tool->unthrottle =3D process_event_stub; + if (tool->attr =3D=3D NULL) + tool->attr =3D process_event_synth_attr_stub; + if (tool->event_update =3D=3D NULL) + tool->event_update =3D process_event_synth_event_update_stub; + if (tool->tracing_data =3D=3D NULL) + tool->tracing_data =3D process_event_synth_tracing_data_stub; + if (tool->build_id =3D=3D NULL) + tool->build_id =3D process_event_op2_stub; + if (tool->finished_round =3D=3D NULL) { + if (tool->ordered_events) + tool->finished_round =3D perf_event__process_finished_round; + else + tool->finished_round =3D process_finished_round_stub; + } + if (tool->id_index =3D=3D NULL) + tool->id_index =3D process_event_op2_stub; + if (tool->auxtrace_info =3D=3D NULL) + tool->auxtrace_info =3D process_event_op2_stub; + if (tool->auxtrace =3D=3D NULL) + tool->auxtrace =3D process_event_auxtrace_stub; + if (tool->auxtrace_error =3D=3D NULL) + tool->auxtrace_error =3D process_event_op2_stub; + if (tool->thread_map =3D=3D NULL) + tool->thread_map =3D process_event_thread_map_stub; + if (tool->cpu_map =3D=3D NULL) + tool->cpu_map =3D process_event_cpu_map_stub; + if (tool->stat_config =3D=3D NULL) + tool->stat_config =3D process_event_stat_config_stub; + if (tool->stat =3D=3D NULL) + tool->stat =3D process_stat_stub; + if (tool->stat_round =3D=3D NULL) + tool->stat_round =3D process_stat_round_stub; + if (tool->time_conv =3D=3D NULL) + tool->time_conv =3D process_event_time_conv_stub; + if (tool->feature =3D=3D NULL) + tool->feature =3D process_event_op2_stub; + if (tool->compressed =3D=3D NULL) { +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed =3D perf_session__process_compressed_event; +#else + tool->compressed =3D perf_session__process_compressed_event_stub; +#endif + } + if (tool->finished_init =3D=3D NULL) + tool->finished_init =3D process_event_op2_stub; +} + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool) +{ + return tool->compressed =3D=3D perf_session__process_compressed_event_stu= b; +} 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; }; =20 +void perf_tool__fill_defaults(struct perf_tool *tool); + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool); + #endif /* __PERF_TOOL_H */ --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2E4E193061 for ; Wed, 26 Jun 2024 20:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434213; cv=none; b=scV/R6BmpskEDqKvQ+h71QpuYLxWGQYzJbIfoWFVjSLkXpuvKw5FiW6Crbpm3elj8Z5FMr5ldvOdwCpKmKjYNDTvCTTiC70qp2jK7FWSZrNipPOTwBThJw732S0Tig9sTWztPDoZXPl+9lv7pCjeSs/Cz4iCoZNIB90vqXhoflc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434213; c=relaxed/simple; bh=0aVHJrC08XhbCG4RutjMTYNM2P5O2raGsxoyhdcFWYM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=kb1UlYsJ+spTnhjxp0ueUDevKBaJNgaY7t5iF9XbL0Falc7wD4kAXsiq+2deL5zKJLtFtZKBaw2ykr0j7qfiTZeaDHkcgI0/3QdNSln7ILBfmu2v8Lax7I5L/X8Oa/hjJtAPpJdf7ZE4xyl3iKNsgw/1SJim+jSMxX2FxlQdyMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=g68d2k08; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="g68d2k08" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dfe4f388d33so15128423276.2 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=vger.kernel.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=g68d2k08wLKCiAVA2EbKSanwRlGf3uWpplqRU32d2aizqzDl+O6P5Js9quWWcmRafh j/BRdRl7nHIiJ7dQjvnT0a7Zu0C6p4XLWUQ1pIoSp1AgXsRZEwMnv1Ip7lz4Hlo9rCT+ SRisur0NMDRhG2Fegh6aXSvN/zhCen57GBSQTiZX5u0/ZrnUjVVLFI5kyY7MaXctaaoC eGmhGoAtCjxsOE+6z7dgNGjiSXWmUg0dVT8wPL5KYVwYq8j3eqJF04bxnyVbjBDaJNy0 SJPCx7kJ/tQw/AmvvDLqZMvzYYXlmAxm5gxroQbFpavqh4hK4w02bTelOAuKpGzSDAPr 8RtA== 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=Pe9Mj/rXWQ4Z/qOhYr6wYfcSKCH83cZ3zThP7mSEuBgcLfzN2CPhVbnj3Q1cYijh74 7Ao1twLl0+PXPxP5L+e9JTdvBGRHb0qWZqiPccFmnUryZKKDFPKwgt2KNmp20+g1XtrJ cieu+9+x3HKZkdCP8kPClrRg6QTgJ+6FKcHzTE5t7JDF1pbduBoUWqeyshzogaKaqH5a /GeGKLMvuxsuLOS7ispvi1K8/NuLyMaMRdPd7JUjZP7AtEjt7YzfEnTUtQeValvozzFP 4t9/qxgfC3ioftoeJn9+rrWsZ2UpAh6HSGZ3KyqoSvmy7dRWxFQOwXTeV5ZJzr8vAwVi Uh+g== X-Forwarded-Encrypted: i=1; AJvYcCUxcJQ9oNPLKfXyKXdebf639hieK5OFy03lyZ0K3xQMztC21G7DlkU2apmvYWj6k7qYuJJXw6wBcQBk+2p1kc+jX32Y9D9FER4/dBJm X-Gm-Message-State: AOJu0YzhBlDOZ3UPQaFVTh77aDXIPkpids+5v/yO3gdmXLZmNMbnx46O f8RlSFhmlSl78fBStH9tnoyhF0zNTipMVrob5bjZxlHxafMHQaG5BwRSKMArTWMXhKACr2cxzYn 1MBrRFg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; } =20 +void perf_tool__init(struct perf_tool *tool, bool ordered_events) +{ + tool->ordered_events =3D ordered_events; + tool->ordering_requires_timestamps =3D false; + tool->namespace_events =3D false; + tool->cgroup_events =3D false; + tool->no_warn =3D false; + tool->show_feat_hdr =3D SHOW_FEAT_NO_HEADER; + + tool->sample =3D process_event_sample_stub; + tool->mmap =3D process_event_stub; + tool->mmap2 =3D process_event_stub; + tool->comm =3D process_event_stub; + tool->namespaces =3D process_event_stub; + tool->cgroup =3D process_event_stub; + tool->fork =3D process_event_stub; + tool->exit =3D process_event_stub; + tool->lost =3D perf_event__process_lost; + tool->lost_samples =3D perf_event__process_lost_samples; + tool->aux =3D perf_event__process_aux; + tool->itrace_start =3D perf_event__process_itrace_start; + tool->context_switch =3D perf_event__process_switch; + tool->ksymbol =3D perf_event__process_ksymbol; + tool->bpf =3D perf_event__process_bpf; + tool->text_poke =3D perf_event__process_text_poke; + tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; + tool->read =3D process_event_sample_stub; + tool->throttle =3D process_event_stub; + tool->unthrottle =3D process_event_stub; + tool->attr =3D process_event_synth_attr_stub; + tool->event_update =3D process_event_synth_event_update_stub; + tool->tracing_data =3D process_event_synth_tracing_data_stub; + tool->build_id =3D process_event_op2_stub; + + if (ordered_events) + tool->finished_round =3D perf_event__process_finished_round; + else + tool->finished_round =3D process_finished_round_stub; + + tool->id_index =3D process_event_op2_stub; + tool->auxtrace_info =3D process_event_op2_stub; + tool->auxtrace =3D process_event_auxtrace_stub; + tool->auxtrace_error =3D process_event_op2_stub; + tool->thread_map =3D process_event_thread_map_stub; + tool->cpu_map =3D process_event_cpu_map_stub; + tool->stat_config =3D process_event_stat_config_stub; + tool->stat =3D process_stat_stub; + tool->stat_round =3D process_stat_round_stub; + tool->time_conv =3D process_event_time_conv_stub; + tool->feature =3D process_event_op2_stub; +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed =3D perf_session__process_compressed_event; +#else + tool->compressed =3D perf_session__process_compressed_event_stub; +#endif + tool->finished_init =3D process_event_op2_stub; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool->sample =3D=3D 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; }; =20 +void perf_tool__init(struct perf_tool *tool, bool ordered_events); void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 461A819413E for ; Wed, 26 Jun 2024 20:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434216; cv=none; b=LfbOxwvOK/09qVbrDA3Qpva/HvZGpK2bQsSedk73WxMqsTea9Ix5VbzkIpxqZOBUIIeV36zxkLGiCREh5f45VfpcWjBBtxWXqF7EBUOKcP3OJdHPyYoJQkyW6u6G/tEfDEtEgiy/dBN8DgQa4V8pxoOcUUPxEPSFRupIGZIUoVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434216; c=relaxed/simple; bh=tz6IrydlIAL03yTzezHDaA3gvT5YEyeJ8FoCdimUD7E=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=aBMEZuewp5nM0PSX9PvZbRgZQHIJmNdxrYV6IjmI+SUkpXnbtbV94aXRk5Y+XQgIWX2dy3QX1+ckV/R/Ramq7cHdYRMbG8tngyFuLobTOJfJ/ReGP+LoWeV/Be+AluKLma+kgHe7gFYCs0ijXUua6LNnjD1j31DUhqvbMC8ns+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uEYXZzYh; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uEYXZzYh" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfeff1ae480so13556522276.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=vger.kernel.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=uEYXZzYhIJqWThqjDNjKRSpZ0YCkfJv9TFN3CXDVWHRBc1zLFcTJ9eQTtVVyrdOyhu gvJwLWUox09sW3kshN7GZTu3z6Av7+ozg/HzXudw4Z9dmP/eBwQ57pszLRG/VdRdzE2V XPv8SASHY863xmgVq107B+O/Osp93ktYIhjPY0XYwByw7X5HSuUhY9rEwbyvN9zXtO+Z O2B9lURYSJTQKFayAxB3yPtDZyHeqWuqJUzg10eSQerUWfLVvfDC0UnHP7o+LCcuGTeV iUh3SAQ3rLzQwKUyGwhOj40TQjm73zQ5BtC1W9oNnX698iR8FnhNH35K90mpIfOlYvNr gEjQ== 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=f/r/R+w3W6OdGEPOZzO07daMkcJN1byRXLfYdzpVBkosMWXU3XMqMnfFF7z25rqQ3s MSDhAYo9nv0FQpNpLDIoFyjc3GaHBeil8zmpk35GTGN2nBi5la+knbAgH+8jzSbsvf2Y 9EgT1GsaIJwH9nYffa8UloK/qqdwNgXmBeNVQltAa2UlveRyvZ/vXiPiXcVH+MFlDRFH d3taOQP0Xefc+ayuyy/IUcS5JBohEOSEc4JebjM+ErLbq76gv27JxOzrUDI7O+8bROC7 NqFgvSZsYsBQRGN9qPHadFN5J1xwKRCLqhhPi2ElcdABUoYIPz6Q55r6ybUbofWxNJ6w NsuQ== X-Forwarded-Encrypted: i=1; AJvYcCWJXMr++/g8/J87N7IAu89K5DRKjsc1X/nqB0oM8HZM/BiP+VuEn780lkF8f0sDOxQ1cMqb7WaYsMqzDVI6rSz/FKxiMDAJWFKlNx9j X-Gm-Message-State: AOJu0YwoRx4Q4MddsIScWfOUFynwuDiR5miipRvZN1fDS/2YP6vunKQ+ JCwfWxQjwwsPpqBK5X8+1nbXpppOkok+OsmoAT/Xt0lVF1FSNEX9Vj6ggVLg2/evIo/TW2oDGXD At3l9kQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; } =20 -static struct perf_tool perf_kmem =3D { - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, -}; - static double fragmentation(unsigned long n_req, unsigned long n_alloc) { if (n_alloc =3D=3D 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[] =3D "No %s allocation events found. Have you = run 'perf kmem record --%s'?\n"; int ret =3D perf_config(kmem_config, NULL); =20 @@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) =20 data.path =3D input_name; =20 + perf_tool__init(&perf_kmem, /*ordered_events=3D*/true); + perf_kmem.sample =3D process_sample_event; + perf_kmem.comm =3D perf_event__process_comm; + perf_kmem.mmap =3D perf_event__process_mmap; + perf_kmem.mmap2 =3D perf_event__process_mmap2; + perf_kmem.namespaces =3D perf_event__process_namespaces; + kmem_session =3D session =3D perf_session__new(&data, &perf_kmem); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3BA21946A4 for ; Wed, 26 Jun 2024 20:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434217; cv=none; b=A7AJXZON8XOE/EcfYmlWJrFO79xI893kQXHDzTXboF1HcY1dTJvofwzaKZmI2Ex1SAjCP5DQEE/2OXcbFWpD57cweureckZLsJ2K6KxmznYSZ8C+OOj5FfXZRsBCvd2FJRFPvBYKZET0UlclLySLOYoJKqhW0eH74bZkGJQy/fI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434217; c=relaxed/simple; bh=qFwb7pD5p1ottsupqVtJ+t1WOnePId5UkLvj0dZnRLg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NYLwt0bZ+MYk740/bbvmzBIVXkZiSt1+XGRe8UK2akOvVKS6nWUHMUF1yO+fRvykfskaMvIBZwb9O2DQDy4KLwe4q06rMCpipKEvS4hLLzU4Zgy+WYPcBWFQJKAFiwX3vBI3LK3UGVuevvdVbxBw79GBP0SJrC4OkB6AMiYfqMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KRJwz9xJ; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KRJwz9xJ" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-64507372362so92714737b3.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=vger.kernel.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=KRJwz9xJv6tiYWOuLDEmFDxlD1wpEaop/w8kPk1Q5hwtNDguHUYGsEHT4BpzF5BZoo mz+WyFE0cy7uXuJ/OJmzvk4JQ3STSX8BjW1USp8Y12vX1lxgAw+Xpe6h1rEFCn2KB0i5 D85UuHsvX0/tTbE8IR6yRuNCsF2GUCAGWx1jRmnUfkvVY+w/vZ/7pmfYwR6paKOkx1G7 HdZh6Ztn1p9z6Y/pyQ2c+kCZDMGlCEH7vkdaohDiY4IATZ2vbX3QZmDRyYP5VDUl2wWj e3x55peHZx8mG7qDHlrjCPkxFSvQAy584BbCQsUmOuD/9UdTbINp4CXOudEt0wTvgJA4 AA3Q== 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=DYz/+idZ3Y47ZZqvHF4iD+AFCKf3odyqBQ73lEGWc3aGjxDm/megWJGEfQbWvEAdq0 9RoV1gM1Fu9fErVa45thFuc0dBcDW6OpAzsRlEqA8njQU19GlQ/kmZ04yakh4SYynvO3 A3pD3ohC31rxdbVewgVe2EvFTrsvxMtsOY7DtAbtlXakuokSkd6BbDRjib+sS+a2Y4ZZ H/CjFXhViIxGUj3j00AD+EuByOPPb+43Xn/XArCVHNdxSIxQorU9lF1zjf8vKVGJfarn JHOV6KzXXxIjsE63LliTVsNxNMozNT4lsGzQr8cc+vay5sUjtupYJnJSm2r8iiiQPe2J xlLQ== X-Forwarded-Encrypted: i=1; AJvYcCUhcELSmiCm7WsvfNOSgzVKv9VlbKQgcn9bVXzNHUq6qVoVMnPNGoARTX6ny84EDv05axNwRPiSqkH4sgXUIIeQP/E11LuA03R1p5He X-Gm-Message-State: AOJu0YwbLJrpwJXtkLHV+cd9EY/oV/WUux6xQn8r1PFwqAKFm5dCngns BWswBq7eiUYK8vuHYKGlF8jdEnyR7FFA5K34IUvtzXVr9exFOZwUmbjacwlAHuKtIataoVgwfk7 yP6rObw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D PERF_DATA_MODE_READ, .force =3D force, }; + struct perf_tool build_id__mark_dso_hit_ops; =20 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; =20 + perf_tool__init(&build_id__mark_dso_hit_ops, /*ordered_events=3D*/true); + build_id__mark_dso_hit_ops.sample =3D build_id__mark_dso_hit; + build_id__mark_dso_hit_ops.mmap =3D perf_event__process_mmap; + build_id__mark_dso_hit_ops.mmap2 =3D perf_event__process_mmap2; + build_id__mark_dso_hit_ops.fork =3D perf_event__process_fork; + build_id__mark_dso_hit_ops.exit =3D perf_event__exit_del_thread; + build_id__mark_dso_hit_ops.attr =3D perf_event__process_attr; + build_id__mark_dso_hit_ops.build_id =3D perf_event__process_build_id; + session =3D 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; } =20 -static int perf_event__exit_del_thread(const struct perf_tool *tool __mayb= e_unused, - union perf_event *event, - struct perf_sample *sample - __maybe_unused, - struct machine *machine) -{ - struct thread *thread =3D 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 =3D { - .sample =3D build_id__mark_dso_hit, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .fork =3D perf_event__process_fork, - .exit =3D perf_event__exit_del_thread, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, - .ordered_events =3D true, -}; - int build_id__sprintf(const struct build_id *build_id, char *bf) { char *bid =3D 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; }; =20 -struct nsinfo; - -extern struct perf_tool build_id__mark_dso_hit_ops; struct dso; struct feat_fd; +struct nsinfo; =20 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 *t= ool __maybe_unused, return machine__process_exit_event(machine, event, sample); } =20 +int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unuse= d, + union perf_event *event, + struct perf_sample *sample __maybe_unused, + struct machine *machine) +{ + struct thread *thread =3D 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: %#"PR= I_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 *t= ool, 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, --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4298A1946CA for ; Wed, 26 Jun 2024 20:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434219; cv=none; b=glemYNdJEoBy9HI5XFIBpyrWLjhxftvZXCiGUfHssMQuy1kTiHOCj18w89jXX52grs+JW5nNaR0/KilJaKj1OdldlWQYec9GiwPnzd5LhM/GYRJqhfk/R/ABGBdnrB0sr1/0pu0drMUKc0IEPRVAhXyhndw5lbPt+Uy5197eT+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434219; c=relaxed/simple; bh=4f3xu/fTKlsZKLAxp35O5+huY8NAWRnMLMbKlqWg7eI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=U3N5WTMLqL6kzRB5GU/WIkBAsT+3R/TvVwxuC0nZTcHZsjlmCQWCAefPK12PL8JOqAQrVDxXwXlKbhKDtkq60ARsJKKxKex+5VKnvlGFjU6Hr1t0o2qQ58AP7BwYLZBgMmKs2Xc/KMZxZ9FmXR/Vc6ClcfK7Yt46bpsiVH4mqpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=D8nQ9t2K; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="D8nQ9t2K" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-63bab20bf5fso164075377b3.0 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=vger.kernel.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=D8nQ9t2KlplFxvgJ8GJC/4h+pfRCxk+rOQxuOQ+/3ctJfIocoRLgsq6e3L3jR+cqX9 HZpuDmwpaDwHAwvbZgfPmo4CANnfihgoRPN0+mL5JVdMq1nJGkjViHvdMM+O4+QPQeld Uwvd+pPU8e0rcvaFeDO6EnGS1qYzpnnvMaEMW516KLbozmmOXjwrj4unUqc2Wl9LwoqW duLevl4i4NxDmlM1viLqmfuoj+5PDUbpu54rgD9CofkiNnSysPCw7bgfQfUbXEZn/nS6 NBkvfd9o9PGWtSnLf/PR3SrMBgCitghoEfydEIv+/l+tbdX7JlxtwHH1kBQkLRAOER56 XLWg== 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=IyrffJguN9P++sl9LoTZnOiCNERq6mGYGzcXLkrRPsOxsL26hUuQ3BrtM/a0AEA/Tn W/GUUvALDUVyfNX/1q0Treh5kQqvW1o6zb3QVieM+aby3pX0cnFma8mQvJmgNj7wrLPh yCg2VG5ZaAYB9Eo8hRra/xc7ht34s6dE0HQe7+Lb2n+Tf2RRbx+rtGyq5A1JKcAnvbvn FlSrJkmchV/aP0o+lylobUK/mS3QPHdS/bLT3/UzGkbzcXy9mueHGeGK8KcGWrXmb4G2 i0z45QGHvO+K6bBawivBVL/YYrmuafZMWLlM8YJAYkJ1ltD6g29w+WCbFVn3zB1CiXCS M+tA== X-Forwarded-Encrypted: i=1; AJvYcCWsQBPxhZ3oineGqY89upw5o36OWVxv/aeSrD8m39bZy3poc8rJSnrq2bvcsdJt2gxuU4vga6jX/cFlwkLoiFXPK5RSq3x15nvpxkiC X-Gm-Message-State: AOJu0Yw4FFpV2LH1I7lXe0KcLx0WOaaIK9vf7i7w9qdu+1dDcNxLpCYu AYpLoXPiIBd5Nl0TsIZZp9GlSvDpGtdvYWKDLwFMA9AEf3bIWVK4f2t31gHKm//tFSeTi8d40B2 48e5iGQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; =20 - struct perf_tool eops =3D { - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, - }; struct perf_data file =3D { .path =3D kvm->file_name, .mode =3D PERF_DATA_MODE_READ, .force =3D kvm->force, }; =20 - kvm->tool =3D eops; + perf_tool__init(&kvm->tool, /*ordered_events=3D*/true); + kvm->tool.sample =3D process_sample_event; + kvm->tool.comm =3D perf_event__process_comm; + kvm->tool.namespaces =3D perf_event__process_namespaces; + kvm->session =3D 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 *kv= m, =20 =20 /* event handling */ + perf_tool__init(&kvm->tool, /*ordered_events=3D*/true); kvm->tool.sample =3D process_sample_event; kvm->tool.comm =3D perf_event__process_comm; kvm->tool.exit =3D perf_event__process_exit; kvm->tool.fork =3D perf_event__process_fork; kvm->tool.lost =3D process_lost_event; kvm->tool.namespaces =3D perf_event__process_namespaces; - kvm->tool.ordered_events =3D true; - perf_tool__fill_defaults(&kvm->tool); =20 /* set defaults */ kvm->display_time =3D 1; --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0758194A5A for ; Wed, 26 Jun 2024 20:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434222; cv=none; b=hu7ZCETFhToZ+D9gnqjQDvlSRJ6bX18jVKtq9u8/0y6caqva3WBo5NvvqG1Sjbt+fs+K3dUWxYICiFo+mmG/nBEsQK+4YCe4eusoCtTSUlCt842brs6IEWSAftpBLPs7yeQ+6e8UUXGlZihDh5Tmj+Qteuf0A864cWykqH7qgzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434222; c=relaxed/simple; bh=RFTmrZzGTM9IWPWjHq70q/GKoQrds29ugAT8XNOZor0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=O0cXtZXi/xOaMMpQiBMV20YskJSmLLLcPaQewQ1xmGmxfd57PHuSpGwI4mIVwbVPMSXeJkuH4V2SQpu5HG6Y4Z/QZVsWxyzV4XjCzeXhzM8rdJfzvklsZuSshR3yBGh02c8qW4auZy2cqhL21/06Gj/bPjBn6SK2/uPUaAL0IsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uG0PR/Zx; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uG0PR/Zx" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e02f2c852f3so10746790276.0 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=1719434219; x=1720039019; darn=vger.kernel.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=uG0PR/Zxn96VV50kPaOiNhQ9PnN+2+GtKgs7pstJ68kOMELjgxSbjBTOLDfQ26Pfjj aq1VocKqA4/EmtvNcu8y06tQ3Bti4MwVO5bmxkuTnNaF9uCEtHTNT+XBsZv7JzBDE/0Y 7jnXtsr1XC94pTcyLoDnVOAIRHBslqposIPMlkgSzRRru2y0+X7rGf/LYW6BLMFBFW5h J8562fE8gtn06PCMcE5vrOAzaF92+4ashp+gljyJtVmQtxl9LIM+W7BODCcSYM5Zna2Q 9UBtTGR3x35uTMvneadKLrKkXQ12zJ53g31Bju/4zEAYt0XjIYZXDbp3U/CxVEY7JoIT w5/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434219; x=1720039019; 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=N/6auzoFqEvK0z/OKX4DFrzZKyRGgBulrLCvaYtZXexom4QkGocuhlNTKuZoJYie1V BVpeF2YUpKJxZjH1KyoGTEvBTuXHmQk86O7Dm9spPw4D6U4shlQtGVQxq/LFuVn+qgPu VDOqpUlMh19T5MWlelDqQ4K5zzOFkrhrRwDjcFdJ5qyJSZvgy1V+Ub7EIMVXf0h5NHUP Cckq8f0T8iDMveizRiR8VeTtUWTJeahvkvWC/EWAOeyBgIvxpKcfQGUICxIg5TP9nByL ZmwIjiiAopApLHo9K18rv+z9IEjTiVTfKM9+xLS1jE5wrpdJCUIjIeFF00Ec+nN9KGh5 x5/w== X-Forwarded-Encrypted: i=1; AJvYcCXbSDQvrWTMJGIzvIAZhJNg5IRKp5lI5OJguoKv+vxaNiy8chDwBaVY9qrm6RzjxOmG7YEasaIlZoWGfXyNtJ6Q6H8/uHjwy+3DMBJ8 X-Gm-Message-State: AOJu0YyY3InodlrQdkE+GXN0X/GinkbIBZq2syMtKeMOQCPm6BJFLw4a 5JhCA6NE9Ajn7nfv87US6vEQ1suA8qOWvcP0KllDtDJQE2xVrkd50CScqamQM/JhyjJnlHAyhF9 w3JPypg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D -EINVAL; - struct perf_tool eops =3D { - .attr =3D perf_event__process_attr, - .event_update =3D process_event_update, - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .namespaces =3D perf_event__process_namespaces, - .tracing_data =3D perf_event__process_tracing_data, - .ordered_events =3D true, - }; + struct perf_tool eops; struct perf_data data =3D { .path =3D input_name, .mode =3D PERF_DATA_MODE_READ, .force =3D force, }; =20 + perf_tool__init(&eops, /*ordered_events=3D*/true); + eops.attr =3D perf_event__process_attr; + eops.event_update =3D process_event_update; + eops.sample =3D process_sample_event; + eops.comm =3D perf_event__process_comm; + eops.mmap =3D perf_event__process_mmap; + eops.namespaces =3D perf_event__process_namespaces; + eops.tracing_data =3D perf_event__process_tracing_data; session =3D 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 struc= t option *options, static int __cmd_contention(int argc, const char **argv) { int err =3D -EINVAL; - struct perf_tool eops =3D { - .attr =3D perf_event__process_attr, - .event_update =3D process_event_update, - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .tracing_data =3D perf_event__process_tracing_data, - .ordered_events =3D true, - }; + struct perf_tool eops; struct perf_data data =3D { .path =3D input_name, .mode =3D PERF_DATA_MODE_READ, @@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **a= rgv) =20 con.result =3D &lockhash_table[0]; =20 + perf_tool__init(&eops, /*ordered_events=3D*/true); + eops.attr =3D perf_event__process_attr; + eops.event_update =3D process_event_update; + eops.sample =3D process_sample_event; + eops.comm =3D perf_event__process_comm; + eops.mmap =3D perf_event__process_mmap; + eops.tracing_data =3D perf_event__process_tracing_data; + session =3D perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 267C8194AC6 for ; Wed, 26 Jun 2024 20:37:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434224; cv=none; b=IzaKU75RuZY94GVrucLjcBBYSH/X5hkkQInpgQF10HkFiVdXQMqwcDSym1FURcsVhsu8RhXEIHrq4biM9XG8VERiJJM1+i4pT/RDOHj+uL97GsuG19LMas5GkCf/gAMiC9TqWsxZmbC5A2C+BZtHNGf2aCkBolw2Zl4Uy/HUMOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434224; c=relaxed/simple; bh=4MeUin7pNU+7EH/vAMBdA4pzYBDobcDnylKN7J0QNiY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Y0ErvdRO0q7EX/k0hNSBlIzI7eRCInkmc26xYgqjVShtU52MKgaV3MlvKDfJzaR/fyDHg0DzEp/Q3ulbZNGRGeVjM4eRs1gQoRUl/NiQLx5F3DtUxv8b+R/yW6QuyRUaKXiDodPSQaobcrHL+nlzXD69o4RhwOVCSw8CmZqXTRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Raq4/Ux7; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Raq4/Ux7" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-63a988bdec8so139362377b3.2 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=vger.kernel.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=Raq4/Ux7ZNXCNsuZ42LKzdxNgY8rmoUoztjk045aaGzxCQjuwZqOrd81fEyX9dvMBO iYNWQEUwT33/s0rq32z8ppuwOeO1ONtsge90n9NuZ2ULPQX68Lq3CRU7dD/tQ5TLDm4j /8pER6My/DIF0k7lKB/9SAvDNele+ws36ghoA5cvVpwbwmSj90IXOvidiaLr2SBGCcok fPTzuNMcCJ3DYMWkKrXKcp6lBcKNuErJfiXItEm7JXBS51ZmLWG0O7oZB0g/wFORgy6B WHxi0wCrAXJEHbnTZD6i8QkzKvtu7cibQ+1dy+SCTDbxcPkclVQn3jFsq2WJSIsGyjkS qy8w== 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=uRxS3tHM8NHYo40uIe+oV/5hn+nSqksEnqgPhxzHPe03OChmkP56k2OuALps9Dc3pO cYOlcLqC76/74lbAnOfWS7PWvnF4k0n312ciIrkOGEFWLmPXHT/07EI85WXTM+PEpKcO XhsxxMGmTFSBx63Y7otSVubiQqoa5ixMOoAfojMjZ6M1WFN2xIal2dDYrH4c1YclSOeP +DF5Cu0Dp7ues6RAC5OQu/NzE/C6MqLJeeKjrK3dEbl0EqQJOAyjgeaxxSD9Fecg4YDQ ugNiEy4uz9w3XooxRSiJ/QiqeqexjThA7pdbW5++X8JFYiXua406AzBOWYNnhmfm7mHY lvkg== X-Forwarded-Encrypted: i=1; AJvYcCVShWEKT9He9V/MjwygjXk7sBuWIuI2Y6tkWqGjAzjWMSru3n4lrqFWA/+aNqDqEVFbxS+Y7McHsjp5JrjCqRszg+ndKWQjVFqtUPIq X-Gm-Message-State: AOJu0Yxdc6W0rQ0wVhv2xQc3//x1k+0gwrhspEcl89nqNt/zCePnhK7/ +L08e59oWjxzhaUpz/zZPLBwTzQhFASyYnoBm8tHEPB4fgCakX/6rdGjBMKb0dbs61YHu+uCa4l o99SWQg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 p= erf_attr_details *details .mode =3D PERF_DATA_MODE_READ, .force =3D details->force, }; - struct perf_tool tool =3D { - /* only needed for pipe mode */ - .attr =3D perf_event__process_attr, - .feature =3D process_header_feature, - }; + struct perf_tool tool; bool has_tracepoint =3D false; =20 + perf_tool__init(&tool, /*ordered_events=3D*/false); + /* only needed for pipe mode */ + tool.attr =3D perf_event__process_attr; + tool.feature =3D process_header_feature; session =3D perf_session__new(&data, &tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A055194AE7 for ; Wed, 26 Jun 2024 20:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434227; cv=none; b=r8DCpKjRmrxn8jJmj2nkRfH2rOzoxhyaiqQkWUKegjNK/cq7Fr8nZ2t0osPtlpL8kKuqKJvduKNRwlX4s5rA3bSDCkHUcuU0nxz0W/c06tWl7M4zXgkNXAjqLM0OZutcQsb6gIWoLA98brIXREyN7NqsDZW956KbJl0gaJO8udM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434227; c=relaxed/simple; bh=jw50PdePtNwHlCvc+bRhx4v0PUa680BXOXn9x9VaU9I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ffY8GFW2wzpVF5tKBxQW6Q9TwYckBkemj2yks1NWa3v35uBd4ioBYZJ+kOIx/v1kil1juNcp90BZSo6d3wMfWV33oClasrSr2YFki8ZBHQrfQ/O1ehuaHyCUS76Gs9j96xLGxbZw/GkcqM5eOu+HckOiDSyUkaeptOLFO+2fXBA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cPnruzxS; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cPnruzxS" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e02bb412435so14996511276.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=vger.kernel.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=cPnruzxStiraOwR+I0e56thyrtHfcR8S1m0dHBnZLFSZEMN6g24AG6shWbakLR+fVI iMeHjvFLyVm5YqwizRuJMESw2E6jMWg/LEld0GPVWmeLsSBk8+oqr6UmZ3I5ZlEihczR lUXCT6neupykafM/cY9h87sAjG5KwfcizP3yfDszuFYhLrvBCCR8NKDJ17MBeytR3WmQ aYjTAVhysS6YbNG8O4YpfMhOzuC3ROlCsnRuYHToOT8MWAX2WwxJZ6byYxOxPHcIMS72 MPVM+i5uqYr+7vgIZbTi/nHS6N5TURMz9VvRW/3GaeUPW08kOf8Hzexb7xQrrgOcnDrk Ezhg== 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=fnblYkExvtb0Rq5uEmSU4V7RsIvGrR0FC9/x2zPrbaCKsjV5zIZ2QRnbOm2+uFsjWT KW4/14LHvho/NS5digvXCJ9/oLCe/zV9oBUfAjlkpw860NfBKHLaCuSrefxSzPlI0Twx tILQFrn0Q/piOk/LoDi157zxMO0Pz0eMkWs98Yh+QBB+fNvddO5zGTt6ozyH7U7JJHwN 0ihhVqIVqTq8R7SzJpAB3Jkil/jUIbmA9aDUgqFGqh0taCR8DGrAczp/tW+iYOR/+hxF ChQy1Z+iZ45ToEI687oGBWutBVIlpN0ll0il1DdDaMabk0xlQ+94PsywjDEo/qrfNHzk UfHA== X-Forwarded-Encrypted: i=1; AJvYcCXaJaSABQMGCLSK+TLj6qIPPpjdKIoQ8MmsNKYOw/l+/bX86cR69lUuoBFD3NNrx6VBIMS6t4uXTBqKRGwyhgdqd07jFDLzMjk2euQX X-Gm-Message-State: AOJu0YxBl0tVY3M0gSTnBm297Tf+bAajbLvNQPd3Ny0zfMv2i02bPrLw KNsIxQYkOVGIbWDtMTNnsu5vhoz/3ozIBe4RSjrc5KPsHk4ZRQwJxK3kjLXWUhG2RqGDvMHwtY7 ZqpqYFQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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] = =3D { "SYS", "NODE", "CPU" }; =20 +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 per= f_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 =3D NULL; + rec->tool.sample =3D process_event_sample_stub; =20 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); } =20 + perf_tool__init(tool, /*ordered_events=3D*/true); + tool->sample =3D process_sample_event; + tool->fork =3D perf_event__process_fork; + tool->exit =3D perf_event__process_exit; + tool->comm =3D perf_event__process_comm; + tool->namespaces =3D perf_event__process_namespaces; + tool->mmap =3D build_id__process_mmap; + tool->mmap2 =3D build_id__process_mmap2; + tool->itrace_start =3D process_timestamp_boundary; + tool->aux =3D process_timestamp_boundary; session =3D perf_session__new(data, tool); if (IS_ERR(session)) { pr_err("Perf session creation failed.\n"); @@ -3326,18 +3345,6 @@ static struct record record =3D { .ctl_fd_ack =3D -1, .synth =3D PERF_SYNTH_ALL, }, - .tool =3D { - .sample =3D process_sample_event, - .fork =3D perf_event__process_fork, - .exit =3D perf_event__process_exit, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .mmap =3D build_id__process_mmap, - .mmap2 =3D build_id__process_mmap2, - .itrace_start =3D process_timestamp_boundary, - .aux =3D process_timestamp_boundary, - .ordered_events =3D true, - }, }; =20 const char record_callchain_help[] =3D 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; } =20 -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); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); =20 +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 */ --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8828F194AF8 for ; Wed, 26 Jun 2024 20:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434228; cv=none; b=Mxuvtpd/WOmRUU52hb3nB1ISVKWAiLVDFI7wrHwYXSYusb6ny5lYFOadUY47VrDvMHb9jm1UefJf4pfnlK1QT+gJjVhDGlFbOWhauQ9ryBtxPTN2bZ6IyRhjImLn+qH9d5ujd3Du+qjQyJ6cqD9MpyU5eRE+bsSUQ+4MDvO/7fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434228; c=relaxed/simple; bh=xTDdcKAsM0Ri5uMJZogx0bCMWjSncnIkrWNhWgEEO0w=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qa5rUPn/lCVRQ9XFDLv99DBUe81Lq0UhdoF2xmaYFmgdAOa6fZNQsOP6vETWhkyb73Z+C3R/BgDM/iSAmPtUUniNb6HWp0aZhOCz8EMD5R7/sGfPYKKoSeaZUic0fqy9XjDqNyZM8WxLucYr6BTgOifBSBcyTGDlPm8u43b/6V4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gJR68Cu5; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gJR68Cu5" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e032e254319so3381353276.3 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=vger.kernel.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=gJR68Cu59FcANsr/UFKwJwonHx9jH42Gd9XwLtzXNDc5/M4sHJ+ccp1X/1wofCk5PZ x+t/PJshpTMZe0k7ajn2XtrouBf/95Iko+yqpVXAe2wfR/vXE6qcTpy10s51kmYTtb4c uScpttRhDDglzBQYY4lM18NYxv5VNidXLE7gB/skswqT76b/TSpxrNW21TfA9khH4//R 5K2tARckE97LOrRIkV6oPjyjkS9xjY5XQlq5NAggCVS5Th/hKHKS+tNtGClU5MZlWB/b YwDeTWu0E6tGLcZPQNmwXUCYG2L6D681pIZXA0JDkDZhCxuSz+gCO3w58QnhTjelmGCV R3FA== 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=nswi218tnInDlDCo/gG7OeGgeeTyzhm5xEZT2zJPrTFqFEgjfTEzGwHZ98S+PHHHRq HuC5Zv6hIxI03DKWHpmxifkG6d7UmFIZPfUz8cPR00bYa6GfSFJ1Oqa4kx5T8t8iVj1A YV+u4JItSUHMtpisuRC/DgWDQCdhfaKgw41THkYMp44e4RsxcXD6oVV9v8RAYeAu3lE7 4xyZWZWmquC9tu22/CDPZgovg8h3+rWiQjS9vDr1rQV+1qCxqutfBR0eyurtu8R5ILYm QYDXNXAPwyc+5XH9pn/w5XBuBPpJCgwW2ICdIWw1vB35hGumspy3sJc+V/b1Q+YQ0eoo BeHQ== X-Forwarded-Encrypted: i=1; AJvYcCXs/yKqgibHNku2pOboFouHx89jiSkCPK88EAMkM4obxb98Hsu7ySdgotPWYeasYoqScRkwxJgnFu2g84PA8EGaQWVRBSpjIFNa7BXc X-Gm-Message-State: AOJu0YzG4k+9cjhUblMTh4TN5GB1mWSP9d2SrYI70Qgy44SihluZ4w0D IvmYWjj++Oe7DczHFbH+N6sfzamD53ZfyK6BhlHuVciT2/gdhqWM/7MiG1BF9bqbqITeNHyn/om zgKlTiA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; } =20 -static struct perf_c2c c2c =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .attr =3D perf_event__process_attr, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, -}; - static const char * const c2c_usage[] =3D { "perf c2c {record|report}", NULL @@ -3070,6 +3052,19 @@ static int perf_c2c__report(int argc, const char **a= rgv) data.path =3D input_name; data.force =3D symbol_conf.force; =20 + perf_tool__init(&c2c.tool, /*ordered_events=3D*/true); + c2c.tool.sample =3D process_sample_event; + c2c.tool.mmap =3D perf_event__process_mmap; + c2c.tool.mmap2 =3D perf_event__process_mmap2; + c2c.tool.comm =3D perf_event__process_comm; + c2c.tool.exit =3D perf_event__process_exit; + c2c.tool.fork =3D perf_event__process_fork; + c2c.tool.lost =3D perf_event__process_lost; + c2c.tool.attr =3D perf_event__process_attr; + c2c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + c2c.tool.auxtrace =3D perf_event__process_auxtrace; + c2c.tool.auxtrace_error =3D perf_event__process_auxtrace_error; + c2c.tool.ordering_requires_timestamps =3D true; session =3D perf_session__new(&data, &c2c.tool); if (IS_ERR(session)) { err =3D PTR_ERR(session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E51C9194083 for ; Wed, 26 Jun 2024 20:37:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434232; cv=none; b=GoicuPIlcL2XKe0NOlPQXzyVkB5Bg81/lF9L0E/nZRx3sK6Hkii7wxySmyaE5wvrlx6lzNzin6SokV3m6f0j5h40Ern3UIvo/AbNteBzPhvnvvSkFvxbpBCcOD/E77QNOdRxQ604XFriWEyB0ySgEomhSa3Ghakbn2hQwmwxtvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434232; c=relaxed/simple; bh=WRHMheJp7s0UW+rmOQwKCmWPOpwEdqZ0h0girqg29wc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=dobOhsJPP17SYPTw9Rdh5PYeRTNWHKHcSx+WVzleTlf0iMW3v9ssHAedhwHFASJFe2T4hawjbn7I49aXZkXFxsTHUxwlwSrLjGIsOa6yzAOHJk3/VTtZ3LKBAiIFh26WTTDzqSzLCm19AJoP0fE002G0zXKpc+qL0gDzN3rGqZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VxJCnQ/Z; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VxJCnQ/Z" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62f46f56353so123318327b3.3 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=vger.kernel.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=VxJCnQ/ZnkxvM3BTZKrUvE29My1KiTQ81qn5b8rKsmM2nfmrlXdIRVh0T6RuseK9SJ XG84I1xefDMLVeK/nisRJNvyqRgtrkrRuQ8cwIz7fdPRLzT28qOxNXr3AyFf8zsqtqhT VfQzo7txoRLaATCFmbs8yuXrOFQ41vBrWROklToKuvjgVGsAVkbSucvBG0JJFVb3gZqu f+eF2g4J90HiZgvt+VuRhGb4EN/ONsjEvWdJXS8KkrTHDgyES454XuML1HFXXcQ3xgbo JLtt12odBfQvPhm61zCHwYGBa22w6wwY1510o9/6JkUIpKNv9y5sDfqR2EIp8btYD2xZ wRZQ== 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=rCwfr0mpfm0H71wbBqBIkQuK26lbMW8x52B7UKQRrspuC+2Gee+LZw4HIeANObgn0h vHl560QId9p875liDA8ZAAqEMvg0WuPfzYCvrdIu/RstOLp5tLPJPnajMAbrw2RswF2P iTnAseMzWTEn3i5rb2xe6DBE5oBkuY+taLQ7kLZbETwpMQSM6s/LqwQGTSt+p2/8AY3V 5dFIvRhavA1vlBQXbrqBHxT/JoLY6ILWBPMOtG/FBvLBlc40vQw0FLECBzxCwTlla8/f FBfrhlN2RRFmihVOunNsisSSPwVqpe/XI1LZA2R1A3o6FLX4EY5nUuWhvnootJO8HO2T q1Og== X-Forwarded-Encrypted: i=1; AJvYcCXcy7btNCsska+Wt72UBSCqU7WTqX49Z/oLpvCmonv0Zz1uulBBKk66Nv3knXOhEbecyVkIGmUJ6tvddpF7+Vm7GRQtcZSrLJUtyOSg X-Gm-Message-State: AOJu0Ywog890wIsi9BLDB5QxH7bxnXGd2kO/pMmpXludEI+vNz0KLJOq C2d+jqTwZDhaLGbP+/FyDnsmHfaxWFrYBT2r9oNI4cRKxf/iabDWFolatwvIqYu6o+NLcc8QWNJ ax4qdEQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D NULL; const char **__argv; int i, j, err =3D 0; - struct perf_script script =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .attr =3D process_attr, - .event_update =3D perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .feature =3D process_feature_event, - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_script__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .stat =3D perf_event__process_stat_event, - .stat_round =3D process_stat_round_event, - .stat_config =3D process_stat_config_event, - .thread_map =3D process_thread_map_event, - .cpu_map =3D process_cpu_map_event, - .throttle =3D process_throttle_event, - .unthrottle =3D process_throttle_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct perf_script script =3D {}; struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, }; @@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path =3D input_name; data.force =3D symbol_conf.force; =20 - if (unsorted_dump) { + if (unsorted_dump) dump_trace =3D true; - script.tool.ordered_events =3D false; - } =20 if (symbol__validate_sym_arguments()) return -1; @@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser =3D 0; } =20 + perf_tool__init(&script.tool, !unsorted_dump); + script.tool.sample =3D process_sample_event; + script.tool.mmap =3D perf_event__process_mmap; + script.tool.mmap2 =3D perf_event__process_mmap2; + script.tool.comm =3D perf_event__process_comm; + script.tool.namespaces =3D perf_event__process_namespaces; + script.tool.cgroup =3D perf_event__process_cgroup; + script.tool.exit =3D perf_event__process_exit; + script.tool.fork =3D perf_event__process_fork; + script.tool.attr =3D process_attr; + script.tool.event_update =3D perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + script.tool.feature =3D process_feature_event; + script.tool.build_id =3D perf_event__process_build_id; + script.tool.id_index =3D perf_event__process_id_index; + script.tool.auxtrace_info =3D perf_script__process_auxtrace_info; + script.tool.auxtrace =3D perf_event__process_auxtrace; + script.tool.auxtrace_error =3D perf_event__process_auxtrace_error; + script.tool.stat =3D perf_event__process_stat_event; + script.tool.stat_round =3D process_stat_round_event; + script.tool.stat_config =3D process_stat_config_event; + script.tool.thread_map =3D process_thread_map_event; + script.tool.cpu_map =3D process_cpu_map_event; + script.tool.throttle =3D process_throttle_event; + script.tool.unthrottle =3D process_throttle_event; + script.tool.ordering_requires_timestamps =3D true; session =3D perf_session__new(&data, &script.tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67EF5195395 for ; Wed, 26 Jun 2024 20:37:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434234; cv=none; b=erBhCml4/7iueeByHM4/fxZ2iIqGZqtH/LCinNhhnnzdcU583sik9fs03MIWOuY6Wz/FYu0Y1TY9FuB1KwhKfJD0zoSD46v5WmFA15xZTIWbU9rEtMyTkgHQkwbCqdvhjdu3cMetAxbnliOY7IVfE3WUBAsiMGEfk3seg/OcUeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434234; c=relaxed/simple; bh=kA/1/6A1SUeAf1WjLbg5KvkpIUJiCLhmIa8iJNWrb0w=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ltvXGzYHSoxWirgpXk/1hLDk3qRKeN3V1nE21BWUO3z1mk9yMayQ58hHwi8DF4j/Az3Y7u2juLx1D6peRbjQC4nR68TFZfP4zMJMo/XiOk7L1SrF8sQvMc+GsWIwaQoxHTiZVKgb62yxl75wdq75xDzKRqjV4I6O0LtTqYRpN+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oIF71dRY; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oIF71dRY" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0342b6f7fbso400334276.0 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=vger.kernel.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=oIF71dRYtf2xJKwz336nVnKMvvt+UTgk8UAgeKamCOslIriM4guaUxRMI7yeJihprC gAlClbQ7Hthnaqlo/RYjdxmCb6GRwpTFJPGiENMBjwQVcykpXqKxtQdrMHiDal32qd3h matOJgDUa1OM0/LznQHLj1od/02Y4G1kLo6CLcF/RtBt8AqWEsAxd9+iLl3PbouHrDJh Njm3D1X0UqHFRu3aPdvN69XZc/3FKikBkgLzfDEMoVGefVxjyZxGsWTXu15nXumXLm5Z LpUBdIOmzLmMJuIyzwcz7d6472s6n2mdHj4Gj+ftZUFG2w+q/mGNC9pc2h5I0144W1AX XwBg== 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=d1eKQEmu/jXyRqMQnFFN1xrmtEb2A7gu9wH6ssFX7T//E5a/sDQtEqCFgUVPGdcBAo l3Xe3lF34sFVCo4h5430fzuD6yXsTR0UoTT3oPimm4foMlc+QQ8H0Pk3f2f95cHKwyxD Gp3S5XmWZqcCrccyUdDVyhJqtOOgYQxDK61XyUX22CbaAE2R8n9KVR0R98LmEIvtEKhp ct81wm0QYmaUaRzLLejcQfJ5odkLUSvGkGsB6+RvkcS12gqv7Fet6IVWTdX6C5ec2M/R B7GNJTySnsYxxgehZrh/Wqgez07E0ncvtITSkXxL9WwvNuFIPyimt7qFaLfpglge749r jnbw== X-Forwarded-Encrypted: i=1; AJvYcCWS9cVSW+V+8Z28mHHP4+WNG0bHNlgqK4UaR30GkRs2XK4TGlXUDA2T+z4gkdTdyc26mEKbF+qRi9b1kEUXNuo/NVDLbZ1L8N/YWScL X-Gm-Message-State: AOJu0YzTmWjkOWAVI1ofCTlgf0HewzCQrL47hNLb9DsvcF4H6ei/Vjuv jXp28Vx46lyc//7BiLR5AmFEHpe5MqoEm0WhG6WvDtTsXvZh5NmzZ3NfrxZ6jqs8b1AXZcWcLuX 38XPhVw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D { - .tool =3D { - .sample =3D perf_event__repipe_sample, - .read =3D perf_event__repipe_sample, - .mmap =3D perf_event__repipe, - .mmap2 =3D perf_event__repipe, - .comm =3D perf_event__repipe, - .namespaces =3D perf_event__repipe, - .cgroup =3D perf_event__repipe, - .fork =3D perf_event__repipe, - .exit =3D perf_event__repipe, - .lost =3D perf_event__repipe, - .lost_samples =3D perf_event__repipe, - .aux =3D perf_event__repipe, - .itrace_start =3D perf_event__repipe, - .aux_output_hw_id =3D perf_event__repipe, - .context_switch =3D perf_event__repipe, - .throttle =3D perf_event__repipe, - .unthrottle =3D perf_event__repipe, - .ksymbol =3D perf_event__repipe, - .bpf =3D perf_event__repipe, - .text_poke =3D perf_event__repipe, - .attr =3D perf_event__repipe_attr, - .event_update =3D perf_event__repipe_event_update, - .tracing_data =3D perf_event__repipe_op2_synth, - .finished_round =3D perf_event__repipe_oe_synth, - .build_id =3D perf_event__repipe_op2_synth, - .id_index =3D perf_event__repipe_op2_synth, - .auxtrace_info =3D perf_event__repipe_op2_synth, - .auxtrace_error =3D perf_event__repipe_op2_synth, - .time_conv =3D perf_event__repipe_op2_synth, - .thread_map =3D perf_event__repipe_op2_synth, - .cpu_map =3D perf_event__repipe_op2_synth, - .stat_config =3D perf_event__repipe_op2_synth, - .stat =3D perf_event__repipe_op2_synth, - .stat_round =3D perf_event__repipe_op2_synth, - .feature =3D perf_event__repipe_op2_synth, - .finished_init =3D perf_event__repipe_op2_synth, - .compressed =3D perf_event__repipe_op4_synth, - .auxtrace =3D perf_event__repipe_auxtrace, - }, .input_name =3D "-", .samples =3D LIST_HEAD_INIT(inject.samples), .output =3D { @@ -2269,6 +2229,7 @@ int cmd_inject(int argc, const char **argv) "perf inject []", NULL }; + bool ordered_events; =20 if (!inject.itrace_synth_opts.set) { /* Disable eager loading of kernel symbols that adds overhead to perf in= ject. */ @@ -2333,7 +2294,47 @@ int cmd_inject(int argc, const char **argv) if (strcmp(inject.input_name, "-")) repipe =3D false; } - + ordered_events =3D inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); + perf_tool__init(&inject.tool, ordered_events); + inject.tool.sample =3D perf_event__repipe_sample; + inject.tool.read =3D perf_event__repipe_sample; + inject.tool.mmap =3D perf_event__repipe; + inject.tool.mmap2 =3D perf_event__repipe; + inject.tool.comm =3D perf_event__repipe; + inject.tool.namespaces =3D perf_event__repipe; + inject.tool.cgroup =3D perf_event__repipe; + inject.tool.fork =3D perf_event__repipe; + inject.tool.exit =3D perf_event__repipe; + inject.tool.lost =3D perf_event__repipe; + inject.tool.lost_samples =3D perf_event__repipe; + inject.tool.aux =3D perf_event__repipe; + inject.tool.itrace_start =3D perf_event__repipe; + inject.tool.aux_output_hw_id =3D perf_event__repipe; + inject.tool.context_switch =3D perf_event__repipe; + inject.tool.throttle =3D perf_event__repipe; + inject.tool.unthrottle =3D perf_event__repipe; + inject.tool.ksymbol =3D perf_event__repipe; + inject.tool.bpf =3D perf_event__repipe; + inject.tool.text_poke =3D perf_event__repipe; + inject.tool.attr =3D perf_event__repipe_attr; + inject.tool.event_update =3D perf_event__repipe_event_update; + inject.tool.tracing_data =3D perf_event__repipe_op2_synth; + inject.tool.finished_round =3D perf_event__repipe_oe_synth; + inject.tool.build_id =3D perf_event__repipe_op2_synth; + inject.tool.id_index =3D perf_event__repipe_op2_synth; + inject.tool.auxtrace_info =3D perf_event__repipe_op2_synth; + inject.tool.auxtrace_error =3D perf_event__repipe_op2_synth; + inject.tool.time_conv =3D perf_event__repipe_op2_synth; + inject.tool.thread_map =3D perf_event__repipe_op2_synth; + inject.tool.cpu_map =3D perf_event__repipe_op2_synth; + inject.tool.stat_config =3D perf_event__repipe_op2_synth; + inject.tool.stat =3D perf_event__repipe_op2_synth; + inject.tool.stat_round =3D perf_event__repipe_op2_synth; + inject.tool.feature =3D perf_event__repipe_op2_synth; + inject.tool.finished_init =3D perf_event__repipe_op2_synth; + inject.tool.compressed =3D perf_event__repipe_op4_synth; + inject.tool.auxtrace =3D perf_event__repipe_auxtrace; inject.session =3D __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 =3D true; inject.tool.ordering_requires_timestamps =3D true; if (known_build_ids !=3D NULL) { inject.known_build_ids =3D @@ -2385,15 +2385,10 @@ int cmd_inject(int argc, const char **argv) } } =20 - if (inject.sched_stat) { - inject.tool.ordered_events =3D true; - } - #ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 =3D perf_event__jit_repipe_mmap2; inject.tool.mmap =3D perf_event__jit_repipe_mmap; - inject.tool.ordered_events =3D true; inject.tool.ordering_requires_timestamps =3D true; /* * JIT MMAP injection injects all MMAP events in one go, so it --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD265194098 for ; Wed, 26 Jun 2024 20:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434236; cv=none; b=E6f1sPbA0/8JrfrE+Xi53bZkQUXTHpYc7m1rObsvPqoNJ2egi4T8NMKtiYOsQWEC9pfjUrWmlq4/WMBjlejON6NQvrkq8ZoPkj/NWANSurrc6X7omHaF3sKmoAcc/OveOP+gcaSN5ydoqHl4qGgbcchEmBYnTZNcBIGQFMzx7pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434236; c=relaxed/simple; bh=3FrpPhcqSWlNmnpFwaNx96Z+Mpxf4dIupHzPwx6lfeQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=phMpqC06rnjR9/McKmHCYuxGBgkNV9nhoHRz6ibbW9G4H9cLIRfPoV1LNqIcYvy1dDJBOfsiydFRk3fb2JSQxEChEWMD4VxdMlooAFEA7MZT/hWbZrMH418Yuu8DQGI0nSdYTs6z/aXOfH628kfxpcjS5jkr12bSy53lA4m1B84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=No33cHiE; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="No33cHiE" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e02b5792baaso14974925276.2 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=vger.kernel.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=No33cHiEorzydKntL3UYfx9jmvKJlMLdbprVzgYwyFjAR4zeM20Prkyq+rdVcvtuWC USZSEouxrVGnVWrAjWychgwVegB7JDzNpoM7j8Ek76VUJBlhWp9ZEWLnto/T6PTqWnIW 3QxcVcE5AlfcgNoqlra1/2cVt6K2xgUmrkWN9P9uOJSk3WRtYd1xhc66uLN9Mdq0ujq/ r/sXXyByGmeuNJiR6Wai3TMywZZXPdeM1PAEFrQi07u+aOBWrp5SFt1IwbY55tLzVg5o xIJUExVlTzWS11B6RT8xLMNk8ZVWsu4EulltjkPR9A+MeKKnZWRldVKmPQI5TKWqQ9LQ 3Tig== 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=LnKwgVrbKroKIrOzrtVj+urgKYUs+5F0POvcdPVXzHi3ne7RTUFyj1RhQOa8wup9G6 vQZhWIZL95+T+HIkCwVADIL/fsfge/6sqM1DCzz0zkuTJuwerCKVGIUpl/zazJQ1i5Wt J4oYWbEoA1cTAYhiJH5/wh14mNt0t6BjrPQweVTm+iGkl7vTSm0SnnqYEj9BYIxKX6K0 HjNpmCq3T2LWPnMm9E4bnDtM0hazwkjbiAtdcjGao8jpQlFa9QmE0Vaz5xAKNDj43RX9 LNIQIIKzHQKJOttuJibS9fXynLsFuREPaecusdnG0I7IJrB7E0X2WDZiNeEr7dhSalFf aw5A== X-Forwarded-Encrypted: i=1; AJvYcCWwg2ZyoGYmV9tqEDITFqyDBEu6KtThMtuGCyJtbhOuu4tQsYcUVXlOHRK5TcWpTH5lb2hyDgSa7zpy1Wt2BBhuBouTp0N+gNEqfXOV X-Gm-Message-State: AOJu0Ywnm3lrlOw0G+EBCzm8w6KVCSrF6naX5pvl3Tba66zql4Imf06D lDmICsfynPDGXLJ14+DepbGJqokxZpVEU9GMg8abp6KhMgWueqWViM1xUKMfvH2Xl0PxLCgQvKN eh2pT+g== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, =20 static void stats_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); + perf_tool__init(&rep->tool, /*ordered_events=3D*/false); rep->tool.attr =3D process_attr; rep->tool.sample =3D count_sample_event; rep->tool.lost_samples =3D count_lost_samples_event; @@ -817,8 +817,7 @@ static int stats_print(struct report *rep) =20 static void tasks_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); - rep->tool.ordered_events =3D true; + perf_tool__init(&rep->tool, /*ordered_events=3D*/true); if (rep->mmaps_mode) { rep->tool.mmap =3D perf_event__process_mmap; rep->tool.mmap2 =3D perf_event__process_mmap2; @@ -1273,30 +1272,6 @@ int cmd_report(int argc, const char **argv) NULL }; struct report report =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .read =3D process_read_event, - .attr =3D process_attr, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .event_update =3D perf_event__process_event_update, - .feature =3D process_feature_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, .max_stack =3D PERF_MAX_STACK_DEPTH, .pretty_printing_style =3D "normal", .socket_filter =3D -1, @@ -1478,6 +1453,7 @@ int cmd_report(int argc, const char **argv) }; int ret =3D hists__init(); char sort_tmp[128]; + bool ordered_events =3D true; =20 if (ret < 0) goto exit; @@ -1532,7 +1508,7 @@ int cmd_report(int argc, const char **argv) report.tasks_mode =3D true; =20 if (dump_trace && report.disable_order) - report.tool.ordered_events =3D false; + ordered_events =3D false; =20 if (quiet) perf_quiet_option(); @@ -1563,6 +1539,29 @@ int cmd_report(int argc, const char **argv) symbol_conf.skip_empty =3D report.skip_empty; =20 repeat: + perf_tool__init(&report.tool, ordered_events); + report.tool.sample =3D process_sample_event; + report.tool.mmap =3D perf_event__process_mmap; + report.tool.mmap2 =3D perf_event__process_mmap2; + report.tool.comm =3D perf_event__process_comm; + report.tool.namespaces =3D perf_event__process_namespaces; + report.tool.cgroup =3D perf_event__process_cgroup; + report.tool.exit =3D perf_event__process_exit; + report.tool.fork =3D perf_event__process_fork; + report.tool.lost =3D perf_event__process_lost; + report.tool.read =3D process_read_event; + report.tool.attr =3D process_attr; +#ifdef HAVE_LIBTRACEEVENT + report.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + report.tool.build_id =3D perf_event__process_build_id; + report.tool.id_index =3D perf_event__process_id_index; + report.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + report.tool.auxtrace =3D perf_event__process_auxtrace; + report.tool.event_update =3D perf_event__process_event_update; + report.tool.feature =3D process_feature_event; + report.tool.ordering_requires_timestamps =3D true; + session =3D perf_session__new(&data, &report.tool); if (IS_ERR(session)) { ret =3D PTR_ERR(session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10E111957ED for ; Wed, 26 Jun 2024 20:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434238; cv=none; b=JtCXc8/VGP6QsWpRTHGF+OTzakYOtFcmSLghUM/GkrWvAZj8fJhhfU4zZi4btys+h6jHMRG8BvWn1HIxa4BQuOUkhy2UQE/BLi3njhEZkEjyyZTsIGDr6abTsp6A+edgxyZ+004eH6rbiHsUSGdyAOafPRXdslRzyrOTmqM7ipI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434238; c=relaxed/simple; bh=4w87sKvNwVN1XhdwrvqeSGrSkFFASpDkmJtJS5HZHW4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=biYsGOwMMk8HEWkYpbwjQKRK7F6tqZjv3rA66S0VGMZ7cq5TMpr7/dAcCJ3JzpDlh3Ny0/npoqb2Oq4pBV872GS3DL3k8pSeoX8NAHI0sSxC42WLeEn4tgJypOr15N89ezD5OTjExjxxO41hy2nRcP2CEasdJZikjK+sIzuq3V4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Jp84zSvE; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jp84zSvE" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e02ba91b9f4so1270294276.1 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=vger.kernel.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=Jp84zSvED2CJ4/tOzX6r8XMAqb8eMoBjdRCwRdsyvjZUWB57Zafuui0R30ulaBQbeZ 2NTYZQyanKraXN5ykDKiseZ3G6IPnsyuh208IJNPITyAWgdhXfbCHzRgI+k9SNaQs2bd rnWWyee5q3ZMrJby/Z9gaYOQLUKn/DxpVLgxJ0oHQJ3kXBIiAkZFdDJscZnVR2bxBQ1V 606YmSMfTfdNnxEdmSLvL7mxH8lUVxG47+oyP5sGw1qSDBUIFkuDniyONretOr8gi3kb 8x+XAQw+ZZ7FQZ4T+LgR3FdV8T+DklKpR7HRntSzVSJxnwbx1AC04wPJTkEr/stId6g5 iuOg== 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=UxE6t/sdarxQMumwd6thbSMFqOC27zpnipdSkn3OfV4hwgNaD99dTlbAf2sK9eU8/1 WlP0ra/r337XVvh/duAZtHpq8rG4eXU4QjwE6Ze6H1XRRo1R+PFJznct+r97NIZ+vqrJ 335jsr1OTXuqeHNj8Ky3K6AVRzHbDH7JEiddEjsYNvvchOigXrhIBHYUdiUEJSnfVs3w 6QthYHGSsnmLCQ5mdJdhvuVyxKAy58XL6aifiMoURARXWUN2gbR9KioAa0zYk6OyFEXr rwr8gza5BEgh4Y+dj66NpUL3ROUnoQoWp+gZW+Boluzd5nrA591S5IZSw8eNwlIqbr9s 2DMg== X-Forwarded-Encrypted: i=1; AJvYcCV/GbIEj9Hej9ypB4K2PoFGVFlgxebidVVPZIzTVWh1oNDEw8kifKj+cklbuLlj1SA9Ys91g0vbXi7u5Ja/c7e/vcdqF04VVKYNc8bW X-Gm-Message-State: AOJu0Yyd8COv7fRMhVrotAuPT5W5wLwb0kha7jExrVg7XewY8iBvpSZL H9zvhE2UAdCX0qi8r8092Wk3NkT3wDQw8yPln3zeBpPeo+qBhXGfAww1XJP4xif2k1CFuqAgrZo edsLUbg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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[] =3D { }; =20 static struct perf_stat perf_stat =3D { - .tool =3D { - .attr =3D perf_event__process_attr, - .event_update =3D perf_event__process_event_update, - .thread_map =3D process_thread_map_event, - .cpu_map =3D process_cpu_map_event, - .stat_config =3D process_stat_config_event, - .stat =3D perf_event__process_stat_event, - .stat_round =3D process_stat_round_event, - }, .aggr_mode =3D AGGR_UNSET, .aggr_level =3D 0, }; @@ -2322,6 +2313,15 @@ static int __cmd_report(int argc, const char **argv) perf_stat.data.path =3D input_name; perf_stat.data.mode =3D PERF_DATA_MODE_READ; =20 + perf_tool__init(&perf_stat.tool, /*ordered_events=3D*/false); + perf_stat.tool.attr =3D perf_event__process_attr; + perf_stat.tool.event_update =3D perf_event__process_event_update; + perf_stat.tool.thread_map =3D process_thread_map_event; + perf_stat.tool.cpu_map =3D process_cpu_map_event; + perf_stat.tool.stat_config =3D process_stat_config_event; + perf_stat.tool.stat =3D perf_event__process_stat_event; + perf_stat.tool.stat_round =3D process_stat_round_event; + session =3D perf_session__new(&perf_stat.data, &perf_stat.tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4261319599E for ; Wed, 26 Jun 2024 20:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434240; cv=none; b=ei6w67k8K25F9T+xZkSaXDzH2q3tXcrJHh6EcUKcyadBV6y22tkzk0VwqnMO9+jMJtdptwSaVp9c16hksPDJ824Dgv+Nxt1NMXAwNakWkaWup30sSj7Kbm5hlOhn1h2CwehjDYedCjO6i+i5BBWR7AtGtB2ezJMglxxRchLh/Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434240; c=relaxed/simple; bh=wSv42CwTUPplQ6+JVwWJj7o3S2bpL4SvoCmSnIcCAeg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=HvO4M7qjhyuJVu7kYZ9FybKaI9bIPt/r1P55hKczaXKmDu/YnkSAEqdM0yIdLyZN7meP1lD9MmupzkyYtN+BiWrlXlDHo65Gzg0WZ6k6AeLu+8GW6vnZSKeUqdYrpFaJ5ajZWYI9IhzHqn0PLBDoDAAPZ1RBARxlFaL7igPU8ys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AoHPqL/8; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AoHPqL/8" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dfa73db88dcso13883991276.0 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=vger.kernel.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=AoHPqL/8fm3NwalY7Kkw101jIP/Q5dCJk6mrqd492P7ST9lI6Q6t9wJ5AGeGtHg9r0 1xHIuEnuxfnkTMdvXt9x/zBFX+vmfhPTqP3pTA9jR5T8dKbr3hvpbyl22xQHbP6MIEQy vQKDtEUR5ojyW2g2c+b8sdzLKIrJO+6s7gMHwMh51adyaHeP2Hr9BGL/tnkWv4kWIi4U qssS75OCQOpMsjH2YySezakUQ078Fcsu4X0b0P/FhgBZVeVfnUGqkAKNMXM8sb3Bj2Ic /mralXV5q6BMD8a2wrqY8K8THuHDaugXV7gXC+kOY2y39lBy4WyzofxIUikAIK8pb86R fXYA== 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=IGFnne5t+6axRNhZzn5Fa1Wdp90lkt6QKcT44IPjzkl9HDLd7O/CdIQNHUgBrWg4K6 PadJxyK9Z6BsChadHoQXkj3dlqSbEb/tAEjenQ4WdtBVkDmNcxYmMbDrbkjTA3qR8VuR bAwA9RAJaN8AubZjevqYALwrW9HvdnVwUzJ41DwonAsGkTepzlohoAYwpAPtznvRszLQ aB8rskKxa0qnEZU5KLuyXxD7raJC3aWyAzbe2PuWlobWSkBA1FRvzcps3wvVf6ko0Ibp ZSXLs8y+kUz+1F6SczG1Pg47UNJdEme6lBbfu7C1xAQ/qaWoJyvEhODIESLywEN3q+J4 8HXw== X-Forwarded-Encrypted: i=1; AJvYcCWjhlgV11XaviK7gWQ0CJa7q3krRVasrGTOrVpKpIfhSZS+lE58imNdr7daDKB1TEzrfO473GYmGSe3/4SZd/IH78I2k+SLqpTCXbUq X-Gm-Message-State: AOJu0Yw4RxpXW6mWhtj+566kg+eWr4MsOySyPUc3HkZL7wPQ6mOaw6mq 1iEX6y8ixb7CzK5+sJlePduJs36jdg+juCU4tschH4IKvNMojuAm6QfafkDNzFgZWCYln29/sdm bGOK9jQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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[] =3D { =20 int cmd_annotate(int argc, const char **argv) { - struct perf_annotate annotate =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .namespaces =3D perf_event__process_namespaces, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .feature =3D process_feature_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct perf_annotate annotate =3D {}; struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, }; @@ -864,6 +843,25 @@ int cmd_annotate(int argc, const char **argv) =20 data.path =3D input_name; =20 + perf_tool__init(&annotate.tool, /*ordered_events=3D*/true); + annotate.tool.sample =3D process_sample_event; + annotate.tool.mmap =3D perf_event__process_mmap; + annotate.tool.mmap2 =3D perf_event__process_mmap2; + annotate.tool.comm =3D perf_event__process_comm; + annotate.tool.exit =3D perf_event__process_exit; + annotate.tool.fork =3D perf_event__process_fork; + annotate.tool.namespaces =3D perf_event__process_namespaces; + annotate.tool.attr =3D perf_event__process_attr; + annotate.tool.build_id =3D perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + annotate.tool.id_index =3D perf_event__process_id_index; + annotate.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + annotate.tool.auxtrace =3D perf_event__process_auxtrace; + annotate.tool.feature =3D process_feature_event; + annotate.tool.ordering_requires_timestamps =3D true; + annotate.session =3D perf_session__new(&data, &annotate.tool); if (IS_ERR(annotate.session)) return PTR_ERR(annotate.session); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2F7F195FE5 for ; Wed, 26 Jun 2024 20:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434244; cv=none; b=J25pjiMVGzPwN5fB+cPEiZ0xHp/EzeiZcFd1JEFYFPAgBv38Lek6qBKDk2BrVVCIjc3Z4E7GWZYzT9G4lFPbeft0AQjkvidA/OP38lDbPhlTf013olalTGE4tn228qwJfK0nCCrxm8T4oZdhDUIZHw3DRaitc+exT6hC2R++nO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434244; c=relaxed/simple; bh=p9FimwsA8nPd48DhGiskfbVWvAqnuMjqgwp7sG3YyCI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GStzWcWdCOY+ZhKboUXR7XivCti/psG+RzhCRsG1xc+F+ajUvwkdypX7Kl44gHN+P0Z0Q2Jaa/1pty2CgZSuNCH0fQaRz1xv0AIPU6f8cbtFJy1uzih6JlQJWXyC2N+SELkBGETNj3DIrttzC0T/vrkH4WM14svxuPRt4E+Wjw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AK6+App9; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AK6+App9" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0322e5d0daso1888628276.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=vger.kernel.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=AK6+App9LxqCSmvmlt+bwOtcZbat2YFXee4EKciOtTUtNj1y3iX2PxJ4EeOiFD1QRP PBGE7DI0LJl7y6vEiMitudAOXs235jADAFWKBBF2Q7WzvUyALstI088IuYaNskPGCphF VhGsWt5jsgXe86Bb97A1/tX0Y+U7crJMfWLMGQln60PttIUyP7M3T6q1LGCMPnVx01a9 PwvwtKW8Toz0uzSlCJ2hSY3x2kO3y29oLk1L6sRSx/RqOIUAFZOELsYrSpcft8cEm9CJ LXkOz54mndP0bqlsvTNm0zwnzkTk6cuygpj26VYvfXCFelgPG/30hLEuTWzc1pxTi1Hv AjBQ== 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=AaeP0TZkschwLmu7Rz9bLza+eSx9WTRMTarB6/mHrOjZPSZtWQXLXCXnYkbJ/pDI9o cEYwP2w9PluYEPHbwwHX7WRbUP+6NLMelOuj+Zs2mL5Xq5IF/cCO0r0IN2J3LgH3v/0j 3v4Vm38TLfV67i9cojS6CHsTq4eJE9Lb5pMZSWFHUYeAxnIYzAkCv9E3jChZTvnIcjoR 4Ur9DiiOSYR7PLdtnKmHzMl6Rf2EuxPeF5HpzHDywSPy47W4LD4XO3tDh/XWYZPD2mxn PMb4RBqVKrQu55hv+1sSfQXZKqScKnEocI1FteC+3kRn+KsdoD9RzrfLDrAa21ylj2gT JHCA== X-Forwarded-Encrypted: i=1; AJvYcCX2125y2+fF+dHwJDd/DvEe+mvnYpOy8oMnTBvl/G1oLnMyYFAj/WRJRzAvW8+Jx/L8ZqAJV6kNW87jE53/SbuIVw7Kq18/cdsf9b7o X-Gm-Message-State: AOJu0YwHb1UhHKQOKfQ9vpFNMStoQ+/w/VO2yUB48hy/F7f1JLkpIE9N eP8CpGD0HdOc6L8umYViQzLF8369wNMQRXovUv3RwIoPkxJXK/Q3pw7UkN/GBmx/XxEwgPxk4xd fdsVcGA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 *sc= hed) sched->tool.tracing_data =3D perf_event__process_tracing_data; sched->tool.build_id =3D perf_event__process_build_id; =20 - sched->tool.ordered_events =3D true; sched->tool.ordering_requires_timestamps =3D true; =20 symbol_conf.use_callchain =3D sched->show_callchain; @@ -3511,14 +3510,6 @@ int cmd_sched(int argc, const char **argv) { static const char default_sort_order[] =3D "avg, max, switch, runtime"; struct perf_sched sched =3D { - .tool =3D { - .sample =3D perf_sched__process_tracepoint_sample, - .comm =3D perf_sched__process_comm, - .namespaces =3D perf_event__process_namespaces, - .lost =3D perf_event__process_lost, - .fork =3D perf_sched__process_fork_event, - .ordered_events =3D true, - }, .cmp_pid =3D LIST_HEAD_INIT(sched.cmp_pid), .sort_list =3D LIST_HEAD_INIT(sched.sort_list), .sort_order =3D default_sort_order, @@ -3635,6 +3626,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; =20 + perf_tool__init(&sched.tool, /*ordered_events=3D*/true); + sched.tool.sample =3D perf_sched__process_tracepoint_sample; + sched.tool.comm =3D perf_sched__process_comm; + sched.tool.namespaces =3D perf_event__process_namespaces; + sched.tool.lost =3D perf_event__process_lost; + sched.tool.fork =3D perf_sched__process_fork_event; + argc =3D parse_options_subcommand(argc, argv, sched_options, sched_subcom= mands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E0C7196C68 for ; Wed, 26 Jun 2024 20:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434245; cv=none; b=SkUOd7kDQdKESHgZFfMkjf6Yu/nNYum9lr7OY2Mj2qCSmThhz66McHPNn5YKyD8GyoNL3SrNTpX3TqUw5pa8xdfYEhiMt0Y+oyQMaRIEhhfPimCUNib7IENLhj1AhZ2maBqY1WgrwPSgYuIDtSivnmhXyPYtlkWfLmtWuUNL3g0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434245; c=relaxed/simple; bh=NNpDhvLM21Dx7gpxRlWCOf8pWQqxyB122lzmpjrWI8Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ilsPDKCC+vryVgzaHbRXGBhzjkMIflz7spFjOHG15k/byzIrGT268+j1RKc9yJyFG4ko4ClRwuC7xupd12ZjrbOinM6cuqR1z2/ROma4I4S/j5E255a64p9HpL1VPEAEGyVt994t271D20DWNJPE8OCfthzntnykix/kvxquDhI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NCACnffO; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NCACnffO" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-63bb7fb3229so153581737b3.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=vger.kernel.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=NCACnffOyIe9SiAUIgK4LEqNZlZ+RpHGbzPtywgL0L/ttgTQ+6BQnrBY1nxsRX9VUv 0DeWTJZ3ig9ffNfuDAYaSFQCi0ccFiBkzrO8Dz72cn4mQ21uc0Z7qXCI4zJMyYhqIvcv InVb+f9RDAIUz5/YSgjPsxqYOgw+Agjyg64OQaYN4hWFIXbxX7kpmvZFTXMHrjQfk89u sJLCCA/DXcOWFYZWTSjF9SHeOUkElu9u9TEYhOa3MNfpcP9T847eEM4D5anWMM7jOe/k sNR5T9JuZrzClU6DtZoZVgb/r247253dbPg1+uFD3oQITjUYlvFJyUiR7yEevvxehrkz IYWQ== 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=vUe/QoGNx3i75ApMnwBf7vM8pfB3Zy8K2bjZlt+qIsye6nQotVws2Y1wq9i2ljrkfI N9S5HIyb5+3TWSduRh5rc9bYCey5gBkner+nFi5GR31dlx6+wIZCaWOQvnAIzeNnjNSh Cq6RF/6cBMmEyr6dmdliuL/S986gWb2/0Sd6iv5qE4Xrpusj+Yuq0e6s5QqXysVo+uf2 yO162jPucYagjdEFiGGZPKMIZrymfgqewihORmSwMfp+j0sIURl4qWqsKX7D5vvAugqg sP92Bi2HC0vHQS3GKULzL7re5YZpNhkyzzPd4cwUe1k05Vn3oOPv9rkwBffN3Q8BYpCH 4qUw== X-Forwarded-Encrypted: i=1; AJvYcCVsAB2IqgZxPps2L8hznBL73DCEkAhuX3YILBkTlGpgWsF76TBoUJCuB2zwF9w+rdaMBB7jMY8dSKTxpilGRNbSZoamZ9CzcWRUxLGw X-Gm-Message-State: AOJu0YzMYCaESBSmn4Rs7dYC90TatT/UY8QMnDYfoWmCKmONCXwLsroB 4uy1z41aWlgLUIIXRW9Zoux+vpX4+t2rLkWg0CHoAYHbalzZakx9qGy+5Z61HooH8LgMG7ZO85o PgQmMVA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D mem->force, }; int ret; - struct perf_session *session =3D perf_session__new(&data, &mem->tool); + struct perf_session *session; + + perf_tool__init(&mem->tool, /*ordered_events=3D*/true); + mem->tool.sample =3D process_sample_event; + mem->tool.mmap =3D perf_event__process_mmap; + mem->tool.mmap2 =3D perf_event__process_mmap2; + mem->tool.comm =3D perf_event__process_comm; + mem->tool.lost =3D perf_event__process_lost; + mem->tool.fork =3D perf_event__process_fork; + mem->tool.attr =3D perf_event__process_attr; + mem->tool.build_id =3D perf_event__process_build_id; + mem->tool.namespaces =3D perf_event__process_namespaces; + mem->tool.auxtrace_info =3D perf_event__process_auxtrace_info; + mem->tool.auxtrace =3D perf_event__process_auxtrace; + mem->tool.auxtrace_error =3D perf_event__process_auxtrace_error; + + session =3D perf_session__new(&data, &mem->tool); =20 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 =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .lost =3D perf_event__process_lost, - .fork =3D perf_event__process_fork, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, - .namespaces =3D perf_event__process_namespaces, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .ordered_events =3D true, - }, .input_name =3D "perf.data", /* * default to both load an store sampling --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C9A8197543 for ; Wed, 26 Jun 2024 20:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434248; cv=none; b=DegAjawTi3ABJ9BfzN+E+xApwYAfQHXKplJy6XX+xsXrYfb0DJhHsTxT+jrEatCvyMgc+rsfLR5UwuQvkMZC4ceIGQZ4P1hP/16xCTvYVDC/v4UWqQna3B8JT33M68z4hsRi1VanU5EbsCfT0DCS7gbS8AtXQf30uXHnXa/Ojs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434248; c=relaxed/simple; bh=wyJ+MS1hXvC6jnjDEgOqcoNvRhtG2Ev85ERR2gsbIdw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=umLsjVua0if/2R5g+PU2qXUHJgc3jDsQAEynJRB5lRJ6lkhrcha8Qzo3VGxNEu8MQ8dDjXFaGvdBhBSpfUNSchvLuFXtwAGlWi9G+xl4+mp5XKyYIq0cXfx/BjvKKx2NpbjHMqIkAknoGxg0FfAm9Hzkf1loxMdypkDKZZy+p18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=t8kZYEJ3; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t8kZYEJ3" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-df771b5e942so13633814276.2 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=vger.kernel.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=t8kZYEJ3Dp7rq+wqrkUv1eoQoRlmB7Y5UGfdOUoVUP0M/e+C9pAp023YchDFEs+QP3 Qq1dx3bI5eU9B1UM6QAArDrX+rPdWl9k0uw/3vVhB45FWZcmeP36b2SLbogJx956NHj7 0jicq/1SYjEzxl/BxLcUJFLWOKBMKyp611r8J/IZ56QgfF+qr9ve74Bv/EU9BCWYT2Ww eYy1REbmJmRY8T/rn6FowF3AVtybPweef/HOQ8NCrCKdPBAvftmgfARFwAcUj3GJiw5u 6ms9OThTKyonxSo60ZAX9j2g4J4ORnX2cCtRxBMwls6ajDmaRODhHHdCPq+1KcFQl2+v tn8Q== 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=Db6gk+2K1iGJAiFbqm4hUt+LxCvGfCO1aMmjqgl0nYFcbD6XPR29ijt83mNcyh8SOW 81iPN07jW6MWT9xSZdM+gOQ0fR25ajrmIcGDMLE4Eg5MsbjXdd9XahNSRylnD8L0k9Rv 8rZnJfGL/1FrRoO0hygxilsQtm339RwFtdSQ5RmqwvUn47Y2ylykGvqY7Mt7KoLG5gcQ OQQ0LTGM4Ocjc1op0y7vLv0f/sR+CDXRyfxjJbOFjJ69AeHrru2lnt61J4VxNHSz7HZL XyTu2WTebPwtSDnzJtJtfTQqfpz9SFNIvKsJCqf2kWgvsCjOpuYxiG6iqAVqbV0IkvgU IcWQ== X-Forwarded-Encrypted: i=1; AJvYcCV0ifkEgEofr1TCS1MAN0XHGHgKnD/0Gw6Xb4RymDK8vtwWaSd9a3+wF1uaJTv88AsFpGLAhn+n9nJEbly4hohZ7YbO0U4997ZN2mYu X-Gm-Message-State: AOJu0YzivbdYQxDQ1J7bQA+e28t3qeO+NAVjNcYJYuIEyiy6EK1E+317 llvLAqp1cjvBVQnRd0unvWGaeC5uTbSaWXsifAoAxAA0zQhg7Cub1Ovgr/HAA6HvZsp1uwzXwPo OPD14OA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D PERF_DATA_MODE_READ, .force =3D tchart->force, }; - - struct perf_session *session =3D perf_session__new(&data, &tchart->tool); + struct perf_session *session; int ret =3D -EINVAL; =20 + perf_tool__init(&tchart->tool, /*ordered_events=3D*/true); + tchart->tool.comm =3D process_comm_event; + tchart->tool.fork =3D process_fork_event; + tchart->tool.exit =3D process_exit_event; + tchart->tool.sample =3D process_sample_event; + + session =3D perf_session__new(&data, &tchart->tool); if (IS_ERR(session)) return PTR_ERR(session); =20 @@ -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 =3D { - .tool =3D { - .comm =3D process_comm_event, - .fork =3D process_fork_event, - .exit =3D process_exit_event, - .sample =3D process_sample_event, - .ordered_events =3D true, - }, .proc_num =3D 15, .min_time =3D NSEC_PER_MSEC, .merge_dist =3D 1000, --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D4B2197A65 for ; Wed, 26 Jun 2024 20:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434250; cv=none; b=WEA8UfEhMOcOS2dTa3riAYohMda58v2TMAn96LlOxrPhP9Qu/Ua5VmAh3W/rHtxg5M2rM/eemItWFfLR38WGLuRtdXvTWBWP2DvL5wGpAeor4wQeFLpdAEOo9bA7KqN6HIk7iZ9yhaQ8kn/YI7qc6SoSm8N1ebumnhcHjxFKa1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434250; c=relaxed/simple; bh=76f5hIdhPASzAgHsGB/OHAjt6PyB0XUm4Scq3YWqa1Y=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=de+vnD5K8cMK3AZEL4zF3AOPighJdCDj1HMKK61h1ZXbWDP3MWGtGfzWyfk+KEzMUPr4sk5qqKF/8Bnn775R8geF9ZUsM9JHBX6HvarCdhrZJk2zS+zIuaZ1/f22WdDLJRbKnb4crvV9XTBH1ewKfohFk/8BYoBsBqx6lvAzDgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=B/LYpcN/; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="B/LYpcN/" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03356970faso1734604276.2 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=vger.kernel.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=B/LYpcN/fViwIGxr50Qem/TbICEM+qRsV8+UgzQs2Sx7POUn/s4dm9eDlZCPKTIjyD BY5h98rFHlT2d3nR6KKgEoDIAKG+JvMo/xOkOl5w14OZ8lNxmhfi9EhvZx3FiSr0x/Vg pEOn3P6QTJ+CcFUZR2I3yeWPhxsz2XdCovdmByjdHihV3oTZsbBY8rN7cNWfyoJs8TZc skwVhg97sa1EUP9D23Q3IjmPOQuooVToT2qo9Ocx14jev3soOFG0X9SP/I2XO1sSaUuJ MbgJr6jPRzXRDruyYZ2ftGzSRodmR6LQxVUX0VEjdbVQT8PTvi1ww/+tv++tFlsOlivA x1iQ== 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=n4ic0TGr0OlPUIpO2/dNr9oVTmqWZPap6378Wgs1IBDblWmxN4Qn8Eg7ViqbKMkPTV BmiDynrHQxceFUoDcXw+yZ+Xy+ffoGqG3PA02hBumEiaFDV3w/kChlXbAoyUI4AiSLIg ufrnHVW7n4KlsdjihWRCImjyIIHz896qw/9+fKQzjZTchuy2J2qj0O63QTJ6Ynn+52JK oV1E583DDtYC9BUyPodNksWngPFrg288htdPaubqh+hkNdAjsgvIOdpxReIpo+bq8ZTA uI6CaciWt9xkjKAjhC+sIKnX/seMMTJ4bNvaRiezkJcozzpM4AQFlibYX3/FVVMCC4Df 3syA== X-Forwarded-Encrypted: i=1; AJvYcCWKtGHNF+VKREVQ3MaYSxYImDFpmSkmyAN9J/41rmY4TEL6b3Bwct9KC9Vq+damgS0+JtYeHuqiMvyfqD5NQ7dn8jEkkGiCZixRve7r X-Gm-Message-State: AOJu0YyQEvdxMJlftt5kfXtZm2NKLBfMDrcSJ5qj9gqtd/5GzcViS/Ar 1dGncREPkOx4fRYviEYIopZjoCPNJ469l/ls/HhOzX/X7prJ7fun8fd/UEe6To/uta5mCo1RcTE 8vvjbcQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 per= f_tool *tool, return ret; } =20 -static struct perf_diff pdiff =3D { - .tool =3D { - .sample =3D diff__process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, -}; +static struct perf_diff pdiff; =20 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; =20 + perf_tool__init(&pdiff.tool, /*ordered_events=3D*/true); + pdiff.tool.sample =3D diff__process_sample_event; + pdiff.tool.mmap =3D perf_event__process_mmap; + pdiff.tool.mmap2 =3D perf_event__process_mmap2; + pdiff.tool.comm =3D perf_event__process_comm; + pdiff.tool.exit =3D perf_event__process_exit; + pdiff.tool.fork =3D perf_event__process_fork; + pdiff.tool.lost =3D perf_event__process_lost; + pdiff.tool.namespaces =3D perf_event__process_namespaces; + pdiff.tool.cgroup =3D perf_event__process_cgroup; + pdiff.tool.ordering_requires_timestamps =3D true; + perf_config(diff__config, NULL); =20 argc =3D parse_options(argc, argv, options, diff_usage, 0); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14ED9197A67 for ; Wed, 26 Jun 2024 20:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434252; cv=none; b=VZ6uu1PfzULa0DXa6JHj90rg7jf5sxI+qu/VXWcFLRG8gZEJvuAj/bx7rzRA3+1AdBOJymkc6v+uztStoPt8KuxoqOzTLtF67TYtATHm0ZrCOVfI7hpW6MBs8bHP3p6H1jMIvuyqnc7GcQRU0bUHLIldZ8OSEcitq927c5OCjDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434252; c=relaxed/simple; bh=dyBAFLuB77d4FySD0MlGoqSmYtedpVSJiMTBSe2shXk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=U1dVG+66P9M/JHUlPqNgY77pc9zaww2XNXn67Bcml63RXBvgU5Mh6p/gNTxApjN+zFejYidycmKGGjmiWMR1pd44MYlgb5zhiweaafrqiZO+sp9WD3WG+ajAozg9zWZnemZBHK/HlGMcDFrNh2+mGjQCDl7eFya8jVniTxfQVcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hhTj+lrK; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hhTj+lrK" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-63bab20bf5fso164083697b3.0 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=vger.kernel.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=hhTj+lrKi3vUuWI2us2XzINk8TWvxDAHYTXFGaNBD8/wV3uikx+j2UY9sgZv5YALhr xaT3CtBq/xD3w60si67MpNJgGXqiBD9A3bJ8G9t9ukagSmvOM0GsIMA4n7I5dDArLZrp vz2VNdi513c9jtsaL8XY1k+A9qxSBFEzO6uFycV1x43CfQqjezX6ZOWxnPM2FCkQlPK8 RRt8ITaGQ0M9Oc5xQBKxJXnbMC27m7nstVgYlTOLzx5NzH7Wlu6RwM/kpwfM3YDPWH9A J4+b9z+vEQEhRRfO472AQK8hscUbMZe7Y2VDe+TAgfTC+WTUyEzFMTuPfBKCE8IvPyrs mvnQ== 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=HGK7CsI90zJybsfyrQlDWMF6OcDCrghs+aUAEKwqj8MtZxZcj0qh1P0Usw7NFAfm2x Kbc2xpMSWZKCfUDsm7ZM2tAQftV4M5bNfF1iO4d0Zguq044RcQmbadcsiYlFbThhbcyu lPcV0G8HmwJ9CDuoHhmtKaieJblWUZXVwcnXYzHWa/gdno65zaOF+K7pBor4ErGmrWLW uRGK1ODRJv6JEzRbFCaZlVZD5XclK25A2e03m5fawK29fISt4rwSq8+I8odbXv4H80Wf iKAAS/msfkDF76g+8N8bSdH1cZKW7Jk3iDPn7ERBrRyhFxN3UiwQDjOGmQ8Jm0cvolb5 cdbw== X-Forwarded-Encrypted: i=1; AJvYcCUYyirW3K9kl71Hhdr8CH3bQdFfLCuBK6Czex/WLB3iiOnTdiNzNPz+hhplUeRRnbfGXYgCwcwBAW6Fp+oc0JAxnYHgWcgXaqU6KEFQ X-Gm-Message-State: AOJu0YyYgNFEvyF/cdl1MYxJ6qFfzvIvPH0wg8mKFpqRPRnkuubCbRcq 2J9HESFGxATomWtqNAdD92MnpCXbvJJN0yHiFwNoXX7gmjp7s0/HlH5MGtpufyG0W9LM/Po/0r2 mz3sIrQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-con= vert-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, con= st char *output_name, struct perf_session *session; int fd; int ret =3D -1; - struct convert_json c =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .event_update =3D perf_event__process_event_update, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, .first =3D true, .events_count =3D 0, }; - struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, .path =3D input_name, .force =3D opts->force, }; =20 + perf_tool__init(&c.tool, /*ordered_events=3D*/true); + c.tool.sample =3D process_sample_event; + c.tool.mmap =3D perf_event__process_mmap; + c.tool.mmap2 =3D perf_event__process_mmap2; + c.tool.comm =3D perf_event__process_comm; + c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.cgroup =3D perf_event__process_cgroup; + c.tool.exit =3D perf_event__process_exit; + c.tool.fork =3D perf_event__process_fork; + c.tool.lost =3D perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + c.tool.build_id =3D perf_event__process_build_id; + c.tool.id_index =3D perf_event__process_id_index; + c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + c.tool.auxtrace =3D perf_event__process_auxtrace; + c.tool.event_update =3D perf_event__process_event_update; + c.tool.ordering_requires_timestamps =3D true; + if (opts->all) { pr_err("--all is currently unsupported for JSON output.\n"); goto err; --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27C9719882B for ; Wed, 26 Jun 2024 20:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434254; cv=none; b=RSGOVZ9HhCT7hKFzVjNOnDulYyVjVE10zD44kprCuXmLgv1dS5qvL7d+rM/NqxuuAymMDd+wX1rm4LiU+NTGGvZyxaZs0JYNKMlx/i3WAkPwIWMVkYAecJycWnIyGQ7TbE/jk+W8ATZJ0vkWHWsECBmmxsuoj6qGvTmPFPQFjbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434254; c=relaxed/simple; bh=4hregmkychdDNk+jks/Rw8XVYDtpylXDSeaooVz7NiM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=aaJ3bFOBJEUmHEmKEPiPl5l3i3mVfGD4Wa8ERFXu3W1NRG4Y7BUuS3kNxj8aaEAme/00BAEQv0yPqhW2bl8S5C5oiCySfVVZdV6gOfPJ8M+6aMHkHWyXfx+ugkS9YYUIYXpU07hvWZB0hIis+N0ZQFfomgy5g1UF9CnmPX2Jxuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3NGhoZgj; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3NGhoZgj" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62d054b1ceeso146328317b3.2 for ; Wed, 26 Jun 2024 13:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434252; x=1720039052; darn=vger.kernel.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=3NGhoZgjQqk4W2wO9UoDeg9Z4eZuv2ksqQ36zy/zczw0KWTg3MSVqn9ocB7luMuLow qDiEdCRSBnIIkBnGNIsp5kFKnKiO6xnyasCC34kUhdxBLL6R4arje4VEL8p1Wx2lUvDv JldMvLUiyFIjQwAzph0xjCZln6VWWQOkksYIS7mBLLTyg5ShV0fmcqq9fE4qEBhV+Sec mM87bWICpGEn1y6mnU90k3HAzE+SbY2la3mMM3APFzJBxp0/vWKF+X9Q6nAIovBrCQA4 uVh2Ql7UcoeZ65tmla25Zs/NuWRcoq3adYgGohnkRXIlGd19Ja40fyaGIivITL7Qyyxq G8kw== 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=SbV1v1B76bZ+0kBXZUSa5dPtILqM9CKVz/uxBs95hMehPaQ049nDxml2RspR8sFCzQ bMgSSRfxsZfe5raWcyuuDkVibzPCN7GhOtkvGo0TWhhywFCQmaOq3IHzzTOR0DzCDSLx iYtba/TNwFRDqdTEnPy+AK2hHKu/rTe0h5d/esA0IuNSEzLAUPKSAXBFrpzmC9YddacG AFfQ6JXng9QQ6gTgcBjm/XEtU495yf7TJMsYKbEdHgfh17jhGSBscQWfjggYCLgMfS5K afmUbYLGiHTbO9HXS+VN0cqfO4YNAILsFEHsdHYRDXVAsRryNMxkI3DP1ym/QoM6C5Zo T3FQ== X-Forwarded-Encrypted: i=1; AJvYcCVgbVFqkGQLLwEOR++7Ql/bXDgQAsnMBO1j8SabeqUQbozSCY6nDkGUy3Dbk1akei0te2JPhGsciW16lw3sAXSuNla23oqpsiT/6ntk X-Gm-Message-State: AOJu0YyDch/TrtajZCBZxgqujipoY1HG5r3qj7EnXhcePiEmBaewzxcj i8EOSfB6I9eAEBFSGZWQQ4/lG4sDuX7yEOXEZZFCKlbKl3u6myqgS53ZZUmfe83DeuJLKaFGmXp uCL4teA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-conve= rt-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 c= har *path, .mode =3D PERF_DATA_MODE_READ, .force =3D opts->force, }; - struct convert c =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .tracing_data =3D perf_event__process_tracing_data, - .build_id =3D perf_event__process_build_id, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct convert c =3D {}; struct ctf_writer *cw =3D &c.writer; int err; =20 + perf_tool__init(&c.tool, /*ordered_events=3D*/true); + c.tool.sample =3D process_sample_event; + c.tool.mmap =3D perf_event__process_mmap; + c.tool.mmap2 =3D perf_event__process_mmap2; + c.tool.comm =3D perf_event__process_comm; + c.tool.exit =3D perf_event__process_exit; + c.tool.fork =3D perf_event__process_fork; + c.tool.lost =3D perf_event__process_lost; + c.tool.tracing_data =3D perf_event__process_tracing_data; + c.tool.build_id =3D perf_event__process_build_id; + c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.ordering_requires_timestamps =3D true; + if (opts->all) { c.tool.comm =3D process_comm_event; c.tool.exit =3D process_exit_event; --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 631A8198A01 for ; Wed, 26 Jun 2024 20:37:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434256; cv=none; b=EIbW3Y724NwFVV1IEPhmHpWXDdKItLUCDIs6KjTgIxlpLxdOM1CpVN069goPfIw3EN9mD/7e9A+pSg2aEGxT2isNmaZbzokjB+SJN6NwbKZEtFbiRj6FBj6HRLDS6UuqGdPTfkNu7QM/5aHUUWEcC2RYKbsxa/IZ3asgSi1BR2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434256; c=relaxed/simple; bh=vLAWwP6pxeZ3+8l+944tuEizrGnbW644ZT2RUZBRZLw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ScCD5Ct47Dno81QUWSd8te+Pt7XVjqlpKTRJrukAfgocgwsujBxW3e7gCIT0L1ajp/BzKcMRnuMtWutwO8tPm2CT440LjTlnx1bPVoz2wfGgdeLJsRwyRb6WsP7gtMfOD5bjfKR6wXDP0l2AFrMKIlPRr+Y8PHHfgzF+oqDdx/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KWHjCidm; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KWHjCidm" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6452f8f2942so77874697b3.1 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=vger.kernel.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=KWHjCidmBAyCkFGW6EIyO48NzgysWZZxlcV9NlHN2Zg6eWifjpyWwi5k3YBFVSEoiY 5y1lUY85q+T3atzhq7Pd7eZKSzKImyRG0l/hP40Dg1/kfDNdZSbosF9GbJtSxSUdcPsd Y2c91tVAtccs4XJgF9jAl6SgySMS7+K4GPVyN0lQRhldTCIuS+FLR+Y2bh7WrC6Vch5A C2Pqbwp6Mvi0zQ+TpB9aJPeUdlnocKxpDZn/HBE6ZPoEvjz7KFEA4zsKuAXSUzHvlu+v Ql1MSq/nqsjckuMaOm4NObCxD1O6QyvfJpjT63DSk7RJJ4YD7ALn2rhFR0EclqgDsbeU 895A== 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=W0yuWvPga54IWzJNPHVIoUgEzVeQ8WxUsUwnEL0up0gQMPi5CWvDWBGbXF8i4Wa6/C IwvRfc28OsbRtbyO3RRhy/LiJbKFaRHdvtT+dwFMjKMBX9oMO5JtXK9Cmypyu1AR54/c iK2ZDeuUwCeLWwOHMMVy0kD1saifL5pADWa/iwn/HbPe2bC3nbTyP/4LqQjrRqv5Ay76 zfpDEM88FA2I6ZAEbl8iOzJySxPgOX0SxD7rqLKlhaK4JhbJtgP43HQC4p6Iiq5dzwcj iuvQn7ElNkq8SoD7JPtAwBpQUaifQr7otjheDVS1z9dmNQsYciYeY3bal/XoVPxHlQ6P en7A== X-Forwarded-Encrypted: i=1; AJvYcCV6f0eSa5o4EVvdWKngdKma20Lm5PYVQgqeatWOJ5+lGgJ/eq8ocK6w44Lua48aaB+b+mQFqBjwul7Nm1IsNxP0ScCTLGGXiY5OHLJL X-Gm-Message-State: AOJu0Yzu3MknwrcjPJjeQNGs7L4r3agl7MkqSCVgrAkOW/lQMmuZXiIS YRNbc6n34NhpW4EtoNYQFZP0Q4U5VJnny9ADWTAPNjsZTu9W810Cn62XUYyQ0VJkMqmMTw+KLe5 cr3gpfQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_updat= e.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_s= cale)); =20 + perf_tool__init(&tmp.tool, /*ordered_events=3D*/false); tmp.name =3D evsel__name(evsel); =20 TEST_ASSERT_VAL("failed to synthesize attr update name", --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D69198A28 for ; Wed, 26 Jun 2024 20:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434259; cv=none; b=u71ctjW2A1fztBa1qw4G6Xb40kQSXbvYplnItF3ciotGCm4YUuyZ3BPq1LojhYDMPhI/dSelTzs4A3S9TytvuKi17iZ+U+rlS708p5L94dPl7q+Gnq3oStlXPm2Jj/+o/6o2gUJui3X83F3YjknIHdnineJmgOKdYYWiB2HnUcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434259; c=relaxed/simple; bh=k7QXVgVjC5ziryU8iqEZw+jIGB8CNwx93bpexssSTVM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=i7SE6h9oBr+f496aAMaMuyG68sDOTv/1j0N0L/YbuPHRBXtcPyqS+0iWUhaAIYbkzN1LeAdab9OaOCLT7tANkhaHpHwEq26SYv8r2SXl6p/wOzhtbhE6tW/N+map5jJGI9zMZcDWcLD/iSQT5bmWlAJIHG5wPmkIs/+h6MIz3b4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JzcfUK3s; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JzcfUK3s" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dff4a650404so13945788276.3 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=vger.kernel.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=JzcfUK3sUNepxqarsISAZwjLZ1X0ZIztuQIeLhyOpBQiFLidZT7wqpBHRN5pB/QMoX ZKcrX1vXSOuX2iCq4T39zhyN4xGU0eXcqoITSSvFGW0gQh8VOjll59+mdcN2yrUBGxbE vuf8ZfT/DOkJMaya2qOD6rQ0RRntzUSfiWGc66fGwxOrxQj4TuJJ7PyOU32T9BUjWaAo t+5oiK/FZKNWrYLpISYksJn8ksPgWUGwizDt36dfJ7bs5ThSMFY4aOmamH+U7pPRZZ+y /I0FBbLVqVHEdhBEzpHzzqnGCOzcd3pzOnynSb6n7uM+SGFPt+2zdYEVQ9QrMJX7PerE a+EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434257; x=1720039057; 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=E1JdETFurSTYJCHY1j6xmNaazN2bu6veg0/McFx/5bje6UNJ8fnKpZHE9e4pbwu+OU XcQ9rKBhBN+peZUpgmKA7vTtPI2HBV6Mh45h9zWG5hRJgYRbOMC7lLOo0E1Wc5G8k4Z/ avNbLx7H7hQRbN4LkE1EAlWoa5oWEuVshKoKpAIdEBpSDn9Eq8N7cJTzuZ9qoYxORfRX kS589HKLiFNrz5Bzmw8EGHW1YVG3dYy3ITHPI/JsnCNtAzABP5L8bynJPVA29WrMuhYA +K8jDPq6Uh7SXs2pi53IQX1Rrv0XXPOrF67pm8ospqQZkw2lMOlIl86BjBWcVYtf3Nwa bU3w== X-Forwarded-Encrypted: i=1; AJvYcCVyrTLYNOQw6hvl7lEgNvfuTYDwNv0bs0nSKu4XAH972PQQjnPsBUsuZJHhibjZUcOuvbpnnEXLl/+QWsXG/m3NGcM0NuolwbwmBffH X-Gm-Message-State: AOJu0YyQQQYZkzLN4daENGK69nNjsJmYIrqq/WIsxgDjZXseKg2A3SqG 97MsIPAPQGCZz/D9Xig1MKfeByCNMbgwgzu2Fj+R0s8l6zohXhOVrMP0Dmaus/8WgZLcLP5b+Vz nBBVXMA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D { .class_list =3D LIST_HEAD_INIT(kwork.class_list), - .tool =3D { - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .sample =3D perf_kwork__process_tracepoint_sample, - .ordered_events =3D true, - }, .atom_page_list =3D LIST_HEAD_INIT(kwork.atom_page_list), .sort_list =3D LIST_HEAD_INIT(kwork.sort_list), .cmp_id =3D LIST_HEAD_INIT(kwork.cmp_id), @@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; =20 + perf_tool__init(&kwork.tool, /*ordered_events=3D*/true); + kwork.tool.mmap =3D perf_event__process_mmap; + kwork.tool.mmap2 =3D perf_event__process_mmap2; + kwork.tool.sample =3D perf_kwork__process_tracepoint_sample; + argc =3D parse_options_subcommand(argc, argv, kwork_options, kwork_subcommands, kwork_usage, PARSE_OPT_STOP_AT_NON_OPTION); --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF88D198E6E for ; Wed, 26 Jun 2024 20:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434261; cv=none; b=Eovhp7N4IhxUiSY0n7KV6HLkwQc0ed6N+V3xT24+P+yjYK4MJYFlxVGTIrCFj50pPpXSCoWUXqiih503Rh1kxb6Xl3XV2RK7D7mdLpYn2zT6EmlzBh3IPFR7bC/yQsr+cxg268YYHzEzoxsnWqOZgQpNYW0N6qeXMdeDd0LL9Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434261; c=relaxed/simple; bh=OpyFDAZT1rvjkAy8/+JR0tp9/7ny2BvFcr8PIIn+PJU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=CLZjB5aLttrlEub+7as0EmCEU3mLdhgPSlOJ7YhpFwFUkmeSPBYXUtZo4zG3Qw7t53Rni+xEB/3vray++tKpRtPBzb0Nu/5E21JhO66FqSjU6ro28DSAM1AZ09bYW+Huf731NbxWzwTddc4/zxrpOYrItYgcz3D3+I4xHcDofbg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dCAu9+/j; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dCAu9+/j" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6313189f622so158244517b3.2 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=vger.kernel.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=dCAu9+/jA7TCs4uzI916un2bdbq+vmRCNUP/E/inIB6Z5zFclaak60vO6lYilJiaYm G2cq68ucfBXoldj+xzUBoKtGLUAQ0DMca7kGNwSd7s+N6wI9go20coqZ31Jy05wEANRX SMffVug7t4Y9o9VEFN/MLdP1I8PZb3cy6in6BnWFdgwflQ7ftlTxVO0Jf9ie0nwtkyzX zZgZNPx/aSpZcTxV9VgE2jQThSV0HxFe3mUo1IdgzmwhVwNtMqyAiRVnoSrr4zhfy5dQ QCKo8d/yKd2PIpksP0IMTSETRohsDAyGV6Zseu2nl+Y3/z0wBTD8NjXXz21zLvj3bZw2 Jb1A== 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=SjBlFMzaLFQcz1BOTjuwxHwm7LnWQ6t5ucmVgVwzPthZf5fGejpabEhZYUlNAQxpGp cWFiYjsCQSnVNyky8Rg8NmmjXO7GoRwsv6h98DAbsh5AhADnxjT10Z3j4zC23Qr7V+BK WLWSog87GRCsgT1Ir2kxHsF8UJD5T3unUJGRR+Ga5FWxGVXQyXkrjuzYqj9CjcW9r/Gx ptw/7ImWmIO2Fi8uKAifR2vyQWhCy4mqBiLOvJzJARiGdr72B7WBWKUEefWY5khrURVE 1tvNkyA0+jngoa+Rm4BtQWDvhJcgWu15CwkAj9epU7qQn9FAhiwmkG8CND5AEceqETKX WEPg== X-Forwarded-Encrypted: i=1; AJvYcCWREQqhWyMtu2o+TKSq9z6fBrpz4a6gbMwE+RadE4u7jCFalPuvinYmHKjbsPxBW6xhlPYsZGIYkVITJIU9ITFvt0bUhO0WMe4yfunI X-Gm-Message-State: AOJu0Ywofp0WpBTK17rNXdTxIUd0J5TeoCROE4KAtxTHjM70n+zODLUa UQSuqC2+x5+wS2bMUGhNYYzJPHPkks5beOOiKrj7dhF3EAkMd23038Z98p1JyjyaotENpLH9mQs yYsvOdQ== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; =20 - perf_tool__fill_defaults(tool); - head =3D 0; cur_size =3D sizeof(union perf_event); =20 @@ -2159,8 +2157,6 @@ static int __perf_session__process_events(struct perf= _session *session) struct ui_progress prog; int err; =20 - perf_tool__fill_defaults(tool); - if (rd.data_size =3D=3D 0) return -1; =20 @@ -2213,8 +2209,6 @@ static int __perf_session__process_dir_events(struct = perf_session *session) u64 total_size =3D perf_data__size(session->data); struct reader *rd; =20 - perf_tool__fill_defaults(tool); - ui_progress__init_size(&prog, total_size, "Sorting events..."); =20 nr_readers =3D 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 orde= red_events) tool->finished_init =3D process_event_op2_stub; } =20 -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample =3D=3D NULL) - tool->sample =3D process_event_sample_stub; - if (tool->mmap =3D=3D NULL) - tool->mmap =3D process_event_stub; - if (tool->mmap2 =3D=3D NULL) - tool->mmap2 =3D process_event_stub; - if (tool->comm =3D=3D NULL) - tool->comm =3D process_event_stub; - if (tool->namespaces =3D=3D NULL) - tool->namespaces =3D process_event_stub; - if (tool->cgroup =3D=3D NULL) - tool->cgroup =3D process_event_stub; - if (tool->fork =3D=3D NULL) - tool->fork =3D process_event_stub; - if (tool->exit =3D=3D NULL) - tool->exit =3D process_event_stub; - if (tool->lost =3D=3D NULL) - tool->lost =3D perf_event__process_lost; - if (tool->lost_samples =3D=3D NULL) - tool->lost_samples =3D perf_event__process_lost_samples; - if (tool->aux =3D=3D NULL) - tool->aux =3D perf_event__process_aux; - if (tool->itrace_start =3D=3D NULL) - tool->itrace_start =3D perf_event__process_itrace_start; - if (tool->context_switch =3D=3D NULL) - tool->context_switch =3D perf_event__process_switch; - if (tool->ksymbol =3D=3D NULL) - tool->ksymbol =3D perf_event__process_ksymbol; - if (tool->bpf =3D=3D NULL) - tool->bpf =3D perf_event__process_bpf; - if (tool->text_poke =3D=3D NULL) - tool->text_poke =3D perf_event__process_text_poke; - if (tool->aux_output_hw_id =3D=3D NULL) - tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; - if (tool->read =3D=3D NULL) - tool->read =3D process_event_sample_stub; - if (tool->throttle =3D=3D NULL) - tool->throttle =3D process_event_stub; - if (tool->unthrottle =3D=3D NULL) - tool->unthrottle =3D process_event_stub; - if (tool->attr =3D=3D NULL) - tool->attr =3D process_event_synth_attr_stub; - if (tool->event_update =3D=3D NULL) - tool->event_update =3D process_event_synth_event_update_stub; - if (tool->tracing_data =3D=3D NULL) - tool->tracing_data =3D process_event_synth_tracing_data_stub; - if (tool->build_id =3D=3D NULL) - tool->build_id =3D process_event_op2_stub; - if (tool->finished_round =3D=3D NULL) { - if (tool->ordered_events) - tool->finished_round =3D perf_event__process_finished_round; - else - tool->finished_round =3D process_finished_round_stub; - } - if (tool->id_index =3D=3D NULL) - tool->id_index =3D process_event_op2_stub; - if (tool->auxtrace_info =3D=3D NULL) - tool->auxtrace_info =3D process_event_op2_stub; - if (tool->auxtrace =3D=3D NULL) - tool->auxtrace =3D process_event_auxtrace_stub; - if (tool->auxtrace_error =3D=3D NULL) - tool->auxtrace_error =3D process_event_op2_stub; - if (tool->thread_map =3D=3D NULL) - tool->thread_map =3D process_event_thread_map_stub; - if (tool->cpu_map =3D=3D NULL) - tool->cpu_map =3D process_event_cpu_map_stub; - if (tool->stat_config =3D=3D NULL) - tool->stat_config =3D process_event_stat_config_stub; - if (tool->stat =3D=3D NULL) - tool->stat =3D process_stat_stub; - if (tool->stat_round =3D=3D NULL) - tool->stat_round =3D process_stat_round_stub; - if (tool->time_conv =3D=3D NULL) - tool->time_conv =3D process_event_time_conv_stub; - if (tool->feature =3D=3D NULL) - tool->feature =3D process_event_op2_stub; - if (tool->compressed =3D=3D NULL) { -#ifdef HAVE_ZSTD_SUPPORT - tool->compressed =3D perf_session__process_compressed_event; -#else - tool->compressed =3D perf_session__process_compressed_event_stub; -#endif - } - if (tool->finished_init =3D=3D NULL) - tool->finished_init =3D process_event_op2_stub; -} - bool perf_tool__compressed_is_stub(const struct perf_tool *tool) { return tool->compressed =3D=3D perf_session__process_compressed_event_stu= b; 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 { }; =20 void perf_tool__init(struct perf_tool *tool, bool ordered_events); -void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); =20 --=20 2.45.2.741.gdbec12cfda-goog From nobody Thu Dec 18 07:12:12 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A0D198E89 for ; Wed, 26 Jun 2024 20:37:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434263; cv=none; b=ObClr/TBj10N4m422/VYL+ecqlW2ypOCT6pSgWmOtv7FWPC8IrO8PMkWxdsdE4dyU4CBdyFTdyoWvF24XdVlRCjS/SLj9RfowauKdPXp+Hoq0Y306ByE55J4CL+QvkjZhvnzIswIBvsd3K0CnbgTtWiMn//wJ1zizGqrAVDlwsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719434263; c=relaxed/simple; bh=WN7MjOnN4Zn7pg1cZh55iymkjdS8QmRhMBO2woXN7eA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=P38HWuy3ZLVv675T6xrMjWsfFo3Ebwiim/UB/N/ds/K3C02AXLHFzfz2L+MnqpUwbLxKFvi5YQs8CWFqCdP2ow1fAL8l0FnQNQ2jNEWZni/W63LDSW5niPlRu4MZU/IPeAHdTbxuu6euedLODTxmkrffVuAVeHmB8rwAFvCBcNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QULJJBHk; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QULJJBHk" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-645eb1025b5so59921467b3.2 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=vger.kernel.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=QULJJBHkDX5WsV8ubLs+wTMlFoxiKrexTI9oK9IS0NC7JmoFBdvdDq/1qkysx2QHwi HICpQF286F8bQu5uItbEguI7UX1QE+2vBdDvIEohC/kDsJnDuJDRVZdgb6sARJAzFQqF 25+J6rXDbGOR+Vng3SSxQfc3yZkKKd1UD1EQVUX/IgorYiZEnieZNSPUIGMKG9z7Q7Kc ZRkGx/gbVihHv8BQ1Il/Ne/CH+lZIovck/O420rEvZzb3Uk1orH4t/iA/HVavsk6pBa/ weAKrpr3tEiWW3WTFjYdbvwDnNxmITxuuEweNGXyeYxuL5c06Ed8qnY0GAU7eM5q/RDE VyVA== 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=QE691A0oE6/+MjSqe8geTT+VXoU7zRzpmq3zFZeJYRmi/LIGiMWRg+xyNRsPe1fpev oqs19AVqbMxHn0J/M7SOY0z1zKt5pHCG4Si3Hxa4J1OGnvCE7M4+vWsFDbUE5lTJSRzN z9b/b3GmEpNTEiqNHYeD2OL3O87CtheE4YhIRNAPI7f5GtIIAT1DOxwswq8B0eE7ZMDr rnqtamtE1PbQnkMOIrkfk0qGZ8L9Ee7UfGwZFLISDGXFat1Aufz1aOxFjkmDKqlhJtnI KpfY/tqdJ39QT7MiNAzyPOpmviv7QTVGaMMPlFWnWPDVyg8/fYnvf3FdQBq3UsYBsm2B qk1w== X-Forwarded-Encrypted: i=1; AJvYcCW2OPQLODewHg+G4u2O3KB5YD6fCHxB8svMTuyz6vsU2zOqlHd2ADI4tI7QAWUSDGVAkddQwCPFOBQbJKBjflkl+AAnrHNK9WhfbE3M X-Gm-Message-State: AOJu0YzmM0n1ur0LHDle6Y3yvo/rAUFizwqFhVKUjLHvSRJ0X1ck2u3B Lh94JpuZR41LvUuUa0sPFA9cNH+WelVQKeHgsqifCwv2XsH8zkhPAd4LzGbGRZb21R35QIX6lmG BoYaeOw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(stru= ct perf_session *session); static int __perf_session__process_pipe_events(struct perf_session *sessio= n) { struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; union perf_event *event; uint32_t size, cur_size =3D 0; void *buf =3D NULL; @@ -2153,7 +2153,7 @@ static int __perf_session__process_events(struct perf= _session *session) .in_place_update =3D session->data->in_place_update, }; struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct ui_progress prog; int err; =20 @@ -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 =3D session->data; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; int i, ret, readers, nr_readers; struct ui_progress prog; u64 total_size =3D 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; --=20 2.45.2.741.gdbec12cfda-goog