From owner-freebsd-fs@FreeBSD.ORG Sat Feb 28 04:31:50 2015 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 614DF4AE; Sat, 28 Feb 2015 04:31:50 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E25A3F5E; Sat, 28 Feb 2015 04:31:49 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t1S4ViX8082098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 28 Feb 2015 06:31:44 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t1S4ViX8082098 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t1S4ViRX082097; Sat, 28 Feb 2015 06:31:44 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 28 Feb 2015 06:31:44 +0200 From: Konstantin Belousov To: fs@freebsd.org Subject: ZFS port and thread_exit() Message-ID: <20150228043144.GQ2379@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: threads@freebsd.org X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Feb 2015 04:31:50 -0000 While looking for some change to thread_exit(), I noted that ZFS on FreeBSD directly calls thread_exit(). It simply cannot work, thread_exit() is the internal function which requires the thread and process state prepared for it call. Among most obvious things, process spin lock must be held, but also several cleanups and accounting have to be done before the call. I believe the function just happens to have the same name as the Solaris counterpart, and for some reasons it is never called. If this is true, kthread_exit() should be used instead. Also, I noted that the userspace port defines thread_exit() as thr_exit(NULL). Again, the direct invocation of the syscall does not look right. The libthr library must do some cleanups on the thread exit, which are not done if syscall is invoked by an application code. Also, the thread itself gets no destructor calls. Could somebody interested in ZFS look into the issues ?