Date: Wed, 24 Dec 2008 15:22:07 -0600 From: "Gerry Weaver" <gerryw@compvia.com> To: "Peter Jeremy" <peterjeremy@optushome.com.au> Cc: freebsd-hackers@freebsd.org Subject: Re: How to access kernel memory from user space Message-ID: <20081224212207.4cc4874b@mail01.compvia.com> In-Reply-To: 20081224084445.GA1081@server.vk2pj.dyndns.org
next in thread | raw e-mail | index | archive | help
=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 <gerryw@compvia.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081224212207.4cc4874b>