2019-08-25 10:49:19 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2007-10-16 01:27:00 -07:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UM_MMU_CONTEXT_H
|
|
|
|
#define __UM_MMU_CONTEXT_H
|
|
|
|
|
2011-08-18 20:09:09 +01:00
|
|
|
#include <linux/sched.h>
|
2017-02-04 00:16:44 +01:00
|
|
|
#include <linux/mm_types.h>
|
2020-06-08 21:33:33 -07:00
|
|
|
#include <linux/mmap_lock.h>
|
2017-02-04 00:16:44 +01:00
|
|
|
|
2021-01-13 22:09:44 +01:00
|
|
|
#include <asm/mm_hooks.h>
|
2011-08-18 20:09:09 +01:00
|
|
|
#include <asm/mmu.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-07-12 13:58:22 -07:00
|
|
|
extern void force_flush_all(void);
|
|
|
|
|
2020-09-02 00:15:37 +10:00
|
|
|
#define activate_mm activate_mm
|
2005-04-16 15:20:36 -07:00
|
|
|
static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
|
|
|
|
{
|
[PATCH] uml: fixes performance regression in activate_mm and thus exec()
Normally, activate_mm() is called from exec(), and thus it used to be a
no-op because we use a completely new "MM context" on the host (for
instance, a new process), and so we didn't need to flush any "TLB entries"
(which for us are the set of memory mappings for the host process from the
virtual "RAM" file).
Kernel threads, instead, are usually handled in a different way. So, when
for AIO we call use_mm(), things used to break and so Benjamin implemented
activate_mm(). However, that is only needed for AIO, and could slow down
exec() inside UML, so be smart: detect being called for AIO (via
PF_BORROWED_MM) and do the full flush only in that situation.
Comment also the caller so that people won't go breaking UML without
noticing. I also rely on the caller's locks for testing current->flags.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
CC: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-03 15:57:25 -07:00
|
|
|
/*
|
2008-06-06 11:31:39 -07:00
|
|
|
* This is called by fs/exec.c and sys_unshare()
|
|
|
|
* when the new ->mm is used for the first time.
|
[PATCH] uml: fixes performance regression in activate_mm and thus exec()
Normally, activate_mm() is called from exec(), and thus it used to be a
no-op because we use a completely new "MM context" on the host (for
instance, a new process), and so we didn't need to flush any "TLB entries"
(which for us are the set of memory mappings for the host process from the
virtual "RAM" file).
Kernel threads, instead, are usually handled in a different way. So, when
for AIO we call use_mm(), things used to break and so Benjamin implemented
activate_mm(). However, that is only needed for AIO, and could slow down
exec() inside UML, so be smart: detect being called for AIO (via
PF_BORROWED_MM) and do the full flush only in that situation.
Comment also the caller so that people won't go breaking UML without
noticing. I also rely on the caller's locks for testing current->flags.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
CC: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-03 15:57:25 -07:00
|
|
|
*/
|
2008-06-06 11:31:39 -07:00
|
|
|
__switch_mm(&new->context.id);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
|
|
|
|
struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
unsigned cpu = smp_processor_id();
|
|
|
|
|
|
|
|
if(prev != next){
|
2009-09-24 09:34:51 -06:00
|
|
|
cpumask_clear_cpu(cpu, mm_cpumask(prev));
|
|
|
|
cpumask_set_cpu(cpu, mm_cpumask(next));
|
2005-04-16 15:20:36 -07:00
|
|
|
if(next != &init_mm)
|
2007-10-16 01:27:06 -07:00
|
|
|
__switch_mm(&next->context.id);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-02 00:15:37 +10:00
|
|
|
#define init_new_context init_new_context
|
2007-10-16 01:26:58 -07:00
|
|
|
extern int init_new_context(struct task_struct *task, struct mm_struct *mm);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2020-09-02 00:15:37 +10:00
|
|
|
#define destroy_context destroy_context
|
2007-10-16 01:26:58 -07:00
|
|
|
extern void destroy_context(struct mm_struct *mm);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2020-09-02 00:15:37 +10:00
|
|
|
#include <asm-generic/mmu_context.h>
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|