Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2471218rwb; Fri, 16 Dec 2022 02:29:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf56zxE3gRnYR6zDtvyYNqeIAFwSzX5tTKz4fZAcBfgu3ETZZ9GnHc7lN6o7bOVAAAF38zDi X-Received: by 2002:a17:902:eb8d:b0:189:89b1:ac95 with SMTP id q13-20020a170902eb8d00b0018989b1ac95mr28519157plg.29.1671186554221; Fri, 16 Dec 2022 02:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671186554; cv=none; d=google.com; s=arc-20160816; b=QilNK993v37aTdxKnlMyJ8hN2aI4DWekASqS0b0M0SZZJ8ATKvsgTI46FdURhzKraw ttamKdkYvNmzE9WCS5tut3en/Ko9fb/HJiiHAkA6J1/oGZniCN1r5mlhkaKTOChTsPER MnNBcDw8tyuuXeZnv18idX6Yg2hvkYYsJsrwNK4oQCrhB390Iv4I3I0A177hs43tAuHu yfocacVmKpvFkpDm03FjbcDvmo67LMsJceyhUpIKgKIuluCN+AeQ1cmOVfI7NDxaO50r ImGqF2schXhM9PTjVhed5tuaAVRoqsQ2fKjJ+K1+lmzssa9HCSejrH5vGM8EvjXWU4zz pwwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gvnmvWHZFbhxHD7n6znAGgnAPV/7PXoYSVcYm9UE3K8=; b=lpdRYuspzrH8RJAROhcV8tbHijrfjipIXDF5yNHis8vW7mW0aAmYTGC7r6vub6ibVX GGv1tVQdr4IF6P7txvS82matXfDhUBpSSJaunEm8YpAy9rFE74JBZpZlctV6Sf/UWh2Q e+DcL8CyPkM7K/GbbVD142RMouHj552EpipBxkh7VNm5PKh2tnbi4yJpXQ6lvfrWKyau 0U1V0pvi8VdzU1p3N3/PQy3wF/2+K3pSGcLSLcoAbzmHR+pTTRRbNC30sudDxk1uRyy2 QgLzjBrxfYyahg2RZ39cBi8+ySxiRjOOl5a8XeJ9inCTGTtUemD735Tz/mhVm2Dfux/E KjbA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a637558000000b0046f51cbaf53si2229338pgn.529.2022.12.16.02.29.04; Fri, 16 Dec 2022 02:29:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbiLPKKv (ORCPT + 70 others); Fri, 16 Dec 2022 05:10:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbiLPKKr (ORCPT ); Fri, 16 Dec 2022 05:10:47 -0500 Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9086B6175; Fri, 16 Dec 2022 02:10:45 -0800 (PST) Date: Fri, 16 Dec 2022 11:10:41 +0100 From: Pablo Neira Ayuso To: Julian Anastasov Cc: Arnd Bergmann , Simon Horman , Arnd Bergmann , 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 Message-ID: References: <20221215170324.2579685-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 Hi Julian, On Thu, Dec 15, 2022 at 09:01:59PM +0200, Julian Anastasov wrote: > > 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. Arnd's patch applies fine on top of net-next, maybe he is addressing something else? > > 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 >