From patchwork Fri Mar 26 09:44:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 12166143 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,UNPARSEABLE_RELAY,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 71626C433DB for ; Fri, 26 Mar 2021 09:45:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 837CB61A0F for ; Fri, 26 Mar 2021 09:45:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 837CB61A0F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C8B346B0070; Fri, 26 Mar 2021 05:45:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C10576B006E; Fri, 26 Mar 2021 05:45:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB00D6B0072; Fri, 26 Mar 2021 05:45:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id 857A96B006E for ; Fri, 26 Mar 2021 05:45:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3596D8249980 for ; Fri, 26 Mar 2021 09:45:04 +0000 (UTC) X-FDA: 77961541728.23.80E1B16 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf26.hostedemail.com (Postfix) with ESMTP id 732B440002C4 for ; Fri, 26 Mar 2021 09:45:01 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=xlpang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0UTMseJh_1616751899; Received: from localhost(mailfrom:xlpang@linux.alibaba.com fp:SMTPD_---0UTMseJh_1616751899) by smtp.aliyun-inc.com(127.0.0.1); Fri, 26 Mar 2021 17:44:59 +0800 From: Xunlei Pang To: Andrew Morton , Alexander Duyck , Mel Gorman Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Xunlei Pang Subject: [PATCH 3/4] mm/page_reporting: Introduce "page_reporting_factor=" boot parameter Date: Fri, 26 Mar 2021 17:44:57 +0800 Message-Id: <1616751898-58393-4-git-send-email-xlpang@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616751898-58393-1-git-send-email-xlpang@linux.alibaba.com> References: <1616751898-58393-1-git-send-email-xlpang@linux.alibaba.com> X-Stat-Signature: wd4hoqyskyktpribhmkmmsmssxc7cp8e X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 732B440002C4 Received-SPF: none (linux.alibaba.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=out30-44.freemail.mail.aliyun.com; client-ip=115.124.30.44 X-HE-DKIM-Result: none/none X-HE-Tag: 1616751901-331044 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: Currently the default behaviour(value 100) is to do full report, although we can control it after boot via "page_reporting_factor" sysfs knob, it could still be late because some amount of memory has already been reported before operating this knob. Sometimes we really want it safely off by default and turn it on as needed at runtime, so "page_reporting_factor=" boot parameter is that guarantee and meets different default setting requirements. There's also a real-world problem that I noticed on tiny instances, it always reports some memory at boot stage before application starts and uses up memory which retriggers EPT fault after boot. The following data(right after boot) indicates that 172032KiB pages were unnecessarily reported and refault in: $ cat /sys/kernel/mm/page_reporting/refault_kbytes 172032 $ cat /sys/kernel/mm/page_reporting/reported_kbytes 0 Thus it's reasonable to turn the page reporting off by default and enable it at runtime as needed. Signed-off-by: Xunlei Pang --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ mm/page_reporting.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0454572..46e296c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3524,6 +3524,9 @@ off: turn off poisoning (default) on: turn on poisoning + page_reporting_factor= [KNL] Guest Free Page Reporting percentile. + [0, 100]: 0 - off, not report; 100 - default, full report. + panic= [KNL] Kernel behaviour on panic: delay timeout > 0: seconds before rebooting timeout = 0: wait forever diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 86c6479..6ffedb8 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -524,3 +524,16 @@ static int __init page_reporting_init(void) } module_init(page_reporting_init); + +static int __init setup_reporting_factor(char *str) +{ + int v; + + if (kstrtoint(str, 10, &v)) + return -EINVAL; + if (v >= 0 && v <= 100) + reporting_factor = v; + + return 0; +} +__setup("page_reporting_factor=", setup_reporting_factor);