netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kunyu <kunyu@nfschina.com>
To: davem@davemloft.net, dsahern@kernel.org, udknight@gmail.com,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
	jolsa@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, kunyu <kunyu@nfschina.com>
Subject: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions
Date: Wed, 12 Jun 2024 16:58:23 +0800	[thread overview]
Message-ID: <20240612085823.28133-1-kunyu@nfschina.com> (raw)

In these functions, the 'cnt' variable is not used or does not require
value checking, so these 'cnt' variables can be removed.

Signed-off-by: kunyu <kunyu@nfschina.com>
---
 arch/x86/net/bpf_jit_comp32.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c
index de0f9e5f9f73..30f9b8a3faed 100644
--- a/arch/x86/net/bpf_jit_comp32.c
+++ b/arch/x86/net/bpf_jit_comp32.c
@@ -207,7 +207,6 @@ static inline void emit_ia32_mov_i(const u8 dst, const u32 val, bool dstk,
 				   u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 
 	if (dstk) {
 		if (val == 0) {
@@ -235,7 +234,6 @@ static inline void emit_ia32_mov_r(const u8 dst, const u8 src, bool dstk,
 				   bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 sreg = sstk ? IA32_EAX : src;
 
 	if (sstk)
@@ -286,7 +284,6 @@ static inline void emit_ia32_mul_r(const u8 dst, const u8 src, bool dstk,
 				   bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 sreg = sstk ? IA32_ECX : src;
 
 	if (sstk)
@@ -319,7 +316,6 @@ static inline void emit_ia32_to_le_r64(const u8 dst[], s32 val,
 					 const struct bpf_prog_aux *aux)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -367,7 +363,6 @@ static inline void emit_ia32_to_be_r64(const u8 dst[], s32 val,
 				       const struct bpf_prog_aux *aux)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -436,7 +431,6 @@ static inline void emit_ia32_div_mod_r(const u8 op, const u8 dst, const u8 src,
 				       bool dstk, bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 
 	if (sstk)
 		/* mov ecx,dword ptr [ebp+off] */
@@ -483,7 +477,6 @@ static inline void emit_ia32_shift_r(const u8 op, const u8 dst, const u8 src,
 				     bool dstk, bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg = dstk ? IA32_EAX : dst;
 	u8 b2;
 
@@ -525,7 +518,6 @@ static inline void emit_ia32_alu_r(const bool is64, const bool hi, const u8 op,
 				   bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 sreg = sstk ? IA32_EAX : src;
 	u8 dreg = dstk ? IA32_EDX : dst;
 
@@ -599,7 +591,6 @@ static inline void emit_ia32_alu_i(const bool is64, const bool hi, const u8 op,
 				   u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg = dstk ? IA32_EAX : dst;
 	u8 sreg = IA32_EDX;
 
@@ -698,7 +689,6 @@ static inline void emit_ia32_alu_i64(const bool is64, const u8 op,
 static inline void emit_ia32_neg64(const u8 dst[], bool dstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -732,7 +722,6 @@ static inline void emit_ia32_lsh_r64(const u8 dst[], const u8 src[],
 				     bool dstk, bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -785,7 +774,6 @@ static inline void emit_ia32_arsh_r64(const u8 dst[], const u8 src[],
 				      bool dstk, bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -838,7 +826,6 @@ static inline void emit_ia32_rsh_r64(const u8 dst[], const u8 src[], bool dstk,
 				     bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -891,7 +878,6 @@ static inline void emit_ia32_lsh_i64(const u8 dst[], const u32 val,
 				     bool dstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -939,7 +925,6 @@ static inline void emit_ia32_rsh_i64(const u8 dst[], const u32 val,
 				     bool dstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -988,7 +973,6 @@ static inline void emit_ia32_arsh_i64(const u8 dst[], const u32 val,
 				      bool dstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
 	u8 dreg_hi = dstk ? IA32_EDX : dst_hi;
 
@@ -1036,7 +1020,6 @@ static inline void emit_ia32_mul_r64(const u8 dst[], const u8 src[], bool dstk,
 				     bool sstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 
 	if (dstk)
 		/* mov eax,dword ptr [ebp+off] */
@@ -1113,7 +1096,6 @@ static inline void emit_ia32_mul_i64(const u8 dst[], const u32 val,
 				     bool dstk, u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	u32 hi;
 
 	hi = val & (1<<31) ? (u32)~0 : 0;
@@ -1200,7 +1182,6 @@ struct jit_context {
 static void emit_prologue(u8 **pprog, u32 stack_depth)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 	const u8 *r1 = bpf2ia32[BPF_REG_1];
 	const u8 fplo = bpf2ia32[BPF_REG_FP][0];
 	const u8 fphi = bpf2ia32[BPF_REG_FP][1];
@@ -1237,7 +1218,6 @@ static void emit_prologue(u8 **pprog, u32 stack_depth)
 	EMIT3(0x89, add_2reg(0x40, IA32_EBP, IA32_EBX), STACK_VAR(tcc[0]));
 	EMIT3(0x89, add_2reg(0x40, IA32_EBP, IA32_EBX), STACK_VAR(tcc[1]));
 
-	BUILD_BUG_ON(cnt != PROLOGUE_SIZE);
 	*pprog = prog;
 }
 
@@ -1246,7 +1226,6 @@ static void emit_epilogue(u8 **pprog, u32 stack_depth)
 {
 	u8 *prog = *pprog;
 	const u8 *r0 = bpf2ia32[BPF_REG_0];
-	int cnt = 0;
 
 	/* mov eax,dword ptr [ebp+off]*/
 	EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(r0[0]));
@@ -1391,7 +1370,6 @@ static void emit_bpf_tail_call(u8 **pprog, u8 *ip)
 static inline void emit_push_r64(const u8 src[], u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 
 	/* mov ecx,dword ptr [ebp+off] */
 	EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src_hi));
@@ -1409,7 +1387,6 @@ static inline void emit_push_r64(const u8 src[], u8 **pprog)
 static void emit_push_r32(const u8 src[], u8 **pprog)
 {
 	u8 *prog = *pprog;
-	int cnt = 0;
 
 	/* mov ecx,dword ptr [ebp+off] */
 	EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src_lo));
@@ -1570,7 +1547,7 @@ static int emit_kfunc_call(const struct bpf_prog *bpf_prog, u8 *end_addr,
 			   const struct bpf_insn *insn, u8 **pprog)
 {
 	const u8 arg_regs[] = { IA32_EAX, IA32_EDX, IA32_ECX };
-	int i, cnt = 0, first_stack_regno, last_stack_regno;
+	int i, first_stack_regno, last_stack_regno;
 	int free_arg_regs = ARRAY_SIZE(arg_regs);
 	const struct btf_func_model *fm;
 	int bytes_in_stack = 0;
@@ -1663,7 +1640,7 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
 	int insn_cnt = bpf_prog->len;
 	bool seen_exit = false;
 	u8 temp[BPF_MAX_INSN_SIZE + BPF_INSN_SAFETY];
-	int i, cnt = 0;
+	int i;
 	int proglen = 0;
 	u8 *prog = temp;
 
-- 
2.18.2


             reply	other threads:[~2024-06-12  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  8:58 kunyu [this message]
2024-06-12 18:07 ` [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions Alexei Starovoitov
2024-06-13  0:38 ` kernel test robot
2024-06-13  2:16 ` kernel test robot

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=20240612085823.28133-1-kunyu@nfschina.com \
    --to=kunyu@nfschina.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=hpa@zytor.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=udknight@gmail.com \
    --cc=x86@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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).