From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752387AbcAFX1s (ORCPT ); Wed, 6 Jan 2016 18:27:48 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:57365 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752145AbcAFX1r (ORCPT ); Wed, 6 Jan 2016 18:27:47 -0500 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.76 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Thu, 7 Jan 2016 08:26:45 +0900 From: Namhyung Kim To: Arnaldo Carvalho de Melo CC: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Steven Rostedt , Frederic Weisbecker , Andi Kleen , Wang Nan Subject: Re: [PATCH v3 3/5] perf tools: Fix dynamic sort keys to sort properly Message-ID: <20160106232645.GC8053@sejong> References: <1452041701-27689-1-git-send-email-namhyung@kernel.org> <1452041701-27689-3-git-send-email-namhyung@kernel.org> <20160106230643.GB2012@kernel.org> MIME-Version: 1.0 In-Reply-To: <20160106230643.GB2012@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/01/07 08:26:44, Serialize by Router on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/01/07 08:26:44, Serialize complete at 2016/01/07 08:26:44 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 06, 2016 at 08:06:43PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Jan 06, 2016 at 09:54:59AM +0900, Namhyung Kim escreveu: > > Currently, the dynamic sort keys compares trace data using memcmp(). > > But for output sorting, it should check data size and compare by word. > > Also it sorted strings in reverse order, fix it. > > Can this be broken down in two patches? This is complex code, lets try > to make it as bisectable as possible. OK, I'll break out the string part then. But I think it doesn't help much to reduce the complexity. Thanks, Namhyung > > - Arnaldo > > > > > Before) > > > > $ perf report -F overhead -s prev_pid,next_pid > > ... > > # Overhead prev_pid next_pid > > # ........ .......... .......... > > # > > 0.39% 490 0 > > 9.12% 225 0 > > 0.04% 224 0 > > 0.51% 731 189 > > 0.08% 731 3 > > 0.12% 731 0 > > 4.82% 729 0 > > 0.08% 1229 0 > > 0.20% 715 0 > > 4.78% 189 225 > > ... > > > > After) > > > > $ perf report -F overhead -s prev_pid,next_pid > > ... > > # Overhead prev_pid next_pid > > # ........ .......... .......... > > # > > 0.43% 0 7 > > 0.04% 0 11 > > 0.04% 0 12 > > 0.08% 0 14 > > 0.04% 0 17 > > 0.08% 0 19 > > 0.04% 0 22 > > 0.04% 0 27 > > 0.04% 0 37 > > 0.04% 0 42 > > ... > > > > Reported-by: Arnaldo Carvalho de Melo > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/util/sort.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 46 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c > > index 9618a64875c0..264d2b630549 100644 > > --- a/tools/perf/util/sort.c > > +++ b/tools/perf/util/sort.c > > @@ -1798,6 +1798,51 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, > > return memcmp(a->raw_data + offset, b->raw_data + offset, size); > > } > > > > +static int64_t __sort__hde_sort(struct perf_hpp_fmt *fmt, > > + struct hist_entry *a, struct hist_entry *b) > > +{ > > + struct hpp_dynamic_entry *hde; > > + struct format_field *field; > > + unsigned offset, size; > > + int64_t *a64, *b64; > > + int32_t *a32, *b32; > > + int16_t *a16, *b16; > > + > > + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); > > + > > + field = hde->field; > > + if (field->flags & FIELD_IS_DYNAMIC) { > > + unsigned long long dyn; > > + > > + pevent_read_number_field(field, a->raw_data, &dyn); > > + offset = dyn & 0xffff; > > + size = (dyn >> 16) & 0xffff; > > + } else { > > + offset = field->offset; > > + size = field->size; > > + } > > + > > + if (field->flags & FIELD_IS_STRING) > > + return strcmp(b->raw_data + offset, a->raw_data + offset); > > + > > + switch (size) { > > + case 8: > > + a64 = a->raw_data + offset; > > + b64 = b->raw_data + offset; > > + return *b64 - *a64; > > + case 4: > > + a32 = a->raw_data + offset; > > + b32 = b->raw_data + offset; > > + return *b32 - *a32; > > + case 2: > > + a16 = a->raw_data + offset; > > + b16 = b->raw_data + offset; > > + return *b16 - *a16; > > + default: > > + return memcmp(b->raw_data + offset, a->raw_data + offset, size); > > + } > > +} > > + > > bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *fmt) > > { > > return fmt->cmp == __sort__hde_cmp; > > @@ -1826,7 +1871,7 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field) > > > > hde->hpp.cmp = __sort__hde_cmp; > > hde->hpp.collapse = __sort__hde_cmp; > > - hde->hpp.sort = __sort__hde_cmp; > > + hde->hpp.sort = __sort__hde_sort; > > > > INIT_LIST_HEAD(&hde->hpp.list); > > INIT_LIST_HEAD(&hde->hpp.sort_list); > > -- > > 2.6.4