From patchwork Wed Apr 21 02:04:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Hui X-Patchwork-Id: 12215285 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.7 required=3.0 tests=BAYES_00, 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 82032C433ED for ; Wed, 21 Apr 2021 02:05:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DBD5A61411 for ; Wed, 21 Apr 2021 02:05:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBD5A61411 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sangfor.com.cn Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 02F066B0070; Tue, 20 Apr 2021 22:05:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EFA1F6B0071; Tue, 20 Apr 2021 22:05:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D74286B0072; Tue, 20 Apr 2021 22:05:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id B85DD6B0070 for ; Tue, 20 Apr 2021 22:05:24 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7D19D18030094 for ; Wed, 21 Apr 2021 02:05:24 +0000 (UTC) X-FDA: 78054732168.15.E8CA770 Received: from mail-m121142.qiye.163.com (mail-m121142.qiye.163.com [115.236.121.142]) by imf16.hostedemail.com (Postfix) with SMTP id 6338380192C0 for ; Wed, 21 Apr 2021 02:05:21 +0000 (UTC) Received: from localhost.localdomain (unknown [14.154.30.246]) by mail-m121142.qiye.163.com (Hmail) with ESMTPA id 31595802E9; Wed, 21 Apr 2021 10:05:16 +0800 (CST) From: Ding Hui To: akpm@linux-foundation.org, naoya.horiguchi@nec.com, osalvador@suse.de Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ding Hui Subject: [RFC PATCH] mm/page_alloc: fix counting of free pages after take off from buddy Date: Wed, 21 Apr 2021 10:04:26 +0800 Message-Id: <20210421020426.5914-1-dinghui@sangfor.com.cn> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGUhMHlZNH0NNTR8eS0tMH0pVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 9ISFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NBQ6Izo4UT8TEgkINjFCKQ4i GSkwCUlVSlVKTUpDQkxLTEpNTENOVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKT1VKTk9VSEtVSU9NWVdZCAFZQUpMSU43Bg++ X-HM-Tid: 0a78f22ca8e4b037kuuu31595802e9 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6338380192C0 X-Stat-Signature: 1ewnp16hkkmqwjyh7ih3jjbuj4pjpeqs Received-SPF: none (sangfor.com.cn>: No applicable sender policy available) receiver=imf16; identity=mailfrom; envelope-from=""; helo=mail-m121142.qiye.163.com; client-ip=115.236.121.142 X-HE-DKIM-Result: none/none X-HE-Tag: 1618970721-161791 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: Recently we found there is a lot MemFree left in /proc/meminfo after do a lot of pages soft offline. I think it's incorrect since NR_FREE_PAGES should not contain HWPoison pages. After take_page_off_buddy, the page is no longer belong to buddy allocator, and will not be used any more, but we maybe missed accounting NR_FREE_PAGES in this situation. Signed-off-by: Ding Hui --- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cfc72873961d..8d65b62784d8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8947,6 +8947,7 @@ bool take_page_off_buddy(struct page *page) del_page_from_free_list(page_head, zone, page_order); break_down_buddy_pages(zone, page_head, page, 0, page_order, migratetype); + __mod_zone_page_state(zone, NR_FREE_PAGES, -1); ret = true; break; }