Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91d1aa43 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Paul E. McKenney
Browse files

context_tracking: New context tracking susbsystem



Create a new subsystem that probes on kernel boundaries
to keep track of the transitions between level contexts
with two basic initial contexts: user or kernel.

This is an abstraction of some RCU code that use such tracking
to implement its userspace extended quiescent state.

We need to pull this up from RCU into this new level of indirection
because this tracking is also going to be used to implement an "on
demand" generic virtual cputime accounting. A necessary step to
shutdown the tick while still accounting the cputime.

Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Gilad Ben-Yossef <gilad@benyossef.com>
Reviewed-by: default avatarSteven Rostedt <rostedt@goodmis.org>
[ paulmck: fix whitespace error and email address. ]
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 4e79752c
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -300,15 +300,16 @@ config SECCOMP_FILTER

	  See Documentation/prctl/seccomp_filter.txt for details.

config HAVE_RCU_USER_QS
config HAVE_CONTEXT_TRACKING
	bool
	help
	  Provide kernel entry/exit hooks necessary for userspace
	  RCU extended quiescent state. Syscalls need to be wrapped inside
	  rcu_user_exit()-rcu_user_enter() through the slow path using
	  TIF_NOHZ flag. Exceptions handlers must be wrapped as well. Irqs
	  are already protected inside rcu_irq_enter/rcu_irq_exit() but
	  preemption or signal handling on irq exit still need to be protected.
	  Provide kernel/user boundaries probes necessary for subsystems
	  that need it, such as userspace RCU extended quiescent state.
	  Syscalls need to be wrapped inside user_exit()-user_enter() through
	  the slow path using TIF_NOHZ flag. Exceptions handlers must be
	  wrapped as well. Irqs are already protected inside
	  rcu_irq_enter/rcu_irq_exit() but preemption or signal handling on
	  irq exit still need to be protected.

config HAVE_VIRT_CPU_ACCOUNTING
	bool
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ config X86
	select KTIME_SCALAR if X86_32
	select GENERIC_STRNCPY_FROM_USER
	select GENERIC_STRNLEN_USER
	select HAVE_RCU_USER_QS if X86_64
	select HAVE_CONTEXT_TRACKING if X86_64
	select HAVE_IRQ_TIME_ACCOUNTING
	select GENERIC_KERNEL_THREAD
	select GENERIC_KERNEL_EXECVE
+7 −8
Original line number Diff line number Diff line
#ifndef _ASM_X86_RCU_H
#define _ASM_X86_RCU_H
#ifndef _ASM_X86_CONTEXT_TRACKING_H
#define _ASM_X86_CONTEXT_TRACKING_H

#ifndef __ASSEMBLY__

#include <linux/rcupdate.h>
#include <linux/context_tracking.h>
#include <asm/ptrace.h>

static inline void exception_enter(struct pt_regs *regs)
{
	rcu_user_exit();
	user_exit();
}

static inline void exception_exit(struct pt_regs *regs)
{
#ifdef CONFIG_RCU_USER_QS
#ifdef CONFIG_CONTEXT_TRACKING
	if (user_mode(regs))
		rcu_user_enter();
		user_enter();
#endif
}

#else /* __ASSEMBLY__ */

#ifdef CONFIG_RCU_USER_QS
#ifdef CONFIG_CONTEXT_TRACKING
# define SCHEDULE_USER call schedule_user
#else
# define SCHEDULE_USER call schedule
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@
#include <asm/ftrace.h>
#include <asm/percpu.h>
#include <asm/asm.h>
#include <asm/rcu.h>
#include <asm/context_tracking.h>
#include <asm/smap.h>
#include <linux/err.h>

+4 −4
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
#include <linux/signal.h>
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
#include <linux/rcupdate.h>
#include <linux/context_tracking.h>

#include <asm/uaccess.h>
#include <asm/pgtable.h>
@@ -1461,7 +1461,7 @@ long syscall_trace_enter(struct pt_regs *regs)
{
	long ret = 0;

	rcu_user_exit();
	user_exit();

	/*
	 * If we stepped into a sysenter/syscall insn, it trapped in
@@ -1516,7 +1516,7 @@ void syscall_trace_leave(struct pt_regs *regs)
	 * or do_notify_resume(), in which case we can be in RCU
	 * user mode.
	 */
	rcu_user_exit();
	user_exit();

	audit_syscall_exit(regs);

@@ -1534,5 +1534,5 @@ void syscall_trace_leave(struct pt_regs *regs)
	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
		tracehook_report_syscall_exit(regs, step);

	rcu_user_enter();
	user_enter();
}
Loading