Received: by 10.223.176.5 with SMTP id f5csp2068783wra; Thu, 8 Feb 2018 08:00:06 -0800 (PST) X-Google-Smtp-Source: AH8x2278jFuSWAlV39Ev3Ri/YT3bNSlZPrMO2S905GqiiHcSLX4zAE8//LvykOXcLJ4iY8Y+ipO2 X-Received: by 10.99.186.84 with SMTP id l20mr852558pgu.83.1518105606368; Thu, 08 Feb 2018 08:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518105606; cv=none; d=google.com; s=arc-20160816; b=hbAxets6FeIHpzIHfz3JPUq558hOQxPmjG9gpS4pyVnfasPFBwqXqWP0UmKt7EMHan DwN04HdxmzVqxwXiuH2rlXcaObJ7dJ5U0q8X8D9D+EciVzfpTCE0bmjUNc+6MxgvGPJG jOXJ77H/YaIMG36YN8zkPpLiJMmHUpMqyHura21jeaEjLV5Dw/DvDa5bLq0WMK1wpwT/ oOevO8afAKs2mB87NunY41urZmt2KLFIE9oMCj+/mDzYdSXTDfZ0MbEwNZwMUWVlsr1b 9KKRBrFzWaLnlW8btWLk+eB8Fr+Df7iwamg0ATU/CFXUr80+suQuDGEZp1fut0AYnWhH Sa9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=Tm4Dtni+HFfcpaD1UH4VgIAsInCwFFRip4PDFQZbGrk=; b=O2MEy/3OEbtxL0RMOO0fBk5PcI+bzyJ5CR3/sF7p3kbVdzddGPXk526thLvbqdx1A0 12WlIJh3RzIK/NyQkQbsO+NtujP1c4QgFdmpC+Ye87nUj6NUsEJ/ycNFrDiQO89U6kWA ft1Om4eb06PICIlQe4ZvaLbx4/FNUpcQh1XNnRMl5gIwsn4zBgaYZDdbmMo8jsLxxX3a Y9YGSO9E1zlfdZRVlqQXm5tDgR+6fgqivrhgf3E+Kr/i88pZJMKWf7pGGo+m4krhoLQJ +jmVqweRIW46MYGh7D8FrG0ikiMXbcTlwUts+dG5NbxIP2ObVt5z1buM4eMxZXUYOUOY J+sA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si107799pgp.577.2018.02.08.07.59.50; Thu, 08 Feb 2018 08:00:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752261AbeBHP6E (ORCPT + 99 others); Thu, 8 Feb 2018 10:58:04 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:36791 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750929AbeBHP6D (ORCPT ); Thu, 8 Feb 2018 10:58:03 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0D678D9B23E2E; Thu, 8 Feb 2018 23:57:49 +0800 (CST) Received: from [127.0.0.1] (10.202.227.238) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.361.1; Thu, 8 Feb 2018 23:57:42 +0800 Subject: Re: [PATCH 5/9] perf utils: add support for arch standard events To: Jiri Olsa References: <1517939104-230881-1-git-send-email-john.garry@huawei.com> <1517939104-230881-6-git-send-email-john.garry@huawei.com> <20180208135409.GA10234@krava> CC: , , , , , , , , , , , , From: John Garry Message-ID: Date: Thu, 8 Feb 2018 15:57:35 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20180208135409.GA10234@krava> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.238] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/02/2018 13:54, Jiri Olsa wrote: > On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: > Hi Jirka, I'll try to combine some responses, below: > 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 > Ok >> + >> +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 > Right, >> + >> +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) > > please indent the code in macro like normal code This looked ok, with a single tab indent. It is same style as "EXPECT" macro. >> mapfile = NULL; >> + rc = nftw(ldirname, preprocess_arch_std_files, get_maxfds(), 0); > > you could use maxfds variable in here sure >> >> +free_standard_arch_events: >> + list_for_each_entry_safe(es1, es2, &arch_std_events, list) >> + free(es1); > > that could go into a function and be used also above fine >> free(metric_name); >> free(metric_group); >> + > > should you call free(arch_std) in here? Right, that's sloppy >> if (rc && verbose) { >> pr_info("%s: Error walking file tree %s\n", prog, ldirname); >> - goto empty_map; >> + goto free_standard_arch_events; >> } else if (rc < 0) { >> /* Make build fail */ >> return 1; >> - } else if (rc) { >> - goto empty_map; >> } > > please put this change into separate patch > > thanks, Sure, I just couldn't see how a value > 0 could be returned in the current code paths. > jirka > > . > Thanks, John