From: Megha Dey <megha.dey@intel.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com,
hpa@zytor.com, andriy.shevchenko@linux.intel.com,
kstewart@linuxfoundation.org, yu-cheng.yu@intel.com,
len.brown@intel.com, gregkh@linuxfoundation.org,
peterz@infradead.org, acme@kernel.org, jolsa@redhat.com,
namhyung@kernel.org, vikas.shivappa@linux.intel.com,
pombredanne@nexb.com, me@kylehuey.com, bp@suse.de,
grzegorz.andrejczuk@intel.com, tony.luck@intel.com,
corbet@lwn.net, ravi.v.shankar@intel.com
Subject: Re: [PATCH V0 2/3] perf/x86/intel/bm.c: Add Intel Branch Monitoring support
Date: Fri, 10 Nov 2017 15:36:03 -0800 [thread overview]
Message-ID: <1510356963.2515.5.camel@megha-Z97X-UD7-TH> (raw)
In-Reply-To: <20171106114943.mg6pwpqe6eqlx7w2@ukko.fi.intel.com>
On Mon, 2017-11-06 at 13:49 +0200, Alexander Shishkin wrote:
> On Fri, Nov 03, 2017 at 11:00:05AM -0700, Megha Dey wrote:
> > +static int intel_bm_event_init(struct perf_event *event)
> > +{
>
> ...
>
> > + /*
> > + * Find a hardware counter for the target task
> > + */
> > + for (i = 0; i < bm_num_counters; i++) {
> > + if ((bm_counter_owner[i] == NULL) ||
> > + (bm_counter_owner[i]->state == PERF_EVENT_STATE_DEAD)) {
> > + counter_to_use = i;
> > + bm_counter_owner[i] = event;
> > + break;
>
> How are two concurrent perf_event_open()s not going to race here?
> Also, I'm not sure what's the value of looking at the ->state here.
> Shouldn't the ->destroy() method clear the corresponding array slot?
Yes you are right. I will add a locking mechanism here to prevent racing
and remove the ->state in the next version.
>
> > + }
> > + }
>
> ...
>
> > + wrmsrl(BR_DETECT_COUNTER_CONFIG_BASE + counter_to_use,
> > + event->hw.bm_counter_conf);
> > + wrmsrl(BR_DETECT_STATUS_MSR, 0);
>
> These wrmsrs will happen on whatever CPU perf_event_open() is called on,
> as opposed to the CPU where the event will be scheduled. You probably want
> to keep the MSR accesses in the start()/stop() callbacks.
Agreed, don't think we need this code here. We are writing to the MSRs
in start() anyways.
>
> Regards,
> --
> Alex
>
next prev parent reply other threads:[~2017-11-10 23:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 18:00 [PATCH V0 0/3] perf/x86/intel: Add " Megha Dey
2017-11-03 18:00 ` [PATCH V0 1/3] x86/cpu/intel: Add Cannonlake to Intel family Megha Dey
2017-11-03 18:00 ` [PATCH V0 2/3] perf/x86/intel/bm.c: Add Intel Branch Monitoring support Megha Dey
2017-11-04 13:24 ` Jiri Olsa
2017-11-11 0:42 ` Dey, Megha
2017-11-04 13:25 ` Jiri Olsa
2017-11-11 0:44 ` Dey, Megha
2017-11-04 13:25 ` Jiri Olsa
2017-11-04 13:25 ` Jiri Olsa
2017-11-11 0:50 ` Dey, Megha
2017-11-04 13:26 ` Jiri Olsa
2017-11-11 0:53 ` Dey, Megha
2017-11-04 13:26 ` Jiri Olsa
[not found] ` <20171106114943.mg6pwpqe6eqlx7w2@ukko.fi.intel.com>
2017-11-10 23:36 ` Megha Dey [this message]
2017-11-03 18:00 ` [PATCH V0 3/3] x86, bm: Add documentation on Intel Branch Monitoring Megha Dey
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=1510356963.2515.5.camel@megha-Z97X-UD7-TH \
--to=megha.dey@intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bp@suse.de \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=grzegorz.andrejczuk@intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=kstewart@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kylehuey.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=pombredanne@nexb.com \
--cc=ravi.v.shankar@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vikas.shivappa@linux.intel.com \
--cc=x86@kernel.org \
--cc=yu-cheng.yu@intel.com \
/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
all inboxes | Powered by JetHome®