Thread (115 messages) 115 messages, 7 authors, 2010-08-04

Re: [PATCH repost] sched: export sched_set/getaffinity to modules

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: 2010-07-13 11:15:55
Also in: kvm, lkml

On Mon, Jul 12, 2010 at 11:59:08PM -0700, Sridhar Samudrala wrote:
On 7/4/2010 2:00 AM, Michael S. Tsirkin wrote:
quoted
On Fri, Jul 02, 2010 at 11:06:37PM +0200, Oleg Nesterov wrote:
quoted
On 07/02, Peter Zijlstra wrote:
quoted
On Fri, 2010-07-02 at 11:01 -0700, Sridhar Samudrala wrote:
quoted
 Does  it (Tejun's kthread_clone() patch) also  inherit the
cgroup of the caller?
Of course, its a simple do_fork() which inherits everything just as you
would expect from a similar sys_clone()/sys_fork() call.
Yes. And I'm afraid it can inherit more than we want. IIUC, this is called
from ioctl(), right?

Then the new thread becomes the natural child of the caller, and it shares
->mm with the parent. And files, dup_fd() without CLONE_FS.

Signals. Say, if you send SIGKILL to this new thread, it can't sleep in
TASK_INTERRUPTIBLE or KILLABLE after that. And this SIGKILL can be sent
just because the parent gets SIGQUIT or abother coredumpable signal.
Or the new thread can recieve SIGSTOP via ^Z.

Perhaps this is OK, I do not know. Just to remind that kernel_thread()
is merely clone(CLONE_VM).

Oleg.
Right. Doing this might break things like flush.  The signal and exit
behaviour needs to be examined carefully. I am also unsure whether
using such threads might be more expensive than inheriting kthreadd.
Should we just leave it to the userspace to set the cgroup/cpumask
after qemu starts the guest and
the vhost threads?

Thanks
Sridhar
Yes but we can't trust userspace to do this. It's important
to do it on thread creation: if we don't, malicious userspace
can create large amount of work exceeding the cgroup limits.

And the same applies so the affinity: if the qemu process
is limited to a set of CPUs, it's important to make
the kernel thread that does work our behalf limited to the same
set of CPUs.

This is not unique to vhost, it's just that virt scenarious are affected
by this more: people seem to run untrusted applications and expect the
damage to be contained.

-- 
MST
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help