From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757686AbcCCNkb (ORCPT ); Thu, 3 Mar 2016 08:40:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53015 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751082AbcCCNka (ORCPT ); Thu, 3 Mar 2016 08:40:30 -0500 Date: Thu, 3 Mar 2016 14:40:22 +0100 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Andi Kleen , Stephane Eranian , Wang Nan Subject: Re: [PATCH 2/8] perf tools: Introduce perf_hpp__setup_hists_formats() Message-ID: <20160303134022.GA5487@krava.redhat.com> References: <1456935128-31299-1-git-send-email-namhyung@kernel.org> <1456935128-31299-3-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456935128-31299-3-git-send-email-namhyung@kernel.org> 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 On Thu, Mar 03, 2016 at 01:12:02AM +0900, Namhyung Kim wrote: SNIP > +struct perf_hpp_fmt *perf_hpp_fmt__copy(struct perf_hpp_fmt *fmt); > + > int hist_entry__filter(struct hist_entry *he, int type, const void *arg); > > static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format, > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c > index 590ebf70e6da..29c75f0374c4 100644 > --- a/tools/perf/util/sort.c > +++ b/tools/perf/util/sort.c > @@ -1908,6 +1908,31 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field, > return hde; > } > > +struct perf_hpp_fmt *perf_hpp_fmt__copy(struct perf_hpp_fmt *fmt) perf_hpp_fmt__dup might be better > +{ > + struct perf_hpp_fmt *new_fmt = NULL; > + > + if (perf_hpp__is_sort_entry(fmt)) { > + struct hpp_sort_entry *hse, *new_hse; > + > + hse = container_of(fmt, struct hpp_sort_entry, hpp); > + new_hse = memdup(hse, sizeof(*hse)); > + if (new_hse) > + new_fmt = &new_hse->hpp; > + } else if (perf_hpp__is_dynamic_entry(fmt)) { > + struct hpp_dynamic_entry *hde, *new_hde; > + > + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); > + new_hde = memdup(hde, sizeof(*hde)); > + if (new_hde) > + new_fmt = &new_hde->hpp; > + } else { > + new_fmt = memdup(fmt, sizeof(*fmt)); > + } how about also initialize new_fmt's list and sort_list in here could save some time in future if perf_hpp_fmt__copy is used in another place, which won't directly initialize them like you do in add_hierarchy_fmt jirka