Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: wuyifan <wuyifan50@huawei.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
	<tony.luck@intel.com>, <Dave.Martin@arm.com>,
	<james.morse@arm.com>, <babu.moger@amd.com>, <shuah@kernel.org>,
	<tan.shaopeng@fujitsu.com>, <fenghuay@nvidia.com>,
	<ben.horgan@arm.com>, <jonathan.cameron@huawei.com>,
	<zengheng4@huawei.com>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kselftest@vger.kernel.org>, <linuxarm@huawei.com>
Cc: <xiaqinxin@huawei.com>, <prime.zeng@hisilicon.com>,
	<wangyushan12@huawei.com>, <xuwei5@huawei.com>,
	<fanghao11@huawei.com>, <wangzhou1@hisilicon.com>
Subject: Re: [PATCH v2 1/6] selftests/resctrl: Introduced linked list management for IMC counters
Date: Wed, 6 May 2026 15:17:52 +0800	[thread overview]
Message-ID: <e4a2b49a-0efe-4942-9683-9c9a5af1b12a@huawei.com> (raw)
In-Reply-To: <b1d3a653-79a5-44db-8d57-c052ae537823@intel.com>

Hi Reinette,

On 4/23/2026 12:02 AM, Reinette Chatre wrote:
> Hi Yifan,
>
> On 4/10/26 2:33 AM, Yifan Wu wrote:
>> @@ -113,6 +115,7 @@ static int parse_imc_read_bw_events(char *imc_dir, unsigned int type,
>>   				    unsigned int *count)
>>   {
>>   	char imc_events_dir[PATH_MAX], imc_counter_cfg[PATH_MAX];
>> +	struct imc_counter_config *imc_counter;
>>   	unsigned int orig_count = *count;
>>   	char cas_count_cfg[1024];
>>   	struct dirent *ep;
>> @@ -167,11 +170,17 @@ static int parse_imc_read_bw_events(char *imc_dir, unsigned int type,
>>   			ksft_print_msg("Maximum iMC count exceeded\n");
>>   			goto out_close;
>>   		}
>> +		imc_counter = calloc(1, sizeof(*imc_counter));
>> +		if (!imc_counter) {
>> +			ksft_perror("Unable to allocate memory for iMC counters\n");
>> +			goto out_close;
>> +		}
>>   
>>   		imc_counters_config[*count].type = type;
>>   		get_read_event_and_umask(cas_count_cfg, *count);
>>   		/* Do not fail after incrementing *count. */
>>   		*count += 1;
>> +		list_add(&imc_counter->entry, &imc_counters_list);
>>   	}
>>   	if (*count == orig_count) {
>>   		ksft_print_msg("Unable to find events in %s\n", imc_events_dir);
> Should cleanup_read_mem_bw_imc() be called on error exit path?
Thank you for your suggestion. When parse_imc_read_bw_events() exits with an
error, the linked list imc_counters_list will be cleaned up in 
test_cleanup().

main()
└── run_single_test()
     ├── mbm_run_test()
     │   └── resctrl_val()
     │       └── mbm_init()
     │           └── initialize_read_mem_bw_imc()
     │               └── enumerate_imcs()
     │                   └── read_from_imc_dir()
     │                       └── parse_imc_read_bw_events()
     │                           └── calloc()
     └── test_cleanup()
         └── mbm_test_cleanup()
             └── cleanup_read_mem_bw_imc()

Calling cleanup_read_mem_bw_imc() in the error exit path may be intended
to prevent resource leaks. However, this results in the function being 
called
repeatedly in both the error exit branch and test_cleanup().

Is there any specific intention behind calling it in 
parse_imc_read_bw_events()?
Or should the cleanup be uniformly handled in test_cleanup()?

Yifan




  reply	other threads:[~2026-05-06  7:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  9:33 [PATCH v2 0/6] selftests/resctrl: Add dynamic linked list management for IMC counters Yifan Wu
2026-04-10  9:33 ` [PATCH v2 1/6] selftests/resctrl: Introduced " Yifan Wu
2026-04-22 16:02   ` Reinette Chatre
2026-05-06  7:17     ` wuyifan [this message]
2026-05-07 16:13       ` Reinette Chatre
2026-05-08 10:14         ` wuyifan
2026-04-10  9:33 ` [PATCH v2 2/6] selftests/resctrl: Refactor the discovery of IMC counters using linked list Yifan Wu
2026-04-22 16:04   ` Reinette Chatre
2026-04-10  9:33 ` [PATCH v2 3/6] selftests/resctrl: Refactor the initialization of IMC's perf_event_attr " Yifan Wu
2026-04-22 16:05   ` Reinette Chatre
2026-04-10  9:33 ` [PATCH v2 4/6] selftests/resctrl: Refactor perf event open/close " Yifan Wu
2026-04-22 16:05   ` Reinette Chatre
2026-04-10  9:33 ` [PATCH v2 5/6] selftests/resctrl: Refactor reading from IMC " Yifan Wu
2026-04-10  9:33 ` [PATCH v2 6/6] selftests/resctrl: Remove the definition of the IMC counter config array and imcs Yifan Wu
2026-04-22 16:05   ` Reinette Chatre

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=e4a2b49a-0efe-4942-9683-9c9a5af1b12a@huawei.com \
    --to=wuyifan50@huawei.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=fanghao11@huawei.com \
    --cc=fenghuay@nvidia.com \
    --cc=james.morse@arm.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=reinette.chatre@intel.com \
    --cc=shuah@kernel.org \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tony.luck@intel.com \
    --cc=wangyushan12@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=xiaqinxin@huawei.com \
    --cc=xuwei5@huawei.com \
    --cc=zengheng4@huawei.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