2022-09-29 10:51:34

by Shradha Gupta

[permalink] [raw]
Subject: [PATCH 0/2] Configurable order free page reporting in hyper-v

Configurable order free page reporting is enabled in page_reporting
driver in mm tree. However, changes need to be made in drivers like
hyper-v's hv_balloon to make it aware of the page order.
These patches add support for the same.
In the page_reporting driver we export the page_reporting_order module
parameter. Following precedence is added in setting the reporting order
a. Value of page_reporting_order parameter
b. Value of order passed while registering with the driver
c. default value (pageblock_order)
Besides this, in the page_reporting module a check is added to ensure
that whenever the page_reporting_order value is changed, it is within
the prescribed limits.

The hv_balloon side changes include consuming the exported
page_reporting_order. Making changes in reporting these variable order
free pages as cold discard hints to hyper-v and dropping and refining
checks that restrict the order to a minimum of 9(default).

Shradha Gupta (2):
mm/page_reporting: Add checks for page_reporting_order param value
hv_balloon: Add support for configurable order free page reporting

drivers/hv/hv_balloon.c | 94 ++++++++++++++++++++++++++++++++---------
mm/page_reporting.c | 50 ++++++++++++++++++++++++++++++++++++++++-----
2 file changed, 118 insertions(+), 26 deletions(-)

--
2.37.2


2022-09-29 11:14:36

by Shradha Gupta

[permalink] [raw]
Subject: [PATCH 1/2] mm/page_reporting: Add checks for page_reporting_order param value

Current code allows the page_reporting_order parameter to be changed
via sysfs to any integer value. The new value is used immediately
in page reporting code with no validation, which could cause incorrect
behavior. Fix this by adding validation of the new value.
Export this parameter for use in the driver that is calling the
page_reporting_register().
This is needed by drivers like hv_balloon to know the order of the
pages reported. Traditionally the values provided in the kernel boot
line or subsequently changed via sysfs take priority therefore, if
page_reporting_order parameter's value is set, it takes precedence
over the value passed while registering with the driver.

Signed-off-by: Shradha Gupta <[email protected]>
---
mm/page_reporting.c | 50 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 5 deletions(-)

diff --git a/mm/page_reporting.c b/mm/page_reporting.c
index 382958eef8a9..29d67c824fd2 100644
--- a/mm/page_reporting.c
+++ b/mm/page_reporting.c
@@ -11,10 +11,42 @@
#include "page_reporting.h"
#include "internal.h"

-unsigned int page_reporting_order = MAX_ORDER;
-module_param(page_reporting_order, uint, 0644);
+/* Initialize to an unsupported value */
+unsigned int page_reporting_order = -1;
+
+int page_order_update_notify(const char *val, const struct kernel_param *kp)
+{
+ /*
+ * If param is set beyond this limit, order is set to default
+ * pageblock_order value
+ */
+ return param_set_uint_minmax(val, kp, 0, MAX_ORDER-1);
+}
+
+const struct kernel_param_ops page_reporting_param_ops = {
+ .set = &page_order_update_notify,
+ /*
+ * For the get op, use param_get_int instead of param_get_uint.
+ * This is to make sure that when unset the initialized value of
+ * -1 is shown correctly
+ */
+ .get = &param_get_int,
+};
+
+module_param_cb(page_reporting_order, &page_reporting_param_ops,
+ &page_reporting_order, 0644);
MODULE_PARM_DESC(page_reporting_order, "Set page reporting order");

+/*
+ * This symbol is also a kernel parameter. Export the page_reporting_order
+ * symbol so that other drivers can access it to control order values without
+ * having to introduce another configurable parameter. Only one driver can
+ * register with the page_reporting driver for the service, so we have just
+ * one control parameter for the use case(which can be accessed in both
+ * drivers)
+ */
+EXPORT_SYMBOL_GPL(page_reporting_order);
+
#define PAGE_REPORTING_DELAY (2 * HZ)
static struct page_reporting_dev_info __rcu *pr_dev_info __read_mostly;

@@ -330,10 +362,18 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)
}

/*
- * Update the page reporting order if it's specified by driver.
- * Otherwise, it falls back to @pageblock_order.
+ * If the page_reporting_order value is not set, we check if
+ * an order is provided from the driver that is performing the
+ * registration. If that is not provided either, we default to
+ * pageblock_order.
*/
- page_reporting_order = prdev->order ? : pageblock_order;
+
+ if (page_reporting_order == -1) {
+ if (prdev->order > 0 && prdev->order <= MAX_ORDER)
+ page_reporting_order = prdev->order;
+ else
+ page_reporting_order = pageblock_order;
+ }

/* initialize state and work structures */
atomic_set(&prdev->state, PAGE_REPORTING_IDLE);
--
2.37.2

2022-09-30 06:34:17

by Shradha Gupta

[permalink] [raw]
Subject: [PATCH v2 0/2] Configurable order free page reporting in hyper-v

In some scenarios Hyper-V needs to manage memory more tightly, so it needs as
much information as possible about unused guest pages. To that end Hyper-V
now allows free page reporting in chunks smaller than 2 Mbytes. Because of
the performance tradeoffs, we want to make the chunk size configurable. Since
there's already a free page reporting module parameter, let's use that rather
than creating yet another parameter.

Configurable order free page reporting is enabled in page_reporting
driver in mm tree. However, changes need to be made in drivers like
hyper-v's hv_balloon to make it aware of the page order.
These patches add support for the same.
In the page_reporting driver(patch 1) we export the page_reporting_order
module parameter. Besides this, in the page_reporting module a check is
added to ensure that whenever the page_reporting_order value is changed, it
is within the prescribed limits.

The hv_balloon side changes(patch 2) include consuming the exported
page_reporting_order. Making changes in reporting these variable order
free pages as cold discard hints to hyper-v and dropping and refining
checks that restrict the order to a minimum of 9(default).

---
Changes in v2
* Add more details in the cover letter about the motivation
* Fix the threading between dependent patches

Shradha Gupta (2):
mm/page_reporting: Add checks for page_reporting_order param
hv_balloon: Add support for configurable order free page reporting

drivers/hv/hv_balloon.c | 94 ++++++++++++++++++++++++++++++++---------
mm/page_reporting.c | 50 +++++++++++++++++++---
2 files changed, 118 insertions(+), 26 deletions(-)

--
2.37.2

2022-10-01 08:11:53

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/2] mm/page_reporting: Add checks for page_reporting_order param value

Hi Shradha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.0-rc7 next-20220930]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Shradha-Gupta/Configurable-order-free-page-reporting-in-hyper-v/20220929-182918
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: arm-randconfig-r003-20220926
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/c3ac7f3e00c93db62e279104fae0b6df0c80d4af
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shradha-Gupta/Configurable-order-free-page-reporting-in-hyper-v/20220929-182918
git checkout c3ac7f3e00c93db62e279104fae0b6df0c80d4af
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> mm/page_reporting.c:17:5: warning: no previous prototype for function 'page_order_update_notify' [-Wmissing-prototypes]
int page_order_update_notify(const char *val, const struct kernel_param *kp)
^
mm/page_reporting.c:17:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int page_order_update_notify(const char *val, const struct kernel_param *kp)
^
static
1 warning generated.


vim +/page_order_update_notify +17 mm/page_reporting.c

16
> 17 int page_order_update_notify(const char *val, const struct kernel_param *kp)
18 {
19 /*
20 * If param is set beyond this limit, order is set to default
21 * pageblock_order value
22 */
23 return param_set_uint_minmax(val, kp, 0, MAX_ORDER-1);
24 }
25

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (2.62 kB)
config (150.11 kB)
Download all attachments

2022-10-01 10:14:17

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/2] mm/page_reporting: Add checks for page_reporting_order param value

Hi Shradha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.0-rc7 next-20220930]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Shradha-Gupta/Configurable-order-free-page-reporting-in-hyper-v/20220929-182918
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: arc-randconfig-r043-20220928
compiler: arc-elf-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/c3ac7f3e00c93db62e279104fae0b6df0c80d4af
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shradha-Gupta/Configurable-order-free-page-reporting-in-hyper-v/20220929-182918
git checkout c3ac7f3e00c93db62e279104fae0b6df0c80d4af
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> mm/page_reporting.c:17:5: warning: no previous prototype for 'page_order_update_notify' [-Wmissing-prototypes]
17 | int page_order_update_notify(const char *val, const struct kernel_param *kp)
| ^~~~~~~~~~~~~~~~~~~~~~~~


vim +/page_order_update_notify +17 mm/page_reporting.c

16
> 17 int page_order_update_notify(const char *val, const struct kernel_param *kp)
18 {
19 /*
20 * If param is set beyond this limit, order is set to default
21 * pageblock_order value
22 */
23 return param_set_uint_minmax(val, kp, 0, MAX_ORDER-1);
24 }
25

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (2.23 kB)
config (180.11 kB)
Download all attachments

2022-10-28 11:11:09

by Wei Liu

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Configurable order free page reporting in hyper-v

On Thu, Sep 29, 2022 at 11:01:37PM -0700, Shradha Gupta wrote:
[...]
>
> Shradha Gupta (2):
> mm/page_reporting: Add checks for page_reporting_order param
> hv_balloon: Add support for configurable order free page reporting
>

Applied to hyperv-next. Thanks.