Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/50757 )
Change subject: sim: Align process memory allocations.
......................................................................
sim: Align process memory allocations.
Align allocation requests in Process::allocateMem to page boundaries,
rather than assume that they already are. This frees the caller from
having to know what boundary to align things to. The older version would
make the caller more aware of the extent of the allocation in theory,
but in reality the caller would just blindly perform the alignment like
this function is anyway.
Change-Id: I897714d4481d961255a9e44ae080135e507be199
---
M src/sim/process.cc
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 71bb494..3a631a5 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -316,6 +316,10 @@
void
Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
{
+ const auto page_size = pTable->pageSize();
+
+ const Addr page_addr = roundDown(vaddr, page_size);
+
// Check if the page has been mapped by other cores if not to clobber.
// When running multithreaded programs in SE-mode with DerivO3CPU
model,
// there are cases where two or more cores have page faults on the same
@@ -324,16 +328,17 @@
// a physical page frame to map with the virtual page. Other cores can
// return if the page has been mapped and `!clobber`.
if (!clobber) {
- const EmulationPageTable::Entry *pte = pTable->lookup(vaddr);
+ const EmulationPageTable::Entry *pte = pTable->lookup(page_addr);
if (pte) {
warn("Process::allocateMem: addr %#x already mapped\n", vaddr);
return;
}
}
- int npages = divCeil(size, pTable->pageSize());
- Addr paddr = seWorkload->allocPhysPages(npages);
- pTable->map(vaddr, paddr, size,
+ const int npages = divCeil(size, page_size);
+ const Addr paddr = seWorkload->allocPhysPages(npages);
+ const Addr pages_size = npages * page_size;
+ pTable->map(page_addr, paddr, pages_size,
clobber ? EmulationPageTable::Clobber :
EmulationPageTable::MappingFlags(0));
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50757
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I897714d4481d961255a9e44ae080135e507be199
Gerrit-Change-Number: 50757
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s