flag = PIF_FIRST;
}
- if (proc && sspt_proc_is_filter_new(proc, pfg)) {
- img_proc_copy_to_sspt(pfg->i_proc, proc);
- sspt_proc_add_filter(proc, pfg);
- pfg_add_proc(pfg, proc);
- flag = flag == PIF_FIRST ? flag : PIF_ADD_PFG;
+ if (proc) {
+ write_lock(&proc->filter_lock);
+ if (sspt_proc_is_filter_new(proc, pfg)) {
+ img_proc_copy_to_sspt(pfg->i_proc, proc);
+ sspt_proc_add_filter(proc, pfg);
+ pfg_add_proc(pfg, proc);
+ flag = flag == PIF_FIRST ? flag : PIF_ADD_PFG;
+ }
+ write_unlock(&proc->filter_lock);
}
}
read_unlock(&pfg_list_lock);
{
struct sspt_filter *fl;
- fl = kmalloc(sizeof(*fl), GFP_KERNEL);
+ fl = kmalloc(sizeof(*fl), GFP_ATOMIC);
if (fl == NULL)
return NULL;
INIT_LIST_HEAD(&fl->list);
- list_add(&fl->list, &proc->filter_list);
fl->proc = proc;
fl->pfg = pfg;
proc->task = task->group_leader;
proc->sm = create_sm_us(task);
INIT_LIST_HEAD(&proc->file_list);
+ rwlock_init(&proc->filter_lock);
INIT_LIST_HEAD(&proc->filter_list);
atomic_set(&proc->usage, 1);
*/
void sspt_proc_add_filter(struct sspt_proc *proc, struct pf_group *pfg)
{
- sspt_filter_create(proc, pfg);
+ struct sspt_filter *f;
+
+ f = sspt_filter_create(proc, pfg);
+ if (f)
+ list_add(&f->list, &proc->filter_list);
}
/**
{
struct sspt_filter *fl, *tmp;
+ write_lock(&proc->filter_lock);
list_for_each_entry_safe(fl, tmp, &proc->filter_list, list) {
if (fl->pfg == pfg) {
list_del(&fl->list);
sspt_filter_free(fl);
}
}
+ write_unlock(&proc->filter_lock);
}
/**
{
struct sspt_filter *fl, *tmp;
+ write_lock(&proc->filter_lock);
list_for_each_entry_safe(fl, tmp, &proc->filter_list, list) {
list_del(&fl->list);
sspt_filter_free(fl);
}
+ write_unlock(&proc->filter_lock);
}
/**
{
bool is_send = false;
+ /* FIXME: add read lock (deadlock in sampler) */
sspt_proc_on_each_filter(proc, is_send_event, (void *)&is_send);
return is_send;
unsigned long r_state_addr; /**< address of r_state */
struct slot_manager *sm; /**< Ptr to the manager slot */
struct list_head file_list; /**< For sspt_file */
+ rwlock_t filter_lock;
struct list_head filter_list; /**< Filter list */
unsigned first_install:1; /**< Install flag */
struct sspt_feature *feature; /**< Ptr to the feature */