Re: [PATCH v2 7/11] Uprobes Implementation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Srikar Dronamraju
Date: Thursday, April 15, 2010 - 2:35 am

Oleg, Thanks for the review.

Okay.


Oh Okay, I get that the thread could be exiting from the time we
allocated the utask to the time we are cleaning up here and hence we
could be leaking utask.

Would it be okay if we explicitly (instead of the using
tracehook_report_exit) call uprobe_free_utask() just after we set
PF_EXITING. We could take the task_lock to synchronize with the
add_utask() and do_exit().


Okay. 
Would it work if we 

static struct uprobe_task *add_utask(struct task_struct *t,
					struct uprobe_process *uproc)
{
	struct uprobe_task *utask;
	int exiting = 0;

	if (!t)
		return NULL;

	utask = kzalloc(sizeof *utask, GFP_USER);
	if (unlikely(utask == NULL))
		return ERR_PTR(-ENOMEM);

	task_lock(t);
	if (unlikely(t->flags & PF_EXITING)) {
		task_unlock(t);
		kfree(utask);	
		return;
	}
	t->utask = utask;
	task_unlock(t);
	utask->uproc = uproc;
	utask->active_ppt = NULL;
	atomic_inc(&uproc->refcount);
}


NORET_TYPE void do_exit(long code)
{
...
	exit_irq_thread();                                                                                                   
                                                                                                                             
        exit_signals(tsk);  /* sets PF_EXITING */                                                                            
	task_lock(tsk)
	if (tsk->utask);
		uprobe_free_utask();
	task_unlock(tsk);
	
       ...
..

}

Something similar would be needed in exec path too.

yeah, PF_EXITING doesnt seem to help us here. But will this be an issue once we
move uprobe_free_utask() after exit_signals.


The tracehook_report_clone is called after the element gets added to the
thread_group list in copy_process().
Looking at three cases where current thread could be cloning a new thread.

a) current thread has a utask and tracehook_report_clone is not yet
called.  
	utask for the new thread will be created by either
tracehook_report_clone or the find_next_thread whichever comes first. 

b) current thread has no utask and tracehook_report_clone is already called.
	new thread is in the thread_group list; so a utask will be created
by find_next_thread.

c) current thread has no utask yet and tracehook_report_clone is not yet called.
	If the creation of utask for the current thread completes after
the current thread called tracehook_report_clone; then its same as case
b.	
	If the creation of utask for the current thread completes before
the current thread calls tracehook_report_clone; then its same as case
a;

Am I missing any other cases?
Also if we are using explicit uprobe calls in exec/exit events; I
propose we use a explicit uprobe_handle_clone call from copy_process.



We didnt want to trace process which is exiting but I think what we
might be doing is not allowing multi-threaded process whose thread group
leader exited. So I remove this check.
Do you see a need for checking if the process is exiting before we place
the probes?


Okay.. Agree, will do changes accordingly.


Okay, I agree that we can remove ctask here and in the else branch.


Okay, So I will remove the breakpoints only for ! CLONE(CLONE_VM) and
!CLONE(CLONE_THREAD)
For CLONE(CLONE_VM) I will create a new uproc and utask structures. 
Since mm is shared; I guess the XOL vma gets shared between the processes.

Again, Thanks Oleg for your comments. 

--
Thanks and Regards
Srikar
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v2 0/11] Uprobes patches., Srikar Dronamraju, (Wed Mar 31, 8:51 am)
[PATCH v2 1/11] Move Macro W to insn.h, Srikar Dronamraju, (Wed Mar 31, 8:51 am)
[PATCH v2 2/11] Move replace_page() to mm/memory.c, Srikar Dronamraju, (Wed Mar 31, 8:51 am)
[PATCH v2 3/11] Enhance replace_page() to support pagecache, Srikar Dronamraju, (Wed Mar 31, 8:51 am)
[PATCH v2 4/11] User Space Breakpoint Assistance Layer, Srikar Dronamraju, (Wed Mar 31, 8:51 am)
[PATCH v2 5/11] X86 details for user space breakpoint assi ..., Srikar Dronamraju, (Wed Mar 31, 8:52 am)
[PATCH v2 6/11] Slot allocation for Execution out of line, Srikar Dronamraju, (Wed Mar 31, 8:52 am)
[PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Wed Mar 31, 8:52 am)
[PATCH v2 8/11] X86 details for uprobes., Srikar Dronamraju, (Wed Mar 31, 8:52 am)
[PATCH v2 9/11] Uprobes Documentation patch, Srikar Dronamraju, (Wed Mar 31, 8:52 am)
[PATCH v2 10/11] Uprobes samples., Srikar Dronamraju, (Wed Mar 31, 8:52 am)
[PATCH v2 11/11] Uprobes traceevents patch., Srikar Dronamraju, (Wed Mar 31, 8:53 am)
Re: [PATCH v2 11/11] Uprobes traceevents patch., Steven Rostedt, (Wed Mar 31, 2:24 pm)
Re: [PATCH v2 11/11] Uprobes traceevents patch., Masami Hiramatsu, (Wed Mar 31, 9:16 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Tue Apr 13, 11:35 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Thu Apr 15, 2:35 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Mon Apr 19, 12:31 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Tue Apr 20, 5:43 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Tue Apr 20, 8:30 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Tue Apr 20, 11:59 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Wed Apr 21, 9:05 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Thu Apr 22, 6:31 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Thu Apr 22, 8:40 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Fri Apr 23, 7:58 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Fri Apr 23, 11:53 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Tue May 11, 1:32 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Tue May 11, 1:43 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Tue May 11, 1:44 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Tue May 11, 1:45 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Tue May 11, 1:47 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Frank Ch. Eigler, (Tue May 11, 1:57 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Tue May 11, 2:01 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Wed May 12, 3:31 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Wed May 12, 3:41 am)
Re: [PATCH v2 11/11] Uprobes traceevents patch., Frederic Weisbecker, (Wed May 12, 4:02 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Peter Zijlstra, (Wed May 12, 4:12 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Wed May 12, 7:24 am)
Re: [PATCH v2 11/11] Uprobes traceevents patch., Srikar Dronamraju, (Wed May 12, 7:34 am)
Re: [PATCH v2 11/11] Uprobes traceevents patch., Frederic Weisbecker, (Wed May 12, 7:57 am)
Re: [PATCH v2 11/11] Uprobes traceevents patch., Frederic Weisbecker, (Wed May 12, 8:15 am)
Re: [PATCH v2 7/11] Uprobes Implementation, Oleg Nesterov, (Thu May 13, 12:40 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Linus Torvalds, (Thu May 13, 12:59 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Andi Kleen, (Thu May 13, 3:12 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Linus Torvalds, (Thu May 13, 3:25 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Roland McGrath, (Thu May 13, 5:56 pm)
Re: [PATCH v2 7/11] Uprobes Implementation, Srikar Dronamraju, (Thu May 13, 10:42 pm)