Skip to contentSkip to conversation

init_new_context: Use the passed task argument

PATCH Andrew Morton 2 participants 2 messages Feb 27, 2007 – Feb 28, 2007 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andrew Morton

author maintainer
#2 lore raw
Quoted 41 lines · On Fri, 23 Feb 2007 21:10:36 +0530 "Aneesh Kumar K.V" <[email protected]>…

From: Aneesh Kumar K.V <[email protected]>

---
 arch/i386/kernel/ldt.c   |    2 +-
 arch/x86_64/kernel/ldt.c |    2 +-
 kernel/fork.c            |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/i386/kernel/ldt.c +1 -1
index b410e5f..925354c 100644
@@ -97,7 +97,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
 	init_MUTEX(&mm->context.sem);
 	mm->context.size = 0;
-	old_mm = current->mm;
+	old_mm = tsk->mm;
 	if (old_mm && old_mm->context.size > 0) {
 		down(&old_mm->context.sem);
 		retval = copy_ldt(&mm->context, &old_mm->context);
arch/x86_64/kernel/ldt.c +1 -1
index d7e5d0c..16ae79d 100644
@@ -101,7 +101,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
 	init_MUTEX(&mm->context.sem);
 	mm->context.size = 0;
-	old_mm = current->mm;
+	old_mm = tsk->mm;
 	if (old_mm && old_mm->context.size > 0) {
 		down(&old_mm->context.sem);
 		retval = copy_ldt(&mm->context, &old_mm->context);
kernel/fork.c +0 -0
index d154cc7..2423d83 100644

kernel/fork.c static struct mm_struct *dup_mm(struct task_struct *tsk) · line 500

Quoted 6 lines
kernel/fork.c +1 -1
@@ -496,7 +496,7 @@ static struct mm_struct *dup_mm(struct task_struct *tsk)
 	if (!mm_init(mm))
 		goto fail_nomem;
 
-	if (init_new_context(tsk, mm))
+	if (init_new_context(current, mm))
 		goto fail_nocontext;

This last change makes the comment over dup_mm() wrong. It also generally makes dup_mm() less useful, although that migt be OK. It also makes the argument to dup_mm() unused and potentially removable.

#3 lore raw
Quoted 44 lines · Andrew Morton
Quoted 44 lines · On Fri, 23 Feb 2007 21:10:36 +0530 "Aneesh Kumar K.V" <[email protected]>…

From: Aneesh Kumar K.V <[email protected]>

---
 arch/i386/kernel/ldt.c   |    2 +-
 arch/x86_64/kernel/ldt.c |    2 +-
 kernel/fork.c            |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/i386/kernel/ldt.c +1 -1
index b410e5f..925354c 100644
@@ -97,7 +97,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
      init_MUTEX(&mm->context.sem);
      mm->context.size = 0;
-     old_mm = current->mm;
+     old_mm = tsk->mm;
      if (old_mm && old_mm->context.size > 0) {
              down(&old_mm->context.sem);
              retval = copy_ldt(&mm->context, &old_mm->context);
arch/x86_64/kernel/ldt.c +1 -1
index d7e5d0c..16ae79d 100644
@@ -101,7 +101,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
      init_MUTEX(&mm->context.sem);
      mm->context.size = 0;
-     old_mm = current->mm;
+     old_mm = tsk->mm;
      if (old_mm && old_mm->context.size > 0) {
              down(&old_mm->context.sem);
              retval = copy_ldt(&mm->context, &old_mm->context);
kernel/fork.c +0 -0
index d154cc7..2423d83 100644
@@ -496,7 +496,7 @@ static struct mm_struct *dup_mm(struct task_struct *tsk)
      if (!mm_init(mm))
              goto fail_nomem;
 
Quoted 8 lines

kernel/fork.c static struct mm_struct *dup_mm(struct task_struct *tsk) · line 500

Quoted 3 lines
kernel/fork.c +1 -1
-     if (init_new_context(tsk, mm))
+     if (init_new_context(current, mm))
              goto fail_nocontext;

This last change makes the comment over dup_mm() wrong. It also generally makes dup_mm() less useful, although that migt be OK. It also makes the argument to dup_mm() unused and potentially removable.

How about the change as below

kernel/fork.c +3 -3
index 2423d83..2184ef5 100644
@@ -477,7 +477,7 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
  */
 static struct mm_struct *dup_mm(struct task_struct *tsk)
 {
-	struct mm_struct *mm, *oldmm = current->mm;
+	struct mm_struct *mm, *oldmm = tsk->mm;
 	int err;
 
 	if (!oldmm)
@@ -496,7 +496,7 @@ static struct mm_struct *dup_mm(struct task_struct *tsk)
 	if (!mm_init(mm))
 		goto fail_nomem;
 
-	if (init_new_context(current, mm))
+	if (init_new_context(tsk, mm))
 		goto fail_nocontext;
 
 	err = dup_mmap(mm, oldmm);
@@ -551,7 +551,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk)
 	}
 
 	retval = -ENOMEM;
-	mm = dup_mm(tsk);
+	mm = dup_mm(current);
 	if (!mm)
 		goto fail_nomem;