lkml.org 
[lkml]   [2021]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [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@gondor.apana.org.au>
    Home Page: http://gondor.apana.org.au/~herbert/
    PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

    \
     
     \ /
      Last update: 2021-12-18 04:24    [W:3.878 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site