lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85994845-1aad-4142-adb3-91aa231b5a7d@linux.dev>
Date: Mon, 3 Jun 2024 14:07:40 +0800
From: Chengming Zhou <chengming.zhou@...ux.dev>
To: Yosry Ahmed <yosryahmed@...gle.com>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: Johannes Weiner <hannes@...xchg.org>, Nhat Pham <nphamcs@...il.com>,
 Matthew Wilcox <willy@...radead.org>, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] mm: zswap: make same_filled functions folio-friendly

On 2024/5/24 11:38, Yosry Ahmed wrote:
> A variable name 'page' is used in zswap_is_folio_same_filled() and
> zswap_fill_page() to point at the kmapped data in a folio. Use 'data'
> instead to avoid confusion and stop it from showing up when searching
> for 'page' references in mm/zswap.c.
> 
> While we are at it, move the kmap/kunmap calls into zswap_fill_page(),
> make it take in a folio, and rename it to zswap_fill_folio().
> 
> Signed-off-by: Yosry Ahmed <yosryahmed@...gle.com>

LGTM, thanks!

Reviewed-by: Chengming Zhou <chengming.zhou@...ux.dev>

> ---
>  mm/zswap.c | 30 +++++++++++++-----------------
>  1 file changed, 13 insertions(+), 17 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index bac66991fb14e..b9b35ef86d9be 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -1375,35 +1375,35 @@ static void shrink_worker(struct work_struct *w)
>  **********************************/
>  static bool zswap_is_folio_same_filled(struct folio *folio, unsigned long *value)
>  {
> -	unsigned long *page;
> +	unsigned long *data;
>  	unsigned long val;
> -	unsigned int pos, last_pos = PAGE_SIZE / sizeof(*page) - 1;
> +	unsigned int pos, last_pos = PAGE_SIZE / sizeof(*data) - 1;
>  	bool ret = false;
>  
> -	page = kmap_local_folio(folio, 0);
> -	val = page[0];
> +	data = kmap_local_folio(folio, 0);
> +	val = data[0];
>  
> -	if (val != page[last_pos])
> +	if (val != data[last_pos])
>  		goto out;
>  
>  	for (pos = 1; pos < last_pos; pos++) {
> -		if (val != page[pos])
> +		if (val != data[pos])
>  			goto out;
>  	}
>  
>  	*value = val;
>  	ret = true;
>  out:
> -	kunmap_local(page);
> +	kunmap_local(data);
>  	return ret;
>  }
>  
> -static void zswap_fill_page(void *ptr, unsigned long value)
> +static void zswap_fill_folio(struct folio *folio, unsigned long value)
>  {
> -	unsigned long *page;
> +	unsigned long *data = kmap_local_folio(folio, 0);
>  
> -	page = (unsigned long *)ptr;
> -	memset_l(page, value, PAGE_SIZE / sizeof(unsigned long));
> +	memset_l(data, value, PAGE_SIZE / sizeof(unsigned long));
> +	kunmap_local(data);
>  }
>  
>  /*********************************
> @@ -1554,7 +1554,6 @@ bool zswap_load(struct folio *folio)
>  	bool swapcache = folio_test_swapcache(folio);
>  	struct xarray *tree = swap_zswap_tree(swp);
>  	struct zswap_entry *entry;
> -	u8 *dst;
>  
>  	VM_WARN_ON_ONCE(!folio_test_locked(folio));
>  
> @@ -1580,11 +1579,8 @@ bool zswap_load(struct folio *folio)
>  
>  	if (entry->length)
>  		zswap_decompress(entry, folio);
> -	else {
> -		dst = kmap_local_folio(folio, 0);
> -		zswap_fill_page(dst, entry->value);
> -		kunmap_local(dst);
> -	}
> +	else
> +		zswap_fill_folio(folio, entry->value);
>  
>  	count_vm_event(ZSWPIN);
>  	if (entry->objcg)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ