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: <d833eb25-fd25-0211-2031-f3b4a5215139@nvidia.com>
Date:   Thu, 4 Aug 2022 16:06:56 -0700
From:   John Hubbard <jhubbard@...dia.com>
To:     Alistair Popple <apopple@...dia.com>, linux-mm@...ck.org
Cc:     akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
        "Sierra Guiza, Alejandro (Alex)" <alex.sierra@....com>,
        Chaitanya Kulkarni <kch@...dia.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Felix Kuehling <Felix.Kuehling@....com>,
        Jason Gunthorpe <jgg@...dia.com>,
        Logan Gunthorpe <logang@...tatee.com>,
        Miaohe Lin <linmiaohe@...wei.com>,
        Muchun Song <songmuchun@...edance.com>,
        Pasha Tatashin <pasha.tatashin@...een.com>,
        Ralph Campbell <rcampbell@...dia.com>
Subject: Re: [PATCH] mm/gup.c: Refactor check_and_migrate_movable_pages()

On 8/3/22 20:22, Alistair Popple wrote:
> @@ -1970,29 +1968,25 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
>   			drain_allow = false;
>   		}
>   
> -		if (folio_isolate_lru(folio)) {
> -			isolation_error_count++;
> +		if (folio_isolate_lru(folio))
>   			continue;
> -		}
> +
>   		list_add_tail(&folio->lru, &movable_page_list);
>   		node_stat_mod_folio(folio,
>   				    NR_ISOLATED_ANON + folio_is_file_lru(folio),
>   				    folio_nr_pages(folio));
>   	}
>   
> -	if (!list_empty(&movable_page_list) || isolation_error_count ||
> -	    coherent_pages)
> -		goto unpin_pages;
> -
>   	/*
> -	 * If list is empty, and no isolation errors, means that all pages are
> -	 * in the correct zone.
> +	 * All pages are still pinned and in the correct zone.
>   	 */
> -	return nr_pages;
> +	if (list_empty(&movable_page_list) && !coherent_pages)
> +		return 0;
>   

At this point, a second part of the (rather long) routine begins. If I
were refactoring this, I'd split it into a top level routine that calls
the two parts:

check_and_migrate_movable_pages()
	collect_migration_candidates()
	unpin_and_migrate_pages()

...which I think would further help in working with this thing.

(I realize that this is additional work. And that it's best done as a
separate patch. And it's just a suggestion.)

> -unpin_pages:
>   	/*
> -	 * pages[i] might be NULL if any device coherent pages were found.
> +	 * Unpin all pages. If device coherent pages were found
> +	 * migrate_deivce_coherent_page() will have already dropped the pin and

"migrate_device_coherent_page()"


thanks,
-- 
John Hubbard
NVIDIA

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ