From owner-freebsd-current Wed Jan 17 10: 5:47 2001 Delivered-To: freebsd-current@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 7658C37B404; Wed, 17 Jan 2001 10:05:18 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f0HI5HD24831; Wed, 17 Jan 2001 10:05:17 -0800 (PST) Date: Wed, 17 Jan 2001 10:05:17 -0800 From: Alfred Perlstein To: Randell Jesup , dillon@freebsd.org Cc: Soren Schmidt , arch@freebsd.org, current@freebsd.org Subject: Re: HEADS-UP: await/asleep removal imminent Message-ID: <20010117100516.Q7240@fw.wintelcom.net> References: <200101171138.MAA11834@freebsd.dk> <20010117092109.O7240@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010117092109.O7240@fw.wintelcom.net>; from bright@wintelcom.net on Wed, Jan 17, 2001 at 09:21:09AM -0800 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Alfred Perlstein [010117 09:24] wrote: > > I'm not going to axe it for a few days, this is a really amazing > API that Matt added, the problem is utility and useage over code > complexity. > > It's just a proposal. I found several places where it may be useful, but I'm not sure if the benefits outweigh the gains. In a copy of the tree I've locked down the socket layer (not the entire stack, just sockets :) ) there's code like this: SOCKBUF_UNLOCK(&so->so_snd, 0); if (top == 0) { MGETHDR(m, M_TRYWAIT, MT_DATA); if (m == NULL) { error = ENOBUFS; SOCKBUF_LOCK(&so->so_snd, 0); goto release; } mlen = MHLEN; ... SOCKBUF_LOCK(&so->so_snd, 0); /* XXX */ The lock must be unwound becasue we're calling MGETHDR with M_TRYWAIT. If wae used M_TRY'A'WAIT the code would probably look something like this: /* SOCKBUF_UNLOCK(&so->so_snd, 0); */ again: if (top == 0) { MGETHDR(m, M_TRYWAIT, MT_DATA); if (m == NULL) { error = mawait(&so->so_snd.sb_mtx, -1, -1); if (error) { if (error == EWOULDBLOCK) error = ENOBUFS; goto release; } goto again; /* SOCKBUF_LOCK(&so->so_snd, 0); */ } mlen = MHLEN; ... /* SOCKBUF_LOCK(&so->so_snd, 0); */ /* XXX */ Which means we don't have to drop the lock over the socket unless we'd block on allocation. Matt, is this what you intended for it to do? So far I've only seen it used to avoid races, but not to optimize out mutex aquire/release. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message