Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp56386lqo; Wed, 15 May 2024 21:20:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzeqp2IJCrV9bPn10V58y/kxgSui00r4GLFVFSs3BRjb0Lzcpe9tfc/mTCGKh6ge5CFfpTKMReZE97g7WEY73wVRNl+EDEkee1HXs0zA== X-Google-Smtp-Source: AGHT+IG++AyHmjkSbZc6qeiw9G2LmsFWBG6SRPeyY2ysHNXF5iM2cxGpcJXsUvBcka4QO19KgRfH X-Received: by 2002:a50:cc48:0:b0:573:5c4c:a87a with SMTP id 4fb4d7f45d1cf-5735c4ca8b7mr10355857a12.27.1715833213191; Wed, 15 May 2024 21:20:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715833213; cv=pass; d=google.com; s=arc-20160816; b=n8uu11wNmd3Xw7B+rKQ3Csh2UMM83IIYWCc/fm315uwBISBui9Sf+BYyVuqxzZcLiC LYmAkQT9tCgVB75jA/ctcVPloXDWSw6LGpq9o0E3kXFyYgyvCjgX1hrocbC7DGVIyxU8 069Z37bRCInbwmR86Gm0vvuBemDu0g71GFi4Cve9ZXmAo+wJOAk0ko7hb7kuBTgzuuO/ 675IU5jDLGCLH/uEG5Nwg0BBqpTOChrU4H9M7duHHn+hdb+ukKCIHWVF7BM8TZgU3ZgK 33Mc5pfvFzC6hQlTlwFbH+6stFV2zlqqZDDfVHOl/QDoQ7TTo/0AiVqMEjkJyqJMttOl L/Dw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=NhvrEJQEtg7mfpXP1eaEk1iTrmpUehU3kjsviXcKots=; fh=PzpReUsCHbmmGcr6KB4OKc/OFnGCQ5UvGwd6VvtXu0Y=; b=aul+XA0KDnqyRNI8Brw7PY0nWVYiqpNfpKefKMFpibK1Bc5Xwfklj8y7pPWTTHOHA4 RjbAHE3YHtpE73jzq2v/p/Nsg4PoCRVyeo08CL4Bgx4DRjRmrkHH+O89ALfYEFrxK1fR 5QuhhLRa4sHF3rpvgYnB0yeoV2b/oqzwQk+cvf578leqZV4quwtwFlfxg+xZT8C0UZPF 4HbU0B7rM1gf1DqK5wi+SkDCrSBX0EFluXlxmklLPEURBk/spSWiBucxI2z3F8pzxW/P BqcvBPEXVltGtvM6a+tdGlKllCx+y5Hww7svIMiRTTZ++mYUWZFH/Ed2XVOWHtF40+x5 cwFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PN9Pakz4; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-180617-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180617-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733beac6f9si8120296a12.25.2024.05.15.21.20.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 21:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180617-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PN9Pakz4; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-180617-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180617-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id E7E941F24036 for ; Thu, 16 May 2024 04:20:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6752B25601; Thu, 16 May 2024 04:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PN9Pakz4" 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 457AD17BA1 for ; Thu, 16 May 2024 04:20:01 +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=1715833203; cv=none; b=IBu1Pf5ATl4mXbVhzjJnUDUWQBL7j9vVw/DHn1+njnfbuc8HTkqF+fLbomCy3kNSIVeSvyg+gyc9OewHQaZzck6c7kK3Mr+Zq+5dKn46iaMkf0/q+LPSszW8CNs02ppVWLWDqCQzmhQliHW1JRCtfOg2P5lSNcfF37hehQLGcXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715833203; c=relaxed/simple; bh=lHHwkYfHA8wjarLgp5Pin3R8Kdwmiap6eamnf3fEAj8=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=JZqIv7Yq6fUWC9ZPwEP1FiBEqBHWqxGJTFmc/MUkBwkPnxs0C5OF1kO9Wv90R9pDwHEhkzk4Ska/tAj+qGS2AoFv6Lo4I1QL5T20vI0fxN9qgu3EG6iCf6qXk6hEalHOPg2OMBCDrjUWrXVxYX+96h4ZCRn98GfidReLMwrQoaw= 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=PN9Pakz4; 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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62035d9ecc4so144948867b3.1 for ; Wed, 15 May 2024 21:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715833201; x=1716438001; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=NhvrEJQEtg7mfpXP1eaEk1iTrmpUehU3kjsviXcKots=; b=PN9Pakz4SXgiav6BxBSqXt+qB/OAbcUzUB281zKhngB03cLS+oQ0j8QxbK9i91dprF Mhs9LRH/zwdrijMPsG0FLAd4jCFZozqyGYPOKUjgA9YfSj6h+NbGv7xqDMIoRP4HxqUa jJr37v6Kny0s5HSznqjAlThPODBrF+vJhBCx6xz+oarmpLucmADCVxkzp1+Sub4NuBlw 0xyV7+aNHDAF21dNo8r/PQFfq+jdTy5enYplpA5c5qhey6dr8OWCi8zAhfbIdsz31h+y je1GdNI1aQRpRatMc8GzpAYLn9oBABRN2KBfz262BD+nx4NVIngsV+S9DKdq9tqT6OsP P3Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715833201; x=1716438001; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NhvrEJQEtg7mfpXP1eaEk1iTrmpUehU3kjsviXcKots=; b=l++2Fl3nUGpp9gel3NOXDyUhIPbuXx7+mGmMn6qaPSLsG38rBS+n5o/ihAzvEyqXJN pyMFytzwb9W4r0FarNU3lMl3gdTG14GH/NZDv5RSFW+M4eBRsCEqE66pZ1Ek1Z2mQmxs fdkaQJeUt77DbF6FSlvKlThsgYKgw0/D7F5vUYPuEVGTcFrNvYqOWcGRd6IcQFeNlhvE w/EOXuDamdSDYTZBUET23OUMVqZ5BmramR2hGXH5rxW8mwi2+0hs/wiIw4xYppq2sjry Vt31R7s+b6xay/9q49nPNjpZw5ocMK/KHI1CN/SVzM2by5cGIO5bWqw9GhZhvgClrz6c OAtA== X-Forwarded-Encrypted: i=1; AJvYcCXYla/op9fPfhFPfIL0lx8GeFgOW2F1Fy/wwW+gMS0xTFuV0pVLGrz/4zjlm9CTn8oRK+tuavH8WQ2tnndxZA/LbCgTPWhu05KfeYDN X-Gm-Message-State: AOJu0Yw+cvMr1loDjkeVtQLk90jMzLJFs6rFxQN38Y/1uvWmDfsEeVgc 7Yl52UGA0SaG3Gh4swN2bJ/Y8zJQ1UXlqSwIg4YhC5jHJrzWMwoFbygk4FfU788pSu5eRw6qq0f ZvfiYAw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bac3:cca1:c362:572]) (user=irogers job=sendgmr) by 2002:a05:690c:668f:b0:61a:bda3:a78c with SMTP id 00721157ae682-622afd81d04mr45306547b3.0.1715833201091; Wed, 15 May 2024 21:20:01 -0700 (PDT) Date: Wed, 15 May 2024 21:19:45 -0700 Message-Id: <20240516041948.3546553-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Subject: [PATCH v1 0/3] Use BPF filters for a "perf top -u" workaround 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 , Changbin Du , John Fastabend , Andrii Nakryiko , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 == $(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. 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 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 | 55 ++++++++++++---- 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 | 27 +++++++- tools/perf/util/bpf_skel/sample_filter.bpf.c | 67 +++++++++++++++----- 9 files changed, 172 insertions(+), 70 deletions(-) -- 2.45.0.rc1.225.g2a3ae87e7f-goog