From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 992213FA5D2 for ; Thu, 19 Mar 2026 23:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962644; cv=none; b=PXUFOupvWTHfALUQFvbPZPwmvpjjXnFwlwwvz/YOqVkTZUu8Fw4j7a3dijHHBKv2i6lDLkmVB38pJrZMltELwAue1+vwNp/CJMBjzh03pez1dd1lOvtoFDMWT8G38EYWP2WdsemRGlJnHDVD/NGAcgcdD1ix6VQzohWYDGH6r9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962644; c=relaxed/simple; bh=p+8j09y1FyGo9ACvwOtcz+yNEqZiJ3Fz0Rzzqj3M3sg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jYqRUnbC2QT6M7BlBTb3ISxxypdO0D9S7ke7GQ2fPCE3MWox9oKrfJCN4XSIjXtGftY3ZbGskNLbSKl2IKHS3bSUYofEaw63IzBYFckC6K+xBqwGBByL64LrPhwCzv7Pm9XQTtCwF7ExDrfXPv6vR9j2pp6tgs1kDTwDIgFo8Po= 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=dWF4xwI1; arc=none smtp.client-ip=74.125.82.74 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="dWF4xwI1" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12737f276a2so1389618c88.1 for ; Thu, 19 Mar 2026 16:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962642; x=1774567442; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fGwLOw5TQbWpR3/XxIqkjD3gfTI56RqD3egsR4RKFmo=; b=dWF4xwI1rY7lOoHSHonmV0VHbNZ0OEJ6E0bB/t5ZKieY6FpmUUNIp+JqEV+H0KzLmV /9gVsxxf/o3WnCtduK8DlknF3kkR3wElITgyOtYqmMJWWcC8Nxl61Fp2W+DZXHEdYSAL aqVESeDZjUkP/gbCk8lhvh2zkNePmfSoLdduK4/LJnodIvCF+fkSZRVupm9aDlZj6fvY u/2jNgfBBGBr+7pX0vVHI3Hmlb6UUQAbNOjztlx6/GWMjkPpfxvu/Gd8+0edX4uO6dry guIV17EEdU5AasMfsBlU+G4EL/GIm1nlhEQzXjEMETM+/VBfoVJjaCHAJl5UmPreuTN1 5iYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962642; x=1774567442; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fGwLOw5TQbWpR3/XxIqkjD3gfTI56RqD3egsR4RKFmo=; b=QOWdOxPyi+/Xq6ZmPz8k40GFOZyJZcWtNq/20+3bIHhZ4DhgeS73jrsWaEXIzkyRm0 grzAD2SqeGTm1BSTy75M1xjtgcOB+xa9mffvy1a99toAGV/ahSPY5l4jXwfJ7g+OXjkw TVYwA2ONYwzDyonCpWUtsV7ZGTpWgjczq7aGrwAmf2aLWoaN5BCQRH5TicH02hhEbgvN fDJkjitBLpzlL6Qn4Y5rRK/IDwPQRgcOOY0PVvNOlQXAleIdsMomfXNa2KKgPJGuUkHh I184pKXQdcru+DHGm719/8TGnm6IYx1UZ3Bu+PedvdEAriJobsxx1eK0G5gKQXAJRGGY 5tDw== X-Forwarded-Encrypted: i=1; AJvYcCWPB6kkuqQKzvVkiGS3nfhDXte+ZxY71A5BODa/U6AIcXO1mX8wRiF0mvrifVW+vwaZ1AeRWRW7W7D5zW8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8IMCyNUYOc6ZGAerEYUSLTz9KDM27rV/mETVk55kWrZ7SXLAz g66/Dz8dPXsQySTpYXMW6MRVxsuWplJvLLJit5MLtzT2Qi7g5vjDoUrqH/aWVblIi8vSv9lRc5j VRiVJ0QnogQ== X-Received: from dlbqq5.prod.google.com ([2002:a05:7022:ed05:b0:128:eccd:75b3]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:220c:b0:12a:67b7:53f8 with SMTP id a92af1059eb24-12a7263d550mr536013c88.8.1773962641535; Thu, 19 Mar 2026 16:24:01 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:10 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-2-irogers@google.com> Subject: [PATCH v2 01/25] perf sample: Document struct perf_sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add kernel-doc for struct perf_sample capturing the somewhat unusual population of fields and lifetime relationships. Signed-off-by: Ian Rogers --- tools/perf/util/sample.h | 110 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/sample.h b/tools/perf/util/sample.h index 3cce8dd202aa..88ff154b630c 100644 --- a/tools/perf/util/sample.h +++ b/tools/perf/util/sample.h @@ -81,47 +81,149 @@ struct simd_flags { #define SIMD_OP_FLAGS_PRED_PARTIAL 0x01 /* partial predicate */ #define SIMD_OP_FLAGS_PRED_EMPTY 0x02 /* empty predicate */ =20 +/** + * struct perf_sample + * + * A sample is generally filled in by evlist__parse_sample/evsel__parse_sa= mple + * which fills in the variables from a "union perf_event *event" which is = data + * from a perf ring buffer or perf.data file. The "event" sample is variab= le in + * length as determined by the perf_event_attr (in the evsel) and details = within + * the sample event itself. A struct perf_sample avoids needing to care ab= out + * the variable length nature of the original event. + * + * To avoid being excessively large parts of the struct perf_sample are po= inters + * into the original sample event. In general the lifetime of a struct + * perf_sample needs to be less than the "union perf_event *event" it was + * derived from. + * + * The struct regs_dump user_regs and intr_regs are lazily allocated again= for + * size reasons, due to them holding a cache of looked up registers. The + * function pair of perf_sample__init and perf_sample__exit correctly init= ialize + * and clean up these values. + */ struct perf_sample { + /** @ip: The sample event PERF_SAMPLE_IP value. */ u64 ip; - u32 pid, tid; + /** @pid: The sample event PERF_SAMPLE_TID pid value. */ + u32 pid; + /** @tid: The sample event PERF_SAMPLE_TID tid value. */ + u32 tid; + /** @time: The sample event PERF_SAMPLE_TIME value. */ u64 time; + /** @addr: The sample event PERF_SAMPLE_ADDR value. */ u64 addr; + /** @id: The sample event PERF_SAMPLE_ID value. */ u64 id; + /** @stream_id: The sample event PERF_SAMPLE_STREAM_ID value. */ u64 stream_id; + /** @period: The sample event PERF_SAMPLE_PERIOD value. */ u64 period; + /** @weight: Data determined by PERF_SAMPLE_WEIGHT or PERF_SAMPLE_WEIGHT_= STRUCT. */ u64 weight; + /** @transaction: The sample event PERF_SAMPLE_TRANSACTION value. */ u64 transaction; + /** @insn_cnt: Filled in and used by intel-pt. */ u64 insn_cnt; + /** @cyc_cnt: Filled in and used by intel-pt. */ u64 cyc_cnt; + /** @cpu: The sample event PERF_SAMPLE_CPU value. */ u32 cpu; + /** + * @raw_size: The size in bytes of raw data from PERF_SAMPLE_RAW. For + * alignment reasons this should always be a multiple of + * sizeof(u64) + sizeof(u32). + */ u32 raw_size; + /** @data_src: The sample event PERF_SAMPLE_DATA_SRC value. */ u64 data_src; + /** @phys_addr: The sample event PERF_SAMPLE_PHYS_ADDR value. */ u64 phys_addr; + /** @data_page_size: The sample event PERF_SAMPLE_DATA_PAGE_SIZE value. */ u64 data_page_size; + /** @code_page_size: The sample event PERF_SAMPLE_CODE_PAGE_SIZE value. */ u64 code_page_size; + /** @cgroup: The sample event PERF_SAMPLE_CGROUP value. */ u64 cgroup; + /** @flags: Extra flag data from auxiliary events like intel-pt. */ u32 flags; + /** @machine_pid: The guest machine pid derived from the sample id. */ u32 machine_pid; + /** @vcpu: The guest machine vcpu derived from the sample id. */ u32 vcpu; + /** + * @insn_len: Instruction length from auxiliary events like + * intel-pt. The instruction itself is held in insn. + */ u16 insn_len; + /** + * @cpumode: The cpumode from struct perf_event_header misc variable + * masked with CPUMODE_MASK. Gives user, kernel and hypervisor + * information. + */ u8 cpumode; + /** @misc: The entire struct perf_event_header misc variable. */ u16 misc; + /** + * @ins_lat: Instruction latency information from weight2 in + * PERF_SAMPLE_WEIGHT_STRUCT or auxiliary events like + * intel-pt. + */ u16 ins_lat; - /** @weight3: On x86 holds retire_lat, on powerpc holds p_stage_cyc. */ + /** + * @weight3: From PERF_SAMPLE_WEIGHT_STRUCT. On x86 holds retire_lat, on + * powerpc holds p_stage_cyc. + */ u16 weight3; - bool no_hw_idx; /* No hw_idx collected in branch_stack */ - bool deferred_callchain; /* Has deferred user callchains */ + /** + * @no_hw_idx: For PERF_SAMPLE_BRANCH_STACK, true when + * PERF_SAMPLE_BRANCH_HW_INDEX isn't set. + */ + bool no_hw_idx; + /** + * @deferred_callchain: When processing PERF_SAMPLE_CALLCHAIN a deferred + * user callchain marker was encountered. When set + * the callchain entry is allocated. + */ + bool deferred_callchain; + /** + * @deferred_cookie: Identifier of the deferred callchain in the later + * PERF_RECORD_CALLCHAIN_DEFERRED event. + */ u64 deferred_cookie; + /** @insn: A copy of the sampled instruction filled in by perf_sample__fe= tch_insn. */ char insn[MAX_INSN]; + /** @raw_data: Pointer into the original event for PERF_SAMPLE_RAW data. = */ void *raw_data; + /** + * @callchain: Pointer into the original event for PERF_SAMPLE_CALLCHAIN + * data. If deferred_callchain is not set, it just points to + * data in the mmap buffer and it should not be freed. + */ struct ip_callchain *callchain; + /** @branch_stack: Pointer into the original event for PERF_SAMPLE_BRANCH= _STACK data. */ struct branch_stack *branch_stack; + /** + * @branch_stack_cntr: Pointer into the original event for + * PERF_SAMPLE_BRANCH_COUNTERS data. + */ u64 *branch_stack_cntr; + /** @user_regs: Values and pointers into the sample for PERF_SAMPLE_REGS_= USER. */ struct regs_dump *user_regs; + /** @intr_regs: Values and pointers into the sample for PERF_SAMPLE_REGS_= INTR. */ struct regs_dump *intr_regs; + /** @user_stack: Size and pointer into the sample for PERF_SAMPLE_STACK_U= SER. */ struct stack_dump user_stack; + /** + * @read: The sample event PERF_SAMPLE_READ counter values. The valid + * values depend on the attr.read_format PERF_FORMAT_ values. + */ struct sample_read read; + /** + * @aux_sample: Similar to raw data but with a 64-bit size and + * alignment, PERF_SAMPLE_AUX data. + */ struct aux_sample aux_sample; + /** @simd_flags: SIMD flag information from ARM SPE auxiliary events. */ struct simd_flags simd_flags; }; =20 --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 EE89A401A06 for ; Thu, 19 Mar 2026 23:24:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962647; cv=none; b=QNgsj5pn0LaU22cQYxAXsTL9Gcty2sy7L2pQkTDEyFE4u7uzefcUa3sPkgEK+fr81TK/rRIT1DYvNTK1i1Xoy9ZY+Puu/PW2RbIfT8J3f+dc9iirA2oM9I1Zgfs0y98M2cH/E8kV1bewVdZdDjRAU42xsF8c3L0SKNvfDhwXMjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962647; c=relaxed/simple; bh=da9kZFbgZ2WPtd5VACLt5Kz4GVNFk2cHHuwtri+vAe4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=p6K2cF9UplHsMoMQXg0giFClPtrVoAPrxbM89mocUFdy2H6yqeVDIlGi/Snzoirhg3w9fwmFtqYU84eYBBg7MGzTGzOv7IFfFmrTrDt/ahy/4ar51Ue1r0hFbcK0PUxWInFx37ad1pdcK9cug9NYbQYv2qwwNga1b2Znh4wIsRk= 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=l5DD8QZR; arc=none smtp.client-ip=209.85.216.74 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="l5DD8QZR" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35845fcf0f5so1615040a91.0 for ; Thu, 19 Mar 2026 16:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962644; x=1774567444; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rxFBTP7Uc7XGPsqUW2Y55ItggKIIf/Ou02Qa4BUhgvs=; b=l5DD8QZRQFKVbndhNMQSpf6/SAy0CyMV/893i3hTSxIeknmgbpf4CeQLfJPTKrdj4/ nL8lIjaQL5I9MVc6eDoivMJiOAfll7+aixK2LtPMM7a8rzfO5RC8RoGJBcn0pRduuP7N hwgPNP18U0yGoAhglxQ8fjfSksGutwZe7uDOEHRI4a8xdkYxkcH6QTpmkJ5htEotTInV GiC7xXkJkt1nq03v8o6i6hvrdFTm/yCDoGu6RB3WvGnQf1yyOXHe5FzPeiwOdoy4vZoy j3Ax9YDb4hU4c6upp4QPqbcQpNotm4AHdL4QwW/zSD+7ri5fHcIUalJlJTZFRKU6dsuk RsBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962644; x=1774567444; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rxFBTP7Uc7XGPsqUW2Y55ItggKIIf/Ou02Qa4BUhgvs=; b=cYHzWKETy91w0QuZRWUVdKyq7IDENsT361ffipbxy93NPExLfrepZZSoEkY2XZxuyk HzwKCACrSQb5tlGCF98GJsJrPjRn7kK9jzchB53BKpmjQbJPAG8We2d2papnXWK4/hds 4A7EhCu7fMCRuxcLZkcr3eCq7umaM1Xj23N9Q7WxsGJc2PtGkjTABusgxVm50geNaWyn DtcPScj66EyW3vzpknzgGGGnN+UQV3hTLnmNodl2ialY0MbmrIy1MIsk3MLQVDDcPce+ Y6VEpHZzEgrOqYjazhwIiV0tV9tCaOE4/IoKyzpdhOCkT0cYejcIQeKu12Vr3wicRrJT Tu5g== X-Forwarded-Encrypted: i=1; AJvYcCXNxXpJgbuLbLxoICc+hLTPuZhKtEU0PtSAwiXNECajyaCsxSIDU67TAZAS5kHm5J5oYWZL+xNK5nF2Vic=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6xwJ89SUO9iIzKQrWHQUUcsYmXJE5mqfmaw3OxgLLodm7ixxJ vhaINcbgh2Et4epIW1NvDtAsZeq3M3IJI5bxaxjZ8g7MFkWPzWBCe+EVWU39TgD96yNw7oidbjd B/bc3y+9KMw== X-Received: from pjuf2.prod.google.com ([2002:a17:90a:ce02:b0:35b:9e0a:de3f]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1a8a:b0:35b:9ab6:1d59 with SMTP id 98e67ed59e1d1-35bd27f16abmr650514a91.13.1773962644102; Thu, 19 Mar 2026 16:24:04 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:11 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-3-irogers@google.com> Subject: [PATCH v2 02/25] perf sample: Make sure perf_sample__init/exit are used From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The deferred stack trace code wasn't using perf_sample__init/exit. Add the deferred stack trace clean up to perf_sample__exit which requires proper NULL initialization in perf_sample__init. Make the perf_sample__exit robust to being called more than once by using zfree. Make the error paths in evsel__parse_sample exit the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 5 ++++- tools/perf/util/evlist.c | 5 ++++- tools/perf/util/evsel.c | 28 +++++++++++++++++----------- tools/perf/util/sample.c | 10 ++++++++-- tools/perf/util/session.c | 13 +++++++++---- 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 5b29f4296861..039323908ebf 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -1087,6 +1087,7 @@ static int perf_inject__sched_stat(const struct perf_= tool *tool, struct perf_sample sample_sw; struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); u32 pid =3D evsel__intval(evsel, sample, "pid"); + int ret; =20 list_for_each_entry(ent, &inject->samples, node) { if (pid =3D=3D ent->tid) @@ -1103,7 +1104,9 @@ static int perf_inject__sched_stat(const struct perf_= tool *tool, perf_event__synthesize_sample(event_sw, evsel->core.attr.sample_type, evsel->core.attr.read_format, &sample_sw); build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); - return perf_event__repipe(tool, event_sw, &sample_sw, machine); + ret =3D perf_event__repipe(tool, event_sw, &sample_sw, machine); + perf_sample__exit(&sample_sw); + return ret; } #endif =20 diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 591bdf0b3e2a..bdb196425071 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1622,8 +1622,11 @@ int evlist__parse_sample(struct evlist *evlist, unio= n perf_event *event, struct struct evsel *evsel =3D evlist__event2evsel(evlist, event); int ret; =20 - if (!evsel) + if (!evsel) { + /* Ensure the sample is okay for perf_sample__exit. */ + perf_sample__init(sample, /*all=3D*/false); return -EFAULT; + } ret =3D evsel__parse_sample(evsel, event, sample); if (ret) return ret; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index f59228c1a39e..34ae388750db 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3067,7 +3067,7 @@ static inline bool overflow(const void *endp, u16 max= _size, const void *offset, #define OVERFLOW_CHECK(offset, size, max_size) \ do { \ if (overflow(endp, (max_size), (offset), (size))) \ - return -EFAULT; \ + goto out_efault; \ } while (0) =20 #define OVERFLOW_CHECK_u64(offset) \ @@ -3199,6 +3199,8 @@ static int __set_offcpu_sample(struct perf_sample *da= ta) data->cgroup =3D *array; =20 return 0; +out_efault: + return -EFAULT; } =20 int evsel__parse_sample(struct evsel *evsel, union perf_event *event, @@ -3217,7 +3219,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, */ union u64_swap u; =20 - memset(data, 0, sizeof(*data)); + perf_sample__init(data, /*all=3D*/true); data->cpu =3D data->pid =3D data->tid =3D -1; data->stream_id =3D data->id =3D data->time =3D -1ULL; data->period =3D evsel->core.attr.sample_period; @@ -3231,25 +3233,26 @@ int evsel__parse_sample(struct evsel *evsel, union = perf_event *event, =20 data->callchain =3D (struct ip_callchain *)&event->callchain_deferred.nr; if (data->callchain->nr > max_callchain_nr) - return -EFAULT; + goto out_efault; =20 data->deferred_cookie =3D event->callchain_deferred.cookie; =20 if (evsel->core.attr.sample_id_all) perf_evsel__parse_id_sample(evsel, event, data); + return 0; } =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) { - if (!evsel->core.attr.sample_id_all) - return 0; - return perf_evsel__parse_id_sample(evsel, event, data); + if (evsel->core.attr.sample_id_all) + perf_evsel__parse_id_sample(evsel, event, data); + return 0; } =20 array =3D event->sample.array; =20 if (perf_event__check_size(event, evsel->sample_size)) - return -EFAULT; + goto out_efault; =20 if (type & PERF_SAMPLE_IDENTIFIER) { data->id =3D *array; @@ -3342,7 +3345,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, sizeof(struct sample_read_value); =20 if (data->read.group.nr > max_group_nr) - return -EFAULT; + goto out_efault; =20 sz =3D data->read.group.nr * sample_read_value_size(read_format); OVERFLOW_CHECK(array, sz, max_size); @@ -3370,7 +3373,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, data->callchain =3D (struct ip_callchain *)array++; callchain_nr =3D data->callchain->nr; if (callchain_nr > max_callchain_nr) - return -EFAULT; + goto out_efault; sz =3D callchain_nr * sizeof(u64); /* * Save the cookie for the deferred user callchain. The last 2 @@ -3428,7 +3431,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, data->branch_stack =3D (struct branch_stack *)array++; =20 if (data->branch_stack->nr > max_branch_nr) - return -EFAULT; + goto out_efault; =20 sz =3D data->branch_stack->nr * sizeof(struct branch_entry); if (evsel__has_branch_hw_idx(evsel)) { @@ -3505,7 +3508,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, data->user_stack.size =3D *array++; if (WARN_ONCE(data->user_stack.size > sz, "user stack dump failure\n")) - return -EFAULT; + goto out_efault; } } =20 @@ -3586,6 +3589,9 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, return __set_offcpu_sample(data); =20 return 0; +out_efault: + perf_sample__exit(data); + return -EFAULT; } =20 int evsel__parse_sample_timestamp(struct evsel *evsel, union perf_event *e= vent, diff --git a/tools/perf/util/sample.c b/tools/perf/util/sample.c index 8f82aaf1aab6..b04cbad7edd3 100644 --- a/tools/perf/util/sample.c +++ b/tools/perf/util/sample.c @@ -21,13 +21,19 @@ void perf_sample__init(struct perf_sample *sample, bool= all) } else { sample->user_regs =3D NULL; sample->intr_regs =3D NULL; + sample->deferred_callchain =3D false; + sample->callchain =3D NULL; } } =20 void perf_sample__exit(struct perf_sample *sample) { - free(sample->user_regs); - free(sample->intr_regs); + zfree(&sample->user_regs); + zfree(&sample->intr_regs); + if (sample->deferred_callchain) { + zfree(&sample->callchain); + sample->deferred_callchain =3D false; + } } =20 struct regs_dump *perf_sample__user_regs(struct perf_sample *sample) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 4b465abfa36c..c48e840da7d4 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1367,14 +1367,18 @@ static int evlist__deliver_deferred_callchain(struc= t evlist *evlist, list_for_each_entry_safe(de, tmp, &evlist->deferred_samples, list) { struct perf_sample orig_sample; =20 + perf_sample__init(&orig_sample, /*all=3D*/false); ret =3D evlist__parse_sample(evlist, de->event, &orig_sample); if (ret < 0) { pr_err("failed to parse original sample\n"); + perf_sample__exit(&orig_sample); break; } =20 - if (sample->tid !=3D orig_sample.tid) + if (sample->tid !=3D orig_sample.tid) { + perf_sample__exit(&orig_sample); continue; + } =20 if (event->callchain_deferred.cookie =3D=3D orig_sample.deferred_cookie) sample__merge_deferred_callchain(&orig_sample, sample); @@ -1385,9 +1389,7 @@ static int evlist__deliver_deferred_callchain(struct = evlist *evlist, ret =3D evlist__deliver_sample(evlist, tool, de->event, &orig_sample, evsel, machine); =20 - if (orig_sample.deferred_callchain) - free(orig_sample.callchain); - + perf_sample__exit(&orig_sample); list_del(&de->list); free(de->event); free(de); @@ -1414,9 +1416,11 @@ static int session__flush_deferred_samples(struct pe= rf_session *session, list_for_each_entry_safe(de, tmp, &evlist->deferred_samples, list) { struct perf_sample sample; =20 + perf_sample__init(&sample, /*all=3D*/false); ret =3D evlist__parse_sample(evlist, de->event, &sample); if (ret < 0) { pr_err("failed to parse original sample\n"); + perf_sample__exit(&sample); break; } =20 @@ -1424,6 +1428,7 @@ static int session__flush_deferred_samples(struct per= f_session *session, ret =3D evlist__deliver_sample(evlist, tool, de->event, &sample, evsel, machine); =20 + perf_sample__exit(&sample); list_del(&de->list); free(de->event); free(de); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.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 BE7C64014B1 for ; Thu, 19 Mar 2026 23:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962650; cv=none; b=P0ePq038AbydbpYkwrO0rtgmbnoVGhyI8p81PV9I/U3zBEI9wBO1UvhAYM4uET4WTiGq2guV5EOV5YaOKofhdPKlNliDzNipuRst9RTnU+KwQTB50iFrw2ek96SAK2S9bDPPm6X2ymvNiqz2TCzSZ/71mCoJ4F+92yJ/2ta9U/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962650; c=relaxed/simple; bh=OO5lQ4rItKvT1zszsZDJAXEl+loRK8WH9QzmuzQA4SI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VaJTT3z4gc29Xd/xbwOno6heT12Zzy6NAZdpgdcDumgWvw6vAIu5+n2GCuKRpg/ceJMKaUZNfs6Y1aBvRfshyX/wZkGJoOfVtaPztU5/DO0hQa1YW43f5cRcikU61IF03GSbklHbp5EYjrXk5v9Bdai4+Ie1iNuzks6Lk7iWFhE= 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=V4rp6P4C; arc=none smtp.client-ip=74.125.82.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="V4rp6P4C" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0e264d802so26393115eec.0 for ; Thu, 19 Mar 2026 16:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962647; x=1774567447; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UBWuinOyxfkLKH95hxSSDNoOlBLzd5ds8vkjTeBSCO8=; b=V4rp6P4CmXe6/a4OOItdds2cWfRKWm4HMKHXDraYZwgLbYRmES2yfkOTQ+j8P6lxVe B4SFSfe6aoHXGSF40rzMU8Z5mtbaN0BC1zYntzaos9r/PN196/UHqrQ2hZ7j9w6XTZNb bmMNA60Hfy5lyZ6lFix1TG44Qoem4Lqx4CC8oDDK+KUIry5ABzoAfGv7KsI9vJVrbSuz vbr0YgGcEIeAAWsf4jbqX2eeNxBAp5t4ayBnzYm1c54vUMouiTg4kCtvr4m9456Cpp2L JJEsYt4p78gQNla+3Qu9UB+eNGnZ7IJtNwqh2LFrHIrP/dMhjf1GTxGaMOwv9kSRVypY uUiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962647; x=1774567447; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UBWuinOyxfkLKH95hxSSDNoOlBLzd5ds8vkjTeBSCO8=; b=hnRFl/ArMwPZ7tp4buxzzBYqbt/KvPa3WY1rrISjkxap5GFVUGYNAfHq7J/U30ruKm jxkvoWbCTnRGZRK5MVIGKhAU7EtK5Ov3WhOlSQNRHUmSEf7PafhJyubdYeRD77LXTqni 4CaRoshvEwbI/zJdJ3PxddvW4TDsUdJ+xTkEUYnd/Hw2WxPztUvxlI+2OtvfQ6iM76Cn 78h+Fu5h6chlNw/Rm7Erjd2oJBWXD1OY4mcV0MjLo5S0fGhHhQ3B+W7bybB/ESD2KqQp crmcdv+HgjzOu7NubTEp1xSwFt32/fZdnpVHs9gpE+HIQ47N4FupgpVgo3WyL+iRCX84 yLkQ== X-Forwarded-Encrypted: i=1; AJvYcCX3vGdZ4LDtkk7Lc+iB1OLWsvIYdPoBWiZpulLolg3CQhZba/lSi3AogyaVZD/MxSLbEs90wTQUAw/oOqc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4ebfgkhSNpg6xhfDIYVnbbrKZioCItBKu1l4bujVBDb1eLnMK 7QQiN3trbzhOyhqotOFvAyLldveht8qMCLF3eLs++x3lHaAG4nNe6liVhMW9t6CTG7/224dQg4C m7hUGKvcoqw== X-Received: from dyff16.prod.google.com ([2002:a05:693c:8050:b0:2c0:d493:ae08]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:5709:b0:2bd:d3f3:b0be with SMTP id 5a478bee46e88-2c10970ed40mr694891eec.20.1773962646533; Thu, 19 Mar 2026 16:24:06 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:12 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-4-irogers@google.com> Subject: [PATCH v2 03/25] perf sample: Add evsel to struct perf_sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the evsel from evsel__parse_sample into the struct perf_sample. Sometimes we want to alter the evsel associated with a sample, such as with off-cpu bpf-output events. In general the evsel and perf_sample are passed as a pair, but this makes an altered evsel something of a chore to keep checking for and setting up. Later patches will remove passing an evsel with the perf_sample and switch to just using the perf_sample's value. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 9 +++++--- tools/perf/builtin-script.c | 4 ++++ tools/perf/tests/hists_cumulate.c | 2 +- tools/perf/tests/hists_filter.c | 1 + tools/perf/tests/hists_output.c | 2 +- tools/perf/util/evsel.c | 1 + tools/perf/util/sample.h | 3 +++ tools/perf/util/session.c | 35 +++++++++++++++++++------------ 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 039323908ebf..5a04d7cff449 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -133,7 +133,7 @@ struct perf_inject { struct perf_file_section secs[HEADER_FEAT_BITS]; struct guest_session guest_session; struct strlist *known_build_ids; - const struct evsel *mmap_evsel; + struct evsel *mmap_evsel; struct ip_callchain *raw_callchain; }; =20 @@ -519,7 +519,7 @@ static struct dso *findnew_dso(int pid, int tid, const = char *filename, * processing mmap events. If not stashed, search the evlist for the first= mmap * gathering event. */ -static const struct evsel *inject__mmap_evsel(struct perf_inject *inject) +static struct evsel *inject__mmap_evsel(struct perf_inject *inject) { struct evsel *pos; =20 @@ -1007,6 +1007,7 @@ int perf_event__inject_buildid(const struct perf_tool= *tool, union perf_event *e .machine =3D machine, .mmap_evsel =3D inject__mmap_evsel(inject), }; + struct evsel *saved_evsel =3D sample->evsel; =20 addr_location__init(&al); thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); @@ -1021,9 +1022,10 @@ int perf_event__inject_buildid(const struct perf_too= l *tool, union perf_event *e /*sample_in_dso=3D*/true); } =20 + sample->evsel =3D inject__mmap_evsel(inject); sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEP= TH, /*symbols=3D*/false, mark_dso_hit_callback, &args); - + sample->evsel =3D saved_evsel; thread__put(thread); repipe: perf_event__repipe(tool, event, sample, machine); @@ -1432,6 +1434,7 @@ static int synthesize_build_id(struct perf_inject *in= ject, struct dso *dso, pid_ { struct machine *machine =3D perf_session__findnew_machine(inject->session= , machine_pid); struct perf_sample synth_sample =3D { + .evsel =3D inject__mmap_evsel(inject), .pid =3D -1, .tid =3D -1, .time =3D -1, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index b80c406d1fc1..8c3d06a3db62 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2909,8 +2909,12 @@ static int print_event_with_time(const struct perf_t= ool *tool, thread =3D machine__findnew_thread(machine, pid, tid); =20 if (evsel) { + struct evsel *saved_evsel =3D sample->evsel; + + sample->evsel =3D evsel; perf_sample__fprintf_start(script, sample, thread, evsel, event->header.type, stdout); + sample->evsel =3D saved_evsel; } =20 perf_event__fprintf(event, machine, stdout); diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cum= ulate.c index 3eb9ef8d7ec6..606aa926a8fc 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -81,7 +81,7 @@ static int add_hist_entries(struct hists *hists, struct m= achine *machine) { struct addr_location al; struct evsel *evsel =3D hists_to_evsel(hists); - struct perf_sample sample =3D { .period =3D 1000, }; + struct perf_sample sample =3D { .evsel =3D evsel, .period =3D 1000, }; size_t i; =20 addr_location__init(&al); diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filte= r.c index 1cebd20cc91c..cc6b26e373d1 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -70,6 +70,7 @@ static int add_hist_entries(struct evlist *evlist, }; struct hists *hists =3D evsel__hists(evsel); =20 + sample.evsel =3D evsel; /* make sure it has no filter at first */ hists->thread_filter =3D NULL; hists->dso_filter =3D NULL; diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_outpu= t.c index ee5ec8bda60e..7818950d786e 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -51,7 +51,7 @@ static int add_hist_entries(struct hists *hists, struct m= achine *machine) { struct addr_location al; struct evsel *evsel =3D hists_to_evsel(hists); - struct perf_sample sample =3D { .period =3D 100, }; + struct perf_sample sample =3D { .evsel =3D evsel, .period =3D 100, }; size_t i; =20 addr_location__init(&al); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 34ae388750db..a7da54d365a9 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3220,6 +3220,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, union u64_swap u; =20 perf_sample__init(data, /*all=3D*/true); + data->evsel =3D evsel; data->cpu =3D data->pid =3D data->tid =3D -1; data->stream_id =3D data->id =3D data->time =3D -1ULL; data->period =3D evsel->core.attr.sample_period; diff --git a/tools/perf/util/sample.h b/tools/perf/util/sample.h index 88ff154b630c..0cae9ffee39c 100644 --- a/tools/perf/util/sample.h +++ b/tools/perf/util/sample.h @@ -5,6 +5,7 @@ #include #include =20 +struct evsel; struct machine; struct thread; =20 @@ -102,6 +103,8 @@ struct simd_flags { * and clean up these values. */ struct perf_sample { + /** @evsel: Backward reference to the evsel used when constructing the sa= mple. */ + struct evsel *evsel; /** @ip: The sample event PERF_SAMPLE_IP value. */ u64 ip; /** @pid: The sample event PERF_SAMPLE_TID pid value. */ diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c48e840da7d4..3794d3a04afb 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1257,8 +1257,9 @@ static int deliver_sample_value(struct evlist *evlist, bool per_thread) { struct perf_sample_id *sid =3D evlist__id2sid(evlist, v->id); - struct evsel *evsel; + struct evsel *saved_evsel =3D sample->evsel; u64 *storage =3D NULL; + int ret; =20 if (sid) { storage =3D perf_sample_id__get_period_storage(sid, sample->tid, per_thr= ead); @@ -1282,8 +1283,10 @@ static int deliver_sample_value(struct evlist *evlis= t, if (!sample->period) return 0; =20 - evsel =3D container_of(sid->evsel, struct evsel, core); - return tool->sample(tool, event, sample, evsel, machine); + sample->evsel =3D container_of(sid->evsel, struct evsel, core); + ret =3D tool->sample(tool, event, sample, sample->evsel, machine); + sample->evsel =3D saved_evsel; + return ret; } =20 static int deliver_sample_group(struct evlist *evlist, @@ -1355,13 +1358,16 @@ static int evlist__deliver_deferred_callchain(struc= t evlist *evlist, struct machine *machine) { struct deferred_event *de, *tmp; - struct evsel *evsel; int ret =3D 0; =20 if (!tool->merge_deferred_callchains) { - evsel =3D evlist__id2evsel(evlist, sample->id); - return tool->callchain_deferred(tool, event, sample, - evsel, machine); + struct evsel *saved_evsel =3D sample->evsel; + + sample->evsel =3D evlist__id2evsel(evlist, sample->id); + ret =3D tool->callchain_deferred(tool, event, sample, + sample->evsel, machine); + sample->evsel =3D saved_evsel; + return ret; } =20 list_for_each_entry_safe(de, tmp, &evlist->deferred_samples, list) { @@ -1385,9 +1391,9 @@ static int evlist__deliver_deferred_callchain(struct = evlist *evlist, else orig_sample.deferred_callchain =3D false; =20 - evsel =3D evlist__id2evsel(evlist, orig_sample.id); + orig_sample.evsel =3D evlist__id2evsel(evlist, orig_sample.id); ret =3D evlist__deliver_sample(evlist, tool, de->event, - &orig_sample, evsel, machine); + &orig_sample, orig_sample.evsel, machine); =20 perf_sample__exit(&orig_sample); list_del(&de->list); @@ -1410,7 +1416,6 @@ static int session__flush_deferred_samples(struct per= f_session *session, struct evlist *evlist =3D session->evlist; struct machine *machine =3D &session->machines.host; struct deferred_event *de, *tmp; - struct evsel *evsel; int ret =3D 0; =20 list_for_each_entry_safe(de, tmp, &evlist->deferred_samples, list) { @@ -1424,9 +1429,9 @@ static int session__flush_deferred_samples(struct per= f_session *session, break; } =20 - evsel =3D evlist__id2evsel(evlist, sample.id); + sample.evsel =3D evlist__id2evsel(evlist, sample.id); ret =3D evlist__deliver_sample(evlist, tool, de->event, - &sample, evsel, machine); + &sample, sample.evsel, machine); =20 perf_sample__exit(&sample); list_del(&de->list); @@ -1451,8 +1456,12 @@ static int machines__deliver_event(struct machines *= machines, =20 dump_event(evlist, event, file_offset, sample, file_path); =20 - evsel =3D evlist__id2evsel(evlist, sample->id); + if (!sample->evsel) + sample->evsel =3D evlist__id2evsel(evlist, sample->id); + else + assert(sample->evsel =3D=3D evlist__id2evsel(evlist, sample->id)); =20 + evsel =3D sample->evsel; machine =3D machines__find_for_cpumode(machines, event, sample); =20 switch (event->header.type) { --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.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 00D1D401A26 for ; Thu, 19 Mar 2026 23:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962653; cv=none; b=jLERZYA2AJMwG+nCYvRDiZgQws4ILJVeyPRPCASAWMIMyzDHBopjsx1JoLAsSkENR3Yy5/hb7UFqblbvdStk7NeHdaLv1PVdYfrVCK5Tbp2IGjfeECjwOILQTWoZND5KbeB5mdcM8oV8uDJIUmx1q4Sjl9CDoA368TJ7K7d+y5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962653; c=relaxed/simple; bh=K6r2iQGHTit7ZwFs3kK2BM3odrhUu/m575fNWeOB+SE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bu5DQxKdedA/KXQDDK3TkOYwfr3ME0YeCgdfSjhE99wmJuZsohEU1TlFHyjLAiSQjrQSPD+JT2wm24d++vAjmYXqB5Q3uW/6DjI3wLoENa6dcEUfVrYI4WP9wHGQvjEzwgPLjd/Z5bFoD1+NzjkwKEpQ88EJfw6jO0poDSGnTVQ= 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=XW7vhfYD; arc=none smtp.client-ip=74.125.82.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="XW7vhfYD" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c105e5ac70so140311eec.0 for ; Thu, 19 Mar 2026 16:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962649; x=1774567449; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WQFPH903gEcJKTfxr+NWb/gUWmIfZSxffYBpS6YtpDQ=; b=XW7vhfYDTmam/3GDSWCWGi0I/+NnnLPn+gYuSf/mD9mpced3xfvN+OwM2JdPWyy8y7 LgxTOb9EJKm3Nnop+opZHE+zuyNmcA3YrcCV1HRPNvkLHYMRr4qwc68OPrxiJ0ORUi4Q qeFA45R18hVxX0nnoNy7LEIhkiT02CxJzGnzPgS38oW2RFoa1aA4I1nupsB7MrjgSP2k rwUpvkDb0xj7Xh64cxdn961BaONIMJy5QzTFMuJZd91tRC6x5MTmu/IQjDOes/x5gqNv qhRVLitg9eU/+I8Vuin1GtVRIHC09YcrLK3BDJBbDiEfnfjEHCFpwNwTYAp3LhA0gmwD hF+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962649; x=1774567449; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WQFPH903gEcJKTfxr+NWb/gUWmIfZSxffYBpS6YtpDQ=; b=R8hiqFnrY0uAd/jq0dKvy/NRE36K9zxUQ2XFIywnPMR6/ro6r/wEQ18EZJL7RkCgim 970WVCM8tCBfl/ImR1vx8PwNcpuZ+PtFYeP5q75MkFu+836iuBDO2aTu69FrYw0YUWmU xFAJ5FxJJEB4gxYtf18lpPihOZ66OP63pnKg4vCkJlgqFP45dASSV/b7B0ZSCB8C6qmP xomdL7M7g4z/8mHntFqOtOqtrjJ6dow9hzu0uDY4OUNyiuD0UBfarkmeRqc32VPAkAP/ XGEhTBB1MkxqU0C61F5Unrnpn5YEcWqSNMC/qt766Kc9y1TxZ0iTQSB4ge8lbGGW8sVV wwKg== X-Forwarded-Encrypted: i=1; AJvYcCXQa4l3AdKtxV3rwP8987Xl6h3eCZMT+F6WXt3escFGJo3T9qufLdJ59WYOw77+WLOcpQPiTnvFm6zfbNI=@vger.kernel.org X-Gm-Message-State: AOJu0YwyNKVfOitzycmdgL/w+LczD1E+Oit6C5EYHF+QcN1KkXufW25/ xEOyNwHXK8KJzh/Bw0aNcowyxFiri+nEQ6SBE//hvDsouJXaPJkNoyuzrapRT0jfQ0sMf4naNQn HztrQkD+UgA== X-Received: from dykh34.prod.google.com ([2002:a05:7300:5722:b0:2be:70ac:88ad]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:3723:b0:2be:fe8:8b0d with SMTP id 5a478bee46e88-2c109752b22mr627779eec.22.1773962648726; Thu, 19 Mar 2026 16:24:08 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:13 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-5-irogers@google.com> Subject: [PATCH v2 04/25] perf tool: Remove evsel from tool APIs that pass the sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now struct perf_sample has the evsel within it there is no need to pass the evsel along with the sample. In the called functions read the sample's evsel in to a variable if there are multiple uses, or use directly if there is just one use - the goal being to leave the code with as little change as possible. Some functions only use the evsel to pass to another function which they also pass the sample, in those cases just pass the sample and get the evsel in the called function. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 3 +-- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 19 ++++++--------- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-kvm.c | 5 ++-- tools/perf/builtin-kwork.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-mem.c | 1 - tools/perf/builtin-record.c | 3 +-- tools/perf/builtin-report.c | 10 +++----- tools/perf/builtin-sched.c | 4 +-- tools/perf/builtin-script.c | 4 +-- tools/perf/builtin-timechart.c | 2 +- tools/perf/builtin-trace.c | 2 +- tools/perf/util/build-id.c | 3 +-- tools/perf/util/build-id.h | 7 +----- tools/perf/util/data-convert-bt.c | 2 +- tools/perf/util/data-convert-json.c | 5 ++-- tools/perf/util/intel-tpebs.c | 3 +-- tools/perf/util/jitdump.c | 2 +- tools/perf/util/session.c | 38 ++++++++++++++--------------- tools/perf/util/tool.c | 4 +-- tools/perf/util/tool.h | 4 +-- 24 files changed, 55 insertions(+), 76 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 686ad08561d6..c97a0fe159f8 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -284,7 +284,6 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_annotate *ann =3D container_of(tool, struct perf_annotate, to= ol); @@ -303,7 +302,7 @@ static int process_sample_event(const struct perf_tool = *tool, goto out_put; =20 if (!al.filtered && - evsel__add_sample(evsel, sample, &al, ann, machine)) { + evsel__add_sample(sample->evsel, sample, &al, ann, machine)) { pr_warning("problem incrementing symbol count, " "skipping event\n"); ret =3D -1; diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index d390ae4e3ec8..89456ba6fcbb 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -314,9 +314,9 @@ static void perf_c2c__evsel_hists_inc_stats(struct evse= l *evsel, static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; struct c2c_hists *c2c_hists =3D &c2c.hists; struct c2c_hist_entry *c2c_he; struct c2c_stats stats =3D { .nr_entries =3D 0, }; diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 69069926dd0b..096adc65451c 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -390,11 +390,11 @@ struct hist_entry_ops block_hist_ops =3D { static int diff__process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_diff *pdiff =3D container_of(tool, struct perf_diff, tool); struct addr_location al; + struct evsel *evsel =3D sample->evsel; struct hists *hists =3D evsel__hists(evsel); struct hist_entry_iter iter =3D { .evsel =3D evsel, diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 5a04d7cff449..89f6fc826187 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -363,18 +363,17 @@ typedef int (*inject_handler)(const 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, struct machine *machine) { - struct perf_inject *inject =3D container_of(tool, struct perf_inject, - tool); + struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); + struct evsel *evsel =3D sample->evsel; =20 if (evsel && evsel->handler) { inject_handler f =3D evsel->handler; return f(tool, event, sample, evsel, machine); } =20 - build_id__mark_dso_hit(tool, event, sample, evsel, machine); + build_id__mark_dso_hit(tool, event, sample, machine); =20 if (inject->itrace_synth_opts.set && sample->aux_sample.size) { event =3D perf_inject__cut_auxtrace_sample(inject, event, sample); @@ -388,10 +387,10 @@ static int perf_event__repipe_sample(const struct per= f_tool *tool, static int perf_event__convert_sample_callchain(const struct perf_tool *to= ol, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); + struct evsel *evsel =3D sample->evsel; struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); union perf_event *event_copy =3D (void *)inject->event_copy; struct callchain_cursor_node *node; @@ -988,10 +987,8 @@ static int mark_dso_hit_callback(struct callchain_curs= or_node *node, void *data) args->mmap_evsel, map, /*sample_in_dso=3D*/false); } =20 -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) +static int perf_event__inject_buildid(const struct perf_tool *tool, union = perf_event *event, + struct perf_sample *sample, struct machine *machine) { struct addr_location al; struct thread *thread; @@ -1023,7 +1020,7 @@ int perf_event__inject_buildid(const struct perf_tool= *tool, union perf_event *e } =20 sample->evsel =3D inject__mmap_evsel(inject); - sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEP= TH, + sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, &args); sample->evsel =3D saved_evsel; thread__put(thread); @@ -1105,7 +1102,7 @@ static int perf_inject__sched_stat(const struct perf_= tool *tool, sample_sw.time =3D sample->time; perf_event__synthesize_sample(event_sw, evsel->core.attr.sample_type, evsel->core.attr.read_format, &sample_sw); - build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); + build_id__mark_dso_hit(tool, event_sw, &sample_sw, machine); ret =3D perf_event__repipe(tool, event_sw, &sample_sw, machine); perf_sample__exit(&sample_sw); return ret; diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 7929a5fa5f46..34852a4c3fc8 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -960,9 +960,9 @@ typedef int (*tracepoint_handler)(struct evsel *evsel, static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; struct thread *thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 0c5e6b3aac74..5e8e6fde097a 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -941,9 +941,9 @@ struct vcpu_event_record *per_vcpu_record(struct thread= *thread, =20 static bool handle_kvm_event(struct perf_kvm_stat *kvm, struct thread *thread, - struct evsel *evsel, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; struct vcpu_event_record *vcpu_record; struct event_key key =3D { .key =3D INVALID_KEY, .exit_reasons =3D kvm->exit_reasons }; @@ -1133,7 +1133,6 @@ static bool skip_sample(struct perf_kvm_stat *kvm, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { int err =3D 0; @@ -1156,7 +1155,7 @@ static int process_sample_event(const struct perf_too= l *tool, return -1; } =20 - if (!handle_kvm_event(kvm, thread, evsel, sample)) + if (!handle_kvm_event(kvm, thread, sample)) err =3D -1; =20 thread__put(thread); diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 6f94a8f45f60..e34a1f35439e 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1955,9 +1955,9 @@ typedef int (*tracepoint_handler)(const struct perf_t= ool *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, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; =20 if (evsel->handler !=3D NULL) { diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index e8962c985d34..dc8d1d3b4cd7 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1430,9 +1430,9 @@ typedef int (*tracepoint_handler)(struct evsel *evsel, static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; struct thread *thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index d43500b92a7b..6101a26b3a78 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -255,7 +255,6 @@ dump_raw_samples(const 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, struct machine *machine) { return dump_raw_samples(tool, event, sample, machine); diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 40917a0be238..09d6af344f3e 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1488,7 +1488,6 @@ static void set_timestamp_boundary(struct record *rec= , u64 sample_time) static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct record *rec =3D container_of(tool, struct record, tool); @@ -1499,7 +1498,7 @@ static int process_sample_event(const struct perf_too= l *tool, return 0; =20 rec->samples++; - return build_id__mark_dso_hit(tool, event, sample, evsel, machine); + return build_id__mark_dso_hit(tool, event, sample, machine); } =20 static int process_buildids(struct record *rec) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 343c0ada5ea1..507002cbdd5b 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -269,10 +269,10 @@ static int process_feature_event(const struct perf_to= ol *tool, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct report *rep =3D container_of(tool, struct report, tool); + struct evsel *evsel =3D sample->evsel; struct addr_location al; struct hist_entry_iter iter =3D { .evsel =3D evsel, @@ -349,7 +349,6 @@ static int process_sample_event(const 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, struct machine *machine __maybe_unused) { struct report *rep =3D container_of(tool, struct report, tool); @@ -357,7 +356,7 @@ static int process_read_event(const struct perf_tool *t= ool, if (rep->show_threads) { int err =3D perf_read_values_add_value(&rep->show_threads_values, event->read.pid, event->read.tid, - evsel, + sample->evsel, event->read.value); =20 if (err) @@ -783,11 +782,10 @@ static void report__output_resort(struct report *rep) =20 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, + struct perf_sample *sample, struct machine *machine __maybe_unused) { - struct hists *hists =3D evsel__hists(evsel); + struct hists *hists =3D evsel__hists(sample->evsel); =20 hists__inc_nr_events(hists); return 0; diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index d083e2bb7703..296b9837278a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1867,9 +1867,9 @@ typedef int (*tracepoint_handler)(const struct perf_t= ool *tool, 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, struct machine *machine) { + struct evsel *evsel =3D sample->evsel; int err =3D 0; =20 if (evsel->handler !=3D NULL) { @@ -3184,10 +3184,10 @@ typedef int (*sched_handler)(const 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, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); + struct evsel *evsel =3D sample->evsel; int err =3D 0; struct perf_cpu this_cpu =3D { .cpu =3D sample->cpu, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8c3d06a3db62..8724c4ab3e88 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2644,10 +2644,10 @@ static bool filter_cpu(struct perf_sample *sample) static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); + struct evsel *evsel =3D sample->evsel; struct addr_location al; struct addr_location addr_al; int ret =3D 0; @@ -2728,10 +2728,10 @@ static int process_sample_event(const struct perf_t= ool *tool, static int process_deferred_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); + struct evsel *evsel =3D sample->evsel; struct perf_event_attr *attr =3D &evsel->core.attr; struct evsel_script *es =3D evsel->priv; unsigned int type =3D output_type(attr->type); diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 28f33e39895d..8692d11ccd29 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -574,10 +574,10 @@ typedef int (*tracepoint_handler)(struct timechart *t= chart, static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct timechart *tchart =3D container_of(tool, struct timechart, tool); + struct evsel *evsel =3D sample->evsel; =20 if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) { if (!tchart->first_time || tchart->first_time > sample->time) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 1c38f3d16a31..e86a3d375757 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3462,10 +3462,10 @@ static void trace__set_base_time(struct trace *trac= e, static int trace__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct trace *trace =3D container_of(tool, struct trace, tool); + struct evsel *evsel =3D sample->evsel; struct thread *thread; int err =3D 0; =20 diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index fdb35133fde4..55b72235f891 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -55,7 +55,6 @@ static int mark_dso_hit_callback(struct callchain_cursor_= node *node, void *data int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct addr_location al; @@ -74,7 +73,7 @@ int build_id__mark_dso_hit(const struct perf_tool *tool _= _maybe_unused, =20 addr_location__exit(&al); =20 - sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEP= TH, + sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, /*data=3D*/NULL); =20 =20 diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 47e621cebe1b..73bad90b06f9 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -34,12 +34,7 @@ char *__dso__build_id_filename(const struct dso *dso, ch= ar *bf, size_t size, bool is_debug, bool is_kallsyms); =20 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); - -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); + struct perf_sample *sample, struct machine *machine); =20 bool perf_session__read_build_ids(struct perf_session *session, bool with_= hits); int perf_session__write_buildid_table(struct perf_session *session, diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index ba1c8e48d495..32e2173b86e3 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -803,10 +803,10 @@ static bool is_flush_needed(struct ctf_stream *cs) static int process_sample_event(const struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct convert *c =3D container_of(tool, struct convert, tool); + struct evsel *evsel =3D sample->evsel; struct evsel_priv *priv =3D evsel->priv; struct ctf_writer *cw =3D &c->writer; struct ctf_stream *cs; diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 6a626322476a..d1f931ee565a 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -159,13 +159,12 @@ static void output_sample_callchain_entry(const struc= t 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, struct machine *machine) { struct convert_json *c =3D container_of(tool, struct convert_json, tool); FILE *out =3D c->out; struct addr_location al; - u64 sample_type =3D __evlist__combined_sample_type(evsel->evlist); + u64 sample_type =3D __evlist__combined_sample_type(sample->evsel->evlist); u8 cpumode =3D PERF_RECORD_MISC_USER; =20 addr_location__init(&al); @@ -245,7 +244,7 @@ static int process_sample_event(const struct perf_tool = *tool, =20 #ifdef HAVE_LIBTRACEEVENT if (sample->raw_data) { - struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_event *tp_format =3D evsel__tp_format(sample->evsel); struct tep_format_field **fields =3D tp_format ? tep_event_fields(tp_for= mat) : NULL; =20 if (fields) { diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c index 2af5455488b2..01e030862d5d 100644 --- a/tools/perf/util/intel-tpebs.c +++ b/tools/perf/util/intel-tpebs.c @@ -185,7 +185,6 @@ static bool should_ignore_sample(const struct perf_samp= le *sample, const struct static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event __maybe_unused, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine __maybe_unused) { struct tpebs_retire_lat *t; @@ -196,7 +195,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, mutex_unlock(tpebs_mtx_get()); return 0; } - t =3D tpebs_retire_lat__find(evsel); + t =3D tpebs_retire_lat__find(sample->evsel); if (!t) { mutex_unlock(tpebs_mtx_get()); return -EINVAL; diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index e0ce8b904729..52e6ffac2b3e 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -642,7 +642,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd= , union jr_entry *jr) =20 ret =3D jit_inject_event(jd, event); if (!ret) - build_id__mark_dso_hit(tool, event, &sample, NULL, jd->machine); + build_id__mark_dso_hit(tool, event, &sample, jd->machine); out: perf_sample__exit(&sample); return ret; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 3794d3a04afb..150398b383fe 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1110,9 +1110,10 @@ char *get_page_size_name(u64 size, char *str) return str; } =20 -static void dump_sample(struct machine *machine, struct evsel *evsel, unio= n perf_event *event, +static void dump_sample(struct machine *machine, union perf_event *event, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; u64 sample_type; char str[PAGE_SIZE_NAME_LEN]; uint16_t e_machine =3D EM_NONE; @@ -1176,9 +1177,10 @@ static void dump_sample(struct machine *machine, str= uct evsel *evsel, union perf sample_read__printf(sample, evsel->core.attr.read_format); } =20 -static void dump_deferred_callchain(struct evsel *evsel, union perf_event = *event, - struct perf_sample *sample) +static void dump_deferred_callchain(union perf_event *event, struct perf_s= ample *sample) { + struct evsel *evsel =3D sample->evsel; + if (!dump_trace) return; =20 @@ -1284,7 +1286,7 @@ static int deliver_sample_value(struct evlist *evlist, return 0; =20 sample->evsel =3D container_of(sid->evsel, struct evsel, core); - ret =3D tool->sample(tool, event, sample, sample->evsel, machine); + ret =3D tool->sample(tool, event, sample, machine); sample->evsel =3D saved_evsel; return ret; } @@ -1316,8 +1318,9 @@ static int deliver_sample_group(struct evlist *evlist, =20 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) + struct machine *machine) { + struct evsel *evsel =3D sample->evsel; /* We know evsel !=3D NULL. */ u64 sample_type =3D evsel->core.attr.sample_type; u64 read_format =3D evsel->core.attr.read_format; @@ -1325,7 +1328,7 @@ static int evlist__deliver_sample(struct evlist *evli= st, const struct perf_tool =20 /* Standard sample delivery. */ if (!(sample_type & PERF_SAMPLE_READ)) - return tool->sample(tool, event, sample, evsel, machine); + return tool->sample(tool, event, sample, machine); =20 /* For PERF_SAMPLE_READ we have either single or group mode. */ if (read_format & PERF_FORMAT_GROUP) @@ -1364,8 +1367,7 @@ static int evlist__deliver_deferred_callchain(struct = evlist *evlist, struct evsel *saved_evsel =3D sample->evsel; =20 sample->evsel =3D evlist__id2evsel(evlist, sample->id); - ret =3D tool->callchain_deferred(tool, event, sample, - sample->evsel, machine); + ret =3D tool->callchain_deferred(tool, event, sample, machine); sample->evsel =3D saved_evsel; return ret; } @@ -1393,7 +1395,7 @@ static int evlist__deliver_deferred_callchain(struct = evlist *evlist, =20 orig_sample.evsel =3D evlist__id2evsel(evlist, orig_sample.id); ret =3D evlist__deliver_sample(evlist, tool, de->event, - &orig_sample, orig_sample.evsel, machine); + &orig_sample, machine); =20 perf_sample__exit(&orig_sample); list_del(&de->list); @@ -1431,7 +1433,7 @@ static int session__flush_deferred_samples(struct per= f_session *session, =20 sample.evsel =3D evlist__id2evsel(evlist, sample.id); ret =3D evlist__deliver_sample(evlist, tool, de->event, - &sample, sample.evsel, machine); + &sample, machine); =20 perf_sample__exit(&sample); list_del(&de->list); @@ -1451,7 +1453,6 @@ static int machines__deliver_event(struct machines *m= achines, const struct perf_tool *tool, u64 file_offset, const char *file_path) { - struct evsel *evsel; struct machine *machine; =20 dump_event(evlist, event, file_offset, sample, file_path); @@ -1461,21 +1462,20 @@ static int machines__deliver_event(struct machines = *machines, else assert(sample->evsel =3D=3D evlist__id2evsel(evlist, sample->id)); =20 - evsel =3D sample->evsel; machine =3D machines__find_for_cpumode(machines, event, sample); =20 switch (event->header.type) { case PERF_RECORD_SAMPLE: - if (evsel =3D=3D NULL) { + if (sample->evsel =3D=3D NULL) { ++evlist->stats.nr_unknown_id; return 0; } if (machine =3D=3D NULL) { ++evlist->stats.nr_unprocessable_samples; - dump_sample(machine, evsel, event, sample); + dump_sample(machine, event, sample); return 0; } - dump_sample(machine, evsel, event, sample); + dump_sample(machine, event, sample); if (sample->deferred_callchain && tool->merge_deferred_callchains) { struct deferred_event *de =3D malloc(sizeof(*de)); size_t sz =3D event->header.size; @@ -1492,7 +1492,7 @@ static int machines__deliver_event(struct machines *m= achines, list_add_tail(&de->list, &evlist->deferred_samples); return 0; } - return evlist__deliver_sample(evlist, tool, event, sample, evsel, machin= e); + return evlist__deliver_sample(evlist, tool, event, sample, machine); case PERF_RECORD_MMAP: return tool->mmap(tool, event, sample, machine); case PERF_RECORD_MMAP2: @@ -1520,8 +1520,8 @@ static int machines__deliver_event(struct machines *m= achines, evlist->stats.total_lost_samples +=3D event->lost_samples.lost; return tool->lost_samples(tool, event, sample, machine); case PERF_RECORD_READ: - dump_read(evsel, event); - return tool->read(tool, event, sample, evsel, machine); + dump_read(sample->evsel, event); + return tool->read(tool, event, sample, machine); case PERF_RECORD_THROTTLE: return tool->throttle(tool, event, sample, machine); case PERF_RECORD_UNTHROTTLE: @@ -1550,7 +1550,7 @@ static int machines__deliver_event(struct machines *m= achines, case PERF_RECORD_AUX_OUTPUT_HW_ID: return tool->aux_output_hw_id(tool, event, sample, machine); case PERF_RECORD_CALLCHAIN_DEFERRED: - dump_deferred_callchain(evsel, event, sample); + dump_deferred_callchain(event, sample); return evlist__deliver_deferred_callchain(evlist, tool, event, sample, machine); default: diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 013c7839e2cf..0f285a2574c8 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -110,7 +110,6 @@ static int process_event_synth_event_update_stub(const = struct perf_tool *tool __ 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"); @@ -348,12 +347,11 @@ bool perf_tool__compressed_is_stub(const struct perf_= tool *tool) static int delegate_ ## name(const struct perf_tool *tool, \ union perf_event *event, \ struct perf_sample *sample, \ - struct evsel *evsel, \ struct machine *machine) \ { \ struct delegate_tool *del_tool =3D container_of(tool, struct delegate_to= ol, tool); \ struct perf_tool *delegate =3D del_tool->delegate; \ - return delegate->name(delegate, event, sample, evsel, machine); \ + return delegate->name(delegate, event, sample, machine); \ } CREATE_DELEGATE_SAMPLE(read); CREATE_DELEGATE_SAMPLE(sample); diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 2d9a4b1ca9d0..2a4f124ffd8d 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -9,7 +9,6 @@ struct perf_session; union perf_event; struct evlist; -struct evsel; struct perf_sample; struct perf_tool; struct machine; @@ -17,7 +16,7 @@ struct ordered_events; =20 typedef int (*event_sample)(const struct perf_tool *tool, union perf_event= *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine); + struct machine *machine); =20 typedef int (*event_op)(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample, struct machine *machine); @@ -103,7 +102,6 @@ bool perf_tool__compressed_is_stub(const struct perf_to= ol *tool); int process_event_sample_stub(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine); =20 struct delegate_tool { --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 351294035D3 for ; Thu, 19 Mar 2026 23:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962654; cv=none; b=JI0Mx7wLCnTjUOKoEpJifPXAGeWDMHd2EP3R0v96NirObrEpe6wxePS7jRaqr/t/Z02MnufUyE2+bbiGwUJUM9JvOY79UlXTJg3ufdKWU+EnDa26hTvx87ez37KkCf+HCbqxEN/SuflEJ+qg06ctzx9aIALeBbbInUZMSAVrto8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962654; c=relaxed/simple; bh=Grcetg7N96Qnq6I52ITEkl+uPXOFh0++ds3TxjPczHA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WJxmPLzFBcEytqeH17phdIMxwlEiCzfNyJGMlVzdVTemSPTC7UhmZk+doeBCYriSvvm1p58p7caQOOLwjLTLwJjZLXArXQ6YgBUAV2StwTEga/8V9vns/1aDqioLsIGvT6GK+jpFvSWF3k9kTh17/AErX6x7xejAJubw7kSfS/k= 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=dj9yih1d; arc=none smtp.client-ip=209.85.214.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="dj9yih1d" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b064884a7cso79561185ad.3 for ; Thu, 19 Mar 2026 16:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962651; x=1774567451; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kC37fKcIzLMF9nndBNyJdJNbqayYrQf0EhLLLr93T5M=; b=dj9yih1dyhQ+OZsm8apeg8VcQs/TsTxO6GYpcortHb3o2TNRnkqBPwBzwiMl9UrB+I GFcj663yh2edJOX//gJtCWgvvw9Y52W3W1AxXyZ+lrLYPTt1A7CGzBNOzP+Dlt7No8VH biqhh3o1MK7NmJRdXLRyNj4ZaYRhR0zf0T3ClMDqSk5a1ChN52Xfr8oIfizyqDvr8r9e 289W0rcknKt7IRXP/BszHbcp5YjvySzVoiZWtIzlgWW5BB6NgI16QAYlsMSXe8t0O3v5 8loa5iXU264/+uR+EglV4cPgvx2Kklq3dtDOGArBczNJYH8W+q5BnYP6Y5vWQl8/xyeV 0wxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962651; x=1774567451; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kC37fKcIzLMF9nndBNyJdJNbqayYrQf0EhLLLr93T5M=; b=dQ4+/GnaMHvuUNtoWTEl2qKyH8uHSgBeHXFXhm8XUHDUCWy5MQgSaHLA/A+d9SI8TF eiBSYL0ZVL0LPxflvxktwnJfepyyyyiYZsTeYn7QsotffLLb35ABIxhplu6B5ZIfatgJ iJmNRvKwG+vu2uwgoqxZ2CFwYAmhuMkPg02pZpiKu+anjSUOy7+IlUOziGxYp5LNAxj3 glBjXFONZXwYxdWoMrW359oNt7o17cV99njEBmpxhnDr4LZ8lNtuYbhnfhHBb5Z7DEXv gCXW57smGASmRjRaRzzHPy5m2v9FBqJ0XJo35tNMH61XN+SgdiUEzZAtmbRmVk9G7a1H u62Q== X-Forwarded-Encrypted: i=1; AJvYcCUW5PJBkvL+JVk7mrq8xTQbnXyI7UW/dcQe/iMA3qXffgBad353B4xKBn3NWfMmxoFOfNKP51NsN8svVo0=@vger.kernel.org X-Gm-Message-State: AOJu0YyoZcsxCTFfxFr2lEmC7W/rIDGwAXplPCaR830+a5cfQsQbuxgj Zwrb9hNHtDhU7h2kwffCc5kZ2ufwYL2/dd7F5APDctgP+qpyagPEZEjT0ozHthcN1Z/uz7DXkfS SwHhfnmnxog== X-Received: from ploo2.prod.google.com ([2002:a17:902:e002:b0:2b0:5538:b55b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:b288:b0:2b0:4fd1:ed5d with SMTP id d9443c01a7336-2b0826d7400mr4680295ad.8.1773962651121; Thu, 19 Mar 2026 16:24:11 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:14 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-6-irogers@google.com> Subject: [PATCH v2 05/25] perf kvm: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the sample now contains the evsel, read the evsel from the sample rather than passing them as a pair. Signed-off-by: Ian Rogers --- tools/perf/builtin-kvm.c | 19 +++-- .../perf/util/kvm-stat-arch/kvm-stat-arm64.c | 17 +++-- .../util/kvm-stat-arch/kvm-stat-loongarch.c | 17 ++--- .../util/kvm-stat-arch/kvm-stat-powerpc.c | 17 ++--- .../perf/util/kvm-stat-arch/kvm-stat-riscv.c | 18 +++-- tools/perf/util/kvm-stat-arch/kvm-stat-s390.c | 20 +++--- tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 70 ++++++++----------- tools/perf/util/kvm-stat.c | 19 +++-- tools/perf/util/kvm-stat.h | 18 ++--- 9 files changed, 89 insertions(+), 126 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 5e8e6fde097a..d9b9792894a8 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -806,7 +806,6 @@ static bool update_kvm_event(struct perf_kvm_stat *kvm, } =20 static bool is_child_event(struct perf_kvm_stat *kvm, - struct evsel *evsel, struct perf_sample *sample, struct event_key *key) { @@ -818,8 +817,8 @@ static bool is_child_event(struct perf_kvm_stat *kvm, return false; =20 for (; child_ops->name; child_ops++) { - if (evsel__name_is(evsel, child_ops->name)) { - child_ops->get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, child_ops->name)) { + child_ops->get_key(sample, key); return true; } } @@ -917,11 +916,10 @@ static bool handle_end_event(struct perf_kvm_stat *kv= m, =20 static struct vcpu_event_record *per_vcpu_record(struct thread *thread, - struct evsel *evsel, struct perf_sample *sample) { /* Only kvm_entry records vcpu id. */ - if (!thread__priv(thread) && kvm_entry_event(evsel)) { + if (!thread__priv(thread) && kvm_entry_event(sample->evsel)) { struct vcpu_event_record *vcpu_record; struct machine *machine =3D maps__machine(thread__maps(thread)); uint16_t e_machine =3D thread__e_machine(thread, machine, /*e_flags=3D*/= NULL); @@ -932,7 +930,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread= *thread, return NULL; } =20 - vcpu_record->vcpu_id =3D evsel__intval(evsel, sample, vcpu_id_str(e_mach= ine)); + vcpu_record->vcpu_id =3D evsel__intval(sample->evsel, sample, vcpu_id_st= r(e_machine)); thread__set_priv(thread, vcpu_record); } =20 @@ -943,12 +941,11 @@ static bool handle_kvm_event(struct perf_kvm_stat *kv= m, struct thread *thread, struct perf_sample *sample) { - struct evsel *evsel =3D sample->evsel; struct vcpu_event_record *vcpu_record; struct event_key key =3D { .key =3D INVALID_KEY, .exit_reasons =3D kvm->exit_reasons }; =20 - vcpu_record =3D per_vcpu_record(thread, evsel, sample); + vcpu_record =3D per_vcpu_record(thread, sample); if (!vcpu_record) return true; =20 @@ -957,13 +954,13 @@ static bool handle_kvm_event(struct perf_kvm_stat *kv= m, (kvm->trace_vcpu !=3D vcpu_record->vcpu_id)) return true; =20 - if (kvm->events_ops->is_begin_event(evsel, sample, &key)) + if (kvm->events_ops->is_begin_event(sample, &key)) return handle_begin_event(kvm, vcpu_record, &key, sample); =20 - if (is_child_event(kvm, evsel, sample, &key)) + if (is_child_event(kvm, sample, &key)) return handle_child_event(kvm, vcpu_record, &key, sample); =20 - if (kvm->events_ops->is_end_event(evsel, sample, &key)) + if (kvm->events_ops->is_end_event(sample, &key)) return handle_end_event(kvm, vcpu_record, &key, sample); =20 return true; diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-arm64.c index c640dcd8af7c..1e76906f719c 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c @@ -17,10 +17,11 @@ static const char * const __kvm_events_tp[] =3D { NULL, }; =20 -static void event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_get_key(struct perf_sample *sample, struct event_key *key) { + struct evsel *evsel =3D sample->evsel; + key->info =3D 0; key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(EM_AARCH64)); key->exit_reasons =3D arm64_exit_reasons; @@ -36,19 +37,17 @@ static void event_get_key(struct evsel *evsel, } } =20 -static bool event_begin(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool event_begin(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return evsel__name_is(evsel, kvm_entry_trace(EM_AARCH64)); + return evsel__name_is(sample->evsel, kvm_entry_trace(EM_AARCH64)); } =20 -static bool event_end(struct evsel *evsel, - struct perf_sample *sample, +static bool event_end(struct perf_sample *sample, struct event_key *key) { - if (evsel__name_is(evsel, kvm_exit_trace(EM_AARCH64))) { - event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, kvm_exit_trace(EM_AARCH64))) { + event_get_key(sample, key); return true; } return false; diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c b/tools/per= f/util/kvm-stat-arch/kvm-stat-loongarch.c index b802e516b138..9d6265290f6d 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c @@ -53,14 +53,12 @@ static const char * const __kvm_events_tp[] =3D { NULL, }; =20 -static bool event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static bool event_begin(struct perf_sample *sample, struct event_key *key) { - return exit_event_begin(evsel, sample, key); + return exit_event_begin(sample, key); } =20 -static bool event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool event_end(struct perf_sample *sample, struct event_key *key __maybe_unused) { /* @@ -71,17 +69,16 @@ static bool event_end(struct evsel *evsel, * kvm:kvm_enter means returning to vmm and then to guest * kvm:kvm_reenter means returning to guest immediately */ - return evsel__name_is(evsel, kvm_entry_trace(EM_LOONGARCH)) || - evsel__name_is(evsel, kvm_reenter_trace); + return evsel__name_is(sample->evsel, kvm_entry_trace(EM_LOONGARCH)) || + evsel__name_is(sample->evsel, kvm_reenter_trace); } =20 -static void event_gspr_get_key(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static void event_gspr_get_key(struct perf_sample *sample, struct event_ke= y *key) { unsigned int insn; =20 key->key =3D LOONGARCH_EXCEPTION_OTHERS; - insn =3D evsel__intval(evsel, sample, "inst_word"); + insn =3D evsel__intval(sample->evsel, sample, "inst_word"); =20 switch (insn >> 24) { case 0: diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c b/tools/perf/= util/kvm-stat-arch/kvm-stat-powerpc.c index 42182d70beb6..5158d7e88ee6 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c @@ -28,12 +28,11 @@ static const char * const ppc_book3s_hv_kvm_tp[] =3D { /* 1 extra placeholder for NULL */ static const char *__kvm_events_tp[NR_TPS + 1]; =20 -static void hcall_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void hcall_event_get_key(struct perf_sample *sample, struct event_key *key) { key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, "req"); + key->key =3D evsel__intval(sample->evsel, sample, "req"); } =20 static const char *get_hcall_exit_reason(u64 exit_code) @@ -51,18 +50,16 @@ static const char *get_hcall_exit_reason(u64 exit_code) return "UNKNOWN"; } =20 -static bool hcall_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool hcall_event_end(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return evsel__name_is(evsel, __kvm_events_tp[3]); + return evsel__name_is(sample->evsel, __kvm_events_tp[3]); } =20 -static bool hcall_event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static bool hcall_event_begin(struct perf_sample *sample, struct event_key= *key) { - if (evsel__name_is(evsel, __kvm_events_tp[2])) { - hcall_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, __kvm_events_tp[2])) { + hcall_event_get_key(sample, key); return true; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-riscv.c index 8d4d5d6ce720..e8db8b4f8e2e 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c @@ -20,30 +20,28 @@ static const char * const __kvm_events_tp[] =3D { NULL, }; =20 -static void event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_get_key(struct perf_sample *sample, struct event_key *key) { int xlen =3D 64; // TODO: 32-bit support. =20 key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(EM_RISCV)) & ~C= AUSE_IRQ_FLAG(xlen); + key->key =3D evsel__intval(sample->evsel, sample, + kvm_exit_reason(EM_RISCV)) & ~CAUSE_IRQ_FLAG(xlen); key->exit_reasons =3D riscv_exit_reasons; } =20 -static bool event_begin(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +static bool event_begin(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return evsel__name_is(evsel, kvm_entry_trace(EM_RISCV)); + return evsel__name_is(sample->evsel, kvm_entry_trace(EM_RISCV)); } =20 -static bool event_end(struct evsel *evsel, - struct perf_sample *sample, +static bool event_end(struct perf_sample *sample, struct event_key *key) { - if (evsel__name_is(evsel, kvm_exit_trace(EM_RISCV))) { - event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, kvm_exit_trace(EM_RISCV))) { + event_get_key(sample, key); return true; } return false; diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c b/tools/perf/uti= l/kvm-stat-arch/kvm-stat-s390.c index 7e29169f5bb0..158372ba0205 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c @@ -18,38 +18,34 @@ define_exit_reasons_table(sie_sigp_order_codes, sigp_or= der_codes); define_exit_reasons_table(sie_diagnose_codes, diagnose_codes); define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes); =20 -static void event_icpt_insn_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_icpt_insn_get_key(struct perf_sample *sample, struct event_key *key) { u64 insn; =20 - insn =3D evsel__intval(evsel, sample, "instruction"); + insn =3D evsel__intval(sample->evsel, sample, "instruction"); key->key =3D icpt_insn_decoder(insn); key->exit_reasons =3D sie_icpt_insn_codes; } =20 -static void event_sigp_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_sigp_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "order_code"); + key->key =3D evsel__intval(sample->evsel, sample, "order_code"); key->exit_reasons =3D sie_sigp_order_codes; } =20 -static void event_diag_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_diag_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "code"); + key->key =3D evsel__intval(sample->evsel, sample, "code"); key->exit_reasons =3D sie_diagnose_codes; } =20 -static void event_icpt_prog_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void event_icpt_prog_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "code"); + key->key =3D evsel__intval(sample->evsel, sample, "code"); key->exit_reasons =3D sie_icpt_prog_codes; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util= /kvm-stat-arch/kvm-stat-x86.c index 0f626db3a439..0ce543d82850 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c @@ -24,45 +24,43 @@ static const struct kvm_events_ops exit_events =3D { * the time of MMIO write: kvm_mmio(KVM_TRACE_MMIO_WRITE...) -> kvm_entry * the time of MMIO read: kvm_exit -> kvm_mmio(KVM_TRACE_MMIO_READ...). */ -static void mmio_event_get_key(struct evsel *evsel, struct perf_sample *sa= mple, +static void mmio_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "gpa"); - key->info =3D evsel__intval(evsel, sample, "type"); + key->key =3D evsel__intval(sample->evsel, sample, "gpa"); + key->info =3D evsel__intval(sample->evsel, sample, "type"); } =20 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 #define KVM_TRACE_MMIO_READ 1 #define KVM_TRACE_MMIO_WRITE 2 =20 -static bool mmio_event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +static bool mmio_event_begin(struct perf_sample *sample, struct event_key = *key) { /* MMIO read begin event in kernel. */ - if (kvm_exit_event(evsel)) + if (kvm_exit_event(sample->evsel)) return true; =20 /* MMIO write begin event in kernel. */ - if (evsel__name_is(evsel, "kvm:kvm_mmio") && - evsel__intval(evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_WRITE) { - mmio_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && + evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_WR= ITE) { + mmio_event_get_key(sample, key); return true; } =20 return false; } =20 -static bool mmio_event_end(struct evsel *evsel, struct perf_sample *sample, - struct event_key *key) +static bool mmio_event_end(struct perf_sample *sample, struct event_key *k= ey) { /* MMIO write end event in kernel. */ - if (kvm_entry_event(evsel)) + if (kvm_entry_event(sample->evsel)) return true; =20 /* MMIO read end event in kernel.*/ - if (evsel__name_is(evsel, "kvm:kvm_mmio") && - evsel__intval(evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_READ) { - mmio_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && + evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_RE= AD) { + mmio_event_get_key(sample, key); return true; } =20 @@ -86,31 +84,27 @@ static const struct kvm_events_ops mmio_events =3D { }; =20 /* The time of emulation pio access is from kvm_pio to kvm_entry. */ -static void ioport_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +static void ioport_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(evsel, sample, "port"); - key->info =3D evsel__intval(evsel, sample, "rw"); + key->key =3D evsel__intval(sample->evsel, sample, "port"); + key->info =3D evsel__intval(sample->evsel, sample, "rw"); } =20 -static bool ioport_event_begin(struct evsel *evsel, - struct perf_sample *sample, +static bool ioport_event_begin(struct perf_sample *sample, struct event_key *key) { - if (evsel__name_is(evsel, "kvm:kvm_pio")) { - ioport_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_pio")) { + ioport_event_get_key(sample, key); return true; } =20 return false; } =20 -static bool ioport_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, - struct event_key *key __maybe_unused) +static bool ioport_event_end(struct perf_sample *sample, struct event_key = *key __maybe_unused) { - return kvm_entry_event(evsel); + return kvm_entry_event(sample->evsel); } =20 static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unus= ed, @@ -130,31 +124,25 @@ static const struct kvm_events_ops ioport_events =3D { }; =20 /* The time of emulation msr is from kvm_msr to kvm_entry. */ -static void msr_event_get_key(struct evsel *evsel, - struct perf_sample *sample, - struct event_key *key) +static void msr_event_get_key(struct perf_sample *sample, struct event_key= *key) { - key->key =3D evsel__intval(evsel, sample, "ecx"); - key->info =3D evsel__intval(evsel, sample, "write"); + key->key =3D evsel__intval(sample->evsel, sample, "ecx"); + key->info =3D evsel__intval(sample->evsel, sample, "write"); } =20 -static bool msr_event_begin(struct evsel *evsel, - struct perf_sample *sample, - struct event_key *key) +static bool msr_event_begin(struct perf_sample *sample, struct event_key *= key) { - if (evsel__name_is(evsel, "kvm:kvm_msr")) { - msr_event_get_key(evsel, sample, key); + if (evsel__name_is(sample->evsel, "kvm:kvm_msr")) { + msr_event_get_key(sample, key); return true; } =20 return false; } =20 -static bool msr_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, - struct event_key *key __maybe_unused) +static bool msr_event_end(struct perf_sample *sample, struct event_key *ke= y __maybe_unused) { - return kvm_entry_event(evsel); + return kvm_entry_event(sample->evsel); } =20 static void msr_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, diff --git a/tools/perf/util/kvm-stat.c b/tools/perf/util/kvm-stat.c index 27f16810498c..f17a6132958d 100644 --- a/tools/perf/util/kvm-stat.c +++ b/tools/perf/util/kvm-stat.c @@ -11,22 +11,20 @@ bool kvm_exit_event(struct evsel *evsel) return evsel__name_is(evsel, kvm_exit_trace(e_machine)); } =20 -void exit_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +void exit_event_get_key(struct perf_sample *sample, struct event_key *key) { - uint16_t e_machine =3D evsel__e_machine(evsel, /*e_flags=3D*/NULL); + uint16_t e_machine =3D evsel__e_machine(sample->evsel, /*e_flags=3D*/NULL= ); =20 key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(e_machine)); + key->key =3D evsel__intval(sample->evsel, sample, kvm_exit_reason(e_mach= ine)); } =20 =20 -bool exit_event_begin(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key) +bool exit_event_begin(struct perf_sample *sample, struct event_key *key) { - if (kvm_exit_event(evsel)) { - exit_event_get_key(evsel, sample, key); + if (kvm_exit_event(sample->evsel)) { + exit_event_get_key(sample, key); return true; } =20 @@ -40,11 +38,10 @@ bool kvm_entry_event(struct evsel *evsel) return evsel__name_is(evsel, kvm_entry_trace(e_machine)); } =20 -bool exit_event_end(struct evsel *evsel, - struct perf_sample *sample __maybe_unused, +bool exit_event_end(struct perf_sample *sample, struct event_key *key __maybe_unused) { - return kvm_entry_event(evsel); + return kvm_entry_event(sample->evsel); } =20 static const char *get_exit_reason(struct perf_kvm_stat *kvm, diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index 4a998aaece5d..cdbd921a555f 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h @@ -53,18 +53,15 @@ struct kvm_event { }; =20 struct child_event_ops { - void (*get_key)(struct evsel *evsel, - struct perf_sample *sample, + void (*get_key)(struct perf_sample *sample, struct event_key *key); const char *name; }; =20 struct kvm_events_ops { - bool (*is_begin_event)(struct evsel *evsel, - struct perf_sample *sample, + bool (*is_begin_event)(struct perf_sample *sample, struct event_key *key); - bool (*is_end_event)(struct evsel *evsel, - struct perf_sample *sample, struct event_key *key); + bool (*is_end_event)(struct perf_sample *sample, struct event_key *key); const struct child_event_ops *child_ops; void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key, char *decode); @@ -116,14 +113,11 @@ struct kvm_reg_events_ops { =20 #ifdef HAVE_LIBTRACEEVENT =20 -void exit_event_get_key(struct evsel *evsel, - struct perf_sample *sample, +void exit_event_get_key(struct perf_sample *sample, struct event_key *key); -bool exit_event_begin(struct evsel *evsel, - struct perf_sample *sample, +bool exit_event_begin(struct perf_sample *sample, struct event_key *key); -bool exit_event_end(struct evsel *evsel, - struct perf_sample *sample, +bool exit_event_end(struct perf_sample *sample, struct event_key *key); void exit_event_decode_key(struct perf_kvm_stat *kvm, struct event_key *key, --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 59760402456 for ; Thu, 19 Mar 2026 23:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962658; cv=none; b=jGDjY91EJQix3szcTmWxvvZUY/VLCTHgdaZayOYN2EVth0tLypbjvMToE8/BCMYL0hWLbSkN/gANO7VR4Ji9rCB9xhcrMhAgx4ZULe4AYm+MsOC8N5Q0aNNEEni/8rndops2LD3fRVAV0Xkpigr05EcTNdtWDhckRtdw9UIp+7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962658; c=relaxed/simple; bh=jH3VRKhrglltEvySji4a+AxO02TUkd/AlOx8VfGrHhU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=psEMpI7/tJiTQ5UvMfzcc+0QzpXaLyazTmb+P9D5TYOeECXAaCidOb8P2rtWXjRomiEIqIIa5mv09dt4TODgXxsrp9NDQuiU8sfK+FIOPWbZuueoj5KGu9nk1lyiUOwUTBpvc/aPWN/bDm0dwNMMOJG/PJAjxbyeRO6rYPmgRt0= 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=tSG+hmt4; arc=none smtp.client-ip=74.125.82.73 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="tSG+hmt4" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-127876be621so891990c88.1 for ; Thu, 19 Mar 2026 16:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962653; x=1774567453; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ho8m7h7wF4wI6cNrqGnGIt2ugC7iGqldUHgQLWewO8c=; b=tSG+hmt4fdkj5/jxgUQH1VJdY7ooos2nEzIP2LEd06dZiB/8tsKiTFtrxR097XAsRW peJZHZ47ejGVViKb/1C2wHBfFvK11D+d8dhGt4/pEUFjoaY652/oLiB31COXj23WZi8h NjrcQtiPU2mfh4t4Pe7E3QyVLiTs3iGcIz5boj/I/P3nL5ZM8V2bJ1sTB0QE6fVc+3im NH6+JMyw1jHaTMARt/QkYy9amarlzmOIIpKEnWOtfpG/5Q2WBg8CoYJMq5Pep/vDeaxj P7zc9nuy93ldpEzd32JJHQi3dYzeoZhVrbw8AUZUlw2ZQR+WhgvWMqNFAWgr0sMOKAj0 V3VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962653; x=1774567453; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ho8m7h7wF4wI6cNrqGnGIt2ugC7iGqldUHgQLWewO8c=; b=ZsRG2COPAXf6UIe2R2JNliDb+5SAVlFGL+g7ONoKi5ChSN5rVqjZS/n+M9fJcJx30Y foXPfL2BqypmOyHJ10DN6mD+b3TXRDj9LuRDfrL3qkDiH0ASjeqhOqdiN6yePGr90ivX Fdk2FHCViueNTL1wg3UW4B4wPrpe7YmEh/UK/XtC5D/5nUl+yLF4D2Ds0atcRAhtcwJz VuYn+s9WeHcbxPuEWkWu69rkBSc56qJAi18InJh+eDAfoli4/SxRcHXClNvhm67lyKOA XPBLA0/r2ADcYo8AENnkYR10pw3X6PRxDClk5VVIuW0W8nVPWzWAIWtc3BMT76J7FhiE lUkg== X-Forwarded-Encrypted: i=1; AJvYcCUSavMgjkpMhVSkj2b80Cg2NDbJpHQyf6HYFlKVCbgHeIi9s4kpcvBAjnZ9jODwV/3dYZxB3BhPdbU/390=@vger.kernel.org X-Gm-Message-State: AOJu0YwIzUC+TZF0/Yl/C0ZYIa9jszVjwcMXxStja3c76robeEwTzhUd Gr1uVA8tcDx0l48E5EEDKBSvNFtGJKtbym3WKlolEJgNPVG2r6hLRoaeGl3/s8mLrj8YDBnjT/H O2Wt9KlcM5g== X-Received: from dybpn13.prod.google.com ([2002:a05:7301:438d:b0:2c0:c93c:ad21]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6609:b0:123:2f12:60b4 with SMTP id a92af1059eb24-12a6858588emr2185336c88.20.1773962653317; Thu, 19 Mar 2026 16:24:13 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:15 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-7-irogers@google.com> Subject: [PATCH v2 06/25] perf evsel: Refactor evsel__intval to perf_sample__intval From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The evsel argument to evsel__intval, and similar functions, is unnecessary as it can be read from the sample. Remove the evsel and rename the function to match that the data is coming from the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-kmem.c | 33 +++---- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-kwork.c | 29 +++--- tools/perf/builtin-lock.c | 32 +++---- tools/perf/builtin-sched.c | 92 +++++++++---------- tools/perf/builtin-timechart.c | 88 +++++++++--------- tools/perf/builtin-trace.c | 12 +-- tools/perf/tests/openat-syscall-tp-fields.c | 2 +- tools/perf/tests/switch-tracking.c | 4 +- tools/perf/util/evsel.c | 22 ++--- tools/perf/util/evsel.h | 12 +-- tools/perf/util/intel-pt.c | 2 +- .../perf/util/kvm-stat-arch/kvm-stat-arm64.c | 6 +- .../util/kvm-stat-arch/kvm-stat-loongarch.c | 2 +- .../util/kvm-stat-arch/kvm-stat-powerpc.c | 2 +- .../perf/util/kvm-stat-arch/kvm-stat-riscv.c | 3 +- tools/perf/util/kvm-stat-arch/kvm-stat-s390.c | 8 +- tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 16 ++-- tools/perf/util/kvm-stat.c | 2 +- 20 files changed, 183 insertions(+), 188 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 89f6fc826187..483c8cac14fd 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -1085,7 +1085,7 @@ static int perf_inject__sched_stat(const struct perf_= tool *tool, union perf_event *event_sw; struct perf_sample sample_sw; struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); - u32 pid =3D evsel__intval(evsel, sample, "pid"); + u32 pid =3D perf_sample__intval(sample, "pid"); int ret; =20 list_for_each_entry(ent, &inject->samples, node) { diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 34852a4c3fc8..96b78a64c1c1 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -173,10 +173,10 @@ static int insert_caller_stat(unsigned long call_site, =20 static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sam= ple *sample) { - unsigned long ptr =3D evsel__intval(evsel, sample, "ptr"), - call_site =3D evsel__intval(evsel, sample, "call_site"); - int bytes_req =3D evsel__intval(evsel, sample, "bytes_req"), - bytes_alloc =3D evsel__intval(evsel, sample, "bytes_alloc"); + unsigned long ptr =3D perf_sample__intval(sample, "ptr"), + call_site =3D perf_sample__intval(sample, "call_site"); + int bytes_req =3D perf_sample__intval(sample, "bytes_req"), + bytes_alloc =3D perf_sample__intval(sample, "bytes_alloc"); =20 if (insert_alloc_stat(call_site, ptr, bytes_req, bytes_alloc, sample->cpu= ) || insert_caller_stat(call_site, bytes_req, bytes_alloc)) @@ -202,7 +202,7 @@ static int evsel__process_alloc_event(struct evsel *evs= el, struct perf_sample *s int node1, node2; =20 node1 =3D cpu__get_node((struct perf_cpu){.cpu =3D sample->cpu}); - node2 =3D evsel__intval(evsel, sample, "node"); + node2 =3D perf_sample__intval(sample, "node"); =20 /* * If the field "node" is NUMA_NO_NODE (-1), we don't take it @@ -243,9 +243,9 @@ static struct alloc_stat *search_alloc_stat(unsigned lo= ng ptr, return NULL; } =20 -static int evsel__process_free_event(struct evsel *evsel, struct perf_samp= le *sample) +static int evsel__process_free_event(struct evsel *evsel __maybe_unused, s= truct perf_sample *sample) { - unsigned long ptr =3D evsel__intval(evsel, sample, "ptr"); + unsigned long ptr =3D perf_sample__intval(sample, "ptr"); struct alloc_stat *s_alloc, *s_caller; =20 s_alloc =3D search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp); @@ -808,9 +808,9 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, static int evsel__process_page_alloc_event(struct evsel *evsel, struct per= f_sample *sample) { u64 page; - unsigned int order =3D evsel__intval(evsel, sample, "order"); - unsigned int gfp_flags =3D evsel__intval(evsel, sample, "gfp_flags"); - unsigned int migrate_type =3D evsel__intval(evsel, sample, + unsigned int order =3D perf_sample__intval(sample, "order"); + unsigned int gfp_flags =3D perf_sample__intval(sample, "gfp_flags"); + unsigned int migrate_type =3D perf_sample__intval(sample, "migratetype"); u64 bytes =3D kmem_page_size << order; u64 callsite; @@ -822,9 +822,9 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp }; =20 if (use_pfn) - page =3D evsel__intval(evsel, sample, "pfn"); + page =3D perf_sample__intval(sample, "pfn"); else - page =3D evsel__intval(evsel, sample, "page"); + page =3D perf_sample__intval(sample, "page"); =20 nr_page_allocs++; total_page_alloc_bytes +=3D bytes; @@ -877,10 +877,11 @@ static int evsel__process_page_alloc_event(struct evs= el *evsel, struct perf_samp return 0; } =20 -static int evsel__process_page_free_event(struct evsel *evsel, struct perf= _sample *sample) +static int evsel__process_page_free_event(struct evsel *evsel __maybe_unus= ed, + struct perf_sample *sample) { u64 page; - unsigned int order =3D evsel__intval(evsel, sample, "order"); + unsigned int order =3D perf_sample__intval(sample, "order"); u64 bytes =3D kmem_page_size << order; struct page_stat *pstat; struct page_stat this =3D { @@ -888,9 +889,9 @@ static int evsel__process_page_free_event(struct evsel = *evsel, struct perf_sampl }; =20 if (use_pfn) - page =3D evsel__intval(evsel, sample, "pfn"); + page =3D perf_sample__intval(sample, "pfn"); else - page =3D evsel__intval(evsel, sample, "page"); + page =3D perf_sample__intval(sample, "page"); =20 nr_page_frees++; total_page_free_bytes +=3D bytes; diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index d9b9792894a8..dd2ed21596aa 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -930,7 +930,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread= *thread, return NULL; } =20 - vcpu_record->vcpu_id =3D evsel__intval(sample->evsel, sample, vcpu_id_st= r(e_machine)); + vcpu_record->vcpu_id =3D perf_sample__intval(sample, vcpu_id_str(e_machi= ne)); thread__set_priv(thread, vcpu_record); } =20 diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index e34a1f35439e..111ae53025d1 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1006,7 +1006,7 @@ static void irq_work_init(struct perf_kwork *kwork, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1014,11 +1014,11 @@ static void irq_work_init(struct perf_kwork *kwork, work->cpu =3D sample->cpu; =20 if (kwork->report =3D=3D KWORK_REPORT_TOP) { - work->id =3D evsel__intval_common(evsel, sample, "common_pid"); + work->id =3D perf_sample__intval_common(sample, "common_pid"); work->name =3D NULL; } else { - work->id =3D evsel__intval(evsel, sample, "irq"); - work->name =3D evsel__strval(evsel, sample, "name"); + work->id =3D perf_sample__intval(sample, "irq"); + work->name =3D perf_sample__strval(sample, "name"); } } =20 @@ -1144,10 +1144,10 @@ static void softirq_work_init(struct perf_kwork *kw= ork, work->cpu =3D sample->cpu; =20 if (kwork->report =3D=3D KWORK_REPORT_TOP) { - work->id =3D evsel__intval_common(evsel, sample, "common_pid"); + work->id =3D perf_sample__intval_common(sample, "common_pid"); work->name =3D NULL; } else { - num =3D evsel__intval(evsel, sample, "vec"); + num =3D perf_sample__intval(sample, "vec"); work->id =3D num; work->name =3D evsel__softirq_name(evsel, num); } @@ -1234,17 +1234,16 @@ static void workqueue_work_init(struct perf_kwork *= kwork __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { char *modp =3D NULL; - unsigned long long function_addr =3D evsel__intval(evsel, - sample, "function"); + unsigned long long function_addr =3D perf_sample__intval(sample, "functio= n"); =20 work->class =3D class; work->cpu =3D sample->cpu; - work->id =3D evsel__intval(evsel, sample, "work"); + work->id =3D perf_sample__intval(sample, "work"); work->name =3D function_addr =3D=3D 0 ? NULL : machine__resolve_kernel_addr(machine, &function_addr, &modp); } @@ -1302,7 +1301,7 @@ static void sched_work_init(struct perf_kwork *kwork = __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1310,11 +1309,11 @@ static void sched_work_init(struct perf_kwork *kwor= k __maybe_unused, work->cpu =3D sample->cpu; =20 if (src_type =3D=3D KWORK_TRACE_EXIT) { - work->id =3D evsel__intval(evsel, sample, "prev_pid"); - work->name =3D strdup(evsel__strval(evsel, sample, "prev_comm")); + work->id =3D perf_sample__intval(sample, "prev_pid"); + work->name =3D strdup(perf_sample__strval(sample, "prev_comm")); } else if (src_type =3D=3D KWORK_TRACE_ENTRY) { - work->id =3D evsel__intval(evsel, sample, "next_pid"); - work->name =3D strdup(evsel__strval(evsel, sample, "next_comm")); + work->id =3D perf_sample__intval(sample, "next_pid"); + work->name =3D strdup(perf_sample__strval(sample, "next_comm")); } } =20 diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index dc8d1d3b4cd7..baf0c99df5df 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -563,15 +563,15 @@ static int get_key_by_aggr_mode(u64 *key, u64 addr, s= truct evsel *evsel, return get_key_by_aggr_mode_simple(key, addr, sample->tid); } =20 -static int report_lock_acquire_event(struct evsel *evsel, +static int report_lock_acquire_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); - int flag =3D evsel__intval(evsel, sample, "flags"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); + int flag =3D perf_sample__intval(sample, "flags"); u64 key; int ret; =20 @@ -638,15 +638,15 @@ static int report_lock_acquire_event(struct evsel *ev= sel, return 0; } =20 -static int report_lock_acquired_event(struct evsel *evsel, +static int report_lock_acquired_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; u64 contended_term; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); u64 key; int ret; =20 @@ -704,14 +704,14 @@ static int report_lock_acquired_event(struct evsel *e= vsel, return 0; } =20 -static int report_lock_contended_event(struct evsel *evsel, +static int report_lock_contended_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); u64 key; int ret; =20 @@ -762,14 +762,14 @@ static int report_lock_contended_event(struct evsel *= evsel, return 0; } =20 -static int report_lock_release_event(struct evsel *evsel, +static int report_lock_release_event(struct evsel *evsel __maybe_unused, struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - const char *name =3D evsel__strval(evsel, sample, "name"); - u64 addr =3D evsel__intval(evsel, sample, "lockdep_addr"); + const char *name =3D perf_sample__strval(sample, "name"); + u64 addr =3D perf_sample__intval(sample, "lockdep_addr"); u64 key; int ret; =20 @@ -969,8 +969,8 @@ static int report_lock_contention_begin_event(struct ev= sel *evsel, struct lock_stat *ls; struct thread_stat *ts; struct lock_seq_stat *seq; - u64 addr =3D evsel__intval(evsel, sample, "lock_addr"); - unsigned int flags =3D evsel__intval(evsel, sample, "flags"); + u64 addr =3D perf_sample__intval(sample, "lock_addr"); + unsigned int flags =3D perf_sample__intval(sample, "flags"); u64 key; int i, ret; static bool kmap_loaded; @@ -1134,7 +1134,7 @@ static int report_lock_contention_end_event(struct ev= sel *evsel, struct thread_stat *ts; struct lock_seq_stat *seq; u64 contended_term; - u64 addr =3D evsel__intval(evsel, sample, "lock_addr"); + u64 addr =3D perf_sample__intval(sample, "lock_addr"); u64 key; int ret; =20 diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 296b9837278a..c7a7e0208a16 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -829,8 +829,8 @@ replay_wakeup_event(struct perf_sched *sched, struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { - const char *comm =3D evsel__strval(evsel, sample, "comm"); - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const char *comm =3D perf_sample__strval(sample, "comm"); + const u32 pid =3D perf_sample__intval(sample, "pid"); struct task_desc *waker, *wakee; =20 if (verbose > 0) { @@ -851,10 +851,10 @@ static int replay_switch_event(struct perf_sched *sch= ed, struct perf_sample *sample, struct machine *machine __maybe_unused) { - const char *prev_comm =3D evsel__strval(evsel, sample, "prev_comm"), - *next_comm =3D evsel__strval(evsel, sample, "next_comm"); - const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"), - next_pid =3D evsel__intval(evsel, sample, "next_pid"); + const char *prev_comm =3D perf_sample__strval(sample, "prev_comm"), + *next_comm =3D perf_sample__strval(sample, "next_comm"); + const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), + next_pid =3D perf_sample__intval(sample, "next_pid"); struct task_desc *prev, __maybe_unused *next; u64 timestamp0, timestamp =3D sample->time; int cpu =3D sample->cpu; @@ -1134,13 +1134,13 @@ static void free_work_atoms(struct work_atoms *atom= s) } =20 static int latency_switch_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"), - next_pid =3D evsel__intval(evsel, sample, "next_pid"); - const char prev_state =3D evsel__taskstate(evsel, sample, "prev_state"); + const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), + next_pid =3D perf_sample__intval(sample, "next_pid"); + const char prev_state =3D perf_sample__taskstate(sample, "prev_state"); struct work_atoms *out_events, *in_events; struct thread *sched_out, *sched_in; u64 timestamp0, timestamp =3D sample->time; @@ -1204,12 +1204,12 @@ static int latency_switch_event(struct perf_sched *= sched, } =20 static int latency_runtime_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 pid =3D evsel__intval(evsel, sample, "pid"); - const u64 runtime =3D evsel__intval(evsel, sample, "runtime"); + const u32 pid =3D perf_sample__intval(sample, "pid"); + const u64 runtime =3D perf_sample__intval(sample, "runtime"); struct thread *thread =3D machine__findnew_thread(machine, -1, pid); struct work_atoms *atoms =3D thread_atoms_search(&sched->atom_root, threa= d, &sched->cmp_pid); u64 timestamp =3D sample->time; @@ -1239,11 +1239,11 @@ static int latency_runtime_event(struct perf_sched = *sched, } =20 static int latency_wakeup_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); struct work_atoms *atoms; struct work_atom *atom; struct thread *wakee; @@ -1300,11 +1300,11 @@ static int latency_wakeup_event(struct perf_sched *= sched, } =20 static int latency_migrate_task_event(struct perf_sched *sched, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); u64 timestamp =3D sample->time; struct work_atoms *atoms; struct work_atom *atom; @@ -1626,11 +1626,11 @@ static void print_sched_map(struct perf_sched *sche= d, struct perf_cpu this_cpu, } } =20 -static int map_switch_event(struct perf_sched *sched, struct evsel *evsel, +static int map_switch_event(struct perf_sched *sched, struct evsel *evsel = __maybe_unused, struct perf_sample *sample, struct machine *machine) { - const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); - const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"); + const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); + const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"); struct thread *sched_in, *sched_out; struct thread_runtime *tr; int new_shortname; @@ -1797,8 +1797,8 @@ static int process_sched_switch_event(const struct pe= rf_tool *tool, { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); int this_cpu =3D sample->cpu, err =3D 0; - u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"), - next_pid =3D evsel__intval(evsel, sample, "next_pid"); + u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"), + next_pid =3D perf_sample__intval(sample, "next_pid"); =20 if (sched->curr_pid[this_cpu] !=3D (u32)-1) { /* @@ -2068,12 +2068,11 @@ static char *timehist_get_commstr(struct thread *th= read) =20 /* prio field format: xxx or xxx->yyy */ #define MAX_PRIO_STR_LEN 8 -static char *timehist_get_priostr(struct evsel *evsel, - struct thread *thread, +static char *timehist_get_priostr(struct thread *thread, struct perf_sample *sample) { static char prio_str[16]; - int prev_prio =3D (int)evsel__intval(evsel, sample, "prev_prio"); + int prev_prio =3D (int)perf_sample__intval(sample, "prev_prio"); struct thread_runtime *tr =3D thread__priv(thread); =20 if (tr->prio !=3D prev_prio && tr->prio !=3D -1) @@ -2161,15 +2160,14 @@ static void timehist_header(struct perf_sched *sche= d) } =20 static void timehist_print_sample(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct addr_location *al, struct thread *thread, u64 t, const char state) { struct thread_runtime *tr =3D thread__priv(thread); - const char *next_comm =3D evsel__strval(evsel, sample, "next_comm"); - const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); + const char *next_comm =3D perf_sample__strval(sample, "next_comm"); + const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); u32 max_cpus =3D sched->max_cpu.cpu + 1; char tstr[64]; char nstr[30]; @@ -2198,14 +2196,15 @@ static void timehist_print_sample(struct perf_sched= *sched, } =20 if (!thread__comm_set(thread)) { - const char *prev_comm =3D evsel__strval(evsel, sample, "pr= ev_comm"); - thread__set_comm(thread, prev_comm, sample->time); + const char *prev_comm =3D perf_sample__strval(sample, "prev_comm"); + + thread__set_comm(thread, prev_comm, sample->time); } =20 printf(" %-*s ", comm_width, timehist_get_commstr(thread)); =20 if (sched->show_prio) - printf(" %-*s ", MAX_PRIO_STR_LEN, timehist_get_priostr(evsel, thread, s= ample)); + printf(" %-*s ", MAX_PRIO_STR_LEN, timehist_get_priostr(thread, sample)); =20 wait_time =3D tr->dt_sleep + tr->dt_iowait + tr->dt_preempt; print_sched_time(wait_time, 6); @@ -2319,7 +2318,7 @@ static bool is_idle_sample(struct perf_sample *sample, { /* pid 0 =3D=3D swapper =3D=3D idle task */ if (evsel__name_is(evsel, "sched:sched_switch")) - return evsel__intval(evsel, sample, "prev_pid") =3D=3D 0; + return perf_sample__intval(sample, "prev_pid") =3D=3D 0; =20 return sample->pid =3D=3D 0; } @@ -2539,7 +2538,7 @@ static struct thread *timehist_get_thread(struct perf= _sched *sched, itr->last_thread =3D thread__get(thread); =20 /* copy task callchain when entering to idle */ - if (evsel__intval(evsel, sample, "next_pid") =3D=3D 0) + if (perf_sample__intval(sample, "next_pid") =3D=3D 0) save_idle_callchain(sched, itr, sample); } } @@ -2572,7 +2571,7 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, if (tr && tr->prio !=3D -1) prio =3D tr->prio; else if (evsel__name_is(evsel, "sched:sched_switch")) - prio =3D evsel__intval(evsel, sample, "prev_prio"); + prio =3D perf_sample__intval(sample, "prev_prio"); =20 if (prio !=3D -1 && !test_bit(prio, sched->prio_bitmap)) { rc =3D true; @@ -2583,8 +2582,8 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, if (sched->idle_hist) { if (!evsel__name_is(evsel, "sched:sched_switch")) rc =3D true; - else if (evsel__intval(evsel, sample, "prev_pid") !=3D 0 && - evsel__intval(evsel, sample, "next_pid") !=3D 0) + else if (perf_sample__intval(sample, "prev_pid") !=3D 0 && + perf_sample__intval(sample, "next_pid") !=3D 0) rc =3D true; } =20 @@ -2647,7 +2646,7 @@ static int timehist_sched_wakeup_event(const struct p= erf_tool *tool, struct thread *thread; struct thread_runtime *tr =3D NULL; /* want pid of awakened task not pid in sample */ - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); =20 thread =3D machine__findnew_thread(machine, 0, pid); if (thread =3D=3D NULL) @@ -2686,8 +2685,8 @@ static void timehist_print_migration_event(struct per= f_sched *sched, return; =20 max_cpus =3D sched->max_cpu.cpu + 1; - ocpu =3D evsel__intval(evsel, sample, "orig_cpu"); - dcpu =3D evsel__intval(evsel, sample, "dest_cpu"); + ocpu =3D perf_sample__intval(sample, "orig_cpu"); + dcpu =3D perf_sample__intval(sample, "dest_cpu"); =20 thread =3D machine__findnew_thread(machine, sample->pid, sample->tid); if (thread =3D=3D NULL) @@ -2736,7 +2735,7 @@ static int timehist_migrate_task_event(const struct p= erf_tool *tool, struct thread *thread; struct thread_runtime *tr =3D NULL; /* want pid of migrated task not pid in sample */ - const u32 pid =3D evsel__intval(evsel, sample, "pid"); + const u32 pid =3D perf_sample__intval(sample, "pid"); =20 thread =3D machine__findnew_thread(machine, 0, pid); if (thread =3D=3D NULL) @@ -2761,14 +2760,13 @@ static int timehist_migrate_task_event(const struct= perf_tool *tool, return 0; } =20 -static void timehist_update_task_prio(struct evsel *evsel, - struct perf_sample *sample, +static void timehist_update_task_prio(struct perf_sample *sample, struct machine *machine) { struct thread *thread; struct thread_runtime *tr =3D NULL; - const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); - const u32 next_prio =3D evsel__intval(evsel, sample, "next_prio"); + const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); + const u32 next_prio =3D perf_sample__intval(sample, "next_prio"); =20 if (next_pid =3D=3D 0) thread =3D get_idle_thread(sample->cpu); @@ -2798,7 +2796,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, struct thread_runtime *tr =3D NULL; u64 tprev, t =3D sample->time; int rc =3D 0; - const char state =3D evsel__taskstate(evsel, sample, "prev_state"); + const char state =3D perf_sample__taskstate(sample, "prev_state"); =20 addr_location__init(&al); if (machine__resolve(machine, &al, sample) < 0) { @@ -2809,7 +2807,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, } =20 if (sched->show_prio || sched->prio_str) - timehist_update_task_prio(evsel, sample, machine); + timehist_update_task_prio(sample, machine); =20 thread =3D timehist_get_thread(sched, sample, machine, evsel); if (thread =3D=3D NULL) { @@ -2891,7 +2889,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, } =20 if (!sched->summary_only) - timehist_print_sample(sched, evsel, sample, &al, thread, t, state); + timehist_print_sample(sched, sample, &al, thread, t, state); } =20 out: diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 8692d11ccd29..034e0ba3f9cb 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -597,12 +597,12 @@ static int process_sample_event(const struct perf_too= l *tool, =20 static int process_sample_cpu_idle(struct timechart *tchart __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u32 state =3D evsel__intval(evsel, sample, "state"); - u32 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); + u32 state =3D perf_sample__intval(sample, "state"); + u32 cpu_id =3D perf_sample__intval(sample, "cpu_id"); =20 if (state =3D=3D (u32)PWR_EVENT_EXIT) c_state_end(tchart, cpu_id, sample->time); @@ -613,12 +613,12 @@ process_sample_cpu_idle(struct timechart *tchart __ma= ybe_unused, =20 static int process_sample_cpu_frequency(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u32 state =3D evsel__intval(evsel, sample, "state"); - u32 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); + u32 state =3D perf_sample__intval(sample, "state"); + u32 cpu_id =3D perf_sample__intval(sample, "cpu_id"); =20 p_state_change(tchart, cpu_id, sample->time, state); return 0; @@ -626,13 +626,13 @@ process_sample_cpu_frequency(struct timechart *tchart, =20 static int process_sample_sched_wakeup(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { - u8 flags =3D evsel__intval(evsel, sample, "common_flags"); - int waker =3D evsel__intval(evsel, sample, "common_pid"); - int wakee =3D evsel__intval(evsel, sample, "pid"); + u8 flags =3D perf_sample__intval(sample, "common_flags"); + int waker =3D perf_sample__intval(sample, "common_pid"); + int wakee =3D perf_sample__intval(sample, "pid"); =20 sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, back= trace); return 0; @@ -640,13 +640,13 @@ process_sample_sched_wakeup(struct timechart *tchart, =20 static int process_sample_sched_switch(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { - int prev_pid =3D evsel__intval(evsel, sample, "prev_pid"); - int next_pid =3D evsel__intval(evsel, sample, "next_pid"); - u64 prev_state =3D evsel__intval(evsel, sample, "prev_state"); + int prev_pid =3D perf_sample__intval(sample, "prev_pid"); + int next_pid =3D perf_sample__intval(sample, "next_pid"); + u64 prev_state =3D perf_sample__intval(sample, "prev_state"); =20 sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid, prev_state, backtrace); @@ -656,12 +656,12 @@ process_sample_sched_switch(struct timechart *tchart, #ifdef SUPPORT_OLD_POWER_EVENTS static int process_sample_power_start(struct timechart *tchart __maybe_unused, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u64 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); - u64 value =3D evsel__intval(evsel, sample, "value"); + u64 cpu_id =3D perf_sample__intval(sample, "cpu_id"); + u64 value =3D perf_sample__intval(sample, "value"); =20 c_state_start(cpu_id, sample->time, value); return 0; @@ -679,12 +679,12 @@ process_sample_power_end(struct timechart *tchart, =20 static int process_sample_power_frequency(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { - u64 cpu_id =3D evsel__intval(evsel, sample, "cpu_id"); - u64 value =3D evsel__intval(evsel, sample, "value"); + u64 cpu_id =3D perf_sample__intval(sample, "cpu_id"); + u64 value =3D perf_sample__intval(sample, "value"); =20 p_state_change(tchart, cpu_id, sample->time, value); return 0; @@ -849,120 +849,120 @@ static int pid_end_io_sample(struct timechart *tcha= rt, int pid, int type, =20 static int process_enter_read(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_READ, sample->time, fd); } =20 static int process_exit_read(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_READ, sample->time, ret); } =20 static int process_enter_write(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_WRITE, sample->time, fd); } =20 static int process_exit_write(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_WRITE, sample->time, ret); } =20 static int process_enter_sync(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_SYNC, sample->time, fd); } =20 static int process_exit_sync(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_SYNC, sample->time, ret); } =20 static int process_enter_tx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_TX, sample->time, fd); } =20 static int process_exit_tx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_TX, sample->time, ret); } =20 static int process_enter_rx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_RX, sample->time, fd); } =20 static int process_exit_rx(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_RX, sample->time, ret); } =20 static int process_enter_poll(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long fd =3D evsel__intval(evsel, sample, "fd"); + long fd =3D perf_sample__intval(sample, "fd"); return pid_begin_io_sample(tchart, sample->tid, IOTYPE_POLL, sample->time, fd); } =20 static int process_exit_poll(struct timechart *tchart, - struct evsel *evsel, + struct evsel *evsel __maybe_unused, struct perf_sample *sample) { - long ret =3D evsel__intval(evsel, sample, "ret"); + long ret =3D perf_sample__intval(sample, "ret"); return pid_end_io_sample(tchart, sample->tid, IOTYPE_POLL, sample->time, ret); } diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e86a3d375757..493eecf218b4 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3059,7 +3059,7 @@ errno_print: { return err; } =20 -static int trace__vfs_getname(struct trace *trace, struct evsel *evsel, +static int trace__vfs_getname(struct trace *trace, struct evsel *evsel __m= aybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3068,7 +3068,7 @@ static int trace__vfs_getname(struct trace *trace, st= ruct evsel *evsel, size_t filename_len, entry_str_len, to_move; ssize_t remaining_space; char *pos; - const char *filename =3D evsel__rawptr(evsel, sample, "pathname"); + const char *filename =3D perf_sample__rawptr(sample, "pathname"); =20 if (!thread) goto out; @@ -3124,7 +3124,7 @@ static int trace__sched_stat_runtime(struct trace *tr= ace, struct evsel *evsel, union perf_event *event __maybe_unused, struct perf_sample *sample) { - u64 runtime =3D evsel__intval(evsel, sample, "runtime"); + u64 runtime =3D perf_sample__intval(sample, "runtime"); double runtime_ms =3D (double)runtime / NSEC_PER_MSEC; struct thread *thread =3D machine__findnew_thread(trace->host, sample->pid, @@ -3143,10 +3143,10 @@ static int trace__sched_stat_runtime(struct trace *= trace, struct evsel *evsel, out_dump: fprintf(trace->output, "%s: comm=3D%s,pid=3D%u,runtime=3D%" PRIu64 ",vrun= time=3D%" PRIu64 ")\n", evsel->name, - evsel__strval(evsel, sample, "comm"), - (pid_t)evsel__intval(evsel, sample, "pid"), + perf_sample__strval(sample, "comm"), + (pid_t)perf_sample__intval(sample, "pid"), runtime, - evsel__intval(evsel, sample, "vruntime")); + perf_sample__intval(sample, "vruntime")); goto out_put; } =20 diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests= /openat-syscall-tp-fields.c index 2a139d2781a8..97550b349418 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c @@ -118,7 +118,7 @@ static int test__syscall_openat_tp_fields(struct test_s= uite *test __maybe_unused goto out_delete_evlist; } =20 - tp_flags =3D evsel__intval(evsel, &sample, "flags"); + tp_flags =3D perf_sample__intval(&sample, "flags"); perf_sample__exit(&sample); if (flags !=3D tp_flags) { pr_debug("%s: Expected flags=3D%#x, got %#x\n", diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.c index 15791fcb76b2..a7ea4b7874be 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -140,8 +140,8 @@ static int process_sample_event(struct evlist *evlist, =20 evsel =3D evlist__id2evsel(evlist, sample.id); if (evsel =3D=3D switch_tracking->switch_evsel) { - next_tid =3D evsel__intval(evsel, &sample, "next_pid"); - prev_tid =3D evsel__intval(evsel, &sample, "prev_pid"); + next_tid =3D perf_sample__intval(&sample, "next_pid"); + prev_tid =3D perf_sample__intval(&sample, "prev_pid"); cpu =3D sample.cpu; pr_debug3("sched_switch: cpu: %d prev_tid %d next_tid %d\n", cpu, prev_tid, next_tid); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a7da54d365a9..041766d39ec3 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3679,9 +3679,9 @@ struct tep_format_field *evsel__common_field(struct e= vsel *evsel, const char *na return tp_format ? tep_find_common_field(tp_format, name) : NULL; } =20 -void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const= char *name) +void *perf_sample__rawptr(struct perf_sample *sample, const char *name) { - struct tep_format_field *field =3D evsel__field(evsel, name); + struct tep_format_field *field =3D evsel__field(sample->evsel, name); int offset; =20 if (!field) @@ -3738,21 +3738,21 @@ u64 format_field__intval(struct tep_format_field *f= ield, struct perf_sample *sam return 0; } =20 -u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const c= har *name) +u64 perf_sample__intval(struct perf_sample *sample, const char *name) { - struct tep_format_field *field =3D evsel__field(evsel, name); + struct tep_format_field *field =3D evsel__field(sample->evsel, name); =20 - return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; + return field ? format_field__intval(field, sample, sample->evsel->needs_s= wap) : 0; } =20 -u64 evsel__intval_common(struct evsel *evsel, struct perf_sample *sample, = const char *name) +u64 perf_sample__intval_common(struct perf_sample *sample, const char *nam= e) { - struct tep_format_field *field =3D evsel__common_field(evsel, name); + struct tep_format_field *field =3D evsel__common_field(sample->evsel, nam= e); =20 - return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; + return field ? format_field__intval(field, sample, sample->evsel->needs_s= wap) : 0; } =20 -char evsel__taskstate(struct evsel *evsel, struct perf_sample *sample, con= st char *name) +char perf_sample__taskstate(struct perf_sample *sample, const char *name) { static struct tep_format_field *prev_state_field; static const char *states; @@ -3761,7 +3761,7 @@ char evsel__taskstate(struct evsel *evsel, struct per= f_sample *sample, const cha unsigned int bit; char state =3D '?'; /* '?' denotes unknown task state */ =20 - field =3D evsel__field(evsel, name); + field =3D evsel__field(sample->evsel, name); =20 if (!field) return state; @@ -3780,7 +3780,7 @@ char evsel__taskstate(struct evsel *evsel, struct per= f_sample *sample, const cha * * We can change this if we have a good reason in the future. */ - val =3D evsel__intval(evsel, sample, name); + val =3D perf_sample__intval(sample, name); bit =3D val ? ffs(val) : 0; state =3D (!bit || bit > strlen(states)) ? 'R' : states[bit-1]; return state; diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index a3d754c029a0..c9d3e6de9677 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -369,14 +369,14 @@ bool evsel__precise_ip_fallback(struct evsel *evsel); struct perf_sample; =20 #ifdef HAVE_LIBTRACEEVENT -void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const= char *name); -u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const c= har *name); -u64 evsel__intval_common(struct evsel *evsel, struct perf_sample *sample, = const char *name); -char evsel__taskstate(struct evsel *evsel, struct perf_sample *sample, con= st char *name); +void *perf_sample__rawptr(struct perf_sample *sample, const char *name); +u64 perf_sample__intval(struct perf_sample *sample, const char *name); +u64 perf_sample__intval_common(struct perf_sample *sample, const char *nam= e); +char perf_sample__taskstate(struct perf_sample *sample, const char *name); =20 -static inline char *evsel__strval(struct evsel *evsel, struct perf_sample = *sample, const char *name) +static inline char *perf_sample__strval(struct perf_sample *sample, const = char *name) { - return evsel__rawptr(evsel, sample, name); + return perf_sample__rawptr(sample, name); } #endif =20 diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index fc9eec8b54b8..dab23a96b1d8 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3426,7 +3426,7 @@ static int intel_pt_process_switch(struct intel_pt *p= t, if (evsel !=3D pt->switch_evsel) return 0; =20 - tid =3D evsel__intval(evsel, sample, "next_pid"); + tid =3D perf_sample__intval(sample, "next_pid"); cpu =3D sample->cpu; =20 intel_pt_log("sched_switch: cpu %d tid %d time %"PRIu64" tsc %#"PRIx64"\n= ", diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-arm64.c index 1e76906f719c..018b0db0e6e7 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c @@ -20,10 +20,8 @@ static const char * const __kvm_events_tp[] =3D { static void event_get_key(struct perf_sample *sample, struct event_key *key) { - struct evsel *evsel =3D sample->evsel; - key->info =3D 0; - key->key =3D evsel__intval(evsel, sample, kvm_exit_reason(EM_AARCH64)); + key->key =3D perf_sample__intval(sample, kvm_exit_reason(EM_AARCH64)); key->exit_reasons =3D arm64_exit_reasons; =20 /* @@ -32,7 +30,7 @@ static void event_get_key(struct perf_sample *sample, * properly decode event's est_ec. */ if (key->key =3D=3D ARM_EXCEPTION_TRAP) { - key->key =3D evsel__intval(evsel, sample, kvm_trap_exit_reason); + key->key =3D perf_sample__intval(sample, kvm_trap_exit_reason); key->exit_reasons =3D arm64_trap_exit_reasons; } } diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c b/tools/per= f/util/kvm-stat-arch/kvm-stat-loongarch.c index 9d6265290f6d..a04cd09e3361 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c @@ -78,7 +78,7 @@ static void event_gspr_get_key(struct perf_sample *sample= , struct event_key *key unsigned int insn; =20 key->key =3D LOONGARCH_EXCEPTION_OTHERS; - insn =3D evsel__intval(sample->evsel, sample, "inst_word"); + insn =3D perf_sample__intval(sample, "inst_word"); =20 switch (insn >> 24) { case 0: diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c b/tools/perf/= util/kvm-stat-arch/kvm-stat-powerpc.c index 5158d7e88ee6..96d9c4ae0209 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c @@ -32,7 +32,7 @@ static void hcall_event_get_key(struct perf_sample *sampl= e, struct event_key *key) { key->info =3D 0; - key->key =3D evsel__intval(sample->evsel, sample, "req"); + key->key =3D perf_sample__intval(sample, "req"); } =20 static const char *get_hcall_exit_reason(u64 exit_code) diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c b/tools/perf/ut= il/kvm-stat-arch/kvm-stat-riscv.c index e8db8b4f8e2e..967bba261a47 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c @@ -26,8 +26,7 @@ static void event_get_key(struct perf_sample *sample, int xlen =3D 64; // TODO: 32-bit support. =20 key->info =3D 0; - key->key =3D evsel__intval(sample->evsel, sample, - kvm_exit_reason(EM_RISCV)) & ~CAUSE_IRQ_FLAG(xlen); + key->key =3D perf_sample__intval(sample, kvm_exit_reason(EM_RISCV)) & ~CA= USE_IRQ_FLAG(xlen); key->exit_reasons =3D riscv_exit_reasons; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c b/tools/perf/uti= l/kvm-stat-arch/kvm-stat-s390.c index 158372ba0205..4771fc69fa39 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-s390.c @@ -23,7 +23,7 @@ static void event_icpt_insn_get_key(struct perf_sample *s= ample, { u64 insn; =20 - insn =3D evsel__intval(sample->evsel, sample, "instruction"); + insn =3D perf_sample__intval(sample, "instruction"); key->key =3D icpt_insn_decoder(insn); key->exit_reasons =3D sie_icpt_insn_codes; } @@ -31,21 +31,21 @@ static void event_icpt_insn_get_key(struct perf_sample = *sample, static void event_sigp_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "order_code"); + key->key =3D perf_sample__intval(sample, "order_code"); key->exit_reasons =3D sie_sigp_order_codes; } =20 static void event_diag_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "code"); + key->key =3D perf_sample__intval(sample, "code"); key->exit_reasons =3D sie_diagnose_codes; } =20 static void event_icpt_prog_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "code"); + key->key =3D perf_sample__intval(sample, "code"); key->exit_reasons =3D sie_icpt_prog_codes; } =20 diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util= /kvm-stat-arch/kvm-stat-x86.c index 0ce543d82850..788d216f0852 100644 --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c @@ -27,8 +27,8 @@ static const struct kvm_events_ops exit_events =3D { static void mmio_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "gpa"); - key->info =3D evsel__intval(sample->evsel, sample, "type"); + key->key =3D perf_sample__intval(sample, "gpa"); + key->info =3D perf_sample__intval(sample, "type"); } =20 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 @@ -43,7 +43,7 @@ static bool mmio_event_begin(struct perf_sample *sample, = struct event_key *key) =20 /* MMIO write begin event in kernel. */ if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && - evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_WR= ITE) { + perf_sample__intval(sample, "type") =3D=3D KVM_TRACE_MMIO_WRITE) { mmio_event_get_key(sample, key); return true; } @@ -59,7 +59,7 @@ static bool mmio_event_end(struct perf_sample *sample, st= ruct event_key *key) =20 /* MMIO read end event in kernel.*/ if (evsel__name_is(sample->evsel, "kvm:kvm_mmio") && - evsel__intval(sample->evsel, sample, "type") =3D=3D KVM_TRACE_MMIO_RE= AD) { + perf_sample__intval(sample, "type") =3D=3D KVM_TRACE_MMIO_READ) { mmio_event_get_key(sample, key); return true; } @@ -87,8 +87,8 @@ static const struct kvm_events_ops mmio_events =3D { static void ioport_event_get_key(struct perf_sample *sample, struct event_key *key) { - key->key =3D evsel__intval(sample->evsel, sample, "port"); - key->info =3D evsel__intval(sample->evsel, sample, "rw"); + key->key =3D perf_sample__intval(sample, "port"); + key->info =3D perf_sample__intval(sample, "rw"); } =20 static bool ioport_event_begin(struct perf_sample *sample, @@ -126,8 +126,8 @@ static const struct kvm_events_ops ioport_events =3D { /* The time of emulation msr is from kvm_msr to kvm_entry. */ static void msr_event_get_key(struct perf_sample *sample, struct event_key= *key) { - key->key =3D evsel__intval(sample->evsel, sample, "ecx"); - key->info =3D evsel__intval(sample->evsel, sample, "write"); + key->key =3D perf_sample__intval(sample, "ecx"); + key->info =3D perf_sample__intval(sample, "write"); } =20 static bool msr_event_begin(struct perf_sample *sample, struct event_key *= key) diff --git a/tools/perf/util/kvm-stat.c b/tools/perf/util/kvm-stat.c index f17a6132958d..755ab659a05c 100644 --- a/tools/perf/util/kvm-stat.c +++ b/tools/perf/util/kvm-stat.c @@ -17,7 +17,7 @@ void exit_event_get_key(struct perf_sample *sample, uint16_t e_machine =3D evsel__e_machine(sample->evsel, /*e_flags=3D*/NULL= ); =20 key->info =3D 0; - key->key =3D evsel__intval(sample->evsel, sample, kvm_exit_reason(e_mach= ine)); + key->key =3D perf_sample__intval(sample, kvm_exit_reason(e_machine)); } =20 =20 --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 EAC503FFAAE for ; Thu, 19 Mar 2026 23:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962660; cv=none; b=CyB+cC+v9OdpRbJaQZfkhda9m+imI82x8Xtdm0NtdVv7CO/TpaNpt/NS7V0yX9NPHg/IjeiUJqH6eci2lmg0MfTBBcQY5vukfJCr6m0/Et+mWvbWYtu+wj6HnwMFHvktEPI17eivnSbT0ybdkXuCVF42zI7QPgnig3y4rPZ3chg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962660; c=relaxed/simple; bh=SHgl0S6yaUi+Exc7QlYdhkS+eHNvrRlR5BNXe5kO8sM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=s1OiLWONsCn2egPBObcf2Blr/7XHKx9zXkD/OpMhSHNe/KhUXSPYIPYu3Rq2mJL2dK9ZJBWptl+RavOeOB2pSrNZZdbKziTsegkXhhGGCodldSwEqkXdhHRQzyjTDGD5SJkaByfpY7uqXBul+2YLCDbo8aPAs0u9UhLEa9uWy/o= 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=kWYGyvrU; arc=none smtp.client-ip=74.125.82.74 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="kWYGyvrU" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12711ec96fbso3108375c88.0 for ; Thu, 19 Mar 2026 16:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962656; x=1774567456; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TqE8bLBlKRkSibRkc3EltsCtmi46Ix8f6FKqSyXSzZc=; b=kWYGyvrUuPK7QA8/00LS4nLwVIUtM4gUICmS9ZovRJ/Bc0ocsanxFNU8WSum5shQoA fwie8/e+WNdv2y/xlcxWliCVEu0Y1yachnhSFGYVdWiRrpBTgChFv7fZ+mqE/r65fOTi KR7dNR4EYQ3B1kmk3rTiIsVeIQY83J6d6YoQ3Gl6vrRcN6XCeML67i46ZJ9++GHykPrw 9fsKRk0ihdgW/2ILEWnFV1gkuda4GwXFBiXCGcVVw0dd1ERZXVYY2o5kD0mBie8zmCOa dFCabWOkJais+H44vu3u3j1EQGN1A2v7xACG4t77QIIwE/CMZYbRv3uylIG7lfPchHlP Y9zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962656; x=1774567456; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TqE8bLBlKRkSibRkc3EltsCtmi46Ix8f6FKqSyXSzZc=; b=amj1QWFGeAUT2fU7OPhlz9M02Uqc+M4tYeKjy+aOraxl3J29tIc985r3PJ3Zm4h/5w Ffd0lrmPRR2LBdqAe9stNe0FsUq6ESgrgR7PfqHQQYlc6iFTQ2t6Mqnbz+lQns0FhpjH 2VXhqj3MDqBYn0y3vHy06QtWp+vSTXwA7E6lnvsty4MsQ2homiQtisNFzd8mgIFOkSxv PY7SoE3MG0wgS/vGqwQyv85TVaWxI2NeKYjfG4nA4pVRz45GaMsQLek9oy1no8lBT5xZ CKjmS0WFnr/TIJ9g5R4NSr4hfe9tSDYzfwqhOOcV+FG9uVaKmlUDxYK3PMzKlObSVAWx COzw== X-Forwarded-Encrypted: i=1; AJvYcCWS07A051qQGacic0WGmzJfCt4BFVMU9nNBpoVCsaukAeiMAgVRin/xyxi9JLlekLx8PpT5vMmskzUk3ro=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1CyKlMx6zzEeypTnDuRnOMPHEXcyJPyVgzAOw9RceWYXMg49q wEJuIpuefC/2FJNgRgpujYtWnrKwvVxybyX4tc1UWP7LkX+9+4v991q63+RTG/NjLWEkJiBxrnm 3Nb+1NYFI5A== X-Received: from dlea10-n1.prod.google.com ([2002:a05:701b:420a:10b0:128:cf1e:df72]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:fd0c:b0:128:d4db:4464 with SMTP id a92af1059eb24-12a726ab63amr516667c88.25.1773962655755; Thu, 19 Mar 2026 16:24:15 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:16 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-8-irogers@google.com> Subject: [PATCH v2 07/25] perf trace: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample now contains the evsel and so don't unnecessarily pass the evsel. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 55 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 493eecf218b4..33199ff2bbfd 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -535,12 +535,12 @@ static struct evsel *perf_evsel__raw_syscall_newtp(co= nst char *direction, void * return NULL; } =20 -#define perf_evsel__sc_tp_uint(evsel, name, sample) \ - ({ struct syscall_tp *fields =3D __evsel__syscall_tp(evsel); \ +#define perf_evsel__sc_tp_uint(name, sample) \ + ({ struct syscall_tp *fields =3D __evsel__syscall_tp(sample->evsel); \ fields->name.integer(&fields->name, sample); }) =20 -#define perf_evsel__sc_tp_ptr(evsel, name, sample) \ - ({ struct syscall_tp *fields =3D __evsel__syscall_tp(evsel); \ +#define perf_evsel__sc_tp_ptr(name, sample) \ + ({ struct syscall_tp *fields =3D __evsel__syscall_tp(sample->evsel); \ fields->name.pointer(&fields->name, sample); }) =20 size_t strarray__scnprintf_suffix(struct strarray *sa, char *bf, size_t si= ze, const char *intfmt, bool show_suffix, int val) @@ -2719,8 +2719,8 @@ static int trace__printf_interrupted_entry(struct tra= ce *trace) return printed; } =20 -static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel, - struct perf_sample *sample, struct thread *thread) +static int trace__fprintf_sample(struct trace *trace, struct perf_sample *= sample, + struct thread *thread) { int printed =3D 0; =20 @@ -2728,7 +2728,7 @@ static int trace__fprintf_sample(struct trace *trace,= struct evsel *evsel, double ts =3D (double)sample->time / NSEC_PER_MSEC; =20 printed +=3D fprintf(trace->output, "%22s %10.3f %s %d/%d [%d]\n", - evsel__name(evsel), ts, + evsel__name(sample->evsel), ts, thread__comm_str(thread), sample->pid, sample->tid, sample->cpu); } @@ -2783,7 +2783,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, void *args; int printed =3D 0; struct thread *thread; - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; + int id =3D perf_evsel__sc_tp_uint(id, sample), err =3D -1; int augmented_args_size =3D 0, e_machine; void *augmented_args =3D NULL; struct syscall *sc; @@ -2798,9 +2798,9 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, if (ttrace =3D=3D NULL) goto out_put; =20 - trace__fprintf_sample(trace, evsel, sample, thread); + trace__fprintf_sample(trace, sample, thread); =20 - args =3D perf_evsel__sc_tp_ptr(evsel, args, sample); + args =3D perf_evsel__sc_tp_ptr(args, sample); =20 if (ttrace->entry_str =3D=3D NULL) { ttrace->entry_str =3D malloc(trace__entry_str_size); @@ -2855,12 +2855,11 @@ static int trace__sys_enter(struct trace *trace, st= ruct evsel *evsel, return err; } =20 -static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evs= el, - struct perf_sample *sample) +static int trace__fprintf_sys_enter(struct trace *trace, struct perf_sampl= e *sample) { struct thread_trace *ttrace; struct thread *thread; - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1; + int id =3D perf_evsel__sc_tp_uint(id, sample), err =3D -1; struct syscall *sc; char msg[1024]; void *args, *augmented_args =3D NULL; @@ -2870,7 +2869,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); e_machine =3D thread__e_machine(thread, trace->host, /*e_flags=3D*/NULL); - sc =3D trace__syscall_info(trace, evsel, e_machine, id); + sc =3D trace__syscall_info(trace, sample->evsel, e_machine, id); if (sc =3D=3D NULL) goto out_put; ttrace =3D thread__trace(thread, trace); @@ -2881,7 +2880,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, if (ttrace =3D=3D NULL) goto out_put; =20 - args =3D perf_evsel__sc_tp_ptr(evsel, args, sample); + args =3D perf_evsel__sc_tp_ptr(args, sample); augmented_args =3D syscall__augmented_args(sc, sample, &augmented_args_si= ze, trace->raw_augmented_syscalls_args_size); printed +=3D syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmente= d_args, augmented_args_size, trace, thread); fprintf(trace->output, "%.*s", (int)printed, msg); @@ -2891,10 +2890,11 @@ static int trace__fprintf_sys_enter(struct trace *t= race, struct evsel *evsel, return err; } =20 -static int trace__resolve_callchain(struct trace *trace, struct evsel *evs= el, +static int trace__resolve_callchain(struct trace *trace, struct perf_sample *sample, struct callchain_cursor *cursor) { + struct evsel *evsel =3D sample->evsel; struct addr_location al; int max_stack =3D evsel->core.attr.sample_max_stack ? evsel->core.attr.sample_max_stack : @@ -2929,7 +2929,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, u64 duration =3D 0; bool duration_calculated =3D false; struct thread *thread; - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample), err =3D -1, callcha= in_ret =3D 0, printed =3D 0; + int id =3D perf_evsel__sc_tp_uint(id, sample), err =3D -1, callchain_ret = =3D 0, printed =3D 0; int alignment =3D trace->args_alignment, e_machine; struct syscall *sc; struct thread_trace *ttrace; @@ -2943,9 +2943,9 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, if (ttrace =3D=3D NULL) goto out_put; =20 - trace__fprintf_sample(trace, evsel, sample, thread); + trace__fprintf_sample(trace, sample, thread); =20 - ret =3D perf_evsel__sc_tp_uint(evsel, ret, sample); + ret =3D perf_evsel__sc_tp_uint(ret, sample); =20 if (trace->summary) thread__update_stats(thread, ttrace, id, sample, ret, trace); @@ -2967,7 +2967,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, if (sample->callchain) { struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); =20 - callchain_ret =3D trace__resolve_callchain(trace, evsel, sample, cursor); + callchain_ret =3D trace__resolve_callchain(trace, sample, cursor); if (callchain_ret =3D=3D 0) { if (cursor->nr < trace->min_stack) goto out; @@ -3182,9 +3182,10 @@ static void bpf_output__fprintf(struct trace *trace, ++trace->nr_events_printed; } =20 -static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *= evsel, struct perf_sample *sample, +static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sa= mple *sample, struct thread *thread, void *augmented_args, int augmented_args= _size) { + struct evsel *evsel =3D sample->evsel; char bf[2048]; size_t size =3D sizeof(bf); const struct tep_event *tp_format =3D evsel__tp_format(evsel); @@ -3267,7 +3268,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, if (sample->callchain) { struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); =20 - callchain_ret =3D trace__resolve_callchain(trace, evsel, sample, cursor); + callchain_ret =3D trace__resolve_callchain(trace, sample, cursor); if (callchain_ret =3D=3D 0) { if (cursor->nr < trace->min_stack) goto out; @@ -3285,7 +3286,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, trace__fprintf_comm_tid(trace, thread, trace->output); =20 if (evsel =3D=3D trace->syscalls.events.bpf_output) { - int id =3D perf_evsel__sc_tp_uint(evsel, id, sample); + int id =3D perf_evsel__sc_tp_uint(id, sample); int e_machine =3D thread ? thread__e_machine(thread, trace->host, /*e_flags=3D*/NULL) : EM_HOST; @@ -3293,7 +3294,7 @@ static int trace__event_handler(struct trace *trace, = struct evsel *evsel, =20 if (sc) { fprintf(trace->output, "%s(", sc->name); - trace__fprintf_sys_enter(trace, evsel, sample); + trace__fprintf_sys_enter(trace, sample); fputc(')', trace->output); goto newline; } @@ -3313,13 +3314,13 @@ static int trace__event_handler(struct trace *trace= , struct evsel *evsel, const struct tep_event *tp_format =3D evsel__tp_format(evsel); =20 if (tp_format && (strncmp(tp_format->name, "sys_enter_", 10) || - trace__fprintf_sys_enter(trace, evsel, sample))) { + trace__fprintf_sys_enter(trace, sample))) { if (trace->libtraceevent_print) { event_format__fprintf(tp_format, sample->cpu, sample->raw_data, sample->raw_size, trace->output); } else { - trace__fprintf_tp_fields(trace, evsel, sample, thread, NULL, 0); + trace__fprintf_tp_fields(trace, sample, thread, NULL, 0); } } } @@ -3378,7 +3379,7 @@ static int trace__pgfault(struct trace *trace, if (sample->callchain) { struct callchain_cursor *cursor =3D get_tls_callchain_cursor(); =20 - callchain_ret =3D trace__resolve_callchain(trace, evsel, sample, cursor); + callchain_ret =3D trace__resolve_callchain(trace, sample, cursor); if (callchain_ret =3D=3D 0) { if (cursor->nr < trace->min_stack) goto out_put; --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 062A240756B for ; Thu, 19 Mar 2026 23:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962661; cv=none; b=tOaVAoVGEn6ZrGcZPv0sgiWe4W+kL+bwL/6PQtnpbqpPtZMr7JJe0HSxCYJlplvpxOXFbVqn7KvK7dLLouPY+5j/9EPPeh32aXwAp5qaZEsUTEosYDTaiuJmxSE+zz9+Px3lZjhQCMhKZ7x+7fMx/TIRsMIo7drsufYvhny9fM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962661; c=relaxed/simple; bh=9QXsI24Yp5FQf5jDlMLj0UtNXbwJolqDUq5R13HFzUQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=sbI7mXFcP+V39LmGG6qbkO18O6lq1x615mv+gp1RHGubyhOZnUaRPqRU4gtQjDwD3ckFtNNCAtW13LVdMI5KrBuAK+RGbblz95nvXg6+lXNtLoWPdhzQMfzjr6COp2mmTODGyiY7HVoDhlKI4zj7HD3VP9Hi6PcThE0KbqvPMEc= 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=cjIG6UBQ; arc=none smtp.client-ip=209.85.216.73 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="cjIG6UBQ" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3594620fe97so8867586a91.1 for ; Thu, 19 Mar 2026 16:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962658; x=1774567458; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uzIu8mm1/8onj9ERb+52EHzK9xyVu3/KusreNB3wQu8=; b=cjIG6UBQRTqf/Mr/R/4kDy1i0zins0yOsfwx99T1vQedjXEl6p76/BMGgYsgK5tC2S 4uXfdFI5Zka50FV/vGn7O6xhSbONdyZaKOxV7bUhT3OMVz6SdzjX3mZi4wXosC+mCSpc BuAqvv2s/0s9Q2O+Q0jQA+me37YodCv0BpEYcmOiVuqjzgJWCySj9qpyJo2XOKmyLS8e eBJYY6nWApkgMZffkcEjMDqtU6ZiyuxB+fhEPcbwYSG1D15ZNrIHrEY5+i5YKIi7x2jr pmNkyFGVxGCaNhfgXN1vp0bgPJYs0Wc8gORTEqz3jtea/ZIPHAdG+C27IjND6Vs3l0C8 tBLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962658; x=1774567458; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uzIu8mm1/8onj9ERb+52EHzK9xyVu3/KusreNB3wQu8=; b=BvXzJUIwhHhXC0yItEtjGofzgJBrLN1LHAhwsvN1hrrFHFJK6BT+0fkbXyCe9vW8C9 Jsxhis81R30LUpQHjfXanrO6cPvyc/D5u+dvfI7R0CLe8Y0RolVNuutPHCg3k1gvHWql mDLdzHarNcNerbAOSsSm/AoyXI+kHTEc/JnqLc3gAjXLuAGm8s6OwpMWBnuu36Tjl7KR MTGFO+IiYcmkMaiiaIbEbipPrsHaSo3RZO4uCzlZ3wydbsIBUA9fKs82COFXCYzGgIrT m5uCOItfjzrPyOJDolJ3Q020jyNCTfdrLGCD8lqb4RyFQKUEa1m/l5d5lBKQkjtCiaGK TFHA== X-Forwarded-Encrypted: i=1; AJvYcCVr11N5+x6TssKRzbb6FX/au7yTloVEItykMVAUf1ha7A2xJ2hURzeWml9QDg7s+jBolHaBrDQmzPyA3SA=@vger.kernel.org X-Gm-Message-State: AOJu0YwsDA5SFhPIkm+yOQj1r5eaSb3dCZb4e2vqvTIpH3xyd8nkplrE 2YRBBX1NAdU4RPXOuB7X8yfgvzeTOIiyaOpY4Ugcn44adEI4MwGVfjenvnhGGy3Dzxx/xTDuXwA T30SSWsj6Hw== X-Received: from pjro10.prod.google.com ([2002:a17:90a:b88a:b0:359:8cdb:17bd]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3908:b0:359:8411:a40 with SMTP id 98e67ed59e1d1-35bd29a00f1mr755687a91.0.1773962658200; Thu, 19 Mar 2026 16:24:18 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:17 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-9-irogers@google.com> Subject: [PATCH v2 08/25] perf callchain: Don't pass evsel and sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Change callchain resolve code to not pass an evsel with the sample, instead just read the evsel from the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-inject.c | 4 ++-- tools/perf/builtin-kmem.c | 6 ++--- tools/perf/builtin-kwork.c | 5 ++-- tools/perf/builtin-lock.c | 24 +++++++++---------- tools/perf/builtin-sched.c | 5 ++-- tools/perf/builtin-script.c | 6 ++--- tools/perf/builtin-trace.c | 2 +- tools/perf/util/build-id.c | 2 +- tools/perf/util/callchain.c | 8 +++---- tools/perf/util/callchain.h | 5 ++-- tools/perf/util/db-export.c | 8 +++---- tools/perf/util/hist.c | 2 +- tools/perf/util/machine.c | 14 +++++------ tools/perf/util/machine.h | 3 --- .../util/scripting-engines/trace-event-perl.c | 2 +- .../scripting-engines/trace-event-python.c | 2 +- 17 files changed, 46 insertions(+), 54 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 89456ba6fcbb..f9ac871264af 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -339,7 +339,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, =20 cursor =3D get_tls_callchain_cursor(); ret =3D sample__resolve_callchain(sample, cursor, NULL, - evsel, &al, sysctl_perf_event_max_stack); + &al, sysctl_perf_event_max_stack); if (ret) goto out; =20 diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 483c8cac14fd..bc6d94806080 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -418,7 +418,7 @@ static int perf_event__convert_sample_callchain(const s= truct perf_tool *tool, goto out; =20 /* this will parse DWARF using stack and register data */ - ret =3D thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D thread__resolve_callchain(thread, cursor, sample, /*parent=3D*/NULL, /*root_al=3D*/NULL, PERF_MAX_STACK_DEPTH); thread__put(thread); @@ -1020,7 +1020,7 @@ static int perf_event__inject_buildid(const struct pe= rf_tool *tool, union perf_e } =20 sample->evsel =3D inject__mmap_evsel(inject); - sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, + sample__for_each_callchain_node(thread, sample, PERF_MAX_STACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, &args); sample->evsel =3D saved_evsel; thread__put(thread); diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 96b78a64c1c1..19b12209fc08 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -394,7 +394,7 @@ static int build_alloc_func_list(void) * Find first non-memory allocation function from callchain. * The allocation functions are in the 'alloc_func_list'. */ -static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) +static u64 find_callsite(struct perf_sample *sample) { struct addr_location al; struct machine *machine =3D &kmem_session->machines.host; @@ -414,7 +414,7 @@ static u64 find_callsite(struct evsel *evsel, struct pe= rf_sample *sample) if (cursor =3D=3D NULL) goto out; =20 - sample__resolve_callchain(sample, cursor, NULL, evsel, &al, 16); + sample__resolve_callchain(sample, cursor, /*parent=3D*/NULL, &al, 16); =20 callchain_cursor_commit(cursor); while (true) { @@ -839,7 +839,7 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp if (parse_gfp_flags(evsel, sample, gfp_flags) < 0) return -1; =20 - callsite =3D find_callsite(evsel, sample); + callsite =3D find_callsite(sample); =20 /* * This is to find the current page (with correct gfp flags and diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 111ae53025d1..043da61cdcef 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -688,7 +688,6 @@ static int latency_entry_event(struct perf_kwork *kwork, =20 static void timehist_save_callchain(struct perf_kwork *kwork, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct symbol *sym; @@ -708,7 +707,7 @@ static void timehist_save_callchain(struct perf_kwork *= kwork, =20 cursor =3D get_tls_callchain_cursor(); =20 - if (thread__resolve_callchain(thread, cursor, evsel, sample, + if (thread__resolve_callchain(thread, cursor, sample, NULL, NULL, kwork->max_stack + 2) !=3D 0) { pr_debug("Failed to resolve callchain, skipping\n"); goto out_put; @@ -838,7 +837,7 @@ static int timehist_entry_event(struct perf_kwork *kwor= k, return ret; =20 if (work !=3D NULL) - timehist_save_callchain(kwork, sample, evsel, machine); + timehist_save_callchain(kwork, sample, machine); =20 return 0; } diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index baf0c99df5df..a35e8ea4e2ef 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -551,13 +551,13 @@ static int get_key_by_aggr_mode_simple(u64 *key, u64 = addr, u32 tid) return 0; } =20 -static u64 callchain_id(struct evsel *evsel, struct perf_sample *sample); +static u64 callchain_id(struct perf_sample *sample); =20 -static int get_key_by_aggr_mode(u64 *key, u64 addr, struct evsel *evsel, +static int get_key_by_aggr_mode(u64 *key, u64 addr, struct perf_sample *sample) { if (aggr_mode =3D=3D LOCK_AGGR_CALLER) { - *key =3D callchain_id(evsel, sample); + *key =3D callchain_id(sample); return 0; } return get_key_by_aggr_mode_simple(key, addr, sample->tid); @@ -841,7 +841,7 @@ static int get_symbol_name_offset(struct map *map, stru= ct symbol *sym, u64 ip, else return strlcpy(buf, sym->name, size); } -static int lock_contention_caller(struct evsel *evsel, struct perf_sample = *sample, +static int lock_contention_caller(struct perf_sample *sample, char *buf, int size) { struct thread *thread; @@ -862,7 +862,7 @@ static int lock_contention_caller(struct evsel *evsel, = struct perf_sample *sampl cursor =3D get_tls_callchain_cursor(); =20 /* use caller function name from the callchain */ - ret =3D thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D thread__resolve_callchain(thread, cursor, sample, NULL, NULL, max_stack_depth); if (ret !=3D 0) { thread__put(thread); @@ -896,7 +896,7 @@ static int lock_contention_caller(struct evsel *evsel, = struct perf_sample *sampl return -1; } =20 -static u64 callchain_id(struct evsel *evsel, struct perf_sample *sample) +static u64 callchain_id(struct perf_sample *sample) { struct callchain_cursor *cursor; struct machine *machine =3D &session->machines.host; @@ -911,7 +911,7 @@ static u64 callchain_id(struct evsel *evsel, struct per= f_sample *sample) =20 cursor =3D get_tls_callchain_cursor(); /* use caller function name from the callchain */ - ret =3D thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D thread__resolve_callchain(thread, cursor, sample, NULL, NULL, max_stack_depth); thread__put(thread); =20 @@ -963,7 +963,7 @@ static u64 *get_callstack(struct perf_sample *sample, i= nt max_stack) return callstack; } =20 -static int report_lock_contention_begin_event(struct evsel *evsel, +static int report_lock_contention_begin_event(struct evsel *evsel __maybe_= unused, struct perf_sample *sample) { struct lock_stat *ls; @@ -978,7 +978,7 @@ static int report_lock_contention_begin_event(struct ev= sel *evsel, struct map *kmap; struct symbol *sym; =20 - ret =3D get_key_by_aggr_mode(&key, addr, evsel, sample); + ret =3D get_key_by_aggr_mode(&key, addr, sample); if (ret < 0) return ret; =20 @@ -1025,7 +1025,7 @@ static int report_lock_contention_begin_event(struct = evsel *evsel, break; case LOCK_AGGR_CALLER: name =3D buf; - if (lock_contention_caller(evsel, sample, buf, sizeof(buf)) < 0) + if (lock_contention_caller(sample, buf, sizeof(buf)) < 0) name =3D "Unknown"; break; case LOCK_AGGR_CGROUP: @@ -1127,7 +1127,7 @@ static int report_lock_contention_begin_event(struct = evsel *evsel, return 0; } =20 -static int report_lock_contention_end_event(struct evsel *evsel, +static int report_lock_contention_end_event(struct evsel *evsel __maybe_un= used, struct perf_sample *sample) { struct lock_stat *ls; @@ -1138,7 +1138,7 @@ static int report_lock_contention_end_event(struct ev= sel *evsel, u64 key; int ret; =20 - ret =3D get_key_by_aggr_mode(&key, addr, evsel, sample); + ret =3D get_key_by_aggr_mode(&key, addr, sample); if (ret < 0) return ret; =20 diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index c7a7e0208a16..854e29bbd6a9 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -2325,7 +2325,6 @@ static bool is_idle_sample(struct perf_sample *sample, =20 static void save_task_callchain(struct perf_sched *sched, struct perf_sample *sample, - struct evsel *evsel, struct machine *machine) { struct callchain_cursor *cursor; @@ -2345,7 +2344,7 @@ static void save_task_callchain(struct perf_sched *sc= hed, =20 cursor =3D get_tls_callchain_cursor(); =20 - if (thread__resolve_callchain(thread, cursor, evsel, sample, + if (thread__resolve_callchain(thread, cursor, sample, NULL, NULL, sched->max_stack + 2) !=3D 0) { if (verbose > 0) pr_err("Failed to resolve callchain. Skipping\n"); @@ -2519,7 +2518,7 @@ static struct thread *timehist_get_thread(struct perf= _sched *sched, sample->tid); } =20 - save_task_callchain(sched, sample, evsel, machine); + save_task_callchain(sched, sample, machine); if (sched->idle_hist) { struct thread *idle; struct idle_thread_runtime *itr; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8724c4ab3e88..8022801721e2 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1683,7 +1683,7 @@ static int perf_sample__fprintf_bts(struct perf_sampl= e *sample, =20 if (symbol_conf.use_callchain && sample->callchain) { cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack)) cursor =3D NULL; @@ -2506,7 +2506,7 @@ static void process_event(struct perf_script *script, =20 if (symbol_conf.use_callchain && sample->callchain) { cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack)) cursor =3D NULL; @@ -2790,7 +2790,7 @@ static int process_deferred_sample_event(const struct= perf_tool *tool, =20 if (symbol_conf.use_callchain && sample->callchain) { cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al.thread, cursor, evsel, + if (thread__resolve_callchain(al.thread, cursor, sample, NULL, NULL, scripting_max_stack)) { pr_info("cannot resolve deferred callchains\n"); diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 33199ff2bbfd..385a9ac2ae96 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2905,7 +2905,7 @@ static int trace__resolve_callchain(struct trace *tra= ce, if (machine__resolve(trace->host, &al, sample) < 0) goto out; =20 - err =3D thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL,= NULL, max_stack); + err =3D thread__resolve_callchain(al.thread, cursor, sample, NULL, NULL, = max_stack); out: addr_location__exit(&al); return err; diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 55b72235f891..af4d874f1381 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -73,7 +73,7 @@ int build_id__mark_dso_hit(const struct perf_tool *tool _= _maybe_unused, =20 addr_location__exit(&al); =20 - sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_S= TACK_DEPTH, + sample__for_each_callchain_node(thread, sample, PERF_MAX_STACK_DEPTH, /*symbols=3D*/false, mark_dso_hit_callback, /*data=3D*/NULL); =20 =20 diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 8ff0898799ee..4f485ed046a4 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -1123,7 +1123,7 @@ int callchain_cursor_append(struct callchain_cursor *= cursor, =20 int sample__resolve_callchain(struct perf_sample *sample, struct callchain_cursor *cursor, struct symbol **parent, - struct evsel *evsel, struct addr_location *al, + struct addr_location *al, int max_stack) { if (sample->callchain =3D=3D NULL && !symbol_conf.show_branchflag_count) @@ -1131,7 +1131,7 @@ int sample__resolve_callchain(struct perf_sample *sam= ple, =20 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain || perf_hpp_list.parent || symbol_conf.show_branchflag_count) { - return thread__resolve_callchain(al->thread, cursor, evsel, sample, + return thread__resolve_callchain(al->thread, cursor, sample, parent, al, max_stack); } return 0; @@ -1806,7 +1806,7 @@ s64 callchain_avg_cycles(struct callchain_node *cnode) return cycles; } =20 -int sample__for_each_callchain_node(struct thread *thread, struct evsel *e= vsel, +int sample__for_each_callchain_node(struct thread *thread, struct perf_sample *sample, int max_stack, bool symbols, callchain_iter_fn cb, void *data) { @@ -1817,7 +1817,7 @@ int sample__for_each_callchain_node(struct thread *th= read, struct evsel *evsel, return -ENOMEM; =20 /* Fill in the callchain. */ - ret =3D __thread__resolve_callchain(thread, cursor, evsel, sample, + ret =3D __thread__resolve_callchain(thread, cursor, sample, /*parent=3D*/NULL, /*root_al=3D*/NULL, max_stack, symbols); if (ret) diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index df54ddb8c0cb..6eb3e20349a9 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -8,7 +8,6 @@ #include "branch.h" =20 struct addr_location; -struct evsel; struct ip_callchain; struct map; struct perf_sample; @@ -251,7 +250,7 @@ int record_opts__parse_callchain(struct record_opts *re= cord, =20 int sample__resolve_callchain(struct perf_sample *sample, struct callchain_cursor *cursor, struct symbol **parent, - struct evsel *evsel, struct addr_location *al, + struct addr_location *al, int max_stack); int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample= *sample); int fill_callchain_info(struct addr_location *al, struct callchain_cursor_= node *node, @@ -314,7 +313,7 @@ s64 callchain_avg_cycles(struct callchain_node *cnode); =20 typedef int (*callchain_iter_fn)(struct callchain_cursor_node *node, void = *data); =20 -int sample__for_each_callchain_node(struct thread *thread, struct evsel *e= vsel, +int sample__for_each_callchain_node(struct thread *thread, struct perf_sample *sample, int max_stack, bool symbols, callchain_iter_fn cb, void *data); =20 diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index ae9a9065aab7..a1f578c3a8d5 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c @@ -209,8 +209,7 @@ static int db_ids_from_al(struct db_export *dbe, struct= addr_location *al, static struct call_path *call_path_from_sample(struct db_export *dbe, struct machine *machine, struct thread *thread, - struct perf_sample *sample, - struct evsel *evsel) + struct perf_sample *sample) { u64 kernel_start =3D machine__kernel_start(machine); struct call_path *current =3D &dbe->cpr->call_path; @@ -228,7 +227,7 @@ static struct call_path *call_path_from_sample(struct d= b_export *dbe, */ callchain_param.order =3D ORDER_CALLER; cursor =3D get_tls_callchain_cursor(); - err =3D thread__resolve_callchain(thread, cursor, evsel, + err =3D thread__resolve_callchain(thread, cursor, sample, NULL, NULL, PERF_MAX_STACK_DEPTH); if (err) { callchain_param.order =3D saved_order; @@ -391,8 +390,7 @@ int db_export__sample(struct db_export *dbe, union perf= _event *event, =20 if (dbe->cpr) { struct call_path *cp =3D call_path_from_sample(dbe, machine, - thread, sample, - evsel); + thread, sample); if (cp) { db_export__call_path(dbe, cp); es.call_path_id =3D cp->db_id; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 7ffaa3d9851b..84a402d248a3 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1339,7 +1339,7 @@ int hist_entry_iter__add(struct hist_entry_iter *iter= , struct addr_location *al, alm =3D map__get(al->map); =20 err =3D sample__resolve_callchain(iter->sample, get_tls_callchain_cursor(= ), &iter->parent, - iter->evsel, al, max_stack_depth); + al, max_stack_depth); if (err) { map__put(alm); return err; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index e76f8c86e62a..c2e0a99efe97 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2778,13 +2778,13 @@ static u64 get_leaf_frame_caller(struct perf_sample= *sample, =20 static int thread__resolve_callchain_sample(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, int max_stack, bool symbols) { + struct evsel *evsel =3D sample->evsel; struct branch_stack *branch =3D sample->branch_stack; struct branch_entry *entries =3D perf_sample__branch_entries(sample); struct ip_callchain *chain =3D sample->callchain; @@ -2986,10 +2986,11 @@ static int unwind_entry(struct unwind_entry *entry,= void *arg) =20 static int thread__resolve_callchain_unwind(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, int max_stack, bool symbols) { + struct evsel *evsel =3D sample->evsel; + /* Can we do dwarf post unwind? */ if (!((evsel->core.attr.sample_type & PERF_SAMPLE_REGS_USER) && (evsel->core.attr.sample_type & PERF_SAMPLE_STACK_USER))) @@ -3009,7 +3010,6 @@ static int thread__resolve_callchain_unwind(struct th= read *thread, =20 int __thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, @@ -3025,22 +3025,22 @@ int __thread__resolve_callchain(struct thread *thre= ad, =20 if (callchain_param.order =3D=3D ORDER_CALLEE) { ret =3D thread__resolve_callchain_sample(thread, cursor, - evsel, sample, + sample, parent, root_al, max_stack, symbols); if (ret) return ret; ret =3D thread__resolve_callchain_unwind(thread, cursor, - evsel, sample, + sample, max_stack, symbols); } else { ret =3D thread__resolve_callchain_unwind(thread, cursor, - evsel, sample, + sample, max_stack, symbols); if (ret) return ret; ret =3D thread__resolve_callchain_sample(thread, cursor, - evsel, sample, + sample, parent, root_al, max_stack, symbols); } diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 22a42c5825fa..048b24e9bd38 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -187,7 +187,6 @@ struct callchain_cursor; =20 int __thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, @@ -196,7 +195,6 @@ int __thread__resolve_callchain(struct thread *thread, =20 static inline int thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, - struct evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, @@ -204,7 +202,6 @@ static inline int thread__resolve_callchain(struct thre= ad *thread, { return __thread__resolve_callchain(thread, cursor, - evsel, sample, parent, root_al, diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/p= erf/util/scripting-engines/trace-event-perl.c index e261a57b87d4..850a0048df82 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -272,7 +272,7 @@ static SV *perl_process_callchain(struct perf_sample *s= ample, =20 cursor =3D get_tls_callchain_cursor(); =20 - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack) !=3D 0) { pr_err("Failed to resolve callchain. Skipping\n"); goto exit; diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 2b0df7bd9a46..0d8665c75d30 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -404,7 +404,7 @@ static PyObject *python_process_callchain(struct perf_s= ample *sample, goto exit; =20 cursor =3D get_tls_callchain_cursor(); - if (thread__resolve_callchain(al->thread, cursor, evsel, + if (thread__resolve_callchain(al->thread, cursor, sample, NULL, NULL, scripting_max_stack) !=3D 0) { pr_err("Failed to resolve callchain. Skipping\n"); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 7F5A240757E for ; Thu, 19 Mar 2026 23:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962663; cv=none; b=n4XtFqAk57WiYewhiwGXbnmxsH8c1+lKRm8eMmH5/hqAqnZ1pi7tt1JKpIK3kOdT04/sBHF+zp3vm409lQZyEi/rcVPiBO5xG0Eo5jzo3RMpPiCU5IzoqwFkVrdirH6qwpym3vookkpnpy0u8h+MjlMKBfND1ypxhQOxT9OVJX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962663; c=relaxed/simple; bh=19yi0++eVPW89pl3buX6d/PyThRne9kD8qxMvttHRQU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GJMoyg4t32gaTRnHvirQUUVoMlPlJkYDtGCxHLiNsPriZZlZorpupsljKIdbQnj9rLfdsV/TqDXRXW7gooWdrLGBDyRRcIj9gu+6XwDPEW0V+lo2H1R6yM1bTgiqZ389TsfS3jUlN4i4erMG5wZnee7OQI1x6dETIQnH0EgZSSA= 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=ANDdIHNf; arc=none smtp.client-ip=74.125.82.73 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="ANDdIHNf" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1276e71652fso70392c88.0 for ; Thu, 19 Mar 2026 16:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962661; x=1774567461; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=X4aFDGz+ocU8pLrA7jQQlv23G1GT6rQZLR8GkVLQCjI=; b=ANDdIHNfYHMhG4hfNqzhVtUVPK88iz/S2pnvZlhp8SOlUQIt0r/1fbndCCj/GCvvZq slVp0vNqOQIyi4vEmLoziDYynrQpCdcOLiBnytKlTD5xLfn4EnaV8tXMK+oqzIuBDIkv uAEjnU5XcxneM1Tn1bjnhPbbZzc3WanexOL1dSaQ0E4UVaQJQjUfCz8oaRCta4QhKOG4 v6OhY2r2qjquht/BPrJJIXG7i+DFzrBNP3WqVG4FzKHpCesnKIUx2ki32J8TTaK7Jz2d uBLv/IUOplVGSB8oGRoZRE4Di9944o0GAuDsQr6Y1gMS23jR2WlR7FmjhTzk2fP0m//c wu+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962661; x=1774567461; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X4aFDGz+ocU8pLrA7jQQlv23G1GT6rQZLR8GkVLQCjI=; b=S0WYgilxSFxFWEvnulcye65LP0/q0QjNfptDA/PrMtzxiomLu7UHhNOSRiUvh9vOao wyIdhm0XDhIyD6p+remfKpa1BB/WAlOBa6Q5JMSvdEW00bvw/fyCvSGTnHFScyZyjX2H bnYTeuglxTlrwgYr3nIs+yIvbyykkW6684XJvByxMifGmBNklQDgA5QYXiZjGVwqqrOH euOTt6ilDV9DY39o6TLeZEJqyWEBflExYYVXHsuZFUTqOUtJs1IZOkwzp3/1vGQKn0p5 aX/UL5LfStOl/qqaF+y+NPiyooUxjWe+K8u6FWch+aECDwGlRIO39O4eiRS9HhaVhGrD BSAQ== X-Forwarded-Encrypted: i=1; AJvYcCWBgV3kM9aGliyCGpjwR1Sogi6unT2VPQc3NxP1usJ0G9JUxFKkfgGASYWW3TcW7cnMe9WFAq7TkOPNhEQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyKtIuOWgq9E7XiRKAGPvfcz5H8jwnd2EX8+T2Z6WB3WW2p6ayO VEpWUDD6lqxLz4H0GO3lCQupijNPPUcXgzPSNr5Tpdaj6GJ2+mLGsCCbXGvErqT17ZctWSDSWhh QkhhFwVnMrA== X-Received: from dybnj1.prod.google.com ([2002:a05:7300:d081:b0:2c0:db56:eddb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6606:b0:127:33e0:ea40 with SMTP id a92af1059eb24-12a726600aamr502694c88.15.1773962660461; Thu, 19 Mar 2026 16:24:20 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:18 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-10-irogers@google.com> Subject: [PATCH v2 09/25] perf lock: Only pass sample to handlers From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The evsel is within the sample and so only the sample needs to be passed. Remove the parameter and fix call site. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 65 ++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index a35e8ea4e2ef..78fb39d06e7c 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -473,28 +473,22 @@ static struct lock_stat *pop_from_result(void) =20 struct trace_lock_handler { /* it's used on CONFIG_LOCKDEP */ - int (*acquire_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*acquire_event)(struct perf_sample *sample); =20 /* it's used on CONFIG_LOCKDEP && CONFIG_LOCK_STAT */ - int (*acquired_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*acquired_event)(struct perf_sample *sample); =20 /* it's used on CONFIG_LOCKDEP && CONFIG_LOCK_STAT */ - int (*contended_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*contended_event)(struct perf_sample *sample); =20 /* it's used on CONFIG_LOCKDEP */ - int (*release_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*release_event)(struct perf_sample *sample); =20 /* it's used when CONFIG_LOCKDEP is off */ - int (*contention_begin_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*contention_begin_event)(struct perf_sample *sample); =20 /* it's used when CONFIG_LOCKDEP is off */ - int (*contention_end_event)(struct evsel *evsel, - struct perf_sample *sample); + int (*contention_end_event)(struct perf_sample *sample); }; =20 static struct lock_seq_stat *get_seq(struct thread_stat *ts, u64 addr) @@ -563,8 +557,7 @@ static int get_key_by_aggr_mode(u64 *key, u64 addr, return get_key_by_aggr_mode_simple(key, addr, sample->tid); } =20 -static int report_lock_acquire_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_acquire_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -638,8 +631,7 @@ static int report_lock_acquire_event(struct evsel *evse= l __maybe_unused, return 0; } =20 -static int report_lock_acquired_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_acquired_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -704,8 +696,7 @@ static int report_lock_acquired_event(struct evsel *evs= el __maybe_unused, return 0; } =20 -static int report_lock_contended_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_contended_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -762,8 +753,7 @@ static int report_lock_contended_event(struct evsel *ev= sel __maybe_unused, return 0; } =20 -static int report_lock_release_event(struct evsel *evsel __maybe_unused, - struct perf_sample *sample) +static int report_lock_release_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -963,8 +953,7 @@ static u64 *get_callstack(struct perf_sample *sample, i= nt max_stack) return callstack; } =20 -static int report_lock_contention_begin_event(struct evsel *evsel __maybe_= unused, - struct perf_sample *sample) +static int report_lock_contention_begin_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -1127,8 +1116,7 @@ static int report_lock_contention_begin_event(struct = evsel *evsel __maybe_unused return 0; } =20 -static int report_lock_contention_end_event(struct evsel *evsel __maybe_un= used, - struct perf_sample *sample) +static int report_lock_contention_end_event(struct perf_sample *sample) { struct lock_stat *ls; struct thread_stat *ts; @@ -1208,45 +1196,45 @@ static struct trace_lock_handler contention_lock_op= s =3D { =20 static struct trace_lock_handler *trace_handler; =20 -static int evsel__process_lock_acquire(struct evsel *evsel, struct perf_sa= mple *sample) +static int evsel__process_lock_acquire(struct perf_sample *sample) { if (trace_handler->acquire_event) - return trace_handler->acquire_event(evsel, sample); + return trace_handler->acquire_event(sample); return 0; } =20 -static int evsel__process_lock_acquired(struct evsel *evsel, struct perf_s= ample *sample) +static int evsel__process_lock_acquired(struct perf_sample *sample) { if (trace_handler->acquired_event) - return trace_handler->acquired_event(evsel, sample); + return trace_handler->acquired_event(sample); return 0; } =20 -static int evsel__process_lock_contended(struct evsel *evsel, struct perf_= sample *sample) +static int evsel__process_lock_contended(struct perf_sample *sample) { if (trace_handler->contended_event) - return trace_handler->contended_event(evsel, sample); + return trace_handler->contended_event(sample); return 0; } =20 -static int evsel__process_lock_release(struct evsel *evsel, struct perf_sa= mple *sample) +static int evsel__process_lock_release(struct perf_sample *sample) { if (trace_handler->release_event) - return trace_handler->release_event(evsel, sample); + return trace_handler->release_event(sample); return 0; } =20 -static int evsel__process_contention_begin(struct evsel *evsel, struct per= f_sample *sample) +static int evsel__process_contention_begin(struct perf_sample *sample) { if (trace_handler->contention_begin_event) - return trace_handler->contention_begin_event(evsel, sample); + return trace_handler->contention_begin_event(sample); return 0; } =20 -static int evsel__process_contention_end(struct evsel *evsel, struct perf_= sample *sample) +static int evsel__process_contention_end(struct perf_sample *sample) { if (trace_handler->contention_end_event) - return trace_handler->contention_end_event(evsel, sample); + return trace_handler->contention_end_event(sample); return 0; } =20 @@ -1424,8 +1412,7 @@ static int process_event_update(const struct perf_too= l *tool, return 0; } =20 -typedef int (*tracepoint_handler)(struct evsel *evsel, - struct perf_sample *sample); +typedef int (*tracepoint_handler)(struct perf_sample *sample); =20 static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, @@ -1445,7 +1432,7 @@ static int process_sample_event(const struct perf_too= l *tool __maybe_unused, =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - err =3D f(evsel, sample); + err =3D f(sample); } =20 thread__put(thread); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:27 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.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 09EB8402457 for ; Thu, 19 Mar 2026 23:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962665; cv=none; b=K80hgCLxsixOFfMoZWV56SLxc45Kere08plYDB/rcOmRWq2mZNK9kXCpC5zVFQOvXmit7ZDySyOWQWlv/DUIJlFc9exU+DobaIf7NCQS8QqbHVOvGvTK93fCFd+CCEUdT0+TdHFxQ1kiqCrG17q03fWamjsqceoBI/HGefuCpBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962665; c=relaxed/simple; bh=RCv6opy0rOqvlNj5z92+NzI29eWRQq7w3cUzbQCiF+k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TY+LZxNZyp9MnGaoCr9afz6Po7p18r1UfSTPIgQ//Y6wqSTcSXPXn2v1BlBkP12x5FRCswY6KDzVsGAAxywQg7CbIT8sgF2TfXCcZCoVIjgsy2jr0XWKizGTGa2c5h8qX0wuMsCHoSAYaTfuECRSnRkeoTeik9gHalv+nTjDg1c= 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=ELcKHMgB; arc=none smtp.client-ip=74.125.82.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="ELcKHMgB" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2bdc1b30ac8so29317397eec.1 for ; Thu, 19 Mar 2026 16:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962663; x=1774567463; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=d33AbYDTlaS5mB4Y5js7O+MGtwScYB2I0WrPSaITagA=; b=ELcKHMgBLcJMJsXxpatr+EkTjk4v72LTHmvljFk90zYx6Xj+4R33RJ8LeAVmyUgsvl IEgCt5Ls14wA7oYlpOYdRnp3ZiqCisrnox674Y9+eFb3YB0hYJFBcfXlLGX3gPuoLypb 9z6qHyQqg4AKFM1kyl5+qjh1Gbd8VQ1HuRhbomCFC/rpOSEKMOCbllig/EOd1ByJCvPS 2DkubAeVanRMTNuCS+6XYHa1rNUrBKZXKzWfU5DT+V6U+UbZJgOleqq4yFXaVCUpafIm RVjGO89VZw05lqM62dZ92sXQZmYZrPfnMO2skWpaLZQJeU3iplNjhVDChye3NCORdN75 T+Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962663; x=1774567463; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d33AbYDTlaS5mB4Y5js7O+MGtwScYB2I0WrPSaITagA=; b=lrUEjwoYHw6ebCi2QQYoqueEh6UdHC2P9CX0LZbSL2gYaGAT7AvlnhYmCqcltmMP37 opx52uAgCkhwjaLv2nD30tCAly9vJWHnwq0JxSomexYN1qHZYwN5jKjL6eoJWHZDTGYZ YeiKKzIwXuqfTtb0fgU7cYm7lje1kXQevfvk/WJwKWLH/62AJajc2jyPEmNrUH6IyRAT y/mJH4mBLsJaqcLlHD7J1+oei1hPqbkSWoolVuPhYIzoso1Pbc/OZmLG32TBjIPhAFT4 TfrUz6rPbauf+sxbtKCSfEZYKMOFBbdOKAO5CYKFpeVlYEdKk8i1GSYrRFpt+xf4Hxoj IL8g== X-Forwarded-Encrypted: i=1; AJvYcCVMpvrPPHI9BWADDGoYNAZIfVF+EB4EcoYCu5AOlt2UGHezeUXCr1To5Fn86ItAvvHdZ7+5GK4p1Kz8XAs=@vger.kernel.org X-Gm-Message-State: AOJu0Yzmy/VpSuOeXPLIJvLRpqPTVN/EWuK5FXmJ77uE07U0ceeZR5KG z4d6PvoCIREHqFfLsZ4e/NrwD2pqc7hXtj+YiE4qUQDELDZuYUAspQLcIuo59jMf2U7Z5Cu7o+X ClI8zKhR89A== X-Received: from dyckg8.prod.google.com ([2002:a05:7301:d188:b0:2c0:b1d7:935c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:3252:b0:2bd:c285:2fe with SMTP id 5a478bee46e88-2c1095fa7fcmr635808eec.9.1773962662896; Thu, 19 Mar 2026 16:24:22 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:19 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-11-irogers@google.com> Subject: [PATCH v2 10/25] perf lock: Constify trace_lock_handler variables From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Structs don't change and so constify. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 78fb39d06e7c..735e6bb234ae 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1179,7 +1179,7 @@ static int report_lock_contention_end_event(struct pe= rf_sample *sample) =20 /* lock oriented handlers */ /* TODO: handlers for CPU oriented, thread oriented */ -static struct trace_lock_handler report_lock_ops =3D { +static const struct trace_lock_handler report_lock_ops =3D { .acquire_event =3D report_lock_acquire_event, .acquired_event =3D report_lock_acquired_event, .contended_event =3D report_lock_contended_event, @@ -1188,13 +1188,13 @@ static struct trace_lock_handler report_lock_ops = =3D { .contention_end_event =3D report_lock_contention_end_event, }; =20 -static struct trace_lock_handler contention_lock_ops =3D { +static const struct trace_lock_handler contention_lock_ops =3D { .contention_begin_event =3D report_lock_contention_begin_event, .contention_end_event =3D report_lock_contention_end_event, }; =20 =20 -static struct trace_lock_handler *trace_handler; +static const struct trace_lock_handler *trace_handler; =20 static int evsel__process_lock_acquire(struct perf_sample *sample) { --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 60F223FFAB9 for ; Thu, 19 Mar 2026 23:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962668; cv=none; b=Ha4fLGKtZuznnocDtkQxHJigmqnMBv8B23IuRBkQiY6kF53OOGF9YWnfxxZhWmpL1hXC/zVKkLFiX7G3F5jsdT7pGjJMHb0708i/XmJB0jhi2WuhTsIOEIN0ZJnWJlXgLfjcD/RucTywee9AXbr1UR3QjYSrNh9GV+KAJWCa01c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962668; c=relaxed/simple; bh=pkK9HPaXhZiS9d2kBp5ohDgmZW3haOyp+PwoUwhtDmA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Pc5KIoM5UcCByEZ0P4jIMQreMqio+NhLWIN/rgW8SEGGl021kHqVVkPAule7wIiUQIOKtTWQxPU8J7OqHGjFqnScgvgg2uHHI0tk5UXp4+PhR7/QPSfRF0Kzl856gUNDlNnuTOgXJPLxG4XP2oBhI4bYB/PQ1+CDkwDY4Ddpqhg= 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=Uk3h2yt6; arc=none smtp.client-ip=74.125.82.73 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="Uk3h2yt6" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-128ba70cc99so940437c88.0 for ; Thu, 19 Mar 2026 16:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962665; x=1774567465; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cbiMPzKFzZoIFy8R/jHDMJz/PJAmM+Tp0jhZyflDyj8=; b=Uk3h2yt6vpZ5CuRTnwBzQDgCtWulOsHy/5ykIcFdPuVG9SEcrC4LGE5FgAaml48BFv L7fLvXpo2x6+48AKSZ45mu2nGoKToOlfVwdPbtI0MNTtgpxXTcM9vRnH0AdnA5GId+Q+ 9UPLV/1StBLPs4O2/g//478RY1pxnWr5lS6jAlAWiZi/SJTtx9ZP55YZ0zsLXjbCobuP 6C6YRFMtzxVlyO3IpDK7aawyw43KP3QHYR/R1J+X7AkpvWqOnoltXktFhPUtWXYgPgXE IFtLtgZN5pyPjvy4OW9RJ2oBR/mDkqLlr9lLCPjFVeg3bVgz7flfC528dVZvxdtS/c6W AzFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962665; x=1774567465; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cbiMPzKFzZoIFy8R/jHDMJz/PJAmM+Tp0jhZyflDyj8=; b=aXsRMDkkcXUTFFTe3GagWO8GkDMRbY2RkSJTxZqNIkWqD3vHi9q0fIu9fGjDnabmJb cPStEBRZ8Loz1BaZPy+l3zwaQrmdbQVArA2ICHy6JVDRqJ/vs5Egf7uatTdPgv08E0vn KWmDpU4vxKV2FV40rgppTkX8n+Ddtyit1pbiofUPlqJBoAb06gXKBA87o/IqWgw3EYNM aYJdK29flzCRywTMhlePh+jIsUSvbJMgcdEQapITodaJnSxzJ5ljY8HIsf+iiWTVq06P AZtZl60j1XciI1NpbAQCu4quX6zgIchiwrX2vZ8bq2YxnmoN93AjSpo2agH7T2BmuCuv Sopw== X-Forwarded-Encrypted: i=1; AJvYcCVFN9Pr2RnZyQ3qhXxIaB2NKV2M6YHq4S2lvo9aYFbDTDzjph6T7aYsQRWAFuydPI8a4/qNeyyHz7a7CAs=@vger.kernel.org X-Gm-Message-State: AOJu0YxZIYG1WzzwXMkXe1xDJoqs4j/voXy6IVTTgjo/wPmEUjK7u5Ub gJG7X5DuYqClnw7OQxk5YpSjdkdVyhC+eCHHW/euTmZEu7GKbXua0A/V/6M2Z1ieZB1cQAGVtzX W5/BjZZ9QvQ== X-Received: from dlaf28.prod.google.com ([2002:a05:701b:241c:b0:121:7afb:490]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:62a9:b0:12a:6a64:81ee with SMTP id a92af1059eb24-12a7265dcadmr409800c88.3.1773962665094; Thu, 19 Mar 2026 16:24:25 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:20 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-12-irogers@google.com> Subject: [PATCH v2 11/25] perf hist: Remove evsel parameter from inc samples functions From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hist_entry__inc_addr_samples and addr_map_symbol__inc_samples unnecessarily take an evsel argument. Read the evsel from the sample instead. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 7 +++---- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-report.c | 18 ++++++++---------- tools/perf/builtin-top.c | 6 +++--- tools/perf/util/annotate.c | 19 +++++++++---------- tools/perf/util/annotate.h | 6 ++---- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c97a0fe159f8..c2d0599fe5f5 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -177,16 +177,15 @@ static int hist_iter__branch_callback(struct hist_ent= ry_iter *iter, struct hist_entry *he =3D iter->he; struct branch_info *bi; struct perf_sample *sample =3D iter->sample; - struct evsel *evsel =3D iter->evsel; int err; =20 bi =3D he->branch_info; - err =3D addr_map_symbol__inc_samples(&bi->from, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->from, sample); =20 if (err) goto out; =20 - err =3D addr_map_symbol__inc_samples(&bi->to, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->to, sample); =20 out: return err; @@ -276,7 +275,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, if (he =3D=3D NULL) return -ENOMEM; =20 - ret =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + ret =3D hist_entry__inc_addr_samples(he, sample, al->addr); hists__inc_nr_samples(hists, true); return ret; } diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index f9ac871264af..5684c14c2bf6 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -371,7 +371,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, =20 if (perf_c2c__has_annotation(NULL)) { perf_c2c__evsel_hists_inc_stats(evsel, he, sample); - addr_map_symbol__inc_samples(mem_info__iaddr(mi), sample, evsel); + addr_map_symbol__inc_samples(mem_info__iaddr(mi), sample); } =20 ret =3D hist_entry__append_callchain(he, sample); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 507002cbdd5b..39968ae5cfb0 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -170,7 +170,6 @@ static int hist_iter__report_callback(struct hist_entry= _iter *iter, int err =3D 0; struct report *rep =3D arg; struct hist_entry *he =3D iter->he; - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; struct mem_info *mi; struct branch_info *bi; @@ -180,25 +179,25 @@ static int hist_iter__report_callback(struct hist_ent= ry_iter *iter, =20 if (sort__mode =3D=3D SORT_MODE__BRANCH) { bi =3D he->branch_info; - err =3D addr_map_symbol__inc_samples(&bi->from, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->from, sample); if (err) goto out; =20 - err =3D addr_map_symbol__inc_samples(&bi->to, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->to, sample); =20 } else if (rep->mem_mode) { mi =3D he->mem_info; - err =3D addr_map_symbol__inc_samples(mem_info__daddr(mi), sample, evsel); + err =3D addr_map_symbol__inc_samples(mem_info__daddr(mi), sample); if (err) goto out; =20 - err =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + err =3D hist_entry__inc_addr_samples(he, sample, al->addr); =20 } else if (symbol_conf.cumulate_callchain) { if (single) - err =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + err =3D hist_entry__inc_addr_samples(he, sample, al->addr); } else { - err =3D hist_entry__inc_addr_samples(he, sample, evsel, al->addr); + err =3D hist_entry__inc_addr_samples(he, sample, al->addr); } =20 out: @@ -214,7 +213,6 @@ static int hist_iter__branch_callback(struct hist_entry= _iter *iter, struct report *rep =3D arg; struct branch_info *bi =3D he->branch_info; struct perf_sample *sample =3D iter->sample; - struct evsel *evsel =3D iter->evsel; int err; =20 branch_type_count(&rep->brtype_stat, &bi->flags, @@ -223,11 +221,11 @@ static int hist_iter__branch_callback(struct hist_ent= ry_iter *iter, if (!ui__has_annotation() && !rep->symbol_ipc) return 0; =20 - err =3D addr_map_symbol__inc_samples(&bi->from, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->from, sample); if (err) goto out; =20 - err =3D addr_map_symbol__inc_samples(&bi->to, sample, evsel); + err =3D addr_map_symbol__inc_samples(&bi->to, sample); =20 out: return err; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 710604c4f6f6..e863f9ef581f 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -198,7 +198,7 @@ static void ui__warn_map_erange(struct map *map, struct= symbol *sym, u64 ip) static void perf_top__record_precise_ip(struct perf_top *top, struct hist_entry *he, struct perf_sample *sample, - struct evsel *evsel, u64 ip) + u64 ip) EXCLUSIVE_LOCKS_REQUIRED(he->hists->lock) { struct annotation *notes; @@ -215,7 +215,7 @@ static void perf_top__record_precise_ip(struct perf_top= *top, if (!annotation__trylock(notes)) return; =20 - err =3D hist_entry__inc_addr_samples(he, sample, evsel, ip); + err =3D hist_entry__inc_addr_samples(he, sample, ip); =20 annotation__unlock(notes); =20 @@ -734,7 +734,7 @@ static int hist_iter__top_callback(struct hist_entry_it= er *iter, struct evsel *evsel =3D iter->evsel; =20 if (perf_hpp_list.sym && single) - perf_top__record_precise_ip(top, iter->he, iter->sample, evsel, al->addr= ); + perf_top__record_precise_ip(top, iter->he, iter->sample, al->addr); =20 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY), diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 2e3522905046..15ff0443c312 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -211,9 +211,10 @@ static int __symbol__account_cycles(struct cyc_hist *c= h, } =20 static int __symbol__inc_addr_samples(struct map_symbol *ms, - struct annotated_source *src, struct evsel *evsel, u64 addr, + struct annotated_source *src, u64 addr, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; struct symbol *sym =3D ms->sym; long hash_key; u64 offset; @@ -316,7 +317,7 @@ struct annotated_source *symbol__hists(struct symbol *s= ym, int nr_hists) } =20 static int symbol__inc_addr_samples(struct map_symbol *ms, - struct evsel *evsel, u64 addr, + u64 addr, struct perf_sample *sample) { struct symbol *sym =3D ms->sym; @@ -324,8 +325,8 @@ static int symbol__inc_addr_samples(struct map_symbol *= ms, =20 if (sym =3D=3D NULL) return 0; - src =3D symbol__hists(sym, evsel->evlist->core.nr_entries); - return src ? __symbol__inc_addr_samples(ms, src, evsel, addr, sample) : 0; + src =3D symbol__hists(sym, sample->evsel->evlist->core.nr_entries); + return src ? __symbol__inc_addr_samples(ms, src, addr, sample) : 0; } =20 static int symbol__account_br_cntr(struct annotated_branch *branch, @@ -579,16 +580,14 @@ static int annotation__compute_ipc(struct annotation = *notes, size_t size, return 0; } =20 -int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample, - struct evsel *evsel) +int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample) { - return symbol__inc_addr_samples(&ams->ms, evsel, ams->al_addr, sample); + return symbol__inc_addr_samples(&ams->ms, ams->al_addr, sample); } =20 -int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, - struct evsel *evsel, u64 ip) +int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, u64 ip) { - return symbol__inc_addr_samples(&he->ms, evsel, ip, sample); + return symbol__inc_addr_samples(&he->ms, ip, sample); } =20 =20 diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 696e36dbf013..1aa6df7d1618 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -422,8 +422,7 @@ static inline struct annotation *symbol__annotation(str= uct symbol *sym) return (void *)sym - symbol_conf.priv_size; } =20 -int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample, - struct evsel *evsel); +int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_= sample *sample); =20 struct annotated_branch *annotation__get_branch(struct annotation *notes); =20 @@ -433,8 +432,7 @@ int addr_map_symbol__account_cycles(struct addr_map_sym= bol *ams, struct evsel *evsel, u64 br_cntr); =20 -int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, - struct evsel *evsel, u64 addr); +int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample= *sample, u64 addr); =20 struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists); void symbol__annotate_zero_histograms(struct symbol *sym); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.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 89E1140B6E4 for ; Thu, 19 Mar 2026 23:24:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962669; cv=none; b=LpoCKJVuSHQXM4M4ZLpWoJUH8SJArLM/ICyGPXDDsAvzgMZPPdqo3i+4WG/w0w5P96TJYHdreLNbmerZ3bj9f8Vdl/nd9dikd9MnuR2/mzbLRZJws1kJIcHtaAo63Uyc8HpiUPslPxgCxx4JJuTH9R0LENa3u8dg5ppDc2YheTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962669; c=relaxed/simple; bh=f5KwYWz1HjZ4yRvLyCRtzSLGeh2v7q8Q8KZbKJVjmbw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=s8NDqBiCyMdDf+hGOnULraW6WPMrXYYRNWskEEZ3SG37ZorZBmEnlJdH7x3JMr/Fnd7tDpgzDLd+TRQ8p21E9evrSwS2lNa6Mi7MJ2n4yEJrZIgKYKC8+2k51QFtSh37MlDalPHe8XRR21gN5PHi6/eRlVsIaFaILyD9N0fZeOE= 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=VopVlkXS; arc=none smtp.client-ip=74.125.82.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="VopVlkXS" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0ba59a830so99765eec.0 for ; Thu, 19 Mar 2026 16:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962668; x=1774567468; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xNmNW7mDn0ItCOOXElmd/MI6vY7MqoQwVcMfL6AVXpo=; b=VopVlkXS0uVuJhZsqcIlmZUzWcGh/7kVRKS7Ejw1WZq5ZJLthqeed81K3x4pNSS3lN WXpWgAm8Nd0qEw4gXZzRf2v9hmWUWLjMrfOe26Fu9PGi+CSTlbUgb/3QAMoBB/qgFHaP llPvV2dkthkDr70fzMdJgDoErtKSzUkApt+Saq1bJ1gnFltko9uSK5srTAVdulmXZZDz 7pmYXcFeel2m9h0YhtGzLUMC3VuZbsVgST99iyAZGv9VLtVSzKzFLFgMA3sYQgXW6Nix 6+UZB4jRBj2Eq+jJ0PZO5A7HPA0n6NJOslqEtfY/OXO653L0vI1AeOb8zxMozBODb4VN qlgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962668; x=1774567468; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xNmNW7mDn0ItCOOXElmd/MI6vY7MqoQwVcMfL6AVXpo=; b=e36QkKLzuaZ20M1pWHOn9epXruGdLBQbLWv3cUBMFqC+9yL592FpsPtReeM5TVzYcm QCmf7E/iG89VkM3QRRWaYe8sOsH69evKsZ7Y3msNzOu7uEpAd4xB9SvOVHWICWC1bf8t 0Bb24nQwJxSHUw7Jj0gE+4hoAsLyh/sXKrAdlVcRdliEc18hdo6+6rIiCHRNs33dpJJW gznRq3hvP/b6Xa5Ls1bj+5Ci0eAYh/lmHd+CdnxvkDuuVAzxqErBjDLCgfVKGlzqTaSd tKK+KO2mSwRYIJvWHiJfurVE/Mtzhis8PgY40xBE6jTBHFAoN1re5I8yVK4bW1WBq5pZ wkDA== X-Forwarded-Encrypted: i=1; AJvYcCVlVx3ivZu4UcWMbiTpn+nJLYRdZwg6YI3kR16KTGOYeh0pIZJe94mHrCWxSb2KtVQWEAz6YcUOJGcY4HY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1oWg73nM2N/t0/dGlu58qqmCwycLSUV1WtLZ0+MOPmQmlsUgJ UeuduG8SBwTcHDKodS4UljL87PhzwOWjLb+6MwXJ2XZXokJH+tZyxNKPvssEuSUE6qiwx51pf16 vVrLLQe07pQ== X-Received: from dybmi40.prod.google.com ([2002:a05:7301:fa8:b0:2c1:6e8:4733]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:2f8a:b0:2c0:c152:ecc7 with SMTP id 5a478bee46e88-2c1096d57e7mr709411eec.16.1773962667579; Thu, 19 Mar 2026 16:24:27 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:21 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-13-irogers@google.com> Subject: [PATCH v2 12/25] perf db-export: Remove evsel from struct export_sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the sample contains the evsel avoid the duplication. Remove the evsel from db_export__sample as it can also read from the sample. Signed-off-by: Ian Rogers --- tools/perf/util/db-export.c | 5 ++--- tools/perf/util/db-export.h | 3 +-- tools/perf/util/scripting-engines/trace-event-python.c | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index a1f578c3a8d5..fdfd825c7ef4 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c @@ -345,14 +345,13 @@ static int db_export__threads(struct db_export *dbe, = struct thread *thread, } =20 int db_export__sample(struct db_export *dbe, union perf_event *event, - struct perf_sample *sample, struct evsel *evsel, + struct perf_sample *sample, struct addr_location *al, struct addr_location *addr_al) { struct thread *thread =3D al->thread; struct export_sample es =3D { .event =3D event, .sample =3D sample, - .evsel =3D evsel, .al =3D al, }; struct thread *main_thread; @@ -365,7 +364,7 @@ int db_export__sample(struct db_export *dbe, union perf= _event *event, if (!machine) return -1; =20 - err =3D db_export__evsel(dbe, evsel); + err =3D db_export__evsel(dbe, sample->evsel); if (err) return err; =20 diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h index 23983cb35706..1abbfd398e3a 100644 --- a/tools/perf/util/db-export.h +++ b/tools/perf/util/db-export.h @@ -25,7 +25,6 @@ struct call_return; struct export_sample { union perf_event *event; struct perf_sample *sample; - struct evsel *evsel; struct addr_location *al; u64 db_id; u64 comm_db_id; @@ -96,7 +95,7 @@ int db_export__symbol(struct db_export *dbe, struct symbo= l *sym, int db_export__branch_type(struct db_export *dbe, u32 branch_type, const char *name); int db_export__sample(struct db_export *dbe, union perf_event *event, - struct perf_sample *sample, struct evsel *evsel, + struct perf_sample *sample, struct addr_location *al, struct addr_location *addr_al); =20 int db_export__branch_types(struct db_export *dbe); diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 0d8665c75d30..9f5c6e5e6ebe 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -1312,7 +1312,7 @@ static void python_export_sample_table(struct db_expo= rt *dbe, t =3D tuple_new(28); =20 tuple_set_d64(t, 0, es->db_id); - tuple_set_d64(t, 1, es->evsel->db_id); + tuple_set_d64(t, 1, es->sample->evsel->db_id); tuple_set_d64(t, 2, maps__machine(thread__maps(es->al->thread))->db_id); tuple_set_d64(t, 3, thread__db_id(es->al->thread)); tuple_set_d64(t, 4, es->comm_db_id); @@ -1353,7 +1353,7 @@ static void python_export_synth(struct db_export *dbe= , struct export_sample *es) t =3D tuple_new(3); =20 tuple_set_d64(t, 0, es->db_id); - tuple_set_d64(t, 1, es->evsel->core.attr.config); + tuple_set_d64(t, 1, es->sample->evsel->core.attr.config); tuple_set_bytes(t, 2, es->sample->raw_data, es->sample->raw_size); =20 call_object(tables->synth_handler, t, "synth_data"); @@ -1368,7 +1368,7 @@ static int python_export_sample(struct db_export *dbe, =20 python_export_sample_table(dbe, es); =20 - if (es->evsel->core.attr.type =3D=3D PERF_TYPE_SYNTH && tables->synth_han= dler) + if (es->sample->evsel->core.attr.type =3D=3D PERF_TYPE_SYNTH && tables->s= ynth_handler) python_export_synth(dbe, es); =20 return 0; @@ -1517,7 +1517,7 @@ static void python_process_event(union perf_event *ev= ent, /* Reserve for future process_hw/sw/raw APIs */ default: if (tables->db_export_mode) - db_export__sample(&tables->dbe, event, sample, evsel, al, addr_al); + db_export__sample(&tables->dbe, event, sample, al, addr_al); else python_process_general_event(sample, evsel, al, addr_al); } --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 1523E40B6FF for ; Thu, 19 Mar 2026 23:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962673; cv=none; b=lGrDF3xQrK4c5+fOkZhgmSSHoJYahGX5ZiJ6PffIG3WwDizx2HKSNMN2ZmfhdXSAWaNd9OPbPLim/cROxeSxNtuqHRtHmMG32qSh0HeuTYEEpvoaQ5T3wfxXbf8MuqkiRJQUt+R+irdyNdGpw2yu0YFlqJrgmTvtePuEpENLI+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962673; c=relaxed/simple; bh=uaXbq5sB6jR23YcrU0TSpwqaN9vxrH71tW18wn1e7gk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rf0TGdevIsLWuRGMG8sZglnekTR4GPTObpQsG05qYBWsKKGsQ+Tx04L4pMzwwAdJ1VT2XvPI24Yho+WIlhfrtmnVXgs0Ns8rNnonZ2LzTdGBC6vxA2OqNIi5qgMgKlLMiCTWN/Ebapsd0XTkwTxdrsrzdlUMrMBJTgHbVnRbTCg= 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=TEOaSLlX; arc=none smtp.client-ip=74.125.82.74 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="TEOaSLlX" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127337c8e52so34469424c88.1 for ; Thu, 19 Mar 2026 16:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962670; x=1774567470; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=//OhO+K8SAxH3wwANO979A4UoFJWciO8XiSL1taUHjA=; b=TEOaSLlXGa5/5LENTxl9y2UgbiGjXqXFbtrXLoltoaSJNNibmBvds5iqt6JBZCOWhe 22DerkpnWWM2QzXyfu+91S1gvkRJQWZZKYAR2O+zZPNKGGKJ0FaAsPaJHnjovGL4xwg5 TUE4rxG8ub8EUkWzuuXd/lCRYsfcSBqWHbjxwYoDsCFWJ6QN3Ig36SUzbYZwh1gRyosH OZJQ8o7SbjrWHPWINocg0SvOaX+1Jq5UYuJ3wy6AbfzuRxUJHjatAbPezK3Bmfgmpqwc 1fejp/EdseDhwkgnMrZ9vBzlXcbCgANfOyf/dmGjwPQvbFayQrlnPO9t578mgFWel1zH FiUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962670; x=1774567470; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=//OhO+K8SAxH3wwANO979A4UoFJWciO8XiSL1taUHjA=; b=Z6QqE1juzn9F7VGGyjYS5hwFnBFNbwuyEfTrJ/AicIUzqt8rfqmBKcqMDSet2mJPeI 6zLx0Gfv+zjXPvQsVa5pM3BG/hMgmn+x/FXrjU/5OqIjThKJXYebUaclOQeio7FjmY7y u2wNrfpT7IV9kXAFvRK7XQZ2hNoRAWKDZN8h/3zM1HTsoI1OORTaYCScdUML5EcpQAVf nR+F/xW2/GRRw9RPRRyu+qr61XqQFRiw/78/phV7sDWoOe9+JCHSthAIosY3mirzvvMn 4GAPySIGtreSkep73rKUl2ghJBZlCcb97qqBXCK4tmaCkP6z376VLhg4oDcOpOH/e56B MTSw== X-Forwarded-Encrypted: i=1; AJvYcCU78CgYAY9zL1aFp2hVt0mdbVpwQscrRCGk91XuY62uDV18K7FWflLvnaIZmOud0YlFhswdL8RmIcn6yOg=@vger.kernel.org X-Gm-Message-State: AOJu0YynYrpbLwjEX2cbjzkg2MBuj/2YuwBm8VpT0t8XYM0JUQjf8TVs xhDPTB0nOFjjeGgwW4etL63Eszbghp0LXMw0XmBNuYlQEEzg0/4x2pDtBDkkm8OCb1dZPbcFYxy exFA/be/42A== X-Received: from dled9-n1.prod.google.com ([2002:a05:701b:42c9:10b0:128:d48f:6f7d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:e24:b0:119:e56b:957b with SMTP id a92af1059eb24-12a725a07e1mr558046c88.0.1773962670036; Thu, 19 Mar 2026 16:24:30 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:22 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-14-irogers@google.com> Subject: [PATCH v2 13/25] perf hist: Remove evsel from struct hist_entry_iter From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct hist_entry_iter has the sample within it so the evsel is unnecessary. Remove the evsel and update uses. Also remove the evsel from hist__account_cycles and derive it from the sample too. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 10 ++++------ tools/perf/builtin-diff.c | 3 +-- tools/perf/builtin-report.c | 6 ++---- tools/perf/builtin-top.c | 9 +++------ tools/perf/tests/hists_cumulate.c | 1 - tools/perf/tests/hists_filter.c | 1 - tools/perf/tests/hists_output.c | 1 - tools/perf/util/hist.c | 24 ++++++++++++------------ tools/perf/util/hist.h | 3 +-- 9 files changed, 23 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c2d0599fe5f5..041f5dc92ea8 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -191,14 +191,12 @@ static int hist_iter__branch_callback(struct hist_ent= ry_iter *iter, return err; } =20 -static int process_branch_callback(struct evsel *evsel, - struct perf_sample *sample, +static int process_branch_callback(struct perf_sample *sample, struct addr_location *al, struct perf_annotate *ann, struct machine *machine) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .add_entry_cb =3D hist_iter__branch_callback, .hide_unresolved =3D symbol_conf.hide_unresolved, @@ -221,8 +219,8 @@ static int process_branch_callback(struct evsel *evsel, if (a.map !=3D NULL) dso__set_hit(map__dso(a.map)); =20 - hist__account_cycles(sample->branch_stack, al, sample, false, - NULL, evsel); + hist__account_cycles(sample->branch_stack, al, sample, /*nonany_branch_mo= de=3D*/false, + /*total_cycles=3D*/NULL); =20 ret =3D hist_entry_iter__add(&iter, &a, PERF_MAX_STACK_DEPTH, ann); out: @@ -269,7 +267,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, process_branch_stack(sample->branch_stack, al, sample); =20 if (ann->has_br_stack && has_annotation(ann)) - return process_branch_callback(evsel, sample, al, ann, machine); + return process_branch_callback(sample, al, ann, machine); =20 he =3D hists__add_entry(hists, al, NULL, NULL, NULL, NULL, sample, true); if (he =3D=3D NULL) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 096adc65451c..67cf5bbaab29 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -397,7 +397,6 @@ static int diff__process_sample_event(const struct perf= _tool *tool, struct evsel *evsel =3D sample->evsel; struct hists *hists =3D evsel__hists(evsel); struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .ops =3D &hist_iter_normal, }; @@ -431,7 +430,7 @@ static int diff__process_sample_event(const struct perf= _tool *tool, } =20 hist__account_cycles(sample->branch_stack, &al, sample, - false, NULL, evsel); + /*nonany_branch_mode=3D*/false, /*total_cycles=3D*/NULL); break; =20 case COMPUTE_STREAM: diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 39968ae5cfb0..1051d7b75361 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -270,10 +270,8 @@ static int process_sample_event(const struct perf_tool= *tool, struct machine *machine) { struct report *rep =3D container_of(tool, struct report, tool); - struct evsel *evsel =3D sample->evsel; struct addr_location al; struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .hide_unresolved =3D symbol_conf.hide_unresolved, .add_entry_cb =3D hist_iter__report_callback, @@ -285,7 +283,7 @@ static int process_sample_event(const struct perf_tool = *tool, return 0; } =20 - if (evswitch__discard(&rep->evswitch, evsel)) + if (evswitch__discard(&rep->evswitch, sample->evsel)) return 0; =20 addr_location__init(&al); @@ -329,7 +327,7 @@ static int process_sample_event(const struct perf_tool = *tool, if (ui__has_annotation() || rep->symbol_ipc || rep->total_cycles_mode) { hist__account_cycles(sample->branch_stack, &al, sample, rep->nonany_branch_mode, - &rep->total_cycles, evsel); + &rep->total_cycles); } =20 rep->total_samples++; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e863f9ef581f..b89ca48e5d02 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -731,20 +731,18 @@ static int hist_iter__top_callback(struct hist_entry_= iter *iter, EXCLUSIVE_LOCKS_REQUIRED(iter->he->hists->lock) { struct perf_top *top =3D arg; - struct evsel *evsel =3D iter->evsel; =20 if (perf_hpp_list.sym && single) perf_top__record_precise_ip(top, iter->he, iter->sample, al->addr); =20 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY), - NULL, evsel); + /*total_cycles=3D*/NULL); return 0; } =20 static void perf_event__process_sample(const struct perf_tool *tool, const union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -830,9 +828,8 @@ static void perf_event__process_sample(const struct per= f_tool *tool, } =20 if (al.sym =3D=3D NULL || !al.sym->idle) { - struct hists *hists =3D evsel__hists(evsel); + struct hists *hists =3D evsel__hists(sample->evsel); struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D sample, .add_entry_cb =3D hist_iter__top_callback, }; @@ -1210,7 +1207,7 @@ static int deliver_event(struct ordered_events *qe, } =20 if (event->header.type =3D=3D PERF_RECORD_SAMPLE) { - perf_event__process_sample(&top->tool, event, evsel, + perf_event__process_sample(&top->tool, event, &sample, machine); } else if (event->header.type =3D=3D PERF_RECORD_LOST) { perf_top__process_lost(top, event, evsel); diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cum= ulate.c index 606aa926a8fc..267cbc24691a 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -87,7 +87,6 @@ static int add_hist_entries(struct hists *hists, struct m= achine *machine) addr_location__init(&al); for (i =3D 0; i < ARRAY_SIZE(fake_samples); i++) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D &sample, .hide_unresolved =3D false, }; diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filte= r.c index cc6b26e373d1..002e3a4c1ca5 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -63,7 +63,6 @@ static int add_hist_entries(struct evlist *evlist, evlist__for_each_entry(evlist, evsel) { for (i =3D 0; i < ARRAY_SIZE(fake_samples); i++) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D &sample, .ops =3D &hist_iter_normal, .hide_unresolved =3D false, diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_outpu= t.c index 7818950d786e..fa683fd7b1e5 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -57,7 +57,6 @@ static int add_hist_entries(struct hists *hists, struct m= achine *machine) addr_location__init(&al); for (i =3D 0; i < ARRAY_SIZE(fake_samples); i++) { struct hist_entry_iter iter =3D { - .evsel =3D evsel, .sample =3D &sample, .ops =3D &hist_iter_normal, .hide_unresolved =3D false, diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 84a402d248a3..632c1edcab9a 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -932,8 +932,8 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter,= struct addr_location *al { u64 cost; struct mem_info *mi =3D iter->mi; - struct hists *hists =3D evsel__hists(iter->evsel); struct perf_sample *sample =3D iter->sample; + struct hists *hists =3D evsel__hists(sample->evsel); struct hist_entry *he; =20 if (mi =3D=3D NULL) @@ -965,7 +965,7 @@ static int iter_finish_mem_entry(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused) { - struct evsel *evsel =3D iter->evsel; + struct evsel *evsel =3D iter->sample->evsel; struct hists *hists =3D evsel__hists(evsel); struct hist_entry *he =3D iter->he; int err =3D -EINVAL; @@ -1033,9 +1033,9 @@ static int iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_locat= ion *al) { struct branch_info *bi; - struct evsel *evsel =3D iter->evsel; - struct hists *hists =3D evsel__hists(evsel); struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; + struct hists *hists =3D evsel__hists(evsel); struct hist_entry *he =3D NULL; int i =3D iter->curr; int err =3D 0; @@ -1075,7 +1075,7 @@ static int iter_finish_branch_entry(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused) { - struct evsel *evsel =3D iter->evsel; + struct evsel *evsel =3D iter->sample->evsel; struct hists *hists =3D evsel__hists(evsel); =20 for (int i =3D 0; i < iter->total; i++) @@ -1100,8 +1100,8 @@ iter_prepare_normal_entry(struct hist_entry_iter *ite= r __maybe_unused, static int iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_loc= ation *al) { - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; struct hist_entry *he; =20 he =3D hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL, @@ -1118,8 +1118,8 @@ iter_finish_normal_entry(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused) { struct hist_entry *he =3D iter->he; - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; =20 if (he =3D=3D NULL) return 0; @@ -1162,9 +1162,9 @@ static int iter_add_single_cumulative_entry(struct hist_entry_iter *iter, struct addr_location *al) { - struct evsel *evsel =3D iter->evsel; - struct hists *hists =3D evsel__hists(evsel); struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; + struct hists *hists =3D evsel__hists(evsel); struct hist_entry **he_cache =3D iter->he_cache; struct hist_entry *he; int err =3D 0; @@ -1221,8 +1221,8 @@ static int iter_add_next_cumulative_entry(struct hist_entry_iter *iter, struct addr_location *al) { - struct evsel *evsel =3D iter->evsel; struct perf_sample *sample =3D iter->sample; + struct evsel *evsel =3D sample->evsel; struct hist_entry **he_cache =3D iter->he_cache; struct hist_entry *he; struct hist_entry he_tmp =3D { @@ -2823,7 +2823,7 @@ int hists__unlink(struct hists *hists) =20 void hist__account_cycles(struct branch_stack *bs, struct addr_location *a= l, struct perf_sample *sample, bool nonany_branch_mode, - u64 *total_cycles, struct evsel *evsel) + u64 *total_cycles) { struct branch_info *bi; struct branch_entry *entries =3D perf_sample__branch_entries(sample); @@ -2847,7 +2847,7 @@ void hist__account_cycles(struct branch_stack *bs, st= ruct addr_location *al, for (int i =3D bs->nr - 1; i >=3D 0; i--) { addr_map_symbol__account_cycles(&bi[i].from, nonany_branch_mode ? NULL : prev, - bi[i].flags.cycles, evsel, + bi[i].flags.cycles, sample->evsel, bi[i].branch_stack_cntr); prev =3D &bi[i].to; =20 diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 1d5ea632ca4e..ee92fffc53a9 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -155,7 +155,6 @@ struct hist_entry_iter { int total; int curr; =20 - struct evsel *evsel; struct perf_sample *sample; struct hist_entry *he; struct symbol *parent; @@ -797,7 +796,7 @@ unsigned int hists__overhead_width(struct hists *hists); =20 void hist__account_cycles(struct branch_stack *bs, struct addr_location *a= l, struct perf_sample *sample, bool nonany_branch_mode, - u64 *total_cycles, struct evsel *evsel); + u64 *total_cycles); =20 struct option; int parse_filter_percentage(const struct option *opt, const char *arg, int= unset); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.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 338A540757C for ; Thu, 19 Mar 2026 23:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962674; cv=none; b=jgcCth42aYV3ltFJjqOBAUBUUD4qXsDSMopGcf19JZORDOkk9uTUojDphDLci6ds7B+SE+3BPhBlTgFkjuvfEn+i1cQbf46zyHLevvUyWPqAYq7Vdia6MyoIlf+hiP+q6pAF9wknXCQ52suf/6gaxPvCC5cabEu748XjcNn4nF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962674; c=relaxed/simple; bh=VBRBWOOsTuUZUQAm9Xp4jFDUX44iF/hvvynPgGnEBf8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=C7s0Zk8wKBPKK9IBpynqFvPR6J6BQqbvFem5RLc1fjgM6yLFBIQahVKtYZ1a8voqC2jfJ/6TTSldXUetrzDXTNGQyE4NpXB+s70KWBnk9HMs8hXJGFih0BSzixhcSO/CjNl2/1GDevAZ37DmkYmcjliktfiPXAVENpuNTNOthJE= 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=pFnesHFp; arc=none smtp.client-ip=74.125.82.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="pFnesHFp" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so92664eec.1 for ; Thu, 19 Mar 2026 16:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962672; x=1774567472; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ex7esaiGl8GWNlFO/kP2nPhlftSsne7shuQzPr/LD2Y=; b=pFnesHFpc4re5JSDwoSd8VvdbF7AXgxGBEGC4BImK25y//YBz0HsgAUQ0eCGyCTAM8 2XPm+S1cj3Ln907/uTeGCKhxt1nAN7NVjE7oWvfwjNC5TyfCD29DgfH40MS4rOaSnlR/ wlk8vskhlESOUhbZwXr1ia11I/zSfYuhjjytl90MdNMEwItGT7X4QY9LHls6tx0HS7Gl ZR+dTF5uhfosDoGHXX+76a0Xfat4zYKWZc5ENEDbrHh8YWAUE3mmMjfP2DfO3BrrrC1h TuVPUt7CoNgPNeDn8BVzcByjxiyAN8uN9VN3xXhs2YxGByU7CMKVsz3bXKgrH1pLVNPM EcRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962672; x=1774567472; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ex7esaiGl8GWNlFO/kP2nPhlftSsne7shuQzPr/LD2Y=; b=Fl/1xtBV8JrYVLgp5qfAf+MykPxHVpiM2cBhgRcQuqXOBWQPFf+BfQBEnz5re2K4vE fWZkYSxC1zf6FeuAqdL7qaCp/rR5a35e1OiWBuFh+7loet3/CXVVVvixUAvqBGLkGyEt MqhF9xQqVGmW0qxGVNd0Y82uYItquQ4u3YWClVAOQHjXI0geuW8Wc/b8U29tzkHqywf5 hxYjHfkslLdOu3mCL2xLmtUwJgc53Nbs+LxUSOaYTDFfAwc7nLLBDbArKuPSXq4MVbE7 9kucWtfZonyuDWpTj5Pmboq/0Qe6QItAesrwcX/qcJKa2cR0oqcFNjxSYR7ZLhNVyZ5a ZGYA== X-Forwarded-Encrypted: i=1; AJvYcCXEk2Ra1eo0NnNt3X9R1B1tnYbPvgVeuSi+0P6xpyIWLnqRjUkhGwQGXRV8Ebs7iH6dQMcXd2XYKV3hkLo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8nsvcYyGqoEo0umHJpzHDmuo+zEuKWrZCmIL1FUCQLXvAmNdj xKXNd5NOAb1EJcV9KgU2OM2oKFzVFXYnd5c+MQFKI0f23hqrmDXQIlQ+m1l+b4uZDNXkn2VfTzA sy0lysLMIsQ== X-Received: from dlaj22.prod.google.com ([2002:a05:701b:2816:b0:128:dd08:f36b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b83:b0:128:c77a:6c8e with SMTP id a92af1059eb24-12a726f5a21mr398186c88.28.1773962672083; Thu, 19 Mar 2026 16:24:32 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:23 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-15-irogers@google.com> Subject: [PATCH v2 14/25] perf report: Directly use sample->evsel to avoid computing from sample->id From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In count_lost_samples_events try to avoid searching for the evsel for the sample, just use the variable within the sample. Signed-off-by: Ian Rogers --- tools/perf/builtin-report.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 1051d7b75361..d53aa7a94192 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -793,9 +793,11 @@ static int count_lost_samples_event(const struct perf_= tool *tool, struct machine *machine __maybe_unused) { struct report *rep =3D container_of(tool, struct report, tool); - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; + + if (!evsel) + evsel =3D evlist__id2evsel(rep->session->evlist, sample->id); =20 - evsel =3D evlist__id2evsel(rep->session->evlist, sample->id); if (evsel) { struct hists *hists =3D evsel__hists(evsel); u32 count =3D event->lost_samples.lost; --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 2F73D407599 for ; Thu, 19 Mar 2026 23:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962676; cv=none; b=qYwzSBR1bUFNAlvrhbvWJnDgVs4yJFLoj1tC/F0E9m9X9z/QnxbCJ0xd/p/awEg/MFVCdlFWOXuHnXFvmaMSWgh3IxnBF+dFFg8jJRxEFWW3ES9N5BN/Ehi+3kyvCWTVQnql93MxVMHtr9vcaVQtqg+XVY+fDdUGVUZr0hy55Do= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962676; c=relaxed/simple; bh=Px3kvXNISBtpkk8Yg/YzO2B/LDlP1VbH2wUqa3xN3DY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RDK9o/NV8UcXCwuxA2rJbWTVGV5mrNu66eiLKRb7KXKU07BsLNWkRnfgWczHa4vD+6Fd9ez/CJ7sW5LsMPz3EIdWhm5Z/45CWt6lKpm8JjeXOCYSZwEFFUACQsFTr4443Z9H2cBnnEognqqL2TyI//WGKhJrMuzFnA6e+PIuJRU= 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=VuQFxI8z; arc=none smtp.client-ip=74.125.82.73 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="VuQFxI8z" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-12711ec96fbso3117473c88.0 for ; Thu, 19 Mar 2026 16:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962674; x=1774567474; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SJxIIiDIQ59GOTFf+kVAJjN1YJAohx4635ngGk36Q3M=; b=VuQFxI8z9RMdC5uKlVHxl/caOCYcEf29VbrLOxJd1AtwIwob1I/4BR/Wf5pUCzYbvn 8fk9+WQa4fRFPkEMF7Nb22Cv6mdn8ZhT8nbLjxGlglDzUj+kxPfQcSVZ4S45WFsVz3RY I1nTGPGgD0UfM+9pQ3EFX+oOj3Fgmp+LQ4bMz4YrrX1cNBVCcwJluaML04/y06rZCcWF hu01IbcqWNrHiaxZXmvhfLhUzfNIkHVEokaSbUEkeAHrfVGxQ7MSUqlQq6ZJtXp+jALa ItS4/fbasPZXggqRpTde0KU7yAxMj0H0ZdbdmqFIT6jwIoNqNASgxIE20I4IfMzkAqyI oLMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962674; x=1774567474; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SJxIIiDIQ59GOTFf+kVAJjN1YJAohx4635ngGk36Q3M=; b=Yvg9/Rv57Pva5haxBREnbOY+Q2pHMAyUUWDWP77TGogW7zri3OOOEJ2fo3zFqc/Dqa vEjOYu5Q14bd2OZzlLMRQDuwa7jnmc7nuYIRUyYEm78am5FcY7UbPylpAv+krRhV1Cjv xlLsgpwKInpZJv65Nm2xCMpq9YJMbbAYXKI4xuHukAS375zYUlY1/yw9385ug1Z6By+p hKdcPqIaCLK/MrMTLtXUi+KGq7M6REPPTnBJ5yYWEGNQJdMstPchHZwVlDeUjkrl+X1h ixzBbF/rJJpRgu2Og/c1WTUE31pwLdtbBKXlezBXdgp+ow4uxN2sdmiKPhMfKEDN6UGF WLqQ== X-Forwarded-Encrypted: i=1; AJvYcCVQFyslQoXyJ6BQnsQrOJxhMRDH8X9HqoD/HJ2k71Hn5nLgng627qY4x1v1FkbrZFOuY/s/jb0R6/OT4mY=@vger.kernel.org X-Gm-Message-State: AOJu0YzFiJmfQcZVAFa0CrJp5ocMKzQsbF80jLTPKSf9R3xuJjDVnS/Q D28enVu+FXm6zYBmDDZM7C50hM6uyXEd5hPRPgtW1+WHKB44doGWN1AwtV6T87eWO60nTzm8aCe QbMA5wvrqfg== X-Received: from dyff16.prod.google.com ([2002:a05:693c:8050:b0:2c0:d493:ae08]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:2382:b0:2ba:8018:cc53 with SMTP id 5a478bee46e88-2c109833e87mr664893eec.35.1773962674232; Thu, 19 Mar 2026 16:24:34 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:24 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-16-irogers@google.com> Subject: [PATCH v2 15/25] perf annotate: Don't pass evsel to add_sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel so read it rather than pass it. Update call site. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 041f5dc92ea8..894e57aa50cd 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -233,11 +233,11 @@ static bool has_annotation(struct perf_annotate *ann) return ui__has_annotation() || ann->use_stdio2; } =20 -static int evsel__add_sample(struct evsel *evsel, struct perf_sample *samp= le, - struct addr_location *al, struct perf_annotate *ann, - struct machine *machine) +static int add_sample(struct perf_sample *sample, + struct addr_location *al, struct perf_annotate *ann, + struct machine *machine) { - struct hists *hists =3D evsel__hists(evsel); + struct hists *hists =3D evsel__hists(sample->evsel); struct hist_entry *he; int ret; =20 @@ -299,7 +299,7 @@ static int process_sample_event(const struct perf_tool = *tool, goto out_put; =20 if (!al.filtered && - evsel__add_sample(sample->evsel, sample, &al, ann, machine)) { + add_sample(sample, &al, ann, machine)) { pr_warning("problem incrementing symbol count, " "skipping event\n"); ret =3D -1; --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 7D3A540FDAD for ; Thu, 19 Mar 2026 23:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962679; cv=none; b=XVtsXwLfscTeJQ3MR53NZYDHVfT7HynzTmlPADkadjiwg3Vnuz0RjGQyJZLCbpNGvGGDZy1XihDkWrF90IKKpmwv53hr2sXWyzBj4cNMA3IkvRwNpxABVNe1NrxZlWW9hxh3+5/1s+pnNw8oKT/JvWU2CU3ocFo0VNZEb8a9y2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962679; c=relaxed/simple; bh=vPg9VgZ3c7SsWfs3DNFG+E/UJQK7VY1DPa8uKtJ7fGc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pasjey9J0StDEZAu60CwiLsfFjB8/RDOUpcDowGNBGeh6bC/yKHOWEwAH0s4q2S6m2U+mWcSROtBhFYWLi7droFQ28msvLiAIcTYK/PsLo1DuclMCp+GUis0GV4+bUFbxtYhRwLkUpeM5ihF3dC43ihUhky+9cQsk5R5O4xzM38= 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=dITCVDzh; arc=none smtp.client-ip=209.85.216.74 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="dITCVDzh" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-358e95e81aeso10086561a91.0 for ; Thu, 19 Mar 2026 16:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962677; x=1774567477; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=W28Iv827p/4MEELaJazuln8g4iiY7jnX7+0vAOMUjQE=; b=dITCVDzhkwXnBInVUDdo8Rxr1O8KEJaoId5WNC8nZZlggTiR6kbZVADxCEHtbHwmOS xKpke/47vFKyIgFS3LxeoW8j5wXMTTjgN4zXDIjSelbPM++2+FubyY/NsMM4d6TRT9NE 06LaHirJfezwhP3HYuExA/aLKeRR6+SiHboP+mRc6xa8iynTM8EVYfwCnmEsvvZv2/2Q 5o4SbR8Z0QBBeg8V4fkWENVHmMaIS16zHnVkGRz8LD530E+OlGt5vnictLJm1AN9khsg TelsY0U5PMT4hjcXOY1maYtX5oC8I0G/ql/ojLgFw6N6qaczXyFbUOVatfUabgzrBgNU nAYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962677; x=1774567477; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W28Iv827p/4MEELaJazuln8g4iiY7jnX7+0vAOMUjQE=; b=bhe2ShCuHl5DDuSQXQ9JcjjMoj9+AYM8ibWgPcDrKZHDaL93rfEhoVrsdU2zk4RYyc kN1q6KQxno5QizUjzn7AcP9FHsk0z+2JhZjBrPvrEW18m/Bjs2eL/LcP6FuW86dLkRgj 1C+fe2sMVGg5rIk92r66rhZXCKYBVnTuE/S4Ojzm41ZRQvq+8bRKhhK9vvaDhRYX9hgw RJJKm1HQAB7o//TQ8wzjqiCf0l7qZEWy6bVKBRf73EJexqyMK49VIbsWiH571vXSG5LP ak8q12kDopXy7eUQeXfUv3p1+JJ/YZjMKmuvufMoD7N2ysYd+wrgxrOyGCsFKFdmpTKU Mo+A== X-Forwarded-Encrypted: i=1; AJvYcCWTDrv13FvJQufYHElvfpI1pZF1qYzCqBIwd1GRNoETh/ixltTIXmeaD8M26TAz2/fuqhproh1PCfQ5LHQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwysDgjpYV4IQG934hpF/Tv+cCQXyKlIlKVBxwJVTCcnLbqaqBv 5q9dpkPtx0MoCCtrX26qaTfczmJqgUlpBeNqOqZkpPBHub8t1sUFO4quZSPfWX/+tSsCUYqGF9n mev3JQIMynw== X-Received: from pjyj6.prod.google.com ([2002:a17:90a:e606:b0:359:8332:2cce]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4b04:b0:354:a284:3fff with SMTP id 98e67ed59e1d1-35bd2d187e4mr704735a91.25.1773962676636; Thu, 19 Mar 2026 16:24:36 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:25 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-17-irogers@google.com> Subject: [PATCH v2 16/25] perf inject: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 37 +++++++++++------------------- tools/perf/util/synthetic-events.c | 9 ++++---- tools/perf/util/synthetic-events.h | 2 -- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index bc6d94806080..6e265b66a551 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -146,14 +146,12 @@ struct event_entry { static int tool__inject_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, const char *filename, struct dso *dso, u32 flags); static int tool__inject_mmap2_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, @@ -357,7 +355,6 @@ perf_inject__cut_auxtrace_sample(struct perf_inject *in= ject, 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(const struct perf_tool *tool, @@ -370,7 +367,7 @@ static int perf_event__repipe_sample(const struct perf_= tool *tool, =20 if (evsel && evsel->handler) { inject_handler f =3D evsel->handler; - return f(tool, event, sample, evsel, machine); + return f(tool, event, sample, machine); } =20 build_id__mark_dso_hit(tool, event, sample, machine); @@ -584,11 +581,14 @@ static int perf_event__repipe_common_mmap(const struc= t perf_tool *tool, } =20 if (dso && !dso__hit(dso)) { - struct evsel *evsel =3D evlist__event2evsel(inject->session->evlist, ev= ent); + struct evsel *evsel =3D sample->evsel; + + if (!evsel) + evsel =3D evlist__event2evsel(inject->session->evlist, event); =20 if (evsel) { dso__set_hit(dso); - tool__inject_build_id(tool, sample, machine, evsel, + tool__inject_build_id(tool, sample, machine, /*misc=3D*/sample->cpumode, filename, dso, flags); } @@ -622,7 +622,7 @@ static int perf_event__repipe_common_mmap(const struct = perf_tool *tool, dso_sought =3D true; } if (evsel && dso && - !tool__inject_mmap2_build_id(tool, sample, machine, evsel, + !tool__inject_mmap2_build_id(tool, sample, machine, sample->cpumode | PERF_RECORD_MISC_MMAP_BUILD_ID, pid, tid, start, len, pgoff, dso, @@ -836,7 +836,6 @@ static bool perf_inject__lookup_known_build_id(struct p= erf_inject *inject, static int tool__inject_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, const char *filename, struct dso *dso, u32 flags) @@ -860,7 +859,7 @@ static int tool__inject_build_id(const struct perf_tool= *tool, =20 err =3D perf_event__synthesize_build_id(tool, sample, machine, perf_event__repipe, - evsel, misc, dso__bid(dso), + misc, dso__bid(dso), filename); if (err) { pr_err("Can't synthesize build_id event for %s\n", filename); @@ -873,7 +872,6 @@ static int tool__inject_build_id(const struct perf_tool= *tool, static int tool__inject_mmap2_build_id(const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, @@ -896,7 +894,6 @@ static int tool__inject_mmap2_build_id(const struct per= f_tool *tool, =20 err =3D perf_event__synthesize_mmap2_build_id(tool, sample, machine, perf_event__repipe, - evsel, misc, pid, tid, start, len, pgoff, dso__bid(dso), @@ -913,7 +910,6 @@ static int mark_dso_hit(const struct perf_inject *injec= t, const struct perf_tool *tool, struct perf_sample *sample, struct machine *machine, - const struct evsel *mmap_evsel, struct map *map, bool sample_in_dso) { struct dso *dso; @@ -943,7 +939,7 @@ static int mark_dso_hit(const struct perf_inject *injec= t, if (dso && !dso__hit(dso)) { dso__set_hit(dso); tool__inject_build_id(tool, sample, machine, - mmap_evsel, misc, dso__long_name(dso), dso, + misc, dso__long_name(dso), dso, map__flags(map)); } } else if (inject->build_id_style =3D=3D BID_RWS__MMAP2_BUILDID_LAZY) { @@ -955,7 +951,6 @@ static int mark_dso_hit(const struct perf_inject *injec= t, map__set_hit(map); perf_event__synthesize_mmap2_build_id(tool, sample, machine, perf_event__repipe, - mmap_evsel, misc, sample->pid, sample->tid, map__start(map), @@ -975,7 +970,6 @@ struct mark_dso_hit_args { const struct perf_tool *tool; struct perf_sample *sample; struct machine *machine; - const struct evsel *mmap_evsel; }; =20 static int mark_dso_hit_callback(struct callchain_cursor_node *node, void = *data) @@ -984,7 +978,7 @@ static int mark_dso_hit_callback(struct callchain_curso= r_node *node, void *data) struct map *map =3D node->ms.map; =20 return mark_dso_hit(args->inject, args->tool, args->sample, args->machine, - args->mmap_evsel, map, /*sample_in_dso=3D*/false); + map, /*sample_in_dso=3D*/false); } =20 static int perf_event__inject_buildid(const struct perf_tool *tool, union = perf_event *event, @@ -1002,7 +996,6 @@ static int perf_event__inject_buildid(const struct per= f_tool *tool, union perf_e */ .sample =3D sample, .machine =3D machine, - .mmap_evsel =3D inject__mmap_evsel(inject), }; struct evsel *saved_evsel =3D sample->evsel; =20 @@ -1015,7 +1008,7 @@ static int perf_event__inject_buildid(const struct pe= rf_tool *tool, union perf_e } =20 if (thread__find_map(thread, sample->cpumode, sample->ip, &al)) { - mark_dso_hit(inject, tool, sample, machine, args.mmap_evsel, al.map, + mark_dso_hit(inject, tool, sample, machine, al.map, /*sample_in_dso=3D*/true); } =20 @@ -1033,7 +1026,6 @@ static int perf_event__inject_buildid(const struct pe= rf_tool *tool, union perf_e 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, struct machine *machine __maybe_unused) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); @@ -1053,13 +1045,12 @@ static int perf_inject__sched_process_exit(const st= ruct 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, struct machine *machine) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); struct event_entry *ent; =20 - perf_inject__sched_process_exit(tool, event, sample, evsel, machine); + perf_inject__sched_process_exit(tool, event, sample, machine); =20 ent =3D malloc(event->header.size + sizeof(struct event_entry)); if (ent =3D=3D NULL) { @@ -1078,13 +1069,13 @@ static int perf_inject__sched_switch(const struct p= erf_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, struct machine *machine) { struct event_entry *ent; union perf_event *event_sw; struct perf_sample sample_sw; struct perf_inject *inject =3D container_of(tool, struct perf_inject, too= l); + struct evsel *evsel =3D sample->evsel; u32 pid =3D perf_sample__intval(sample, "pid"); int ret; =20 @@ -1449,7 +1440,7 @@ static int synthesize_build_id(struct perf_inject *in= ject, struct dso *dso, pid_ dso__set_hit(dso); =20 return perf_event__synthesize_build_id(&inject->tool, &synth_sample, mach= ine, - process_build_id, inject__mmap_evsel(inject), + process_build_id, /*misc=3D*/synth_sample.cpumode, dso__bid(dso), dso__long_name(dso)); } diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index ef79433ebc3a..53e411cf33cc 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -2247,7 +2247,6 @@ int perf_event__synthesize_build_id(const struct perf= _tool *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, const struct build_id *bid, const char *filename) @@ -2270,12 +2269,13 @@ int perf_event__synthesize_build_id(const struct pe= rf_tool *tool, ev.build_id.header.size =3D len; strcpy(ev.build_id.filename, filename); =20 - if (evsel) { + if (sample->evsel) { void *array =3D &ev; int ret; =20 array +=3D ev.header.size; - ret =3D perf_event__synthesize_id_sample(array, evsel->core.attr.sample_= type, sample); + ret =3D perf_event__synthesize_id_sample(array, sample->evsel->core.attr= .sample_type, + sample); if (ret < 0) return ret; =20 @@ -2294,7 +2294,6 @@ int perf_event__synthesize_mmap2_build_id(const struc= t perf_tool *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, @@ -2334,7 +2333,7 @@ int perf_event__synthesize_mmap2_build_id(const struc= t perf_tool *tool, =20 array =3D &ev; array +=3D ev.header.size; - ret =3D perf_event__synthesize_id_sample(array, evsel->core.attr.sample_t= ype, sample); + ret =3D perf_event__synthesize_id_sample(array, sample->evsel->core.attr.= sample_type, sample); if (ret < 0) return ret; =20 diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic= -events.h index b0edad0c3100..473a43a78993 100644 --- a/tools/perf/util/synthetic-events.h +++ b/tools/perf/util/synthetic-events.h @@ -50,7 +50,6 @@ int perf_event__synthesize_build_id(const struct perf_too= l *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, const struct build_id *bid, const char *filename); @@ -58,7 +57,6 @@ int perf_event__synthesize_mmap2_build_id(const struct pe= rf_tool *tool, struct perf_sample *sample, struct machine *machine, perf_event__handler_t process, - const struct evsel *evsel, __u16 misc, __u32 pid, __u32 tid, __u64 start, __u64 len, __u64 pgoff, --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 2A1E840FD9C for ; Thu, 19 Mar 2026 23:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962681; cv=none; b=GtN5EihXHq74q1ZTD8QvsBHWh8xLSMKY2P04I11NV3FpVcc0JU5urWkpBDaGy63qXogsdfMTF3fWm5gvsAt5PV1TPfsbcCzV4ntkU2TGzeOOT8P4VWPfzwhj9SBKB6RbfKT4f9IbjzsLSG9xYjtD37l94o4CMTlh94SmEUJ2vA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962681; c=relaxed/simple; bh=3xHkozfOBQ5O/0UIsbkAMpaM2l17KKcrX8h7fai6Z3Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CydhCnMRGg0ir7ML3a0CUJ13CrGyKO5NPjunOG1tFsmbpzHh2XgY1TFctaO6x6JNoGm6pKZ6BbplEMqwUnRJJOlgWt2VrVqCmz/O9GkkhEPYH2//HuhERI0RNMnlu1ha9RR5DSsSzR1p0utSwi9HRWCnup413fPwKtGgVrzIrSw= 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=ZSUd9PRe; arc=none smtp.client-ip=74.125.82.73 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="ZSUd9PRe" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1276e71652fso70502c88.0 for ; Thu, 19 Mar 2026 16:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962679; x=1774567479; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=j3NPJHDhmF9h/ESu+OU97vNzfzIxPr2OOmbu63IbKTw=; b=ZSUd9PReeo5S5vZ4jaL1l4GXzOoCoiFxPMRA4Ez32G0B/kd+8S7EjNQVuqokOao7YB x/v+3OtsKkyk1LT+29KMQ8USPRf2nRtcPGY33bMv+tnrpockvEgzm12awDEPRU4IZBdM 0ucUNBoxiCjDZmMC0zxfG0PPx/141KRx/Sw3njBeOq+xvsnv6hbq4nAWBYWpkyxer9yN rrxP6V3KRTG/alc1ZOuVGLKXWV1X9JwTGaTfCI9YqEyP4v3UvsCNdX7gMAmKQmxZJ9Rc yN1z1yp/EWYMc8+7FBDM76QpRJk3dRJBkn28gsuOUaNfpNTaeBIgjliEbBQKXYMFCdC7 L5FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962679; x=1774567479; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j3NPJHDhmF9h/ESu+OU97vNzfzIxPr2OOmbu63IbKTw=; b=VV99qXV1pGIcDknK3/OnMp9dsfHhTbW/+kqa3tbtNCxcQ/BBZhGM0zAiz4Re6sQNxc p2rFE8J68QJXjmA5RgrXRhBJfD5ssjudyrK775u7hoxLreBHvub/96Hck8unF5Ruo9PR n8tCHaJvLjw7nHE5vuaYEHRqo6f2ewjqscs7WuCNgECOeOTh35kDB3TJBkETCS2Cau2I r5fLlxi6CB3I5svHnbfIhV1QD9lFx1g0WiKJ1oUUku2zZ7Wjk06MgKb/LVg0P6iQhqHI P2vN9rnTYQL8IsAjZkVUMJqO31bUboFmqrzeVOqfKsM7wu+OODtN2G89T/imDoyw3m7M xUbA== X-Forwarded-Encrypted: i=1; AJvYcCUB3KF0MZRMd8NRYMinXbRsGZGcGF1KyTmnXw+pbuFRJP5KpP3/DKKNNI3JM84jktA8sG/FVVINB/t91vc=@vger.kernel.org X-Gm-Message-State: AOJu0YwG5IfaRHWekw5YwzqgxqmPBZb1nYOs14nSneHiBQHvfW+6QkIT c/yqJEajjh3jG0AnF5t5q3g2wcxewQFUKCW2VLlpX74LTkD8J601fMVKdvptAn17pFDE1uVdp9E /dGD2KxlnAg== X-Received: from dlbsw9.prod.google.com ([2002:a05:7022:3a89:b0:128:f497:319c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:31f:b0:127:5cfe:1ee0 with SMTP id a92af1059eb24-12a726b2844mr437271c88.21.1773962678957; Thu, 19 Mar 2026 16:24:38 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:26 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-18-irogers@google.com> Subject: [PATCH v2 17/25] perf kmem: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 19b12209fc08..ea2437971e8b 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -171,7 +171,7 @@ static int insert_caller_stat(unsigned long call_site, return 0; } =20 -static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sam= ple *sample) +static int evsel__process_alloc_event(struct perf_sample *sample) { unsigned long ptr =3D perf_sample__intval(sample, "ptr"), call_site =3D perf_sample__intval(sample, "call_site"); @@ -198,7 +198,7 @@ static int evsel__process_alloc_event(struct evsel *evs= el, struct perf_sample *s * If the tracepoint contains the field "node" the tool stats the * cross allocation. */ - if (evsel__field(evsel, "node")) { + if (evsel__field(sample->evsel, "node")) { int node1, node2; =20 node1 =3D cpu__get_node((struct perf_cpu){.cpu =3D sample->cpu}); @@ -243,7 +243,7 @@ static struct alloc_stat *search_alloc_stat(unsigned lo= ng ptr, return NULL; } =20 -static int evsel__process_free_event(struct evsel *evsel __maybe_unused, s= truct perf_sample *sample) +static int evsel__process_free_event(struct perf_sample *sample) { unsigned long ptr =3D perf_sample__intval(sample, "ptr"); struct alloc_stat *s_alloc, *s_caller; @@ -751,8 +751,7 @@ static char *compact_gfp_string(unsigned long gfp_flags) return NULL; } =20 -static int parse_gfp_flags(struct evsel *evsel, struct perf_sample *sample, - unsigned int gfp_flags) +static int parse_gfp_flags(struct perf_sample *sample, unsigned int gfp_fl= ags) { struct tep_record record =3D { .cpu =3D sample->cpu, @@ -773,7 +772,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, } =20 trace_seq_init(&seq); - tp_format =3D evsel__tp_format(evsel); + tp_format =3D evsel__tp_format(sample->evsel); if (tp_format) tep_print_event(tp_format->tep, &seq, &record, "%s", TEP_PRINT_INFO); =20 @@ -805,7 +804,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, return 0; } =20 -static int evsel__process_page_alloc_event(struct evsel *evsel, struct per= f_sample *sample) +static int evsel__process_page_alloc_event(struct perf_sample *sample) { u64 page; unsigned int order =3D perf_sample__intval(sample, "order"); @@ -836,7 +835,7 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp return 0; } =20 - if (parse_gfp_flags(evsel, sample, gfp_flags) < 0) + if (parse_gfp_flags(sample, gfp_flags) < 0) return -1; =20 callsite =3D find_callsite(sample); @@ -877,8 +876,7 @@ static int evsel__process_page_alloc_event(struct evsel= *evsel, struct perf_samp return 0; } =20 -static int evsel__process_page_free_event(struct evsel *evsel __maybe_unus= ed, - struct perf_sample *sample) +static int evsel__process_page_free_event(struct perf_sample *sample) { u64 page; unsigned int order =3D perf_sample__intval(sample, "order"); @@ -955,8 +953,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *= sample) return false; } =20 -typedef int (*tracepoint_handler)(struct evsel *evsel, - struct perf_sample *sample); +typedef int (*tracepoint_handler)(struct perf_sample *sample); =20 static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, @@ -981,7 +978,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - err =3D f(evsel, sample); + err =3D f(sample); } =20 thread__put(thread); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 8726A410D21 for ; Thu, 19 Mar 2026 23:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962684; cv=none; b=qON+1Bcnbd8vSjgEXYcYCrGjMM+IHUK57MnXua7V+YVDiNCTpuPFIBheBTUIq9yGPNRDgy6+WwA+VJz8gMNJ3F39VPpvrybNj8MSRWtdlVoQ676bCgOQtPtyExcwCacScGHSgmG5wKAbhtWSwPOFvcHIbCRrDBrqmqH1qY538HE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962684; c=relaxed/simple; bh=GJGmWir/z8tzqTHpefOip4Rhd2MnioF1X+iH6cT1a58=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jHQ20THfJew/H2otjTq42LgIkoJNuLboQmZmpcr4H98nGwO1WzxfrPB0dQvkUeLEGT0M6b8Ss0wnonU1bIvKOqvxmzIaJDzDDNiK8xDR7YVsSLnn8OG3xnRz7pzb6XTQrs97VwUgCowssscsZMWFuSt8L9imsooTJSwI8ahi3sU= 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=mbSlNyp5; arc=none smtp.client-ip=74.125.82.73 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="mbSlNyp5" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-127337c8e52so34474663c88.1 for ; Thu, 19 Mar 2026 16:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962682; x=1774567482; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dq9QvNkmP0NbbInrfNeTKB+bqbjxGKe/TZJ69fhqg+g=; b=mbSlNyp5THVsC+wJAaAxIjAY7NlNtt7mRTmdMN9vR2GkprcJR6sfsi1VuWgP/pXjSs wC1r4HLEHLUy6xNkKkoBzw9m1xHbKHhpzTc9tBMFWG/Zx6wzBR1tt/owJPbn4EEAiyCt tmqvKF8CjPb0HAzAVW+NAvdJ+MQyGW6q881DfPGCf8riUCC3nMKu0+wtBaO8/irx+Qjm Ex+54JLLiYThK2oBpnz65X0qYS1jXPMM1tMNPZE4OfWoNqBcMTo8l9FFjPryfFP8mQ0Y F+58M2S/ZOntTVhehHcF5AHl/yg0itfodExIjSSuRpvUJ2ejKSr9N9mpmOuiWQHlqOdR A82A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962682; x=1774567482; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dq9QvNkmP0NbbInrfNeTKB+bqbjxGKe/TZJ69fhqg+g=; b=P6jsYPmn+RjNf2NebCwtPrKczi8WWha58Ufo83dkEcWNRSpK5ddobhWdXbrB/7gyPU NsCR4xAa1EA3fV5JV10M3S2vZ4MHkf/xErqDwcP0x4tZGz7SmmDysv3dDjGeqYMMjIff ZcZlFNfGKsWbSnaMT7+zZh5FhvR1Xb5lh5f5WusNXbmsuwrNrfuqFKLjqids+NqwNE1M PuX/kYRaKLgKRcg+Jo99bkWjBZpMKI+h8kMxFomvYjhpCYy3yA60gUT2bR2om3lpAQoZ tH67Fp+OCy2fHwR7b7PfuTBuc9b6YSJlrGNKDWrh6CgoahzcoP32RbdurFTghbCP/nEe Fxcg== X-Forwarded-Encrypted: i=1; AJvYcCUCJGIUA9zuTjt69b2bKxzd0bTL31Fxthc2KqTesYOhD1Eay5EFMaTTiIO0xe8MJZ+N3cNEwGg9Fw62300=@vger.kernel.org X-Gm-Message-State: AOJu0YzIM840L04+uYJ5p1vkhvlcUS8kSUGlZqmBQbOwn6oGvMwcghXd DIM6CNCEW7+qeZ3qnHs6qW9LWd8qKtJKNTbXthNUEmJdQwWMglaBKtUHeuFtlsQDiPUoVw16pbl Z7FGXYcK4KA== X-Received: from dyw22.prod.google.com ([2002:a05:7300:8816:b0:2c0:d207:5bbf]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:6d22:b0:2ba:6723:5060 with SMTP id 5a478bee46e88-2c1097aeeb3mr631775eec.31.1773962681376; Thu, 19 Mar 2026 16:24:41 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:27 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-19-irogers@google.com> Subject: [PATCH v2 18/25] perf kwork: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Remove the evsel from struct kwork_class. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 74 +++++++++++++------------------------- tools/perf/util/kwork.h | 9 +++-- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 043da61cdcef..bbc6c209eb14 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -448,7 +448,6 @@ static int work_push_atom(struct perf_kwork *kwork, struct kwork_class *class, enum kwork_trace_type src_type, enum kwork_trace_type dst_type, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct kwork_work **ret_work, @@ -458,7 +457,7 @@ static int work_push_atom(struct perf_kwork *kwork, struct kwork_work *work, key; =20 BUG_ON(class->work_init =3D=3D NULL); - class->work_init(kwork, class, &key, src_type, evsel, sample, machine); + class->work_init(kwork, class, &key, src_type, sample, machine); =20 atom =3D atom_new(kwork, sample); if (atom =3D=3D NULL) @@ -507,7 +506,6 @@ static struct kwork_atom *work_pop_atom(struct perf_kwo= rk *kwork, struct kwork_class *class, enum kwork_trace_type src_type, enum kwork_trace_type dst_type, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct kwork_work **ret_work) @@ -516,7 +514,7 @@ static struct kwork_atom *work_pop_atom(struct perf_kwo= rk *kwork, struct kwork_work *work, key; =20 BUG_ON(class->work_init =3D=3D NULL); - class->work_init(kwork, class, &key, src_type, evsel, sample, machine); + class->work_init(kwork, class, &key, src_type, sample, machine); =20 work =3D work_findnew(&class->work_root, &key, &kwork->cmp_id); if (ret_work !=3D NULL) @@ -599,18 +597,16 @@ static void report_update_exit_event(struct kwork_wor= k *work, =20 static int report_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int report_exit_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -618,7 +614,7 @@ static int report_exit_event(struct perf_kwork *kwork, struct kwork_work *work =3D NULL; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (work =3D=3D NULL) return -1; @@ -654,18 +650,16 @@ static void latency_update_entry_event(struct kwork_w= ork *work, =20 static int latency_raise_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_RAISE, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int latency_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -673,7 +667,7 @@ static int latency_entry_event(struct perf_kwork *kwork, struct kwork_work *work =3D NULL; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_RAISE, evsel, sample, + KWORK_TRACE_RAISE, sample, machine, &work); if (work =3D=3D NULL) return -1; @@ -812,18 +806,16 @@ static void timehist_print_event(struct perf_kwork *k= work, =20 static int timehist_raise_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_RAISE, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int timehist_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -831,7 +823,7 @@ static int timehist_entry_event(struct perf_kwork *kwor= k, struct kwork_work *work =3D NULL; =20 ret =3D work_push_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_RAISE, evsel, sample, + KWORK_TRACE_RAISE, sample, machine, &work, true); if (ret) return ret; @@ -844,7 +836,6 @@ static int timehist_entry_event(struct perf_kwork *kwor= k, =20 static int timehist_exit_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -861,7 +852,7 @@ static int timehist_exit_event(struct perf_kwork *kwork, } =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (work =3D=3D NULL) { ret =3D -1; @@ -895,18 +886,16 @@ static void top_update_runtime(struct kwork_work *wor= k, =20 static int top_entry_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { return work_push_atom(kwork, class, KWORK_TRACE_ENTRY, - KWORK_TRACE_MAX, evsel, sample, + KWORK_TRACE_MAX, sample, machine, NULL, true); } =20 static int top_exit_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -915,7 +904,7 @@ static int top_exit_event(struct perf_kwork *kwork, struct kwork_atom *atom; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (!work) return -1; @@ -936,7 +925,6 @@ static int top_exit_event(struct perf_kwork *kwork, =20 static int top_sched_switch_event(struct perf_kwork *kwork, struct kwork_class *class, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -944,7 +932,7 @@ static int top_sched_switch_event(struct perf_kwork *kw= ork, struct kwork_work *work; =20 atom =3D work_pop_atom(kwork, class, KWORK_TRACE_EXIT, - KWORK_TRACE_ENTRY, evsel, sample, + KWORK_TRACE_ENTRY, sample, machine, &work); if (!work) return -1; @@ -954,12 +942,11 @@ static int top_sched_switch_event(struct perf_kwork *= kwork, atom_del(atom); } =20 - return top_entry_event(kwork, class, evsel, sample, machine); + return top_entry_event(kwork, class, sample, machine); } =20 static struct kwork_class kwork_irq; static int process_irq_handler_entry_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -967,12 +954,11 @@ static int process_irq_handler_entry_event(const stru= ct perf_tool *tool, =20 if (kwork->tp_handler->entry_event) return kwork->tp_handler->entry_event(kwork, &kwork_irq, - evsel, sample, machine); + sample, machine); return 0; } =20 static int process_irq_handler_exit_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -980,7 +966,7 @@ static int process_irq_handler_exit_event(const struct = perf_tool *tool, =20 if (kwork->tp_handler->exit_event) return kwork->tp_handler->exit_event(kwork, &kwork_irq, - evsel, sample, machine); + sample, machine); return 0; } =20 @@ -1005,7 +991,6 @@ static void irq_work_init(struct perf_kwork *kwork, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1038,7 +1023,6 @@ static struct kwork_class kwork_irq =3D { =20 static struct kwork_class kwork_softirq; static int process_softirq_raise_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1046,13 +1030,12 @@ static int process_softirq_raise_event(const struct= perf_tool *tool, =20 if (kwork->tp_handler->raise_event) return kwork->tp_handler->raise_event(kwork, &kwork_softirq, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_softirq_entry_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1060,13 +1043,12 @@ static int process_softirq_entry_event(const struct= perf_tool *tool, =20 if (kwork->tp_handler->entry_event) return kwork->tp_handler->entry_event(kwork, &kwork_softirq, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_softirq_exit_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1074,7 +1056,7 @@ static int process_softirq_exit_event(const struct pe= rf_tool *tool, =20 if (kwork->tp_handler->exit_event) return kwork->tp_handler->exit_event(kwork, &kwork_softirq, - evsel, sample, machine); + sample, machine); =20 return 0; } @@ -1133,7 +1115,6 @@ static void softirq_work_init(struct perf_kwork *kwor= k, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1148,7 +1129,7 @@ static void softirq_work_init(struct perf_kwork *kwor= k, } else { num =3D perf_sample__intval(sample, "vec"); work->id =3D num; - work->name =3D evsel__softirq_name(evsel, num); + work->name =3D evsel__softirq_name(sample->evsel, num); } } =20 @@ -1169,7 +1150,6 @@ static struct kwork_class kwork_softirq =3D { =20 static struct kwork_class kwork_workqueue; static int process_workqueue_activate_work_event(const struct perf_tool *t= ool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1177,13 +1157,12 @@ static int process_workqueue_activate_work_event(co= nst struct perf_tool *tool, =20 if (kwork->tp_handler->raise_event) return kwork->tp_handler->raise_event(kwork, &kwork_workqueue, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_workqueue_execute_start_event(const struct perf_tool *t= ool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1191,13 +1170,12 @@ static int process_workqueue_execute_start_event(co= nst struct perf_tool *tool, =20 if (kwork->tp_handler->entry_event) return kwork->tp_handler->entry_event(kwork, &kwork_workqueue, - evsel, sample, machine); + sample, machine); =20 return 0; } =20 static int process_workqueue_execute_end_event(const struct perf_tool *too= l, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1205,7 +1183,7 @@ static int process_workqueue_execute_end_event(const = struct perf_tool *tool, =20 if (kwork->tp_handler->exit_event) return kwork->tp_handler->exit_event(kwork, &kwork_workqueue, - evsel, sample, machine); + sample, machine); =20 return 0; } @@ -1233,7 +1211,6 @@ static void workqueue_work_init(struct perf_kwork *kw= ork __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1267,7 +1244,6 @@ static struct kwork_class kwork_workqueue =3D { =20 static struct kwork_class kwork_sched; static int process_sched_switch_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1275,7 +1251,7 @@ static int process_sched_switch_event(const struct pe= rf_tool *tool, =20 if (kwork->tp_handler->sched_switch_event) return kwork->tp_handler->sched_switch_event(kwork, &kwork_sched, - evsel, sample, machine); + sample, machine); return 0; } =20 @@ -1300,7 +1276,6 @@ static void sched_work_init(struct perf_kwork *kwork = __maybe_unused, struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -1946,7 +1921,6 @@ static int perf_kwork__report(struct perf_kwork *kwor= k) } =20 typedef int (*tracepoint_handler)(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -1961,7 +1935,7 @@ static int perf_kwork__process_tracepoint_sample(cons= t struct perf_tool *tool, if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; =20 - err =3D f(tool, evsel, sample, machine); + err =3D f(tool, sample, machine); } =20 return err; diff --git a/tools/perf/util/kwork.h b/tools/perf/util/kwork.h index db00269b73f2..abf637d44794 100644 --- a/tools/perf/util/kwork.h +++ b/tools/perf/util/kwork.h @@ -157,7 +157,6 @@ struct kwork_class { struct kwork_class *class, struct kwork_work *work, enum kwork_trace_type src_type, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -167,19 +166,19 @@ struct kwork_class { =20 struct trace_kwork_handler { int (*raise_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); =20 int (*entry_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); =20 int (*exit_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); =20 int (*sched_switch_event)(struct perf_kwork *kwork, - struct kwork_class *class, struct evsel *evsel, + struct kwork_class *class, struct perf_sample *sample, struct machine *machine); }; =20 --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.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 EF151411601 for ; Thu, 19 Mar 2026 23:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962686; cv=none; b=HPWQzZvZ4dLZZOvobYTcjWqftNHixC8FEKkmYJ0wIP6uT1XModNHUCkSjHtN/pz9nKwj3I4XI3ngMnUMpN1ombPhTQHzdhN46ndj/pkttpSZM82/un/5RU5ZriT2IO+sNGRkt1NRvzwEU2WLR1lMxakYw8ChWEb4aF57vZQg3k0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962686; c=relaxed/simple; bh=NSZutYu9IXwLiRY7oCOxEQOAo+GIIQHnWcOx7ulhb8M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=d2jvQ+0yCKsypk8jTkVg69MN4u39nuogQtvvlSv3/jTlnGHAizRzh9PR3xjkY7DiYkoLmcvbkOeDPwchmKSEUAaCNBgUuueDTOSRR97h/BpEXAVfR2TI2WHIp7qT4sOtAajvb3kIts2wyPoTyJzISp0Pie4v8Chc/jx0R88H588= 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=o5Bk9iVZ; arc=none smtp.client-ip=74.125.82.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="o5Bk9iVZ" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0ec884bffso107416eec.1 for ; Thu, 19 Mar 2026 16:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962684; x=1774567484; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TKCH+cdSZvjQddYwKOK4gXBAmhvFc/KmpRQzl0aK/io=; b=o5Bk9iVZtwLWNlUzVBNgryMGkgj5lZYy3ueu4ViNabwLepgDCDKETifLT/npLbL93/ sVAqQfNM3tgjTjg8MKD1x/9hHYl34eSzvEeJPTAMRKwbpYd94W+VrvGBSeslF8oAaKFO LaMBjNjRfDbvNZEPiR6UKOQeVt0x1fPxGy8noQh4KBJqlKNbnVowsOvf6iSJ/god+eID 7a4ePRfqHMxkjRnmqeYxLzBVJNHAEx26reFyPsqK+LSw1FnC7wYLS/I4BHOCmC/BKtEy O9Yfm9LOhSx30R0HP1t5Q8cqTBf2QMTttn7fmetC66oguTjFeGR+5FAozIxEgQr/Vd3e 4M9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962684; x=1774567484; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TKCH+cdSZvjQddYwKOK4gXBAmhvFc/KmpRQzl0aK/io=; b=Qbw66vo37BZf/pir4pxBMl4u8N9S7pnuuynIumUl2rsVo7akpYNm9d579oe59ObinR WlrqznDU1PpuumW+un1cRt9N5dfkIhRAvY08VhlukxkTONNE5s3O1XFmgIV2MPtcc9dg SY9965csmW2UNE74LOGfggMAeMVEOjgNVSwQ0iSAp6tjiUNGnQ1dQgqSsCYBqhAO0RdR 0S6J6yf+PjVQU31zKy7pVmpRNYrmLfhkSkxGtJf90cjyaECxtvjIDJztHsXMypVBy5hA 1OSuzmH/H1ecWQE7MKmQOzTNG7ZVCEFpXQdLf4rbnl/qEZ3xkBZN8/tdCHT0LZs5/OqN h6iQ== X-Forwarded-Encrypted: i=1; AJvYcCUXAn7MQUcrHTyimbjj9hhw20jkl7vz+ZHh/x7XMg76XUxf4fxzpyZ4qMBcI1JxOExfgIMV1/2ksT0xmN4=@vger.kernel.org X-Gm-Message-State: AOJu0YwgDu19z7YThUw8m1SsdQpEzD5Ic3+IWzLLCvkNVU5+aYghs+pG wCPBbSdDsoONhaQ0zUz/EZq1u5988SRkGGmE8W6Tc0yerV94jG3x7ajVJ4SlVU+z0g3d/c+iUSc os8dXmJ/Hyg== X-Received: from dlbcy23.prod.google.com ([2002:a05:7022:b97:b0:127:2073:9a6d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:226:b0:128:d51a:5157 with SMTP id a92af1059eb24-12a726cfa7bmr401475c88.33.1773962683839; Thu, 19 Mar 2026 16:24:43 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:28 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-20-irogers@google.com> Subject: [PATCH v2 19/25] perf sched: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 92 ++++++++++++++------------------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 854e29bbd6a9..ad397c6766a2 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -129,21 +129,20 @@ typedef int (*sort_fn_t)(struct work_atoms *, struct = work_atoms *); struct perf_sched; =20 struct trace_sched_handler { - int (*switch_event)(struct perf_sched *sched, struct evsel *evsel, - struct perf_sample *sample, struct machine *machine); + int (*switch_event)(struct perf_sched *sched, struct perf_sample *sample, + struct machine *machine); =20 - int (*runtime_event)(struct perf_sched *sched, struct evsel *evsel, - struct perf_sample *sample, struct machine *machine); + int (*runtime_event)(struct perf_sched *sched, struct perf_sample *sample, + struct machine *machine); =20 - int (*wakeup_event)(struct perf_sched *sched, struct evsel *evsel, - struct perf_sample *sample, struct machine *machine); + int (*wakeup_event)(struct perf_sched *sched, struct perf_sample *sample, + struct machine *machine); =20 /* PERF_RECORD_FORK event, not sched_process_fork tracepoint */ int (*fork_event)(struct perf_sched *sched, union perf_event *event, struct machine *machine); =20 int (*migrate_task_event)(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); }; @@ -826,7 +825,7 @@ static void test_calibrations(struct perf_sched *sched) =20 static int replay_wakeup_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, + struct perf_sample *sample, struct machine *machine __maybe_unused) { const char *comm =3D perf_sample__strval(sample, "comm"); @@ -834,7 +833,7 @@ replay_wakeup_event(struct perf_sched *sched, struct task_desc *waker, *wakee; =20 if (verbose > 0) { - printf("sched_wakeup event %p\n", evsel); + printf("sched_wakeup event %p\n", sample->evsel); =20 printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid); } @@ -847,7 +846,6 @@ replay_wakeup_event(struct perf_sched *sched, } =20 static int replay_switch_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { @@ -861,7 +859,7 @@ static int replay_switch_event(struct perf_sched *sched, s64 delta; =20 if (verbose > 0) - printf("sched_switch event %p\n", evsel); + printf("sched_switch event %p\n", sample->evsel); =20 if (cpu >=3D MAX_CPUS || cpu < 0) return 0; @@ -1134,7 +1132,6 @@ static void free_work_atoms(struct work_atoms *atoms) } =20 static int latency_switch_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1204,7 +1201,6 @@ static int latency_switch_event(struct perf_sched *sc= hed, } =20 static int latency_runtime_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1239,7 +1235,6 @@ static int latency_runtime_event(struct perf_sched *s= ched, } =20 static int latency_wakeup_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1300,7 +1295,6 @@ static int latency_wakeup_event(struct perf_sched *sc= hed, } =20 static int latency_migrate_task_event(struct perf_sched *sched, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, struct machine *machine) { @@ -1519,20 +1513,18 @@ static void perf_sched__sort_lat(struct perf_sched = *sched) } =20 static int process_sched_wakeup_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 if (sched->tp_handler->wakeup_event) - return sched->tp_handler->wakeup_event(sched, evsel, sample, machine); + return sched->tp_handler->wakeup_event(sched, sample, machine); =20 return 0; } =20 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) { @@ -1626,8 +1618,8 @@ static void print_sched_map(struct perf_sched *sched,= struct perf_cpu this_cpu, } } =20 -static int map_switch_event(struct perf_sched *sched, struct evsel *evsel = __maybe_unused, - struct perf_sample *sample, struct machine *machine) +static int map_switch_event(struct perf_sched *sched, struct perf_sample = *sample, + struct machine *machine) { const u32 next_pid =3D perf_sample__intval(sample, "next_pid"); const u32 prev_pid =3D perf_sample__intval(sample, "prev_pid"); @@ -1791,7 +1783,6 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel __mayb } =20 static int process_sched_switch_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -1810,21 +1801,20 @@ static int process_sched_switch_event(const struct = perf_tool *tool, } =20 if (sched->tp_handler->switch_event) - err =3D sched->tp_handler->switch_event(sched, evsel, sample, machine); + err =3D sched->tp_handler->switch_event(sched, sample, machine); =20 sched->curr_pid[this_cpu] =3D next_pid; return err; } =20 static int process_sched_runtime_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 if (sched->tp_handler->runtime_event) - return sched->tp_handler->runtime_event(sched, evsel, sample, machine); + return sched->tp_handler->runtime_event(sched, sample, machine); =20 return 0; } @@ -1847,20 +1837,18 @@ static int perf_sched__process_fork_event(const str= uct perf_tool *tool, } =20 static int process_sched_migrate_task_event(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { struct perf_sched *sched =3D container_of(tool, struct perf_sched, tool); =20 if (sched->tp_handler->migrate_task_event) - return sched->tp_handler->migrate_task_event(sched, evsel, sample, machi= ne); + return sched->tp_handler->migrate_task_event(sched, sample, machine); =20 return 0; } =20 typedef int (*tracepoint_handler)(const struct perf_tool *tool, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -1874,7 +1862,7 @@ static int perf_sched__process_tracepoint_sample(cons= t struct perf_tool *tool __ =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - err =3D f(tool, evsel, sample, machine); + err =3D f(tool, sample, machine); } =20 return err; @@ -2313,11 +2301,10 @@ static void timehist_update_runtime_stats(struct th= read_runtime *r, r->total_pre_mig_time +=3D r->dt_pre_mig; } =20 -static bool is_idle_sample(struct perf_sample *sample, - struct evsel *evsel) +static bool is_idle_sample(struct perf_sample *sample) { /* pid 0 =3D=3D swapper =3D=3D idle task */ - if (evsel__name_is(evsel, "sched:sched_switch")) + if (evsel__name_is(sample->evsel, "sched:sched_switch")) return perf_sample__intval(sample, "prev_pid") =3D=3D 0; =20 return sample->pid =3D=3D 0; @@ -2499,12 +2486,11 @@ static void save_idle_callchain(struct perf_sched *= sched, =20 static struct thread *timehist_get_thread(struct perf_sched *sched, struct perf_sample *sample, - struct machine *machine, - struct evsel *evsel) + struct machine *machine) { struct thread *thread; =20 - if (is_idle_sample(sample, evsel)) { + if (is_idle_sample(sample)) { thread =3D get_idle_thread(sample->cpu); if (thread =3D=3D NULL) pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); @@ -2547,7 +2533,6 @@ static struct thread *timehist_get_thread(struct perf= _sched *sched, =20 static bool timehist_skip_sample(struct perf_sched *sched, struct thread *thread, - struct evsel *evsel, struct perf_sample *sample) { bool rc =3D false; @@ -2569,7 +2554,7 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, tr =3D thread__get_runtime(thread); if (tr && tr->prio !=3D -1) prio =3D tr->prio; - else if (evsel__name_is(evsel, "sched:sched_switch")) + else if (evsel__name_is(sample->evsel, "sched:sched_switch")) prio =3D perf_sample__intval(sample, "prev_prio"); =20 if (prio !=3D -1 && !test_bit(prio, sched->prio_bitmap)) { @@ -2579,7 +2564,7 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, } =20 if (sched->idle_hist) { - if (!evsel__name_is(evsel, "sched:sched_switch")) + if (!evsel__name_is(sample->evsel, "sched:sched_switch")) rc =3D true; else if (perf_sample__intval(sample, "prev_pid") !=3D 0 && perf_sample__intval(sample, "next_pid") !=3D 0) @@ -2590,7 +2575,6 @@ static bool timehist_skip_sample(struct perf_sched *s= ched, } =20 static void timehist_print_wakeup_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct thread *awakened) @@ -2603,8 +2587,8 @@ static void timehist_print_wakeup_event(struct perf_s= ched *sched, return; =20 /* show wakeup unless both awakee and awaker are filtered */ - if (timehist_skip_sample(sched, thread, evsel, sample) && - timehist_skip_sample(sched, awakened, evsel, sample)) { + if (timehist_skip_sample(sched, thread, sample) && + timehist_skip_sample(sched, awakened, sample)) { thread__put(thread); return; } @@ -2628,7 +2612,6 @@ static void timehist_print_wakeup_event(struct perf_s= ched *sched, =20 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, struct machine *machine __maybe_unused) { @@ -2637,7 +2620,6 @@ static int timehist_sched_wakeup_ignore(const struct = perf_tool *tool __maybe_unu =20 static int timehist_sched_wakeup_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -2663,14 +2645,13 @@ static int timehist_sched_wakeup_event(const struct= perf_tool *tool, /* show wakeups if requested */ if (sched->show_wakeups && !perf_time__skip_sample(&sched->ptime, sample->time)) - timehist_print_wakeup_event(sched, evsel, sample, machine, thread); + timehist_print_wakeup_event(sched, sample, machine, thread); =20 thread__put(thread); return 0; } =20 static void timehist_print_migration_event(struct perf_sched *sched, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine, struct thread *migrated) @@ -2691,8 +2672,8 @@ static void timehist_print_migration_event(struct per= f_sched *sched, if (thread =3D=3D NULL) return; =20 - if (timehist_skip_sample(sched, thread, evsel, sample) && - timehist_skip_sample(sched, migrated, evsel, sample)) { + if (timehist_skip_sample(sched, thread, sample) && + timehist_skip_sample(sched, migrated, sample)) { thread__put(thread); return; } @@ -2726,7 +2707,6 @@ static void timehist_print_migration_event(struct per= f_sched *sched, =20 static int timehist_migrate_task_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -2751,8 +2731,7 @@ static int timehist_migrate_task_event(const struct p= erf_tool *tool, =20 /* show migrations if requested */ if (sched->show_migrations) { - timehist_print_migration_event(sched, evsel, sample, - machine, thread); + timehist_print_migration_event(sched, sample, machine, thread); } thread__put(thread); =20 @@ -2784,7 +2763,6 @@ static void timehist_update_task_prio(struct perf_sam= ple *sample, =20 static int timehist_sched_change_event(const struct perf_tool *tool, union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { @@ -2808,13 +2786,13 @@ static int timehist_sched_change_event(const struct= perf_tool *tool, if (sched->show_prio || sched->prio_str) timehist_update_task_prio(sample, machine); =20 - thread =3D timehist_get_thread(sched, sample, machine, evsel); + thread =3D timehist_get_thread(sched, sample, machine); if (thread =3D=3D NULL) { rc =3D -1; goto out; } =20 - if (timehist_skip_sample(sched, thread, evsel, sample)) + if (timehist_skip_sample(sched, thread, sample)) goto out; =20 tr =3D thread__get_runtime(thread); @@ -2823,7 +2801,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, goto out; } =20 - tprev =3D evsel__get_time(evsel, sample->cpu); + tprev =3D evsel__get_time(sample->evsel, sample->cpu); =20 /* * If start time given: @@ -2913,7 +2891,7 @@ static int timehist_sched_change_event(const struct p= erf_tool *tool, tr->migrated =3D 0; } =20 - evsel__save_time(evsel, sample->time, sample->cpu); + evsel__save_time(sample->evsel, sample->time, sample->cpu); =20 thread__put(thread); addr_location__exit(&al); @@ -2922,11 +2900,10 @@ static int timehist_sched_change_event(const struct= perf_tool *tool, =20 static int timehist_sched_switch_event(const struct perf_tool *tool, union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine __maybe_unused) { - return timehist_sched_change_event(tool, event, evsel, sample, machine); + return timehist_sched_change_event(tool, event, sample, machine); } =20 static int process_lost(const struct perf_tool *tool __maybe_unused, @@ -3174,7 +3151,6 @@ static void timehist_print_summary(struct perf_sched = *sched, =20 typedef int (*sched_handler)(const struct perf_tool *tool, union perf_event *event, - struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 @@ -3196,7 +3172,7 @@ static int perf_timehist__process_sample(const struct= perf_tool *tool, if (evsel->handler !=3D NULL) { sched_handler f =3D evsel->handler; =20 - err =3D f(tool, event, evsel, sample, machine); + err =3D f(tool, event, sample, machine); } =20 return err; --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 6BEE0411618 for ; Thu, 19 Mar 2026 23:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962688; cv=none; b=m0OzvFPnE64hwJOtTPU9CWPQwLkfvjg6nHwibFDO9XavJ4oUxx2bsq67QTWkpqkBrpL2Xp8kuunx0rmWJ6BP/r8+ZKwO1vKf4zWHUVxw7Zra56YdWVflrEYd596AeYmAOHsP2pQ8dNdYZwjO1LiGxBzCKLm7S2PxoOxr6KgsLjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962688; c=relaxed/simple; bh=P8KDmNQFrM0XR+mgWRTGutdGK2cdbUvdj6uQlGb++3k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=W8CaAb/uCW029aeFUliEhoVJyWCmoVu9AgibD4KjjYiWZP0TeoOp6t2Ya2SYIpjrjJnq/ON4SW+VKM9Xq4whVHeU0266GRbSG8iVGhxM/LFkC2UN+ns1V1x0NvFJXmTsukgwAA7jCjr2HRYI7H1BuIWWWDg3iWFLShnuNwf5qt4= 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=qKBG0kiI; arc=none smtp.client-ip=74.125.82.74 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="qKBG0kiI" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127133794b6so1319874c88.1 for ; Thu, 19 Mar 2026 16:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962687; x=1774567487; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mqHnahhuT1GAymhjowNR84SadXg0EkK+QwbF+RTjHSA=; b=qKBG0kiIuGSN4DtjgSCDKF3zdqanHEpK0fm4AjhAuh4FS+V3orqf/OVQb/QRPSu3HI ChIcb79CtfxP4NEqo5URaky+b0RpZzGGkR1JBA9Frv8X52dc9D52EPg4jQqPIU5pfLQr yWseC+jOIXkP1xY3PddC8mLvHOjucocjy1NTS/I+SrRii07PNyGVtk/tndOTwEfnPV4d X2te7yTxezw2UOHx8lXmBbq5gQDF1F3opcNAoKpgmm1QvKt24OCLZP5jZIi/sJPjffCt dmsxcI8ap3jcTTmiW2a8fQlGjl0O3au79ZJfL6vNxXw22Hbvt1Zh2eq1YfKQ7yKIC1AE VeFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962687; x=1774567487; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mqHnahhuT1GAymhjowNR84SadXg0EkK+QwbF+RTjHSA=; b=HTTUfbWp1wiZd9yGzezVYLk2ZaBdWNuwbBH+CkhjcR5Mb+E9P08FDKXG/7+9lWpMF2 CffmsX4MzjfVaHdSTMKGG0CiwXuPqIw695PdO1/fWQnLOGw/J2xeN6i68tdKdo1WKREV J2UdjKZe5cdwaWxPVaaEd0QyjPdJzBMUVql41irBtgIS61AZCsX1ApvcIePGbeaLuIbe z0WoptwdmRghbuxuouGBbxoAdEv+97deJ5dzGIXq8XHw1L2EHKD3AcSOuv9M64RZeO9J M6gq8zXRpdV70jPlgbImXRxBAvLrw5afQ7Rw0a9+11/MJAo9Gx0ZOw2R2xz04dBpPNzG Imiw== X-Forwarded-Encrypted: i=1; AJvYcCWZoP0rkbNQQM72BsqD8gSTsvTCrbLOWshM5+W6LEaxPFvDGyiDGPoEHyubBJs+iuA8Oyd8fFbkOkRy85I=@vger.kernel.org X-Gm-Message-State: AOJu0YwcVS+aRSsyM6kG01PNXUlq7/QKNCDYRaz39F75zXkXR/CTLchm 4AbwPXbFkS63WDsmi83Ir6fVA8+cMKliPpXiWQb5BawTC+/5AehHx6I9vfe371gVePcgYLbGA9L 4Puuwo3Kq1A== X-Received: from dybgi3.prod.google.com ([2002:a05:7301:83:b0:2c0:fbcb:769c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:e2cb:b0:2c0:dd99:f11 with SMTP id 5a478bee46e88-2c1097589e5mr602979eec.22.1773962686434; Thu, 19 Mar 2026 16:24:46 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:29 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-21-irogers@google.com> Subject: [PATCH v2 20/25] perf timechart: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 034e0ba3f9cb..de551c9d3053 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -567,7 +567,6 @@ static const char *cat_backtrace(union perf_event *even= t, } =20 typedef int (*tracepoint_handler)(struct timechart *tchart, - struct evsel *evsel, struct perf_sample *sample, const char *backtrace); =20 @@ -588,7 +587,7 @@ static int process_sample_event(const struct perf_tool = *tool, =20 if (evsel->handler !=3D NULL) { tracepoint_handler f =3D evsel->handler; - return f(tchart, evsel, sample, + return f(tchart, sample, cat_backtrace(event, sample, machine)); } =20 @@ -597,7 +596,6 @@ static int process_sample_event(const struct perf_tool = *tool, =20 static int process_sample_cpu_idle(struct timechart *tchart __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -613,7 +611,6 @@ process_sample_cpu_idle(struct timechart *tchart __mayb= e_unused, =20 static int process_sample_cpu_frequency(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -626,7 +623,6 @@ process_sample_cpu_frequency(struct timechart *tchart, =20 static int process_sample_sched_wakeup(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { @@ -640,7 +636,6 @@ process_sample_sched_wakeup(struct timechart *tchart, =20 static int process_sample_sched_switch(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace) { @@ -656,7 +651,6 @@ process_sample_sched_switch(struct timechart *tchart, #ifdef SUPPORT_OLD_POWER_EVENTS static int process_sample_power_start(struct timechart *tchart __maybe_unused, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -669,7 +663,6 @@ process_sample_power_start(struct timechart *tchart __m= aybe_unused, =20 static int process_sample_power_end(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -679,7 +672,6 @@ process_sample_power_end(struct timechart *tchart, =20 static int process_sample_power_frequency(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample, const char *backtrace __maybe_unused) { @@ -849,7 +841,6 @@ static int pid_end_io_sample(struct timechart *tchart, = int pid, int type, =20 static int process_enter_read(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long fd =3D perf_sample__intval(sample, "fd"); @@ -859,7 +850,6 @@ process_enter_read(struct timechart *tchart, =20 static int process_exit_read(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long ret =3D perf_sample__intval(sample, "ret"); @@ -869,7 +859,6 @@ process_exit_read(struct timechart *tchart, =20 static int process_enter_write(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long fd =3D perf_sample__intval(sample, "fd"); @@ -879,7 +868,6 @@ process_enter_write(struct timechart *tchart, =20 static int process_exit_write(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long ret =3D perf_sample__intval(sample, "ret"); @@ -889,7 +877,6 @@ process_exit_write(struct timechart *tchart, =20 static int process_enter_sync(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long fd =3D perf_sample__intval(sample, "fd"); @@ -899,7 +886,6 @@ process_enter_sync(struct timechart *tchart, =20 static int process_exit_sync(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long ret =3D perf_sample__intval(sample, "ret"); @@ -909,7 +895,6 @@ process_exit_sync(struct timechart *tchart, =20 static int process_enter_tx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long fd =3D perf_sample__intval(sample, "fd"); @@ -919,7 +904,6 @@ process_enter_tx(struct timechart *tchart, =20 static int process_exit_tx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long ret =3D perf_sample__intval(sample, "ret"); @@ -929,7 +913,6 @@ process_exit_tx(struct timechart *tchart, =20 static int process_enter_rx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long fd =3D perf_sample__intval(sample, "fd"); @@ -939,7 +922,6 @@ process_enter_rx(struct timechart *tchart, =20 static int process_exit_rx(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long ret =3D perf_sample__intval(sample, "ret"); @@ -949,7 +931,6 @@ process_exit_rx(struct timechart *tchart, =20 static int process_enter_poll(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long fd =3D perf_sample__intval(sample, "fd"); @@ -959,7 +940,6 @@ process_enter_poll(struct timechart *tchart, =20 static int process_exit_poll(struct timechart *tchart, - struct evsel *evsel __maybe_unused, struct perf_sample *sample) { long ret =3D perf_sample__intval(sample, "ret"); --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 D615341163F for ; Thu, 19 Mar 2026 23:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962691; cv=none; b=SzDhvQPkBvnYM4BxtE8FVK9L25y4tW8zOsvHed/25F1HmAesF3B6SFIcUBUbbB5HomHCtSobo+wc8PB9IzGZddso6QOXjgMEFahlDi3tson+l0Irqpv+f+i0z+VZ6ugoFckYlAMp9c2GkzgL4J2/xFrg4ZKVLbLRT9lhS5fR1rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962691; c=relaxed/simple; bh=3n96E9V/4QhhKs4hWAjfN7C8Br55p1AJ1VBaBO3fk2Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=g6kpiAuDoxCp/Ulb5Ne2iV2PaQCE1ym2lFac5fk9phXsrUUImmvmKMWXeJul7yteASX3ERGwllAWtFgX39nfUs8aZVDFTYaLvMarAybxqYA50E0ZT6xSewj8/nMXgq9vqhkJyBF/LjBusJL9pGHt8Hvqqc+dCbeeorJaCSl61gc= 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=U+iGpN7h; arc=none smtp.client-ip=74.125.82.73 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="U+iGpN7h" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1279caef718so1973529c88.1 for ; Thu, 19 Mar 2026 16:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962689; x=1774567489; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=imsNgYZdY1tqbGGPfOlwwoZDMdJ12rSBPWNrXkSgWrs=; b=U+iGpN7h2qyyAmxey0iFQ6DNX58j3KvzAqWU4ttNO3B1Ov0V50q4D5XpBse5QLMWIf mLFqiisBsg3CkDMiTLbaqnPfT9vHFfRHiUZrmp1RYgcJQakimHeBzXLmDQL55U+BQceb PRmJoo+YX+YLBmtOMNoGCngtT03vt5/wzVVJzIFl+0QwOfRrWRQ2ilmWGJTioZmtsj16 xPZoIcrpEpee9y4WfGLWqWVDu+ql1nEiuls1XQMOXxzV9tDYO6bVxcyKQUUtn7HZLEir EuU4j80Xqq9H3NS67mG65bn3pfiY6X1m/1QR17gl1p55S1gDS5B8/Xbh1QMRyLp4voul uSYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962689; x=1774567489; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=imsNgYZdY1tqbGGPfOlwwoZDMdJ12rSBPWNrXkSgWrs=; b=KFLWcODH1znStEBapdHf9deHENgYsOgBQzl0AwylYAlH3e83QtGe2rHePM+HIPQXiw r2XN3b8RTlYIvnxeTXDYcvduwAvxZYunA8/Hx4inN89hAl/TgFKN7slFrv8pV/RtIyvq Tcxd6Idf26+71kKSmJS0iwxO0mPyD91ZYZWrOr7UkjGxJeuv1F8f4ezKiEwR+FO2Vev0 rlvaWnSGUjQvaIIxqNGlwn+0se+hk235hOUlGM04ywvWM2PN+7EjTpM4kb+UkmFqPiKa 1Hj2HbO0mFr3QCvxtL2hN0LSihthfTCXJYXkzkt1VX2xWFWCdi9FS6V/vUSv9+WoBv1L Peuw== X-Forwarded-Encrypted: i=1; AJvYcCVXsGGHLCaHuTqmH9gXmEYf5k3J+AzhlRR059iFno9J1poQE/9yQa/HKtsO6RUSUHwgqSPaDHrL9A3pY4M=@vger.kernel.org X-Gm-Message-State: AOJu0YzVxsny0mn6mw4GWvVLPdossdJI8WSIFqrQxROuK8Z1iOHpHhgF l2B2xu063JcEwpLkS7q41J+fMhjKgc82PZR9hnbS0o5yaHSH8CVpq1aod6/RghApAexz0zNp7UG vDiOoHTT8CQ== X-Received: from dyblf40.prod.google.com ([2002:a05:7301:a28:b0:2c0:e2b8:48ba]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:3b0b:b0:2c0:be45:6811 with SMTP id 5a478bee46e88-2c1097ae93bmr534509eec.32.1773962688847; Thu, 19 Mar 2026 16:24:48 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:30 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-22-irogers@google.com> Subject: [PATCH v2 21/25] perf trace: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. In trace__handle_event try to use the evsel from the sample to avoid recomputation. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 385a9ac2ae96..c4ec4f603d5f 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2580,7 +2580,7 @@ static struct syscall *trace__find_syscall(struct tra= ce *trace, int e_machine, i return sc; } =20 -typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel, +typedef int (*tracepoint_handler)(struct trace *trace, union perf_event *event, struct perf_sample *sample); =20 @@ -2775,10 +2775,11 @@ static void *syscall__augmented_args(struct syscall= *sc, struct perf_sample *sam return NULL; } =20 -static int trace__sys_enter(struct trace *trace, struct evsel *evsel, +static int trace__sys_enter(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; char *msg; void *args; int printed =3D 0; @@ -2921,10 +2922,11 @@ static int trace__fprintf_callchain(struct trace *t= race, struct perf_sample *sam return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchai= n_cursor(), symbol_conf.bt_stop_list, trace->output); } =20 -static int trace__sys_exit(struct trace *trace, struct evsel *evsel, +static int trace__sys_exit(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; long ret; u64 duration =3D 0; bool duration_calculated =3D false; @@ -3059,7 +3061,7 @@ errno_print: { return err; } =20 -static int trace__vfs_getname(struct trace *trace, struct evsel *evsel __m= aybe_unused, +static int trace__vfs_getname(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3120,7 +3122,7 @@ static int trace__vfs_getname(struct trace *trace, st= ruct evsel *evsel __maybe_u return 0; } =20 -static int trace__sched_stat_runtime(struct trace *trace, struct evsel *ev= sel, +static int trace__sched_stat_runtime(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { @@ -3142,7 +3144,7 @@ static int trace__sched_stat_runtime(struct trace *tr= ace, struct evsel *evsel, =20 out_dump: fprintf(trace->output, "%s: comm=3D%s,pid=3D%u,runtime=3D%" PRIu64 ",vrun= time=3D%" PRIu64 ")\n", - evsel->name, + sample->evsel->name, perf_sample__strval(sample, "comm"), (pid_t)perf_sample__intval(sample, "pid"), runtime, @@ -3253,10 +3255,11 @@ static size_t trace__fprintf_tp_fields(struct trace= *trace, struct perf_sample * return fprintf(trace->output, "%.*s", (int)printed, bf); } =20 -static int trace__event_handler(struct trace *trace, struct evsel *evsel, +static int trace__event_handler(struct trace *trace, union perf_event *event __maybe_unused, struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; struct thread *thread; int callchain_ret =3D 0; =20 @@ -3444,7 +3447,6 @@ static int trace__pgfault(struct trace *trace, } =20 static void trace__set_base_time(struct trace *trace, - struct evsel *evsel, struct perf_sample *sample) { /* @@ -3456,7 +3458,7 @@ static void trace__set_base_time(struct trace *trace, * appears in our event stream (vfs_getname comes to mind). */ if (trace->base_time =3D=3D 0 && !trace->full_time && - (evsel->core.attr.sample_type & PERF_SAMPLE_TIME)) + (sample->evsel->core.attr.sample_type & PERF_SAMPLE_TIME)) trace->base_time =3D sample->time; } =20 @@ -3476,11 +3478,11 @@ static int trace__process_sample(const struct perf_= tool *tool, if (thread && thread__is_filtered(thread)) goto out; =20 - trace__set_base_time(trace, evsel, sample); + trace__set_base_time(trace, sample); =20 if (handler) { ++trace->nr_events; - handler(trace, evsel, event, sample); + handler(trace, event, sample); } out: thread__put(thread); @@ -3622,14 +3624,16 @@ static void evlist__free_syscall_tp_fields(struct e= vlist *evlist) static void trace__handle_event(struct trace *trace, union perf_event *eve= nt, struct perf_sample *sample) { const u32 type =3D event->header.type; - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; =20 if (type !=3D PERF_RECORD_SAMPLE) { trace__process_event(trace, trace->host, event, sample); return; } =20 - evsel =3D evlist__id2evsel(trace->evlist, sample->id); + if (evsel =3D=3D NULL) + evsel =3D evlist__id2evsel(trace->evlist, sample->id); + if (evsel =3D=3D NULL) { fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sampl= e->id); return; @@ -3638,7 +3642,7 @@ static void trace__handle_event(struct trace *trace, = union perf_event *event, st if (evswitch__discard(&trace->evswitch, evsel)) return; =20 - trace__set_base_time(trace, evsel, sample); + trace__set_base_time(trace, sample); =20 if (evsel->core.attr.type =3D=3D PERF_TYPE_TRACEPOINT && sample->raw_data =3D=3D NULL) { @@ -3647,7 +3651,7 @@ static void trace__handle_event(struct trace *trace, = union perf_event *event, st sample->cpu, sample->raw_size); } else { tracepoint_handler handler =3D evsel->handler; - handler(trace, evsel, event, sample); + handler(trace, event, sample); } =20 if (trace->nr_events_printed >=3D trace->max_events && trace->max_events = !=3D ULONG_MAX) --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.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 4AE0341325A for ; Thu, 19 Mar 2026 23:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962693; cv=none; b=e3GMKNyWzt7uL37wLcKadnKe/iNJ9D1Evo62OEMp/55UDpc79fU1056dl0/kaelrF8yfHpeWaSp553kFs1EMv5pjg4q+ByxJWZbbemd5OWQ2Rp9lLZ+nMQXgAWlTxNL+/58hysPb2tmpsDSPNvfbuAwJfXbrvpUpFgGJcwTj1eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962693; c=relaxed/simple; bh=nQKlfJP7iPPRZwHgkfibxtIFOBIy32Z3EoTWSHNa2g4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rgp6X3WJPu4gNN+W9y3JMXD237BzsHx7qFmCttOP2wc/X94tsEObfCwrqE8jsv5u1f11Bp334Sa5ZyaZ67T1QCcMo3cRTBVlncSqFRikgnmLetdQZjFvfEAzDkq8zb3RXBB8Ppnm3TjkKk5I1t6SKXCt4x3W8Xd8jEyB+1zlC4o= 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=bbB+PiVG; arc=none smtp.client-ip=74.125.82.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="bbB+PiVG" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0fb39b41aso2237392eec.0 for ; Thu, 19 Mar 2026 16:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962692; x=1774567492; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M9pkC5P8S36AmhD0fZGvAVfRmdPNACn5tpVw32aG+t0=; b=bbB+PiVGpqyluVoAilICVjx6zvZ5vslZJUuSBfoxnyruQuOJrZj1szIOcKIvZ4jAHE dMzw+7nNHoD8xlq1/TepyKJ2VICe/UEdrhtSyZlQzV9C2K0OI65SgPoGmGBgj7c6qtfl 8n0RSWJO42XDKNDWdJdTTbcMdLbD1JNH1efeiMbukazAzP3/BaOuKEXBV9sgroyTHQAK iKmQFMKjoHAcpXqT2VCd1X443BWMqXciQO4fgygQHUZ18HOSm3m5FPwq1khP1ktjtOcZ eM0rTvYTh/non9ePk3hBuLH+tg0fRWybaYpMY4Pd4ApFuHTUn/KSrMVPclBf7nW47Ydk gL7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962692; x=1774567492; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M9pkC5P8S36AmhD0fZGvAVfRmdPNACn5tpVw32aG+t0=; b=ZI/O69smGM9Sxwid90bi3M36DVcOJjKcMHGuFGCsSzXKlUVtKGWvBnxNcfv28+cD8N acziuaBhBB4ZWmTa12Cl9SJ86lGT+rEPwCv9YPiqmMShJy+OVL6gZV0Iwu9m4lsKC/0p xaaUSSUPFk4xTpKjIm13/bU86imHdi9T0vWMJB9PPXF2GhpQumXWoeoR5daa80eiYvO3 ywgL1LKDNq8rrwWvYpQ6YJiaxvwWJGSRJAcZ35uyoVo3W+zT2WzZmdB6QxyrdwtJJ0F1 qDoh7sfd5rNMiOkjxIk14RneEPu3ZPsBAKcO4MazaqabohQuJ1LjjbvYgJKRLJ/Huw5o g+ug== X-Forwarded-Encrypted: i=1; AJvYcCVTRn+fO3n0M0FTtDRTjskr0unKR4YUndeJJvFqwPUARuf2jGtkjsUpPC6WYjUJfAvgZo17GwcvmcCTSBc=@vger.kernel.org X-Gm-Message-State: AOJu0YygRjyqOYzw+h4uDMtSBwcmr4EVqHBSqg9O7adzymxiJ3RoO9W4 sslTG+ePhfLeAM5zH+eu/kYDBntXHf9jXiPFufpIuB2b7FVgR9eRQmR/A/3isT0fBvMYUMId0CQ s3va0zH69mg== X-Received: from dybso14.prod.google.com ([2002:a05:7301:690e:b0:2c0:b988:33bc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:2216:b0:2be:2cfe:68b7 with SMTP id 5a478bee46e88-2c109622b94mr560778eec.11.1773962691319; Thu, 19 Mar 2026 16:24:51 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:31 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-23-irogers@google.com> Subject: [PATCH v2 22/25] perf evlist: Try to avoid computing evsel from sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the sample has an evsel, don't recompute using the sample.id. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 5 +++-- tools/perf/builtin-top.c | 4 +++- tools/perf/tests/mmap-basic.c | 4 +++- tools/perf/tests/switch-tracking.c | 5 ++++- tools/perf/util/intel-pt.c | 10 +++++++--- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 6e265b66a551..9ea082bccbe6 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -1693,11 +1693,12 @@ static int guest_session__fetch(struct guest_sessio= n *gs) static int evlist__append_id_sample(struct evlist *evlist, union perf_even= t *ev, const struct perf_sample *sample) { - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; void *array; int ret; =20 - evsel =3D evlist__id2evsel(evlist, sample->id); + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample->id); array =3D ev; =20 if (!evsel) { diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index b89ca48e5d02..faa422e35166 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1163,7 +1163,9 @@ static int deliver_event(struct ordered_events *qe, goto next_event; } =20 - evsel =3D evlist__id2evsel(session->evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(session->evlist, sample.id); assert(evsel !=3D NULL); =20 if (event->header.type =3D=3D PERF_RECORD_SAMPLE) { diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 3313c236104e..a18d84d858aa 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -142,7 +142,9 @@ static int test__basic_mmap(struct test_suite *test __m= aybe_unused, int subtest } =20 err =3D -1; - evsel =3D evlist__id2evsel(evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample.id); perf_sample__exit(&sample); if (evsel =3D=3D NULL) { pr_debug("event with id %" PRIu64 diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-t= racking.c index a7ea4b7874be..ed17c3be71c4 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -138,7 +138,10 @@ static int process_sample_event(struct evlist *evlist, goto out; } =20 - evsel =3D evlist__id2evsel(evlist, sample.id); + evsel =3D sample.evsel; + if (!evsel) + evsel =3D evlist__id2evsel(evlist, sample.id); + if (evsel =3D=3D switch_tracking->switch_evsel) { next_tid =3D perf_sample__intval(&sample, "next_pid"); prev_tid =3D perf_sample__intval(&sample, "prev_pid"); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index dab23a96b1d8..3d759546a7c0 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3421,7 +3421,10 @@ static int intel_pt_process_switch(struct intel_pt *= pt, { pid_t tid; int cpu, ret; - struct evsel *evsel =3D evlist__id2evsel(pt->session->evlist, sample->id); + struct evsel *evsel =3D sample->evsel; + + if (!evsel) + evsel =3D evlist__id2evsel(pt->session->evlist, sample->id); =20 if (evsel !=3D pt->switch_evsel) return 0; @@ -3611,10 +3614,11 @@ static int intel_pt_process_aux_output_hw_id(struct= intel_pt *pt, u64 hw_id =3D event->aux_output_hw_id.hw_id; struct auxtrace_queue *queue; struct intel_pt_queue *ptq; - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; =20 queue =3D auxtrace_queues__sample_queue(&pt->queues, sample, pt->session); - evsel =3D evlist__id2evsel_strict(pt->session->evlist, sample->id); + if (!evsel) + evsel =3D evlist__id2evsel_strict(pt->session->evlist, sample->id); if (!queue || !queue->priv || !evsel || hw_id > INTEL_PT_MAX_PEBS) { pr_err("Bad AUX output hardware ID\n"); return -EINVAL; --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.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 BD28041B35F for ; Thu, 19 Mar 2026 23:24:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962696; cv=none; b=Vbq3ujspVn7ViT+2KMZ2lQZnCCWVt5qg7qwCqZ4pCSWitXBZXxhz+jGWp96wxD9PQ4nwqfsThSKOk7S8qDJTdQOguoAq1eIQJZxjcUub1qGfylovlOyjOCEobxHc2Mk2x7hcJW+I0DstFKXRs9amad5UDrM/2k5j8NogRZmR9HQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962696; c=relaxed/simple; bh=VqXAxS+gs14YPXizPgx/ZNO31O5r2Byhw+Wl32Abii8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UyR/FteIjWmJdp9ZSPebp4pwbF8tXSiFoySWjGqwnFx+d+vr4k3mQfB7Jjl/rFVeXu897aoooA6j3XGwsIRd4pvX7xIavPJj516win3ZkE2rHqtLXqHScA6H9v+U4nhAylZ/JWuBdFO7Ea3LviaB2wqQ/mD2gvnQTF+qDXu2CtQ= 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=MIDJKA6K; arc=none smtp.client-ip=74.125.82.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="MIDJKA6K" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2bdc1b30ac8so29326584eec.1 for ; Thu, 19 Mar 2026 16:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962694; x=1774567494; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=f3cm7lxJwAStEidrUkDbb4Cn0vXEiORxhkTxfV3eox0=; b=MIDJKA6K6DC1JKn6J/YvNuC27gdgZshTTL/EVN6ifOGbouLXdEDcoCYreJNA9GGvOa 0WQi9ceOLkAKvpal1OGoiGvSNGJqpbRRKZzVOjzoyCdJV9ExRjBMNTczVOfQJfS9Lq6A TU6amYGHZ8WTi2yB4HY35F/ypoCYAOX+a866xo2XjtzDiwIjC/ZjnmJgT8MOZDTYaevM lozxXJVW/gfJntDJKF0MPmLEcku9xxTP4w42XRIZqevUBK8dI0AnjNgUlGyf+/y5xTOe 1B6PsBo7ua3DxaLHh5Z/p3t9yzxLybZ9ssWwjUsQS131ob1asHwbJ5sm42Y+/WjtREyS tBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962694; x=1774567494; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f3cm7lxJwAStEidrUkDbb4Cn0vXEiORxhkTxfV3eox0=; b=LzcnRrU5nYou5mBEF9rgCtl2MekQuBArybEYT+EHTtMhLC8AV+QORVtwf7P7aiiFIY 6GyS/nsKe7e2PIOLmMwIZv+TOgDzeMAowv7gC9V0i5ht/0pciOXCANXmP7h1UuKiH+Qo xO5oFVrP5PKQExKpatyiOAe+I6RC+B92Wn9xMC62n6UVbXEz4EleZVRu7ERqqs8gsMYb gPwownMTN4RglO05H/YCu14pUGr0J7877L8oxp2rh5Jr6HRZuiYWZEqZUqwjfcgae49P 8k2Dm5AkWlfSwbO8OlAiIByVG+LjaFe6banOkPjXWz2BHKQqn4iENUzicurQtPQq52mo wAzA== X-Forwarded-Encrypted: i=1; AJvYcCXikCaIyxlq93yhDUb1Bx7MptWLjmRaZBl530aQYF7kW+0sru53bPKTS3ZjRYSUoUG3lMAncKpSZfe5Czo=@vger.kernel.org X-Gm-Message-State: AOJu0YzsLHYcLVQacZtvakR8kP+nyP0tyHUP8SfpmQM7br7z2WzCSudC ziYbPv3iVbvy/mEmpVFCZIy043JSOEfzWmNQg7DxE3RzQWWNaOFJ8DMc9UoJAYqsVUpyhgPqCUE Yrm33R7yUSg== X-Received: from dybna27.prod.google.com ([2002:a05:7300:cc1b:b0:2c1:f6:65e5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:d705:b0:2be:142f:d48a with SMTP id 5a478bee46e88-2c109784293mr734368eec.27.1773962693513; Thu, 19 Mar 2026 16:24:53 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:32 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-24-irogers@google.com> Subject: [PATCH v2 23/25] perf script: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Remove the evsel from the struct scripting_context so that the sample version is always accessed. Signed-off-by: Ian Rogers --- tools/perf/builtin-script.c | 12 ++++-- .../util/scripting-engines/trace-event-perl.c | 21 +++++------ .../scripting-engines/trace-event-python.c | 37 ++++++++----------- tools/perf/util/trace-event-scripting.c | 5 +-- tools/perf/util/trace-event.h | 3 -- 5 files changed, 33 insertions(+), 45 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8022801721e2..53da706d959f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2418,12 +2418,13 @@ static bool show_event(struct perf_sample *sample, } =20 static void process_event(struct perf_script *script, - struct perf_sample *sample, struct evsel *evsel, + struct perf_sample *sample, struct addr_location *al, struct addr_location *addr_al, struct machine *machine) { struct thread *thread =3D al->thread; + struct evsel *evsel =3D sample->evsel; struct perf_event_attr *attr =3D &evsel->core.attr; unsigned int type =3D evsel__output_type(evsel); struct evsel_script *es =3D evsel->priv; @@ -2714,9 +2715,9 @@ static int process_sample_event(const struct perf_too= l *tool, thread__resolve(al.thread, &addr_al, sample); addr_al_ptr =3D &addr_al; } - scripting_ops->process_event(event, sample, evsel, &al, addr_al_ptr); + scripting_ops->process_event(event, sample, &al, addr_al_ptr); } else { - process_event(scr, sample, evsel, &al, &addr_al, machine); + process_event(scr, sample, &al, &addr_al, machine); } =20 out_put: @@ -2892,9 +2893,12 @@ static int print_event_with_time(const struct perf_t= ool *tool, { struct perf_script *script =3D container_of(tool, struct perf_script, too= l); struct perf_session *session =3D script->session; - struct evsel *evsel =3D evlist__id2evsel(session->evlist, sample->id); + struct evsel *evsel =3D sample->evsel; struct thread *thread =3D NULL; =20 + if (!evsel) + evsel =3D evlist__id2evsel(session->evlist, sample->id); + if (evsel && !evsel->core.attr.sample_id_all) { sample->cpu =3D 0; sample->time =3D timestamp; diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/p= erf/util/scripting-engines/trace-event-perl.c index 850a0048df82..7a18ea4b7d50 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -257,7 +257,6 @@ static void define_event_symbols(struct tep_event *even= t, } =20 static SV *perl_process_callchain(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al) { struct callchain_cursor *cursor; @@ -340,7 +339,6 @@ static SV *perl_process_callchain(struct perf_sample *s= ample, } =20 static void perl_process_tracepoint(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al) { struct thread *thread =3D al->thread; @@ -355,6 +353,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, unsigned long long nsecs =3D sample->time; const char *comm =3D thread__comm_str(thread); DECLARE_BITMAP(events_defined, TRACE_EVENT_TYPE_MAX); + struct evsel *evsel =3D sample->evsel; =20 bitmap_zero(events_defined, TRACE_EVENT_TYPE_MAX); dSP; @@ -389,7 +388,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, XPUSHs(sv_2mortal(newSVuv(ns))); XPUSHs(sv_2mortal(newSViv(pid))); XPUSHs(sv_2mortal(newSVpv(comm, 0))); - XPUSHs(sv_2mortal(perl_process_callchain(sample, evsel, al))); + XPUSHs(sv_2mortal(perl_process_callchain(sample, al))); =20 /* common fields other than pid can be accessed via xsub fns */ =20 @@ -426,7 +425,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, XPUSHs(sv_2mortal(newSVuv(nsecs))); XPUSHs(sv_2mortal(newSViv(pid))); XPUSHs(sv_2mortal(newSVpv(comm, 0))); - XPUSHs(sv_2mortal(perl_process_callchain(sample, evsel, al))); + XPUSHs(sv_2mortal(perl_process_callchain(sample, al))); call_pv("main::trace_unhandled", G_SCALAR); } SPAGAIN; @@ -435,9 +434,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, LEAVE; } =20 -static void perl_process_event_generic(union perf_event *event, - struct perf_sample *sample, - struct evsel *evsel) +static void perl_process_event_generic(union perf_event *event, struct per= f_sample *sample) { dSP; =20 @@ -448,7 +445,8 @@ static void perl_process_event_generic(union perf_event= *event, SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpvn((const char *)event, event->header.size))); - XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->core.attr, sizeof(evsel-= >core.attr)))); + XPUSHs(sv_2mortal(newSVpvn((const char *)&sample->evsel->core.attr, + sizeof(sample->evsel->core.attr)))); XPUSHs(sv_2mortal(newSVpvn((const char *)sample, sizeof(*sample)))); XPUSHs(sv_2mortal(newSVpvn((const char *)sample->raw_data, sample->raw_si= ze))); PUTBACK; @@ -461,13 +459,12 @@ static void perl_process_event_generic(union perf_eve= nt *event, =20 static void perl_process_event(union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { - scripting_context__update(scripting_context, event, sample, evsel, al, ad= dr_al); - perl_process_tracepoint(sample, evsel, al); - perl_process_event_generic(event, sample, evsel); + scripting_context__update(scripting_context, event, sample, al, addr_al); + perl_process_tracepoint(sample, al); + perl_process_event_generic(event, sample); } =20 static void run_start_sub(void) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 9f5c6e5e6ebe..63d04b051846 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -390,7 +390,6 @@ static unsigned long get_offset(struct symbol *sym, str= uct addr_location *al) } =20 static PyObject *python_process_callchain(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al) { PyObject *pylist; @@ -651,11 +650,9 @@ static PyObject *get_sample_value_as_tuple(struct samp= le_read_value *value, return t; } =20 -static void set_sample_read_in_dict(PyObject *dict_sample, - struct perf_sample *sample, - struct evsel *evsel) +static void set_sample_read_in_dict(PyObject *dict_sample, struct perf_sam= ple *sample) { - u64 read_format =3D evsel->core.attr.read_format; + u64 read_format =3D sample->evsel->core.attr.read_format; PyObject *values; unsigned int i; =20 @@ -741,11 +738,10 @@ static void regs_map(struct regs_dump *regs, uint64_t= mask, uint16_t e_machine, =20 static int set_regs_in_dict(PyObject *dict, struct perf_sample *sample, - struct evsel *evsel, uint16_t e_machine, uint32_t e_flags) { - struct perf_event_attr *attr =3D &evsel->core.attr; + struct perf_event_attr *attr =3D &sample->evsel->core.attr; =20 int size =3D (__sw_hweight64(attr->sample_regs_intr) * MAX_REG_SIZE) + 1; char *bf =3D NULL; @@ -831,7 +827,6 @@ static void python_process_sample_flags(struct perf_sam= ple *sample, PyObject *di } =20 static PyObject *get_perf_sample_dict(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al, PyObject *callchain) @@ -839,6 +834,7 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, PyObject *dict, *dict_sample, *brstack, *brstacksym; uint16_t e_machine =3D EM_HOST; uint32_t e_flags =3D EF_HOST; + struct evsel *evsel =3D sample->evsel; =20 dict =3D PyDict_New(); if (!dict) @@ -871,7 +867,7 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, PyLong_FromUnsignedLongLong(sample->phys_addr)); pydict_set_item_string_decref(dict_sample, "addr", PyLong_FromUnsignedLongLong(sample->addr)); - set_sample_read_in_dict(dict_sample, sample, evsel); + set_sample_read_in_dict(dict_sample, sample); pydict_set_item_string_decref(dict_sample, "weight", PyLong_FromUnsignedLongLong(sample->weight)); pydict_set_item_string_decref(dict_sample, "ins_lat", @@ -928,7 +924,7 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, if (al->thread) e_machine =3D thread__e_machine(al->thread, /*machine=3D*/NULL, &e_flags= ); =20 - if (set_regs_in_dict(dict, sample, evsel, e_machine, e_flags)) + if (set_regs_in_dict(dict, sample, e_machine, e_flags)) Py_FatalError("Failed to setting regs in dict"); =20 return dict; @@ -936,7 +932,6 @@ static PyObject *get_perf_sample_dict(struct perf_sampl= e *sample, =20 #ifdef HAVE_LIBTRACEEVENT static void python_process_tracepoint(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { @@ -954,6 +949,7 @@ static void python_process_tracepoint(struct perf_sampl= e *sample, const char *comm =3D thread__comm_str(al->thread); const char *default_handler_name =3D "trace_unhandled"; DECLARE_BITMAP(events_defined, TRACE_EVENT_TYPE_MAX); + struct evsel *evsel =3D sample->evsel; =20 bitmap_zero(events_defined, TRACE_EVENT_TYPE_MAX); =20 @@ -995,7 +991,7 @@ static void python_process_tracepoint(struct perf_sampl= e *sample, PyTuple_SetItem(t, n++, context); =20 /* ip unwinding */ - callchain =3D python_process_callchain(sample, evsel, al); + callchain =3D python_process_callchain(sample, al); /* Need an additional reference for the perf_sample dict */ Py_INCREF(callchain); =20 @@ -1051,7 +1047,7 @@ static void python_process_tracepoint(struct perf_sam= ple *sample, PyTuple_SetItem(t, n++, dict); =20 if (get_argument_count(handler) =3D=3D (int) n + 1) { - all_entries_dict =3D get_perf_sample_dict(sample, evsel, al, addr_al, + all_entries_dict =3D get_perf_sample_dict(sample, al, addr_al, callchain); PyTuple_SetItem(t, n++, all_entries_dict); } else { @@ -1070,7 +1066,6 @@ static void python_process_tracepoint(struct perf_sam= ple *sample, } #else static void python_process_tracepoint(struct perf_sample *sample __maybe_u= nused, - struct evsel *evsel __maybe_unused, struct addr_location *al __maybe_unused, struct addr_location *addr_al __maybe_unused) { @@ -1465,7 +1460,6 @@ static int python_process_call_return(struct call_ret= urn *cr, u64 *parent_db_id, } =20 static void python_process_general_event(struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { @@ -1488,8 +1482,8 @@ static void python_process_general_event(struct perf_= sample *sample, Py_FatalError("couldn't create Python tuple"); =20 /* ip unwinding */ - callchain =3D python_process_callchain(sample, evsel, al); - dict =3D get_perf_sample_dict(sample, evsel, al, addr_al, callchain); + callchain =3D python_process_callchain(sample, al); + dict =3D get_perf_sample_dict(sample, al, addr_al, callchain); =20 PyTuple_SetItem(t, n++, dict); if (_PyTuple_Resize(&t, n) =3D=3D -1) @@ -1502,24 +1496,23 @@ static void python_process_general_event(struct per= f_sample *sample, =20 static void python_process_event(union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { struct tables *tables =3D &tables_global; =20 - scripting_context__update(scripting_context, event, sample, evsel, al, ad= dr_al); + scripting_context__update(scripting_context, event, sample, al, addr_al); =20 - switch (evsel->core.attr.type) { + switch (sample->evsel->core.attr.type) { case PERF_TYPE_TRACEPOINT: - python_process_tracepoint(sample, evsel, al, addr_al); + python_process_tracepoint(sample, al, addr_al); break; /* Reserve for future process_hw/sw/raw APIs */ default: if (tables->db_export_mode) db_export__sample(&tables->dbe, event, sample, al, addr_al); else - python_process_general_event(sample, evsel, al, addr_al); + python_process_general_event(sample, al, addr_al); } } =20 diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trac= e-event-scripting.c index fa850e44cb46..dc584ac316a3 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c @@ -103,12 +103,11 @@ int script_spec__for_each(int (*cb)(struct scripting_= ops *ops, const char *spec) void scripting_context__update(struct scripting_context *c, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al) { #ifdef HAVE_LIBTRACEEVENT - const struct tep_event *tp_format =3D evsel__tp_format(evsel); + const struct tep_event *tp_format =3D evsel__tp_format(sample->evsel); =20 c->pevent =3D tp_format ? tp_format->tep : NULL; #else @@ -117,7 +116,6 @@ void scripting_context__update(struct scripting_context= *c, c->event_data =3D sample->raw_data; c->event =3D event; c->sample =3D sample; - c->evsel =3D evsel; c->al =3D al; c->addr_al =3D addr_al; } @@ -134,7 +132,6 @@ static int stop_script_unsupported(void) =20 static void process_event_unsupported(union perf_event *event __maybe_unus= ed, struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, struct addr_location *al __maybe_unused, struct addr_location *addr_al __maybe_unused) { diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 914d9b69ed62..720121c74f1d 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -94,7 +94,6 @@ struct scripting_ops { int (*stop_script) (void); void (*process_event) (union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al); void (*process_switch)(union perf_event *event, @@ -124,7 +123,6 @@ struct scripting_context { void *event_data; union perf_event *event; struct perf_sample *sample; - struct evsel *evsel; struct addr_location *al; struct addr_location *addr_al; struct perf_session *session; @@ -133,7 +131,6 @@ struct scripting_context { void scripting_context__update(struct scripting_context *scripting_context, union perf_event *event, struct perf_sample *sample, - struct evsel *evsel, struct addr_location *al, struct addr_location *addr_al); =20 --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 B6A3241B37E for ; Thu, 19 Mar 2026 23:24:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962698; cv=none; b=uFH8GSWwNgMjyQsyTPPAACMum0EsoZxuyYp0RgiqWxUPSwb6GWU+BPrUTa+ZEVLR98P/z1Nuy15moQJ4QXWn18RJFEzg3euiWSPTlVZ8JJ+zCC/JJk8O0QNGA99KO5dZEQVH5vWn2lGtQZr9pQuxfOXAizumF2xCV3ADGZdxdSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962698; c=relaxed/simple; bh=DVFz0me6prlqmOZRJuHgLBjq4/TJp1BgBDFREufIWGc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kIIsThfEmEbLm/Pzozrn3AL7ffaszxdOAJ40ULs/wfIJYCOUUuXoP2vstBudL6/WO5Jr2bbHj+jwj2WiI69fjlsjpi4QvbsJzSTXJmGz1MzA/LJ65ovpTyjqf+xCcVzKR8D2A/NBF0z/sO8RKRtT71PKzAlo/pXqvAGyQMDGBOY= 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=g6wQ4Iig; arc=none smtp.client-ip=209.85.216.74 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="g6wQ4Iig" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35b8da51b3eso95996a91.1 for ; Thu, 19 Mar 2026 16:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962696; x=1774567496; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=H9w9UzhqInn6IYvlRecfZ1X0RPnPfXjSSvFkmfIoAts=; b=g6wQ4IigxTsd/h4UZejtZz1wZAoqG8fvcrEewoBuXqcTHrhGEkmvl74HTJV+7Qm2tK X/Zgfx3FAoPqQvodEAX74DInGBXHJATqdfFAJ+aFmv0LVHpKYjYGljhKvtCVXpDoddf2 Q63hr+4P9fZNPa/Tvkk4iBJHnNl8kcV9n9EDdG7ytn2m0RljAd9uhdKF+vdFcQMp85mA aPJH6+k5psVk0kkFLyU0TfAe9i3LpcnJEIR83pukj8ZvyGFpl/Yt8g6r/KitqUz9DIbH 6GnxC1G9j/IGzLbMJICU3nfK+Kk2hTz/fBq7opkkjI8qZEXro5YmLGIEz+OCVMlYBcg5 MvKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962696; x=1774567496; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H9w9UzhqInn6IYvlRecfZ1X0RPnPfXjSSvFkmfIoAts=; b=Ix6GepapkaJDLxenP6dV6LrdWJNyPv4dqRxWLY3N/VKhQWAf3SlehArr6F8LiEPhCM PWnptud6XD0W74gHHlzL6Ij+DqGyXCvY4rlIkQUW6hUZCZLDiDR3+9JTDw864ls/hOR9 IDBX8OyJ97/ZEVhTPGbziALBwqsGUq2n4AW2u1gDjniljCyYhEyU6qvOF4fT/B0J71s5 mVxMsPUqed/X/Jt1IHRhbtd0TbP8k04IW3IBcEGzYIgIi1jrEUuv7G/OGRPcq5CJPA8V E234AjHc6BzvJUeS82k+2LwIdZxKhUSwL96Zsj6709TbxCI5SH1zdEYQkc7P+QGg3vP/ /zFw== X-Forwarded-Encrypted: i=1; AJvYcCWeG9O/d60lOmXocdMy0V9ou6FH0RbZnMJ5IOmsDIFANafhSu+ZSt6PESm5UVnjs4Wq2U/HI1AgARYbtYs=@vger.kernel.org X-Gm-Message-State: AOJu0YzHwohPvsaidsqoQEOuF2CoxouDVLFDLUjoYfxlH3eVpAgUGAV3 KRYmwC31AugE9o2PTnsximbnTvDIWWWKU8foPF1FIuoQpug2Z7cnd92KYt/R0SV04V4X+tbpocm 3xk3/rWxwWg== X-Received: from pjbbw10.prod.google.com ([2002:a17:90a:f60a:b0:35b:9c71:2d38]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3907:b0:35b:97e8:904d with SMTP id 98e67ed59e1d1-35bd2bf5398mr699189a91.13.1773962695804; Thu, 19 Mar 2026 16:24:55 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:33 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-25-irogers@google.com> Subject: [PATCH v2 24/25] perf s390-sample-raw: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sample contains the evsel and so it is unnecessary to pass the evsel as well. Signed-off-by: Ian Rogers --- tools/perf/util/s390-sample-raw.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sampl= e-raw.c index c6ae0ae8d86a..bfa342536b9b 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -284,8 +284,9 @@ static bool s390_pai_all_test(struct perf_sample *sampl= e) return true; } =20 -static void s390_pai_all_dump(struct evsel *evsel, struct perf_sample *sam= ple) +static void s390_pai_all_dump(struct perf_sample *sample) { + struct evsel *evsel =3D sample->evsel; size_t len =3D sample->raw_size, offset =3D 0; unsigned char *p =3D sample->raw_data; const char *color =3D PERF_COLOR_BLUE; @@ -332,14 +333,16 @@ void evlist__s390_sample_raw(struct evlist *evlist, u= nion perf_event *event, struct perf_sample *sample) { const char *pai_name; - struct evsel *evsel; + struct evsel *evsel =3D sample->evsel; =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) return; =20 - evsel =3D evlist__event2evsel(evlist, event); - if (!evsel) - return; + if (!evsel) { + evsel =3D evlist__event2evsel(evlist, event); + if (!evsel) + return; + } =20 /* Check for raw data in sample */ if (!sample->raw_size || !sample->raw_data) @@ -372,6 +375,6 @@ void evlist__s390_sample_raw(struct evlist *evlist, uni= on perf_event *event, } else { if (!evsel->pmu) evsel->pmu =3D perf_pmus__find_by_type(evsel->core.attr.type); - s390_pai_all_dump(evsel, sample); + s390_pai_all_dump(sample); } } --=20 2.53.0.959.g497ff81fa9-goog From nobody Mon Apr 6 09:11:28 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 669D541C305 for ; Thu, 19 Mar 2026 23:24:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962701; cv=none; b=XlzqwkuSnDPTt87hfrGf43JuMlQTXJm+eOCgtadJsFzQYAvJe0S90wjE113CNeKSoRsT5XX/iWFPo3cU3rDTA+0sEAAJ1+URRI+H7zui6eYrrvoTkgebpKPVKiQnyjxI4yBh7cOS62bIGT+/gyP9Z4pZ5leTLEgd1fCAjQ3zDNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962701; c=relaxed/simple; bh=uS+Uo7Uea+sK0cag3i4TRSz4T9zVxU/R2GcBbXVObe0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=evTgOq5FatVy+XtMqd65GEMg10rFTM8PDcxoh6r1PhCyiCC5GOwuRB37jofYVsYi/ZmVUvMGNDFvzNHCv58JfcLhL1Oq9PnLZ8FhDc+JACtBRQ0st/EoNtMOMegv7056ka1KOzojB9Tkv+51IIaVZWV/5q6E72i2tXBs8HKz6NU= 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=m78fkXhO; arc=none smtp.client-ip=74.125.82.74 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="m78fkXhO" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12734af2ca4so479526c88.0 for ; Thu, 19 Mar 2026 16:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773962699; x=1774567499; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1gUztKY4N8cazk2OKll8MhFt0eTLdZ6QKcUsAqNQqSQ=; b=m78fkXhO6nooKGCkbH/KQgw5QgQU8SSs5wDXrNaUXFPsIMUKCxU2lKEaAwRysnwdNs sG/r+6U7otUyHujUrZ9ehTArk2RFpNuk3Et/nnn//D+7G8HRh3OfLqtIsgP7nXxcFKz4 UiWbil0A4TPDA/SW80rDWcA01F6MRNDHHSjak2UDCtPmeC6GD10l0uFgAg9jWGLTMz0I HJ9KTyXppdzRdO/oftHH+oDt6PQYgz3ilaPMifXVpkWLLC93/pwPitSdu7XD8Z6ULtv3 3+y0WO3t5TManrzEwLI+XSz+r4H1We2DS7VsQk/+n7FaRQDBXWtrFnV+zbrdhZ7KQbqo 9iTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773962699; x=1774567499; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1gUztKY4N8cazk2OKll8MhFt0eTLdZ6QKcUsAqNQqSQ=; b=T/bX18x0MBtn2hafPwAgqar+bMFqzrBCKEEAmR+7pRi/YH2D1aaYkwBYqTnvWQ6O4c AcHw/zLb/pQK6PpfyoTZKoJ3H2kpFIlKRs45JQFguG0v/oxuPJea4+G//TuMtzZ0R9Is AlPVHnfNtHCXZ/69rDgBLXPT0iCU7Wr+uRKZSUjDY9S8XCTZWqQJQQrveVlcEUfGPsO/ RizqhpHr/Ah4PyOafYeQL3ecZ1QpGLYILn5jpxk330EHKS+eSTv3B75CZcxsmCeG8VIB uYXh0C5UMn0oF9UBoI2vBRQfTV/n00xBpLYp1ZR6WMFRnNW240mymWfHVELN4hs6lvjr 4Afw== X-Forwarded-Encrypted: i=1; AJvYcCVoatLO1cBkQNprG9PUdbuZp/IeMep9qTV/VsvV73eZ8To3KUqy1ccxcjtBlPG0epzmpPtP19/vAiC2XqA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2luuYbD46YFoBQLxpaWxWsjniF3jT5I0Oo3TIp7m9K+HZjyP+ B1gOYkkhdNOwaQp27DjXIN3liOpXySJ4lCQaizGkc5VvBlS4X3uTt2NJMJ2/M4mI0RWM7yuJsGs VygSZRjCBAQ== X-Received: from dlbrl10.prod.google.com ([2002:a05:7022:f50a:b0:12a:6fc0:69e8]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:125:b0:119:e569:f875 with SMTP id a92af1059eb24-12a72342011mr609259c88.18.1773962698382; Thu, 19 Mar 2026 16:24:58 -0700 (PDT) Date: Thu, 19 Mar 2026 16:23:34 -0700 In-Reply-To: <20260319232334.287517-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209174032.4142096-1-irogers@google.com> <20260319232334.287517-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260319232334.287517-26-irogers@google.com> Subject: [PATCH v2 25/25] perf evsel: Don't pass evsel with sample From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, ajones@ventanamicro.com, ak@linux.intel.com, alex@ghiti.fr, alexander.shishkin@linux.intel.com, anup@brainfault.org, aou@eecs.berkeley.edu, atrajeev@linux.ibm.com, blakejones@google.com, ctshao@google.com, dapeng1.mi@linux.intel.com, derek.foreman@collabora.com, dvyukov@google.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, krzysztof.m.lopatowski@gmail.com, leo.yan@arm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, nichen@iscas.ac.cn, palmer@dabbelt.com, peterz@infradead.org, pjw@kernel.org, ravi.bangoria@amd.com, swapnil.sapkal@amd.com, tanze@kylinos.cn, thomas.falcon@intel.com, tianyou.li@intel.com, yujie.liu@intel.com, zhouquan@iscas.ac.cn Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Arrange for the sample to contain the evsel and so it is unnecessary to pass the evsel as well. This is done for uniformity, although parsing of the sample is arguably a special case. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 041766d39ec3..21602d121260 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2997,10 +2997,10 @@ int evsel__open_per_thread(struct evsel *evsel, str= uct perf_thread_map *threads) return ret; } =20 -static int perf_evsel__parse_id_sample(const struct evsel *evsel, - const union perf_event *event, +static int perf_evsel__parse_id_sample(const union perf_event *event, struct perf_sample *sample) { + const struct evsel *evsel =3D sample->evsel; u64 type =3D evsel->core.attr.sample_type; const __u64 *array =3D event->sample.array; bool swapped =3D evsel->needs_swap; @@ -3239,14 +3239,14 @@ int evsel__parse_sample(struct evsel *evsel, union = perf_event *event, data->deferred_cookie =3D event->callchain_deferred.cookie; =20 if (evsel->core.attr.sample_id_all) - perf_evsel__parse_id_sample(evsel, event, data); + perf_evsel__parse_id_sample(event, data); =20 return 0; } =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) { if (evsel->core.attr.sample_id_all) - perf_evsel__parse_id_sample(evsel, event, data); + perf_evsel__parse_id_sample(event, data); return 0; } =20 @@ -3606,12 +3606,13 @@ int evsel__parse_sample_timestamp(struct evsel *evs= el, union perf_event *event, =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) { struct perf_sample data =3D { + .evsel =3D evsel, .time =3D -1ULL, }; =20 if (!evsel->core.attr.sample_id_all) return -1; - if (perf_evsel__parse_id_sample(evsel, event, &data)) + if (perf_evsel__parse_id_sample(event, &data)) return -1; =20 *timestamp =3D data.time; --=20 2.53.0.959.g497ff81fa9-goog