All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Eduard Zingerman <eddyz87@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>,
	Arnd Bergmann <arnd@kernel.org>, Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH bpf-next v2 3/3] bpf: Avoid putting struct bpf_scc_callchain variables on the stack
Date: Wed, 2 Jul 2025 19:01:13 -0700	[thread overview]
Message-ID: <d7a1884c-5566-4356-b91c-b7c461077331@linux.dev> (raw)
In-Reply-To: <cd208a86a068c70994461066b6d863307a5e0645.camel@gmail.com>



On 7/2/25 12:03 PM, Eduard Zingerman wrote:
> On Wed, 2025-07-02 at 10:11 -0700, Yonghong Song wrote:
>> Add a 'struct bpf_scc_callchain callchain' field in bpf_verifier_env.
>> This way, the previous bpf_scc_callchain local variables can be
>> replaced by taking address of env->callchain. This can reduce stack
>> usage and fix the following error:
>>      kernel/bpf/verifier.c:19921:12: error: stack frame size (1368) exceeds limit (1280) in 'do_check'
>>          [-Werror,-Wframe-larger-than]
>>
>> Reported-by: Arnd Bergmann <arnd@kernel.org>
>> Acked-by: Jiri Olsa <jolsa@kernel.org>
>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>> ---
> Oh, well.
> I liked stack allocation for callchain object, because it emphasized
> its ephemeral by-value status.
>
> The changes lgtm, all places with callchain stack allocation replaced.
>
> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
>
> [...]
>
>>   include/linux/bpf_verifier.h |  1 +
>>   kernel/bpf/verifier.c        | 36 ++++++++++++++++++------------------
>>   2 files changed, 19 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
>> index 7e459e839f8b..e2c175d608bb 100644
>> --- a/include/linux/bpf_verifier.h
>> +++ b/include/linux/bpf_verifier.h
>> @@ -841,6 +841,7 @@ struct bpf_verifier_env {
>>   	char tmp_str_buf[TMP_STR_BUF_LEN];
>>   	struct bpf_insn insn_buf[INSN_BUF_SIZE];
>>   	struct bpf_insn epilogue_buf[INSN_BUF_SIZE];
>> +	struct bpf_scc_callchain callchain;
> Nit: maybe a comment here about this being a scratch buffer?

Maybe I can just change the variable name from 'callchain'
to 'callchain_buf' so it will be clear it is a scratch buffer?

>
>>   	/* array of pointers to bpf_scc_info indexed by SCC id */
>>   	struct bpf_scc_info **scc_info;
>>   	u32 scc_cnt;
> [...]


      reply	other threads:[~2025-07-03  2:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 17:11 [PATCH bpf-next v2 0/3] bpf: Reduce verifier stack frame size Yonghong Song
2025-07-02 17:11 ` [PATCH bpf-next v2 1/3] bpf: Simplify assignment to struct bpf_insn pointer in do_misc_fixups() Yonghong Song
2025-07-02 18:58   ` Eduard Zingerman
2025-07-02 17:11 ` [PATCH bpf-next v2 2/3] bpf: Reduce stack frame size by using env->insn_buf for bpf insns Yonghong Song
2025-07-02 20:33   ` Eduard Zingerman
2025-07-03  2:02     ` Yonghong Song
2025-07-02 17:11 ` [PATCH bpf-next v2 3/3] bpf: Avoid putting struct bpf_scc_callchain variables on the stack Yonghong Song
2025-07-02 19:03   ` Eduard Zingerman
2025-07-03  2:01     ` Yonghong Song [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=d7a1884c-5566-4356-b91c-b7c461077331@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=andrii@kernel.org \
    --cc=arnd@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.