linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com,
	mingo@redhat.com, acme@kernel.org, gavin.hindman@intel.com,
	jithu.joseph@intel.com, dave.hansen@intel.com, hpa@zytor.com,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 2/6] perf/core: Add helper to obtain performance counter index
Date: Tue, 18 Sep 2018 10:54:28 -0700	[thread overview]
Message-ID: <07d81d39-6f78-7a07-099c-883c65b540e6@intel.com> (raw)
In-Reply-To: <20180917230758.GA3117@worktop.programming.kicks-ass.net>

Hi Peter,

On 9/17/2018 4:07 PM, Peter Zijlstra wrote:
> On Mon, Sep 17, 2018 at 09:37:14AM -0700, Reinette Chatre wrote:
>> On 9/17/2018 1:23 AM, Peter Zijlstra wrote:
> 
>>> I said arch/x86/include/asm/perf_events.h and call it:
>>> x86_perf_rdpmc_index().
>>>
>>> This function is very much x86 specific.
> 
>> Moving it to arch/x86/include/asm/perf_event.h is not trivial since this
>> file is not familiar with struct perf_event.
> 
> Urgh, right you are. Does it work if you make it a regular function
> instead of an inline? Put the thing in arch/x86/events/core.c or so and
> only an extern decl in asm/perf_event.h.

It works, but checkpatch.pl does not like it very much:
> CHECK: extern prototypes should be avoided in .h files
> #66: FILE: arch/x86/include/asm/perf_event.h:273:
> +extern int x86_perf_rdpmc_index(struct perf_event *event);

Doing this also prevents the availability of a x86_perf_rdpmc_index()
for when !CONFIG_PERF_EVENTS. I do not know if this is of big concern
since CONFIG_PERF_EVENTS is automatically selected by CONFIG_X86 ... but
at the same time there are other function definitions in
arch/x86/include/asm/perf_event.h for when !CONFIG_PERF_EVENTS.

Considering the above, would you like me to continue with the move to
arch/x86/events/core.c? Here is what I understood your suggestion to mean:

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index dfb2f7c0d019..3550d800b030 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1033,6 +1033,27 @@ static inline void x86_assign_hw_event(struct
perf_event *event,
        }
 }

+/**
+ * x86_perf_rdpmc_index - Return PMC counter used for event
+ * @event: the perf_event to which the PMC counter was assigned
+ *
+ * The counter assigned to this performance event may change if interrupts
+ * are enabled. This counter should thus never be used while interrupts are
+ * enabled. Before this function is used to obtain the assigned counter the
+ * event should be checked for validity using, for example,
+ * perf_event_read_local(), within the same interrupt disabled section in
+ * which this counter is planned to be used.
+ *
+ * Return: The index of the performance monitoring counter assigned to
+ * @perf_event.
+ */
+int x86_perf_rdpmc_index(struct perf_event *event)
+{
+       lockdep_assert_irqs_disabled();
+
+       return event->hw.event_base_rdpmc;
+}
+
 static inline int match_prev_assignment(struct hw_perf_event *hwc,
                                        struct cpu_hw_events *cpuc,
                                        int i)
diff --git a/arch/x86/include/asm/perf_event.h
b/arch/x86/include/asm/perf_event.h
index 12f54082f4c8..b2cf84c35a6d 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -270,6 +270,7 @@ struct perf_guest_switch_msr {
 extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
 extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap);
 extern void perf_check_microcode(void);
+extern int x86_perf_rdpmc_index(struct perf_event *event);
 #else
 static inline struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
 {

Thank you

Reinette

  reply	other threads:[~2018-09-18 17:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 17:14 [PATCH V3 0/6] perf/core and x86/intel_rdt: Fix lack of coordination with perf Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 1/6] perf/core: Add sanity check to deal with pinned event failure Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 2/6] perf/core: Add helper to obtain performance counter index Reinette Chatre
2018-09-17  8:23   ` Peter Zijlstra
2018-09-17 16:37     ` Reinette Chatre
2018-09-17 23:07       ` Peter Zijlstra
2018-09-18 17:54         ` Reinette Chatre [this message]
2018-09-19  9:17           ` Peter Zijlstra
2018-09-11 17:14 ` [PATCH V3 3/6] x86/intel_rdt: Remove local register variables Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 4/6] x86/intel_rdt: Create required perf event attributes Reinette Chatre
2018-09-12  5:49   ` kbuild test robot
2018-09-12  7:20   ` kbuild test robot
2018-09-12 19:54   ` [PATCH V4 " Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 5/6] x86/intel_rdt: Use perf infrastructure for measurements Reinette Chatre
2018-09-17  8:58   ` Peter Zijlstra
2018-09-17 16:54     ` Reinette Chatre
2018-09-11 17:14 ` [PATCH V3 6/6] x86/intel_rdt: Re-enable pseudo-lock measurements Reinette Chatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07d81d39-6f78-7a07-099c-883c65b540e6@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=acme@kernel.org \
    --cc=dave.hansen@intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=gavin.hindman@intel.com \
    --cc=hpa@zytor.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).