Review Board 2.0.15


M5 utility: Touch all pages in readfile buffer

Review Request #121 - Created Aug. 9, 2010 and submitted

Information
Joel Hestness
gem5
Reviewers
Default
util/m5/m5.c: in readfile(), added memset to touch all pages - ensure they are in the page table

This problem is caused by Linux demand paging.  If the pages are not yet mapped in the page table, the M5 utility does not know the physical memory address in the simulated system to which it is sending the file read from the host machine.
This fixes the functionality for x86, where the problem was first encountered.  I have also tested the utility for Alpha.  The simulated system executes approximately 10% more instructions during the readfile operation due to the memset, but the simulation time required for this is still marginal.  Using memset provides an ISA independent solution compared to buffer accesses that use a page-sized stride.
Ship it!
Posted (Aug. 9, 2010, 3:54 a.m.)
looks fine
Posted (Aug. 9, 2010, 5:13 a.m.)



  
  1. How is this not a possible issue for every isa? We're talking about touching 256kB of data. That shouldn't take very long. We've beaten this to death, it's time to just call it done and move on. If we're that concerned just do:
    for (int x = 0; x < sizeof(buf); x += 512) 
        buf[x] = 0;
    
    It improves the speed by three orders of magnitude, doesn't require and ifdef and will work on everything that doesn't have a unbelievably small page size.
    
util/m5/m5.c (Diff revision 1)
 
 
I actually just noticed that you're zeroing sizeof(buf).  Perhaps you should do what gabe said and just touch one word per page.  Seems like this could also be #ifdef x86.
  1. Seems like an overoptimization to me, unless we plan on using readfile to bring in some really huge files.  Also, there's no harm in doing this in non-x86 ISAs.  I won't fight putting those changes in, I'm just questioning their necessity.