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

Can do mincore warning #78

Merged
merged 3 commits into from
Mar 9, 2020
Merged

Can do mincore warning #78

merged 3 commits into from
Mar 9, 2020

Conversation

johnmay
Copy link
Contributor

@johnmay johnmay commented Mar 8, 2020

As reported by #74, on Kernal 5.2+ mincore does not report correctly if you don't have write permission. Touch and evict still work as expect it's just the reporting that is wrong. This PR adds a runtime can_do_mincore function for __linux__ which checks the Kernal version and if the user running the process has write permission to the file. If o_verbose and vmtouch can't get accurate information it issues a warning: vmtouch: WARNING: Process does not have write permission, residency chart will not be accurate.

Actual kernal check:
https://github.com/torvalds/linux/blob/b7a16c7ad790d0ecb44dcb08a6a75d0d0455ab5f/mm/mincore.c#L181-L195

Example:

[john@machine vmtouch]$ ./vmtouch -v /nvme/arthor/pubchem.smi.atdb
/nvme/arthor/pubchem.smi.atdb
vmtouch: WARNING: Process does not have write permission, residency chart will not be accurate
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 3543272/3543272

           Files: 1
     Directories: 0
  Resident Pages: 3543272/3543272  13G/13G  100%
         Elapsed: 0.014981 seconds
# sudo can see the residency correctly and doesn't get a warning
[john@machine vmtouch]$ sudo ./vmtouch -v /nvme/arthor/pubchem.smi.atdb
/nvme/arthor/pubchem.smi.atdb
[OOOOOOOOOOOOOOOo                                            ] 904352/3543272

           Files: 1
     Directories: 0
  Resident Pages: 904352/3543272  3G/13G  25.5%
         Elapsed: 0.13137 seconds
# allow group/other write access, residency is correct - no warning
[john@machine vmtouch]$ sudo chmod ugo+w /nvme/arthor/pubchem.smi.atdb
[john@machine vmtouch]$ ./vmtouch -v /nvme/arthor/pubchem.smi.atdb
/nvme/arthor/pubchem.smi.atdb
[OOOOOOOOOOOOOOOo                                            ] 904352/3543272

           Files: 1
     Directories: 0
  Resident Pages: 904352/3543272  3G/13G  25.5%
         Elapsed: 0.13547 seconds

@hoytech
Copy link
Owner

hoytech commented Mar 9, 2020

Good idea, thank you!

@hoytech hoytech merged commit 3382336 into hoytech:master Mar 9, 2020
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.

None yet

2 participants