History

Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull scheduler fixes from Ingo Molnar: "Two smaller fixes - plus a context tracking tracing fix that is a bit bigger" * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: tracing/context-tracking: Add preempt_schedule_context() for tracing sched: Fix clear NOHZ_BALANCE_KICK sched/x86: Construct all sibling maps if smt

Linus Torvalds committed 13 years ago

Commit a3d5c342 parents 86c7667 29bb9e54 files · +78 −9Browse files

Showing the changes to kernel (2 of 4 files). Show all

Unified · Split

2 files
  1. kernel/context_tracking.c +40 −0
  2. kernel/sched/core.c +17 −4
kernel/context_tracking.c+40−0
@@ -70,6 +70,46 @@ void user_enter(void) · 69 unmodified lines
7070 local_irq_restore(flags);
7171 }
7272
73+#ifdef CONFIG_PREEMPT
74+/**
75+ * preempt_schedule_context - preempt_schedule called by tracing
76+ *
77+ * The tracing infrastructure uses preempt_enable_notrace to prevent
78+ * recursion and tracing preempt enabling caused by the tracing
79+ * infrastructure itself. But as tracing can happen in areas coming
80+ * from userspace or just about to enter userspace, a preempt enable
81+ * can occur before user_exit() is called. This will cause the scheduler
82+ * to be called when the system is still in usermode.
83+ *
84+ * To prevent this, the preempt_enable_notrace will use this function
85+ * instead of preempt_schedule() to exit user context if needed before
86+ * calling the scheduler.
87+ */
88+void __sched notrace preempt_schedule_context(void)
89+{
90+ struct thread_info *ti = current_thread_info();
91+ enum ctx_state prev_ctx;
92+
93+ if (likely(ti->preempt_count || irqs_disabled()))
94+ return;
95+
96+ /*
97+ * Need to disable preemption in case user_exit() is traced
98+ * and the tracer calls preempt_enable_notrace() causing
99+ * an infinite recursion.
100+ */
101+ preempt_disable_notrace();
102+ prev_ctx = exception_enter();
103+ preempt_enable_no_resched_notrace();
104+
105+ preempt_schedule();
106+
107+ preempt_disable_notrace();
108+ exception_exit(prev_ctx);
109+ preempt_enable_notrace();
110+}
111+EXPORT_SYMBOL_GPL(preempt_schedule_context);
112+#endif /* CONFIG_PREEMPT */
73113
74114 /**
75115 * user_exit - Inform the context tracking that the CPU is
kernel/sched/core.c+17−4
@@ -633,7 +633,19 @@ void wake_up_nohz_cpu(int cpu) · 632 unmodified lines
633633 static inline bool got_nohz_idle_kick(void)
634634 {
635635 int cpu = smp_processor_id();
636− return idle_cpu(cpu) && test_bit(NOHZ_BALANCE_KICK, nohz_flags(cpu));
636+
637+ if (!test_bit(NOHZ_BALANCE_KICK, nohz_flags(cpu)))
638+ return false;
639+
640+ if (idle_cpu(cpu) && !need_resched())
641+ return true;
642+
643+ /*
644+ * We can't run Idle Load Balance on this CPU for this time so we
645+ * cancel it and clear NOHZ_BALANCE_KICK
646+ */
647+ clear_bit(NOHZ_BALANCE_KICK, nohz_flags(cpu));
648+ return false;
637649 }
638650
639651 #else /* CONFIG_NO_HZ_COMMON */
@@ -1393,8 +1405,9 @@ static void sched_ttwu_pending(void) · 753 unmodified lines
13931405
13941406 void scheduler_ipi(void)
13951407 {
1396− if (llist_empty(&this_rq()->wake_list) && !got_nohz_idle_kick()
1397− && !tick_nohz_full_cpu(smp_processor_id()))
1408+ if (llist_empty(&this_rq()->wake_list)
1409+ && !tick_nohz_full_cpu(smp_processor_id())
1410+ && !got_nohz_idle_kick())
13981411 return;
13991412
14001413 /*
@@ -1417,7 +1430,7 @@ void scheduler_ipi(void) · 16 unmodified lines
14171430 /*
14181431 * Check if someone kicked us for doing the nohz idle load balance.
14191432 */
1420− if (unlikely(got_nohz_idle_kick() && !need_resched())) {
1433+ if (unlikely(got_nohz_idle_kick())) {
14211434 this_rq()->idle_balance = 1;
14221435 raise_softirq_irqoff(SCHED_SOFTIRQ);
14231436 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t