mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Menglong Dong <menglong8.dong@gmail.com>, ast@kernel.org
Cc: daniel@iogearbox.net, john.fastabend@gmail.com,
	andrii@kernel.org,  martin.lau@linux.dev, song@kernel.org,
	yonghong.song@linux.dev, kpsingh@kernel.org, 	sdf@fomichev.me,
	haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org,
		linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 1/2] bpf, x86: inline bpf_get_current_task() for x86_64
Date: Mon, 19 Jan 2026 12:43:17 -0800	[thread overview]
Message-ID: <e2403635a55fcf95e3d2aac7c0606388a62c713a.camel@gmail.com> (raw)
In-Reply-To: <20260119070246.249499-2-dongml2@chinatelecom.cn>

On Mon, 2026-01-19 at 15:02 +0800, Menglong Dong wrote:
> Inline bpf_get_current_task() and bpf_get_current_task_btf() for x86_64
                                                                   ^^^^^^
					Nit: this change is no longer x86 specific.

> to obtain better performance.
> 
> In !CONFIG_SMP case, the percpu variable is just a normal variable, and
> we can read the current_task directly.
> 
> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

[...]

> @@ -23319,6 +23323,24 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
>  			insn      = new_prog->insnsi + i + delta;
>  			goto next_insn;
>  		}
> +
> +		/* Implement bpf_get_current_task() and bpf_get_current_task_btf() inline. */
> +		if ((insn->imm == BPF_FUNC_get_current_task || insn->imm == BPF_FUNC_get_current_task_btf) &&
> +		    verifier_inlines_helper_call(env, insn->imm)) {
> +			insn_buf[0] = BPF_MOV64_IMM(BPF_REG_0, (u32)(unsigned long)&current_task);
> +			insn_buf[1] = BPF_MOV64_PERCPU_REG(BPF_REG_0, BPF_REG_0);
> +			insn_buf[2] = BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0);
                                                 ^^^^^^^
			Silly question:
			  This assumes pointer size of 8 bytes.
			  Which is true for all archs where bpf_jit_supports_percpu_insn()
			  returns true at the moment. Do we want an additional safety check
			  here?

> +			cnt = 3;
> +
> +			new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt);
> +			if (!new_prog)
> +				return -ENOMEM;
> +
> +			delta    += cnt - 1;
> +			env->prog = prog = new_prog;
> +			insn      = new_prog->insnsi + i + delta;
> +			goto next_insn;
> +		}
>  #endif
>  		/* Implement bpf_get_func_arg inline. */
>  		if (prog_type == BPF_PROG_TYPE_TRACING &&

  reply	other threads:[~2026-01-19 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19  7:02 [PATCH bpf-next v5 0/2] " Menglong Dong
2026-01-19  7:02 ` [PATCH bpf-next v5 1/2] " Menglong Dong
2026-01-19 20:43   ` Eduard Zingerman [this message]
2026-01-19  7:02 ` [PATCH bpf-next v5 2/2] selftests/bpf: test the jited inline of bpf_get_current_task Menglong Dong
2026-01-19 20:37   ` Eduard Zingerman
2026-01-20  1:27     ` Menglong Dong

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=e2403635a55fcf95e3d2aac7c0606388a62c713a.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.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=menglong8.dong@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@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

all inboxes | Powered by JetHome®