From patchwork Thu Mar 18 11:06:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12147917 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0CF03C433E0 for ; Thu, 18 Mar 2021 11:08:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7653A64DBA for ; Thu, 18 Mar 2021 11:08:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7653A64DBA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 062AE6B0072; Thu, 18 Mar 2021 07:08:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 039426B0073; Thu, 18 Mar 2021 07:08:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1B066B0074; Thu, 18 Mar 2021 07:08:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id CAEC16B0072 for ; Thu, 18 Mar 2021 07:08:36 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 935A5180222AB for ; Thu, 18 Mar 2021 11:08:36 +0000 (UTC) X-FDA: 77932721832.16.802EE0D Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf24.hostedemail.com (Postfix) with ESMTP id 00456A0000FD for ; Thu, 18 Mar 2021 11:08:35 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id v23so1120372ple.9 for ; Thu, 18 Mar 2021 04:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6xtw62qD+a/Q8lM+edqL90eMuRS6Phfvme83OFdVlXw=; b=rB7UVX6Cw0ILixk1ob5vWfS1HkVmsmbTSSwfxC7TE5WQ3fh+AvmkDsV1Qx1cqFM2A6 FItEFb7z4z34js3YLg3dXSGQiLrS0rQEDhX6OsyLtz4LHOm6A6WuR/2KiGdFE+/neqvy +wWHWlp8OCl290Ds7S6MKE4TT19nkgoNHkdkC1d8bWuH13kfs6sjYwDKLJG14NWGRMaX rCVfNanTnlMuhyxKyLqY4VIlGGeXZkV4uCDnyQTRukB7VNm9ZgXfQPLsWpn9QTkJdxAo PaC52X38X5Cs2cI/CQVmw1MbkMKivRczESS0Y9WReaIG8x7/Yp/6O/GTVQk3B0GDQvzP HeFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6xtw62qD+a/Q8lM+edqL90eMuRS6Phfvme83OFdVlXw=; b=EcbKs8UMLbX/TZ4aL8WsP1szpwXbeRP0dBUdQRMESBbVePKWy5cT7+iAFpy5stkdbJ Pa1mA9cMiRsxm5F1/fqpPNH+2mdVR5BU+0duD1ejiOx0KXnEzAcrLV9xvNXniWoOY+JD qJamOBA7U5fftHS9hVkBQkUO3OXf4XKVvyzcAY/PvJQ2rp3Tmlj50kiECutK2GYAA4lh vfiaFTiCTlhA+yFfuBjva6hhFBikvVjknvTbxNa7OFut9AOu1HL6EhZ1i4bkXpK/B6aX eB9wGkufO6KKSMV2JAgSTlq6LSxsv2nFzA6qXO9BRRsohoEjBDxCwNJK+yuk9ibBNuXg RJ0g== X-Gm-Message-State: AOAM533vefgQhcy0DepZbe+EqYvofHKug/n+XQSPOXmrPqAapkho5eFd cvvsze0cnTMbg7JNfO+QsFXdQQ== X-Google-Smtp-Source: ABdhPJzIa469RR5z4zKgOSL2tgWTJOS7BOpGioj765KvTrpGIKZhprUgxCm/4fFELrfQOwe7585A4w== X-Received: by 2002:a17:90a:bc06:: with SMTP id w6mr3707116pjr.44.1616065715161; Thu, 18 Mar 2021 04:08:35 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.231]) by smtp.gmail.com with ESMTPSA id e21sm1779509pgv.74.2021.03.18.04.08.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Mar 2021 04:08:34 -0700 (PDT) From: Muchun Song To: guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, shakeelb@google.com, vdavydov.dev@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v4 2/5] mm: memcontrol: directly access page->memcg_data in mm/page_alloc.c Date: Thu, 18 Mar 2021 19:06:55 +0800 Message-Id: <20210318110658.60892-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210318110658.60892-1-songmuchun@bytedance.com> References: <20210318110658.60892-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: jpwaey8wrk7g6cmyg66xqmmss6t11j4p X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 00456A0000FD Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-pl1-f175.google.com; client-ip=209.85.214.175 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616065715-861255 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: The page_memcg() is not suitable for use by page_expected_state() and page_bad_reason(). Because it can BUG_ON() for the slab pages when CONFIG_DEBUG_VM is enabled. As neither lru, nor kmem, nor slab page should have anything left in there by the time the page is freed, what we care about is whether the value of page->memcg_data is 0. So just directly access page->memcg_data here. Signed-off-by: Muchun Song Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt --- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f10966e3b4a5..e5454b85a106 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1124,7 +1124,7 @@ static inline bool page_expected_state(struct page *page, if (unlikely((unsigned long)page->mapping | page_ref_count(page) | #ifdef CONFIG_MEMCG - (unsigned long)page_memcg(page) | + page->memcg_data | #endif (page->flags & check_flags))) return false; @@ -1149,7 +1149,7 @@ static const char *page_bad_reason(struct page *page, unsigned long flags) bad_reason = "PAGE_FLAGS_CHECK_AT_FREE flag(s) set"; } #ifdef CONFIG_MEMCG - if (unlikely(page_memcg(page))) + if (unlikely(page->memcg_data)) bad_reason = "page still charged to cgroup"; #endif return bad_reason;