diff mbox

[1/4] printk: Re-add irqsave/restore in printk_sched

Message ID 1399068558-2373-2-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz May 2, 2014, 10:09 p.m. UTC
A commit in akpm's tree (printk: remove separate printk_sched
buffers...), removed the printk_sched irqsave/restore lines
since it was safe for current users. Since we may be expanding
usage of printk_sched(), re-add the irqsave/restore logic
to make the functionality more generally safe.

Cc: 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>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 kernel/printk/printk.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jan Kara May 4, 2014, 2:58 p.m. UTC | #1
On Fri 02-05-14 15:09:15, John Stultz wrote:
> A commit in akpm's tree (printk: remove separate printk_sched
> buffers...), removed the printk_sched irqsave/restore lines
> since it was safe for current users. Since we may be expanding
> usage of printk_sched(), re-add the irqsave/restore logic
> to make the functionality more generally safe.
  So I'm just wondering: Do you have anything particular for which you need
interrupts disabled? Won't e.g. disabling preemption be enough?

								Honza

> Cc: 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>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  kernel/printk/printk.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 82d19e6..bf62f2b 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2586,15 +2586,18 @@ void wake_up_klogd(void)
>  
>  int printk_sched(const char *fmt, ...)
>  {
> +	unsigned long flags;
>  	va_list args;
>  	int r;
>  
> +	local_irq_save(flags);
>  	va_start(args, fmt);
>  	r = vprintk_emit(0, SCHED_MESSAGE_LOGLEVEL, NULL, 0, fmt, args);
>  	va_end(args);
>  
>  	__this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
>  	irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
> +	local_irq_restore(flags);
>  
>  	return r;
>  }
> -- 
> 1.9.1
>
Peter Zijlstra May 4, 2014, 4:13 p.m. UTC | #2
On Sun, May 04, 2014 at 04:58:47PM +0200, Jan Kara wrote:
> On Fri 02-05-14 15:09:15, John Stultz wrote:
> > A commit in akpm's tree (printk: remove separate printk_sched
> > buffers...), removed the printk_sched irqsave/restore lines
> > since it was safe for current users. Since we may be expanding
> > usage of printk_sched(), re-add the irqsave/restore logic
> > to make the functionality more generally safe.
>   So I'm just wondering: Do you have anything particular for which you need
> interrupts disabled? Won't e.g. disabling preemption be enough?

Yeah, I think preemption disabled is sufficient.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
John Stultz May 5, 2014, 8:16 p.m. UTC | #3
On 05/04/2014 09:13 AM, Peter Zijlstra wrote:
> On Sun, May 04, 2014 at 04:58:47PM +0200, Jan Kara wrote:
>> On Fri 02-05-14 15:09:15, John Stultz wrote:
>>> A commit in akpm's tree (printk: remove separate printk_sched
>>> buffers...), removed the printk_sched irqsave/restore lines
>>> since it was safe for current users. Since we may be expanding
>>> usage of printk_sched(), re-add the irqsave/restore logic
>>> to make the functionality more generally safe.
>>   So I'm just wondering: Do you have anything particular for which you need
>> interrupts disabled? Won't e.g. disabling preemption be enough?
> Yeah, I think preemption disabled is sufficient.

Ok, will change this and resend.

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

Patch

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 82d19e6..bf62f2b 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2586,15 +2586,18 @@  void wake_up_klogd(void)
 
 int printk_sched(const char *fmt, ...)
 {
+	unsigned long flags;
 	va_list args;
 	int r;
 
+	local_irq_save(flags);
 	va_start(args, fmt);
 	r = vprintk_emit(0, SCHED_MESSAGE_LOGLEVEL, NULL, 0, fmt, args);
 	va_end(args);
 
 	__this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
 	irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
+	local_irq_restore(flags);
 
 	return r;
 }