From patchwork Fri Feb 25 00:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12759479 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 18F82C433F5 for ; Fri, 25 Feb 2022 00:34:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9D9A8D0006; Thu, 24 Feb 2022 19:34:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4F718D0001; Thu, 24 Feb 2022 19:34:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EDDE8D0006; Thu, 24 Feb 2022 19:34:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 7E5758D0001 for ; Thu, 24 Feb 2022 19:34:45 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 923D89F33D for ; Fri, 25 Feb 2022 00:34:43 +0000 (UTC) X-FDA: 79179431646.22.2595B96 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf19.hostedemail.com (Postfix) with ESMTP id 329B41A0008 for ; Fri, 25 Feb 2022 00:34:43 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id cm8so5236621edb.3 for ; Thu, 24 Feb 2022 16:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uV4wBUWA2UECsFZTXgl5VjPgFRRqp+MEQd9SNZm1H5k=; b=a6Vnlb+DXvatZ1kODfxsl4neHMsRZDeRD7PR3nUDh+j1AyWLtpam8eSKeAKpB7+2tx K283KMzgr1d7YmT6BpKMBWNBjK/AbqGXSgoAYFd1XPSC5QzRDch5RhpeI+EvMXFCv/ht H67m6Oj03Z7rnpxO2scQmQ5AC/DV8lEKCT4T1Qr1/HenZEtC4hkFTZKMfZDWhpgZ70LM T0+ZcMd3F2C/ZFIaJlh5+4tpwfGoFPG12Yh/MWAh4c9HxdVrCLDhyI5qKcBfSlXXPijP PzKY2w+OfX5pLMziBPbIevhlkHMHG6QNplCeS1qXYwpH4LR8aZwiKXwG8iGtIdB+JC6a 0JzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uV4wBUWA2UECsFZTXgl5VjPgFRRqp+MEQd9SNZm1H5k=; b=s3vcusBZERHMpNp8lodipjrIx+XPxgiX7QDzzlYcSn6QQU5vDqSCyNdTk/Lalkl/oN tr3ZDbz9+qa0Up4dKElLmZ/MYUtZABhIuMK+NhP2CIMqyCHXrVp8SbEw/d9x/asM2Bb7 S45E7ADMbV1RMwcGZFqk0+PFVOQMgp2+VeyMQOhWHu2GgI1pQU2ajEsq+zgncTDQyIam RmBUqKBZPv+tSPGLXoL2iy4kc08xz3cNOYLQpza1zbu09O8W2rQ9NkFS7Wrox0xY4GLg gGDouc8Oj5gP6oC7/wUSOjV6SUGM8Oh0WpvEaUyvShsLHgedtXJbZzQt4eSjugecvtGe xTlw== X-Gm-Message-State: AOAM532BxD8TapiXtb8SmnA7c3X00EeaEQrvg2j05Yar9mnEuIvvBYDw LYA4r7u6wZPC2yGthE40eFI= X-Google-Smtp-Source: ABdhPJyt8lkUIMqItrJ/qgRwB3FiJ3nB/EIBnPDeJ8equOOsrEMp4CSPfOLuDO1HxBd3h70Q0HCSRg== X-Received: by 2002:a05:6402:1d54:b0:410:f02d:4765 with SMTP id dz20-20020a0564021d5400b00410f02d4765mr4719468edb.28.1645749281926; Thu, 24 Feb 2022 16:34:41 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id r11-20020aa7cfcb000000b00412c58c43ccsm528200edy.37.2022.02.24.16.34.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Feb 2022 16:34:41 -0800 (PST) From: Wei Yang To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/3] mm/memcg: set pos to prev unconditionally Date: Fri, 25 Feb 2022 00:34:36 +0000 Message-Id: <20220225003437.12620-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220225003437.12620-1-richard.weiyang@gmail.com> References: <20220225003437.12620-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 329B41A0008 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=a6Vnlb+D; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 44xh456h416361rz63p77s7j5gm7a9pk X-HE-Tag: 1645749283-883047 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: Current code set pos to prev based on condition (prev && !reclaim), while we can do this unconditionally. Since: * If !reclaim, pos is the same as prev no matter it is NULL or not. * If reclaim, pos would be set properly from iter->position. Signed-off-by: Wei Yang --- mm/memcontrol.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9464fe2aa329..03399146168f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -980,7 +980,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, struct mem_cgroup_reclaim_iter *iter; struct cgroup_subsys_state *css = NULL; struct mem_cgroup *memcg = NULL; - struct mem_cgroup *pos = NULL; + struct mem_cgroup *pos = prev; if (mem_cgroup_disabled()) return NULL; @@ -988,9 +988,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, if (!root) root = root_mem_cgroup; - if (prev && !reclaim) - pos = prev; - rcu_read_lock(); if (reclaim) {