Does KMALLOC allocates only in page size memory or it can allocate less ? What are the sizes that the kmalloc can allocate ? Where can I find description of it, as everywher
You can see some common sizes used by kmalloc() int your system with:
cat /proc/slabinfo | grep kmalloc
More important than the consideration of whether kmalloc can allocate less than a page is the question of whether it can allocate more than a page: if you are calling kmalloc() in atomic context (with the GFP_ATOMIC flag), it can't and won't try very hard to find contiguous pages in memory, so if your memory is very fragmented, and the order of your allocation is high (allocation size → pagesize*2^(allocation order)), the allocation may fail. So, in atomic context, big allocations are likely to fail.
There is an example of a failed allocation of order 7 (512 Kb) at this other SO question about maximum AF_UNIX datagram size.