From ca7f809965e9cdc70bfe11db33795e84a0477a55 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Fri, 11 Dec 2020 20:27:48 +0100 Subject: [PATCH] configure: Add __vmalloc() wrapper Signed-off-by: Robert Baldyga --- configure.d/1_vmalloc.conf | 42 +++++++++++++++++++++++++++ modules/cas_cache/ocf_env.h | 2 +- modules/cas_cache/utils/utils_mpool.c | 11 +++---- 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 configure.d/1_vmalloc.conf diff --git a/configure.d/1_vmalloc.conf b/configure.d/1_vmalloc.conf new file mode 100644 index 0000000..23ce8b4 --- /dev/null +++ b/configure.d/1_vmalloc.conf @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Copyright(c) 2012-2020 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +. $(dirname $3)/conf_framework + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "__vmalloc(0, 0);" "linux/vmalloc.h" + then + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct pgprot x; __vmalloc(0, 0, x);" "linux/vmalloc.h" + then + echo $cur_name "2" >> $config_file_path + else + echo $cur_name "X" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline void *cas_vmalloc(unsigned long size, gfp_t gfp_mask) + { + return __vmalloc(size, gfp_mask); + }" ;; + "2") + add_function " + static inline void *cas_vmalloc(unsigned long size, gfp_t gfp_mask) + { + return __vmalloc(size, gfp_mask, PAGE_KERNEL); + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/modules/cas_cache/ocf_env.h b/modules/cas_cache/ocf_env.h index cccff29..4a64eba 100644 --- a/modules/cas_cache/ocf_env.h +++ b/modules/cas_cache/ocf_env.h @@ -41,7 +41,7 @@ static inline void env_free(const void *ptr) static inline void *env_vmalloc_flags(size_t size, int flags) { - return __vmalloc(size, flags | __GFP_HIGHMEM, PAGE_KERNEL); + return cas_vmalloc(size, flags | __GFP_HIGHMEM); } static inline void *env_vzalloc_flags(size_t size, int flags) diff --git a/modules/cas_cache/utils/utils_mpool.c b/modules/cas_cache/utils/utils_mpool.c index 01d1625..f4a0524 100644 --- a/modules/cas_cache/utils/utils_mpool.c +++ b/modules/cas_cache/utils/utils_mpool.c @@ -77,17 +77,18 @@ static env_allocator *cas_mpool_get_allocator( void *cas_mpool_new_f(struct cas_mpool *mpool, uint32_t count, int flags) { + unsigned long size; void *items = NULL; env_allocator *allocator; allocator = cas_mpool_get_allocator(mpool, count); - if (allocator) + if (allocator) { items = env_allocator_new(allocator); - else - items = __vmalloc(mpool->hdr_size + (mpool->item_size * count), - flags | __GFP_ZERO | __GFP_HIGHMEM, - PAGE_KERNEL); + } else { + size = mpool->hdr_size + (mpool->item_size * count); + items = cas_vmalloc(size, flags | __GFP_ZERO | __GFP_HIGHMEM); + } #ifdef ZERO_OR_NULL_PTR if (ZERO_OR_NULL_PTR(items))