-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Zend, ext/opcache: use PR_SET_VMA_ANON_NAME (Linux 5.17) #8234
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 2.00 of the Zend license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| http://www.zend.com/license/2_00.txt. | | ||
| If you did not receive a copy of the Zend license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| license@zend.com so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Authors: Max Kellermann <max.kellermann@ionos.com> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#ifndef ZEND_MMAP_H | ||
#define ZEND_MMAP_H | ||
|
||
#include "zend_portability.h" | ||
|
||
#ifdef __linux__ | ||
# include <sys/prctl.h> | ||
|
||
/* fallback definitions if our libc is older than the kernel */ | ||
# ifndef PR_SET_VMA | ||
# define PR_SET_VMA 0x53564d41 | ||
# endif | ||
# ifndef PR_SET_VMA_ANON_NAME | ||
# define PR_SET_VMA_ANON_NAME 0 | ||
# endif | ||
#endif // __linux__ | ||
|
||
/** | ||
* Set a name for the specified memory area. | ||
* | ||
* This feature requires Linux 5.17. | ||
*/ | ||
static zend_always_inline void zend_mmap_set_name(const void *start, size_t len, const char *name) | ||
{ | ||
#ifdef __linux__ | ||
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)start, len, (unsigned long)name); | ||
#endif | ||
} | ||
|
||
#endif /* ZEND_MMAP_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to call
prctl
with options unsupported by the kernel?https://github.com/torvalds/linux/blob/7403e6d8263937dea206dd201fed1ceed190ca18/kernel/sys.c#L2615
Looks like the answer is yes and it'll just return
-1
but the docs aren't very clear so I thought I'd ask.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes,, it will just return -1;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it warrants a new file for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this a new file to reduce header dependencies, to avoid adding a dependency to
sys/prctl.h
to almost all sources.The PHP code base is currently pretty clumsy about header dependencies; you have catch-all headers like
zend_portability.h
. I don't like that.My coding style is to have many small and domain-specific headers with only the bare minimum of header-including-other-header. This speeds up compile times and improves code correctness.
But ... since this is not my project, I'll accept any style you desire, and will amend this PR.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel if it had more it maybe it would worth it but that s personal opinion tough, other members might think differently. But what do you make about the other points I made below ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would generally agree that many of our files are too big and mixing too much code of different purposes can make it hard to understand the original intention of the file. But I don't know how the other maintainers feel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same sentiment here