From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 21 14:21:12 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A85F937B404; Mon, 21 Jul 2003 14:21:12 -0700 (PDT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7BEC443FA3; Mon, 21 Jul 2003 14:21:11 -0700 (PDT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.9/8.12.9) with ESMTP id h6LLKbai001057; Mon, 21 Jul 2003 17:20:37 -0400 (EDT) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)h6LLKbYo001054; Mon, 21 Jul 2003 17:20:37 -0400 (EDT) Date: Mon, 21 Jul 2003 17:20:37 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: Pawel Jakub Dawidek In-Reply-To: <20030721190146.GB43543@garage.freebsd.pl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: deischen@freebsd.org cc: Marc Ramirez cc: freebsd-hackers@freebsd.org Subject: Re: Communications kernel -> userland X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jul 2003 21:21:13 -0000 On Mon, 21 Jul 2003, Pawel Jakub Dawidek wrote: > For example syscall is marking some range with mark() function. For now > on this range isn't accessable from userland. If process will try to > write to this page, page is copied (copy-on-write). If this page will > be modified by kernel it will be marked as MODIFIED. Now when syscall > will call unmark() on this range we could get two scenarious: > > 1. Page is marked as MODIFIED (by kernel) so userland copy > of this page (if it exists of course) is destroyed and > this page will be putted in its place. > This is replacement for copyin() and then copyout() or > just copyout().. > 2. Page isn't marked as MODIFIED, so kernel version of page > is destroyed (is there is userland version). > This is replacement for just copyin(). > > There could be other ways. Thread/process could be locked if it is > trying to access memory marked with mark() function. And this, I think, > don't hit performance, because this happends really rarely. So maybe it > is better to lock thread for a moment instead of doplicating page, but I > don't think so. This sounds a bit like some of the IO Lite stuff -- moving to a page-centric model for IO interfaces to avoid copy operations, in many cases able to share pages between applications, buffer cache, network buffers, etc. Take a look at: http://www.cs.princeton.edu/~vivek/ For some details. Some of the benefits of this approach are captured in the common case through sendfile(), in practice, but it's definitely worth a read. I guess what I had in mind was something more network-specific, with interfaces optimized for memory mapped network packet streams. In the simplest case, something like memory-mapping the BPF buffer from kernel space to userspace, with some sort of simple stream synchronization so that the user application could notify the kernel as to when it could reuse bits of the buffer, but avoiding copy operations and lots of context switching. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Network Associates Laboratories