[lkml]   [2022]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: staging: r8188eu: how to handle nested mutex under spinlock
Hi Fabio,

On 4/3/22 15:37, Fabio M. De Francesco wrote:
>> >
>> > drivers/staging/r8188eu/core/rtw_pwrctrl.c:379
>> >
>> > if (pwrpriv->ps_processing) {
>> > while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000)
>> > msleep(10);
>> > }
>> >
>> Hm, just wondering, shouldn't we annotate load from
>> pwrpriv->ps_processing with READ_ONCE() inside while loop?
>> IIUC compiler might want to cache first load into register and we will
>> stuck here forever.
> You're right. This can be cached. In situations like these one should use
> barriers or other API that use barriers implicitly (completions, for example).

Not sure about completions, since they may sleep.

Also, don't think that barriers are needed here, since this code just
waiting for observing value 1. Might be barrier will slightly speed up
waiting thread, but will also slow down other thread

> In this list, a couple of weeks ago, I suggested someone to use them. He/she
> re-submitted his/her patches with wait_for_completion() / complete(), I placed
> my Reviewed-by tag and Greg was happy to accept it and merge.
> Not sure about READ_ONCE(), because, as far as I know, it is used only to
> prevent load tearing. But I might be wrong here.
> Fabio
> P.S.: Is Paul's book still un-read? Unfortunately, I am not yet done :(

If I could read it 24/7 I will be the happiest person ever :) As you
might expect I am not yet done as well

With regards,
Pavel Skripkin
[unhandled content-type:application/pgp-signature]
 \ /
  Last update: 2022-04-03 14:46    [W:0.051 / U:2.756 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site