* [PATCH] xfs: Simplify maximum determination in xrep_calc_ag_resblks()
@ 2025-03-01 10:30 ` Markus Elfring
2025-04-30 8:27 ` Carlos Maiolino
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2025-03-01 10:30 UTC (permalink / raw)
To: linux-xfs, Carlos Maiolino, Chandan Babu R, Darrick J. Wong
Cc: LKML, kernel-janitors, Qasim Ijaz, Natalie Vock
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Mar 2025 11:24:52 +0100
Reduce nested max() calls by a single max3() call in this
function implementation.
The source code was transformed by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/xfs/scrub/repair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 3b5288d3ef4e..6b23a3943907 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -382,7 +382,7 @@ xrep_calc_ag_resblks(
refcbt_sz);
xfs_perag_put(pag);
- return max(max(bnobt_sz, inobt_sz), max(rmapbt_sz, refcbt_sz));
+ return max3(bnobt_sz, inobt_sz, max(rmapbt_sz, refcbt_sz));
}
#ifdef CONFIG_XFS_RT
--
2.48.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: Simplify maximum determination in xrep_calc_ag_resblks()
2025-03-01 10:30 ` [PATCH] xfs: Simplify maximum determination in xrep_calc_ag_resblks() Markus Elfring
@ 2025-04-30 8:27 ` Carlos Maiolino
2025-04-30 8:34 ` Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Carlos Maiolino @ 2025-04-30 8:27 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-xfs, Chandan Babu R, Darrick J. Wong, LKML,
kernel-janitors, Qasim Ijaz, Natalie Vock
On Sat, Mar 01, 2025 at 11:30:52AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 1 Mar 2025 11:24:52 +0100
>
> Reduce nested max() calls by a single max3() call in this
> function implementation.
>
> The source code was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> fs/xfs/scrub/repair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
> index 3b5288d3ef4e..6b23a3943907 100644
> --- a/fs/xfs/scrub/repair.c
> +++ b/fs/xfs/scrub/repair.c
> @@ -382,7 +382,7 @@ xrep_calc_ag_resblks(
> refcbt_sz);
> xfs_perag_put(pag);
>
> - return max(max(bnobt_sz, inobt_sz), max(rmapbt_sz, refcbt_sz));
> + return max3(bnobt_sz, inobt_sz, max(rmapbt_sz, refcbt_sz));
I have nothing against the patch itself, but honestly I don't see how it
improves anything. It boils down to nesting comparison instructions too, and
doesn't make the code more clear IMHO.
So, unless somebody else has a stronger reason to have this change, NAK from my
side.
Carlos
> }
>
> #ifdef CONFIG_XFS_RT
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: Simplify maximum determination in xrep_calc_ag_resblks()
2025-04-30 8:27 ` Carlos Maiolino
@ 2025-04-30 8:34 ` Markus Elfring
2025-04-30 9:34 ` Carlos Maiolino
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2025-04-30 8:34 UTC (permalink / raw)
To: Carlos Maiolino, linux-xfs, kernel-janitors
Cc: Chandan Babu R, Darrick J. Wong, LKML, Qasim Ijaz, Natalie Vock
…
>> +++ b/fs/xfs/scrub/repair.c
>> @@ -382,7 +382,7 @@ xrep_calc_ag_resblks(
>> refcbt_sz);
>> xfs_perag_put(pag);
>>
>> - return max(max(bnobt_sz, inobt_sz), max(rmapbt_sz, refcbt_sz));
>> + return max3(bnobt_sz, inobt_sz, max(rmapbt_sz, refcbt_sz));
>
> I have nothing against the patch itself, but honestly I don't see how it
> improves anything. It boils down to nesting comparison instructions too, and
> doesn't make the code more clear IMHO.
> So, unless somebody else has a stronger reason to have this change, NAK from my side.
Would you be looking for a wrapper call variant like max4()?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: Simplify maximum determination in xrep_calc_ag_resblks()
2025-04-30 8:34 ` Markus Elfring
@ 2025-04-30 9:34 ` Carlos Maiolino
0 siblings, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2025-04-30 9:34 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-xfs, kernel-janitors, Chandan Babu R, Darrick J. Wong,
LKML, Qasim Ijaz, Natalie Vock
On Wed, Apr 30, 2025 at 10:34:59AM +0200, Markus Elfring wrote:
> …
> >> +++ b/fs/xfs/scrub/repair.c
> >> @@ -382,7 +382,7 @@ xrep_calc_ag_resblks(
> >> refcbt_sz);
> >> xfs_perag_put(pag);
> >>
> >> - return max(max(bnobt_sz, inobt_sz), max(rmapbt_sz, refcbt_sz));
> >> + return max3(bnobt_sz, inobt_sz, max(rmapbt_sz, refcbt_sz));
> >
> > I have nothing against the patch itself, but honestly I don't see how it
> > improves anything. It boils down to nesting comparison instructions too, and
> > doesn't make the code more clear IMHO.
> > So, unless somebody else has a stronger reason to have this change, NAK from my side.
> Would you be looking for a wrapper call variant like max4()?
I have no preference really, between a max(max(), max()) and a max4(a, b, c, d),
the latter is a tad easier to the eyes, if it's worth adding a new max() macro
for that, it's another thing. Although a quick search on the source code
returned returned several usages of the max(max3(a,b,c), d) patterns, so I think
indeed the kernel could benefit of a max4() :)
>
> Regards,
> Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-30 9:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <oL08RYG1VC2E9huS2ixv9tI5xAJxx88B60-95yE-8PIDHIdkDkYdqKhA9T_qDEoFzv4qGpCn0M0WtI3JV3f5EA==@protonmail.internalid>
2025-03-01 10:30 ` [PATCH] xfs: Simplify maximum determination in xrep_calc_ag_resblks() Markus Elfring
2025-04-30 8:27 ` Carlos Maiolino
2025-04-30 8:34 ` Markus Elfring
2025-04-30 9:34 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®