From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbdFANCc (ORCPT ); Thu, 1 Jun 2017 09:02:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbdFANCb (ORCPT ); Thu, 1 Jun 2017 09:02:31 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CE9E239DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org Date: Thu, 1 Jun 2017 10:02:26 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Ingo Molnar , Peter Zijlstra , Namhyung Kim , David Ahern , "Du, Changbin" Subject: Re: [PATCH 2/2] perf tools: Remove extra list_del_init calls in list reset Message-ID: <20170601130226.GA2899@kernel.org> References: <20170601111744.15580-1-jolsa@kernel.org> <20170601111744.15580-2-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170601111744.15580-2-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jun 01, 2017 at 01:17:44PM +0200, Jiri Olsa escreveu: > We only needs to remove the format from the currently > iterated list. The other removals/inits are superfluous > because we free the format in any case. > > Link: http://lkml.kernel.org/n/tip-8umo89ntt3kawmfwsivav43t@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/perf/ui/hist.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c > index feb2174ddd1f..a0fee2ac8599 100644 > --- a/tools/perf/ui/hist.c > +++ b/tools/perf/ui/hist.c > @@ -614,15 +614,15 @@ void perf_hpp__reset_output_field(struct perf_hpp_list *list) > > /* reset output fields */ > perf_hpp_list__for_each_format_safe(list, fmt, tmp) { > - list_del_init(&fmt->list); > - list_del_init(&fmt->sort_list); > + list_del(&fmt->list); > + /* Remove the fmt from next loop processing. */ > + list_del(&fmt->sort_list); Why not just add the comment and leave it as list_del_init(), then, in fmt_free() -> fmt->free() -> hse_free() (for instance), have: BUG_ON(!list_empty(&fmt->list)); BUG_ON(!list_empty(&fmt->sort_list)); The patch would be smaller and overall the code would be more robust? > fmt_free(fmt); > } > > /* reset sort keys */ > perf_hpp_list__for_each_sort_list_safe(list, fmt, tmp) { > - list_del_init(&fmt->list); > - list_del_init(&fmt->sort_list); > + list_del(&fmt->sort_list); Ditto, just ditch what you said you would do in the cset comment, i.e. ditch the extra "list_del_init(&fmt->list);" call, no? - Arnaldo > fmt_free(fmt); > } > } > -- > 2.9.4