Skip to content

Commit

Permalink
BUILD: Fix various build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tvegas1 committed Jul 1, 2024
1 parent 46455ff commit 79e224a
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 18 deletions.
4 changes: 4 additions & 0 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ci/vm/provision2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions kernel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
15 changes: 10 additions & 5 deletions kernel/xpmem_pfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;

Expand All @@ -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)));
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion kernel/xpmem_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions m4/ac_path_kernel_source.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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__ \
Expand Down Expand Up @@ -148,6 +150,8 @@ AC_DEFUN([AC_KERNEL_CHECKS],
AC_CHECK_DECLS([vm_flags_set], [], [], [[#include <linux/mm.h>]])
AC_SUBST(KFLAGS, [$KFLAGS])
CPPFLAGS="$save_CPPFLAGS"
CFLAGS="$save_CFLAGS"
]
)
8 changes: 4 additions & 4 deletions test/share/include/xpmem_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions test/share/xpmem_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion test/share/xpmem_proc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 79e224a

Please sign in to comment.