[PATCH] s390/cmm: Use max to simplify cmm_timer_fn

Thorsten Blum posted 1 patch 1 month, 2 weeks ago
arch/s390/mm/cmm.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH] s390/cmm: Use max to simplify cmm_timer_fn
Posted by Thorsten Blum 1 month, 2 weeks ago
Use max() to replace the open-coded version and simplify cmm_timer_fn().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/s390/mm/cmm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index 06512bc178a5..fa1318d748b1 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/init.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/gfp.h>
@@ -212,10 +213,7 @@ static void cmm_timer_fn(struct timer_list *unused)
 	long nr;
 
 	nr = cmm_timed_pages_target - cmm_timeout_pages;
-	if (nr < 0)
-		cmm_timed_pages_target = 0;
-	else
-		cmm_timed_pages_target = nr;
+	cmm_timed_pages_target = max(0, nr);
 	cmm_kick_thread();
 	cmm_set_timer();
 }
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
Re: [PATCH] s390/cmm: Use max to simplify cmm_timer_fn
Posted by Heiko Carstens 1 month, 2 weeks ago
Thorsten,

On Mon, Dec 22, 2025 at 11:39:17AM +0100, Thorsten Blum wrote:
> Use max() to replace the open-coded version and simplify cmm_timer_fn().
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/s390/mm/cmm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

...

>  	nr = cmm_timed_pages_target - cmm_timeout_pages;
> -	if (nr < 0)
> -		cmm_timed_pages_target = 0;
> -	else
> -		cmm_timed_pages_target = nr;
> +	cmm_timed_pages_target = max(0, nr);

Just in case it wasn't clear in the past: trivial patches like this won't be
taken. You already managed to send buggy patches which look trivial, and I'm
not willing to spend time to look for subtle bugs such trivial patches might
introduce.

In other words: you may stop sending such patches which address s390 code.