Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3870814pxb; Tue, 17 Nov 2020 05:52:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9tvFJkXejIj7cu9ex/AG05WnfZHe8jPbkyXkZ61+g+PHlKys5KrGid8k+rXjgQoYpks/Q X-Received: by 2002:a17:906:c193:: with SMTP id g19mr20324882ejz.393.1605621146005; Tue, 17 Nov 2020 05:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621145; cv=none; d=google.com; s=arc-20160816; b=ryJNknCJ+5mrp+k0PTeNEuIHAbLQ5C5vstWq4mMpa3WyLRzssgNWOd5rLmqsvnyO02 rBS3Zv0puoMZihEpkGU1rhN4IreVFPFjwfZhC/TCjAARGCcrGusghfw2Xy97hEIGd8K3 9xS4YX0PUhdBCSRULOHV3AUsQYB3zFGdmqdYWhXjhBV7HoapiF3aYkLcRoyAXOHV1g1k 6sX15DxYJF+9sKq9YWyNnY4vOVWunDpa+3RJ6DTTj8d90hoWNnt3jzqsgjwDrK/5Z/uD OWrrVNprCyodGgi0B2RhMhu8iBDExI2CSe9DJWIn/tOWKAWViOZU5C8feqHgTqeGASbv /VnA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/uO66pMGTLx/VGetakMOAwhXtf7ky6bMcPLD+uc2XAs=; b=HnwQpbDgn4n9deOOBB5ihZ7EuDy5GjkqNNQ6i3l2vBG7mAtx4rDbZh6UMh2+0puuEj 5DTSXn/9KSx1NvulCAa4866ilb5HVht8oo4t9fJ0XleeOHn+hbZf2aSXpKVqr6bA8S+x I4oR+NFEkiAq9Rf+oNGesmiQ8zAM7BaL5WheVOblZZ33dP8nrMP8bSlimyiew0TK+Ary 2KTDgtMn8+i4FcVsmhPx2N8ZfDSaTGCYJcypiNQ0KJZK/4pyD7Z0GZCnGT4aicMYij48 usFo/QUy1p3RZ/bQc4I6ORZOr7AkViQQ/S7AyoVs57ze3gYDs3phmkuL927Vew8gvzHz qCbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZLHVZvAU; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si13149017ejv.576.2020.11.17.05.52.02; Tue, 17 Nov 2020 05:52:25 -0800 (PST) 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=@kernel.org header.s=default header.b=ZLHVZvAU; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732696AbgKQNuU (ORCPT + 99 others); Tue, 17 Nov 2020 08:50:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:42504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732328AbgKQNcn (ORCPT ); Tue, 17 Nov 2020 08:32:43 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B20621734; Tue, 17 Nov 2020 13:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619962; bh=he4KIhkkXcT7YqobN4HKFO1MI7XBPuzBlAVknM5R6SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLHVZvAUhYAKHtQFwRVb2awuCeHTlrUhnr1FObTmB9TNqsn1dGu+PuS8mhQMbcalf 3XnO0IpUC3Y5OHTGPmad3cvZkcU/ablcrwWkeEatnpQHqOQ4iKQBrftmKvPUrhVMS7 OkGJQ6ZoPgSfMk6eJSDhhRPA/YOSSTIUcyAaDF+E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, zhongjiang-ali , Andrew Morton , Johannes Weiner , Michal Hocko , Linus Torvalds , Sasha Levin Subject: [PATCH 5.9 032/255] mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg Date: Tue, 17 Nov 2020 14:02:52 +0100 Message-Id: <20201117122140.506848721@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhongjiang-ali [ Upstream commit 7de2e9f195b9cb27583c5c64deaaf5e6afcc163e ] memcg_page_state will get the specified number in hierarchical memcg, It should multiply by HPAGE_PMD_NR rather than an page if the item is NR_ANON_THPS. [akpm@linux-foundation.org: fix printk warning] [akpm@linux-foundation.org: use u64 cast, per Michal] Fixes: 468c398233da ("mm: memcontrol: switch to native NR_ANON_THPS counter") Signed-off-by: zhongjiang-ali Signed-off-by: Andrew Morton Acked-by: Johannes Weiner Acked-by: Michal Hocko Link: https://lkml.kernel.org/r/1603722395-72443-1-git-send-email-zhongjiang-ali@linux.alibaba.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/memcontrol.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index de51787831728..51ce5d172855a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4068,11 +4068,17 @@ static int memcg_stat_show(struct seq_file *m, void *v) (u64)memsw * PAGE_SIZE); for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { + unsigned long nr; + if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) continue; + nr = memcg_page_state(memcg, memcg1_stats[i]); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (memcg1_stats[i] == NR_ANON_THPS) + nr *= HPAGE_PMD_NR; +#endif seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i], - (u64)memcg_page_state(memcg, memcg1_stats[i]) * - PAGE_SIZE); + (u64)nr * PAGE_SIZE); } for (i = 0; i < ARRAY_SIZE(memcg1_events); i++) -- 2.27.0