From: "Zanoni, Paulo R" <paulo.r.zanoni@intel.com>
To: "intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"chris@chris-wilson.co.uk" <chris@chris-wilson.co.uk>
Cc: "daniel.vetter@ffwll.ch" <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH] drm/i915: Only expand COND once in wait_for()
Date: Tue, 13 Sep 2016 21:05:12 +0000 [thread overview]
Message-ID: <1473800707.2435.89.camel@intel.com> (raw)
In-Reply-To: <20160913194019.28541-1-chris@chris-wilson.co.uk>
Em Ter, 2016-09-13 às 20:40 +0100, Chris Wilson escreveu:
> I was looking at some wait_for() timeouts on a slow system, with lots
> of
> debug enabled (KASAN, lockdep, mmio_debug). Thinking that we were
> mishandling the timeout, I tried to ensure that we loop at least once
> after first testing COND. However, the double test of COND either
> side
> of the timeout check makes that unlikely. But we can do an equivalent
> loop, that keeps the COND check after testing for timeout (required
> so
> that we are not preempted between testing COND and then testing for a
> timeout) without expanding COND twice.
>
> The advantage of only expanding COND once is a dramatic reduction in
> code size:
>
> text data bss dec hex
> 1308733 5184 1152 1315069 1410fd
> before
> 1305341 5184 1152 1311677 1403bd
> after
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/i915/intel_drv.h | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_drv.h
> b/drivers/gpu/drm/i915/intel_drv.h
> index cb99a2540863..597899d71df9 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -52,13 +52,16 @@
> */
> #define _wait_for(COND, US, W) ({ \
> unsigned long timeout__ = jiffies + usecs_to_jiffies(US) +
> 1; \
> - int ret__ = 0;
> \
> - while (!(COND)) {
> \
> - if (time_after(jiffies, timeout__)) {
> \
> - if (!(COND))
> \
> - ret__ = -ETIMEDOUT;
> \
> + int ret__;
ret__ starts "uninitialized".
> \
> + for (;;) {
> \
> + if (time_after(jiffies, timeout__))
> \
> + ret__ = -ETIMEDOUT;
If we didn't hit the timeout, it's still "uninitialized".
> \
> + if (COND) {
> \
> + ret__ = 0;
If the condition was not met, it's still "uninitialized".
> \
> break;
> \
> }
> \
> + if (ret__)
But we read its "uninitialized" value here.
But why isn't the compiler complaining about this? Am I failing to see
something here?
If my analysis is correct, all you need to do is to keep ret__ being
initialized to zero. At least for clarity of the future code readers in
case it's expected to be auto-initialized to zero due to some weird
rule about compound statements or something.
With the ret__ initialization to zero:
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> \
> + break;
> \
> if ((W) && drm_can_sleep()) {
> \
> usleep_range((W), (W)*2);
> \
> } else {
> \
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-09-13 21:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 19:40 [PATCH] drm/i915: Only expand COND once in wait_for() Chris Wilson
2016-09-13 21:05 ` Zanoni, Paulo R [this message]
2016-09-14 5:37 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-09-14 9:22 ` [PATCH] " Chris Wilson
2016-09-14 12:10 ` Dave Gordon
2016-09-14 18:53 ` Paulo Zanoni
2016-09-15 9:50 ` Chris Wilson
2016-09-14 13:37 ` Zanoni, Paulo R
2016-09-14 12:49 ` ✗ Fi.CI.BAT: failure for drm/i915: Only expand COND once in wait_for() (rev2) Patchwork
2016-09-15 7:20 ` ✓ Fi.CI.BAT: success " Patchwork
2016-09-19 1:40 ` [drm/i915] c19d736b05: WARNING: CPU: 0 PID: 236 at drivers/gpu/drm/i915/intel_display.c:1085 intel_disable_pipe+0x157/0x250 [i915] kernel test robot
2016-09-19 1:40 ` [lkp] " kernel test robot
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=1473800707.2435.89.camel@intel.com \
--to=paulo.r.zanoni@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.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 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.