lkml.org 
[lkml]   [2011]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 1/8] vfork: introduce complete_vfork_done()
No functional changes.

Move the clear-and-complete-vfork_done code into the new trivial
helper, complete_vfork_done().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

include/linux/sched.h | 1 +
fs/exec.c | 8 ++------
kernel/fork.c | 17 ++++++++++-------
3 files changed, 13 insertions(+), 13 deletions(-)

--- 3.1/include/linux/sched.h~1_complete_vfork_done 2011-07-26 15:50:14.000000000 +0200
+++ 3.1/include/linux/sched.h 2011-07-26 17:11:40.000000000 +0200
@@ -2253,6 +2253,7 @@ extern int do_execve(const char *,
const char __user * const __user *,
const char __user * const __user *, struct pt_regs *);
extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
+extern void complete_vfork_done(struct task_struct *tsk);
struct task_struct *fork_idle(int);

extern void set_task_comm(struct task_struct *tsk, char *from);
--- 3.1/fs/exec.c~1_complete_vfork_done 2011-07-23 15:26:19.000000000 +0200
+++ 3.1/fs/exec.c 2011-07-26 17:15:10.000000000 +0200
@@ -1885,7 +1885,6 @@ static int coredump_wait(int exit_code,
{
struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm;
- struct completion *vfork_done;
int core_waiters = -EBUSY;

init_completion(&core_state->startup);
@@ -1904,11 +1903,8 @@ static int coredump_wait(int exit_code,
* Make sure nobody is waiting for us to release the VM,
* otherwise we can deadlock when we wait on each other
*/
- vfork_done = tsk->vfork_done;
- if (vfork_done) {
- tsk->vfork_done = NULL;
- complete(vfork_done);
- }
+ if (tsk->vfork_done)
+ complete_vfork_done(tsk);

if (core_waiters)
wait_for_completion(&core_state->startup);
--- 3.1/kernel/fork.c~1_complete_vfork_done 2011-07-26 15:50:15.000000000 +0200
+++ 3.1/kernel/fork.c 2011-07-26 17:32:22.000000000 +0200
@@ -662,8 +662,6 @@ EXPORT_SYMBOL_GPL(get_task_mm);
*/
void mm_release(struct task_struct *tsk, struct mm_struct *mm)
{
- struct completion *vfork_done = tsk->vfork_done;
-
/* Get rid of any futexes when releasing the mm */
#ifdef CONFIG_FUTEX
if (unlikely(tsk->robust_list)) {
@@ -683,11 +681,8 @@ void mm_release(struct task_struct *tsk,
/* Get rid of any cached register state */
deactivate_mm(tsk, mm);

- /* notify parent sleeping on vfork() */
- if (vfork_done) {
- tsk->vfork_done = NULL;
- complete(vfork_done);
- }
+ if (tsk->vfork_done)
+ complete_vfork_done(tsk);

/*
* If we're exiting normally, clear a user-space tid field if
@@ -1446,6 +1441,14 @@ struct task_struct * __cpuinit fork_idle
return task;
}

+void complete_vfork_done(struct task_struct *tsk)
+{
+ struct completion *vfork_done = tsk->vfork_done;
+
+ tsk->vfork_done = NULL;
+ complete(vfork_done);
+}
+
/*
* Ok, this is the main fork-routine.
*


\
 
 \ /
  Last update: 2011-07-27 18:37    [W:0.259 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site