From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751408AbbLUIgz (ORCPT ); Mon, 21 Dec 2015 03:36:55 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33080 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbbLUIgx (ORCPT ); Mon, 21 Dec 2015 03:36:53 -0500 Date: Mon, 21 Dec 2015 17:36:07 +0900 From: Namhyung Kim To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , David Ahern , Steven Rostedt , Frederic Weisbecker , Andi Kleen , Wang Nan Subject: Re: [PATCH 06/10] perf tools: Try to show pretty printed output for dynamic sort keys Message-ID: <20151221083607.GA22464@danjae.kornet> References: <1450193743-4409-1-git-send-email-namhyung@kernel.org> <1450193743-4409-7-git-send-email-namhyung@kernel.org> <20151220141245.GB17267@krava.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151220141245.GB17267@krava.local> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On Sun, Dec 20, 2015 at 03:12:45PM +0100, Jiri Olsa wrote: > On Wed, Dec 16, 2015 at 12:35:39AM +0900, Namhyung Kim wrote: > > SNIP > > > struct trace_seq seq; > > + char *str, *pos; > > + struct format_field *field; > > + struct pevent_record rec = { > > + .cpu = he->cpu, > > + .data = he->raw_data, > > + .size = he->raw_size, > > + }; > > + size_t namelen; > > int ret; > > > > hde = container_of(fmt, struct hpp_dynamic_entry, hpp); > > @@ -1605,9 +1654,28 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, > > if (hists_to_evsel(he->hists) != hde->evsel) > > return scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, "N/A"); > > > > + field = hde->field; > > trace_seq_init(&seq); > > - print_event_field(&seq, he->raw_data, hde->field); > > - ret = scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, seq.buffer); > > + pevent_event_info(&seq, field->event, &rec); > > hm, maybe we could cache the seq.buffer data in hist_entry? > > IIRC pevent_event_info code does a lot of stuff, so > it might be better to call it just once.. caching > its results in hist_entry seems like small price Right. I did the same thing for 'trace' sort key, so will move it to here. Thanks, Namhyung > > > + > > + namelen = strlen(field->name); > > + str = strtok_r(seq.buffer, " ", &pos); > > + while (str) { > > + if (!strncmp(str, field->name, namelen)) { > > + str += namelen + 1; > > + break; > > + } > > + > > + str = strtok_r(NULL, " ", &pos); > > + } > > + > > SNIP >