|
|
@@ -2151,12 +2151,15 @@ void wake_up_new_task(struct task_struct *p)
|
|
|
|
|
|
#ifdef CONFIG_PREEMPT_NOTIFIERS
|
|
|
|
|
|
+static struct static_key preempt_notifier_key = STATIC_KEY_INIT_FALSE;
|
|
|
+
|
|
|
/**
|
|
|
* preempt_notifier_register - tell me when current is being preempted & rescheduled
|
|
|
* @notifier: notifier struct to register
|
|
|
*/
|
|
|
void preempt_notifier_register(struct preempt_notifier *notifier)
|
|
|
{
|
|
|
+ static_key_slow_inc(&preempt_notifier_key);
|
|
|
hlist_add_head(¬ifier->link, ¤t->preempt_notifiers);
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(preempt_notifier_register);
|
|
|
@@ -2170,10 +2173,11 @@ EXPORT_SYMBOL_GPL(preempt_notifier_register);
|
|
|
void preempt_notifier_unregister(struct preempt_notifier *notifier)
|
|
|
{
|
|
|
hlist_del(¬ifier->link);
|
|
|
+ static_key_slow_dec(&preempt_notifier_key);
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(preempt_notifier_unregister);
|
|
|
|
|
|
-static void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
|
+static void __fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
|
{
|
|
|
struct preempt_notifier *notifier;
|
|
|
|
|
|
@@ -2181,9 +2185,15 @@ static void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
|
notifier->ops->sched_in(notifier, raw_smp_processor_id());
|
|
|
}
|
|
|
|
|
|
+static __always_inline void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
|
+{
|
|
|
+ if (static_key_false(&preempt_notifier_key))
|
|
|
+ __fire_sched_in_preempt_notifiers(curr);
|
|
|
+}
|
|
|
+
|
|
|
static void
|
|
|
-fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
|
- struct task_struct *next)
|
|
|
+__fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
|
+ struct task_struct *next)
|
|
|
{
|
|
|
struct preempt_notifier *notifier;
|
|
|
|
|
|
@@ -2191,13 +2201,21 @@ fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
|
notifier->ops->sched_out(notifier, next);
|
|
|
}
|
|
|
|
|
|
+static __always_inline void
|
|
|
+fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
|
+ struct task_struct *next)
|
|
|
+{
|
|
|
+ if (static_key_false(&preempt_notifier_key))
|
|
|
+ __fire_sched_out_preempt_notifiers(curr, next);
|
|
|
+}
|
|
|
+
|
|
|
#else /* !CONFIG_PREEMPT_NOTIFIERS */
|
|
|
|
|
|
-static void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
|
+static inline void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-static void
|
|
|
+static inline void
|
|
|
fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
|
struct task_struct *next)
|
|
|
{
|