linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Aristeu Rozanski <aris@ruivo.org>
Cc: David Hildenbrand <david@redhat.com>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Subject: Re: [PATCH] mm: make folio page count functions return unsigned
Date: Wed, 27 Aug 2025 02:20:41 +0100	[thread overview]
Message-ID: <aK5daUurTM8ET2gf@casper.infradead.org> (raw)
In-Reply-To: <20250826220041.GS3581799@cathedrallabs.org>

On Tue, Aug 26, 2025 at 06:00:41PM -0400, Aristeu Rozanski wrote:
> some actually expect an int (e.g. memcg1_charge_statistics()), it'd be a good
> idea to get those fixed.

Yes.

> > Then, e.g., -1 will be (unsigned int)0xffffffff, and casting that to 
> > "long" means trouble, because we wouldn't sign-extend properly and get 
> > (long)0x00000000ffffffff.
> > 
> > Using "unsigned long" instead work perfectly fine.
> > 
> > e.g., -1 will be (unsigned long)0xffffffffffffffff. Passing that to a 
> > function that expects "long" or "unsigned long" works as expected.
> 
> We could run into problems if folio_nr_pages() ever returns an unsigned long
> larger than LONG_MAX :^)

I feel comfortable saying that we'll never support a folio size larger
than 2^31 bytes on 32-bit or 2^63 bytes on 64-bit because folio_size()
returns a size_t so that constrains us.  That means folio_nr_pages()
must lie in the range [1..2^19] or [1..2^51] respectively.  We're never
going to support PAGE_SIZE smaller than 4KiB; nobody's interested in
designing hardware to support smaller page sizes.

We are likely to see folio_nr_pages() be larger than 2^31 at some point.
arm64 supports 2^13 pages per level, so a PMD is 2^13, a PUD is 2^26
and a P4D is 2^39 pages.  That's an utterly impractical page size for
most uses, but just wait until the AI people decide that it saaves them
a fraction of a joule per calculation.  I'm not putting any work into
supporting that at this point, but I'm also trying not to do anything
that makes adding that support harder.


  reply	other threads:[~2025-08-27  1:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26 15:37 Aristeu Rozanski
2025-08-26 19:00 ` Matthew Wilcox
2025-08-26 21:45   ` David Hildenbrand
2025-08-26 22:00     ` Aristeu Rozanski
2025-08-27  1:20       ` Matthew Wilcox [this message]
2025-08-27  9:14         ` David Hildenbrand
2025-08-27  9:13 ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aK5daUurTM8ET2gf@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aris@ruivo.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox