linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition
@ 2023-09-12  7:04 Kamalesh Babulal
  2023-09-12  7:04 ` [PATCH 2/2] cgroup: Avoid extra dereference in css_populate_dir() Kamalesh Babulal
  2023-09-18 18:57 ` [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition Tejun Heo
  0 siblings, 2 replies; 4+ messages in thread
From: Kamalesh Babulal @ 2023-09-12  7:04 UTC (permalink / raw)
  To: Tejun Heo, Zefan Li, Johannes Weiner; +Cc: Tom Hromatka, cgroups, linux-kernel

There is no check for possible failure while populating
cgroup1_base_files cft in css_populate_dir(), like its cgroup v2 counter
parts cgroup_{base,psi}_files.  In case of failure, the cgroup might not
be set up right.  Add ret value check to return on failure.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
---
 kernel/cgroup/cgroup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 1fb7f562289d..a6b1ea324b0e 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1731,8 +1731,10 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
 					return ret;
 			}
 		} else {
-			cgroup_addrm_files(css, cgrp,
-					   cgroup1_base_files, true);
+			ret  =  cgroup_addrm_files(css, cgrp,
+						   cgroup1_base_files, true);
+			if  (ret  < 0)
+				return ret;
 		}
 	} else {
 		list_for_each_entry(cfts, &css->ss->cfts, node) {

base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
-- 
2.41.0


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

* [PATCH 2/2] cgroup: Avoid extra dereference in css_populate_dir()
  2023-09-12  7:04 [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition Kamalesh Babulal
@ 2023-09-12  7:04 ` Kamalesh Babulal
  2023-09-18 18:58   ` Tejun Heo
  2023-09-18 18:57 ` [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition Tejun Heo
  1 sibling, 1 reply; 4+ messages in thread
From: Kamalesh Babulal @ 2023-09-12  7:04 UTC (permalink / raw)
  To: Tejun Heo, Zefan Li, Johannes Weiner; +Cc: Tom Hromatka, cgroups, linux-kernel

Use css directly instead of dereferencing it from &cgroup->self, while
adding the cgroup v2 cft base and psi files in css_populate_dir(). Both
points to the same css, when css->ss is NULL, this avoids extra deferences
and makes code consistent in usage across the function.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
---
 kernel/cgroup/cgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index a6b1ea324b0e..f8ff85033e5a 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1719,13 +1719,13 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
 
 	if (!css->ss) {
 		if (cgroup_on_dfl(cgrp)) {
-			ret = cgroup_addrm_files(&cgrp->self, cgrp,
+			ret = cgroup_addrm_files(css, cgrp,
 						 cgroup_base_files, true);
 			if (ret < 0)
 				return ret;
 
 			if (cgroup_psi_enabled()) {
-				ret = cgroup_addrm_files(&cgrp->self, cgrp,
+				ret = cgroup_addrm_files(css, cgrp,
 							 cgroup_psi_files, true);
 				if (ret < 0)
 					return ret;
-- 
2.41.0


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

* Re: [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition
  2023-09-12  7:04 [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition Kamalesh Babulal
  2023-09-12  7:04 ` [PATCH 2/2] cgroup: Avoid extra dereference in css_populate_dir() Kamalesh Babulal
@ 2023-09-18 18:57 ` Tejun Heo
  1 sibling, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2023-09-18 18:57 UTC (permalink / raw)
  To: Kamalesh Babulal
  Cc: Zefan Li, Johannes Weiner, Tom Hromatka, cgroups, linux-kernel

On Tue, Sep 12, 2023 at 12:34:34PM +0530, Kamalesh Babulal wrote:
> There is no check for possible failure while populating
> cgroup1_base_files cft in css_populate_dir(), like its cgroup v2 counter
> parts cgroup_{base,psi}_files.  In case of failure, the cgroup might not
> be set up right.  Add ret value check to return on failure.
> 
> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>

Applied to cgroup/for-6.7 with double spaces removed.

Thanks.

-- 
tejun

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

* Re: [PATCH 2/2] cgroup: Avoid extra dereference in css_populate_dir()
  2023-09-12  7:04 ` [PATCH 2/2] cgroup: Avoid extra dereference in css_populate_dir() Kamalesh Babulal
@ 2023-09-18 18:58   ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2023-09-18 18:58 UTC (permalink / raw)
  To: Kamalesh Babulal
  Cc: Zefan Li, Johannes Weiner, Tom Hromatka, cgroups, linux-kernel

On Tue, Sep 12, 2023 at 12:34:35PM +0530, Kamalesh Babulal wrote:
> Use css directly instead of dereferencing it from &cgroup->self, while
> adding the cgroup v2 cft base and psi files in css_populate_dir(). Both
> points to the same css, when css->ss is NULL, this avoids extra deferences
> and makes code consistent in usage across the function.
> 
> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>

Applied to cgroup/for-6.7.

Thanks.

-- 
tejun

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

end of thread, other threads:[~2023-09-18 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12  7:04 [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition Kamalesh Babulal
2023-09-12  7:04 ` [PATCH 2/2] cgroup: Avoid extra dereference in css_populate_dir() Kamalesh Babulal
2023-09-18 18:58   ` Tejun Heo
2023-09-18 18:57 ` [PATCH 1/2] cgroup: Check for ret during cgroup1_base_files cft addition Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).