Netdev List
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	John Fastabend <john.fastabend@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>
Subject: Re: [bpf-next PATCH 1/2] bpf, verifier: Remove redundant var_off.value ops in scalar known reg cases
Date: Fri, 25 Sep 2020 21:36:06 -0700	[thread overview]
Message-ID: <5f6ec536c3f22_af05120838@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <CAADnVQ+5CbptcUpjJN8bP64zrwu1j3doz+iyDEoH6mApELLNWQ@mail.gmail.com>

Alexei Starovoitov wrote:
> On Thu, Sep 24, 2020 at 11:45 AM John Fastabend
> <john.fastabend@gmail.com> wrote:
> >
> > In BPF_AND and BPF_OR alu cases we have this pattern when the src and dst
> > tnum is a constant.
> >
> >  1 dst_reg->var_off = tnum_[op](dst_reg->var_off, src_reg.var_off)
> >  2 scalar32_min_max_[op]
> >  3       if (known) return
> >  4 scalar_min_max_[op]
> >  5       if (known)
> >  6          __mark_reg_known(dst_reg,
> >                    dst_reg->var_off.value [op] src_reg.var_off.value)
> >
> > The result is in 1 we calculate the var_off value and store it in the
> > dst_reg. Then in 6 we duplicate this logic doing the op again on the
> > value.
> >
> > The duplication comes from the the tnum_[op] handlers because they have
> > already done the value calcuation. For example this is tnum_and().
> >
> >  struct tnum tnum_and(struct tnum a, struct tnum b)
> >  {
> >         u64 alpha, beta, v;
> >
> >         alpha = a.value | a.mask;
> >         beta = b.value | b.mask;
> >         v = a.value & b.value;
> >         return TNUM(v, alpha & beta & ~v);
> >  }
> >
> > So lets remove the redundant op calculation. Its confusing for readers
> > and unnecessary. Its also not harmful because those ops have the
> > property, r1 & r1 = r1 and r1 | r1 = r1.
> >
> > Signed-off-by: John Fastabend <john.fastabend@gmail.com>
> 
> Applied. Thanks for the follow up.
> In the future please always cc bpf@vger for two reasons:
> - to get proper 'Link:' integrated in git commit
> - to get them into a new instance of
> https://patchwork.kernel.org/project/bpf/list

+1

>   which we will start using soon to send automatic 'applied' emails.


Apologies, I updated some scripts and unfortunately typo dropped a '-'
and cut off bpf@vger from the CC list. Also I just used it to land
two more patches without bpf@vger happy to resend with CC included
if folks want. Sorry for the extra work/noise.

Thanks.

      reply	other threads:[~2020-09-26  4:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24 18:45 [bpf-next PATCH 1/2] bpf, verifier: Remove redundant var_off.value ops in scalar known reg cases John Fastabend
2020-09-24 18:45 ` [bpf-next PATCH 2/2] bpf: Add AND verifier test case where 32bit and 64bit bounds differ John Fastabend
2020-09-25 23:56 ` [bpf-next PATCH 1/2] bpf, verifier: Remove redundant var_off.value ops in scalar known reg cases Alexei Starovoitov
2020-09-26  4:36   ` John Fastabend [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=5f6ec536c3f22_af05120838@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /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