Skip to content

Commit

Permalink
Detect HAVE_LARGE_STACKS at compile time (openzfs#12384)
Browse files Browse the repository at this point in the history
Move HAVE_LARGE_STACKS definitions to header and set when appropriate.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Kevin Bowling <[email protected]>
Closes openzfs#12350
  • Loading branch information
kev009 authored Aug 19, 2021
1 parent 4f92fe0 commit ec6a6e8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 32 deletions.
1 change: 0 additions & 1 deletion config/Rules.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ AM_CPPFLAGS = -D_GNU_SOURCE
AM_CPPFLAGS += -D_REENTRANT
AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64
AM_CPPFLAGS += -D_LARGEFILE64_SOURCE
AM_CPPFLAGS += -DHAVE_LARGE_STACKS=1
AM_CPPFLAGS += -DLIBEXECDIR=\"$(libexecdir)\"
AM_CPPFLAGS += -DRUNSTATEDIR=\"$(runstatedir)\"
AM_CPPFLAGS += -DSBINDIR=\"$(sbindir)\"
Expand Down
31 changes: 0 additions & 31 deletions config/kernel-config-defined.m4
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [
])
])
ZFS_AC_KERNEL_SRC_CONFIG_THREAD_SIZE
ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC
ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS
ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE
Expand All @@ -29,42 +28,12 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [
ZFS_LINUX_TEST_COMPILE_ALL([config])
AC_MSG_RESULT([done])
ZFS_AC_KERNEL_CONFIG_THREAD_SIZE
ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS
ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE
ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE
])

dnl #
dnl # Check configured THREAD_SIZE
dnl #
dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64
dnl # the default thread stack size was increased to 16K from 8K. Therefore,
dnl # on newer kernels and some architectures stack usage optimizations can be
dnl # conditionally applied to improve performance without negatively impacting
dnl # stability.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_THREAD_SIZE], [
ZFS_LINUX_TEST_SRC([config_thread_size], [
#include <linux/module.h>
],[
#if (THREAD_SIZE < 16384)
#error "THREAD_SIZE is less than 16K"
#endif
])
])

AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [
AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks])
ZFS_LINUX_TEST_RESULT([config_thread_size], [
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks])
],[
AC_MSG_RESULT([no])
])
])

dnl #
dnl # Check CONFIG_DEBUG_LOCK_ALLOC
dnl #
Expand Down
4 changes: 4 additions & 0 deletions include/os/freebsd/zfs/sys/zfs_context_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include <sys/ccompat.h>
#include <linux/types.h>

#if KSTACK_PAGES * PAGE_SIZE >= 16384
#define HAVE_LARGE_STACKS 1
#endif

#define cond_resched() kern_yield(PRI_USER)

#define taskq_create_sysdc(a, b, d, e, p, dc, f) \
Expand Down
5 changes: 5 additions & 0 deletions include/os/linux/zfs/sys/zfs_context_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@

#include <linux/dcache_compat.h>
#include <linux/utsname_compat.h>
#include <linux/module.h>

#if THREAD_SIZE >= 16384
#define HAVE_LARGE_STACKS 1
#endif

#endif
1 change: 1 addition & 0 deletions lib/libspl/include/os/freebsd/sys/zfs_context_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#ifndef ZFS_CONTEXT_OS_H_
#define ZFS_CONTEXT_OS_H_

#define HAVE_LARGE_STACKS 1
#define ZFS_EXPORTS_PATH "/etc/zfs/exports"

#endif
3 changes: 3 additions & 0 deletions lib/libspl/include/os/linux/sys/zfs_context_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@

#ifndef ZFS_CONTEXT_OS_H
#define ZFS_CONTEXT_OS_H

#define HAVE_LARGE_STACKS 1

#endif

0 comments on commit ec6a6e8

Please sign in to comment.