public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	bpf@vger.kernel.org, Aleksei Shchekotikhin <alekseis@google.com>,
	Nilay Vaish <nilayvaish@google.com>
Subject: Re: [PATCH v2] bpf: Allocate bpf_event_entry with node info
Date: Wed, 29 May 2024 10:31:24 +0200	[thread overview]
Message-ID: <Zlbn3DOGrzHlw95h@krava> (raw)
In-Reply-To: <20240529065311.1218230-1-namhyung@kernel.org>

On Tue, May 28, 2024 at 11:53:11PM -0700, Namhyung Kim wrote:
> It was reported that accessing perf_event map entry caused pretty high
> LLC misses in get_map_perf_counter().  As reading perf_event is allowed
> for the local CPU only, I think we can use the target CPU of the event
> as hint for the allocation like in perf_event_alloc() so that the event
> and the entry can be in the same node at least.

looks good, is there any profile to prove the gain?

jirka

> 
> Reported-by: Aleksei Shchekotikhin <alekseis@google.com>
> Reported-by: Nilay Vaish <nilayvaish@google.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

> ---
> v2) fix build errors
> 
>  kernel/bpf/arraymap.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
> index feabc0193852..067f7cf27042 100644
> --- a/kernel/bpf/arraymap.c
> +++ b/kernel/bpf/arraymap.c
> @@ -1194,10 +1194,17 @@ static struct bpf_event_entry *bpf_event_entry_gen(struct file *perf_file,
>  						   struct file *map_file)
>  {
>  	struct bpf_event_entry *ee;
> +	struct perf_event *event = perf_file->private_data;
> +	int node = -1;
>  
> -	ee = kzalloc(sizeof(*ee), GFP_KERNEL);
> +#ifdef CONFIG_PERF_EVENTS
> +	if (event->cpu >= 0)
> +		node = cpu_to_node(event->cpu);
> +#endif
> +
> +	ee = kzalloc_node(sizeof(*ee), GFP_KERNEL, node);
>  	if (ee) {
> -		ee->event = perf_file->private_data;
> +		ee->event = event;
>  		ee->perf_file = perf_file;
>  		ee->map_file = map_file;
>  	}
> -- 
> 2.45.1.288.g0e0cd299f1-goog
> 

  reply	other threads:[~2024-05-29  8:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  6:53 [PATCH v2] bpf: Allocate bpf_event_entry with node info Namhyung Kim
2024-05-29  8:31 ` Jiri Olsa [this message]
2024-05-29 16:54   ` Namhyung Kim
2024-05-29 17:23     ` Alexei Starovoitov
2024-05-29 18:27       ` Namhyung Kim

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=Zlbn3DOGrzHlw95h@krava \
    --to=olsajiri@gmail.com \
    --cc=alekseis@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=namhyung@kernel.org \
    --cc=nilayvaish@google.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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