[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210419184553.GA26214@worktop.programming.kicks-ass.net>
Date: Mon, 19 Apr 2021 20:45:53 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Valentin Schneider <valentin.schneider@....com>
Cc: syzbot <syzbot+9362b31a2e0cad8b749d@...kaller.appspotmail.com>,
bp@...en8.de, dwmw@...zon.co.uk, hpa@...or.com,
linux-kernel@...r.kernel.org, luto@...nel.org, mingo@...hat.com,
syzkaller-bugs@...glegroups.com, tglx@...utronix.de, x86@...nel.org
Subject: Re: [syzbot] WARNING in kthread_is_per_cpu
On Mon, Apr 19, 2021 at 12:31:22PM +0100, Valentin Schneider wrote:
> if ((p->flags & PF_KTHREAD) && kthread_is_per_cpu(p))
> `\
> to_kthread(p);
> `\
> WARN_ON(!(p->flags & PF_KTHREAD));
>
> ... Huh?
Something like so perhaps?
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 1578973c5740..eeba40df61ac 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -78,6 +78,14 @@ static inline void set_kthread_struct(void *kthread)
current->set_child_tid = (__force void __user *)kthread;
}
+static inline struct kthread *__to_kthread(struct task_struct *k)
+{
+ void *kthread = (__force void *)k->set_child_tid;
+ if (kthread && !(k->flags & PF_KTHREAD))
+ kthread = NULL;
+ return kthread;
+}
+
static inline struct kthread *to_kthread(struct task_struct *k)
{
WARN_ON(!(k->flags & PF_KTHREAD));
@@ -516,7 +524,7 @@ void kthread_set_per_cpu(struct task_struct *k, int cpu)
bool kthread_is_per_cpu(struct task_struct *k)
{
- struct kthread *kthread = to_kthread(k);
+ struct kthread *kthread = __to_kthread(k);
if (!kthread)
return false;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3384ea74cad4..dc6311bd6986 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7658,7 +7658,7 @@ static void balance_push(struct rq *rq)
* histerical raisins.
*/
if (rq->idle == push_task ||
- ((push_task->flags & PF_KTHREAD) && kthread_is_per_cpu(push_task)) ||
+ kthread_is_per_cpu(push_task) ||
is_migration_disabled(push_task)) {
/*
Powered by blists - more mailing lists