Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756349Ab0GAO3K (ORCPT ); Thu, 1 Jul 2010 10:29:10 -0400 Received: from hera.kernel.org ([140.211.167.34]:35710 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753811Ab0GAO3I (ORCPT ); Thu, 1 Jul 2010 10:29:08 -0400 Message-ID: <4C2CA5C5.4040402@kernel.org> Date: Thu, 01 Jul 2010 16:27:17 +0200 From: Tejun Heo User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4-1.1.1 Thunderbird/3.0.4 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: Peter Zijlstra , Ingo Molnar , Sridhar Samudrala , Oleg Nesterov , netdev , lkml , "kvm@vger.kernel.org" , Andrew Morton , Dmitri Vorobiev , Jiri Kosina , Thomas Gleixner , Andi Kleen Subject: Re: [PATCH repost] sched: export sched_set/getaffinity to modules References: <20100625101022.GA16321@redhat.com> <20100701110708.GA27368@redhat.com> <1277983179.1917.10.camel@laptop> <1277984603.1917.15.camel@laptop> <20100701115507.GA31333@redhat.com> <20100701122340.GB31333@redhat.com> <1277987657.1917.32.camel@laptop> <1277988395.1917.47.camel@laptop> <20100701130816.GB32223@redhat.com> <1277991024.1917.108.camel@laptop> <20100701133956.GD32223@redhat.com> In-Reply-To: <20100701133956.GD32223@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.3 (hera.kernel.org [127.0.0.1]); Thu, 01 Jul 2010 14:27:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1244 Lines: 45 Hello, On 07/01/2010 03:39 PM, Michael S. Tsirkin wrote: >> I think that's called kernel_thread() see >> kernel/kthread.c:create_kthread(). >> >> Doing the whole kthreadd dance and then copying bits and pieces back >> sounds very fragile, so yeah, something like that should work. > > Thanks! > Sridhar, Tejun, have the time to look into this approach? All that's necessary is shortcutting indirection through kthreadd. ie. An exported function which looks like the following, struct kthread_clone_or_whatever(int (*threadfn).....) { struct kthread_create_info create; int pid; INIT create; pid = kernel_thread(kthread, &create, CLONE_FS...); if (pid < 0) return ERROR; wait_for_completion(&create.done); if (!IS_ERR(create.result)) SET NAME; return create.result; } It might be a good idea to make the function take extra clone flags but anyways once created cloned task can be treated the same way as other kthreads, so nothing else needs to be changed. Thanks. -- tejun -- 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/