From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC4E31E907B for ; Mon, 18 Nov 2024 22:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970463; cv=none; b=bqTNBAiEP/dkn2fKe06rube0Bwy2AM1Msrfcr/JE+eLk4XgPmbf3fk87PIKfZx7I6V988wG4bQrU1NOjPT7cFzG0b/9UDdwbviyDesrFaSK5z4xpa/+qPDWDZw3BkJ8noqjd6kLoy+DucG/RrQSW16F2B//wVP6U0HHr4Xk91v8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970463; c=relaxed/simple; bh=HXojo0/fTP/zExJdIYj45kNltzewwVI4CI/1w1068zE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NsBeL39l/uuE8i389PKxMOCpAvPkl6QLwYPxwVTYojYZBipP8u3Ru0nbQsZjngjK8RwbqcwrJeaVUTFGdF5G7ymERa4zz7/in5IG3HH3TzjFoCov2bVSbr6igJrLrqjbPQlo85R+bUngZGp0GuRpRP2fzlrKTXhQWVf7gZTSz/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=etIWfmx/; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="etIWfmx/" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ee51558e90so65567767b3.1 for ; Mon, 18 Nov 2024 14:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970461; x=1732575261; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wcPgicYw7lNCwZ4lAX6Rp3LicdE0a0SwYEgY1Pd6MHA=; b=etIWfmx/7Ui/YXmuyzC2Ajhf4eUTjT+ZM1rVZBULXdnvMhQqeFnbuv2gmcYY4unqPy AoEPfloENysARJLvCwapik2LLadhNJ2uHxfnmduBOygzw1UMGNqsGEHUDPXEgRxj6TGR oTIFJlD14YVpT8a90BJ7Kg8PWVmiBTaTtKxQG/tkhItGrjWC1JN4dxTI4LzFHCcUj/52 95z+BjJWKs73HW91+zUNdTOpu5FXxqQ0vrHsFerQnbxY+xP3iI6hc19tdWYEC/p2hZO1 3yV81antg5Wh4JlvU5nTmgLrTPNCljq0Xl2tqgt/0egHsWlXbMCIo7LbICQYzjcuPdf1 zWWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970461; x=1732575261; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wcPgicYw7lNCwZ4lAX6Rp3LicdE0a0SwYEgY1Pd6MHA=; b=gUxsDUNO06Q/doSfHuLtdGgSCivp+i9g26aJFj5r3Kevzsv6DWTg3XQtusYGgytGL7 SCk1K0t8A57MQKFcjG7rZAticZ0t9nFO9X8q1aYTJgtE1hRXvsBZUQZvQ0Dq964xq82X IfESRmw5im21qbFmJBUPtsSDNrXN3E1m5Bqg3bmwYB66WDD+M+YP8i7E1d2pUSwAaFJO vm0qtpB83sm/br7EFuDx+CYzYK7yGOLA8mIj8ntk+aCCPrcSSJAjAwXbGHNAs+haixjK 5vlvbBc91T0m8pqclCGB4fjZ16yP7bwuqs9znFh80r8xCDuWNZMcXt62fk1laE/hk8Xg vTjQ== X-Forwarded-Encrypted: i=1; AJvYcCW6tvJalYHDhv4A+/LOQH9VV+NGXc98C5mSWrAFCMWD5d0Zq20IspcrVMis1W6zzNdTyB3YByUNaXh4Z/I=@vger.kernel.org X-Gm-Message-State: AOJu0YyqA5VvvRMjzP5BUdjqv8O3vjJQc0YcHFeTQlciHJBGTKD0q7C4 J4lkEYxHBSwz/FRuh+Lw94BpE5hmC2w/J+Y6wfDUgaaxyt0+GDvx/H1IR4THcEZ7WA8UknySWtO sDl//ow== X-Google-Smtp-Source: AGHT+IGPv4JaCyn7zRXGpIzy8isHlbIcxqrVk715hTkaLLRFHcVSEMYfjdPn9FY18xv6x3jHLXZWo0bjlfhy X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a05:690c:6585:b0:6e2:371f:4aef with SMTP id 00721157ae682-6ee55c95c78mr1282587b3.3.1731970460841; Mon, 18 Nov 2024 14:54:20 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:39 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 1/7] perf env: Ensure failure broken topology file reads are always -1 encoded From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" get_core_id returns 0 on success and a negative errno value on error. Currently the error can only be -1, but fixing this to be any errno value breaks perf: https://lore.kernel.org/lkml/Zzu4Sdebve-NXEMX@google.com/ To avoid this, make sure all error values are written as -1. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/perf/util/env.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index e2843ca2edd9..e890a52e01a6 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -326,10 +326,13 @@ int perf_env__read_cpu_topology_map(struct perf_env *= env) =20 for (idx =3D 0; idx < nr_cpus; ++idx) { struct perf_cpu cpu =3D { .cpu =3D idx }; + int core_id =3D cpu__get_core_id(cpu); + int socket_id =3D cpu__get_socket_id(cpu); + int die_id =3D cpu__get_die_id(cpu); =20 - env->cpu[idx].core_id =3D cpu__get_core_id(cpu); - env->cpu[idx].socket_id =3D cpu__get_socket_id(cpu); - env->cpu[idx].die_id =3D cpu__get_die_id(cpu); + env->cpu[idx].core_id =3D core_id >=3D 0 ? core_id : -1; + env->cpu[idx].socket_id =3D socket_id >=3D 0 ? socket_id : -1; + env->cpu[idx].die_id =3D die_id >=3D 0 ? die_id : -1; } =20 env->nr_cpus_avail =3D nr_cpus; --=20 2.47.0.338.g60cca15819-goog From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BE911EABB5 for ; Mon, 18 Nov 2024 22:54:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970468; cv=none; b=L1jIAf+WHaNKNknE6m3kqIeBfqDwb1RlkQ7kJHNgL50grsOSOI34q9GC9uDeEaQ9FOpeMyMspFMuRbJ1eLMzSZBbgHvdoIo8pPde9qI2VfVhzOlHOE0PCOdfRZj6B3RTp6OB+zlRT43akbY1WkFPWh/+j8nZYne147NkWDhN+T8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970468; c=relaxed/simple; bh=VX9TWUF2qGeJZiWNv+7mi/FjvE3szYCNmmy+gilPg2g=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SQu0pbkHLgCvYZ9pNBTLZjJ74EguybbrTLPgE+rUkiHW5rwE7ztTHU6FOtLwb2UtdiT6TXgwyvKSGnugzruZZr3vPRbRiJeAUoTZCsZJDVDDBNM4mgZg6YxgRuTJ6UoICvQS/dYS3INe91hxBGaUATpOjC6au/vCG+dwbPkCT3U= 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=SIPYB+Hp; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SIPYB+Hp" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e3810bac8a7so596293276.0 for ; Mon, 18 Nov 2024 14:54:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970465; x=1732575265; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=rQtEfOo4KPSbQdX3jmc6H31yrRxVNnjZvuIGaMQg2zI=; b=SIPYB+HpXzKCFxvCt8vWLeDj2M33d0jQH1lbIz9v5oQX0AH6hDggi4Y2bpae0QF4/b fDayX+oIYE6svke4THPe7iSSbv3CzzOzu3/Oo6r7StmRkbUDQY7SXfTHIaeWDm8Ylhd1 ceJVZVz/3VGN3XXKa6aLXlITpDVJw+zKPCUfLq3HTeaIfOw76T1J+6MPWlpfoWqOx8Td WuEN/9cTDK6Mcg1Fy8iehQ3X+CALfu8KjMIBwLcmoDA+giZd0QAjj9eUG3+nFwiP68Q9 S6FhExRbEyi8dGfxVDcdRr0F/2JiOhPt6Pec4Zids4AfDMAKtWXFdQaNcSIvWB4RGyVz TQLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970465; x=1732575265; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rQtEfOo4KPSbQdX3jmc6H31yrRxVNnjZvuIGaMQg2zI=; b=FYGloIfuJOUZvA5WR9vT4Vw1a+HqAzkx18Tz95fwSV1zSnJdhEHfub4s6rscvM+HMq mowOPCFQ02eLU+CUgfjdAG7cdrNVnLV6jAZzA6YqLdz5YMRGnBHCtw7ByMrW0bu2Xu97 fCGmVOWbbTOMH5zDlA9sxoAD/SqojJc0w1AzskOE0oS8bLLT6xrF47ZQsNo1rF5mkv+h nIGDAlI8JN2R8fzPphuw7AA0dnoUeH9ghAJUmyIOUOC+xhzqi/vCRsB8QICPXbFzhSvd vuQBLzTt/F5tfeAFN0lMJWK1zKlPoZcsTWCErk0Hq2HE4ZgdBrb2dBiHA25QFPr/Mqa9 Evxg== X-Forwarded-Encrypted: i=1; AJvYcCXlPPADZnqJ9ZhW06yFr8eRNpjKhOedr8rQkTtLk2uSVWLyfLrLmNyHjKHh3Oa5l47T8uvLdyxKTFnSwtQ=@vger.kernel.org X-Gm-Message-State: AOJu0YytWHx13IG6tLUR8583TUSuwtiODGUR/G4RzNw7NlvdWFGqv5W1 +e4IfEmZp9wTXK0Qw/2ctd8dWNaGcqav5GPjpgSAVlqBzu2zfLf2y0PJU+02hKeqSmLIE5AZol5 lrY31Ww== X-Google-Smtp-Source: AGHT+IESymJgcL0iR2MG+SNvIYAz+LsVdc118GWunXIeRiiyTRrJ3UvGAsXkTRV4gaFo6qBZ/eIAB/2/E+Pu X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a25:c50e:0:b0:e28:eaba:356a with SMTP id 3f1490d57ef6-e38265f8620mr96382276.9.1731970465464; Mon, 18 Nov 2024 14:54:25 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:40 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 2/7] tool api fs: Correctly encode errno for read/write open failures From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch from returning -1 to -errno so that callers can determine types of failure. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/lib/api/fs/fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index 337fde770e45..edec23406dbc 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c @@ -296,7 +296,7 @@ int filename__read_int(const char *filename, int *value) int fd =3D open(filename, O_RDONLY), err =3D -1; =20 if (fd < 0) - return -1; + return -errno; =20 if (read(fd, line, sizeof(line)) > 0) { *value =3D atoi(line); @@ -314,7 +314,7 @@ static int filename__read_ull_base(const char *filename, int fd =3D open(filename, O_RDONLY), err =3D -1; =20 if (fd < 0) - return -1; + return -errno; =20 if (read(fd, line, sizeof(line)) > 0) { *value =3D strtoull(line, NULL, base); @@ -372,7 +372,7 @@ int filename__write_int(const char *filename, int value) char buf[64]; =20 if (fd < 0) - return err; + return -errno; =20 sprintf(buf, "%d", value); if (write(fd, buf, sizeof(buf)) =3D=3D sizeof(buf)) --=20 2.47.0.338.g60cca15819-goog From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28EEB1EB9F2 for ; Mon, 18 Nov 2024 22:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970472; cv=none; b=WJoq3c7KFoIxU8OWUeb99EkU4bzabm9W4TOndK/aLvXjUI/kJHZBvZEOplNfb6NnZv+7jUdqjSuupHqA2ryF7uz2VXULs4iQnOJx6kN30+ML4ZVXZBAyb4WjelnovZpqbhUAfivaEYevlTDohY+LhF80QPGwOVgdzHzpphymP8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970472; c=relaxed/simple; bh=vA5wDZ8FL6MLUmxSvynTx1BhyBJedSIPLTdOMqvm9LU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=jbIugOkLBrAoA95TWbDOtO4sgMSCT7nZ6KxJrt5H8P5X5833X7o9ZoCMWzc2VP3xgGF4VvcvyD0vbrAtkiXgXje157dilIoaJLUMSrKnYIz/5k1SUn2TVu5wmWbRFdRxGoZBWSefzAgIQ8giPn1zRD3AToAO/ypb+mT4Z1RMgh4= 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=Myh8Isev; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Myh8Isev" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e381f195051so533777276.3 for ; Mon, 18 Nov 2024 14:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970470; x=1732575270; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=55WiVKsndQFaxxZ4QGA42VCMnpZnpnS70BqjVyyPtNw=; b=Myh8IsevvdAU5pnEEY32Bi17LrAQApSh+W/j03qsmboTu2rVyd1f8RyuZFY2Hwz0+0 tUVW5d8HIv2CsdRuXcnKdteiplgCmHnqxs/jl28dF23qen0gdhwvcDTGaAuJHVanaWwM JQnvVkJIoDF9dhSbiUXu0xX/p8JurNnt+GIDcWEvcMY06w+VIn9kGV5BsPTqGTNN5VgW o4mt9a1favgmtEI7bfiSwTLcLVjdyQAO5tpn4f0z18yx6zigow67hTGv8PHLL8p1h/2f /kvE69rsFNF3V7F0mne0HWkvvabN3YRouO35gwvYefUBw9WwxsU0oi1PI1ZnKCl7bjBS y+VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970470; x=1732575270; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=55WiVKsndQFaxxZ4QGA42VCMnpZnpnS70BqjVyyPtNw=; b=GE6zHcydpprW6ca6TYxL0+PKNbbvMd32N3w4oOk7+ZoD6m/ZBr35suRbxgmv5Nw+aM QjUkniBpYE8iNtgLQ97T0fbbWCBqTFISUASy5dnT1sPBm8bU090OZUkYzrqYzzFxqK9D 414rn/Y+naZCPr7S9w1lxoWEhF4IE1xxihWfeRu6EE25aSfyM/Wdich8gJYBpwpzTK30 3HvRNXmh+rkM03jYPoVbCpKg/XTAbXAqBjkcjVmrqZfdz5+QbHdGI7P/4rn2d6iLVAE4 0uU4iMyDkTgpcRyQ8fa8CQ9qxtc5V0E4jhoIBF594p+IHZBCuYqAbDFZUIPAYi+WrJl2 RdCA== X-Forwarded-Encrypted: i=1; AJvYcCXso3zoRTmzY4Eao6DLZ0Y0I1U16q5buyKmFBMNdQBt42xVoHE7ltGh6jtMkokj8nRbgyZ4wmULZJSOYsY=@vger.kernel.org X-Gm-Message-State: AOJu0YwZgqs9/kh0qGjHs/7FgcfpKZcUN0KcMxT3jJbQz5YTqbqz4IWo wXd0jyo7puV+4otgFad3oaYNzq89rVn3TRX3O+kek5YRX9CW8EJQvmfABf+l0jqzuiknQlKHIR6 0SlQrtg== X-Google-Smtp-Source: AGHT+IEnzfOOnKnsl2wElo/yWtr4ZvRaQdLFyQfunTe1jiNtXAdPQKfXDrXow9PDuQmLSZJD3ZO4Ga/aIc2+ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a25:df87:0:b0:e38:7793:62b4 with SMTP id 3f1490d57ef6-e38779367b8mr151863276.10.1731970470161; Mon, 18 Nov 2024 14:54:30 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:41 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 3/7] perf trace-event: Constify print arguments From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Capture that these functions don't mutate their input. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/perf/util/trace-event-parse.c | 2 +- tools/perf/util/trace-event.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-ev= ent-parse.c index 41d53e1b43e7..9c015fc2bcfb 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -99,7 +99,7 @@ unsigned long long read_size(struct tep_event *event, voi= d *ptr, int size) return tep_read_number(event->tep, ptr, size); } =20 -void event_format__fprintf(struct tep_event *event, +void event_format__fprintf(const struct tep_event *event, int cpu, void *data, int size, FILE *fp) { struct tep_record record; diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 79b939f947dd..2543bf969fdd 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -39,7 +39,7 @@ trace_event__tp_format(const char *sys, const char *name); =20 struct tep_event *trace_event__tp_format_id(int id); =20 -void event_format__fprintf(struct tep_event *event, +void event_format__fprintf(const struct tep_event *event, int cpu, void *data, int size, FILE *fp); =20 int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long = size); --=20 2.47.0.338.g60cca15819-goog From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB3751EC003 for ; Mon, 18 Nov 2024 22:54:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970477; cv=none; b=Mo0mW5Fr5T2IHjWQCC9GqPzAcTGwJ9dhdO+blJHk+pLVx5vGxc26DgSzSag613yDYqW1xkF5EYzHQDDzQyTBbSq+O5N/8Af1vUATil+GrIymnUp4ZtUr5hTt8Tp45Ync6PCG1L6D7JVMHTD9IIh7cxoU3f8SSKp30PLFy5otnCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970477; c=relaxed/simple; bh=jLMv6psh26jQg+qmfgIhNouYWgAxBlI8CM4lBpCniiI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Uh3JpzsEO/jsjeKV83L9X8NkxL2iIQGVTmAlcyp34AkEunZjd1DM/JZ0GVJe83oZFB9yrAk1M3IiqEghVUziYWumwbEsPiZyJq0lVQ/PQgBrV76e7Pw3mjNkwaSS1LjwOC2+XTE1wRiVBMbd+ZP5vm9rapRILXr+DkG/NKZtZ2w= 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=d/qE3qxY; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="d/qE3qxY" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e384d715e96so3091644276.2 for ; Mon, 18 Nov 2024 14:54:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970475; x=1732575275; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=FG3Sh83F7FOGs8gw5xePFCnagv+uNMSUGfyFfbaEqMQ=; b=d/qE3qxYvq0s3SEdOaqjJUJbxxCqff56nE8M5v2GZzkTynKSP0TOMHF9CH+/0/OMVc be0Xg8W+zuERWtviR1l8VK035m+lSLbb4UzQoE63+/hVNHHOj5rMFy8z0eeo1g8eOqZs QN1xpNkB8MNXrTc3WjP1FsP5MD/1FUpd5KZ8fB8kB4Mr6OPd8Gt4bLwQejsIURERx/zV 5exjcs0ztjwtxFg4QnGiSIC/U8+MevsxtR1wNA0xcLztxRH/vC+lG6G/1Q6JbRVKvFZj 494FSegvlkQB36X/OsX+9T2ScFAS+kk8IovzdP5zscZDCnQblmwsfPEh09II6FCYZm+h 1RPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970475; x=1732575275; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FG3Sh83F7FOGs8gw5xePFCnagv+uNMSUGfyFfbaEqMQ=; b=scIfchYJoJYCKNkPx0TsqueVQA/iP3a+H1ugume07EBpvvhpHqmrT9JLATKyHndN2b qIWYNIPS8EXY+uFNBw3OazXQl3BdI64rSPK3dVrBeB/ZH3h3SRJPL31SrzontV20gDbb DpS0X/FmlhnzKblvPYcVNBqQPtIeXVHppEjwzcGH5uUx6Tl2XjvqIGdpn5vO913dF184 opgjyueuIEbRPvqKCKf8K0+XRk9wweqVkX22aDuzPyIxQau896JG79NKLXrdpDLlMGh2 65/0NavzNLwzozduxpXTwcKSzJSse748ELKrGLXGBKYj3bxgaLVNaSLAOZZF/Jwnd6iH 0yFQ== X-Forwarded-Encrypted: i=1; AJvYcCW9oBmoNlBEUS7+KbdQ3tI2axKsdxYj4YMCg2k1w43MCvQivsmGX0DFxwhqUBLUgpFufzOT2ISOZZtGKY8=@vger.kernel.org X-Gm-Message-State: AOJu0YyT11rJSy2XV6G1Sg2TF3yGaqeKJKn8mOoBFmganqRJs/LSejq1 WD173HtRAgpGUNGei/JMsQlM+vli7Vun60+AN5UaI6KqK8+V9K267D2vT0WkalVBiVpa7G/5l7y IC1s4Gg== X-Google-Smtp-Source: AGHT+IGl1aqGhFtUZ1apRuwVVnoRAl8J4uAIA9T+sYV7QTDRk/6WeLhJGKOFjO0Kn4m5EaYRZcmrmTJNmUYv X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a25:e0c5:0:b0:e38:22d8:e5f3 with SMTP id 3f1490d57ef6-e3825d27591mr174594276.2.1731970474602; Mon, 18 Nov 2024 14:54:34 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:42 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 4/7] perf trace-event: Always build trace-event-info.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" trace-event-info.c has no libtraceevent depdendencies, always build it and use it in builtin-record and perf_event_attr printing. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/perf/builtin-record.c | 2 -- tools/perf/util/Build | 2 +- tools/perf/util/perf_event_attr_fprintf.c | 4 ---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f83252472921..0b637cea4850 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1748,10 +1748,8 @@ static void record__init_features(struct record *rec) if (rec->no_buildid) perf_header__clear_feat(&session->header, HEADER_BUILD_ID); =20 -#ifdef HAVE_LIBTRACEEVENT if (!have_tracepoints(&rec->evlist->core.entries)) perf_header__clear_feat(&session->header, HEADER_TRACING_DATA); -#endif =20 if (!rec->opts.branch_stack) perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); diff --git a/tools/perf/util/Build b/tools/perf/util/Build index c06d2ee9024c..47522612484e 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -86,7 +86,7 @@ perf-util-y +=3D pmu-bison.o perf-util-y +=3D hwmon_pmu.o perf-util-y +=3D tool_pmu.o perf-util-y +=3D svghelper.o -perf-util-$(CONFIG_LIBTRACEEVENT) +=3D trace-event-info.o +perf-util-y +=3D trace-event-info.o perf-util-y +=3D trace-event-scripting.o perf-util-$(CONFIG_LIBTRACEEVENT) +=3D trace-event.o perf-util-$(CONFIG_LIBTRACEEVENT) +=3D trace-event-parse.o diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/pe= rf_event_attr_fprintf.c index 59fbbba79697..a73c74b99a3b 100644 --- a/tools/perf/util/perf_event_attr_fprintf.c +++ b/tools/perf/util/perf_event_attr_fprintf.c @@ -212,7 +212,6 @@ static void __p_config_hw_cache_id(char *buf, size_t si= ze, u64 value) } } =20 -#ifdef HAVE_LIBTRACEEVENT static void __p_config_tracepoint_id(char *buf, size_t size, u64 value) { char *str =3D tracepoint_id_to_name(value); @@ -220,7 +219,6 @@ static void __p_config_tracepoint_id(char *buf, size_t = size, u64 value) print_id_hex(str); free(str); } -#endif =20 static void __p_config_id(struct perf_pmu *pmu, char *buf, size_t size, u3= 2 type, u64 value) { @@ -238,9 +236,7 @@ static void __p_config_id(struct perf_pmu *pmu, char *b= uf, size_t size, u32 type case PERF_TYPE_HW_CACHE: return __p_config_hw_cache_id(buf, size, value); case PERF_TYPE_TRACEPOINT: -#ifdef HAVE_LIBTRACEEVENT return __p_config_tracepoint_id(buf, size, value); -#endif case PERF_TYPE_RAW: case PERF_TYPE_BREAKPOINT: default: --=20 2.47.0.338.g60cca15819-goog From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 322CB1EE001 for ; Mon, 18 Nov 2024 22:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970482; cv=none; b=n5fv7q28/6+m+Y919xIFUKks+tiVnRjw5nuxdZab9TN22Js3JZsHr4TkcrP7PFA2AxYMoamVuJlp7mHIEUz9JxGr3Rj49cSdRn7WkBJlUBp1YnYU+zFlncSEBky/Jyrsg8VTJXfRs5pCZk4jz1bS7cqHwW0nICUDNLuL6zeZv0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970482; c=relaxed/simple; bh=mGhk140QZdt4j9l9JIQDlAq6kmxP1h7Khw8epzrTtQw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=WsDL6XtdsPfX15o/9DhbYJw6C/86nHP/8NXvCN6gmobPFwMmqzDL6QchOPkrIe84qbra+Y/CC57psGvPi0TacAxFH24nnWrPfRBUz/IL0J/kVntHZa4m+vRzeEsryc0j48+IYez+tY84hOqbuDDG1jvfZ9FiXHlNr6nZPP8hneU= 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=vOPGoslK; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vOPGoslK" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ea863ecfe9so7296717b3.3 for ; Mon, 18 Nov 2024 14:54:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970479; x=1732575279; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=TDhvCMX7JOKls9vxeiCGPEnafFSjBkepNjN/DQ23IUs=; b=vOPGoslKVhq3QVW83F8Esyxq8hjv/QPZddolFf7LaQEMPLGaTn+1lrDw0qjXXtg+XP 2SEoLp6+daGwvwYmd8+7T5VDy7SFB/ju2ajEKux1TjYBgW7Hws/nZ2i5tDsf2p/XrfSV aHMCBfySwgtIiXkrYMKRGC3XJ5xkOTQEhTKvVy5WALbuAGzzyjPLY8SPbCT7Yasw0HOb l9udUzKgScx9ZYFANWx2zxwsGy0OWUxel1vfw0UMsfLtUVumDg8s9C/um754YvfcVQYc FWoiVvMIf3KW1F9j9WLI/cLz1vtzO/floZlqgbBvqQTKblXcHYWy7a16JiPbHPHmM3w1 e6sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970479; x=1732575279; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TDhvCMX7JOKls9vxeiCGPEnafFSjBkepNjN/DQ23IUs=; b=dphL63ga/dPad3Enp//b370pBpTtAVPR+Arx20Qhq74eVNSlgT9KeZQPZSQLAT+2Xg lLkpckv/It8n+Ag2o+7H0RNLTS+0/zqodbZF/a9Hcs1vS4HvmVgOqWth5d1XqH6bCjSz oNxtM6aZk/xiWqjiTwNvbMgfzIF447WVq39+0s/BqTm1rf6eboM+MXWvs+jVqi6Boe3s RWxilBl4Qs4OreGiFZGmkTOJl7eO+sy77edJUWuiuGRP8jJUjxt3YHO+JSDh2XMt2Pef /eoqumEbeKllj2t+Mn0MgCVWIL4KAJ5fCY4TQD9uLZ15TE6Nezec8zsULbsiH3YbQNPl vAhQ== X-Forwarded-Encrypted: i=1; AJvYcCWvhxVqtbvVO3OeQg4ZctJQCmUQhPpa2QoaHhvIoQDIxHbIF+l/XuThzXcKbquNzNvRXr4v322vaPjx1tU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0mooLMWsGRSwZej5DScilNNVpymPvnY8HRsuSwRUfu1HkXGlO D58rduk1AOHfx6UgEiqWak8X6t9Bcl4yuym/FxZO82JbmtMz9Zu1pjjlOYI1tn+FZOIZTE7vOOv 5P/yrOg== X-Google-Smtp-Source: AGHT+IHdKY4PrQ3sjQRomCGzWEZYw36OZj62aQVWdr+T9sfmCulxuAmnlhvC+HMtegX2oDG2yXdzlBscn8PN X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a05:690c:528f:b0:6e2:1b8c:39bf with SMTP id 00721157ae682-6ee55a3e3afmr472107b3.2.1731970479221; Mon, 18 Nov 2024 14:54:39 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:43 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 5/7] perf evsel: Add/use accessor for tp_format From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add an accessor function for tp_format. Rather than search+replace uses try to use a variable and reuse it. Add additional NULL checks when accessing/using the value. Make sure the PTR_ERR is nulled out on error path in evsel__newtp_idx. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/perf/builtin-kmem.c | 12 +-- tools/perf/builtin-kwork.c | 3 +- tools/perf/builtin-script.c | 9 ++- tools/perf/builtin-trace.c | 79 +++++++++++++------ tools/perf/util/data-convert-bt.c | 10 ++- tools/perf/util/data-convert-json.c | 8 +- tools/perf/util/evsel.c | 9 ++- tools/perf/util/evsel.h | 5 ++ tools/perf/util/evsel_fprintf.c | 4 +- .../util/scripting-engines/trace-event-perl.c | 3 +- .../scripting-engines/trace-event-python.c | 3 +- tools/perf/util/sort.c | 33 +++++--- tools/perf/util/trace-event-scripting.c | 10 ++- 13 files changed, 128 insertions(+), 60 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 4d8d94146f8d..67fb1946ef13 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -761,6 +761,7 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, }; struct trace_seq seq; char *str, *pos =3D NULL; + const struct tep_event *tp_format; =20 if (nr_gfps) { struct gfp_flag key =3D { @@ -772,8 +773,9 @@ static int parse_gfp_flags(struct evsel *evsel, struct = perf_sample *sample, } =20 trace_seq_init(&seq); - tep_print_event(evsel->tp_format->tep, - &seq, &record, "%s", TEP_PRINT_INFO); + tp_format =3D evsel__tp_format(evsel); + if (tp_format) + tep_print_event(tp_format->tep, &seq, &record, "%s", TEP_PRINT_INFO); =20 str =3D strtok_r(seq.buffer, " ", &pos); while (str) { @@ -2012,13 +2014,13 @@ int cmd_kmem(int argc, const char **argv) =20 if (kmem_page) { struct evsel *evsel =3D evlist__find_tracepoint_by_name(session->evlist,= "kmem:mm_page_alloc"); + const struct tep_event *tp_format =3D evsel ? evsel__tp_format(evsel) : = NULL; =20 - if (evsel =3D=3D NULL) { + if (tp_format =3D=3D NULL) { pr_err(errmsg, "page", "page"); goto out_delete; } - - kmem_page_size =3D tep_get_page_size(evsel->tp_format->tep); + kmem_page_size =3D tep_get_page_size(tp_format->tep); symbol_conf.use_callchain =3D true; } =20 diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 8234410cba4c..4eaa6cf5a775 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1103,7 +1103,8 @@ static char *evsel__softirq_name(struct evsel *evsel,= u64 num) char *name =3D NULL; bool found =3D false; struct tep_print_flag_sym *sym =3D NULL; - struct tep_print_arg *args =3D evsel->tp_format->print_fmt.args; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_print_arg *args =3D tp_format ? tp_format->print_fmt.args : NU= LL; =20 if ((args =3D=3D NULL) || (args->next =3D=3D NULL)) return NULL; diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9e47905f75a6..aad607b8918f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2289,8 +2289,13 @@ static void process_event(struct perf_script *script, } #ifdef HAVE_LIBTRACEEVENT if (PRINT_FIELD(TRACE) && sample->raw_data) { - event_format__fprintf(evsel->tp_format, sample->cpu, - sample->raw_data, sample->raw_size, fp); + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + + if (tp_format) { + event_format__fprintf(tp_format, sample->cpu, + sample->raw_data, sample->raw_size, + fp); + } } #endif if (attr->type =3D=3D PERF_TYPE_SYNTH && PRINT_FIELD(SYNTH)) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 6a1a128fe645..3c46de1a8d79 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -389,7 +389,12 @@ static struct syscall_arg_fmt *evsel__syscall_arg_fmt(= struct evsel *evsel) } =20 if (et->fmt =3D=3D NULL) { - et->fmt =3D calloc(evsel->tp_format->format.nr_fields, sizeof(struct sys= call_arg_fmt)); + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + + if (tp_format =3D=3D NULL) + goto out_delete; + + et->fmt =3D calloc(tp_format->format.nr_fields, sizeof(struct syscall_ar= g_fmt)); if (et->fmt =3D=3D NULL) goto out_delete; } @@ -2154,8 +2159,12 @@ static int evsel__init_tp_arg_scnprintf(struct evsel= *evsel, bool *use_btf) struct syscall_arg_fmt *fmt =3D evsel__syscall_arg_fmt(evsel); =20 if (fmt !=3D NULL) { - syscall_arg_fmt__init_array(fmt, evsel->tp_format->format.fields, use_bt= f); - return 0; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + + if (tp_format) { + syscall_arg_fmt__init_array(fmt, tp_format->format.fields, use_btf); + return 0; + } } =20 return -ENOMEM; @@ -3027,7 +3036,8 @@ static size_t trace__fprintf_tp_fields(struct trace *= trace, struct evsel *evsel, { char bf[2048]; size_t size =3D sizeof(bf); - struct tep_format_field *field =3D evsel->tp_format->format.fields; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_format_field *field =3D tp_format ? tp_format->format.fields := NULL; struct syscall_arg_fmt *arg =3D __evsel__syscall_arg_fmt(evsel); size_t printed =3D 0, btf_printed; unsigned long val; @@ -3145,11 +3155,13 @@ static int trace__event_handler(struct trace *trace= , struct evsel *evsel, =20 if (evsel__is_bpf_output(evsel)) { bpf_output__fprintf(trace, sample); - } else if (evsel->tp_format) { - if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || - trace__fprintf_sys_enter(trace, evsel, sample)) { + } else { + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + + if (tp_format && (strncmp(tp_format->name, "sys_enter_", 10) || + trace__fprintf_sys_enter(trace, evsel, sample))) { if (trace->libtraceevent_print) { - event_format__fprintf(evsel->tp_format, sample->cpu, + event_format__fprintf(tp_format, sample->cpu, sample->raw_data, sample->raw_size, trace->output); } else { @@ -4077,17 +4089,23 @@ static int ordered_events__deliver_event(struct ord= ered_events *oe, static struct syscall_arg_fmt *evsel__find_syscall_arg_fmt_by_name(struct = evsel *evsel, char *arg, char **type) { - struct tep_format_field *field; struct syscall_arg_fmt *fmt =3D __evsel__syscall_arg_fmt(evsel); + const struct tep_event *tp_format; + + if (!fmt) + return NULL; =20 - if (evsel->tp_format =3D=3D NULL || fmt =3D=3D NULL) + tp_format =3D evsel__tp_format(evsel); + if (!tp_format) return NULL; =20 - for (field =3D evsel->tp_format->format.fields; field; field =3D field->n= ext, ++fmt) + for (const struct tep_format_field *field =3D tp_format->format.fields; f= ield; + field =3D field->next, ++fmt) { if (strcmp(field->name, arg) =3D=3D 0) { *type =3D field->type; return fmt; } + } =20 return NULL; } @@ -4843,13 +4861,18 @@ static void evsel__set_syscall_arg_fmt(struct evsel= *evsel, const char *name) const struct syscall_fmt *scfmt =3D syscall_fmt__find(name); =20 if (scfmt) { - int skip =3D 0; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + + if (tp_format) { + int skip =3D 0; =20 - if (strcmp(evsel->tp_format->format.fields->name, "__syscall_nr") =3D= =3D 0 || - strcmp(evsel->tp_format->format.fields->name, "nr") =3D=3D 0) - ++skip; + if (strcmp(tp_format->format.fields->name, "__syscall_nr") =3D=3D 0 || + strcmp(tp_format->format.fields->name, "nr") =3D=3D 0) + ++skip; =20 - memcpy(fmt + skip, scfmt->arg, (evsel->tp_format->format.nr_fields - sk= ip) * sizeof(*fmt)); + memcpy(fmt + skip, scfmt->arg, + (tp_format->format.nr_fields - skip) * sizeof(*fmt)); + } } } } @@ -4859,10 +4882,16 @@ static int evlist__set_syscall_tp_fields(struct evl= ist *evlist, bool *use_btf) struct evsel *evsel; =20 evlist__for_each_entry(evlist, evsel) { - if (evsel->priv || !evsel->tp_format) + const struct tep_event *tp_format; + + if (evsel->priv) + continue; + + tp_format =3D evsel__tp_format(evsel); + if (!tp_format) continue; =20 - if (strcmp(evsel->tp_format->system, "syscalls")) { + if (strcmp(tp_format->system, "syscalls")) { evsel__init_tp_arg_scnprintf(evsel, use_btf); continue; } @@ -4870,20 +4899,24 @@ static int evlist__set_syscall_tp_fields(struct evl= ist *evlist, bool *use_btf) if (evsel__init_syscall_tp(evsel)) return -1; =20 - if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) { + if (!strncmp(tp_format->name, "sys_enter_", 10)) { struct syscall_tp *sc =3D __evsel__syscall_tp(evsel); =20 if (__tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64))) return -1; =20 - evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_= enter_") - 1); - } else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) { + evsel__set_syscall_arg_fmt(evsel, + tp_format->name + sizeof("sys_enter_") - 1); + } else if (!strncmp(tp_format->name, "sys_exit_", 9)) { struct syscall_tp *sc =3D __evsel__syscall_tp(evsel); =20 - if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof= (u64), evsel->needs_swap)) + if (__tp_field__init_uint(&sc->ret, sizeof(u64), + sc->id.offset + sizeof(u64), + evsel->needs_swap)) return -1; =20 - evsel__set_syscall_arg_fmt(evsel, evsel->tp_format->name + sizeof("sys_= exit_") - 1); + evsel__set_syscall_arg_fmt(evsel, + tp_format->name + sizeof("sys_exit_") - 1); } } =20 diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index f0599c61fab4..5e7ff09fbc95 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -426,8 +426,9 @@ static int add_tracepoint_values(struct ctf_writer *cw, struct evsel *evsel, struct perf_sample *sample) { - struct tep_format_field *common_fields =3D evsel->tp_format->format.commo= n_fields; - struct tep_format_field *fields =3D evsel->tp_format->format.field= s; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_format_field *common_fields =3D tp_format->format.common_field= s; + struct tep_format_field *fields =3D tp_format->format.fields; int ret; =20 ret =3D add_tracepoint_fields_values(cw, event_class, event, @@ -1064,8 +1065,9 @@ static int add_tracepoint_types(struct ctf_writer *cw, struct evsel *evsel, struct bt_ctf_event_class *class) { - struct tep_format_field *common_fields =3D evsel->tp_format->format.commo= n_fields; - struct tep_format_field *fields =3D evsel->tp_format->format.field= s; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_format_field *common_fields =3D tp_format ? tp_format->format.= common_fields : NULL; + struct tep_format_field *fields =3D tp_format ? tp_format->format.= fields : NULL; int ret; =20 ret =3D add_tracepoint_fields_types(cw, common_fields, class); diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 8304cd2d4a9c..d9f805bf6fb0 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -230,12 +230,12 @@ static int process_sample_event(const struct perf_too= l *tool, =20 #ifdef HAVE_LIBTRACEEVENT if (sample->raw_data) { - int i; - struct tep_format_field **fields; + struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_format_field **fields =3D tp_format ? tep_event_fields(tp_for= mat) : NULL; =20 - fields =3D tep_event_fields(evsel->tp_format); if (fields) { - i =3D 0; + int i =3D 0; + while (fields[i]) { struct trace_seq s; =20 diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index f745723d486b..4759d644a5aa 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -571,6 +571,7 @@ struct evsel *evsel__newtp_idx(const char *sys, const c= har *name, int idx, bool evsel->tp_format =3D trace_event__tp_format(sys, name); if (IS_ERR(evsel->tp_format)) { err =3D PTR_ERR(evsel->tp_format); + evsel->tp_format =3D NULL; goto out_free; } attr.config =3D evsel->tp_format->id; @@ -3218,12 +3219,16 @@ u16 evsel__id_hdr_size(const struct evsel *evsel) #ifdef HAVE_LIBTRACEEVENT struct tep_format_field *evsel__field(struct evsel *evsel, const char *nam= e) { - return tep_find_field(evsel->tp_format, name); + struct tep_event *tp_format =3D evsel__tp_format(evsel); + + return tp_format ? tep_find_field(tp_format, name) : NULL; } =20 struct tep_format_field *evsel__common_field(struct evsel *evsel, const ch= ar *name) { - return tep_find_common_field(evsel->tp_format, name); + struct tep_event *tp_format =3D evsel__tp_format(evsel); + + 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) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 04934a7af174..c3e53d320bf5 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -257,6 +257,11 @@ static inline struct evsel *evsel__newtp(const char *s= ys, const char *name) { return evsel__newtp_idx(sys, name, 0, true); } + +static inline struct tep_event *evsel__tp_format(struct evsel *evsel) +{ + return evsel->tp_format; +} #endif =20 #ifdef HAVE_LIBTRACEEVENT diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprint= f.c index 86b7f46f9e2a..103984b29b1e 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c @@ -81,13 +81,15 @@ int evsel__fprintf(struct evsel *evsel, struct perf_att= r_details *details, FILE #ifdef HAVE_LIBTRACEEVENT if (details->trace_fields) { struct tep_format_field *field; + const struct tep_event *tp_format; =20 if (evsel->core.attr.type !=3D PERF_TYPE_TRACEPOINT) { printed +=3D comma_fprintf(fp, &first, " (not a tracepoint)"); goto out; } =20 - field =3D evsel->tp_format->format.fields; + tp_format =3D evsel__tp_format(evsel); + field =3D tp_format ? tp_format->format.fields : NULL; if (field =3D=3D NULL) { printed +=3D comma_fprintf(fp, &first, " (no trace field)"); goto out; diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/p= erf/util/scripting-engines/trace-event-perl.c index 85b7f188f729..e261a57b87d4 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -344,7 +344,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, struct addr_location *al) { struct thread *thread =3D al->thread; - struct tep_event *event =3D evsel->tp_format; + struct tep_event *event; struct tep_format_field *field; static char handler[256]; unsigned long long val; @@ -362,6 +362,7 @@ static void perl_process_tracepoint(struct perf_sample = *sample, if (evsel->core.attr.type !=3D PERF_TYPE_TRACEPOINT) return; =20 + event =3D evsel__tp_format(evsel); if (!event) { pr_debug("ug! no event found for type %" PRIu64, (u64)evsel->core.attr.c= onfig); return; diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 8bdae066e839..231233639b5d 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -949,7 +949,7 @@ static void python_process_tracepoint(struct perf_sampl= e *sample, struct addr_location *al, struct addr_location *addr_al) { - struct tep_event *event =3D evsel->tp_format; + struct tep_event *event; PyObject *handler, *context, *t, *obj =3D NULL, *callchain; PyObject *dict =3D NULL, *all_entries_dict =3D NULL; static char handler_name[256]; @@ -966,6 +966,7 @@ static void python_process_tracepoint(struct perf_sampl= e *sample, =20 bitmap_zero(events_defined, TRACE_EVENT_TYPE_MAX); =20 + event =3D evsel__tp_format(evsel); if (!event) { snprintf(handler_name, sizeof(handler_name), "ug! no event found for type %" PRIu64, (u64)evsel->core.attr.config); diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 9dd60c7869a2..3dd33721823f 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1038,17 +1038,19 @@ static char *get_trace_output(struct hist_entry *he) .data =3D he->raw_data, .size =3D he->raw_size, }; + struct tep_event *tp_format; =20 evsel =3D hists_to_evsel(he->hists); =20 trace_seq_init(&seq); - if (symbol_conf.raw_trace) { - tep_print_fields(&seq, he->raw_data, he->raw_size, - evsel->tp_format); - } else { - tep_print_event(evsel->tp_format->tep, - &seq, &rec, "%s", TEP_PRINT_INFO); + tp_format =3D evsel__tp_format(evsel); + if (tp_format) { + if (symbol_conf.raw_trace) + tep_print_fields(&seq, he->raw_data, he->raw_size, tp_format); + else + tep_print_event(tp_format->tep, &seq, &rec, "%s", TEP_PRINT_INFO); } + /* * Trim the buffer, it starts at 4KB and we're not going to * add anything more to this buffer. @@ -3293,9 +3295,8 @@ static int __dynamic_dimension__add(struct evsel *evs= el, static int add_evsel_fields(struct evsel *evsel, bool raw_trace, int level) { int ret; - struct tep_format_field *field; - - field =3D evsel->tp_format->format.fields; + struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_format_field *field =3D tp_format ? tp_format->format.fields := NULL; while (field) { ret =3D __dynamic_dimension__add(evsel, field, raw_trace, level); if (ret < 0) @@ -3328,13 +3329,19 @@ static int add_all_matching_fields(struct evlist *e= vlist, { int ret =3D -ESRCH; struct evsel *evsel; - struct tep_format_field *field; =20 evlist__for_each_entry(evlist, evsel) { + struct tep_event *tp_format; + struct tep_format_field *field; + if (evsel->core.attr.type !=3D PERF_TYPE_TRACEPOINT) continue; =20 - field =3D tep_find_any_field(evsel->tp_format, field_name); + tp_format =3D evsel__tp_format(evsel); + if (tp_format =3D=3D NULL) + continue; + + field =3D tep_find_any_field(tp_format, field_name); if (field =3D=3D NULL) continue; =20 @@ -3416,7 +3423,9 @@ static int add_dynamic_entry(struct evlist *evlist, c= onst char *tok, if (!strcmp(field_name, "*")) { ret =3D add_evsel_fields(evsel, raw_trace, level); } else { - struct tep_format_field *field =3D tep_find_any_field(evsel->tp_format, = field_name); + struct tep_event *tp_format =3D evsel__tp_format(evsel); + struct tep_format_field *field =3D + tp_format ? tep_find_any_field(tp_format, field_name) : NULL; =20 if (field =3D=3D NULL) { pr_debug("Cannot find event field for %s.%s\n", diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trac= e-event-scripting.c index 5596fcda2c10..edfde7056c99 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c @@ -28,12 +28,14 @@ void scripting_context__update(struct scripting_context= *c, struct addr_location *al, struct addr_location *addr_al) { - c->event_data =3D sample->raw_data; - c->pevent =3D NULL; #ifdef HAVE_LIBTRACEEVENT - if (evsel->tp_format) - c->pevent =3D evsel->tp_format->tep; + const struct tep_event *tp_format =3D evsel__tp_format(evsel); + + c->pevent =3D tp_format ? tp_format->tep : NULL; +#else + c->pevent =3D NULL; #endif + c->event_data =3D sample->raw_data; c->event =3D event; c->sample =3D sample; c->evsel =3D evsel; --=20 2.47.0.338.g60cca15819-goog From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A8F61EE01F for ; Mon, 18 Nov 2024 22:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970484; cv=none; b=fAYmrmjT781EnVGoLYzBdpAVuQF3hJolYycyMiLlPU3Jf+a0MRe1Yg1HMbBUfIkigx25nhAM/QqKZ2bPe6hdkX0PK/RWGIU3SGz2QLwfB6aB2EoSn1S6trOgmz4DwJ2cSs3KAsp5+rpW5fkCBbm54L8q9a1yI7RhFA0+Qc8Rg/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970484; c=relaxed/simple; bh=bYH4LKGJAu2JkyiwoaF6CJMpGr6DfUExCzpwzjBU1UE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=CVI93EHIip7CjlkX1+cqEjn9+JxFV0yKDtRun7JslCORNy21Gn0E7seHlbE5T92e7FlYFCgotQGidInXvYLCfXynv0juHd5eCGVi/cugg7C7oSX4WakB5M4OPDhr2vxSGu3RZUeroAsOq0NEweqLV+UfvpDxH8CY02HRioEXOGk= 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=N0/gzjx0; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="N0/gzjx0" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ee426e3414so61795427b3.3 for ; Mon, 18 Nov 2024 14:54:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970482; x=1732575282; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=4TkdfKR0RxAasZPeEtuzLUXU2avDKikbT7HP7un2dUo=; b=N0/gzjx0LKMMQ7rTAqV5lmPjnfJtFaZDlsIeNfQJ5RCadugHgXrusGjztSh2x1PObo K4zTAAsxa15b+nBmxGLSp6/Rx7vARlNTgVKvf0q/9YciysTLhekGtzTZMcZvosqUt2UM oejkNmJ2mZV1W8wOV2OV8K0bZ4sfj2t087yc5I+WW6LHFuvMQxWclqsAKuH+fdSHxlIr fIoV0Zb3LcR5rdMfdCxC2tygIqay1yYUx35qGFbiK7U3nzTv715p2YzzUsu9slCKS3Sq ++1AyaVD2XiDUBZ6b4V+ZZfKxP7lMAT/4L7JAP5K6wdVX5xzQAFqSzdJfWbOT9xPKU9e fFdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970482; x=1732575282; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4TkdfKR0RxAasZPeEtuzLUXU2avDKikbT7HP7un2dUo=; b=R8uSWk7ukL8XRKajY3128KUo9z65Tz2bgPv+7MyBOoQVgDCdxwEBonVHcyfoehUhrY EE11Ry5q+uVWyKDpW6i5vzu+hqLsQxizp9Jfs9vgVtcr/02eUUCs4RQvuawLruDFUaxE FuKhUg9/obZjk9GUzQVchXXJ1S0T6lEzwNiAHxaSUL9khgE2wDWRSIlkqpk+51NtTiWd RphmwBK49mFj+HwoYqKnR4PC2L/du7QI/9qq5CEircadjwcZWDb4KV3YguKlAq6ICNId /4+2ig7LaXKIXbEAyS7w/1qx83oO6PW/8GldnWRt5foYir/tRBhp7hL8LwgKjmsbpZWP yVnA== X-Forwarded-Encrypted: i=1; AJvYcCVBPvhQ/Jb/CuA+TfxRJFmXhSJqtswpfpA7XDLrgZ6nW6MnnLY07WJ828maycdkw6XaUiQoi/46RKdrTQE=@vger.kernel.org X-Gm-Message-State: AOJu0YyvHySGW+/enSrAtsqx8e76O028ON8zosrncGncgSjylI1WPWrh wkiZcq8e2sOaaALw3lHGUqNjex+JUgtbGXYTV8d4myh/x8gwzFYZgJM43OQCUcghfhydR1lpWy5 qftfPEw== X-Google-Smtp-Source: AGHT+IGMI+SDlmNkfxJrIzlOTnDXSAFa6oFdQqPI8mWkiZCCyyKWgJveun+tJonhhJcLxWOhRjo32pBPUuYU X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a05:690c:6585:b0:6e2:371f:4aef with SMTP id 00721157ae682-6ee55c95c78mr1282607b3.3.1731970481857; Mon, 18 Nov 2024 14:54:41 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:44 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 6/7] perf evsel: Allow evsel__newtp without libtraceevent From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch from reading the tracepoint format to reading the id directly for the evsel config. This avoids the need to initialize libtraceevent, plugins, etc. It is sufficient for many tracepoint commands to work like: $ perf stat -e sched:sched_switch true To populate evsel->tp_format, do lazy initialization using libtraceevent in the evsel__tp_format function (the sys and name are saved in evsel__newtp_idx for this purpose). Reading the id should be indicative of the format failing to load, but if not an error is reported in evsel__tp_format. This could happen for a tracepoint with a format that fails to parse. As tracepoints can be parsed without libtraceevent with this, remove the associated #ifdefs in parse-events.c. By only lazily parsing the tracepoint format information it is hoped this will help improve the performance of code using tracepoints but not the format information. It also cuts down on the build and ifdef logic. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/perf/util/evsel.c | 103 ++++++++++++++++++++++++--------- tools/perf/util/evsel.h | 14 ++--- tools/perf/util/parse-events.c | 16 +---- 3 files changed, 82 insertions(+), 51 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 4759d644a5aa..6cffba96477e 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -544,54 +544,101 @@ struct evsel *evsel__clone(struct evsel *orig) return NULL; } =20 +static int trace_event__id(const char *sys, const char *name) +{ + char *tp_dir =3D get_events_file(sys); + char path[PATH_MAX]; + int id, err; + + if (!tp_dir) + return -1; + + scnprintf(path, PATH_MAX, "%s/%s/id", tp_dir, name); + put_events_file(tp_dir); + err =3D filename__read_int(path, &id); + if (err) + return err; + + return id; +} + /* * Returns pointer with encoded error via interface. */ -#ifdef HAVE_LIBTRACEEVENT struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx,= bool format) { + struct perf_event_attr attr =3D { + .type =3D PERF_TYPE_TRACEPOINT, + .sample_type =3D (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | + PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD), + }; struct evsel *evsel =3D zalloc(perf_evsel__object.size); - int err =3D -ENOMEM; + int err =3D -ENOMEM, id =3D -1; =20 - if (evsel =3D=3D NULL) { + if (evsel =3D=3D NULL) goto out_err; - } else { - struct perf_event_attr attr =3D { - .type =3D PERF_TYPE_TRACEPOINT, - .sample_type =3D (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | - PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD), - }; =20 - if (asprintf(&evsel->name, "%s:%s", sys, name) < 0) - goto out_free; =20 - event_attr_init(&attr); + if (asprintf(&evsel->name, "%s:%s", sys, name) < 0) + goto out_free; =20 - if (format) { - evsel->tp_format =3D trace_event__tp_format(sys, name); - if (IS_ERR(evsel->tp_format)) { - err =3D PTR_ERR(evsel->tp_format); - evsel->tp_format =3D NULL; - goto out_free; - } - attr.config =3D evsel->tp_format->id; - } else { - attr.config =3D (__u64) -1; - } +#ifdef HAVE_LIBTRACEEVENT + evsel->tp_sys =3D strdup(sys); + if (!evsel->tp_sys) + goto out_free; =20 + evsel->tp_name =3D strdup(name); + if (!evsel->tp_name) + goto out_free; +#endif =20 - attr.sample_period =3D 1; - evsel__init(evsel, &attr, idx); - } + event_attr_init(&attr); =20 + if (format) { + id =3D trace_event__id(sys, name); + if (id < 0) { + err =3D id; + goto out_free; + } + } + attr.config =3D (__u64)id; + attr.sample_period =3D 1; + evsel__init(evsel, &attr, idx); return evsel; =20 out_free: zfree(&evsel->name); +#ifdef HAVE_LIBTRACEEVENT + zfree(&evsel->tp_sys); + zfree(&evsel->tp_name); +#endif free(evsel); out_err: return ERR_PTR(err); } + +#ifdef HAVE_LIBTRACEEVENT +struct tep_event *evsel__tp_format(struct evsel *evsel) +{ + struct tep_event *tp_format =3D evsel->tp_format; + + if (tp_format) + return tp_format; + + if (evsel->core.attr.type !=3D PERF_TYPE_TRACEPOINT) + return NULL; + + tp_format =3D trace_event__tp_format(evsel->tp_sys, evsel->tp_name); + if (IS_ERR(tp_format)) { + int err =3D -PTR_ERR(evsel->tp_format); + + pr_err("Error getting tracepoint format '%s' '%s'(%d)\n", + evsel__name(evsel), strerror(err), err); + return NULL; + } + evsel->tp_format =3D tp_format; + return evsel->tp_format; +} #endif =20 const char *const evsel__hw_names[PERF_COUNT_HW_MAX] =3D { @@ -1588,6 +1635,10 @@ void evsel__exit(struct evsel *evsel) perf_thread_map__put(evsel->core.threads); zfree(&evsel->group_name); zfree(&evsel->name); +#ifdef HAVE_LIBTRACEEVENT + zfree(&evsel->tp_sys); + zfree(&evsel->tp_name); +#endif zfree(&evsel->filter); zfree(&evsel->group_pmu_name); zfree(&evsel->unit); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index c3e53d320bf5..93b6244ec302 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -59,6 +59,8 @@ struct evsel { char *group_name; const char *group_pmu_name; #ifdef HAVE_LIBTRACEEVENT + char *tp_sys; + char *tp_name; struct tep_event *tp_format; #endif char *filter; @@ -247,25 +249,17 @@ int copy_config_terms(struct list_head *dst, struct l= ist_head *src); void free_config_terms(struct list_head *config_terms); =20 =20 -#ifdef HAVE_LIBTRACEEVENT -struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx,= bool format); - /* * Returns pointer with encoded error via interface. */ +struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx,= bool format); static inline struct evsel *evsel__newtp(const char *sys, const char *name) { return evsel__newtp_idx(sys, name, 0, true); } =20 -static inline struct tep_event *evsel__tp_format(struct evsel *evsel) -{ - return evsel->tp_format; -} -#endif - #ifdef HAVE_LIBTRACEEVENT -struct tep_event *event_format__new(const char *sys, const char *name); +struct tep_event *evsel__tp_format(struct evsel *evsel); #endif =20 void evsel__init(struct evsel *evsel, struct perf_event_attr *attr, int id= x); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index afeb8d815bbf..7fc1c36ef2a4 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -489,7 +489,6 @@ int parse_events_add_cache(struct list_head *list, int = *idx, const char *name, return found_supported ? 0 : -EINVAL; } =20 -#ifdef HAVE_LIBTRACEEVENT static void tracepoint_error(struct parse_events_error *e, int err, const char *sys, const char *name, int column) { @@ -644,7 +643,6 @@ static int add_tracepoint_multi_sys(struct parse_events= _state *parse_state, closedir(events_dir); return ret; } -#endif /* HAVE_LIBTRACEEVENT */ =20 size_t default_breakpoint_len(void) { @@ -1066,7 +1064,6 @@ static int config_term_pmu(struct perf_event_attr *at= tr, return config_term_common(attr, term, err); } =20 -#ifdef HAVE_LIBTRACEEVENT static int config_term_tracepoint(struct perf_event_attr *attr, struct parse_events_term *term, struct parse_events_error *err) @@ -1111,7 +1108,6 @@ static int config_term_tracepoint(struct perf_event_a= ttr *attr, =20 return 0; } -#endif =20 static int config_attr(struct perf_event_attr *attr, const struct parse_events_terms *head, @@ -1303,7 +1299,7 @@ int parse_events_add_tracepoint(struct parse_events_s= tate *parse_state, struct parse_events_terms *head_config, void *loc_) { YYLTYPE *loc =3D loc_; -#ifdef HAVE_LIBTRACEEVENT + if (head_config) { struct perf_event_attr attr; =20 @@ -1318,16 +1314,6 @@ int parse_events_add_tracepoint(struct parse_events_= state *parse_state, else return add_tracepoint_event(parse_state, list, sys, event, err, head_config, loc); -#else - (void)parse_state; - (void)list; - (void)sys; - (void)event; - (void)head_config; - parse_events_error__handle(err, loc->first_column, strdup("unsupported tr= acepoint"), - strdup("libtraceevent is necessary for tracepoint support")); - return -1; -#endif } =20 static int __parse_events_add_numeric(struct parse_events_state *parse_sta= te, --=20 2.47.0.338.g60cca15819-goog From nobody Thu Nov 21 21:53:30 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88DD11EF087 for ; Mon, 18 Nov 2024 22:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970488; cv=none; b=FLmj8VXwh1cko7FHXrvESawyyHz35gCLqGZV7/l0DFXgvNnpyhpqeGrCn7rkLvybsr0jLsYjNfXBWU9Y8V1IbHcZa0JYi77yFhI3BLApVJ52A4kOUs8XlsRCl1J4zBXEZA+965JjYqzNQubM9ZU7V7RNW7HIWB1lBMAmVfvHu3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731970488; c=relaxed/simple; bh=6p59fnGhg3R8WxuGSRydhk66jb7GPNK67Y0Q+xJOfHU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=PMJ6xLOp55q/O+10GV6TfAeCclqvTwnsDZNT+HwBaBcgpebnKLYmp8mJPCGm9iE/qo2WPQ7NHsB/9twGnpxwXE5LxrkkxBih7VSMCLwWR3ZMCpq4uz7EDSXp5Ss/L4+6zuEtMgGwGV8mxShM6Fw51ai4VMzBDweh78UogtH6R6E= 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=AM92ePW3; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AM92ePW3" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6eae6aba72fso45132037b3.2 for ; Mon, 18 Nov 2024 14:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731970484; x=1732575284; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=mD5jCks16HgKMtJGIMozMf0vz7aQdcDKdJJkobIuclw=; b=AM92ePW37BYp3sik6DEYF8wHVlto9NN4Si+D/1pmJFmYCh1Z6H5wBhzVfubqyG0oyQ hBQbpL87qD3+fsihXK2uShYl0Ru0yWWYnnU2ejcXnCzCh0Ws9gv0pqNFWdhs1G1ALfiA 5cmFO1msPz9icM31VQV6vNUK4mhZtBGdyBbVBhwU6ypFARlxHYncymILJNv9LaWnHWqL YqtuOUpNfaIroZeDZzDsz8VCOmSnjcEppUxQ03Pp0MNuyhyKoQIkj9LFesU3jycZSXOP JqoIgzAGZLzQqpp3E+Wetg3euTLUSWcXFTweQATsgxCPs3LLTQ7VbS+mC/g35U2mhz4g YP1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731970484; x=1732575284; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mD5jCks16HgKMtJGIMozMf0vz7aQdcDKdJJkobIuclw=; b=uV9WIzIOvFFKrO8PRDf5KKYUqunz//7LtQDXQ3a07LfTrmxCezZpXtL0rBIW/RQdZe mMc54beqNaqehDR2g4Su/SQj2NtrRm5FuRnNMufw0sz+ybsrhBWYah23gbK4b6TJe6YK n/X5Bl/xoUNkUPKAaTk1gEcnCP10Y6WafOVl3FqnqgAmC5baqqSxWH1Vlj2PZlVGGxTX 4S9rEArycbaG5Mh6ytMQTrElEwobehoDlkcAD1+DY/oFIUqUH47ouzTNyR9P62sWNv43 hkn4970m7cUOZIeSjogMM42F7gcvvgiJduKJUX2NnyCuLjceZqM20NnXMWaVaWTLuvp6 aYUw== X-Forwarded-Encrypted: i=1; AJvYcCWmT3zUdEx8p4Ja2nlddb+mjjnH3rjcIrVmqfg+tLOfKGwuOlOYQAc3sg6jeAhm+Keq9HrNHoe1znL7kTo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw99ohY6Sz6n0v8dqPPA8hmCbfq+cs9zaY7Js1MTm/IsuMpbwuC L6MzGDlHSxqbZt3SdyQ8uw7bVq8QfU6TIGG9OC1y3BK5lzCDukaIZ2edUMyDHdMWsm0m7OEDxyv luT2DUQ== X-Google-Smtp-Source: AGHT+IGuX9TenwXB6zRWjhv+Zw88XIC0zVlyiSRcC9mseqOdSWcEQUv3ttxqHj2nG4fp9lkaeBfIfZttkCLY X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:22a4:ded5:5c37:fcc7]) (user=irogers job=sendgmr) by 2002:a81:d101:0:b0:6ea:fa4:a365 with SMTP id 00721157ae682-6ee55ce4770mr1223427b3.8.1731970484513; Mon, 18 Nov 2024 14:54:44 -0800 (PST) Date: Mon, 18 Nov 2024 14:53:45 -0800 In-Reply-To: <20241118225345.889810-1-irogers@google.com> Message-Id: <20241118225345.889810-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241118225345.889810-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Subject: [PATCH v5 7/7] perf tests: Enable tests disabled due to tracepoint parsing From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Athira Jajeev , James Clark , Dominique Martinet , Yang Li , Colin Ian King , Yang Jihong , "Steinar H. Gunderson" , Oliver Upton , Ilkka Koskinen , Ze Gao , Weilin Wang , Ben Gainey , zhaimingbing , Zixian Cai , Andi Kleen , Paran Lee , Thomas Falcon , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Steven Rostedt (Google)" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Tracepoint parsing required libtraceevent but no longer does. Remove the Build logic and #ifdefs that caused the tests not to be run. Test code that directly uses libtraceevent is still guarded. Signed-off-by: Ian Rogers Reviewed-by: Namhyung Kim --- tools/perf/tests/Build | 6 +++--- tools/perf/tests/builtin-test.c | 2 -- tools/perf/tests/parse-events.c | 25 +------------------------ 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index ec4e1f034742..4bf8d3f5eae7 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -5,10 +5,10 @@ perf-test-y +=3D tests-scripts.o perf-test-y +=3D parse-events.o perf-test-y +=3D dso-data.o perf-test-y +=3D vmlinux-kallsyms.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D openat-syscall.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D openat-syscall-all-cpus.o +perf-test-y +=3D openat-syscall.o +perf-test-y +=3D openat-syscall-all-cpus.o perf-test-$(CONFIG_LIBTRACEEVENT) +=3D openat-syscall-tp-fields.o -perf-test-$(CONFIG_LIBTRACEEVENT) +=3D mmap-basic.o +perf-test-y +=3D mmap-basic.o perf-test-y +=3D perf-record.o perf-test-y +=3D evsel-roundtrip-name.o perf-test-$(CONFIG_LIBTRACEEVENT) +=3D evsel-tp-sched.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 8dcf74d3c0a3..738ad32b2c8a 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -60,11 +60,9 @@ static struct test_suite *arch_tests[] =3D { =20 static struct test_suite *generic_tests[] =3D { &suite__vmlinux_matches_kallsyms, -#ifdef HAVE_LIBTRACEEVENT &suite__openat_syscall_event, &suite__openat_syscall_event_on_all_cpus, &suite__basic_mmap, -#endif &suite__mem, &suite__parse_events, &suite__expr, diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index 82a19674a38f..5ec2e5607987 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -54,8 +54,6 @@ static bool test_perf_config(const struct perf_evsel *evs= el, __u64 expected_conf return (evsel->attr.config & PERF_HW_EVENT_MASK) =3D=3D expected_config; } =20 -#ifdef HAVE_LIBTRACEEVENT - #if defined(__s390x__) /* Return true if kvm module is available and loaded. Test this * and return success when trace point kvm_s390_create_vm @@ -112,7 +110,6 @@ static int test__checkevent_tracepoint_multi(struct evl= ist *evlist) } return TEST_OK; } -#endif /* HAVE_LIBTRACEEVENT */ =20 static int test__checkevent_raw(struct evlist *evlist) { @@ -311,7 +308,6 @@ static int test__checkevent_breakpoint_rw(struct evlist= *evlist) return TEST_OK; } =20 -#ifdef HAVE_LIBTRACEEVENT static int test__checkevent_tracepoint_modifier(struct evlist *evlist) { struct evsel *evsel =3D evlist__first(evlist); @@ -340,7 +336,6 @@ test__checkevent_tracepoint_multi_modifier(struct evlis= t *evlist) =20 return test__checkevent_tracepoint_multi(evlist); } -#endif /* HAVE_LIBTRACEEVENT */ =20 static int test__checkevent_raw_modifier(struct evlist *evlist) { @@ -629,7 +624,6 @@ static int test__checkevent_pmu(struct evlist *evlist) return TEST_OK; } =20 -#ifdef HAVE_LIBTRACEEVENT static int test__checkevent_list(struct evlist *evlist) { struct evsel *evsel =3D evlist__first(evlist); @@ -671,7 +665,6 @@ static int test__checkevent_list(struct evlist *evlist) =20 return TEST_OK; } -#endif =20 static int test__checkevent_pmu_name(struct evlist *evlist) { @@ -971,7 +964,6 @@ static int test__group2(struct evlist *evlist) return TEST_OK; } =20 -#ifdef HAVE_LIBTRACEEVENT static int test__group3(struct evlist *evlist __maybe_unused) { struct evsel *evsel, *group1_leader =3D NULL, *group2_leader =3D NULL; @@ -1078,7 +1070,6 @@ static int test__group3(struct evlist *evlist __maybe= _unused) } return TEST_OK; } -#endif =20 static int test__group4(struct evlist *evlist __maybe_unused) { @@ -1813,7 +1804,6 @@ static int test__term_equal_legacy(struct evlist *evl= ist) return TEST_OK; } =20 -#ifdef HAVE_LIBTRACEEVENT static int count_tracepoints(void) { struct dirent *events_ent; @@ -1867,7 +1857,6 @@ static int test__all_tracepoints(struct evlist *evlis= t) =20 return test__checkevent_tracepoint_multi(evlist); } -#endif /* HAVE_LIBTRACEVENT */ =20 struct evlist_test { const char *name; @@ -1876,7 +1865,6 @@ struct evlist_test { }; =20 static const struct evlist_test test__events[] =3D { -#ifdef HAVE_LIBTRACEEVENT { .name =3D "syscalls:sys_enter_openat", .check =3D test__checkevent_tracepoint, @@ -1887,7 +1875,6 @@ static const struct evlist_test test__events[] =3D { .check =3D test__checkevent_tracepoint_multi, /* 1 */ }, -#endif { .name =3D "r1a", .check =3D test__checkevent_raw, @@ -1938,7 +1925,6 @@ static const struct evlist_test test__events[] =3D { .check =3D test__checkevent_breakpoint_w, /* 1 */ }, -#ifdef HAVE_LIBTRACEEVENT { .name =3D "syscalls:sys_enter_openat:k", .check =3D test__checkevent_tracepoint_modifier, @@ -1949,7 +1935,6 @@ static const struct evlist_test test__events[] =3D { .check =3D test__checkevent_tracepoint_multi_modifier, /* 3 */ }, -#endif { .name =3D "r1a:kp", .check =3D test__checkevent_raw_modifier, @@ -1995,13 +1980,11 @@ static const struct evlist_test test__events[] =3D { .check =3D test__checkevent_breakpoint_w_modifier, /* 2 */ }, -#ifdef HAVE_LIBTRACEEVENT { .name =3D "r1,syscalls:sys_enter_openat:k,1:1:hp", .check =3D test__checkevent_list, /* 3 */ }, -#endif { .name =3D "instructions:G", .check =3D test__checkevent_exclude_host_modifier, @@ -2032,13 +2015,11 @@ static const struct evlist_test test__events[] =3D { .check =3D test__group2, /* 9 */ }, -#ifdef HAVE_LIBTRACEEVENT { .name =3D "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycle= s,1:3}:G,instructions:u", .check =3D test__group3, /* 0 */ }, -#endif { .name =3D "{cycles:u,instructions:kp}:p", .check =3D test__group4, @@ -2049,13 +2030,11 @@ static const struct evlist_test test__events[] =3D { .check =3D test__group5, /* 2 */ }, -#ifdef HAVE_LIBTRACEEVENT { .name =3D "*:*", .check =3D test__all_tracepoints, /* 3 */ }, -#endif { .name =3D "{cycles,cache-misses:G}:H", .check =3D test__group_gh1, @@ -2111,7 +2090,7 @@ static const struct evlist_test test__events[] =3D { .check =3D test__checkevent_breakpoint_len_rw_modifier, /* 4 */ }, -#if defined(__s390x__) && defined(HAVE_LIBTRACEEVENT) +#if defined(__s390x__) { .name =3D "kvm-s390:kvm_s390_create_vm", .check =3D test__checkevent_tracepoint, @@ -2265,13 +2244,11 @@ static const struct evlist_test test__events[] =3D { .check =3D test__checkevent_breakpoint_2_events, /* 3 */ }, -#ifdef HAVE_LIBTRACEEVENT { .name =3D "9p:9p_client_req", .check =3D test__checkevent_tracepoint, /* 4 */ }, -#endif }; =20 static const struct evlist_test test__events_pmu[] =3D { --=20 2.47.0.338.g60cca15819-goog