get Page size
Hi!
How can we get the page size in linux. Can i change that in in aprogram? In Kernel module programming is there any way to get the memory pieces just like 10 bytes, 2 bytes? ( i think kmalloc allocates entire page if the requested memory is less than the page size So its a waste of remaining memory) Please reply me. bye, Eshwar. |
To get page size:
Code:
|
to add one thing to the above, kmalloc keeps around a pool of various sized memory objects. whether or not there is one as small as 10 bytes, i doubt, but you should recieve the next largest chunk if that pool has a free chunk. if you are going to be allocating a large quantity of constant size memory chunks, you may want to look into having kmalloc create a special pool of objects for you of that size using kmem_cache_create() and kmem_cache_alloc() from [kernel/slab/mm.c].
|
I seriously doubt youll get a buffer of 10bytes using kmalloc, since the minimum memory that kmalloc handles is anywhere from 32 to 64 bytes, depending on page size and kernel.
|
Quote:
|
Hi guys thank you very much.
|
HI,
When I am trying to getpagefile(), it is always returning me 4096. Can you please help. I am reallocating the memory from 4096 to 2048 through realloc(), but everytime it is giving me 4096. Thanks, |
Quote:
PS. There is a ksize function which can be used to figure out actual size of allocated memory. |
Quote:
Also, keep in mind everything I said in my posts is over ten years old, so things may have changed. |
Quote:
|
All times are GMT -5. The time now is 03:54 PM. |