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: <20200309174854.b6b8c7f019c3dde048c28f94@linux-foundation.org>
Date:   Mon, 9 Mar 2020 17:48:54 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Wei Yang <richard.weiyang@...ux.alibaba.com>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Tim Chen <tim.c.chen@...ux.intel.com>
Subject: Re: [PATCH] mm/swap_slots.c: don't reset the cache slot after use

On Mon,  9 Mar 2020 17:09:40 +0800 Wei Yang <richard.weiyang@...ux.alibaba.com> wrote:

> Currently we would clear the cache slot if it is used. While this is not
> necessary, since this entry would not be used until refilled.
> 
> Leave it untouched and assigned the value directly to entry which makes
> the code little more neat.
> 
> Also this patch merges the else and if, since this is the only case we
> refill and repeat swap cache.

cc Tim, who can hopefully remember how this code works ;)

> --- a/mm/swap_slots.c
> +++ b/mm/swap_slots.c
> @@ -309,7 +309,7 @@ int free_swap_slot(swp_entry_t entry)
>  
>  swp_entry_t get_swap_page(struct page *page)
>  {
> -	swp_entry_t entry, *pentry;
> +	swp_entry_t entry;
>  	struct swap_slots_cache *cache;
>  
>  	entry.val = 0;
> @@ -336,13 +336,10 @@ swp_entry_t get_swap_page(struct page *page)
>  		if (cache->slots) {
>  repeat:
>  			if (cache->nr) {
> -				pentry = &cache->slots[cache->cur++];
> -				entry = *pentry;
> -				pentry->val = 0;
> +				entry = cache->slots[cache->cur++];
>  				cache->nr--;
> -			} else {
> -				if (refill_swap_slots_cache(cache))
> -					goto repeat;
> +			} else if (refill_swap_slots_cache(cache)) {
> +				goto repeat;
>  			}
>  		}
>  		mutex_unlock(&cache->alloc_lock);
> -- 
> 2.20.1 (Apple Git-117)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ