linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: WangYuli <wangyuli@uniontech.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	yuzhao@google.com, stevensd@chromium.org, kaleshsingh@google.com,
	zhanjun@uniontech.com, niecheng1@uniontech.com,
	guanwentao@uniontech.com, Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] mm: vmscan: Avoid signedness error for GCC 5.4
Date: Sat, 10 May 2025 11:24:19 +0100	[thread overview]
Message-ID: <20250510112419.749652a7@pumpkin> (raw)
In-Reply-To: <74D5BC8AD7E5511A+13242b55-13e5-463a-9422-f863d58b6af6@uniontech.com>

On Wed, 7 May 2025 12:06:11 +0800
WangYuli <wangyuli@uniontech.com> wrote:

> Hi Andrew Morton,
> 
> On 2025/5/7 07:24, Andrew Morton wrote:
> > On Wed,  7 May 2025 00:02:38 +0800 WangYuli <wangyuli@uniontech.com> wrote:
> >
> > Make `tier' unsigned?  After all, negative tier numbers are nonsensical.  
> 
> That point is well taken.
> 
> However, I've noticed that variables named "tier" seem to be commonly 
> defined as int rather than unsigned int throughout the mm subsystem, and 
> perhaps even the wider kernel code.
> 
> I was wondering if changing just this one instance might feel a little 
> inconsistent?
> 
> Perhaps a possible approach for now could be to change this line to for 
> (i = tier % MAX_NR_TIERS; i <= min_t(int, tier, MAX_NR_TIERS - 1); i++) 
> {, which would allow us to keep the signed int type for the tier 
> variable itself.

Remember that min_t(int, a, b) is just min((int)a, (int)b) and you really
wouldn't put casts like that in code.
Even if a cast can't be avoided only one side would normally need it.

There really ought to be a 'duck shoot' against min_t().
I'm trying very hard to stop any more being added.

	David

> 
> Regarding the potential for a more comprehensive change in the future to 
> redefine all these "tier" variables and related ones as unsigned int, I 
> would be very grateful for your guidance on whether that's a direction 
> we should consider.
> 
> But actually, whether it's signed or not likely won't affect its normal 
> operation...
> 
> Thanks,
> 



  parent reply	other threads:[~2025-05-10 10:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 16:02 WangYuli
2025-05-06 16:22 ` Matthew Wilcox
2025-05-07  2:55   ` WangYuli
2025-05-07 20:46     ` David Laight
2025-05-07 12:06   ` David Laight
2025-05-06 23:24 ` Andrew Morton
2025-05-07  4:06   ` WangYuli
2025-05-07 18:07     ` Andrew Morton
2025-05-07 20:49       ` Matthew Wilcox
2025-05-10 10:24     ` David Laight [this message]
2025-05-15 15:11       ` WangYuli

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=20250510112419.749652a7@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=guanwentao@uniontech.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=niecheng1@uniontech.com \
    --cc=stevensd@chromium.org \
    --cc=wangyuli@uniontech.com \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.com \
    --cc=zhanjun@uniontech.com \
    /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