From 61e2af80bce7771e88ab42c6a0e7f98855733697 Mon Sep 17 00:00:00 2001 From: Michal Rakowski Date: Sun, 19 May 2019 18:27:36 +0200 Subject: [PATCH 1/2] Added configure script Signed-off-by: Michal Rakowski --- configure | 68 ++++++++++++++++++++++++ modules/Makefile | 2 +- modules/cas_cache/linux_kernel_version.h | 2 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 configure diff --git a/configure b/configure new file mode 100755 index 0000000..1a9a661 --- /dev/null +++ b/configure @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright(c) 2012-2019 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +MODULE_FILE=test_mod.c +OBJ_MOD=test_mod.o +KERN_VER=`uname -r` +PWD=`pwd` +NPROC=`nproc` +DEFINE_FILE=modules/generated_defines.h + + +add_define() { + echo -n "#define " >> $DEFINE_FILE + for arg in "$@"; do + echo -e "$arg" >> $DEFINE_FILE + done +} + +add_function() { + for arg in "$@"; do + echo -e "$arg" >> $DEFINE_FILE + done +} + +compile_module(){ + if [ $# -gt 1 ] + then + INCLUDE="#include <$2>" + else + INCLUDE="" + fi + +############# TEST MODULE ############# +cat > $MODULE_FILE << EOF +#include +#include +$INCLUDE + +int init_module(void) { + $1; + return 0; +} +void cleanup_module(void) {}; +EOF +####################################### + + make -C /lib/modules/$KERN_VER/build M=$PWD modules\ + obj-m=$OBJ_MOD -j$NPROC &> /dev/null + + local ret=$? + if [ $ret -eq 0 ]; then + make -j$NPROC -C /lib/modules/$KERN_VER/build M=$PWD clean\ + obj-m=test.o &> /dev/null + fi + + return $ret +} + +kernel_not_supp_fail() { + echo "Current kernel is not supported!" + rm $DEFINE_FILE + exit 1 +} + +rm -f $DEFINE_FILE diff --git a/modules/Makefile b/modules/Makefile index 87d2b06..6ecbbc3 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -47,7 +47,7 @@ default: $(VERSION_FILE) sync clean: cd $(KERNEL_DIR) && make M=$(PWD) clean - + rm $(PWD)/generated_defines.h distclean: clean distsync install: diff --git a/modules/cas_cache/linux_kernel_version.h b/modules/cas_cache/linux_kernel_version.h index 3e6e516..57fd6cb 100644 --- a/modules/cas_cache/linux_kernel_version.h +++ b/modules/cas_cache/linux_kernel_version.h @@ -38,6 +38,8 @@ #include #include +#include "generated_defines.h" + #ifdef CONFIG_SLAB #include #endif From 869cb9c6ede864302aeb3067ad563dab7f98123d Mon Sep 17 00:00:00 2001 From: Michal Rakowski Date: Tue, 21 May 2019 12:11:42 +0200 Subject: [PATCH 2/2] Enabling CentOS 7.6 Signed-off-by: Michal Rakowski --- configure | 38 ++++++++++++++++++++++++ modules/cas_cache/linux_kernel_version.h | 8 ++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 1a9a661..92642c6 100755 --- a/configure +++ b/configure @@ -66,3 +66,41 @@ kernel_not_supp_fail() { } rm -f $DEFINE_FILE + +compile_module "part_round_stats(1, 1)" "linux/genhd.h" +if [ $? -eq 0 ]; then + add_define "CAS_PART_ROUND_STATS(q, cpu, part) part_round_stats(cpu, part)" +else + compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h" + if [ $? -eq 0 ]; then + add_define "CAS_PART_ROUND_STATS(q, cpu, part)\\"\ + "\tpart_round_stats(q, cpu, part)" + fi +fi + + +compile_module "part_inc_in_flight(1, 1)" "linux/genhd.h" +if [ $? -eq 0 ]; then + add_define "CAS_PART_INC_IN_FLIGHT(q, cpu, part)\\"\ + "\tpart_inc_in_flight(cpu, part)" +else + compile_module "part_inc_in_flight(NULL, 1, 1)" "linux/genhd.h" + if [ $? -eq 0 ]; then + add_define "CAS_PART_INC_IN_FLIGHT(q, cpu, part)\\"\ + "\tpart_inc_in_flight(q, cpu, part)" + fi +fi + + +compile_module "part_dec_in_flight(1, 1)" "linux/genhd.h" +if [ $? -eq 0 ]; then + add_define "CAS_PART_DEC_IN_FLIGHT(q, cpu, part)\\"\ + "\tpart_dec_in_flight(cpu, part)" +else + compile_module "part_dec_in_flight(NULL, 1, 1)" "linux/genhd.h" + if [ $? -eq 0 ]; then + add_define "CAS_PART_DEC_IN_FLIGHT(q, cpu, part)\\"\ + "\tpart_dec_in_flight(q, cpu, part)" + fi +fi + diff --git a/modules/cas_cache/linux_kernel_version.h b/modules/cas_cache/linux_kernel_version.h index 57fd6cb..aecbc87 100644 --- a/modules/cas_cache/linux_kernel_version.h +++ b/modules/cas_cache/linux_kernel_version.h @@ -505,10 +505,10 @@ static inline void cas_generic_start_io_acct(struct request_queue *q, { int cpu = part_stat_lock(); - part_round_stats(cpu, part); + CAS_PART_ROUND_STATS(q, cpu, part); part_stat_inc(cpu, part, ios[rw]); part_stat_add(cpu, part, sectors[rw], sectors); - part_inc_in_flight(part, rw); + CAS_PART_INC_IN_FLIGHT(q, part, rw); part_stat_unlock(); } @@ -520,8 +520,8 @@ static inline void cas_generic_end_io_acct(struct request_queue *q, int cpu = part_stat_lock(); part_stat_add(cpu, part, ticks[rw], duration); - part_round_stats(cpu, part); - part_dec_in_flight(part, rw); + CAS_PART_ROUND_STATS(q, cpu, part); + CAS_PART_DEC_IN_FLIGHT(q, part, rw); part_stat_unlock(); }