size of page of memory - reasoning using offset

2019-07-25 11:55发布

问题:

It is theoretical consideration, but I think that this forum is ok for it. If Am I wrong ask for move it somewhere.
Virtual address (a8b43e) was mapped to (13fcb43e).
What can we say about size of page ?

So, we should look at maximal possible size of offset.
Here, we can see that matching suffixes is b43e. Moreover, we should look at binary representation of: 8 and c:
8 = 1000
c = 1100
So two last bits are matching. On the whole size of page is <= 2^{4*4+2} = 2^18.

Is it ok ?

回答1:

Your math is correct, but this only gives you an upper bound on the page size, because some address bits above the page offset may happen to match by chance between the physical and virtual address.

To find the real page size with this method, you need to look at a lot of samples and take the minimum match length.

Also keep in mind the OS could be preferring pages with more matching bits for some reason (perhaps page coloring), so even a large number of samples might not ever see a match length = page offset.