From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S265127AbUADEm0 (ORCPT ); Sat, 3 Jan 2004 23:42:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S265136AbUADEm0 (ORCPT ); Sat, 3 Jan 2004 23:42:26 -0500 Received: from x35.xmailserver.org ([69.30.125.51]:18304 "EHLO x35.xmailserver.org") by vger.kernel.org with ESMTP id S265127AbUADEmY (ORCPT ); Sat, 3 Jan 2004 23:42:24 -0500 X-AuthUser: davidel@xmailserver.org Date: Sat, 3 Jan 2004 20:42:26 -0800 (PST) From: Davide Libenzi X-X-Sender: davide@bigblue.dev.mdolabs.com To: Rusty Russell cc: Linus Torvalds , Andrew Morton , , Linux Kernel Mailing List Subject: Re: [PATCH 1/2] kthread_create In-Reply-To: <20040104043037.007922C0F1@lists.samba.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 4 Jan 2004, Rusty Russell wrote: > In message you write: > > Rusty, I took a better look at the patch and I think we can have > > per-kthread stuff w/out littering the task_struct and by making the thing > > more robust. > > Except sharing data with a lock is perfectly robust. > > > We keep a global list_head protected by a global spinlock. We > > define a structure that contain all the per-kthread stuff we need > > (including a task_struct* to the kthread itself). When a kthread starts it > > will add itself to the list, and when it will die it will remove itself > > from the list. > > Yeah, I deliberately didn't implement this, because (1) it seems like > a lot of complexity when using a lock and letting them share a single > structure works fine and is even simpler, and (2) the thread can't > just "do_exit()". > > You can get around (2) by having a permenant parent "kthread" thread > which is a parent to all the kthreads (it'll get a SIGCHLD when > someone does "do_exit()"). But the implementation was pretty ugly, > since it involved having a communications mechanism with the kthread > parent, which means you have the global ktm_message-like-thing for > this... You will lose in any case. What happens if the thread does do_exit() and you do kthread_stop() after that? With the patch I posted to you, the kthread_stop() will simply miss the lookup and return -ENOENT. - Davide