2021-01-26 01:30:44

by Jens Wiklander

[permalink] [raw]
Subject: [PATCH] tee: optee: remove need_resched() before cond_resched()

Testing need_resched() before cond_resched() is not needed as an
equivalent test is done internally in cond_resched(). So drop the
need_resched() test.

Fixes: dcb3b06d9c34 ("tee: optee: replace might_sleep with cond_resched")
Signed-off-by: Jens Wiklander <[email protected]>
---
drivers/tee/optee/call.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c
index 780d7c4fd756..7a77e375b503 100644
--- a/drivers/tee/optee/call.c
+++ b/drivers/tee/optee/call.c
@@ -149,8 +149,7 @@ u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg)
*/
optee_cq_wait_for_completion(&optee->call_queue, &w);
} else if (OPTEE_SMC_RETURN_IS_RPC(res.a0)) {
- if (need_resched())
- cond_resched();
+ cond_resched();
param.a0 = res.a0;
param.a1 = res.a1;
param.a2 = res.a2;
--
2.25.1


2021-01-26 22:22:12

by Jens Wiklander

[permalink] [raw]
Subject: Re: [PATCH] tee: optee: remove need_resched() before cond_resched()

Hi Rouven and Sumit,

On Mon, Jan 25, 2021 at 10:55 AM Jens Wiklander
<[email protected]> wrote:
>
> Testing need_resched() before cond_resched() is not needed as an
> equivalent test is done internally in cond_resched(). So drop the
> need_resched() test.
>
> Fixes: dcb3b06d9c34 ("tee: optee: replace might_sleep with cond_resched")
> Signed-off-by: Jens Wiklander <[email protected]>
> ---
> drivers/tee/optee/call.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)

Can you please test to see that this works in your setups too?

Thanks,
Jens

2021-01-31 09:53:12

by Rouven Czerwinski

[permalink] [raw]
Subject: Re: [PATCH] tee: optee: remove need_resched() before cond_resched()

Hi Jens,

On 29.01.21 14:29, Jens Wiklander wrote:
> Hi Rouven and Sumit,
>
> On Mon, Jan 25, 2021 at 10:58 AM Jens Wiklander via OP-TEE
> <[email protected]> wrote:
>>
>> Hi Rouven and Sumit,
>>
>> On Mon, Jan 25, 2021 at 10:55 AM Jens Wiklander
>> <[email protected]> wrote:
>>>
>>> Testing need_resched() before cond_resched() is not needed as an
>>> equivalent test is done internally in cond_resched(). So drop the
>>> need_resched() test.
>>>
>>> Fixes: dcb3b06d9c34 ("tee: optee: replace might_sleep with cond_resched")
>>> Signed-off-by: Jens Wiklander <[email protected]>
>>> ---
>>> drivers/tee/optee/call.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> Can you please test to see that this works in your setups too?
>
> Does this work for you? I'd like to get this patch ready for v5.12.

Yes it does. I also looked at it right after Arnds mail, so for future
reference:


cond_resched()

_cond_resched() (ifndef CONFIG_PREEMPTION)

should_resched(0)

tif_need_resched() (+ preempt_count == 0 for current thread)



while:



need_resched()

tif_need_resched()


You can add my
Reviewed-by: Rouven Czerwinski <[email protected]>

I also retested on the STM32-DK2 and the problem remains fixed:

Tested-by: Rouven Czerwinski <[email protected]>

Regrads and thanks for the patch,
Rouven

2021-02-01 05:05:48

by Sumit Garg

[permalink] [raw]
Subject: Re: [PATCH] tee: optee: remove need_resched() before cond_resched()

Hi Jens,

On Fri, 29 Jan 2021 at 18:59, Jens Wiklander <[email protected]> wrote:
>
> Hi Rouven and Sumit,
>
> On Mon, Jan 25, 2021 at 10:58 AM Jens Wiklander via OP-TEE
> <[email protected]> wrote:
> >
> > Hi Rouven and Sumit,
> >
> > On Mon, Jan 25, 2021 at 10:55 AM Jens Wiklander
> > <[email protected]> wrote:
> > >
> > > Testing need_resched() before cond_resched() is not needed as an
> > > equivalent test is done internally in cond_resched(). So drop the
> > > need_resched() test.
> > >
> > > Fixes: dcb3b06d9c34 ("tee: optee: replace might_sleep with cond_resched")
> > > Signed-off-by: Jens Wiklander <[email protected]>
> > > ---
> > > drivers/tee/optee/call.c | 3 +--
> > > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > Can you please test to see that this works in your setups too?
>
> Does this work for you? I'd like to get this patch ready for v5.12.

It does work for me as well.

Tested-by: Sumit Garg <[email protected]>

-Sumit

>
> Thanks,
> Jens

2021-02-03 07:12:31

by Jens Wiklander

[permalink] [raw]
Subject: Re: [PATCH] tee: optee: remove need_resched() before cond_resched()

On Fri, Jan 29, 2021 at 02:29:33PM +0100, Jens Wiklander wrote:
> Hi Rouven and Sumit,
>
> On Mon, Jan 25, 2021 at 10:58 AM Jens Wiklander via OP-TEE
> <[email protected]> wrote:
> >
> > Hi Rouven and Sumit,
> >
> > On Mon, Jan 25, 2021 at 10:55 AM Jens Wiklander
> > <[email protected]> wrote:
> > >
> > > Testing need_resched() before cond_resched() is not needed as an
> > > equivalent test is done internally in cond_resched(). So drop the
> > > need_resched() test.
> > >
> > > Fixes: dcb3b06d9c34 ("tee: optee: replace might_sleep with cond_resched")
> > > Signed-off-by: Jens Wiklander <[email protected]>
> > > ---
> > > drivers/tee/optee/call.c | 3 +--
> > > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > Can you please test to see that this works in your setups too?
>
> Does this work for you? I'd like to get this patch ready for v5.12.

Thanks for the help with this patch. I'll submit this up for v5.12.

Cheers,
Jens