Thread (1 message) 1 message, 1 author, 2024-02-06

Re: [PATCH] tracing: use ring_buffer_record_is_set_on() in tracer_tracing_is_on()

From: Sven Schnelle <svens@linux.ibm.com>
Date: 2024-02-06 06:36:13
Also in: lkml

Steven Rostedt [off-list ref] writes:
On Mon, 05 Feb 2024 14:16:30 +0100
Sven Schnelle [off-list ref] wrote:
quoted
Another issue i'm hitting sometimes is this part:

csum1=`md5sum trace`
sleep $SLEEP_TIME
csum2=`md5sum trace`

if [ "$csum1" != "$csum2" ]; then
    fail "Tracing file is still changing"
fi

This is because the command line was replaced in the
saved_cmdlines_buffer, an example diff between both files
is:
[..]
quoted
This can be improved by:

echo 32768 > /sys/kernel/tracing/saved_cmdlines_size

But this is of course not a fix - should we maybe replace the program
name with <...> before comparing, remove the check completely, or do
anything else? What do you think?
Hmm, actually I would say that this exposes a real bug. Not a major
one, but one that I find annoying. The saved commandlines should only
be updated when a trace event occurs. But really, it should only be
updated if one is added to the ring buffer. If the ring buffer isn't
being updated, we shouldn't be adding new command lines.

There may be a location that has tracing off but still updating the
cmdlines which will break the saved cache.
Looking at trace_save_cmdline():

tpid = tsk->pid & (PID_MAX_DEFAULT - 1); where PID_MAX_DEFAULT = 0x8000

so this is basically

tpid = tsk->pid & 0x7fff;

further on:

        // might clash with other pid if (otherpid & 0x7fff) == (tsk->pid & 0x7fff)
	idx = savedcmd->map_pid_to_cmdline[tpid];
	if (idx == NO_CMDLINE_MAP) {
                // This will pick an existing entry if there are
                // more than cmdline_num entries present
		idx = (savedcmd->cmdline_idx + 1) % savedcmd->cmdline_num;      
		savedcmd->map_pid_to_cmdline[tpid] = idx;
		savedcmd->cmdline_idx = idx;
	}

So i think the problem that sometimes '<...>' instead of the correct
comm is logged is just expected behaviour given the code above. 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help