Mitch Crane wrote:
Hi all,
I've been looking at the following solution to get started, I'd like
to ask those with more experience, what are the drawbacks?
1. invoke slabs_init with prealloc set to "true"
2. use mmap instead of malloc
if (prealloc) {
/* Allocate everything in a big chunk with malloc */
mem_base = malloc(mem_limit);
changes to
if (prealloc) {
/* Map everything to my block device special file
in a big chunk with mmap..
fd is a global file descriptor (to be closed on cleanup)
filename is the block device special file "/dev/foo" */
fd = open(filename, O_RDWR, 0600);
mem_base = mmap(NULL, mem_limit, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
By doing so you will end up talking to your block device _every_ time
you try to look up an item in the cache. You might want to consider
keeping the data structures in memory instead...
Cheers,
Trond