From owner-freebsd-arch@FreeBSD.ORG Wed May 20 18:45:32 2009 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 48F631065674; Wed, 20 May 2009 18:45:32 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.229]) by mx1.freebsd.org (Postfix) with ESMTP id 2013D8FC15; Wed, 20 May 2009 18:45:32 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id k40so234663rvb.43 for ; Wed, 20 May 2009 11:45:30 -0700 (PDT) Received: by 10.141.13.13 with SMTP id q13mr766349rvi.163.1242845130668; Wed, 20 May 2009 11:45:30 -0700 (PDT) Received: from ?10.0.1.198? (udp016664uds.hawaiiantel.net [72.235.41.117]) by mx.google.com with ESMTPS id g22sm4381413rvb.6.2009.05.20.11.45.28 (version=SSLv3 cipher=RC4-MD5); Wed, 20 May 2009 11:45:29 -0700 (PDT) Date: Wed, 20 May 2009 08:49:30 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: John Baldwin In-Reply-To: <200905191458.50764.jhb@freebsd.org> Message-ID: References: <200905191458.50764.jhb@freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@FreeBSD.org Subject: Re: sglist(9) 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, 20 May 2009 18:45:32 -0000 On Tue, 19 May 2009, John Baldwin wrote: > So one of the things I worked on while hacking away at unmapped disk I/O > requests was a little API to manage scatter/gather lists of phyiscal > addresses. The basic premise is that a sglist describes a logical object > that is backed by one or more physical address ranges. To minimize locking, > the sglist objects themselves are immutable once they are shared. The > unmapped disk I/O project is still very much a WIP (and I'm not even working > on any of the really hard bits myself). However, I actually found this > object to be useful for something else I have been working on: the mmap() > extensions for the Nvidia amd64 driver. For the Nvidia patches I have > created a new type of VM object that is very similar to OBJT_DEVICE objects > except that it uses a sglist to determine the physical pages backing the > object instead of calling the d_mmap() method for each page. Anyway, adding > this little API is just the first in a series of patches needed for the > Nvidia driver work. I plan to MFC them to 7.x relatively soon in the hopes > that we can soon have a supported Nvidia driver on amd64 on 7.x. > > The current patches for all the Nvidia stuff is at > http://www.FreeBSD.org/~jhb/pat/ > > This particular patch to just add the sglist(9) API is at > http://www.FreeBSD.org/~jhb/patches/sglist.patch and is slightly more > polished in that it includes a manpage. :) I have a couple of minor comments: 1) SGLIST_APPEND() contains a return() within a macro. Shouldn't this be an inline that returns an error code that is always checked? These kinds of macros get people into trouble. It also could be written in such a way that you don't have to handle nseg == 0 at each callsite and then it's big enough that it probably shouldn't be a macro or an inline. 2) I worry that if all users do sglist_count() followed by a dynamic allocation and then an _append() they will be very expensive. pmap_kextract() is much more expensive than it may first seem to be. Do you have a user of count already? 3) Rather than having sg_segs be an actual pointer, did you consider making it an unsized array? This removes the overhead of one pointer from the structure while enforcing that it's always contiguously allocated. 4) SGLIST_INIT might be better off as an inline, and may not even belong in the header file. In general I think this is a good idea. It'd be nice to work on replacing the buf layer's implementation with something like this that could be used directly by drivers. Have you considered a busdma operation to load from a sglist? Thanks, Jeff > > -- > John Baldwin > _______________________________________________ > 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" >