[PATCH] fs/resctrl: Optimize code in rdt_get_tree()

Shaopeng Tan posted 1 patch 3 months, 4 weeks ago
There is a newer version of this series
fs/resctrl/rdtgroup.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
[PATCH] fs/resctrl: Optimize code in rdt_get_tree()
Posted by Shaopeng Tan 3 months, 4 weeks ago
schemata_list_destroy() has to be called if schemata_list_create() fails.

rdt_get_tree() calls schemata_list_destroy() in two different ways: 
directly if schemata_list_create() itself fails and 
on the exit path via the out_schemata_free goto label.

Remove schemata_list_destroy() call on schemata_list_create() failure.
Use existing out_schemata_free goto label instead.

Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
 fs/resctrl/rdtgroup.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 1beb124e25f6..592d4f69fce9 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2608,10 +2608,8 @@ static int rdt_get_tree(struct fs_context *fc)
 		goto out_root;
 
 	ret = schemata_list_create();
-	if (ret) {
-		schemata_list_destroy();
-		goto out_ctx;
-	}
+	if (ret)
+		goto out_schemata_free;
 
 	ret = closid_init();
 	if (ret)
@@ -2683,7 +2681,6 @@ static int rdt_get_tree(struct fs_context *fc)
 	closid_exit();
 out_schemata_free:
 	schemata_list_destroy();
-out_ctx:
 	rdt_disable_ctx();
 out_root:
 	rdtgroup_destroy_root();
-- 
2.43.5
Re: [PATCH] fs/resctrl: Optimize code in rdt_get_tree()
Posted by Reinette Chatre 3 months, 4 weeks ago
Hi Shaopeng,

On 6/13/25 12:37 AM, Shaopeng Tan wrote:
> schemata_list_destroy() has to be called if schemata_list_create() fails.
> 
> rdt_get_tree() calls schemata_list_destroy() in two different ways: 
> directly if schemata_list_create() itself fails and 
> on the exit path via the out_schemata_free goto label.
> 
> Remove schemata_list_destroy() call on schemata_list_create() failure.
> Use existing out_schemata_free goto label instead.
> 
> Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
> ---
>  fs/resctrl/rdtgroup.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 1beb124e25f6..592d4f69fce9 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -2608,10 +2608,8 @@ static int rdt_get_tree(struct fs_context *fc)
>  		goto out_root;
>  
>  	ret = schemata_list_create();
> -	if (ret) {
> -		schemata_list_destroy();
> -		goto out_ctx;
> -	}
> +	if (ret)
> +		goto out_schemata_free;
>  
>  	ret = closid_init();
>  	if (ret)
> @@ -2683,7 +2681,6 @@ static int rdt_get_tree(struct fs_context *fc)
>  	closid_exit();
>  out_schemata_free:
>  	schemata_list_destroy();
> -out_ctx:
>  	rdt_disable_ctx();
>  out_root:
>  	rdtgroup_destroy_root();

Could you please resubmit this independently? That is, not in an
email thread with the cpumask patch?

With that:
| Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>

Thank you very much.

Reinette
Re: [PATCH] fs/resctrl: Optimize code in rdt_get_tree()
Posted by James Morse 3 months, 4 weeks ago
Hello!

On 13/06/2025 08:37, Shaopeng Tan wrote:
> schemata_list_destroy() has to be called if schemata_list_create() fails.
> 
> rdt_get_tree() calls schemata_list_destroy() in two different ways: 
> directly if schemata_list_create() itself fails and 
> on the exit path via the out_schemata_free goto label.
> 
> Remove schemata_list_destroy() call on schemata_list_create() failure.
> Use existing out_schemata_free goto label instead.

Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James