linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Aristeu Rozanski <aris@ruivo.org>
Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
	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: Tue, 26 Aug 2025 20:00:09 +0100	[thread overview]
Message-ID: <aK4EOf-EE43pi-xq@casper.infradead.org> (raw)
In-Reply-To: <20250826153721.GA23292@cathedrallabs.org>

On Tue, Aug 26, 2025 at 11:37:21AM -0400, Aristeu Rozanski wrote:
> As raised by Andrew [1], a folio/compound page never spans a negative number
> of pages. Consequently, let's use "unsigned long" instead of "long"
> consistently for folio_nr_pages(), folio_large_nr_pages() and compound_nr().
> 
> Using "unsigned long" as return value is fine, because even
> "(long)-folio_nr_pages()" will keep on working as expected. Using "unsigned
> int" instead would actually break these use cases.

I wish I'd written down what this broke, but it did.

Sometimes we pass -folio_nr_pages() to functions.  If it has an unsigned
long type, things can go wrong.

Please don't do this.


  reply	other threads:[~2025-08-26 19:00 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 [this message]
2025-08-26 21:45   ` David Hildenbrand
2025-08-26 22:00     ` Aristeu Rozanski
2025-08-27  1:20       ` Matthew Wilcox
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=aK4EOf-EE43pi-xq@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