Skip to content

Commit 3fe91aa

Browse files
committed
Add L2ARC arcstats for MFU/MRU buffers and buffer content type
Currently the ARC state (MFU/MRU) of cached L2ARC buffer and their content type is unknown. Knowing this information may prove beneficial in adjusting the L2ARC caching policy in the future. This commit adds L2ARC arcstats that display the aligned size (in bytes) of L2ARC buffers according to their content type (data/metadata) and according to their ARC state (MRU/MFU or prefetch). It also expands the existing evict_l2_eligible arcstat to differentiate between MFU and MRU buffers. L2ARC caches buffers from the MRU and MFU lists of ARC. Upon caching a buffer, its ARC state (MRU/MFU) is stored in the L2 header (b_arcs_state). The l2_m{f,r}u_asize arcstats reflect the aligned size (in bytes) of L2ARC buffers according to their ARC state (based on b_arcs_state). We also account for the case where an L2ARC and ARC cached MRU or MRU_ghost buffer transitions to MFU. The l2_prefetch_asize reflects the alinged size (in bytes) of L2ARC buffers that were cached while they had the prefetch flag set in ARC. This is dynamically updated as the prefetch flag of L2ARC buffers changes. When buffers are evicted from ARC, if they are determined to be L2ARC eligible then their logical size is recorded in evict_l2_eligible_m{r,f}u arcstats according to their ARC state upon eviction. Persistent L2ARC: When commiting an L2ARC buffer to a log block (L2ARC metadata) its b_arcs_state and prefetch flag is also stored. If the buffer changes its arcstate or prefetch flag this is reflected in the above arcstats. However, the L2ARC metadata cannot currently be updated to reflect this change. Example: L2ARC caches an MRU buffer. L2ARC metadata and arcstats count this as an MRU buffer. The buffer transitions to MFU. The arcstats are updated to reflect this. Upon pool re-import or on/offlining the L2ARC device the arcstats are cleared and the buffer will now be counted as an MRU buffer, as the L2ARC metadata were not updated. Bug fix: - If l2arc_noprefetch is set, arc_read_done clears the L2CACHE flag of an ARC buffer. However, prefetches may be issued in a way that arc_read_done() is bypassed. Instead, move the related code in l2arc_write_eligible() to account for those cases too. Signed-off-by: George Amanakis <[email protected]>
1 parent 770269e commit 3fe91aa

File tree

3 files changed

+169
-25
lines changed

3 files changed

+169
-25
lines changed

cmd/zdb/zdb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,6 +4188,8 @@ dump_l2arc_log_entries(uint64_t log_entries,
41884188
(u_longlong_t)L2BLK_GET_PREFETCH((&le[j])->le_prop));
41894189
(void) printf("|\t\t\t\taddress: %llu\n",
41904190
(u_longlong_t)le[j].le_daddr);
4191+
(void) printf("|\t\t\t\tstate: %llu\n",
4192+
(u_longlong_t)L2BLK_GET_STATE((&le[j])->le_prop));
41914193
(void) printf("|\n");
41924194
}
41934195
(void) printf("\n");

include/sys/arc_impl.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ typedef struct l2arc_lb_ptr_buf {
350350
#define L2BLK_SET_TYPE(field, x) BF64_SET((field), 48, 8, x)
351351
#define L2BLK_GET_PROTECTED(field) BF64_GET((field), 56, 1)
352352
#define L2BLK_SET_PROTECTED(field, x) BF64_SET((field), 56, 1, x)
353+
#define L2BLK_GET_STATE(field) BF64_GET((field), 57, 4)
354+
#define L2BLK_SET_STATE(field, x) BF64_SET((field), 57, 4, x)
353355

354356
#define PTR_SWAP(x, y) \
355357
do { \
@@ -446,6 +448,7 @@ typedef struct l2arc_buf_hdr {
446448
uint64_t b_daddr; /* disk address, offset byte */
447449
uint32_t b_hits;
448450
list_node_t b_l2node;
451+
arc_state_type_t b_arcs_state;
449452
} l2arc_buf_hdr_t;
450453

451454
typedef struct l2arc_write_callback {
@@ -546,6 +549,8 @@ typedef struct arc_stats {
546549
kstat_named_t arcstat_evict_not_enough;
547550
kstat_named_t arcstat_evict_l2_cached;
548551
kstat_named_t arcstat_evict_l2_eligible;
552+
kstat_named_t arcstat_evict_l2_eligible_mfu;
553+
kstat_named_t arcstat_evict_l2_eligible_mru;
549554
kstat_named_t arcstat_evict_l2_ineligible;
550555
kstat_named_t arcstat_evict_l2_skip;
551556
kstat_named_t arcstat_hash_elements;
@@ -744,6 +749,18 @@ typedef struct arc_stats {
744749
kstat_named_t arcstat_mfu_ghost_evictable_metadata;
745750
kstat_named_t arcstat_l2_hits;
746751
kstat_named_t arcstat_l2_misses;
752+
/*
753+
* Aligned size (in bytes) of L2ARC cached buffers by ARC state.
754+
*/
755+
kstat_named_t arcstat_l2_prefetch_asize;
756+
kstat_named_t arcstat_l2_mru_asize;
757+
kstat_named_t arcstat_l2_mfu_asize;
758+
/*
759+
* Aligned size (in bytes) of L2ARC cached buffers by buffer content
760+
* type.
761+
*/
762+
kstat_named_t arcstat_l2_bufc_data_asize;
763+
kstat_named_t arcstat_l2_bufc_metadata_asize;
747764
kstat_named_t arcstat_l2_feeds;
748765
kstat_named_t arcstat_l2_rw_clash;
749766
kstat_named_t arcstat_l2_read_bytes;

0 commit comments

Comments
 (0)