From owner-svn-src-head@FreeBSD.ORG Tue Jun 12 13:50:02 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 145581065670; Tue, 12 Jun 2012 13:50:02 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id A58928FC0A; Tue, 12 Jun 2012 13:50:00 +0000 (UTC) Received: by yenl8 with SMTP id l8so3893890yen.13 for ; Tue, 12 Jun 2012 06:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=cl7O+FCHZ72gH0qCl3AQVqwkWmaPXmD6ouzxCnfSJt8=; b=i0hoS1xDleMtArjHNmiPFUcblAL9oGaER/0k8N/fKh4Q5M4q0RyzgX+Mld+RpTjpOt kih8tCj77JoA1/urcbFC6N3azhoc0SDNzL1eiEo9FV8Xi7LrOXjAnuUreq5gEEfJQBzj rxB48Cx8mSiGYRVMYx1DH/UyqaBlp6quHWePxeCy/kU5PbSGm8yS/s9keEoD7lhPvIQu /YafBfndpXXfdHX8+D4q6PY3DLOxVt5DGE6g7kU55Uxh9BknNwor0VYZ2Ks1XkT5h3BQ zAcwuHOrNxwi49rHfm/92vwHXuxS0n1/oFDmVR1Wp83S/0WHjUC9HWeyyklQ97+3Hysg PtxQ== Received: by 10.236.73.6 with SMTP id u6mr27442323yhd.31.1339509000112; Tue, 12 Jun 2012 06:50:00 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPS id e5sm31515627ani.18.2012.06.12.06.49.58 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 06:49:59 -0700 (PDT) Date: Tue, 12 Jun 2012 15:49:50 +0200 From: Mateusz Guzik To: Pawel Jakub Dawidek Message-ID: <20120612134950.GC20749@dft-labs.eu> References: <201206112205.q5BM5QIv013266@svn.freebsd.org> <4FD6FD39.5090800@gmail.com> <20120612104749.GB20749@dft-labs.eu> <20120612114335.GA1372@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20120612114335.GA1372@garage.freebsd.pl> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, davidxu@FreeBSD.org Subject: Re: svn commit: r236935 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 13:50:02 -0000 On Tue, Jun 12, 2012 at 01:43:35PM +0200, Pawel Jakub Dawidek wrote: > On Tue, Jun 12, 2012 at 12:47:49PM +0200, Mateusz Guzik wrote: > > The problem is that fdalloc grows to at most fdp->fd_nfiles * 2, which > > still may not be enough to have place for new fd with high number. > > I was under impression that fd_first_free() can return at most > fdp->fd_nfiles, but indeed I missed this: > > if (low >= size) > return (low); > > So fd_first_free() can return number biffer than size... > > > This fixed the problem for me, although I'm not sure whether it's ok to > > grow the table like this: > > http://people.freebsd.org/~mjg/patches/fdalloc.patch > > The patch looks good to me, could you please commit it, preferably after > David's trying it and also update fd_first_free() comment, so it is > clear that returned value can exceed 'size -1'? > Given that you partially reverted r236935 I created a combined patch: http://people.freebsd.org/~mjg/patches/fdalloc%2bfd_first_free.patch Is this ok? Most changes are obiously yours, so I see no problem if you prefer to commit this yourself. Otherwise I plan to commit it with the following: Re-apply reverted parts of r236935 by pjd with some fixes. If fdalloc decides to grow fdtable it does it once and at most doubles the size. This still may be not enough for sufficiently large fd. Use fd in calculations of new size in order to fix this. Fix description of fd_first_free to note that it returns passed fd if it exceeds fdtable's size. ====== fd_last_used has very same problem with comment as fd_first_free. This function is static and the only caller always passes 0 as low. Given that, how about the following: http://people.freebsd.org/~mjg/patches/fd_last_used-cleanup.patch Thanks, -- Mateusz Guzik