From owner-freebsd-current@FreeBSD.ORG Thu Aug 22 02:06:25 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B9924F9; Thu, 22 Aug 2013 02:06:25 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from shell0.rawbw.com (shell0.rawbw.com [198.144.192.45]) by mx1.freebsd.org (Postfix) with ESMTP id 9E05A2576; Thu, 22 Aug 2013 02:06:25 +0000 (UTC) Received: from eagle.yuri.org (stunnel@localhost [127.0.0.1]) (authenticated bits=0) by shell0.rawbw.com (8.14.4/8.14.4) with ESMTP id r7M26O0R005218; Wed, 21 Aug 2013 19:06:24 -0700 (PDT) (envelope-from yuri@rawbw.com) Message-ID: <52157220.8030400@rawbw.com> Date: Wed, 21 Aug 2013 19:06:24 -0700 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130628 Thunderbird/17.0.7 MIME-Version: 1.0 To: Mateusz Guzik Subject: Re: How to best overload the fileops ? References: <521508F4.6030502@rawbw.com> <20130821232113.GD94127@funkthat.com> <521552E2.2000008@rawbw.com> <20130822001022.GA18115@dft-labs.eu> <52155B8D.1020807@rawbw.com> <20130822012011.GA11987@dft-labs.eu> In-Reply-To: <20130822012011.GA11987@dft-labs.eu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: John-Mark Gurney , Roman Divacky , current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Aug 2013 02:06:25 -0000 > I don't think there is a need to provide anything like this right now, > nor I have any good idea how to implement it. This kinda leave it hanging in the same state. To do this kqueue fileops need to be exposed. It is always possible to create something like "struct fileops* kqueue_fileops()" and that would do it. I just tried to make such exposure as nice as I could, using some accepted paradigms (overloading, etc) and macros that look like some IDE might create. Another approach is to read fileops from file after the first call to sys_kqueue, but I dislike this because this would require an additional lock, also this would make the first call to epoll_create different from the others, which it shouldn't be. Also this would look much more like a hack. What is wrong with the suggested approach anyway? >> > >> >No, sys_kqueue calling code is all protected by the lock on this >> >file object. So nobody can close or reuse it. >> > > I don't follow. > > sys_kqueue creates fp on its own, before that there is nothing to lock > in the first place. By the time it returns, created fp can be long gone > because some other thread closed it. I added the method kqueue_locked that leaves the the lock release to the calling routine (another kernel module). This way both epoll_create and sys_kqueue run under one atomic lock. Yuri