linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] sched: fix the PREEMPT_ACTIVE check in __trace_sched_switch_state()
@ 2014-10-07 19:50 Oleg Nesterov
  2014-10-07 19:51 ` [PATCH 1/1] " Oleg Nesterov
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Oleg Nesterov @ 2014-10-07 19:50 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: Steven Rostedt, linux-kernel

And note that another caller of task_preempt_count(), set_cpu(), is
fine but it doesn't really need this helper.

And afaics we do not need ->saved_preempt_count at all, the trivial
patch below makes it unnecessary, we can kill it and all its users.

Not only this will simplify the code, this will make (well, almost)
the per-cpu preempt counter arch-agnostic.

Or I missed something?

Do you think this makes sense? If yes, I'll try to make the patches.

Oleg.
---

OBVIOUSLY INCOMPLETE, BREAKS EVERYTHING EXCEPT x86. Just to explain what
I mean.

(this depends on !__ARCH_WANT_UNLOCKED_CTXSW, but it was already removed
 and x86 doesn't use it anyway).


--- x/kernel/sched/core.c
+++ x/kernel/sched/core.c
@@ -2279,6 +2279,7 @@ asmlinkage __visible void schedule_tail(struct task_struct *prev)
 {
 	struct rq *rq = this_rq();
 
+	preempt_count_set(PREEMPT_DISABLED);
 	finish_task_switch(rq, prev);
 
 	/*
@@ -2304,6 +2305,7 @@ context_switch(struct rq *rq, struct task_struct *prev,
 	       struct task_struct *next)
 {
 	struct mm_struct *mm, *oldmm;
+	int pc;
 
 	prepare_task_switch(rq, prev, next);
 
@@ -2338,10 +2340,13 @@ context_switch(struct rq *rq, struct task_struct *prev,
 #endif
 
 	context_tracking_task_switch(prev, next);
+
 	/* Here we just switch the register state and the stack. */
+	pc = this_cpu_read(__preempt_count);
 	switch_to(prev, next, prev);
-
 	barrier();
+	preempt_count_set(pc);
+
 	/*
 	 * this_rq must be evaluated again because prev may have moved
 	 * CPUs since it called schedule(), thus the 'rq' on its stack


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2014-10-28 11:07 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-07 19:50 [PATCH 0/1] sched: fix the PREEMPT_ACTIVE check in __trace_sched_switch_state() Oleg Nesterov
2014-10-07 19:51 ` [PATCH 1/1] " Oleg Nesterov
2014-10-10  9:54   ` Peter Zijlstra
2014-10-10  9:56     ` Peter Zijlstra
2014-10-28 11:05   ` [tip:sched/core] sched: Fix " tip-bot for Oleg Nesterov
2014-10-08  8:00 ` [PATCH 0/1] sched: fix " Peter Zijlstra
2014-10-08 18:33   ` [PATCH 0/2] (Was: sched: fix the PREEMPT_ACTIVE check in __trace_sched_switch_state()) Oleg Nesterov
2014-10-08 18:33     ` [PATCH 1/2] sched: schedule_tail() should disable preemption Oleg Nesterov
2014-10-08 19:36       ` [PATCH v2 " Oleg Nesterov
2014-10-08 21:37         ` Kirill Tkhai
2014-10-09 14:57           ` Oleg Nesterov
2014-10-09 15:17             ` Peter Zijlstra
2014-10-09 16:57               ` Oleg Nesterov
2014-10-09 17:28                 ` Peter Zijlstra
2014-10-09 17:32                   ` Peter Zijlstra
2014-10-09 17:55                     ` Oleg Nesterov
2014-10-28 11:06         ` [tip:sched/core] sched: Fix schedule_tail() to " tip-bot for Oleg Nesterov
2014-10-08 18:33     ` [PATCH 2/2] sched: kill task_preempt_count() Oleg Nesterov
2014-10-28 11:06       ` [tip:sched/core] sched: Kill task_preempt_count() tip-bot for Oleg Nesterov
2014-10-09 19:32 ` [PATCH 0/1] sched: make finish_task_switch() return struct rq * Oleg Nesterov
2014-10-09 19:32   ` [PATCH 1/1] " Oleg Nesterov
2014-10-10 10:06     ` Peter Zijlstra
2014-10-10 17:06       ` Oleg Nesterov
2014-10-10 20:32         ` Peter Zijlstra
2014-10-14 17:57           ` Oleg Nesterov
2014-10-28 11:06     ` [tip:sched/core] sched: Make finish_task_switch() return ' struct rq *' tip-bot for Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).