From nobody Wed Apr 1 20:37:29 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 0C70641B362 for ; Wed, 1 Apr 2026 16:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060013; cv=none; b=uMNCKPRh0FfC8CVIRgjqWo6kc/vJIxYlN4N9TJ8HSbLu0+SN8xw0Jr5kU1UZBgRz8EhMowt4a1k8Y7b1y2OSU7cJvfiLdoWqPD3BMF1rFk77QYLprlFxFGs3Yp8gR0ulOkQarQ0zqiN3cVrmBqQr3Kdpj3XX5dw6mROc6QtibQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060013; c=relaxed/simple; bh=M6LerUGQ/FegXHi0SxaTfjtXEbJdYcXQ+sl9wiXh/SQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Z9qdfB85oJ8EO+4nr1xz0G1KThAmM6Tn+wz2GSmEDPP6zaW240ALk0fvlLjRk1o+ayQUoTB33bD3/e6pP5Qd83J7OFI5jalkUnwDPGf5PkeWqlDB9iBZpYG9XQnC6ouhZlklE8H1knPpd+kaznc3jgheFN2TIRFU7YhxCfx2ERw= 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=ryKwLgYq; arc=none smtp.client-ip=209.85.215.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="ryKwLgYq" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c741c4cebf3so4239156a12.2 for ; Wed, 01 Apr 2026 09:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060011; x=1775664811; 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=0+JPhC0NfmjsreQ1S+6TmS21rrwcvm5mWtScohYKt4w=; b=ryKwLgYqvbbJj4ORGxxfk90Vi7xqzpx1Q406vujbeSDxcAM4i8Lk49kEZYsbW/5S2k ExRn2wLqi782cDnJhcik2ingTEvLWagjlPdW3SfAdb3zhEqMiX9IrVvm4C9LGPe4nE4O 5KpDUZCdCO0u6p1RlZGXHw5YUrQwZd73hJxxY5rz5f4YUxvbpLggrV1Vm5QlmqPylGMm ComcZMxaB48f+ZH7r+WE7pSZtuJqu6giftRmIb/kKeZc30kbeV6mz83HwSq+Bdy3Yft4 T5A+8RzvPIAvDQMO51mP20vNIu4z0BFvL5DZciGW4bY0uDUH4+YTgyDFHFDzRXZdT5Dw 78Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060011; x=1775664811; 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=0+JPhC0NfmjsreQ1S+6TmS21rrwcvm5mWtScohYKt4w=; b=hZJ6lk44dpPm5vD3EyjwbKFLqzpVhLsMB1skhExBfC5wokGRlkBqTAi2M4gtU5lCmE vFzDAhYv+VABgsuvDhCWCwyjzF32EfTVMwV9yLf7rpK0lMaKwdN6do9cPafJsZdfrI9s zbTSVthnZVBWvqELWZR0OXSnt2TpZdBpUx8vrp45xYJbwnqnefV0+O6XH98TWWeKdm8G ZWS5XRpEu+a28l6aK01fOmCt0LYwB8pA4PULNjRqhcbK6nBzm1KX+B9Hdphckn6PQRV3 t0sgAKdmaLDhnFO1bbmQPD/VBzEn53/597Ep+O5WM1/xY9e0Ta/VXP3S8KcCBSFQ4o4x A9fA== X-Forwarded-Encrypted: i=1; AJvYcCVUX6UIKaUgFbfg4UBonG/k7GB5Qr/L5hMCNJ+Tc4Bg9+eDOXpy4BJRBXgILO4GNwWFnqLKuawJn5QLITo=@vger.kernel.org X-Gm-Message-State: AOJu0Yx90JgKdTm+XCMFEi3aKRJcFiC9Jb78KexC14hkWYPTaCpojmFD a0Pr0CEVliJ7BMO2JnvS2IMeFgwO9f3Vv7I1sQBurKehiBnpoHtAV2ZNHQAO1O9UtI179QaGaYt 0TzVbobVoDg== X-Received: from pjev15.prod.google.com ([2002:a17:90a:e0f:b0:35d:ab01:e224]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1e47:b0:35d:9dc8:7191 with SMTP id 98e67ed59e1d1-35dc6edc843mr4125867a91.14.1775060011170; Wed, 01 Apr 2026 09:13:31 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:17 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-2-irogers@google.com> Subject: [PATCH v4 1/8] perf clockid: Add missing include From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" clockid_t is declared in time.h but the include is missing. Reordering header files may result in build breakages. Add the include to avoid this. Signed-off-by: Ian Rogers --- tools/perf/util/clockid.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/clockid.h b/tools/perf/util/clockid.h index 9b49b4711c76..33dbd8673c1c 100644 --- a/tools/perf/util/clockid.h +++ b/tools/perf/util/clockid.h @@ -1,8 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ - #ifndef __PERF_CLOCKID_H #define __PERF_CLOCKID_H =20 +#include + struct option; int parse_clockid(const struct option *opt, const char *str, int unset); =20 --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 4261546AF3C for ; Wed, 1 Apr 2026 16:13:34 +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=1775060015; cv=none; b=O4SNXp5a0yhfWtl420Ha2wY3ySZmcaaSGOOyXQHuBsMDkeVXsbDSmCZ3v9w4dHrge/ueTAECmOn7E6haXP3k8TTIUw8x6BN+4dIXMXNTLLNjRhJC4ZnZieAzATaMOqNqKzfIMwVg97Q1p5r0n2EjeG2hPdgA3b225obU6Qni3Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060015; c=relaxed/simple; bh=8CeMSsp5bG8bbzyCebrPJbm+yMmmsP613Zzq5fJ4G94=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iewEj0hsR6DGPaf64ZQtafQ58mcmC4ebU4eRROHjxtnBbbQUs+R6XntSqHCkKCPEO9Yfx3/A5C/RPtIBYZsZ0nqlJhwq/YzhXQZrvaHCuYcHaxwJkCxc0AuoBi+G4Fw96ESgd/midVXv0MfXui/QJ1+xm6v9/4EKfbED5SzV4DI= 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=fDwRXfF7; 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="fDwRXfF7" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so9135474eec.1 for ; Wed, 01 Apr 2026 09:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060013; x=1775664813; 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=RGYJCmJpaCc2bncJjH0L02E19d9BBzjQUz5zjpm1zYc=; b=fDwRXfF7X3h4v9c1zuOL3IwSmlNzoxUK8lTG46q/bFsHXEHR8Nm8lz+Y8Vg6dKlFad uHJK2+kVUSX2ODyOYX7PoU93l7j0pghavUyIkk3T7/5fdFGTXlh6TYh6cCyKzZNV3ucR pAz8QdmhJqRQT8tRhSVvIuNlJy+BK0NwL3CdKtgGqwCbyBSvcN5gPbdNM7eVl4tXsuPR pF/9K+Esmcdno2VUBvGR2LZ73/CDDMRMi8VGJ/5A53U1LgFlizvRoVFwPdt08qic6nug vPG06Ki9S03JYMUeRZQRGe3HHwRSSUWIKkfiVTWDmZLu3QqiE5d9k/PG7E7cflq8WlDY T+UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060013; x=1775664813; 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=RGYJCmJpaCc2bncJjH0L02E19d9BBzjQUz5zjpm1zYc=; b=nrZyg7K4JTRIpN8XTRyIUD7A/9B70L/3TBt2yVjAI70QVcpld8TUQ1+1yhdFQOB90K 1KY6cLKOyP6M+aqum6QcQm9M9LsTys5KBXUTRfGYEyEASSkXEdQORsoo3UcNnLzzL5rJ jSY2PcNzYCuzIDDfqWFFWLmC/QlrWDL9m+PxXGFnQBQWXakQBJ+TO5vdiZkx2wZE2Kkt PECSzUacGtgQmBbfXUqp0qKq6fLy5QyuCggkpEVln6a3hhCBP2yxFcIbUAR9D/o6tFDo rJBMcsKj+DYw2lpRaHgK+i6x0rf8hvyu0PBbRjiqiG6/+1c0WsAMxrwNtirOUR+9seCU 5I0g== X-Forwarded-Encrypted: i=1; AJvYcCWCvqMc+3mPgOzJrIZO1deVitzF5Zmb1EFlHaPaBBvFhRwRtiezYqA3sGDP0Ff7/Ihp8zVwv5BW3fb6sZ8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxvegu2H6UaOhBzkw8Nr03sEWXLaoxw01cCFQWGBw/OVlv5s6PG MrOcZZHoGRsp4GSLj2YTjh+KCPV2vTZKPDvdzfLCdZLyT5fawZ0k6cTccM3VrxMZ4lrHby9OHE0 uGMJydJ0ffw== X-Received: from dlaf1.prod.google.com ([2002:a05:701b:2401:b0:128:f497:319c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6189:b0:128:cc34:3617 with SMTP id a92af1059eb24-12be64ac958mr2448028c88.21.1775060013079; Wed, 01 Apr 2026 09:13:33 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:18 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-3-irogers@google.com> Subject: [PATCH v4 2/8] perf header: Add utility to convert feature number to a string From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For logging and debug messages it can be convenient to convert a feature number to a name. Add header_feat__name for this and reuse the data already within the feat_ops struct. Signed-off-by: Ian Rogers --- tools/perf/util/header.c | 7 +++++++ tools/perf/util/header.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 9142a8ba4019..fcd53271e189 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3770,6 +3770,13 @@ struct header_print_data { bool full; /* extended list of headers */ }; =20 +const char *header_feat__name(unsigned int id) +{ + if (id < HEADER_LAST_FEATURE) + return feat_ops[id].name ?: "INVALID"; + return "INVALID"; +} + static int perf_file_section__fprintf_info(struct perf_file_section *secti= on, struct perf_header *ph, int feat, int fd, void *data) diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index cc40ac796f52..ca22030a1434 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -132,6 +132,8 @@ struct perf_header_feature_ops { =20 extern const char perf_version_string[]; =20 +const char *header_feat__name(unsigned int id); + int perf_session__read_header(struct perf_session *session); int perf_session__write_header(struct perf_session *session, struct evlist *evlist, --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 CA09F47278B for ; Wed, 1 Apr 2026 16:13:35 +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=1775060017; cv=none; b=K1SfZmBaYDQN2V/OqkpemBJ5A4iomR+y9lVnGxdnGSnehlItrSj5xuZHzJyFgSnIiIzBqRLLgSQJiZZY5Nn9wDwsL2zLju1ONhZibBDtKhhkRaFwXSQUqRxhRH5FCQWrL+ZJU//iDBixRPDR2HIx/RU8z3ld+BtOPeZ6ojtGwQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060017; c=relaxed/simple; bh=pQw3DSGto9YWSkBY2nT7ZjSAEw73RvDiI42ofQz12bI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=a49l7qLcbpovlvy0tZ8fg03JYRSAq/gNhCAqMJCgTawTv8ljUw5I7C36L/lqcAconCqiG32HkXFAtT2r6OjznOldaJTgw20WPcq8PO7jWVEXs1/Us+wZtdMWXbAbU1h6lQh0zr44vW6MDsHuulXqrDMPFbqLyLIzdFMotUuDYIY= 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=aaisriLx; 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="aaisriLx" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c5b48baf75so9154399eec.0 for ; Wed, 01 Apr 2026 09:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060015; x=1775664815; 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=d6aSMFYxARFqb+s5PRfj6hVV83IM5y47yqCQJKiEqaA=; b=aaisriLxk3rdYOthfaUlIa/0P/7mzdyReUVpX5NIyZBDYFeZaJ3TshBCSHInsVjrye /arTMh6b1nlXJbBKnHVwNrqCEuZd8XKHVzp83RmljX76XuNZOpsT/PwiBDVixkpUGBqk whct6JTeBUjHSV/sxt7aG5/Wkgy7GwCELlGuftpFOIb+k7Hf+d296jooX7hrEfFc4zGm 9M/ukF/x+erLgrcXiksXdoPu1QC3SnCPaOeKtyceNmiERGyG+z+YSLsorX4Q5c07SYSu AUlpO8KHp0k1YmGwg+fh92tYdJLOLXyXJ6OLxaDLU0jef0Jx6531QRtXqQEqeaclBX2u 5D6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060015; x=1775664815; 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=d6aSMFYxARFqb+s5PRfj6hVV83IM5y47yqCQJKiEqaA=; b=ehizfyXSs3QiMTb6CPVzKnjD2rmuF0tToeP7+8wQ0SxuaTwLQAL+oDtro0U/Rx3YlF Yv0dHNEUGtNFdn0Jy+x5kd6M2rPP5apiJIXKqXO6HEcFpVYtt62eSnk4hm7212w0lB9q suZuYdtJ97gOC9TdgFRXxrd203drBwkpOXIrTWbMgH5fIp4IYbeT5b4juTXm7UB7/Rzy ZXYu1XUN/FpIFbEWrJvAqyNTHHMrvmkM2ba3sAXzNyvvMIin1YPwn54Vw+u3+yCNAZIv tU1w1qCsKySbKpPZwOhYeLhnyA6AMYEA1ppFPgebLsKW22NhO52Ja5kF9VTw1Je0aV5l GbEA== X-Forwarded-Encrypted: i=1; AJvYcCWEDjCkMT/KIj4WOARqM1tphyVyU6F892FM5rrp8zX87aAFIoSs24YfjekR/KDPqKValHBPIcKQlhRPKkQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0V8khm0M0KmYakAp5+MAuD1n8YrU9c7i0mJs93EU4oGJ/LIt5 wSEuZgsg4pNj9oB9z/kGL9Fx+2wEzZNxNqMcLdgQPlpTSLxfasVsvz3YEgcSyGPa/rsr76Rmz/0 s1IO3lyuLZw== X-Received: from dybir8.prod.google.com ([2002:a05:7300:c8c8:b0:2c0:be02:79e8]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:3724:b0:2c1:27c:75bd with SMTP id 5a478bee46e88-2c92db587e3mr2528654eec.0.1775060014789; Wed, 01 Apr 2026 09:13:34 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:19 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-4-irogers@google.com> Subject: [PATCH v4 3/8] perf header: Properly warn/print when libtraceevent/libbpf support is missing From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" By removing the features from feat_ops with ifdefs the previous logic would print "# (null)" when perf processed a feature that lacked builtin support. Remove the ifdefs from feat_ops and in the relevant functions print errors/messages about the lack of support. Signed-off-by: Ian Rogers --- tools/perf/util/header.c | 70 +++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index fcd53271e189..50c006be895f 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -306,16 +306,19 @@ static int do_read_bitmap(struct feat_fd *ff, unsigne= d long **pset, u64 *psize) return 0; } =20 -#ifdef HAVE_LIBTRACEEVENT static int write_tracing_data(struct feat_fd *ff, - struct evlist *evlist) + struct evlist *evlist __maybe_unused) { if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) return -1; =20 +#ifdef HAVE_LIBTRACEEVENT return read_tracing_data(ff->fd, &evlist->core.entries); -} +#else + pr_err("ERROR: Trying to write tracing data without libtraceevent support= .\n"); + return -1; #endif +} =20 static int write_build_id(struct feat_fd *ff, struct evlist *evlist __maybe_unused) @@ -1026,10 +1029,10 @@ static int write_dir_format(struct feat_fd *ff, return do_write(ff, &data->dir.version, sizeof(data->dir.version)); } =20 -#ifdef HAVE_LIBBPF_SUPPORT -static int write_bpf_prog_info(struct feat_fd *ff, +static int write_bpf_prog_info(struct feat_fd *ff __maybe_unused, struct evlist *evlist __maybe_unused) { +#ifdef HAVE_LIBBPF_SUPPORT struct perf_env *env =3D &ff->ph->env; struct rb_root *root; struct rb_node *next; @@ -1067,11 +1070,16 @@ static int write_bpf_prog_info(struct feat_fd *ff, out: up_read(&env->bpf_progs.lock); return ret; +#else + pr_err("ERROR: Trying to write bpf_prog_info without libbpf support.\n"); + return -1; +#endif // HAVE_LIBBPF_SUPPORT } =20 -static int write_bpf_btf(struct feat_fd *ff, +static int write_bpf_btf(struct feat_fd *ff __maybe_unused, struct evlist *evlist __maybe_unused) { +#ifdef HAVE_LIBBPF_SUPPORT struct perf_env *env =3D &ff->ph->env; struct rb_root *root; struct rb_node *next; @@ -1100,8 +1108,11 @@ static int write_bpf_btf(struct feat_fd *ff, out: up_read(&env->bpf_progs.lock); return ret; -} +#else + pr_err("ERROR: Trying to write btf data without libbpf support.\n"); + return -1; #endif // HAVE_LIBBPF_SUPPORT +} =20 static int cpu_cache_level__sort(const void *a, const void *b) { @@ -1980,9 +1991,9 @@ static void print_dir_format(struct feat_fd *ff, FILE= *fp) fprintf(fp, "# directory data version : %"PRIu64"\n", data->dir.version); } =20 -#ifdef HAVE_LIBBPF_SUPPORT -static void print_bpf_prog_info(struct feat_fd *ff, FILE *fp) +static void print_bpf_prog_info(struct feat_fd *ff __maybe_unused, FILE *f= p) { +#ifdef HAVE_LIBBPF_SUPPORT struct perf_env *env =3D &ff->ph->env; struct rb_root *root; struct rb_node *next; @@ -1993,7 +2004,7 @@ static void print_bpf_prog_info(struct feat_fd *ff, F= ILE *fp) next =3D rb_first(root); =20 if (!next) - printf("# bpf_prog_info empty\n"); + fprintf(fp, "# bpf_prog_info empty\n"); =20 while (next) { struct bpf_prog_info_node *node; @@ -2006,10 +2017,14 @@ static void print_bpf_prog_info(struct feat_fd *ff,= FILE *fp) } =20 up_read(&env->bpf_progs.lock); +#else + fprintf(fp, "# bpf_prog_info missing, no libbpf support\n"); +#endif // HAVE_LIBBPF_SUPPORT } =20 -static void print_bpf_btf(struct feat_fd *ff, FILE *fp) +static void print_bpf_btf(struct feat_fd *ff __maybe_unused, FILE *fp) { +#ifdef HAVE_LIBBPF_SUPPORT struct perf_env *env =3D &ff->ph->env; struct rb_root *root; struct rb_node *next; @@ -2031,8 +2046,10 @@ static void print_bpf_btf(struct feat_fd *ff, FILE *= fp) } =20 up_read(&env->bpf_progs.lock); -} +#else + fprintf(fp, "# bpf btf data missing, no libbpf support\n"); #endif // HAVE_LIBBPF_SUPPORT +} =20 static void free_event_desc(struct evsel *events) { @@ -2644,14 +2661,17 @@ static int process_e_machine(struct feat_fd *ff, vo= id *data __maybe_unused) return do_read_u32(ff, &ff->ph->env.e_flags); } =20 -#ifdef HAVE_LIBTRACEEVENT -static int process_tracing_data(struct feat_fd *ff, void *data) +static int process_tracing_data(struct feat_fd *ff __maybe_unused, void *d= ata __maybe_unused) { +#ifdef HAVE_LIBTRACEEVENT ssize_t ret =3D trace_report(ff->fd, data, false); =20 return ret < 0 ? -1 : 0; -} +#else + pr_err("ERROR: Trying to read tracing data without libtraceevent support.= \n"); + return -1; #endif +} =20 static int process_build_id(struct feat_fd *ff, void *data __maybe_unused) { @@ -3330,9 +3350,9 @@ static int process_dir_format(struct feat_fd *ff, return do_read_u64(ff, &data->dir.version); } =20 -#ifdef HAVE_LIBBPF_SUPPORT -static int process_bpf_prog_info(struct feat_fd *ff, void *data __maybe_un= used) +static int process_bpf_prog_info(struct feat_fd *ff __maybe_unused, void *= data __maybe_unused) { +#ifdef HAVE_LIBBPF_SUPPORT struct bpf_prog_info_node *info_node; struct perf_env *env =3D &ff->ph->env; struct perf_bpil *info_linear; @@ -3402,10 +3422,15 @@ static int process_bpf_prog_info(struct feat_fd *ff= , void *data __maybe_unused) free(info_node); up_write(&env->bpf_progs.lock); return err; +#else + pr_err("ERROR: Trying to read bpf_prog_info without libbpf support.\n"); + return -1; +#endif // HAVE_LIBBPF_SUPPORT } =20 -static int process_bpf_btf(struct feat_fd *ff, void *data __maybe_unused) +static int process_bpf_btf(struct feat_fd *ff __maybe_unused, void *data = __maybe_unused) { +#ifdef HAVE_LIBBPF_SUPPORT struct perf_env *env =3D &ff->ph->env; struct btf_node *node =3D NULL; u32 count, i; @@ -3449,8 +3474,11 @@ static int process_bpf_btf(struct feat_fd *ff, void = *data __maybe_unused) up_write(&env->bpf_progs.lock); free(node); return err; -} +#else + pr_err("ERROR: Trying to read btf data without libbpf support.\n"); + return -1; #endif // HAVE_LIBBPF_SUPPORT +} =20 static int process_compressed(struct feat_fd *ff, void *data __maybe_unused) @@ -3726,9 +3754,7 @@ static int process_cpu_domain_info(struct feat_fd *ff= , void *data __maybe_unused const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE]; =20 const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE] =3D { -#ifdef HAVE_LIBTRACEEVENT FEAT_OPN(TRACING_DATA, tracing_data, false), -#endif FEAT_OPN(BUILD_ID, build_id, false), FEAT_OPR(HOSTNAME, hostname, false), FEAT_OPR(OSRELEASE, osrelease, false), @@ -3752,10 +3778,8 @@ const struct perf_header_feature_ops feat_ops[HEADER= _LAST_FEATURE] =3D { FEAT_OPR(MEM_TOPOLOGY, mem_topology, true), FEAT_OPR(CLOCKID, clockid, false), FEAT_OPN(DIR_FORMAT, dir_format, false), -#ifdef HAVE_LIBBPF_SUPPORT FEAT_OPR(BPF_PROG_INFO, bpf_prog_info, false), FEAT_OPR(BPF_BTF, bpf_btf, false), -#endif FEAT_OPR(COMPRESSED, compressed, false), FEAT_OPR(CPU_PMU_CAPS, cpu_pmu_caps, false), FEAT_OPR(CLOCK_DATA, clock_data, false), --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 C7A804779A4 for ; Wed, 1 Apr 2026 16:13:37 +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=1775060019; cv=none; b=c7Ovm109RIh6pmt9FhSEVQfvbEk8QLsetA7jdL09cT4V64MjlGIxRh9i4omSIz2FH3TXVcw1fqPh9bAPzjkFiAdCfXmeOHSevBLPbfqYFTWTZnMifiu2aLaQ3w4vbmODhYuYbqErpvm3H6bsm53ztLwVG1WTnqKyF3kI5vxuDWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060019; c=relaxed/simple; bh=etWLpPUbAL9PbGn2PsAzD1vzOgdSqQ+V+536k9PjEfA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MpyiswTmd+zH9SAS/puEsN9UIqH2i49nM+J7c/gEvNBrAGbhY+vS+2jB4fcvsbvMXxsjab25bYf0dOvxU0gPe2309RCtk4lN3sMoEzWZDqtW/TbNIQCmVtsk4sfemlgxlfpjohxPwSbYjJTatOXOnpu8G0/7IsJDQ2Aq23UiKBw= 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=WmdC/Kf2; 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="WmdC/Kf2" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2bdf6fe90a9so7067289eec.1 for ; Wed, 01 Apr 2026 09:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060017; x=1775664817; 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=WMSD5CIynbKr+BJ31meFhjj49c+zZqPVABuWE4dY/sQ=; b=WmdC/Kf22QYLprlJnDJBocJ3Ae5EID73l5WtahVrT07bYIg1+nAHGKNQ3wbkEuPUga 88KD9N+D9eIjKXC8d5JvqpZ+PtYGmN6jLbg0GupE7xaKe6zu6+pA/t6Ipb8KFqQssSOy Z7IdgncozHt+9TureME06ka4S+Qziu5X0ahQ7DU1OeRR0fD1uXW3pUJmu+RbXw8ZyjnL ztXls1k8SQh04SjEgoZ+0EfmP/WA/KyKs+QJtIlSNazaaH8cdqHXn4QwHGwsbzdVltyP 79zIR6XcGMG98ZvL/A3ZnCAShkyo+pqZQIReoMZxgjKgxNueNsT3P5Um5OTdOn4QWtuY q72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060017; x=1775664817; 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=WMSD5CIynbKr+BJ31meFhjj49c+zZqPVABuWE4dY/sQ=; b=idC3EJ4v4k6OV9+UfN+LRFIPQUND1XhA5NA6mbab2pxmk97RLu3ZfF5nVftdk2v3G/ XqGUaoDeU3D6Y8EpUB9UNV4unMhLvneeWDjfO+gqu1SUKvsGiRq+YzkWWeRp9lDAdavq RwGFcX2C0rBQinvJmn+JOtX+ved4I/oxrjoPbzgKIgArp8lQJgzDk7c4xzKfy+VVHecp l8K5eAdQNI4nxFqcEYxd1ppcy9W2kfvJDYmXSBM/4ulnnJx77r1DyUmnZKeaTWnmhZ96 Nu5D45PcmVwoa5xBwhbpwxpCUq0cKdO15OGmaw2bz0l5ddef1oHvskhwdV9H6qoZvnoA WsbQ== X-Forwarded-Encrypted: i=1; AJvYcCUQ7KznOUZdEGriiMedYUalxa/6TZwimvWndmBAfy3FQWUtAo2oUNFwxclEA30c38bNN9AViiRboRu1kKg=@vger.kernel.org X-Gm-Message-State: AOJu0Ywahb4VLGcXafO34jWezddpe/wKi3lXSR5e8nZjvO8dqXKzjGJ2 v63x69L2sj4WIXkfSVSho6ugSPibcHfPQhKydmtiBmOCxd6C4Q9qT0k+qXple+EMfcZFphGKvZC k42Y4wLqaQg== X-Received: from dlbrn6.prod.google.com ([2002:a05:7022:1506:b0:128:ebd8:625d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:ec7:b0:128:d7a7:5271 with SMTP id a92af1059eb24-12be6584897mr2097291c88.28.1775060016753; Wed, 01 Apr 2026 09:13:36 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:20 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-5-irogers@google.com> Subject: [PATCH v4 4/8] perf session: Extra logging for failed to process events From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Print log information in ordered event processing so that the cause of finished round failing is clearer. Print the event name along with its number when an event isn't processed. Add extra detail about where the failure happened. The following log lines come from running `perf data convert`. Before: 0xa250 [0x10]: failed to process type: 80 After: 0xa250 [0x10]: piped event processing failed for event of type: FEATURE (= 80) Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 4b465abfa36c..492515789d3d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -131,10 +131,17 @@ static int ordered_events__deliver_event(struct order= ed_events *oe, { struct perf_session *session =3D container_of(oe, struct perf_session, ordered_events); + int ret =3D perf_session__deliver_event(session, event->event, + session->tool, event->file_offset, + event->file_path); =20 - return perf_session__deliver_event(session, event->event, - session->tool, event->file_offset, - event->file_path); + if (ret) { + pr_err("%#" PRIx64 " [%#x]: ordered event processing failed (%d) for eve= nt of type: %s (%d)\n", + event->file_offset, event->event->header.size, ret, + perf_event__name(event->event->header.type), + event->event->header.type); + } + return ret; } =20 struct perf_session *__perf_session__new(struct perf_data *data, @@ -2110,8 +2117,10 @@ static int __perf_session__process_pipe_events(struc= t perf_session *session) } =20 if ((skip =3D perf_session__process_event(session, event, head, "pipe")) = < 0) { - pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n", - head, event->header.size, event->header.type); + pr_err("%#" PRIx64 " [%#x]: piped event processing failed for event of t= ype: %s (%d)\n", + head, event->header.size, + perf_event__name(event->header.type), + event->header.type); err =3D -EINVAL; goto out_err; } @@ -2225,8 +2234,10 @@ static int __perf_session__process_decomp_events(str= uct perf_session *session) if (size < sizeof(struct perf_event_header) || (skip =3D perf_session__process_event(session, event, decomp->file_p= os, decomp->file_path)) < 0) { - pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n", - decomp->file_pos + decomp->head, event->header.size, event->header.typ= e); + pr_err("%#" PRIx64 " [%#x]: decompress event processing failed for even= t of type: %s (%d)\n", + decomp->file_pos + decomp->head, event->header.size, + perf_event__name(event->header.type), + event->header.type); return -EINVAL; } =20 @@ -2382,8 +2393,9 @@ reader__read_event(struct reader *rd, struct perf_ses= sion *session, if (size < sizeof(struct perf_event_header) || (skip =3D rd->process(session, event, rd->file_pos, rd->path)) < 0) { errno =3D -skip; - pr_err("%#" PRIx64 " [%#x]: failed to process type: %d [%m]\n", + pr_err("%#" PRIx64 " [%#x]: processing failed for event of type: %s (%d)= [%m]\n", rd->file_offset + rd->head, event->header.size, + perf_event__name(event->header.type), event->header.type); err =3D skip; goto out; --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 9E299477E3A for ; Wed, 1 Apr 2026 16:13:39 +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=1775060021; cv=none; b=rOk9MbNbBNfYZPjxhF6w6D+EIiQe+OyIZ/1w3vc6QHKsHpBFhnmQjbCQ5ySxHJWlWC+deLsj3JxlpYf2bB9KJUuvli4BVVzR274VcvM92gCyXCqYTBN2A6PM78kB2kLW93m3XYeJ1xkLux6PFaumYxxrkjcoa4p9YCerRaAb/9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060021; c=relaxed/simple; bh=daUycZGKxNhd94DDxuZtSOrtakyDqeJmxMYIs+AZVX8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZHTTjN1/8g/Igv20FeifKfILgqsm3I3iP8MG79FtwQVJHxqCFjr9gCbmRZgcQCRvLbT5DwRr0f3R2Ad9P88rF39SnsaQfd9fa9l4YXijw9Uxs812gMEFQNMd99CMeZKqY8UyUdD1Ne8nDnXkyHkzhnB4LkkZU4ASIG8xLgdM1Wg= 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=BkO5L4wx; 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="BkO5L4wx" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so9135619eec.1 for ; Wed, 01 Apr 2026 09:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060019; x=1775664819; 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=qtqGLq8r8l3Xpdp7N+jBvQCvJc83P/vBiuR2WAVo3kU=; b=BkO5L4wxu1xaAv+P/NtA3/1OUMIJXLhPQfce1qz8gxwUrdcnhSa30AmAfbrjOWvsvu bWTWsoAet8nYVhJCgAoHqPdHbQvaEMWiAxYH/czTXIoULKWArvBipjtrAKQRM8918Om8 sMYjBn47Ltcv0Xu+W+1+XsseURYBjnTyhSe4AStEf79WhpGFXKcQOGzHVBri5EiUzLVx tCLKoCcFIPtjr/gL/hSSdLoUgQ0laG2VFxnrrRllBYoyNMgU47WvJQdwTV/ATK9j3C0Q Y4KUie3rksnzPfCRDq5oEkl/G5CBN4gf8eVXwqnFVH2fKJzRHjEAuz7fNfyikglvzKaE JL4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060019; x=1775664819; 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=qtqGLq8r8l3Xpdp7N+jBvQCvJc83P/vBiuR2WAVo3kU=; b=o+ZzzJ2iHVL9F5q/45T5Mp/RB5uSvCqtSkhtQLsRIC2VquBoUc1bivZQ5cvrGrt2cr lEIufW+nMI0sSRKOnRuLuBC1BI0eymm159KpMpsycZ+ineWvExhL3TJc2+jrqWBIBR/4 Pp8fuLFPcpSTi642Vpo8x2BP53/xXDU+kBBBhcpZXecXvERuNJJQLAsqaBNumR7faM8q UNtMoAzerrlaFIvsp4q5eR4Axnee9gjdy4cf1icmGyfImU1Hlbs1nj3wMxJbB8TCKA1M 2dUjv+KKrnGKOWKy+0SHH+n1TDUPv3RI+9w/y8U/cm7Sak8ZC9XqVwE8e45eojTNCAZM b0fA== X-Forwarded-Encrypted: i=1; AJvYcCXEV2LIiF4WunnZWDgzYZJy5t+0IbpxiVxaYyqs7+/Tx679vgOejOelhsAY/Ut6XX9mLggaNCnfLcJlDdM=@vger.kernel.org X-Gm-Message-State: AOJu0YwNi8YZ935gX9evYUHdVbwsK1f6EWe1gEOy30vt+WBsXOucvyVy FFhdcSqtv5rqixu8OUpWbfyzg5O/5emVgBU3/tCT6sViCiRV3L+unbgmNlPXryBK3i9ZpaWB7Nb dKwvfpGOqqA== X-Received: from dybkl9.prod.google.com ([2002:a05:7301:d09:b0:2c8:8992:d02a]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:1f09:b0:2c6:7f49:a86c with SMTP id 5a478bee46e88-2c9312811fdmr2053011eec.15.1775060018480; Wed, 01 Apr 2026 09:13:38 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:21 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-6-irogers@google.com> Subject: [PATCH v4 5/8] perf header: Refactor pipe mode end marker handling From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In non-pipe/data mode the header has a 256-bit bitmap representing whether a feature is enabled or not. In pipe mode features are written out in perf_event__synthesize_features as PERF_RECORD_HEADER_FEATURE events with a special zero sized marker for the last feature. If a new feature is added the last feature marker event appears as that feature from old pipe mode perf data. As the event is zero sized it will fail to be processed and generally terminate perf. Add a last_feat variable to the header that in non-pipe/data mode is just HEADER_LAST_FEATURE. In pipe mode compute the last_feat by handling zero sized feature events, assuming they are the marker and updating last_feat accordingly. Potentially a feature event could be zero sized and so still process the feature event, just ignore the error if it fails. As perf_event__process_feature can properly handle pipe mode data, migrate users to it except for report that still wants to group events and stop header printing with the last feature marker. Make perf_event__process_feature non-fatal in the case of a newer feature than this version of perf's HEADER_LAST_FEATURE, which was the behavior all users wanted. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 11 +---- tools/perf/builtin-report.c | 27 +++++------- tools/perf/builtin-script.c | 11 +---- tools/perf/util/data-convert-bt.c | 9 ++-- tools/perf/util/data-convert-json.c | 12 +---- tools/perf/util/header.c | 68 +++++++++++++++++++++++------ tools/perf/util/header.h | 4 +- tools/perf/util/intel-tpebs.c | 11 +---- 8 files changed, 75 insertions(+), 78 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 686ad08561d6..530348b6981b 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -313,15 +313,6 @@ static int process_sample_event(const struct perf_tool= *tool, return ret; } =20 -static int process_feature_event(const struct perf_tool *tool __maybe_unus= ed, - struct perf_session *session, - union perf_event *event) -{ - if (event->feat.feat_id < HEADER_LAST_FEATURE) - return perf_event__process_feature(session, event); - return 0; -} - static int hist_entry__stdio_annotate(struct hist_entry *he, struct evsel *evsel, struct perf_annotate *ann) @@ -875,7 +866,7 @@ int cmd_annotate(int argc, const char **argv) annotate.tool.id_index =3D perf_event__process_id_index; annotate.tool.auxtrace_info =3D perf_event__process_auxtrace_info; annotate.tool.auxtrace =3D perf_event__process_auxtrace; - annotate.tool.feature =3D process_feature_event; + annotate.tool.feature =3D perf_event__process_feature; annotate.tool.ordering_requires_timestamps =3D true; =20 annotate.session =3D perf_session__new(&data, &annotate.tool); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 343c0ada5ea1..95c0bdba6b11 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -245,25 +245,20 @@ static int process_feature_event(const struct perf_to= ol *tool, union perf_event *event) { struct report *rep =3D container_of(tool, struct report, tool); + int ret =3D perf_event__process_feature(tool, session, event); =20 - if (event->feat.feat_id < HEADER_LAST_FEATURE) - return perf_event__process_feature(session, event); + if (ret =3D=3D 0 && event->header.size =3D=3D sizeof(struct perf_record_h= eader_feature) && + (int)event->feat.feat_id >=3D session->header.last_feat) { + /* + * (feat_id =3D HEADER_LAST_FEATURE) is the end marker which means + * all features are received. + */ + if (rep->header_only) + session_done =3D 1; =20 - if (event->feat.feat_id !=3D HEADER_LAST_FEATURE) { - pr_err("failed: wrong feature ID: %" PRI_lu64 "\n", - event->feat.feat_id); - return -1; - } else if (rep->header_only) { - session_done =3D 1; + setup_forced_leader(rep, session->evlist); } - - /* - * (feat_id =3D HEADER_LAST_FEATURE) is the end marker which - * means all features are received, now we can force the - * group if needed. - */ - setup_forced_leader(rep, session->evlist); - return 0; + return ret; } =20 static int process_sample_event(const struct perf_tool *tool, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index b80c406d1fc1..4f95448c237a 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3943,15 +3943,6 @@ int process_cpu_map_event(const struct perf_tool *to= ol, return set_maps(script); } =20 -static int process_feature_event(const struct perf_tool *tool __maybe_unus= ed, - struct perf_session *session, - union perf_event *event) -{ - if (event->feat.feat_id < HEADER_LAST_FEATURE) - return perf_event__process_feature(session, event); - return 0; -} - static int perf_script__process_auxtrace_info(const struct perf_tool *tool, struct perf_session *session, union perf_event *event) @@ -4426,7 +4417,7 @@ int cmd_script(int argc, const char **argv) #ifdef HAVE_LIBTRACEEVENT script.tool.tracing_data =3D perf_event__process_tracing_data; #endif - script.tool.feature =3D process_feature_event; + script.tool.feature =3D perf_event__process_feature; script.tool.build_id =3D perf_event__process_build_id; script.tool.id_index =3D perf_event__process_id_index; script.tool.auxtrace_info =3D perf_script__process_auxtrace_info; diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index ba1c8e48d495..665bf8eea24b 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -1412,13 +1412,10 @@ static int process_feature_event(const struct perf_= tool *tool, struct convert *c =3D container_of(tool, struct convert, tool); struct ctf_writer *cw =3D &c->writer; struct perf_record_header_feature *fe =3D &event->feat; + int ret =3D perf_event__process_feature(tool, session, event); =20 - if (event->feat.feat_id < HEADER_LAST_FEATURE) { - int ret =3D perf_event__process_feature(session, event); - - if (ret) - return ret; - } + if (ret) + return ret; =20 switch (fe->feat_id) { case HEADER_HOSTNAME: diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 6a626322476a..4b1b2f7bed25 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -326,16 +326,6 @@ static void output_headers(struct perf_session *sessio= n, struct convert_json *c) output_json_format(out, false, 2, "]"); } =20 -static int process_feature_event(const struct perf_tool *tool __maybe_unus= ed, - struct perf_session *session, - union perf_event *event) -{ - if (event->feat.feat_id < HEADER_LAST_FEATURE) - return perf_event__process_feature(session, event); - - return 0; -} - int bt_convert__perf2json(const char *input_name, const char *output_name, struct perf_data_convert_opts *opts __maybe_unused) { @@ -375,7 +365,7 @@ int bt_convert__perf2json(const char *input_name, const= char *output_name, c.tool.auxtrace =3D perf_event__process_auxtrace; c.tool.event_update =3D perf_event__process_event_update; c.tool.attr =3D perf_event__process_attr; - c.tool.feature =3D process_feature_event; + c.tool.feature =3D perf_event__process_feature; c.tool.ordering_requires_timestamps =3D true; =20 if (opts->all) { diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 50c006be895f..a940edeb7ab5 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3809,11 +3809,11 @@ static int perf_file_section__fprintf_info(struct p= erf_file_section *section, struct feat_fd ff; =20 if (lseek(fd, section->offset, SEEK_SET) =3D=3D (off_t)-1) { - pr_debug("Failed to lseek to %" PRIu64 " offset for feature " - "%d, continuing...\n", section->offset, feat); + pr_debug("Failed to lseek to %" PRIu64 " offset for feature %s (%d), con= tinuing...\n", + section->offset, header_feat__name(feat), feat); return 0; } - if (feat >=3D HEADER_LAST_FEATURE) { + if (feat >=3D ph->last_feat) { pr_warning("unknown feature %d\n", feat); return 0; } @@ -3865,7 +3865,7 @@ int perf_header__fprintf_info(struct perf_session *se= ssion, FILE *fp, bool full) return 0; =20 fprintf(fp, "# missing features: "); - for_each_clear_bit(bit, header->adds_features, HEADER_LAST_FEATURE) { + for_each_clear_bit(bit, header->adds_features, header->last_feat) { if (bit) fprintf(fp, "%s ", feat_ops[bit].name); } @@ -4195,7 +4195,7 @@ int perf_header__process_sections(struct perf_header = *header, int fd, if (err < 0) goto out_free; =20 - for_each_set_bit(feat, header->adds_features, HEADER_LAST_FEATURE) { + for_each_set_bit(feat, header->adds_features, header->last_feat) { err =3D process(sec++, header, feat, fd, data); if (err < 0) goto out_free; @@ -4410,6 +4410,7 @@ int perf_file_header__read(struct perf_file_header *h= eader, ph->data_offset =3D header->data.offset; ph->data_size =3D header->data.size; ph->feat_offset =3D header->data.offset + header->data.size; + ph->last_feat =3D HEADER_LAST_FEATURE; return 0; } =20 @@ -4425,8 +4426,8 @@ static int perf_file_section__process(struct perf_fil= e_section *section, }; =20 if (lseek(fd, section->offset, SEEK_SET) =3D=3D (off_t)-1) { - pr_debug("Failed to lseek to %" PRIu64 " offset for feature " - "%d, continuing...\n", section->offset, feat); + pr_debug("Failed to lseek to %" PRIu64 " offset for feature %s (%d), con= tinuing...\n", + section->offset, header_feat__name(feat), feat); return 0; } =20 @@ -4459,6 +4460,8 @@ static int perf_file_header__read_pipe(struct perf_pi= pe_file_header *header, if (ph->needs_swap) header->size =3D bswap_64(header->size); =20 + /* The last feature is written out as a 0 sized event and will update thi= s value. */ + ph->last_feat =3D 0; return 0; } =20 @@ -4691,31 +4694,68 @@ int perf_session__read_header(struct perf_session *= session) return -ENOMEM; } =20 -int perf_event__process_feature(struct perf_session *session, +int perf_event__process_feature(const struct perf_tool *tool __maybe_unuse= d, + struct perf_session *session, union perf_event *event) { struct feat_fd ff =3D { .fd =3D 0 }; struct perf_record_header_feature *fe =3D (struct perf_record_header_feat= ure *)event; + struct perf_header *header =3D &session->header; int type =3D fe->header.type; - u64 feat =3D fe->feat_id; + int feat =3D (int)fe->feat_id; int ret =3D 0; bool print =3D dump_trace; + bool last_feature_mark =3D false; =20 if (type < 0 || type >=3D PERF_RECORD_HEADER_MAX) { pr_warning("invalid record type %d in pipe-mode\n", type); return 0; } - if (feat =3D=3D HEADER_RESERVED || feat >=3D HEADER_LAST_FEATURE) { - pr_warning("invalid record type %d in pipe-mode\n", type); + if (feat =3D=3D HEADER_RESERVED) { + pr_warning("invalid reserved record type in pipe-mode\n"); + return -1; + } + if (feat < 0 || feat =3D=3D INT_MAX) { + pr_warning("invalid value for feature type %x\n", feat); + return -1; + } + if (feat >=3D header->last_feat) { + if (event->header.size =3D=3D sizeof(*fe)) { + /* + * Either an unexpected zero size feature or the + * HEADER_LAST_FEATURE mark. + */ + if (feat > header->last_feat) + header->last_feat =3D min(feat, HEADER_LAST_FEATURE); + last_feature_mark =3D true; + } else { + /* + * A feature but beyond what is known as in + * bounds. Assume the last feature is 1 beyond this + * feature. + */ + session->header.last_feat =3D min(feat + 1, HEADER_LAST_FEATURE); + } + } + if (feat >=3D HEADER_LAST_FEATURE) { + if (!last_feature_mark) { + pr_warning("unknown feature %d for data file version (%s) in this versi= on of perf (%s)\n", + feat, header->env.version, perf_version_string); + } + return 0; + } + if (event->header.size < sizeof(*fe)) { + pr_warning("feature header size too small\n"); return -1; } - ff.buf =3D (void *)fe->data; ff.size =3D event->header.size - sizeof(*fe); - ff.ph =3D &session->header; + ff.ph =3D header; =20 if (feat_ops[feat].process && feat_ops[feat].process(&ff, NULL)) { - ret =3D -1; + // Processing failed, ignore when this is the last feature mark. + if (!last_feature_mark) + ret =3D -1; goto out; } =20 diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index ca22030a1434..41ce663d93ff 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -109,6 +109,7 @@ struct perf_header { u64 data_size; u64 feat_offset; DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); + int last_feat; struct perf_env env; }; =20 @@ -172,7 +173,8 @@ int perf_header__process_sections(struct perf_header *h= eader, int fd, =20 int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full); =20 -int perf_event__process_feature(struct perf_session *session, +int perf_event__process_feature(const struct perf_tool *tool, + struct perf_session *session, union perf_event *event); int perf_event__process_attr(const struct perf_tool *tool, union perf_even= t *event, struct evlist **pevlist); diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c index 2af5455488b2..8b615dc94e9e 100644 --- a/tools/perf/util/intel-tpebs.c +++ b/tools/perf/util/intel-tpebs.c @@ -216,15 +216,6 @@ static int process_sample_event(const struct perf_tool= *tool __maybe_unused, return 0; } =20 -static int process_feature_event(const struct perf_tool *tool __maybe_unus= ed, - struct perf_session *session, - union perf_event *event) -{ - if (event->feat.feat_id < HEADER_LAST_FEATURE) - return perf_event__process_feature(session, event); - return 0; -} - static void *__sample_reader(void *arg __maybe_unused) { struct perf_session *session; @@ -237,7 +228,7 @@ static void *__sample_reader(void *arg __maybe_unused) =20 perf_tool__init(&tool, /*ordered_events=3D*/false); tool.sample =3D process_sample_event; - tool.feature =3D process_feature_event; + tool.feature =3D perf_event__process_feature; tool.attr =3D perf_event__process_attr; =20 session =3D perf_session__new(&data, &tool); --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 2103E477E57 for ; Wed, 1 Apr 2026 16:13:41 +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=1775060023; cv=none; b=Iamv/6vFRDhm4HMBzi4sn9t/obFrGbh2Pd8H/VL2sJcsC3bDJ76ccizZix2JNxrg9J1jLQk8zM2rvE808N9Iha2O/gAxsh1tzyWujw7t1Y+r1xgtEuXoqbHTJ4J0PAl4ISVzXYyF0+sgs+wc7rUdDJXnMQ7/Tj6pCWbbusMz3yU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060023; c=relaxed/simple; bh=YXtKPFZbWWZBopwp0wtvWhgawI8Cv5FypUVRsO7wl+U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rDKs6L5Rb6RMUaF5OOxyrz1aHrE1+O+fuRBx79kmOBGmn0z8SDMIL0o7IQkqgbr04+i9OIxy63iTY0IQdnsZ13EZ+BfkC/Gkt8Va9PeZdUCpt/PxcmBd4WCU1/d5UGiE5M16X0OBBljRWIKJL1T2bhRnQe6/UrB8NG8OqZxpzXo= 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=U6OIrRi4; 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="U6OIrRi4" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127337c8e52so15020635c88.1 for ; Wed, 01 Apr 2026 09:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060021; x=1775664821; 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=mXhmCfoDGbEzRy0vkOhlRcCB2RW/wzuPXoAXA+lWSZE=; b=U6OIrRi4qROE3ukRboDnhOaAC15PiPc8NPMazpoWSrCn04eOXdEWiNs7UR4FwMPyiW lnoP6tTH2xbZN6miScS2bi5Ou9enzcLaZh2tRAqzTJjJviazPJCLIEiJ8KYqFqWmcVYr /gwu87cl6Ktt4cBCas8vKT8Dzctq4gX9JwNVDOuUUKt5X0AbtM3o3BNzsOs12NLHr9eM vLpSfVl/+lXM4RN8OWPuohRoSt5aucU9+N0WulyuWbNY+sFcKMDsUvJUEkOfaUuZubQq 8fFA2V5fSwxoCyCZ1j2LQuwf0K+oaFqwC6HwvRZ3KHZYLE7b6GMs8F+LB1DNCjv5N3q0 SLMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060021; x=1775664821; 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=mXhmCfoDGbEzRy0vkOhlRcCB2RW/wzuPXoAXA+lWSZE=; b=ih2sQCRpRLCDxvJSI4VvQvqz5yEMxP4E8Q8twjT9u72y+CZ7/T7Js2lbNsgUH01NA8 i+x+DopB9lgc2HoKPDGEKs4QBH8921Acf6XqXxAYtVq/iYEWPuXGlKZN7NFQjVtvoPHW yNAW4LZlRzIt5mHLVfSb1MOPVk3WHMWucGC7a6ffqXjOk41c53cYfpCza+WAccVFmktx KNumY81BeN+CCmLU81w1YYDAPjXAHf7ITEMC5srwWA6azyL5SbUGKN/3th1kJjDEX2KM 2Z3ltRfZy31h0uk72ptsrzl0SfkgM2/mGaKdQO7modMUZStlz0hhyMqngVpYn5ibX1hY GgsA== X-Forwarded-Encrypted: i=1; AJvYcCVW08fAtIHD56kbKQnOSMyWT7+dFs7Qumhz27RHPyk5tkq1ali9aGNvwEuilBGp5tpRnaSu1NgPE/Tf8Pk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+nUi1kLSqZSSetXRlGQiS+AwgalByF72HzdueAy2CV/QbP7OZ xr3zZ0ZYWsBTmdKmMt0lILGEfCOvS4TXTtdjrTtPmE4Dqkf6Lo3h12/O4b13596Sbk5cex81HI6 MPYThVE/RwA== X-Received: from dlag5.prod.google.com ([2002:a05:701b:2505:b0:12a:7b92:3d63]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:7a3:b0:11b:9b9f:426b with SMTP id a92af1059eb24-12be6557586mr2641472c88.20.1775060020875; Wed, 01 Apr 2026 09:13:40 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:22 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-7-irogers@google.com> Subject: [PATCH v4 6/8] perf ordered-events: Event processing consistency with the regular reader From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some event processing functions like perf_event__process_tracing_data return a zero or positive value on success. Ordered event processing handles any non-zero value as an error, which is inconsistent with reader__process_events and reader__read_event that only treat negative values as errors. Make the ordered events error handling consistent with that of the events reader. Signed-off-by: Ian Rogers --- tools/perf/util/ordered-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-eve= nts.c index 8c62611f10aa..a5857f9f5af2 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -243,7 +243,7 @@ static int do_flush(struct ordered_events *oe, bool sho= w_progress) if (iter->timestamp > limit) break; ret =3D oe->deliver(oe, iter); - if (ret) + if (ret < 0) return ret; =20 ordered_events__delete(oe, iter); --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 975BF478871 for ; Wed, 1 Apr 2026 16:13:43 +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=1775060024; cv=none; b=awmNGP3WqDA/ThwxcjltacqI1S19NFGAlEpJC+YwuyQvXGLXcvHyHZaLsG1LojT2b4kwtOQ2zOo9PXF4pdTlwpL+xj0EMczbfXKn5X2euXdsMe7AHd6zBcmPmSxDopSD8Yw2RfklE0d31jPY+t6IrKr8xSzNhlH9oE/beOgcPhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060024; c=relaxed/simple; bh=6ubSl4mQOS2cDCE+bYaE4aL6nqQ5aKfnZ4KXJ4LgEkQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Xi2/cDHrtzPSIFCWFyM42tl8ZPHkrilW06UiBCwKtT7M390c35P7PgXWBMyFbmY8qYIAObgFokMfVFjagk8tx072CRLO0oGA3+iqQMhnAv670Rl8dAR+j8kUNOHIsoFzse26u6wsscbDgf0S/71/x+iYNw3DYTs6r3j/vYL59hA= 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=F2SR5+5b; 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="F2SR5+5b" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127876be621so999989c88.1 for ; Wed, 01 Apr 2026 09:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060023; x=1775664823; 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=rCJ4l1oK32c2aW0VPxyI7wG69g3+cb8rh2zHyRRWSPE=; b=F2SR5+5bKg313Ao3uZ9mFg10piNFt4abmGLqQih6VsS3w5imlorPYM5A8y9LmVYoC1 KfHnigPF1Qbo5PhMiHRf2bd8rotETFuNVQa/QViw0MdzkYJ4tka56Bhr7HVvt/C5nzqx +sF65QnnobtgD7QwU43G5+FYIQlocJ/eBAoiOSGIsK3j/4XKfAZeYRtCj9c14f3IvA4N YPKKZdk0mVnqwhzaPW9mNpy/+DcoYNfhQifizotQa0ScaOOpyCFpCcHAaZaMFMlJFfxe ewsEg1/uES1C9ce1TlkAsRAjNq8s8ZDltO6DP0Tipo9lt7i7LONhtwCdF4klpBOCCReF So0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060023; x=1775664823; 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=rCJ4l1oK32c2aW0VPxyI7wG69g3+cb8rh2zHyRRWSPE=; b=ix2H8wTAaZPcty9qLvPNrel8+CkHIOTEnOx1vpWWwURMs5mbQ6J5F0xZolKE7FkPA8 L1s6hcTgOgyoYmj6Z1HAXCkJrdfqDMjQDbsxsteX32r1GIGz5g0x7wxSaiGdgpbuvBO3 vbIiHJglJqPikrKO2r4JseCju975+ZAnUMOtF5W+QN3p10po/fNCV9z3kJsp2R4x4p4o VEMMWvSwOhRxKXhF1MKAOSesLhWwYpNTey/JMQ/nAW006Tur/4Ctf6RVC/9LEH/6B8yE AFwOMEcAOah0d62kh42+KLlLKLMH6tKUQ+imaqeu/TdyqshKdb710+h4mGM45UyI8Pui CyCA== X-Forwarded-Encrypted: i=1; AJvYcCUYFaMXg3vqd+u03Of0p9TjCPgtg0KZK9eiztpPpvj7L0Ub7zASIHOeonAXdogdcrCCTJa1PcDWbDvxJb8=@vger.kernel.org X-Gm-Message-State: AOJu0YzfV0gEf4uTDH09XAYTJUKYyMJzGEeeZ7oLlbAew3MpxloQJ1e2 heKnpQwebukJyFXDSlvR75+3QwE5GrcxytifZfw8nuQbEXGISlXPgYzYMU15JBbVZRZ0dP2uIeX GkHp0A2MVKQ== X-Received: from dlbvg26.prod.google.com ([2002:a05:7022:7f1a:b0:12a:c608:a29b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:2390:b0:12a:6d05:3941 with SMTP id a92af1059eb24-12bdde10310mr3832543c88.2.1775060022593; Wed, 01 Apr 2026 09:13:42 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:23 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-8-irogers@google.com> Subject: [PATCH v4 7/8] perf evsel: Make unknown event names more unique From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In situations like the perf data converter the evsel__name will be used to create babeltrace events. If the events have the same name then creation can fail. Avoid these failures by including more information into the unknown event names. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 5a294595a677..1281af056cec 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -926,7 +926,8 @@ const char *evsel__name(struct evsel *evsel) break; =20 case PERF_TYPE_TRACEPOINT: - scnprintf(bf, sizeof(bf), "%s", "unknown tracepoint"); + scnprintf(bf, sizeof(bf), "unknown tracepoint id=3D%#"PRIx64, + evsel->core.attr.config); break; =20 case PERF_TYPE_BREAKPOINT: @@ -938,8 +939,8 @@ const char *evsel__name(struct evsel *evsel) break; =20 default: - scnprintf(bf, sizeof(bf), "unknown attr type: %d", - evsel->core.attr.type); + scnprintf(bf, sizeof(bf), "unknown event PMU=3D%d config=3D%#"PRIx64, + evsel->core.attr.type, evsel->core.attr.config); break; } =20 --=20 2.53.0.1118.gaef5881109-goog From nobody Wed Apr 1 20:37:29 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 8E446478E49 for ; Wed, 1 Apr 2026 16:13:45 +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=1775060026; cv=none; b=YIptrGYgs07vfYKO9QcPEbEG4IN2hndIAUwQnIOYm7QpI94uX9HRDB5mCpTYwrHdqbFy7dmyCh9KSh1Tiwfy7ZmVRBB89NUKtwE0U76CqkDD1yZZgj0dGqy4RCfZN4xSuwvzVIqGNQi0luEVhpOCMTZWGFl4kroTbzl9E4O/nNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775060026; c=relaxed/simple; bh=abvX/CdYXf1z0V/pYoLfI9bKqCOKdcOm41xIkkZrNoI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=i5Na/YqWSRX6oeX2uOPwBpuBjXJ81t+pEpfW0txLUT1qO/n93e7hLz6Zlu1mSaZN2kd7+ZZiA7374KMJf2DHNPB9Wu0rmklC7kKWxxRU7ze3CHp4Q9DGkJNeoBVbxazV8pMpU8nL/84+OxjFEq8yQNM8sOtWgawLto9tAnmcizc= 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=czs3xc/8; 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="czs3xc/8" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12711ec96fbso1128332c88.0 for ; Wed, 01 Apr 2026 09:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775060025; x=1775664825; 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=lsV4SuzH+dJOzt/rj3hoFEqVCugrtnIk7rnjy9TZFug=; b=czs3xc/8g48uRTNjRURwjpAeVSCwvWNsEkFrxz9W+t9Fa+dNkx7nfisvlQWGkPTn/4 S2/v2X3Dlcg8oviaCFEu5ORb3AYdt4TcTE5CH2fXoPWCqS+vlyy3XDxs1z+Now24ieBX PceV6tK42+xxWqo/Yeho6TGCb47dYIOTC0i5HakluPYo2i7zVU7sKtztyLghDf20JfzY ns11+xkKLiK+unZbz9jUKUm6ubUYppgwtDwaJQxp3caSHuL9k9zvmSMc31z07as+dVBu Otwjo0ELCKU7R95DiHnywvR+w2ROgfKuMBHrVfs7zkcnA3lZ3jKHau6/IABvZZ3dpYm+ i2rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775060025; x=1775664825; 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=lsV4SuzH+dJOzt/rj3hoFEqVCugrtnIk7rnjy9TZFug=; b=aWej3OR8WpHalekH101vsSuowzUO2P55Hzzw1k+5bWpWolfMA+42nc8uZzso4cBRXl 3Wjtj0FojGXmW0td3GldiGgq0cb841CbGL4LiwZLSL5IHZFAkJ/sbfibPe3DQjP2M62J E35cch/CqpebVqefhWdmkFUh686ZPFIRsVeYpDAWLtawfT14URxB7ES3VwtM/6zkJHRE k+Lqj9Ah9yqUYVwvayxEcMNmW5lDbayTYX/C1PyKpljhuP07uDYSrJ1V7IrCv/3vCU6d K1pEZbTd7Lrm3yGvCn78unoZ0ykYeA9VCtoqfp7W6IbUMOjC1ySsNNAxKEgdXXbMV4UK HsSw== X-Forwarded-Encrypted: i=1; AJvYcCWyNOI8hKCJ5m3qx9Wp0jWd5Jci5hcNox4uRYHG/kNzXSI2BNEAxo41HOoB4KKGYVvEPnvDRIpYqTYCPl0=@vger.kernel.org X-Gm-Message-State: AOJu0YxGWTywkRnH32//VVAvoLY5fHctZ8LYvQIoBLVBJ1b0qDR1NFbc QwV6BkG+Yb70p41MEOVMdc9uCpRcd/A5EO0oa41JfbZkMNa/rxswqwycc3aaFPGauGKhMKNUqZ1 Oqu+aIXP4Ig== X-Received: from dlbsn4.prod.google.com ([2002:a05:7022:b904:b0:12a:80f3:8f8a]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:f509:b0:124:9acd:328d with SMTP id a92af1059eb24-12be64ed2abmr1358812c88.22.1775060024586; Wed, 01 Apr 2026 09:13:44 -0700 (PDT) Date: Wed, 1 Apr 2026 09:13:24 -0700 In-Reply-To: <20260401161324.332356-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: <20260401055206.43187-1-irogers@google.com> <20260401161324.332356-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260401161324.332356-9-irogers@google.com> Subject: [PATCH v4 8/8] perf data convert ctf: Pipe mode improvements From: Ian Rogers To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ashelat@redhat.com, ctshao@google.com, derek.foreman@collabora.com, howardchu95@gmail.com, hrishikesh123s@gmail.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, swapnil.sapkal@amd.com, thomas.falcon@intel.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Handle the finished_round event. Set up the CTF events when the feature event desc is read. In pipe mode the attr events will create the evsels and the feature event desc events will name the evsels. The CTF events need the evsel name, so wait until feature event descs are read (in pipe mode) before setting up the events except for tracepoint events. Handle the tracing_data event so that tracepoint information is available when setting up tracepoint events. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-bt.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 665bf8eea24b..20f8b81c3d9b 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -1181,6 +1181,10 @@ static int add_event(struct ctf_writer *cw, struct e= vsel *evsel) const char *name =3D evsel__name(evsel); int ret; =20 + if (evsel->priv) { + pr_err("Error: attempt to add already added event %s\n", name); + return -1; + } pr("Adding event '%s' (type %d)\n", name, evsel->core.attr.type); =20 event_class =3D bt_ctf_event_class_create(name); @@ -1223,13 +1227,28 @@ static int add_event(struct ctf_writer *cw, struct = evsel *evsel) return -1; } =20 -static int setup_events(struct ctf_writer *cw, struct perf_session *sessio= n) +enum setup_events_type { + SETUP_EVENTS_ALL, + SETUP_EVENTS_NOT_TRACEPOINT, + SETUP_EVENTS_TRACEPOINT_ONLY, +}; + +static int setup_events(struct ctf_writer *cw, struct perf_session *sessio= n, + enum setup_events_type type) { struct evlist *evlist =3D session->evlist; struct evsel *evsel; int ret; =20 evlist__for_each_entry(evlist, evsel) { + bool is_tracepoint =3D evsel->core.attr.type =3D=3D PERF_TYPE_TRACEPOINT; + + if (is_tracepoint && type =3D=3D SETUP_EVENTS_NOT_TRACEPOINT) + continue; + + if (!is_tracepoint && type =3D=3D SETUP_EVENTS_TRACEPOINT_ONLY) + continue; + ret =3D add_event(cw, evsel); if (ret) return ret; @@ -1418,6 +1437,18 @@ static int process_feature_event(const struct perf_t= ool *tool, return ret; =20 switch (fe->feat_id) { + case HEADER_EVENT_DESC: + /* + * In non-pipe mode (not here) the evsels combine the desc with + * the perf_event_attr when it is parsed. In pipe mode the + * perf_event_attr events appear first and then the event desc + * feature events that set the names appear after. Once we have + * the full evsel data we can generate the babeltrace + * events. For tracepoint events we still don't have the tracing + * data and so need to wait until the tracing data event to add + * those events to babeltrace. + */ + return setup_events(cw, session, SETUP_EVENTS_NOT_TRACEPOINT); case HEADER_HOSTNAME: if (session->header.env.hostname) { return bt_ctf_writer_add_environment_field(cw->writer, "host", @@ -1448,6 +1479,26 @@ static int process_feature_event(const struct perf_t= ool *tool, return 0; } =20 +static int process_tracing_data(const struct perf_tool *tool, + struct perf_session *session, + union perf_event *event) +{ + struct convert *c =3D container_of(tool, struct convert, tool); + struct ctf_writer *cw =3D &c->writer; + int ret; + + ret =3D perf_event__process_tracing_data(tool, session, event); + if (ret < 0) + return ret; + + /* + * Now the attr was set up by the attr event, the name by the feature + * event desc event and the tracepoint data set up above, the tracepoint + * babeltrace events can be added. + */ + return setup_events(cw, session, SETUP_EVENTS_TRACEPOINT_ONLY); +} + static int ctf_writer__setup_clock(struct ctf_writer *cw, struct perf_session *session, bool tod) @@ -1677,9 +1728,10 @@ int bt_convert__perf2ctf(const char *input, const ch= ar *path, c.tool.exit =3D perf_event__process_exit; c.tool.fork =3D perf_event__process_fork; c.tool.lost =3D perf_event__process_lost; - c.tool.tracing_data =3D perf_event__process_tracing_data; + c.tool.tracing_data =3D process_tracing_data; c.tool.build_id =3D perf_event__process_build_id; c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.finished_round =3D perf_event__process_finished_round; c.tool.attr =3D perf_event__process_attr; c.tool.feature =3D process_feature_event; c.tool.ordering_requires_timestamps =3D true; @@ -1724,8 +1776,11 @@ int bt_convert__perf2ctf(const char *input, const ch= ar *path, if (ctf_writer__setup_env(cw, session)) goto free_writer; =20 - /* CTF events setup */ - if (setup_events(cw, session)) + /* + * CTF events setup. Note, in pipe mode no events exist yet (they come + * in via events) and so this does nothing. + */ + if (setup_events(cw, session, SETUP_EVENTS_ALL)) goto free_writer; =20 if (opts->all && setup_non_sample_events(cw, session)) --=20 2.53.0.1118.gaef5881109-goog