<div dir="ltr">Thanks a lot, it worked :)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 19, 2021 at 7:00 PM ckim <<a href="mailto:ckim@etri.re.kr">ckim@etri.re.kr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div 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="gmail-m_6765896237702261359composer_signature" dir="auto"><div style="font-size:85%;color:rgb(87,87,87)" dir="auto">내 Galaxy에서 보냄</div></div><div dir="auto"><br></div><div><br></div><div align="left" dir="auto" style="font-size:100%;color:rgb(0,0,0)"><div>-------- 원본 이메일 --------</div><div>발신: wuzhouhui <<a href="mailto:wuzhouhui14@mails.ucas.ac.cn" target="_blank">wuzhouhui14@mails.ucas.ac.cn</a>> </div><div>날짜: 21/8/19 오후 9:17 (GMT+09:00) </div><div>받은 사람: Lloyd <<a href="mailto:lloydkl.tech@gmail.com" target="_blank">lloydkl.tech@gmail.com</a>>, <a href="mailto:kernelnewbies@kernelnewbies.org" target="_blank">kernelnewbies@kernelnewbies.org</a> </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>> <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>> <a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br><br><br>_______________________________________________<br>Kernelnewbies mailing list<br><a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br><a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br></div>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div>