From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: linux-staging@lists.linux.dev, gregkh@linuxfoundation.org,
phil@philpotter.co.uk, larry.finger@lwfinger.net,
julia.lawall@inria.fr, linux-kernel@vger.kernel.org,
Michael Straube <michael.straube@stud.uni-goettingen.de>,
martin@kaiser.cx
Subject: Re: [RFC] staging: r8188eu: Sleeping in atomic context (SAC) bugs
Date: Mon, 7 Feb 2022 20:38:08 +0300 [thread overview]
Message-ID: <20220207173808.GR1978@kadam> (raw)
In-Reply-To: <23161490.ouqheUzb2q@leap>
On Mon, Feb 07, 2022 at 03:18:52PM +0100, Fabio M. De Francesco wrote:
> 1) Leave the code as-is with those msleep(10) and risk to hang the driver (or
> the whole kernel?).
> 2) Change msleep(10) to mdelay(10). It's a huge amount of time, but we are
> guaranteed that it is safe.
> 3) Change to mdelay() and try to figure out what's the minimum amount of time
> that suffice. I forgot to say that those msleep(10) are within "while" loops,
> therefore they are called an unknown amount of times.
You are talking about the:
rtw_set_802_11_disassociate() <- disables preempt
-> _rtw_pwr_wakeup()
_rtw_pwr_wakeup() calls msleep() on two different paths.
Let's just add it to the TODO list.
The code is a mess, right? Maybe if we clean it up a bit first the
answer will become obvious.
The first loop is trying to prevent racing with rtw_ps_processor().
Sleeping is not a valid way to prevent race conditions. Especially
since it just gives up and it's like, "Oh well, three seconds are up.
Let's just race."
I don't really think that sleeping in atomic bugs are likely to lock up
the whole system these days because even the cheapest mobile phones have
something like 64 cores in them. But imagine it was twenty years and
you had only one core with CONFIG_PREEMPT turned on. The CPU was in
ips_enter() and it was preempted by this thread, which is totally
possible in theory. Then this thread took the spinlock and we changed
the msleep to mdelay(). There is now no way for the other thread to
complete ips_enter() because we don't give up the CPU so we just sit for
3 seconds and then timeout.
In other words, changing from msleep to mdelay could make bad code even
worse. Plus it silences the warning so now the problem is hard to find.
regards,
dan carpenter
prev parent reply other threads:[~2022-02-07 17:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-07 0:02 [RFC] staging: r8188eu: Sleeping in atomic context (SAC) bugs Fabio M. De Francesco
2022-02-07 9:21 ` Dan Carpenter
2022-02-07 14:18 ` Fabio M. De Francesco
2022-02-07 17:17 ` Fabio M. De Francesco
2022-02-07 17:38 ` Dan Carpenter [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=20220207173808.GR1978@kadam \
--to=dan.carpenter@oracle.com \
--cc=fmdefrancesco@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@inria.fr \
--cc=larry.finger@lwfinger.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=martin@kaiser.cx \
--cc=michael.straube@stud.uni-goettingen.de \
--cc=phil@philpotter.co.uk \
/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