Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp791212lqb; Fri, 24 May 2024 13:23:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmU4UDS+eUxFnLqmAF/Gg5XyRtjyS4u00LWnxGuXvZttucUCCf2Tm0hu6Yk2bQVrv4NnNPhXpS1aon2cNTsKNhUUKSsSFVVd8JPcXd5w== X-Google-Smtp-Source: AGHT+IFoxbhAPGRS7sxKqzyq+Avu+UiQ2TvUoB3cYTKtWdjal33u2iAq9G1AHc4h8t3iGzo8wrzF X-Received: by 2002:a05:6871:68d:b0:239:61f7:51a7 with SMTP id 586e51a60fabf-24ca1170613mr3219674fac.13.1716582190373; Fri, 24 May 2024 13:23:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716582190; cv=pass; d=google.com; s=arc-20160816; b=EvwGXJo+DzLqBsBwDwqFebMUTWZQhmjdiGWzCkzdMMhoQsIXoI06xRnUCIl7x/p0qD 2bHIJYqFhR3Hh7FtJ7kEA/ABz2PYsnsLiKf2qFSNJWhrBC8SukUNcD12EoPx6Nr+MiDg sUkpTcheNWOGvZpFmRVgGN7mxiNr1609pTuTxEZDgXvHcxYT/CrlqlECxHr2qqir2HHB Ai2wFr5tWun7cXqEAQw77H7FIriJbvzfQF6yRqnHqoQjmtsubVWMgiKSH5lUuM8mmbCv eeLTnylsLYKQwcY1MLdFkGllW3Gl72wv2VOGqjYPuQycURgODSNobULf26YH+cEYe3yQ 6efg== 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:dkim-signature; bh=F+IQkIDsWv6TAoxlWNpgArjw1bM2St+LuCkqXoQSIsY=; fh=uDv/oDw/qgy3SH4fCebGjkpeCLCf9AJzP5GP+YhSUbk=; b=rNkQYFZQO/Lmoyi9MwOAMawfFRjYnCsQlbporJFAmns1X+P/SQ90CSE9uIuIKmSIyU m6Y57PT2eAHm+iWGi14Lp5+um1ro3ujy3/rFQ5lEAEb4jIdMT/ARq+zs16pZY8qXQs9D NvmE/QC+eS2EsvMk4LcWlqZq0Jpdyes3EOM+DtkTifUXotk9SXbLeTa5DgsN8wFcKKkN WOlmH4TyH0bmjuvQr8dgp82S0deX4YNxEo+MD/JrKjGs1lB672Stza2KWtuRZvAKzmxJ 1zAtoK74UXlAfnVKM8Q+EXgdVDZ35EpKpOObQHHSOXcYbutffT8U/gqTxVxx8TYKieAy LcfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QJaLqKif; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-189083-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189083-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18b2f72si29883281cf.501.2024.05.24.13.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 13:23:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189083-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QJaLqKif; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-189083-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189083-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0A5E71C20E9E for ; Fri, 24 May 2024 20:23:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E515657CBA; Fri, 24 May 2024 20:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QJaLqKif" Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (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 91136446AC for ; Fri, 24 May 2024 20:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716582178; cv=none; b=HeTlIvyWYgszwM33b++P9E6LIbnfHrFD03cRhnyMaGx7AC/40AzNXPUDrTRDfkFy3/WCoPMSzfGxN517Vqnp37YkY/riU/U6Vlfg1GCUgz31IARLR6KmlIKXnncWVEbJQV5E63AhDsDYLHLURiXxiqv1SMMnlFw2dcWo+MXx0Qo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716582178; c=relaxed/simple; bh=DN5DiwrRd5qbw3sclKQ+zjoZIjY62xjvwfTAj7+2NkE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fAbnyYyix5qVYZzxQnVdYEQrVFsnzWueQbURMRGFPh6J9zWczn9kfwUdl7KH3BeMLSH2k3e2GYJwWo2IRGSLBo+WhMg7nAKrF9KAPDQ7WZtJdMU0cZqF3+ZGW16qRq43wMPXmNqCzjAXjDDV1wsBak4UPIsyr4cMa7DF3QRw60A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QJaLqKif; arc=none smtp.client-ip=209.85.160.177 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=google.com Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-43dfa9a98d2so8721cf.1 for ; Fri, 24 May 2024 13:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716582175; x=1717186975; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=F+IQkIDsWv6TAoxlWNpgArjw1bM2St+LuCkqXoQSIsY=; b=QJaLqKif2mVg0g3Xd1/jW0UV2qDjoIfbjuU73axBV2gHhOMI7qwbq60LITDZgIOecS +5mFpnmXvzLyrBmAGH2UTyh6TrPE/xEI5+RoV9MuEHPsBk5XyCykZ58SEs43eo7lQ6FY kh1eLU7okNrNFyrhVwo+RNa1T/k7Is0Rt3MT7H/BQIaXG3qnY2Z3yUZBsUgyuiiWkL6F U5iPZwCmRWS01tmqGWJ1q0Njnn4miB1PfLuOAf+egbI3xdzYhJOVtqs6JVSjESvQpWmW 6ybKtSSLefGtJoTaEopFSOY14riW5JLiHtlDyGEUc1s5tVjc7EeDX+0V87UpoeGOrN6l 3kSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716582175; x=1717186975; 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=F+IQkIDsWv6TAoxlWNpgArjw1bM2St+LuCkqXoQSIsY=; b=kQ5+pCbw+e72xdZFlD8rN37oO5UUMn6uU9/eXtXm+l1PCd5nfzFXYo+X0Eio4VQ9Cn EVNdHlxlFLfpMYdEXR0gPZjwK72r+OR5/hTou5vI2DcEloIF/vuJ+CN+sG35hQfl7BC6 PUEe9oaeKpPCjkJfB4ZagXdQOP4Jpv5aYYTy+HR5sGh4kKhsquWGioMjHPwDCWwo3oU7 AVW0FP19z6ujDKnop9krZm+8h72eeCvZr9owk21sLtbUIP8madiY0FNRDAeaEJUuoAP2 HlepvnNe2P3G2nO3sbm5TvBD8oHEWb4bBoEYjCa5l1uQD20OP4UenTAsB4GkHNsoMg41 uoNA== X-Forwarded-Encrypted: i=1; AJvYcCVAxLOgQZyVr77hu8srozw5sCBVd+JWASLAQTDBonCUQQXW40pGVm2kPeyeaxuYEv3069pFEa7y/XouT8QK22XdvswykCcqWcK6Wg19 X-Gm-Message-State: AOJu0Yw8QlY5Pdhv3EcZWSpkZDyIkBoxuuR4ezQvNZ6rIFjY5N9tRpgS CCy4nq6+deq8UcrB4fted6shnE5aiOpQ/cwntJ5ySw71ULm4UFhX+IGL9IsgxJbUodPxB8PTcOz jCSx+IJvh/Rk4JipFnX+pMWphHCa9nlIV8VRX X-Received: by 2002:a05:622a:2507:b0:43e:143f:d184 with SMTP id d75a77b69052e-43fb9f9acb5mr651011cf.20.1716582175215; Fri, 24 May 2024 13:22:55 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240521010439.321264-1-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Fri, 24 May 2024 13:22:43 -0700 Message-ID: Subject: Re: [PATCH v2 0/3] Use BPF filters for a "perf top -u" workaround To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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" Content-Transfer-Encoding: quoted-printable On Fri, May 24, 2024 at 10:58=E2=80=AFAM Namhyung Kim = wrote: > > On Wed, May 22, 2024 at 09:38:57PM -0700, Namhyung Kim wrote: > > On Mon, May 20, 2024 at 6:04=E2=80=AFPM Ian Rogers = wrote: > > > > > > 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, t= his 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. > > > > > > 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 > > Hmm.. I'm seeing this. > > $ make build-test > ... > cd . && make GEN_VMLINUX_H=3D1 FEATURES_DUMP=3D/home/namhyung/project/l= inux/tools/perf/BUILD_TEST_FEATURE_DUMP -j64 O=3D/tmp/tmp.EeXFOfLPt5 DESTDI= R=3D/tmp/tmp.Y0eiZKvc9D > ... > CLANG /tmp/tmp.EeXFOfLPt5/util/bpf_skel/.tmp/sample_filter.bpf.o > In file included from util/bpf_skel/sample_filter.bpf.c:8: > In file included from util/bpf_skel/sample-filter.h:4: > /home/namhyung/project/linux/tools/include/uapi/linux/perf_event.h:29:6= : error: redefinition of 'perf_type_id' > enum perf_type_id { > ^ > /tmp/tmp.EeXFOfLPt5/util/bpf_skel/.tmp/../vmlinux.h:54086:6: note: prev= ious definition is here > enum perf_type_id { > ^ > In file included from util/bpf_skel/sample_filter.bpf.c:8: > In file included from util/bpf_skel/sample-filter.h:4: > /home/namhyung/project/linux/tools/include/uapi/linux/perf_event.h:30:2= : error: redefinition of enumerator 'PERF_TYPE_HARDWARE' > PERF_TYPE_HARDWARE =3D 0, > ^ > /tmp/tmp.EeXFOfLPt5/util/bpf_skel/.tmp/../vmlinux.h:54087:2: note: prev= ious definition is here > PERF_TYPE_HARDWARE =3D 0, > ^ > ... > make[3]: *** [Makefile.perf:264: sub-make] Error 2 > make[2]: *** [Makefile:70: all] Error 2 > make[1]: *** [tests/make:340: make_gen_vmlinux_h_O] Error 1 > make: *** [Makefile:103: build-test] Error 2 IIRC this only exists for the sake of asserts. I can move the asserts to placate the generated vmlinux.h. I'll send a v3. Thanks, Ian > Thanks, > Namhyung >