From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>
Subject: Re: [PATCH] libtracecmd: Support changing /proc/kallsyms
Date: Mon, 02 Jun 2025 17:05:13 +0200 [thread overview]
Message-ID: <a6def6ddb25d2fcb1b01abcb83c62b8c@linux.ibm.com> (raw)
In-Reply-To: <20250530164502.4adf0c06@gandalf.local.home>
On 2025-05-30 22:45, Steven Rostedt wrote:
> On Thu, 17 Apr 2025 01:13:00 +0200
> Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> I finally got some time to look at this. Sorry for the delay.
>
>> Running BPF selftests under trace-cmd intermittently fails with:
>>
>> error in size of file '/proc/kallsyms'
>>
>> This is because these selftests load and unload BPF programs.
>> bpf_prog_put() uses workqueues and RCU, so these programs disappear
>> from /proc/kallsyms after a delay.
>>
>> trace-cmd reads /proc/kallsyms twice: the first time to compute its
>> size, and the second time to copy it into the trace file. If the
>> resulting sizes don't match, which is what happens in this case,
>> recording fails.
>>
>> Fix by first copying /proc/kallsyms into a temporary file, and then
>> into the trace file. An alternative would be to read it into a
>> malloc()-ed buffer, but this would increase trace-cmd memory usage,
>> since /proc/kallsyms can be a few dozen megabytes large. In case
>> /tmp is tmpfs, both solutions are almost equivalent.
>
> Actually, when compression is set, the file is already read into
> memory,
> and then it is compressed. In fact, it's allocated twice!
>
> The size is copied into this temp buffer. I wonder if we could just
> update
> the size if it is different?
>
> __hidden long long
> tcmd_do_write_check(struct tracecmd_output *handle, const void *data,
> long long size)
> {
> if (handle->do_compress)
> return tracecmd_compress_buffer_write(handle->compress, data, size);
>
> if (handle->msg_handle)
> return tracecmd_msg_data_send(handle->msg_handle, data, size);
>
> return __do_write_check(handle->fd, data, size);
> }
>
> Now for the "do_compress" we can just update the handle->buffer[] as
> the
> size is the first thing written into it.
>
> For the __do_write_check() we can save the file descriptor location and
> go
> back and update what was written.
>
> For the "->msg_handle", for now just error out. Unless you are running
> bpf
> programs while using trace-cmd on guests or sending off the network?
>
> -- Steve
Thanks for taking a look.
What you propose should work for me.
Would you mind if I make do_lseek() non-static for this?
And maybe rename it to tcmd_do_lseek().
Touching do_compress/msg_handle/pointer/fd directly feels hackish.
next prev parent reply other threads:[~2025-06-02 15:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 23:13 [PATCH] libtracecmd: Support changing /proc/kallsyms Ilya Leoshkevich
2025-05-14 7:51 ` Ilya Leoshkevich
2025-05-14 13:45 ` Steven Rostedt
2025-05-30 20:45 ` Steven Rostedt
2025-06-02 15:05 ` Ilya Leoshkevich [this message]
2025-06-02 15:19 ` Steven Rostedt
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=a6def6ddb25d2fcb1b01abcb83c62b8c@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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.