[igt-dev] [PATCH 1/2] gputop: fix region array max iteration index loop bug
Kamil Konieczny
kamil.konieczny at linux.intel.com
Wed Aug 9 11:08:45 UTC 2023
Hi Adrián,
On 2023-08-08 at 22:03:30 +0100, Adrián Larumbe wrote:
> If c->regions->num_regions equals 1, then c->regions->max_region_id equals
> 0, so neither of the cumulative memory region size loops will be executed.
> Fix it by adjusting loop termination condition.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe at collabora.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
> tools/gputop.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/gputop.c b/tools/gputop.c
> index ac106abea2ee..ea95e0333dd2 100644
> --- a/tools/gputop.c
> +++ b/tools/gputop.c
> @@ -166,11 +166,11 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
> len = printf("%*s ", c->clients->max_pid_len, c->pid_str);
>
> if (c->regions->num_regions) {
> - for (sz = 0, i = 0; i < c->regions->max_region_id; i++)
> + for (sz = 0, i = 0; i <= c->regions->max_region_id; i++)
> sz += c->memory[i].total;
> len += print_size(sz);
>
> - for (sz = 0, i = 0; i < c->regions->max_region_id; i++)
> + for (sz = 0, i = 0; i <= c->regions->max_region_id; i++)
> sz += c->memory[i].resident;
> len += print_size(sz);
> }
> --
> 2.41.0
>
More information about the igt-dev
mailing list