2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
Support for vectorized algorithms on x86
This is initial support for x86 vectorized implementations of ZFS parity
and checksum algorithms.
For the compilation phase, configure step checks if toolchain supports relevant
instruction sets. Each implementation must ensure that the code is not passed
to compiler if relevant instruction set is not supported. For this purpose,
following new defines are provided if instruction set is supported:
- HAVE_SSE,
- HAVE_SSE2,
- HAVE_SSE3,
- HAVE_SSSE3,
- HAVE_SSE4_1,
- HAVE_SSE4_2,
- HAVE_AVX,
- HAVE_AVX2.
For detecting if an instruction set can be used in runtime, following functions
are provided in (include/linux/simd_x86.h):
- zfs_sse_available()
- zfs_sse2_available()
- zfs_sse3_available()
- zfs_ssse3_available()
- zfs_sse4_1_available()
- zfs_sse4_2_available()
- zfs_avx_available()
- zfs_avx2_available()
- zfs_bmi1_available()
- zfs_bmi2_available()
These function should be called once, on module load, or initialization.
They are safe to use from user and kernel space.
If an implementation is using more than single instruction set, both compiler
and runtime support for all relevant instruction sets should be checked.
Kernel fpu methods:
- kfpu_begin()
- kfpu_end()
Use __get_cpuid_max and __cpuid_count from <cpuid.h>
Both gcc and clang have support for these. They also handle ebx register
in case it is used for PIC code.
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #4381
2016-02-29 18:42:27 +00:00
|
|
|
dnl # Default ZFS kernel configuration
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
|
2020-04-14 18:36:28 +00:00
|
|
|
AM_COND_IF([BUILD_LINUX], [
|
|
|
|
dnl # Setup the kernel build environment.
|
|
|
|
ZFS_AC_KERNEL
|
|
|
|
ZFS_AC_QAT
|
2019-10-01 19:50:34 +00:00
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
dnl # Sanity checks for module building and CONFIG_* defines
|
|
|
|
ZFS_AC_KERNEL_TEST_MODULE
|
|
|
|
ZFS_AC_KERNEL_CONFIG_DEFINED
|
2019-10-01 19:50:34 +00:00
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
dnl # Sequential ZFS_LINUX_TRY_COMPILE tests
|
|
|
|
ZFS_AC_KERNEL_FPU_HEADER
|
2020-11-02 21:39:50 +00:00
|
|
|
ZFS_AC_KERNEL_OBJTOOL_HEADER
|
2020-04-14 18:36:28 +00:00
|
|
|
ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
|
|
|
|
ZFS_AC_KERNEL_MISC_MINOR
|
|
|
|
ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
|
2019-10-01 19:50:34 +00:00
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests
|
|
|
|
ZFS_AC_KERNEL_TEST_SRC
|
|
|
|
ZFS_AC_KERNEL_TEST_RESULT
|
2019-10-01 19:50:34 +00:00
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
|
|
|
|
KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
|
|
|
|
])
|
2019-10-01 19:50:34 +00:00
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
AC_SUBST(KERNEL_MAKE)
|
|
|
|
])
|
2019-10-01 19:50:34 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Generate and compile all of the kernel API test cases to determine
|
|
|
|
dnl # which interfaces are available. By invoking the kernel build system
|
|
|
|
dnl # only once the compilation can be done in parallel significantly
|
|
|
|
dnl # speeding up the process.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
|
|
|
|
ZFS_AC_KERNEL_SRC_OBJTOOL
|
|
|
|
ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE
|
|
|
|
ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE
|
|
|
|
ZFS_AC_KERNEL_SRC_PDE_DATA
|
|
|
|
ZFS_AC_KERNEL_SRC_FALLOCATE
|
|
|
|
ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
|
|
|
|
ZFS_AC_KERNEL_SRC_RWSEM
|
|
|
|
ZFS_AC_KERNEL_SRC_SCHED
|
|
|
|
ZFS_AC_KERNEL_SRC_USLEEP_RANGE
|
|
|
|
ZFS_AC_KERNEL_SRC_KMEM_CACHE
|
2019-07-21 17:34:07 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_KVMALLOC
|
2020-06-08 23:32:02 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_WAIT
|
|
|
|
ZFS_AC_KERNEL_SRC_INODE_TIMES
|
|
|
|
ZFS_AC_KERNEL_SRC_INODE_LOCK
|
|
|
|
ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
|
|
|
|
ZFS_AC_KERNEL_SRC_RW
|
|
|
|
ZFS_AC_KERNEL_SRC_TIMER_SETUP
|
|
|
|
ZFS_AC_KERNEL_SRC_SUPER_USER_NS
|
2020-02-06 18:30:41 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_PROC_OPERATIONS
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
|
2019-11-12 16:59:06 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_BIO
|
|
|
|
ZFS_AC_KERNEL_SRC_BLKDEV
|
|
|
|
ZFS_AC_KERNEL_SRC_BLK_QUEUE
|
2020-12-22 21:53:25 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_REVALIDATE_DISK
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_GET_DISK_RO
|
|
|
|
ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL
|
|
|
|
ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY
|
|
|
|
ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE
|
|
|
|
ZFS_AC_KERNEL_SRC_XATTR
|
|
|
|
ZFS_AC_KERNEL_SRC_ACL
|
|
|
|
ZFS_AC_KERNEL_SRC_INODE_GETATTR
|
|
|
|
ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS
|
|
|
|
ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION
|
|
|
|
ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
|
|
|
|
ZFS_AC_KERNEL_SRC_FILE_INODE
|
|
|
|
ZFS_AC_KERNEL_SRC_FILE_DENTRY
|
|
|
|
ZFS_AC_KERNEL_SRC_FSYNC
|
|
|
|
ZFS_AC_KERNEL_SRC_AIO_FSYNC
|
|
|
|
ZFS_AC_KERNEL_SRC_EVICT_INODE
|
|
|
|
ZFS_AC_KERNEL_SRC_DIRTY_INODE
|
|
|
|
ZFS_AC_KERNEL_SRC_SHRINKER
|
|
|
|
ZFS_AC_KERNEL_SRC_MKDIR_UMODE_T
|
2019-11-12 16:59:06 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS
|
|
|
|
ZFS_AC_KERNEL_SRC_CREATE_FLAGS
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_GET_LINK
|
|
|
|
ZFS_AC_KERNEL_SRC_PUT_LINK
|
|
|
|
ZFS_AC_KERNEL_SRC_TMPFILE
|
|
|
|
ZFS_AC_KERNEL_SRC_AUTOMOUNT
|
|
|
|
ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE
|
|
|
|
ZFS_AC_KERNEL_SRC_COMMIT_METADATA
|
|
|
|
ZFS_AC_KERNEL_SRC_CLEAR_INODE
|
|
|
|
ZFS_AC_KERNEL_SRC_SETATTR_PREPARE
|
|
|
|
ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED
|
|
|
|
ZFS_AC_KERNEL_SRC_DENTRY
|
|
|
|
ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
|
|
|
|
ZFS_AC_KERNEL_SRC_SECURITY_INODE
|
|
|
|
ZFS_AC_KERNEL_SRC_FST_MOUNT
|
|
|
|
ZFS_AC_KERNEL_SRC_BDI
|
|
|
|
ZFS_AC_KERNEL_SRC_SET_NLINK
|
|
|
|
ZFS_AC_KERNEL_SRC_SGET
|
|
|
|
ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE
|
|
|
|
ZFS_AC_KERNEL_SRC_VFS_GETATTR
|
|
|
|
ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
|
|
|
|
ZFS_AC_KERNEL_SRC_VFS_ITERATE
|
|
|
|
ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
|
|
|
|
ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE
|
|
|
|
ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS
|
Linux 5.10 compat: use iov_iter in uio structure
As of the 5.10 kernel the generic splice compatibility code has been
removed. All filesystems are now responsible for registering a
->splice_read and ->splice_write callback to support this operation.
The good news is the VFS provided generic_file_splice_read() and
iter_file_splice_write() callbacks can be used provided the ->iter_read
and ->iter_write callback support pipes. However, this is currently
not the case and only iovecs and bvecs (not pipes) are ever attached
to the uio structure.
This commit changes that by allowing full iov_iter structures to be
attached to uios. Ever since the 4.9 kernel the iov_iter structure
has supported iovecs, kvecs, bvevs, and pipes so it's desirable to
pass the entire thing when possible. In conjunction with this the
uio helper functions (i.e uiomove(), uiocopy(), etc) have been
updated to understand the new UIO_ITER type.
Note that using the kernel provided uio_iter interfaces allowed the
existing Linux specific uio handling code to be simplified. When
there's no longer a need to support kernel's older than 4.9, then
it will be possible to remove the iovec and bvec members from the
uio structure and always use a uio_iter. Until then we need to
maintain all of the existing types for older kernels.
Some additional refactoring and cleanup was included in this change:
- Added checks to configure to detect available iov_iter interfaces.
Some are available all the way back to the 3.10 kernel and are used
when available. In particular, uio_prefaultpages() now always uses
iov_iter_fault_in_readable() which is available for all supported
kernels.
- The unused UIO_USERISPACE type has been removed. It is no longer
needed now that the uio_seg enum is platform specific.
- Moved zfs_uio.c from the zcommon.ko module to the Linux specific
platform code for the zfs.ko module. This gets it out of libzfs
where it was never needed and keeps this Linux specific code out
of the common sources.
- Removed unnecessary O_APPEND handling from zfs_iter_write(), this
is redundant and O_APPEND is already handled in zfs_write();
NOTE: Cleanly applying this kernel compatibility change required
applying the following commits. This makes the change larger than
it absolutely needs to be, but the resulting code matches what's in
the branch branch. This is both more tested and makes it easier to
apply any future backports in this area.
7cf4cd824 Remove incorrect assertion
783be694f Reduce confusion in zfs_write
af5626ac2 Return EFAULT at the end of zfs_write() when set
cc1f85be8 Simplify offset and length limit in zfs_write
9585538d0 Const some unchanging variables in zfs_write
86e74dc16 Remove redundant oid parameter to update_pages
b3d723fb0 Factor uid, gid, and projid out of loop in zfs_write
3d40b6554 Share zfs_fsync, zfs_read, zfs_write, et al between Linux and FreeBSD
Reviewed-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11351
2020-12-18 16:48:26 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_VFS_IOV_ITER
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
|
|
|
|
ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
|
|
|
|
ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN
|
|
|
|
ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT
|
|
|
|
ZFS_AC_KERNEL_SRC_FPU
|
|
|
|
ZFS_AC_KERNEL_SRC_FMODE_T
|
|
|
|
ZFS_AC_KERNEL_SRC_KUIDGID_T
|
|
|
|
ZFS_AC_KERNEL_SRC_KUID_HELPERS
|
|
|
|
ZFS_AC_KERNEL_SRC_MODULE_PARAM_CALL_CONST
|
|
|
|
ZFS_AC_KERNEL_SRC_RENAME_WANTS_FLAGS
|
|
|
|
ZFS_AC_KERNEL_SRC_CURRENT_TIME
|
|
|
|
ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
|
|
|
|
ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
|
2020-02-26 20:42:33 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_KTIME
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
|
|
|
|
ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
|
|
|
|
ZFS_AC_KERNEL_SRC_KSTRTOUL
|
2020-06-27 01:06:50 +00:00
|
|
|
ZFS_AC_KERNEL_SRC_PERCPU
|
2019-10-01 19:50:34 +00:00
|
|
|
|
|
|
|
AC_MSG_CHECKING([for available kernel interfaces])
|
|
|
|
ZFS_LINUX_TEST_COMPILE_ALL([kabi])
|
|
|
|
AC_MSG_RESULT([done])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Check results of kernel interface tests.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
|
|
|
|
ZFS_AC_KERNEL_ACCESS_OK_TYPE
|
|
|
|
ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
|
2017-03-07 20:59:31 +00:00
|
|
|
ZFS_AC_KERNEL_OBJTOOL
|
2018-02-16 01:53:18 +00:00
|
|
|
ZFS_AC_KERNEL_PDE_DATA
|
|
|
|
ZFS_AC_KERNEL_FALLOCATE
|
|
|
|
ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_RWSEM
|
|
|
|
ZFS_AC_KERNEL_SCHED
|
2018-02-16 01:53:18 +00:00
|
|
|
ZFS_AC_KERNEL_USLEEP_RANGE
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_KMEM_CACHE
|
2019-07-21 17:34:07 +00:00
|
|
|
ZFS_AC_KERNEL_KVMALLOC
|
2020-06-08 23:32:02 +00:00
|
|
|
ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_WAIT
|
2018-06-20 04:51:18 +00:00
|
|
|
ZFS_AC_KERNEL_INODE_TIMES
|
2018-02-16 01:53:18 +00:00
|
|
|
ZFS_AC_KERNEL_INODE_LOCK
|
|
|
|
ZFS_AC_KERNEL_GROUP_INFO_GID
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_RW
|
2019-05-23 21:40:28 +00:00
|
|
|
ZFS_AC_KERNEL_TIMER_SETUP
|
2016-08-03 17:19:04 +00:00
|
|
|
ZFS_AC_KERNEL_SUPER_USER_NS
|
2020-02-06 18:30:41 +00:00
|
|
|
ZFS_AC_KERNEL_PROC_OPERATIONS
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
|
2019-11-12 16:59:06 +00:00
|
|
|
ZFS_AC_KERNEL_BIO
|
|
|
|
ZFS_AC_KERNEL_BLKDEV
|
|
|
|
ZFS_AC_KERNEL_BLK_QUEUE
|
2020-12-22 21:53:25 +00:00
|
|
|
ZFS_AC_KERNEL_REVALIDATE_DISK
|
2010-08-26 18:22:58 +00:00
|
|
|
ZFS_AC_KERNEL_GET_DISK_RO
|
2016-12-30 22:03:59 +00:00
|
|
|
ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
|
2012-08-01 08:29:59 +00:00
|
|
|
ZFS_AC_KERNEL_DISCARD_GRANULARITY
|
2013-10-28 16:22:15 +00:00
|
|
|
ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_XATTR
|
|
|
|
ZFS_AC_KERNEL_ACL
|
|
|
|
ZFS_AC_KERNEL_INODE_GETATTR
|
2016-12-16 21:54:51 +00:00
|
|
|
ZFS_AC_KERNEL_INODE_SET_FLAGS
|
2018-02-08 22:27:59 +00:00
|
|
|
ZFS_AC_KERNEL_INODE_SET_IVERSION
|
2012-02-02 19:55:48 +00:00
|
|
|
ZFS_AC_KERNEL_SHOW_OPTIONS
|
2015-02-07 12:41:01 +00:00
|
|
|
ZFS_AC_KERNEL_FILE_INODE
|
2016-08-04 15:57:35 +00:00
|
|
|
ZFS_AC_KERNEL_FILE_DENTRY
|
2011-11-10 04:47:59 +00:00
|
|
|
ZFS_AC_KERNEL_FSYNC
|
2016-11-15 17:20:46 +00:00
|
|
|
ZFS_AC_KERNEL_AIO_FSYNC
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_EVICT_INODE
|
|
|
|
ZFS_AC_KERNEL_DIRTY_INODE
|
|
|
|
ZFS_AC_KERNEL_SHRINKER
|
2012-08-16 23:31:54 +00:00
|
|
|
ZFS_AC_KERNEL_MKDIR_UMODE_T
|
2019-11-12 16:59:06 +00:00
|
|
|
ZFS_AC_KERNEL_LOOKUP_FLAGS
|
|
|
|
ZFS_AC_KERNEL_CREATE_FLAGS
|
2016-01-14 18:25:10 +00:00
|
|
|
ZFS_AC_KERNEL_GET_LINK
|
2015-07-15 17:54:26 +00:00
|
|
|
ZFS_AC_KERNEL_PUT_LINK
|
2016-01-26 20:29:46 +00:00
|
|
|
ZFS_AC_KERNEL_TMPFILE
|
2011-11-11 07:15:53 +00:00
|
|
|
ZFS_AC_KERNEL_AUTOMOUNT
|
2012-07-23 17:55:48 +00:00
|
|
|
ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
|
2012-09-16 06:03:04 +00:00
|
|
|
ZFS_AC_KERNEL_COMMIT_METADATA
|
2012-07-23 18:39:25 +00:00
|
|
|
ZFS_AC_KERNEL_CLEAR_INODE
|
2016-10-18 23:49:23 +00:00
|
|
|
ZFS_AC_KERNEL_SETATTR_PREPARE
|
2011-03-22 16:55:09 +00:00
|
|
|
ZFS_AC_KERNEL_INSERT_INODE_LOCKED
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_DENTRY
|
2011-06-25 12:30:29 +00:00
|
|
|
ZFS_AC_KERNEL_TRUNCATE_SETSIZE
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SECURITY_INODE
|
2018-04-12 19:24:38 +00:00
|
|
|
ZFS_AC_KERNEL_FST_MOUNT
|
2017-05-02 16:46:18 +00:00
|
|
|
ZFS_AC_KERNEL_BDI
|
2011-12-16 21:15:12 +00:00
|
|
|
ZFS_AC_KERNEL_SET_NLINK
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_SGET
|
2013-06-13 17:51:09 +00:00
|
|
|
ZFS_AC_KERNEL_LSEEK_EXECUTE
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_VFS_GETATTR
|
|
|
|
ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
|
2013-08-07 12:53:45 +00:00
|
|
|
ZFS_AC_KERNEL_VFS_ITERATE
|
2018-08-27 17:04:21 +00:00
|
|
|
ZFS_AC_KERNEL_VFS_DIRECT_IO
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_VFS_RW_ITERATE
|
|
|
|
ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS
|
Linux 5.10 compat: use iov_iter in uio structure
As of the 5.10 kernel the generic splice compatibility code has been
removed. All filesystems are now responsible for registering a
->splice_read and ->splice_write callback to support this operation.
The good news is the VFS provided generic_file_splice_read() and
iter_file_splice_write() callbacks can be used provided the ->iter_read
and ->iter_write callback support pipes. However, this is currently
not the case and only iovecs and bvecs (not pipes) are ever attached
to the uio structure.
This commit changes that by allowing full iov_iter structures to be
attached to uios. Ever since the 4.9 kernel the iov_iter structure
has supported iovecs, kvecs, bvevs, and pipes so it's desirable to
pass the entire thing when possible. In conjunction with this the
uio helper functions (i.e uiomove(), uiocopy(), etc) have been
updated to understand the new UIO_ITER type.
Note that using the kernel provided uio_iter interfaces allowed the
existing Linux specific uio handling code to be simplified. When
there's no longer a need to support kernel's older than 4.9, then
it will be possible to remove the iovec and bvec members from the
uio structure and always use a uio_iter. Until then we need to
maintain all of the existing types for older kernels.
Some additional refactoring and cleanup was included in this change:
- Added checks to configure to detect available iov_iter interfaces.
Some are available all the way back to the 3.10 kernel and are used
when available. In particular, uio_prefaultpages() now always uses
iov_iter_fault_in_readable() which is available for all supported
kernels.
- The unused UIO_USERISPACE type has been removed. It is no longer
needed now that the uio_seg enum is platform specific.
- Moved zfs_uio.c from the zcommon.ko module to the Linux specific
platform code for the zfs.ko module. This gets it out of libzfs
where it was never needed and keeps this Linux specific code out
of the common sources.
- Removed unnecessary O_APPEND handling from zfs_iter_write(), this
is redundant and O_APPEND is already handled in zfs_write();
NOTE: Cleanly applying this kernel compatibility change required
applying the following commits. This makes the change larger than
it absolutely needs to be, but the resulting code matches what's in
the branch branch. This is both more tested and makes it easier to
apply any future backports in this area.
7cf4cd824 Remove incorrect assertion
783be694f Reduce confusion in zfs_write
af5626ac2 Return EFAULT at the end of zfs_write() when set
cc1f85be8 Simplify offset and length limit in zfs_write
9585538d0 Const some unchanging variables in zfs_write
86e74dc16 Remove redundant oid parameter to update_pages
b3d723fb0 Factor uid, gid, and projid out of loop in zfs_write
3d40b6554 Share zfs_fsync, zfs_read, zfs_write, et al between Linux and FreeBSD
Reviewed-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11351
2020-12-18 16:48:26 +00:00
|
|
|
ZFS_AC_KERNEL_VFS_IOV_ITER
|
2015-05-11 14:22:56 +00:00
|
|
|
ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
|
2015-04-24 23:21:13 +00:00
|
|
|
ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
|
zvol processing should use struct bio
Internally, zvols are files exposed through the block device API. This
is intended to reduce overhead when things require block devices.
However, the ZoL zvol code emulates a traditional block device in that
it has a top half and a bottom half. This is an unnecessary source of
overhead that does not exist on any other OpenZFS platform does this.
This patch removes it. Early users of this patch reported double digit
performance gains in IOPS on zvols in the range of 50% to 80%.
Comments in the code suggest that the current implementation was done to
obtain IO merging from Linux's IO elevator. However, the DMU already
does write merging while arc_read() should implicitly merge read IOs
because only 1 thread is permitted to fetch the buffer into ARC. In
addition, commercial ZFSOnLinux distributions report that regular files
are more performant than zvols under the current implementation, and the
main consumers of zvols are VMs and iSCSI targets, which have their own
elevators to merge IOs.
Some minor refactoring allows us to register zfs_request() as our
->make_request() handler in place of the generic_make_request()
function. This eliminates the layer of code that broke IO requests on
zvols into a top half and a bottom half. This has several benefits:
1. No per zvol spinlocks.
2. No redundant IO elevator processing.
3. Interrupts are disabled only when actually necessary.
4. No redispatching of IOs when all taskq threads are busy.
5. Linux's page out routines will properly block.
6. Many autotools checks become obsolete.
An unfortunate consequence of eliminating the layer that
generic_make_request() is that we no longer calls the instrumentation
hooks for block IO accounting. Those hooks are GPL-exported, so we
cannot call them ourselves and consequently, we lose the ability to do
IO monitoring via iostat. Since zvols are internally files mapped as
block devices, this should be okay. Anyone who is willing to accept the
performance penalty for the block IO layer's accounting could use the
loop device in between the zvol and its consumer. Alternatively, perf
and ftrace likely could be used. Also, tools like latencytop will still
work. Tools such as latencytop sometimes provide a better view of
performance bottlenecks than the traditional block IO accounting tools
do.
Lastly, if direct reclaim occurs during spacemap loading and swap is on
a zvol, this code will deadlock. That deadlock could already occur with
sync=always on zvols. Given that swap on zvols is not yet production
ready, this is not a blocker.
Signed-off-by: Richard Yao <ryao@gentoo.org>
2014-07-04 22:43:47 +00:00
|
|
|
ZFS_AC_KERNEL_MAKE_REQUEST_FN
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_GENERIC_IO_ACCT
|
Support for vectorized algorithms on x86
This is initial support for x86 vectorized implementations of ZFS parity
and checksum algorithms.
For the compilation phase, configure step checks if toolchain supports relevant
instruction sets. Each implementation must ensure that the code is not passed
to compiler if relevant instruction set is not supported. For this purpose,
following new defines are provided if instruction set is supported:
- HAVE_SSE,
- HAVE_SSE2,
- HAVE_SSE3,
- HAVE_SSSE3,
- HAVE_SSE4_1,
- HAVE_SSE4_2,
- HAVE_AVX,
- HAVE_AVX2.
For detecting if an instruction set can be used in runtime, following functions
are provided in (include/linux/simd_x86.h):
- zfs_sse_available()
- zfs_sse2_available()
- zfs_sse3_available()
- zfs_ssse3_available()
- zfs_sse4_1_available()
- zfs_sse4_2_available()
- zfs_avx_available()
- zfs_avx2_available()
- zfs_bmi1_available()
- zfs_bmi2_available()
These function should be called once, on module load, or initialization.
They are safe to use from user and kernel space.
If an implementation is using more than single instruction set, both compiler
and runtime support for all relevant instruction sets should be checked.
Kernel fpu methods:
- kfpu_begin()
- kfpu_end()
Use __get_cpuid_max and __cpuid_count from <cpuid.h>
Both gcc and clang have support for these. They also handle ebx register
in case it is used for PIC code.
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #4381
2016-02-29 18:42:27 +00:00
|
|
|
ZFS_AC_KERNEL_FPU
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_AC_KERNEL_FMODE_T
|
|
|
|
ZFS_AC_KERNEL_KUIDGID_T
|
2016-05-30 17:37:36 +00:00
|
|
|
ZFS_AC_KERNEL_KUID_HELPERS
|
2016-08-21 19:29:49 +00:00
|
|
|
ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
|
2016-10-19 18:19:01 +00:00
|
|
|
ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
|
2017-05-10 16:30:48 +00:00
|
|
|
ZFS_AC_KERNEL_CURRENT_TIME
|
2018-03-07 23:40:42 +00:00
|
|
|
ZFS_AC_KERNEL_USERNS_CAPABILITIES
|
2018-09-25 00:11:25 +00:00
|
|
|
ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
|
2020-02-26 20:42:33 +00:00
|
|
|
ZFS_AC_KERNEL_KTIME
|
2019-01-10 22:28:10 +00:00
|
|
|
ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
|
2019-05-04 23:40:48 +00:00
|
|
|
ZFS_AC_KERNEL_TOTALHIGH_PAGES
|
2019-05-24 19:26:18 +00:00
|
|
|
ZFS_AC_KERNEL_KSTRTOUL
|
2020-06-27 01:06:50 +00:00
|
|
|
ZFS_AC_KERNEL_PERCPU
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Detect name used for Module.symvers file in kernel
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
|
|
|
|
modpost=$LINUX/scripts/Makefile.modpost
|
|
|
|
AC_MSG_CHECKING([kernel file name for module symbols])
|
2012-07-17 08:36:43 +00:00
|
|
|
AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([grep -q Modules.symvers $modpost], [
|
2010-08-26 18:22:58 +00:00
|
|
|
LINUX_SYMBOLS=Modules.symvers
|
2011-08-24 16:52:16 +00:00
|
|
|
], [
|
2010-08-26 18:22:58 +00:00
|
|
|
LINUX_SYMBOLS=Module.symvers
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2011-03-07 21:03:48 +00:00
|
|
|
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
|
2011-03-07 21:03:48 +00:00
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Please make sure the kernel devel package for your distribution
|
2019-10-01 19:50:34 +00:00
|
|
|
*** is installed. If you are building with a custom kernel, make sure
|
|
|
|
*** the kernel is configured, built, and the '--with-linux=PATH'
|
|
|
|
*** configure option refers to the location of the kernel source.
|
|
|
|
])
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
|
|
|
], [
|
2010-08-26 18:22:58 +00:00
|
|
|
LINUX_SYMBOLS=NONE
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
AC_MSG_RESULT($LINUX_SYMBOLS)
|
|
|
|
AC_SUBST(LINUX_SYMBOLS)
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Detect the kernel to be built against
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_KERNEL], [
|
|
|
|
AC_ARG_WITH([linux],
|
|
|
|
AS_HELP_STRING([--with-linux=PATH],
|
|
|
|
[Path to kernel source]),
|
|
|
|
[kernelsrc="$withval"])
|
|
|
|
|
|
|
|
AC_ARG_WITH(linux-obj,
|
|
|
|
AS_HELP_STRING([--with-linux-obj=PATH],
|
|
|
|
[Path to kernel build objects]),
|
|
|
|
[kernelbuild="$withval"])
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([kernel source directory])
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test -z "$kernelsrc"], [
|
|
|
|
AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
|
2011-02-10 22:54:33 +00:00
|
|
|
headersdir="/lib/modules/$(uname -r)/source"
|
|
|
|
sourcelink=$(readlink -f "$headersdir")
|
2011-08-24 16:52:16 +00:00
|
|
|
], [test -e "/lib/modules/$(uname -r)/build"], [
|
2011-02-10 22:54:33 +00:00
|
|
|
headersdir="/lib/modules/$(uname -r)/build"
|
2010-08-26 18:22:58 +00:00
|
|
|
sourcelink=$(readlink -f "$headersdir")
|
2011-08-24 16:52:16 +00:00
|
|
|
], [
|
2010-08-26 18:22:58 +00:00
|
|
|
sourcelink=$(ls -1d /usr/src/kernels/* \
|
2011-08-24 16:52:16 +00:00
|
|
|
/usr/src/linux-* \
|
2010-08-26 18:22:58 +00:00
|
|
|
2>/dev/null | grep -v obj | tail -1)
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
|
2010-08-26 18:22:58 +00:00
|
|
|
kernelsrc=`readlink -f ${sourcelink}`
|
2011-08-24 16:52:16 +00:00
|
|
|
], [
|
2012-11-30 04:19:25 +00:00
|
|
|
kernelsrc="[Not found]"
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
|
|
|
], [
|
|
|
|
AS_IF([test "$kernelsrc" = "NONE"], [
|
2010-08-26 18:22:58 +00:00
|
|
|
kernsrcver=NONE
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2017-05-24 23:02:04 +00:00
|
|
|
withlinux=yes
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
|
|
|
|
AC_MSG_RESULT([$kernelsrc])
|
2012-11-30 04:19:25 +00:00
|
|
|
AS_IF([test ! -d "$kernelsrc"], [
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Please make sure the kernel devel package for your distribution
|
2013-03-30 02:27:50 +00:00
|
|
|
*** is installed and then try again. If that fails, you can specify the
|
2012-11-30 04:19:25 +00:00
|
|
|
*** location of the kernel source with the '--with-linux=PATH' option.])
|
|
|
|
])
|
|
|
|
|
2010-08-26 18:22:58 +00:00
|
|
|
AC_MSG_CHECKING([kernel build directory])
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test -z "$kernelbuild"], [
|
2017-05-24 23:02:04 +00:00
|
|
|
AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
|
2011-02-10 22:54:33 +00:00
|
|
|
kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
|
2011-08-24 16:52:16 +00:00
|
|
|
], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
|
2010-08-26 18:22:58 +00:00
|
|
|
kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
|
2011-08-24 16:52:16 +00:00
|
|
|
], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
|
2012-07-25 21:38:58 +00:00
|
|
|
kernelbuild=${kernelsrc}-obj/${target_cpu}/default
|
2011-08-24 16:52:16 +00:00
|
|
|
], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
|
2010-08-26 18:22:58 +00:00
|
|
|
kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
|
2011-08-24 16:52:16 +00:00
|
|
|
], [
|
2010-08-26 18:22:58 +00:00
|
|
|
kernelbuild=${kernelsrc}
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
AC_MSG_RESULT([$kernelbuild])
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([kernel source version])
|
|
|
|
utsrelease1=$kernelbuild/include/linux/version.h
|
|
|
|
utsrelease2=$kernelbuild/include/linux/utsrelease.h
|
|
|
|
utsrelease3=$kernelbuild/include/generated/utsrelease.h
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
|
2010-08-26 18:22:58 +00:00
|
|
|
utsrelease=linux/version.h
|
2011-08-24 16:52:16 +00:00
|
|
|
], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
|
2010-08-26 18:22:58 +00:00
|
|
|
utsrelease=linux/utsrelease.h
|
2011-08-24 16:52:16 +00:00
|
|
|
], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
|
2010-08-26 18:22:58 +00:00
|
|
|
utsrelease=generated/utsrelease.h
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test "$utsrelease"], [
|
2010-08-26 18:22:58 +00:00
|
|
|
kernsrcver=`(echo "#include <$utsrelease>";
|
|
|
|
echo "kernsrcver=UTS_RELEASE") |
|
2018-12-05 17:31:44 +00:00
|
|
|
${CPP} -I $kernelbuild/include - |
|
2010-08-26 18:22:58 +00:00
|
|
|
grep "^kernsrcver=" | cut -d \" -f 2`
|
|
|
|
|
2011-08-24 16:52:16 +00:00
|
|
|
AS_IF([test -z "$kernsrcver"], [
|
2010-08-26 18:22:58 +00:00
|
|
|
AC_MSG_RESULT([Not found])
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Cannot determine kernel version.
|
|
|
|
])
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
|
|
|
], [
|
2010-08-26 18:22:58 +00:00
|
|
|
AC_MSG_RESULT([Not found])
|
2012-07-17 08:36:43 +00:00
|
|
|
if test "x$enable_linux_builtin" != xyes; then
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Cannot find UTS_RELEASE definition.
|
|
|
|
])
|
2012-07-17 08:36:43 +00:00
|
|
|
else
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Cannot find UTS_RELEASE definition.
|
|
|
|
*** Please run 'make prepare' inside the kernel source tree.])
|
|
|
|
fi
|
2011-08-24 16:52:16 +00:00
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
|
|
|
|
AC_MSG_RESULT([$kernsrcver])
|
|
|
|
|
2019-11-12 16:59:06 +00:00
|
|
|
AS_VERSION_COMPARE([$kernsrcver], [$ZFS_META_KVER_MIN], [
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Cannot build against kernel version $kernsrcver.
|
|
|
|
*** The minimum supported kernel version is $ZFS_META_KVER_MIN.
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2010-08-26 18:22:58 +00:00
|
|
|
LINUX=${kernelsrc}
|
|
|
|
LINUX_OBJ=${kernelbuild}
|
|
|
|
LINUX_VERSION=${kernsrcver}
|
|
|
|
|
|
|
|
AC_SUBST(LINUX)
|
|
|
|
AC_SUBST(LINUX_OBJ)
|
|
|
|
AC_SUBST(LINUX_VERSION)
|
|
|
|
|
|
|
|
ZFS_AC_MODULE_SYMVERS
|
|
|
|
])
|
|
|
|
|
2017-03-23 00:58:47 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Detect the QAT module to be built against, QAT provides hardware
|
|
|
|
dnl # acceleration for data compression:
|
|
|
|
dnl #
|
|
|
|
dnl # https://01.org/intel-quickassist-technology
|
|
|
|
dnl #
|
|
|
|
dnl # 1) Download and install QAT driver from the above link
|
|
|
|
dnl # 2) Start QAT driver in your system:
|
|
|
|
dnl # service qat_service start
|
|
|
|
dnl # 3) Enable QAT in ZFS, e.g.:
|
|
|
|
dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
|
|
|
|
dnl # make
|
|
|
|
dnl # 4) Set GZIP compression in ZFS dataset:
|
|
|
|
dnl # zfs set compression = gzip <dataset>
|
|
|
|
dnl #
|
|
|
|
dnl # Then the data written to this ZFS pool is compressed by QAT accelerator
|
|
|
|
dnl # automatically, and de-compressed by QAT when read from the pool.
|
|
|
|
dnl #
|
|
|
|
dnl # 1) Get QAT hardware statistics with:
|
|
|
|
dnl # cat /proc/icp_dh895xcc_dev/qat
|
|
|
|
dnl # 2) To disable QAT:
|
|
|
|
dnl # insmod zfs.ko zfs_qat_disable=1
|
2017-03-23 00:58:47 +00:00
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_QAT], [
|
|
|
|
AC_ARG_WITH([qat],
|
|
|
|
AS_HELP_STRING([--with-qat=PATH],
|
|
|
|
[Path to qat source]),
|
|
|
|
AS_IF([test "$withval" = "yes"],
|
|
|
|
AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
|
|
|
|
[qatsrc="$withval"]))
|
|
|
|
|
|
|
|
AC_ARG_WITH([qat-obj],
|
|
|
|
AS_HELP_STRING([--with-qat-obj=PATH],
|
|
|
|
[Path to qat build objects]),
|
|
|
|
[qatbuild="$withval"])
|
|
|
|
|
|
|
|
AS_IF([test ! -z "${qatsrc}"], [
|
|
|
|
AC_MSG_CHECKING([qat source directory])
|
|
|
|
AC_MSG_RESULT([$qatsrc])
|
|
|
|
QAT_SRC="${qatsrc}/quickassist"
|
|
|
|
AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
|
|
|
|
AC_MSG_ERROR([
|
2019-10-01 19:50:34 +00:00
|
|
|
*** Please make sure the qat driver package is installed
|
|
|
|
*** and specify the location of the qat source with the
|
|
|
|
*** '--with-qat=PATH' option then try again. Failed to
|
|
|
|
*** find cpa.h in:
|
|
|
|
${QAT_SRC}/include])
|
2017-03-23 00:58:47 +00:00
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
AS_IF([test ! -z "${qatsrc}"], [
|
|
|
|
AC_MSG_CHECKING([qat build directory])
|
|
|
|
AS_IF([test -z "$qatbuild"], [
|
|
|
|
qatbuild="${qatsrc}/build"
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_MSG_RESULT([$qatbuild])
|
|
|
|
QAT_OBJ=${qatbuild}
|
2017-10-20 18:11:25 +00:00
|
|
|
AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
|
2017-03-23 00:58:47 +00:00
|
|
|
AC_MSG_ERROR([
|
2019-10-01 19:50:34 +00:00
|
|
|
*** Please make sure the qat driver is installed then try again.
|
|
|
|
*** Failed to find icp_qa_al.ko or qat_api.ko in:
|
|
|
|
$QAT_OBJ])
|
2017-03-23 00:58:47 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
AC_SUBST(QAT_SRC)
|
|
|
|
AC_SUBST(QAT_OBJ)
|
|
|
|
|
|
|
|
AC_DEFINE(HAVE_QAT, 1,
|
|
|
|
[qat is enabled and existed])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Detect the name used for the QAT Module.symvers file.
|
|
|
|
dnl #
|
|
|
|
AS_IF([test ! -z "${qatsrc}"], [
|
|
|
|
AC_MSG_CHECKING([qat file for module symbols])
|
|
|
|
QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
|
|
|
|
|
|
|
|
AS_IF([test -r $QAT_SYMBOLS], [
|
|
|
|
AC_MSG_RESULT([$QAT_SYMBOLS])
|
|
|
|
AC_SUBST(QAT_SYMBOLS)
|
|
|
|
],[
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Please make sure the qat driver is installed then try again.
|
|
|
|
*** Failed to find Module.symvers in:
|
|
|
|
$QAT_SYMBOLS
|
2017-03-23 00:58:47 +00:00
|
|
|
])
|
|
|
|
])
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2012-07-17 08:36:43 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Basic toolchain sanity check.
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_DEFUN([ZFS_AC_KERNEL_TEST_MODULE], [
|
2014-10-03 17:58:47 +00:00
|
|
|
AC_MSG_CHECKING([whether modules can be built])
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_LINUX_TRY_COMPILE([], [], [
|
2012-07-17 08:36:43 +00:00
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
],[
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
if test "x$enable_linux_builtin" != xyes; then
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Unable to build an empty module.
|
|
|
|
])
|
2012-07-17 08:36:43 +00:00
|
|
|
else
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Unable to build an empty module.
|
|
|
|
*** Please run 'make scripts' inside the kernel source tree.])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2011-03-07 18:59:26 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_CONFTEST_H
|
2011-03-07 18:59:26 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
|
|
|
|
test -d build/$2 || mkdir -p build/$2
|
|
|
|
cat - <<_ACEOF >build/$2/$2.h
|
|
|
|
$1
|
|
|
|
_ACEOF
|
|
|
|
])
|
2012-05-21 19:59:58 +00:00
|
|
|
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl #
|
|
|
|
dnl # ZFS_LINUX_CONFTEST_C
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
|
|
|
|
test -d build/$2 || mkdir -p build/$2
|
|
|
|
cat confdefs.h - <<_ACEOF >build/$2/$2.c
|
|
|
|
$1
|
|
|
|
_ACEOF
|
2012-05-21 19:59:58 +00:00
|
|
|
])
|
|
|
|
|
2015-12-02 19:53:37 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_CONFTEST_MAKEFILE
|
2015-12-02 19:53:37 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # $1 - test case name
|
|
|
|
dnl # $2 - add to top-level Makefile
|
|
|
|
dnl # $3 - additional build flags
|
2015-12-02 19:53:37 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
|
|
|
|
test -d build || mkdir -p build
|
|
|
|
test -d build/$1 || mkdir -p build/$1
|
|
|
|
|
|
|
|
file=build/$1/Makefile
|
|
|
|
|
|
|
|
dnl # Example command line to manually build source.
|
|
|
|
cat - <<_ACEOF >$file
|
|
|
|
# Example command line to manually build source
|
|
|
|
# make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
|
|
|
|
|
|
|
|
ccflags-y := -Werror $FRAME_LARGER_THAN
|
|
|
|
_ACEOF
|
|
|
|
|
|
|
|
dnl # Additional custom CFLAGS as requested.
|
|
|
|
m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
|
|
|
|
|
|
|
|
dnl # Test case source
|
|
|
|
echo "obj-m := $1.o" >>$file
|
|
|
|
|
|
|
|
AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], [])
|
2015-12-02 19:53:37 +00:00
|
|
|
])
|
|
|
|
|
2012-05-21 19:59:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY])
|
2012-05-21 19:59:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
m4_define([ZFS_LINUX_TEST_PROGRAM], [
|
2020-12-23 19:40:02 +00:00
|
|
|
#include <linux/module.h>
|
2019-10-01 19:50:34 +00:00
|
|
|
$1
|
2020-12-23 19:40:02 +00:00
|
|
|
|
2019-10-01 19:50:34 +00:00
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
$2
|
|
|
|
;
|
|
|
|
return 0;
|
|
|
|
}
|
2020-12-23 19:40:02 +00:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("conftest");
|
|
|
|
MODULE_AUTHOR(ZFS_META_AUTHOR);
|
|
|
|
MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
|
|
|
|
MODULE_LICENSE($3);
|
2019-10-01 19:50:34 +00:00
|
|
|
])
|
|
|
|
|
2012-05-21 19:59:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_REMOVE
|
2012-05-21 19:59:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Removes the specified test source and results.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [
|
|
|
|
test -d build/$1 && rm -Rf build/$1
|
|
|
|
test -f build/Makefile && sed '/$1/d' build/Makefile
|
|
|
|
])
|
2012-05-21 19:59:58 +00:00
|
|
|
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl #
|
|
|
|
dnl # ZFS_LINUX_COMPILE
|
|
|
|
dnl #
|
|
|
|
dnl # $1 - build dir
|
|
|
|
dnl # $2 - test command
|
|
|
|
dnl # $3 - pass command
|
|
|
|
dnl # $4 - fail command
|
|
|
|
dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes'
|
|
|
|
dnl # $6 - set KBUILD_MODPOST_WARN='yes'
|
|
|
|
dnl #
|
|
|
|
dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST}
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_COMPILE], [
|
|
|
|
AC_TRY_COMMAND([
|
|
|
|
KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
|
|
|
|
make modules -k -j$TEST_JOBS -C $LINUX_OBJ $ARCH_UM
|
2020-02-14 16:30:29 +00:00
|
|
|
M=$PWD/$1 >$1/build.log 2>&1])
|
2019-10-01 19:50:34 +00:00
|
|
|
AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_COMPILE
|
2018-02-16 01:53:18 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Perform a full compile excluding the final modpost phase.
|
2018-02-16 01:53:18 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [
|
|
|
|
ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
|
|
|
|
mv $2/Makefile $2/Makefile.compile.$1
|
|
|
|
mv $2/build.log $2/build.log.$1
|
2018-02-16 01:53:18 +00:00
|
|
|
],[
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Unable to compile test source to determine kernel interfaces.])
|
|
|
|
], [yes], [])
|
2018-02-16 01:53:18 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_MODPOST
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Perform a full compile including the modpost phase. This may
|
|
|
|
dnl # be an incremental build if the objects have already been built.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [
|
|
|
|
ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
|
|
|
|
mv $2/Makefile $2/Makefile.modpost.$1
|
|
|
|
cat $2/build.log >>build/build.log.$1
|
|
|
|
],[
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** Unable to modpost test source to determine kernel interfaces.])
|
|
|
|
], [], [yes])
|
Swap DTRACE_PROBE* with Linux tracepoints
This patch leverages Linux tracepoints from within the ZFS on Linux
code base. It also refactors the debug code to bring it back in sync
with Illumos.
The information exported via tracepoints can be used for a variety of
reasons (e.g. debugging, tuning, general exploration/understanding,
etc). It is advantageous to use Linux tracepoints as the mechanism to
export this kind of information (as opposed to something else) for a
number of reasons:
* A number of external tools can make use of our tracepoints
"automatically" (e.g. perf, systemtap)
* Tracepoints are designed to be extremely cheap when disabled
* It's one of the "accepted" ways to export this kind of
information; many other kernel subsystems use tracepoints too.
Unfortunately, though, there are a few caveats as well:
* Linux tracepoints appear to only be available to GPL licensed
modules due to the way certain kernel functions are exported.
Thus, to actually make use of the tracepoints introduced by this
patch, one might have to patch and re-compile the kernel;
exporting the necessary functions to non-GPL modules.
* Prior to upstream kernel version v3.14-rc6-30-g66cc69e, Linux
tracepoints are not available for unsigned kernel modules
(tracepoints will get disabled due to the module's 'F' taint).
Thus, one either has to sign the zfs kernel module prior to
loading it, or use a kernel versioned v3.14-rc6-30-g66cc69e or
newer.
Assuming the above two requirements are satisfied, lets look at an
example of how this patch can be used and what information it exposes
(all commands run as 'root'):
# list all zfs tracepoints available
$ ls /sys/kernel/debug/tracing/events/zfs
enable filter zfs_arc__delete
zfs_arc__evict zfs_arc__hit zfs_arc__miss
zfs_l2arc__evict zfs_l2arc__hit zfs_l2arc__iodone
zfs_l2arc__miss zfs_l2arc__read zfs_l2arc__write
zfs_new_state__mfu zfs_new_state__mru
# enable all zfs tracepoints, clear the tracepoint ring buffer
$ echo 1 > /sys/kernel/debug/tracing/events/zfs/enable
$ echo 0 > /sys/kernel/debug/tracing/trace
# import zpool called 'tank', inspect tracepoint data (each line was
# truncated, they're too long for a commit message otherwise)
$ zpool import tank
$ cat /sys/kernel/debug/tracing/trace | head -n35
# tracer: nop
#
# entries-in-buffer/entries-written: 1219/1219 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss: hdr...
z_rd_int/0-30156 [003] .... 91344.200611: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201173: zfs_arc__miss: hdr...
z_rd_int/1-30157 [003] .... 91344.201756: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201795: zfs_arc__miss: hdr...
z_rd_int/2-30158 [003] .... 91344.202099: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202126: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202130: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202134: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202146: zfs_arc__miss: hdr...
z_rd_int/3-30159 [003] .... 91344.202457: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202484: zfs_arc__miss: hdr...
z_rd_int/4-30160 [003] .... 91344.202866: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202891: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203034: zfs_arc__miss: hdr...
z_rd_iss/1-30149 [001] .... 91344.203749: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.203789: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203878: zfs_arc__miss: hdr...
z_rd_iss/3-30151 [001] .... 91344.204315: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.204332: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204337: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204352: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204356: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204360: zfs_arc__hit: hdr ...
To highlight the kind of detailed information that is being exported
using this infrastructure, I've taken the first tracepoint line from the
output above and reformatted it such that it fits in 80 columns:
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss:
hdr {
dva 0x1:0x40082
birth 15491
cksum0 0x163edbff3a
flags 0x640
datacnt 1
type 1
size 2048
spa 3133524293419867460
state_type 0
access 0
mru_hits 0
mru_ghost_hits 0
mfu_hits 0
mfu_ghost_hits 0
l2_hits 0
refcount 1
} bp {
dva0 0x1:0x40082
dva1 0x1:0x3000e5
dva2 0x1:0x5a006e
cksum 0x163edbff3a:0x75af30b3dd6:0x1499263ff5f2b:0x288bd118815e00
lsize 2048
} zb {
objset 0
object 0
level -1
blkid 0
}
For the specific tracepoint shown here, 'zfs_arc__miss', data is
exported detailing the arc_buf_hdr_t (hdr), blkptr_t (bp), and
zbookmark_t (zb) that caused the ARC miss (down to the exact DVA!).
This kind of precise and detailed information can be extremely valuable
when trying to answer certain kinds of questions.
For anybody unfamiliar but looking to build on this, I found the XFS
source code along with the following three web links to be extremely
helpful:
* http://lwn.net/Articles/379903/
* http://lwn.net/Articles/381064/
* http://lwn.net/Articles/383362/
I should also node the more "boring" aspects of this patch:
* The ZFS_LINUX_COMPILE_IFELSE autoconf macro was modified to
support a sixth paramter. This parameter is used to populate the
contents of the new conftest.h file. If no sixth parameter is
provided, conftest.h will be empty.
* The ZFS_LINUX_TRY_COMPILE_HEADER autoconf macro was introduced.
This macro is nearly identical to the ZFS_LINUX_TRY_COMPILE macro,
except it has support for a fifth option that is then passed as
the sixth parameter to ZFS_LINUX_COMPILE_IFELSE.
These autoconf changes were needed to test the availability of the Linux
tracepoint macros. Due to the odd nature of the Linux tracepoint macro
API, a separate ".h" must be created (the path and filename is used
internally by the kernel's define_trace.h file).
* The HAVE_DECLARE_EVENT_CLASS autoconf macro was introduced. This
is to determine if we can safely enable the Linux tracepoint
functionality. We need to selectively disable the tracepoint code
due to the kernel exporting certain functions as GPL only. Without
this check, the build process will fail at link time.
In addition, the SET_ERROR macro was modified into a tracepoint as well.
To do this, the 'sdt.h' file was moved into the 'include/sys' directory
and now contains a userspace portion and a kernel space portion. The
dprintf and zfs_dbgmsg* interfaces are now implemented as tracepoint as
well.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2014-06-13 17:54:48 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Perform the compilation of the test cases in two phases.
|
Swap DTRACE_PROBE* with Linux tracepoints
This patch leverages Linux tracepoints from within the ZFS on Linux
code base. It also refactors the debug code to bring it back in sync
with Illumos.
The information exported via tracepoints can be used for a variety of
reasons (e.g. debugging, tuning, general exploration/understanding,
etc). It is advantageous to use Linux tracepoints as the mechanism to
export this kind of information (as opposed to something else) for a
number of reasons:
* A number of external tools can make use of our tracepoints
"automatically" (e.g. perf, systemtap)
* Tracepoints are designed to be extremely cheap when disabled
* It's one of the "accepted" ways to export this kind of
information; many other kernel subsystems use tracepoints too.
Unfortunately, though, there are a few caveats as well:
* Linux tracepoints appear to only be available to GPL licensed
modules due to the way certain kernel functions are exported.
Thus, to actually make use of the tracepoints introduced by this
patch, one might have to patch and re-compile the kernel;
exporting the necessary functions to non-GPL modules.
* Prior to upstream kernel version v3.14-rc6-30-g66cc69e, Linux
tracepoints are not available for unsigned kernel modules
(tracepoints will get disabled due to the module's 'F' taint).
Thus, one either has to sign the zfs kernel module prior to
loading it, or use a kernel versioned v3.14-rc6-30-g66cc69e or
newer.
Assuming the above two requirements are satisfied, lets look at an
example of how this patch can be used and what information it exposes
(all commands run as 'root'):
# list all zfs tracepoints available
$ ls /sys/kernel/debug/tracing/events/zfs
enable filter zfs_arc__delete
zfs_arc__evict zfs_arc__hit zfs_arc__miss
zfs_l2arc__evict zfs_l2arc__hit zfs_l2arc__iodone
zfs_l2arc__miss zfs_l2arc__read zfs_l2arc__write
zfs_new_state__mfu zfs_new_state__mru
# enable all zfs tracepoints, clear the tracepoint ring buffer
$ echo 1 > /sys/kernel/debug/tracing/events/zfs/enable
$ echo 0 > /sys/kernel/debug/tracing/trace
# import zpool called 'tank', inspect tracepoint data (each line was
# truncated, they're too long for a commit message otherwise)
$ zpool import tank
$ cat /sys/kernel/debug/tracing/trace | head -n35
# tracer: nop
#
# entries-in-buffer/entries-written: 1219/1219 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss: hdr...
z_rd_int/0-30156 [003] .... 91344.200611: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201173: zfs_arc__miss: hdr...
z_rd_int/1-30157 [003] .... 91344.201756: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201795: zfs_arc__miss: hdr...
z_rd_int/2-30158 [003] .... 91344.202099: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202126: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202130: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202134: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202146: zfs_arc__miss: hdr...
z_rd_int/3-30159 [003] .... 91344.202457: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202484: zfs_arc__miss: hdr...
z_rd_int/4-30160 [003] .... 91344.202866: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202891: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203034: zfs_arc__miss: hdr...
z_rd_iss/1-30149 [001] .... 91344.203749: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.203789: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203878: zfs_arc__miss: hdr...
z_rd_iss/3-30151 [001] .... 91344.204315: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.204332: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204337: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204352: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204356: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204360: zfs_arc__hit: hdr ...
To highlight the kind of detailed information that is being exported
using this infrastructure, I've taken the first tracepoint line from the
output above and reformatted it such that it fits in 80 columns:
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss:
hdr {
dva 0x1:0x40082
birth 15491
cksum0 0x163edbff3a
flags 0x640
datacnt 1
type 1
size 2048
spa 3133524293419867460
state_type 0
access 0
mru_hits 0
mru_ghost_hits 0
mfu_hits 0
mfu_ghost_hits 0
l2_hits 0
refcount 1
} bp {
dva0 0x1:0x40082
dva1 0x1:0x3000e5
dva2 0x1:0x5a006e
cksum 0x163edbff3a:0x75af30b3dd6:0x1499263ff5f2b:0x288bd118815e00
lsize 2048
} zb {
objset 0
object 0
level -1
blkid 0
}
For the specific tracepoint shown here, 'zfs_arc__miss', data is
exported detailing the arc_buf_hdr_t (hdr), blkptr_t (bp), and
zbookmark_t (zb) that caused the ARC miss (down to the exact DVA!).
This kind of precise and detailed information can be extremely valuable
when trying to answer certain kinds of questions.
For anybody unfamiliar but looking to build on this, I found the XFS
source code along with the following three web links to be extremely
helpful:
* http://lwn.net/Articles/379903/
* http://lwn.net/Articles/381064/
* http://lwn.net/Articles/383362/
I should also node the more "boring" aspects of this patch:
* The ZFS_LINUX_COMPILE_IFELSE autoconf macro was modified to
support a sixth paramter. This parameter is used to populate the
contents of the new conftest.h file. If no sixth parameter is
provided, conftest.h will be empty.
* The ZFS_LINUX_TRY_COMPILE_HEADER autoconf macro was introduced.
This macro is nearly identical to the ZFS_LINUX_TRY_COMPILE macro,
except it has support for a fifth option that is then passed as
the sixth parameter to ZFS_LINUX_COMPILE_IFELSE.
These autoconf changes were needed to test the availability of the Linux
tracepoint macros. Due to the odd nature of the Linux tracepoint macro
API, a separate ".h" must be created (the path and filename is used
internally by the kernel's define_trace.h file).
* The HAVE_DECLARE_EVENT_CLASS autoconf macro was introduced. This
is to determine if we can safely enable the Linux tracepoint
functionality. We need to selectively disable the tracepoint code
due to the kernel exporting certain functions as GPL only. Without
this check, the build process will fail at link time.
In addition, the SET_ERROR macro was modified into a tracepoint as well.
To do this, the 'sdt.h' file was moved into the 'include/sys' directory
and now contains a userspace portion and a kernel space portion. The
dprintf and zfs_dbgmsg* interfaces are now implemented as tracepoint as
well.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2014-06-13 17:54:48 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Phase 1) attempt to build the object files for all of the tests
|
|
|
|
dnl # defined by the ZFS_LINUX_TEST_SRC macro. But do not
|
|
|
|
dnl # perform the final modpost stage.
|
|
|
|
dnl #
|
|
|
|
dnl # Phase 2) disable all tests which failed the initial compilation,
|
|
|
|
dnl # then invoke the final modpost step for the remaining tests.
|
|
|
|
dnl #
|
|
|
|
dnl # This allows us efficiently build the test cases in parallel while
|
|
|
|
dnl # remaining resilient to build failures which are expected when
|
|
|
|
dnl # detecting the available kernel interfaces.
|
|
|
|
dnl #
|
|
|
|
dnl # The maximum allowed parallelism can be controlled by setting the
|
|
|
|
dnl # TEST_JOBS environment variable. Otherwise, it default to $(nproc).
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [
|
|
|
|
dnl # Phase 1 - Compilation only, final linking is skipped.
|
|
|
|
ZFS_LINUX_TEST_COMPILE([$1], [build])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Phase 2 - When building external modules disable test cases
|
|
|
|
dnl # which failed to compile and invoke modpost to verify the
|
|
|
|
dnl # final linking.
|
|
|
|
dnl #
|
|
|
|
dnl # Test names suffixed with '_license' call modpost independently
|
|
|
|
dnl # to ensure that a single incompatibility does not result in the
|
|
|
|
dnl # modpost phase exiting early. This check is not performed on
|
|
|
|
dnl # every symbol since the majority are compatible and doing so
|
|
|
|
dnl # would significantly slow down this phase.
|
|
|
|
dnl #
|
|
|
|
dnl # When configuring for builtin (--enable-linux-builtin)
|
|
|
|
dnl # fake the linking step artificially create the expected .ko
|
|
|
|
dnl # files for tests which did compile. This is required for
|
|
|
|
dnl # kernels which do not have loadable module support or have
|
|
|
|
dnl # not yet been built.
|
|
|
|
dnl #
|
|
|
|
AS_IF([test "x$enable_linux_builtin" = "xno"], [
|
|
|
|
for dir in $(awk '/^obj-m/ { print [$]3 }' \
|
|
|
|
build/Makefile.compile.$1); do
|
|
|
|
name=${dir%/}
|
|
|
|
AS_IF([test -f build/$name/$name.o], [
|
|
|
|
AS_IF([test "${name##*_}" = "license"], [
|
|
|
|
ZFS_LINUX_TEST_MODPOST([$1],
|
|
|
|
[build/$name])
|
|
|
|
echo "obj-n += $dir" >>build/Makefile
|
|
|
|
], [
|
|
|
|
echo "obj-m += $dir" >>build/Makefile
|
|
|
|
])
|
|
|
|
], [
|
|
|
|
echo "obj-n += $dir" >>build/Makefile
|
|
|
|
])
|
|
|
|
done
|
|
|
|
|
|
|
|
ZFS_LINUX_TEST_MODPOST([$1], [build])
|
|
|
|
], [
|
|
|
|
for dir in $(awk '/^obj-m/ { print [$]3 }' \
|
|
|
|
build/Makefile.compile.$1); do
|
|
|
|
name=${dir%/}
|
|
|
|
AS_IF([test -f build/$name/$name.o], [
|
|
|
|
touch build/$name/$name.ko
|
|
|
|
])
|
|
|
|
done
|
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_SRC
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # $1 - name
|
|
|
|
dnl # $2 - global
|
|
|
|
dnl # $3 - source
|
|
|
|
dnl # $4 - extra cflags
|
|
|
|
dnl # $5 - check license-compatibility
|
|
|
|
dnl #
|
2020-12-23 19:40:02 +00:00
|
|
|
dnl # Check if the test source is buildable at all and then if it is
|
|
|
|
dnl # license compatible.
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # N.B because all of the test cases are compiled in parallel they
|
|
|
|
dnl # must never depend on the results of previous tests. Each test
|
|
|
|
dnl # needs to be entirely independent.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_SRC], [
|
2020-12-23 19:40:02 +00:00
|
|
|
ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]],
|
|
|
|
[["Dual BSD/GPL"]])], [$1])
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4])
|
|
|
|
|
|
|
|
AS_IF([ test -n "$5" ], [
|
2020-12-23 19:40:02 +00:00
|
|
|
ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM(
|
|
|
|
[[$2]], [[$3]], [[$5]])], [$1_license])
|
2019-10-01 19:50:34 +00:00
|
|
|
ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4])
|
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_RESULT
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC)
|
|
|
|
dnl # $2 - run on success (valid .ko generated)
|
|
|
|
dnl # $3 - run on failure (unable to compile)
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_RESULT], [
|
|
|
|
AS_IF([test -d build/$1], [
|
|
|
|
AS_IF([test -f build/$1/$1.ko], [$2], [$3])
|
|
|
|
], [
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** No matching source for the "$1" test, check that
|
|
|
|
*** both the test source and result macros refer to the same name.
|
|
|
|
])
|
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_ERROR
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Generic error message which can be used when none of the expected
|
|
|
|
dnl # kernel interfaces were detected.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_ERROR], [
|
|
|
|
AC_MSG_ERROR([
|
|
|
|
*** None of the expected "$1" interfaces were detected.
|
|
|
|
*** This may be because your kernel version is newer than what is
|
|
|
|
*** supported, or you are using a patched custom kernel with
|
|
|
|
*** incompatible modifications.
|
|
|
|
***
|
|
|
|
*** ZFS Version: $ZFS_META_ALIAS
|
|
|
|
*** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
|
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # ZFS_LINUX_TEST_RESULT_SYMBOL
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to
|
|
|
|
dnl # verify symbol exports, unless --enable-linux-builtin was provided to
|
|
|
|
dnl # configure.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [
|
|
|
|
AS_IF([ ! test -f build/$1/$1.ko], [
|
|
|
|
$5
|
|
|
|
], [
|
|
|
|
AS_IF([test "x$enable_linux_builtin" != "xyes"], [
|
|
|
|
ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5])
|
|
|
|
], [
|
|
|
|
$4
|
|
|
|
])
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl #
|
|
|
|
dnl # ZFS_LINUX_COMPILE_IFELSE
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
|
|
|
|
ZFS_LINUX_TEST_REMOVE([conftest])
|
|
|
|
|
|
|
|
m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])])
|
|
|
|
m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])],
|
|
|
|
[ZFS_LINUX_CONFTEST_H([], [conftest])])
|
|
|
|
|
|
|
|
ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no],
|
|
|
|
[m4_ifvaln([$5], [-I$PWD/build/conftest], [])])
|
|
|
|
ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], [])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # ZFS_LINUX_TRY_COMPILE
|
|
|
|
dnl #
|
|
|
|
dnl # $1 - global
|
|
|
|
dnl # $2 - source
|
|
|
|
dnl # $3 - run on success (valid .ko generated)
|
|
|
|
dnl # $4 - run on failure (unable to compile)
|
|
|
|
dnl #
|
2020-02-28 17:23:48 +00:00
|
|
|
dnl # When configuring as builtin (--enable-linux-builtin) for kernels
|
|
|
|
dnl # without loadable module support (CONFIG_MODULES=n) only the object
|
|
|
|
dnl # file is created. See ZFS_LINUX_TEST_COMPILE_ALL for details.
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [
|
2020-02-28 17:23:48 +00:00
|
|
|
AS_IF([test "x$enable_linux_builtin" = "xyes"], [
|
|
|
|
ZFS_LINUX_COMPILE_IFELSE(
|
2020-12-23 19:40:02 +00:00
|
|
|
[ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
|
|
|
|
[[ZFS_META_LICENSE]])],
|
2020-02-28 17:23:48 +00:00
|
|
|
[test -f build/conftest/conftest.o], [$3], [$4])
|
|
|
|
], [
|
|
|
|
ZFS_LINUX_COMPILE_IFELSE(
|
2020-12-23 19:40:02 +00:00
|
|
|
[ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
|
|
|
|
[[ZFS_META_LICENSE]])],
|
2020-02-28 17:23:48 +00:00
|
|
|
[test -f build/conftest/conftest.ko], [$3], [$4])
|
|
|
|
])
|
2019-10-01 19:50:34 +00:00
|
|
|
])
|
|
|
|
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
|
|
|
dnl # ZFS_CHECK_SYMBOL_EXPORT
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Check if a symbol is exported on not by consulting the symbols
|
|
|
|
dnl # file, or optionally the source code.
|
2010-08-26 18:22:58 +00:00
|
|
|
dnl #
|
2012-07-25 21:38:58 +00:00
|
|
|
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
|
2010-08-26 18:22:58 +00:00
|
|
|
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
|
|
|
|
$LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
|
|
|
|
rc=$?
|
2012-07-25 21:38:58 +00:00
|
|
|
if test $rc -ne 0; then
|
2010-08-26 18:22:58 +00:00
|
|
|
export=0
|
|
|
|
for file in $2; do
|
2012-07-25 21:38:58 +00:00
|
|
|
grep -q -E "EXPORT_SYMBOL.*($1)" \
|
|
|
|
"$LINUX/$file" 2>/dev/null
|
2010-08-26 18:22:58 +00:00
|
|
|
rc=$?
|
2012-07-25 21:38:58 +00:00
|
|
|
if test $rc -eq 0; then
|
2011-08-24 16:52:16 +00:00
|
|
|
export=1
|
|
|
|
break;
|
2012-07-25 21:38:58 +00:00
|
|
|
fi
|
2010-08-26 18:22:58 +00:00
|
|
|
done
|
2012-07-25 21:38:58 +00:00
|
|
|
if test $export -eq 0; then :
|
2010-08-26 18:22:58 +00:00
|
|
|
$4
|
2012-07-25 21:38:58 +00:00
|
|
|
else :
|
2010-08-26 18:22:58 +00:00
|
|
|
$3
|
2012-07-25 21:38:58 +00:00
|
|
|
fi
|
|
|
|
else :
|
2010-08-26 18:22:58 +00:00
|
|
|
$3
|
2012-07-25 21:38:58 +00:00
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
|
2019-10-01 19:50:34 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called
|
|
|
|
dnl # to verify symbol exports, unless --enable-linux-builtin was provided
|
|
|
|
dnl # to configure.
|
2012-07-25 21:38:58 +00:00
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
|
|
|
|
ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
|
|
|
|
if test $rc -ne 0; then :
|
|
|
|
$6
|
|
|
|
else
|
|
|
|
if test "x$enable_linux_builtin" != xyes; then
|
|
|
|
ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
|
|
|
|
fi
|
|
|
|
if test $rc -ne 0; then :
|
|
|
|
$6
|
|
|
|
else :
|
|
|
|
$5
|
|
|
|
fi
|
|
|
|
fi
|
2010-08-26 18:22:58 +00:00
|
|
|
])
|
Swap DTRACE_PROBE* with Linux tracepoints
This patch leverages Linux tracepoints from within the ZFS on Linux
code base. It also refactors the debug code to bring it back in sync
with Illumos.
The information exported via tracepoints can be used for a variety of
reasons (e.g. debugging, tuning, general exploration/understanding,
etc). It is advantageous to use Linux tracepoints as the mechanism to
export this kind of information (as opposed to something else) for a
number of reasons:
* A number of external tools can make use of our tracepoints
"automatically" (e.g. perf, systemtap)
* Tracepoints are designed to be extremely cheap when disabled
* It's one of the "accepted" ways to export this kind of
information; many other kernel subsystems use tracepoints too.
Unfortunately, though, there are a few caveats as well:
* Linux tracepoints appear to only be available to GPL licensed
modules due to the way certain kernel functions are exported.
Thus, to actually make use of the tracepoints introduced by this
patch, one might have to patch and re-compile the kernel;
exporting the necessary functions to non-GPL modules.
* Prior to upstream kernel version v3.14-rc6-30-g66cc69e, Linux
tracepoints are not available for unsigned kernel modules
(tracepoints will get disabled due to the module's 'F' taint).
Thus, one either has to sign the zfs kernel module prior to
loading it, or use a kernel versioned v3.14-rc6-30-g66cc69e or
newer.
Assuming the above two requirements are satisfied, lets look at an
example of how this patch can be used and what information it exposes
(all commands run as 'root'):
# list all zfs tracepoints available
$ ls /sys/kernel/debug/tracing/events/zfs
enable filter zfs_arc__delete
zfs_arc__evict zfs_arc__hit zfs_arc__miss
zfs_l2arc__evict zfs_l2arc__hit zfs_l2arc__iodone
zfs_l2arc__miss zfs_l2arc__read zfs_l2arc__write
zfs_new_state__mfu zfs_new_state__mru
# enable all zfs tracepoints, clear the tracepoint ring buffer
$ echo 1 > /sys/kernel/debug/tracing/events/zfs/enable
$ echo 0 > /sys/kernel/debug/tracing/trace
# import zpool called 'tank', inspect tracepoint data (each line was
# truncated, they're too long for a commit message otherwise)
$ zpool import tank
$ cat /sys/kernel/debug/tracing/trace | head -n35
# tracer: nop
#
# entries-in-buffer/entries-written: 1219/1219 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss: hdr...
z_rd_int/0-30156 [003] .... 91344.200611: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201173: zfs_arc__miss: hdr...
z_rd_int/1-30157 [003] .... 91344.201756: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201795: zfs_arc__miss: hdr...
z_rd_int/2-30158 [003] .... 91344.202099: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202126: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202130: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202134: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202146: zfs_arc__miss: hdr...
z_rd_int/3-30159 [003] .... 91344.202457: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202484: zfs_arc__miss: hdr...
z_rd_int/4-30160 [003] .... 91344.202866: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202891: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203034: zfs_arc__miss: hdr...
z_rd_iss/1-30149 [001] .... 91344.203749: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.203789: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203878: zfs_arc__miss: hdr...
z_rd_iss/3-30151 [001] .... 91344.204315: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.204332: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204337: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204352: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204356: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204360: zfs_arc__hit: hdr ...
To highlight the kind of detailed information that is being exported
using this infrastructure, I've taken the first tracepoint line from the
output above and reformatted it such that it fits in 80 columns:
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss:
hdr {
dva 0x1:0x40082
birth 15491
cksum0 0x163edbff3a
flags 0x640
datacnt 1
type 1
size 2048
spa 3133524293419867460
state_type 0
access 0
mru_hits 0
mru_ghost_hits 0
mfu_hits 0
mfu_ghost_hits 0
l2_hits 0
refcount 1
} bp {
dva0 0x1:0x40082
dva1 0x1:0x3000e5
dva2 0x1:0x5a006e
cksum 0x163edbff3a:0x75af30b3dd6:0x1499263ff5f2b:0x288bd118815e00
lsize 2048
} zb {
objset 0
object 0
level -1
blkid 0
}
For the specific tracepoint shown here, 'zfs_arc__miss', data is
exported detailing the arc_buf_hdr_t (hdr), blkptr_t (bp), and
zbookmark_t (zb) that caused the ARC miss (down to the exact DVA!).
This kind of precise and detailed information can be extremely valuable
when trying to answer certain kinds of questions.
For anybody unfamiliar but looking to build on this, I found the XFS
source code along with the following three web links to be extremely
helpful:
* http://lwn.net/Articles/379903/
* http://lwn.net/Articles/381064/
* http://lwn.net/Articles/383362/
I should also node the more "boring" aspects of this patch:
* The ZFS_LINUX_COMPILE_IFELSE autoconf macro was modified to
support a sixth paramter. This parameter is used to populate the
contents of the new conftest.h file. If no sixth parameter is
provided, conftest.h will be empty.
* The ZFS_LINUX_TRY_COMPILE_HEADER autoconf macro was introduced.
This macro is nearly identical to the ZFS_LINUX_TRY_COMPILE macro,
except it has support for a fifth option that is then passed as
the sixth parameter to ZFS_LINUX_COMPILE_IFELSE.
These autoconf changes were needed to test the availability of the Linux
tracepoint macros. Due to the odd nature of the Linux tracepoint macro
API, a separate ".h" must be created (the path and filename is used
internally by the kernel's define_trace.h file).
* The HAVE_DECLARE_EVENT_CLASS autoconf macro was introduced. This
is to determine if we can safely enable the Linux tracepoint
functionality. We need to selectively disable the tracepoint code
due to the kernel exporting certain functions as GPL only. Without
this check, the build process will fail at link time.
In addition, the SET_ERROR macro was modified into a tracepoint as well.
To do this, the 'sdt.h' file was moved into the 'include/sys' directory
and now contains a userspace portion and a kernel space portion. The
dprintf and zfs_dbgmsg* interfaces are now implemented as tracepoint as
well.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2014-06-13 17:54:48 +00:00
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # ZFS_LINUX_TRY_COMPILE_HEADER
|
|
|
|
dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
|
|
|
|
dnl # provided via the fifth parameter
|
|
|
|
dnl #
|
2019-10-01 19:50:34 +00:00
|
|
|
AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [
|
|
|
|
ZFS_LINUX_COMPILE_IFELSE(
|
2020-12-23 19:40:02 +00:00
|
|
|
[ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]], [[ZFS_META_LICENSE]])],
|
2019-10-01 19:50:34 +00:00
|
|
|
[test -f build/conftest/conftest.ko],
|
|
|
|
[$3], [$4], [$5])
|
Swap DTRACE_PROBE* with Linux tracepoints
This patch leverages Linux tracepoints from within the ZFS on Linux
code base. It also refactors the debug code to bring it back in sync
with Illumos.
The information exported via tracepoints can be used for a variety of
reasons (e.g. debugging, tuning, general exploration/understanding,
etc). It is advantageous to use Linux tracepoints as the mechanism to
export this kind of information (as opposed to something else) for a
number of reasons:
* A number of external tools can make use of our tracepoints
"automatically" (e.g. perf, systemtap)
* Tracepoints are designed to be extremely cheap when disabled
* It's one of the "accepted" ways to export this kind of
information; many other kernel subsystems use tracepoints too.
Unfortunately, though, there are a few caveats as well:
* Linux tracepoints appear to only be available to GPL licensed
modules due to the way certain kernel functions are exported.
Thus, to actually make use of the tracepoints introduced by this
patch, one might have to patch and re-compile the kernel;
exporting the necessary functions to non-GPL modules.
* Prior to upstream kernel version v3.14-rc6-30-g66cc69e, Linux
tracepoints are not available for unsigned kernel modules
(tracepoints will get disabled due to the module's 'F' taint).
Thus, one either has to sign the zfs kernel module prior to
loading it, or use a kernel versioned v3.14-rc6-30-g66cc69e or
newer.
Assuming the above two requirements are satisfied, lets look at an
example of how this patch can be used and what information it exposes
(all commands run as 'root'):
# list all zfs tracepoints available
$ ls /sys/kernel/debug/tracing/events/zfs
enable filter zfs_arc__delete
zfs_arc__evict zfs_arc__hit zfs_arc__miss
zfs_l2arc__evict zfs_l2arc__hit zfs_l2arc__iodone
zfs_l2arc__miss zfs_l2arc__read zfs_l2arc__write
zfs_new_state__mfu zfs_new_state__mru
# enable all zfs tracepoints, clear the tracepoint ring buffer
$ echo 1 > /sys/kernel/debug/tracing/events/zfs/enable
$ echo 0 > /sys/kernel/debug/tracing/trace
# import zpool called 'tank', inspect tracepoint data (each line was
# truncated, they're too long for a commit message otherwise)
$ zpool import tank
$ cat /sys/kernel/debug/tracing/trace | head -n35
# tracer: nop
#
# entries-in-buffer/entries-written: 1219/1219 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss: hdr...
z_rd_int/0-30156 [003] .... 91344.200611: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201173: zfs_arc__miss: hdr...
z_rd_int/1-30157 [003] .... 91344.201756: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.201795: zfs_arc__miss: hdr...
z_rd_int/2-30158 [003] .... 91344.202099: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202126: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202130: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202134: zfs_arc__hit: hdr ...
lt-zpool-30132 [003] .... 91344.202146: zfs_arc__miss: hdr...
z_rd_int/3-30159 [003] .... 91344.202457: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202484: zfs_arc__miss: hdr...
z_rd_int/4-30160 [003] .... 91344.202866: zfs_new_state__mru...
lt-zpool-30132 [003] .... 91344.202891: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203034: zfs_arc__miss: hdr...
z_rd_iss/1-30149 [001] .... 91344.203749: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.203789: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.203878: zfs_arc__miss: hdr...
z_rd_iss/3-30151 [001] .... 91344.204315: zfs_new_state__mru...
lt-zpool-30132 [001] .... 91344.204332: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204337: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204352: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204356: zfs_arc__hit: hdr ...
lt-zpool-30132 [001] .... 91344.204360: zfs_arc__hit: hdr ...
To highlight the kind of detailed information that is being exported
using this infrastructure, I've taken the first tracepoint line from the
output above and reformatted it such that it fits in 80 columns:
lt-zpool-30132 [003] .... 91344.200050: zfs_arc__miss:
hdr {
dva 0x1:0x40082
birth 15491
cksum0 0x163edbff3a
flags 0x640
datacnt 1
type 1
size 2048
spa 3133524293419867460
state_type 0
access 0
mru_hits 0
mru_ghost_hits 0
mfu_hits 0
mfu_ghost_hits 0
l2_hits 0
refcount 1
} bp {
dva0 0x1:0x40082
dva1 0x1:0x3000e5
dva2 0x1:0x5a006e
cksum 0x163edbff3a:0x75af30b3dd6:0x1499263ff5f2b:0x288bd118815e00
lsize 2048
} zb {
objset 0
object 0
level -1
blkid 0
}
For the specific tracepoint shown here, 'zfs_arc__miss', data is
exported detailing the arc_buf_hdr_t (hdr), blkptr_t (bp), and
zbookmark_t (zb) that caused the ARC miss (down to the exact DVA!).
This kind of precise and detailed information can be extremely valuable
when trying to answer certain kinds of questions.
For anybody unfamiliar but looking to build on this, I found the XFS
source code along with the following three web links to be extremely
helpful:
* http://lwn.net/Articles/379903/
* http://lwn.net/Articles/381064/
* http://lwn.net/Articles/383362/
I should also node the more "boring" aspects of this patch:
* The ZFS_LINUX_COMPILE_IFELSE autoconf macro was modified to
support a sixth paramter. This parameter is used to populate the
contents of the new conftest.h file. If no sixth parameter is
provided, conftest.h will be empty.
* The ZFS_LINUX_TRY_COMPILE_HEADER autoconf macro was introduced.
This macro is nearly identical to the ZFS_LINUX_TRY_COMPILE macro,
except it has support for a fifth option that is then passed as
the sixth parameter to ZFS_LINUX_COMPILE_IFELSE.
These autoconf changes were needed to test the availability of the Linux
tracepoint macros. Due to the odd nature of the Linux tracepoint macro
API, a separate ".h" must be created (the path and filename is used
internally by the kernel's define_trace.h file).
* The HAVE_DECLARE_EVENT_CLASS autoconf macro was introduced. This
is to determine if we can safely enable the Linux tracepoint
functionality. We need to selectively disable the tracepoint code
due to the kernel exporting certain functions as GPL only. Without
this check, the build process will fail at link time.
In addition, the SET_ERROR macro was modified into a tracepoint as well.
To do this, the 'sdt.h' file was moved into the 'include/sys' directory
and now contains a userspace portion and a kernel space portion. The
dprintf and zfs_dbgmsg* interfaces are now implemented as tracepoint as
well.
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2014-06-13 17:54:48 +00:00
|
|
|
])
|