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

Missing defines on systems with kernel < 4.X #544

Closed
mfelsche opened this issue Jun 15, 2022 · 1 comment · Fixed by #545
Closed

Missing defines on systems with kernel < 4.X #544

mfelsche opened this issue Jun 15, 2022 · 1 comment · Fixed by #545

Comments

@mfelsche
Copy link
Contributor

Description

We are running into trouble with centos 7 based builds of snmalloc. ( Dockerimage )

We do have to support such an old system for the time being (don't ask), you might not want to support it, which i totally understand.
The system is based on gcc 9, kernel 3.10.0 and libraries, which is all horribly outdated.

Our build system gives the following error:

...
 /cargo/registry/src/github.com-1ecc6299db9ec823/snmalloc-sys-0.3.1/snmalloc/src/snmalloc/override/../global/../backend/../backend_helpers/../mem/../ds/../pal/pal_linux.h: In static member function 'static void snmalloc::PALLinux::notify_not_using(void*, size_t)':
  /cargo/registry/src/github.com-1ecc6299db9ec823/snmalloc-sys-0.3.1/snmalloc/src/snmalloc/override/../global/../backend/../backend_helpers/../mem/../ds/../pal/pal_linux.h:111:24: error: 'MADV_FREE' was not declared in this scope; did you mean 'MADV_REMOVE'?
    111 |       madvise(p, size, MADV_FREE);
        |                        ^~~~~~~~~
        |                        MADV_REMOVE
  /cargo/registry/src/github.com-1ecc6299db9ec823/snmalloc-sys-0.3.1/snmalloc/src/snmalloc/override/../global/../backend/../backend_helpers/../mem/../ds/../pal/pal_linux.h: In static member function 'static uint64_t snmalloc::PALLinux::get_entropy64()':
  /cargo/registry/src/github.com-1ecc6299db9ec823/snmalloc-sys-0.3.1/snmalloc/src/snmalloc/override/../global/../backend/../backend_helpers/../mem/../ds/../pal/pal_linux.h:180:57: error: 'GRND_NONBLOCK' was not declared in this scope; did you mean 'O_NONBLOCK'?
    180 |           ret = syscall(SYS_getrandom, current, length, GRND_NONBLOCK);
        |                                                         ^~~~~~~~~~~~~
        |                                                         O_NONBLOCK
  gmake[3]: *** [CMakeFiles/snmallocshim-rust.dir/src/snmalloc/override/rust.cc.o] Error 1

Possible Solutions

On those old systems we do have GRND_NONBLOCK etc. defined in /usr/include/linux/random.h, i do think this include is missing (maybe guarded by a check if GRND_NONBLOCK is defined).

MADV_FREE is only available since linux 4.5. Should we fallback to MADV_REMOVE for systems where MADV_FREE is not defined?

I will happily provide those fixes if you deem them good enough or maybe you have another idea?

@mfelsche mfelsche changed the title Missing defines on kernel < 4.X Missing defines on systems with kernel < 4.X Jun 15, 2022
@mjp41
Copy link
Member

mjp41 commented Jun 15, 2022

So MADV_FREE could fall back to MADV_DONTNEED.

I am happy for a small amount of ifdef magic to handle this. Overall, I can't promise I won't break things in the future, as this won't be tested in CI. But the PAL tends not to change much, so I think it shouldn't be too bad.

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 a pull request may close this issue.

2 participants