From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932783AbcCINtG (ORCPT ); Wed, 9 Mar 2016 08:49:06 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33854 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932664AbcCINsc (ORCPT ); Wed, 9 Mar 2016 08:48:32 -0500 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Andi Kleen , Stephane Eranian , Wang Nan Subject: [PATCH v2 1/7] perf tools: Fix hist_entry__filter() for hierarchy Date: Wed, 9 Mar 2016 22:46:56 +0900 Message-Id: <1457531222-18130-2-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1457531222-18130-1-git-send-email-namhyung@kernel.org> References: <1457531222-18130-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When hierarchy mode is enabled each output format is in a separate hpp list. So when applying filter it should check all formats in the list. Currently it only checks a single ->fmt field which was not set properly. Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 041f236379e0..c3c823377d39 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1602,16 +1602,30 @@ int hist_entry__filter(struct hist_entry *he, int type, const void *arg) { struct perf_hpp_fmt *fmt; struct hpp_sort_entry *hse; + int ret = -1; + int r; - fmt = he->fmt; - if (fmt == NULL || !perf_hpp__is_sort_entry(fmt)) - return -1; + perf_hpp_list__for_each_format(he->hpp_list, fmt) { + if (!perf_hpp__is_sort_entry(fmt)) + continue; - hse = container_of(fmt, struct hpp_sort_entry, hpp); - if (hse->se->se_filter == NULL) - return -1; + hse = container_of(fmt, struct hpp_sort_entry, hpp); + if (hse->se->se_filter == NULL) + continue; - return hse->se->se_filter(he, type, arg); + /* + * hist entry is filtered if any of sort key in the hpp list + * is applied. But it should skip non-matched filter types. + */ + r = hse->se->se_filter(he, type, arg); + if (r >= 0) { + if (ret < 0) + ret = 0; + ret |= r; + } + } + + return ret; } static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd, int level) -- 2.7.2