From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42F3FC43381 for ; Thu, 28 Feb 2019 10:16:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3C3B21850 for ; Thu, 28 Feb 2019 10:16:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W3zr3Rf7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732317AbfB1KQd (ORCPT ); Thu, 28 Feb 2019 05:16:33 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36230 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732211AbfB1KQd (ORCPT ); Thu, 28 Feb 2019 05:16:33 -0500 Received: by mail-pf1-f195.google.com with SMTP id n22so9517969pfa.3 for ; Thu, 28 Feb 2019 02:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NqxzpvIPP7ChbcrYsqJy6OhDC+x7TdMAVp90AkKux38=; b=W3zr3Rf7r/28vGlZ97ozcGDlzApb58T42nfFE39VEwt26jJzsWAL61MvlM88rvSrag PKNeTFzRH7NieyU/uBAvSLw4ffghwwSOoTlhKpnqxBc03FqZOmiRMZuiS58qS9uAhfVc o5AZxXPx1Xb2X/+qxMU4RoPncSkteS37Vnk0H3T6KOxHe3/6rImPrR0IlGU0x4SPZkNi raIjkoXrIH/+AlMh9g5riHXwNtePdvnwW9LQDlEuO8QdiorLK+p57EJH8lSc6cBvtPX1 UeJbCvgIKwpvSNgD1ORbPuslXWDZuKbL0/txSvv2nmTZlX2YiJ6OEPgZl4bpH37418MT YnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NqxzpvIPP7ChbcrYsqJy6OhDC+x7TdMAVp90AkKux38=; b=OvZvsiR1s6hwrfS+UuhIJLsN6jNJhwM80U3Mkp6R9zB2p7UgzGAoFj0puI0S5bXUVk R3wLp5n0Cwpvq1q2AGS+096PP/tL3IOJ0zwBKtAS/iL6tRc0LsjgZ39m9ToYAax4tgw3 Gc/9tLttXOxjh9tq7ZU7fsWMm5gxptCGVbC8iIQ21U7nv9aku/K591r+hY3VO7KW9zku UX0uz4EFgk5eEUrHk9iqRmMOouCOEYEHhCsGkaMFdkmhmJY1nMJ+4TNk+QE6vab+4Aoe kQx3HGjU9df1UhKIbIaMPe1CrJ8SVQfwL688y0wEQgv0Ra6zHx+8XVrFMK/QdD92DDZs 6rlQ== X-Gm-Message-State: AHQUAuZfy1ujwQdGIgU6/eDb0x5pC8iihw2feyz3RYt3I5CeOHy1QWwh hbn464xN5WfCShhjV8d7SL4= X-Google-Smtp-Source: AHgI3Iap4UsVYo8fT+exAr8Uaf7WA1Mxra2E8swtkyD6kBKFmMLZJ+6JN6fDfoS0CLVspYk6qh304w== X-Received: by 2002:a63:5a42:: with SMTP id k2mr7643086pgm.333.1551348992547; Thu, 28 Feb 2019 02:16:32 -0800 (PST) Received: from Inspiron-3521 ([223.186.159.144]) by smtp.gmail.com with ESMTPSA id o6sm49085888pgo.27.2019.02.28.02.16.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 02:16:32 -0800 (PST) Date: Thu, 28 Feb 2019 15:46:25 +0530 From: Leslie Monis To: David Laight Cc: "netdev@vger.kernel.org" Subject: Re: [PATCH net-next] net: sched: pie: fix 64-bit division Message-ID: <20190228101534.GA8035@Inspiron-3521> References: <20190227010006.22219-1-lesliemonis@gmail.com> <44c1c447befd45e49a06b1e3d3f5f7a6@AcuMS.aculab.com> <20190227161228.GA2014@Inspiron-3521> <387a2fe8539c4de7bf3f97aadbd9b924@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <387a2fe8539c4de7bf3f97aadbd9b924@AcuMS.aculab.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Feb 28, 2019 at 10:10:33AM +0000, David Laight wrote: > From: Leslie Monis > > Sent: 27 February 2019 16:12 > > > > On Wed, Feb 27, 2019 at 10:11:14AM +0000, David Laight wrote: > > > From: Leslie Monis > > > > Sent: 27 February 2019 01:00 > > > > Use div_u64() to resolve build failures on 32-bit platforms. > > > > > > > > Fixes: 3f7ae5f3dc52 ("net: sched: pie: add more cases to auto-tune alpha and beta") > > > > Signed-off-by: Leslie Monis > > > > --- > > > > net/sched/sch_pie.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c > > > > index 4c0670b6aec1..f93cfe034c72 100644 > > > > --- a/net/sched/sch_pie.c > > > > +++ b/net/sched/sch_pie.c > > > > @@ -429,7 +429,7 @@ static void calculate_probability(struct Qdisc *sch) > > > > */ > > > > > > > > if (qdelay == 0 && qdelay_old == 0 && update_prob) > > > > - q->vars.prob = (q->vars.prob * 98) / 100; > > > > + q->vars.prob = 98 * div_u64(q->vars.prob, 100); > > > > > > This has significantly different rounding after the change. > > > The result for small values is very different. > > > The alterative: > > > q->vars.prob -= div_u64(q->vars.prob, 50); > > > is much nearer to the original - but never goes to zero. > > > > > > If the 98% decay factor isn't critical then you could remove > > > 1/64th or 1/32nd + 1/16th to avoid the slow division. > > > > > > David > > > > Hi David, > > > > You're right, the change does make the result for small > > values different. I made it anyway as the probability > > value is scaled by u64. It is safe to say that q->vars.prob > > holds relatively large values (in its scaled form) in all > > cases where it isn't 0. > > > > But, I think we can avoid the slow division here. RFC 8033 > > does say that using (1 - 1/64) should be sufficient. This > > will give us: > > q-vars.prob -= q->vars.prob >> 6; > > which I feel would be much better. What do you reckon? > > I think I'd leave it as a division - the compiler should do the shift. > So: > /* Scale by 98.4% */ > q-vars.prob -= q->vars.prob / 64u; > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > Alright, I'll prepare a patch for this. May I credit you with a Suggested-by tag? Thanks, Leslie