^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/zalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "dso.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "session.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "thread.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "thread-stack.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "namespaces.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "comm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "map.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "symbol.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "unwind.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "callchain.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <api/fs/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int thread__init_maps(struct thread *thread, struct machine *machine)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) pid_t pid = thread->pid_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) if (pid == thread->tid || pid == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) thread->maps = maps__new(machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct thread *leader = __machine__findnew_thread(machine, pid, pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (leader) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) thread->maps = maps__get(leader->maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) thread__put(leader);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) return thread->maps ? 0 : -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct thread *thread__new(pid_t pid, pid_t tid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) char *comm_str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct comm *comm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct thread *thread = zalloc(sizeof(*thread));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (thread != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) thread->pid_ = pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) thread->tid = tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) thread->ppid = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) thread->cpu = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) thread->lbr_stitch_enable = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) INIT_LIST_HEAD(&thread->namespaces_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) INIT_LIST_HEAD(&thread->comm_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) init_rwsem(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) init_rwsem(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) comm_str = malloc(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (!comm_str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) goto err_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) snprintf(comm_str, 32, ":%d", tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) comm = comm__new(comm_str, 0, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) free(comm_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (!comm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) goto err_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) list_add(&comm->list, &thread->comm_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) refcount_set(&thread->refcnt, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) RB_CLEAR_NODE(&thread->rb_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* Thread holds first ref to nsdata. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) thread->nsinfo = nsinfo__new(pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) srccode_state_init(&thread->srccode_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) err_thread:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) free(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) void thread__delete(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct namespaces *namespaces, *tmp_namespaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct comm *comm, *tmp_comm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) BUG_ON(!RB_EMPTY_NODE(&thread->rb_node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) thread_stack__free(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (thread->maps) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) maps__put(thread->maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) thread->maps = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) down_write(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) list_for_each_entry_safe(namespaces, tmp_namespaces,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) &thread->namespaces_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) list_del_init(&namespaces->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) namespaces__free(namespaces);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) up_write(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) down_write(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) list_for_each_entry_safe(comm, tmp_comm, &thread->comm_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) list_del_init(&comm->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) comm__free(comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) up_write(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) nsinfo__zput(thread->nsinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) srccode_state_free(&thread->srccode_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) exit_rwsem(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) exit_rwsem(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) thread__free_stitch_list(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) free(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct thread *thread__get(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) refcount_inc(&thread->refcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) return thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) void thread__put(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (thread && refcount_dec_and_test(&thread->refcnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * Remove it from the dead threads list, as last reference is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * gone, if it is in a dead threads list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * We may not be there anymore if say, the machine where it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * stored was already deleted, so we already removed it from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * the dead threads and some other piece of code still keeps a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * This is what 'perf sched' does and finally drops it in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * perf_sched__lat(), where it calls perf_sched__read_events(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * that processes the events by creating a session and deleting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * it, which ends up destroying the list heads for the dead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * threads, but before it does that it removes all threads from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * it using list_del_init().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * So we need to check here if it is in a dead threads list and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * if so, remove it before finally deleting the thread, to avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * an use after free situation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (!list_empty(&thread->node))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) list_del_init(&thread->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) thread__delete(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static struct namespaces *__thread__namespaces(const struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (list_empty(&thread->namespaces_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return list_first_entry(&thread->namespaces_list, struct namespaces, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct namespaces *thread__namespaces(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct namespaces *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) down_read(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) ns = __thread__namespaces(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) up_read(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) return ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static int __thread__set_namespaces(struct thread *thread, u64 timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct perf_record_namespaces *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct namespaces *new, *curr = __thread__namespaces(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) new = namespaces__new(event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (!new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) list_add(&new->list, &thread->namespaces_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (timestamp && curr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * setns syscall must have changed few or all the namespaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * of this thread. Update end time for the namespaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * previously used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) curr = list_next_entry(new, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) curr->end_time = timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int thread__set_namespaces(struct thread *thread, u64 timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct perf_record_namespaces *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) down_write(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) ret = __thread__set_namespaces(thread, timestamp, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) up_write(&thread->namespaces_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct comm *thread__comm(const struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (list_empty(&thread->comm_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return list_first_entry(&thread->comm_list, struct comm, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct comm *thread__exec_comm(const struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct comm *comm, *last = NULL, *second_last = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) list_for_each_entry(comm, &thread->comm_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (comm->exec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return comm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) second_last = last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) last = comm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * 'last' with no start time might be the parent's comm of a synthesized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * thread (created by processing a synthesized fork event). For a main
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * thread, that is very probably wrong. Prefer a later comm to avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * that case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (second_last && !last->start && thread->pid_ == thread->tid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return second_last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static int ____thread__set_comm(struct thread *thread, const char *str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) u64 timestamp, bool exec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct comm *new, *curr = thread__comm(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* Override the default :tid entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (!thread->comm_set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) int err = comm__override(curr, str, timestamp, exec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) new = comm__new(str, timestamp, exec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (!new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) list_add(&new->list, &thread->comm_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (exec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) unwind__flush_access(thread->maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) thread->comm_set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) bool exec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) down_write(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ret = ____thread__set_comm(thread, str, timestamp, exec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) up_write(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int thread__set_comm_from_proc(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) char path[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) char *comm = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) size_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) int err = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (!(snprintf(path, sizeof(path), "%d/task/%d/comm",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) thread->pid_, thread->tid) >= (int)sizeof(path)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) procfs__read_str(path, &comm, &sz) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) comm[sz - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) err = thread__set_comm(thread, comm, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static const char *__thread__comm_str(const struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) const struct comm *comm = thread__comm(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (!comm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) return comm__str(comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) const char *thread__comm_str(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) down_read(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) str = __thread__comm_str(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) up_read(&thread->comm_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /* CHECKME: it should probably better return the max comm len from its comm list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int thread__comm_len(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if (!thread->comm_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) const char *comm = thread__comm_str(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) if (!comm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) thread->comm_len = strlen(comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) return thread->comm_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) size_t thread__fprintf(struct thread *thread, FILE *fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) maps__fprintf(thread->maps, fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) int thread__insert_map(struct thread *thread, struct map *map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ret = unwind__prepare_access(thread->maps, map, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) maps__fixup_overlappings(thread->maps, map, stderr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) maps__insert(thread->maps, map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) static int __thread__prepare_access(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) bool initialized = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) struct maps *maps = thread->maps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) struct map *map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) down_read(&maps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) maps__for_each_entry(maps, map) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) err = unwind__prepare_access(thread->maps, map, &initialized);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (err || initialized)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) up_read(&maps->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static int thread__prepare_access(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if (dwarf_callchain_users)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) err = __thread__prepare_access(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static int thread__clone_maps(struct thread *thread, struct thread *parent, bool do_maps_clone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) /* This is new thread, we share map groups for process. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if (thread->pid_ == parent->pid_)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) return thread__prepare_access(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if (thread->maps == parent->maps) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) pr_debug("broken map groups on thread %d/%d parent %d/%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) thread->pid_, thread->tid, parent->pid_, parent->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* But this one is new process, copy maps. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) return do_maps_clone ? maps__clone(thread, parent->maps) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if (parent->comm_set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) const char *comm = thread__comm_str(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (!comm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) err = thread__set_comm(thread, comm, timestamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) thread->ppid = parent->tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) return thread__clone_maps(thread, parent, do_maps_clone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) struct addr_location *al)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) size_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) const u8 cpumodes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) PERF_RECORD_MISC_USER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) PERF_RECORD_MISC_KERNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) PERF_RECORD_MISC_GUEST_USER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) PERF_RECORD_MISC_GUEST_KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) for (i = 0; i < ARRAY_SIZE(cpumodes); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) thread__find_symbol(thread, cpumodes[i], addr, al);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) if (al->map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) struct thread *thread__main_thread(struct machine *machine, struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (thread->pid_ == thread->tid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) return thread__get(thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) if (thread->pid_ == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) return machine__find_thread(machine, thread->pid_, thread->pid_);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) int thread__memcpy(struct thread *thread, struct machine *machine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) void *buf, u64 ip, int len, bool *is64bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) u8 cpumode = PERF_RECORD_MISC_USER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) struct addr_location al;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) if (machine__kernel_ip(machine, ip))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) cpumode = PERF_RECORD_MISC_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) if (!thread__find_map(thread, cpumode, ip, &al) || !al.map->dso ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) al.map->dso->data.status == DSO_DATA_STATUS_ERROR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) map__load(al.map) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) offset = al.map->map_ip(al.map, ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) if (is64bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) *is64bit = al.map->dso->is_64_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) return dso__data_read_offset(al.map->dso, machine, offset, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) void thread__free_stitch_list(struct thread *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) struct lbr_stitch *lbr_stitch = thread->lbr_stitch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) struct stitch_list *pos, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (!lbr_stitch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) list_for_each_entry_safe(pos, tmp, &lbr_stitch->lists, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) list_del_init(&pos->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) free(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) list_for_each_entry_safe(pos, tmp, &lbr_stitch->free_lists, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) list_del_init(&pos->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) free(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) zfree(&lbr_stitch->prev_lbr_cursor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) zfree(&thread->lbr_stitch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) }