From 79e224aa7186549ff54981ecb8601cd8c3f182b4 Mon Sep 17 00:00:00 2001 From: Thomas Vegas Date: Mon, 1 Jul 2024 14:01:54 +0300 Subject: [PATCH] BUILD: Fix various build warnings --- ci/azure-pipelines.yml | 4 ++++ ci/vm/provision2.sh | 3 +++ kernel/Makefile.am | 4 ++-- kernel/xpmem_pfn.c | 15 ++++++++++----- kernel/xpmem_private.h | 2 +- m4/ac_path_kernel_source.m4 | 4 ++++ test/share/include/xpmem_test.h | 8 ++++---- test/share/xpmem_master.c | 10 +++++----- test/share/xpmem_proc2.c | 2 +- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 723d9ce..03bcb3a 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -96,6 +96,8 @@ stages: set -eEx ./autogen.sh kernel_ver=$(rpm -qa | grep kernel-devel | cut -d'-' -f3-) + export CFLAGS='-Werror -Wall' + export KFLAGS='-Werror' ./configure --with-kerneldir=/usr/src/kernels/${kernel_ver} make displayName: Build on CentOS @@ -105,6 +107,8 @@ stages: set -eEx ./autogen.sh kernel_ver=$(dpkg -l | grep 'linux-headers-.*-generic' | awk '{print $2}') + export CFLAGS='-Werror -Wall' + export KFLAGS='-Werror' ./configure --enable-gtest --with-kerneldir=/usr/src/${kernel_ver} make displayName: Build on Ubuntu diff --git a/ci/vm/provision2.sh b/ci/vm/provision2.sh index 562723c..332a479 100644 --- a/ci/vm/provision2.sh +++ b/ci/vm/provision2.sh @@ -4,6 +4,9 @@ set -Exeuo pipefail OS=$1 PR_NUM=$2 +export CFLAGS="-Werror -Wall" +export KFLAGS="-Werror" + xpmem_build() { uname -r gcc --version diff --git a/kernel/Makefile.am b/kernel/Makefile.am index 93ba4b3..6e22a85 100644 --- a/kernel/Makefile.am +++ b/kernel/Makefile.am @@ -19,8 +19,8 @@ EXTRA_DIST = ${module_sources} module_DATA = $(MODULE) - -KCPPFLAGS = -include @abs_top_builddir@/config.h -I@abs_top_srcdir@/include +KCPPFLAGS = -include @abs_top_builddir@/config.h -I@abs_top_srcdir@/include \ + $(KFLAGS) export KCPPFLAGS $(MODULE): ${module_sources} diff --git a/kernel/xpmem_pfn.c b/kernel/xpmem_pfn.c index 8d9cbc0..ba38f46 100644 --- a/kernel/xpmem_pfn.c +++ b/kernel/xpmem_pfn.c @@ -321,6 +321,8 @@ xpmem_remap_pages(struct xpmem_segment *seg, return ctx.result; } +static DEFINE_PER_CPU(cpumask_t, saved_mask_percpu); + /* * Fault in and pin a single page for the specified task and mm. */ @@ -329,9 +331,9 @@ xpmem_pin_pages(struct xpmem_thread_group *tg, struct task_struct *src_task, struct mm_struct *src_mm, u64 vaddr, struct page **pages, unsigned long count) { + cpumask_t *saved_mask = NULL; long nr_pinned; struct vm_area_struct *vma; - cpumask_t saved_mask = CPU_MASK_NONE; int foll_write; unsigned long avail; @@ -357,10 +359,12 @@ xpmem_pin_pages(struct xpmem_thread_group *tg, struct task_struct *src_task, */ if (xpmem_vaddr_to_pte_offset(src_mm, vaddr, NULL) == NULL && cpu_to_node(task_cpu(current)) != cpu_to_node(task_cpu(src_task))) { + saved_mask = this_cpu_ptr(&saved_mask_percpu); + #ifdef HAVE_STRUCT_TASK_STRUCT_CPUS_MASK - saved_mask = current->cpus_mask; + *saved_mask = current->cpus_mask; #else - saved_mask = current->cpus_allowed; + *saved_mask = current->cpus_allowed; #endif set_cpus_allowed_ptr(current, cpumask_of(task_cpu(src_task))); } @@ -388,8 +392,9 @@ xpmem_pin_pages(struct xpmem_thread_group *tg, struct task_struct *src_task, nr_pinned = get_user_pages (src_task, src_mm, vaddr, count, foll_write, 0, pages, NULL); #endif - if (!cpumask_empty(&saved_mask)) - set_cpus_allowed_ptr(current, &saved_mask); + if (saved_mask) { + set_cpus_allowed_ptr(current, saved_mask); + } if (nr_pinned > 0) { atomic_long_add(nr_pinned, &tg->n_pinned); diff --git a/kernel/xpmem_private.h b/kernel/xpmem_private.h index efbd8e3..2a27d27 100644 --- a/kernel/xpmem_private.h +++ b/kernel/xpmem_private.h @@ -268,7 +268,7 @@ struct xpmem_partition { */ #define XPMEM_MAX_PAGE_FAULT_AFTER 32 #define XPMEM_MAX_PAGE_FAULT_BEFORE 16 -#define XPMEM_MAX_PAGE_FAULTS 128 +#define XPMEM_MAX_PAGE_FAULTS 96 struct xpmem_config { rwlock_t lock; diff --git a/m4/ac_path_kernel_source.m4 b/m4/ac_path_kernel_source.m4 index 6c90239..9419705 100644 --- a/m4/ac_path_kernel_source.m4 +++ b/m4/ac_path_kernel_source.m4 @@ -101,7 +101,9 @@ AC_DEFUN([AC_KERNEL_CHECKS], -e s/sparc32.*/sparc/ \ -e s/sparc64.*/sparc/ \ -e s/s390x/s390/) + save_CFLAGS="$CFLAGS" save_CPPFLAGS="$CPPFLAGS" + CFLAGS= CPPFLAGS="-include $kerneldir/include/linux/kconfig.h \ -include $kerneldir/include/linux/compiler.h \ -D__KERNEL__ \ @@ -148,6 +150,8 @@ AC_DEFUN([AC_KERNEL_CHECKS], AC_CHECK_DECLS([vm_flags_set], [], [], [[#include ]]) + AC_SUBST(KFLAGS, [$KFLAGS]) CPPFLAGS="$save_CPPFLAGS" + CFLAGS="$save_CFLAGS" ] ) diff --git a/test/share/include/xpmem_test.h b/test/share/include/xpmem_test.h index 56358c1..b1ec553 100644 --- a/test/share/include/xpmem_test.h +++ b/test/share/include/xpmem_test.h @@ -6,9 +6,9 @@ #define NR_TEST_PAGES 4 #define PAGE_SIZE page_size() -#define SHARE_SIZE NR_TEST_PAGES * PAGE_SIZE -#define PAGE_INT_SIZE (PAGE_SIZE / sizeof(int)) -#define SHARE_INT_SIZE (SHARE_SIZE / sizeof(int)) +#define SHARE_SIZE (NR_TEST_PAGES * PAGE_SIZE) +#define PAGE_INT_SIZE ((int)(PAGE_SIZE / sizeof(int))) +#define SHARE_INT_SIZE ((int)(SHARE_SIZE / sizeof(int))) /* Used to specify size of /tmp/xpmem.share */ #define TMP_SHARE_SIZE 32 @@ -46,7 +46,7 @@ xpmem_segid_t make_share(int **data, size_t size) return -1; } - for (i=0; i < (size / sizeof(int)); i++) + for (i=0; i < (int)(size / sizeof(int)); i++) *(ptr + i) = i; segid = xpmem_make(ptr, size, XPMEM_PERMIT_MODE, (void *)0666); diff --git a/test/share/xpmem_master.c b/test/share/xpmem_master.c index 96880a8..2b91c3a 100644 --- a/test/share/xpmem_master.c +++ b/test/share/xpmem_master.c @@ -21,12 +21,12 @@ printf("==== %s PASSED ====\n\n", (name)) : \ printf("==== %s FAILED ====\n\n", (name))) -int test_base(test_args* t) { return 0; } -int test_two_attach(test_args* t) { return 0; } -int test_two_shares(test_args* t) { return 0; } -int test_fork(test_args* t) { return 0; } +int test_base(test_args* t) { (void)t; return 0; } +int test_two_attach(test_args* t) { (void)t; return 0; } +int test_two_shares(test_args* t) { (void)t; return 0; } +int test_fork(test_args* t) { (void)t; return 0; } -int main(int argc, char** argv) +int main(void) { pid_t p1, p2; int i, fd, lock, status[2]; diff --git a/test/share/xpmem_proc2.c b/test/share/xpmem_proc2.c index fbe45df..f0065c8 100644 --- a/test/share/xpmem_proc2.c +++ b/test/share/xpmem_proc2.c @@ -198,7 +198,7 @@ int test_fork(test_args *xpmem_args) printf("xpmem_proc2: reading to pin pages\n"); for (i = 0; i < PAGE_INT_SIZE; i++) { if (*(data + i) != PAGE_INT_SIZE + i) { - printf("xpmem_proc2: ***mismatch at %d: expected %lu " + printf("xpmem_proc2: ***mismatch at %d: expected %d " "got %d\n", i, PAGE_INT_SIZE + i, *(data + i)); ret = -2; }