linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X
@ 2014-11-17 20:07 Denis Kirjanov
  2014-11-18  1:50 ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Kirjanov @ 2014-11-17 20:07 UTC (permalink / raw)
  To: netdev
  Cc: Philippe Bergheaud, linuxppc-dev, Denis Kirjanov, Daniel Borkmann,
	Alexei Starovoitov

Reduce duplicated code by unifying
BPF_ALU | BPF_MOD | BPF_X and BPF_ALU | BPF_DIV | BPF_X

CC: Alexei Starovoitov<alexei.starovoitov@gmail.com>
CC: Daniel Borkmann<dborkman@redhat.com>
CC: Philippe Bergheaud<felix@linux.vnet.ibm.com>
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 arch/powerpc/net/bpf_jit_comp.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index d3fa80d..1ca125b 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -181,6 +181,7 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
 			}
 			break;
 		case BPF_ALU | BPF_MOD | BPF_X: /* A %= X; */
+		case BPF_ALU | BPF_DIV | BPF_X: /* A /= X; */
 			ctx->seen |= SEEN_XREG;
 			PPC_CMPWI(r_X, 0);
 			if (ctx->pc_ret0 != -1) {
@@ -190,9 +191,13 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
 				PPC_LI(r_ret, 0);
 				PPC_JMP(exit_addr);
 			}
-			PPC_DIVWU(r_scratch1, r_A, r_X);
-			PPC_MUL(r_scratch1, r_X, r_scratch1);
-			PPC_SUB(r_A, r_A, r_scratch1);
+			if (code == (BPF_ALU | BPF_MOD | BPF_X)) {
+				PPC_DIVWU(r_scratch1, r_A, r_X);
+				PPC_MUL(r_scratch1, r_X, r_scratch1);
+				PPC_SUB(r_A, r_A, r_scratch1);
+			} else {
+				PPC_DIVWU(r_A, r_A, r_X);
+			}
 			break;
 		case BPF_ALU | BPF_MOD | BPF_K: /* A %= K; */
 			PPC_LI32(r_scratch2, K);
@@ -200,22 +205,6 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
 			PPC_MUL(r_scratch1, r_scratch2, r_scratch1);
 			PPC_SUB(r_A, r_A, r_scratch1);
 			break;
-		case BPF_ALU | BPF_DIV | BPF_X: /* A /= X; */
-			ctx->seen |= SEEN_XREG;
-			PPC_CMPWI(r_X, 0);
-			if (ctx->pc_ret0 != -1) {
-				PPC_BCC(COND_EQ, addrs[ctx->pc_ret0]);
-			} else {
-				/*
-				 * Exit, returning 0; first pass hits here
-				 * (longer worst-case code size).
-				 */
-				PPC_BCC_SHORT(COND_NE, (ctx->idx*4)+12);
-				PPC_LI(r_ret, 0);
-				PPC_JMP(exit_addr);
-			}
-			PPC_DIVWU(r_A, r_A, r_X);
-			break;
 		case BPF_ALU | BPF_DIV | BPF_K: /* A /= K */
 			if (K == 1)
 				break;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X
  2014-11-17 20:07 [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X Denis Kirjanov
@ 2014-11-18  1:50 ` Michael Ellerman
  2014-11-18  6:58   ` Denis Kirjanov
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2014-11-18  1:50 UTC (permalink / raw)
  To: Denis Kirjanov
  Cc: Philippe Bergheaud, netdev, Daniel Borkmann, Alexei Starovoitov,
	linuxppc-dev

On Mon, 2014-11-17 at 23:07 +0300, Denis Kirjanov wrote:
> Reduce duplicated code by unifying
> BPF_ALU | BPF_MOD | BPF_X and BPF_ALU | BPF_DIV | BPF_X
> 
> CC: Alexei Starovoitov<alexei.starovoitov@gmail.com>
> CC: Daniel Borkmann<dborkman@redhat.com>
> CC: Philippe Bergheaud<felix@linux.vnet.ibm.com>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>

Please include the output of the test suite.

Assuming that's OK I'm happy for it to go in.

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X
  2014-11-18  1:50 ` Michael Ellerman
@ 2014-11-18  6:58   ` Denis Kirjanov
  2014-11-18 15:37     ` Alexei Starovoitov
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Kirjanov @ 2014-11-18  6:58 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Philippe Bergheaud, netdev, Daniel Borkmann, Alexei Starovoitov,
	linuxppc-dev

Hi Michael,

This patch added no new functionality so I haven't put the test
results (of course I ran the test suite to check the patch).

The output :
[  650.198958] test_bpf: Summary: 60 PASSED, 0 FAILED

On 11/18/14, Michael Ellerman <mpe@ellerman.id.au> wrote:
> On Mon, 2014-11-17 at 23:07 +0300, Denis Kirjanov wrote:
>> Reduce duplicated code by unifying
>> BPF_ALU | BPF_MOD | BPF_X and BPF_ALU | BPF_DIV | BPF_X
>>
>> CC: Alexei Starovoitov<alexei.starovoitov@gmail.com>
>> CC: Daniel Borkmann<dborkman@redhat.com>
>> CC: Philippe Bergheaud<felix@linux.vnet.ibm.com>
>> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>
> Please include the output of the test suite.
>
> Assuming that's OK I'm happy for it to go in.
>
> cheers
>
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X
  2014-11-18  6:58   ` Denis Kirjanov
@ 2014-11-18 15:37     ` Alexei Starovoitov
  2014-11-18 18:20       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Alexei Starovoitov @ 2014-11-18 15:37 UTC (permalink / raw)
  To: Denis Kirjanov
  Cc: Philippe Bergheaud, Daniel Borkmann, linuxppc-dev,
	netdev@vger.kernel.org

On Mon, Nov 17, 2014 at 10:58 PM, Denis Kirjanov <kda@linux-powerpc.org> wrote:
> Hi Michael,
>
> This patch added no new functionality so I haven't put the test
> results (of course I ran the test suite to check the patch).
>
> The output :
> [  650.198958] test_bpf: Summary: 60 PASSED, 0 FAILED

Acked-by: Alexei Starovoitov <ast@plumgrid.com>

btw, please don't top post.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X
  2014-11-18 15:37     ` Alexei Starovoitov
@ 2014-11-18 18:20       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2014-11-18 18:20 UTC (permalink / raw)
  To: alexei.starovoitov; +Cc: kda, linuxppc-dev, dborkman, netdev, felix

From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Date: Tue, 18 Nov 2014 07:37:21 -0800

> On Mon, Nov 17, 2014 at 10:58 PM, Denis Kirjanov <kda@linux-powerpc.org> wrote:
>> Hi Michael,
>>
>> This patch added no new functionality so I haven't put the test
>> results (of course I ran the test suite to check the patch).
>>
>> The output :
>> [  650.198958] test_bpf: Summary: 60 PASSED, 0 FAILED
> 
> Acked-by: Alexei Starovoitov <ast@plumgrid.com>

Applied, thanks everyone.

> btw, please don't top post.

Seriously, it's my biggest pet peeve.  It's like going to a dinner party
and eating with your feet.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-18 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-17 20:07 [PATCH net-next] PPC: bpf_jit_comp: Unify BPF_MOD | BPF_X and BPF_DIV | BPF_X Denis Kirjanov
2014-11-18  1:50 ` Michael Ellerman
2014-11-18  6:58   ` Denis Kirjanov
2014-11-18 15:37     ` Alexei Starovoitov
2014-11-18 18:20       ` David Miller

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).