Messages in this thread Patch in this message | | | From | Sergey Senozhatsky <> | Subject | [RFC][PATCHv3 4/5] printk: enable printk offloading | Date | Tue, 9 May 2017 17:28:58 +0900 |
| |
Initialize kernel printing thread and make printk offloading possible. By default `atomic_print_limit' is set to 0, so no offloading will take place, unless requested by user.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> --- kernel/printk/printk.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ba640fbcee7c..81ea575728b9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -49,6 +49,7 @@ #include <linux/sched/debug.h> #include <linux/sched/task_stack.h> #include <linux/kthread.h> +#include <uapi/linux/sched/types.h> #include <linux/uaccess.h> #include <asm/sections.h> @@ -2927,6 +2928,43 @@ static DEFINE_PER_CPU(struct irq_work, wake_up_klogd_work) = { .flags = IRQ_WORK_LAZY, }; +static int printk_kthread_func(void *data) +{ + while (1) { + set_current_state(TASK_INTERRUPTIBLE); + if (!test_bit(PRINTK_PENDING_OUTPUT, &printk_pending)) + schedule(); + + __set_current_state(TASK_RUNNING); + + console_lock(); + console_unlock(); + } + + return 0; +} + +/* + * Init printk kthread at late_initcall stage, after core/arch/device/etc. + * initialization. + */ +static int __init init_printk_kthread(void) +{ + struct task_struct *thread; + struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO / 2 }; + + thread = kthread_run(printk_kthread_func, NULL, "printk"); + if (IS_ERR(thread)) { + pr_err("printk: unable to create printing thread\n"); + return PTR_ERR(thread); + } + + sched_setscheduler(thread, SCHED_FIFO, ¶m); + printk_kthread = thread; + return 0; +} +late_initcall(init_printk_kthread); + void wake_up_klogd(void) { preempt_disable(); -- 2.12.2
| |