From owner-freebsd-ipfw@FreeBSD.ORG Wed Aug 25 10:45:04 2004 Return-Path: Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B4CE716A4CE; Wed, 25 Aug 2004 10:45:04 +0000 (GMT) Received: from shellma.zin.lublin.pl (shellma.zin.lublin.pl [212.182.126.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3DEBD43D2D; Wed, 25 Aug 2004 10:45:04 +0000 (GMT) (envelope-from pawmal-posting@freebsd.lublin.pl) Received: by shellma.zin.lublin.pl (Postfix, from userid 1018) id 091493474C2; Wed, 25 Aug 2004 12:43:11 +0200 (CEST) Date: Wed, 25 Aug 2004 12:43:10 +0200 From: Pawel Malachowski To: Pawel Jakub Dawidek Message-ID: <20040825104310.GA57463@shellma.zin.lublin.pl> References: <200408232155.i7NLt4gF052086@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200408232155.i7NLt4gF052086@freefall.freebsd.org> User-Agent: Mutt/1.4.2i cc: ipfw@freebsd.org Subject: Re: kern/46557: ipfw pipe show fails with lots of queues X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2004 10:45:04 -0000 On Mon, Aug 23, 2004 at 09:55:04PM +0000, Pawel Jakub Dawidek wrote: > Here is prosposed patch against HEAD: [...] > +static int > +dummynet_get(struct sockopt *sopt) > +{ > + char *buf, *bp ; /* bp is the "copy-pointer" */ > + size_t size ; > + struct dn_flow_set *set ; > + struct dn_pipe *p ; > + int error=0, i ; > + > + /* XXX lock held too long */ > + DUMMYNET_LOCK(); > + /* > + * XXX: Ugly, but we need to allocate memory with M_WAITOK flag and we > + * cannot use this flag while holding a mutex. > + */ > + for (i = 0; i < 10; i++) { > + size = dn_calc_size(); > + DUMMYNET_UNLOCK(); > + buf = malloc(size, M_TEMP, M_WAITOK); Wouldn't it be better to allocate size+something or size*i*something? Theoretically with dynamic pipes we can be so unlucky that even after 10 tries and with plenty of free memory we still can't hit this size because it floats all the time. (If so, next condition should be >=.) Right now, we will report ENOBUFS not only when there is no memory (BTW, shouldn't it be ENOMEM?) but also when we have ENOLUCK. ;) > + DUMMYNET_LOCK(); > + if (size == dn_calc_size()) > + break; > + free(buf, M_TEMP); > + buf = NULL; > + } > + if (buf == NULL) { > DUMMYNET_UNLOCK(); > return ENOBUFS ; > } -- Paweł Małachowski