signal/timer/event fds v7 - signalfd core ...
A message that is not in the archive (sent off-list or not yet received): [email protected]
Review
Quoted 6 lines · Davide Libenzi
(quoted diff) +5
-0+struct signalfd_lockctx { + struct task_struct *tsk; + struct sighand_struct *sighand; + unsigned long flags; +};
signalfd_lockctx is "private" to signalfd_lock/signalfd_unlock. But lk->sighand is used only by signalfd_lock(). I'd suggest to remove it.
Quoted 15 lines
(quoted diff) +15
-0+void signalfd_deliver(struct task_struct *tsk, int sig) +{ + struct sighand_struct *sighand = tsk->sighand; + struct signalfd_ctx *ctx, *tmp; + + list_for_each_entry_safe(ctx, tmp, &sighand->sfdlist, lnk) { + /* + * We use a negative signal value as a way to broadcast that the + * sighand has been orphaned, so that we can notify all the + * listeners about this. Remeber the ctx->sigmask is inverted, + * so if the user is interested in a signal, that corresponding + * bit will be zero. + */ + if (sig < 0) { + if (ctx->tsk == tsk) {
Review
Quoted 10 lines
(quoted diff) +10
-0+ ctx->tsk = NULL; + list_del_init(&ctx->lnk); + wake_up(&ctx->wqh); + } + } else if (sig > 0) { + if (!sigismember(&ctx->sigmask, sig)) + wake_up(&ctx->wqh); + } + } +}
I tried to avoid this comment, but can't help myself :)
This is a matter of taste, of course, but imho this is a classical "hide the problem" example.
Why "else if (sig > 0)" ? sig can't be == 0. In my opinion, it is better to add BUG_ON(!sig), but use just "else".
Oleg.
Quoted 10 lines · Oleg Nesterov
Review
Quoted 6 lines · Davide Libenzi
(quoted diff) +5
-0+struct signalfd_lockctx { + struct task_struct *tsk; + struct sighand_struct *sighand; + unsigned long flags; +};
signalfd_lockctxis "private" to signalfd_lock/signalfd_unlock. Butlk->sighandis used only bysignalfd_lock(). I'd suggest to remove it.
Ack
Quoted 19 lines
Quoted 19 lines
(quoted diff) +19
-0+void signalfd_deliver(struct task_struct *tsk, int sig) +{ + struct sighand_struct *sighand = tsk->sighand; + struct signalfd_ctx *ctx, *tmp; + + list_for_each_entry_safe(ctx, tmp, &sighand->sfdlist, lnk) { + /* + * We use a negative signal value as a way to broadcast that the + * sighand has been orphaned, so that we can notify all the + * listeners about this. Remeber the ctx->sigmask is inverted, + * so if the user is interested in a signal, that corresponding + * bit will be zero. + */ + if (sig < 0) { + if (ctx->tsk == tsk) { + ctx->tsk = NULL; + list_del_init(&ctx->lnk); + wake_up(&ctx->wqh); + }
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ } else if (sig > 0) { + if (!sigismember(&ctx->sigmask, sig)) + wake_up(&ctx->wqh); + } + } +}I tried to avoid this comment, but can't help myself :)
Added BUG_ON() and using "else".
- Davide
Review
Quoted 6 lines · Davide Libenzi
(quoted diff) +5
-0+static void signalfd_unlock(struct signalfd_ctx *ctx, + struct signalfd_lockctx *lk) +{ + unlock_task_sighand(lk->tsk, &lk->flags); +}
Again, this is a matter of taste. But I can't understand why signalfd_unlock() needs "signalfd_ctx *ctx" parameter. If we have "struct signalfd_lockctx *lk", signalfd_lock() can setup lk->ctx if it is ever needed.
Oleg.
Quoted 11 lines · Oleg Nesterov
Review
Quoted 6 lines · Davide Libenzi
(quoted diff) +5
-0+static void signalfd_unlock(struct signalfd_ctx *ctx, + struct signalfd_lockctx *lk) +{ + unlock_task_sighand(lk->tsk, &lk->flags); +}Again, this is a matter of taste. But I can't understand why
signalfd_unlock()needs "signalfd_ctx*ctx" parameter. If we have "structsignalfd_lockctx*lk",signalfd_lock()can setuplk->ctxif it is ever needed.
With the new API, I agree. Removed.
- Davide