Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp431627pxf; Thu, 18 Mar 2021 04:10:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRY922Z+PEMMMyFgD2D4O43wTTA6GVZjaflzyh75oT2CyjJJTCHZyREYrh4E5oMX8p/vIM X-Received: by 2002:a05:6402:10c6:: with SMTP id p6mr2898230edu.241.1616065827761; Thu, 18 Mar 2021 04:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616065827; cv=none; d=google.com; s=arc-20160816; b=oYK6eWS1Db06zdoCYKgsoL3LGLzC3+k/+RPckMsmKPfBh53kQeH3KGvT7xS2Q/FfMG cucBoqOoZoJjxokHRD9jOQYmHFFjN+W4+NgHdMIexPnp+l1vTSwHKN51iaVXjqpaG99H XIIKA5pRpRf08CDa/lTIW9CmooxxT4xvMaPCwhYI0bmIL1jpMsASUszNtbvGJRk3py4M 1fU3dHaVa7p0lwjoVt3ewL6NRCSsReUpH1AOPNXKQstIxtrS7ngR0YpfZvaCh1/OtBpk uZFlR9RRzd9SUZ9kfRYs2JQE6AA42FwP4xirmDs5eL+uV5lzm0VtgkFYdcnWk2ATG/RJ X9lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6xtw62qD+a/Q8lM+edqL90eMuRS6Phfvme83OFdVlXw=; b=KMlrxptwt2EyL/XpCIqmFqBQ9hXeod2C/7ulCIR64b9GmAJjYQEIXu5DuPyQPHCp8E WrfmnxASYZyU3IWW955KIGpRDEM9S+lXTQTV1UIK76vFvf99nybv8fA0nU7aTRPNAe3W leS4oChNuOdazDIfc3gvrnto8sdvyembmUWEbtP+ktxYaJWbKozFMe7lp91NiLawIySI N+irDcL3b2pHIgU+x35IKlHdVnQ8I5YSasb1gMRvLsb6y5mJ0I9JZ4ZFUp/KHIXRNJOj TwTveqcINHqYrXVBGwQHhr4fjbB4hkZluBZnDxVGOVkT6B3oHPo/NDPQ0VAoAdfUKkFG 7mTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=rB7UVX6C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n28si1305984edc.564.2021.03.18.04.10.05; Thu, 18 Mar 2021 04:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=rB7UVX6C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbhCRLJJ (ORCPT + 99 others); Thu, 18 Mar 2021 07:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230422AbhCRLIf (ORCPT ); Thu, 18 Mar 2021 07:08:35 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81373C06174A for ; Thu, 18 Mar 2021 04:08:35 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id h20so1120784plr.4 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=qoI71YAC5AHWl/P+NA6ui/HSDgrahQHvtcAhokMFMjjWJ+S7TB5A4xslj9oc6qpQ5o X6+5PEn+pEBSgxIuTgSWR+d5+21uAqhbIGX6WWcuPQjVv/1JJ/pOz43bDt3mEjMevlQA BebtdVFStNRFJ6kYivmZCYThuEIIJj1VHATEyFkpygmO0tRejT9pZSkXXNaD8w8TJOQu z5VhMe24QHxflV0yYmo22MC660MUalebTpmM8W4bND1ahrO4E5fcpItqDJcWWoZgHDul gp0nRXhA3Bwax9oCtVxd4euntYMmhvc6p858h24cYc37iapPSNO/HYM4jkOUSnTYuZit /rPg== X-Gm-Message-State: AOAM5304JA4rXR6cWDC3Y1v7CXEP7DkoD5K8yLYsMJlgT3tSr/aFfT9z F4jd7xRATxFNITZLU0moM+bkCQ== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.11.0