Message ID | 20210802134347.387008080@linuxfoundation.org |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1955751jas; Mon, 2 Aug 2021 07:06:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6z/hgJQXp3kYl0s31Y619gpRev8JPukX9RfknwXft79U3vitFPZI7SBCJxEeZZarGsLOU X-Received: by 2002:a6b:fe03:: with SMTP id x3mr753088ioh.120.1627913162610; Mon, 02 Aug 2021 07:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913162; cv=none; d=google.com; s=arc-20160816; b=TkH02OF4sog9QCfSuothSLTCDo7ysPA35Nij2dyG9IRxC819omSHX/lngJa2fR7Vgf C3ZlIzUvvCnmBmjOg3snV+BDPAJMFpHOgsf2rTBByZ9oGD8ReShDvDpGgO52FeaJzwNi 3G3JE45NbxSAyyxbvBorBHHigHUnLctGRL9BATRMcJcD8+r3wgGRwKPKQ/MM5d7p1lN4 GnQqX+odh+Fw1NTasdGq3Z/BpHeWC/NZpTcsD/5GlMbKSTRJ8HhOJpXrZNCboWP6Bw1P uQa4CV88Mn7yiZJMp0YuXjltZJFy/PYdptBLSpm6QPAPgKh3ASFpHZXmi37XM9p3srsl UDaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6DQToJSGGYmGNEqqGVjnakZbjeFVvC4ZKbRtv0Cdx3M=; b=kN76OyJdxXMsgDn7c731g6CPClwNA7YFH2Z6i0Paz0VD85lGspxYpMoNxpmO3b+6Hn KhaA5eFqLTO+v1fSze/TbaUYN4uLdtqQB2dghdwdAi97pUOcnoS9UQ91sV7OiSxpb6yg 4ej1dDPhoaL1Vdi3iEZSgrFUqDBoT3mlT1/9VnPzAUdDA8SLaEuuRdOhMYj/08CpSS2t lEiln+8CI3YtKBTAf3wMWpTXV93m+Jzj02+2/++YU3UbOr6zmBOzy03fIJvZz821gyLc RtI7BNYvaC9gMcHnLt+W32djKQxhNCj8m6YOxB/WaygQtZYoTE4k9FoqFy7zrRLhzJJm QjXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v+lNzKHM; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: <stable-owner@vger.kernel.org> Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si13757525ils.18.2021.08.02.07.06.01; Mon, 02 Aug 2021 07:06:02 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=v+lNzKHM; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236399AbhHBOGH (ORCPT <rfc822;semen.protsenko@linaro.org> + 12 others); Mon, 2 Aug 2021 10:06:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237019AbhHBOE2 (ORCPT <rfc822;stable@vger.kernel.org>); Mon, 2 Aug 2021 10:04:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E767B6124D; Mon, 2 Aug 2021 13:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912679; bh=q1eFjOKrqN+tpgJBV14nxq5uL2vp6IrctvQiV2wGy54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+lNzKHMUr1TouNj89Uf7z47N3WK4f46+U2aT635XcUl0Lnnl/zKtuL7eFdTq7OpG ufzTUZynAMkjfpxzcNh5qHYZ/iOxwdkgiKT4dWHbmvj9lF5PcIS6rABQdGiOo+tGEq T5di2DjQ3J1wezXhZgDnMwhvD/1QM4ZpbyJpsENE= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, John Garry <john.garry@huawei.com>, Jin Yao <yao.jin@linux.intel.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@redhat.com>, Kajol Jain <kjain@linux.ibm.com>, Mark Rutland <mark.rutland@arm.com>, Namhyung Kim <namhyung@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Arnaldo Carvalho de Melo <acme@redhat.com> Subject: [PATCH 5.13 103/104] perf pmu: Fix alias matching Date: Mon, 2 Aug 2021 15:45:40 +0200 Message-Id: <20210802134347.387008080@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134344.028226640@linuxfoundation.org> References: <20210802134344.028226640@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
--- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -742,9 +742,13 @@ struct pmu_events_map *__weak pmu_events return perf_pmu__find_map(NULL); } -static bool perf_pmu__valid_suffix(char *pmu_name, char *tok) +/* + * Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name + * to be valid. + */ +static bool perf_pmu__valid_suffix(const char *pmu_name, char *tok) { - char *p; + const char *p; if (strncmp(pmu_name, tok, strlen(tok))) return false; @@ -753,12 +757,16 @@ static bool perf_pmu__valid_suffix(char if (*p == 0) return true; - if (*p != '_') - return false; + if (*p == '_') + ++p; - ++p; - if (*p == 0 || !isdigit(*p)) - return false; + /* Ensure we end in a number */ + while (1) { + if (!isdigit(*p)) + return false; + if (*(++p) == 0) + break; + } return true; } @@ -789,12 +797,19 @@ bool pmu_uncore_alias_match(const char * * match "socket" in "socketX_pmunameY" and then "pmuname" in * "pmunameY". */ - for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) { + while (1) { + char *next_tok = strtok_r(NULL, ",", &tmp); + name = strstr(name, tok); - if (!name || !perf_pmu__valid_suffix((char *)name, tok)) { + if (!name || + (!next_tok && !perf_pmu__valid_suffix(name, tok))) { res = false; goto out; } + if (!next_tok) + break; + tok = next_tok; + name += strlen(tok); } res = true;