Message ID | 561bb4974499a328ac39aff31858465d9bd12b1c.1722752370.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | Accepted |
Commit | 871cdea0f82ebcfa1d86ef527b054a20a6dff8a2 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,v2] tcp: Use clamp() in htcp_alpha_update() | expand |
On Sun, Aug 4, 2024 at 8:20 AM Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > > Using clamp instead of min(max()) is easier to read and it matches even > better the comment just above it. > > It also reduces the size of the preprocessed files by ~ 2.5 ko. > (see [1] for a discussion about it) > > $ ls -l net/ipv4/tcp_htcp*.i > 5576024 27 juil. 10:19 net/ipv4/tcp_htcp.old.i > 5573550 27 juil. 10:21 net/ipv4/tcp_htcp.new.i > > [1]: https://lore.kernel.org/all/23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com/ > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Eric Dumazet <edumazet@google.com>
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Sun, 4 Aug 2024 08:20:17 +0200 you wrote: > Using clamp instead of min(max()) is easier to read and it matches even > better the comment just above it. > > It also reduces the size of the preprocessed files by ~ 2.5 ko. > (see [1] for a discussion about it) > > $ ls -l net/ipv4/tcp_htcp*.i > 5576024 27 juil. 10:19 net/ipv4/tcp_htcp.old.i > 5573550 27 juil. 10:21 net/ipv4/tcp_htcp.new.i > > [...] Here is the summary with links: - [net-next,v2] tcp: Use clamp() in htcp_alpha_update() https://git.kernel.org/netdev/net-next/c/871cdea0f82e You are awesome, thank you!
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c index 52b1f2665dfa..81b96331b2bb 100644 --- a/net/ipv4/tcp_htcp.c +++ b/net/ipv4/tcp_htcp.c @@ -185,7 +185,7 @@ static inline void htcp_alpha_update(struct htcp *ca) u32 scale = (HZ << 3) / (10 * minRTT); /* clamping ratio to interval [0.5,10]<<3 */ - scale = min(max(scale, 1U << 2), 10U << 3); + scale = clamp(scale, 1U << 2, 10U << 3); factor = (factor << 3) / scale; if (!factor) factor = 1;
Using clamp instead of min(max()) is easier to read and it matches even better the comment just above it. It also reduces the size of the preprocessed files by ~ 2.5 ko. (see [1] for a discussion about it) $ ls -l net/ipv4/tcp_htcp*.i 5576024 27 juil. 10:19 net/ipv4/tcp_htcp.old.i 5573550 27 juil. 10:21 net/ipv4/tcp_htcp.new.i [1]: https://lore.kernel.org/all/23bdb6fc8d884ceebeb6e8b8653b8cfe@AcuMS.aculab.com/ Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- Compile tested only. Changes in v2: - synch numbers with latest -next v1: https://lore.kernel.org/all/22c2e12d7a09202cc31a729fd29c0f2095ea34b7.1722083270.git.christophe.jaillet@wanadoo.fr/ --- net/ipv4/tcp_htcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)