public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] RDMA/rxe: Rewrite rxe_task.c
@ 2023-03-29  6:27 Dan Carpenter
  2023-03-29  6:48 ` Dan Carpenter
  2023-03-29 18:22 ` Leon Romanovsky
  0 siblings, 2 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-03-29  6:27 UTC (permalink / raw)
  To: rpearsonhpe; +Cc: linux-rdma

Hello Bob Pearson,

The patch d94671632572: "RDMA/rxe: Rewrite rxe_task.c" from Mar 4,
2023, leads to the following Smatch static checker warning:

	drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
	warn: bitwise AND condition is false here

drivers/infiniband/sw/rxe/rxe_task.c
    20 static bool __reserve_if_idle(struct rxe_task *task)
    21 {
    22         WARN_ON(rxe_read(task->qp) <= 0);
    23 
--> 24         if (task->tasklet.state & TASKLET_STATE_SCHED)
                                         ^^^^^^^^^^^^^^^^^^^
This is zero.  Should the check be == TASKLET_STATE_SCHED?

    25                 return false;
    26 
    27         if (task->state == TASK_STATE_IDLE) {
    28                 rxe_get(task->qp);
    29                 task->state = TASK_STATE_BUSY;
    30                 task->num_sched++;
    31                 return true;
    32         }
    33 
    34         if (task->state == TASK_STATE_BUSY)
    35                 task->state = TASK_STATE_ARMED;
    36 
    37         return false;
    38 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug report] RDMA/rxe: Rewrite rxe_task.c
  2023-03-29  6:27 [bug report] RDMA/rxe: Rewrite rxe_task.c Dan Carpenter
@ 2023-03-29  6:48 ` Dan Carpenter
  2023-03-29 19:09   ` Bob Pearson
  2023-03-29 18:22 ` Leon Romanovsky
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2023-03-29  6:48 UTC (permalink / raw)
  To: rpearsonhpe; +Cc: linux-rdma

On Wed, Mar 29, 2023 at 09:27:26AM +0300, Dan Carpenter wrote:
> Hello Bob Pearson,
> 
> The patch d94671632572: "RDMA/rxe: Rewrite rxe_task.c" from Mar 4,
> 2023, leads to the following Smatch static checker warning:
> 
> 	drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
> 	warn: bitwise AND condition is false here
> 
> drivers/infiniband/sw/rxe/rxe_task.c
>     20 static bool __reserve_if_idle(struct rxe_task *task)
>     21 {
>     22         WARN_ON(rxe_read(task->qp) <= 0);
>     23 
> --> 24         if (task->tasklet.state & TASKLET_STATE_SCHED)
>                                          ^^^^^^^^^^^^^^^^^^^
> This is zero.  Should the check be == TASKLET_STATE_SCHED?
> 

The next function as well.

drivers/infiniband/sw/rxe/rxe_task.c:49 __is_done() warn: bitwise AND condition is false here

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug report] RDMA/rxe: Rewrite rxe_task.c
  2023-03-29  6:27 [bug report] RDMA/rxe: Rewrite rxe_task.c Dan Carpenter
  2023-03-29  6:48 ` Dan Carpenter
@ 2023-03-29 18:22 ` Leon Romanovsky
  1 sibling, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2023-03-29 18:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: rpearsonhpe, linux-rdma

On Wed, Mar 29, 2023 at 09:27:26AM +0300, Dan Carpenter wrote:
> Hello Bob Pearson,
> 
> The patch d94671632572: "RDMA/rxe: Rewrite rxe_task.c" from Mar 4,
> 2023, leads to the following Smatch static checker warning:
> 
> 	drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
> 	warn: bitwise AND condition is false here

Fix:
https://lore.kernel.org/all/1a6376525c40454282a14ab659de0b17b02fe523.1680113901.git.leon@kernel.org

Thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug report] RDMA/rxe: Rewrite rxe_task.c
  2023-03-29  6:48 ` Dan Carpenter
@ 2023-03-29 19:09   ` Bob Pearson
  2023-03-29 19:17     ` Leon Romanovsky
  2023-03-30  4:06     ` Dan Carpenter
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Pearson @ 2023-03-29 19:09 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-rdma

On 3/29/23 01:48, Dan Carpenter wrote:
> On Wed, Mar 29, 2023 at 09:27:26AM +0300, Dan Carpenter wrote:
>> Hello Bob Pearson,
>>
>> The patch d94671632572: "RDMA/rxe: Rewrite rxe_task.c" from Mar 4,
>> 2023, leads to the following Smatch static checker warning:
>>
>> 	drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
>> 	warn: bitwise AND condition is false here
>>
>> drivers/infiniband/sw/rxe/rxe_task.c
>>     20 static bool __reserve_if_idle(struct rxe_task *task)
>>     21 {
>>     22         WARN_ON(rxe_read(task->qp) <= 0);
>>     23 
>> --> 24         if (task->tasklet.state & TASKLET_STATE_SCHED)
>>                                          ^^^^^^^^^^^^^^^^^^^
>> This is zero.  Should the check be == TASKLET_STATE_SCHED?
>>
> 
> The next function as well.
> 
> drivers/infiniband/sw/rxe/rxe_task.c:49 __is_done() warn: bitwise AND condition is false here
> 
> regards,
> dan carpenter
> 

Good catch. I was trying to open code the test in tasklet_schedule which was
test_and_set_bit(TASKLET_STATE_SCHED, &t->state). I should have typed

	if (task->tasklet.state & (1 << TASKLET_STATE_BIT)) or similar.

Thanks,

Bob

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug report] RDMA/rxe: Rewrite rxe_task.c
  2023-03-29 19:09   ` Bob Pearson
@ 2023-03-29 19:17     ` Leon Romanovsky
  2023-03-30  4:06     ` Dan Carpenter
  1 sibling, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2023-03-29 19:17 UTC (permalink / raw)
  To: Bob Pearson; +Cc: Dan Carpenter, linux-rdma

On Wed, Mar 29, 2023 at 02:09:17PM -0500, Bob Pearson wrote:
> On 3/29/23 01:48, Dan Carpenter wrote:
> > On Wed, Mar 29, 2023 at 09:27:26AM +0300, Dan Carpenter wrote:
> >> Hello Bob Pearson,
> >>
> >> The patch d94671632572: "RDMA/rxe: Rewrite rxe_task.c" from Mar 4,
> >> 2023, leads to the following Smatch static checker warning:
> >>
> >> 	drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
> >> 	warn: bitwise AND condition is false here
> >>
> >> drivers/infiniband/sw/rxe/rxe_task.c
> >>     20 static bool __reserve_if_idle(struct rxe_task *task)
> >>     21 {
> >>     22         WARN_ON(rxe_read(task->qp) <= 0);
> >>     23 
> >> --> 24         if (task->tasklet.state & TASKLET_STATE_SCHED)
> >>                                          ^^^^^^^^^^^^^^^^^^^
> >> This is zero.  Should the check be == TASKLET_STATE_SCHED?
> >>
> > 
> > The next function as well.
> > 
> > drivers/infiniband/sw/rxe/rxe_task.c:49 __is_done() warn: bitwise AND condition is false here
> > 
> > regards,
> > dan carpenter
> > 
> 
> Good catch. I was trying to open code the test in tasklet_schedule which was
> test_and_set_bit(TASKLET_STATE_SCHED, &t->state). I should have typed
> 
> 	if (task->tasklet.state & (1 << TASKLET_STATE_BIT)) or similar.

What is wrong with test_bit(TASKLET_STATE_SCHED, &task->tasklet.state)?

Thanks

> 
> Thanks,
> 
> Bob

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug report] RDMA/rxe: Rewrite rxe_task.c
  2023-03-29 19:09   ` Bob Pearson
  2023-03-29 19:17     ` Leon Romanovsky
@ 2023-03-30  4:06     ` Dan Carpenter
  1 sibling, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-03-30  4:06 UTC (permalink / raw)
  To: Bob Pearson; +Cc: linux-rdma

On Wed, Mar 29, 2023 at 02:09:17PM -0500, Bob Pearson wrote:
> On 3/29/23 01:48, Dan Carpenter wrote:
> > On Wed, Mar 29, 2023 at 09:27:26AM +0300, Dan Carpenter wrote:
> >> Hello Bob Pearson,
> >>
> >> The patch d94671632572: "RDMA/rxe: Rewrite rxe_task.c" from Mar 4,
> >> 2023, leads to the following Smatch static checker warning:
> >>
> >> 	drivers/infiniband/sw/rxe/rxe_task.c:24 __reserve_if_idle()
> >> 	warn: bitwise AND condition is false here
> >>
> >> drivers/infiniband/sw/rxe/rxe_task.c
> >>     20 static bool __reserve_if_idle(struct rxe_task *task)
> >>     21 {
> >>     22         WARN_ON(rxe_read(task->qp) <= 0);
> >>     23 
> >> --> 24         if (task->tasklet.state & TASKLET_STATE_SCHED)
> >>                                          ^^^^^^^^^^^^^^^^^^^
> >> This is zero.  Should the check be == TASKLET_STATE_SCHED?
> >>
> > 
> > The next function as well.
> > 
> > drivers/infiniband/sw/rxe/rxe_task.c:49 __is_done() warn: bitwise AND condition is false here
> > 
> > regards,
> > dan carpenter
> > 
> 
> Good catch. I was trying to open code the test in tasklet_schedule which was
> test_and_set_bit(TASKLET_STATE_SCHED, &t->state). I should have typed
> 
> 	if (task->tasklet.state & (1 << TASKLET_STATE_BIT)) or similar.

Thanks.  I'm sorry, I didn't look at this carefully. I just looked at
the next lines which are talking about a different state.  (My bug
reports are the much lazier option than my patches because it's faster
to be lazy).

Also I'm supposed to have a different check for shifter vs mask bugs
which should have warned about this.  I'll look into that.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-30  4:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29  6:27 [bug report] RDMA/rxe: Rewrite rxe_task.c Dan Carpenter
2023-03-29  6:48 ` Dan Carpenter
2023-03-29 19:09   ` Bob Pearson
2023-03-29 19:17     ` Leon Romanovsky
2023-03-30  4:06     ` Dan Carpenter
2023-03-29 18:22 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox