From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 23 10:20:37 2004 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 F2B5B16A4CF for ; Thu, 23 Sep 2004 10:20:36 +0000 (GMT) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [194.125.244.127]) by mx1.FreeBSD.org (Postfix) with ESMTP id 06CB443D1D for ; Thu, 23 Sep 2004 10:20:15 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) (authenticated bits=0)i8NDPqR6039691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Sep 2004 13:25:53 GMT Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000) id A0B8B7F; Thu, 23 Sep 2004 13:19:53 +0300 (EEST) Date: Thu, 23 Sep 2004 13:19:53 +0300 From: Andrey Simonenko To: Niels Heinen Message-ID: <20040923101953.GA463@pm514-9.comsys.ntu-kpi.kiev.ua> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i cc: freebsd-hackers@freebsd.org Subject: Re: Copy data from kernel to user space memory 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: Thu, 23 Sep 2004 10:20:37 -0000 On Thu, Sep 23, 2004 at 11:38:28AM +0200, Niels Heinen wrote: > The module buffers packets and currently copies it into user memory > when its system call interface is used. At the moment my user space > application is the one that allocates the memory. I want the memory > to be allocated by the module in order to make things more efficient. > > I'd really appriciate it if someone could explain how this should be done You can allocate OBJT_DEFAULT object with desired size, then map it to the process' vmspace and copy packets from the module to this region of process' memory, then tell process the start address of the mapped object and its size. And don't forget to serialize access to the region of memory. Read documentation (or relevant sys/vm code) for vm_object_allocate(9), vm_map_find(9), vm_map_remove(9). I'm not sure that you get some performance with this method, usually an application allocates memory, makes syscall and tells how many bytes the kernel (the module) can store in this memory. But I don't see the complete picture, so may be you can't use this standard approach.