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: Thu, 4 Apr 2024 09:45:58 -0400
From: Peter Xu <peterx@...hat.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	Huacai Chen <chenhuacai@...nel.org>,
	David Hildenbrand <david@...hat.com>,
	Jason Gunthorpe <jgg@...dia.com>,
	Nathan Chancellor <nathan@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	WANG Xuerui <kernel@...0n.name>,
	Ryan Roberts <ryan.roberts@....com>, loongarch@...ts.linux.dev
Subject: Re: [PATCH 1/3] mm: Allow anon exclusive check over hugetlb tail
 pages

On Thu, Apr 04, 2024 at 01:05:57AM +0100, Matthew Wilcox wrote:
> On Tue, Apr 02, 2024 at 09:32:47PM -0400, peterx@...hat.com wrote:
> > +++ b/include/linux/page-flags.h
> > @@ -1095,7 +1095,13 @@ PAGEFLAG(Isolated, isolated, PF_ANY);
> >  static __always_inline int PageAnonExclusive(const struct page *page)
> >  {
> >  	VM_BUG_ON_PGFLAGS(!PageAnon(page), page);
> > -	VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page);
> > +	/*
> > +	 * Allow the anon-exclusive check to work on hugetlb tail pages.
> > +	 * Here hugetlb pages will always guarantee the anon-exclusiveness
> > +	 * of the head page represents the tail pages.
> > +	 */
> > +	if (PageHuge(page) && !PageHead(page))
> > +		page = compound_head(page);
> 
> I think this should be written as:
> 
> 	/*
> 	 * HugeTLB stores this information on the head page; THP keeps
> 	 * it per page
> 	 */

This comment does look clean and cleaner indeed.  And yes, mention THP can
be helpful too.

> 	if (PageHuge(page))
> 		page = compound_head(page);

I would think PageHead() check would help us to avoid compound_head() on
heads, which should still be the majority cases iiuc (assuming page->flags
is already around in the cache anyway).  I've no strong opinion though, as
I can hardly tell a difference in reality.

> 
> >  	return test_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags);
> >  }
> 

Thanks,

-- 
Peter Xu


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ