Fix: implicit declarations caused by buffer size checks.
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 16 Oct 2018 19:23:22 +0000 (15:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 Oct 2018 04:28:53 +0000 (00:28 -0400)
commitb1ddb9416fae4adb1e74d5218cecc4d152e36468
treec8fd82da963351dc482f544531e68342e4b00197
parent362fee9413ea3b73587f53f2574ce6b5efaea14e
Fix: implicit declarations caused by buffer size checks.

Issue
=====
Three kernel functions used in the following commit are unavailable on
some supported kernels:

commit 1f0ab1eb0409d23de5f67cc588c3ea4cee4d10e0
Prevent allocation of buffers if exceeding available memory

* si_mem_available() was added in kernel 4.6 with commit d02bd27.
* {set, clear}_current_oom_origin() were added in kernel 3.8 with commit:
  e1e12d2f

Solution
========
Add wrappers around these functions such that older kernels will build
with these functions defined as NOP or trivial return value.

wrapper_check_enough_free_pages() uses the si_mem_available() kernel
function to compute if the number pages requested passed as parameter is
smaller than the number of pages available on the machine. If the
si_mem_available() kernel function is unavailable, we always return
true.

wrapper_set_current_oom_origin() function wraps the
set_current_oom_origin() kernel function when it is available.
If set_current_oom_origin() is unavailable the wrapper is empty.

wrapper_clear_current_oom_origin() function wraps the
clear_current_oom_origin() kernel function when it is available.
If clear_current_oom_origin() is unavailable the wrapper is empty.

Drawbacks
=========
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/ring_buffer_backend.c
wrapper/mm.h [new file with mode: 0644]
This page took 0.027021 seconds and 4 git commands to generate.