[PATCH 1/1] sched/fair:Avoid unnecessary assignment to cfs_rq->on_list
From: qianjun . kernel
Date: Wed Jan 06 2021 - 20:58:57 EST
From: jun qian <qianjun.kernel@xxxxxxxxx>
Obviously, cfs_rq->on_list is already equal to 1 when cfs_rq->on_list
is assigned a value of 1, so an else branch is needed to avoid unnecessary
assignment operations.
Signed-off-by: jun qian <qianjun.kernel@xxxxxxxxx>
---
kernel/sched/fair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 04a3ce20da67..ef6ebd95443d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -305,8 +305,8 @@ static inline bool list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
if (cfs_rq->on_list)
return rq->tmp_alone_branch == &rq->leaf_cfs_rq_list;
-
- cfs_rq->on_list = 1;
+ else
+ cfs_rq->on_list = 1;
/*
* Ensure we either appear before our parent (if already
--
2.18.2