Skip to contentSkip to conversation

mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded()

PATCH Applied Miaohe Lin 2 participants 2 messages Oct 12, 2020

Subsystems (3)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH v2 1/1 mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded()

The mz->usage_in_excess >= mz_node->usage_in_excess check is exactly the else case of mz->usage_in_excess < mz_node->usage_in_excess. So we could replace else if (mz->usage_in_excess >= mz_node->usage_in_excess) with else equally. Also drop the comment which doesn't really explain much.

---
 mm/memcontrol.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
mm/memcontrol.c +2 -7
index 2636f8bad908..b080a9434b9e 100644
@@ -623,14 +623,9 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
 		if (mz->usage_in_excess < mz_node->usage_in_excess) {
 			p = &(*p)->rb_left;
 			rightmost = false;
-		}
-
-		/*
-		 * We can't avoid mem cgroups that are over their soft
-		 * limit by the same amount
-		 */
-		else if (mz->usage_in_excess >= mz_node->usage_in_excess)
+		} else {
 			p = &(*p)->rb_right;
+		}
 	}
 
 	if (rightmost)
Signature · 1 line
2.19.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · Miaohe Lin

The mz->usage_in_excess >= mz_node->usage_in_excess check is exactly the else case of mz->usage_in_excess < mz_node->usage_in_excess. So we could replace else if (mz->usage_in_excess >= mz_node->usage_in_excess) with else equally. Also drop the comment which doesn't really explain much.

Looks good to me.