Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1394138rbb; Mon, 26 Feb 2024 08:00:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhWZ54pJBidBcAILdl7sATgauUL5WYMdzajw+yEAMp+xs5SdyYdz2jvlQfLpbMClI64NXP5NlUCCEsjfwDmZRTErC+y1XaBKtTM80maQ== X-Google-Smtp-Source: AGHT+IGgmkwrCaIZcHdz+Q4R9nBhik6pCAkfLRDbSHukxDLdZj+ooYWoR/1c7zbX7jzzr79+6PAH X-Received: by 2002:ac2:494b:0:b0:512:fdf4:33d9 with SMTP id o11-20020ac2494b000000b00512fdf433d9mr1801554lfi.40.1708963222035; Mon, 26 Feb 2024 08:00:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708963222; cv=pass; d=google.com; s=arc-20160816; b=0agCEG5X0H8ZlqbBZ3cvpDnC1piY3QkzPvBcsTl2aIbp90NuPoUDz4vo17DepRUrWC YHjvYuq5J8HApo3o82LlIFT6RLD90+/IqUXXzGyw9hY+IBO42wEZ7T1KGUgfAnolgwOy LY2JPFLRpE8tVzdwCGZ8n1xhKHui3ocjdrblv1oQYYZJkLn1zulgfwTvVUYYtvMS6P9z VXTFTbXJT+3ebMC0qYN+/EdrrGhtbjBCug1/X7qCuP6Gmulblgfu+H6B2NgpErBYDc6y V4u7RRftSV+6W37b4JxBsw9hKrs9hE2CpRx1oWJSvcz7d4U+UZmYSZWWFFzw5mvvXwDM bydw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=o8Q6p3XFLg3w78aRq+SVPhmudeI9cxuWsLnUsnNwyUk=; fh=SsSC9r1tuC3jvUZdKqBayfa1caDXe/Rut5XO2z7ORuI=; b=LRnYjuPRo0G1rigikGwpClmf5Sjm4kJI+TNNSGoIGkpXyN+tPgbHfHxRxrA5K6LBfD 0K6me9kVIinsqdxuOskPhqXZGQWXxVV5vFzqKyFx7hyQQkShTWWxB4Zj6TOuXz2X376A gu43iL+bENodaoYY7NRJFxeQe0dfKi5XeHI67UckabKOhmEdYx/qOXJb6IhN8wb7wUeC W+PlvKfVml79S3ob5qcBjajCEQpTCvgt6EQhOZMcEdvtHlt+JLQRfB4GGQS0C6BGuK2y vCSSDCFjnCmL4aLOHXYByL/CAjBIInkadGBusWl/ja5xzfHzmTkhjrx+OHpSoC8/hnWo qWjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="QkD/LCs3"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81852-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ck15-20020a170906c44f00b00a3f2147fcc3si2150469ejb.90.2024.02.26.08.00.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:00:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81852-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="QkD/LCs3"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81852-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A3551F25D5A for ; Mon, 26 Feb 2024 16:00:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 556C012C548; Mon, 26 Feb 2024 16:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QkD/LCs3" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C33FA12BEA1; Mon, 26 Feb 2024 16:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708963213; cv=none; b=q8LCmuLIkW+k5uxJazRjmXvoRbGhMQ5Xn2c1W/U/3ZwY7ru8VjGSHoglfXDErPCry3HBClK29qzOygblmC0kYlkmyestcKqFttWQ09h18vxs9eKZhiWGtMGmSUnwVyNDNf3y/NmkMCFWTV8cNn9U0QdbiVf/7wpn2hese0kNLck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708963213; c=relaxed/simple; bh=eiEN98yjHWpgsNieB++vFqM13GnLlyTzpq+LgyXfNJQ=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=m0s0fTy228gOGuB0P73Ph+InQfkcIruaBof91YjEqCFbVWzsM2aw4ImC4nDDPb4cWb77kdhHzRCtKEi+ytQHnWTxONA86Qd2au5BYcKSwNoWC23cwERgw9z8oPDsQEeDHg+eGDXkTTTaiMqZkEWwwN1qCGApvK5txKJzOnRkc5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QkD/LCs3; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708963212; x=1740499212; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=eiEN98yjHWpgsNieB++vFqM13GnLlyTzpq+LgyXfNJQ=; b=QkD/LCs3soZs/MyJ4+ilDzn1vFS0yW7zn3SycV0yvs4uOM8EMhOOTHyi wVbwY2938XgYxfaW+0vwBDMNhpzZdua8hVHfEUTbzlY5HYX15QYlr/syQ fUikc+i57oAhVLSDGXNTX4qrlHu2oaru7fY0m/ueSjdtjg5SeyGgK4Vjx ErkCUjQUIHt4V0bRTrlIPPk5IU98945LjkcPT+XFwXZjxvT6E/lP8KbKk ZTwCuNcZm3vxI2J/dckpa+r2QTwph85+LKqI5rtOkywmrmAIklQJyY9Xb zHUv5Ss4ln6QmhmPVAUo8jbKSvRkvxKxG5dn+2bd5/ET+zJq+wCTKiuo0 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3419570" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3419570" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 08:00:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6914761" Received: from linux.intel.com ([10.54.29.200]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 08:00:10 -0800 Received: from [10.213.175.136] (kliang2-mobl1.ccr.corp.intel.com [10.213.175.136]) (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 11EDC580ABD; Mon, 26 Feb 2024 08:00:08 -0800 (PST) Message-ID: Date: Mon, 26 Feb 2024 11:00:07 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/2] perf metrics: Fix metric matching Content-Language: en-US To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240224011420.3066322-1-irogers@google.com> From: "Liang, Kan" In-Reply-To: <20240224011420.3066322-1-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024-02-23 8:14 p.m., Ian Rogers wrote: > The metric match function fails for cases like looking for "metric" in > the string "all;foo_metric;metric" as the "metric" in "foo_metric" > matches but isn't preceeded by a ';'. Fix this by matching the first > list item and recursively matching on failure the next item after a > semicolon. > > Signed-off-by: Ian Rogers For the series, Reviewed-by: Kan Liang Thanks, Kan > --- > tools/perf/util/metricgroup.c | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index b24a1c177a80..2d6865c392ef 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -352,25 +352,23 @@ static int setup_metric_events(const char *pmu, struct hashmap *ids, > return 0; > } > > -static bool match_metric(const char *n, const char *list) > +static bool match_metric(const char *metric_or_groups, const char *sought) > { > int len; > char *m; > > - if (!list) > + if (!sought) > return false; > - if (!strcmp(list, "all")) > + if (!strcmp(sought, "all")) > return true; > - if (!n) > - return !strcasecmp(list, "No_group"); > - len = strlen(list); > - m = strcasestr(n, list); > - if (!m) > - return false; > - if ((m == n || m[-1] == ';' || m[-1] == ' ') && > - (m[len] == 0 || m[len] == ';')) > + if (!metric_or_groups) > + return !strcasecmp(sought, "No_group"); > + len = strlen(sought); > + if (!strncasecmp(metric_or_groups, sought, len) && > + (metric_or_groups[len] == 0 || metric_or_groups[len] == ';')) > return true; > - return false; > + m = strchr(metric_or_groups, ';'); > + return m && match_metric(m + 1, sought); > } > > static bool match_pm_metric(const struct pmu_metric *pm, const char *pmu, const char *metric)