From owner-freebsd-arch@FreeBSD.ORG Sun Jan 27 19:27:10 2008 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 98AF916A46B for ; Sun, 27 Jan 2008 19:27:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from cmail.optima.ua (cmail.optima.ua [195.248.191.121]) by mx1.freebsd.org (Postfix) with ESMTP id A76ED13C45B for ; Sun, 27 Jan 2008 19:27:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) X-Spam-Flag: SKIP X-Spam-Yversion: Spamooborona 1.7.0 Received: from [212.86.226.226] (account mav@alkar.net HELO [192.168.3.2]) by cmail.optima.ua (CommuniGate Pro SMTP 5.1.14) with ESMTPA id 69673907; Sun, 27 Jan 2008 20:27:08 +0200 Message-ID: <479CCCF8.7030601@FreeBSD.org> Date: Sun, 27 Jan 2008 20:27:04 +0200 From: Alexander Motin User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: freebsd-arch@freebsd.org, freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: kstackusage() patch request for comments 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: Sun, 27 Jan 2008 19:27:10 -0000 Hi. I have made a patch http://www.mavhome.dp.ua/kstackusage.patch that implements machine dependent function returning current kernel thread stack usage statistics and uses it in netgraph subsystem for receiving maximum benefit from direct function calls and minimum queueing while keeping stack protected. As I have never developed machine-dependant things I would like to hear any comments about it. The main question I have is about source files and headers I should use for this specific purposes. Is it correct way to define function in machine independent header, but implement it in machdep.c? Or I should define it in machine dependent headers? Also I would be grateful for help with implementations of this function for arch different from i386/amd64. Thanks. -- Alexander Motin From owner-freebsd-arch@FreeBSD.ORG Mon Jan 28 03:53:56 2008 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 3A1C416A418 for ; Mon, 28 Jan 2008 03:53:56 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id F056613C448 for ; Mon, 28 Jan 2008 03:53:55 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id D5E99207E; Mon, 28 Jan 2008 04:38:12 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 507312049; Mon, 28 Jan 2008 04:38:12 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id 25D8884487; Mon, 28 Jan 2008 04:38:12 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Alexander Motin References: <479CCCF8.7030601@FreeBSD.org> Date: Mon, 28 Jan 2008 04:38:12 +0100 In-Reply-To: <479CCCF8.7030601@FreeBSD.org> (Alexander Motin's message of "Sun\, 27 Jan 2008 20\:27\:04 +0200") Message-ID: <86sl0iwrff.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, freebsd-arch@freebsd.org Subject: Re: kstackusage() patch request for comments 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: Mon, 28 Jan 2008 03:53:56 -0000 Alexander Motin writes: > The main question I have is about source files and headers I should > use for this specific purposes. Is it correct way to define function > in machine independent header, but implement it in machdep.c? Or I > should define it in machine dependent headers? If you intend to implement the same functions on all platforms, the prototypes should be in a machine-independent header. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-arch@FreeBSD.ORG Tue Jan 29 05:08:22 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA88C16A417; Tue, 29 Jan 2008 05:08:22 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from webaccess-cl.virtdom.com (webaccess-cl.virtdom.com [216.240.101.25]) by mx1.freebsd.org (Postfix) with ESMTP id B03EC13C447; Tue, 29 Jan 2008 05:08:22 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from [192.168.1.107] (cpe-24-94-75-93.hawaii.res.rr.com [24.94.75.93]) (authenticated bits=0) by webaccess-cl.virtdom.com (8.13.6/8.13.6) with ESMTP id m0T58H33019311; Tue, 29 Jan 2008 00:08:19 -0500 (EST) (envelope-from jroberson@chesapeake.net) Date: Mon, 28 Jan 2008 19:12:12 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: arch@freebsd.org Message-ID: <20080128190244.R957@desktop> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: attilio@freebsd.org, ups@freebsd.org, rwatson@freebsd.org Subject: rwlock patch to prefer writers and improve spinning. 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: Tue, 29 Jan 2008 05:08:23 -0000 http://people.freebsd.org/~jeff/rwlock.diff Attilio and I have come up with a rwlock patch that prevents writer starvation by blocking readers whenever there are writers waiting on the turnstile. To avoid deadlocks caused by recursive readers a new per-thread count of outstanding rw read locks is maintained. When a thread is known to own read locks it will bypass the pending writers checks. This could lead to writer starvation in pathological cases but will not deadlock. In addition, I have added code to optimistically spin in the write lock path when there are readers. The spin is limited by two counters. One controls the number of spins while waiting for the lock state to change and another controls the number of lock state changes we'll observe before we give up. To add these two features new flags were required. I removed the recursion flag and instead there is an extra branch in the inlined code to check the recursion count before the atomic. Another option would be to further increase the alignment of struct thread, however, I don't really think that is necessary. This has been thoroughly tested with nokia's stack but it had to be forward ported to current. Any rwlock users are encouraged to test before I commit. Feedback is welcome. Thanks, Jeff From owner-freebsd-arch@FreeBSD.ORG Tue Jan 29 12:07:50 2008 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 2F32116A417; Tue, 29 Jan 2008 12:07:50 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from falcon.cybervisiontech.com (falcon.cybervisiontech.com [217.20.163.9]) by mx1.freebsd.org (Postfix) with ESMTP id A51E613C45D; Tue, 29 Jan 2008 12:07:49 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from localhost (localhost [127.0.0.1]) by falcon.cybervisiontech.com (Postfix) with ESMTP id 80D4443DC2A; Tue, 29 Jan 2008 14:07:48 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at falcon.cybervisiontech.com Received: from falcon.cybervisiontech.com ([127.0.0.1]) by localhost (falcon.cybervisiontech.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HYFwKyZoOUFy; Tue, 29 Jan 2008 14:07:48 +0200 (EET) Received: from [10.2.1.87] (gateway.cybervisiontech.com.ua [88.81.251.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by falcon.cybervisiontech.com (Postfix) with ESMTP id 235E543DBC2; Tue, 29 Jan 2008 14:07:48 +0200 (EET) Message-ID: <479F1713.2030705@icyb.net.ua> Date: Tue, 29 Jan 2008 14:07:47 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.9 (X11/20080123) MIME-Version: 1.0 To: freebsd-gnome@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: HAL/freebsd architecture 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: Tue, 29 Jan 2008 12:07:50 -0000 This is not a concrete suggestion and I can not volunteer to write any code yet (unfortunately). Recently I played a little bit with DesktopBSD live CD and liked some add-on software provided there and some implementation approaches were quite interesting for me too. Just in case, the tools can be found in sysutils/desktopbsd-tools and there is a FAQ page on using them in "plain" FreeBSD: http://desktopbsd.net/wiki/doku.php?id=doc:desktopbsd_tools_in_freebsd This got me thinking: maybe we could also apply the same approach as used for dbsd-hwnotify to HAL/FreeBSD. I.e. hald could do initial querying of devices and then just wait for notification from devd about any changes. This, of course, would require some changes to the base system, but I think that these would be useful for many more applications than just hald. Some things that come to mind first: "forward" instruction to devd.conf to execute some action for all events in addition to any event-specific actions. This is so that we could preserve current devd functionality but also allow to delegate some decisions to other software. I think that this way we could get a lot of current hald functionality for free, without the special probing/polling routines that have to written at present. But this would probably mean some additional changes in kernel-land. For example, there are complaints now that CD-ROM drivers do not automatically notice media removal/change and, for instance, do not update GEOM_LABEL information [*]. This is important for HAL functionality too. So, media checking/polling would probably have to go to the CD-ROM drivers. But, as I said earlier, this would probably be a universal good - we could kill several birds with one stone. To summarize: most of what FreeBSD hald currently does in userland is either already done in kernel as well or it better be done in kernel. hald should just mostly listen to notifications coming from kernel. Most likely this is best done via devd. Such approaches, of course, would require changes to pieces of kernel and to devd. And, for sure, there could be some quite hard cases. E.g. I don't how to notify userland about media change via devctl mechanism. [*] http://www.freebsd.org/cgi/query-pr.cgi?pr=119743 -- Andriy Gapon From owner-freebsd-arch@FreeBSD.ORG Tue Jan 29 20:01:04 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A52C16A41B for ; Tue, 29 Jan 2008 20:01:04 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.155]) by mx1.freebsd.org (Postfix) with ESMTP id B7B2F13C447 for ; Tue, 29 Jan 2008 20:01:03 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by fg-out-1718.google.com with SMTP id 16so2500914fgg.35 for ; Tue, 29 Jan 2008 12:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=xi5sEg5TwjkTMQZHd4JccOmLx7OApgRlrDjHU5yFr5Q=; b=dubfg99S3Zy8vnAHbiNIbieM2ifRInG2xsCGafccDgqqsAlmsfxbHW7tCSvcAjUq8ZEaIN8ryIR2qJL8kqp/6zZhDFG/7kAvYWJOOAsBP/FJe0rNWy0Ts+lsyb294IxceUyMnjqCApC3kjqH//JAvN63PvDwOD+cdVwskCV78GM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=knBSGfEyxfKu8TGmEy8+cEzfEW4Rj13102NxtPv5xTN53xtLxjY7EppsxuDhljS3JAXA3V5vSc0Bg2uuy5LiojIiQFTMj+8nOztF9Y77ojaANZFORaDtqXl6eOXroMEYJzDIdgtdSEwu+IwOzeYmgwGwfNqxtxwGvx+93/Cj5UY= Received: by 10.86.25.17 with SMTP id 17mr6791890fgy.73.1201636861595; Tue, 29 Jan 2008 12:01:01 -0800 (PST) Received: by 10.86.28.19 with HTTP; Tue, 29 Jan 2008 12:01:01 -0800 (PST) Message-ID: <3bbf2fe10801291201n7b355205o43b648791f5ca387@mail.gmail.com> Date: Tue, 29 Jan 2008 21:01:01 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Jeff Roberson" In-Reply-To: <20080128190244.R957@desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080128190244.R957@desktop> X-Google-Sender-Auth: 9f6c8e2e50b07103 Cc: ups@freebsd.org, arch@freebsd.org, rwatson@freebsd.org Subject: Re: rwlock patch to prefer writers and improve spinning. 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: Tue, 29 Jan 2008 20:01:04 -0000 2008/1/29, Jeff Roberson : > http://people.freebsd.org/~jeff/rwlock.diff > > Attilio and I have come up with a rwlock patch that prevents writer > starvation by blocking readers whenever there are writers waiting on the > turnstile. > > To avoid deadlocks caused by recursive readers a new per-thread count of > outstanding rw read locks is maintained. When a thread is known to own > read locks it will bypass the pending writers checks. This could lead to > writer starvation in pathological cases but will not deadlock. > > In addition, I have added code to optimistically spin in the write lock > path when there are readers. The spin is limited by two counters. One > controls the number of spins while waiting for the lock state to change > and another controls the number of lock state changes we'll observe before > we give up. > > To add these two features new flags were required. I removed the > recursion flag and instead there is an extra branch in the inlined code to > check the recursion count before the atomic. Another option would be to > further increase the alignment of struct thread, however, I don't really > think that is necessary. > > This has been thoroughly tested with nokia's stack but it had to be > forward ported to current. Any rwlock users are encouraged to test before > I commit. > > Feedback is welcome. Jeff, it is not missing a kern/subr_witness.c part where some checks are axed out? Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-freebsd-arch@FreeBSD.ORG Wed Jan 30 00:31:40 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F89F16A417; Wed, 30 Jan 2008 00:31:40 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from webaccess-cl.virtdom.com (webaccess-cl.virtdom.com [216.240.101.25]) by mx1.freebsd.org (Postfix) with ESMTP id 1205E13C45B; Wed, 30 Jan 2008 00:31:39 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from [192.168.1.107] (cpe-24-94-75-93.hawaii.res.rr.com [24.94.75.93]) (authenticated bits=0) by webaccess-cl.virtdom.com (8.13.6/8.13.6) with ESMTP id m0U0VYbP082403; Tue, 29 Jan 2008 19:31:35 -0500 (EST) (envelope-from jroberson@chesapeake.net) Date: Tue, 29 Jan 2008 14:35:34 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: Attilio Rao In-Reply-To: <3bbf2fe10801291201n7b355205o43b648791f5ca387@mail.gmail.com> Message-ID: <20080129143512.M957@desktop> References: <20080128190244.R957@desktop> <3bbf2fe10801291201n7b355205o43b648791f5ca387@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: ups@freebsd.org, arch@freebsd.org, rwatson@freebsd.org Subject: Re: rwlock patch to prefer writers and improve spinning. 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: Wed, 30 Jan 2008 00:31:40 -0000 On Tue, 29 Jan 2008, Attilio Rao wrote: > 2008/1/29, Jeff Roberson : >> http://people.freebsd.org/~jeff/rwlock.diff >> >> Attilio and I have come up with a rwlock patch that prevents writer >> starvation by blocking readers whenever there are writers waiting on the >> turnstile. >> >> To avoid deadlocks caused by recursive readers a new per-thread count of >> outstanding rw read locks is maintained. When a thread is known to own >> read locks it will bypass the pending writers checks. This could lead to >> writer starvation in pathological cases but will not deadlock. >> >> In addition, I have added code to optimistically spin in the write lock >> path when there are readers. The spin is limited by two counters. One >> controls the number of spins while waiting for the lock state to change >> and another controls the number of lock state changes we'll observe before >> we give up. >> >> To add these two features new flags were required. I removed the >> recursion flag and instead there is an extra branch in the inlined code to >> check the recursion count before the atomic. Another option would be to >> further increase the alignment of struct thread, however, I don't really >> think that is necessary. >> >> This has been thoroughly tested with nokia's stack but it had to be >> forward ported to current. Any rwlock users are encouraged to test before >> I commit. >> >> Feedback is welcome. > > Jeff, > it is not missing a kern/subr_witness.c part where some checks are axed out? Oh you are right I forgot to include some turnstile pieces as well. I will provide them soon. > > Attilio > > > -- > Peace can only be achieved by understanding - A. Einstein > From owner-freebsd-arch@FreeBSD.ORG Wed Jan 30 00:59:57 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8214416A418 for ; Wed, 30 Jan 2008 00:59:57 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152]) by mx1.freebsd.org (Postfix) with ESMTP id 9379813C45A for ; Wed, 30 Jan 2008 00:59:54 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by fg-out-1718.google.com with SMTP id 16so32307fgg.35 for ; Tue, 29 Jan 2008 16:59:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=xwRvjptm4qEEl3iElVUshWz8xOUfNYGxpMICAJ6u9wk=; b=uP59L7FXcNIO1EScCIaYCNITq8rxbSEevy164Vin1KMk3ajjSihnw45xDav8zGKrIWnbomIDapWdrVC9IvNHwCOm/BQv0EhJ4uKbHyVHmS7DKRUZLqG/vFwItGAp4cBAULyGtvuTwBf9Jyy3j7Jtei2adv5Wcj2DgWT0GM96hWM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=ZXsxup6QkPR7w+YISCjoP/+Vb5dSThFJwj+YcIoBOe3Kkb9O8QvSwYmGeIxOTPRCOdhKGWhgbxi+e31i5ThsTlV/0E8aVe9xoYrU640tY+Do0TiuMWnhNCxLqEVPlbloAnjSJg1vY2zBzGqxG9YlTiemsOsHn9nfdf7Q/HXcLyM= Received: by 10.86.28.5 with SMTP id b5mr67581fgb.79.1201654793125; Tue, 29 Jan 2008 16:59:53 -0800 (PST) Received: by 10.86.28.19 with HTTP; Tue, 29 Jan 2008 16:59:53 -0800 (PST) Message-ID: <3bbf2fe10801291659r650ec27eu5c346b1b85118713@mail.gmail.com> Date: Wed, 30 Jan 2008 01:59:53 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Jeff Roberson" In-Reply-To: <20080129143512.M957@desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080128190244.R957@desktop> <3bbf2fe10801291201n7b355205o43b648791f5ca387@mail.gmail.com> <20080129143512.M957@desktop> X-Google-Sender-Auth: 5c75ad6b3912479c Cc: ups@freebsd.org, arch@freebsd.org, rwatson@freebsd.org Subject: Re: rwlock patch to prefer writers and improve spinning. 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: Wed, 30 Jan 2008 00:59:57 -0000 2008/1/30, Jeff Roberson : > On Tue, 29 Jan 2008, Attilio Rao wrote: > > > 2008/1/29, Jeff Roberson : > >> http://people.freebsd.org/~jeff/rwlock.diff > >> > >> Attilio and I have come up with a rwlock patch that prevents writer > >> starvation by blocking readers whenever there are writers waiting on the > >> turnstile. > >> > >> To avoid deadlocks caused by recursive readers a new per-thread count of > >> outstanding rw read locks is maintained. When a thread is known to own > >> read locks it will bypass the pending writers checks. This could lead to > >> writer starvation in pathological cases but will not deadlock. > >> > >> In addition, I have added code to optimistically spin in the write lock > >> path when there are readers. The spin is limited by two counters. One > >> controls the number of spins while waiting for the lock state to change > >> and another controls the number of lock state changes we'll observe before > >> we give up. > >> > >> To add these two features new flags were required. I removed the > >> recursion flag and instead there is an extra branch in the inlined code to > >> check the recursion count before the atomic. Another option would be to > >> further increase the alignment of struct thread, however, I don't really > >> think that is necessary. > >> > >> This has been thoroughly tested with nokia's stack but it had to be > >> forward ported to current. Any rwlock users are encouraged to test before > >> I commit. > >> > >> Feedback is welcome. > > > > Jeff, > > it is not missing a kern/subr_witness.c part where some checks are axed out? > > Oh you are right I forgot to include some turnstile pieces as well. I > will provide them soon. Gah, I meant kern/subr_turnstile.c really :) Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-freebsd-arch@FreeBSD.ORG Wed Jan 30 01:02:52 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D259116A468 for ; Wed, 30 Jan 2008 01:02:52 +0000 (UTC) (envelope-from sitaramanpvk@gmail.com) Received: from hu-out-0506.google.com (hu-out-0506.google.com [72.14.214.227]) by mx1.freebsd.org (Postfix) with ESMTP id 59A3913C448 for ; Wed, 30 Jan 2008 01:02:52 +0000 (UTC) (envelope-from sitaramanpvk@gmail.com) Received: by hu-out-0506.google.com with SMTP id 28so21755hub.8 for ; Tue, 29 Jan 2008 17:02:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:to:subject:date:mime-version:x-mailer:x-mimeole:thread-index:content-type:content-transfer-encoding:from; bh=ivgOAJSqLcnzuILvP31VYiIfvrxa5KFgyqF1OUqCErk=; b=WPXywKTeoVOPEO85pjia3zVppWGHECnj7tWbV+L7AzkosT6n0PnQPnwbLHgFdubiBjHqaf4ZWKz71St5lDHAwgx5lI17IN7i+rWt7cg1IqGVnvsDHhg2VEOyrRfWpOMMjZxmo1ug/EFZwhr1pL2OmIwIgOVmb1vcpv8xRTK+Fmc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:to:subject:date:mime-version:x-mailer:x-mimeole:thread-index:content-type:content-transfer-encoding:from; b=RbKk9ok7MCztRdS0SWKGPq008Spr8VDYuqhoJZEvyDft84c0oQUaQliv1F123TtGeOLFoHbfQqfqBZ09odvwTo8u1CxLTJZgYYJqTjFafKI4Rju5am4yxSXfE65tNR7TSc7ekbh1zo3hD+7ktFbHuNvKuYU/F7dphVHCv6bY+yw= Received: by 10.67.19.9 with SMTP id w9mr2084034ugi.86.1201653520505; Tue, 29 Jan 2008 16:38:40 -0800 (PST) Received: from ?41.251.149.56? ( [41.251.149.56]) by mx.google.com with ESMTPS id q40sm4144741ugc.70.2008.01.29.16.38.34 (version=SSLv3 cipher=OTHER); Tue, 29 Jan 2008 16:38:39 -0800 (PST) Message-ID: <6Pvx8xBqSID2zm.52DC8D7CFA@KWUDG> To: Date: Wed, 30 Jan 2008 00:22:48 +0000 MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Thread-Index: nduCnbzvtwejhSDDh4tJ57yhqKBeOat53wME Content-Type: text/plain; charset="Windows-1251" Content-Transfer-Encoding: 7bit From: wheel Cc: Subject: Birds macassar 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: Wed, 30 Jan 2008 01:02:52 -0000 Make your girlfriend or wife speechless with increased hardness, richer orgasms and more power in bed your online shop. medbestequal+com secure ordering, very fast chipping Dives corded unleavened From owner-freebsd-arch@FreeBSD.ORG Wed Jan 30 01:07:26 2008 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 42A7F16A421 for ; Wed, 30 Jan 2008 01:07:26 +0000 (UTC) (envelope-from sitaramanpvk@gmail.com) Received: from hu-out-0506.google.com (hu-out-0506.google.com [72.14.214.228]) by mx1.freebsd.org (Postfix) with ESMTP id BD53813C461 for ; Wed, 30 Jan 2008 01:07:25 +0000 (UTC) (envelope-from sitaramanpvk@gmail.com) Received: by hu-out-0506.google.com with SMTP id 28so22302hub.8 for ; Tue, 29 Jan 2008 17:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:to:subject:date:mime-version:x-mailer:x-mimeole:thread-index:content-type:content-transfer-encoding:from; bh=ivgOAJSqLcnzuILvP31VYiIfvrxa5KFgyqF1OUqCErk=; b=WPXywKTeoVOPEO85pjia3zVppWGHECnj7tWbV+L7AzkosT6n0PnQPnwbLHgFdubiBjHqaf4ZWKz71St5lDHAwgx5lI17IN7i+rWt7cg1IqGVnvsDHhg2VEOyrRfWpOMMjZxmo1ug/EFZwhr1pL2OmIwIgOVmb1vcpv8xRTK+Fmc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:to:subject:date:mime-version:x-mailer:x-mimeole:thread-index:content-type:content-transfer-encoding:from; b=RbKk9ok7MCztRdS0SWKGPq008Spr8VDYuqhoJZEvyDft84c0oQUaQliv1F123TtGeOLFoHbfQqfqBZ09odvwTo8u1CxLTJZgYYJqTjFafKI4Rju5am4yxSXfE65tNR7TSc7ekbh1zo3hD+7ktFbHuNvKuYU/F7dphVHCv6bY+yw= Received: by 10.67.19.9 with SMTP id w9mr2084034ugi.86.1201653520505; Tue, 29 Jan 2008 16:38:40 -0800 (PST) Received: from ?41.251.149.56? ( [41.251.149.56]) by mx.google.com with ESMTPS id q40sm4144741ugc.70.2008.01.29.16.38.34 (version=SSLv3 cipher=OTHER); Tue, 29 Jan 2008 16:38:39 -0800 (PST) Message-ID: <6Pvx8xBqSID2zm.52DC8D7CFA@KWUDG> To: Date: Wed, 30 Jan 2008 00:22:48 +0000 MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Thread-Index: nduCnbzvtwejhSDDh4tJ57yhqKBeOat53wME Content-Type: text/plain; charset="Windows-1251" Content-Transfer-Encoding: 7bit From: wheel Cc: Subject: Birds macassar 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: Wed, 30 Jan 2008 01:07:26 -0000 Make your girlfriend or wife speechless with increased hardness, richer orgasms and more power in bed your online shop. medbestequal+com secure ordering, very fast chipping Dives corded unleavened From owner-freebsd-arch@FreeBSD.ORG Thu Jan 31 00:52:03 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D88816A46D; Thu, 31 Jan 2008 00:52:03 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from webaccess-cl.virtdom.com (webaccess-cl.virtdom.com [216.240.101.25]) by mx1.freebsd.org (Postfix) with ESMTP id CDCAB13C4D9; Thu, 31 Jan 2008 00:52:02 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from [192.168.1.107] (cpe-24-94-75-93.hawaii.res.rr.com [24.94.75.93]) (authenticated bits=0) by webaccess-cl.virtdom.com (8.13.6/8.13.6) with ESMTP id m0V0q0Ms087960; Wed, 30 Jan 2008 19:52:01 -0500 (EST) (envelope-from jroberson@chesapeake.net) Date: Wed, 30 Jan 2008 14:56:05 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: Attilio Rao In-Reply-To: <3bbf2fe10801291659r650ec27eu5c346b1b85118713@mail.gmail.com> Message-ID: <20080130145548.P957@desktop> References: <20080128190244.R957@desktop> <3bbf2fe10801291201n7b355205o43b648791f5ca387@mail.gmail.com> <20080129143512.M957@desktop> <3bbf2fe10801291659r650ec27eu5c346b1b85118713@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: ups@freebsd.org, arch@freebsd.org, rwatson@freebsd.org Subject: Re: rwlock patch to prefer writers and improve spinning. 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, 31 Jan 2008 00:52:03 -0000 On Wed, 30 Jan 2008, Attilio Rao wrote: > 2008/1/30, Jeff Roberson : >> On Tue, 29 Jan 2008, Attilio Rao wrote: >> >>> 2008/1/29, Jeff Roberson : >>>> http://people.freebsd.org/~jeff/rwlock.diff >>>> >>>> Attilio and I have come up with a rwlock patch that prevents writer >>>> starvation by blocking readers whenever there are writers waiting on the >>>> turnstile. >>>> >>>> To avoid deadlocks caused by recursive readers a new per-thread count of >>>> outstanding rw read locks is maintained. When a thread is known to own >>>> read locks it will bypass the pending writers checks. This could lead to >>>> writer starvation in pathological cases but will not deadlock. >>>> >>>> In addition, I have added code to optimistically spin in the write lock >>>> path when there are readers. The spin is limited by two counters. One >>>> controls the number of spins while waiting for the lock state to change >>>> and another controls the number of lock state changes we'll observe before >>>> we give up. >>>> >>>> To add these two features new flags were required. I removed the >>>> recursion flag and instead there is an extra branch in the inlined code to >>>> check the recursion count before the atomic. Another option would be to >>>> further increase the alignment of struct thread, however, I don't really >>>> think that is necessary. >>>> >>>> This has been thoroughly tested with nokia's stack but it had to be >>>> forward ported to current. Any rwlock users are encouraged to test before >>>> I commit. >>>> >>>> Feedback is welcome. >>> >>> Jeff, >>> it is not missing a kern/subr_witness.c part where some checks are axed out? >> >> Oh you are right I forgot to include some turnstile pieces as well. I >> will provide them soon. > > Gah, I meant kern/subr_turnstile.c really :) The patch is updated in place at: http://people.freebsd.org/~jeff/rwlock.diff > > Attilio > > > -- > Peace can only be achieved by understanding - A. Einstein > From owner-freebsd-arch@FreeBSD.ORG Thu Jan 31 09:33:58 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA4AA16A468; Thu, 31 Jan 2008 09:33:58 +0000 (UTC) (envelope-from gary.jennejohn@freenet.de) Received: from mout3.freenet.de (mout3.freenet.de [IPv6:2001:748:100:40::2:5]) by mx1.freebsd.org (Postfix) with ESMTP id 56C5213C468; Thu, 31 Jan 2008 09:33:58 +0000 (UTC) (envelope-from gary.jennejohn@freenet.de) Received: from [195.4.92.12] (helo=2.mx.freenet.de) by mout3.freenet.de with esmtpa (Exim 4.68) (envelope-from ) id 1JKVnw-0000KV-RC; Thu, 31 Jan 2008 10:33:56 +0100 Received: from x0f97.x.pppool.de ([89.59.15.151]:53058 helo=peedub.jennejohn.org) by 2.mx.freenet.de with esmtpa (ID gary.jennejohn@freenet.de) (port 25) (Exim 4.68 #9) id 1JKVnw-00078w-IM; Thu, 31 Jan 2008 10:33:56 +0100 Date: Thu, 31 Jan 2008 10:33:55 +0100 From: Gary Jennejohn To: Jeff Roberson Message-ID: <20080131103355.30cc5bb0@peedub.jennejohn.org> In-Reply-To: <20080130145548.P957@desktop> References: <20080128190244.R957@desktop> <3bbf2fe10801291201n7b355205o43b648791f5ca387@mail.gmail.com> <20080129143512.M957@desktop> <3bbf2fe10801291659r650ec27eu5c346b1b85118713@mail.gmail.com> <20080130145548.P957@desktop> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.10.14; amd64-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Attilio Rao , ups@freebsd.org, rwatson@freebsd.org, arch@freebsd.org Subject: Re: rwlock patch to prefer writers and improve spinning. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gary.jennejohn@freenet.de List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2008 09:33:58 -0000 On Wed, 30 Jan 2008 14:56:05 -1000 (HST) Jeff Roberson wrote: > On Wed, 30 Jan 2008, Attilio Rao wrote: > >>> Jeff, > >>> it is not missing a kern/subr_witness.c part where some checks are axed out? > >> > >> Oh you are right I forgot to include some turnstile pieces as well. I > >> will provide them soon. > > > > Gah, I meant kern/subr_turnstile.c really :) > > The patch is updated in place at: > > http://people.freebsd.org/~jeff/rwlock.diff > Doesn't apply cleanly against -current updated about 10 minutes ago: Hunk #22 failed at 797. 1 out of 22 hunks failed--saving rejects to kern/kern_rwlock.c.rej I have __FBSDID("$FreeBSD: src/sys/kern/kern_rwlock.c,v 1.34 2008/01/17 20:15:15 jhb Exp $"); Easy enough to apply by hand, but still... --- Gary Jennejohn From owner-freebsd-arch@FreeBSD.ORG Thu Jan 31 19:29:22 2008 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 570FE16A417 for ; Thu, 31 Jan 2008 19:29:22 +0000 (UTC) (envelope-from maxim.zhuravlev@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.184]) by mx1.freebsd.org (Postfix) with ESMTP id EFA7913C469 for ; Thu, 31 Jan 2008 19:29:19 +0000 (UTC) (envelope-from maxim.zhuravlev@gmail.com) Received: by fk-out-0910.google.com with SMTP id b27so884911fka.11 for ; Thu, 31 Jan 2008 11:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; bh=WrJzowXKwJ4WZnTjux6xf4em9teDCM1G836qRPvk2ZM=; b=tNeeCoumrLvfNS4K9m2CWrZpxdiePAxpMt0wMczsWy4z0IdfCrTuj2R2rHTA1Co38rm0s3zUoF0666cT7YKR8HHWQ9VLRU5P9wpXbFTQlEpNtMGFlc/17nDQTBJ8eCu2Gi5CkEIxNwh7CIDI4I4S/bVSuVoX30tk1U3WTDJo64U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=Al23CAmA5kTgZIBq8g3TX0SeWgD58D8zUyaVBTQG+3gujAXmcWUq3OYtdAbtvUTXnUkoHJx63DQqgDLbf562tHemlzmX8deBRGIUOo4cXWSK7lHjV07StZ38De7IE+4HIvKrrgPYtiQthTFQ0rFOfUtKtIACCzm6h6aTZd7kmfg= Received: by 10.82.114.3 with SMTP id m3mr4461036buc.24.1201806126731; Thu, 31 Jan 2008 11:02:06 -0800 (PST) Received: by 10.82.172.13 with HTTP; Thu, 31 Jan 2008 11:02:06 -0800 (PST) Message-ID: Date: Thu, 31 Jan 2008 22:02:06 +0300 From: "Maxim Zhuravlev" Sender: maxim.zhuravlev@gmail.com To: freebsd-arch@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 6d22e8e5ea12ae30 Subject: [RFC] Some new generic device features. 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, 31 Jan 2008 19:29:22 -0000 Hi. I'm currently working on project named *Enhanced NewBus*. It's a successor of *Generic Input Device Layer Project* I've been working on for GSoC2007 [1]. As the project is to be quite an extensive one, I would like to get some comments/suggestions on the design[2] first. It can be found here:http://wiki.freebsd.org/EnhancedNewBus. In brief, the design suggests to implement in-kernel device piping. There are two types of devices: logical (ex. console device, demuxing device) and hardware (mices, displays). I suggest to add logical devices to NewBus domain. Side effect is that device tree will transform to a graph (ex. two mice can be parents of a demuxing device, while being children of a same bus). The approach lets to implement a generic way of ex. device demuxing, cause it's obvious that functionality, provided by logical devices may be useful not just for input devices, while some kind of devices may require some specific features. Also it will be easier to implement such complex device drivers, like a console driver is, by abstracting work with underlying devices. To make it possible one needs to implement a way to track input/output requests through the graph. The generic device input/output subsystem is internally asynchronous for the sake of flexibility. New logical drivers require a new more intellectual autoconfiguration process. More here: [2]. [1] http://wiki.freebsd.org/GenericInputDeviceLayer [2] http://wiki.freebsd.org/EnhancedNewBus -- Maxim Zhuravlev From owner-freebsd-arch@FreeBSD.ORG Thu Jan 31 21:34:59 2008 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 6FD7C16A417; Thu, 31 Jan 2008 21:34:59 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe12.swipnet.se [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id D518413C447; Thu, 31 Jan 2008 21:34:58 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [85.19.218.18] (account mc467741@c2i.net [85.19.218.18] verified) by mailfe12.swip.net (CommuniGate Pro SMTP 5.1.13) with ESMTPA id 614935817; Thu, 31 Jan 2008 21:34:55 +0100 From: Hans Petter Selasky To: freebsd-arch@freebsd.org Date: Thu, 31 Jan 2008 21:35:47 +0100 User-Agent: KMail/1.9.7 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801312135.48600.hselasky@c2i.net> Cc: Maxim Zhuravlev Subject: Re: [RFC] Some new generic device features. 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, 31 Jan 2008 21:34:59 -0000 Hi, Some general comments: Must be detach safe. Does it support non-giant enabled input drivers? How does it handle mutexes? --HPS On Thursday 31 January 2008, Maxim Zhuravlev wrote: > Hi. > > I'm currently working on project named *Enhanced NewBus*. It's a > successor of *Generic Input Device Layer Project* I've been working on > for GSoC2007 [1]. > As the project is to be quite an extensive one, I would like to get > some comments/suggestions on the design[2] first. It can be found > here:http://wiki.freebsd.org/EnhancedNewBus. > > In brief, the design suggests to implement in-kernel device piping. > There are two types of devices: logical (ex. console device, demuxing > device) and hardware (mices, displays). I suggest to add logical > devices to NewBus domain. Side effect is that device tree will > transform to a graph (ex. two mice can be parents of a demuxing > device, while being children of a same bus). The approach lets to > implement a generic way of ex. device demuxing, cause it's obvious > that functionality, provided by logical devices may be useful not just > for input devices, while some kind of devices may require some > specific features. Also it will be easier to implement such complex > device drivers, like a console driver is, by abstracting work with > underlying devices. To make it possible one needs to implement a way > to track input/output requests through the graph. The generic device > input/output subsystem is internally asynchronous for the sake of > flexibility. New logical drivers require a new more intellectual > autoconfiguration process. > > More here: [2]. > > [1] http://wiki.freebsd.org/GenericInputDeviceLayer > [2] http://wiki.freebsd.org/EnhancedNewBus > > -- > Maxim Zhuravlev > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" From owner-freebsd-arch@FreeBSD.ORG Fri Feb 1 14:49:19 2008 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 5688D16A417 for ; Fri, 1 Feb 2008 14:49:19 +0000 (UTC) (envelope-from maxim.zhuravlev@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.191]) by mx1.freebsd.org (Postfix) with ESMTP id D71D113C442 for ; Fri, 1 Feb 2008 14:49:18 +0000 (UTC) (envelope-from maxim.zhuravlev@gmail.com) Received: by fk-out-0910.google.com with SMTP id b27so1391184fka.11 for ; Fri, 01 Feb 2008 06:49:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=VzKyWj8/g0V46Aq+Mu4ExaM3dVLt/2hKLWiLdqUD1uI=; b=bl82BIbrMakdw9u1W/MZNmTQf9vZCfQlJdnpONXFF/8e/UjAarJ9YiOiXDbNp5O8N+69CNAxBrfGqhisjj9J9u4RsEKt34O8+flvNZ8gC1Wmm7ETi7zO1t47Y9CBS6wmYTdzL3p+3hZ7DQ+h/Ikch9QgdOjvlBref0KVPTj3DsE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=vH6yUsRST7JjOIySgdaID79dfpALkQLUoIS8IO4tHK9LQTkgfnXJ7f5osQZoSVr3nAmDenlc3gVlLrW6bwO7r1/pYHf17z3YZErbfrb+dRSokhjQ3qBYEmyj7nvdn8lf/kbl341HOWL8xFsV/rHeVgfJk5aWu6LYaLZTSdW50pU= Received: by 10.82.116.15 with SMTP id o15mr6477168buc.3.1201877357279; Fri, 01 Feb 2008 06:49:17 -0800 (PST) Received: by 10.82.172.13 with HTTP; Fri, 1 Feb 2008 06:49:17 -0800 (PST) Message-ID: Date: Fri, 1 Feb 2008 17:49:17 +0300 From: "Maxim Zhuravlev" Sender: maxim.zhuravlev@gmail.com To: "Hans Petter Selasky" In-Reply-To: <200801312135.48600.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200801312135.48600.hselasky@c2i.net> X-Google-Sender-Auth: 93aad473fb60124f Cc: freebsd-arch@freebsd.org Subject: Re: [RFC] Some new generic device features. 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: Fri, 01 Feb 2008 14:49:19 -0000 2008/1/31, Hans Petter Selasky : > Hi, > > Some general comments: > > How does it handle mutexes? By now mutexes are used by io subsystem: All input/output requests (iors) and queues of iors are guarded by spin mutexes. As for devices, their NewBus sided structures will be guarded by (spin?) mutexes. > Does it support non-giant enabled input drivers? I don't really get what you mean. Did that answer about NewBus sided structures + paralleled/serialized ior processing clarify anything? -- - Maxim Zhuravlev From owner-freebsd-arch@FreeBSD.ORG Sat Feb 2 20:47:57 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C84A16A421 for ; Sat, 2 Feb 2008 20:47:57 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 3872313C4E3 for ; Sat, 2 Feb 2008 20:47:57 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id DF15D17104 for ; Sat, 2 Feb 2008 20:47:55 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.2/8.14.2) with ESMTP id m12KltPG012081 for ; Sat, 2 Feb 2008 20:47:55 GMT (envelope-from phk@critter.freebsd.dk) To: arch@freebsd.org From: Poul-Henning Kamp Date: Sat, 02 Feb 2008 20:47:55 +0000 Message-ID: <12080.1201985275@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Subject: adding general purpose mtx+cv to kthread 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: Sat, 02 Feb 2008 20:47:57 -0000 The select(2) system call has a dirty little secret data structure (struct seltd) which it hangs off the kthread (->td_sel), amongst the reasons for this is to avoid a mtx_init() and cv_init() and associated destroy calls with each call to select(2). I'm working on an enhancement to sendfile(2) that has the exact same need for a mtx+cv combo and the question is how many other such we have, once we get through the code. Various solutions present themselves, from swallowing the overhead for sendfile(2) since it's probably delta anyway over sharing selects data structure (safe for the locks, since both syscalls are stateless) to what seems most sensible to me: Add a general purpose mtx+cv to struct kthread for use by syscalls that need to keep track of things and sleep on stuff. This wouldn't make the seltd structure go away, it contains other stuff as well, it would just eliminate the mtx+cv combo from it. Any comment or insights ? -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.