2007-02-27 20:26:59

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] init_new_context: Use the passed task argument

> On Fri, 23 Feb 2007 21:10:36 +0530 "Aneesh Kumar K.V" <[email protected]> wrote:
> From: Aneesh Kumar K.V <[email protected]>
>
> Signed-off-by: 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(-)
>
> diff --git a/arch/i386/kernel/ldt.c b/arch/i386/kernel/ldt.c
> index b410e5f..925354c 100644
> --- a/arch/i386/kernel/ldt.c
> +++ b/arch/i386/kernel/ldt.c
> @@ -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);
> diff --git a/arch/x86_64/kernel/ldt.c b/arch/x86_64/kernel/ldt.c
> index d7e5d0c..16ae79d 100644
> --- a/arch/x86_64/kernel/ldt.c
> +++ b/arch/x86_64/kernel/ldt.c
> @@ -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);
> diff --git a/kernel/fork.c b/kernel/fork.c
> index d154cc7..2423d83 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -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.



2007-02-28 04:12:30

by Aneesh Kumar K.V

[permalink] [raw]
Subject: Re: [PATCH] init_new_context: Use the passed task argument

On 2/28/07, Andrew Morton <[email protected]> wrote:
> > On Fri, 23 Feb 2007 21:10:36 +0530 "Aneesh Kumar K.V" <[email protected]> wrote:
> > From: Aneesh Kumar K.V <[email protected]>
> >
> > Signed-off-by: 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(-)
> >
> > diff --git a/arch/i386/kernel/ldt.c b/arch/i386/kernel/ldt.c
> > index b410e5f..925354c 100644
> > --- a/arch/i386/kernel/ldt.c
> > +++ b/arch/i386/kernel/ldt.c
> > @@ -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);
> > diff --git a/arch/x86_64/kernel/ldt.c b/arch/x86_64/kernel/ldt.c
> > index d7e5d0c..16ae79d 100644
> > --- a/arch/x86_64/kernel/ldt.c
> > +++ b/arch/x86_64/kernel/ldt.c
> > @@ -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);
> > diff --git a/kernel/fork.c b/kernel/fork.c
> > index d154cc7..2423d83 100644
> > --- a/kernel/fork.c
> > +++ b/kernel/fork.c
> > @@ -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.
>


How about the change as below


Attachments:
(No filename) (2.17 kB)
fork.diff (816.00 B)
Download all attachments