[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YhA6QIDME2wFbgIU@google.com>
Date: Sat, 19 Feb 2022 00:30:56 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: kernel test robot <lkp@...el.com>,
Vipin Sharma <vipinsh@...gle.com>, kbuild-all@...ts.01.org,
mkoutny@...e.com, tj@...nel.org, lizefan.x@...edance.com,
hannes@...xchg.org, dmatlack@...gle.com, jiangshanlai@...il.com,
kvm@...r.kernel.org, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] KVM: Move VM's worker kthreads back to the original
cgroup before exiting.
On Thu, Feb 17, 2022, Paolo Bonzini wrote:
> On 2/17/22 13:34, kernel test robot wrote:
> > > 5859 reattach_err = cgroup_attach_task_all(current->real_parent, current);
>
> This needs to be within rcu_dereference().
As Vipin found out the hard way, cgroup_attach_task_all() can't be inside an RCU
critical section as it might sleep due to mutex_lock().
My sched knowledge is sketchy at best, but I believe KVM just needs to guarantee
the liveliness of real_parent when passing it to cgroup_attach_task_all().
Presumably kthreadd_task can (in theory) be killed/exiting while this is going on,
but at that point I doubt anyone cares much about cgroup accuracy.
So I think this can be:
rcu_read_lock();
parent = rcu_dereference(current->real_parent);
get_task_struct(parent);
rcu_read_unlock();
(void)cgroup_attach_task_all(parent, current);
put_task_struct(parent);
> > 5860 if (reattach_err) {
> > 5861 kvm_err("%s: cgroup_attach_task_all failed on reattach with err %d\n",
> > 5862 __func__, reattach_err);
Eh, I wouldn't bother logging the error, userspace can't take action on it, and
if the system is OOM it's just more noise in the log to dig through.
Powered by blists - more mailing lists