kmalloc - Address is not consecutive

Lloyd at
Thu Aug 19 06:54:18 EDT 2021


I am trying to print the address of consecutive locations in a
memory allocated using kmalloc. It prints non contiguous addresses! I tried
with kmalloc_array, and  normal array on stack, I got the same  result. May
I know the reason? The code fragment for array and result are given below.

uint8_t MyArray[100]={'0'};
printk(KERN_INFO "\nAddress is-> %p\n",&MyArray[0]);
printk(KERN_INFO "\nAddress is-> %p\n",&MyArray[1]);
printk(KERN_INFO "\nAddress is-> %p\n",&MyArray[2]);

[ 8684.613909]               Address is-> 00000000b3330991
[ 8684.613914]               Address is-> 000000000519068c
[ 8684.613915]               Address is-> 00000000e448ca76

Thanks a lot,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Kernelnewbies mailing list