Skip to content

Commit 500445c

Browse files
Prakash Suryabehlendorf
authored andcommitted
Illumos 5445 - Add more visibility via arcstats
5445 Add more visibility via arcstats; specifically arc_state_t stats and differentiate between "data" and "metadata" Reviewed by: Basil Crow <basil.crow@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Bayard Bell <bayard.bell@nexenta.com> Approved by: Robert Mustacchi <rm@joyent.com> References: https://www.illumos.org/issues/5445 illumos/illumos-gate@4076b1b Porting Notes: This patch is an improved version of cc7f677 which was previously merged in ZoL. This patch incorporates the additional improvements which were made upstream. Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #3533
1 parent ca67b33 commit 500445c

File tree

1 file changed

+151
-40
lines changed

1 file changed

+151
-40
lines changed

module/zfs/arc.c

Lines changed: 151 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -298,25 +298,137 @@ typedef struct arc_stats {
298298
kstat_named_t arcstat_c_min;
299299
kstat_named_t arcstat_c_max;
300300
kstat_named_t arcstat_size;
301+
/*
302+
* Number of bytes consumed by internal ARC structures necessary
303+
* for tracking purposes; these structures are not actually
304+
* backed by ARC buffers. This includes arc_buf_hdr_t structures
305+
* (allocated via arc_buf_hdr_t_full and arc_buf_hdr_t_l2only
306+
* caches), and arc_buf_t structures (allocated via arc_buf_t
307+
* cache).
308+
*/
301309
kstat_named_t arcstat_hdr_size;
310+
/*
311+
* Number of bytes consumed by ARC buffers of type equal to
312+
* ARC_BUFC_DATA. This is generally consumed by buffers backing
313+
* on disk user data (e.g. plain file contents).
314+
*/
302315
kstat_named_t arcstat_data_size;
303-
kstat_named_t arcstat_meta_size;
316+
/*
317+
* Number of bytes consumed by ARC buffers of type equal to
318+
* ARC_BUFC_METADATA. This is generally consumed by buffers
319+
* backing on disk data that is used for internal ZFS
320+
* structures (e.g. ZAP, dnode, indirect blocks, etc).
321+
*/
322+
kstat_named_t arcstat_metadata_size;
323+
/*
324+
* Number of bytes consumed by various buffers and structures
325+
* not actually backed with ARC buffers. This includes bonus
326+
* buffers (allocated directly via zio_buf_* functions),
327+
* dmu_buf_impl_t structures (allocated via dmu_buf_impl_t
328+
* cache), and dnode_t structures (allocated via dnode_t cache).
329+
*/
304330
kstat_named_t arcstat_other_size;
331+
/*
332+
* Total number of bytes consumed by ARC buffers residing in the
333+
* arc_anon state. This includes *all* buffers in the arc_anon
334+
* state; e.g. data, metadata, evictable, and unevictable buffers
335+
* are all included in this value.
336+
*/
305337
kstat_named_t arcstat_anon_size;
306-
kstat_named_t arcstat_anon_evict_data;
307-
kstat_named_t arcstat_anon_evict_metadata;
338+
/*
339+
* Number of bytes consumed by ARC buffers that meet the
340+
* following criteria: backing buffers of type ARC_BUFC_DATA,
341+
* residing in the arc_anon state, and are eligible for eviction
342+
* (e.g. have no outstanding holds on the buffer).
343+
*/
344+
kstat_named_t arcstat_anon_evictable_data;
345+
/*
346+
* Number of bytes consumed by ARC buffers that meet the
347+
* following criteria: backing buffers of type ARC_BUFC_METADATA,
348+
* residing in the arc_anon state, and are eligible for eviction
349+
* (e.g. have no outstanding holds on the buffer).
350+
*/
351+
kstat_named_t arcstat_anon_evictable_metadata;
352+
/*
353+
* Total number of bytes consumed by ARC buffers residing in the
354+
* arc_mru state. This includes *all* buffers in the arc_mru
355+
* state; e.g. data, metadata, evictable, and unevictable buffers
356+
* are all included in this value.
357+
*/
308358
kstat_named_t arcstat_mru_size;
309-
kstat_named_t arcstat_mru_evict_data;
310-
kstat_named_t arcstat_mru_evict_metadata;
359+
/*
360+
* Number of bytes consumed by ARC buffers that meet the
361+
* following criteria: backing buffers of type ARC_BUFC_DATA,
362+
* residing in the arc_mru state, and are eligible for eviction
363+
* (e.g. have no outstanding holds on the buffer).
364+
*/
365+
kstat_named_t arcstat_mru_evictable_data;
366+
/*
367+
* Number of bytes consumed by ARC buffers that meet the
368+
* following criteria: backing buffers of type ARC_BUFC_METADATA,
369+
* residing in the arc_mru state, and are eligible for eviction
370+
* (e.g. have no outstanding holds on the buffer).
371+
*/
372+
kstat_named_t arcstat_mru_evictable_metadata;
373+
/*
374+
* Total number of bytes that *would have been* consumed by ARC
375+
* buffers in the arc_mru_ghost state. The key thing to note
376+
* here, is the fact that this size doesn't actually indicate
377+
* RAM consumption. The ghost lists only consist of headers and
378+
* don't actually have ARC buffers linked off of these headers.
379+
* Thus, *if* the headers had associated ARC buffers, these
380+
* buffers *would have* consumed this number of bytes.
381+
*/
311382
kstat_named_t arcstat_mru_ghost_size;
312-
kstat_named_t arcstat_mru_ghost_evict_data;
313-
kstat_named_t arcstat_mru_ghost_evict_metadata;
383+
/*
384+
* Number of bytes that *would have been* consumed by ARC
385+
* buffers that are eligible for eviction, of type
386+
* ARC_BUFC_DATA, and linked off the arc_mru_ghost state.
387+
*/
388+
kstat_named_t arcstat_mru_ghost_evictable_data;
389+
/*
390+
* Number of bytes that *would have been* consumed by ARC
391+
* buffers that are eligible for eviction, of type
392+
* ARC_BUFC_METADATA, and linked off the arc_mru_ghost state.
393+
*/
394+
kstat_named_t arcstat_mru_ghost_evictable_metadata;
395+
/*
396+
* Total number of bytes consumed by ARC buffers residing in the
397+
* arc_mfu state. This includes *all* buffers in the arc_mfu
398+
* state; e.g. data, metadata, evictable, and unevictable buffers
399+
* are all included in this value.
400+
*/
314401
kstat_named_t arcstat_mfu_size;
315-
kstat_named_t arcstat_mfu_evict_data;
316-
kstat_named_t arcstat_mfu_evict_metadata;
402+
/*
403+
* Number of bytes consumed by ARC buffers that are eligible for
404+
* eviction, of type ARC_BUFC_DATA, and reside in the arc_mfu
405+
* state.
406+
*/
407+
kstat_named_t arcstat_mfu_evictable_data;
408+
/*
409+
* Number of bytes consumed by ARC buffers that are eligible for
410+
* eviction, of type ARC_BUFC_METADATA, and reside in the
411+
* arc_mfu state.
412+
*/
413+
kstat_named_t arcstat_mfu_evictable_metadata;
414+
/*
415+
* Total number of bytes that *would have been* consumed by ARC
416+
* buffers in the arc_mfu_ghost state. See the comment above
417+
* arcstat_mru_ghost_size for more details.
418+
*/
317419
kstat_named_t arcstat_mfu_ghost_size;
318-
kstat_named_t arcstat_mfu_ghost_evict_data;
319-
kstat_named_t arcstat_mfu_ghost_evict_metadata;
420+
/*
421+
* Number of bytes that *would have been* consumed by ARC
422+
* buffers that are eligible for eviction, of type
423+
* ARC_BUFC_DATA, and linked off the arc_mfu_ghost state.
424+
*/
425+
kstat_named_t arcstat_mfu_ghost_evictable_data;
426+
/*
427+
* Number of bytes that *would have been* consumed by ARC
428+
* buffers that are eligible for eviction, of type
429+
* ARC_BUFC_METADATA, and linked off the arc_mru_ghost state.
430+
*/
431+
kstat_named_t arcstat_mfu_ghost_evictable_metadata;
320432
kstat_named_t arcstat_l2_hits;
321433
kstat_named_t arcstat_l2_misses;
322434
kstat_named_t arcstat_l2_feeds;
@@ -392,23 +504,23 @@ static arc_stats_t arc_stats = {
392504
{ "size", KSTAT_DATA_UINT64 },
393505
{ "hdr_size", KSTAT_DATA_UINT64 },
394506
{ "data_size", KSTAT_DATA_UINT64 },
395-
{ "meta_size", KSTAT_DATA_UINT64 },
507+
{ "metadata_size", KSTAT_DATA_UINT64 },
396508
{ "other_size", KSTAT_DATA_UINT64 },
397509
{ "anon_size", KSTAT_DATA_UINT64 },
398-
{ "anon_evict_data", KSTAT_DATA_UINT64 },
399-
{ "anon_evict_metadata", KSTAT_DATA_UINT64 },
510+
{ "anon_evictable_data", KSTAT_DATA_UINT64 },
511+
{ "anon_evictable_metadata", KSTAT_DATA_UINT64 },
400512
{ "mru_size", KSTAT_DATA_UINT64 },
401-
{ "mru_evict_data", KSTAT_DATA_UINT64 },
402-
{ "mru_evict_metadata", KSTAT_DATA_UINT64 },
513+
{ "mru_evictable_data", KSTAT_DATA_UINT64 },
514+
{ "mru_evictable_metadata", KSTAT_DATA_UINT64 },
403515
{ "mru_ghost_size", KSTAT_DATA_UINT64 },
404-
{ "mru_ghost_evict_data", KSTAT_DATA_UINT64 },
405-
{ "mru_ghost_evict_metadata", KSTAT_DATA_UINT64 },
516+
{ "mru_ghost_evictable_data", KSTAT_DATA_UINT64 },
517+
{ "mru_ghost_evictable_metadata", KSTAT_DATA_UINT64 },
406518
{ "mfu_size", KSTAT_DATA_UINT64 },
407-
{ "mfu_evict_data", KSTAT_DATA_UINT64 },
408-
{ "mfu_evict_metadata", KSTAT_DATA_UINT64 },
519+
{ "mfu_evictable_data", KSTAT_DATA_UINT64 },
520+
{ "mfu_evictable_metadata", KSTAT_DATA_UINT64 },
409521
{ "mfu_ghost_size", KSTAT_DATA_UINT64 },
410-
{ "mfu_ghost_evict_data", KSTAT_DATA_UINT64 },
411-
{ "mfu_ghost_evict_metadata", KSTAT_DATA_UINT64 },
522+
{ "mfu_ghost_evictable_data", KSTAT_DATA_UINT64 },
523+
{ "mfu_ghost_evictable_metadata", KSTAT_DATA_UINT64 },
412524
{ "l2_hits", KSTAT_DATA_UINT64 },
413525
{ "l2_misses", KSTAT_DATA_UINT64 },
414526
{ "l2_feeds", KSTAT_DATA_UINT64 },
@@ -446,7 +558,7 @@ static arc_stats_t arc_stats = {
446558
{ "arc_meta_used", KSTAT_DATA_UINT64 },
447559
{ "arc_meta_limit", KSTAT_DATA_UINT64 },
448560
{ "arc_meta_max", KSTAT_DATA_UINT64 },
449-
{ "arc_meta_min", KSTAT_DATA_UINT64 },
561+
{ "arc_meta_min", KSTAT_DATA_UINT64 }
450562
};
451563

452564
#define ARCSTAT(stat) (arc_stats.stat.value.ui64)
@@ -1470,7 +1582,7 @@ arc_space_consume(uint64_t space, arc_space_type_t type)
14701582
ARCSTAT_INCR(arcstat_data_size, space);
14711583
break;
14721584
case ARC_SPACE_META:
1473-
ARCSTAT_INCR(arcstat_meta_size, space);
1585+
ARCSTAT_INCR(arcstat_metadata_size, space);
14741586
break;
14751587
case ARC_SPACE_OTHER:
14761588
ARCSTAT_INCR(arcstat_other_size, space);
@@ -1483,11 +1595,8 @@ arc_space_consume(uint64_t space, arc_space_type_t type)
14831595
break;
14841596
}
14851597

1486-
if (type != ARC_SPACE_DATA) {
1598+
if (type != ARC_SPACE_DATA)
14871599
ARCSTAT_INCR(arcstat_meta_used, space);
1488-
if (arc_meta_max < arc_meta_used)
1489-
arc_meta_max = arc_meta_used;
1490-
}
14911600

14921601
atomic_add_64(&arc_size, space);
14931602
}
@@ -1504,7 +1613,7 @@ arc_space_return(uint64_t space, arc_space_type_t type)
15041613
ARCSTAT_INCR(arcstat_data_size, -space);
15051614
break;
15061615
case ARC_SPACE_META:
1507-
ARCSTAT_INCR(arcstat_meta_size, -space);
1616+
ARCSTAT_INCR(arcstat_metadata_size, -space);
15081617
break;
15091618
case ARC_SPACE_OTHER:
15101619
ARCSTAT_INCR(arcstat_other_size, -space);
@@ -1519,6 +1628,8 @@ arc_space_return(uint64_t space, arc_space_type_t type)
15191628

15201629
if (type != ARC_SPACE_DATA) {
15211630
ASSERT(arc_meta_used >= space);
1631+
if (arc_meta_max < arc_meta_used)
1632+
arc_meta_max = arc_meta_used;
15221633
ARCSTAT_INCR(arcstat_meta_used, -space);
15231634
}
15241635

@@ -4971,28 +5082,28 @@ arc_kstat_update(kstat_t *ksp, int rw)
49715082
arc_stats_t *as = ksp->ks_data;
49725083

49735084
if (rw == KSTAT_WRITE) {
4974-
return (SET_ERROR(EACCES));
5085+
return (EACCES);
49755086
} else {
49765087
arc_kstat_update_state(arc_anon,
49775088
&as->arcstat_anon_size,
4978-
&as->arcstat_anon_evict_data,
4979-
&as->arcstat_anon_evict_metadata);
5089+
&as->arcstat_anon_evictable_data,
5090+
&as->arcstat_anon_evictable_metadata);
49805091
arc_kstat_update_state(arc_mru,
49815092
&as->arcstat_mru_size,
4982-
&as->arcstat_mru_evict_data,
4983-
&as->arcstat_mru_evict_metadata);
5093+
&as->arcstat_mru_evictable_data,
5094+
&as->arcstat_mru_evictable_metadata);
49845095
arc_kstat_update_state(arc_mru_ghost,
49855096
&as->arcstat_mru_ghost_size,
4986-
&as->arcstat_mru_ghost_evict_data,
4987-
&as->arcstat_mru_ghost_evict_metadata);
5097+
&as->arcstat_mru_ghost_evictable_data,
5098+
&as->arcstat_mru_ghost_evictable_metadata);
49885099
arc_kstat_update_state(arc_mfu,
49895100
&as->arcstat_mfu_size,
4990-
&as->arcstat_mfu_evict_data,
4991-
&as->arcstat_mfu_evict_metadata);
5101+
&as->arcstat_mfu_evictable_data,
5102+
&as->arcstat_mfu_evictable_metadata);
49925103
arc_kstat_update_state(arc_mfu_ghost,
49935104
&as->arcstat_mfu_ghost_size,
4994-
&as->arcstat_mfu_ghost_evict_data,
4995-
&as->arcstat_mfu_ghost_evict_metadata);
5105+
&as->arcstat_mfu_ghost_evictable_data,
5106+
&as->arcstat_mfu_ghost_evictable_metadata);
49965107
}
49975108

49985109
return (0);

0 commit comments

Comments
 (0)