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

fix mmap/mremap address not aligned to MMAP_GRANULARITY #1113

Closed

Conversation

ZhangHongchen1
Copy link
Contributor

when we do mmap(MAP_SHARED),mmaped address should be aligned to MMAP_GRANULARITY,otherwise error will returned and the test will fail.
mremap and remap_file_pages should also follow this rule.

Hongchen Zhang added 3 commits December 8, 2023 10:49
For some architectures like LoongArch, mmap(MAP_FIXED | MAP_SHARED)
has to be aligned to SHMLBA. So use MMAP_GRANULARITY instead of
page size when mmap, otherwise the test will fail.

Suggested-by: Huacai Chen <[email protected]>
Signed-off-by: Hongchen Zhang <[email protected]>
the target address of mremap should be aligned to MMAP_GRANULARITY,
otherwise the test will fail.

Signed-off-by: Hongchen Zhang <[email protected]>
the <start> parameter of remap_file_pages should be aligned to
MMAP_GRANULARITY, otherwise the test will fail.

Signed-off-by: Hongchen Zhang <[email protected]>
@pevik
Copy link
Member

pevik commented Dec 8, 2023

It looks like it works on x86_64, aarch64 and ppc64le

Reviewed-by: Petr Vorel <[email protected]>

@ZhangHongchen1
Copy link
Contributor Author

It looks like it works on x86_64, aarch64 and ppc64le

@pevik Thanks for your review.
It is ok before or after this patch ,because getpagesize() is equal to MMAP_GRANULARITY.
But on some architecture like LoongArch,getpagesize is not equal to MMAP_GRANULARITY.
So, we should use MMAP_GRANULARITY instead of page size.

@pevik
Copy link
Member

pevik commented Dec 11, 2023

@ZhangHongchen1 ok, so you use SHMLBA which is different than page size on LoongArch. Thanks for info.

pevik pushed a commit that referenced this pull request Dec 11, 2023
For some architectures like LoongArch, mmap(MAP_FIXED | MAP_SHARED)
has to be aligned to SHMLBA. So use MMAP_GRANULARITY instead of
page size when mmap(), otherwise the test will fail.

Link: #1113
Suggested-by: Huacai Chen <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Hongchen Zhang <[email protected]>
pevik pushed a commit that referenced this pull request Dec 11, 2023
the target address of mremap() should be aligned to MMAP_GRANULARITY,
otherwise the test will fail.

Link: #1113
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Hongchen Zhang <[email protected]>
@pevik pevik closed this in be1dbe6 Dec 11, 2023
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.

2 participants