* dm-cache-statistics and DMEMIT
@ 2025-08-18 19:05 John Rinehart
2025-08-18 19:55 ` Bryn M. Reeves
0 siblings, 1 reply; 2+ messages in thread
From: John Rinehart @ 2025-08-18 19:05 UTC (permalink / raw)
To: dm-devel
I'm using dm-cache in writeback mode and I'm trying to figure out how
I can see the cache stats in "real-time" (poll every second). Like, I
want to poll for the values in this data structure:
https://github.com/torvalds/linux/blob/be48bcf004f9d0c9207ff21d0edb3b42f253829e/drivers/md/dm-cache-target.c#L283-L295.
But, I'm at a loss for how to do that.
There are also these DMEMIT messages that I'm really interested in
printing to dmesg or subscribing to, or whatever, but I don't know how
to access them (CONFIG_DM_DEBUG didn't do anything useful - which
makes sense after reading the source a bit):
https://github.com/torvalds/linux/blob/be48bcf004f9d0c9207ff21d0edb3b42f253829e/drivers/md/dm-cache-target.c#L3184-L3197.
Can you help a brother out?
Thanks!
-- John Rinehart
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: dm-cache-statistics and DMEMIT
2025-08-18 19:05 dm-cache-statistics and DMEMIT John Rinehart
@ 2025-08-18 19:55 ` Bryn M. Reeves
0 siblings, 0 replies; 2+ messages in thread
From: Bryn M. Reeves @ 2025-08-18 19:55 UTC (permalink / raw)
To: John Rinehart; +Cc: dm-devel
On Mon, Aug 18, 2025 at 12:05:08PM -0700, John Rinehart wrote:
> I'm using dm-cache in writeback mode and I'm trying to figure out how
> I can see the cache stats in "real-time" (poll every second). Like, I
> want to poll for the values in this data structure:
> https://github.com/torvalds/linux/blob/be48bcf004f9d0c9207ff21d0edb3b42f253829e/drivers/md/dm-cache-target.c#L283-L295.
>
> But, I'm at a loss for how to do that.
That's the internal data structure that tracks the cache stats: you
could write a bpf or systemtap script to dump the contents periodically
if you really want to get at every field.
> There are also these DMEMIT messages that I'm really interested in
> printing to dmesg or subscribing to, or whatever, but I don't know how
> to access them (CONFIG_DM_DEBUG didn't do anything useful - which
> makes sense after reading the source a bit):
> https://github.com/torvalds/linux/blob/be48bcf004f9d0c9207ff21d0edb3b42f253829e/drivers/md/dm-cache-target.c#L3184-L3197.
This is the 'status' handler for the cache target - the DMEMIT() is what
prints the status values for the target in response to the
DM_TABLE_STATUS ioctl. The easiest way to retrieve it is with the
'dmsetup status' command.
I don't have a dm-cache device to hand right now, but here's how it
behaves for a dm-snapshot device and a thin pool. The cache target
follows the same pattern (with the fields described in the comment above
the code you linked to, on line 3134):
# dmsetup status /dev/mapper/fedora-root--snapset_before
0 20971520 snapshot 168344/21061632 664
# dmsetup status /dev/mapper/fedora-pool0-tpool
0 4194304 thin-pool 815 124/1024 1883/32768 - rw discard_passdown queue_if_no_space - 256
There's a slightly more detailed description of the status fields in the
docs: Documentation/admin-guide/device-mapper/cache.rst (other files in
that directory describe the other DM targets).
Regards,
Bryn.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-18 19:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 19:05 dm-cache-statistics and DMEMIT John Rinehart
2025-08-18 19:55 ` Bryn M. Reeves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).