• Oleg Nesterov's avatar
    uprobes: Kill uprobes_mutex[], separate alloc_uprobe() and __uprobe_register() · 66d06dff
    Oleg Nesterov authored
    uprobe_register() and uprobe_unregister() are the only users of
    mutex_lock(uprobes_hash(inode)), and the only reason why we can't
    simply remove it is that we need to ensure that delete_uprobe() is
    not possible after alloc_uprobe() and before consumer_add().
    
    IOW, we need to ensure that when we take uprobe->register_rwsem
    this uprobe is still valid and we didn't race with _unregister()
    which called delete_uprobe() in between.
    
    With this patch uprobe_register() simply checks uprobe_is_active()
    and retries if it hits this very unlikely race. uprobes_mutex[] is
    no longer needed and can be removed.
    
    There is another reason for this change, prepare_uprobe() should be
    folded into alloc_uprobe() and we do not want to hold the extra locks
    around read_mapping_page/etc.
    Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
    Acked-by: default avatarAnton Arapov <anton@redhat.com>
    Acked-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
    66d06dff
uprobes.c 38.3 KB