From: Anthony PERARD <anthony@xenproject.org>
To: Jahan Murudi <jahan.murudi.zg@renesas.com>
Cc: xen-devel@lists.xenproject.org,
Anthony PERARD <anthony.perard@vates.tech>
Subject: Re: [PATCH v4 2/4] xentop: add pcpu implementation with proper error handling
Date: Wed, 3 Sep 2025 19:00:42 +0200 [thread overview]
Message-ID: <aLh0OrD3LxxS5KHS@l14> (raw)
In-Reply-To: <20250903102323.2553142-3-jahan.murudi.zg@renesas.com>
On Wed, Sep 03, 2025 at 03:53:21PM +0530, Jahan Murudi wrote:
> diff --git a/tools/xentop/pcpu.c b/tools/xentop/pcpu.c
> new file mode 100644
> index 0000000000..cdb4cb2131
> --- /dev/null
> +++ b/tools/xentop/pcpu.c
[..]
> +/* Accessor functions for xentop.c */
> +int get_pcpu_count(void)
> +{
> + return allocated_pcpus;
> +}
> +
> +float get_pcpu_usage(int cpu_index)
You could use `size_t` instead of `int` for the `cpu_index`, and then,
no need to check for negatives. `allocated_pcpus` could also be `size_t`
or `unsigned int`, since "0" mean not available, we don't need "-1" or
other negative numbers.
> +{
> + if (!pcpu_stats || cpu_index < 0 || cpu_index >= allocated_pcpus) {
> + return 0.0;
> + }
> + return pcpu_stats[cpu_index].usage_pct;
> +}
Thanks,
--
Anthony PERARD
next prev parent reply other threads:[~2025-09-03 17:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 10:23 [PATCH v4 0/4] xentop: add physical CPU usage support Jahan Murudi
2025-09-03 10:23 ` [PATCH v4 1/4] xentop: add pcpu header and basic infrastructure Jahan Murudi
2025-09-03 10:23 ` [PATCH v4 2/4] xentop: add pcpu implementation with proper error handling Jahan Murudi
2025-09-03 17:00 ` Anthony PERARD [this message]
2025-09-03 10:23 ` [PATCH v4 3/4] xentop: update Makefile to link against libxenctrl Jahan Murudi
2025-09-03 10:23 ` [PATCH v4 4/4] xentop: integrate pcpu support into main program Jahan Murudi
2025-09-03 16:05 ` [PATCH v4 0/4] xentop: add physical CPU usage support Anthony PERARD
2025-09-03 17:07 ` Anthony PERARD
2025-09-03 18:01 ` Jahan Murudi
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=aLh0OrD3LxxS5KHS@l14 \
--to=anthony@xenproject.org \
--cc=anthony.perard@vates.tech \
--cc=jahan.murudi.zg@renesas.com \
--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.