Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp854imm; Tue, 31 Jul 2018 12:40:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNG3d9bNm9zWT1PdqcT4/ZSzAIbXLP0qVBJAuWn45u+Sk/UXhSPzKxHmk4pnjBeEs+7TA6 X-Received: by 2002:a62:2646:: with SMTP id m67-v6mr23861018pfm.254.1533066018133; Tue, 31 Jul 2018 12:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533066018; cv=none; d=google.com; s=arc-20160816; b=MzvLr5FVku4JEfAjoQKYnUxhQBcglsnZaebzTwaTkrqHFtMeXrBovuCWKla/6StTGs jw40x2rrkh33dNVSky/SXUhA6z7fIzjxkqCYtD0zioT0Kex5qF2uhd5FQGLzNl0PR8xK r8pnWG2UJseOSzn/2hkTHR4IHcODMg0CwkGf2369FBCdM8AuMl5S1Z7+uyA2Vgo8/RTt l1dDOmkrRB8c4c6eIeOj+TG9Fz/l2SeRmauuuCH1iVj0McNnuSHaPfApCVenLsN8HpnX yYt8traRbN84N/g+O3Z5C+VQplAgi21jQCgHmb7Y7Yy+c/K4xrO9pxndanbZM6mngZmY Td2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4sz+1Zgf71d3dXds//PRuBv232oDROFoYCTCLpMn6zA=; b=o4U7yhT+W9XYXSJ83rIh2+cVaIZCQJgPWgM02HS/LWhVc+bIw8rXdjFU/ZpBQVvav6 rePKAvt934uGcI8Qd/M48KoIGVB2E4Rfn8cODoNuDHEilryhxGqmKNv5b+/uXv7+jdlE ge0OFUDK4scwh8dsTEf1ZruVwhv75P7CgByCVMcENAXPbcr5jtUZgiQFZ0GiVJqOmfVC y5IbOZ9kmSAtAAXJIBEktTKLY+VF2dWzZJ0cKwgXvxDgj+1Xyu727KnYJXfit527a7pw VXFVYs0JALC9ym9ejbxbg43rvUNWoiowxgJR1kcj1N9rbVXQp6uwLKpX15+gIblTvfbo XMJQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si14141649pfo.54.2018.07.31.12.39.58; Tue, 31 Jul 2018 12:40:18 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732373AbeGaVUe (ORCPT + 99 others); Tue, 31 Jul 2018 17:20:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:3846 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732322AbeGaVUd (ORCPT ); Tue, 31 Jul 2018 17:20:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2018 12:38:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,428,1526367600"; d="scan'208";a="77594081" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga001.jf.intel.com with ESMTP; 31 Jul 2018 12:38:43 -0700 From: Reinette Chatre To: tglx@linutronix.de, mingo@redhat.com, fenghua.yu@intel.com, tony.luck@intel.com, vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH 1/2] perf/x86: Expose PMC hardware reservation Date: Tue, 31 Jul 2018 12:38:28 -0700 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When multiple users need to use performance counters a reservation mechanism is required to ensure coordination. This reservation mechanism already exists and any user can currently reserve/release a single performance counter and/or its matching event configuration via the exported symbols reserve_perfctr_nmi() and reserve_evntsel_nmi() (and their matching release functions). These reservation functions take as parameter a single performance counter or event configuration register at a time and they are typically called in a loop where they are called for every counter on the system. The current users of these exported symbols are oprofile and the x86 events system that each use wrappers to these exported symbols as a way to reserve the entire pmc system - calling a reserve of each counter and its configuration registers. A user wanting to use x86 PMC hardware can currently do so by duplicating the x86 PMC hardware reservation by creating a new wrapper for the exported reserve_perfctr_nmi() and reserve_evntsel_nmi() functions. This duplication is not desirable and thus the current wrapping x86 pmc reservation routine itself (reserve_pmc_hardware()) and matching release function (release_pmc_hardware()) are exported for users needing to coordinate use of PMC hardware. Signed-off-by: Reinette Chatre --- arch/x86/events/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 5f4829f10129..e883a0a11f53 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -144,7 +144,7 @@ static DEFINE_MUTEX(pmc_reserve_mutex); #ifdef CONFIG_X86_LOCAL_APIC -static bool reserve_pmc_hardware(void) +bool reserve_pmc_hardware(void) { int i; @@ -173,7 +173,7 @@ static bool reserve_pmc_hardware(void) return false; } -static void release_pmc_hardware(void) +void release_pmc_hardware(void) { int i; @@ -189,6 +189,8 @@ static bool reserve_pmc_hardware(void) { return true; } static void release_pmc_hardware(void) {} #endif +EXPORT_SYMBOL(reserve_pmc_hardware); +EXPORT_SYMBOL(release_pmc_hardware); static bool check_hw_exists(void) { -- 2.17.0