linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: vmscan: Avoid signedness error for GCC 5.4
@ 2025-05-07  4:08 WangYuli
  2025-05-07 20:40 ` David Laight
  0 siblings, 1 reply; 2+ messages in thread
From: WangYuli @ 2025-05-07  4:08 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, linux-kernel, yuzhao, stevensd, kaleshsingh, zhanjun,
	niecheng1, guanwentao, WangYuli, Matthew Wilcox

To the GCC 5.4 compiler, (MAX_NR_TIERS - 1) (i.e., (4U - 1)) is
unsigned, whereas tier is a signed integer.

Then, the __types_ok check within the __careful_cmp_once macro failed,
triggered BUILD_BUG_ON.

Use min_t instead of min to circumvent this compiler error.

Fix follow error with gcc 5.4:
  mm/vmscan.c: In function ‘read_ctrl_pos’:
  mm/vmscan.c:3166:728: error: call to ‘__compiletime_assert_887’ declared with attribute error: min(tier, 4U - 1) signedness error

Cc: Matthew Wilcox <willy@infradead.org>
Fixes: 37a260870f2c ("mm/mglru: rework type selection")
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
Changelog:
 *v1->v2:
    1. Fix commit msg.
    2. Use min_t instead of min.
---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 3783e45bfc92..8d9a82621c4f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3163,7 +3163,7 @@ static void read_ctrl_pos(struct lruvec *lruvec, int type, int tier, int gain,
 	pos->gain = gain;
 	pos->refaulted = pos->total = 0;
 
-	for (i = tier % MAX_NR_TIERS; i <= min(tier, MAX_NR_TIERS - 1); i++) {
+	for (i = tier % MAX_NR_TIERS; i <= min_t(int, tier, MAX_NR_TIERS - 1); i++) {
 		pos->refaulted += lrugen->avg_refaulted[type][i] +
 				  atomic_long_read(&lrugen->refaulted[hist][type][i]);
 		pos->total += lrugen->avg_total[type][i] +
-- 
2.49.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-07 20:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-07  4:08 [PATCH v2] mm: vmscan: Avoid signedness error for GCC 5.4 WangYuli
2025-05-07 20:40 ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox