All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryn M. Reeves" <bmr@redhat.com>
To: John Rinehart <johnrichardrinehart@gmail.com>
Cc: dm-devel@lists.linux.dev
Subject: Re: dm-cache-statistics and DMEMIT
Date: Mon, 18 Aug 2025 20:55:25 +0100	[thread overview]
Message-ID: <aKOFLeLCn_rJ74gr@redhat.com> (raw)
In-Reply-To: <CAGc5Yo9DFwyzNMtv5hochwhpqY3Pv6uqkqshUTOo++LAbs=jgw@mail.gmail.com>

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.


      reply	other threads:[~2025-08-18 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-18 19:05 dm-cache-statistics and DMEMIT John Rinehart
2025-08-18 19:55 ` Bryn M. Reeves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aKOFLeLCn_rJ74gr@redhat.com \
    --to=bmr@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=johnrichardrinehart@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.