Re: [RFC PATCH 9/9] printk: Wake up klogd using irq_work

2012-10-29 Thread Frederic Weisbecker
2012/10/29 Steven Rostedt :
> On Mon, 2012-10-29 at 14:28 +0100, Frederic Weisbecker wrote:
>> klogd is woken up asynchronously from the tick in order
>> to do it safely.
>>
>> However if printk is called when the tick is stopped, the reader
>> won't be woken up until the next interrupt, which might not fire
>> before a while. As a result, the user may miss some message.
>
> Just a grammar nit (and goes for your previous patch as well). We say
> "might not fire for a while." or you could say ".. for some time", but
> not "before a while" ;-)

Right!

>
> I wounder what the French translation of that is.

You don't really want to know ;)
But as you guess, this is quite close to something like "before a while" ;)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH 9/9] printk: Wake up klogd using irq_work

2012-10-29 Thread Steven Rostedt
On Mon, 2012-10-29 at 14:28 +0100, Frederic Weisbecker wrote:
> klogd is woken up asynchronously from the tick in order
> to do it safely.
> 
> However if printk is called when the tick is stopped, the reader
> won't be woken up until the next interrupt, which might not fire
> before a while. As a result, the user may miss some message.

Just a grammar nit (and goes for your previous patch as well). We say
"might not fire for a while." or you could say ".. for some time", but
not "before a while" ;-)

I wounder what the French translation of that is.

-- Steve


> 
> To fix this, lets implement the printk tick using a lazy irq work.
> This subsystem takes care of the timer tick state and can
> fix up accordingly.
> 
> Signed-off-by: Frederic Weisbecker 


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


[RFC PATCH 9/9] printk: Wake up klogd using irq_work

2012-10-29 Thread Frederic Weisbecker
klogd is woken up asynchronously from the tick in order
to do it safely.

However if printk is called when the tick is stopped, the reader
won't be woken up until the next interrupt, which might not fire
before a while. As a result, the user may miss some message.

To fix this, lets implement the printk tick using a lazy irq work.
This subsystem takes care of the timer tick state and can
fix up accordingly.

Signed-off-by: Frederic Weisbecker 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Andrew Morton 
Cc: Steven Rostedt 
Cc: Paul Gortmaker 
---
 include/linux/printk.h   |3 ---
 init/Kconfig |1 +
 kernel/printk.c  |   12 +---
 kernel/time/tick-sched.c |2 +-
 kernel/timer.c   |1 -
 5 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 9afc01e..86c4b62 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -98,9 +98,6 @@ int no_printk(const char *fmt, ...)
 extern asmlinkage __printf(1, 2)
 void early_printk(const char *fmt, ...);
 
-extern int printk_needs_cpu(int cpu);
-extern void printk_tick(void);
-
 #ifdef CONFIG_PRINTK
 asmlinkage __printf(5, 0)
 int vprintk_emit(int facility, int level,
diff --git a/init/Kconfig b/init/Kconfig
index 8ba9fc3..9c42e6a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1184,6 +1184,7 @@ config HOTPLUG
 config PRINTK
default y
bool "Enable support for printk" if EXPERT
+   select IRQ_WORK
help
  This option enables normal printk support. Removing it
  eliminates most of the message strings from the kernel image
diff --git a/kernel/printk.c b/kernel/printk.c
index 66a2ea3..bb1b0d3 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -1956,7 +1957,7 @@ int is_console_locked(void)
 static DEFINE_PER_CPU(int, printk_pending);
 static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);
 
-void printk_tick(void)
+static void wake_up_klogd_work_func(struct irq_work *irq_work)
 {
if (__this_cpu_read(printk_pending)) {
int pending = __this_cpu_xchg(printk_pending, 0);
@@ -1969,17 +1970,14 @@ void printk_tick(void)
}
 }
 
-int printk_needs_cpu(int cpu)
-{
-   if (cpu_is_offline(cpu))
-   printk_tick();
-   return __this_cpu_read(printk_pending);
-}
+static DEFINE_IRQ_WORK_LAZY(wake_up_klogd_work, wake_up_klogd_work_func);
 
 void wake_up_klogd(void)
 {
if (waitqueue_active(_wait))
this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
+
+   irq_work_queue(_up_klogd_work);
 }
 
 static void console_cont_flush(char *text, size_t size)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7ac2fd8..0efed16 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -289,7 +289,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched 
*ts,
time_delta = timekeeping_max_deferment();
} while (read_seqretry(_lock, seq));
 
-   if (rcu_needs_cpu(cpu, _delta_jiffies) || printk_needs_cpu(cpu) ||
+   if (rcu_needs_cpu(cpu, _delta_jiffies) ||
arch_needs_cpu(cpu) || irq_work_needs_cpu()) {
next_jiffies = last_jiffies + 1;
delta_jiffies = 1;
diff --git a/kernel/timer.c b/kernel/timer.c
index d5de1b2..5d6d0f1 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1349,7 +1349,6 @@ void update_process_times(int user_tick)
account_process_tick(p, user_tick);
run_local_timers();
rcu_check_callbacks(cpu, user_tick);
-   printk_tick();
 #ifdef CONFIG_IRQ_WORK
if (in_irq())
irq_work_run();
-- 
1.7.5.4

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


Re: [RFC PATCH 9/9] printk: Wake up klogd using irq_work

2012-10-29 Thread Frederic Weisbecker
2012/10/29 Steven Rostedt rost...@goodmis.org:
 On Mon, 2012-10-29 at 14:28 +0100, Frederic Weisbecker wrote:
 klogd is woken up asynchronously from the tick in order
 to do it safely.

 However if printk is called when the tick is stopped, the reader
 won't be woken up until the next interrupt, which might not fire
 before a while. As a result, the user may miss some message.

 Just a grammar nit (and goes for your previous patch as well). We say
 might not fire for a while. or you could say .. for some time, but
 not before a while ;-)

Right!


 I wounder what the French translation of that is.

You don't really want to know ;)
But as you guess, this is quite close to something like before a while ;)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 9/9] printk: Wake up klogd using irq_work

2012-10-29 Thread Frederic Weisbecker
klogd is woken up asynchronously from the tick in order
to do it safely.

However if printk is called when the tick is stopped, the reader
won't be woken up until the next interrupt, which might not fire
before a while. As a result, the user may miss some message.

To fix this, lets implement the printk tick using a lazy irq work.
This subsystem takes care of the timer tick state and can
fix up accordingly.

Signed-off-by: Frederic Weisbecker fweis...@gmail.com
Cc: Peter Zijlstra pet...@infradead.org
Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@kernel.org
Cc: Andrew Morton a...@linux-foundation.org
Cc: Steven Rostedt rost...@goodmis.org
Cc: Paul Gortmaker paul.gortma...@windriver.com
---
 include/linux/printk.h   |3 ---
 init/Kconfig |1 +
 kernel/printk.c  |   12 +---
 kernel/time/tick-sched.c |2 +-
 kernel/timer.c   |1 -
 5 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 9afc01e..86c4b62 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -98,9 +98,6 @@ int no_printk(const char *fmt, ...)
 extern asmlinkage __printf(1, 2)
 void early_printk(const char *fmt, ...);
 
-extern int printk_needs_cpu(int cpu);
-extern void printk_tick(void);
-
 #ifdef CONFIG_PRINTK
 asmlinkage __printf(5, 0)
 int vprintk_emit(int facility, int level,
diff --git a/init/Kconfig b/init/Kconfig
index 8ba9fc3..9c42e6a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1184,6 +1184,7 @@ config HOTPLUG
 config PRINTK
default y
bool Enable support for printk if EXPERT
+   select IRQ_WORK
help
  This option enables normal printk support. Removing it
  eliminates most of the message strings from the kernel image
diff --git a/kernel/printk.c b/kernel/printk.c
index 66a2ea3..bb1b0d3 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -42,6 +42,7 @@
 #include linux/notifier.h
 #include linux/rculist.h
 #include linux/poll.h
+#include linux/irq_work.h
 
 #include asm/uaccess.h
 
@@ -1956,7 +1957,7 @@ int is_console_locked(void)
 static DEFINE_PER_CPU(int, printk_pending);
 static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);
 
-void printk_tick(void)
+static void wake_up_klogd_work_func(struct irq_work *irq_work)
 {
if (__this_cpu_read(printk_pending)) {
int pending = __this_cpu_xchg(printk_pending, 0);
@@ -1969,17 +1970,14 @@ void printk_tick(void)
}
 }
 
-int printk_needs_cpu(int cpu)
-{
-   if (cpu_is_offline(cpu))
-   printk_tick();
-   return __this_cpu_read(printk_pending);
-}
+static DEFINE_IRQ_WORK_LAZY(wake_up_klogd_work, wake_up_klogd_work_func);
 
 void wake_up_klogd(void)
 {
if (waitqueue_active(log_wait))
this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
+
+   irq_work_queue(wake_up_klogd_work);
 }
 
 static void console_cont_flush(char *text, size_t size)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7ac2fd8..0efed16 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -289,7 +289,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched 
*ts,
time_delta = timekeeping_max_deferment();
} while (read_seqretry(xtime_lock, seq));
 
-   if (rcu_needs_cpu(cpu, rcu_delta_jiffies) || printk_needs_cpu(cpu) ||
+   if (rcu_needs_cpu(cpu, rcu_delta_jiffies) ||
arch_needs_cpu(cpu) || irq_work_needs_cpu()) {
next_jiffies = last_jiffies + 1;
delta_jiffies = 1;
diff --git a/kernel/timer.c b/kernel/timer.c
index d5de1b2..5d6d0f1 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1349,7 +1349,6 @@ void update_process_times(int user_tick)
account_process_tick(p, user_tick);
run_local_timers();
rcu_check_callbacks(cpu, user_tick);
-   printk_tick();
 #ifdef CONFIG_IRQ_WORK
if (in_irq())
irq_work_run();
-- 
1.7.5.4

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


Re: [RFC PATCH 9/9] printk: Wake up klogd using irq_work

2012-10-29 Thread Steven Rostedt
On Mon, 2012-10-29 at 14:28 +0100, Frederic Weisbecker wrote:
 klogd is woken up asynchronously from the tick in order
 to do it safely.
 
 However if printk is called when the tick is stopped, the reader
 won't be woken up until the next interrupt, which might not fire
 before a while. As a result, the user may miss some message.

Just a grammar nit (and goes for your previous patch as well). We say
might not fire for a while. or you could say .. for some time, but
not before a while ;-)

I wounder what the French translation of that is.

-- Steve


 
 To fix this, lets implement the printk tick using a lazy irq work.
 This subsystem takes care of the timer tick state and can
 fix up accordingly.
 
 Signed-off-by: Frederic Weisbecker fweis...@gmail.com


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