• Ian Rogers's avatar
    perf machine: Move machine's threads into its own abstraction · d436f90a
    Ian Rogers authored
    Move thread_rb_node into the machine.c file. This hides the
    implementation of threads from the rest of the code allowing for it to
    be refactored.
    
    Locking discipline is tightened up in this change. As the lock is now
    encapsulated in threads, the findnew function requires holding it (as
    it already did in machine). Rather than do conditionals with locks
    based on whether the thread should be created (which could potentially
    be error prone with a read lock match with a write unlock), have a
    separate threads__find that won't create the thread and only holds the
    read lock. This effectively duplicates the findnew logic, with the
    existing findnew logic only operating under a write lock assuming
    creation is necessary as a previous find failed. The creation may
    still fail with the write lock due to another thread. The duplication
    is removed in a later next patch that delegates the implementation to
    hashtable.
    Signed-off-by: default avatarIan Rogers <irogers@google.com>
    Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Cc: Yang Jihong <yangjihong1@huawei.com>
    Cc: Oliver Upton <oliver.upton@linux.dev>
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/r/20240301053646.1449657-5-irogers@google.com
    d436f90a
bpf_lock_contention.c 13 KB