From owner-freebsd-current@FreeBSD.ORG Mon May 27 23:35:24 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4D37A49E for ; Mon, 27 May 2013 23:35:24 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 11E0F372 for ; Mon, 27 May 2013 23:35:23 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id DF47D7300A; Tue, 28 May 2013 01:38:01 +0200 (CEST) Date: Tue, 28 May 2013 01:38:01 +0200 From: Luigi Rizzo To: current@freebsd.org Subject: copyin+copyout in one step ? Message-ID: <20130527233801.GA32042@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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: Mon, 27 May 2013 23:35:24 -0000 Hi, say a process P1 wants to use the kernel to copy the content of a buffer SRC (in its user address space) to a buffer DST (in the address space of another process P2), and assume that P1 issues the request to the kernel when P2 has already told the kernel where the data should go: P1 P2 +------+ +--------+ | SRC | | DST | +--v---+ +--^-----+ --------|------------------------|---------- | | kernel | ^ | | | +--------+ | +----->| tmpbuf +--------+ copyin| | copyout P1 ctx+--------+ P2 ctx I guess the one above is the canonical way: P1 does a copyin() to a temporary buffer, then notifies P2 which can then issue or complete a syscall to do a copyout from tmpbuf to DST in P2's context. But I wonder, is it possible to do it as follows: P2 tells the kernel where the data should go (DST); later, P1 issues a system call and through a combined "copyinout()" moves data directly from SRC to DST, operating in the context of P1. | copyinout() ? | +------------>-----------+ issued by P1 Is this doable at all ? I suspect that "tell DST to the kernel" might be especially expensive as it needs to pin the page so it is accessible while doing the syscall for P1 ? (the whole point for this optimization is saving the extra copy through the buffer, but it may be pointless if pinning the memory is more expensive than the copy) cheers luigi