From 8172df643b6cdc7fe233b18c8d8e9b29455ae9f1 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 20 Jul 2021 10:13:21 -0400 Subject: Minor ARC optimizations Remove unneeded global, practically constant, state pointer variables (arc_anon, arc_mru, etc.), replacing them with macros of real state variables addresses (&ARC_anon, &ARC_mru, etc.). Change ARC_EVICT_ALL from -1ULL to UINT64_MAX, not requiring special handling in inner loop of ARC reclamation. Respectively change bytes argument of arc_evict_state() from int64_t to uint64_t. Reviewed-by: Matthew Ahrens Reviewed-by: Mark Maybee Reviewed-by: Ryan Moeller Signed-off-by: Alexander Motin Closes #12348 --- include/sys/arc.h | 2 +- include/sys/arc_impl.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include/sys') diff --git a/include/sys/arc.h b/include/sys/arc.h index f58fa53b6..ef07a657f 100644 --- a/include/sys/arc.h +++ b/include/sys/arc.h @@ -44,7 +44,7 @@ extern "C" { * Used by arc_flush() to inform arc_evict_state() that it should evict * all available buffers from the arc state being passed in. */ -#define ARC_EVICT_ALL -1ULL +#define ARC_EVICT_ALL UINT64_MAX #define HDR_SET_LSIZE(hdr, x) do { \ ASSERT(IS_P2ALIGNED(x, 1U << SPA_MINBLOCKSHIFT)); \ diff --git a/include/sys/arc_impl.h b/include/sys/arc_impl.h index ddfa28c15..747100a22 100644 --- a/include/sys/arc_impl.h +++ b/include/sys/arc_impl.h @@ -964,6 +964,13 @@ typedef struct arc_evict_waiter { #define arc_c_max ARCSTAT(arcstat_c_max) /* max target cache size */ #define arc_sys_free ARCSTAT(arcstat_sys_free) /* target system free bytes */ +#define arc_anon (&ARC_anon) +#define arc_mru (&ARC_mru) +#define arc_mru_ghost (&ARC_mru_ghost) +#define arc_mfu (&ARC_mfu) +#define arc_mfu_ghost (&ARC_mfu_ghost) +#define arc_l2c_only (&ARC_l2c_only) + extern taskq_t *arc_prune_taskq; extern arc_stats_t arc_stats; extern arc_sums_t arc_sums; @@ -974,8 +981,8 @@ extern int arc_no_grow_shift; extern int arc_shrink_shift; extern kmutex_t arc_prune_mtx; extern list_t arc_prune_list; -extern arc_state_t *arc_mfu; -extern arc_state_t *arc_mru; +extern arc_state_t ARC_mfu; +extern arc_state_t ARC_mru; extern uint_t zfs_arc_pc_percent; extern int arc_lotsfree_percent; extern unsigned long zfs_arc_min; -- cgit v1.2.3