From patchwork Tue Oct 5 20:24:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 12537813 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 B78F6C433F5 for ; Tue, 5 Oct 2021 20:25:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 342A661423 for ; Tue, 5 Oct 2021 20:25:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 342A661423 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C4D0D6B006C; Tue, 5 Oct 2021 16:25:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFC43900003; Tue, 5 Oct 2021 16:25:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEBA0900002; Tue, 5 Oct 2021 16:25:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id A00636B006C for ; Tue, 5 Oct 2021 16:25:22 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 441A9183A6ECD for ; Tue, 5 Oct 2021 20:25:22 +0000 (UTC) X-FDA: 78663513684.17.FFE444A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id E4DFC9008037 for ; Tue, 5 Oct 2021 20:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633465521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=fphjzfCNo4ZpuqMZyls+oQxve30/shqr62DPT4ol2Kk=; b=R42K2PpGzQebBVmX66VxdDAkkaUE/P80NDBx9vTPx/PcKaUvUu0CoCldRNTIP/+WrsKOQr MQ+XwznikhSUCCD7cpOM+gIZ5s0q0mtXuNuTB+bQHekCk8NL9zaGbj/Enslg4Mc9V7dXgZ MjUkYgFG40JEFdHPXgXQQETAduCjI6s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-0Zf8uCHhPCqIIoHyVyTwIg-1; Tue, 05 Oct 2021 16:25:20 -0400 X-MC-Unique: 0Zf8uCHhPCqIIoHyVyTwIg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62BB71966320; Tue, 5 Oct 2021 20:25:18 +0000 (UTC) Received: from llong.com (unknown [10.22.34.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id B59FF5D9D5; Tue, 5 Oct 2021 20:25:16 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Muchun Song , Waiman Long Subject: [PATCH v2] mm/memcg: Remove obsolete memcg_free_kmem() Date: Tue, 5 Oct 2021 16:24:50 -0400 Message-Id: <20211005202450.11775-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Rspamd-Queue-Id: E4DFC9008037 X-Stat-Signature: fa57zy87ipupqyirb1qbxkknt5qsa194 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R42K2PpG; spf=none (imf29.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-HE-Tag: 1633465521-843077 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: Since commit d648bcc7fe65 ("mm: kmem: make memcg_kmem_enabled() irreversible"), the only thing memcg_free_kmem() does is to call memcg_offline_kmem() when the memcg is still online which can happen when online_css() fails due to -ENOMEM. However, the name memcg_free_kmem() is confusing and it is more clear and straight forward to call memcg_offline_kmem() directly from mem_cgroup_css_free(). Suggested-by: Roman Gushchin Signed-off-by: Waiman Long Reviewed-by: Roman Gushchin Reviewed-by: Shakeel Butt Reviewed-by: Aaron Tomlin --- mm/memcontrol.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6da5020a8656..96a93c608d80 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3656,13 +3656,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) memcg_free_cache_id(kmemcg_id); } - -static void memcg_free_kmem(struct mem_cgroup *memcg) -{ - /* css_alloc() failed, offlining didn't happen */ - if (unlikely(memcg->kmem_state == KMEM_ONLINE)) - memcg_offline_kmem(memcg); -} #else static int memcg_online_kmem(struct mem_cgroup *memcg) { @@ -3671,9 +3664,6 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) static void memcg_offline_kmem(struct mem_cgroup *memcg) { } -static void memcg_free_kmem(struct mem_cgroup *memcg) -{ -} #endif /* CONFIG_MEMCG_KMEM */ static int memcg_update_kmem_max(struct mem_cgroup *memcg, @@ -5308,7 +5298,9 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css) cancel_work_sync(&memcg->high_work); mem_cgroup_remove_from_trees(memcg); free_shrinker_info(memcg); - memcg_free_kmem(memcg); + + /* Need to offline kmem if online_css() fails */ + memcg_offline_kmem(memcg); mem_cgroup_free(memcg); }