PerlNew99 has asked for the wisdom of the Perl Monks concerning the following question:

I'm new in Perl and what I would like to do ,for a given pid,is to parse from all virtual addresses to physical ones and the related information about PTE soft-dirty bit at each time interval . So what I would like to get ,by supposing an overall duration of 1 second and an observation time of 0.1 s(Thus I should get an array/list of 10 elements zero or one) is a data structure like this:

#PageNumberKey Soft_dirty-bit [pageframenumber#1]-> [0 1 0 0 1 1 0 0 1 1] [pageframenumber#2]-> [0 0 0 1 1 0 0 0 0 0] [pageframenumber#3]-> [0 0 0 0 0 1 0 0 1 0] [pageframenumber#4]-> [1 1 0 0 1 1 1 0 0 1] [pageframenumber#5]-> [1 1 0 0 0 0 0 0 1 1] ........................ ..........................
I'm thinking something like each hash key is linked to a list of values(array), but before that I need to parse the binary file proc/pid/pagemap in linux and then getting the above structure. I read something around ,but I got stuck at the moment. The structure of that file can be found at https://www.kernel.org/doc/Documentation/vm/pagemap.txt . I read something around ,but I got stuck at the moment. Thanks for reading.Any help/solution is very appreciated . PS: I also asked for help at stackoverflow so that I might have more chance to get an answer!
  • Comment on How to parse /proc/pid/pagemap and create an appropriate data structure
  • Download Code

Replies are listed 'Best First'.
Re: How to parse /proc/pid/pagemap and create an appropriate data structure
by rizzo (Curate) on Jun 14, 2018 at 17:34 UTC
      myself has posted the file which talks about the data structure. Anyway, a part from a tutorial it would be great having a bunch of solution. Thanks anyway
Re: How to parse /proc/pid/pagemap and create an appropriate data structure
by choroba (Cardinal) on Jun 14, 2018 at 16:10 UTC
    Crossposted to StackOverflow. It's considered polite to inform about crossposting to prevent wasted efforts of people not attending both sites, searching for a solution to a problem already solved at the other end of the internets.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,