Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1092360lqb; Wed, 29 May 2024 23:04:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUX0i2inwdpV1OSXNxG/FmWu8g7t5yyupKsAc28X7ZC1EBic3/FQMB6Tf5GkYObsz9emCMhbBbCzIB3FnVj9xNVKWiueFephUDdCToVkA== X-Google-Smtp-Source: AGHT+IHCCrVlLcuI1ZzMPEMD1F3naxVpRaK1ZeWhb0XT/MgQgYTldCtUQgQRHca/WFW5BnGy9J0f X-Received: by 2002:a05:6871:3a07:b0:24f:e9e5:c5d9 with SMTP id 586e51a60fabf-25060bc04c6mr1428975fac.29.1717049059571; Wed, 29 May 2024 23:04:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717049059; cv=pass; d=google.com; s=arc-20160816; b=yQGYPgwhEKh+Fy+9dklKbxl1QY32wOkKTSOnHhws6sZ+nK5i8vHi6ai55ifCPeba+5 hctEDC0hpWXILbJj83zO0QW/FyJzLM/hl5p8VrTtwVrwLuE24f9LyHc0fxJzj2ed8i6U nKLvD7rBdp7ayKkxdWfXYWEQbt6uGtkBt2SwGoBPbQPRda7zV/k6T05nkOgzgNdFJ4TP bPVy/m4gjlyy1vydZL4h4UFX2EfICugcCrh+zKbWyZBoYpHqIl0dn/H/I91i2GbuoEMg 3L5plvE+s65CqGEYhEAihj9cN6b7H5zel3ulKG1DHrIKa+r+o7saxlU8MsB8n/ZomIPc 1Gaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=ThHnNR/9j74Rarkk9nUgCXBgAgDJGiDv+klBudZG31w=; fh=FIYsLajw4XrD48kC+99gw32jk7SXWTm4TXc3BBvkwsY=; b=U7zk+VDagHP6O3CwGatIWUFkXNaZzPLachvd5Ssb7pbiV6WYlYbMXjK70SJfu71QKz WyTHr1mEVO2ebRJXxUx0U/tnAnJrDNNRjps8LmP1zlwJ+co2JD+IUcTFplnEIpD52Uqz 3iob/IRdA6j4N7wXFuRZQYK9Ja2XBDg7fQDYKXGfYV48jEGIMCOR1Q+WC6pgOQVmd9IV q7/XcDc+PVYCZJdbNUL44CEKZfIBnlbYjac1v5/CFFPZft6H8pnyl8hc9fr4eKPpF104 px9JFwbFT9sOIANitE4OJ/tLzyMklnoeONnK+cvxwHlFlvz6vW8lPPfaIumptcnrfsYt EzCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194977-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822779bf8esi11088627a12.298.2024.05.29.23.04.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 23:04:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194977-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194977-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 33D49285E18 for ; Thu, 30 May 2024 06:04:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 988F4143746; Thu, 30 May 2024 06:04:10 +0000 (UTC) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 C2C8A7F; Thu, 30 May 2024 06:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717049050; cv=none; b=SKluSDmg4M2I6xJqfmlIW5IgqxQyF0mS0+hENK/5KZxlamwNWQB8JlrG1GnDWp/SKCoTLqczFoAZgpL6lSjZ6sEMsmxPahBzHEzGxCa4VTbGe7Um1tHaVlDEkhwzq3ihzJqgnkhpESFucYTf112b55hyNfBIzS/b3wNlUNFUyyk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717049050; c=relaxed/simple; bh=URxu/tsa8bKNnf2t3ZCrJR7OioSdMvg9SOTtIE8dyKw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=GQzvHlh9Qh6txY2B+Qk+CnE0B/6UQ9ODbGBDLIxuHGIWZz0hv/lm9cS060Qc94/FVvs1P9q9VaO6VsAU/gbAlzJ2pR4a9e4D71K9vnYp052fVauFsdfNr8KocPUEemvz4PKS8oYXAWe+iBWLWnmBZn3H/dqtnMfhd4oafL4r7Fc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-681ad26f277so437357a12.3; Wed, 29 May 2024 23:04:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717049048; x=1717653848; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ThHnNR/9j74Rarkk9nUgCXBgAgDJGiDv+klBudZG31w=; b=mCJrrsk51ik5y17Ul+z8hx7iE0O2cOH8rlDonYfHwSUa7N7P3RdE6bc/VV4r2qOOba G/lo+JyMV7xhwvXOIX22LtXe5SzqGKGzeiHjCRsFHbBzRTFWRAUPjM80JafDgrkTBmnP HGGTcrwPhTiw2dqle/S7Pg1iF9MaOFPerOzXqSP3ZS9VOYCCnB55Jtted/G3bayqVA7K FF8VBXVCfHxCDb8fupTjnN33jJUdzVeNklf9JsH3+GrRJzQbb6RyAYRGd1aQ04J80MEn VEIcyr+Oo2PNk9BZ4ma/IFITv4QFWDAoqwNQE5kjfp1UjRsfs/XpjPISgPopdvX7QAFR qRnQ== X-Forwarded-Encrypted: i=1; AJvYcCV03O3NztfQFoaOGWkqcntZATCnR13XNg9Tyqp51GlnAo9nUtMNx9BgxOVnSVPnDfk0Hkd9izEYm3mGyc4YkejXZxIJnS8JO3NOhsTjRLzEHIkyzB/Xx6aYqTwvjKJ4t/a3M8pJ/CUUqdJ/P0wmIX1025k9IcZirLk0kteiT5YGX60VkA== X-Gm-Message-State: AOJu0YwtZm3ms3f7pDdoPVBOkxVim6S6SXM3FO2VALTNfCTVqTEsGLr9 Jw7YZEEqxCD/CWDjUl6dPy9OEHTYm3PCkURAi+2z4sNOeAraag+uE5PwQu8bJSJEuWhgkgcmhzH CfyLgMtVrruUzlCowjdzJ22SC3ph/jA== X-Received: by 2002:a17:90a:f490:b0:2b1:782:8827 with SMTP id 98e67ed59e1d1-2c1ab9f6d69mr1272467a91.20.1717049047939; Wed, 29 May 2024 23:04:07 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240524205227.244375-1-irogers@google.com> In-Reply-To: <20240524205227.244375-1-irogers@google.com> From: Namhyung Kim Date: Wed, 29 May 2024 23:03:56 -0700 Message-ID: Subject: Re: [PATCH v3 0/3] Use BPF filters for a "perf top -u" workaround To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Changbin Du , Yang Jihong , Andrii Nakryiko , John Fastabend , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 24, 2024 at 1:52=E2=80=AFPM Ian Rogers wro= te: > > Allow uid and gid to be terms in BPF filters by first breaking the > connection between filter terms and PERF_SAMPLE_xx values. Calculate > the uid and gid using the bpf_get_current_uid_gid helper, rather than > from a value in the sample. Allow filters to be passed to perf top, this = allows: > > $ perf top -e cycles:P --filter "uid =3D=3D $(id -u)" > > to work as a "perf top -u" workaround, as "perf top -u" usually fails > due to processes/threads terminating between the /proc scan and the > perf_event_open. > > v3. Move PERF_SAMPLE_xx asserts to sample_filter.bpf.c to avoid > conflicting definitions between vmlinux.h and perf_event.h as > reported by Namhyung. > v2. Allow PERF_SAMPLE_xx to be computed from the PBF_TERM_xx value > using a shift as requested by Namhyung. > > Ian Rogers (3): > perf bpf filter: Give terms their own enum > perf bpf filter: Add uid and gid terms > perf top: Allow filters on events Acked-by: Namhyung Kim Thanks, Namhyung > > tools/perf/Documentation/perf-record.txt | 2 +- > tools/perf/Documentation/perf-top.txt | 4 ++ > tools/perf/builtin-top.c | 9 +++ > tools/perf/util/bpf-filter.c | 33 +++++---- > tools/perf/util/bpf-filter.h | 5 +- > tools/perf/util/bpf-filter.l | 66 +++++++++--------- > tools/perf/util/bpf-filter.y | 7 +- > tools/perf/util/bpf_skel/sample-filter.h | 40 ++++++++++- > tools/perf/util/bpf_skel/sample_filter.bpf.c | 73 +++++++++++++++----- > 9 files changed, 169 insertions(+), 70 deletions(-) > > -- > 2.45.1.288.g0e0cd299f1-goog >