Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4748453pxv; Tue, 29 Jun 2021 14:49:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxblpVXDsDbPyFNz6T+NCh6u0AgaFgENb9Fgl6BUHvhLkdjwtQ7wjPMjzl9Vy2JtsfLItlA X-Received: by 2002:a17:907:62a5:: with SMTP id nd37mr31676490ejc.148.1625003355701; Tue, 29 Jun 2021 14:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625003355; cv=none; d=google.com; s=arc-20160816; b=MJU5edmC/Es0aAPxdEOXQNvOdrAQAOTwzY8Vhk5cBJM3yg7mRbfnLpGCjciO2xqLoR snX/3qW1qsqx5PJ21S8ExXm3KiNBgnHdCk6Df3v9LSGokJTJJvDNbxlxITKQ04EC26By GzNCOa9247BgvZo25rQdkEROLsuMPTts+UJUNIySPWec/+sX2F4z6quHlAXoqW1tnlIG Vz3/SK1zmcpuS6uDBaBmfrd+E6xXqNxfm9gmZTAB076+KEpbIROzBOZia0fP79sKt90O 3f2rfho5Mn7kHOmFTtxQcE5cCUrtRsJhhxjFIoX4QMBRvq0qZv0jOCcNZd+aCYaqhnI6 3Vgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=mVdm8pcj7Xm2PvDRqCWjKPD95anigUdO8YSsfwW+8k4=; b=CIwELQl5oOlHppccTGzlfmsGA0XrNF/cNvNV4/Ww9q1PlnTs9vdZwM+70StazpQVMV huZrmdl9U+IQQLn7TNdTE8DAcjzP32z1n+KYzdFMCoQjlBF/2H+hu3fpG8wIjlxICib0 /JIv3+JYKr7pUGA/50xKXG4myNxP33FQYy55mIB9PNpg/2ddHSFHi1SMb136Pw3sMr6e ltOvH/9j3ssEYZrXFxxQXFdF/NsQQqxLvuDwuCoNlV2LKvJJdPTQSdOwM90wRhhYxGGS x5bsJWkqUwFHmTdVE5T/DWpibqmbDKnVKAnsDjRz/ABQpzTesaCLPumz1P8gteOvnIr+ I2Bw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 19si18232122ejx.529.2021.06.29.14.48.52; Tue, 29 Jun 2021 14:49:15 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235407AbhF2Vu3 (ORCPT + 99 others); Tue, 29 Jun 2021 17:50:29 -0400 Received: from mga02.intel.com ([134.134.136.20]:62191 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233660AbhF2Vu2 (ORCPT ); Tue, 29 Jun 2021 17:50:28 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10030"; a="195398110" X-IronPort-AV: E=Sophos;i="5.83,310,1616482800"; d="scan'208";a="195398110" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2021 14:47:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,310,1616482800"; d="scan'208";a="558083495" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 29 Jun 2021 14:47:59 -0700 Received: from [10.212.193.2] (kliang2-MOBL.ccr.corp.intel.com [10.212.193.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 001E45807C8; Tue, 29 Jun 2021 14:47:57 -0700 (PDT) Subject: Re: [PATCH v1] perf tools: Fix pattern matching for same substring used in different pmu type To: Jiri Olsa , "Jin, Yao" Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com References: <20210609045738.1051-1-yao.jin@linux.intel.com> <982714a5-8a5d-8f8a-4e30-bd9a497ffa40@linux.intel.com> <4787334d-cf28-5b25-8d11-c767c52288f1@linux.intel.com> <14a70048-ddd0-3297-9ae9-6b76dd0f1000@linux.intel.com> From: "Liang, Kan" Message-ID: <844625a7-5903-519e-9ef4-ca6684661aef@linux.intel.com> Date: Tue, 29 Jun 2021 17:47:56 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/29/2021 5:15 PM, Jiri Olsa wrote: > On Mon, Jun 28, 2021 at 09:52:42AM +0800, Jin, Yao wrote: > > SNIP > >>>>>> +    /* >>>>>> +     * The pmu_name has substring tok. If the format of >>>>>> +     * pmu_name is or _, return true. >>>>>> +     */ >>>>>> +    p = pmu_name + strlen(tok); >>>>>> +    if (*p == 0) >>>>>> +        return true; >>>>>> + >>>>>> +    if (*p != '_') >>>>>> +        return false; >>>>>> + >>>>>> +    ++p; >>>>>> +    if (*p == 0 || !isdigit(*p)) >>>>>> +        return false; >>>>>> + >>>>>> +    return true; >>>>>> +} >>> >>> hum, so we have pattern serch and then another function checking >>> if that search was ok.. >> >> Yes, that's what this patch does. >> >> I understand that's convenient, because >>> it's on 2 different places >> >> Yes, on pmu_uncore_alias_match() and on parse-events.y. >> >> but could we have some generic solution, >>> line one function/search that returns/search for valid pmu name? >>> >> >> Sorry, I don't understand this idea well. Would you like to further explain? >> >> Or can you accept the regex approach? > > I don't really have any suggestion, just would be great to have > this encapsulated in one function.. Yes, I agree. One function is better. We just changed the design for the uncore PMU on SPR. There will be two PMU names for each uncore unit, a real name and an alias. The perf tool should handle both names. So we have to compare both names here. I think one generic function can facilitate the code rebase. https://lore.kernel.org/lkml/1624990443-168533-7-git-send-email-kan.liang@linux.intel.com/ Thanks, Kan