From patchwork Sat May 8 03:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Hui X-Patchwork-Id: 12245815 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 5519DC433ED for ; Sat, 8 May 2021 03:56:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD4F261106 for ; Sat, 8 May 2021 03:56:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD4F261106 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 0BAD98D0025; Fri, 7 May 2021 23:56:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 092798D001A; Fri, 7 May 2021 23:56:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E74638D0025; Fri, 7 May 2021 23:56:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id C6EF08D001A for ; Fri, 7 May 2021 23:56:40 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7D12E181AF5C3 for ; Sat, 8 May 2021 03:56:40 +0000 (UTC) X-FDA: 78116702160.08.C55858A Received: from mail-m121142.qiye.163.com (mail-m121142.qiye.163.com [115.236.121.142]) by imf04.hostedemail.com (Postfix) with SMTP id 35DA9138 for ; Sat, 8 May 2021 03:56:32 +0000 (UTC) Received: from localhost.localdomain (unknown [14.154.28.254]) by mail-m121142.qiye.163.com (Hmail) with ESMTPA id B20FD80762; Sat, 8 May 2021 11:56:31 +0800 (CST) From: Ding Hui To: david@redhat.com, naoya.horiguchi@nec.com, osalvador@suse.de Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ding Hui Subject: [PATCH v2] mm/page_alloc: fix counting of free pages after take off from buddy Date: Sat, 8 May 2021 11:55:33 +0800 Message-Id: <20210508035533.23222-1-dinghui@sangfor.com.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: <8cd355d2-1adc-4189-7b65-cfea13129db5@sangfor.com.cn> References: <8cd355d2-1adc-4189-7b65-cfea13129db5@sangfor.com.cn> X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGUseSlYYTElMGR0fGkhDH01VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 9ISFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MTo6Tjo4CT8KPzkPNCoZNw8u H1YKCTlVSlVKTUlLT09NSkJJSEtOVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKT1VKTk9VSUNVSU5PWVdZCAFZQUlKT0I3Bg++ X-HM-Tid: 0a794a1ea173b037kuuub20fd80762 Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=sangfor.com.cn; spf=pass (imf04.hostedemail.com: domain of dinghui@sangfor.com.cn designates 115.236.121.142 as permitted sender) smtp.mailfrom=dinghui@sangfor.com.cn X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 35DA9138 X-Stat-Signature: p4bj8ahf58rafig66zzy6edk6mdarz5w Received-SPF: none (sangfor.com.cn>: No applicable sender policy available) receiver=imf04; 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: 1620446192-974554 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. For offline free pages, after a successful call take_page_off_buddy(), the page is no longer belong to buddy allocator, and will not be used any more, but we missed accounting NR_FREE_PAGES in this situation. Do update like rmqueue() does. Signed-off-by: Ding Hui --- V2: use __mod_zone_freepage_state instead of __mod_zone_page_state mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cfc72873961d..e124a615303b 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_freepage_state(zone, -1, migratetype); ret = true; break; }