Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp632121pxb; Thu, 25 Feb 2021 10:56:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG07bHR+q5AvuS4xdCBY3Vtis1OnvHssPVK0xj8aYnkUXWS/O+4UKbviw1vWp1/XjF+1Lz X-Received: by 2002:aa7:d287:: with SMTP id w7mr4474932edq.26.1614279370969; Thu, 25 Feb 2021 10:56:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614279370; cv=none; d=google.com; s=arc-20160816; b=CBFGSWIHk9SY9xCfz0VeurXbWBsnRF5cAAiJ7jh8sIJ/Ivpl28I0yW8WGwC5DRSiob XWkD5FaQBlhkmp36n+ZwUKmd+Xi7O2Ug2uy0+mwr6s3cUX8RzBUd6RY9SYhxS5+0ZW6S XdtsmI5M8lsW0jPWcZ1nbClVrrgO/NJ0WrISKZt7q0X653+jnVZcvDjR77NTbvh/TGf5 XnGDNBBP7lmsC27Ah5yPFiq4SfSL4mq1G7fbdSZq2prDr4iwGa57nViTqUZnaURt3c2Z AvW7Ee7L8zvJGOtWAak0lnWQhmmTrV0Pj1hz523SXJ+cLlacqK9VAh5MufNRANdMDbhR NV7A== 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=HegVE8Ke6znBhOf0ABy7cQANSvwYs/7Gea0hSwTSK60=; b=JdhRsoCOWwKKxwFyo7x2riZGG1YmKxc6vHHq7Z3M3uFFM9eCyIhsNCZZGbIrChq0ql I23sX0feSMh0QHqluIj6WqsydifhnsLKsGIKthdRuhtP32K6NrouLv0E7Va3tzi0s3EB RgIZFzGuvXzbjJEXBuC4ftrSBa+wiAOmO0qKA2CCphAlyAiY2YhEuyo+0PVkf26Ot5kh lfkaoM8hU63kHNPaPY/mGiopjz+rb8kMYBeMsd7q5W/sxOwWxuxvGK1qmBJkLFSAH9ey SPAe9nBJvMpybH3R6pPi2urNAqdhN/s6kcypRsHk2+rMX1pVHwhxoZ115E1Bm44S6efI Urgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QlW4EmeN; 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 d4si3580891edo.136.2021.02.25.10.55.43; Thu, 25 Feb 2021 10:56:10 -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=QlW4EmeN; 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 S233293AbhBYSwY (ORCPT + 99 others); Thu, 25 Feb 2021 13:52:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39534 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232686AbhBYSwU (ORCPT ); Thu, 25 Feb 2021 13:52:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614279053; 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=HegVE8Ke6znBhOf0ABy7cQANSvwYs/7Gea0hSwTSK60=; b=QlW4EmeNfgRDhl8CfuKv3pSCCNtxCCay2p/WeKYMlB/ROLAaq+03k4fj5euPpHMmnUqf1G 6odihgFCHWj6yA52vsIFl8eFOnOowiATdnid+5AV79NNhXZOgRpMoRGKovCYxf10oYfIoG D9UxoFvMF11T+QXJrNLUxGzpZDKGEzw= 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-226-lVXC8I9_Ptq_omhAxqm9ww-1; Thu, 25 Feb 2021 13:50:49 -0500 X-MC-Unique: lVXC8I9_Ptq_omhAxqm9ww-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F49180197A; Thu, 25 Feb 2021 18:50:46 +0000 (UTC) Received: from krava (unknown [10.40.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA94B1F432; Thu, 25 Feb 2021 18:50:42 +0000 (UTC) Date: Thu, 25 Feb 2021 19:50:41 +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.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 jirka --- diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 42c84adeb2fb..0b5d355ad4f6 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2028,10 +2028,9 @@ 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; @@ -2041,8 +2040,16 @@ static void perf_pmu__parse_init(void) char *tmp = strchr(alias->name, '-'); if (tmp != NULL) { - SET_SYMBOL(strndup(alias->name, tmp - alias->name), - PMU_EVENT_SYMBOL_PREFIX); + char *prefix = strndup(alias->name, tmp - alias->name); + + if (perf_pmu__find(prefix)) { + pr_debug2("perf_pmu__parse_init: skipping conflicting alias '%s'\n", + alias->name); + free(prefix); + continue; + } + + SET_SYMBOL(prefix, PMU_EVENT_SYMBOL_PREFIX); p++; SET_SYMBOL(strdup(++tmp), PMU_EVENT_SYMBOL_SUFFIX); len += 2; @@ -2052,6 +2059,12 @@ static void perf_pmu__parse_init(void) } } } + + /* 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);