core, x86: Add user return notifiers
Add a general per-cpu notifier that is called whenever the kernel is about to return to userspace. The notifier uses a thread_info flag and existing checks, so there is no impact on user return or context switch fast paths. This will be used initially to speed up KVM task switching by lazily updating MSRs. Signed-off-by: Avi Kivity <avi@redhat.com> LKML-Reference: <1253342422-13811-1-git-send-email-avi@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
committed by
H. Peter Anvin
parent
817b33d38f
commit
7c68af6e32
42
include/linux/user-return-notifier.h
Normal file
42
include/linux/user-return-notifier.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _LINUX_USER_RETURN_NOTIFIER_H
|
||||
#define _LINUX_USER_RETURN_NOTIFIER_H
|
||||
|
||||
#ifdef CONFIG_USER_RETURN_NOTIFIER
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
struct user_return_notifier {
|
||||
void (*on_user_return)(struct user_return_notifier *urn);
|
||||
struct hlist_node link;
|
||||
};
|
||||
|
||||
|
||||
void user_return_notifier_register(struct user_return_notifier *urn);
|
||||
void user_return_notifier_unregister(struct user_return_notifier *urn);
|
||||
|
||||
static inline void propagate_user_return_notify(struct task_struct *prev,
|
||||
struct task_struct *next)
|
||||
{
|
||||
if (test_tsk_thread_flag(prev, TIF_USER_RETURN_NOTIFY)) {
|
||||
clear_tsk_thread_flag(prev, TIF_USER_RETURN_NOTIFY);
|
||||
set_tsk_thread_flag(next, TIF_USER_RETURN_NOTIFY);
|
||||
}
|
||||
}
|
||||
|
||||
void fire_user_return_notifiers(void);
|
||||
|
||||
#else
|
||||
|
||||
struct user_return_notifier {};
|
||||
|
||||
static inline void propagate_user_return_notify(struct task_struct *prev,
|
||||
struct task_struct *next)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void fire_user_return_notifiers(void) {}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user