struct uprobe {
struct rb_node rb_node; /* node in the rb tree */
atomic_t ref;
+ struct rw_semaphore register_rwsem;
struct rw_semaphore consumer_rwsem;
struct mutex copy_mutex; /* TODO: kill me and UPROBE_COPY_INSN */
struct list_head pending_list;
uprobe->inode = igrab(inode);
uprobe->offset = offset;
+ init_rwsem(&uprobe->register_rwsem);
init_rwsem(&uprobe->consumer_rwsem);
mutex_init(&uprobe->copy_mutex);
/* For now assume that the instruction need not be single-stepped */
if (!test_bit(UPROBE_RUN_HANDLER, &uprobe->flags))
return;
- down_read(&uprobe->consumer_rwsem);
+ down_read(&uprobe->register_rwsem);
for (uc = uprobe->consumers; uc; uc = uc->next)
uc->handler(uc, regs);
- up_read(&uprobe->consumer_rwsem);
+ up_read(&uprobe->register_rwsem);
}
static void consumer_add(struct uprobe *uprobe, struct uprobe_consumer *uc)
mutex_lock(uprobes_hash(inode));
uprobe = alloc_uprobe(inode, offset);
if (uprobe) {
+ down_write(&uprobe->register_rwsem);
ret = __uprobe_register(uprobe, uc);
if (ret)
__uprobe_unregister(uprobe, uc);
+ up_write(&uprobe->register_rwsem);
}
mutex_unlock(uprobes_hash(inode));
if (uprobe)
return;
mutex_lock(uprobes_hash(inode));
+ down_write(&uprobe->register_rwsem);
__uprobe_unregister(uprobe, uc);
+ up_write(&uprobe->register_rwsem);
mutex_unlock(uprobes_hash(inode));
put_uprobe(uprobe);
}