From nobody Mon Dec 15 21:32:59 2025 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 8F87F23098F for ; Wed, 15 Jan 2025 08:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736928066; cv=none; b=E1WlWxbK29YMvHOVczt7x+mMSfRFaCKtAu6iUUBwSzJs5tKGm6hE4GxZEWGyUWLizlTLBww3vl4sTGBO/vHruADUH9h/YgProQZo91xC3hugEKtHENJjPTRteMmQNc8qdfTkotLvKrDNlZTP8f4QRX2M5XlM2rC3UsXC4pZND/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736928066; c=relaxed/simple; bh=YKHxLAnwi1/RFMou0CO808TfBTITsxzcHkibYVw5Mwo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kcBxsa1XdLxUqhdcaSz8g1ePtxy6BCXy8AsN9mGcY4PaMaUI25XP/Vg6ka0P6fRm52p3pIH7vA87LwbFNBXX9hobhSm54tK/UOvAAmXqNNAU8jJgEogawzzVvLIOg8YNiBLsJhW1/B1Fd6wrUn+TmMybsNXnFcHL63v/xLt5JLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dvyukov.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tqp28Gbk; arc=none smtp.client-ip=209.85.208.73 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--dvyukov.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tqp28Gbk" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-5da03762497so607164a12.1 for ; Wed, 15 Jan 2025 00:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736928063; x=1737532863; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YgHKE3uZqH4ST2EhNohkGFxAJXehtiGaOdsmit+cAuY=; b=tqp28GbkFDaoldts3q5FzEshcchxv0Yra1ffgoJDN7yg0yXqOEarDuiZHPtS0sY1pf m5gnaxjGmmd18cgMLYO7BarL+Mx8B/M5aePGkxsMcSyM9h9K45GrOxhhf1ocrpaYL9bj 76fLwvEq+sAk5E7DA+XXZDS7ndneLuQp1uk9U22BveL/xcTaDGOYR8+017aCFDAea2bF VwFLlQcG7jkkLs/fB+29ij6f3eWrV6qUYfePDKC2t0SQ37uC/ql0TCKo9Js0JMWX79WP Gy62ophkk/jO/0ibMAs4r6TacyYqHqEQJc6JUPaCBioIXpQMNSxD+wkO2LKd+E95+JJH uNrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736928063; x=1737532863; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YgHKE3uZqH4ST2EhNohkGFxAJXehtiGaOdsmit+cAuY=; b=QVcN1AVvhvZKBXaOAzkjgozsqzIpXAKtN52Lhw/r8HKvSV9pVY7q/E60LTkpIXNXYq B9GflgPQgOlugu5jR0BxsiFEqhFmBf5d5NGdJMDPyiN0eTQ1jtHaR2o1w2ytLu+u80jF GYBhY12bH9eCy9HNhTns4w4qNisl2hP8Eg6JhVsGvTYureiZiIO2Y0aM7LpSNSeE8SDg koe+ZnBk1XhXh7ZLDdO/sLNNdQyPhDnJ9MwY5UB+3IOrLHd5I33dWzmdOS13EuLBvoMc MXfwv0+4/uxUnirDYXfI3xM1HwGq7THQnL8Wv3L2HldWD1qjZJRo3j0pr54qF/4SmuDP 4Iyw== X-Forwarded-Encrypted: i=1; AJvYcCX/EEJ5ZhQgXaQaukJiMBpDb6azRs2eDBqpGk/9VfjJafdVOX8jOPlhOAg5mySJ3XwOZYAUxHZh+fwLv38=@vger.kernel.org X-Gm-Message-State: AOJu0YwgM1idO6BeGnsEjaMlp4BE7kwHTmLVzcomwRTY+XGlLoftakp7 Oz+ZvdsEDKb8nLjvoqhfmgEJ/lM0MRehbAofDeE9PNqaRuPYK+B8MpOcZ2AbTsqRficlUBjiQw+ wOiUzWg== X-Google-Smtp-Source: AGHT+IHN6w2FMMthhnA3GmLnZ6CBcMdxbW6uiBVxYW7Oy7R2XJatzlT8mYEDwMJrIUH3NvuPCDn+ZnwdO1uR X-Received: from edpj11.prod.google.com ([2002:aa7:c0cb:0:b0:5d9:3dfe:dcaf]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:845:b0:5d9:c2f:a961 with SMTP id 4fb4d7f45d1cf-5da0c2f19e7mr1440448a12.11.1736928063010; Wed, 15 Jan 2025 00:01:03 -0800 (PST) Date: Wed, 15 Jan 2025 09:00:41 +0100 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <84c4b55614e24a344f86ae0db62e8fa8f251f874.1736927981.git.dvyukov@google.com> Subject: [PATCH v3 1/2] perf hist: Deduplicate cmp/sort/collapse code From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Application of cmp/sort/collapse fmt callbacks is duplicated 6 times. Factor it into a common helper function. NFC. Signed-off-by: Dmitry Vyukov Cc: Namhyung Kim Cc: Ian Rogers Cc: linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes in v2: - add perf_hpp_fmt_cmp_t typedef to util/hist.h - use the typedef for perf_hpp_fmt::{cmp,collapse,sort} Changes in v3: - make fn a pointer in hist_entry__cmp_impl() --- tools/perf/util/hist.c | 103 +++++++++++++++++------------------------ tools/perf/util/hist.h | 14 +++--- 2 files changed, 49 insertions(+), 68 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index fff1345658016..493b3cc30eac0 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -32,6 +32,9 @@ #include #include =20 +static int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry = *right); +static int64_t hist_entry__collapse(struct hist_entry *left, struct hist_e= ntry *right); + static bool hists__filter_entry_by_dso(struct hists *hists, struct hist_entry *he); static bool hists__filter_entry_by_thread(struct hists *hists, @@ -1292,19 +1295,26 @@ int hist_entry_iter__add(struct hist_entry_iter *it= er, struct addr_location *al, return err; } =20 -int64_t -hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) +static int64_t +hist_entry__cmp_impl(struct perf_hpp_list *hpp_list, struct hist_entry *le= ft, + struct hist_entry *right, unsigned long fn_offset, + bool ignore_dynamic, bool ignore_skipped) { struct hists *hists =3D left->hists; struct perf_hpp_fmt *fmt; + perf_hpp_fmt_cmp_t *fn; int64_t cmp =3D 0; =20 - hists__for_each_sort_list(hists, fmt) { - if (perf_hpp__is_dynamic_entry(fmt) && + perf_hpp_list__for_each_sort_list(hpp_list, fmt) { + if (ignore_dynamic && perf_hpp__is_dynamic_entry(fmt) && !perf_hpp__defined_dynamic_entry(fmt, hists)) continue; =20 - cmp =3D fmt->cmp(fmt, left, right); + if (ignore_skipped && perf_hpp__should_skip(fmt, hists)) + continue; + + fn =3D (void *)fmt + fn_offset; + cmp =3D (*fn)(fmt, left, right); if (cmp) break; } @@ -1313,23 +1323,33 @@ hist_entry__cmp(struct hist_entry *left, struct his= t_entry *right) } =20 int64_t -hist_entry__collapse(struct hist_entry *left, struct hist_entry *right) +hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) { - struct hists *hists =3D left->hists; - struct perf_hpp_fmt *fmt; - int64_t cmp =3D 0; + return hist_entry__cmp_impl(left->hists->hpp_list, left, right, + offsetof(struct perf_hpp_fmt, cmp), true, false); +} =20 - hists__for_each_sort_list(hists, fmt) { - if (perf_hpp__is_dynamic_entry(fmt) && - !perf_hpp__defined_dynamic_entry(fmt, hists)) - continue; +static int64_t +hist_entry__sort(struct hist_entry *left, struct hist_entry *right) +{ + return hist_entry__cmp_impl(left->hists->hpp_list, left, right, + offsetof(struct perf_hpp_fmt, sort), false, true); +} =20 - cmp =3D fmt->collapse(fmt, left, right); - if (cmp) - break; - } +int64_t +hist_entry__collapse(struct hist_entry *left, struct hist_entry *right) +{ + return hist_entry__cmp_impl(left->hists->hpp_list, left, right, + offsetof(struct perf_hpp_fmt, collapse), true, false); +} =20 - return cmp; +static int64_t +hist_entry__collapse_hierarchy(struct perf_hpp_list *hpp_list, + struct hist_entry *left, + struct hist_entry *right) +{ + return hist_entry__cmp_impl(hpp_list, left, right, + offsetof(struct perf_hpp_fmt, collapse), false, false); } =20 void hist_entry__delete(struct hist_entry *he) @@ -1503,14 +1523,7 @@ static struct hist_entry *hierarchy_insert_entry(str= uct hists *hists, while (*p !=3D NULL) { parent =3D *p; iter =3D rb_entry(parent, struct hist_entry, rb_node_in); - - cmp =3D 0; - perf_hpp_list__for_each_sort_list(hpp_list, fmt) { - cmp =3D fmt->collapse(fmt, iter, he); - if (cmp) - break; - } - + cmp =3D hist_entry__collapse_hierarchy(hpp_list, iter, he); if (!cmp) { he_stat__add_stat(&iter->stat, &he->stat); return iter; @@ -1730,24 +1743,6 @@ int hists__collapse_resort(struct hists *hists, stru= ct ui_progress *prog) return 0; } =20 -static int64_t hist_entry__sort(struct hist_entry *a, struct hist_entry *b) -{ - struct hists *hists =3D a->hists; - struct perf_hpp_fmt *fmt; - int64_t cmp =3D 0; - - hists__for_each_sort_list(hists, fmt) { - if (perf_hpp__should_skip(fmt, a->hists)) - continue; - - cmp =3D fmt->sort(fmt, a, b); - if (cmp) - break; - } - - return cmp; -} - static void hists__reset_filter_stats(struct hists *hists) { hists->nr_non_filtered_entries =3D 0; @@ -2449,21 +2444,15 @@ static struct hist_entry *add_dummy_hierarchy_entry= (struct hists *hists, struct rb_node **p; struct rb_node *parent =3D NULL; struct hist_entry *he; - struct perf_hpp_fmt *fmt; bool leftmost =3D true; =20 p =3D &root->rb_root.rb_node; while (*p !=3D NULL) { - int64_t cmp =3D 0; + int64_t cmp; =20 parent =3D *p; he =3D rb_entry(parent, struct hist_entry, rb_node_in); - - perf_hpp_list__for_each_sort_list(he->hpp_list, fmt) { - cmp =3D fmt->collapse(fmt, he, pair); - if (cmp) - break; - } + cmp =3D hist_entry__collapse_hierarchy(he->hpp_list, he, pair); if (!cmp) goto out; =20 @@ -2521,16 +2510,10 @@ static struct hist_entry *hists__find_hierarchy_ent= ry(struct rb_root_cached *roo =20 while (n) { struct hist_entry *iter; - struct perf_hpp_fmt *fmt; - int64_t cmp =3D 0; + int64_t cmp; =20 iter =3D rb_entry(n, struct hist_entry, rb_node_in); - perf_hpp_list__for_each_sort_list(he->hpp_list, fmt) { - cmp =3D fmt->collapse(fmt, iter, he); - if (cmp) - break; - } - + cmp =3D hist_entry__collapse_hierarchy(he->hpp_list, iter, he); if (cmp < 0) n =3D n->rb_left; else if (cmp > 0) diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 1131056924d9c..46c8373e31465 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -342,8 +342,6 @@ int hist_entry_iter__add(struct hist_entry_iter *iter, = struct addr_location *al, struct perf_hpp; struct perf_hpp_fmt; =20 -int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); -int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *r= ight); int hist_entry__transaction_len(void); int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size, struct hists *hists); @@ -452,6 +450,9 @@ struct perf_hpp { bool skip; }; =20 +typedef int64_t (*perf_hpp_fmt_cmp_t)( + struct perf_hpp_fmt *, struct hist_entry *, struct hist_entry *); + struct perf_hpp_fmt { const char *name; int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, @@ -463,12 +464,9 @@ struct perf_hpp_fmt { struct hist_entry *he); int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he); - int64_t (*cmp)(struct perf_hpp_fmt *fmt, - struct hist_entry *a, struct hist_entry *b); - int64_t (*collapse)(struct perf_hpp_fmt *fmt, - struct hist_entry *a, struct hist_entry *b); - int64_t (*sort)(struct perf_hpp_fmt *fmt, - struct hist_entry *a, struct hist_entry *b); + perf_hpp_fmt_cmp_t cmp; + perf_hpp_fmt_cmp_t collapse; + perf_hpp_fmt_cmp_t sort; bool (*equal)(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b); void (*free)(struct perf_hpp_fmt *fmt); =20 --=20 2.48.0.rc2.279.g1de40edade-goog From nobody Mon Dec 15 21:32:59 2025 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (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 E6DA2236EB8 for ; Wed, 15 Jan 2025 08:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736928068; cv=none; b=G1NzGiWoIQIm4pr+0idanv9BjAxDCPq4xujpr5hT2BMbQKaujn+yx1cjTdCmnhP5yq8jwwumbtF1NslZiuNtM6Vgg/WGFUNMUAKcmRIU3BmrIRWhK0lRA0qy0vJavNZikQPFQpeZK8Mic7pQAAed2tw62HSjPqaz7dpQetcXljU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736928068; c=relaxed/simple; bh=KR+WO74H0KLVFOGNgOJZh6kbJOu9TObNxexKACaFMGI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=t4jKu992T8g1fyzsWVATo4DTtVCZR52lJ6DtuMs5WMoX+1GO/fSiD9HcWm3FiAa+Xh4xpoJr5Qb0nDEmZeZLd7FmgBMN12PwHOwzRNbio34GJ+6uH+HxH7AS6gvddqCgDNGW93b8cbwj4ugIeLLWlMmrVy9C5itO/BG44oNooDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dvyukov.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=J55QquPY; arc=none smtp.client-ip=209.85.208.74 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--dvyukov.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="J55QquPY" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-5d40c0c728aso5243495a12.2 for ; Wed, 15 Jan 2025 00:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736928065; x=1737532865; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=usWiQpF3MryasBotTIqnPXSZBuDJImkYsCGHtSkpl0o=; b=J55QquPYTkMtJ2gDMG0ZyKFaVfpSIWoJG6XzOI9qlqPYVncKctsH0CTaHI84OVgU2Y SWe8VfC5fj1bMFEvSdD2lrRr9UsxvGp81g1H1J9Qmz3JkNUbI4HjEwVxJLyG7eaEYLX+ h3N3XxKIB3IjikZYqm9BpIvJciRvUXIGdfA3XNkpCsLWvLenSHCrxIVuA/M28VW9J+r9 SLkTGPxEjfBkTCKv9xx0i/FA8Vrr7heflhGjvS9o2GK96dnVW8AWH9HdR6cpiDDs2Ng5 bDvotx4K8tO4aGhjK0s3ZvxBWa2sJcU2Rr3bWXDShztOH6n5BlVXKq8KHreDhLllTxxf OeEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736928065; x=1737532865; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=usWiQpF3MryasBotTIqnPXSZBuDJImkYsCGHtSkpl0o=; b=uaN2jrPuohudAhlSPoYUfV8p9fqfHYlb5KzKb57olJkeM6SJXPYQC86PzRp+xZQAoI dQfHeSjdSKbdXQybrol3kZ8njJBphNKBXgeutU+VtYXvols+hI55mNZkHxUJxPGMkz1z D+5PLsQfnM36TJHKfQK0jU7kX0UHpTkz0o1LgQnuNW5vvzT9qxMmFYfEERXiOogGhrXe YF7QejBqyoSG2sQlLQZlFpgjk7IdvyzTrCEVkt7Qv7jhxXkxHnwSu6XFcvgyYwfBxJbS gSKzPEifTwPFtsGDU1XZuvQ3HKwaOGGJKhNqndBYNl1U/cPTE+ox1QFddfnFD1FzZukZ skrw== X-Forwarded-Encrypted: i=1; AJvYcCWIvyOHrNB4RPXqjAeLuPXJ99I9EU1Sq5FiYvBC2Xjc83lKffu/XaMn5kCbddfctqP58ntEmmuGFvKTFB4=@vger.kernel.org X-Gm-Message-State: AOJu0YwaPavCOOLDwJulNvpwPVW3INXqdkH5C3GKGIimbs7J662BRPbJ fOwtxt/YVCFIqde4N3PFgRZH6D2LweJYSrtpICbJwvCQcwm5HD3i0XamGU8czOb/WiTMPSwM7EW HekcO1Q== X-Google-Smtp-Source: AGHT+IFubxo6Yp6KVOHXVTLhbeWeYZbE2oZBIMDA+DK9TY45pusOMuk/4qqquUWROJIg1U+NeCCkFy/LUMQQ X-Received: from edxu14.prod.google.com ([2002:a05:6402:64e:b0:5d9:a5e:5b52]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:530f:b0:5d1:2377:5af3 with SMTP id 4fb4d7f45d1cf-5d972e00027mr63767378a12.5.1736928065374; Wed, 15 Jan 2025 00:01:05 -0800 (PST) Date: Wed, 15 Jan 2025 09:00:42 +0100 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <359dc444ce94d20e59d3a9e360c36fbeac833a04.1736927981.git.dvyukov@google.com> Subject: [PATCH v3 2/2] perf hist: Fix bogus profiles when filters are enabled From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a filtered column is not present in the sort order, profiles become arbitrary broken. Filtered and non-filtered entries are collapsed together, and the filtered-by field ends up with a random value (either from a filtered or non-filtered entry). If we end up with filtered entry/value, then the whole collapsed entry will be filtered out and will be missing in the profile. If we end up with non-filtered entry/value, then the overhead value will be wrongly larger (include some subset of filtered out samples). This leads to very confusing profiles. The problem is hard to notice, and if noticed hard to understand. If the filter is for a single value, then it can be fixed by adding the corresponding field to the sort order (provided user understood the problem). But if the filter is for multiple values, it's impossible to fix b/c there is no concept of binary sorting based on filter predicate (we want to group all non-filtered values in one bucket, and all filtered values in another). Examples of affected commands: perf report --tid=3D123 perf report --sort overhead,symbol --comm=3Dfoo,bar Fix this by considering filtered status as the highest priority sort/collapse predicate. As a side effect this effectively adds a new feature of showing profile where several lines are combined based on arbitrary filtering predicate. For example, showing symbols from binaries foo and bar combined together, but not from other binaries; or showing combined overhead of several particular threads. Signed-off-by: Dmitry Vyukov Cc: Namhyung Kim Cc: Ian Rogers Cc: linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- tools/perf/util/hist.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 493b3cc30eac0..0f30f843c566d 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1303,7 +1303,16 @@ hist_entry__cmp_impl(struct perf_hpp_list *hpp_list,= struct hist_entry *left, struct hists *hists =3D left->hists; struct perf_hpp_fmt *fmt; perf_hpp_fmt_cmp_t *fn; - int64_t cmp =3D 0; + int64_t cmp; + + /* + * Never collapse filtered and non-filtered entries. + * Note this is not the same as having an extra (invisible) fmt + * that corresponds to the filtered status. + */ + cmp =3D (int64_t)!!left->filtered - (int64_t)!!right->filtered; + if (cmp) + return cmp; =20 perf_hpp_list__for_each_sort_list(hpp_list, fmt) { if (ignore_dynamic && perf_hpp__is_dynamic_entry(fmt) && --=20 2.48.0.rc2.279.g1de40edade-goog