linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Aristeu Rozanski <aris@ruivo.org>
To: David Hildenbrand <david@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	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: Tue, 26 Aug 2025 18:00:41 -0400	[thread overview]
Message-ID: <20250826220041.GS3581799@cathedrallabs.org> (raw)
In-Reply-To: <a959a7f8-20c0-4c2a-9cef-ffad4f8b805b@redhat.com>

On Tue, Aug 26, 2025 at 11:45:52PM +0200, David Hildenbrand wrote:
> IIRC, the issue is if we pass -folio_nr_pages() to functions that expect 
> a "long" and we are using "unsigned int" as return type.

some actually expect an int (e.g. memcg1_charge_statistics()), it'd be a good
idea to get those fixed.

> 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 :^)

-- 
Aristeu



  reply	other threads:[~2025-08-26 22:01 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 [this message]
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=20250826220041.GS3581799@cathedrallabs.org \
    --to=aris@ruivo.org \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.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 \
    --cc=willy@infradead.org \
    /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