mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: akpm@linux-foundation.org, dtor@mail.ru, linux-kernel@vger.kernel.org
Subject: Re: Fw: Re: + add-locking-to-evdev.patch added to -mm tree
Date: Mon, 9 Apr 2007 12:42:34 +0400	[thread overview]
Message-ID: <20070409084234.GA92@tv-sign.ru> (raw)
In-Reply-To: <20070408041611.GA18559@linux.vnet.ibm.com>

On 04/07, Paul E. McKenney wrote:
>
> The __kill_fasync() function in turn calls send_sigio(), which
> read-acquires both the fown_struct lock and tasklist_lock, then does
> send_sigio_to_task() for each thread in the task.
> 
> The send_sigio_to_task() function invokes group_send_sig_info(), which
> calls lock_task_sighand(), which expects one of its callers to have
> done an rcu_read_lock().  But I believe that read-holding tasklist_lock
> also suffices.  Oleg, could you please either confirm or educate?  @@@
> 
> (I think this is OK, just been awhile since I dug through the signal
> code.)

I also think this is OK.

The comment above lock_task_sighand() is not very clear. Note that it is
_not_ safe in general to do

	read_lock(tasklist_lock);
	lock_task_sighand(tsk);

even if we know that tsk can't go away (say, get_task_struct()).

However, it is safe to do:

	read_lock(tasklist_lock);
	tsk = find_task_in_pids_database();
	lock_task_sighand(tsk);

"find_task_in_pids_database" means something like find_task_by_pid_type() or
do_each_pid_task() (our case). Because read_lock(tasklist_lock) protects us
from release_task()->__exit_signal() which clears ->sighand _and_ removes tsk
from kernel/pid.c:pid_hash[] "atomically" under write_lock_irq(tasklist_lock).

rcu_read_lock() is OK for both cases. It would be nice to convert send_sigio()
to use RCU, but we also need tasklist_lock for

	- SIGCONT, see sig_needs_tasklist()

	- group wide signals (PIDTYPE_PGID), see the comment in copy_process()
	  above the recalc_sigpending() call.

Oleg.


  reply	other threads:[~2007-04-09  8:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-08  4:16 Paul E. McKenney
2007-04-09  8:42 ` Oleg Nesterov [this message]
2007-04-09 13:43 ` Dmitry Torokhov

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=20070409084234.GA92@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=dtor@mail.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    /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

all inboxes | Powered by JetHome®