Re: what is the difference between kmalloc and vmalloc?

2012-11-26 Thread Mulyadi Santosa
Hi...

On Mon, Nov 26, 2012 at 1:51 PM, Vijay Chauhan  wrote:
> Is it necessary that vmalloc always allocate virtually contiguous
> memory and not physically contiguous?

to the best I know, yes vmalloc allocate virtually contigous.

However, since they manage the pages by fiddling with the page tables,
there is a chance that some of them are physically contigous IMHO

> Except large size memory allocation why one needs to use vmalloc? Can
> we say that use kmalloc and  if it fails retry with kmalloc?

nice question: AFAIK vmalloc() is made to tackle large size memory
allocation, or in other word to side step memory fragmentation issue.

IIRC too, that by using vmalloc, the vmalloc-ed area are guarded by
guard pages on both start and end address. So it's like stack overflow
guard pages. But don't count me on this info. Check it by yourself.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: what is the difference between kmalloc and vmalloc?

2012-11-25 Thread Vijay Chauhan
On Thu, Nov 22, 2012 at 9:39 AM, Mulyadi Santosa
 wrote:
> On Thu, Nov 22, 2012 at 10:12 AM, horse_rivers  wrote:
>> thanks!
>
> kmalloc allocates memory from slab cache. It tends to be physically
> contigous and you can get memory size smaller than page size.
>
> vmalloc, on the other hand, is when you need only virtually contigous
> memory area. Example of such usage is for allocating memory to load
> kernel module.

Is it necessary that vmalloc always allocate virtually contiguous
memory and not physically contiguous?
Except large size memory allocation why one needs to use vmalloc? Can
we say that use kmalloc and  if it fails retry with kmalloc?

regards
Vijay

>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: what is the difference between kmalloc and vmalloc?

2012-11-21 Thread Vivek Dasgupta
kmalloc allocates physically contiguous memory, while vmalloc
allocates memory which is only virtually contiguous and not
necessarily physically contiguous.

Usually physically contiguous memory is required for hardware devices
(dma etc) , thus kmalloc is useful for allocating such memory. And
though this is not always the requirement, still kmalloc is preferred
, because it is better in terms of performance, because vmalloc can
result in greater TLB thrashing .

vmalloc is useful when very large amounts of memory is to be
allocated, because when memory becomes heavily fragmented, you may not
get success while allocating large memory via kmalloc.

Slab layer serves like a cache for commonly used data structures,
again with a view to reduce fragmentation, and to speed up operations.
To allocate objects from slab you will have to use functions like
kmem_cache_create() and kmem_cache_alloc() ..

thanks
Vivek

On Thu, Nov 22, 2012 at 8:42 AM, horse_rivers  wrote:
>
> thanks!
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: what is the difference between kmalloc and vmalloc?

2012-11-21 Thread Mulyadi Santosa
On Thu, Nov 22, 2012 at 10:12 AM, horse_rivers  wrote:
> thanks!

kmalloc allocates memory from slab cache. It tends to be physically
contigous and you can get memory size smaller than page size.

vmalloc, on the other hand, is when you need only virtually contigous
memory area. Example of such usage is for allocating memory to load
kernel module.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


what is the difference between kmalloc and vmalloc?

2012-11-21 Thread horse_rivers
thanks!

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies