From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BE0E390CAA; Mon, 13 Apr 2026 19:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776107488; cv=none; b=A5qw0FIL7DkVKj47DG9584wnru08mgh9JnCL1o4f8rHWjhknfdbCgRXp+Dw4Uh3Yx93VtsIfHbNqLQVVnttykBrObTjWlxXW9aegBNAzDMFvsTN1IxM5DLQo6meGShD1gMwrdKa9d9xgjDaggGDTNB8+6Pk9KBiTYEzqTSJpb68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776107488; c=relaxed/simple; bh=dVEd6XRC3YyZMNAa6XUNAlW4qEvGGYQcJPArlXG/IdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aEcnOXhqRhrwAYLZJu5YtYYGjCOGcag3eoo1ECmGEG8+8/XNbFzTnqjPyFdxKd03p9I+Xc0fLOdWJ8372OMB+by+u1MLUxk1S26ZIHW1pRFc4ahDKP2PhnOAIxybHof8qdXy/D/Cw5MAuN0uU/1ZjKmLv7Ff7cjqZ3r3bg/Hb7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=in2P7yIM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="in2P7yIM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6807C2BCB6; Mon, 13 Apr 2026 19:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776107488; bh=dVEd6XRC3YyZMNAa6XUNAlW4qEvGGYQcJPArlXG/IdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=in2P7yIM8V0H3sRjPbgW40CcnKPXe4oIBR/kTuZ5oL/ffScEB7YV6T7wTozq59kf9 Sk/FqfHP0wDOTHE1WVPcaUy4dAQo956s7NHMa3F//E2LDWrAzMPwMXWnekcIcQ1uVg 5pCsfgzNrgpctKjWIDIZ//0fIf8AYaQbKVmsu1OR39sMmHxh1uqDu8g/J0Xsdp1+DW Ks8Iiqvzi62vHC4hrAJ1VPD4HBKxe0k3TUo9+BFM5Xaa5v++zn6b3U4NFfCUvSF4sQ PY2GttWjb2uCFMeCm+4D+P7tjJz3eBQncGRq82ulJ01S+si+W8+biTlX4OgdsVlwEd W6UABdFzEB8eQ== From: Puranjay Mohan To: bpf@vger.kernel.org Cc: Puranjay Mohan , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Xu Kuohai" , "Catalin Marinas" , "Will Deacon" , "Luke Nelson" , "Xi Wang" , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , "Pu Lehui" , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , "Alexandre Ghiti" , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 2/2] bpf, riscv: Remove redundant bpf_flush_icache() after pack allocator finalize Date: Mon, 13 Apr 2026 12:11:09 -0700 Message-ID: <20260413191111.3426023-3-puranjay@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260413191111.3426023-1-puranjay@kernel.org> References: <20260413191111.3426023-1-puranjay@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit bpf_flush_icache() calls flush_icache_range() to clean the data cache and invalidate the instruction cache for the JITed code region. However, since commit 48a8f78c50bd ("bpf, riscv: use prog pack allocator in the BPF JIT"), this flush is redundant. bpf_jit_binary_pack_finalize() copies the JITed instructions to the ROX region via bpf_arch_text_copy() -> patch_text_nosync(), and patch_text_nosync() already calls flush_icache_range() on the written range. The subsequent bpf_flush_icache() repeats the same cache maintenance on an overlapping range. Remove the redundant bpf_flush_icache() call and its now-unused definition. Fixes: 48a8f78c50bd ("bpf, riscv: use prog pack allocator in the BPF JIT") Acked-by: Song Liu Signed-off-by: Puranjay Mohan --- arch/riscv/net/bpf_jit.h | 6 ------ arch/riscv/net/bpf_jit_core.c | 7 ------- 2 files changed, 13 deletions(-) diff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h index 632ced07bca4..da0271790244 100644 --- a/arch/riscv/net/bpf_jit.h +++ b/arch/riscv/net/bpf_jit.h @@ -11,7 +11,6 @@ #include #include -#include /* verify runtime detection extension status */ #define rv_ext_enabled(ext) \ @@ -105,11 +104,6 @@ static inline void bpf_fill_ill_insns(void *area, unsigned int size) memset(area, 0, size); } -static inline void bpf_flush_icache(void *start, void *end) -{ - flush_icache_range((unsigned long)start, (unsigned long)end); -} - /* Emit a 4-byte riscv instruction. */ static inline void emit(const u32 insn, struct rv_jit_context *ctx) { diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c index b3581e926436..f7fd4afc3ca3 100644 --- a/arch/riscv/net/bpf_jit_core.c +++ b/arch/riscv/net/bpf_jit_core.c @@ -183,13 +183,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog = orig_prog; goto out_offset; } - /* - * The instructions have now been copied to the ROX region from - * where they will execute. - * Write any modified data cache blocks out to memory and - * invalidate the corresponding blocks in the instruction cache. - */ - bpf_flush_icache(jit_data->ro_header, ctx->ro_insns + ctx->ninsns); for (i = 0; i < prog->len; i++) ctx->offset[i] = ninsns_rvoff(ctx->offset[i]); bpf_prog_fill_jited_linfo(prog, ctx->offset); -- 2.52.0