Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic check for pagemap support #30

Merged
merged 5 commits into from
Nov 13, 2023
Merged

Add dynamic check for pagemap support #30

merged 5 commits into from
Nov 13, 2023

Conversation

greg7mdp
Copy link
Contributor

@greg7mdp greg7mdp commented Nov 13, 2023

This is to better support systems like Ubuntu running under WSL2, where the kernel may be running without configured pagemap soft-dirty support, as shown by:

zcat /proc/config.gz | grep SOFT_DIRTY
CONFIG_HAVE_ARCH_SOFT_DIRTY=y
# CONFIG_MEM_SOFT_DIRTY is not set

In this change, after attempting the clear the soft-dirty bits when opening a new chainbase db, we try mapping and modifying a 4K page to verify that the soft-dirty feature is working correctly.

@heifner could you try this branch on your system? I have some problems with my own WSL2/windows environment.

@heifner
Copy link
Member

heifner commented Nov 13, 2023

@heifner could you try this branch on your system? I have some problems with my own WSL2/windows environment.

On WSL2:

CHAINBASE: Detect pagemap support: Not supported

start/stop/start now works.

// Bit 62 page swapped
// Bit 63 page present
//
// Here we are just checking bit #55 (the soft-dirty bit).
Copy link
Member

Choose a reason for hiding this comment

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

I think we only need this comment once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed duplicate comment.

fs::resize_file(path, pagesz);
bip::file_mapping mapping = bip::file_mapping(path.generic_string().c_str(), bip::read_write);
bip::mapped_region region = bip::mapped_region(mapping, bip::read_write);
char* p = (char *)region.get_address();
Copy link
Member

Choose a reason for hiding this comment

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

I doubt you need to go through the trouble of creating a temporary file; you can probably just use a variable on the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, that was way overkill, I simplified it.

@greg7mdp greg7mdp merged commit d3dba51 into main Nov 13, 2023
2 checks passed
@greg7mdp greg7mdp deleted the gh_1878 branch November 13, 2023 21:53
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