Skip to content

Commit 28aefb2

Browse files
amotinbehlendorf
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]> Closes #12421
1 parent 772f58c commit 28aefb2

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
@@ -2579,13 +2579,6 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t *hdr,
25792579
l2arc_hdr_arcstats_increment_state(hdr);
25802580
}
25812581
}
2582-
2583-
/*
2584-
* L2 headers should never be on the L2 state list since they don't
2585-
* have L1 headers allocated.
2586-
*/
2587-
ASSERT(multilist_is_empty(&arc_l2c_only->arcs_list[ARC_BUFC_DATA]) &&
2588-
multilist_is_empty(&arc_l2c_only->arcs_list[ARC_BUFC_METADATA]));
25892582
}
25902583

25912584
void
@@ -7462,6 +7455,12 @@ arc_state_multilist_index_func(multilist_t *ml, void *obj)
74627455
multilist_get_num_sublists(ml));
74637456
}
74647457

7458+
static unsigned int
7459+
arc_state_l2c_multilist_index_func(multilist_t *ml, void *obj)
7460+
{
7461+
panic("Header %p insert into arc_l2c_only %p", obj, ml);
7462+
}
7463+
74657464
#define WARN_IF_TUNING_IGNORED(tuning, value, do_warn) do { \
74667465
if ((do_warn) && (tuning) && ((tuning) != (value))) { \
74677466
cmn_err(CE_WARN, \
@@ -7609,14 +7608,18 @@ arc_state_init(void)
76097608
sizeof (arc_buf_hdr_t),
76107609
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
76117610
arc_state_multilist_index_func);
7611+
/*
7612+
* L2 headers should never be on the L2 state list since they don't
7613+
* have L1 headers allocated. Special index function asserts that.
7614+
*/
76127615
multilist_create(&arc_l2c_only->arcs_list[ARC_BUFC_METADATA],
76137616
sizeof (arc_buf_hdr_t),
76147617
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
7615-
arc_state_multilist_index_func);
7618+
arc_state_l2c_multilist_index_func);
76167619
multilist_create(&arc_l2c_only->arcs_list[ARC_BUFC_DATA],
76177620
sizeof (arc_buf_hdr_t),
76187621
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
7619-
arc_state_multilist_index_func);
7622+
arc_state_l2c_multilist_index_func);
76207623

76217624
zfs_refcount_create(&arc_anon->arcs_esize[ARC_BUFC_METADATA]);
76227625
zfs_refcount_create(&arc_anon->arcs_esize[ARC_BUFC_DATA]);

0 commit comments

Comments
 (0)