All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: zerons <sironhide0null@gmail.com>
Cc: bpf <bpf@vger.kernel.org>
Subject: Re: branch prediction issue
Date: Thu, 21 Oct 2021 17:43:39 -0700	[thread overview]
Message-ID: <CAADnVQLB6t7FwT7OMid63VJCRTorXGi5PJHve-fxd8Tvo6fM3w@mail.gmail.com> (raw)
In-Reply-To: <57c1bcd6-f034-f5d1-f282-a6d843a2937f@gmail.com>

On Fri, Oct 8, 2021 at 7:30 AM zerons <sironhide0null@gmail.com> wrote:
>
> In check_cond_jmp_op(), the is_branch_taken() is called when
> 1) SRC op is imm
> 2) the value of SRC op is known
>
> Here comes the question: what if the value of DST op is known.
>
> Consider the following instructions:
>
> BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_8, 0),
> BPF_JMP32_IMM(BPF_JGT, BPF_REG_7, 0x7ffffff0, 1),
> BPF_EXIT_INSN(),
> BPF_LD_IMM64(BPF_REG_3, 0x7fffffe0),
> BPF_JMP32_REG(BPF_JGT, BPF_REG_3, BPF_REG_7, 1),
> BPF_EXIT_INSN(),
> BPF_EXIT_INSN(), ==> point_a
...
> The point_a instructions should be dead code. I wonder if the
> verifier do this on purpose. Do we need to handle this situation?

The compiler would never generate such code. It would be optimized.
What's the point of adding complexity to the verifier for an
artificial use case?

      reply	other threads:[~2021-10-22  0:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 14:28 branch prediction issue zerons
2021-10-22  0:43 ` Alexei Starovoitov [this message]

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=CAADnVQLB6t7FwT7OMid63VJCRTorXGi5PJHve-fxd8Tvo6fM3w@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=sironhide0null@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.