[<prev] [next>] [day] [month] [year] [list]
Message-ID: <26ac4c2d-91cf-656d-2b7e-21a95e500e70@gmail.com>
Date: Sun, 3 Apr 2022 15:45:49 +0300
From: Pavel Skripkin <paskripkin@...il.com>
To: "Fabio M. De Francesco" <fmdefrancesco@...il.com>,
Michael Straube <straube.linux@...il.com>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Larry Finger <Larry.Finger@...inger.net>,
Phillip Potter <phil@...lpotter.co.uk>,
"open list:STAGING SUBSYSTEM" <linux-staging@...ts.linux.dev>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: 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
Download attachment "OpenPGP_signature" of type "application/pgp-signature" (841 bytes)
Powered by blists - more mailing lists