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]
Date:   Tue, 23 Mar 2021 11:29:24 +0100
From:   David Hildenbrand <david@...hat.com>
To:     Miaohe Lin <linmiaohe@...wei.com>, akpm@...ux-foundation.org
Cc:     jglisse@...hat.com, shy828301@...il.com,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 4/5] mm/migrate.c: use helper migrate_vma_collect_skip()
 in migrate_vma_collect_hole()

On 20.03.21 10:37, Miaohe Lin wrote:
> It's more recommended to use helper function migrate_vma_collect_skip() to
> skip the unexpected case and it also helps remove some duplicated codes.
> Move migrate_vma_collect_skip() above migrate_vma_collect_hole() to avoid
> compiler warning.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
> ---
>   mm/migrate.c | 28 +++++++++++-----------------
>   1 file changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 271081b014cb..3e169b72d7b2 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2315,44 +2315,38 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
>   #endif /* CONFIG_NUMA */
>   
>   #ifdef CONFIG_DEVICE_PRIVATE
> -static int migrate_vma_collect_hole(unsigned long start,
> +static int migrate_vma_collect_skip(unsigned long start,
>   				    unsigned long end,
> -				    __always_unused int depth,
>   				    struct mm_walk *walk)
>   {
>   	struct migrate_vma *migrate = walk->private;
>   	unsigned long addr;
>   
> -	/* Only allow populating anonymous memory. */
> -	if (!vma_is_anonymous(walk->vma)) {
> -		for (addr = start; addr < end; addr += PAGE_SIZE) {
> -			migrate->src[migrate->npages] = 0;
> -			migrate->dst[migrate->npages] = 0;
> -			migrate->npages++;
> -		}
> -		return 0;
> -	}
> -
>   	for (addr = start; addr < end; addr += PAGE_SIZE) {
> -		migrate->src[migrate->npages] = MIGRATE_PFN_MIGRATE;
>   		migrate->dst[migrate->npages] = 0;
> -		migrate->npages++;
> -		migrate->cpages++;
> +		migrate->src[migrate->npages++] = 0;
>   	}
>   
>   	return 0;
>   }
>   
> -static int migrate_vma_collect_skip(unsigned long start,
> +static int migrate_vma_collect_hole(unsigned long start,
>   				    unsigned long end,
> +				    __always_unused int depth,
>   				    struct mm_walk *walk)
>   {
>   	struct migrate_vma *migrate = walk->private;
>   	unsigned long addr;
>   
> +	/* Only allow populating anonymous memory. */
> +	if (!vma_is_anonymous(walk->vma))
> +		return migrate_vma_collect_skip(start, end, walk);
> +
>   	for (addr = start; addr < end; addr += PAGE_SIZE) {
> +		migrate->src[migrate->npages] = MIGRATE_PFN_MIGRATE;
>   		migrate->dst[migrate->npages] = 0;
> -		migrate->src[migrate->npages++] = 0;
> +		migrate->npages++;
> +		migrate->cpages++;
>   	}
>   
>   	return 0;
> 


Reviewed-by: David Hildenbrand <david@...hat.com>

-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ