From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Ming Lei <tom.leiming@gmail.com>
Cc: Martin KaFai Lau <kafai@fb.com>,
Network Development <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
FB Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH net-next 0/4] bpf: bpf_htab: Add BPF_MAP_TYPE_PERCPU_HASH
Date: Mon, 11 Jan 2016 22:00:08 -0800 [thread overview]
Message-ID: <20160112060007.GB31180@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <CACVXFVMZRS5fxta6xvehfzQHW37KxWSs630_6MO1s+GRyb0teQ@mail.gmail.com>
On Tue, Jan 12, 2016 at 01:48:10PM +0800, Ming Lei wrote:
> The total memory consumption is still much less than memory consumed
> by percpu hash since a new element is only added to hash if the key is run
> on that CPU. Most of times, for one key it may touch very few CPUs.
>
> For percpu hash, the memory is always allocated to every CPU no matter
> if the key is run from the CPU.
In Martin's use case all cpus are servicing network traffic and all of them
are counting packets.
> In my test, removing the current kmalloc() in update element callback can
> improve io thoughput by 10% not mention the percpu ida allocation cost, and
> looks it isn't cheap. That is why I don't think it is good to
> introduce another new
> allocation in the eBPF prog path.
I don't think anyone is arguing that pre-allocation is not needed.
In some cases better performance can be achieved with pre-allocation,
in some other cases regular hash map will be enough,
and in others hash map with per-cpu is needed as well.
> You can find my test in the link below:
>
> https://patchwork.ozlabs.org/patch/556926/
yes, for tools/biolatency pre-allocation is a win,
but in many other cases we simply cannot pre-allocate all elements.
prev parent reply other threads:[~2016-01-12 6:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 22:35 Martin KaFai Lau
2016-01-07 22:35 ` [PATCH net-next 1/4] bpf: bpf_htab: Refactor some htab_elem logic Martin KaFai Lau
2016-01-07 22:35 ` [PATCH net-next 2/4] bpf: bpf_htab: Add BPF_MAP_TYPE_PERCPU_HASH Martin KaFai Lau
2016-01-09 10:06 ` Ming Lei
2016-01-12 3:11 ` Martin KaFai Lau
2016-01-12 7:44 ` Martin KaFai Lau
2016-01-09 10:33 ` Ming Lei
2016-01-07 22:35 ` [PATCH net-next 3/4] bpf: bpf_htab: Add syscall to iterate percpu value of a key Martin KaFai Lau
2016-01-07 22:35 ` [PATCH net-next 4/4] bpf: bpf_htab: Test for BPF_MAP_TYPE_PERCPU_HASH Martin KaFai Lau
2016-01-08 6:55 ` [PATCH net-next 0/4] bpf: bpf_htab: Add BPF_MAP_TYPE_PERCPU_HASH Ming Lei
2016-01-09 0:44 ` Martin KaFai Lau
2016-01-09 9:39 ` Ming Lei
2016-01-10 2:30 ` Martin KaFai Lau
2016-01-11 2:20 ` Ming Lei
2016-01-11 22:35 ` Martin KaFai Lau
2016-01-12 5:48 ` Ming Lei
2016-01-12 6:00 ` 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=20160112060007.GB31180@ast-mbp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=kafai@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tom.leiming@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 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®