From: Song Liu <songliubraving@fb.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: bpf <bpf@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>,
Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH bpf] libbpf: count present CPUs, not theoretically possible
Date: Mon, 30 Sep 2019 06:06:54 +0000 [thread overview]
Message-ID: <05329A22-363F-4C12-9B6D-F9A2941C749E@fb.com> (raw)
In-Reply-To: <20190928063033.1674094-1-andriin@fb.com>
> On Sep 27, 2019, at 11:30 PM, Andrii Nakryiko <andriin@fb.com> wrote:
>
> This patch switches libbpf_num_possible_cpus() from using possible CPU
> set to present CPU set. This fixes issues with incorrect auto-sizing of
> PERF_EVENT_ARRAY map on HOTPLUG-enabled systems.
>
> On HOTPLUG enabled systems, /sys/devices/system/cpu/possible is going to
> be a set of any representable (i.e., potentially possible) CPU, which is
> normally way higher than real amount of CPUs (e.g., 0-127 on VM I've
> tested on, while there were just two CPU cores actually present).
> /sys/devices/system/cpu/present, on the other hand, will only contain
> CPUs that are physically present in the system (even if not online yet),
> which is what we really want, especially when creating per-CPU maps or
> perf events.
>
> On systems with HOTPLUG disabled, present and possible are identical, so
> there is no change of behavior there.
>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
> tools/lib/bpf/libbpf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index e0276520171b..45351c074e45 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -5899,7 +5899,7 @@ void bpf_program__bpil_offs_to_addr(struct bpf_prog_info_linear *info_linear)
>
> int libbpf_num_possible_cpus(void)
> {
> - static const char *fcpu = "/sys/devices/system/cpu/possible";
> + static const char *fcpu = "/sys/devices/system/cpu/present";
This is _very_ confusing. "possible cpus", "present cpus", and "online
cpus" are existing terminologies. I don't think we should force people
to remember something like "By possible cpus, libbpf actually means
present cpus".
This change works if we call it "libbbpf_num_cpus()". However,
libbpf_num_possible_cpus(), should mean possible CPUs.
Thanks,
Song
next prev parent reply other threads:[~2019-09-30 6:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-28 6:30 [PATCH bpf] libbpf: count present CPUs, not theoretically possible Andrii Nakryiko
2019-09-28 11:20 ` Alan Maguire
2019-09-28 16:31 ` Andrii Nakryiko
2019-09-28 17:46 ` Alan Maguire
2019-09-30 6:06 ` Song Liu [this message]
2019-09-30 16:22 ` Andrii Nakryiko
2019-09-30 8:32 ` Daniel Borkmann
2019-09-30 16:26 ` Andrii Nakryiko
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=05329A22-363F-4C12-9B6D-F9A2941C749E@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--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;
as well as URLs for NNTP newsgroup(s).