From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, dborkman@redhat.com,
linux-kernel@vger.kernel.org, darkjames-ws@darkjames.pl
Subject: Re: [PATCH RFC] reciprocal_divide: correction/update of the algorithm
Date: Tue, 14 Jan 2014 23:39:35 +0100 [thread overview]
Message-ID: <20140114223935.GA16276@order.stressinduktion.org> (raw)
In-Reply-To: <1389722825.31367.260.camel@edumazet-glaptop2.roam.corp.google.com>
On Tue, Jan 14, 2014 at 10:07:05AM -0800, Eric Dumazet wrote:
> On Mon, 2014-01-13 at 22:42 +0100, Hannes Frederic Sowa wrote:
> > This patch is a RFC and part of a series Daniel Borkmann and me want to
> > do when introducing prandom_u32_range{,_ro} and prandom_u32_max{,_ro}
> > helpers later this week.
>
> > -static inline u32 reciprocal_divide(u32 A, u32 R)
> > +struct reciprocal_value reciprocal_value(u32 d);
> > +
> > +static inline u32 reciprocal_divide(u32 a, struct reciprocal_value R)
> > {
> > - return (u32)(((u64)A * R) >> 32);
> > + u32 t = (u32)(((u64)a * R.m) >> 32);
> > + return (t + ((a - t) >> R.sh1)) >> R.sh2;
> > }
>
> I would rather introduce new helpers and convert users that really need
> them.
>
> For instance, just use a divide in BPF, because doing this on JIT might
> be too complex for the gains. Strangely, libpcap doesn't seem to
> optimize any divide, like divides by a power of two...
>
> Reciprocal were added 7 years ago, for very specific uses, but current
> cpus have reasonably fast dividers.
Agreed. The new algorithm would need to change the size of struct
sock_filter, which is exported to user space. We will leave BPF as-is
for the time being and check that later.
Greetings,
Hannes
next prev parent reply other threads:[~2014-01-14 22:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-13 21:42 [PATCH RFC] reciprocal_divide: correction/update of the algorithm Hannes Frederic Sowa
2014-01-14 18:02 ` Randy Dunlap
2014-01-15 15:02 ` Hannes Frederic Sowa
2014-01-14 18:07 ` Eric Dumazet
2014-01-14 19:22 ` Austin S Hemmelgarn
2014-01-14 19:50 ` Eric Dumazet
2014-01-14 20:10 ` Hannes Frederic Sowa
2014-01-14 20:53 ` Austin S Hemmelgarn
2014-01-14 22:45 ` Eric Dumazet
2014-01-14 23:25 ` Borislav Petkov
2014-01-15 2:51 ` Austin S. Hemmelgarn
2014-01-14 22:39 ` Hannes Frederic Sowa [this message]
2014-01-15 7:02 ` [PATCH net] bpf: do not use reciprocal divide Eric Dumazet
2014-01-15 7:28 ` David Miller
2014-01-15 7:39 ` Eric Dumazet
2014-01-15 8:00 ` Heiko Carstens
2014-01-15 8:13 ` Martin Schwidefsky
2014-01-15 10:51 ` Heiko Carstens
2014-01-15 14:21 ` Eric Dumazet
2014-01-15 14:25 ` Eric Dumazet
2014-01-15 14:50 ` [PATCH v2 " Eric Dumazet
2014-01-15 15:10 ` Matt Evans
2014-01-15 16:09 ` Eric Dumazet
2014-01-16 1:02 ` David Miller
2014-01-17 8:59 ` Heiko Carstens
2014-01-18 2:56 ` David Miller
2014-01-18 10:12 ` Heiko Carstens
2014-01-15 15:35 ` [PATCH " Martin Schwidefsky
2014-01-15 15:26 ` Martin Schwidefsky
2014-01-15 16:07 ` Eric Dumazet
2014-01-15 14:16 ` Eric Dumazet
2014-01-15 15:10 ` Heiko Carstens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140114223935.GA16276@order.stressinduktion.org \
--to=hannes@stressinduktion.org \
--cc=darkjames-ws@darkjames.pl \
--cc=dborkman@redhat.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).