Received: by 10.223.176.5 with SMTP id f5csp1929697wra; Thu, 8 Feb 2018 05:56:36 -0800 (PST) X-Google-Smtp-Source: AH8x225q+aKQMy1hngYvZO1CteTPbUF6wH22Kz8HNdJUsZlcgnCNzzye+xCCd5UYMTIa9gq7zP9r X-Received: by 2002:a17:902:8e83:: with SMTP id bg3-v6mr750099plb.246.1518098196673; Thu, 08 Feb 2018 05:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518098196; cv=none; d=google.com; s=arc-20160816; b=uojWdv6DEh5OeNPLy8SGojmr92LAr6E+T9RdWX3QttjyXBsBvG05s76TxcdB+P9H77 Tn7wkRyNwYIH/msoRGmhuftLv4tDsRjTccVj7WY2yIwVRhXzWlBwPFdFcSbzO77s32oN VcGYijL1scVDIkFdVgFXd++BCPcILKmwYIp3A3OHCklWHPb5RvWNgcEIcYuUTMWjNOhq D1ghZQ7ebp+HgJS+ze9f/jvS28phvhv2wKRP1mGnWaXNeKlgiTOFz1yv4ausK7WU9iww eCZElezjrSycVPJ0j4wqdKlCQC3byVkF1vaHS6nYii32jkG/SVcWOp6RbJ/c4si71Zn9 kxPg== 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=YDCtAr4MOi7EVLNl6DVne93jgTP+RY15pxuJ0hBmxFU=; b=I+dovG3//JaYkYK/CDvFr50KjdxKxWGMurdClUzPj5vGqAyZNQKc/kymgj2HmVWBXd nEyZqq4CX5VVxWoe5fEA3q6M02U6wGpAxbPU6z8ie76H9T9rme8+Y4msMlKLWVW2reIK cownaUMGA2eTBoN3a+bzH0jQcb6mk7EL5zPkdFr+3WMfPCbtRkhZdpQCBa1IKhGPquHE lNOVOyKGrsdQzVYMiD9ZrOhOLISFL3TwG9C/7QArMIFilLbXwA6G7O5lq3tfUtdPElSe RZ86yYIGdHzNLhIGsuE+btxiX5ZbLpoFdYXNh3lArau28uyHXz2rniZsSSqUmyKfwDFX mYgA== 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 m10si145pgn.120.2018.02.08.05.56.22; Thu, 08 Feb 2018 05:56:36 -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 S1752478AbeBHNzR (ORCPT + 99 others); Thu, 8 Feb 2018 08:55:17 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35264 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752448AbeBHNzP (ORCPT ); Thu, 8 Feb 2018 08:55:15 -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 1F914EAEBE; Thu, 8 Feb 2018 13:55:15 +0000 (UTC) Received: from krava (unknown [10.43.17.63]) by smtp.corp.redhat.com (Postfix) with SMTP id 3D9172026E04; Thu, 8 Feb 2018 13:55:13 +0000 (UTC) Date: Thu, 8 Feb 2018 14:55:12 +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: <20180208135512.GG10234@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.1]); Thu, 08 Feb 2018 13:55:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 13:55:15 +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 > + char *perpkg; > + char *unit; > + char *metric_expr; > + char *metric_name; > + char *metric_group; > + struct list_head list; > + char strings[]; > +}; > + > +static LIST_HEAD(arch_std_events); > + > +#define ADD_EVENT_STRING(string) do { if (string) { \ > + es->string = strings; \ > + strings += snprintf(strings, len, "%s", string) + 1; \ > +} } while (0) > + > +static int save_arch_std_events(void *data, char *name, char *event, > + char *desc, char *long_desc, char *pmu, > + char *unit, char *perpkg, char *metric_expr, > + char *metric_name, char *metric_group) > +{ > + struct event_struct *es; > + struct stat *sb = data; > + int len; > + char *strings; > + > + /* > + * Lazily allocate size of the json file to hold the > + * strings, which would be more than large enough. > + */ > + len = sb->st_size; > + > + es = malloc(sizeof(*es) + len); hum, so for single event you allocate buffer of the size of the entire file this event is defined in? what do I miss? I assume there're more of those arch-defined events defined in the single file.. jirka