lib/ocf_env: fix incorrect value for free memory estimate

OCF relies on our env to get information about free memory.
It then uses that information to return a descriptive
error if not enough memory is available.
But no other calculation done based on that value.

Our implementation was not correct because it returned
the size of available physical memory in the system,
while we use HUGEPAGE memory for most of OCF operations.

There doesn't seem to be a reliant API for getting
the size of available HUGEPAGE memory, so instead
return UINT64_MAX, as it is done in ocf/env/posix/ocf_env.h.
This way, OCF will not know ahead of time if there
is enough memory available, but it will still fail
properly on operations that require too much memory.

Change-Id: Iec2e3cfa8453253513d5861d7e6acf0e08dad1e9
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1976
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Vitaliy Mysak 2020-04-22 17:03:16 +02:00 committed by Tomasz Zawadzki
parent 51d69a7f54
commit 33f97fa33a

View File

@ -171,8 +171,7 @@ static inline void env_vfree(const void *ptr)
static inline uint64_t env_get_free_memory(void) static inline uint64_t env_get_free_memory(void)
{ {
/* TODO: do we need implementation for this function? */ return -1;
return sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
} }
/* *** ALLOCATOR *** */ /* *** ALLOCATOR *** */