From owner-freebsd-threads@FreeBSD.ORG Sat Feb 28 07:36:32 2015 Return-Path: Delivered-To: threads@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 EA35145C; Sat, 28 Feb 2015 07:36:32 +0000 (UTC) Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com [IPv6:2607:f8b0:400e:c03::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B6530C5; Sat, 28 Feb 2015 07:36:32 +0000 (UTC) Received: by padbj1 with SMTP id bj1so2908113pad.11; Fri, 27 Feb 2015 23:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=8lQMRl9788W2sRuLfOjF9I3SXtGuBMhdsPrhwY4rnkQ=; b=iR0Dwh3DRuvk+GPJ0CoNSD/gnM2yezis7olLaxIEkjDo9BhQst/Rxh4Sf3qRQJ8QKl orMRbL9m/Wxvdi49sEQ8wW9XmNGtj9zwGHSvaiq/7AUNd1E3+X9Ri7q57uHf3Fe86ERW 8vpb5GHwbCIMmmjhJKHxmALER7Xtjmn+U8+cuJ7eccv5D5dQ1+E/yoUGJQemtvc8m1Tc 6ARPjTOUSsm6AeEE7U0F1dMxij+st2v9BdEfspa/Esoyb+23LkjVWkwqdgMhe/iw0aLI yLO9z/bzW7iN6bfioQCCSPKQhrzQ9xSYgYIlf9Azup4Oa3ANtlLujJXLee+ODwFhOKj8 t25w== X-Received: by 10.67.7.10 with SMTP id cy10mr29448764pad.151.1425108992214; Fri, 27 Feb 2015 23:36:32 -0800 (PST) Received: from raichu (216-243-33-91.users.condointernet.net. [216.243.33.91]) by mx.google.com with ESMTPSA id qn14sm5961247pab.33.2015.02.27.23.36.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Feb 2015 23:36:31 -0800 (PST) Sender: Mark Johnston Date: Fri, 27 Feb 2015 23:36:26 -0800 From: Mark Johnston To: Konstantin Belousov Subject: Re: ZFS port and thread_exit() Message-ID: <20150228073625.GA2627@raichu> References: <20150228043144.GQ2379@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150228043144.GQ2379@kib.kiev.ua> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: threads@freebsd.org, fs@freebsd.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Feb 2015 07:36:33 -0000 On Sat, Feb 28, 2015 at 06:31:44AM +0200, Konstantin Belousov wrote: > 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. I'm not very familiar with the ZFS code, but: The opensolaris compat proc.h #defines thread_exit to kthread_exit after FreeBSD's proc.h is included, so calls to thread_exit() in ZFS code should be replaced. Also, zfs.ko contains no references to thread_exit, but does reference kthread_exit. > > 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. This is done in zfs_context.h, which includes cddl/contrib/opensolaris/head/thread.h, which #defines thr_exit(r) to pthread_exit(r). There is no other thread.h in the src tree, and libzpool.so references only pthread_exit. So it seems to me that the compat layer is doing the right thing. > > Could somebody interested in ZFS look into the issues ? > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org"