bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	John Fastabend <john.fastabend@gmail.com>,
	bpf <bpf@vger.kernel.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH v4 bpf-next 2/7] libbpf: Add BTF_KIND_FLOAT support
Date: Tue, 23 Feb 2021 21:14:15 +0100	[thread overview]
Message-ID: <72463e86ed993f8bf68db676e2c3f7fcd30a717c.camel@linux.ibm.com> (raw)
In-Reply-To: <CAEf4Bzav=QQwOfjQsosYWYt6YLXUV19Zswy2pddRDYgZEXCgbg@mail.gmail.com>

On Mon, 2021-02-22 at 23:03 -0800, Andrii Nakryiko wrote:
> On Mon, Feb 22, 2021 at 1:50 PM Ilya Leoshkevich <iii@linux.ibm.com>
> wrote:
> > 
> > The logic follows that of BTF_KIND_INT most of the time. Sanitization
> > replaces BTF_KIND_FLOATs with BTF_KIND_CONSTs pointing to
> > equally-sized BTF_KIND_ARRAYs on older kernels, for example, the
> > following:
> > 
> >     [4] FLOAT 'float' size=4
> > 
> > becomes the following:
> > 
> >     [4] CONST '(anon)' type_id=10
> >     ...
> >     [8] INT 'unsigned int' size=4 bits_offset=0 nr_bits=32
> > encoding=(none)
> >     [9] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8
> > encoding=(none)
> >     [10] ARRAY '(anon)' type_id=9 index_type_id=8 nr_elems=4
> > 
> 
> I liked Yonghong's initial suggestion to replace it with PTR to VOID.
> The only concern was that if this type was used from VAR, then
> sizeof(void *) != sizeof(float) on 64-bit architectures, which might
> theoretically mess up DATASEC layout. But is this a real concern? BPF
> programs don't really support floats, so there is no point in
> declaring float variables. I'd rather stick to a simple FLOAT -> PTR
> substitution than extend generated BTF.
> 
> Alternatively, was FLOAT -> anonymous empty STRUCT with desired size
> considered? Any problems with that?

An empty STRUCT is a really nice idea - it's future-proof and has much
smaller implementation than char[]. I'll go for it.

[...]


  parent reply	other threads:[~2021-02-23 20:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 21:49 [PATCH v4 bpf-next 0/7] Add BTF_KIND_FLOAT support Ilya Leoshkevich
2021-02-22 21:49 ` [PATCH v4 bpf-next 1/7] bpf: Add BTF_KIND_FLOAT to uapi Ilya Leoshkevich
2021-02-22 21:49 ` [PATCH v4 bpf-next 2/7] libbpf: Add BTF_KIND_FLOAT support Ilya Leoshkevich
2021-02-23  7:03   ` Andrii Nakryiko
2021-02-23  7:08     ` Andrii Nakryiko
2021-02-23 20:14     ` Ilya Leoshkevich [this message]
2021-02-22 21:49 ` [PATCH v4 bpf-next 3/7] tools/bpftool: " Ilya Leoshkevich
2021-02-22 21:49 ` [PATCH v4 bpf-next 4/7] selftests/bpf: Use 25th bit in "invalid BTF_INFO" test Ilya Leoshkevich
2021-02-22 21:49 ` [PATCH v4 bpf-next 5/7] bpf: Add BTF_KIND_FLOAT support Ilya Leoshkevich
2021-02-22 21:49 ` [PATCH v4 bpf-next 6/7] selftest/bpf: Add BTF_KIND_FLOAT tests Ilya Leoshkevich
2021-02-23  7:11   ` Andrii Nakryiko
2021-02-23 20:16     ` Ilya Leoshkevich
2021-02-23 21:35       ` Andrii Nakryiko
2021-02-22 21:49 ` [PATCH v4 bpf-next 7/7] bpf: Document BTF_KIND_FLOAT in btf.rst Ilya Leoshkevich

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=72463e86ed993f8bf68db676e2c3f7fcd30a717c.camel@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=acme@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=yhs@fb.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 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).