From owner-freebsd-hackers@FreeBSD.ORG Tue Dec 23 09:06:56 2008 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 E6D541065783 for ; Tue, 23 Dec 2008 09:06:56 +0000 (UTC) (envelope-from rdivacky@lev.vlakno.cz) Received: from vlakno.cz (77-93-215-190.static.masterinter.net [77.93.215.190]) by mx1.freebsd.org (Postfix) with ESMTP id A06138FC08 for ; Tue, 23 Dec 2008 09:06:55 +0000 (UTC) (envelope-from rdivacky@lev.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id C6B9C9CB2B8; Tue, 23 Dec 2008 10:01:51 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (lev.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VW33dGQzE2mb; Tue, 23 Dec 2008 10:01:49 +0100 (CET) Received: from lev.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 899DF9CB2C6; Tue, 23 Dec 2008 10:01:49 +0100 (CET) Received: (from rdivacky@localhost) by lev.vlakno.cz (8.14.2/8.14.2/Submit) id mBN91mBb016506; Tue, 23 Dec 2008 10:01:48 +0100 (CET) (envelope-from rdivacky) Date: Tue, 23 Dec 2008 10:01:48 +0100 From: Roman Divacky To: Gerry Weaver Message-ID: <20081223090148.GA16158@freebsd.org> References: <20081223000534.f740ca8a@mail01.compvia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081223000534.f740ca8a@mail01.compvia.com> User-Agent: Mutt/1.4.2.3i Cc: freebsd-hackers@freebsd.org Subject: Re: How to access kernel memory from user 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, 23 Dec 2008 09:06:57 -0000 On Mon, Dec 22, 2008 at 06:05:34PM -0600, Gerry Weaver wrote: > Hello All, > > I am working on a driver that collects various network statistics via pfil. I have a simple array of structures that I use to store the statistics. I also have a user space process that needs to collect these statistics every second or so. A copy operation from kernel to user space would be too expensive. Is there a mechanism that would allow me to gain direct access to my kernel array from user space? The user process would only need read access. It seems like maybe this could be done with mmap, but since this is not a character driver, there is no device file etc.. I'm a newbie, so I apologize if this is something that should be obvious. would it be feasible to allocate a buffer in userspace and map it into the kernelspace? if so, I believe sf_buf (man 9 sf_buf) should work roman