[2/2] cgroup: Avoid extra dereference in css_populate_dir()

Message ID 5870fc2459d97b2e47c5a8dc47f1a2a3837c5e03.1694501024.git.kamalesh.babulal@oracle.com
State New
Headers
Series [1/2] cgroup: Check for ret during cgroup1_base_files cft addition |

Commit Message

Kamalesh Babulal Sept. 12, 2023, 7:04 a.m. UTC
  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(-)
  

Comments

Tejun Heo Sept. 18, 2023, 6:58 p.m. UTC | #1
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.
  

Patch

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;