[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211218032409.GA11425@gondor.apana.org.au>
Date: Sat, 18 Dec 2021 14:24:09 +1100
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: Jason@...c4.com, linux-kernel@...r.kernel.org, tytso@....edu,
tglx@...utronix.de, peterz@...radead.org
Subject: Re: [PATCH 5/5] random: Defer processing of randomness on PREEMPT_RT.
On Fri, Dec 17, 2021 at 10:00:52AM +0100, Sebastian Andrzej Siewior wrote:
>
> I'm sorry, I can't connect the dots here. I was trying to explain that
> for the lock in question it is not possible to spin-wait without
> disabling interrupts first.
That's precisely the problem the socket lock was designed to
solve.
The way it works is that the interrupt path obtains a normal
spin lock, then tests if the sleepable side is holding the resource
or not. If it is, then the interrupt-path work is added to a
linked list to be processed later.
On the sleepable side, you first obtain the spin lock, then
you check whether the resource is held (by another thread), if
it is you then add yourself to a wait queue and sleep (this is
essentially a home-made mutex).
The tricky bit is in the unlock path on the sleepable side, you
check whether any interrupt-path work has been postponed while
you were holding the resource and process them if they have been.
Take a look at lock_sock/release_sock and bh_lock_sock/bh_unlock_sock
in net/core/sock.c.
Cheers,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists