Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp534235imm; Fri, 15 Jun 2018 01:57:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ68uiW0hf+PvgUylTBjUipQlzxnHiC+ijkC8/0KMrz3xdTuGQAPut/gW0BKrFjPgQEJyAa X-Received: by 2002:a62:a6dd:: with SMTP id r90-v6mr944803pfl.60.1529053027280; Fri, 15 Jun 2018 01:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529053027; cv=none; d=google.com; s=arc-20160816; b=ZysfP1vLZSLwGJwgYx4wRyjc7Dw6Guk8szZWNJQEDFhCRJtv75z6TIgsnMZlAIkjYv I0ae9FkkBkEL+0bnsPIbWrDJs1FhEs1KoLqVLa17+6rb/MckFHaOp22S1x5gtOFBwcvA BBNcoACicUK2TEyEDiMPOXkeW5W44Ywb3hCv+93aCSsZU4sw0O+Or/cweBcJPXyaAyva fFJxQlCx+0TA2m3MW5Uie/P9PN/2TjvyiANkYYraTHWsceWNUaDsgs5EApIoUQRm6Yuy 7yzcBx8/UYsxuWLIGPWrtx/rhQb87klrrH1mRd6LbWZUZtWwkpooxB9bAHgyAYOuULu8 p8eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :organization:from:references:cc:to:subject :arc-authentication-results; bh=Eij2ax+uyb0SZRAqm1XXDQJVv6NTgD+aJfM7cLeSFtA=; b=GzwrhRycwONBGnaY3XIzUT9Khf9KiHY0NWry4cnoef8S5klz2iOterwxmJVskpoF+6 hHXkI5bSxo6vvs6NXhDZFL2Tlnif1W3ho5pFhdMqBksJcWAL7GGNaixGIb5dwh/JOVFQ a8Gw1DXyNnA2Zi/FQ4qGgkBWeuPV3NWuA08RTrqr/93NL5dKOe+pXClriI2XI5hBBeQv uGlhWgHZOM78XjwuWi8y0zwNqPGavfcu0kfiHq1i5L85On9e2WdeoQSmxyCFjFCdfuHC qvfCpBrlw+/xUZH23y+LD6Q0kWQ9msOCVgen5iJ6vj/RcplYl7cFFi1SDIp+uBdvS48w 34CA== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si7533646plb.30.2018.06.15.01.56.51; Fri, 15 Jun 2018 01:57:07 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965553AbeFOI4Y (ORCPT + 99 others); Fri, 15 Jun 2018 04:56:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52488 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936183AbeFOI4X (ORCPT ); Fri, 15 Jun 2018 04:56:23 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5F8roiw113878 for ; Fri, 15 Jun 2018 04:56:23 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jm7qa6fq7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 15 Jun 2018 04:56:23 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Jun 2018 09:56:20 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Jun 2018 09:56:18 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5F8uHC834144390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 15 Jun 2018 08:56:17 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAB1CA4055; Fri, 15 Jun 2018 09:47:05 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C927A4059; Fri, 15 Jun 2018 09:47:05 +0100 (BST) Received: from oc3784624756.ibm.com (unknown [9.152.212.222]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 15 Jun 2018 09:47:05 +0100 (BST) Subject: Re: [PATCH 3/3] perf stat: Remove duplicate event counting To: Jiri Olsa 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 References: <20180614114845.41221-1-tmricht@linux.ibm.com> <20180614114845.41221-3-tmricht@linux.ibm.com> <20180615082124.GG5082@krava> From: Thomas-Mich Richter Organization: IBM LTC Date: Fri, 15 Jun 2018 10:56:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180615082124.GG5082@krava> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18061508-0012-0000-0000-0000027FB1D0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061508-0013-0000-0000-000020B0D885 Message-Id: <351a9e7d-5cca-57ae-8e87-4a792bde5ecd@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-15_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806150096 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/15/2018 10:21 AM, Jiri Olsa wrote: > 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 > Thanks for the review. I will resend the patch set later today when I have added Arnaldo's comments. After that we add your rb tree stuff. -- Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294