Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164488
b: refs/heads/master
c: 3d2d827
h: refs/heads/master
v: v3
  • Loading branch information
Michael S. Tsirkin authored and Linus Torvalds committed Sep 22, 2009
1 parent e477bdb commit 0155577
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 425fbf047cc70bb30dff368a6da02c8c2d229318
refs/heads/master: 3d2d827f5ca5e32816194119d5c980c7e04474a6
47 changes: 1 addition & 46 deletions trunk/fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/file.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/mmu_context.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/aio.h>
Expand All @@ -34,7 +35,6 @@

#include <asm/kmap_types.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>

#if DEBUG > 1
#define dprintk printk
Expand Down Expand Up @@ -594,51 +594,6 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
return ret;
}

/*
* 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;
struct task_struct *tsk = current;

task_lock(tsk);
active_mm = tsk->active_mm;
atomic_inc(&mm->mm_count);
tsk->mm = mm;
tsk->active_mm = mm;
switch_mm(active_mm, mm, tsk);
task_unlock(tsk);

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)
*/
static void unuse_mm(struct mm_struct *mm)
{
struct task_struct *tsk = current;

task_lock(tsk);
tsk->mm = NULL;
/* active_mm is still 'mm' */
enter_lazy_tlb(mm, tsk);
task_unlock(tsk);
}

/*
* Queue up a kiocb to be retried. Assumes that the kiocb
* has already been marked as kicked, and places it on
Expand Down
9 changes: 9 additions & 0 deletions trunk/include/linux/mmu_context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _LINUX_MMU_CONTEXT_H
#define _LINUX_MMU_CONTEXT_H

struct mm_struct;

void use_mm(struct mm_struct *mm);
void unuse_mm(struct mm_struct *mm);

#endif
2 changes: 1 addition & 1 deletion trunk/mm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
maccess.o page_alloc.o page-writeback.o \
readahead.o swap.o truncate.o vmscan.o shmem.o \
prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
page_isolation.o mm_init.o $(mmu-y)
page_isolation.o mm_init.o mmu_context.o $(mmu-y)
obj-y += init-mm.o

obj-$(CONFIG_PROC_PAGE_MONITOR) += pagewalk.o
Expand Down
55 changes: 55 additions & 0 deletions trunk/mm/mmu_context.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Copyright (C) 2009 Red Hat, Inc.
*
* See ../COPYING for licensing terms.
*/

#include <linux/mm.h>
#include <linux/mmu_context.h>
#include <linux/sched.h>

#include <asm/mmu_context.h>

/*
* 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)
*/
void use_mm(struct mm_struct *mm)
{
struct mm_struct *active_mm;
struct task_struct *tsk = current;

task_lock(tsk);
active_mm = tsk->active_mm;
atomic_inc(&mm->mm_count);
tsk->mm = mm;
tsk->active_mm = mm;
switch_mm(active_mm, mm, tsk);
task_unlock(tsk);

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)
{
struct task_struct *tsk = current;

task_lock(tsk);
tsk->mm = NULL;
/* active_mm is still 'mm' */
enter_lazy_tlb(mm, tsk);
task_unlock(tsk);
}

0 comments on commit 0155577

Please sign in to comment.