All of lore.kernel.org
 help / color / mirror / Atom feed
From: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
To: Lloyd <lloydkl.tech@gmail.com>, kernelnewbies@kernelnewbies.org
Subject: Re: kmalloc - Address is not consecutive
Date: Thu, 19 Aug 2021 20:16:35 +0800	[thread overview]
Message-ID: <32f8b3aa-1bdd-109a-7267-515bb0fdab20@mails.ucas.ac.cn> (raw)
In-Reply-To: <CAA10ZTpsOaCmgoTWrvwMVx_CTEZ4eE6-ZkXPp161Vwuj1ApErA@mail.gmail.com>



On 8/19/21 6:54 PM, Lloyd wrote:
> Hi,
>
> 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
>
Quoted from Documentation/core-api/printk-formats.rst:
> A raw pointer value may be printed with %p which will hash the address
> before printing. The kernel also supports extended specifiers for printing
> pointers of different types.
So the address printed neither logical nor physical address.

> Thanks a lot,
>   Lloyd
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2021-08-19 12:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 10:54 kmalloc - Address is not consecutive Lloyd
2021-08-19 12:16 ` wuzhouhui [this message]
2021-08-19 13:29   ` ckim
     [not found]   ` <E1mGi6z-0002zV-NE@shelob.surriel.com>
2021-08-19 13:33     ` Lloyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32f8b3aa-1bdd-109a-7267-515bb0fdab20@mails.ucas.ac.cn \
    --to=wuzhouhui14@mails.ucas.ac.cn \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=lloydkl.tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.