uprobes: Introduce uprobe->register_rwsem
authorOleg Nesterov <oleg@redhat.com>
Sat, 24 Nov 2012 16:29:40 +0000 (17:29 +0100)
committerOleg Nesterov <oleg@redhat.com>
Fri, 8 Feb 2013 16:47:03 +0000 (17:47 +0100)
commite591c8d78e49e6206935cf31c4d2b603bbb29166
treefd454634604829933828e06849550dfbcfc37542
parent9a98e03cc145c994da824dac7602334f50feb670
uprobes: Introduce uprobe->register_rwsem

Introduce uprobe->register_rwsem. It is taken for writing around
__uprobe_register/unregister.

Change handler_chain() to use this sem rather than consumer_rwsem.

The main reason for this change is that we have the nasty problem
with mmap_sem/consumer_rwsem dependency. filter_chain() needs to
protect uprobe->consumers like handler_chain(), but they can not
use the same lock. filter_chain() can be called under ->mmap_sem
(currently this is always true), but we want to allow ->handler()
to play with the probed task's memory, and this needs ->mmap_sem.

Alternatively we could use srcu, but synchronize_srcu() is very
slow and ->register_rwsem allows us to do more. In particular, we
can teach handler_chain() to do remove_breakpoint() if this bp is
"nacked" by all consumers, we know that we can't race with the
new consumer which does uprobe_register().

See also the next patches. uprobes_mutex[] is almost ready to die.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
kernel/events/uprobes.c