From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 24 21:22:20 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 EF9FD106564A for ; Wed, 24 Dec 2008 21:22:19 +0000 (UTC) (envelope-from gerryw@compvia.com) Received: from mail01.compvia.com (mail01.compvia.com [12.147.132.91]) by mx1.freebsd.org (Postfix) with ESMTP id 9D9C88FC16 for ; Wed, 24 Dec 2008 21:22:19 +0000 (UTC) (envelope-from gerryw@compvia.com) Received: from [10.10.20.11] ([10.10.20.11]) by mail01.compvia.com (Kerio MailServer 6.5.1); Wed, 24 Dec 2008 15:22:07 -0600 To: "Peter Jeremy" From: "Gerry Weaver" In-Reply-To: 20081224084445.GA1081@server.vk2pj.dyndns.org Message-ID: <20081224212207.4cc4874b@mail01.compvia.com> Date: Wed, 24 Dec 2008 15:22:07 -0600 X-Mailer: Kerio MailServer 6.5.1 WebMail X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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: Wed, 24 Dec 2008 21:22:20 -0000 =5F=5F=5F=5F=5F =20 From: Peter Jeremy [mailto:peterjeremy@optushome.com.au] To: Gerry Weaver [mailto:gerryw@compvia.com] Cc: freebsd-hackers@freebsd.org Sent: Wed, 24 Dec 2008 02:44:45 -0600 Subject: Re: How to access kernel memory from user space On 2008-Dec-22 18:05:34 -0600, Gerry Weaver wrote: >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. =20 The easiest (and hackiest) approach would be to kldsym(2) to locate the symbol in KVM and then mmap(2) the relevant part of /dev/kmem. The biggest downside is that the userland process needs to be group kmem. =20 The other approach would be for your kernel driver to grow a character device node and directly support mmap. =20 --=20 Peter Jeremy Please excuse any delays as the result of my ISP's inability to implem= ent an MTA that is either RFC2821-compliant or matches their claimed behav= iour.Hello All, Happy Holidays Everyone!! Thanks for the advice Peter. In this case, the driver I'm working on wil= l run on a dedicated embedded platform, so process group membership shouldn't be an issue. My= main=20 concern is performance. Any additional overhead will effect the stats, s= o I want to try to keep it minimal. Is there any significant trade off in performance be= tween the two approaches=3F The typical data array size is around 20k. Also, Is there = anything in the source or ports tree that I could use as an example for the device node case=3F= I've been looking around, but haven't found anything yet. I'll continue digging though ;-) Thanks Again, Gerry =20