• K
    perf machine: Use hashtable for machine threads · 91e467bc
    Kan Liang 提交于
    To process any events, it needs to find the thread in the machine first.
    The machine maintains a rb tree to store all threads. The rb tree is
    protected by a rw lock.
    
    It is not a problem for current perf which serially processing events.
    However, it will have scalability performance issue to process events in
    parallel, especially on a heavy load system which have many threads.
    
    Introduce a hashtable to divide the big rb tree into many samll rb tree
    for threads. The index is thread id % hashtable size. It can reduce the
    lock contention.
    
    Committer notes:
    
    Renamed some variables and function names to reduce semantic confusion:
    
      'struct threads' pointers: thread -> threads
      threads hastable index: tid -> hash_bucket
      struct threads *machine__thread() -> machine__threads()
      Cast tid to (unsigned int) to handle -1 in machine__threads() (Kan Liang)
    Signed-off-by: NKan Liang <kan.liang@intel.com>
    Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Lukasz Odzioba <lukasz.odzioba@intel.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1505096603-215017-2-git-send-email-kan.liang@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    91e467bc
machine.c 54.8 KB