Skip to content

Commit

Permalink
[PATCH] ppc32: fix destroy_context() race condition
Browse files Browse the repository at this point in the history
Fix for a race condition when a task gets preempted by another task while
executing the destroy_context(...) in a FEW_CONTEXTS environment.
mm->context == NO_CONTEXT but the context_map may indicate all contexts are
in use.

The solution to this problem is to disable kernel preemption while
destroying a MMU context.

Signed-off-by: Guillaume Autran <gautran@mrv.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Guillaume Autran authored and Linus Torvalds committed Jul 13, 2005
1 parent 88bd512 commit ddca3b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/asm-ppc/mmu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,15 @@ static inline void get_mmu_context(struct mm_struct *mm)
*/
static inline void destroy_context(struct mm_struct *mm)
{
preempt_disable();
if (mm->context != NO_CONTEXT) {
clear_bit(mm->context, context_map);
mm->context = NO_CONTEXT;
#ifdef FEW_CONTEXTS
atomic_inc(&nr_free_contexts);
#endif
}
preempt_enable();
}

static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
Expand Down

0 comments on commit ddca3b8

Please sign in to comment.