use_mm/unuse_mm correctness
Subsystems (3)
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
Signature · 9 lines
Suparna Bhattacharya ([email protected]) Linux Technology Center IBM Software Labs, India -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Suparna Bhattacharya
Can anyone spot a problem in the following routines ?
If CONFIG_PREEMPT=y, then this might help:
fs/aio.c +2 -1
@@ -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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
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
Quoted 18 lines · Hugh Dickins
Quoted 1 line · Suparna Bhattacharya
Can anyone spot a problem in the following routines ?
If
CONFIG_PREEMPT=y, then this might help:fs/aio.c +2
-1@@ -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 (); }/*
Signature · 9 lines
Suparna Bhattacharya ([email protected]) Linux Technology Center IBM Software Labs, India -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · Suparna Bhattacharya
However, in the aio case,
use_mmandunuse_mmare called only by workqueue threads, so there shouldn't be any migration even if a pre-empt occurs (cpus_allowedis 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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>