Received: by 10.223.176.5 with SMTP id f5csp1928664wra; Thu, 8 Feb 2018 05:55:26 -0800 (PST) X-Google-Smtp-Source: AH8x224w4rPRRRiEML99NtuXYQlRMldiiAFtfAETrgPwXEOiGbQ4cFj0Vd3CCtKRXnr5rpCCDZAE X-Received: by 2002:a17:902:5517:: with SMTP id f23-v6mr699427pli.163.1518098125919; Thu, 08 Feb 2018 05:55:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518098125; cv=none; d=google.com; s=arc-20160816; b=kc5crU7W/QAS+DCb2KDBqdhQIiaqN1/rSNzEq+aDczrWlGw5qDbYt4It/8EGiQ5tjn qhpcOL4f1+HSIsf8i0PPDelyhyeIIjgvuiiW8Cdk7CJdCO6pj3IaEkLEp9uRw/bnSvwz +ePHfLKA/85CAGaaP6IRuEfscJNVgnGcHfSwX2AftGRPt88TKEZP2uuYP1urNSRYdb7s izS24F8yZNEQHG3JBs7YRcXSLiA9Y24A/E5RhM2ZCKiGoWWNTqijB+qs+tFNp06rw8lx V9AanIJlopLLOXM95WW5TfhaiqBvRwfvCDm9L+1TE8Au0BTiFIkPeXEqMBWEVga16jln kmsg== 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=y0NbF+5jBIgLhtQfrxcsDITz1LeJF4ca8yrqM1ghYkc=; b=KrDjAHCmG3IrKYnwbak6/vIjDT4dsKeaeHMhCmddx0ZRY0j2YW3gc5n2lBe6a5+r26 L09QYohUWmwBLVHn9qd2MmCRtqceWoEg62wzjlOfUqWQnttjq2IPTw1pSyAsWfr9VWdd gT3HtFJaBFp07d4k2gUB3toqZfQiDA9xbBN/OANyzsygGP8IWmMeX4E6NipL2ayExnBF aUWfDZLc8MNZkC+2i1xjGa3gLM5nVJAdmAfovxe+bl/IRowlx2SyOxCRR+TphN4cMtTS 32xc5/Msy5qhC+I4CklNUN47p2tRERReJTZ4nMK+6cZXHzQ1QRYJLoxY5hdtTeKJqolK PIhQ== 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 b30si1953976pge.738.2018.02.08.05.55.12; Thu, 08 Feb 2018 05:55:25 -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 S1752103AbeBHNyO (ORCPT + 99 others); Thu, 8 Feb 2018 08:54:14 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55858 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752013AbeBHNyN (ORCPT ); Thu, 8 Feb 2018 08:54:13 -0500 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 BA7427D679; Thu, 8 Feb 2018 13:54:12 +0000 (UTC) Received: from krava (unknown [10.43.17.63]) by smtp.corp.redhat.com (Postfix) with SMTP id 96A922024CA2; Thu, 8 Feb 2018 13:54:09 +0000 (UTC) Date: Thu, 8 Feb 2018 14:54:09 +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: <20180208135409.GA10234@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.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.2]); Thu, 08 Feb 2018 13:54:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 08 Feb 2018 13:54:12 +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 Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > +static void fixup_field(char *from, char **to) > +{ > + *to = malloc(strlen(from)); > + > + strcpy(*to, from); > +} > + > +#define EVENT_PREFIX "event=" > + > +#define TRY_FIXUP_FIELD(string) do { if (es->string && !*string)\ > + fixup_field(es->string, string); \ > +} while (0) please indent the code in the macro like normal code > + > +static int > +try_fixup(const char *fn, char *arch_std, char **event, char **desc, > + char **name, char **long_desc, char **pmu, char **filter, > + char **perpkg, char **unit, char **metric_expr, char **metric_name, > + char **metric_group) > +{ > + /* try to find matching event from arch standard values */ > + struct event_struct *es; > + > + list_for_each_entry(es, &arch_std_events, list) { > + if (!strcmp(arch_std, es->event+strlen(EVENT_PREFIX))) { you could use just sizeof(EVENT_PREFIX). no need to call strlen jirka