Skip to content

Pre-set ACCESSED and DIRTY flags in page table entries#1067

Merged
CvvT merged 2 commits into
microsoft:mainfrom
dywongcloud:main
Jul 23, 2026
Merged

Pre-set ACCESSED and DIRTY flags in page table entries#1067
CvvT merged 2 commits into
microsoft:mainfrom
dywongcloud:main

Conversation

@dywongcloud

@dywongcloud dywongcloud commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Pre-set the ACCESSED and DIRTY flags when creating page table entries, matching Linux’s _KERNPG_TABLE behavior. This avoids atomic read-modify-write operations by the CPU page-table walker on first access.

claude and others added 2 commits July 22, 2026 22:02
Mirrors the Linux kernel's _KERNPG_TABLE convention
(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) for
entries that point at another page table (PML4E, non-huge PDPTE,
non-huge PDE). Pre-setting Accessed/Dirty avoids the CPU needing an
atomic read-modify-write on the entry the first time it's walked,
reducing cache-coherency traffic on the page-table walk path.

Addresses microsoft#980, following up on a review comment
from ziqiaozhou on PR microsoft#972 that suggested this optimization.

Fixes 5 call sites that construct parent/intermediate table-pointer
flags: three in litebox_platform_lvbs's map_phys_frame_range,
map_non_contiguous_phys_frames, and page-fault handler; one in
litebox_platform_linux_kernel's page-fault handler; and the raw
PTE_TABLE_FLAGS constant used for manual PML4/PDPT/PDE writes during
litebox_runner_lvbs's early boot trampoline mapping.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016L8VyzZRY6AgtSd3EWAxQa
Pre-set ACCESSED and DIRTY flags in page table entries

@CvvT CvvT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dywongcloud Thanks for breaking down your previous PR. This one look reasonable to me. One minor concern is the long PR message that is unnecessary and makes git log harder to read. I would appreciate it if you could shorten it. For this PR, only keeping the text from summary should be fine. We would like to keep a consistent style. Thanks!

@dywongcloud

Copy link
Copy Markdown
Contributor Author

Hi @dywongcloud Thanks for breaking down your previous PR. This one look reasonable to me. One minor concern is the long PR message that is unnecessary and makes git log harder to read. I would appreciate it if you could shorten it. For this PR, only keeping the text from summary should be fine. We would like to keep a consistent style. Thanks!

Hi I shortened it! Please let me know!

@dywongcloud
dywongcloud requested a review from CvvT July 23, 2026 21:52
@dywongcloud dywongcloud reopened this Jul 23, 2026
@dywongcloud

Copy link
Copy Markdown
Contributor Author

sorry i accidentally closed it but I reopened it

@CvvT CvvT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@CvvT
CvvT added this pull request to the merge queue Jul 23, 2026
Merged via the queue into microsoft:main with commit d424651 Jul 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants