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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 E6CB5C54FCC for ; Tue, 21 Apr 2020 15:00:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5D8A206E9 for ; Tue, 21 Apr 2020 15:00:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5D8A206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5079F8E0005; Tue, 21 Apr 2020 11:00:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48FA98E0003; Tue, 21 Apr 2020 11:00:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37E898E0005; Tue, 21 Apr 2020 11:00:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 1D1248E0003 for ; Tue, 21 Apr 2020 11:00:00 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D3DE25DE5 for ; Tue, 21 Apr 2020 14:59:59 +0000 (UTC) X-FDA: 76732172118.19.crowd15_1d0ae78171039 X-HE-Tag: crowd15_1d0ae78171039 X-Filterd-Recvd-Size: 3541 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Apr 2020 14:59:59 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id k11so16848041wrp.5 for ; Tue, 21 Apr 2020 07:59:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6kQDmF+56uplUVq81ScUnvbvW6vesuxuQRIXZ8DEreE=; b=KuKdy/SHDPRHWBE+4wstASRz6PLxNxZG/+kVYJwWRXmARfM5c9N9NBl6NTLQLPZays GpFyrvZgM+pyiWBuMU1W6yfAOh98ciGIIo3pQ59OD/wd3FQXolKffKNp5XRG6UfzRx6t HhYC23X4p6bKq735JJwD/Pj4e/AgXoGDNvGCxdaZHjGBPLsYAi9Hiwc9xNxmVYNma/n8 iGzdvau/sbc0xcfzWCsTisECdwlBG9evuHVilcK9/jFgjD1BrA+rcwBaJ3HpABf7WgmK AUpAqNaXDfQFQ5iXMi7+b6pqEK+zPUw3oroUeYi1fLEKNW7VR8hajuSTqFJ/Zq+p7G+J +Q0A== X-Gm-Message-State: AGi0PubTaa/d6qjglu0X6fumi3xAih6gxTR6SfbQyqKHJwq36nGGR5r9 gqJc2n+6HCfd0JMGThv6NRk= X-Google-Smtp-Source: APiQypKeMWulrbl1hAeNFHUGPCL4mpVT1gBgKujxZ4+KGZyPdPdRG0DA8y1WWvu67sjrnznKWKZ+5Q== X-Received: by 2002:adf:b344:: with SMTP id k4mr23666341wrd.76.1587481198440; Tue, 21 Apr 2020 07:59:58 -0700 (PDT) Received: from localhost (ip-37-188-130-62.eurotel.cz. [37.188.130.62]) by smtp.gmail.com with ESMTPSA id m1sm4046629wro.64.2020.04.21.07.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 07:59:57 -0700 (PDT) Date: Tue, 21 Apr 2020 16:59:56 +0200 From: Michal Hocko To: xiakaixu1987@gmail.com Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, linux-mm@kvack.org, Kaixu Xia Subject: Re: [PATCH] mm: memcontrol: simplify value comparison between count and limit Message-ID: <20200421145956.GJ27314@dhcp22.suse.cz> References: <1587479661-27237-1-git-send-email-kaixuxia@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1587479661-27237-1-git-send-email-kaixuxia@tencent.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 Tue 21-04-20 22:34:21, xiakaixu1987@gmail.com wrote: > From: Kaixu Xia > > When the variables count and limit have the same value(count == limit), > the result of min(margin, limit - count) statement should be 0 and the > variable margin is set to 0. So in this case, the min() statement is not > necessary and we can directly set the variable margin to 0. I expect that the compiler would generate the same code but there is no reason to differ in memsw branch from the main limit check so the patch looks ok to me. > Signed-off-by: Kaixu Xia Acked-by: Michal Hocko > --- > mm/memcontrol.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 5beea03dd58a..fedc5afdc482 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1314,7 +1314,7 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg) > if (do_memsw_account()) { > count = page_counter_read(&memcg->memsw); > limit = READ_ONCE(memcg->memsw.max); > - if (count <= limit) > + if (count < limit) > margin = min(margin, limit - count); > else > margin = 0; > -- > 2.20.0 -- Michal Hocko SUSE Labs