From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752892AbdLFOsk (ORCPT ); Wed, 6 Dec 2017 09:48:40 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2216 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752134AbdLFOma (ORCPT ); Wed, 6 Dec 2017 09:42:30 -0500 Subject: Re: [RFC PATCH 1/5] perf jevents: add support for pmu events vendor subdirectory To: Jiri Olsa References: <1512490399-94107-1-git-send-email-john.garry@huawei.com> <1512490399-94107-2-git-send-email-john.garry@huawei.com> <20171206133829.GC12508@krava> CC: , , , , , , , , , , , , , , , From: John Garry Message-ID: <5aaa3863-f90e-cd0e-37ee-58a8f17f6e63@huawei.com> Date: Wed, 6 Dec 2017 14:41:57 +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: <20171206133829.GC12508@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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/12/2017 13:38, Jiri Olsa wrote: > On Wed, Dec 06, 2017 at 12:13:15AM +0800, John Garry wrote: > > SNIP > >> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c >> index b578aa2..a0d489e 100644 >> --- a/tools/perf/pmu-events/jevents.c >> +++ b/tools/perf/pmu-events/jevents.c >> @@ -588,7 +588,7 @@ static char *file_name_to_table_name(char *fname) >> * Derive rest of table name from basename of the JSON file, >> * replacing hyphens and stripping out .json suffix. >> */ >> - n = asprintf(&tblname, "pme_%s", basename(fname)); >> + n = asprintf(&tblname, "pme_%s", fname); >> if (n < 0) { >> pr_info("%s: asprintf() error %s for file %s\n", prog, >> strerror(errno), fname); >> @@ -598,7 +598,7 @@ static char *file_name_to_table_name(char *fname) >> for (i = 0; i < strlen(tblname); i++) { >> c = tblname[i]; >> >> - if (c == '-') >> + if (c == '-' || c == '/') >> tblname[i] = '_'; >> else if (c == '.') { >> tblname[i] = '\0'; >> @@ -755,15 +755,52 @@ static int get_maxfds(void) >> static FILE *eventsfp; >> static char *mapfile; >> >> +static int isLeafDir(const char *fpath) > > we use _ to separate words in functions names > Ok (I will also check functions added elsewhere) >> +{ >> + DIR *d; >> + struct dirent *dir; >> + int res = 1; >> + d = opendir(fpath); >> + if (!d) >> + return 0; >> + >> + while ((dir = readdir(d)) != NULL) { >> + if (dir-> d_type == DT_DIR && dir->d_name[0] != '.') { >> + res = 0; >> + break; > > just recently got into a issue on xfs when d_type is DT_UNKNOWN > for directory.. you need to handle it > Sure Cheers, John > thanks, > jirka > > . > From mboxrd@z Thu Jan 1 00:00:00 1970 From: john.garry@huawei.com (John Garry) Date: Wed, 6 Dec 2017 14:41:57 +0000 Subject: [RFC PATCH 1/5] perf jevents: add support for pmu events vendor subdirectory In-Reply-To: <20171206133829.GC12508@krava> References: <1512490399-94107-1-git-send-email-john.garry@huawei.com> <1512490399-94107-2-git-send-email-john.garry@huawei.com> <20171206133829.GC12508@krava> Message-ID: <5aaa3863-f90e-cd0e-37ee-58a8f17f6e63@huawei.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 06/12/2017 13:38, Jiri Olsa wrote: > On Wed, Dec 06, 2017 at 12:13:15AM +0800, John Garry wrote: > > SNIP > >> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c >> index b578aa2..a0d489e 100644 >> --- a/tools/perf/pmu-events/jevents.c >> +++ b/tools/perf/pmu-events/jevents.c >> @@ -588,7 +588,7 @@ static char *file_name_to_table_name(char *fname) >> * Derive rest of table name from basename of the JSON file, >> * replacing hyphens and stripping out .json suffix. >> */ >> - n = asprintf(&tblname, "pme_%s", basename(fname)); >> + n = asprintf(&tblname, "pme_%s", fname); >> if (n < 0) { >> pr_info("%s: asprintf() error %s for file %s\n", prog, >> strerror(errno), fname); >> @@ -598,7 +598,7 @@ static char *file_name_to_table_name(char *fname) >> for (i = 0; i < strlen(tblname); i++) { >> c = tblname[i]; >> >> - if (c == '-') >> + if (c == '-' || c == '/') >> tblname[i] = '_'; >> else if (c == '.') { >> tblname[i] = '\0'; >> @@ -755,15 +755,52 @@ static int get_maxfds(void) >> static FILE *eventsfp; >> static char *mapfile; >> >> +static int isLeafDir(const char *fpath) > > we use _ to separate words in functions names > Ok (I will also check functions added elsewhere) >> +{ >> + DIR *d; >> + struct dirent *dir; >> + int res = 1; >> + d = opendir(fpath); >> + if (!d) >> + return 0; >> + >> + while ((dir = readdir(d)) != NULL) { >> + if (dir-> d_type == DT_DIR && dir->d_name[0] != '.') { >> + res = 0; >> + break; > > just recently got into a issue on xfs when d_type is DT_UNKNOWN > for directory.. you need to handle it > Sure Cheers, John > thanks, > jirka > > . >