From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 1B6F12C0296 for ; Thu, 13 Aug 2026 08:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786609889; cv=none; b=h7h4YIc5NKJW8z5MIr7QS9jeztw3Qq2Ea8UxYB/0UqglUk8cw9fLHf656X5bKbSKNdOwcJaG0RSl6vKOVTOxRP+Uc7bq6Hn8WODwY/1yODt7YCPsJ32DNK0jt/h8VOL9EZcZ6CV2er01jPK3kwdbMORHTTIaKx5cByrtoYiJLUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786609889; c=relaxed/simple; bh=LMi/OV+Cm0ipRtfFs5ZeyscPdvojyaPEEcChB2H4lKo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ROwZgn2+ef9tGQJrB7+ctiAgj86NBm/BZOPSncL/pm4YpLgL1dDCdzLNUtTedV5F+5sTwzahlNplqVmWDVyzbp6MPF9dv9xN5Uj/aLL6VqdWgsKWQi6DujrCYRb6I40SwzTOvNtBSfYJ+R1NabIfcRPZ5ejfRwvfbH9pvrlui/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=emXwTQRi; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="emXwTQRi" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-c15c42a45adso109340066b.0 for ; Thu, 13 Aug 2026 01:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786609886; x=1787214686; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7yUisejUB/RXblzXQvMfPo73Fse8gZhIxVZGVkZNBxE=; b=emXwTQRioauzsfYCuKe+X1AtxW3vLMlNQqdBbUq+oJane0pKk7Sl8XAydwey/FlTz6 Q+MJAJIzZCY2QdJ40rcEG3KvDCl3pcaUT3JzqzblLl+YN+z4TwPYPuFqyFcxSz6P3oZ+ dqRRMVeEzlmbHIrmFQ9SJ9Ki+yp2XkP5U4luHKUpjm+6dKz8JsBaYIBvyj38dWgmyFjW WwZsw3gbAALeGOCKJ0VTNV/JWgJBct4X+rbA3tgScvPJqoc0/PqhGsyeMFyEYNwEoaTI 7E97pc3TyNm/O2v3t8Ppdf6nD2UXCUWy9XMCwG7JZoFJptsjsKPUD4Uz19Up8J806F2E 5Jsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786609886; x=1787214686; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7yUisejUB/RXblzXQvMfPo73Fse8gZhIxVZGVkZNBxE=; b=plKIE8mgj4yxTF7omC5VwiFLOQSmv5CQL/ZJ7fXsUDfbgktLqNIanrput5h1lifjUN qjUK8Iko4QN4jFIBdg+635BAbXanDSXjekZIXp4Sik6fxCfatfHiNpXSdoQEK4xLDUma B2Z2BJDqFTXj1qFmgKKeRVI9Ue62ppQ4eCznfl7kP25RqRbmz/a7jiwtwWImvBvXY7hy VvaPyoghLwlD0vP2QlSMsIlLqHHGHFp4pt6Pc/+qtR9wZI9H1Qxw9YGziyoo01Ae4vGh T7kUzjRSpTk+bX8JPscnd9FEVfizKH6jKzP/OLBInEMEdYCSYcgJNiSDN/otrVzxV+dF IqxQ== X-Gm-Message-State: AOJu0YwvU2IEC0yskrTDJ02lfrevikRUHrarvujRYjliaRh93fGEupj0 OC8nv0RRCcowGVqUFfWZeMTjlhhOQvcrI81NgCLJgTcl+v9hTGX7vJxY2M9ugkARX8Y= X-Gm-Gg: AR+sD10HUBJ2DV5mSBbG7AQEwWe4eO7TSOBhXW/cQ8bpGc9FWgixasHU0/m8H1jQ1LX bivhVDIFt+KFke/sQT6mXKp+juEx4+IWoGAv/mf3FmrYCd4R+Yh4J5/yb90w08DFsftucLJPdM5 BaU78s9ZNhiRIexxLewKaIg/JmXdNZJk7pmSXgsXidc6H9ELDsL8Djca0H85M2JjGmpq24V8tNB N6ea9+0Nyxq7JDgonEDskrP/G+0QTB+T+3wJJ+JqoM36gqeHq3XanLwdX7cR09I7qa4rMzA9lR2 VH3eyuQtZgNXpidOVbUBgHD6qL3nF4DSHn7+DDzdf0UjTpfKfxIqayu7cAYwO2/bM7LlnyV4pD0 T/MnresDI3gTFPH0aoEfOZWxB4LrYaHgbGLL70EBNnDEuYQoWEseisDizQDGAtBXgVlEYPyJPNi KOCt706h1xHOdIg4ohbUIWqr6T21WqCx2CDV2fVYctO6gXu1+idSXLcav+bo0wVxWviQ== X-Received: by 2002:a17:907:a686:b0:c15:a7b9:2ae1 with SMTP id a640c23a62f3a-c210a820123mr158648066b.6.1786609886208; Thu, 13 Aug 2026 01:31:26 -0700 (PDT) Received: from [192.168.1.3] ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c21087e2c7dsm61260066b.39.2026.08.13.01.31.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Aug 2026 01:31:25 -0700 (PDT) Message-ID: <856c4a5a-6b45-42ea-822a-01791b952af3@linaro.org> Date: Thu, 13 Aug 2026 09:31:24 +0100 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/9] perf dlfilter: Add non-empty branch stack filter To: Amir Ayupov Cc: linux-doc@vger.kernel.org, Mike Leach , Jonathan Corbet , Shuah Khan , Swapnil Sapkal , linux-perf-users@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Suzuki K Poulose , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Will Deacon References: <20260803090640.2412336-1-aaupov@fb.com> <20260803090640.2412336-4-aaupov@fb.com> Content-Language: en-US From: James Clark In-Reply-To: <20260803090640.2412336-4-aaupov@fb.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 03/08/2026 10:06, Amir Ayupov wrote: > --itrace=L adds decoded branch history to existing samples, but a sample > that was recorded while the decoder had no trace for that thread keeps an > empty branch stack. Consumers of the resulting perf script output, such > as profile generators for context-sensitive PGO, have no use for those > samples. > > Add an opt-in dlfilter that drops samples whose parsed branch stack is > empty, so users can exclude them without changing default sample > semantics. Build and install it alongside perf's existing dlfilters. > > Signed-off-by: Amir Ayupov > --- > tools/perf/Makefile.perf | 1 + > .../dlfilters/dlfilter-nonempty-brstack.c | 26 +++++++++++++++++++ > 2 files changed, 27 insertions(+) > create mode 100644 tools/perf/dlfilters/dlfilter-nonempty-brstack.c > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > index 0031112c036e8..aeb8085b0756d 100644 > --- a/tools/perf/Makefile.perf > +++ b/tools/perf/Makefile.perf > @@ -427,6 +427,7 @@ PROGRAMS += $(OUTPUT)$(LIBJVMTI) > endif > > DLFILTERS := dlfilter-test-api-v0.so dlfilter-test-api-v2.so dlfilter-show-cycles.so > +DLFILTERS += dlfilter-nonempty-brstack.so > DLFILTERS := $(patsubst %,$(OUTPUT)dlfilters/%,$(DLFILTERS)) > > # what 'all' will build and 'install' will install, in perfexecdir > diff --git a/tools/perf/dlfilters/dlfilter-nonempty-brstack.c b/tools/perf/dlfilters/dlfilter-nonempty-brstack.c > new file mode 100644 > index 0000000000000..9e66205b841d5 > --- /dev/null > +++ b/tools/perf/dlfilters/dlfilter-nonempty-brstack.c > @@ -0,0 +1,26 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * dlfilter-nonempty-brstack.c: Filter out samples with no branch stack > + * Copyright (c) 2026, Meta Platforms, Inc. > + */ > +#include > + > +#include > + > +int filter_event(void *data, const struct perf_dlfilter_sample *sample, void *ctx) > +{ > + /* Return 1 to filter out the sample, 0 to keep it */ > + return !sample->brstack_nr; > +} > + > +const char *filter_description(const char **long_description) > +{ > + static char *long_desc = > + "Instruction trace decoders can add branch history to existing " > + "samples, but samples that were recorded while no trace was " > + "being collected get an empty branch stack. Filter those out so " > + "that only samples carrying branch history remain."; > + > + *long_description = long_desc; > + return "Keep only samples with a non-empty branch stack"; > +} Reviewed-by: James Clark