Linux Power Management development
 help / color / mirror / Atom feed
From: "Zhang, Rui" <rui.zhang@intel.com>
To: "rafael@kernel.org" <rafael@kernel.org>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>
Subject: Re: [PATCH V2 2/3] powercap: intel_rapl: Introduce APIs for PMU support
Date: Mon, 22 Apr 2024 16:23:17 +0000	[thread overview]
Message-ID: <ea096c2ff7699beb3a9a2ad1742653dbbe12a0fc.camel@intel.com> (raw)
In-Reply-To: <0e345bdd91f90d1141e4114f55a8626fd0fad212.camel@intel.com>

> 
> > > +static void __rapl_pmu_event_start(struct perf_event *event)
> > > +{
> > > +       struct rapl_package_pmu_data *data =
> > > event_to_pmu_data(event);
> > > +
> > > +       if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))
> > > +               return;
> > > +
> > > +       event->hw.state = 0;
> > > +
> > > +       list_add_tail(&event->active_entry, &data->active_list);
> > > +
> > > +       local64_set(&event->hw.prev_count,
> > > event_read_counter(event));
> > > +       if (++data->n_active == 1)
> > > +               hrtimer_start(&data->hrtimer, data-
> > > >timer_interval,
> > > +                             HRTIMER_MODE_REL_PINNED);
> > > +}
> > > +
> > > +static void rapl_pmu_event_start(struct perf_event *event, int
> > > mode)
> > > +{
> > > +       struct rapl_package_pmu_data *data =
> > > event_to_pmu_data(event);
> > > +       unsigned long flags;
> > > +
> > > +       raw_spin_lock_irqsave(&data->lock, flags);
> > > +       __rapl_pmu_event_start(event);
> > > +       raw_spin_unlock_irqrestore(&data->lock, flags);
> > 
> > Why does it need to be raw_spin_lock_?
> > 
> > What exactly is protected by data->lock?
> > 
> This is copied from MSR RAPL PMU, which exists from day 1 of the
> code.
> 
> Let me double check.
> 


RAPL Package supports multiple events, and rapl_pmu_event_start(),
rapl_pmu_event_add() and rapl_pmu_event_stop() can be invoked for each
event.

And this lock is used to protect the per package data->active_list and
data->n_active from concurrent access.

And we need to do this in the hrtimer handler (rapl_hrtimer_handle()).

Thanks for reviewing and patch V3 has been updated and submitted.

thanks,
rui



  reply	other threads:[~2024-04-22 16:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08  3:51 [PATCH V2 0/3] powercap: Introduce TPMI RAPL PMU support Zhang Rui
2024-04-08  3:51 ` [PATCH V2 1/3] powercap: intel_rapl: Sort header files Zhang Rui
2024-04-16 14:01   ` Rafael J. Wysocki
2024-04-17  1:57     ` Zhang, Rui
2024-04-17  8:34       ` Rafael J. Wysocki
2024-04-08  3:51 ` [PATCH V2 2/3] powercap: intel_rapl: Introduce APIs for PMU support Zhang Rui
2024-04-16 13:58   ` Rafael J. Wysocki
2024-04-17  5:26     ` Zhang, Rui
2024-04-22 16:23       ` Zhang, Rui [this message]
2024-04-08  3:51 ` [PATCH V2 3/3] powercap: intel_rapl_tpmi: Enable " Zhang Rui

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=ea096c2ff7699beb3a9a2ad1742653dbbe12a0fc.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=srinivas.pandruvada@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