From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74DD5C433E7 for ; Fri, 9 Oct 2020 15:12:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 317A4221FD for ; Fri, 9 Oct 2020 15:12:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="H9vZZHdq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389133AbgJIPMe (ORCPT ); Fri, 9 Oct 2020 11:12:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:42306 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388696AbgJIPMe (ORCPT ); Fri, 9 Oct 2020 11:12:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1602256352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BSD1kYo1TCGseCG0CMo0C9XsPcUqaOsDq8A7C+bHfAc=; b=H9vZZHdqeJILfnwmhQEIFVlV29sQ5i/dofyz5kArPDdfu1Dl+uoOE0Y+YJku6zahrYl3R8 R/CyAR+M+8h6Z/GdvxRvvFvdlvT3x/HxRWyaaesz1u2dqzvfRhAsNXJcGvmv0RJzWUK37C N8LATr1C4lgtsO/P/i/6e2kwNWMVDNU= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 592C3B251; Fri, 9 Oct 2020 15:12:32 +0000 (UTC) Date: Fri, 9 Oct 2020 17:12:27 +0200 From: Michal Hocko To: Miaohe Lin Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: memcontrol: eliminate redundant check in __mem_cgroup_insert_exceeded() Message-ID: <20201009151227.GP4967@dhcp22.suse.cz> References: <20201009135104.39048-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201009135104.39048-1-linmiaohe@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Michal Hocko 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