])
dnl #
-dnl # 2.6.14 API change,
-dnl # check whether 'div64_64()' is available
-dnl #
+dnl # 2.6.22 API change,
+dnl # First introduced 'div64_64()' in lib/div64.c
+dnl
AC_DEFUN([SPL_AC_DIV64_64], [
- AC_MSG_CHECKING([whether div64_64() is available])
- SPL_LINUX_TRY_COMPILE([
- #include <asm/div64.h>
- #include <linux/types.h>
- ],[
- uint64_t i = div64_64(1ULL, 1ULL);
- ],[
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_DIV64_64, 1, [div64_64() is available])
- ],[
- AC_MSG_RESULT(no)
- ])
+ SPL_CHECK_SYMBOL_EXPORT(
+ [div64_64],
+ [],
+ [AC_DEFINE(HAVE_DIV64_64, 1,
+ [div64_64() is available])],
+ [])
+])
+
+dnl #
+dnl # 2.6.26 API change,
+dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
+dnl #
+AC_DEFUN([SPL_AC_DIV64_U64], [
+ SPL_CHECK_SYMBOL_EXPORT(
+ [div64_u64],
+ [],
+ [AC_DEFINE(HAVE_DIV64_U64, 1,
+ [div64_u64() is available])],
+ [])
])
dnl #
[])
])
+dnl #
+dnl # 2.6.18 API change,
+dnl # First introduced global_page_state() support as an inline.
+dnl #
+AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
+ AC_MSG_CHECKING([whether global_page_state() is available])
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/vmstat.h>
+ ],[
+ unsigned long state;
+ state = global_page_state(NR_FREE_PAGES);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
+ [global_page_state() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
dnl #
dnl # 2.6.21 API change,
dnl # Public global zone stats now include free/inactive/active page
- echo "$as_me:$LINENO: checking whether div64_64() is available" >&5
-echo $ECHO_N "checking whether div64_64() is available... $ECHO_C" >&6
-
-
-cat >conftest.c <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-
- #include <asm/div64.h>
- #include <linux/types.h>
-
-int
-main (void)
-{
-
- uint64_t i = div64_64(1ULL, 1ULL);
+ echo "$as_me:$LINENO: checking whether symbol div64_64 is exported" >&5
+echo $ECHO_N "checking whether symbol div64_64 is exported... $ECHO_C" >&6
+ grep -q -E '[[:space:]]div64_64[[:space:]]' $LINUX_OBJ/Module.symvers 2>/dev/null
+ rc=$?
+ if test $rc -ne 0; then
+ export=0
+ for file in ; do
+ grep -q -E "EXPORT_SYMBOL.*(div64_64)" "$LINUX_OBJ/$file" 2>/dev/null
+ rc=$?
+ if test $rc -eq 0; then
+ export=1
+ break;
+ fi
+ done
+ if test $export -eq 0; then
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
- ;
- return 0;
-}
+ else
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DIV64_64 1
_ACEOF
-
- rm -Rf build && mkdir -p build
- echo "obj-m := conftest.o" >build/Makefile
- if { ac_try='cp conftest.c build && make modules LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
+ fi
+ else
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
#define HAVE_DIV64_64 1
_ACEOF
+ fi
+
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
- echo "$as_me:$LINENO: result: no" >&5
+ echo "$as_me:$LINENO: checking whether symbol div64_u64 is exported" >&5
+echo $ECHO_N "checking whether symbol div64_u64 is exported... $ECHO_C" >&6
+ grep -q -E '[[:space:]]div64_u64[[:space:]]' $LINUX_OBJ/Module.symvers 2>/dev/null
+ rc=$?
+ if test $rc -ne 0; then
+ export=0
+ for file in ; do
+ grep -q -E "EXPORT_SYMBOL.*(div64_u64)" "$LINUX_OBJ/$file" 2>/dev/null
+ rc=$?
+ if test $rc -eq 0; then
+ export=1
+ break;
+ fi
+ done
+ if test $export -eq 0; then
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
+ else
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DIV64_U64 1
+_ACEOF
-fi
+ fi
+ else
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
- rm -Rf build
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DIV64_U64 1
+_ACEOF
+ fi
+ echo "$as_me:$LINENO: checking whether global_page_state() is available" >&5
+echo $ECHO_N "checking whether global_page_state() is available... $ECHO_C" >&6
+
+
+cat >conftest.c <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+
+ #include <linux/vmstat.h>
+
+int
+main (void)
+{
+
+ unsigned long state;
+ state = global_page_state(NR_FREE_PAGES);
+
+ ;
+ return 0;
+}
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build
+ echo "obj-m := conftest.o" >build/Makefile
+ if { ac_try='cp conftest.c build && make modules LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_GLOBAL_PAGE_STATE 1
+_ACEOF
+
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+
+fi
+
+ rm -Rf build
+
+
+
+
echo "$as_me:$LINENO: checking whether free/inactive/active page state is available" >&5
echo $ECHO_N "checking whether free/inactive/active page state is available... $ECHO_C" >&6
SPL_AC_MONOTONIC_CLOCK
SPL_AC_INODE_I_MUTEX
SPL_AC_DIV64_64
+SPL_AC_DIV64_U64
SPL_AC_3ARGS_ON_EACH_CPU
SPL_AC_KALLSYMS_LOOKUP_NAME
SPL_AC_GET_VMALLOC_INFO
SPL_AC_NEXT_ONLINE_PGDAT
SPL_AC_NEXT_ZONE
SPL_AC_GET_ZONE_COUNTS
+SPL_AC_GLOBAL_PAGE_STATE
SPL_AC_ZONE_STAT_ITEM_FIA
AC_CONFIG_FILES([
#ifndef _SPL_KALLSYMS_COMPAT_H
#define _SPL_KALLSYMS_COMPAT_H
+#define SYMBOL_POISON ((void*)0xabcddcba)
+
#ifdef HAVE_KALLSYMS_LOOKUP_NAME
#include <linux/kallsyms.h>
unsigned long *);
extern get_zone_counts_t get_zone_counts_fn;
# define get_zone_counts(a,i,f) get_zone_counts_fn(a,i,f)
+# endif /* HAVE_GET_ZONE_COUNTS */
extern unsigned long spl_global_page_state(int);
/* Defines designed to simulate enum but large enough to ensure no overlap */
# define NR_FREE_PAGES 0x8001
# define NR_INACTIVE 0x8002
# define NR_ACTIVE 0x8003
-# else
-# error "HAVE_ZONE_STAT_ITEM_FIA and HAVE_GET_ZONE_COUNTS unavailable"
-# endif /* HAVE_GET_ZONE_COUNTS */
#else
#define spl_global_page_state(item) global_page_state(item)
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
EXPORT_SYMBOL(p0);
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
-kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = NULL;
+kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = SYMBOL_POISON;
#endif
int
#if BITS_PER_LONG == 32
uint64_t __udivdi3(uint64_t dividend, uint64_t divisor)
{
-#ifdef HAVE_DIV64_64
+#if defined(HAVE_DIV64_64) /* 2.6.22 - 2.6.25 API */
return div64_64(dividend, divisor);
+#elif defined(HAVE_DIV64_U64) /* 2.6.26 - 2.6.x API */
+ return div64_u64(dividend, divisor);
#else
- /* Taken from a 2.6.24 kernel. */
+ /* Implementation from 2.6.30 kernel */
uint32_t high, d;
high = divisor >> 32;
} else
d = divisor;
- do_div(dividend, d);
-
- return dividend;
-#endif
+ return do_div64(dividend, d);
+#endif /* HAVE_DIV64_64, HAVE_DIV64_U64 */
}
EXPORT_SYMBOL(__udivdi3);
return dividend - divisor * (dividend / divisor);
}
EXPORT_SYMBOL(__umoddi3);
-#endif
+#endif /* BITS_PER_LONG */
/* NOTE: The strtoxx behavior is solely based on my reading of the Solaris
* ddi_strtol(9F) man page. I have not verified the behavior of these
* functions against their Solaris counterparts. It is possible that I
- * may have misinterpretted the man page or the man page is incorrect.
+ * may have misinterpreted the man page or the man page is incorrect.
*/
int ddi_strtoul(const char *, char **, int, unsigned long *);
int ddi_strtol(const char *, char **, int, long *);
"TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
NULL };
+ int rc;
/* Doing address resolution in the kernel is tricky and just
* not a good idea in general. So to set the proper 'hw_serial'
* use the usermodehelper support to ask '/bin/sh' to run
* '/usr/bin/hostid' and redirect the result to /proc/sys/spl/hostid
- * for us to use. It's a horific solution but it will do for now.
+ * for us to use. It's a horrific solution but it will do for now.
*/
- return call_usermodehelper(sh_path, argv, envp, 1);
+ rc = call_usermodehelper(sh_path, argv, envp, 1);
+ if (rc)
+ printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
+ argv[0], argv[1], argv[2], rc);
+
+ return rc;
}
uint32_t
}
EXPORT_SYMBOL(zone_get_hostid);
-#ifdef HAVE_KALLSYMS_LOOKUP_NAME
-#define set_kallsyms_lookup_name() (0)
-#else
+#ifndef HAVE_KALLSYMS_LOOKUP_NAME
/*
* Because kallsyms_lookup_name() is no longer exported in the
* mainline kernel we are forced to resort to somewhat drastic
rc = call_usermodehelper(sh_path, argv, envp, 1);
if (rc)
- return rc;
+ printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
+ argv[0], argv[1], argv[2], rc);
- return spl_kmem_init_kallsyms_lookup();
+ return rc;
}
#endif
if ((rc = set_hostid()))
GOTO(out7, rc = -EADDRNOTAVAIL);
+#ifndef HAVE_KALLSYMS_LOOKUP_NAME
if ((rc = set_kallsyms_lookup_name()))
GOTO(out7, rc = -EADDRNOTAVAIL);
+#endif /* HAVE_KALLSYMS_LOOKUP_NAME */
+
+ if ((rc = spl_kmem_init_kallsyms_lookup()))
+ GOTO(out7, rc);
printk("SPL: Loaded Solaris Porting Layer v%s\n", SPL_META_VERSION);
RETURN(rc);
EXPORT_SYMBOL(zio_arena);
#ifndef HAVE_GET_VMALLOC_INFO
-get_vmalloc_info_t get_vmalloc_info_fn = NULL;
+get_vmalloc_info_t get_vmalloc_info_fn = SYMBOL_POISON;
EXPORT_SYMBOL(get_vmalloc_info_fn);
#endif /* HAVE_GET_VMALLOC_INFO */
#ifndef HAVE_FIRST_ONLINE_PGDAT
-first_online_pgdat_t first_online_pgdat_fn = NULL;
+first_online_pgdat_t first_online_pgdat_fn = SYMBOL_POISON;
EXPORT_SYMBOL(first_online_pgdat_fn);
#endif /* HAVE_FIRST_ONLINE_PGDAT */
#ifndef HAVE_NEXT_ONLINE_PGDAT
-next_online_pgdat_t next_online_pgdat_fn = NULL;
+next_online_pgdat_t next_online_pgdat_fn = SYMBOL_POISON;
EXPORT_SYMBOL(next_online_pgdat_fn);
#endif /* HAVE_NEXT_ONLINE_PGDAT */
#ifndef HAVE_NEXT_ZONE
-next_zone_t next_zone_fn = NULL;
+next_zone_t next_zone_fn = SYMBOL_POISON;
EXPORT_SYMBOL(next_zone_fn);
#endif /* HAVE_NEXT_ZONE */
#ifndef HAVE_ZONE_STAT_ITEM_FIA
# ifndef HAVE_GET_ZONE_COUNTS
-get_zone_counts_t get_zone_counts_fn = NULL;
+get_zone_counts_t get_zone_counts_fn = SYMBOL_POISON;
EXPORT_SYMBOL(get_zone_counts_fn);
+# endif /* HAVE_GET_ZONE_COUNTS */
unsigned long
spl_global_page_state(int item)
return active;
}
+# ifdef HAVE_GLOBAL_PAGE_STATE
return global_page_state((enum zone_stat_item)item);
+# else
+ return 0; /* Unsupported */
+# endif /* HAVE_GLOBAL_PAGE_STATE */
}
EXPORT_SYMBOL(spl_global_page_state);
-# else
-# error "HAVE_ZONE_STAT_ITEM_FIA and HAVE_GET_ZONE_COUNTS unavailable"
-# endif /* HAVE_GET_ZONE_COUNTS */
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
pgcnt_t
}
/* Solaris default values */
- swapfs_minfree = MAX(2*1024*1024 / PAGE_SIZE, physmem / 8);
- swapfs_reserve = MIN(4*1024*1024 / PAGE_SIZE, physmem / 16);
+ swapfs_minfree = MAX(2*1024*1024 >> PAGE_SHIFT, physmem >> 3);
+ swapfs_reserve = MIN(4*1024*1024 >> PAGE_SHIFT, physmem >> 4);
}
/*
printk(KERN_ERR "Error: Unknown symbol get_zone_counts\n");
return -EFAULT;
}
-# else
-# error "HAVE_ZONE_STAT_ITEM_FIA and HAVE_GET_ZONE_COUNTS unavailable"
# endif /* HAVE_GET_ZONE_COUNTS */
#endif /* HAVE_ZONE_STAT_ITEM_FIA */
if (write) {
/* This may only be set once at module load time */
- if (spl_kallsyms_lookup_name_fn)
+ if (spl_kallsyms_lookup_name_fn != SYMBOL_POISON)
RETURN(-EEXIST);
/* We can't use proc_doulongvec_minmax() in the write
/* Deal with signed/unsigned mismatch */
return (hrtime_t)(res & ~(1ULL << 63));
#else
- int64_t j = get_jiffies_64();
+ uint64_t j = get_jiffies_64();
- return j * NSEC_PER_SEC / HZ;
+ return (hrtime_t)(j * NSEC_PER_SEC / HZ);
#endif
}
EXPORT_SYMBOL(__gethrtime);
/* Remove all odd items from the queue */
splat_vprint(file, SPLAT_LIST_TEST6_NAME,
- "Removing %d odd items from the list\n", list_size / 2);
+ "Removing %d odd items from the list\n", list_size >> 1);
for (li = list_head(&list); li != NULL; li = list_next(&list, li)) {
if (li->li_data % 2 == 1) {
li_prev = list_prev(&list, li);
/* div64_64() is available */
#undef HAVE_DIV64_64
+/* div64_u64() is available */
+#undef HAVE_DIV64_U64
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* get_zone_counts() is available */
#undef HAVE_GET_ZONE_COUNTS
+/* global_page_state() is available */
+#undef HAVE_GLOBAL_PAGE_STATE
+
/* init_utsname() is available */
#undef HAVE_INIT_UTSNAME