From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Song Liu <songliubraving@fb.com>
Cc: Song Liu <song@kernel.org>, bpf <bpf@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Kernel Team <Kernel-team@fb.com>,
Peter Zijlstra <peterz@infradead.org>, X86 ML <x86@kernel.org>
Subject: Re: [PATCH v5 bpf-next 7/7] bpf, x86_64: use bpf_prog_pack allocator
Date: Fri, 21 Jan 2022 10:29:55 -0800 [thread overview]
Message-ID: <CAADnVQLWj6cVE=OEqNfSBcAzFJDHPF8sPfqGfaCknV+Q=1HOmQ@mail.gmail.com> (raw)
In-Reply-To: <F72EEF0D-4F61-4AE1-B2A1-D16A5DBCCC37@fb.com>
On Fri, Jan 21, 2022 at 9:53 AM Song Liu <songliubraving@fb.com> wrote:
> >
> > the header->size could be just below 2MB.
> > I don't think kzalloc() can handle that.
>
> Technically, kzalloc can handle 2MB allocation via:
> kzalloc() => kmalloc() => kmalloc_large() => kmalloc_order()
>
> But this would fail when the memory is fragmented. I guess we should use
> kvmalloc() instead?
Contiguous 2MB allocation?
> >
> >> + if (!tmp_header) {
> >> + bpf_jit_binary_free_pack(header);
> >> + header = NULL;
> >> + prog = orig_prog;
> >> + goto out_addrs;
> >> + }
> >> + tmp_header->size = header->size;
> >> + tmp_image = (void *)tmp_header + ((void *)image - (void *)header);
> >
> > Why is 'tmp_image' needed at all?
> > The above math can be done where necessary.
>
> We pass both image and tmp_image to do_jit(), as it needs both of them.
> I think maintaining a tmp_image variable makes the logic cleaner. We can
> remove it from x64_jit_data, I guess.
I'd remove from x64_jit_data. The recompute is cheap.
Speaking of tmp_header name... would be great to come up
with something more descriptive.
Here both tmp_header/tmp_image and header/image are used at the same time.
My initial confusion with the patch was due to the name 'tmp'.
The "tmp" prefix implies that the tmp_image will be used first
and then it will become an image.
But it's not the case.
Maybe call it 'rw_header' and add a comment that 'header/image'
are not writeable directly ?
Or call it 'poke_header' ?
Other ideas?
next prev parent reply other threads:[~2022-01-21 18:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 19:12 [PATCH v5 bpf-next 0/7] bpf_prog_pack allocator Song Liu
2022-01-20 19:12 ` [PATCH v5 bpf-next 1/7] x86/Kconfig: select HAVE_ARCH_HUGE_VMALLOC with HAVE_ARCH_HUGE_VMAP Song Liu
2022-01-20 19:13 ` [PATCH v5 bpf-next 2/7] bpf: use bytes instead of pages for bpf_jit_[charge|uncharge]_modmem Song Liu
2022-01-20 19:13 ` [PATCH v5 bpf-next 3/7] bpf: use size instead of pages in bpf_binary_header Song Liu
2022-01-20 19:13 ` [PATCH v5 bpf-next 4/7] bpf: add a pointer of bpf_binary_header to bpf_prog Song Liu
2022-01-20 19:13 ` [PATCH v5 bpf-next 5/7] x86/alternative: introduce text_poke_copy Song Liu
2022-01-21 9:52 ` Peter Zijlstra
2022-01-20 19:13 ` [PATCH v5 bpf-next 6/7] bpf: introduce bpf_prog_pack allocator Song Liu
2022-01-20 19:13 ` [PATCH v5 bpf-next 7/7] bpf, x86_64: use " Song Liu
2022-01-21 4:59 ` Alexei Starovoitov
2022-01-21 17:53 ` Song Liu
2022-01-21 18:29 ` Alexei Starovoitov [this message]
2022-01-21 18:56 ` Song Liu
2022-01-21 1:06 ` [PATCH v5 bpf-next 0/7] " Song Liu
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='CAADnVQLWj6cVE=OEqNfSBcAzFJDHPF8sPfqGfaCknV+Q=1HOmQ@mail.gmail.com' \
--to=alexei.starovoitov@gmail.com \
--cc=Kernel-team@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
--cc=songliubraving@fb.com \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).