public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
@ 2023-07-01  7:38 Miaohe Lin
  2023-07-10 15:46 ` Michal Koutný
       [not found] ` <20230701073856.2095425-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Miaohe Lin @ 2023-07-01  7:38 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, hannes-druUgvl0LCNAfugRpC6u6w,
	lizefan.x-EC8Uxl6Npydl57MIdRCFDg
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linmiaohe-hv44wF8Li93QT0dZR+AlfA

The return value of cgroup_rm_cftypes_locked() is always 0. So remove
it to simplify the code. No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 kernel/cgroup/cgroup.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index bfe3cd8ccf36..b0d98542eea2 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4320,14 +4320,13 @@ static int cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
 	return ret;
 }
 
-static int cgroup_rm_cftypes_locked(struct cftype *cfts)
+static void cgroup_rm_cftypes_locked(struct cftype *cfts)
 {
 	lockdep_assert_held(&cgroup_mutex);
 
 	list_del(&cfts->node);
 	cgroup_apply_cftypes(cfts, false);
 	cgroup_exit_cftypes(cfts);
-	return 0;
 }
 
 /**
@@ -4343,8 +4342,6 @@ static int cgroup_rm_cftypes_locked(struct cftype *cfts)
  */
 int cgroup_rm_cftypes(struct cftype *cfts)
 {
-	int ret;
-
 	if (!cfts || cfts[0].name[0] == '\0')
 		return 0;
 
@@ -4352,9 +4349,9 @@ int cgroup_rm_cftypes(struct cftype *cfts)
 		return -ENOENT;
 
 	cgroup_lock();
-	ret = cgroup_rm_cftypes_locked(cfts);
+	cgroup_rm_cftypes_locked(cfts);
 	cgroup_unlock();
-	return ret;
+	return 0;
 }
 
 /**
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
  2023-07-01  7:38 [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked() Miaohe Lin
@ 2023-07-10 15:46 ` Michal Koutný
  2023-07-11  2:58   ` Miaohe Lin
       [not found] ` <20230701073856.2095425-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Michal Koutný @ 2023-07-10 15:46 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: tj, hannes, lizefan.x, cgroups, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Hi.

On Sat, Jul 01, 2023 at 03:38:56PM +0800, Miaohe Lin <linmiaohe@huawei.com> wrote:
> The return value of cgroup_rm_cftypes_locked() is always 0. So remove
> it to simplify the code. No functional change intended.

I'd add a comment that it builds upon cgroup_addrm_files()'s:
> For removals, this function never fails.

> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  kernel/cgroup/cgroup.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

Reviewed-by: Michal Koutný <mkoutny@suse.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
       [not found] ` <20230701073856.2095425-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2023-07-10 19:40   ` Tejun Heo
       [not found]     ` <ZKxeke6SfBe37Jso-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2023-07-10 19:40 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Sat, Jul 01, 2023 at 03:38:56PM +0800, Miaohe Lin wrote:
> The return value of cgroup_rm_cftypes_locked() is always 0. So remove
> it to simplify the code. No functional change intended.
> 
> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

Applied to cgroup/for-6.6. Please feel free to follow up with the comment
addition Michal suggested.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
  2023-07-10 15:46 ` Michal Koutný
@ 2023-07-11  2:58   ` Miaohe Lin
       [not found]     ` <7d3323ab-f796-6846-ab08-5d48734595e1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Miaohe Lin @ 2023-07-11  2:58 UTC (permalink / raw)
  To: Michal Koutný
  Cc: tj-DgEjT+Ai2ygdnm+yROfE0A, hannes-druUgvl0LCNAfugRpC6u6w,
	lizefan.x-EC8Uxl6Npydl57MIdRCFDg, cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 2023/7/10 23:46, Michal Koutný wrote:
> Hi.
> 
> On Sat, Jul 01, 2023 at 03:38:56PM +0800, Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
>> The return value of cgroup_rm_cftypes_locked() is always 0. So remove
>> it to simplify the code. No functional change intended.
> 
> I'd add a comment that it builds upon cgroup_addrm_files()'s:

Do you mean something like below:

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index b0d98542eea2..2c02f319a7d4 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4320,6 +4320,7 @@ static int cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
        return ret;
 }

+/* It builds upon cgroup_addrm_files()'s. */
 static void cgroup_rm_cftypes_locked(struct cftype *cfts)
 {
        lockdep_assert_held(&cgroup_mutex);


>> For removals, this function never fails.
> 
>> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> ---
>>  kernel/cgroup/cgroup.c | 9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> Reviewed-by: Michal Koutný <mkoutny-IBi9RG/b67k@public.gmane.org>

Thanks for review and suggestion.


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
       [not found]     ` <ZKxeke6SfBe37Jso-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
@ 2023-07-11  3:00       ` Miaohe Lin
       [not found]         ` <27428e7d-e280-2f78-7856-056d4e174057-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Miaohe Lin @ 2023-07-11  3:00 UTC (permalink / raw)
  To: Tejun Heo
  Cc: hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 2023/7/11 3:40, Tejun Heo wrote:
> On Sat, Jul 01, 2023 at 03:38:56PM +0800, Miaohe Lin wrote:
>> The return value of cgroup_rm_cftypes_locked() is always 0. So remove
>> it to simplify the code. No functional change intended.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> 
> Applied to cgroup/for-6.6. Please feel free to follow up with the comment
> addition Michal suggested.

Should I send a v2 patch or a separate patch? Both is fine to me.

Thanks for your work.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
       [not found]     ` <7d3323ab-f796-6846-ab08-5d48734595e1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2023-07-11 11:21       ` Michal Koutný
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Koutný @ 2023-07-11 11:21 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: tj-DgEjT+Ai2ygdnm+yROfE0A, hannes-druUgvl0LCNAfugRpC6u6w,
	lizefan.x-EC8Uxl6Npydl57MIdRCFDg, cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

On Tue, Jul 11, 2023 at 10:58:48AM +0800, Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
> +/* It builds upon cgroup_addrm_files()'s. */
>  static void cgroup_rm_cftypes_locked(struct cftype *cfts)
>  {
>         lockdep_assert_held(&cgroup_mutex);
> 

I meant adding the reasoning to the commit message -- swallowing errors
on removal is fine because cgroup_addrm_files() won't fail at removal.
It's a minor remark for the future readers ;-)

Michal

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
       [not found]         ` <27428e7d-e280-2f78-7856-056d4e174057-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2023-07-11 21:40           ` Tejun Heo
       [not found]             ` <ZK3MR5liSMSrlKVm-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2023-07-11 21:40 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, Jul 11, 2023 at 11:00:58AM +0800, Miaohe Lin wrote:
> On 2023/7/11 3:40, Tejun Heo wrote:
> > On Sat, Jul 01, 2023 at 03:38:56PM +0800, Miaohe Lin wrote:
> >> The return value of cgroup_rm_cftypes_locked() is always 0. So remove
> >> it to simplify the code. No functional change intended.
> >>
> >> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> > 
> > Applied to cgroup/for-6.6. Please feel free to follow up with the comment
> > addition Michal suggested.
> 
> Should I send a v2 patch or a separate patch? Both is fine to me.

Please send a separate patch.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
       [not found]             ` <ZK3MR5liSMSrlKVm-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
@ 2023-07-12  2:02               ` Miaohe Lin
  0 siblings, 0 replies; 8+ messages in thread
From: Miaohe Lin @ 2023-07-12  2:02 UTC (permalink / raw)
  To: Tejun Heo, Michal Koutný
  Cc: hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 2023/7/12 5:40, Tejun Heo wrote:
> On Tue, Jul 11, 2023 at 11:00:58AM +0800, Miaohe Lin wrote:
>> On 2023/7/11 3:40, Tejun Heo wrote:
>>> On Sat, Jul 01, 2023 at 03:38:56PM +0800, Miaohe Lin wrote:
>>>> The return value of cgroup_rm_cftypes_locked() is always 0. So remove
>>>> it to simplify the code. No functional change intended.
>>>>
>>>> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>>>
>>> Applied to cgroup/for-6.6. Please feel free to follow up with the comment
>>> addition Michal suggested.
>>
>> Should I send a v2 patch or a separate patch? Both is fine to me.
> 
> Please send a separate patch.

I see. But since Michal is meant adding the reasoning to the commit message, it seems
a v2 patch is required. Or could you help modify the commit message? It should looks
like:

"
The return value of cgroup_rm_cftypes_locked() is always 0 and swallowing
errors on removal is fine because cgroup_addrm_files() won't fail at
removal. So remove return value to simplify the code. No functional
change intended.
"

Thanks a lot.




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-12  2:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-01  7:38 [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked() Miaohe Lin
2023-07-10 15:46 ` Michal Koutný
2023-07-11  2:58   ` Miaohe Lin
     [not found]     ` <7d3323ab-f796-6846-ab08-5d48734595e1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-07-11 11:21       ` Michal Koutný
     [not found] ` <20230701073856.2095425-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-07-10 19:40   ` Tejun Heo
     [not found]     ` <ZKxeke6SfBe37Jso-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-07-11  3:00       ` Miaohe Lin
     [not found]         ` <27428e7d-e280-2f78-7856-056d4e174057-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-07-11 21:40           ` Tejun Heo
     [not found]             ` <ZK3MR5liSMSrlKVm-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-07-12  2:02               ` Miaohe Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox