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] [day] [month] [year] [list]
Message-ID: <20250608181030.20741f9b@pumpkin>
Date: Sun, 8 Jun 2025 18:10:30 +0100
From: David Laight <david.laight.linux@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: lizhe.67@...edance.com, akpm@...ux-foundation.org, jgg@...pe.ca,
 jhubbard@...dia.com, peterx@...hat.com, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, muchun.song@...ux.dev, dev.jain@....com
Subject: Re: [PATCH v4] gup: optimize longterm pin_user_pages() for large
 folio

On Fri, 6 Jun 2025 09:21:25 +0200
David Hildenbrand <david@...hat.com> wrote:

> >    * Returns the number of collected folios. Return value is always >= 0.
> >    */
> > @@ -2324,16 +2349,12 @@ static void collect_longterm_unpinnable_folios(
> >   		struct list_head *movable_folio_list,
> >   		struct pages_or_folios *pofs)
> >   {
> > -	struct folio *prev_folio = NULL;
> >   	bool drain_allow = true;
> > -	unsigned long i;
> > -
> > -	for (i = 0; i < pofs->nr_entries; i++) {
> > -		struct folio *folio = pofs_get_folio(pofs, i);
> > +	struct folio *folio;
> > +	long i = 0;
> >   
> > -		if (folio == prev_folio)
> > -			continue;
> > -		prev_folio = folio;
> > +	for (folio = pofs_get_folio(pofs, i); folio;
> > +		 folio = pofs_next_folio(folio, pofs, &i)) {  
> 
> Nit: indentation is still off?

I tend to move the 'initialisation' to the line above:
	folio = pofs_get_folio(pofs, i);
	for (; folio; folio = pofs_next_folio(folio, pofs, &i)) {
		code...
For 'search' loops you don't always want the conditional, so:
	folio = pofs_get_folio(pofs, i);
	for (;; folio = pofs_next_folio(folio, pofs, &i)) {
		if (!folio)
			return -ENOENT;
		code...

The 'really useful (tm)' part of a 'for' loop is the statement
executed by 'continue'.

:-)

	David


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ