Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp90183pxb; Mon, 16 Aug 2021 00:14:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyriqAFj7V+i9/4ORUDhPpw/IBRwJXLmP7Qb11pYpU1l+hOUvQ95NkWsNGf1apL+EcbGBtr X-Received: by 2002:a02:4e04:: with SMTP id r4mr14130433jaa.99.1629098068710; Mon, 16 Aug 2021 00:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629098068; cv=none; d=google.com; s=arc-20160816; b=o0Gqqb3ZZUg7nswnmHOrnTksf3rU0zA2bKk5htfy2e6ZimQ5GxdvMYhSawAWpEBTdO uREZcNw6vU0Tmk8Yl4G5vMGhokGB4ZkwJwWpPjEzaCw4DYu4hSXUBJu+c3LfWeCcVyWh JC5+rkm8QJ3KdjdLnubMwHy5R2aVJCBzwXmNzzni6Y11XWebhcJuHHCQjIhBrQSLeHc6 BfQ3O1Tpxpa6JQM+vXkQ7YKakqfjDGkNLaHJIjdRkGO2G5NzmsujrlSR9t3/pU5mgaCS wFrVjvRJkBZFwQoxTOGXagfP8kLaoAuE14N2B1aEiuZg64w4lXcckpK/tAFKTTWV6kQx D6MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=5U+edsiBQgFWVoZpxgEmFtClPEajyfi4o6+gA7F02mc=; b=HlEinsNMylDxX+W1w+97LrOGUhit0syN68AcD2X2PNNGJdmqDF1zb3MK3ghce5SA3k BvSRmFgscFSXnQCYtVxectrRQkl0wh8HIpo5vkIZbftqtPiTr4N/fWu5n59keuuh8KTw mzhqyGvejnVfyZLNcpNAj5Jr7jBarr6NmA8Yhm4QIFPyNLEdurNzhbm2o98dDkZ1aVy3 Wx0hgB6VsR7mY0rwGQRZxWgTV7KCHvhQ7karsmsz8+igbJxc94G3fn1DjxNg2ZMV4fj6 bhM+P715KDcjjW1CgaO/UcrMQMboQsW2vpJ1CERecz5BrpHNHFITkS2NQQLltwe3Uxy6 qDoQ== ARC-Authentication-Results: i=1; mx.google.com; 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=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si10632602ilv.82.2021.08.16.00.14.17; Mon, 16 Aug 2021 00:14:28 -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; 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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234205AbhHPHNn (ORCPT + 99 others); Mon, 16 Aug 2021 03:13:43 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:8419 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234090AbhHPHNX (ORCPT ); Mon, 16 Aug 2021 03:13:23 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Gp4yV0rKdz881L; Mon, 16 Aug 2021 15:08:50 +0800 (CST) Received: from dggema756-chm.china.huawei.com (10.1.198.198) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 16 Aug 2021 15:12:48 +0800 Received: from localhost.localdomain (10.175.112.125) by dggema756-chm.china.huawei.com (10.1.198.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 16 Aug 2021 15:12:47 +0800 From: Chen Huang To: Roman Gushchin , Muchun Song , "Wang Hai" , Greg Kroah-Hartman CC: , , , Chen Huang , Michal Hocko , Vladimir Davydov , "Xiongchun Duan" , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10.y 06/11] mm: memcontrol: directly access page->memcg_data in mm/page_alloc.c Date: Mon, 16 Aug 2021 07:21:42 +0000 Message-ID: <20210816072147.3481782-7-chenhuang5@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20210816072147.3481782-1-chenhuang5@huawei.com> References: <20210816072147.3481782-1-chenhuang5@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggema756-chm.china.huawei.com (10.1.198.198) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muchun Song 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. Link: https://lkml.kernel.org/r/20210319163821.20704-4-songmuchun@bytedance.com Signed-off-by: Muchun Song Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt Cc: Michal Hocko Cc: Roman Gushchin Cc: Vladimir Davydov Cc: Xiongchun Duan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Chen Huang --- 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 8ec194271b91..12deac86a7ac 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1094,7 +1094,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; @@ -1119,7 +1119,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.18.0.huawei.25