tags:

views:

257

answers:

1

I'm working on one piece of a very high performance piece of hardware that works under Linux. We'd like to cache some data but we're worried about memory consumption - so the idea is to create a user process to manage the cache. That way, the cache can be in virtual memory, not in kernel space, et cetera.

The question is: what's the best way to do this? My first instinct is to have the kernel module create a character device file, and have a user program that opens that file, then sits on a select statement waiting for commands to arrive on it. But I'm concerned that this might not be optimal. A friend mentioned he knew of a socket-based interface, but when pressed he couldn't provide any details....

Any suggestions?

+1  A: 

I think you're looking for the netlink interface. See Why and How to Use Netlink Socket [sic] for more information. Be careful of security issues when talking between the kernel and user space; there was a recent vulnerability when udev neglected to check that messages were coming from the kernel rather than user space.

Brian Campbell
The recent vulnerability had a slightly different cause than what you stated: udev assumed that any netlink messages it was receiving originated in the kernel, but user processes could have maliciously sent messages to udev.
ephemient
Will this have better performance than simply creating a character device?
Mike Heinz
I don't have any experience with using this myself; I've just heard of it, and since you were asking about a socket-based interface, I thought I'd mention it.
Brian Campbell