Skip to content

Commit 08d26d2

Browse files
amotinrincebrain
authored andcommitted
Optimize arc_l2c_only lists assertions
It is very expensive and not informative to call multilist_is_empty() for each arc_change_state() on debug builds to check for impossible. Instead implement special index function for arc_l2c_only->arcs_list, multilists, panicking on any attempt to use it. Reviewed-by: Mark Maybee <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored-By: iXsystems, Inc. Closes openzfs#12421
1 parent 96c53cf commit 08d26d2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

module/zfs/arc.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,13 +2578,6 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t *hdr,
25782578
l2arc_hdr_arcstats_increment_state(hdr);
25792579
}
25802580
}
2581-
2582-
/*
2583-
* L2 headers should never be on the L2 state list since they don't
2584-
* have L1 headers allocated.
2585-
*/
2586-
ASSERT(multilist_is_empty(&arc_l2c_only->arcs_list[ARC_BUFC_DATA]) &&
2587-
multilist_is_empty(&arc_l2c_only->arcs_list[ARC_BUFC_METADATA]));
25882581
}
25892582

25902583
void
@@ -7456,6 +7449,12 @@ arc_state_multilist_index_func(multilist_t *ml, void *obj)
74567449
multilist_get_num_sublists(ml));
74577450
}
74587451

7452+
static unsigned int
7453+
arc_state_l2c_multilist_index_func(multilist_t *ml, void *obj)
7454+
{
7455+
panic("Header %p insert into arc_l2c_only %p", obj, ml);
7456+
}
7457+
74597458
#define WARN_IF_TUNING_IGNORED(tuning, value, do_warn) do { \
74607459
if ((do_warn) && (tuning) && ((tuning) != (value))) { \
74617460
cmn_err(CE_WARN, \
@@ -7603,14 +7602,18 @@ arc_state_init(void)
76037602
sizeof (arc_buf_hdr_t),
76047603
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
76057604
arc_state_multilist_index_func);
7605+
/*
7606+
* L2 headers should never be on the L2 state list since they don't
7607+
* have L1 headers allocated. Special index function asserts that.
7608+
*/
76067609
multilist_create(&arc_l2c_only->arcs_list[ARC_BUFC_METADATA],
76077610
sizeof (arc_buf_hdr_t),
76087611
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
7609-
arc_state_multilist_index_func);
7612+
arc_state_l2c_multilist_index_func);
76107613
multilist_create(&arc_l2c_only->arcs_list[ARC_BUFC_DATA],
76117614
sizeof (arc_buf_hdr_t),
76127615
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
7613-
arc_state_multilist_index_func);
7616+
arc_state_l2c_multilist_index_func);
76147617

76157618
zfs_refcount_create(&arc_anon->arcs_esize[ARC_BUFC_METADATA]);
76167619
zfs_refcount_create(&arc_anon->arcs_esize[ARC_BUFC_DATA]);

0 commit comments

Comments
 (0)