Skip to content

Fix PT page allocation#665

Closed
gh1403 wants to merge 1 commit intoChampSim:developfrom
gh1403:fix-ptpage
Closed

Fix PT page allocation#665
gh1403 wants to merge 1 commit intoChampSim:developfrom
gh1403:fix-ptpage

Conversation

@gh1403
Copy link
Copy Markdown
Contributor

@gh1403 gh1403 commented Nov 5, 2025

Currently each VirtualMemory::get_pte_pa function call would allocate a new PT page, as champsim::page_offset{next_pte_page} == champsim::page_offset{0} is always true.

Also, PT page insertion logic seems to use the wrong level for index comparison. Consider level = 1, the function will try to insert the full PFN into page_table. While in VirtualMemory::va_to_pa it will do another page address translation. Therefore, the fault penalty and the overall memory usage will be doubled.

@gh1403 gh1403 changed the base branch from master to develop November 5, 2025 10:53
@gh1403 gh1403 changed the title Fix PTE page allocation Fix PT page allocation Nov 5, 2025
@maccoymerrell
Copy link
Copy Markdown
Contributor

I think that the PT page insertion logic is correct (from our work with R-MAX, we rebuilt the page table structure from tracing and found it was correctly done). The PTW is providing the level index for the get_pte_pa calls.
If you believe this is an error, could you generate some printouts showing that we are triggering additional page faults / allocating additional pages without this change?

@gh1403
Copy link
Copy Markdown
Contributor Author

gh1403 commented Nov 7, 2025

please use my test branch here and run random workloads like:

bin/champsim --warmup-instructions 0 --simulation-instructions 2500000 ../traces/dpc3/436.cactusADM-1804B.champsimtrace

The output logs would have unrealistically high numbers of 'new active pte page', and the count of 'new next pte page' would also be more than 'new data page'. For example, 436.cactusADM-1804B workload has about only 4MB memory footprint but allocates thousands of pte pages (should only need tens of them).

@maccoymerrell
Copy link
Copy Markdown
Contributor

@ngober This seems like a major issue. We are overallocating a significant number of pages for pte entries. Like mentioned above, translation is going to be much slower as well.

@maccoymerrell
Copy link
Copy Markdown
Contributor

This probably needs a test added to the test suite.

Also, from some initial runs, this could account for as much as a 5% performance differencd for some workloads. Others may be closer to 1%. Drops off as the TLB is filled and ptw walks become less frequent.

@ngober
Copy link
Copy Markdown
Collaborator

ngober commented Nov 7, 2025

Oh, yea, that does look like a bug. That will over-allocate pages especially when warming up. Let's add a test on this and get it merged.

@ngober ngober added the bug label Nov 7, 2025
@ngober
Copy link
Copy Markdown
Collaborator

ngober commented Feb 14, 2026

Resolved with #688

@ngober ngober closed this Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants