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
> 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
> 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
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
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
5 matches
Mail list logo