In case we are building in a flatpak, we might want to rely on a system
installed sysprofd. This means we might want to pretend we have sysprofd
support (to be found on the system), but not actually build sysprofd.
We need this for recent changes to how natural sizing will work now that
the max-content-* properties are stabilizing for their first public ABI
release.
The kernel says here http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/events/ring_buffer.c?id=7a1dcf6ad#n61 :
* Since the mmap() consumer (userspace) can run on a different CPU:
*
* kernel user
*
* if (LOAD ->data_tail) { LOAD ->data_head
* (A) smp_rmb() (C)
* STORE $data LOAD $data
* smp_wmb() (B) smp_mb() (D)
* STORE ->data_head STORE ->data_tail
* }
*
* Where A pairs with D, and B pairs with C.
*
* In our case (A) is a control dependency that separates the load of
* the ->data_tail and the stores of $data. In case ->data_tail
* indicates there is no room in the buffer to store $data we do not.
*
* D needs to be a full barrier since it separates the data READ
* from the tail WRITE.
*
* For B a WMB is sufficient since it separates two WRITEs, and for C
* an RMB is sufficient since it separates two READs.
*
* See perf_output_begin().
So I'm pretty sure we need a full barrier before writing out data_tail.
If we check the UID of the pid from /proc/pid/status and the UID matches
our current user, we should be able to forego the authorization dialog.
This should fix a regression where sysprof worked from jhbuild when
profiling a process you have access to.
This fixes the "auto-stop" feature when the child exits, at least in the
case of /usr/bin/gnome-calculator. However, when testing with gedit I
did not see it accurately clean up, so something still needs to be
troubleshooted.
So changing this was a little backwards. The goal here is to allow using
libsysprof-2 without polkit, it just won't have the ability to elevate
privileges.
Just a quick workaround to use a tmpfile if memfd is not available. We
should try to ensure that we get something on tmpfs, but this is probably
good enough for a fallback.
We can use this to notify the user that not enough samples where collected
to build a callgraph. This can happen when all the samples collected are
ignored (due to being in ignored kernel space address ranges for example).
We keep the start time as a iso8601 string, which is useful, but not
enough for relative timestamps to the epoch (start time). Include a
clock time in the same clock domain.
We were not getting the proper value for time. We need sample_id_all set
according to my cursory reading of the core.c in the kernel. Also, the
time is aligned to 64-bit (after the comm field).