printk: Add printk_deferred_once
authorJohn Stultz <john.stultz@linaro.org>
Wed, 4 Jun 2014 23:11:41 +0000 (16:11 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 4 Jun 2014 23:54:17 +0000 (16:54 -0700)
Two of the three prink_deferred uses are really printk_once style
uses, so add a printk_deferred_once macro to simplify those call
sites.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/printk.h
kernel/sched/deadline.c
kernel/sched/rt.c

index 7847301e2837c9f9fae18d39466993e7d8f0fa49..f086d6c99dbc25f89cc3e76feb76e290a42491a8 100644 (file)
@@ -266,9 +266,20 @@ extern asmlinkage void dump_stack(void) __cold;
                printk(fmt, ##__VA_ARGS__);                     \
        }                                                       \
 })
+#define printk_deferred_once(fmt, ...)                         \
+({                                                             \
+       static bool __print_once __read_mostly;                 \
+                                                               \
+       if (!__print_once) {                                    \
+               __print_once = true;                            \
+               printk_deferred(fmt, ##__VA_ARGS__);            \
+       }                                                       \
+})
 #else
 #define printk_once(fmt, ...)                                  \
        no_printk(fmt, ##__VA_ARGS__)
+#define printk_deferred_once(fmt, ...)                         \
+       no_printk(fmt, ##__VA_ARGS__)
 #endif
 
 #define pr_emerg_once(fmt, ...)                                        \
index d17e1c48a79df4b9dd5f29ab69fd084f7ad2e724..e1574fca03b5fed87445e764fd9f21ca1887499d 100644 (file)
@@ -348,12 +348,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,
         * entity.
         */
        if (dl_time_before(dl_se->deadline, rq_clock(rq))) {
-               static bool lag_once = false;
-
-               if (!lag_once) {
-                       lag_once = true;
-                       printk_deferred("sched: DL replenish lagged to much\n");
-               }
+               printk_deferred_once("sched: DL replenish lagged to much\n");
                dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline;
                dl_se->runtime = pi_se->dl_runtime;
        }
index 5d7667b37c2163c1b3fcb5ff1898c1069a97dc22..b3512f1afce9361588a8ccb50f7ad75540122426 100644 (file)
@@ -890,14 +890,8 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
                 * but accrue some time due to boosting.
                 */
                if (likely(rt_b->rt_runtime)) {
-                       static bool once = false;
-
                        rt_rq->rt_throttled = 1;
-
-                       if (!once) {
-                               once = true;
-                               printk_deferred("sched: RT throttling activated\n");
-                       }
+                       printk_deferred_once("sched: RT throttling activated\n");
                } else {
                        /*
                         * In case we did anyway, make it go away,