linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Lukasz Luba <lukasz.luba@arm.com>
Cc: Nishanth Menon <nm@ti.com>, Juri Lelli <juri.lelli@redhat.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Liviu Dudau <liviu.dudau@arm.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Benjamin Segall <bsegall@google.com>,
	alyssa.rosenzweig@collabora.com,
	Fabio Estevam <festevam@gmail.com>,
	Matthias Kaehlcke <mka@chromium.org>,
	Rob Herring <robh@kernel.org>,
	Amit Kucheria <amit.kucheria@verdurent.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Kevin Hilman <khilman@kernel.org>, Andy Gross <agross@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	steven.price@arm.com, Chanwoo Choi <cw00.choi@samsung.com>,
	Ingo Molnar <mingo@redhat.com>, dl-linux-imx <linux-imx@nxp.com>,
	"Zhang, Rui" <rui.zhang@intel.com>, Mel Gorman <mgorman@suse.de>,
	orjan.eide@arm.com, Daniel Vetter <daniel@ffwll.ch>,
	Linux PM <linux-pm@vger.kernel.org>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	"moderated list:ARM/Mediatek SoC..."
	<linux-mediatek@lists.infradead.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	Dietmar Eggemann <Dietmar.Eggemann@arm.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	David Airlie <airlied@linux.ie>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Quentin Perret <qperret@google.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Sascha Hauer <kernel@pengutronix.de>,
	Sudeep Holla <sudeep.holla@arm.com>,
	patrick.bellasi@matbug.net, Shawn Guo <shawnguo@kernel.org>
Subject: Re: [PATCH v8 4/8] PM / EM: add support for other devices than CPUs in Energy Model
Date: Wed, 3 Jun 2020 17:40:34 +0200	[thread overview]
Message-ID: <CAJZ5v0iDNH7tZmKsYgW1xp-g3WmOod+Wo-AzJmszXuv_wztwwA@mail.gmail.com> (raw)
In-Reply-To: <d6a0d345-53ef-523c-836d-3bc4ea4c6e66@arm.com>

On Wed, Jun 3, 2020 at 5:26 PM Lukasz Luba <lukasz.luba@arm.com> wrote:
>
>
>
> On 6/3/20 4:13 PM, Rafael J. Wysocki wrote:
> > On Tue, Jun 2, 2020 at 1:31 PM Lukasz Luba <lukasz.luba@arm.com> wrote:
> >>
> >> Hi Daniel,
> >>
> >> On 6/1/20 10:44 PM, Daniel Lezcano wrote:
> >>> On 27/05/2020 11:58, Lukasz Luba wrote:
> >>>> Add support for other devices than CPUs. The registration function
> >>>> does not require a valid cpumask pointer and is ready to handle new
> >>>> devices. Some of the internal structures has been reorganized in order to
> >>>> keep consistent view (like removing per_cpu pd pointers).
> >>>>
> >>>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> >>>> ---
> >>>
> >>> [ ... ]
> >>>
> >>>>    }
> >>>>    EXPORT_SYMBOL_GPL(em_register_perf_domain);
> >>>> +
> >>>> +/**
> >>>> + * em_dev_unregister_perf_domain() - Unregister Energy Model (EM) for a device
> >>>> + * @dev             : Device for which the EM is registered
> >>>> + *
> >>>> + * Try to unregister the EM for the specified device (but not a CPU).
> >>>> + */
> >>>> +void em_dev_unregister_perf_domain(struct device *dev)
> >>>> +{
> >>>> +    if (IS_ERR_OR_NULL(dev) || !dev->em_pd)
> >>>> +            return;
> >>>> +
> >>>> +    if (_is_cpu_device(dev))
> >>>> +            return;
> >>>> +
> >>>> +    mutex_lock(&em_pd_mutex);
> >>>
> >>> Is the mutex really needed?
> >>
> >> I just wanted to align this unregister code with register. Since there
> >> is debugfs dir lookup and the device's EM existence checks I thought it
> >> wouldn't harm just to lock for a while and make sure the registration
> >> path is not used. These two paths shouldn't affect each other, but with
> >> modules loading/unloading I wanted to play safe.
> >>
> >> I can change it maybe to just dmb() and the end of the function if it's
> >> a big performance problem in this unloading path. What do you think?
> >
> > I would rather leave the mutex locking as is.
> >
> > However, the question to ask is what exactly may go wrong without that
> > locking in place?  Is there any specific race condition that you are
> > concerned about?
> >
>
> I tried to test this with module loading & unloading with panfrost
> driver and CPU hotplug (which should bail out quickly) and was OK.
> I don't see any particular race. I don't too much about the
> debugfs code, though. That's why I tried to protect from some
> scripts/services which try to re-load the driver.
>
> Apart from that, maybe just this dev->em = NULL to be populated to all
> CPUs, which mutex_unlock synchronizes for free here.

If it may run concurrently with the registration for the same device,
the locking is necessary, but in that case the !dev->em_pd check needs
to go under the mutex too IMO, or you may end up leaking the pd if the
registration can run between that check and the point at which the
mutex is taken.

Apart from this your kerneldoc comments might me improved IMO.

First of all, you can use @dev inside of a kerneldoc (if @dev
represents an argument of the documented function) and that will
produce the right output automatically.

Second, it is better to avoid saying things like "Try to unregister
..." in kerneldoc comments (the "Try to" part is redundant).  Simply
say "Unregister ..." instead.

Thanks!

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

  reply	other threads:[~2020-06-03 15:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  9:58 [PATCH v8 0/8] Add support for devices in the Energy Model Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 1/8] PM / EM: change naming convention from 'capacity' to 'performance' Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 2/8] PM / EM: introduce em_dev_register_perf_domain function Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 3/8] PM / EM: update callback structure and add device pointer Lukasz Luba
2020-05-29 17:43   ` Daniel Lezcano
2020-06-01  9:20     ` Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 4/8] PM / EM: add support for other devices than CPUs in Energy Model Lukasz Luba
2020-06-01 21:44   ` Daniel Lezcano
2020-06-02 11:31     ` Lukasz Luba
2020-06-03 15:13       ` Rafael J. Wysocki
2020-06-03 15:25         ` Lukasz Luba
2020-06-03 15:40           ` Rafael J. Wysocki [this message]
2020-06-03 16:12             ` Lukasz Luba
2020-06-03 16:22               ` Rafael J. Wysocki
2020-06-03 16:45                 ` Lukasz Luba
2020-06-08 11:51   ` Dan Carpenter
2020-06-08 12:34     ` Lukasz Luba
2020-06-08 12:51       ` Dan Carpenter
2020-06-08 12:59         ` Lukasz Luba
2020-06-08 13:25           ` Dan Carpenter
2020-06-08 13:49             ` Lukasz Luba
2020-06-10 10:12   ` [RESEND][PATCH " Lukasz Luba
2020-06-24 15:21     ` Rafael J. Wysocki
2020-06-24 15:29       ` Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 5/8] PM / EM: remove em_register_perf_domain Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 6/8] PM / EM: change name of em_pd_energy to em_cpu_energy Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 7/8] Documentation: power: update Energy Model description Lukasz Luba
2020-05-27  9:58 ` [PATCH v8 8/8] OPP: refactor dev_pm_opp_of_register_em() and update related drivers Lukasz Luba
2020-05-29 15:00 ` [PATCH v8 0/8] Add support for devices in the Energy Model Lukasz Luba
2020-05-29 16:18   ` Rafael J. Wysocki
2020-05-29 17:05     ` Lukasz Luba
2020-06-17  9:17     ` Lukasz Luba

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=CAJZ5v0iDNH7tZmKsYgW1xp-g3WmOod+Wo-AzJmszXuv_wztwwA@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=Dietmar.Eggemann@arm.com \
    --cc=agross@kernel.org \
    --cc=airlied@linux.ie \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=amit.kucheria@verdurent.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=bsegall@google.com \
    --cc=cw00.choi@samsung.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel@pengutronix.de \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lukasz.luba@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=mka@chromium.org \
    --cc=nm@ti.com \
    --cc=orjan.eide@arm.com \
    --cc=patrick.bellasi@matbug.net \
    --cc=peterz@infradead.org \
    --cc=qperret@google.com \
    --cc=rdunlap@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=robh@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rui.zhang@intel.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=steven.price@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=tomeu.vizoso@collabora.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.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).