[Buildroot] [PATCH 1/1] package/bdwgc: needs MMU

Thomas Petazzoni thomas.petazzoni at bootlin.com
Sat Nov 5 21:51:43 UTC 2022


On Sat,  5 Nov 2022 22:16:39 +0100
Fabrice Fontaine <fontaine.fabrice at gmail.com> wrote:

> Fix the following build failure raise since bump to version 8.2.2 in
> commit d7619682552dd34f499e9f17b0234af53da743ec and
> https://github.com/ivmai/bdwgc/commit/9d8c196268068bb75f86dee0ba75ccd024531e72:
> 
> os_dep.c: In function 'block_unmap_inner':
> os_dep.c:2668:17: warning: implicit declaration of function 'madvise'; did you mean 'raise'? [-Wimplicit-function-declaration]
>  2668 |             if (madvise(start_addr, len, MADV_DONTNEED) == -1)
>       |                 ^~~~~~~
>       |                 raise
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/2b9924cb8c36a75e1ca7aefe83e95dc11c10ded6
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>

I hesitated a bit, because normally madvise() is only to provide an
advice to the OS, and therefore should not be strictly mandatory.
However, MADV_DONTNEED changes the semantic of future memory accesses:

       MADV_DONTNEED
              Do not expect access in the near future.  (For the time being, the application is
              finished with the given range, so the kernel can free resources  associated  with
              it.)

              After a successful MADV_DONTNEED operation, the semantics of memory access in the
              specified region are changed: subsequent accesses of pages in the range will suc‐
              ceed,  but will result in either repopulating the memory contents from the up-to-
              date contents of the underlying mapped file (for  shared  file  mappings,  shared
              anonymous  mappings,  and  shmem-based  techniques such as System V shared memory
              segments) or zero-fill-on-demand pages for anonymous private mappings.

              Note that, when applied to shared mappings, MADV_DONTNEED might not lead to imme‐
              diate freeing of the pages in the range.  The kernel is free to delay freeing the
              pages until an appropriate moment.  The resident set size (RSS)  of  the  calling
              process will be immediately reduced however.

              MADV_DONTNEED  cannot  be  applied  to locked pages, Huge TLB pages, or VM_PFNMAP
              pages.  (Pages marked with the kernel-internal VM_PFNMAP flag are special  memory
              areas that are not managed by the virtual memory subsystem.  Such pages are typi‐
              cally created by device drivers that map the pages into user space.)

And also the function in bdgwc that uses madvise() is a convoluted mess
of #ifdef-ery, so I didn't want to take any risk there, and I don't
really care about bdwgc on noMMU targets. So I applied your patch.

However, you forgot to propagate this dependency to package/poke, which
also selects bdwgc.

Applied to master with this fix. Thanks!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com



More information about the buildroot mailing list