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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 65907C2D0BF for ; Tue, 10 Dec 2019 14:08:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 331CC207FF for ; Tue, 10 Dec 2019 14:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 331CC207FF 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 C3B896B2CAE; Tue, 10 Dec 2019 09:08:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BEBF16B2CAF; Tue, 10 Dec 2019 09:08:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B01786B2CB0; Tue, 10 Dec 2019 09:08:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id 966F56B2CAE for ; Tue, 10 Dec 2019 09:08:02 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 12A02181AEF31 for ; Tue, 10 Dec 2019 14:08:02 +0000 (UTC) X-FDA: 76249410804.27.hole03_80488a694a42d X-HE-Tag: hole03_80488a694a42d X-Filterd-Recvd-Size: 4858 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Dec 2019 14:08:01 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id q9so3362927wmj.5 for ; Tue, 10 Dec 2019 06:08:01 -0800 (PST) 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:user-agent; bh=JOrvgpzri55cuZvf0g5PJCe5RKiv3DNl9WA35jfmGNA=; b=KSmn51WIe48Dw+hePd4amI6yOwfbtAar6OoZAgEMHQMLr7b2Sq9wRyQ3x0GMEHfZ+J r/ZJ3EJXzgbYOu17Ya2a1xLTS2nJrsMsdk6VDUrYkyjzOAiRg3HcFVeha4FGjpywrM0O q5dUF+QLy/qvOe/6tuShzf5DFoaJB8kk/dutAEFoAUKOC9n4huFhMjvZI7aY3X8CrqDr UEv5/fkBze+z/IMtzTehaxbsAtfeoljrKa3Lg9K3cB9N97qruvckug4vME7SfUfFv4rk wIC8PQh51mGmHjJ36GT9iJ9p8E5HYlP5fztnFDmxXl79I/Ulp0FvixL07pIxRTBjnJs7 lvkw== X-Gm-Message-State: APjAAAVP6QEs3nu27+u0Q/u7jm9xWv8N8dw9ag5Vih4q2ugU3jdaZBDO PqQOPOv2IHmAnZxjhXt6/bA= X-Google-Smtp-Source: APXvYqwJtpMeRV9/dPQzUGGfgWCOqNHmCdtyqiAq1hNDJDJIwLpsBTZ3tqq0TEvFOmuvp5V761VrHw== X-Received: by 2002:a1c:7e13:: with SMTP id z19mr5424339wmc.67.1575986880429; Tue, 10 Dec 2019 06:08:00 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id b17sm3383425wrp.49.2019.12.10.06.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 06:07:59 -0800 (PST) Date: Tue, 10 Dec 2019 15:07:58 +0100 From: Michal Hocko To: chengkaitao Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, smuchun@gmail.com Subject: Re: [PATCH] mm: cleanup some useless code Message-ID: <20191210140758.GK10404@dhcp22.suse.cz> References: <20191210134911.2570-1-pilgrimtao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191210134911.2570-1-pilgrimtao@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) 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 10-12-19 05:49:10, chengkaitao wrote: > From: Kaitao Cheng > > There is a duplicate PageTransHuge, because hpage_nr_pages have > the same one. I am not a great fan of changes like these - a minor code churn without a clear benefit - but in this particular case I do agree that there is an improvement because we have two states to represent the same thing. I have hard time believing this makes a more optimal code as PageTransHuge is a trivial check so it doesn't make much sense to replicate the state locally. That being said the changelog could be improved a bit. What about something like the following? " Compound pages handling in mem_cgroup_migrate is more convoluted than necessary. The state is duplicated in compound variable and the same could be achieved by PageTransHuge check which is trivial and hpage_nr_pages is already PageTransHuge aware. It is much simpler to just use hpage_nr_pages for nr_pages and replace the local variable by PageTransHuge check directly " > Signed-off-by: Kaitao Cheng To the change Acked-by: Michal Hocko Thanks! > --- > mm/memcontrol.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index bc01423277c5..870284d3ee9d 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6678,7 +6678,6 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage) > { > struct mem_cgroup *memcg; > unsigned int nr_pages; > - bool compound; > unsigned long flags; > > VM_BUG_ON_PAGE(!PageLocked(oldpage), oldpage); > @@ -6700,8 +6699,7 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage) > return; > > /* Force-charge the new page. The old one will be freed soon */ > - compound = PageTransHuge(newpage); > - nr_pages = compound ? hpage_nr_pages(newpage) : 1; > + nr_pages = hpage_nr_pages(newpage); > > page_counter_charge(&memcg->memory, nr_pages); > if (do_memsw_account()) > @@ -6711,7 +6709,8 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage) > commit_charge(newpage, memcg, false); > > local_irq_save(flags); > - mem_cgroup_charge_statistics(memcg, newpage, compound, nr_pages); > + mem_cgroup_charge_statistics(memcg, newpage, PageTransHuge(newpage), > + nr_pages); > memcg_check_events(memcg, newpage); > local_irq_restore(flags); > } > -- > 2.20.1 -- Michal Hocko SUSE Labs