All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: Marc Gonzalez <marc.w.gonzalez@free.fr>
Cc: Arnd Bergmann <arnd@arndb.de>, Will Deacon <will.deacon@arm.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Bjorn Helgaas <helgaas@kernel.org>
Subject: Re: [PATCH v1] iopoll: Tweak readx_poll_timeout sleep range
Date: Thu, 13 Jun 2019 09:11:56 -0700	[thread overview]
Message-ID: <CAD=FV=U+Ky1bAuAuuY+eBdTP9U3kbuH0tfwyN0Zs-iw0GNUFyQ@mail.gmail.com> (raw)
In-Reply-To: <a732f522-5e65-3ac4-de04-802ef5455747@free.fr>

Hi,

On Thu, Jun 13, 2019 at 9:04 AM Marc Gonzalez <marc.w.gonzalez@free.fr> wrote:
>
> On 13/06/2019 14:42, Arnd Bergmann wrote:
>
> > On Thu, Jun 13, 2019 at 2:16 PM Marc Gonzalez wrote:
> >
> >> Chopping max delay in 4 seems excessive. Let's just cut it in half.
> >>
> >> Signed-off-by: Marc Gonzalez <marc.w.gonzalez@free.fr>
> >> ---
> >> When max_us=100, old_min was 26 us; new_min would be 50 us
> >> Was there a good reason for the 1/4th?
> >> Is new_min=0 a problem? (for max=1)
> >
> > You normally want a large enough range between min and max. I don't
> > see anything wrong with a factor of four.
>
> Hmmm, I expect the typical use-case to be:
> "HW manual states operation X completes in 100 µs.
> Let's call usleep_range(100, foo); before hitting the reg."
>
> And foo needs to be a "reasonable" value: big enough to be able
> to merge several requests, low enough not to wait too long after
> the HW is ready.
>
> In this case, I'd say usleep_range(100, 200); makes sense.
>
> Come to think of it, I'm not sure min=26 (or min=50) makes sense...
> Why wait *less* than what the user specified?

IIRC usleep_range() nearly always tries to sleep for the max.  My
recollection of the design is that you only end up with something less
than the max if the system was going to wake up anyway.  In such a
case it seems like it wouldn't be insane to go and check if the
condition is already true if 25% of the time has passed.  Maybe you'll
get lucky and you can return early.

Are you actually seeing problems with the / 4, or is this patch just a
result of code inspection?

-Doug

WARNING: multiple messages have this Message-ID (diff)
From: Doug Anderson <dianders@chromium.org>
To: Marc Gonzalez <marc.w.gonzalez@free.fr>
Cc: Arnd Bergmann <arnd@arndb.de>, Will Deacon <will.deacon@arm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v1] iopoll: Tweak readx_poll_timeout sleep range
Date: Thu, 13 Jun 2019 09:11:56 -0700	[thread overview]
Message-ID: <CAD=FV=U+Ky1bAuAuuY+eBdTP9U3kbuH0tfwyN0Zs-iw0GNUFyQ@mail.gmail.com> (raw)
In-Reply-To: <a732f522-5e65-3ac4-de04-802ef5455747@free.fr>

Hi,

On Thu, Jun 13, 2019 at 9:04 AM Marc Gonzalez <marc.w.gonzalez@free.fr> wrote:
>
> On 13/06/2019 14:42, Arnd Bergmann wrote:
>
> > On Thu, Jun 13, 2019 at 2:16 PM Marc Gonzalez wrote:
> >
> >> Chopping max delay in 4 seems excessive. Let's just cut it in half.
> >>
> >> Signed-off-by: Marc Gonzalez <marc.w.gonzalez@free.fr>
> >> ---
> >> When max_us=100, old_min was 26 us; new_min would be 50 us
> >> Was there a good reason for the 1/4th?
> >> Is new_min=0 a problem? (for max=1)
> >
> > You normally want a large enough range between min and max. I don't
> > see anything wrong with a factor of four.
>
> Hmmm, I expect the typical use-case to be:
> "HW manual states operation X completes in 100 µs.
> Let's call usleep_range(100, foo); before hitting the reg."
>
> And foo needs to be a "reasonable" value: big enough to be able
> to merge several requests, low enough not to wait too long after
> the HW is ready.
>
> In this case, I'd say usleep_range(100, 200); makes sense.
>
> Come to think of it, I'm not sure min=26 (or min=50) makes sense...
> Why wait *less* than what the user specified?

IIRC usleep_range() nearly always tries to sleep for the max.  My
recollection of the design is that you only end up with something less
than the max if the system was going to wake up anyway.  In such a
case it seems like it wouldn't be insane to go and check if the
condition is already true if 25% of the time has passed.  Maybe you'll
get lucky and you can return early.

Are you actually seeing problems with the / 4, or is this patch just a
result of code inspection?

-Doug

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-06-13 16:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 12:16 [PATCH v1] iopoll: Tweak readx_poll_timeout sleep range Marc Gonzalez
2019-06-13 12:16 ` Marc Gonzalez
2019-06-13 12:42 ` Arnd Bergmann
2019-06-13 12:42   ` Arnd Bergmann
2019-06-13 16:04   ` Marc Gonzalez
2019-06-13 16:04     ` Marc Gonzalez
2019-06-13 16:11     ` Doug Anderson [this message]
2019-06-13 16:11       ` Doug Anderson
2019-06-13 16:36       ` Marc Gonzalez
2019-06-13 16:36         ` Marc Gonzalez
2019-06-13 17:10         ` Doug Anderson
2019-06-13 17:10           ` Doug Anderson

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='CAD=FV=U+Ky1bAuAuuY+eBdTP9U3kbuH0tfwyN0Zs-iw0GNUFyQ@mail.gmail.com' \
    --to=dianders@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bjorn.andersson@linaro.org \
    --cc=helgaas@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.w.gonzalez@free.fr \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=will.deacon@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.