configure: Add __vmalloc() wrapper

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2020-12-11 20:27:48 +01:00
parent bbd0cb57a5
commit ca7f809965
3 changed files with 49 additions and 6 deletions

View File

@ -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 $@

View File

@ -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)

View File

@ -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))