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=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 BFE30C4332E for ; Thu, 19 Mar 2020 17:36:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 817662071C for ; Thu, 19 Mar 2020 17:36:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="mNWMwk+E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 817662071C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0D1BB6B0003; Thu, 19 Mar 2020 13:36:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 083DE6B0005; Thu, 19 Mar 2020 13:36:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDA7B6B0007; Thu, 19 Mar 2020 13:36:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id D31686B0003 for ; Thu, 19 Mar 2020 13:36:10 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 777701856D0D5 for ; Thu, 19 Mar 2020 17:36:10 +0000 (UTC) X-FDA: 76612815300.25.trip84_35da050a21558 X-HE-Tag: trip84_35da050a21558 X-Filterd-Recvd-Size: 4091 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Mar 2020 17:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IEK/DGbSglZceWdKeekxvkYd/Isw9Ua7BiMcMgLRKmo=; b=mNWMwk+EUsI+VjH6MdPgKGgefC YBkSw+cxFz+nnt6AagRRD+FbEIDzSxnD+r2kyizVy9/3rk3y7dJaXIQ7snTu3ypkJ5+nt5c+GWYtX itTzqvvZ968ONxqiQyXuhqjFjY+15mq85BIZ+EwNrpEcA0k5Rauslg4YVRPUR1J/UsKeGQJQ3jjH+ kXQh65t+pbMtCWrnOdVzAP0Sd3OnXeN+vU4bi3NiTC4qrvqXP0gsO4rjAy53X1I6Kis6BRmsfIQ8y 2Wv5xnBXFpSCreYw+IDwlvR5KgUFEfjvx/E1vPjCF4cXVVnIoDjfnXnmKmgf7EJvFr2EQ1DhAdM1z zB8SKitw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEz5S-0006KI-Gd; Thu, 19 Mar 2020 17:36:06 +0000 Date: Thu, 19 Mar 2020 10:36:06 -0700 From: Matthew Wilcox To: Chris Down Cc: qiwuchen55@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, chenqiwu Subject: Re: [PATCH] mm/vmscan: fix incorrect return type for cgroup_reclaim() Message-ID: <20200319173606.GL22433@bombadil.infradead.org> References: <1584633026-26288-1-git-send-email-qiwuchen55@gmail.com> <20200319162025.GA237751@chrisdown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200319162025.GA237751@chrisdown.name> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Mar 19, 2020 at 04:20:25PM +0000, Chris Down wrote: > qiwuchen55@gmail.com writes: > > From: chenqiwu > > > > The return type of cgroup_reclaim() is bool, but the correct type > > should be struct mem_cgroup pointer. As a result, cgroup_reclaim() > > can be used to wrap sc->target_mem_cgroup in vmscan code. > > The code changes looks okay to me, but the changelog and patch subject could > do with some improvement. For example, the type isn't "incorrect" before and > "correct" now, per se, it's just coercing from *struct mem_cgroup to bool. > > Could you make it more clear what your intent is in the patch? If it's that > you found the code confusing, you can just write something like: > > mm/vmscan: return target_mem_cgroup from cgroup_reclaim > > Previously the code splits apart the action of checking whether we are > in cgroup reclaim from getting the target memory cgroup for that > reclaim. This split is confusing and seems unnecessary, since > cgroup_reclaim itself only checks if sc->target_mem_cgroup is NULL or > not, so merge the two use cases into one by returning the > target_mem_cgroup itself from cgroup_reclaim. Thank you for this better changelog; I have a better idea about what this patch is doing now. > > @@ -276,9 +276,9 @@ static void unregister_memcg_shrinker(struct shrinker *shrinker) > > { > > } > > > > -static bool cgroup_reclaim(struct scan_control *sc) > > +static struct mem_cgroup *cgroup_reclaim(struct scan_control *sc) > > { > > - return false; > > + return NULL; > > } I think this is actually the important bit. For those who build their kernels with cgroups disabled, it will save a small number of instructions since cgroup_reclaim() will be NULL rather than dereferencing sc->target_mem_group. It'd be nice to have that saving quantified as part of the changelog. > > @@ -2625,7 +2626,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat, > > > > static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) > > { > > - struct mem_cgroup *target_memcg = sc->target_mem_cgroup; > > + struct mem_cgroup *target_memcg = cgroup_reclaim(sc); It feels like the name is wrong, doesn't it? cgroup_reclaim() doesn't really scream to me "I return a mem_cgroup pointer". I can't think of a good name, but maybe someone else can.