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: <e3075e27-93d2-4a11-a174-f05a7497870e@intel.com>
Date: Thu, 12 Jun 2025 07:09:34 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Pankaj Raghav <p.raghav@...sung.com>,
 Suren Baghdasaryan <surenb@...gle.com>, Ryan Roberts <ryan.roberts@....com>,
 Mike Rapoport <rppt@...nel.org>, Michal Hocko <mhocko@...e.com>,
 Thomas Gleixner <tglx@...utronix.de>, Nico Pache <npache@...hat.com>,
 Dev Jain <dev.jain@....com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
 Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...hat.com>,
 "H . Peter Anvin" <hpa@...or.com>, Vlastimil Babka <vbabka@...e.cz>,
 Zi Yan <ziy@...dia.com>, Dave Hansen <dave.hansen@...ux.intel.com>,
 David Hildenbrand <david@...hat.com>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 Andrew Morton <akpm@...ux-foundation.org>,
 "Liam R . Howlett" <Liam.Howlett@...cle.com>, Jens Axboe <axboe@...nel.dk>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org, willy@...radead.org,
 x86@...nel.org, linux-block@...r.kernel.org, linux-fsdevel@...r.kernel.org,
 "Darrick J . Wong" <djwong@...nel.org>, mcgrof@...nel.org,
 gost.dev@...sung.com, kernel@...kajraghav.com, hch@....de
Subject: Re: [PATCH 4/5] mm: add mm_get_static_huge_zero_folio() routine

On 6/12/25 03:50, Pankaj Raghav wrote:
> +/*
> + * mm_get_static_huge_zero_folio - Get a PMD sized zero folio

Isn't that a rather inaccurate function name and comment?

The third line of the function literally returns a non-PMD-sized zero folio.

> + * This function will return a PMD sized zero folio if CONFIG_STATIC_PMD_ZERO_PAGE
> + * is enabled. Otherwise, a ZERO_PAGE folio is returned.
> + *
> + * Deduce the size of the folio with folio_size instead of assuming the
> + * folio size.
> + */
> +static inline struct folio *mm_get_static_huge_zero_folio(void)
> +{
> +	if(IS_ENABLED(CONFIG_STATIC_PMD_ZERO_PAGE))
> +		return READ_ONCE(huge_zero_folio);
> +	return page_folio(ZERO_PAGE(0));
> +}

This doesn't tell us very much about when I should use:

	mm_get_static_huge_zero_folio()
vs.
	mm_get_huge_zero_folio(mm)
vs.
	page_folio(ZERO_PAGE(0))

What's with the "mm_" in the name? Usually "mm" means "mm_struct" not
Memory Management. It's really weird to prefix something that doesn't
take an "mm_struct" with "mm_"

Isn't the "get_" also a bad idea since mm_get_huge_zero_folio() does its
own refcounting but this interface does not?

Shouldn't this be something more along the lines of:

/*
 * pick_zero_folio() - Pick and return the largest available zero folio
 *
 * mm_get_huge_zero_folio() is preferred over this function. It is more
 * flexible and can provide a larger zero page under wider
 * circumstances.
 *
 * Only use this when there is no mm available.
 *
 * ... then other comments
 */
static inline struct folio *pick_zero_folio(void)
{
	if (IS_ENABLED(CONFIG_STATIC_PMD_ZERO_PAGE))
		return READ_ONCE(huge_zero_folio);
	return page_folio(ZERO_PAGE(0));
}

Or, maybe even name it _just_: zero_folio()

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ