Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp507172imm; Fri, 15 Jun 2018 01:22:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKITx4Kkhq5XFmIkatuZRPx+F7TniePZ2bJAVxEsOgO7K/2ia9qMcZz6hlHT9j3IezFWu6aM X-Received: by 2002:a17:902:9a06:: with SMTP id v6-v6mr867270plp.21.1529050923827; Fri, 15 Jun 2018 01:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529050923; cv=none; d=google.com; s=arc-20160816; b=oOk7i+GwLnk5FWvR7hSAWFWo5SBacUvdP6Is6K/OJhaf4Cv7KX1a8OiJEpbU0zOfrJ mXtxduYDVdaKSrsd2SQn8jq7kbGvEaAinydCrQ6RJKWU2zM9H/fnWNAg9CyFL7MHdDxL 7SRAQxmMCDkw1Qy3fUAt9b+hGywYDC12a3O1mA+FIdbLQRu6v9iqI/av5KuFt1hZno8J OZkRWWRp3nh+LA0TgVRPbZBGMTjocJtdy4rpMmhvKxzmX6xF7BxHUjzC7o5vYKarcg9Q 751JIEOMPZc3Lo4FgXLq4d89K+KkHs3YZthOLum6TctZ3A7OQT2JcZUh5O9ospgRSMLJ nJuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=twHe8/vYeuJqnTDYCBkobzF0/oRC0aup/NiiYUj3MSo=; b=rcnnd/wmqSX9TUm8H4YhoVUEpoTOrq+NYgeJ9+OIUrY+skv3kdeGWHAQ2Xwz6uJmxh cvCtQVq5cg5hC5/6V6ETHcSrYLuSspncfdPyQVYsnz+3Oo6sBQlVSKejm/mBeI7VeeFt 1BP0fsZXYatOUjSzgALO0jQb64u+rQ8w7CIk+kPrVHOvdW2Fa33hWoMoI6VzEnnVEW+L uTmsLcofyWm3Wg4tVl/jDIKxZDLtA1W9O2mc9kaqEp7buJz6508zncObiLemYHA4OFUK 6as2RaGfKLrT1ich6TG7hh/PDwa+26S1WelqsNcvCw5/q2d/tCoy2DvU34jjwIQ7o6S9 NQFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10-v6si5895199pgc.261.2018.06.15.01.21.48; Fri, 15 Jun 2018 01:22:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755994AbeFOIV2 (ORCPT + 99 others); Fri, 15 Jun 2018 04:21:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58406 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755755AbeFOIV1 (ORCPT ); Fri, 15 Jun 2018 04:21:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A7EC87A81; Fri, 15 Jun 2018 08:21:26 +0000 (UTC) Received: from krava (unknown [10.43.17.64]) by smtp.corp.redhat.com (Postfix) with SMTP id 6E0B02023580; Fri, 15 Jun 2018 08:21:25 +0000 (UTC) Date: Fri, 15 Jun 2018 10:21:24 +0200 From: Jiri Olsa To: Thomas Richter Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Subject: Re: [PATCH 3/3] perf stat: Remove duplicate event counting Message-ID: <20180615082124.GG5082@krava> References: <20180614114845.41221-1-tmricht@linux.ibm.com> <20180614114845.41221-3-tmricht@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180614114845.41221-3-tmricht@linux.ibm.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 15 Jun 2018 08:21:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 15 Jun 2018 08:21:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 14, 2018 at 01:48:45PM +0200, Thomas Richter wrote: SNIP > +static void perf_pmu_assign_str(char *name, const char *field, char **old_str, > + char **new_str) > +{ > + if (!*old_str) > + goto set_new; > + > + if (*new_str) { /* Have new string, check with old */ > + if (strcasecmp(*old_str, *new_str)) > + pr_debug("alias %s differs in field '%s'\n", > + name, field); > + zfree(old_str); > + } else /* Nothing new --> keep old string */ > + return; > +set_new: > + *old_str = *new_str; > + *new_str = NULL; > +} > + > +static void perf_pmu_update_alias(struct perf_pmu_alias *old, > + struct perf_pmu_alias *newalias) > +{ > + perf_pmu_assign_str(old->name, "desc", &old->desc, &newalias->desc); > + perf_pmu_assign_str(old->name, "long_desc", &old->long_desc, > + &newalias->long_desc); > + perf_pmu_assign_str(old->name, "topic", &old->topic, &newalias->topic); > + perf_pmu_assign_str(old->name, "metric_expr", &old->metric_expr, > + &newalias->metric_expr); > + perf_pmu_assign_str(old->name, "metric_name", &old->metric_name, > + &newalias->metric_name); > + perf_pmu_assign_str(old->name, "value", &old->str, &newalias->str); > + old->scale = newalias->scale; > + old->per_pkg = newalias->per_pkg; > + old->snapshot = newalias->snapshot; > + memcpy(old->unit, newalias->unit, sizeof(old->unit)); > +} > + > +/* Delete an alias entry. */ > +static void perf_pmu_free_alias(struct perf_pmu_alias *newalias) > +{ > + zfree(&newalias->name); > + zfree(&newalias->desc); > + zfree(&newalias->long_desc); > + zfree(&newalias->topic); > + zfree(&newalias->str); > + zfree(&newalias->metric_expr); > + zfree(&newalias->metric_name); > + parse_events_terms__purge(&newalias->terms); > + free(newalias); > +} > + > +/* Merge an alias, search in alias list. If this name is already > + * present merge both of them to combine all information. > + */ > +static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias, > + struct list_head *alist) > +{ > + struct perf_pmu_alias *a; > + > + list_for_each_entry(a, alist, list) { > + if (!strcasecmp(newalias->name, a->name)) { > + perf_pmu_update_alias(a, newalias); > + perf_pmu_free_alias(newalias); > + return true; > + } > + } > + return false; > +} ok, I like your change better.. we can rebuilt it to use rb tree later when we have this fixed thanks, jirka