From owner-freebsd-net Sat Jul 15 14:27: 8 2000 Delivered-To: freebsd-net@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 3F8A137B565; Sat, 15 Jul 2000 14:27:05 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e6FLR3G26773; Sat, 15 Jul 2000 14:27:03 -0700 (PDT) Date: Sat, 15 Jul 2000 14:27:03 -0700 From: Alfred Perlstein To: David Greenman Cc: net@freebsd.org, dillon@freebsd.org Subject: Re: mbuf refcnt and sendfile Message-ID: <20000715142703.E25571@fw.wintelcom.net> References: <20000715065506.Y25571@fw.wintelcom.net> <200007151904.MAA20589@implode.root.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <200007151904.MAA20589@implode.root.com>; from dg@root.com on Sat, Jul 15, 2000 at 12:04:39PM -0700 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org * David Greenman [000715 12:16] wrote: > >http://www.freebsd.org/cgi/query-pr.cgi?pr=19866 > > > >David, I'm pretty sure you didn't like the 'fix' for the mbuf > >cluster refcount presented in this PR (linking all copies using > >a doubly linked list), I have presented an alternative: > > > > Instead of keeping them in a linked list there should be an int/char * > > in the mbuf header that works the same way mclrefcnt does. Instead > > of managing a linked list all one has to do is copy the pointer into > > the new mbuf header and increment it, and decrease it on free, when > > it's zero the deref code is called. > > > >I was wondering what your thoughts on this are? > > I thought it seemed very clever. The linked list method or the pointer refcount method? > >I also had an idea to save on sf_buf's in sendfile: > > > > Forget about them, set the m_ext->ext_buf to point directly at the > > vm_page_t backing the mbuf, you don't need the extra indirection. > > > >I think that could work if you did a vm_page_wire and pmap_qenter > >for each mbuf ref callback and a vm_page_unwire and pmap_qremove > >for each mbuf free callback. > > This one makes my brain hurt (too much to consider). > > There's only one mapping address, so multiple pmap_qenter's would be a > no-op and the first pmap_qremove would remove the mapping, which is not > what you want. You can't use the wire count == 0 to decide when to remove > the mapping either, since it is used all over the system for other > purposes. Basically, you have to have a seperate counter of sendfile > consumers of the page - I don't see any way around that. Ok, I see what's going on, if you have multiple sf_bufs you have the same page mapped in at different offsets (multiple times), you still need the refcount, you could hash on the object/offset and share sf_bufs with multiple sends when you have overlap, but that could pessimize the case when you have a large working set and it's unlikely to have overlap. I was trying to figure out some trick, some sort of existing refcount method for mapping pages in but I haven't found one yet. It could be useful to have a generic refcount scheme for vm pages, perhaps Andrew Gallatin would like it for his zero copy stuff so he can avoid multiple mappings. -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message