Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
Here is some code which fails with malloc < 1 page and sometimes succeeds with large mallocs (> 16 pages) What's wrong? #include #include #include #include #include #include #include #include #include // Copyright: skeleton took from an older post on the freebsd list #include #include

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
> If your kernel module creates a device in /dev that implements the > mmap method, then you don't need to worry about mucking around with > vm_maps and objects and whatnot.  Your mmap method just needs to be > able to convert offsets into the device into physical memory > addresses, Yes I'm aware

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
> By using kernel_map instead of kmem_map, vm_map_lookup() now always > return a vm_object. That's a big progress. > As expected, when this object is kmem_object, the user mapping works > fine (for smaller or larger mallocs.) > > Otherwise that object doesn't match kernel_object. It's an anonymous

Re: malloc pages map to user space

2012-03-22 Thread Eric Saint-Etienne
I've refined the behaviour I observe, which isn't consistent depending on the size one mallocates. (see interleaved comments) > In my driver, I need to map some malloc-ed memory, obtained from > another module, into userspace. > > The problem: on the smaller mallocs, as well as on some bigeer ones

malloc pages map to user space

2012-03-21 Thread Eric Saint-Etienne
Hi, >From within the freeBSD kernel, not all malloc are made equal: * malloc() smaller than KMEM_ZMAX (set to one page size) end up in UMA SLABs, themselves laid out in powers of 2 (from 16 bytes, 32... to 4096 bytes) * bigger malloc() are done through uma_large_malloc() which uses