netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>,
	netdev@vger.kernel.org, dborkman@redhat.com,
	darkjames-ws@darkjames.pl, Mircea Gherzan <mgherzan@gmail.com>,
	Russell King <rmk+kernel@arm.linux.org.uk>,
	Matt Evans <matt@ozlabs.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [PATCH net] bpf: do not use reciprocal divide
Date: Wed, 15 Jan 2014 09:00:07 +0100	[thread overview]
Message-ID: <20140115080007.GA6638@osiris> (raw)
In-Reply-To: <1389769361.31367.325.camel@edumazet-glaptop2.roam.corp.google.com>

On Tue, Jan 14, 2014 at 11:02:41PM -0800, Eric Dumazet wrote:
> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> index 16871da37371..e349dc7d0992 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
> @@ -371,11 +371,11 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
>  		/* dr %r4,%r12 */
>  		EMIT2(0x1d4c);
>  		break;
> -	case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K) */
> -		/* m %r4,<d(K)>(%r13) */
> -		EMIT4_DISP(0x5c40d000, EMIT_CONST(K));
> -		/* lr %r5,%r4 */
> -		EMIT2(0x1854);
> +	case BPF_S_ALU_DIV_K: /* A /= K */
> +		/* lhi %r4,0 */
> +		EMIT4(0xa7480000);
> +		/* d %r4,<d(K)>(%r13) */
> +		EMIT4_DISP(0x5d40d000, EMIT_CONST(K));
>  		break;

The s390 part looks good.

> diff --git a/net/core/filter.c b/net/core/filter.c
> index 01b780856db2..ad30d626a5bd 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -166,7 +165,7 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
>  			A /= X;
>  			continue;
>  		case BPF_S_ALU_DIV_K:
> -			A = reciprocal_divide(A, K);
> +			A /= K;
>  			continue;
>  		case BPF_S_ALU_MOD_X:
>  			if (X == 0)
> @@ -553,11 +552,6 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
>  		/* Some instructions need special checks */
>  		switch (code) {
>  		case BPF_S_ALU_DIV_K:
> -			/* check for division by zero */
> -			if (ftest->k == 0)
> -				return -EINVAL;
> -			ftest->k = reciprocal_value(ftest->k);
> -			break;

Are you sure you want to remove the k == 0 check? Is there something
else that would prevent a division by zero?

  parent reply	other threads:[~2014-01-15  8:00 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
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 [this message]
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=20140115080007.GA6638@osiris \
    --to=heiko.carstens@de.ibm.com \
    --cc=darkjames-ws@darkjames.pl \
    --cc=dborkman@redhat.com \
    --cc=eric.dumazet@gmail.com \
    --cc=hannes@stressinduktion.org \
    --cc=matt@ozlabs.org \
    --cc=mgherzan@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=schwidefsky@de.ibm.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;
as well as URLs for NNTP newsgroup(s).