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=unavailable 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 CCFA5C433DF for ; Fri, 9 Oct 2020 15:12:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5365722277 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" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5365722277 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DD0786B00B4; Fri, 9 Oct 2020 11:12:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5B306B00B5; Fri, 9 Oct 2020 11:12:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C22316B00B6; Fri, 9 Oct 2020 11:12:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 913636B00B4 for ; Fri, 9 Oct 2020 11:12:34 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2838E8249980 for ; Fri, 9 Oct 2020 15:12:34 +0000 (UTC) X-FDA: 77352728628.09.goat06_0709d3e271e1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 0CA52180AD811 for ; Fri, 9 Oct 2020 15:12:34 +0000 (UTC) X-HE-Tag: goat06_0709d3e271e1 X-Filterd-Recvd-Size: 2710 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 15:12:33 +0000 (UTC) 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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