From: Cyril H. <su...@li...> - 2011-02-07 19:36:46
|
The branch, master, has been updated via 877cbae0f4809f09dd13c1b76771e695ece3d9aa (commit) from ef78227f9275d780649e14a8785c6913c18b7462 (commit) - Log ----------------------------------------------------------------- commit 877cbae0f4809f09dd13c1b76771e695ece3d9aa Author: Cyril Hrubis <ch...@su...> Date: Mon Feb 7 20:00:31 2011 +0100 Fix build on system without MADV_MERGEABLE. * added autoconf check for MADV_MERGEABLE * ifdefed all code that is using MADV_MERGEABLE TODO: Some ifdefed code was in the common functions however they compile fine now, they may fail to work correctly Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: configure.ac | 1 + m4/{ltp-time.m4 => ltp-madvise.m4} | 22 +++++++++------------- testcases/kernel/mem/lib/mem.c | 9 +++++++++ testcases/kernel/mem/oom/lib/oom.c | 2 ++ testcases/kernel/syscalls/mmap/mmap10.c | 8 ++++++++ 5 files changed, 29 insertions(+), 13 deletions(-) copy m4/{ltp-time.m4 => ltp-madvise.m4} (68%) diff --git a/configure.ac b/configure.ac index fcc828e..f2ed429 100644 --- a/configure.ac +++ b/configure.ac @@ -162,5 +162,6 @@ LTP_CHECK_SYSCALL_SIGNALFD LTP_CHECK_SYSCALL_UNSHARE LTP_CHECK_TASKSTATS LTP_CHECK_TIME +LTP_CHECK_MADVISE AC_OUTPUT diff --git a/m4/ltp-time.m4 b/m4/ltp-madvise.m4 similarity index 68% copy from m4/ltp-time.m4 copy to m4/ltp-madvise.m4 index 3ff9e62..d29da79 100644 --- a/m4/ltp-time.m4 +++ b/m4/ltp-madvise.m4 @@ -1,5 +1,5 @@ dnl -dnl Copyright (c) Copyrights-are-for-losers, Inc 2010 +dnl Copyright (c) Linux Test Project, 2011 dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by @@ -15,21 +15,17 @@ dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl -dnl Author: Garrett Cooper <yan...@gm...> +dnl Author: Cyril Hrubis <ch...@su...> dnl dnl -dnl LTP_CHECK_TIME -dnl -dnl For all directly related time syscalls. -dnl +dnl LTP_CHECK_MADVISE dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_TIME],[ - AC_CHECK_DECLS([CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE],,,[ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include <time.h> -]) +AC_DEFUN([LTP_CHECK_MADVISE], +[dnl +AC_CHECK_DECLS([MADV_MERGEABLE],[have_madv_mergeable="yes"],,[#include <sys/mman.h>]) +if test "x$have_madv_mergeable" = "xyes"; then + AC_DEFINE(HAVE_MADV_MERGEABLE,1,[Define to 1 if you have MADV_MERGEABLE]) +fi ]) diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index 297eedd..1a53359 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -182,9 +182,11 @@ int alloc_mem(long int length, int testcase) } if (testcase == MLOCK && mlock(s, length) == -1) tst_brkm(TINFO|TERRNO, cleanup, "mlock"); +#ifdef HAVE_MADV_MERGEABLE if (testcase == KSM && madvise(s, length, MADV_MERGEABLE) == -1) tst_brkm(TBROK|TERRNO, cleanup, "madvise"); +#endif memset(s, '\a', length); return 0; @@ -345,9 +347,12 @@ void create_same_memory(int size, int num, int unit) MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); if (memory[0][j] == MAP_FAILED) tst_brkm(TBROK|TERRNO, tst_exit, "mmap"); + +#ifdef HAVE_MADV_MERGEABLE if (madvise(memory[0][j], unit * MB, MADV_MERGEABLE) == -1) tst_brkm(TBROK|TERRNO, tst_exit, "madvise"); +#endif for (i = 0; i < unit * MB; i++) memory[0][j][i] = 'c'; } @@ -395,9 +400,11 @@ void create_same_memory(int size, int num, int unit) MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); if (memory[1][j] == MAP_FAILED) tst_brkm(TBROK|TERRNO, tst_exit, "mmap"); +#ifdef HAVE_MADV_MERGEABLE if (madvise(memory[1][j], unit * MB, MADV_MERGEABLE) == -1) tst_brkm(TBROK|TERRNO, tst_exit, "madvise"); +#endif for (i = 0; i < unit * MB; i++) memory[1][j][i] = 'a'; } @@ -467,10 +474,12 @@ void create_same_memory(int size, int num, int unit) if (memory[k][j] == MAP_FAILED) tst_brkm(TBROK|TERRNO, cleanup, "mmap"); +#ifdef HAVE_MADV_MERGEABLE if (madvise(memory[k][j], unit * MB, MADV_MERGEABLE) == -1) tst_brkm(TBROK|TERRNO, cleanup, "madvise"); +#endif for (i = 0; i < unit * MB; i++) memory[k][j][i] = 'a'; } diff --git a/testcases/kernel/mem/oom/lib/oom.c b/testcases/kernel/mem/oom/lib/oom.c index ba37a7f..24fd1f7 100644 --- a/testcases/kernel/mem/oom/lib/oom.c +++ b/testcases/kernel/mem/oom/lib/oom.c @@ -155,9 +155,11 @@ int alloc_mem(long int length, int testcase) } if (testcase == MLOCK && mlock(s, length) == -1) tst_brkm(TINFO|TERRNO, cleanup, "mlock"); +#ifdef HAVE_MADV_MERGEABLE if (testcase == KSM && madvise(s, length, MADV_MERGEABLE) == -1) tst_brkm(TBROK|TERRNO, cleanup, "madvise"); +#endif memset(s, '\a', length); return 0; diff --git a/testcases/kernel/syscalls/mmap/mmap10.c b/testcases/kernel/syscalls/mmap/mmap10.c index d3877a3..3191580 100644 --- a/testcases/kernel/syscalls/mmap/mmap10.c +++ b/testcases/kernel/syscalls/mmap/mmap10.c @@ -66,6 +66,8 @@ char *TCID = "mmap10"; int TST_TOTAL = 1; + +#ifdef HAVE_MADV_MERGEABLE static int fd, opt_anon, opt_ksm; void setup(void); @@ -178,3 +180,9 @@ void help(void) printf(" -a Test anonymous pages\n"); printf(" -s Add to KSM regions\n"); } +#else +int main(void) +{ + tst_brkm(TCONF, NULL, "MADV_MERGEABLE missing in sys/mman.h"); +} +#endif hooks/post-receive -- ltp |