Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1207183
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [tip:sched/core] sched: Change the sched_class::set_cpus_allowed( ) calling context |
| Date | 2015-08-13 23:40 +0200 |
| Message-ID | <pX8oa-7bD-7@gated-at.bofh.it> (permalink) |
| References | <pqqbP-4cj-55@gated-at.bofh.it> <pWDu4-4ta-49@gated-at.bofh.it> <pX5Tj-3pd-11@gated-at.bofh.it> <pX7s5-5R1-3@gated-at.bofh.it> <pX7Lt-6dP-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Aug 13, 2015 at 04:59:01PM -0400, Sasha Levin wrote:
> Seems to work fine now, thanks!
I've no clue how this doesn't also explode on actual hardware, that code
is convoluted, read and weep.
Ingo, please stick somewhere appropriate :-)
---
Subject: sched: Avoid trying to dequeue/enqueue the idle thread
From: Peter Zijlstra <peterz@infradead.org>
Date: Thu Aug 13 23:09:29 CEST 2015
Sasha reports that his virtual machine tries to schedule the idle
thread since commit 6c37067e2786 ("sched: Change the
sched_class::set_cpus_allowed() calling context").
His trace shows this happening from idle_thread_get()->init_idle(),
which is the _second_ init_idle() invocation on that task_struct, the
first being done through idle_init()->fork_idle(). (this code is
insane...)
Because we call init_idle() twice in a row, its ->sched_class ==
&idle_sched_class and ->on_rq = TASK_ON_RQ_QUEUED. This means
do_set_cpus_allowed() thinks we're queued and will call dequeue_task(),
which is implemented with BUG() for the idle class, seeing how
dequeueing the idle task is a daft thing.
Aside of the whole insanity of calling init_idle() _twice_, change the
code to call set_cpus_allowed_common() instead as this is 'obviously'
before the idle task gets ran etc..
Fixes: 6c37067e2786 ("sched: Change the sched_class::set_cpus_allowed() calling context")
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4924,7 +4924,7 @@ void init_idle(struct task_struct *idle,
idle->state = TASK_RUNNING;
idle->se.exec_start = sched_clock();
- do_set_cpus_allowed(idle, cpumask_of(cpu));
+ set_cpus_allowed_common(idle, cpumask_of(cpu));
/*
* We're having a chicken and egg problem, even though we are
* holding rq->lock, the cpu isn't yet set to this cpu so the
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[tip:sched/core] sched: Change the sched_class::set_cpus_allowed( ) calling context tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2015-08-12 14:40 +0200
Re: [tip:sched/core] sched: Change the sched_class::set_cpus_allowed( ) calling context Sasha Levin <sasha.levin@oracle.com> - 2015-08-13 21:00 +0200
Re: [tip:sched/core] sched: Change the sched_class::set_cpus_allowed( ) calling context Peter Zijlstra <peterz@infradead.org> - 2015-08-13 22:40 +0200
Re: [tip:sched/core] sched: Change the sched_class::set_cpus_allowed( ) calling context Sasha Levin <sasha.levin@oracle.com> - 2015-08-13 23:00 +0200
Re: [tip:sched/core] sched: Change the sched_class::set_cpus_allowed( ) calling context Peter Zijlstra <peterz@infradead.org> - 2015-08-13 23:40 +0200
csiph-web