![]() |
lvs-devel
|
| To: | Simon Horman <horms@xxxxxxxxxxxx>, Julian Anastasov <ja@xxxxxx> |
|---|---|
| Subject: | [PATCH] ipvs: use div_s64 for signed division |
| Cc: | Arnd Bergmann <arnd@xxxxxxxx>, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, Jozsef Kadlecsik <kadlec@xxxxxxxxxxxxx>, Florian Westphal <fw@xxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, Eric Dumazet <edumazet@xxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, Paolo Abeni <pabeni@xxxxxxxxxx>, Jiri Wiesner <jwiesner@xxxxxxx>, netdev@xxxxxxxxxxxxxxx, lvs-devel@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx, coreteam@xxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx |
| From: | Arnd Bergmann <arnd@xxxxxxxxxx> |
| Date: | Thu, 15 Dec 2022 18:03:15 +0100 |
From: Arnd Bergmann <arnd@xxxxxxxx>
do_div() is only well-behaved for positive numbers, and now warns
when the first argument is a an s64:
net/netfilter/ipvs/ip_vs_est.c: In function 'ip_vs_est_calc_limits':
include/asm-generic/div64.h:222:35: error: comparison of distinct pointer types
lacks a cast [-Werror]
222 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
| ^~
net/netfilter/ipvs/ip_vs_est.c:694:17: note: in expansion of macro 'do_div'
694 | do_div(val, loops);
Convert to using the more appropriate div_s64(), which also
simplifies the code a bit.
Fixes: 705dd3444081 ("ipvs: use kthreads for stats estimation")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
net/netfilter/ipvs/ip_vs_est.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c
index ce2a1549b304..dbc32f8cf1f9 100644
--- a/net/netfilter/ipvs/ip_vs_est.c
+++ b/net/netfilter/ipvs/ip_vs_est.c
@@ -691,15 +691,13 @@ static int ip_vs_est_calc_limits(struct netns_ipvs *ipvs,
int *chain_max)
}
if (diff >= NSEC_PER_SEC)
continue;
- val = diff;
- do_div(val, loops);
+ val = div_s64(diff, loops);
if (!min_est || val < min_est) {
min_est = val;
/* goal: 95usec per chain */
val = 95 * NSEC_PER_USEC;
if (val >= min_est) {
- do_div(val, min_est);
- max = (int)val;
+ max = div_s64(val, min_est);
} else {
max = 1;
}
--
2.35.1
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [linux-next:master] BUILD REGRESSION 39ab32797f072eaf86b1faa7384ac73450684110, kernel test robot |
|---|---|
| Next by Date: | Re: [PATCH] ipvs: use div_s64 for signed division, Julian Anastasov |
| Previous by Thread: | [linux-next:master] BUILD REGRESSION 39ab32797f072eaf86b1faa7384ac73450684110, kernel test robot |
| Next by Thread: | Re: [PATCH] ipvs: use div_s64 for signed division, Julian Anastasov |
| Indexes: | [Date] [Thread] [Top] [All Lists] |