All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincenzo Mezzela <vincenzo.mezzela@gmail.com>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: gregkh@linuxfoundation.org, javier.carrasco.cruz@gmail.com,
	julia.lawall@inria.fr, linux-kernel@vger.kernel.org,
	rafael@kernel.org, skhan@linuxfoundation.org
Subject: Re: [PATCH 0/2 v4] drivers: arch_topology: introduce automatic cleanup feature
Date: Tue, 14 May 2024 09:14:03 +0200	[thread overview]
Message-ID: <8a0df605-463f-4d61-ad64-a39f3ebb3153@gmail.com> (raw)
In-Reply-To: <ZkHlHAj1aPEToEYO@bogus>


On 13/05/24 12:02, Sudeep Holla wrote:
> On Mon, May 13, 2024 at 10:13:02AM +0200, Vincenzo Mezzela wrote:
>> This patch series introduces the automatic cleanup feature using the __free
>> attribute. With this modification, resources allocated with __free are
>> automatically released at the end of the scope.
>>
>> In some cases, modifying the structure of loops is necessary to utilize the
>> __free attribute effectively. For example:
>>
>> ```
>> struct device_node *t;
>>
>> do {
>>      t = of_get_child_by_name(..);
>>      if (t) {
>>
>>          // some code here
>>
>>          of_node_put(t);
>>      }
>>      i++;
>>
>> } while (t);
>>
>> //       ^
>> //       |
>> //  device_node here
>> ```
>>
>> To use the __free attribute here, we need to move the declaration of the device_node
>> within the loop, otherwise the automatic cleanup is called only at the end of the
>> function, and not at end of each iteration of the loop, being it scope-based.
>>
>> However, moving the declaration of the device_node within the loop, we can no
>> longer check the exit condition in the loop statement, being it outside
>> the loop's scope.
>>
>> Therefore, this work is split into two patches. The first patch moves the exit
>> condition of the loop directly within the loop's scope with an explicit break
>> statement:
>>
>> ```
>> struct device_node *t;
>>
>> do {
>>      t = of_get_child_by_name(..);
>>      if (!t)
>>          break;
>>
>>      // some code here
>>
>>      of_node_put(t);
>>      i++;
>>
>> } while (1);
>> ```
>> The second patch eliminates all of_node_put() calls, introducing the __free
>> attribute to the device_node.
>>
>>
>> changes in v2:
>>      - check loop exit condition within the loop
>>      - add cleanup.h header
>>
>> changes in v3:
>>      - split patch in two
>>      - fix misalignment
>>      - fix checkpatch warnings
>>      - replace break with return statement where possible
>>
>> changes in v4:
>>      - fix commit subject
>>      - fix coding style
>>
> Looks good now to me.
>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
>
> It is merge window now, so there is a chance that it may get lost. You
> may have to post it again at -rc1. Greg can then pick it up for v6.11
>
> --
> Regards,
> Sudeep

Ok, perfect.

Thanks!


Vincenzo



  reply	other threads:[~2024-05-14  7:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 13:19 [PATCH] drivers: use __free attribute instead of of_node_put() Vincenzo Mezzela
2024-04-19 14:01 ` Sudeep Holla
2024-04-22  8:27   ` Vincenzo Mezzela
2024-04-22 13:09   ` [PATCH v2] " Vincenzo Mezzela
2024-04-24 10:37     ` Sudeep Holla
2024-04-24 12:42       ` Vincenzo Mezzela
2024-04-24 12:54         ` Sudeep Holla
2024-05-01  9:43           ` [PATCH 0/2 v3] drivers: introduce automatic cleanup feature Vincenzo Mezzela
2024-05-01  9:43             ` [PATCH 1/2 v3] drivers: reorganize do-while loops Vincenzo Mezzela
2024-05-01 11:04               ` Sudeep Holla
2024-05-01  9:43             ` [PATCH 2/2 v3] drivers: use __free attribute instead of of_node_put() Vincenzo Mezzela
2024-05-01 10:48               ` Greg KH
2024-05-01 12:33                 ` Vincenzo Mezzela
2024-05-01 13:06                   ` Greg KH
2024-05-06 15:30                     ` Vincenzo Mezzela
2024-05-07 10:32                       ` Sudeep Holla
2024-05-01 11:08               ` Sudeep Holla
2024-05-01 11:56                 ` Julia Lawall
2024-05-01 13:19             ` [PATCH 0/2 v3] drivers: introduce automatic cleanup feature Conor Dooley
2024-05-13  8:13             ` [PATCH 0/2 v4] drivers: arch_topology: " Vincenzo Mezzela
2024-05-13  8:13               ` [PATCH 1/2 v4] drivers: arch_topology: Refactor do-while loops Vincenzo Mezzela
2024-05-13  8:13               ` [PATCH 2/2 v4] drivers: arch_topology: use __free attribute instead of of_node_put() Vincenzo Mezzela
2024-05-13 10:02               ` [PATCH 0/2 v4] drivers: arch_topology: introduce automatic cleanup feature Sudeep Holla
2024-05-14  7:14                 ` Vincenzo Mezzela [this message]
2024-05-28  8:23                 ` Vincenzo Mezzela
2024-06-03  8:45                   ` Sudeep Holla

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=8a0df605-463f-4d61-ad64-a39f3ebb3153@gmail.com \
    --to=vincenzo.mezzela@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=sudeep.holla@arm.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 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.