Using vmalloc in device driver code

neha naik nehanaik27 at gmail.com
Fri Apr 5 10:52:46 EDT 2013


Hi Arun,
   I read that there is a minor page fault associated with vmalloc in
following document :
https://www.kernel.org/doc/gorman/html/understand/understand007.html
  That is why i am concerned that it may cause issues if trying to access
memory in io context (when call returns from the underlying device back).

Regards,
Neha

On Fri, Apr 5, 2013 at 2:09 AM, Arun KS <getarunks at gmail.com> wrote:

> Hi Neha,
>
> On Fri, Apr 5, 2013 at 12:25 AM, neha naik <nehanaik27 at gmail.com> wrote:
>
>> Hi All,
>>  From what i have learnt vmalloc requires a minor page fault to sync the
>> process page tables with the reference page tables. So, is it safe to use
>> memory already allocated by vmalloc in io context/device driver code
>> (especially when the io call has returned back to the device driver after
>> finishing io on the device). I know that in general it is better to use
>> kmalloc (for better efficiency  and so on....) but, i want to know if it is
>> inaccurate to use vmalloc in this particular case and why (in terms of
>> cannot service page faults in interrupt context etc)?
>>
>>
> vmalloc doesn't result in any minor page fault. Once the page are
> allocated for vmalloc, pages will reside in the main memory till released.
>
> The only difference between kmalloc-ed and vmalloc-ed memory
> is continuity of the pages in main memory.
> Pages allocated using vmalloc is not suitable for purposes like dma since
> it may be fragmented across main memory.. Otherwise both are same.
>
> There is no other advantage to kmalloc over vmalloc.
> HTH.
>
> Thanks,
> Arun
>
>
>> Thanks in advance for your help.
>>
>> Regards,
>> Neha
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130405/70ba9f9d/attachment.html 


More information about the Kernelnewbies mailing list