mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Kevin Hilman <khilman@kernel.org>,
	 Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] base: power: domain: Replace mdelay with msleep
Date: Mon, 12 Feb 2018 11:38:13 +0100	[thread overview]
Message-ID: <1518431893.2744.1.camel@pengutronix.de> (raw)
In-Reply-To: <CAPDyKFoft7aCoKtODz66AAjpDQELVhqGurFYBV6FHP9hzhy-Ug@mail.gmail.com>

Am Freitag, den 09.02.2018, 14:58 +0100 schrieb Ulf Hansson:
> On 26 January 2018 at 09:38, Jia-Ju Bai <baijiaju1990@gmail.com>
> wrote:
> > After checking all possible call chains to genpd_dev_pm_detach()
> > and
> > genpd_dev_pm_attach() here,
> > my tool finds that these functions are never called in atomic
> > context,
> > namely never in an interrupt handler or holding a spinlock.
> > Thus mdelay can be replaced with msleep to avoid busy wait.
> > 
> > This is found by a static analysis tool named DCNS written by
> > myself.
> > 
> > Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> > ---
> >  drivers/base/power/domain.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/base/power/domain.c
> > b/drivers/base/power/domain.c
> > index 0c80bea..f84ac72 100644
> > --- a/drivers/base/power/domain.c
> > +++ b/drivers/base/power/domain.c
> > @@ -2144,7 +2144,7 @@ static void genpd_dev_pm_detach(struct device
> > *dev, bool power_off)
> >                 if (ret != -EAGAIN)
> >                         break;
> > 
> > -               mdelay(i);
> > +               msleep(i);
> 
> This looks like a nice improvement, however moving to msleep() makes
> the call to cond_resched() below a bit superfluous. Perhaps remove
> that as well.

At least for small values of i, msleep also has a high chance to
overshoot the desired sleep by a lot. It would be better to convert
them to usleep_range with an acceptable slack.

Regards,
Lucas

> >                 cond_resched();
> >         }
> > 
> > @@ -2231,7 +2231,7 @@ int genpd_dev_pm_attach(struct device *dev)
> >                 if (ret != -EAGAIN)
> >                         break;
> > 
> > -               mdelay(i);
> > +               msleep(i);
> 
> Ditto.
> 
> >                 cond_resched();
> >         }
> >         mutex_unlock(&gpd_list_lock);
> > --
> > 1.7.9.5
> > 
> 
> Kind regards
> Uffe

  reply	other threads:[~2018-02-12 10:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26  8:38 Jia-Ju Bai
2018-01-26 10:26 ` Pavel Machek
2018-01-26 10:28   ` Jia-Ju Bai
2018-02-09 11:56 ` Rafael J. Wysocki
2018-02-09 13:58 ` Ulf Hansson
2018-02-12 10:38   ` Lucas Stach [this message]
2018-02-12 12:40     ` Ulf Hansson

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=1518431893.2744.1.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=baijiaju1990@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@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

all inboxes | Powered by JetHome®