From 33f97fa33ad89651d75bafb5fb87dc4cd28dde6a Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Wed, 22 Apr 2020 17:03:16 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1976 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Tomasz Zawadzki --- lib/env_ocf/ocf_env.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/env_ocf/ocf_env.h b/lib/env_ocf/ocf_env.h index 0b6ecb7a0..81d2e814b 100644 --- a/lib/env_ocf/ocf_env.h +++ b/lib/env_ocf/ocf_env.h @@ -171,8 +171,7 @@ static inline void env_vfree(const void *ptr) static inline uint64_t env_get_free_memory(void) { - /* TODO: do we need implementation for this function? */ - return sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES); + return -1; } /* *** ALLOCATOR *** */