Netdev List
 help / color / mirror / Atom feed
From: Jiong Wang <jiong.wang@netronome.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: alexei.starovoitov@gmail.com, daniel@iogearbox.net,
	oss-drivers@netronome.com, netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next 7/7] nfp: bpf: migrate to advanced reciprocal divide in reciprocal_div.h
Date: Thu, 5 Jul 2018 19:28:24 +0100	[thread overview]
Message-ID: <80ac616c-0ccd-5db4-31d7-6436a794772e@netronome.com> (raw)
In-Reply-To: <20180626135924.0050ab10@cakuba.netronome.com>

On 26/06/2018 21:59, Jakub Kicinski wrote:
> On Sun, 24 Jun 2018 20:54:21 -0700, Jakub Kicinski wrote:
>> +	 * NOTE: because we are using "reciprocal_value_adv" which doesn't
>> +	 * support dividend with MSB set, so we need to JIT separate NFP
>> +	 * sequence to handle such case. It could be a simple sequence if there
>> +	 * is conditional move, however there isn't for NFP. So, we don't bother
>> +	 * generating compare-if-set-branch sequence by rejecting the program
>> +	 * straight away when the u32 dividend has MSB set. Divide by such a
>> +	 * large constant would be rare in practice. Also, the programmer could
>> +	 * simply rewrite it as "result = divisor >= the_const".
> Thinking about this again, can we just use carry bit?

Good catch, yes we can.

> The code may end
> up shorter than the explanation why we don't support that case :P
>
> immed[c, 0]
> alu[--, a, -, b]
> alu[c, c, +carry, 0]

eBPF input will be "a = a / b", given "immed" doesn't affect carry bit,
I'd reorder the sequence so we only need one tmp register for holding
"b" who is constant.

   alu[--, a, -, b]
   immed[b, 0]
   alu[a, b, +carry, 0]
  
Thanks.
Regards,
Jiong

>
> Should be equivalent to:
>
> c = a >= b
>
> (Thanks to Edwin for double-checking the carry semantics.)

      reply	other threads:[~2018-07-05 18:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25  3:54 [PATCH bpf-next 0/7] nfp: bpf: add multiplication, divide and memcpy from maps Jakub Kicinski
2018-06-25  3:54 ` [PATCH bpf-next 1/7] nfp: bpf: allow source ptr type be map ptr in memcpy optimization Jakub Kicinski
2018-06-26  5:50   ` Song Liu
2018-06-26  7:08     ` Jakub Kicinski
2018-06-26 16:26       ` Song Liu
2018-06-25  3:54 ` [PATCH bpf-next 2/7] lib: reciprocal_div: implement the improved algorithm on the paper mentioned Jakub Kicinski
2018-06-26  6:21   ` Song Liu
2018-06-26 20:52     ` Jakub Kicinski
2018-06-27  8:54       ` Daniel Borkmann
2018-06-25  3:54 ` [PATCH bpf-next 3/7] nfp: bpf: rename umin/umax to umin_src/umax_src Jakub Kicinski
2018-06-26  6:21   ` Song Liu
2018-06-25  3:54 ` [PATCH bpf-next 4/7] nfp: bpf: copy range info for all operands of all ALU operations Jakub Kicinski
2018-06-26  6:50   ` Song Liu
2018-06-25  3:54 ` [PATCH bpf-next 5/7] nfp: bpf: support u16 and u32 multiplications Jakub Kicinski
2018-06-26 22:23   ` Song Liu
2018-06-25  3:54 ` [PATCH bpf-next 6/7] nfp: bpf: support u32 divide using reciprocal_div.h Jakub Kicinski
2018-06-26 22:28   ` Song Liu
2018-06-25  3:54 ` [PATCH bpf-next 7/7] nfp: bpf: migrate to advanced reciprocal divide in reciprocal_div.h Jakub Kicinski
2018-06-26 20:59   ` Jakub Kicinski
2018-07-05 18:28     ` Jiong Wang [this message]

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=80ac616c-0ccd-5db4-31d7-6436a794772e@netronome.com \
    --to=jiong.wang@netronome.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    /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