Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA) : (9 Items)
   
identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
Hello All,

I have to find actual physical memory address used by process . I am using structure _procfs_map_info with 
DCMD_PROC_PAGEDATA call as shown below.
(http://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.cookbook/topic/s3_procfs_DCMD_PROC_MAPINFO.html)


typedef struct _procfs_map_info {
  uint64_t   vaddr;
  uint64_t   size;
  uint32_t   flags;
  dev_t      dev;
  off_t      offset;
  ino_t      ino;
} procfs_mapinfo;

i couldn't find much info about variables dev,offset and ino. Could you please help me understand this?

is it possible to determine physical RAM address with this structure(using vaddr, offset etc..)?

Thank you!

 
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
To paraphrase a colleague of ours: "what problem are you trying to solve?".


-- Michael


________________________________
From: Surya kumar(deleted) <community-noreply@qnx.com>
Sent: Friday, July 2, 2021 14:05
To: ostech-core_os
Subject: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)

Hello All,

I have to find actual physical memory address used by process . I am using structure _procfs_map_info with 
DCMD_PROC_PAGEDATA call as shown below.
(http://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.cookbook/topic/s3_procfs_DCMD_PROC_MAPINFO.html)


typedef struct _procfs_map_info {
  uint64_t   vaddr;
  uint64_t   size;
  uint32_t   flags;
  dev_t      dev;
  off_t      offset;
  ino_t      ino;
} procfs_mapinfo;

i couldn't find much info about variables dev,offset and ino. Could you please help me understand this?

is it possible to determine physical RAM address with this structure(using vaddr, offset etc..)?

Thank you!





_______________________________________________

OSTech
http://community.qnx.com/sf/go/post121487
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
Attachment: HTML sf-attachment-mime40087 2.97 KB
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
Hello Michael,

Thank you for your response.

Currently we suspecting RAM memory used by PCI device and some process is overlapping.
We know the physical RAM mapping of PCI device but we want to determine physical RAM address of process.
This issue is sporadic.

Please let me know if you need more information.

Best Regards,
Surya
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
'paddr' field is added 11 years ago but seems still not documented, here is the actual strucutre:
typedef struct _procfs_map_info {
	_Uint64t					vaddr;
	_Uint64t					size;
	_Uint32t					flags;
	dev_t						dev;
#if __OFF_BITS__ == 64
	off_t						offset;
	ino_t						ino;
#elif __OFF_BITS__ == 32
	off64_t						offset;
	ino64_t						ino;
#else
#error __OFF_BITS__ value is unsupported
#endif
	_Uint64t					paddr;
}							procfs_mapinfo;
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
Thanks Lichun Zhu!

Just to confirm does paddr indicate physical address?

Thanks a lot again!
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
yes, physical address or -1 invalid.
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
Hi Lichun Zhu

I recently got access to real system to test changes. the physical address of processes is always printed as 0.

I am printing memory info of running process by another test exe by using DCMD_PROC_PAGEDATA call.
Could you please let me know if there is any mistake in my approach or could you please share as sample program for 
printing physical address.

With Best Regards,
Surya
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
Hi Lichun Zhu

I recently got access to real system to test changes. the physical address of processes is always printed as 0.

I am printing memory info of running process by another test exe by using DCMD_PROC_PAGEDATA call.
Could you please let me know if there is any mistake in my approach or could you please share as sample program for 
printing physical address.

With Best Regards,
Surya
Re: identify physical RAM memory address from structure _procfs_map_info(DCMD_PROC_PAGEDATA)  
It's a bit hard to comment without more details and without seeing your code. Here's an example I have for using 
DCMD_PROC_PAGEDATA. It is meant to check the effect of MAP_LAZY and it looks at the current process, but the principles 
are the same for what you are trying to do:

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <devctl.h>
#include <sys/mman.h>
#include <sys/procfs.h>

int
main(int argc, char **argv)
{
    // Map a page using MAP_LAZY.
    void    *ptr = mmap(0, __PAGESIZE * 10, PROT_READ | PROT_WRITE,
                        MAP_ANON | MAP_PRIVATE | MAP_LAZY, NOFD, 0);
    if (ptr == MAP_FAILED) {
        perror("mmap");
        return 1;
    }

    printf("ptr=%p\n", ptr);

    // Open the devctl interface for this process.
    int fd = open("/proc/self/ctl", O_RDWR);
    if (fd == -1) {
        perror("open");
        return 1;
    }

    // Ask for up to 32 mapinfo entries.
    procfs_mapinfo  mapinfo[32];
    memset(mapinfo, 0, sizeof(mapinfo));
    if (devctl(fd, DCMD_PROC_PAGEDATA, mapinfo, sizeof(mapinfo), NULL) == -1) {
        perror("devctl");
        return 1;
    }

    // Print results.
    for (int i = 0; i < 32; i++) {
        printf("vaddr=%lx size=%zu flags=%x paddr=%lx\n",
               (uintptr_t)mapinfo[i].vaddr,
               (size_t)mapinfo[i].size,
               mapinfo[i].flags,
               (uintptr_t)mapinfo[i].paddr);
    }

    return 0;
}

The output looks like:

ptr=9053000
vaddr=7fc7000 size=4096 flags=1083082 paddr=ffffffffffffffff
vaddr=7fc8000 size=516096 flags=1083382 paddr=ffffffffffffffff
vaddr=8046000 size=8192 flags=1783382 paddr=43b82e000
vaddr=8048000 size=4096 flags=1600571 paddr=43b80d000
vaddr=8049000 size=2097152 flags=10800a2 paddr=ffffffffffffffff
vaddr=8249000 size=4096 flags=1600132 paddr=43b87f000
vaddr=824a000 size=4096 flags=1700332 paddr=43beb7000
vaddr=9048000 size=20480 flags=1780302 paddr=432206000
vaddr=904d000 size=24576 flags=1080302 paddr=ffffffffffffffff
vaddr=9053000 size=40960 flags=1080382 paddr=ffffffffffffffff
vaddr=905d000 size=4096 flags=1780302 paddr=43b7fa000
vaddr=905e000 size=24576 flags=1080302 paddr=ffffffffffffffff
vaddr=9064000 size=4096 flags=1780302 paddr=43b774000
vaddr=100000000 size=221184 flags=610571 paddr=126a000
vaddr=100036000 size=2093056 flags=10800a2 paddr=ffffffffffffffff
vaddr=100235000 size=8192 flags=610172 paddr=43b4d0000
vaddr=100237000 size=4096 flags=710372 paddr=43b852000
vaddr=100238000 size=4096 flags=1780332 paddr=43b881000
vaddr=100239000 size=724992 flags=610571 paddr=1124000
vaddr=1002ea000 size=2097152 flags=1080022 paddr=ffffffffffffffff
vaddr=1004ea000 size=16384 flags=1680132 paddr=44a5ee000
vaddr=1004ee000 size=8192 flags=710372 paddr=43b7fd000
vaddr=1004f0000 size=12288 flags=1780332 paddr=43b725000
vaddr=1004f3000 size=90112 flags=610571 paddr=11dc000
vaddr=100509000 size=2093056 flags=1080022 paddr=ffffffffffffffff
vaddr=100708000 size=4096 flags=1680132 paddr=43b74a000
vaddr=100709000 size=4096 flags=710372 paddr=43b826000
vaddr=0 size=0 flags=0 paddr=0
vaddr=0 size=0 flags=0 paddr=0
vaddr=0 size=0 flags=0 paddr=0
vaddr=0 size=0 flags=0 paddr=0
vaddr=0 size=0 flags=0 paddr=0

--Elad