Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp641389pxb; Thu, 25 Feb 2021 11:08:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1kJskUJuGd3oz6Wt8F9JXDUmp63Ykx+asiYVQVvQrbhU+lP10gtM6K0zI5dKWGKv7vla3 X-Received: by 2002:a17:906:2bd6:: with SMTP id n22mr4102258ejg.91.1614280103302; Thu, 25 Feb 2021 11:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614280103; cv=none; d=google.com; s=arc-20160816; b=WeV9Gs4bclDB2QLw3uHg/4Kq5Zvq6sNDk6t3jNWi/aCGnMgnZd6timMLJUJHQCSoQ7 uHOM/IFnRavrq+7J6TicBEth7bFVDMRhihMuSzP0rHfA71b7Wf0SBLHQdZrUeQm0u2Dl uSYOBT3m8kjByNd2qmE+arCSRWHRAhoxszGTNC9p8uK0Ztw+rSO8kJTqRsVMd0nUK15m 8XL7jRMBUUqvsgoVQmiMStL/VTOo7yOHrbCpGLZsielf3u5kXVSDPOcttSEEld8Hy22E FkhVqabvoZbWHyyZx14aESNS+3eYuMNsjX+xe9REUcv/3001U1fuvs/8NjTUZJxGvnGK nKyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+tBBjR9sNYzM6KSzYefGASfGJGZayMCw0kAzhSTkJbQ=; b=Dd4En0v+jj+rvVKItQw9OtWZXtfvUf0vdyf7Fk0aiv3ThkqqAhvScdEMmO2tm8zewr IMOVM8X3vB/0TTD1dmr48DNhu1i/HbY/z3456K+TKKv3zhK+F9W7eMbapxwd4PLr5J8G YaeX+Pqm6WbA6jqz+MoklPtFv1YTtGq2nVCdt96++stUloV1jWbFds/v5HNmU4uXsFqR iN6tB5lVihw0yZ7Bto4l7GYqZsQEY/L8iQhVodIr0Ze2kIcygKdw9Go3Dbem07dj9B1U pYC5ahXzQbF4z1R/IC3qCRdhWQfLuFsdlyH1Pp45JjphuxbCfDTtcbOycXP9+gg2gXf2 /L0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JQ04+YiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si5162819ejo.67.2021.02.25.11.07.59; Thu, 25 Feb 2021 11:08:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JQ04+YiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232847AbhBYTFG (ORCPT + 99 others); Thu, 25 Feb 2021 14:05:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58881 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbhBYTFB (ORCPT ); Thu, 25 Feb 2021 14:05:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614279814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+tBBjR9sNYzM6KSzYefGASfGJGZayMCw0kAzhSTkJbQ=; b=JQ04+YiS7+TwEWAGNShZxrHBJ61ZuSt4ejdKpjNW9UOg0UVcuJRcTj/7B8Ib1cZkMsydCF 8cbJzOAsQn5uydJ2IyUnPIaRUgqad1RSHBAv2yZh0/Zr9X3Xog6qPINFdhdLrIDVTzmOJk soRLN8o1NOVVuKCmUVof8oZQD6WfiMQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-CcjKFO4YOG-GHfa8jG3qZw-1; Thu, 25 Feb 2021 14:03:30 -0500 X-MC-Unique: CcjKFO4YOG-GHfa8jG3qZw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84D5DC73A0; Thu, 25 Feb 2021 19:03:28 +0000 (UTC) Received: from krava (unknown [10.40.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DC3060854; Thu, 25 Feb 2021 19:03:25 +0000 (UTC) Date: Thu, 25 Feb 2021 20:03:24 +0100 From: Jiri Olsa To: "Jin, Yao" Cc: kernel test robot , Chris Wilson , Arnaldo Carvalho de Melo , Jiri Olsa , Tvrtko Ursulin , Matthew Brost , LKML , lkp@lists.01.org, lkp@intel.com, Andi Kleen , Adrian Hunter , "Liang, Kan" , "Jin, Yao" , "Yi, Ammy" Subject: Re: [drm/i915/gt] 8c3b1ba0e7: perf-sanity-tests.Parse_event_definition_strings.fail Message-ID: References: <20210224074841.GD6114@xsang-OptiPlex-9020> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 07:50:46PM +0100, Jiri Olsa wrote: > On Thu, Feb 25, 2021 at 07:16:44PM +0100, Jiri Olsa wrote: > > On Thu, Feb 25, 2021 at 02:33:57PM +0100, Jiri Olsa wrote: > > > On Thu, Feb 25, 2021 at 04:06:23PM +0800, Jin, Yao wrote: > > > > Hi Chris, Arnaldo, Jiri, > > > > > > > > We observe the parsing error for "software/xxx/" on some platforms. > > > > > > > > For example, > > > > > > > > # perf stat -e software/r1a/ -a -- sleep 1 > > > > event syntax error: 'software/r1a/' > > > > \___ parser error > > > > Run 'perf list' for a list of valid events > > > > > > > > Usage: perf stat [] [] > > > > > > > > -e, --event event selector. use 'perf list' to list available events > > > > > > > > And perf test is failed too. > > > > > > > > # perf test 6 -vv > > > > ... > > > > running test 4 'software/r1a/'failed to parse event 'software/r1a/', err 1, str 'parser error' > > > > event syntax error: 'software/r1a/' > > > > \___ parser error > > > > > > > > running test 4 'software/r0x1a/'failed to parse event 'software/r0x1a/', err 1, str 'parser error' > > > > event syntax error: 'software/r0x1a/' > > > > \___ parser error > > > > ... > > > > > > > > The issue should be the conflict between event "i915/software-gt-awake-time/" and pmu "software". > > > > > > > > # perf list | grep i915/software > > > > i915/software-gt-awake-time/ [Kernel PMU event] > > > > > > > > Perf supports the event format as "prefix-xxx-suffix", so the "software" > > > > string in "software-gt-awake-time" is added to perf_pmu_events_list as > > > > PMU_EVENT_SYMBOL_PREFIX. When parsing the string such as "software/xxx/", > > > > it’s parsed as PMU_EVENT_SYMBOL_PREFIX for "software", then it would error > > > > out in next processing. > > > > > > > > So the easy way is to rename "software-gt-awake-time" to "gt-awake-time", > > > > right? Otherwise we have to hardcode something in perf tool. > > > > > > > > What do you think of this issue and the solution? > > > > > > > > BTW, as the robot reported, it's related to the commit 8c3b1ba0e7ea > > > > ("drm/i915/gt: Track the overall awake/busy time"). > > > > > > yes, I think you're right.. I'll try to reproduce and check on this > > > > > > I'm still not clear why is that parsing fail if those 2 events are > > > distinguished by - and / ... but yep, we are asking for trouble in > > > here ;-) > > > > > > I think we could either prioritaze one or add extra check when we > > > add prefix-xxx-suffix events and do not add ones that have conflict.. > > > that seems like best solution to me now > > > > would patch below work for you? > > > > jirka > > and now with more fixes after I ran tests ;-) > > we should perhaps add also same check for non '-' aliases, I'll check and one more version ;-) jirka --- diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 42c84adeb2fb..d9e795056d15 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2028,30 +2028,49 @@ static void perf_pmu__parse_init(void) perf_pmu_events_list_num = -1; return; } - perf_pmu_events_list = malloc(sizeof(struct perf_pmu_event_symbol) * len); + perf_pmu_events_list = zalloc(sizeof(struct perf_pmu_event_symbol) * len); if (!perf_pmu_events_list) return; - perf_pmu_events_list_num = len; len = 0; pmu = NULL; while ((pmu = perf_pmu__scan(pmu)) != NULL) { list_for_each_entry(alias, &pmu->aliases, list) { struct perf_pmu_event_symbol *p = perf_pmu_events_list + len; - char *tmp = strchr(alias->name, '-'); + char *prefix = strdup(alias->name); + char *tmp = strchr(prefix, '-'); + + if (tmp != NULL) + *tmp = 0; + + /* + * Skip any prefix that conflicts with pmu name, + * otherwise the event parser gets confused. + */ + if (perf_pmu__find(prefix)) { + pr_debug2("perf_pmu__parse_init: skipping conflicting alias '%s'\n", + alias->name); + free(prefix); + continue; + } if (tmp != NULL) { - SET_SYMBOL(strndup(alias->name, tmp - alias->name), - PMU_EVENT_SYMBOL_PREFIX); + SET_SYMBOL(prefix, PMU_EVENT_SYMBOL_PREFIX); p++; SET_SYMBOL(strdup(++tmp), PMU_EVENT_SYMBOL_SUFFIX); len += 2; } else { - SET_SYMBOL(strdup(alias->name), PMU_EVENT_SYMBOL); + SET_SYMBOL(prefix, PMU_EVENT_SYMBOL); len++; } } } + + /* unlikely, but still.. */ + if (!len) + goto err; + perf_pmu_events_list_num = len; + qsort(perf_pmu_events_list, len, sizeof(struct perf_pmu_event_symbol), comp_pmu);