static void comm_strs__remove_if_last(struct comm_str *cs);
static void comm_strs__init(void)
- NO_THREAD_SAFETY_ANALYSIS /* Inherently single threaded due to pthread_once. */
{
init_rwsem(&_comm_strs.lock);
_comm_strs.capacity = 16;
}
static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str)
- SHARED_LOCKS_REQUIRED(comm_strs->lock)
{
struct comm_str **result;
}
struct thread *thread__new(pid_t pid, pid_t tid)
- NO_THREAD_SAFETY_ANALYSIS /* Allocation/creation is inherently single threaded. */
{
RC_STRUCT(thread) *_thread = zalloc(sizeof(*_thread));
struct thread *thread;
struct comm *thread__comm(struct thread *thread)
{
- struct comm *res = NULL;
+ if (list_empty(thread__comm_list(thread)))
+ return NULL;
- down_read(thread__comm_lock(thread));
- if (!list_empty(thread__comm_list(thread)))
- res = list_first_entry(thread__comm_list(thread), struct comm, list);
- up_read(thread__comm_lock(thread));
- return res;
+ return list_first_entry(thread__comm_list(thread), struct comm, list);
}
struct comm *thread__exec_comm(struct thread *thread)
{
struct comm *comm, *last = NULL, *second_last = NULL;
- down_read(thread__comm_lock(thread));
list_for_each_entry(comm, thread__comm_list(thread), list) {
- if (comm->exec) {
- up_read(thread__comm_lock(thread));
+ if (comm->exec)
return comm;
- }
second_last = last;
last = comm;
}
- up_read(thread__comm_lock(thread));
/*
* 'last' with no start time might be the parent's comm of a synthesized
static int ____thread__set_comm(struct thread *thread, const char *str,
u64 timestamp, bool exec)
- EXCLUSIVE_LOCKS_REQUIRED(thread__comm_lock(thread))
{
struct comm *new, *curr = thread__comm(thread);
return &RC_CHK_ACCESS(thread)->namespaces_lock;
}
-static inline struct rw_semaphore *thread__comm_lock(struct thread *thread)
+static inline struct list_head *thread__comm_list(struct thread *thread)
{
- return &RC_CHK_ACCESS(thread)->comm_lock;
+ return &RC_CHK_ACCESS(thread)->comm_list;
}
-static inline struct list_head *thread__comm_list(struct thread *thread)
- SHARED_LOCKS_REQUIRED(thread__comm_lock(thread))
+static inline struct rw_semaphore *thread__comm_lock(struct thread *thread)
{
- return &RC_CHK_ACCESS(thread)->comm_list;
+ return &RC_CHK_ACCESS(thread)->comm_lock;
}
static inline u64 thread__db_id(const struct thread *thread)