Received: by 10.223.185.116 with SMTP id b49csp1322173wrg; Fri, 23 Feb 2018 16:21:05 -0800 (PST) X-Google-Smtp-Source: AH8x227rHchmlA9JR6kPPlY1tySMUwRTl2URygonulIWwA4HmkPGVUhs9PysFr1xHGiq9S1igIaI X-Received: by 10.98.17.86 with SMTP id z83mr3380697pfi.207.1519431664995; Fri, 23 Feb 2018 16:21:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519431664; cv=none; d=google.com; s=arc-20160816; b=bWTouBUFTg1zYtgPSAiZYZpffNwkBSCRpnDzuI8eawOhVHDLxfKThHC5w9ctIH04cL lt2zfcxCYctH3AQMUAQuKusqqHERfeno8doTcG+zrwIwWx9H3DTi1LVIktgsF5piqSFY WVCX8voqZtuPKbjKW9oPkLLiijhBCJEav4gdZVUexaSHzlkHzeym5iH/x62EErOAodV/ QIz/FusF85LSDUGN2yMBD2tO1Aby2DLEN6B2LdV7SEijmM1mmQCWM7wV+cgq+AggpGi8 +InJvfEbT20V+xe2rdHaLdKDjMueKn4xGkJfdr/IjaMoDGe7z2REDlD03too8gjEoyqv 9TYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=mK9bvU4mfTJ3kHftIZ7CpNUrCp4OWm3LwuPnMI7MDbI=; b=r5ConwTd9uFoPyWHjeaJeVYRkK+YEEofkC2AU6LQ/LTnGcKw8Si7gNzHYT5vHjOYYk fQsBTTZJ2hYqDcBjt1vcNaRQMrUH44BJD1mNL8IUIV3ez5yr8b5XVsO4E1xH74GyC7FU KTWZ4e4tU4nqnzqt+eV9rEGdkkcOSul5+SmK3rwyt1FoBJpi4SFN19hIC5l0/FQzPQpz z+YCNDc+xuISc3aXOS2uiF084x9hN5EuULr5TyWk0eZfmcovVxhdoDGBDgCqWQ+Dln3j TxQG3K2C7qx8C57IRSW8rMe9+xgJoSpGApUl6RhQ5NV9oPMiUzJ/qV0rc+CPGOPotjvC u+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=YIZRRJjL; dkim=pass header.i=@codeaurora.org header.s=default header.b=c7svz/J3; 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 t1-v6si2608702plr.558.2018.02.23.16.20.50; Fri, 23 Feb 2018 16:21:04 -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=pass header.i=@codeaurora.org header.s=default header.b=YIZRRJjL; dkim=pass header.i=@codeaurora.org header.s=default header.b=c7svz/J3; 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 S1752442AbeBXATt (ORCPT + 99 others); Fri, 23 Feb 2018 19:19:49 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:40624 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752146AbeBXATq (ORCPT ); Fri, 23 Feb 2018 19:19:46 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8985460B67; Sat, 24 Feb 2018 00:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519431585; bh=uVjJ+e0vphYmNA5CsKXTRgGJfo1/NXJlhngcLBErFbQ=; h=From:To:Cc:Subject:Date:From; b=YIZRRJjLqu10pERBWli3nmIdIcAK6yHVa/zq3+LNW4cMbUWVTzITUwhnTKQOYRoyp djfKWPQzQwYIAHOeYZ8jT6tdWvPDxC7CvRfDKc67F2Ieg1qm7+Kybb0Kx1QPzOY1FX +w7AHSxdWgJIGoLqkfumWgbKLJ1wBOrJEc6a99jE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from skannan1-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skannan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4837E602B6; Sat, 24 Feb 2018 00:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519431584; bh=uVjJ+e0vphYmNA5CsKXTRgGJfo1/NXJlhngcLBErFbQ=; h=From:To:Cc:Subject:Date:From; b=c7svz/J3dQ6NNNUhgkDRYbMPOdCoIV2uuvbZDpo88H7libIR606kykmnxRpxbRzMq 4LgQEYO+DfW9Cd6m+LfwYa+CLFK60XvBlBtZOpJiiOfUni2EsSiM7e/Etc/BGaTopL 5fgCSbRH74LAlRRhwdkWkCgRXJzjD1+WzDz8/0rc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4837E602B6 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=skannan@codeaurora.org From: Saravana Kannan To: mark.rutland@arm.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim Cc: skannan@codeaurora.org, avilaj@codeaurora.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] perf/core: Add API to look up PMU type by name Date: Fri, 23 Feb 2018 16:19:37 -0800 Message-Id: <1519431578-11995-1-git-send-email-skannan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; +} + /** * perf_event_create_kernel_counter * -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project