Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1571667rwb; Thu, 15 Dec 2022 11:46:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6n7fHdCzPNBYhwfuUkP9caZwBMtgjF8BDwxdeEodNRnONe/pVnh0xk3rvfalJ0U3SuBSd4 X-Received: by 2002:a05:6a21:3a93:b0:ad:94c0:da62 with SMTP id zv19-20020a056a213a9300b000ad94c0da62mr20500091pzb.28.1671133561457; Thu, 15 Dec 2022 11:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671133561; cv=none; d=google.com; s=arc-20160816; b=ndZn0hLW3tHnrS7ZTpMcZuX9j2wo2HSFBv668Q3kVNWqia1UkyxuyFZtwE47ivQ5Y2 SBMy4F6v12TNu3ufqeUd+Avz+4m/TAWR10wK0x7jiot3Zfp42C7MNIWZkUjDtJhonPas yl66apTfxRzTNw4JFHcF3mal5Tmf1mJKKY2FNZn0d4/XF1LbPDxnNb9b2Uh4G6xBT9Y2 JqYk8xWQ1Pa3n366Iw6si1VpMYRwPviO48URN3VhEKJmnhWpAPo6CZpOkdgjF6DexQmk TGMuLAvRZJhkzVIIWGE9jDhxW5D5vxMrYN6uYSj6B5aTuksHu9TwystTjqkOc/xiJUzk /ivA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date; bh=GdzkKHaOXISowCmfXrXvBeRo+Qhilj38/eZFi7R2Xc4=; b=HoYglNhFtdoYYcc83BMvdz5D1xgS7ZS3R7/eThA7Ys7tYySnJsmPTqSgsvUzUFJC0T ZpK4YZtU9wCVmi11x0Qov+s0zBp5VtqiUKwroVF3hDUjRMDNO9USvlDtqihzZQMuRg6w 15EiMLfxLs9jSs4WHOebpMMEVIF/+Ga9dINXrTNObQNrhsrzezCC5psuVFSdFSKvW7Uq iSWt6KMx4AGQh5LACGqzenjb2A6Zu5YEGsHf/l6TIHwavgQxHWlBdDwUnCAUQlrFLp8S Gs957tmi/gUs2I+ItWv8CTG+Jl1Cu0q7JEsILnby48QPxU5K2nCzCWptRpB9+UYsvMG+ uDwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ssi.bg Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n186-20020a6327c3000000b00479079b77a6si323578pgn.105.2022.12.15.11.45.52; Thu, 15 Dec 2022 11:46:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ssi.bg Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbiLOTCR (ORCPT + 68 others); Thu, 15 Dec 2022 14:02:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbiLOTCL (ORCPT ); Thu, 15 Dec 2022 14:02:11 -0500 Received: from mg.ssi.bg (mg.ssi.bg [193.238.174.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2333C164B2; Thu, 15 Dec 2022 11:02:09 -0800 (PST) Received: from mg.ssi.bg (localhost [127.0.0.1]) by mg.ssi.bg (Proxmox) with ESMTP id 149C521903; Thu, 15 Dec 2022 21:02:07 +0200 (EET) Received: from ink.ssi.bg (unknown [193.238.174.40]) by mg.ssi.bg (Proxmox) with ESMTP id B2E30217C8; Thu, 15 Dec 2022 21:02:05 +0200 (EET) Received: from ja.ssi.bg (unknown [178.16.129.10]) by ink.ssi.bg (Postfix) with ESMTPS id 795763C043D; Thu, 15 Dec 2022 21:02:02 +0200 (EET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by ja.ssi.bg (8.17.1/8.16.1) with ESMTP id 2BFJ1xvf099033; Thu, 15 Dec 2022 21:01:59 +0200 Date: Thu, 15 Dec 2022 21:01:59 +0200 (EET) From: Julian Anastasov To: Arnd Bergmann cc: Simon Horman , Arnd Bergmann , Pablo Neira Ayuso , Jakub Kicinski , Paolo Abeni , Jiri Wiesner , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel Subject: Re: [PATCH] ipvs: use div_s64 for signed division In-Reply-To: <20221215170324.2579685-1-arnd@kernel.org> Message-ID: References: <20221215170324.2579685-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, 15 Dec 2022, Arnd Bergmann wrote: > From: Arnd Bergmann > > 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); net-next already contains fix for this warning and changes val to u64. > 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 > --- > 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); On CONFIG_X86_32 both versions execute single divl for our case but div_s64 is not inlined. I'm not expert in this area but if you think div_u64 is more appropriate then post another patch. Note that now val is u64 and min_est is still s32 (can be u32). > 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 Regards -- Julian Anastasov