All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: kernel test robot <lkp@intel.com>
Cc: LKP <lkp@01.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	wfg@linux.intel.com
Subject: Re: 85f1abe001 ("kthread, sched/wait: Fix kthread_parkme() .."): WARNING: CPU: 0 PID: 1 at kernel/kthread.c:486 kthread_park
Date: Fri, 4 May 2018 11:11:42 +0200	[thread overview]
Message-ID: <20180504091142.GI12235@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180503165452.GH12217@hirez.programming.kicks-ass.net>

On Thu, May 03, 2018 at 06:54:52PM +0200, Peter Zijlstra wrote:
> On Thu, May 03, 2018 at 11:52:31PM +0800, kernel test robot wrote:
> > [    0.011005] CPU: GenuineIntel Intel Core Processor (Haswell) (family: 0x6, model: 0x3c, stepping: 0x4)
> > [    0.012011] Spectre V2 : Spectre mitigation: kernel not compiled with retpoline; no mitigation available!
> > [    0.013949] Performance Events: no PMU driver, software events only.
> > [    0.019490] NMI watchdog: Perf event create on CPU 0 failed with -2
> > [    0.020005] NMI watchdog: Perf NMI watchdog permanently disabled
> > [    0.020692] WARNING: CPU: 0 PID: 1 at kernel/kthread.c:486 kthread_park+0x2b/0x56
> > [    0.021000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.17.0-rc3-00038-g85f1abe #687
> > [    0.021000] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
> > [    0.021000] EIP: kthread_park+0x2b/0x56
> > [    0.021000] EFLAGS: 00210202 CPU: 0
> > [    0.021000] EAX: cf464d40 EBX: cf422500 ECX: 00000000 EDX: 00000004
> > [    0.021000] ESI: c221e2c0 EDI: 00000000 EBP: cf42df68 ESP: cf42df60
> > [    0.021000]  DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068
> > [    0.021000] CR0: 80050033 CR2: ffffffff CR3: 022e8000 CR4: 00140690
> > [    0.021000] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
> > [    0.021000] DR6: fffe0ff0 DR7: 00000400
> > [    0.021000] Call Trace:
> > [    0.021000]  smpboot_update_cpumask_percpu_thread+0x28/0x42
> > [    0.021000]  softlockup_update_smpboot_threads+0x37/0x39
> > [    0.021000]  lockup_detector_reconfigure+0x17/0x62
> > [    0.021000]  lockup_detector_init+0x5d/0x69
> > [    0.021000]  kernel_init_freeable+0x52/0x15c
> > [    0.021000]  ? rest_init+0xf4/0xf4
> > [    0.021000]  kernel_init+0x8/0xd0
> > [    0.021000]  ret_from_fork+0x19/0x30
> > [    0.021000] Code: 55 89 e5 56 53 8b 50 14 0f ba e2 15 72 02 0f 0b 8b 98 44 03 00 00 80 e2 04 74 09 0f 0b be da ff ff ff eb 2c 8b 13 80 e2 04 74 09 <0f> 0b be f0 ff ff ff eb 1c 80 0b 04 8b 15 70 de f6 c1 31 f6 39 
> > [    0.021000] ---[ end trace 3a71adb42feecba7 ]---
> > [    0.021060] TSC deadline timer enabled
> 
> Clearly my machine didn't do that :-)
> 
> I think I see what's going on, this path actually does a kthread_park()
> when already parked, which sorta used to work.
> 
> Let me try and fix that.

I tried to reproduce using kvm, but I cannot trigger the above. I
suspect the below will cure things, can you confirm?

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 2017a39ab490..481951bf091d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -193,7 +193,7 @@ EXPORT_SYMBOL_GPL(kthread_parkme);
 
 void kthread_park_complete(struct task_struct *k)
 {
-	complete(&to_kthread(k)->parked);
+	complete_all(&to_kthread(k)->parked);
 }
 
 static int kthread(void *_create)
@@ -459,6 +459,7 @@ void kthread_unpark(struct task_struct *k)
 	if (test_bit(KTHREAD_IS_PER_CPU, &kthread->flags))
 		__kthread_bind(k, kthread->cpu, TASK_PARKED);
 
+	reinit_completion(&kthread->parked);
 	clear_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
 	wake_up_state(k, TASK_PARKED);
 }
@@ -483,9 +484,6 @@ int kthread_park(struct task_struct *k)
 	if (WARN_ON(k->flags & PF_EXITING))
 		return -ENOSYS;
 
-	if (WARN_ON_ONCE(test_bit(KTHREAD_SHOULD_PARK, &kthread->flags)))
-		return -EBUSY;
-
 	set_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
 	if (k != current) {
 		wake_up_process(k);

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: lkp@lists.01.org
Subject: Re: 85f1abe001 ("kthread, sched/wait: Fix kthread_parkme() .."): WARNING: CPU: 0 PID: 1 at kernel/kthread.c:486 kthread_park
Date: Fri, 04 May 2018 11:11:42 +0200	[thread overview]
Message-ID: <20180504091142.GI12235@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180503165452.GH12217@hirez.programming.kicks-ass.net>

[-- Attachment #1: Type: text/plain, Size: 3479 bytes --]

On Thu, May 03, 2018 at 06:54:52PM +0200, Peter Zijlstra wrote:
> On Thu, May 03, 2018 at 11:52:31PM +0800, kernel test robot wrote:
> > [    0.011005] CPU: GenuineIntel Intel Core Processor (Haswell) (family: 0x6, model: 0x3c, stepping: 0x4)
> > [    0.012011] Spectre V2 : Spectre mitigation: kernel not compiled with retpoline; no mitigation available!
> > [    0.013949] Performance Events: no PMU driver, software events only.
> > [    0.019490] NMI watchdog: Perf event create on CPU 0 failed with -2
> > [    0.020005] NMI watchdog: Perf NMI watchdog permanently disabled
> > [    0.020692] WARNING: CPU: 0 PID: 1 at kernel/kthread.c:486 kthread_park+0x2b/0x56
> > [    0.021000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.17.0-rc3-00038-g85f1abe #687
> > [    0.021000] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
> > [    0.021000] EIP: kthread_park+0x2b/0x56
> > [    0.021000] EFLAGS: 00210202 CPU: 0
> > [    0.021000] EAX: cf464d40 EBX: cf422500 ECX: 00000000 EDX: 00000004
> > [    0.021000] ESI: c221e2c0 EDI: 00000000 EBP: cf42df68 ESP: cf42df60
> > [    0.021000]  DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068
> > [    0.021000] CR0: 80050033 CR2: ffffffff CR3: 022e8000 CR4: 00140690
> > [    0.021000] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
> > [    0.021000] DR6: fffe0ff0 DR7: 00000400
> > [    0.021000] Call Trace:
> > [    0.021000]  smpboot_update_cpumask_percpu_thread+0x28/0x42
> > [    0.021000]  softlockup_update_smpboot_threads+0x37/0x39
> > [    0.021000]  lockup_detector_reconfigure+0x17/0x62
> > [    0.021000]  lockup_detector_init+0x5d/0x69
> > [    0.021000]  kernel_init_freeable+0x52/0x15c
> > [    0.021000]  ? rest_init+0xf4/0xf4
> > [    0.021000]  kernel_init+0x8/0xd0
> > [    0.021000]  ret_from_fork+0x19/0x30
> > [    0.021000] Code: 55 89 e5 56 53 8b 50 14 0f ba e2 15 72 02 0f 0b 8b 98 44 03 00 00 80 e2 04 74 09 0f 0b be da ff ff ff eb 2c 8b 13 80 e2 04 74 09 <0f> 0b be f0 ff ff ff eb 1c 80 0b 04 8b 15 70 de f6 c1 31 f6 39 
> > [    0.021000] ---[ end trace 3a71adb42feecba7 ]---
> > [    0.021060] TSC deadline timer enabled
> 
> Clearly my machine didn't do that :-)
> 
> I think I see what's going on, this path actually does a kthread_park()
> when already parked, which sorta used to work.
> 
> Let me try and fix that.

I tried to reproduce using kvm, but I cannot trigger the above. I
suspect the below will cure things, can you confirm?

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 2017a39ab490..481951bf091d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -193,7 +193,7 @@ EXPORT_SYMBOL_GPL(kthread_parkme);
 
 void kthread_park_complete(struct task_struct *k)
 {
-	complete(&to_kthread(k)->parked);
+	complete_all(&to_kthread(k)->parked);
 }
 
 static int kthread(void *_create)
@@ -459,6 +459,7 @@ void kthread_unpark(struct task_struct *k)
 	if (test_bit(KTHREAD_IS_PER_CPU, &kthread->flags))
 		__kthread_bind(k, kthread->cpu, TASK_PARKED);
 
+	reinit_completion(&kthread->parked);
 	clear_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
 	wake_up_state(k, TASK_PARKED);
 }
@@ -483,9 +484,6 @@ int kthread_park(struct task_struct *k)
 	if (WARN_ON(k->flags & PF_EXITING))
 		return -ENOSYS;
 
-	if (WARN_ON_ONCE(test_bit(KTHREAD_SHOULD_PARK, &kthread->flags)))
-		return -EBUSY;
-
 	set_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
 	if (k != current) {
 		wake_up_process(k);

  reply	other threads:[~2018-05-04  9:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 15:52 85f1abe001 ("kthread, sched/wait: Fix kthread_parkme() .."): WARNING: CPU: 0 PID: 1 at kernel/kthread.c:486 kthread_park kernel test robot
2018-05-03 15:52 ` kernel test robot
2018-05-03 16:54 ` Peter Zijlstra
2018-05-03 16:54   ` Peter Zijlstra
2018-05-04  9:11   ` Peter Zijlstra [this message]
2018-05-04  9:11     ` Peter Zijlstra
2018-05-25  9:46     ` [tip:sched/core] kthread: Allow kthread_park() on a parked kthread tip-bot for Peter Zijlstra
2018-05-24 12:42 85f1abe001 ("kthread, sched/wait: Fix kthread_parkme() .."): WARNING: CPU: 0 PID: 1 at kernel/kthread.c:486 kthread_park Meelis Roos
2018-05-24 12:53 ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180504091142.GI12235@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=lkp@intel.com \
    --cc=mingo@kernel.org \
    --cc=wfg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.