Received: by 10.223.176.5 with SMTP id f5csp1930428wra; Thu, 8 Feb 2018 05:57:26 -0800 (PST) X-Google-Smtp-Source: AH8x225IWTkMK7nMFIn9h2DKAk/sP3ZnJkO5w7FWLL6h+G9QyswhPZ7R/KmqQi5dABYimzDJ2O+2 X-Received: by 10.99.60.86 with SMTP id i22mr572033pgn.399.1518098246553; Thu, 08 Feb 2018 05:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518098246; cv=none; d=google.com; s=arc-20160816; b=vPu+zek3zOIAhbqJPNApJj4ebytaEeFHyfaNmMYP88/DLnolj21wpZarEdeSlWvzTk PVra4pbT/TSErLZAcjIyUqsRKJ4JZuVCPIVQBZzQwhbLfjy0bhfP+71vaSLnOsxAK3Jh Cy+Dni1Cdk4UKfmfh3qkovKPU2H+cux1BTwOOFZXofU2zLhlbA/E4dI3ozSY2If2gkbb NoyE8k7lYOOtoI61iyUqBmGelHT9/lTCt+jehuioPiEt5hcb20fZPPOA+Umcjokp6JmX 9FkgRphw5cNiVZeVY8+fZVByCzCovVk6CMCnDkMNs2di4LgBUZP/Zc7e1/pirl/TIyxr h/Gw== 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=UllqQ+0IvdBs2hkZ8W/0RoeEkzcXzgErWjhXXHfPujk=; b=IVhkJrlmhPLS7uPOb2fcqGV4DT5njWBYYE2AqfJJnSY8noZj1HbnIMROk1sZl1i+R5 6r9uVhTggebuQsdjyTJuyQRe5rtaB3LGCjYQap5OK1+HrPH+cU48X3w6f6g3whzVHqkg pYCOA6x+OjpcHfM4TLI40zP232cIoWCpLneAjL1m9yxpntR3m5PuFyUbRhmXqznvYOfi g54dc2Dsgua4q7b0bl/4pOtABOKLOfiMk9GSlF8x5qLQEF1F5eVv1xUwSwLmKHBG1ybq vTHED81CBY3MK0mwZP6YNbF3Z1X0GTtq47DVTGkpu9lZTbSVEVJcEV5Fu8fkhidnNTKC BLMQ== 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 z131si1254829pgz.803.2018.02.08.05.57.12; Thu, 08 Feb 2018 05:57:26 -0800 (PST) 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 S1752440AbeBHNzE (ORCPT + 99 others); Thu, 8 Feb 2018 08:55:04 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54262 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752410AbeBHNzC (ORCPT ); Thu, 8 Feb 2018 08:55:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10BE38190298; Thu, 8 Feb 2018 13:55:02 +0000 (UTC) Received: from krava (unknown [10.43.17.63]) by smtp.corp.redhat.com (Postfix) with SMTP id 2239BB07B5; Thu, 8 Feb 2018 13:55:00 +0000 (UTC) Date: Thu, 8 Feb 2018 14:54:59 +0100 From: Jiri Olsa To: John Garry Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, namhyung@kernel.org, ak@linux.intel.com, wcohen@redhat.com, will.deacon@arm.com, ganapatrao.kulkarni@cavium.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, zhangshaokun@hisilicon.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 5/9] perf utils: add support for arch standard events Message-ID: <20180208135459.GF10234@krava> References: <1517939104-230881-1-git-send-email-john.garry@huawei.com> <1517939104-230881-6-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1517939104-230881-6-git-send-email-john.garry@huawei.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 13:55:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 13:55:02 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > /* Call func with each event in the json file */ > int json_events(const char *fn, > int (*func)(void *data, char *name, char *event, char *desc, > @@ -442,6 +550,7 @@ int json_events(const char *fn, > char *metric_expr = NULL; > char *metric_name = NULL; > char *metric_group = NULL; > + char *arch_std = NULL; > unsigned long long eventcode = 0; > struct msrmap *msr = NULL; > jsmntok_t *msrval = NULL; > @@ -527,6 +636,10 @@ int json_events(const char *fn, > addfield(map, &metric_expr, "", "", val); > for (s = metric_expr; *s; s++) > *s = tolower(*s); > + } else if (json_streq(map, field, "ArchStdEvent")) { > + addfield(map, &arch_std, "", "", val); > + for (s = arch_std; *s; s++) > + *s = tolower(*s); > } > /* ignore unknown fields */ > } > @@ -538,7 +651,7 @@ int json_events(const char *fn, > addfield(map, &extra_desc, " ", > "(Precise event)", NULL); > } > - snprintf(buf, sizeof buf, "event=%#llx", eventcode); > + snprintf(buf, sizeof(buf), "%s%#llx", EVENT_PREFIX, eventcode); > addfield(map, &event, ",", buf, NULL); > if (desc && extra_desc) > addfield(map, &desc, " ", extra_desc, NULL); > @@ -550,9 +663,21 @@ int json_events(const char *fn, > addfield(map, &event, ",", msr->pname, msrval); > if (name) > fixname(name); > - > - err = func(data, name, real_event(name, event), desc, long_desc, > - pmu, unit, perpkg, metric_expr, metric_name, metric_group); > + err = 0; > + if (arch_std) { > + /* > + * An arch standard event is referenced, so try to > + * fixup any unassigned values. > + */ > + err = try_fixup(fn, arch_std, &event, &desc, &name, > + &long_desc, &pmu, &filter, &perpkg, > + &unit, &metric_expr, &metric_name, > + &metric_group); > + } > + if (!err) > + err = func(data, name, real_event(name, event), desc, > + long_desc, pmu, unit, perpkg, metric_expr, > + metric_name, metric_group); > free(event); > free(desc); > free(name); > @@ -565,6 +690,7 @@ int json_events(const char *fn, > free(metric_expr); > free(metric_name); > free(metric_group); > + should you call free(arch_std) in here? jirka