public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [patch 2/13] signal/timer/event fds v7 - signalfd core ...
Date: Tue, 20 Mar 2007 03:13:10 +0300	[thread overview]
Message-ID: <20070320001310.GA327@tv-sign.ru> (raw)
In-Reply-To: <send-serie.davidel@xmailserver.org.15249.1174348071.2>

On 03/19, Davide Libenzi wrote:
>
> +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.

> +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);
> +			}
> +		} 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.


       reply	other threads:[~2007-03-20  0:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <send-serie.davidel@xmailserver.org.15249.1174348071.2>
2007-03-20  0:13 ` Oleg Nesterov [this message]
2007-03-20  0:20   ` [patch 2/13] signal/timer/event fds v7 - signalfd core Davide Libenzi
2007-03-20  0:22 ` Oleg Nesterov
2007-03-20  0:24   ` Davide Libenzi
     [not found] <Pine.LNX.4.64.0703271506080.5424@alien.or.mcafeemobile.com>
2007-03-30 19:39 ` Andrew Morton
2007-03-31  0:29   ` Davide Libenzi

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=20070320001310.GA327@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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