Re: Re: _pa/virt_to_phys and __va/phys_to_virt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mark...everyone...

> Can we go via an example? Say I have a kernel module
> and am loading it after system start. Then in that
> module, I need some kinds of buffer and want to
> allocate memory using kmalloc. Then because I am a
> kernel space prog. kernel doesnt defer the allocation
> and tries to give me what I need. 

Note that "deferred" allocation doesn't always happen, especially when 
you use GFP_ATOMIC. Deferred allocation only happens if memory 
allocator can not satisfy your request due to lack of free RAM, so it 
sleeps and wait until some amount of memory is released....

>Say it finds a
> physical addr. range starting at 0x04000000. Then is
> the virtual addr. given to me 0xC4000000? I am
> wondering this...

yes, IMHO this is correct. Like Fawaad said, memory area that is mapped 
into kernel address space (above PAGE_OFFSET) always has same virtual 
address no matter what context you are in (process context, interrupt 
context. In this case, since module is also a part of kernel, any 
allocation done via kmalloc is also mapped on kernel address space, 
thus has constant virtual address on every situation.

Hope it explains the issue better....

regards

Mulyadi Santosa


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux