mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Tejun Heo <htejun@gmail.com>, LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH] sched/kthread: Complain loudly when others violate our flags
Date: Wed, 28 Sep 2011 02:22:49 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1109280211400.2711@ionos> (raw)
In-Reply-To: <1317158254.26514.55.camel@gandalf.stny.rr.com>

On Tue, 27 Sep 2011, Steven Rostedt wrote:
> I looked at the task that it tried to migrate, and it happened to be the
> kworker thread! Then I went into kernel/workqueue.c and found this
> nonsense:
> 
> 	if (bind && !on_unbound_cpu)
> 		kthread_bind(worker->task, gcwq->cpu);
> 	else {
> 		worker->task->flags |= PF_THREAD_BOUND;
> 		if (on_unbound_cpu)
> 			worker->flags |= WORKER_UNBOUND;
> 	}
> 
> Nothing but the scheduler and kthread_bind() has the right to set the
> PF_THREAD_BOUND flag. Especially when the thread IS NOT BOUNDED!!!!!!

Yikes, I somehow missed that gem. :(
 
> I don't go around and stick my hand down your pants to play with your
> flags! Don't stick your hand in ours and play with our flags!
> 
> WTF is the workqueue code setting the PF_THREAD_BOUND flag manually?
> Talk about fragile coupling! You just made this flag meaningless. Don't
> do that.

And looking at the hotplug code in that very file is just making me
more nervous about that abuse.

> Sorry but I just wasted two whole days because of this nonsense and I'm
> not particularly happy about it.
>  
> -- Steve
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> 
> diff --git a/kernel/sched.c b/kernel/sched.c
> index ec5f472..682a90c 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -2233,6 +2233,9 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
>  	if (task_cpu(p) != new_cpu) {
>  		p->se.nr_migrations++;
>  		perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0);
> +		if (WARN_ON(p->flags & PF_THREAD_BOUND))
> +			printk(KERN_WARNING "migrating bounded task %s:%d\n",
> +			       p->comm, p->pid);

That should be a if (WARN(...)) and if triggers we should just refuse
to migrate it. So probably set_task_cpu() is not the proper place for
that. Can we move that check on layer up to avoid it reaching
set_task_cpu() ?

>  	}
>  
>  	__set_task_cpu(p, new_cpu);

And please submit a patch which gets rid of

> 		worker->task->flags |= PF_THREAD_BOUND;

Thanks,

	tglx

  reply	other threads:[~2011-09-28  0:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 21:17 Steven Rostedt
2011-09-28  0:22 ` Thomas Gleixner [this message]
2011-09-30  3:48 ` Tejun Heo
2011-09-30  4:05   ` Steven Rostedt
2011-09-30  4:14     ` Tejun Heo
2011-09-30  8:34       ` Peter Zijlstra
2011-09-30  8:55         ` Tejun Heo
2011-09-30  9:04           ` Peter Zijlstra
2011-10-03  1:15             ` Tejun Heo
2011-10-03 10:20               ` Peter Zijlstra
2011-10-07  1:40                 ` Tejun Heo
2011-10-03 10:33               ` Peter Zijlstra
2011-10-03 13:43                 ` Thomas Gleixner
2011-10-03 10:50               ` Peter Zijlstra
2011-09-30  9:23       ` Peter Zijlstra
2011-09-30  9:29       ` Peter Zijlstra
2011-09-30  9:27   ` Peter Zijlstra
2011-10-03  1:22     ` Tejun Heo
2011-09-30  3:55 ` Tejun Heo
2011-09-30  4:08   ` Steven Rostedt
2011-09-30  4:28     ` Tejun Heo

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=alpine.LFD.2.02.1109280211400.2711@ionos \
    --to=tglx@linutronix.de \
    --cc=a.p.zijlstra@chello.nl \
    --cc=htejun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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

all inboxes | Powered by JetHome®