Re: [Query] Preemption (hogging) of the work handler

From: Rafael J. Wysocki
Date: Wed Jul 13 2016 - 08:06:02 EST


On Wed, Jul 13, 2016 at 9:00 AM, Sergey Senozhatsky
<sergey.senozhatsky.work@xxxxxxxxx> wrote:
> On (07/12/16 10:11), Viresh Kumar wrote:
>> +extern bool printk_sync_suspended;
>> static int suspend_enter(suspend_state_t state, bool *wakeup)
>> {
>> char suspend_abort[MAX_SUSPEND_ABORT_LEN];
>> @@ -218,6 +219,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
>> }
>>
>> arch_suspend_disable_irqs();
>> + printk_sync_suspended = true;
>> BUG_ON(!irqs_disabled());
>>
>> error = syscore_suspend();
>> @@ -237,6 +239,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
>> syscore_resume();
>> }
>>
>> + printk_sync_suspended = false;
>> arch_suspend_enable_irqs();
>> BUG_ON(irqs_disabled());
>>
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index 46bb017ac2c9..187054074b96 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -293,6 +293,7 @@ static u32 log_buf_len = __LOG_BUF_LEN;
>>
>> /* Control whether printing to console must be synchronous. */
>> static bool __read_mostly printk_sync = false;
>> +bool printk_sync_suspended = false;
>> /* Printing kthread for async printk */
>> static struct task_struct *printk_kthread;
>> /* When `true' printing thread has messages to print */
>> @@ -300,7 +301,7 @@ static bool printk_kthread_need_flush_console;
>>
>> static inline bool can_printk_async(void)
>> {
>> - return !printk_sync && printk_kthread;
>> + return !printk_sync && !printk_sync_suspended && printk_kthread;
>> }
>>
>> /* Return log buffer address */
>>
>>
>> i.e. I disabled async-printk after interrupts are disabled on the last
>> running CPU (0) and enabled it again before enabling interrupts back.
>>
>> This FIXES the hangs for me :)
>
> ah, just saw this. OK, very close to what I sent in another thread, so I
> guess it will work on your side.
> let me know if it doesn't, I'll fold it into 0001 and re-spin the series.
> thanks for your help!

But you need to do an analogous thing for hibernation. Essentially,
wherever disable_nonboot_cpus() is called.

Thanks,
Rafael