* use_mm/unuse_mm correctness
@ 2003-06-16 3:59 Suparna Bhattacharya
2003-06-16 6:16 ` Hugh Dickins
0 siblings, 1 reply; 5+ messages in thread
From: Suparna Bhattacharya @ 2003-06-16 3:59 UTC (permalink / raw)
To: linux-mm
Can anyone spot a problem in the following routines ?
These are used by AIO workqueue routines to take on the
caller's address space when executing certain operations,
and then to switch back to the workqueue thread's original
mm context.
We are seeing some strange bugs in -mm lately, and this
code is one of the suspects. Can't yet see what could be
wrong ...
/*
* use_mm
* Makes the calling kernel thread take on the specified
* mm context.
* Called by the retry thread execute retries within the
* iocb issuer's mm context, so that copy_from/to_user
* operations work seamlessly for aio.
* (Note: this routine is intended to be called only
* from a kernel thread context)
*/
static void use_mm(struct mm_struct *mm)
{
struct mm_struct *active_mm = current->active_mm;
atomic_inc(&mm->mm_count);
current->mm = mm;
current->active_mm = mm;
activate_mm(active_mm, mm);
mmdrop(active_mm);
}
/*
* unuse_mm
* Reverses the effect of use_mm, i.e. releases the
* specified mm context which was earlier taken on
* by the calling kernel thread
* (Note: this routine is intended to be called only
* from a kernel thread context)
*/
void unuse_mm(struct mm_struct *mm)
{
current->mm = NULL;
/* active_mm is still 'mm' */
enter_lazy_tlb(mm, current, smp_processor_id());
}
Regards
Suparna
--
Suparna Bhattacharya (suparna@in.ibm.com)
Linux Technology Center
IBM Software Labs, India
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use_mm/unuse_mm correctness
2003-06-16 3:59 use_mm/unuse_mm correctness Suparna Bhattacharya
@ 2003-06-16 6:16 ` Hugh Dickins
2003-06-16 6:43 ` Suparna Bhattacharya
0 siblings, 1 reply; 5+ messages in thread
From: Hugh Dickins @ 2003-06-16 6:16 UTC (permalink / raw)
To: Suparna Bhattacharya; +Cc: linux-mm
On Mon, 16 Jun 2003, Suparna Bhattacharya wrote:
> Can anyone spot a problem in the following routines ?
If CONFIG_PREEMPT=y, then this might help:
--- 2.5.71-mm1/fs/aio.c Sun Jun 15 12:36:09 2003
+++ linux/fs/aio.c Mon Jun 16 07:05:53 2003
@@ -582,7 +582,8 @@ void unuse_mm(struct mm_struct *mm)
{
current->mm = NULL;
/* active_mm is still 'mm' */
- enter_lazy_tlb(mm, current, smp_processor_id());
+ enter_lazy_tlb(mm, current, get_cpu());
+ put_cpu();
}
/*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use_mm/unuse_mm correctness
2003-06-16 6:16 ` Hugh Dickins
@ 2003-06-16 6:43 ` Suparna Bhattacharya
2003-06-16 9:30 ` Hugh Dickins
0 siblings, 1 reply; 5+ messages in thread
From: Suparna Bhattacharya @ 2003-06-16 6:43 UTC (permalink / raw)
To: Hugh Dickins; +Cc: linux-mm
get_cpu() would be the right thing to do - thanks for
pointing that out.
However, in the aio case, use_mm and unuse_mm are called
only by workqueue threads, so there shouldn't be any
migration even if a pre-empt occurs (cpus_allowed is fixed
to a particular cpu), should it ?
Regards
Suparna
On Mon, Jun 16, 2003 at 07:16:12AM +0100, Hugh Dickins wrote:
> On Mon, 16 Jun 2003, Suparna Bhattacharya wrote:
> > Can anyone spot a problem in the following routines ?
>
> If CONFIG_PREEMPT=y, then this might help:
>
> --- 2.5.71-mm1/fs/aio.c Sun Jun 15 12:36:09 2003
> +++ linux/fs/aio.c Mon Jun 16 07:05:53 2003
> @@ -582,7 +582,8 @@ void unuse_mm(struct mm_struct *mm)
> {
> current->mm = NULL;
> /* active_mm is still 'mm' */
> - enter_lazy_tlb(mm, current, smp_processor_id());
> + enter_lazy_tlb(mm, current, get_cpu());
> + put_cpu();
> }
>
> /*
>
--
Suparna Bhattacharya (suparna@in.ibm.com)
Linux Technology Center
IBM Software Labs, India
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use_mm/unuse_mm correctness
2003-06-16 6:43 ` Suparna Bhattacharya
@ 2003-06-16 9:30 ` Hugh Dickins
0 siblings, 0 replies; 5+ messages in thread
From: Hugh Dickins @ 2003-06-16 9:30 UTC (permalink / raw)
To: Suparna Bhattacharya; +Cc: linux-mm
On Mon, 16 Jun 2003, Suparna Bhattacharya wrote:
>
> However, in the aio case, use_mm and unuse_mm are called
> only by workqueue threads, so there shouldn't be any
> migration even if a pre-empt occurs (cpus_allowed is fixed
> to a particular cpu), should it ?
Ah, yes, I certainly hope the cpu can't change in such a case!
Sorry for the noise, I hope someone else can help,
Hugh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use_mm/unuse_mm correctness
@ 2003-06-17 0:06 Venu Vadapalli
0 siblings, 0 replies; 5+ messages in thread
From: Venu Vadapalli @ 2003-06-17 0:06 UTC (permalink / raw)
To: linux-mm
Do kernel threads have 'mm'? I thought they inherit the active_mm from the
previously running task or in this case just use the desired mm...
This email message (including attachments) contains Company Proprietary
and/or Confidential Information and is intended only for the addressee. Any
unauthorized review, use, disclosure or distribution is prohibited. If you
are not the intended recipient, please contact the sender by reply email and
destroy all copies of the original message. Thank you.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-06-17 0:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-16 3:59 use_mm/unuse_mm correctness Suparna Bhattacharya
2003-06-16 6:16 ` Hugh Dickins
2003-06-16 6:43 ` Suparna Bhattacharya
2003-06-16 9:30 ` Hugh Dickins
2003-06-17 0:06 Venu Vadapalli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox