All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v4 12/13] monitor: add 'info ramblock-attributes' command
Date: Tue, 19 May 2026 12:00:13 +0200	[thread overview]
Message-ID: <87bjebpvma.fsf@pond.sub.org> (raw)
In-Reply-To: <CAJ+F1CKpZsWFZy9LSU8WCekNq3B_hWhfw4Xz1pyp2zkRzhPs_g@mail.gmail.com> ("Marc-André Lureau"'s message of "Mon, 18 May 2026 12:27:02 +0400")

Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Hi Markus
>
> I am not an expert in this area, and I am only working on this series
> occasionally (too little activity to keep me fresh on the topic,
> unfortunately). Bear with me.

Sure!

> On Mon, May 18, 2026 at 10:34 AM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>>
>> > Add a new 'info ramblock-attributes' HMP command and the corresponding
>> > 'x-query-ramblock-attributes' QMP command to display the shared/private
>> > memory attributes for ram blocks.
>> >
>> > The QMP command returns structured data (RamBlockAttributesInfo list
>> > with per-range shared/populated attributes), while HMP formats it for
>> > human consumption.
>> >
>> > This is useful for debugging confidential guests (TDX, SNP) to inspect
>> > which memory regions are shared vs private, and their population state
>> > when a RamDiscardManager is present (e.g. virtio-mem).
>> >
>> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> > ---
>> >  qapi/machine.json             | 55 +++++++++++++++++++++++++++++++++
>> >  include/monitor/hmp.h         |  1 +
>> >  hw/core/machine-hmp-cmds.c    | 32 +++++++++++++++++++
>> >  system/ram-block-attributes.c | 72 +++++++++++++++++++++++++++++++++++++++++++
>> >  hmp-commands-info.hx          | 13 ++++++++
>> >  5 files changed, 173 insertions(+)
>> >
>> > diff --git a/qapi/machine.json b/qapi/machine.json
>> > index 685e4e29b87..aac8a235cf6 100644
>> > --- a/qapi/machine.json
>> > +++ b/qapi/machine.json
>>
>> I have a few fairly ignorant questions.  They may or may not indicate a
>> need for doc improvements.
>>
>> > @@ -1738,6 +1738,61 @@
>> >    'returns': 'HumanReadableText',
>> >    'features': [ 'unstable' ] }
>> >
>> > +##
>> > +# @RamBlockAttributeRange:
>> > +#
>> > +# A contiguous range within a ram block with uniform attributes.
>>
>> RAM please.  More of the same below, not flagging it again.
>>
>
> ok
>
>> > +#
>> > +# @start: start offset in bytes within the ram block
>> > +#
>> > +# @length: length in bytes of the range
>> > +#
>> > +# @shared: true if the range is shared, false if private
>>
>> What does it mean for a range to be shared?
>
> commit 5d6483edaa9232d8f3709f68c8eab4bc2033fb70
> "in the current context
>     of RamDiscardManager for guest_memfd, the shared state is analogous to
>     being populated, while the private state can be considered discarded for
>     simplicity. In the future, it would be more complicated if considering
>     more states like private/shared/discarded at the same time."

Thought and care went into that commit message.  Unfortunately, it's
still greek to me.  Not criticism!  It needs to make sense to the people
working in that area, and I'm not.

Can we assume that anybody with a use for x-query-ramblock-attributes
understands what "range is shared" means?

>> > +#
>> > +# @populated: true if the range is populated (only present when a
>> > +#     RamDiscardManager is managing the block)
>>
>> What's a RamDiscardManager?
>
> commit 8947d7fc4e77d36fae44411b1b63c513863f89a7
>  * A #RamDiscardManager coordinates which parts of specific RAM #MemoryRegion
>  * regions are currently populated to be used/accessed by the VM, notifying
>  * after parts were discarded (freeing up memory) and before parts will be
>  * populated (consuming memory), to be used/accessed by the VM.
>
> In this series, RamDiscardManager learned to aggregate from multiple
> sources (virtio-mem + RamBlockAttributes), so virtio-mem can work with
> confidential VMs.

Can we assume that anybody with a use for x-query-ramblock-attributes
understands what "a RamDiscardManager is managing the block" means?

I can't find anything about RamDiscardManager in docs.  Would it make
sense to have something there, so we can point to it here?

>> > +#
>> > +# Since: 11.1
>> > +##
>> > +{ 'struct': 'RamBlockAttributeRange',
>> > +  'data': { 'start': 'uint64',
>> > +            'length': 'uint64',
>> > +            'shared': 'bool',
>> > +            '*populated': 'bool' } }
>> > +
>> > +##
>> > +# @RamBlockAttributesInfo:
>> > +#
>> > +# Shared/private memory attributes for a ram block.
>> > +#
>> > +# @name: the ram block identifier
>>
>> Where do RAM block names come from?
>
> They are set during vmstate_register_ram(). "idstr" and "name" are
> used interchangeably to refer to it.

    void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
    {
        qemu_ram_set_idstr(mr->ram_block,
                           memory_region_name(mr), dev);
        qemu_ram_set_migratable(mr->ram_block);
        ram_block_add_cpr_blocker(mr->ram_block, &error_fatal);
    }

Looks like it's the name of the memory region associated with the RAM
block.  Would "the memory region name" do?  Or would something like "the
name of the RAM block's memory region" be better?

>>
>> > +#
>> > +# @ranges: list of attribute ranges
>> > +#
>> > +# Since: 11.1
>> > +##
>> > +{ 'struct': 'RamBlockAttributesInfo',
>> > +  'data': { 'name': 'str',
>> > +            'ranges': [ 'RamBlockAttributeRange' ] } }
>> > +
>> > +##
>> > +# @x-query-ramblock-attributes:
>> > +#
>> > +# Query ram block shared/private attributes.  This is useful
>> > +# to debug confidential guests.
>>
>> What are RAM blocks?
>
> They are the actual host allocated memory backing guest RAM MemoryRegions

How are RAM blocks related to memory regions?

>> > +#
>> > +# Features:
>> > +#
>> > +# @unstable: This command is meant for debugging.
>> > +#
>> > +# Returns: list of ram block attributes
>> > +#
>> > +# Since: 11.1
>> > +##
>> > +{ 'command': 'x-query-ramblock-attributes',
>> > +  'returns': [ 'RamBlockAttributesInfo' ],
>> > +  'features': [ 'unstable' ] }
>> > +
>> >  ##
>> >  # @x-query-roms:
>> >  #
>>
>> [...]



  reply	other threads:[~2026-05-19 10:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 12:30 [PATCH v4 00/13] Make RamDiscardManager work with multiple sources & virtio-mem Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 01/13] system/memory: split RamDiscardManager into source and manager Marc-André Lureau
2026-06-02 13:31   ` David Hildenbrand (Arm)
2026-05-04 12:30 ` [PATCH v4 02/13] system/memory: move RamDiscardManager to separate compilation unit Marc-André Lureau
2026-06-02 13:33   ` David Hildenbrand (Arm)
2026-05-04 12:30 ` [PATCH v4 03/13] system/memory: constify section arguments Marc-André Lureau
2026-05-18  7:30   ` Philippe Mathieu-Daudé
2026-06-02 13:33   ` David Hildenbrand (Arm)
2026-05-04 12:30 ` [PATCH v4 04/13] system/ram-discard-manager: implement replay via is_populated iteration Marc-André Lureau
2026-05-13 20:40   ` Peter Xu
2026-06-02 13:37   ` David Hildenbrand (Arm)
2026-06-03 15:00     ` marcandre.lureau
2026-05-04 12:30 ` [PATCH v4 05/13] virtio-mem: remove replay_populated/replay_discarded implementation Marc-André Lureau
2026-05-13 20:40   ` Peter Xu
2026-06-02 13:38   ` David Hildenbrand (Arm)
2026-05-04 12:30 ` [PATCH v4 06/13] system/ram-discard-manager: drop replay from source interface Marc-André Lureau
2026-05-13 20:40   ` Peter Xu
2026-06-02 13:41   ` David Hildenbrand (Arm)
2026-05-04 12:30 ` [PATCH v4 07/13] system/memory: implement RamDiscardManager multi-source aggregation Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 08/13] system/physmem: destroy ram block attributes before RCU-deferred reclaim Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 09/13] system/memory: add RamDiscardManager reference counting and cleanup Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 10/13] tests: add unit tests for RamDiscardManager multi-source aggregation Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 11/13] system/physmem: make ram_block_discard_range() handle guest_memfd Marc-André Lureau
2026-05-13 20:37   ` Peter Xu
2026-05-27  9:49   ` Xiaoyao Li
2026-05-04 12:30 ` [PATCH v4 12/13] monitor: add 'info ramblock-attributes' command Marc-André Lureau
2026-05-13 20:39   ` Peter Xu
2026-05-18 10:29     ` marcandre.lureau
2026-05-18  6:32   ` Markus Armbruster
2026-05-18  8:27     ` Marc-André Lureau
2026-05-19 10:00       ` Markus Armbruster [this message]
2026-06-02 13:54   ` David Hildenbrand (Arm)
2026-06-04 11:59     ` Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 13/13] RFC: hw/virtio: start virtio-mem guest_memfd regions as shared Marc-André Lureau
2026-05-13 20:47   ` Peter Xu
2026-05-27  9:48     ` Xiaoyao Li
2026-06-02 13:50       ` David Hildenbrand (Arm)
2026-06-02 14:29         ` Xiaoyao Li
2026-05-14  7:32   ` Chenyi Qiang
2026-05-13 20:53 ` [PATCH v4 00/13] Make RamDiscardManager work with multiple sources & virtio-mem Peter Xu
2026-05-14  5:15   ` Chenyi Qiang
2026-06-02 13:23   ` David Hildenbrand (Arm)

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=87bjebpvma.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.