Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1234920 > unrolled thread

[RFC][PATCH 11/11] sched: More notrace

Started byPeter Zijlstra <peterz@infradead.org>
First post2015-09-29 11:50 +0200
Last post2015-09-29 18:00 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC][PATCH 11/11] sched: More notrace Peter Zijlstra <peterz@infradead.org> - 2015-09-29 11:50 +0200
    Re: [RFC][PATCH 11/11] sched: More notrace Thomas Gleixner <tglx@linutronix.de> - 2015-09-29 15:30 +0200
    Re: [RFC][PATCH 11/11] sched: More notrace Steven Rostedt <rostedt@goodmis.org> - 2015-09-29 18:00 +0200

#1234920 — [RFC][PATCH 11/11] sched: More notrace

FromPeter Zijlstra <peterz@infradead.org>
Date2015-09-29 11:50 +0200
Subject[RFC][PATCH 11/11] sched: More notrace
Message-ID<qdZHQ-2IS-11@gated-at.bofh.it>
preempt_schedule_common() is marked notrace, but it does not use
_notrace() preempt_count functions and __schedule() is also not marked
notrace, which means that its perfectly possible to end up in the
tracer from preempt_schedule_common().

So either we need more notrace, or we need to remove notrace from
preempt_schedule_common().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/sched/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3044,7 +3044,7 @@ pick_next_task(struct rq *rq, struct tas
  *
  * WARNING: must be called with preemption disabled!
  */
-static void __sched __schedule(bool preempt)
+static void __sched notrace __schedule(bool preempt)
 {
 	struct task_struct *prev, *next;
 	unsigned long *switch_count;
@@ -3190,9 +3190,9 @@ void __sched schedule_preempt_disabled(v
 static void __sched notrace preempt_schedule_common(void)
 {
 	do {
-		preempt_disable();
+		preempt_disable_notrace();
 		__schedule(true);
-		sched_preempt_enable_no_resched();
+		preempt_enable_no_resched_notrace();
 
 		/*
 		 * Check again in case we missed a preemption opportunity


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1235053

FromThomas Gleixner <tglx@linutronix.de>
Date2015-09-29 15:30 +0200
Message-ID<qe38K-7J7-17@gated-at.bofh.it>
In reply to#1234920
On Tue, 29 Sep 2015, Peter Zijlstra wrote:

> preempt_schedule_common() is marked notrace, but it does not use
> _notrace() preempt_count functions and __schedule() is also not marked
> notrace, which means that its perfectly possible to end up in the
> tracer from preempt_schedule_common().
> 
> So either we need more notrace, or we need to remove notrace from
> preempt_schedule_common().

More notrace is the right thing to do. We have enough pointless
information in tracing already.

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1235337

FromSteven Rostedt <rostedt@goodmis.org>
Date2015-09-29 18:00 +0200
Message-ID<qe5tU-2x8-17@gated-at.bofh.it>
In reply to#1234920
On Tue, 29 Sep 2015 11:28:36 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> preempt_schedule_common() is marked notrace, but it does not use
> _notrace() preempt_count functions and __schedule() is also not marked
> notrace, which means that its perfectly possible to end up in the
> tracer from preempt_schedule_common().
> 
> So either we need more notrace, or we need to remove notrace from
> preempt_schedule_common().

Yep, there's some history to this. This was originally the issue that
caused function tracing to go into infinite recursion. But now we have
preempt_schedule_notrace(), which is used by the function tracer, and
that function must not be traced till preemption is disabled.

Now if function tracing is running and we take an interrupt when
NEED_RESCHED is set, it calls

  preempt_schedule_common() (not traced)

But then that calls preempt_disable() (traced)

function tracer calls preempt_disable_notrace() followed by
preempt_enable_notrace() which will see NEED_RESCHED set, and it will
call preempt_schedule_notrace(), which stops the recursion, but
still calls __schedule() here, and that means when we return, we call
the __schedule() from preempt_schedule_common().

That said, I prefer this patch. Preemption is disabled before calling
__schedule(), and we get rid of a one round recursion with the
scheduler.

Feel free to add any of the above to your change log.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  kernel/sched/core.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3044,7 +3044,7 @@ pick_next_task(struct rq *rq, struct tas
>   *
>   * WARNING: must be called with preemption disabled!
>   */
> -static void __sched __schedule(bool preempt)
> +static void __sched notrace __schedule(bool preempt)
>  {
>  	struct task_struct *prev, *next;
>  	unsigned long *switch_count;
> @@ -3190,9 +3190,9 @@ void __sched schedule_preempt_disabled(v
>  static void __sched notrace preempt_schedule_common(void)
>  {
>  	do {
> -		preempt_disable();
> +		preempt_disable_notrace();
>  		__schedule(true);
> -		sched_preempt_enable_no_resched();
> +		preempt_enable_no_resched_notrace();
>  
>  		/*
>  		 * Check again in case we missed a preemption opportunity
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web