linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, gkohli@codeaurora.org, tglx@linutronix.de,
	mpe@ellerman.id.au, bigeasy@linutronix.de,
	linux-kernel@vger.kernel.org, will.deacon@arm.com
Subject: Re: [PATCH 4/4] kthread: Simplify kthread_park() completion
Date: Fri, 8 Jun 2018 11:52:20 +0200	[thread overview]
Message-ID: <20180608095220.GA18941@redhat.com> (raw)
In-Reply-To: <20180607124006.266038375@infradead.org>

Peter,

I am travelling till the end of the next week, unlikely I will be able
to reply to emails or even read them.

But I want very much to comment this change,

On 06/07, Peter Zijlstra wrote:
>
> Now that smpboot_update_cpumask_percpu_thread() is gone, we no longer
> have anybody calling kthread_park() on already parked threads. So
> revert commit:
>
>   b1f5b378e126 ("kthread: Allow kthread_park() on a parked kthread")

Great, I obviously like this patch but the changelog should be fixed ;)

smpboot_update_cpumask_percpu_thread() was actually fine. And we can
(should) revert this commit in any case. Unless I am totally confused.

So how this code

	for_each_cpu_and(cpu, &tmp, cpu_online_mask)
		smpboot_park_thread(plug_thread, cpu);

in smpboot_update_cpumask_percpu_thread() can hit a KTHREAD_SHOULD_PARK
thread? Lets look into kernel test robot's .config:

	CONFIG_NR_CPUS=1

Now look at NR_CPUS==1 version of for_each_cpu* helpers:

	#define for_each_cpu(cpu, mask)			\
		for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
	#define for_each_cpu_not(cpu, mask)		\
		for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
	#define for_each_cpu_wrap(cpu, mask, start)	\
		for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)(start))
	#define for_each_cpu_and(cpu, mask, and)	\
		for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)

See? They all ignore the "mask" argument, and this is obviously wrong.

So even if the "tmp" cpumask is empty the code above always does

		smpboot_park_thread(plug_thread, 0);

and hits the already parked kthread.

Oleg.

  reply	other threads:[~2018-06-08  9:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 12:33 [PATCH 0/4] kthread/smpboot: More fixes Peter Zijlstra
2018-06-07 12:33 ` [PATCH 1/4] kthread, sched: Fix kthread_parkme() (again...) Peter Zijlstra
2018-06-07 12:33 ` [PATCH 2/4] watchdog/softlockup: Replace "watchdog/%u" threads with cpu_stop_work Peter Zijlstra
2018-06-07 14:24   ` Peter Zijlstra
2018-06-07 14:42     ` Peter Zijlstra
2018-06-08 13:57     ` Oleg Nesterov
2018-06-12 12:17       ` Peter Zijlstra
2018-06-07 12:33 ` [PATCH 3/4] smpboot: Remove cpumask from the API Peter Zijlstra
2018-06-07 12:33 ` [PATCH 4/4] kthread: Simplify kthread_park() completion Peter Zijlstra
2018-06-08  9:52   ` Oleg Nesterov [this message]
2018-06-12 12:42     ` Peter Zijlstra
2018-06-25  7:12     ` Peter Zijlstra
2018-06-25 16:53       ` Oleg Nesterov

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=20180608095220.GA18941@redhat.com \
    --to=oleg@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=gkohli@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).