From owner-freebsd-hackers@FreeBSD.ORG Tue May 25 16:41:07 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D8F91065674; Tue, 25 May 2010 16:41:07 +0000 (UTC) (envelope-from julian@elischer.org) Received: from out-0.mx.aerioconnect.net (outj.internet-mail-service.net [216.240.47.233]) by mx1.freebsd.org (Postfix) with ESMTP id 7C6138FC15; Tue, 25 May 2010 16:41:07 +0000 (UTC) Received: from idiom.com (postfix@mx0.idiom.com [216.240.32.160]) by out-0.mx.aerioconnect.net (8.13.8/8.13.8) with ESMTP id o4PGf5NL007196; Tue, 25 May 2010 09:41:05 -0700 X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id CDAFB2D6012; Tue, 25 May 2010 09:41:04 -0700 (PDT) Message-ID: <4BFBFDAB.9000106@elischer.org> Date: Tue, 25 May 2010 09:41:15 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Dmitry Krivenok References: <201005250855.57770.jhb@freebsd.org> In-Reply-To: <201005250855.57770.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.67 on 216.240.47.51 Cc: freebsd-hackers@freebsd.org Subject: Re: select/poll for sockets in kernel space X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2010 16:41:07 -0000 On 5/25/10 5:55 AM, John Baldwin wrote: > On Tuesday 25 May 2010 5:02:35 am Dmitry Krivenok wrote: >> Hello Hackers! >> >> I'm developing a module for FreeBSD-8 and encountered the problem with >> polling sockets. [...] >> >> Thanks in advance! >> >> P.S. >> I know about kqueue, but I have to use select/poll is this task. > > Why do you have to use select/poll? If these are dedicated sockets that you > create internally, then the right thing to do is probably to install your own > upcalls that get called when data for a socket arrives. This is what the in- > kernel NFS client does to handle incoming data. It's also what netgraph does. An incoming packet is sent to the ksocket node and immediately passed to whatever node is attached to the ksocket node. If your project is of high throughput requirement, then you might look ad duplicating what it does (in /sys/netgraph/ng_ksocket.c), or alternatively, if your project is of medium throughput, (or lower) you might consider simply implementing it as a netgraph node and make use of the configuration framework etc. that already exists, and actually use a netgraph ksocket node to do the work for you. >