Рассмотрим следующий простой пример:
Код: Выделить всё
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
#include [*]
volatile atomic_int variable;
int futex_word;
int foo(void *v)
{
while (1)
{
int expected = atomic_load(&variable);
atomic_compare_exchange_strong(&variable, &expected, expected + 1);
syscall(SYS_futex, &futex_word, FUTEX_WAKE, 1);
}
}
int main(void)
{
void *stack = (char *)mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0) + 4096;
clone(foo, stack, CLONE_CHILD_SETTID, NULL);
sleep(1000);
}
Код: Выделить всё
sudo perf record --call-graph dwarf,16384 -F 9123 ./main
Код: Выделить всё
sudo perf report

На изображении самый первый развернутый символ foo состоит из двух записей:
Код: Выделить всё
95.53% foo
Код: Выделить всё
0.93% __GI___clone
Why there's such a mismatch? I see this pretty often when profiling different binaries, but not sure if it's possible to interpret it as a measurement error.
Источник: https://stackoverflow.com/questions/781 ... -match-the