linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* 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-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