linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded()
@ 2020-10-09 13:51 Miaohe Lin
  2020-10-09 15:12 ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: Miaohe Lin @ 2020-10-09 13:51 UTC (permalink / raw)
  To: akpm, hannes, mhocko, vdavydov.dev
  Cc: cgroups, linux-mm, linux-kernel, linmiaohe

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.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2636f8bad908..f607afd0fcbf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -629,7 +629,7 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
 		 * 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;
 	}
 
-- 
2.19.1



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

* Re: [PATCH] mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded()
  2020-10-09 13:51 [PATCH] mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded() Miaohe Lin
@ 2020-10-09 15:12 ` Michal Hocko
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2020-10-09 15:12 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, hannes, vdavydov.dev, cgroups, linux-mm, linux-kernel

On Fri 09-10-20 09:51:04, Miaohe Lin wrote:
> 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.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Acked-by: Michal Hocko <mhocko@suse.com>

I believe this is a result of a very unreadable code. Resp. the comment
makes it hard to follow. It would be slightly better to simply drop the
comment which doesn't really explain much IMHO.

> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 2636f8bad908..f607afd0fcbf 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -629,7 +629,7 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
>  		 * 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;
>  	}
>  
> -- 
> 2.19.1

-- 
Michal Hocko
SUSE Labs


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

* Re: [PATCH] mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded()
@ 2020-10-10  1:58 linmiaohe
  0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-10-10  1:58 UTC (permalink / raw)
  To: Michal Hocko; +Cc: akpm, hannes, vdavydov.dev, cgroups, linux-mm, linux-kernel

Michal Hocko <mhocko@suse.com> wrote:
> On Fri 09-10-20 09:51:04, Miaohe Lin wrote:
>> 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.
>> 
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>
>Acked-by: Michal Hocko <mhocko@suse.com>
>
>I believe this is a result of a very unreadable code. Resp. the comment makes it hard to follow. It would be slightly better to simply drop the comment which doesn't really explain much IMHO.
>

Agree. Will do it in v2. Many thanks.



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

end of thread, other threads:[~2020-10-10  1:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09 13:51 [PATCH] mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded() Miaohe Lin
2020-10-09 15:12 ` Michal Hocko
2020-10-10  1:58 linmiaohe

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).