linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Nathan Chancellor <natechancellor@gmail.com>,
	David Airlie <airlied@linux.ie>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/scheduler: Simplify spsc_queue_count check in drm_sched_entity_select_rq
Date: Tue, 2 Oct 2018 14:56:49 +0000	[thread overview]
Message-ID: <7c5cbc38-f052-7f0f-d13e-6a7ce2ea80ba@amd.com> (raw)
In-Reply-To: <20181002064124.25881-1-natechancellor@gmail.com>

Am 02.10.2018 um 08:41 schrieb Nathan Chancellor:
> Clang generates a warning when it sees a logical not followed by a
> conditional operator like ==, >, or <.
>
> drivers/gpu/drm/scheduler/sched_entity.c:470:6: warning: logical not is
> only applied to the left hand side of this comparison
> [-Wlogical-not-parentheses]
>          if (!spsc_queue_count(&entity->job_queue) == 0 ||
>              ^                                     ~~
> drivers/gpu/drm/scheduler/sched_entity.c:470:6: note: add parentheses
> after the '!' to evaluate the comparison first
>          if (!spsc_queue_count(&entity->job_queue) == 0 ||
>              ^
>               (                                        )
> drivers/gpu/drm/scheduler/sched_entity.c:470:6: note: add parentheses
> around left hand side expression to silence this warning
>          if (!spsc_queue_count(&entity->job_queue) == 0 ||
>              ^
>              (                                    )
> 1 warning generated.
>
> It assumes the author might have made a mistake in their logic:
>
> if (!a == b) -> if (!(a == b))
>
> Sometimes that is the case; other times, it's just a super convoluted
> way of saying 'if (a)' when b = 0:
>
> if (!1 == 0) -> if (0 == 0) -> if (true)
>
> Alternatively:
>
> if (!1 == 0) -> if (!!1) -> if (1)
>
> Simplify this comparison so that Clang doesn't complain.
>
> Fixes: 35e160e781a0 ("drm/scheduler: change entities rq even earlier")
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

Going to pick that up for pushing upstream as well.

Thanks,
Christian.

> ---
>   drivers/gpu/drm/scheduler/sched_entity.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index 4e5e95c0cab5..3e22a54a99c2 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -467,8 +467,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
>   	struct dma_fence *fence;
>   	struct drm_sched_rq *rq;
>   
> -	if (!spsc_queue_count(&entity->job_queue) == 0 ||
> -	    entity->num_rq_list <= 1)
> +	if (spsc_queue_count(&entity->job_queue) || entity->num_rq_list <= 1)
>   		return;
>   
>   	fence = READ_ONCE(entity->last_scheduled);


      reply	other threads:[~2018-10-02 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02  6:41 [PATCH] drm/scheduler: Simplify spsc_queue_count check in drm_sched_entity_select_rq Nathan Chancellor
2018-10-02 14:56 ` Koenig, Christian [this message]

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=7c5cbc38-f052-7f0f-d13e-6a7ce2ea80ba@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.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;
as well as URLs for NNTP newsgroup(s).