From owner-freebsd-arch@FreeBSD.ORG Thu Jan 28 11:03:31 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94B84106568D for ; Thu, 28 Jan 2010 11:03:31 +0000 (UTC) (envelope-from giovanni.trematerra@gmail.com) Received: from mail-fx0-f226.google.com (mail-fx0-f226.google.com [209.85.220.226]) by mx1.freebsd.org (Postfix) with ESMTP id 2E6658FC0A for ; Thu, 28 Jan 2010 11:03:30 +0000 (UTC) Received: by fxm26 with SMTP id 26so249630fxm.13 for ; Thu, 28 Jan 2010 03:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:cc:content-type; bh=kebx9f5Br9FBQTIJKArEFYNZ6e12nidi6/aS4gGpjaQ=; b=ELd4Pk7660fx78J5b1rI99JgHHu8r7gtJSVBuzKYW7Ja3mOVYvfj6odosLJqM+qHIW WE6GE73+MVyzsDxMr7svvRipvsY2Tol5MoyoDnAbklNeBgkMiGUzydY2N1kzm8BwO66k Bt1xjHjZJW1oEMcPkz+g54AD080vpn9eWwJsw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=PHe+gQkTGNQw6rtPPwtRCsdo3O0UjjGZ7FQDvGGNomK1ADvdSijbilsK01C4TQ7dei xU5j/D2ApnwkhSSBaqdtGVIM9Z2TjMkymkJjNt5Bri3oYI5Ijiyg6Gge1HgGiNsCaGfc E+t+SXNpHxKxWBSqLlz/msHD/yWSB0y82L/w4= MIME-Version: 1.0 Received: by 10.223.144.207 with SMTP id a15mr1267957fav.70.1264675130734; Thu, 28 Jan 2010 02:38:50 -0800 (PST) Date: Thu, 28 Jan 2010 11:38:50 +0100 Message-ID: <4e6cba831001280238x6a86e9f8vf5b7858b4bb82178@mail.gmail.com> From: Giovanni Trematerra To: freebsd-arch@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Attilio Rao Subject: kthread interface X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2010 11:03:31 -0000 Hi all, There is a race in kthread_exit when all the threads of a kernel process exit at same time. I came up with a quick and dirty patch that resolve the issue at least in my test case. http://www.trematerra.net/patches/kthread_exit.diff Nonetheless I see space for improvement into kthread interface. At present, with kproc_kthread_add you could have a kernel process without a main thread and that seems to me only a way to logical grouping threads and pretty useless. I propose to remove kproc_kthread_add and don't let kthread_exit call kproc_exit on the last exiting thread but demand user to handle process termination. If you need kernel threads but no reason to have a kernel process with a main thread that acts as a coordinator you can attach them to proc0 by kthread_add passing NULL for (struct proc *) argument. I attached a patch to better show my proposal. http://www.trematerra.net/patches/kproc_kthread_add.diff Note: the two patches are mutually exclusive Thanks for your attention. -- Gianni