From owner-freebsd-net Tue Oct 23 11:50:14 2001 Delivered-To: freebsd-net@freebsd.org Received: from iguana.aciri.org (iguana.aciri.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id F1AD937B403 for ; Tue, 23 Oct 2001 11:50:10 -0700 (PDT) Received: (from rizzo@localhost) by iguana.aciri.org (8.11.3/8.11.1) id f9NIkpW35146; Tue, 23 Oct 2001 11:46:51 -0700 (PDT) (envelope-from rizzo) Date: Tue, 23 Oct 2001 11:46:50 -0700 From: Luigi Rizzo To: Alfred Perlstein Cc: net@FreeBSD.ORG Subject: Re: performance issues with M_PREPEND on clusters Message-ID: <20011023114650.C34494@iguana.aciri.org> References: <20011023110307.A34494@iguana.aciri.org> <20011023132813.I15052@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011023132813.I15052@elvis.mu.org> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Tue, Oct 23, 2001 at 01:28:13PM -0500, Alfred Perlstein wrote: ... > > In the mbuf code, M_LEADINGSPACE always returns 0 when M_EXT is > > set, instead of calling the second part of M_WRITABLE to check > > whether there is a chance of writing into the cluster. This means ... > I've seen this brought up before, this is not what you want to > do otherwise you risk corrupting EXT data. The right thing to > do is have the people allocating writable EXT bufs mark them > as such. Other EXT type buffers such as sendfile bufs can not > be written to no matter what the sharecount is. Actually, the BSD code works the other way around: * standard EXT bufs as returned by MCLGET _are_ writable if m_ext.ext_free == NULL and their refcnt is 1 (they _must_ be, otherwise we would have errors when m_free() decides to dispose of a cluster, which is a form of writing), and * people allocating "other EXT type" implicitly mark the buffer as not-writable by setting m_ext.ext_free to the proper routine. This is certainly what the sendfile bufs that you mentioned do. M_WRITABLE (used in the patch i proposed) does exactly the checks that you do when you m_free() a cluster. If this is wrong, then m_free() is broken! Am i missing something else ? cheers luigi #define M_WRITABLE(m) (!((m)->m_flags & M_EXT) || \ ((m)->m_ext.ext_free == NULL && mclrefcnt[mtocl((m)->m_ext.ext_buf)] == 1)) ----------------------------------+----------------------------------------- Luigi RIZZO, luigi@iet.unipi.it . ACIRI/ICSI (on leave from Univ. di Pisa) http://www.iet.unipi.it/~luigi/ . 1947 Center St, Berkeley CA 94704 Phone: (510) 666 2927 ----------------------------------+----------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message