Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp291966pxt; Wed, 11 Aug 2021 21:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+siVfnexMOmXUm86WYhxGGIQleKXoYXBj77tdWLAQd5IVC0cZmmxUnomiDx4F3O0aQsX9 X-Received: by 2002:a05:6638:1b9:: with SMTP id b25mr2062978jaq.23.1628742831156; Wed, 11 Aug 2021 21:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628742831; cv=none; d=google.com; s=arc-20160816; b=t4t5HAJFJ9nKhWNJuvXCcjLtPmcmz2zQ09ITt7lfEPfnOKlvTvB4e69OsHMa8h+bS0 BNFKpzIFzBfqCjNA7es7jVCBqiy30Kix+KEyk7tTl1tZLR1UEWa4c+a4WFDoKzUro1cA C3gp6DR+9H43CmX+gTKo7p7inq4XWl1CS1rxPnduTaZwfs24okVoSMt5C9fAi24L4PZb oK7pKliRqamOvmd2ODIA0/3oWPQy6Vpw6Ci0xlPEa9ZC5Fw1mO557SfwLV7Yau71yWSO sdzziAH5pi+298wsiefI0ZGY6EgQRIYDWoZXu3NbThLvPCsEgIxcpqvHqhsyJwN9UwnL qt5A== 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=4yb2z43ku52aWsACjskfpYqynDKVG+jwBjD7DB942i0=; b=jMvGAJZGOXJuG8R6cNuEfuXh7k3leRe09CYnistcdBZt27uRcwZ4fRFiM0Pz6wWLF5 WUg29TA293FlD9lI83o+jocYWPDFBDX4Gopg7EDVyz3jCrg45c54/6Pg5vwxQbpr/Q66 kiPvAiEoxb2VhySdLLB2oOk6KXnxIxFrMS1TLnsRnU6y9ootw6DDPBZp7wJldtX9ZOnH DyFlSa7CHUA4R2hLaFLcYOkEziZH8REMNoHxwgC0p/4NG/rmE68LT4t2QRD+bem/JkKz JwEVa34/jGbk2T15XCm2oA5c3kcZeABct88OQEcSjB0z5Fh33ja2zpxzZZWFDyr+++G/ mL/g== 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 f14si1768639jar.87.2021.08.11.21.33.39; Wed, 11 Aug 2021 21:33:51 -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 S233887AbhHLEdV (ORCPT + 99 others); Thu, 12 Aug 2021 00:33:21 -0400 Received: from mga03.intel.com ([134.134.136.65]:37429 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbhHLEdV (ORCPT ); Thu, 12 Aug 2021 00:33:21 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10073"; a="215303541" X-IronPort-AV: E=Sophos;i="5.84,314,1620716400"; d="scan'208";a="215303541" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2021 21:32:56 -0700 X-IronPort-AV: E=Sophos;i="5.84,314,1620716400"; d="scan'208";a="517293211" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.249.174.184]) ([10.249.174.184]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2021 21:32:52 -0700 Subject: Re: [PATCH v4 1/2] perf pmu: Add PMU alias support To: Jiri Olsa Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, rickyman7@gmail.com, Kan Liang References: <20210811024827.9483-1-yao.jin@linux.intel.com> <20210811024827.9483-2-yao.jin@linux.intel.com> From: "Jin, Yao" Message-ID: <6401ef3a-1a59-4575-7c1d-8065e8a2b5c6@linux.intel.com> Date: Thu, 12 Aug 2021 12:32:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On 8/12/2021 3:23 AM, Jiri Olsa wrote: > On Wed, Aug 11, 2021 at 10:48:26AM +0800, Jin Yao wrote: > > SNIP > >> if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true, false)) >> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c >> index fc683bc41715..796a4be752f4 100644 >> --- a/tools/perf/util/pmu.c >> +++ b/tools/perf/util/pmu.c >> @@ -946,6 +946,18 @@ perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) >> return NULL; >> } >> >> +char * __weak >> +pmu_find_real_name(const char *name) >> +{ >> + return strdup(name); >> +} > hm, why does this need to return already strdup? it forces you > to add all those goto below.. could just return name and keep > the 'pmu->name = strdup(name);' below? > > that should make the change simpler > > jirka > In x86 specific __pmu_find_real_name, static char *__pmu_find_real_name(const char *name) { struct perf_pmu_alias_name *pmu; list_for_each_entry(pmu, &pmu_alias_name_list, list) { if (!strcmp(name, pmu->alias)) return strdup(pmu->name); } return strdup(name); } We have returned with strdup(name). OK, I will change the code to: static char *__pmu_find_real_name(const char *name) { struct perf_pmu_alias_name *pmu; list_for_each_entry(pmu, &pmu_alias_name_list, list) { if (!strcmp(name, pmu->alias)) return pmu->name; } return name; } And keep 'pmu->name = strdup(name);' in pmu_lookup(). Thanks Jin Yao