Received: by 10.223.185.116 with SMTP id b49csp1612299wrg; Sat, 24 Feb 2018 00:09:13 -0800 (PST) X-Google-Smtp-Source: AG47ELuzCaDeUpq7Tp5RhHMJvymX4atNKcmngIV1neYGbrJTNPD/vazgFKqE9GTzA/cdqkNuiIjH X-Received: by 2002:a17:902:7009:: with SMTP id y9-v6mr444913plk.395.1519459753242; Sat, 24 Feb 2018 00:09:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519459753; cv=none; d=google.com; s=arc-20160816; b=aKw2ELAC+V/cFabi9IZaluA3L8/D9PGWXi1logASftrsFFa4Xbhv2YoLXL8NGzxtNJ AbCPmjNPKfnAThfpBTNDlHqsaLHIgNO+g1tfN/rw7QVU9kVbhSXR2Uns1NR1r/4GHmkL 7f9eWu27JQ/BG6V43FNRnrkjj1i7nbUnlxYTmGpQeZQwtLnWy1caRKC6vL0zANCd7E5r HjPTJjlJwlpEdrYbqdti+R/oaqI3B9G2CEtbq/q42bze0sr8WyZfXAMy7BSRpbKvtREq oI81hl571XbO+JweAgvNtktY7YH4bbY19LXtKsUIKPSyRGLVdZDou7CVI6urbfvHHC6w a44Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=V2tflhuIaU2rI/nmqhNe1bBi8cvn7EixalbnJ3vzc4k=; b=cUVwCTVeDpzv8sYFRM0C+vhQTSkqmm7J2yjOank94hf3HOQyZVbIsJxquPJJYqZR4F 4HQ1ssBh9Fnf0trf/8Tm8+/jlKxSZH8CJ7lzz/ONps6JPMeeqo5HVCn8CJshol5cpLTP jyjH5PlrcbY/l7MGEH8tHTgpg3BW/y9glV7wd9RssiKOB1aGUXj7dkPwjZDVf89oFL48 33YEA7D9JaZwxQrAq5N5qdDfgQ5Qv62r1+fUIjjjnfEAj9ATDdE/37Ulgcs2vGrQDH/d VygHGquB38azfnHSSuW8OhFYWLneY5DsHCshjzI9HKwZ2gZ+VXOts7g9I+fzrX+Xmwuw 6t4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Ae0nsKrp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l62si2617824pgd.777.2018.02.24.00.08.58; Sat, 24 Feb 2018 00:09:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Ae0nsKrp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbeBXIIS (ORCPT + 99 others); Sat, 24 Feb 2018 03:08:18 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:56186 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbeBXIIR (ORCPT ); Sat, 24 Feb 2018 03:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=V2tflhuIaU2rI/nmqhNe1bBi8cvn7EixalbnJ3vzc4k=; b=Ae0nsKrpfP3xDyf+SI8FBwC75 aQXIqaP/NkeedCoQ/3vELo80sm5TOy0r+Wbjphk2o5vb7DJ0g321dcXBDLNKGZRT+LEZUW+ev+6pY Ixy1ZgpsTfzQdGCBmEmOGzlI2tJ5XewnrQoykQCuPuipvHlGZz4l/zyMqmzCWc4xZ0c11MuNt7iGA IJdrIZ8aAZRGizIUgKyaLnUCHJtuBomyxneiLhmb9OR44R/R1Z7wQ710hlz3Hkhtmu9+lO6hWkDfd 2Jz1Z2IsxnrAzynlX/Ggjj7qY3YT6A4AykhSLMf3f9zVnPRjQq8jIlgQwO9daY5LDmeZ+t/70W7jX I+t3TTU4Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1epUsO-0002Yr-KP; Sat, 24 Feb 2018 08:08:12 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A25122029F1DF; Sat, 24 Feb 2018 09:08:09 +0100 (CET) Date: Sat, 24 Feb 2018 09:08:09 +0100 From: Peter Zijlstra To: Saravana Kannan Cc: mark.rutland@arm.com, Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , avilaj@codeaurora.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/2] perf/core: Add API to look up PMU type by name Message-ID: <20180224080809.GA25201@hirez.programming.kicks-ass.net> References: <1519431578-11995-1-git-send-email-skannan@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519431578-11995-1-git-send-email-skannan@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 23, 2018 at 04:19:37PM -0800, Saravana Kannan wrote: > When the event numbers registered by multiple PMUs overlap, the > attr->type value passed to perf_event_create_kernel_counter() is used > to determine which PMU to use to create a perf_event. > > However, when the PMU in question is not a standard PMU (defined in > perf_type_id), there is no way for a kernel client to look up the PMU > type for the PMU of interest and set the attr->type appropriately. > > So, add an API to look up the PMU type by name. That way, the kernel > APIs can function in a fashion similar to the user space interface. > > Signed-off-by: Saravana Kannan > --- > kernel/events/core.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 96db9ae..5d3df58 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -10310,6 +10310,29 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id) > return err; > } > > +int perf_find_pmu_type_by_name(const char *name) > +{ > + struct pmu *pmu; > + int ret = -1; > + > + mutex_lock(&pmus_lock); > + > + list_for_each_entry(pmu, &pmus, entry) { > + if (!pmu->name || pmu->type < 0) > + continue; > + > + if (!strcmp(name, pmu->name)) { > + ret = pmu->type; > + goto out; > + } > + } > + > +out: > + mutex_unlock(&pmus_lock); > + > + return ret; > +} Not without an in-tree user.