mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-06 08:10:25 +03:00
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 <mahrens@delphix.com> Reviewed-by: Mark Maybee <mark.maybee@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Closes #12348
This commit is contained in:
parent
4dfb698aac
commit
6a49948c73
@ -44,7 +44,7 @@ extern "C" {
|
|||||||
* Used by arc_flush() to inform arc_evict_state() that it should evict
|
* Used by arc_flush() to inform arc_evict_state() that it should evict
|
||||||
* all available buffers from the arc state being passed in.
|
* 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 { \
|
#define HDR_SET_LSIZE(hdr, x) do { \
|
||||||
ASSERT(IS_P2ALIGNED(x, 1U << SPA_MINBLOCKSHIFT)); \
|
ASSERT(IS_P2ALIGNED(x, 1U << SPA_MINBLOCKSHIFT)); \
|
||||||
|
@ -964,6 +964,13 @@ typedef struct arc_evict_waiter {
|
|||||||
#define arc_c_max ARCSTAT(arcstat_c_max) /* max target cache size */
|
#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_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 taskq_t *arc_prune_taskq;
|
||||||
extern arc_stats_t arc_stats;
|
extern arc_stats_t arc_stats;
|
||||||
extern arc_sums_t arc_sums;
|
extern arc_sums_t arc_sums;
|
||||||
@ -974,8 +981,8 @@ extern int arc_no_grow_shift;
|
|||||||
extern int arc_shrink_shift;
|
extern int arc_shrink_shift;
|
||||||
extern kmutex_t arc_prune_mtx;
|
extern kmutex_t arc_prune_mtx;
|
||||||
extern list_t arc_prune_list;
|
extern list_t arc_prune_list;
|
||||||
extern arc_state_t *arc_mfu;
|
extern arc_state_t ARC_mfu;
|
||||||
extern arc_state_t *arc_mru;
|
extern arc_state_t ARC_mru;
|
||||||
extern uint_t zfs_arc_pc_percent;
|
extern uint_t zfs_arc_pc_percent;
|
||||||
extern int arc_lotsfree_percent;
|
extern int arc_lotsfree_percent;
|
||||||
extern unsigned long zfs_arc_min;
|
extern unsigned long zfs_arc_min;
|
||||||
|
@ -648,13 +648,6 @@ arc_sums_t arc_sums;
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
kstat_t *arc_ksp;
|
kstat_t *arc_ksp;
|
||||||
static arc_state_t *arc_anon;
|
|
||||||
static arc_state_t *arc_mru_ghost;
|
|
||||||
static arc_state_t *arc_mfu_ghost;
|
|
||||||
static arc_state_t *arc_l2c_only;
|
|
||||||
|
|
||||||
arc_state_t *arc_mru;
|
|
||||||
arc_state_t *arc_mfu;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are several ARC variables that are critical to export as kstats --
|
* There are several ARC variables that are critical to export as kstats --
|
||||||
@ -2203,7 +2196,6 @@ arc_evictable_space_increment(arc_buf_hdr_t *hdr, arc_state_t *state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(!GHOST_STATE(state));
|
|
||||||
if (hdr->b_l1hdr.b_pabd != NULL) {
|
if (hdr->b_l1hdr.b_pabd != NULL) {
|
||||||
(void) zfs_refcount_add_many(&state->arcs_esize[type],
|
(void) zfs_refcount_add_many(&state->arcs_esize[type],
|
||||||
arc_hdr_size(hdr), hdr);
|
arc_hdr_size(hdr), hdr);
|
||||||
@ -2244,7 +2236,6 @@ arc_evictable_space_decrement(arc_buf_hdr_t *hdr, arc_state_t *state)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(!GHOST_STATE(state));
|
|
||||||
if (hdr->b_l1hdr.b_pabd != NULL) {
|
if (hdr->b_l1hdr.b_pabd != NULL) {
|
||||||
(void) zfs_refcount_remove_many(&state->arcs_esize[type],
|
(void) zfs_refcount_remove_many(&state->arcs_esize[type],
|
||||||
arc_hdr_size(hdr), hdr);
|
arc_hdr_size(hdr), hdr);
|
||||||
@ -4036,23 +4027,21 @@ arc_set_need_free(void)
|
|||||||
|
|
||||||
static uint64_t
|
static uint64_t
|
||||||
arc_evict_state_impl(multilist_t *ml, int idx, arc_buf_hdr_t *marker,
|
arc_evict_state_impl(multilist_t *ml, int idx, arc_buf_hdr_t *marker,
|
||||||
uint64_t spa, int64_t bytes)
|
uint64_t spa, uint64_t bytes)
|
||||||
{
|
{
|
||||||
multilist_sublist_t *mls;
|
multilist_sublist_t *mls;
|
||||||
uint64_t bytes_evicted = 0, real_evicted = 0;
|
uint64_t bytes_evicted = 0, real_evicted = 0;
|
||||||
arc_buf_hdr_t *hdr;
|
arc_buf_hdr_t *hdr;
|
||||||
kmutex_t *hash_lock;
|
kmutex_t *hash_lock;
|
||||||
int evict_count = 0;
|
int evict_count = zfs_arc_evict_batch_limit;
|
||||||
|
|
||||||
ASSERT3P(marker, !=, NULL);
|
ASSERT3P(marker, !=, NULL);
|
||||||
IMPLY(bytes < 0, bytes == ARC_EVICT_ALL);
|
|
||||||
|
|
||||||
mls = multilist_sublist_lock(ml, idx);
|
mls = multilist_sublist_lock(ml, idx);
|
||||||
|
|
||||||
for (hdr = multilist_sublist_prev(mls, marker); hdr != NULL;
|
for (hdr = multilist_sublist_prev(mls, marker); likely(hdr != NULL);
|
||||||
hdr = multilist_sublist_prev(mls, marker)) {
|
hdr = multilist_sublist_prev(mls, marker)) {
|
||||||
if ((bytes != ARC_EVICT_ALL && bytes_evicted >= bytes) ||
|
if ((evict_count <= 0) || (bytes_evicted >= bytes))
|
||||||
(evict_count >= zfs_arc_evict_batch_limit))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4114,7 +4103,7 @@ arc_evict_state_impl(multilist_t *ml, int idx, arc_buf_hdr_t *marker,
|
|||||||
* evict_count in this case.
|
* evict_count in this case.
|
||||||
*/
|
*/
|
||||||
if (evicted != 0)
|
if (evicted != 0)
|
||||||
evict_count++;
|
evict_count--;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ARCSTAT_BUMP(arcstat_mutex_miss);
|
ARCSTAT_BUMP(arcstat_mutex_miss);
|
||||||
@ -4175,7 +4164,7 @@ arc_evict_state_impl(multilist_t *ml, int idx, arc_buf_hdr_t *marker,
|
|||||||
* the given arc state; which is used by arc_flush().
|
* the given arc state; which is used by arc_flush().
|
||||||
*/
|
*/
|
||||||
static uint64_t
|
static uint64_t
|
||||||
arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
|
arc_evict_state(arc_state_t *state, uint64_t spa, uint64_t bytes,
|
||||||
arc_buf_contents_t type)
|
arc_buf_contents_t type)
|
||||||
{
|
{
|
||||||
uint64_t total_evicted = 0;
|
uint64_t total_evicted = 0;
|
||||||
@ -4183,8 +4172,6 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
|
|||||||
int num_sublists;
|
int num_sublists;
|
||||||
arc_buf_hdr_t **markers;
|
arc_buf_hdr_t **markers;
|
||||||
|
|
||||||
IMPLY(bytes < 0, bytes == ARC_EVICT_ALL);
|
|
||||||
|
|
||||||
num_sublists = multilist_get_num_sublists(ml);
|
num_sublists = multilist_get_num_sublists(ml);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4216,7 +4203,7 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
|
|||||||
* While we haven't hit our target number of bytes to evict, or
|
* While we haven't hit our target number of bytes to evict, or
|
||||||
* we're evicting all available buffers.
|
* we're evicting all available buffers.
|
||||||
*/
|
*/
|
||||||
while (total_evicted < bytes || bytes == ARC_EVICT_ALL) {
|
while (total_evicted < bytes) {
|
||||||
int sublist_idx = multilist_get_random_index(ml);
|
int sublist_idx = multilist_get_random_index(ml);
|
||||||
uint64_t scan_evicted = 0;
|
uint64_t scan_evicted = 0;
|
||||||
|
|
||||||
@ -4244,9 +4231,7 @@ arc_evict_state(arc_state_t *state, uint64_t spa, int64_t bytes,
|
|||||||
uint64_t bytes_remaining;
|
uint64_t bytes_remaining;
|
||||||
uint64_t bytes_evicted;
|
uint64_t bytes_evicted;
|
||||||
|
|
||||||
if (bytes == ARC_EVICT_ALL)
|
if (total_evicted < bytes)
|
||||||
bytes_remaining = ARC_EVICT_ALL;
|
|
||||||
else if (total_evicted < bytes)
|
|
||||||
bytes_remaining = bytes - total_evicted;
|
bytes_remaining = bytes - total_evicted;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
@ -4341,7 +4326,7 @@ static uint64_t
|
|||||||
arc_evict_impl(arc_state_t *state, uint64_t spa, int64_t bytes,
|
arc_evict_impl(arc_state_t *state, uint64_t spa, int64_t bytes,
|
||||||
arc_buf_contents_t type)
|
arc_buf_contents_t type)
|
||||||
{
|
{
|
||||||
int64_t delta;
|
uint64_t delta;
|
||||||
|
|
||||||
if (bytes > 0 && zfs_refcount_count(&state->arcs_esize[type]) > 0) {
|
if (bytes > 0 && zfs_refcount_count(&state->arcs_esize[type]) > 0) {
|
||||||
delta = MIN(zfs_refcount_count(&state->arcs_esize[type]),
|
delta = MIN(zfs_refcount_count(&state->arcs_esize[type]),
|
||||||
@ -7601,13 +7586,6 @@ arc_tuning_update(boolean_t verbose)
|
|||||||
static void
|
static void
|
||||||
arc_state_init(void)
|
arc_state_init(void)
|
||||||
{
|
{
|
||||||
arc_anon = &ARC_anon;
|
|
||||||
arc_mru = &ARC_mru;
|
|
||||||
arc_mru_ghost = &ARC_mru_ghost;
|
|
||||||
arc_mfu = &ARC_mfu;
|
|
||||||
arc_mfu_ghost = &ARC_mfu_ghost;
|
|
||||||
arc_l2c_only = &ARC_l2c_only;
|
|
||||||
|
|
||||||
multilist_create(&arc_mru->arcs_list[ARC_BUFC_METADATA],
|
multilist_create(&arc_mru->arcs_list[ARC_BUFC_METADATA],
|
||||||
sizeof (arc_buf_hdr_t),
|
sizeof (arc_buf_hdr_t),
|
||||||
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
|
offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node),
|
||||||
|
Loading…
Reference in New Issue
Block a user