All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matias Ezequiel Vara Larsen <matiasevara@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: xen-devel@lists.xenproject.org,
	"Matias Ezequiel Vara Larsen" <matias.vara@vates.fr>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Dario Faggioli" <dfaggioli@suse.com>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>
Subject: Re: API/ABIs: Re: [RFC PATCH v2 0/2] Add a new acquire resource to query vcpu statistics
Date: Tue, 14 Mar 2023 11:28:15 +0100	[thread overview]
Message-ID: <20230314102815.GA4225@horizon> (raw)
In-Reply-To: <84e0cf30-d4f6-b1d2-b99c-7a297f5c5c2c@suse.com>

On Fri, Mar 10, 2023 at 12:34:33PM +0100, Jan Beulich wrote:
> On 10.03.2023 11:58, Matias Ezequiel Vara Larsen wrote:
> > Oh, I see, thanks for the clarification. To summarise, these are the current
> > options:
> > 1. Use a "uint64_t" field thus limiting the number of counters to 64. The
> > current vcpu_runstate_info structure is limited to 4 counters though, one for
> > each RUNSTATE_*. 
> > 2. Use a dynamic array but this makes harder to use the interface.
> > 3. Eliminate stats_active and set to ~0 the actual stats value to mark inactive
> > counters. This requires adding a "nr_stats" field to know how many counters are.
> 
> While nr_stats can indeed be seen as a generalization of the earlier
> stats_active, I think it is possible to get away without, as long as
> padding fields also are filled with the "inactive" marker.
> 

Understood.

> > Also, this requires to make sure to saturate at 2^^64-2.
> 
> Thinking of it - considering overflowed counters inactive looks like a
> reasonable model to me as well (which would mean saturating at 2^^64-1).
> 
> > I might miss some details here but these are the options to evaluate. 
> > 
> > I would go with a variation of 1) by using two uint64_t, i.e., up to 128 vcpu's
> > counters, which I think it would be enough. I may be wrong.
> 
> Well, to me it doesn't matter whether it's 32, 64, or 128 - my concern
> is with any kind of inherent upper bound. Using 128 right away might
> look excessive, just like 32 might look too little. Hence my desire to
> get away without any built-in upper bound. IOW I continue to favor 3,
> irrespective of the presence or absence of nr_stats.
> 
I see. 3) layout would look like:

struct vcpu_shmem_stats {
#define VCPU_STATS_MAGIC 0xaabbccdd
    uint32_t magic;
    uint32_t offset;  // roundup(sizeof(vcpu_shmem_stats), cacheline_size)
    uint32_t size;    // sizeof(vcpu_stats)
    uint32_t stride;  // roundup(sizeof(vcpu_stats), cacheline_size)
};

struct vcpu_stats {
    /*
     * If the least-significant bit of the seq number is set then an update
     * is in progress and the consumer must wait to read a consistent set of
     * values. This mechanism is similar to Linux's seqlock.
     */
    uint32_t seq;
    uint32 _pad;
    /*
     * If the most-significant bit of a counter is set then the counter
     * is inactive and the consumer must ignore its value. Note that this
     * could also indicate that the counter has overflowed.
     */
    uint64_t stats_a; // e.g., runstate_running_time
    ...
};

All padding fields shall be marked as "inactive". The consumer can't
distinguish inactive from overflowed. Also, the consumer shall always verify
before reading that:

offsetof(struct vcpu_stats, stats_y) < size. 

in case the consumer knows about a counter, e.g., stats_y, that Xen does not
it.

Matias 


  reply	other threads:[~2023-03-14 10:28 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 12:39 [RFC PATCH v2 0/2] Add a new acquire resource to query vcpu statistics Matias Ezequiel Vara Larsen
2022-10-07 12:39 ` [RFC PATCH v2 1/2] xen/memory : Add a stats_table resource type Matias Ezequiel Vara Larsen
2022-12-13 17:02   ` Jan Beulich
2023-02-16 14:48     ` Matias Ezequiel Vara Larsen
2023-02-16 15:10       ` Jan Beulich
2022-12-14  7:29   ` Jan Beulich
2022-12-14  7:56     ` Jan Beulich
2023-02-17  8:50       ` Matias Ezequiel Vara Larsen
2023-02-17  8:57         ` Jan Beulich
2023-02-17  9:29           ` Matias Ezequiel Vara Larsen
2023-02-17 14:10             ` Jan Beulich
2023-02-23 12:16               ` Matias Ezequiel Vara Larsen
2023-02-23 12:42                 ` Jan Beulich
2023-03-07 14:44                   ` Matias Ezequiel Vara Larsen
2023-03-07 16:55                     ` Jan Beulich
2023-03-09  9:22                       ` Matias Ezequiel Vara Larsen
2023-02-16 15:07     ` Matias Ezequiel Vara Larsen
2023-02-16 15:15       ` Jan Beulich
2023-02-20 16:51         ` Matias Ezequiel Vara Larsen
2023-02-21  8:48           ` Jan Beulich
2022-10-07 12:39 ` [RFC PATCH v2 2/2] tools/misc: Add xen-vcpus-stats tool Matias Ezequiel Vara Larsen
2023-02-23 16:01   ` Andrew Cooper
2023-02-23 20:31     ` Julien Grall
2023-03-17 11:01       ` Matias Ezequiel Vara Larsen
2023-03-29 21:29         ` Julien Grall
2023-02-24 15:31     ` Matias Ezequiel Vara Larsen
2023-02-23 19:56 ` API/ABIs: Re: [RFC PATCH v2 0/2] Add a new acquire resource to query vcpu statistics Andrew Cooper
2023-03-06 14:23   ` Matias Ezequiel Vara Larsen
2023-03-07 10:12     ` Jan Beulich
2023-03-08 11:54       ` Matias Ezequiel Vara Larsen
2023-03-08 14:16         ` Jan Beulich
2023-03-09 10:38           ` Matias Ezequiel Vara Larsen
2023-03-09 11:50             ` Jan Beulich
2023-03-10 10:58               ` Matias Ezequiel Vara Larsen
2023-03-10 11:34                 ` Jan Beulich
2023-03-14 10:28                   ` Matias Ezequiel Vara Larsen [this message]
2023-03-14 10:34                     ` Jan Beulich

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=20230314102815.GA4225@horizon \
    --to=matiasevara@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=dfaggioli@suse.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=matias.vara@vates.fr \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.