lkml.org 
[lkml]   [2021]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] signal: Allow RT tasks to cache one sigqueue struct
    Date
    On Wed, Mar 03 2021 at 16:37, Oleg Nesterov wrote:
    > On 03/03, Sebastian Andrzej Siewior wrote:
    >>
    >> +static struct sigqueue *sigqueue_from_cache(struct task_struct *t)
    >> +{
    >> + struct sigqueue *q = t->sigqueue_cache;
    >> +
    >> + if (q && cmpxchg(&t->sigqueue_cache, q, NULL) == q)
    >> + return q;
    >> + return NULL;
    >> +}
    >> +
    >> +static bool sigqueue_add_cache(struct task_struct *t, struct sigqueue *q)
    >> +{
    >> + if (!t->sigqueue_cache && cmpxchg(&t->sigqueue_cache, NULL, q) == NULL)
    >> + return true;
    >> + return false;
    >> +}
    >
    > Do we really need cmpxchg? It seems they are always called with
    > spinlock held.

    With which spinlock held?

    __send_signal() <- sighand::siglock held
    __sigqueue_alloc()

    alloc_posix_timer()
    sigqueue_alloc() <- No lock held
    __sigqueue_alloc()

    and on the free side we have a bunch of callers which do not hold
    sighand::siglock either. So the cmpxchg() is required.

    Thanks,

    tglx

    \
     
     \ /
      Last update: 2021-03-04 22:13    [W:2.202 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site