From: "Sharma, Swati2" <swati2.sharma@intel.com>
To: "Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
igt-dev@lists.freedesktop.org,
"Adrián Larumbe" <adrian.larumbe@collabora.com>,
tvrtko.ursulin@intel.com, robdclark@chromium.org,
kernel@collabora.com
Subject: Re: [igt-dev] [PATCH 2/2] lib/igt_drm_fdinfo.c: refactor region array population code
Date: Wed, 9 Aug 2023 19:47:12 +0530 [thread overview]
Message-ID: <000e0cfb-3305-ed72-87a0-faef7197c8e5@intel.com> (raw)
In-Reply-To: <20230809113111.hi2ot2dkd4ozzrgf@kamilkon-desk1>
Hi Adrian,
Nitpick: Please remove .c from subject.
On 09-Aug-23 5:01 PM, Kamil Konieczny wrote:
> Hi Adrián,
> On 2023-08-08 at 22:03:31 +0100, Adrián Larumbe wrote:
>> The same sequence of operations is being done every time a DRM memory
>> region key:value pair is found in the DRM fdinfo file. Refactor them all
>> into a macro to avoid code reduplication.
>>
>> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
>
> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
>
>> ---
>> lib/igt_drm_fdinfo.c | 64 +++++++++++++-------------------------------
>> 1 file changed, 19 insertions(+), 45 deletions(-)
>>
>> diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
>> index f5a5b8e19dc3..b72822894782 100644
>> --- a/lib/igt_drm_fdinfo.c
>> +++ b/lib/igt_drm_fdinfo.c
>> @@ -191,6 +191,19 @@ out:
>> return found;
>> }
>>
>> +#define UPDATE_REGION(idx, region, val) \
>> + do { \
>> + if (idx >= 0) { \
>> + info->region_mem[idx].region = val; \
>> + if (!regions_found[idx]) { \
>> + info->num_regions++; \
>> + regions_found[idx] = true; \
>> + if (idx > info->last_region_index) \
>> + info->last_region_index = idx; \
>> + } \
>> + } \
>> + } while (0)
>> +
>> unsigned int
>> __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
>> const char **name_map, unsigned int map_entries,
>> @@ -245,63 +258,24 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
>> } else if (!strncmp(l, "drm-total-", 10)) {
>> idx = parse_region(l, info, strlen("drm-total-"),
>> region_map, region_entries, &val);
>> - if (idx >= 0) {
>> - info->region_mem[idx].total = val;
>> - if (!regions_found[idx]) {
>> - info->num_regions++;
>> - regions_found[idx] = true;
>> - if (idx > info->last_region_index)
>> - info->last_region_index = idx;
>> - }
>> - }
>> + UPDATE_REGION(idx, total, val);
>> } else if (!strncmp(l, "drm-shared-", 11)) {
>> idx = parse_region(l, info, strlen("drm-shared-"),
>> region_map, region_entries, &val);
>> - if (idx >= 0) {
>> - info->region_mem[idx].shared = val;
>> - if (!regions_found[idx]) {
>> - info->num_regions++;
>> - regions_found[idx] = true;
>> - if (idx > info->last_region_index)
>> - info->last_region_index = idx;
>> - }
>> - }
>> + UPDATE_REGION(idx, shared, val);
>> +
>> } else if (!strncmp(l, "drm-resident-", 13)) {
>> idx = parse_region(l, info, strlen("drm-resident-"),
>> region_map, region_entries, &val);
>> - if (idx >= 0) {
>> - info->region_mem[idx].resident = val;
>> - if (!regions_found[idx]) {
>> - info->num_regions++;
>> - regions_found[idx] = true;
>> - if (idx > info->last_region_index)
>> - info->last_region_index = idx;
>> - }
>> - }
>> + UPDATE_REGION(idx, resident, val);
>> } else if (!strncmp(l, "drm-purgeable-", 14)) {
>> idx = parse_region(l, info, strlen("drm-purgeable-"),
>> region_map, region_entries, &val);
>> - if (idx >= 0) {
>> - info->region_mem[idx].purgeable = val;
>> - if (!regions_found[idx]) {
>> - info->num_regions++;
>> - regions_found[idx] = true;
>> - if (idx > info->last_region_index)
>> - info->last_region_index = idx;
>> - }
>> - }
>> + UPDATE_REGION(idx, purgeable, val);
>> } else if (!strncmp(l, "drm-active-", 11)) {
>> idx = parse_region(l, info, strlen("drm-active-"),
>> region_map, region_entries, &val);
>> - if (idx >= 0) {
>> - info->region_mem[idx].active = val;
>> - if (!regions_found[idx]) {
>> - info->num_regions++;
>> - regions_found[idx] = true;
>> - if (idx > info->last_region_index)
>> - info->last_region_index = idx;
>> - }
>> - }
>> + UPDATE_REGION(idx, active, val);
>> }
>> }
>>
>> --
>> 2.41.0
>>
next prev parent reply other threads:[~2023-08-09 14:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 21:03 [igt-dev] [PATCH 1/2] gputop: fix region array max iteration index loop bug Adrián Larumbe
2023-08-08 21:03 ` [igt-dev] [PATCH 2/2] lib/igt_drm_fdinfo.c: refactor region array population code Adrián Larumbe
2023-08-09 11:31 ` Kamil Konieczny
2023-08-09 14:17 ` Sharma, Swati2 [this message]
2023-08-08 22:42 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] gputop: fix region array max iteration index loop bug Patchwork
2023-08-09 1:56 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-09 11:08 ` [igt-dev] [PATCH 1/2] " Kamil Konieczny
2023-08-09 11:15 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [1/2] " Patchwork
2023-08-10 19:18 ` Kamil Konieczny
2023-08-11 9:23 ` Yedireswarapu, SaiX Nandan
2023-08-11 6:55 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
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=000e0cfb-3305-ed72-87a0-faef7197c8e5@intel.com \
--to=swati2.sharma@intel.com \
--cc=adrian.larumbe@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=kernel@collabora.com \
--cc=robdclark@chromium.org \
--cc=tvrtko.ursulin@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox