1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SHRINKER_CALLBACK
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
46 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_MUTEX_OWNER_TASK_STRUCT
50 SPL_AC_MUTEX_LOCK_NESTED
51 SPL_AC_3ARGS_ON_EACH_CPU
52 SPL_AC_KALLSYMS_LOOKUP_NAME
53 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_FIRST_ONLINE_PGDAT
56 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_GLOBAL_PAGE_STATE
60 SPL_AC_ZONE_STAT_ITEM_FREE
61 SPL_AC_ZONE_STAT_ITEM_INACTIVE
62 SPL_AC_ZONE_STAT_ITEM_ACTIVE
63 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_SET_FS_PWD_WITH_CONST
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_2ARGS_VFS_FSYNC
71 SPL_AC_INODE_TRUNCATE_RANGE
72 SPL_AC_FS_STRUCT_SPINLOCK
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
79 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
80 SPL_AC_KERNEL_FALLOCATE
81 SPL_AC_SHRINK_DCACHE_MEMORY
82 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_CONFIG_KALLSYMS
85 SPL_AC_CONFIG_ZLIB_INFLATE
86 SPL_AC_CONFIG_ZLIB_DEFLATE
87 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
88 SPL_AC_SHRINK_CONTROL_STRUCT
89 SPL_AC_RWSEM_SPINLOCK_IS_RAW
90 SPL_AC_SCHED_RT_HEADER
91 SPL_AC_2ARGS_VFS_GETATTR
93 SPL_AC_KMEM_CACHE_ALLOCFLAGS
97 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
98 modpost=$LINUX/scripts/Makefile.modpost
99 AC_MSG_CHECKING([kernel file name for module symbols])
100 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
101 if grep -q Modules.symvers $modpost; then
102 LINUX_SYMBOLS=Modules.symvers
104 LINUX_SYMBOLS=Module.symvers
107 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
109 *** Please make sure the kernel devel package for your distribution
110 *** is installed. If you are building with a custom kernel, make sure the
111 *** kernel is configured, built, and the '--with-linux=PATH' configure
112 *** option refers to the location of the kernel source.])
117 AC_MSG_RESULT($LINUX_SYMBOLS)
118 AC_SUBST(LINUX_SYMBOLS)
121 AC_DEFUN([SPL_AC_KERNEL], [
123 AS_HELP_STRING([--with-linux=PATH],
124 [Path to kernel source]),
125 [kernelsrc="$withval"])
127 AC_ARG_WITH([linux-obj],
128 AS_HELP_STRING([--with-linux-obj=PATH],
129 [Path to kernel build objects]),
130 [kernelbuild="$withval"])
132 AC_MSG_CHECKING([kernel source directory])
133 if test -z "$kernelsrc"; then
134 if test -e "/lib/modules/$(uname -r)/source"; then
135 headersdir="/lib/modules/$(uname -r)/source"
136 sourcelink=$(readlink -f "$headersdir")
137 elif test -e "/lib/modules/$(uname -r)/build"; then
138 headersdir="/lib/modules/$(uname -r)/build"
139 sourcelink=$(readlink -f "$headersdir")
141 sourcelink=$(ls -1d /usr/src/kernels/* \
143 2>/dev/null | grep -v obj | tail -1)
146 if test -n "$sourcelink" && test -e ${sourcelink}; then
147 kernelsrc=`readlink -f ${sourcelink}`
149 kernelsrc="[Not found]"
152 if test "$kernelsrc" = "NONE"; then
157 AC_MSG_RESULT([$kernelsrc])
158 if test ! -d "$kernelsrc"; then
160 *** Please make sure the kernel devel package for your distribution
161 *** is installed and then try again. If that fails, you can specify the
162 *** location of the kernel source with the '--with-linux=PATH' option.])
165 AC_MSG_CHECKING([kernel build directory])
166 if test -z "$kernelbuild"; then
167 if test -e "/lib/modules/$(uname -r)/build"; then
168 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
169 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
170 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
171 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
172 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
173 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
174 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
176 kernelbuild=${kernelsrc}
179 AC_MSG_RESULT([$kernelbuild])
181 AC_MSG_CHECKING([kernel source version])
182 utsrelease1=$kernelbuild/include/linux/version.h
183 utsrelease2=$kernelbuild/include/linux/utsrelease.h
184 utsrelease3=$kernelbuild/include/generated/utsrelease.h
185 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
186 utsrelease=linux/version.h
187 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
188 utsrelease=linux/utsrelease.h
189 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
190 utsrelease=generated/utsrelease.h
193 if test "$utsrelease"; then
194 kernsrcver=`(echo "#include <$utsrelease>";
195 echo "kernsrcver=UTS_RELEASE") |
196 cpp -I $kernelbuild/include |
197 grep "^kernsrcver=" | cut -d \" -f 2`
199 if test -z "$kernsrcver"; then
200 AC_MSG_RESULT([Not found])
201 AC_MSG_ERROR([*** Cannot determine kernel version.])
204 AC_MSG_RESULT([Not found])
205 if test "x$enable_linux_builtin" != xyes; then
206 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
209 *** Cannot find UTS_RELEASE definition.
210 *** Please run 'make prepare' inside the kernel source tree.])
214 AC_MSG_RESULT([$kernsrcver])
217 LINUX_OBJ=${kernelbuild}
218 LINUX_VERSION=${kernsrcver}
222 AC_SUBST(LINUX_VERSION)
224 SPL_AC_MODULE_SYMVERS
228 dnl # Default SPL user configuration
230 AC_DEFUN([SPL_AC_CONFIG_USER], [])
233 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
234 dnl # are missing, it is non-fatal, but you will not be able to build
235 dnl # RPM packages and will be warned if you try too.
237 dnl # By default, the generic spec file will be used because it requires
238 dnl # minimal dependencies. Distribution specific spec files can be
239 dnl # placed under the 'rpm/<distribution>' directory and enabled using
240 dnl # the --with-spec=<distribution> configure option.
242 AC_DEFUN([SPL_AC_RPM], [
246 AC_MSG_CHECKING([whether $RPM is available])
247 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
248 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
250 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
253 AC_MSG_RESULT([$HAVE_RPM])
256 AC_MSG_CHECKING([whether $RPMBUILD is available])
257 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
258 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
260 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
263 AC_MSG_RESULT([$HAVE_RPMBUILD])
266 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
268 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
271 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
276 RPM_SPEC_DIR="rpm/generic"
278 AS_HELP_STRING([--with-spec=SPEC],
279 [Spec files 'generic|fedora']),
280 [RPM_SPEC_DIR="rpm/$withval"])
282 AC_MSG_CHECKING([whether spec files are available])
283 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
287 AC_SUBST(RPM_VERSION)
289 AC_SUBST(HAVE_RPMBUILD)
291 AC_SUBST(RPMBUILD_VERSION)
293 AC_SUBST(RPM_SPEC_DIR)
294 AC_SUBST(RPM_DEFINE_UTIL)
295 AC_SUBST(RPM_DEFINE_KMOD)
296 AC_SUBST(RPM_DEFINE_DKMS)
297 AC_SUBST(RPM_DEFINE_COMMON)
298 AC_SUBST(SRPM_DEFINE_UTIL)
299 AC_SUBST(SRPM_DEFINE_KMOD)
300 AC_SUBST(SRPM_DEFINE_DKMS)
301 AC_SUBST(SRPM_DEFINE_COMMON)
305 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
306 dnl # tools are missing it is non-fatal but you will not be able to build
307 dnl # DEB packages and will be warned if you try too.
309 AC_DEFUN([SPL_AC_DPKG], [
311 DPKGBUILD=dpkg-buildpackage
313 AC_MSG_CHECKING([whether $DPKG is available])
314 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
315 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
317 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
320 AC_MSG_RESULT([$HAVE_DPKG])
323 AC_MSG_CHECKING([whether $DPKGBUILD is available])
324 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
325 DPKGBUILD_VERSION=$(echo $tmp | \
326 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
328 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
331 AC_MSG_RESULT([$HAVE_DPKGBUILD])
336 AC_SUBST(DPKG_VERSION)
338 AC_SUBST(HAVE_DPKGBUILD)
340 AC_SUBST(DPKGBUILD_VERSION)
344 dnl # Until native packaging for various different packing systems
345 dnl # can be added the least we can do is attempt to use alien to
346 dnl # convert the RPM packages to the needed package type. This is
347 dnl # a hack but so far it has worked reasonable well.
349 AC_DEFUN([SPL_AC_ALIEN], [
352 AC_MSG_CHECKING([whether $ALIEN is available])
353 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
354 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
356 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
359 AC_MSG_RESULT([$HAVE_ALIEN])
364 AC_SUBST(ALIEN_VERSION)
368 dnl # Using the VENDOR tag from config.guess set the default
369 dnl # package type for 'make pkg': (rpm | deb | tgz)
371 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
372 AC_MSG_CHECKING([linux distribution])
373 if test -f /etc/toss-release ; then
375 elif test -f /etc/fedora-release ; then
377 elif test -f /etc/redhat-release ; then
379 elif test -f /etc/gentoo-release ; then
381 elif test -f /etc/arch-release ; then
383 elif test -f /etc/SuSE-release ; then
385 elif test -f /etc/slackware-version ; then
387 elif test -f /etc/lunar.release ; then
389 elif test -f /etc/lsb-release ; then
391 elif test -f /etc/debian_version ; then
396 AC_MSG_RESULT([$VENDOR])
399 AC_MSG_CHECKING([default package type])
401 toss) DEFAULT_PACKAGE=rpm ;;
402 redhat) DEFAULT_PACKAGE=rpm ;;
403 fedora) DEFAULT_PACKAGE=rpm ;;
404 gentoo) DEFAULT_PACKAGE=tgz ;;
405 arch) DEFAULT_PACKAGE=tgz ;;
406 sles) DEFAULT_PACKAGE=rpm ;;
407 slackware) DEFAULT_PACKAGE=tgz ;;
408 lunar) DEFAULT_PACKAGE=tgz ;;
409 ubuntu) DEFAULT_PACKAGE=deb ;;
410 debian) DEFAULT_PACKAGE=deb ;;
411 *) DEFAULT_PACKAGE=rpm ;;
414 AC_MSG_RESULT([$DEFAULT_PACKAGE])
415 AC_SUBST(DEFAULT_PACKAGE)
419 dnl # Default SPL user configuration
421 AC_DEFUN([SPL_AC_PACKAGE], [
422 SPL_AC_DEFAULT_PACKAGE
428 AC_DEFUN([SPL_AC_LICENSE], [
429 AC_MSG_CHECKING([spl license])
431 AC_MSG_RESULT([$LICENSE])
432 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
436 AC_DEFUN([SPL_AC_CONFIG], [
438 AC_ARG_WITH([config],
439 AS_HELP_STRING([--with-config=CONFIG],
440 [Config file 'kernel|user|all|srpm']),
441 [SPL_CONFIG="$withval"])
442 AC_ARG_ENABLE([linux-builtin],
443 [AC_HELP_STRING([--enable-linux-builtin],
444 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
446 [enable_linux_builtin=no])
448 AC_MSG_CHECKING([spl config])
449 AC_MSG_RESULT([$SPL_CONFIG]);
452 case "$SPL_CONFIG" in
453 kernel) SPL_AC_CONFIG_KERNEL ;;
454 user) SPL_AC_CONFIG_USER ;;
455 all) SPL_AC_CONFIG_KERNEL
456 SPL_AC_CONFIG_USER ;;
459 AC_MSG_RESULT([Error!])
460 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
461 user kernel|user|all|srpm]) ;;
464 AM_CONDITIONAL([CONFIG_USER],
465 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
466 AM_CONDITIONAL([CONFIG_KERNEL],
467 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
468 [test "x$enable_linux_builtin" != xyes ])
472 dnl # Enable if the SPL should be compiled with internal debugging enabled.
473 dnl # By default this support is disabled.
475 AC_DEFUN([SPL_AC_DEBUG], [
476 AC_MSG_CHECKING([whether debugging is enabled])
477 AC_ARG_ENABLE([debug],
478 [AS_HELP_STRING([--enable-debug],
479 [Enable generic debug support @<:@default=no@:>@])],
483 AS_IF([test "x$enable_debug" = xyes],
485 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
486 DEBUG_CFLAGS="-DDEBUG -Werror"
487 DEBUG_SPL="_with_debug"
489 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
490 DEBUG_CFLAGS="-DNDEBUG"
491 DEBUG_SPL="_without_debug"
494 AC_SUBST(DEBUG_CFLAGS)
496 AC_MSG_RESULT([$enable_debug])
500 dnl # Enabled by default it provides a basic debug log infrastructure.
501 dnl # Each subsystem registers itself with a name and logs messages
502 dnl # using predefined types. If the debug mask it set to allow the
503 dnl # message type it will be written to the internal log. The log
504 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
505 dnl # after dumping the log it must be decoded using the spl utility.
507 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
508 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
510 AC_DEFUN([SPL_AC_DEBUG_LOG], [
511 AC_ARG_ENABLE([debug-log],
512 [AS_HELP_STRING([--enable-debug-log],
513 [Enable basic debug logging @<:@default=yes@:>@])],
515 [enable_debug_log=yes])
517 AS_IF([test "x$enable_debug_log" = xyes],
519 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
520 DEBUG_LOG="_with_debug_log"
521 AC_DEFINE([DEBUG_LOG], [1],
522 [Define to 1 to enable basic debug logging])
524 DEBUG_LOG="_without_debug_log"
528 AC_MSG_CHECKING([whether basic debug logging is enabled])
529 AC_MSG_RESULT([$enable_debug_log])
533 dnl # Enabled by default it provides a minimal level of memory tracking.
534 dnl # A total count of bytes allocated is kept for each alloc and free.
535 dnl # Then at module unload time a report to the console will be printed
536 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
537 dnl # and provide an easy way to inspect the kmem based slab.
539 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
540 AC_ARG_ENABLE([debug-kmem],
541 [AS_HELP_STRING([--enable-debug-kmem],
542 [Enable basic kmem accounting @<:@default=yes@:>@])],
544 [enable_debug_kmem=yes])
546 AS_IF([test "x$enable_debug_kmem" = xyes],
548 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
549 DEBUG_KMEM="_with_debug_kmem"
550 AC_DEFINE([DEBUG_KMEM], [1],
551 [Define to 1 to enable basic kmem accounting])
553 DEBUG_KMEM="_without_debug_kmem"
557 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
558 AC_MSG_RESULT([$enable_debug_kmem])
562 dnl # Disabled by default it provides detailed memory tracking. This
563 dnl # feature also requires --enable-debug-kmem to be set. When enabled
564 dnl # not only will total bytes be tracked but also the location of every
565 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
566 dnl # addresses and where they were allocated will be dumped to the console.
567 dnl # Enabling this feature has a significant impact on performance but it
568 dnl # makes finding memory leaks pretty straight forward.
570 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
571 AC_ARG_ENABLE([debug-kmem-tracking],
572 [AS_HELP_STRING([--enable-debug-kmem-tracking],
573 [Enable detailed kmem tracking @<:@default=no@:>@])],
575 [enable_debug_kmem_tracking=no])
577 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
579 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
580 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
581 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
582 [Define to 1 to enable detailed kmem tracking])
584 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
587 AC_SUBST(DEBUG_KMEM_TRACKING)
588 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
589 AC_MSG_RESULT([$enable_debug_kmem_tracking])
593 dnl # SPL_LINUX_CONFTEST
595 AC_DEFUN([SPL_LINUX_CONFTEST], [
596 cat confdefs.h - <<_ACEOF >conftest.c
602 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
604 m4_define([SPL_LANG_PROGRAM], [
609 dnl Do *not* indent the following line: there may be CPP directives.
610 dnl Don't move the `;' right after for the same reason.
618 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
620 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
621 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
622 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
623 echo "obj-m := conftest.o" >build/Makefile
625 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
627 [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
629 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
635 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
637 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
638 [SPL_LINUX_COMPILE_IFELSE(
639 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
641 [test -s build/conftest.o],
646 dnl # SPL_CHECK_SYMBOL_EXPORT
647 dnl # check symbol exported or not
649 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
650 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
651 $LINUX_OBJ/Module*.symvers 2>/dev/null
653 if test $rc -ne 0; then
656 grep -q -E "EXPORT_SYMBOL.*($1)" \
657 "$LINUX_OBJ/$file" 2>/dev/null
659 if test $rc -eq 0; then
664 if test $export -eq 0; then :
675 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
676 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
677 dnl # is called if not compiling for builtin
679 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
680 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
681 if test $rc -ne 0; then :
684 if test "x$enable_linux_builtin" != xyes; then
685 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
687 if test $rc -ne 0; then :
696 dnl # SPL_CHECK_SYMBOL_HEADER
697 dnl # check if a symbol prototype is defined in listed headers.
699 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
700 AC_MSG_CHECKING([whether symbol $1 exists in header])
703 grep -q "$2" "$LINUX/$file" 2>/dev/null
705 if test $rc -eq 0; then
710 if test $header -eq 0; then
720 dnl # SPL_CHECK_HEADER
721 dnl # check whether header exists and define HAVE_$2_HEADER
723 AC_DEFUN([SPL_CHECK_HEADER],
724 [AC_MSG_CHECKING([whether header $1 exists])
725 SPL_LINUX_TRY_COMPILE([
730 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
740 dnl # Basic toolchain sanity check.
742 AC_DEFUN([SPL_AC_TEST_MODULE],
743 [AC_MSG_CHECKING([whether modules can be built])
744 SPL_LINUX_TRY_COMPILE([],[],[
748 if test "x$enable_linux_builtin" != xyes; then
749 AC_MSG_ERROR([*** Unable to build an empty module.])
752 *** Unable to build an empty module.
753 *** Please run 'make scripts' inside the kernel source tree.])
759 dnl # Use the atomic implemenation based on global spinlocks. This
760 dnl # should only be needed by 32-bit kernels which do not provide
761 dnl # the atomic64_* API. It may be optionally enabled as a fallback
762 dnl # if problems are observed with the direct mapping to the native
763 dnl # Linux atomic operations. You may not disable atomic spinlocks
764 dnl # if you kernel does not an atomic64_* API.
766 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
767 AC_ARG_ENABLE([atomic-spinlocks],
768 [AS_HELP_STRING([--enable-atomic-spinlocks],
769 [Atomic types use spinlocks @<:@default=check@:>@])],
771 [enable_atomic_spinlocks=check])
773 SPL_LINUX_TRY_COMPILE([
774 #include <linux/fs.h>
776 atomic64_t *ptr __attribute__ ((unused));
779 AC_DEFINE(HAVE_ATOMIC64_T, 1,
780 [kernel defines atomic64_t])
785 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
786 AS_IF([test "x$have_atomic64_t" = xyes], [
787 enable_atomic_spinlocks=no
789 enable_atomic_spinlocks=yes
793 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
794 AC_DEFINE([ATOMIC_SPINLOCK], [1],
795 [Atomic types use spinlocks])
797 AS_IF([test "x$have_atomic64_t" = xno], [
799 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
803 AC_MSG_CHECKING([whether atomic types use spinlocks])
804 AC_MSG_RESULT([$enable_atomic_spinlocks])
806 AC_MSG_CHECKING([whether kernel defines atomic64_t])
807 AC_MSG_RESULT([$have_atomic64_t])
811 dnl # 2.6.24 API change,
812 dnl # check if atomic64_cmpxchg is defined
814 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
815 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
816 SPL_LINUX_TRY_COMPILE([
817 #include <linux/fs.h>
819 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
822 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
823 [kernel defines atomic64_cmpxchg])
830 dnl # 2.6.24 API change,
831 dnl # check if atomic64_xchg is defined
833 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
834 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
835 SPL_LINUX_TRY_COMPILE([
836 #include <linux/fs.h>
838 atomic64_xchg((atomic64_t *)NULL, 0);
841 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
842 [kernel defines atomic64_xchg])
849 dnl # 2.6.24 API change,
850 dnl # check if uintptr_t typedef is defined
852 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
853 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
854 SPL_LINUX_TRY_COMPILE([
855 #include <linux/types.h>
857 uintptr_t *ptr __attribute__ ((unused));
860 AC_DEFINE(HAVE_UINTPTR_T, 1,
861 [kernel defines uintptr_t])
868 dnl # 2.6.21 API change,
869 dnl # 'register_sysctl_table' use only one argument instead of two
871 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
872 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
873 SPL_LINUX_TRY_COMPILE([
874 #include <linux/sysctl.h>
876 (void) register_sysctl_table(NULL, 0);
879 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
880 [register_sysctl_table() wants 2 args])
886 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
887 tmp_flags="$EXTRA_KCFLAGS"
888 EXTRA_KCFLAGS="-Werror"
890 dnl # 2.6.23 to 2.6.34 API change
891 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
893 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
894 SPL_LINUX_TRY_COMPILE([
895 #include <linux/mm.h>
897 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
899 struct shrinker cache_shrinker = {
900 .shrink = shrinker_cb,
901 .seeks = DEFAULT_SEEKS,
903 register_shrinker(&cache_shrinker);
906 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
907 [old shrinker callback wants 2 args])
911 dnl # 2.6.35 - 2.6.39 API change
912 dnl # ->shrink(struct shrinker *,
913 dnl # int nr_to_scan, gfp_t gfp_mask)
915 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
916 SPL_LINUX_TRY_COMPILE([
917 #include <linux/mm.h>
919 int shrinker_cb(struct shrinker *, int nr_to_scan,
922 struct shrinker cache_shrinker = {
923 .shrink = shrinker_cb,
924 .seeks = DEFAULT_SEEKS,
926 register_shrinker(&cache_shrinker);
929 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
930 [old shrinker callback wants 3 args])
934 dnl # 3.0 - 3.11 API change
935 dnl # ->shrink(struct shrinker *,
936 dnl # struct shrink_control *sc)
939 [whether new 2-argument shrinker exists])
940 SPL_LINUX_TRY_COMPILE([
941 #include <linux/mm.h>
943 int shrinker_cb(struct shrinker *,
944 struct shrink_control *sc);
946 struct shrinker cache_shrinker = {
947 .shrink = shrinker_cb,
948 .seeks = DEFAULT_SEEKS,
950 register_shrinker(&cache_shrinker);
953 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
954 [new shrinker callback wants 2 args])
958 dnl # 3.12 API change,
959 dnl # ->shrink() is logically split in to
960 dnl # ->count_objects() and ->scan_objects()
963 [whether ->count_objects callback exists])
964 SPL_LINUX_TRY_COMPILE([
965 #include <linux/mm.h>
967 unsigned long shrinker_cb(
969 struct shrink_control *sc);
971 struct shrinker cache_shrinker = {
972 .count_objects = shrinker_cb,
973 .scan_objects = shrinker_cb,
974 .seeks = DEFAULT_SEEKS,
976 register_shrinker(&cache_shrinker);
979 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
980 1, [->count_objects exists])
987 EXTRA_KCFLAGS="$tmp_flags"
991 dnl # Custom SPL patch may export this system it is not required
993 AC_DEFUN([SPL_AC_TASK_CURR],
994 [AC_MSG_CHECKING([whether task_curr() is available])
995 SPL_LINUX_TRY_COMPILE_SYMBOL([
996 #include <linux/sched.h>
999 ], [task_curr], [kernel/sched.c], [
1001 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1008 dnl # 2.6.19 API change,
1009 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1011 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1012 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1013 SPL_LINUX_TRY_COMPILE([
1014 #include <linux/sysctl.h>
1016 #ifndef CTL_UNNUMBERED
1017 #error CTL_UNNUMBERED undefined
1021 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1022 [unnumbered sysctl support exists])
1029 dnl # 2.6.33 API change,
1030 dnl # Removed .ctl_name from struct ctl_table.
1032 AC_DEFUN([SPL_AC_CTL_NAME], [
1033 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1034 SPL_LINUX_TRY_COMPILE([
1035 #include <linux/sysctl.h>
1037 struct ctl_table ctl __attribute__ ((unused));
1041 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1048 dnl # 2.6.16 API change.
1049 dnl # Check if 'fls64()' is available
1051 AC_DEFUN([SPL_AC_FLS64],
1052 [AC_MSG_CHECKING([whether fls64() is available])
1053 SPL_LINUX_TRY_COMPILE([
1054 #include <linux/bitops.h>
1059 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1066 dnl # 2.6.18 API change, check whether device_create() is available.
1067 dnl # Device_create() was introduced in 2.6.18 and depricated
1068 dnl # class_device_create() which was fully removed in 2.6.26.
1070 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1071 [AC_MSG_CHECKING([whether device_create() is available])
1072 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1074 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1075 [device_create() is available])
1082 dnl # 2.6.27 API change,
1083 dnl # device_create() uses 5 args, new 'drvdata' argument.
1085 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1086 AC_MSG_CHECKING([whether device_create() wants 5 args])
1087 tmp_flags="$EXTRA_KCFLAGS"
1088 EXTRA_KCFLAGS="-Werror"
1089 SPL_LINUX_TRY_COMPILE([
1090 #include <linux/device.h>
1092 device_create(NULL, NULL, 0, NULL, "%d", 1);
1095 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1096 [device_create wants 5 args])
1100 EXTRA_KCFLAGS="$tmp_flags"
1104 dnl # 2.6.13 API change, check whether class_device_create() is available.
1105 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1106 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1108 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1109 [AC_MSG_CHECKING([whether class_device_create() is available])
1110 SPL_LINUX_TRY_COMPILE_SYMBOL([
1111 #include <linux/device.h>
1113 class_device_create(NULL, NULL, 0, NULL, NULL);
1114 ], [class_device_create], [drivers/base/class.c], [
1116 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1117 [class_device_create() is available])
1124 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1126 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1127 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1128 SPL_LINUX_TRY_COMPILE_SYMBOL([
1129 #include <linux/time.h>
1131 set_normalized_timespec(NULL, 0, 0);
1132 ], [set_normalized_timespec], [kernel/time.c], [
1134 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1135 [set_normalized_timespec() is available as export])
1142 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1143 dnl # previously it was available in time.h as an inline.
1145 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1146 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1147 SPL_LINUX_TRY_COMPILE([
1148 #include <linux/time.h>
1149 void set_normalized_timespec(struct timespec *ts,
1150 time_t sec, long nsec) { }
1157 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1158 [set_normalized_timespec() is available as inline])
1163 dnl # 2.6.18 API change,
1164 dnl # timespec_sub() inline function available in linux/time.h
1166 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1167 AC_MSG_CHECKING([whether timespec_sub() is available])
1168 SPL_LINUX_TRY_COMPILE([
1169 #include <linux/time.h>
1171 struct timespec a = { 0 };
1172 struct timespec b = { 0 };
1173 struct timespec c __attribute__ ((unused));
1174 c = timespec_sub(a, b);
1177 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1184 dnl # 2.6.19 API change,
1185 dnl # check if init_utsname() is available in linux/utsname.h
1187 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1188 AC_MSG_CHECKING([whether init_utsname() is available])
1189 SPL_LINUX_TRY_COMPILE([
1190 #include <linux/utsname.h>
1192 struct new_utsname *a __attribute__ ((unused));
1196 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1203 dnl # 2.6.18 API change,
1204 dnl # added linux/uaccess.h
1206 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1207 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1211 dnl # 2.6.12 API change,
1212 dnl # check whether 'kmalloc_node()' is available.
1214 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1215 AC_MSG_CHECKING([whether kmalloc_node() is available])
1216 SPL_LINUX_TRY_COMPILE([
1217 #include <linux/slab.h>
1219 void *a __attribute__ ((unused));
1220 a = kmalloc_node(1, GFP_KERNEL, 0);
1223 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1230 dnl # 2.6.9 API change,
1231 dnl # check whether 'monotonic_clock()' is available it may
1232 dnl # be available for some archs but not others.
1234 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1235 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1236 SPL_LINUX_TRY_COMPILE_SYMBOL([
1237 #include <linux/timex.h>
1240 ], [monotonic_clock], [], [
1242 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1243 [monotonic_clock() is available])
1250 dnl # 2.6.16 API change,
1251 dnl # check whether 'struct inode' has i_mutex
1253 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1254 AC_MSG_CHECKING([whether struct inode has i_mutex])
1255 SPL_LINUX_TRY_COMPILE([
1256 #include <linux/fs.h>
1257 #include <linux/mutex.h>
1260 mutex_init(&i.i_mutex);
1263 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1270 dnl # 2.6.29 API change,
1271 dnl # Adaptive mutexs introduced.
1273 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1274 AC_MSG_CHECKING([whether struct mutex has owner])
1275 SPL_LINUX_TRY_COMPILE([
1276 #include <linux/mutex.h>
1278 struct mutex mtx __attribute__ ((unused));
1282 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1289 dnl # 2.6.39 API change,
1290 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1291 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1292 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1293 dnl # pointer which frankly makes a lot more sense.
1295 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1296 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1297 tmp_flags="$EXTRA_KCFLAGS"
1298 EXTRA_KCFLAGS="-Werror"
1299 SPL_LINUX_TRY_COMPILE([
1300 #include <linux/mutex.h>
1301 #include <linux/sched.h>
1303 struct mutex mtx __attribute__ ((unused));
1304 mtx.owner = current;
1307 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1308 [struct mutex owner is a task_struct])
1312 EXTRA_KCFLAGS="$tmp_flags"
1316 dnl # 2.6.18 API change,
1317 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1318 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1319 dnl # if the mutex validator is disabled or otherwise unavailable.
1321 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1322 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1323 SPL_LINUX_TRY_COMPILE([
1324 #include <linux/mutex.h>
1328 mutex_lock_nested(&mutex, 0);
1331 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1332 [mutex_lock_nested() is available])
1339 dnl # 2.6.27 API change,
1340 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1342 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1343 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1344 SPL_LINUX_TRY_COMPILE([
1345 #include <linux/interrupt.h>
1346 #include <linux/smp.h>
1348 void on_each_cpu_func(void *data) { return; }
1350 on_each_cpu(on_each_cpu_func, NULL, 0);
1353 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1354 [on_each_cpu wants 3 args])
1361 dnl # 2.6.18 API change,
1362 dnl # kallsyms_lookup_name no longer exported
1364 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1365 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1366 SPL_LINUX_TRY_COMPILE_SYMBOL([
1367 #include <linux/kallsyms.h>
1369 kallsyms_lookup_name(NULL);
1370 ], [kallsyms_lookup_name], [], [
1372 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1373 [kallsyms_lookup_name() is available])
1380 dnl # Proposed API change,
1381 dnl # This symbol is not available in stock kernels. You may build a
1382 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1383 dnl # these symbols for use. If your already rolling a custom kernel for
1384 dnl # your environment this is recommended.
1386 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1387 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1388 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1390 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1391 [get_vmalloc_info() is available])
1398 dnl # 3.10 API change,
1399 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1401 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1402 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1403 SPL_LINUX_TRY_COMPILE([
1404 #include <linux/vmalloc.h>
1405 struct vmalloc_info { void *a; };
1412 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1417 dnl # 3.10 API change,
1418 dnl # PDE is replaced by PDE_DATA
1420 AC_DEFUN([SPL_AC_PDE_DATA], [
1421 AC_MSG_CHECKING([whether PDE_DATA() is available])
1422 SPL_LINUX_TRY_COMPILE_SYMBOL([
1423 #include <linux/proc_fs.h>
1426 ], [PDE_DATA], [], [
1428 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1435 dnl # 2.6.17 API change
1436 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1437 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1438 dnl # were exported in 2.6.17 for use by modules which was consistent with
1439 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1440 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1441 dnl # were dropped entirely leaving modules no way to directly iterate over
1442 dnl # the zone list. Because we need access to the zone helpers we check
1443 dnl # if the kernel contains the old or new implementation. Then we check
1444 dnl # to see if the symbols we need for each version are available. If they
1445 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1447 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1448 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1449 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1451 if test $rc -eq 0; then
1452 AC_MSG_RESULT([yes])
1453 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1460 dnl # Proposed API change,
1461 dnl # This symbol is not available in stock kernels. You may build a
1462 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1463 dnl # these symbols for use. If your already rolling a custom kernel for
1464 dnl # your environment this is recommended.
1466 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1467 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1468 SPL_LINUX_TRY_COMPILE_SYMBOL([
1469 #include <linux/mmzone.h>
1471 first_online_pgdat();
1472 ], [first_online_pgdat], [], [
1474 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1475 [first_online_pgdat() is available])
1482 dnl # Proposed API change,
1483 dnl # This symbol is not available in stock kernels. You may build a
1484 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1485 dnl # these symbols for use. If your already rolling a custom kernel for
1486 dnl # your environment this is recommended.
1488 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1489 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1490 SPL_LINUX_TRY_COMPILE_SYMBOL([
1491 #include <linux/mmzone.h>
1493 next_online_pgdat(NULL);
1494 ], [next_online_pgdat], [], [
1496 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1497 [next_online_pgdat() is available])
1504 dnl # Proposed API change,
1505 dnl # This symbol is not available in stock kernels. You may build a
1506 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1507 dnl # these symbols for use. If your already rolling a custom kernel for
1508 dnl # your environment this is recommended.
1510 AC_DEFUN([SPL_AC_NEXT_ZONE],
1511 [AC_MSG_CHECKING([whether next_zone() is available])
1512 SPL_LINUX_TRY_COMPILE_SYMBOL([
1513 #include <linux/mmzone.h>
1516 ], [next_zone], [], [
1518 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1525 dnl # 2.6.17 API change,
1526 dnl # See SPL_AC_PGDAT_HELPERS for details.
1528 AC_DEFUN([SPL_AC_PGDAT_LIST],
1529 [AC_MSG_CHECKING([whether pgdat_list is available])
1530 SPL_LINUX_TRY_COMPILE_SYMBOL([
1531 #include <linux/topology.h>
1532 pg_data_t *tmp = pgdat_list;
1533 ], [], [pgdat_list], [], [
1535 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1542 dnl # 2.6.18 API change,
1543 dnl # First introduced global_page_state() support as an inline.
1545 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1546 AC_MSG_CHECKING([whether global_page_state() is available])
1547 SPL_LINUX_TRY_COMPILE([
1548 #include <linux/mm.h>
1550 unsigned long state __attribute__ ((unused));
1551 state = global_page_state(0);
1554 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1555 [global_page_state() is available])
1562 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1563 dnl # Public global zone stats now include a free page count. However
1564 dnl # the enumerated names of the counters have changed since this API
1565 dnl # was introduced. We need to deduce the corrent name to use. This
1566 dnl # replaces the priviate get_zone_counts() interface.
1568 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1569 dnl # is 2.6.30 as of when this was written.
1571 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1572 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1573 SPL_LINUX_TRY_COMPILE([
1574 #include <linux/mm.h>
1576 enum zone_stat_item zsi __attribute__ ((unused));
1577 zsi = NR_FREE_PAGES;
1580 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1581 [Page state NR_FREE_PAGES is available])
1588 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1589 dnl # Public global zone stats now include an inactive page count. However
1590 dnl # the enumerated names of the counters have changed since this API
1591 dnl # was introduced. We need to deduce the corrent name to use. This
1592 dnl # replaces the priviate get_zone_counts() interface.
1594 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1595 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1596 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1598 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1599 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1600 SPL_LINUX_TRY_COMPILE([
1601 #include <linux/mm.h>
1603 enum zone_stat_item zsi __attribute__ ((unused));
1607 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1608 [Page state NR_INACTIVE is available])
1613 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1614 SPL_LINUX_TRY_COMPILE([
1615 #include <linux/mm.h>
1617 enum zone_stat_item zsi __attribute__ ((unused));
1618 zsi = NR_INACTIVE_ANON;
1621 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1622 [Page state NR_INACTIVE_ANON is available])
1627 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1628 SPL_LINUX_TRY_COMPILE([
1629 #include <linux/mm.h>
1631 enum zone_stat_item zsi __attribute__ ((unused));
1632 zsi = NR_INACTIVE_FILE;
1635 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1636 [Page state NR_INACTIVE_FILE is available])
1643 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1644 dnl # Public global zone stats now include an active page count. However
1645 dnl # the enumerated names of the counters have changed since this API
1646 dnl # was introduced. We need to deduce the corrent name to use. This
1647 dnl # replaces the priviate get_zone_counts() interface.
1649 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1650 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1651 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1653 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1654 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1655 SPL_LINUX_TRY_COMPILE([
1656 #include <linux/mm.h>
1658 enum zone_stat_item zsi __attribute__ ((unused));
1662 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1663 [Page state NR_ACTIVE is available])
1668 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1669 SPL_LINUX_TRY_COMPILE([
1670 #include <linux/mm.h>
1672 enum zone_stat_item zsi __attribute__ ((unused));
1673 zsi = NR_ACTIVE_ANON;
1676 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1677 [Page state NR_ACTIVE_ANON is available])
1682 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1683 SPL_LINUX_TRY_COMPILE([
1684 #include <linux/mm.h>
1686 enum zone_stat_item zsi __attribute__ ((unused));
1687 zsi = NR_ACTIVE_FILE;
1690 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1691 [Page state NR_ACTIVE_FILE is available])
1698 dnl # Proposed API change for legacy kernels.
1699 dnl # This symbol is not available in older kernels. For kernels post
1700 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1701 dnl # page state information. This symbol is only used in legacy kernels
1702 dnl # any only as a last resort.
1704 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1705 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1706 SPL_LINUX_TRY_COMPILE([
1708 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1709 #error "global_page_state needs NR_FREE_PAGES"
1712 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1713 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1714 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1715 #error "global_page_state needs NR_ACTIVE*"
1718 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1719 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1720 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1721 #error "global_page_state needs NR_INACTIVE*"
1727 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1728 [get_zone_counts() is needed])
1730 AC_MSG_CHECKING([whether get_zone_counts() is available])
1731 SPL_LINUX_TRY_COMPILE_SYMBOL([
1732 #include <linux/mmzone.h>
1734 get_zone_counts(NULL, NULL, NULL);
1735 ], [get_zone_counts], [], [
1737 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1738 [get_zone_counts() is available])
1746 dnl # 2.6.27 API change,
1747 dnl # The user_path_dir() replaces __user_walk()
1749 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1750 [AC_MSG_CHECKING([whether user_path_dir() is available])
1751 SPL_LINUX_TRY_COMPILE_SYMBOL([
1752 #include <linux/fcntl.h>
1753 #include <linux/namei.h>
1755 user_path_dir(NULL, NULL);
1756 ], [user_path_at], [], [
1758 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1765 dnl # Symbol available in RHEL kernels not in stock kernels.
1767 AC_DEFUN([SPL_AC_SET_FS_PWD],
1768 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1769 SPL_LINUX_TRY_COMPILE_SYMBOL([
1770 #include <linux/spinlock.h>
1771 #include <linux/fs_struct.h>
1774 ], [set_fs_pwd], [], [
1776 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1783 dnl # 3.9 API change
1784 dnl # set_fs_pwd takes const struct path *
1786 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1787 tmp_flags="$EXTRA_KCFLAGS"
1788 EXTRA_KCFLAGS="-Werror"
1789 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1790 SPL_LINUX_TRY_COMPILE([
1791 #include <linux/spinlock.h>
1792 #include <linux/fs_struct.h>
1793 #include <linux/path.h>
1794 void (*const set_fs_pwd_func)
1795 (struct fs_struct *, const struct path *)
1801 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1802 [set_fs_pwd() needs const path *])
1804 SPL_LINUX_TRY_COMPILE([
1805 #include <linux/spinlock.h>
1806 #include <linux/fs_struct.h>
1807 #include <linux/path.h>
1808 void (*const set_fs_pwd_func)
1809 (struct fs_struct *, struct path *)
1816 AC_MSG_ERROR(unknown)
1819 EXTRA_KCFLAGS="$tmp_flags"
1822 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1823 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1824 SPL_LINUX_TRY_COMPILE([
1825 #include <linux/fs.h>
1827 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1830 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1831 [vfs_unlink() wants 2 args])
1835 dnl # Linux 3.13 API change
1836 dnl # Added delegated inode
1838 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1839 SPL_LINUX_TRY_COMPILE([
1840 #include <linux/fs.h>
1842 vfs_unlink((struct inode *) NULL,
1843 (struct dentry *) NULL,
1844 (struct inode **) NULL);
1847 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1848 [vfs_unlink() wants 3 args])
1856 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1857 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1858 SPL_LINUX_TRY_COMPILE([
1859 #include <linux/fs.h>
1861 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1862 (struct inode *) NULL, (struct dentry *) NULL);
1865 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1866 [vfs_rename() wants 4 args])
1870 dnl # Linux 3.13 API change
1871 dnl # Added delegated inode
1873 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1874 SPL_LINUX_TRY_COMPILE([
1875 #include <linux/fs.h>
1877 vfs_rename((struct inode *) NULL,
1878 (struct dentry *) NULL,
1879 (struct inode *) NULL,
1880 (struct dentry *) NULL,
1881 (struct inode **) NULL);
1884 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1885 [vfs_rename() wants 5 args])
1889 dnl # Linux 3.15 API change
1892 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1893 SPL_LINUX_TRY_COMPILE([
1894 #include <linux/fs.h>
1896 vfs_rename((struct inode *) NULL,
1897 (struct dentry *) NULL,
1898 (struct inode *) NULL,
1899 (struct dentry *) NULL,
1900 (struct inode **) NULL,
1904 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1905 [vfs_rename() wants 6 args])
1914 dnl # 2.6.36 API change,
1915 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1916 dnl # a spinlock_t to improve the fastpath performance.
1918 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1919 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1920 tmp_flags="$EXTRA_KCFLAGS"
1921 EXTRA_KCFLAGS="-Werror"
1922 SPL_LINUX_TRY_COMPILE([
1923 #include <linux/sched.h>
1924 #include <linux/fs_struct.h>
1926 struct fs_struct fs;
1927 spin_lock_init(&fs.lock);
1930 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1931 [struct fs_struct uses spinlock_t])
1935 EXTRA_KCFLAGS="$tmp_flags"
1939 dnl # 2.6.29 API change,
1940 dnl # check whether 'struct cred' exists
1942 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1943 AC_MSG_CHECKING([whether struct cred exists])
1944 SPL_LINUX_TRY_COMPILE([
1945 #include <linux/cred.h>
1947 struct cred *cr __attribute__ ((unused));
1951 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1959 dnl # User namespaces, use kuid_t in place of uid_t
1960 dnl # where available. Not strictly a user namespaces thing
1961 dnl # but it should prevent surprises
1963 AC_DEFUN([SPL_AC_KUIDGID_T], [
1964 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1965 SPL_LINUX_TRY_COMPILE([
1966 #include <linux/uidgid.h>
1968 kuid_t userid = KUIDT_INIT(0);
1969 kgid_t groupid = KGIDT_INIT(0);
1971 SPL_LINUX_TRY_COMPILE([
1972 #include <linux/uidgid.h>
1977 AC_MSG_RESULT(yes; optional)
1979 AC_MSG_RESULT(yes; mandatory)
1980 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1988 dnl # Custom SPL patch may export this symbol.
1990 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1991 [AC_MSG_CHECKING([whether groups_search() is available])
1992 SPL_LINUX_TRY_COMPILE_SYMBOL([
1993 #include <linux/cred.h>
1994 #ifdef HAVE_KUIDGID_T
1995 #include <linux/uidgid.h>
1998 #ifdef HAVE_KUIDGID_T
1999 groups_search(NULL, KGIDT_INIT(0));
2001 groups_search(NULL, 0);
2003 ], [groups_search], [], [
2005 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
2012 dnl # 2.6.x API change,
2013 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
2015 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
2016 [AC_MSG_CHECKING([whether __put_task_struct() is available])
2017 SPL_LINUX_TRY_COMPILE_SYMBOL([
2018 #include <linux/sched.h>
2020 __put_task_struct(NULL);
2021 ], [__put_task_struct], [], [
2023 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
2024 [__put_task_struct() is available])
2031 dnl # 2.6.32 API change,
2032 dnl # Unused 'struct file *' removed from prototype.
2034 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
2035 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
2036 SPL_LINUX_TRY_COMPILE([
2037 #include <linux/sysctl.h>
2039 proc_dostring(NULL, 0, NULL, NULL, NULL);
2042 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
2043 [proc_handler() wants 5 args])
2050 dnl # 2.6.x API change,
2051 dnl # kvasprintf() function added.
2053 AC_DEFUN([SPL_AC_KVASPRINTF],
2054 [AC_MSG_CHECKING([whether kvasprintf() is available])
2055 SPL_LINUX_TRY_COMPILE_SYMBOL([
2056 #include <linux/kernel.h>
2058 kvasprintf(0, NULL, *((va_list*)NULL));
2059 ], [kvasprintf], [], [
2061 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2068 dnl # 2.6.29 API change,
2069 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2071 AC_DEFUN([SPL_AC_VFS_FSYNC],
2072 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2073 SPL_LINUX_TRY_COMPILE_SYMBOL([
2074 #include <linux/fs.h>
2077 ], [vfs_fsync], [fs/sync.c], [
2079 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2086 dnl # 2.6.35 API change,
2087 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2089 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2090 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2091 SPL_LINUX_TRY_COMPILE([
2092 #include <linux/fs.h>
2097 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2104 dnl # 3.5 API change,
2105 dnl # inode_operations.truncate_range removed
2107 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2108 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2109 SPL_LINUX_TRY_COMPILE([
2110 #include <linux/fs.h>
2112 struct inode_operations ops;
2113 ops.truncate_range = NULL;
2116 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2117 [truncate_range() inode operation is available])
2124 dnl # Linux 2.6.38 - 3.x API
2126 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2127 AC_MSG_CHECKING([whether fops->fallocate() exists])
2128 SPL_LINUX_TRY_COMPILE([
2129 #include <linux/fs.h>
2131 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2132 struct file_operations fops __attribute__ ((unused)) = {
2133 .fallocate = fallocate,
2137 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2144 dnl # Linux 2.6.x - 2.6.37 API
2146 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2147 AC_MSG_CHECKING([whether iops->fallocate() exists])
2148 SPL_LINUX_TRY_COMPILE([
2149 #include <linux/fs.h>
2151 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2152 struct inode_operations fops __attribute__ ((unused)) = {
2153 .fallocate = fallocate,
2157 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2164 dnl # PaX Linux 2.6.38 - 3.x API
2166 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2167 AC_MSG_CHECKING([whether fops->fallocate() exists])
2168 SPL_LINUX_TRY_COMPILE([
2169 #include <linux/fs.h>
2171 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2172 struct file_operations_no_const fops __attribute__ ((unused)) = {
2173 .fallocate = fallocate,
2177 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2184 dnl # The fallocate callback was moved from the inode_operations
2185 dnl # structure to the file_operations structure.
2187 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2188 SPL_AC_KERNEL_FILE_FALLOCATE
2189 SPL_AC_KERNEL_INODE_FALLOCATE
2190 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2194 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2195 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2196 dnl # condition. The fixed version is exported as a symbol. The race
2197 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2198 dnl # call that version while holding sem->wait_lock.
2200 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2201 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2202 SPL_LINUX_TRY_COMPILE_SYMBOL([
2203 #include <linux/rwsem.h>
2204 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2205 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2207 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2208 [rwsem_is_locked() acquires sem->wait_lock])
2215 dnl # 2.6.xx API compat,
2216 dnl # There currently exists no exposed API to partially shrink the dcache.
2217 dnl # The expected mechanism to shrink the cache is a registered shrinker
2218 dnl # which is called during memory pressure.
2220 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2221 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2222 SPL_LINUX_TRY_COMPILE_SYMBOL([
2223 #include <linux/dcache.h>
2225 shrink_dcache_memory(0, 0);
2226 ], [shrink_dcache_memory], [fs/dcache.c], [
2228 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2229 [shrink_dcache_memory() is available])
2236 dnl # 2.6.xx API compat,
2237 dnl # There currently exists no exposed API to partially shrink the icache.
2238 dnl # The expected mechanism to shrink the cache is a registered shrinker
2239 dnl # which is called during memory pressure.
2241 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2242 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2243 SPL_LINUX_TRY_COMPILE_SYMBOL([
2244 #include <linux/dcache.h>
2246 shrink_icache_memory(0, 0);
2247 ], [shrink_icache_memory], [fs/inode.c], [
2249 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2250 [shrink_icache_memory() is available])
2257 dnl # 2.6.28 API change
2258 dnl # The kern_path() function has been introduced. We adopt it as the new way
2259 dnl # of looking up paths. When it is not available, we emulate it using the
2260 dnl # older interfaces.
2262 AC_DEFUN([SPL_AC_KERN_PATH],
2263 [AC_MSG_CHECKING([whether kern_path() is available])
2264 SPL_LINUX_TRY_COMPILE_SYMBOL([
2265 #include <linux/namei.h>
2267 int r = kern_path(NULL, 0, NULL);
2268 ], [kern_path], [fs/namei.c], [
2270 AC_DEFINE(HAVE_KERN_PATH, 1,
2271 [kern_path() is available])
2274 AC_MSG_CHECKING([whether path_lookup() is available])
2275 SPL_LINUX_TRY_COMPILE_SYMBOL([
2276 #include <linux/namei.h>
2278 int r = path_lookup(NULL, 0, NULL);
2279 ], [path_lookup], [fs/namei.c], [
2281 AC_DEFINE(HAVE_KERN_PATH, 1,
2282 [kern_path() is available])
2286 *** Neither kern_path() nor path_lookup() is available.
2287 *** Please file an issue:
2288 *** https://github.com/zfsonlinux/spl/issues/new])
2295 dnl # /proc/kallsyms support,
2296 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2298 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2299 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2300 SPL_LINUX_TRY_COMPILE([
2301 #if !defined(CONFIG_KALLSYMS)
2302 #error CONFIG_KALLSYMS not defined
2305 AC_MSG_RESULT([yes])
2309 *** This kernel does not include the required kallsyms support.
2310 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2315 dnl # zlib inflate compat,
2316 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2318 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2319 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2320 SPL_LINUX_TRY_COMPILE([
2321 #if !defined(CONFIG_ZLIB_INFLATE) && \
2322 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2323 #error CONFIG_ZLIB_INFLATE not defined
2326 AC_MSG_RESULT([yes])
2330 *** This kernel does not include the required zlib inflate support.
2331 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2336 dnl # zlib deflate compat,
2337 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2339 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2340 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2341 SPL_LINUX_TRY_COMPILE([
2342 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2343 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2344 #error CONFIG_ZLIB_DEFLATE not defined
2347 AC_MSG_RESULT([yes])
2351 *** This kernel does not include the required zlib deflate support.
2352 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2357 dnl # 2.6.39 API compat,
2358 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2359 dnl # This was done to avoid always having to allocate the maximum size
2360 dnl # workspace (268K). The caller can now specific the windowBits and
2361 dnl # memLevel compression parameters to get a smaller workspace.
2363 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2364 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2365 SPL_LINUX_TRY_COMPILE([
2366 #include <linux/zlib.h>
2368 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2371 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2372 [zlib_deflate_workspacesize() wants 2 args])
2379 dnl # 2.6.39 API change,
2380 dnl # Shrinker adjust to use common shrink_control structure.
2382 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2383 AC_MSG_CHECKING([whether struct shrink_control exists])
2384 SPL_LINUX_TRY_COMPILE([
2385 #include <linux/mm.h>
2387 struct shrink_control sc __attribute__ ((unused));
2390 sc.gfp_mask = GFP_KERNEL;
2393 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2394 [struct shrink_control exists])
2401 dnl # 3.1 API Change
2403 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2404 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2406 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2407 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2408 tmp_flags="$EXTRA_KCFLAGS"
2409 EXTRA_KCFLAGS="-Werror"
2410 SPL_LINUX_TRY_COMPILE([
2411 #include <linux/rwsem.h>
2413 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2414 raw_spinlock_t dummy_lock __attribute__ ((unused));
2415 dummy_semaphore.wait_lock = dummy_lock;
2418 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2419 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2423 EXTRA_KCFLAGS="$tmp_flags"
2427 dnl # 3.9 API change,
2428 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2430 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2431 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2432 SPL_LINUX_TRY_COMPILE([
2433 #include <linux/sched.h>
2434 #include <linux/sched/rt.h>
2438 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2446 dnl # 3.9 API change,
2447 dnl # vfs_getattr() uses 2 args
2448 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2450 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2451 AC_MSG_CHECKING([whether vfs_getattr() wants])
2452 SPL_LINUX_TRY_COMPILE([
2453 #include <linux/fs.h>
2455 vfs_getattr((struct path *) NULL,
2456 (struct kstat *)NULL);
2458 AC_MSG_RESULT(2 args)
2459 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2460 [vfs_getattr wants 2 args])
2462 SPL_LINUX_TRY_COMPILE([
2463 #include <linux/fs.h>
2465 vfs_getattr((struct vfsmount *)NULL,
2466 (struct dentry *)NULL,
2467 (struct kstat *)NULL);
2469 AC_MSG_RESULT(3 args)
2471 AC_MSG_ERROR(unknown)
2477 dnl # 2.6.36 API compatibility.
2478 dnl # Added usleep_range timer.
2479 dnl # usleep_range is a finer precision implementation of msleep
2480 dnl # designed to be a drop-in replacement for udelay where a precise
2481 dnl # sleep / busy-wait is unnecessary.
2483 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2484 AC_MSG_CHECKING([whether usleep_range() is available])
2485 SPL_LINUX_TRY_COMPILE([
2486 #include <linux/delay.h>
2491 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2492 [usleep_range is available])
2499 dnl # 2.6.35 API change,
2500 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2501 dnl # private allocation flags which are applied when allocating a new slab
2502 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2503 dnl # non-default flags.
2505 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2506 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2507 SPL_LINUX_TRY_COMPILE([
2508 #include <linux/slab.h>
2510 struct kmem_cache cachep __attribute__ ((unused));
2511 cachep.allocflags = GFP_KERNEL;
2514 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2515 [struct kmem_cache has allocflags])
2519 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2520 SPL_LINUX_TRY_COMPILE([
2521 #include <linux/slab.h>
2523 struct kmem_cache cachep __attribute__ ((unused));
2524 cachep.gfpflags = GFP_KERNEL;
2527 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2528 [struct kmem_cache has gfpflags])
2536 dnl # 3.17 API change,
2537 dnl # wait_on_bit() no longer requires an action argument. The former
2538 dnl # "wait_on_bit" interface required an 'action' function to be provided
2539 dnl # which does the actual waiting. There were over 20 such functions in the
2540 dnl # kernel, many of them identical, though most cases can be satisfied by one
2541 dnl # of just two functions: one which uses io_schedule() and one which just
2542 dnl # uses schedule(). This API change was made to consolidate all of those
2543 dnl # redundant wait functions.
2545 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2546 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2547 SPL_LINUX_TRY_COMPILE([
2548 #include <linux/wait.h>
2550 int (*action)(void *) = NULL;
2551 wait_on_bit(NULL, 0, action, 0);
2554 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])