mirror of
https://github.com/openzfs/zfs.git
synced 2026-07-16 17:27:25 +02:00
Disconnect metaslab tracing from default builds
This code can not even be enabled without patching and has no use without some external tools. 32 additional bytes in zio_t plus their initialization/destruction is too high cost for rarely used development tool. Making it conditional under METASLAB_TRACE define reduces zio_t on FreeBSD by 64 bytes due to stucture alignment and removed the initialization from CPU profiles. Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes #18714
This commit is contained in:
@@ -218,6 +218,21 @@ AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS], [
|
||||
AC_MSG_RESULT([$enable_invariants])
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_METASLAB_TRACING], [
|
||||
AC_MSG_CHECKING([whether metaslab tracing is enabled])
|
||||
AC_ARG_ENABLE([metaslab-tracing],
|
||||
[AS_HELP_STRING([--enable-metaslab-tracing],
|
||||
[Enable metaslab tracing @<:@default=no@:>@])],
|
||||
[],
|
||||
[enable_metaslab_tracing=no])
|
||||
|
||||
AS_IF([test "x$enable_metaslab_tracing" = xyes], [
|
||||
AC_DEFINE(METASLAB_TRACE, 1, [metaslab tracing enabled])
|
||||
])
|
||||
|
||||
AC_MSG_RESULT([$enable_metaslab_tracing])
|
||||
])
|
||||
|
||||
dnl # Disabled by default. If enabled allows a configured "turn objtools
|
||||
dnl # warnings into errors" (CONFIG_OBJTOOL_WERROR) behavior to take effect.
|
||||
dnl # If disabled, objtool warnings are never turned into errors. It can't
|
||||
|
||||
@@ -66,6 +66,7 @@ ZFS_AC_DEBUGINFO
|
||||
ZFS_AC_DEBUG_KMEM
|
||||
ZFS_AC_DEBUG_KMEM_TRACKING
|
||||
ZFS_AC_DEBUG_INVARIANTS
|
||||
ZFS_AC_METASLAB_TRACING
|
||||
ZFS_AC_OBJTOOL_WERROR
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
|
||||
@@ -98,9 +98,19 @@ void metaslab_check_free(spa_t *, const blkptr_t *);
|
||||
|
||||
void metaslab_stat_init(void);
|
||||
void metaslab_stat_fini(void);
|
||||
#ifdef METASLAB_TRACE
|
||||
void metaslab_trace_move(zio_alloc_list_t *, zio_alloc_list_t *);
|
||||
void metaslab_trace_init(zio_alloc_list_t *);
|
||||
void metaslab_trace_fini(zio_alloc_list_t *);
|
||||
#else
|
||||
static inline void
|
||||
metaslab_trace_move(zio_alloc_list_t *old __maybe_unused,
|
||||
zio_alloc_list_t *dst __maybe_unused) {}
|
||||
static inline void
|
||||
metaslab_trace_init(zio_alloc_list_t *zal __maybe_unused) {}
|
||||
static inline void
|
||||
metaslab_trace_fini(zio_alloc_list_t *zal __maybe_unused) {}
|
||||
#endif
|
||||
|
||||
metaslab_class_t *metaslab_class_create(spa_t *, const char *,
|
||||
const metaslab_ops_t *, boolean_t);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef METASLAB_TRACE
|
||||
/*
|
||||
* Metaslab allocation tracing record.
|
||||
*/
|
||||
@@ -56,6 +57,7 @@ typedef struct metaslab_alloc_trace {
|
||||
uint64_t mat_offset;
|
||||
int mat_allocator;
|
||||
} metaslab_alloc_trace_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Used by the metaslab allocation tracing facility to indicate
|
||||
|
||||
@@ -457,10 +457,18 @@ enum trim_flag {
|
||||
ZIO_TRIM_SECURE = 1U << 0,
|
||||
};
|
||||
|
||||
#ifdef METASLAB_TRACE
|
||||
typedef struct zio_alloc_list {
|
||||
list_t zal_list;
|
||||
uint64_t zal_size;
|
||||
} zio_alloc_list_t;
|
||||
#define ZIO_ALLOC_LIST(zio) (&(zio)->io_alloc_list)
|
||||
#else
|
||||
typedef struct zio_alloc_list {
|
||||
uint8_t zal_pad;
|
||||
} zio_alloc_list_t;
|
||||
#define ZIO_ALLOC_LIST(zio) NULL
|
||||
#endif
|
||||
|
||||
typedef struct zio_link {
|
||||
zio_t *zl_parent;
|
||||
@@ -530,7 +538,9 @@ struct zio {
|
||||
hrtime_t io_delta; /* vdev queue service delta */
|
||||
hrtime_t io_delay; /* Device access time (disk or */
|
||||
/* file). */
|
||||
#ifdef METASLAB_TRACE
|
||||
zio_alloc_list_t io_alloc_list;
|
||||
#endif
|
||||
|
||||
/* Internal pipeline state */
|
||||
zio_flag_t io_flags;
|
||||
|
||||
+28
-8
@@ -265,11 +265,11 @@ static int zfs_metaslab_segment_weight_enabled = B_TRUE;
|
||||
*/
|
||||
static int zfs_metaslab_switch_threshold = 2;
|
||||
|
||||
#ifdef METASLAB_TRACE
|
||||
/*
|
||||
* Internal switch to enable/disable the metaslab allocation tracing
|
||||
* facility.
|
||||
* Switch to enable/disable the metaslab allocation tracing facility.
|
||||
*/
|
||||
static const boolean_t metaslab_trace_enabled = B_FALSE;
|
||||
static int metaslab_trace_enabled = B_FALSE;
|
||||
|
||||
/*
|
||||
* Maximum entries that the metaslab allocation tracing facility will keep
|
||||
@@ -279,7 +279,8 @@ static const boolean_t metaslab_trace_enabled = B_FALSE;
|
||||
* to every exceed this value. In debug mode, the system will panic if this
|
||||
* limit is ever reached allowing for further investigation.
|
||||
*/
|
||||
static const uint64_t metaslab_trace_max_entries = 5000;
|
||||
static uint64_t metaslab_trace_max_entries = 5000;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum number of metaslabs per group that can be disabled
|
||||
@@ -356,7 +357,9 @@ static unsigned int metaslab_idx_func(multilist_t *, void *);
|
||||
static void metaslab_evict(metaslab_t *, uint64_t);
|
||||
static void metaslab_rt_add(zfs_range_tree_t *rt, zfs_range_seg_t *rs,
|
||||
void *arg);
|
||||
#ifdef METASLAB_TRACE
|
||||
kmem_cache_t *metaslab_alloc_trace_cache;
|
||||
#endif
|
||||
|
||||
typedef struct metaslab_stats {
|
||||
kstat_named_t metaslabstat_trace_over_limit;
|
||||
@@ -391,10 +394,12 @@ static kstat_t *metaslab_ksp;
|
||||
void
|
||||
metaslab_stat_init(void)
|
||||
{
|
||||
#ifdef METASLAB_TRACE
|
||||
ASSERT0P(metaslab_alloc_trace_cache);
|
||||
metaslab_alloc_trace_cache = kmem_cache_create(
|
||||
"metaslab_alloc_trace_cache", sizeof (metaslab_alloc_trace_t),
|
||||
0, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
#endif
|
||||
metaslab_ksp = kstat_create("zfs", 0, "metaslab_stats",
|
||||
"misc", KSTAT_TYPE_NAMED, sizeof (metaslab_stats) /
|
||||
sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL);
|
||||
@@ -412,8 +417,10 @@ metaslab_stat_fini(void)
|
||||
metaslab_ksp = NULL;
|
||||
}
|
||||
|
||||
#ifdef METASLAB_TRACE
|
||||
kmem_cache_destroy(metaslab_alloc_trace_cache);
|
||||
metaslab_alloc_trace_cache = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4743,10 +4750,13 @@ metaslab_is_unique(metaslab_t *msp, dva_t *dva)
|
||||
* Add an allocation trace element to the allocation tracing list.
|
||||
*/
|
||||
static void
|
||||
metaslab_trace_add(zio_alloc_list_t *zal, metaslab_group_t *mg,
|
||||
metaslab_t *msp, uint64_t psize, uint32_t dva_id, uint64_t offset,
|
||||
int allocator)
|
||||
metaslab_trace_add(zio_alloc_list_t *zal __maybe_unused,
|
||||
metaslab_group_t *mg __maybe_unused,
|
||||
metaslab_t *msp __maybe_unused, uint64_t psize __maybe_unused,
|
||||
uint32_t dva_id __maybe_unused, uint64_t offset __maybe_unused,
|
||||
int allocator __maybe_unused)
|
||||
{
|
||||
#ifdef METASLAB_TRACE
|
||||
metaslab_alloc_trace_t *mat;
|
||||
|
||||
if (!metaslab_trace_enabled)
|
||||
@@ -4792,8 +4802,10 @@ metaslab_trace_add(zio_alloc_list_t *zal, metaslab_group_t *mg,
|
||||
zal->zal_size++;
|
||||
|
||||
ASSERT3U(zal->zal_size, <=, metaslab_trace_max_entries);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef METASLAB_TRACE
|
||||
void
|
||||
metaslab_trace_move(zio_alloc_list_t *old, zio_alloc_list_t *new)
|
||||
{
|
||||
@@ -4821,6 +4833,7 @@ metaslab_trace_fini(zio_alloc_list_t *zal)
|
||||
list_destroy(&zal->zal_list);
|
||||
zal->zal_size = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ==========================================================================
|
||||
@@ -6038,7 +6051,6 @@ metaslab_alloc_range(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
|
||||
ASSERT(ndvas > 0 && ndvas <= spa_max_replication(spa));
|
||||
ASSERT0(BP_GET_NDVAS(bp));
|
||||
ASSERT(hintbp == NULL || ndvas <= BP_GET_NDVAS(hintbp));
|
||||
ASSERT3P(zal, !=, NULL);
|
||||
|
||||
uint64_t smallest_psize = UINT64_MAX;
|
||||
for (int d = 0; d < ndvas; d++) {
|
||||
@@ -6488,3 +6500,11 @@ ZFS_MODULE_PARAM_CALL(zfs, zfs_, active_allocator,
|
||||
ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, condense_pct, UINT, ZMOD_RW,
|
||||
"Condense on-disk spacemap when it is more than this many percents "
|
||||
"of in-memory counterpart");
|
||||
|
||||
#ifdef METASLAB_TRACE
|
||||
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, trace_enabled, INT, ZMOD_RW,
|
||||
"Enable metaslab allocation tracing");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, trace_max_entries, U64, ZMOD_RW,
|
||||
"Maximum entries for metaslab allocation tracing");
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -967,7 +967,7 @@ zio_create(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
|
||||
offsetof(zio_link_t, zl_parent_node));
|
||||
list_create(&zio->io_child_list, sizeof (zio_link_t),
|
||||
offsetof(zio_link_t, zl_child_node));
|
||||
metaslab_trace_init(&zio->io_alloc_list);
|
||||
metaslab_trace_init(ZIO_ALLOC_LIST(zio));
|
||||
|
||||
if (vd != NULL)
|
||||
zio->io_child_type = ZIO_CHILD_VDEV;
|
||||
@@ -1038,7 +1038,7 @@ zio_create(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
|
||||
void
|
||||
zio_destroy(zio_t *zio)
|
||||
{
|
||||
metaslab_trace_fini(&zio->io_alloc_list);
|
||||
metaslab_trace_fini(ZIO_ALLOC_LIST(zio));
|
||||
list_destroy(&zio->io_parent_list);
|
||||
list_destroy(&zio->io_child_list);
|
||||
mutex_destroy(&zio->io_lock);
|
||||
@@ -3191,7 +3191,7 @@ zio_write_gang_block(zio_t *pio, metaslab_class_t *mc)
|
||||
uint64_t candidate = gangblocksize;
|
||||
error = metaslab_alloc_range(spa, mc, gangblocksize, gangblocksize,
|
||||
bp, gbh_copies, txg, pio == gio ? NULL : gio->io_bp, flags,
|
||||
&pio->io_alloc_list, pio->io_allocator, pio, &candidate);
|
||||
ZIO_ALLOC_LIST(pio), pio->io_allocator, pio, &candidate);
|
||||
if (error) {
|
||||
pio->io_error = error;
|
||||
return (pio);
|
||||
@@ -3282,7 +3282,7 @@ zio_write_gang_block(zio_t *pio, metaslab_class_t *mc)
|
||||
resid -= psize;
|
||||
zio_inherit_allocator(zio, cio);
|
||||
if (allocated) {
|
||||
metaslab_trace_move(&cio_list, &cio->io_alloc_list);
|
||||
metaslab_trace_move(&cio_list, ZIO_ALLOC_LIST(cio));
|
||||
metaslab_group_alloc_increment_all(spa,
|
||||
&cio->io_bp_orig, zio->io_allocator, flags, psize,
|
||||
cio);
|
||||
@@ -4363,7 +4363,7 @@ again:
|
||||
ASSERT(ZIO_HAS_ALLOCATOR(zio));
|
||||
error = metaslab_alloc(spa, mc, zio->io_size, bp,
|
||||
zio->io_prop.zp_copies, zio->io_txg, NULL, flags,
|
||||
&zio->io_alloc_list, zio->io_allocator, zio);
|
||||
ZIO_ALLOC_LIST(zio), zio->io_allocator, zio);
|
||||
|
||||
/*
|
||||
* When the dedup or special class is spilling into the normal class,
|
||||
|
||||
Reference in New Issue
Block a user