RE: memory used by kernel?

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

 



The address returned by the kmalloc is a virtual address which is
already mapped in the kernel page tables  The address has a direct
mapping to the physical memory and the address will be in between
PAGE_OFFSET ( 3GB normally) and high_memory (The virutail address that
corresponds to the end of physical memory, remember the kernel maps all
the physical RAM above PAGE_OFFSET). 

Kmalloc() uses the slab allocater  to ge a contiguous physical memory
(good for DMA, more efficient to avoid internal and external
fragmentation) area of any size but less than 131072 (I think).
kmem_cache_alloc() is a similar function but used to allocate memory for
well known kernel structures from the slab allocator (For eg:
tast_struct). In both cases the allocated memory will be physically
contiguous and the virtual address also will be contiguous. Also there
is NO manipulation of kernel page tables as the physical memory is
already mapped in the page tables.

Vmalloc does not guarantee that the physical memory is contiguous, but
the virtual address will be contiguous. Return the virtual address above
high_memory and vmalloc requires the manipulation ( It updates the page
directory/page table to add the new mapping) of kernel page tables to
map the physical memory frames allocated (From the buddy system in
multiple of 4K) above the high_memory and return the virtual address. 

Aboo


-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Mandeep Sandhu
Sent: Monday, October 11, 2004 3:20 PM
To: arm@xxxxxxxxxxxxxxx
Cc: 'matrix reloaded'; 'kernelnewbies'; 'manish regmi'
Subject: RE: memory used by kernel?

On Fri, 2004-10-08 at 21:09, Anand wrote:
> hey  this link sld help u better http://kerneltrap.org/node/view/2450 
> ,
> More over in the kernel space kmalloc() does the Physical Memory
> allocation,

but the address returned by kmalloc is also a virtual address right??
it's only that kmalloc gives a continuous chunk of mem. as compared
to vmalloc

thanx,
-mandeep
> and vmalloc does the Virtual Memory allocation.
>  
> Rgds,
> Anand
>         -----Original Message-----
>         From: kernelnewbies-bounce@xxxxxxxxxxxx
>         [mailto:kernelnewbies-bounce@xxxxxxxxxxxx]On Behalf Of matrix
>         reloaded
>         Sent: Friday, October 08, 2004 3:46 PM
>         To: Mandeep Sandhu
>         Cc: kernelnewbies; manish regmi
>         Subject: Re: memory used by kernel?
>         
>         
>         
>         
>         
>         
>         On Fri, 08 Oct 2004 Mandeep Sandhu wrote : 
>         
>         >then is there amax limit upto which the kernel can allocate
>         mem 
>         >for itself + what is the significance of the 3G/1G split?? 
>         >Is'nt this 1G mapping the limit upto which all kernel space 
>         >addresses can exist??? can the kernel eat into user-space mem
>         >as well? 
>         
>         This 1G thing is virtual address space division, but you are
>         right in the sense that 
>         this may be the limit for kernel memory usage, as for physical
>         memory you need to 
>         have virtual address space also in protected mode on x86. 
>         
>         Thanks. 
>         Sumit Sharma 
>         IBM, Bangalore. 
>         
>         
>         
>         

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


--
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