Skip to contentSkip to conversation

sched/clock: prevent tracing recursion in sched_clock_cpu()

PATCH In review Fernando Luis Vázquez Cao 4 participants 7 messages Mar 6, 2014 – Mar 11, 2014 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/clock: prevent tracing recursion in sched_clock_cpu()

From: Fernando Luis Vazquez Cao <[email protected]>

Prevent tracing of preempt_disable/enable() in sched_clock_cpu(). When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are traced and this causes trace_clock() users (and probably others) to go into an infinite recursion. Systems with a stable sched_clock() are not affected.

This problem is similar to that fixed by upstream commit 95ef1e52922 ("KVM guest: prevent tracing recursion with kvmclock").

Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Steven Rostedt <[email protected]>

---

kernel/sched/clock.c +2 -2
diff -urNp linux-3.14-rc5-orig/kernel/sched/clock.c linux-3.14-rc5/kernel/sched/clock.c
@@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
 	if (unlikely(!sched_clock_running))
 		return 0ull;
 
-	preempt_disable();
+	preempt_disable_notrace();
 	scd = cpu_sdc(cpu);
 
 	if (cpu != smp_processor_id())
 		clock = sched_clock_remote(scd);
 	else
 		clock = sched_clock_local(scd);
-	preempt_enable();
+	preempt_enable_notrace();
 
 	return clock;
 }
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, 06 Mar 2014 14:25:28 +0900 Fernando Luis Vázquez Cao…

From: Fernando Luis Vazquez Cao <[email protected]>

Prevent tracing of preempt_disable/enable() in sched_clock_cpu(). When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are traced and this causes trace_clock() users (and probably others) to go into an infinite recursion. Systems with a stable sched_clock() are not affected.

This problem is similar to that fixed by upstream commit 95ef1e52922 ("KVM guest: prevent tracing recursion with kvmclock").

Also similar to: 569d6557ab957.

-- Steve

Quoted 29 lines
Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Steven Rostedt <[email protected]>

---

diff -urNp linux-3.14-rc5-orig/kernel/sched/clock.c linux-3.14-rc5/kernel/sched/clock.c

kernel/sched/clock.c +2 -2
@@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
 	if (unlikely(!sched_clock_running))
 		return 0ull;
 
-	preempt_disable();
+	preempt_disable_notrace();
 	scd = cpu_sdc(cpu);
 
 	if (cpu != smp_processor_id())
 		clock = sched_clock_remote(scd);
 	else
 		clock = sched_clock_local(scd);
-	preempt_enable();
+	preempt_enable_notrace();
 
 	return clock;
 }
maintainer
#5 lore raw
In reply to Fernando Luis Vázquez Cao
Quoted 8 lines · Fernando Luis Vázquez Cao

From: Fernando Luis Vazquez Cao <[email protected]>

Prevent tracing of preempt_disable/enable() in sched_clock_cpu(). When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are traced and this causes trace_clock() users (and probably others) to go into an infinite recursion. Systems with a stable sched_clock() are not affected.

Quoted 8 lines

This problem is similar to that fixed by upstream commit 95ef1e52922 ("KVM guest: prevent tracing recursion with kvmclock").

Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Steven Rostedt <[email protected]>

Thanks!

#2 lore raw
In reply to Steven Rostedt
Quoted 11 lines · Steven Rostedt
Quoted 8 lines · On Thu, 06 Mar 2014 14:25:28 +0900 Fernando Luis Vázquez Cao…

From: Fernando Luis Vazquez Cao <[email protected]>

Prevent tracing of preempt_disable/enable() in sched_clock_cpu(). When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are traced and this causes trace_clock() users (and probably others) to go into an infinite recursion. Systems with a stable sched_clock() are not affected.

Quoted 5 lines
Quoted 2 lines

This problem is similar to that fixed by upstream commit 95ef1e52922 ("KVM guest: prevent tracing recursion with kvmclock").

Also similar to: 569d6557ab957.

Thank you four your review, Peter, Steven.

By the way, who is going to pick this patch? Do you want me to resend with Steven's Acked-by added?

- Fernando

#3 lore raw
Quoted 4 lines · On Mon, 10 Mar 2014 16:17:18 +0900 Fernando Luis Vázquez Cao…

Thank you four your review, Peter, Steven.

By the way, who is going to pick this patch? Do you want me to resend with Steven's Acked-by added?

I don't think you have to. I believe Peter got it. I know there's a bunch of patches he's trying to get pushed forward.

-- Steve

maintainer
#4 lore raw
Quoted 11 lines · Steven Rostedt
Quoted 4 lines · On Mon, 10 Mar 2014 16:17:18 +0900 Fernando Luis Vázquez Cao…

Thank you four your review, Peter, Steven.

By the way, who is going to pick this patch? Do you want me to resend with Steven's Acked-by added?

I don't think you have to. I believe Peter got it. I know there's a bunch of patches he's trying to get pushed forward.

Yeah, I do have it (and the scheduler patch you were after Steve), I just need to trick Ingo into actually looking at his computer somehow. He seems busy with real life stuff for a bit.

#6 lore raw

[tip:sched/core] sched/clock: Prevent tracing recursion in sched_clock_cpu()

In reply to Fernando Luis Vázquez Cao
sched/clock: Prevent tracing recursion in sched_clock_cpu()
Commit-ID:  96b3d28bf4b00f62fc8386ff5d487d1830793a3d
Gitweb:     http://git.kernel.org/tip/96b3d28bf4b00f62fc8386ff5d487d1830793a3d
Author:     Fernando Luis Vazquez Cao <[email protected]>
AuthorDate: Thu, 6 Mar 2014 14:25:28 +0900
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 11 Mar 2014 11:33:48 +0100

sched/clock: Prevent tracing recursion in sched_clock_cpu()

Prevent tracing of preempt_disable/enable() in sched_clock_cpu(). When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are traced and this causes trace_clock() users (and probably others) to go into an infinite recursion. Systems with a stable sched_clock() are not affected.

This problem is similar to that fixed by upstream commit 95ef1e52922 ("KVM guest: prevent tracing recursion with kvmclock").

---
 kernel/sched/clock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/clock.c +2 -2
index 43c2bcc..b30a292 100644
@@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
 	if (unlikely(!sched_clock_running))
 		return 0ull;
 
-	preempt_disable();
+	preempt_disable_notrace();
 	scd = cpu_sdc(cpu);
 
 	if (cpu != smp_processor_id())
 		clock = sched_clock_remote(scd);
 	else
 		clock = sched_clock_local(scd);
-	preempt_enable();
+	preempt_enable_notrace();
 
 	return clock;
 }