Re: [RFC v2] zswap: Add CONFIG_ZSWAP_IO_SWITCH to handle swap IO issue

From: Randy Dunlap
Date: Fri Sep 20 2019 - 20:22:49 EST


On 9/19/19 11:35 PM, Hui Zhu wrote:
> This is the second version of this patch. The previous version is in
> https://lkml.org/lkml/2019/9/11/935
> I updated the commit introduction and Kconfig because it is not clear.
>
Hi,
Just a few minor fixes (below):

>
> Signed-off-by: Hui Zhu <teawaterz@xxxxxxxxxxxxxxxxx>
> ---
> include/linux/swap.h | 3 +++
> mm/Kconfig | 18 +++++++++++++++++
> mm/page_io.c | 16 +++++++++++++++
> mm/zswap.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 92 insertions(+)
>
> diff --git a/mm/Kconfig b/mm/Kconfig
> index 56cec63..5408d65 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -546,6 +546,24 @@ config ZSWAP
> they have not be fully explored on the large set of potential
> configurations and workloads that exist.
>
> +config ZSWAP_IO_SWITCH
> + bool "Compressed cache for swap pages according to the IO status"
> + depends on ZSWAP
> + def_bool n

Just drop the "def_bool n". It's already a "bool" and 'n' is the default value for it.

> + help
> + This function help the system that normal swap speed is higher

helps the system in which normal swap speed is higher

> + than zswap speed to handle the swap IO issue.
> + For example, a VM that is disk device is not set cache config or

possibly:
For example, a VM where the disk device is not set for cache config or

> + set cache=writeback.
> +
> + This function make zswap just work when the disk of the swap file

This function makes

> + is under high IO load.
> + It add two parameters read_in_flight_limit and write_in_flight_limit to

It adds two parameters (read_in_flight_limit and write_in_flight_limit) to

> + zswap. When zswap is enabled, pages will be stored to zswap only
> + when the IO in flight number of swap device is bigger than

of the swap device

> + zswap_read_in_flight_limit or zswap_write_in_flight_limit.
> + If unsure, say "n".
> +
> config ZPOOL
> tristate "Common API for compressed memory storage"
> help

> diff --git a/mm/zswap.c b/mm/zswap.c
> index 0e22744..1255645 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -62,6 +62,13 @@ static u64 zswap_reject_compress_poor;
> static u64 zswap_reject_alloc_fail;
> /* Store failed because the entry metadata could not be allocated (rare) */
> static u64 zswap_reject_kmemcache_fail;
> +#ifdef CONFIG_ZSWAP_IO_SWITCH
> +/* Store failed because zswap_read_in_flight_limit or
> + * zswap_write_in_flight_limit is bigger than IO in flight number of
> + * swap device
> + */

Please use the documented multi-line comment format. E.g.:

/*
* Store failed because zswap_read_in_flight_limit or
* zswap_write_in_flight_limit is bigger than IO in flight number of
* swap device.
*/

> +static u64 zswap_reject_io;
> +#endif
> /* Duplicate store was encountered (rare) */
> static u64 zswap_duplicate_entry;
>
> @@ -114,6 +121,22 @@ static bool zswap_same_filled_pages_enabled = true;
> module_param_named(same_filled_pages_enabled, zswap_same_filled_pages_enabled,
> bool, 0644);
>
> +#ifdef CONFIG_ZSWAP_IO_SWITCH
> +/* zswap will not try to store the page if zswap_read_in_flight_limit is
> + * bigger than IO read in flight number of swap device
> + */

Use documented multi-line comment format.

> +static unsigned int zswap_read_in_flight_limit;
> +module_param_named(read_in_flight_limit, zswap_read_in_flight_limit,
> + uint, 0644);
> +
> +/* zswap will not try to store the page if zswap_write_in_flight_limit is
> + * bigger than IO write in flight number of swap device
> + */

ditto.

thanks.
--
~Randy