<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body dir="auto"><div dir="auto">Hi! this one is easy :)</div><div dir="auto">For printing pointer in kernel space, you should use %px not %p as format specifier. I heard this is for security reason(?).</div><div dir="auto">Chan Kim</div><div dir="auto"><br></div><div id="composer_signature" dir="auto"><div style="font-size:85%;color:#575757" dir="auto">내 Galaxy에서 보냄</div></div><div dir="auto"><br></div><div><br></div><div align="left" dir="auto" style="font-size:100%;color:#000000"><div>-------- 원본 이메일 --------</div><div>발신: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn> </div><div>날짜: 21/8/19 오후 9:17 (GMT+09:00) </div><div>받은 사람: Lloyd <lloydkl.tech@gmail.com>, kernelnewbies@kernelnewbies.org </div><div>제목: Re: kmalloc - Address is not consecutive </div><div><br></div></div><br><br>On 8/19/21 6:54 PM, Lloyd wrote:<br>> Hi,<br>><br>> I am trying to print the address of consecutive locations in a <br>> memory allocated using kmalloc. It prints non contiguous addresses! I <br>> tried with kmalloc_array, and normal array on stack, I got the same <br>> result. May I know the reason? The code fragment for array and result <br>> are given below.<br>><br>> uint8_t MyArray[100]={'0'};<br>> printk(KERN_INFO "\nAddress is-> %p\n",&MyArray[0]);<br>> printk(KERN_INFO "\nAddress is-> %p\n",&MyArray[1]);<br>> printk(KERN_INFO "\nAddress is-> %p\n",&MyArray[2]);<br>><br>><br>> [ 8684.613909] Address is-> 00000000b3330991<br>> [ 8684.613914] Address is-> 000000000519068c<br>> [ 8684.613915] Address is-> 00000000e448ca76<br>><br>Quoted from Documentation/core-api/printk-formats.rst:<br>> A raw pointer value may be printed with %p which will hash the address<br>> before printing. The kernel also supports extended specifiers for printing<br>> pointers of different types.<br>So the address printed neither logical nor physical address.<br><br>> Thanks a lot,<br>> Lloyd<br>><br>><br>> _______________________________________________<br>> Kernelnewbies mailing list<br>> Kernelnewbies@kernelnewbies.org<br>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<br><br><br>_______________________________________________<br>Kernelnewbies mailing list<br>Kernelnewbies@kernelnewbies.org<br>https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<br></body></html>