diff mbox

[3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled

Message ID 2bd51cac-bbb7-da76-9648-4ae24ba342b2@users.sourceforge.net
State Rejected
Delegated to: David Miller
Headers show

Commit Message

SF Markus Elfring Sept. 3, 2016, 4:40 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 18:00:03 +0200

Move the assignment for the local variable "flen" a bit at the beginning
so that it will only be performed if BPF JIT is enabled for this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/sparc/net/bpf_jit_comp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel Borkmann Sept. 3, 2016, 4:58 p.m. UTC | #1
On 09/03/2016 06:40 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 18:00:03 +0200
>
> Move the assignment for the local variable "flen" a bit at the beginning
> so that it will only be performed if BPF JIT is enabled for this function.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Why is that a particular issue (did you measure some improvement when
you say "fine-tuning" as per subject) ?

That's all not in critical path here by the way, same for patch 2.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index a927470..a6b6e29 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -365,13 +365,14 @@  void bpf_jit_compile(struct bpf_prog *fp)
 	unsigned int cleanup_addr, proglen, oldproglen;
 	u32 temp[8], *prog, *func, seen, pass;
 	const struct sock_filter *filter;
-	int i, flen = fp->len, pc_ret0;
+	int i, flen, pc_ret0;
 	unsigned int *addrs;
 	void *image;
 
 	if (!bpf_jit_enable)
 		return;
 
+	flen = fp->len;
 	addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
 	if (addrs == NULL)
 		return;