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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 916FBC433EF for ; Wed, 30 Mar 2022 15:57:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED7B36B0072; Wed, 30 Mar 2022 11:57:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E88CB8D0002; Wed, 30 Mar 2022 11:57:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D50BD8D0001; Wed, 30 Mar 2022 11:57:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id C7BC36B0072 for ; Wed, 30 Mar 2022 11:57:10 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 85F59A2301 for ; Wed, 30 Mar 2022 15:57:10 +0000 (UTC) X-FDA: 79301506620.19.B0235BC Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf16.hostedemail.com (Postfix) with ESMTP id 946F418000C for ; Wed, 30 Mar 2022 15:57:09 +0000 (UTC) Received: by mail-qt1-f180.google.com with SMTP id i4so18420539qti.7 for ; Wed, 30 Mar 2022 08:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2DqrTDJij/+jnL6IguPlfSJVz0YoCK5Qn6m+J92VWzI=; b=orgO24LkHCF4EOuz/ab4HIS8kjgemcfoGLDYGu7EWuXlTISEDMSKr4h2nrxRs2PzEc EjAshco2pN7gXzRJhW+0+mjZnkG0Xxm5vCR41OHjwj7BNKSAbpspP9aKawjBtJt4ZKKk Iat4FhW+5tFjMxnCnwdh8Bfl7HaK837UV+gjMj9/2UCWjyP+V8to1NZzXlrfzbZHkzeX WwPTYlpbpMAm35NaEV1dkfMAfyfgI3ZCHwuPlupG2iXlGyuDmKzIaZ/YYwDXbMdDNC9p km4O1WETMIikl7k5dpkF/phamL+DERfeGpjhuTN3hR+/OfQDxFYdrJ2a9p8r5UE1gffJ TTpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2DqrTDJij/+jnL6IguPlfSJVz0YoCK5Qn6m+J92VWzI=; b=vVisgw/Om8n3a/3+W9k70aF3bXZL3hy4HxUcde2J7xWU48X05kMmmUSXaz50BDoqim gLQ/cVqzRcrIz/cw8rWwTSNrf5bwjsI7RyxdyyU5XMVnV8YivlQIACTakN1ueqdn46vt 6KL63qrvYajiomnVvDcJjw04gitU/R2HPf2Gi+rwaD0a1T8BAFqyu1PD+oC73aix2a8Z YpAK81LHyAdaX4sh6UiDHzZAQomuVb7SkCzGtCd0tx3LgxKvQXu6gM1KKBTTCa1xH5tv +ZE5dQbkmbWHuQ1tlEG63p4H/3zzIdLiZuIBzaYvCua3Gqll8Ill+H0pXyKg7IjX4dlF XAAw== X-Gm-Message-State: AOAM531EqQdjlE0lq9rClt5k0Ib0HGCypQGiGip26EKO02h2gLCbrlyM 3wk6xrc7OitOFxyaLxMoJpeKpQ== X-Google-Smtp-Source: ABdhPJwis4J+aFI90oZrgLFV575jBY3CiFlk/12EJdxfp3LWn6/dudg9zJuHrQONsGAd5+Dx3cTrPw== X-Received: by 2002:ac8:7d86:0:b0:2e1:fe79:d602 with SMTP id c6-20020ac87d86000000b002e1fe79d602mr162679qtd.502.1648655828801; Wed, 30 Mar 2022 08:57:08 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id j11-20020a37a00b000000b0067b436faccesm10958647qke.122.2022.03.30.08.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 08:57:08 -0700 (PDT) Date: Wed, 30 Mar 2022 11:57:07 -0400 From: Johannes Weiner To: Wei Yang Cc: mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 3/3] mm/memcg: move generation assignment and comparison together Message-ID: References: <20220225003437.12620-1-richard.weiyang@gmail.com> <20220225003437.12620-4-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220225003437.12620-4-richard.weiyang@gmail.com> Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=orgO24Lk; spf=pass (imf16.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.180 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 946F418000C X-Stat-Signature: fkt561gw44u541je4wbbjhhc93z1rmmx X-HE-Tag: 1648655829-944420 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, Feb 25, 2022 at 12:34:37AM +0000, Wei Yang wrote: > For each round-trip, we assign generation on first invocation and > compare it on subsequent invocations. > > Let's move them together to make it more self-explaining. Also this > reduce a check on prev. > > Signed-off-by: Wei Yang This makes sense. The function is structured into 1) load state, 2) advance, 3) save state. The load state is a better fit for initializing reclaim->generation. > @@ -996,7 +996,14 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, > mz = root->nodeinfo[reclaim->pgdat->node_id]; > iter = &mz->iter; > > - if (prev && reclaim->generation != iter->generation) > + /* > + * On first invocation, assign iter->generation to > + * reclaim->generation. > + * On subsequent invocations, make sure no one else jump in. > + */ > + if (!prev) > + reclaim->generation = iter->generation; > + else if (reclaim->generation != iter->generation) > goto out_unlock; The comment duplicates the code, it doesn't explain why we're doing this. How about: /* * On start, join the current reclaim iteration cycle. * Exit when a concurrent walker completes it. */ With that, please feel free to add: Acked-by: Johannes Weiner