From patchwork Mon Oct 25 12:52:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12581789 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E9EEC433EF for ; Mon, 25 Oct 2021 12:53:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5028A60E97 for ; Mon, 25 Oct 2021 12:53:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5028A60E97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D7A19940007; Mon, 25 Oct 2021 08:53:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D29DE6B0072; Mon, 25 Oct 2021 08:53:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF130940007; Mon, 25 Oct 2021 08:53:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id ABFF26B006C for ; Mon, 25 Oct 2021 08:53:37 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4188A2B350 for ; Mon, 25 Oct 2021 12:53:37 +0000 (UTC) X-FDA: 78734951274.06.C67B331 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf30.hostedemail.com (Postfix) with ESMTP id D15B6E001980 for ; Mon, 25 Oct 2021 12:53:27 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id m21so10812941pgu.13 for ; Mon, 25 Oct 2021 05:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QqjXJItGS4YzuoDfo84aL3q/TLgAPyW97JB5OeC7FWM=; b=awGrCLBqKt46OYGLaxkc6leqIztb7LxrGq1vcFMqQEAev80h84si95P9OEHaKRe8qh EU2o5D5xslyrPgpzUgei4rcVX0VO7mKXWAp5s4wsp+vH5bW+tNenb2qTjasVnkjohJs4 woiQupfxfUyq1WMTSkVCFCP+xZtEqGNlGP7BqtfUe7GweQdUUMcroRn7E+MDoEHejTga 7952lroUT/zox/0oUEXjZcGA50vLi/sF7CTlOe0Ia7QEhZeUbsZ7losWOEhkWPeKcJqV HLbxYLpnCN1t2dDq06Pw+685hOjmsYILh4h8g7vBmwOgnGy7kXGjetShrwQA8SUps7LL fk3w== 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:mime-version :content-transfer-encoding; bh=QqjXJItGS4YzuoDfo84aL3q/TLgAPyW97JB5OeC7FWM=; b=tpeoobrdMofIF3Jrt44GpmEqPnKd2fTElKuCiOtFI7FsFqehVHCFXBOavrETXdXtxR 04P7eGaOC8Ya9a+wmV0Femu9OkSSxWSs/EiQxRbSuIiVYyDgXEtN7m+LgnrSMik9Yu1A Q+Z74Xd/y1Bno6MB3XsKkDOwzVP6qK4KaVKnFLNPcFYUm4dqHuV0tgxW/rNxtbj6aKmD iCUn4Qs+izGlK5h0suvTGMGvt/ZWqMkEVttmlWtbUa6CxjblZ8YwzJWgctpYN2N37lnl AbDbjbPwWvu+byRK8yFnrArVuo1XbWHt/bgbedS1qbpODGPWcWC7EFfpasp8SmAPMZ7w F80A== X-Gm-Message-State: AOAM533dQ6+1XlrHnBqafaPa2MXlP081uWpoFSpuK8iFsoe+XxGlV9W/ rUR2WuAdtKxFXgjafHFQvHSfJQ== X-Google-Smtp-Source: ABdhPJyDucaDmVgY0HaVFQaWMWYdh3bNqExErgbPMsdz40RdZBM+2lhdhO5CcoHxfOtqB6S6LPqhDg== X-Received: by 2002:a05:6a00:1142:b0:44d:d43a:ac5d with SMTP id b2-20020a056a00114200b0044dd43aac5dmr17886234pfm.30.1635166415800; Mon, 25 Oct 2021 05:53:35 -0700 (PDT) Received: from localhost.localdomain ([61.120.150.70]) by smtp.gmail.com with ESMTPSA id a20sm18679912pfn.136.2021.10.25.05.53.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Oct 2021 05:53:35 -0700 (PDT) From: Muchun Song To: akpm@linux-foundation.org, mhocko@kernel.org, shakeelb@google.com, willy@infradead.org, guro@fb.com, hannes@cmpxchg.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH] mm: memcontrol: remove the kmem states Date: Mon, 25 Oct 2021 20:52:59 +0800 Message-Id: <20211025125259.56624-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D15B6E001980 X-Stat-Signature: rezjgkahoft83k36kdd54ok1xbu9xiw4 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=awGrCLBq; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf30.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1635166407-515767 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: Now the kmem states is only used to indicate whether the kmem is offline. However, we can set ->kmemcg_id to -1 to indicate whether the kmem is offline. Finally, we can remove the kmem states to simplify the code. Signed-off-by: Muchun Song Acked-by: Roman Gushchin --- include/linux/memcontrol.h | 7 ------- mm/memcontrol.c | 7 ++----- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index e34bf0cbdf55..509e1480e3be 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -180,12 +180,6 @@ struct mem_cgroup_thresholds { struct mem_cgroup_threshold_ary *spare; }; -enum memcg_kmem_state { - KMEM_NONE, - KMEM_ALLOCATED, - KMEM_ONLINE, -}; - #if defined(CONFIG_SMP) struct memcg_padding { char x[0]; @@ -318,7 +312,6 @@ struct mem_cgroup { #ifdef CONFIG_MEMCG_KMEM int kmemcg_id; - enum memcg_kmem_state kmem_state; struct obj_cgroup __rcu *objcg; struct list_head objcg_list; /* list of inherited objcgs */ #endif diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e26f87cd7e4c..760e3669a7c8 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3621,7 +3621,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) return 0; BUG_ON(memcg->kmemcg_id >= 0); - BUG_ON(memcg->kmem_state); memcg_id = memcg_alloc_cache_id(); if (memcg_id < 0) @@ -3638,7 +3637,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) static_branch_enable(&memcg_kmem_enabled_key); memcg->kmemcg_id = memcg_id; - memcg->kmem_state = KMEM_ONLINE; return 0; } @@ -3648,11 +3646,9 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) struct mem_cgroup *parent; int kmemcg_id; - if (memcg->kmem_state != KMEM_ONLINE) + if (memcg->kmemcg_id == -1) return; - memcg->kmem_state = KMEM_ALLOCATED; - parent = parent_mem_cgroup(memcg); if (!parent) parent = root_mem_cgroup; @@ -3671,6 +3667,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) memcg_drain_all_list_lrus(kmemcg_id, parent); memcg_free_cache_id(kmemcg_id); + memcg->kmemcg_id = -1; } #else static int memcg_online_kmem(struct mem_cgroup *memcg)