Message ID | 20230701073856.2095425-1-linmiaohe@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10897016vqr; Sat, 1 Jul 2023 01:04:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5X5id2oj8ep7tDzN2XlKy1cnQ5EsZrHNvnB5F+lkQ5DlYd5UASBiT/JnDqm5Vx3XIjHIOZ X-Received: by 2002:a5d:9601:0:b0:77a:c741:b749 with SMTP id w1-20020a5d9601000000b0077ac741b749mr4967597iol.1.1688198676611; Sat, 01 Jul 2023 01:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688198676; cv=none; d=google.com; s=arc-20160816; b=cyCkZ/2teFx8y5jyDj7tROuCaA6MKlsUCAYKDN8QK/YB5CmZqI93f9prPRKTU3I1fZ Mv+AKuhrh/1h9oMkl2C5OvhdnjA/M6uMCTcqgR9C2bI9CDK5K3f4OpNvbPQaGzYKu7JR 7VOKwTvFN4IZJWAPk1b11S210tkonLfKMGoZ01K/6wKUrwce2s8Pe4j2ufjJ3k6zIVri ak2tdhglfljqSv5XyKX7xC1poU5WF+mofmdZAJKdf0SKpw81X0/cHiDnEvPZ8/aMCygC JYQ+oTHP/OdsJFHbzMmVPQaan4uDTgFhCZ0rY/QWbmvwIbL29J12p45U3ZuzQgNRimGg wfiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=VYaot9a6LTC4ap0a0DDTSfvsDq/vrJkA8HTxWBCJTh4=; fh=/oR+NcEnzekdk9My/33KlMJIJsUMb/9hQpen5cpkHSY=; b=ocEkXINzTbhNJ7CUvBe5lOrkIe0fAosKVIHyvuNqcBtZAqBN/YPsHbz1a6PLBJtZ5E 2bSKS79i6/72X6/zK8cNdA8VQ4cordQaOnSASl/KezA4S2/u3b8lpeflgJvwwrZ6JOPv aF6JeOI8NBiRrvrkNshYHPz+6o+FiC1IStYKH/Fb+E67kWeznj6Vpy0CfpnWC0KR72hW KFycwNKfBiVRHq1CKKwg8BQ6+KsydYOOyWysYUZnx8Uuf4klXe9cL/tWWQBHOvDONK2g Ru976e6e6fPacLGO9L31u3NWwtpHmJGtCyAJWzNJoyqaq7fS2I0oEIw6QJkRvaIu//Kx yhsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y64-20020a638a43000000b0054fd4d7d642si13610785pgd.4.2023.07.01.01.04.23; Sat, 01 Jul 2023 01:04:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbjGAHik (ORCPT <rfc822;nicolai.engesland@gmail.com> + 99 others); Sat, 1 Jul 2023 03:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbjGAHih (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 1 Jul 2023 03:38:37 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA11199; Sat, 1 Jul 2023 00:38:34 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QtPCx4LL3zTknD; Sat, 1 Jul 2023 15:37:33 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 1 Jul 2023 15:38:29 +0800 From: Miaohe Lin <linmiaohe@huawei.com> To: <tj@kernel.org>, <hannes@cmpxchg.org>, <lizefan.x@bytedance.com> CC: <cgroups@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com> Subject: [PATCH] cgroup: remove unneeded return value of cgroup_rm_cftypes_locked() Date: Sat, 1 Jul 2023 15:38:56 +0800 Message-ID: <20230701073856.2095425-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770204615515806947?= X-GMAIL-MSGID: =?utf-8?q?1770204615515806947?= |
Series |
cgroup: remove unneeded return value of cgroup_rm_cftypes_locked()
|
|
Commit Message
Miaohe Lin
July 1, 2023, 7:38 a.m. UTC
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@huawei.com>
---
kernel/cgroup/cgroup.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
Comments
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>
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@huawei.com> Applied to cgroup/for-6.6. Please feel free to follow up with the comment addition Michal suggested. Thanks.
On 2023/7/10 23:46, Michal Koutný wrote: > 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: 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@huawei.com> >> --- >> kernel/cgroup/cgroup.c | 9 +++------ >> 1 file changed, 3 insertions(+), 6 deletions(-) > > Reviewed-by: Michal Koutný <mkoutny@suse.com> Thanks for review and suggestion.
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@huawei.com> > > 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.
On Tue, Jul 11, 2023 at 10:58:48AM +0800, Miaohe Lin <linmiaohe@huawei.com> 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
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@huawei.com> > > > > 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.
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@huawei.com> >>> >>> 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.
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; } /**