Hi :
you can find out the meaning in vmalloc.c, function vmalloc(). vmalloc accept only one parameter, the size of memory that you want to allocate. this function will return the virtual address which you can use to read/write data inside it. vmalloc hides some implementation details about real memory allocation, for example: the virtual address that returned from vmalloc() function is continuous, but physical memory can not continuous. vmalloc() will first call function alloc_vmap_area(), which you mentioned before, this function will occupy a continuous virtuall address space in VMALLOC region, note that it only occupies virtual address space, no physical memory are mapped to these virtual address at this moment. so if you operate at this virtual address as you did before, it is a bug! vmalloc() then call function __vmalloc_area_node(), which will find out enough non-continuous physical memory, then modify PTEs of current task, map the virtual address to real physical memory. after this, you can operate at the address returned by alloc_vmap_area(). the example code you did lacks this action, you can try to add this and test again. i suggest that you use kmalloc() and vmalloc() directly. if you want to allocate small and physical continuous memory, use kmalloc(). if you want to allocate very large(e.g. 10MB) and physical non-continuous memory, use vmalloc(). Best Regards Date: Wed, 18 Apr 2012 18:00:03 +0800 Subject: Re: how to use the memory allocated in kernel? From: summerxyt@xxxxxxxxx To: dhylands@xxxxxxxxx CC: kernelnewbies@xxxxxxxxxxxxxxxxx Hi Dave, Thanks for reply. My English is not very good, and so I want to ask about a term:map. Does map mean that creat e a relationship between the virtual space and physical memory? Thanks again!
在 2012年4月18日 下午4:17,Dave Hylands <dhylands@xxxxxxxxx>写道: Hi , _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies |
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies