• Thomas Richter's avatar
    s390/cpum_cf: rework PER_CPU_DEFINE of struct cpu_cf_events · 9b9cf3c7
    Thomas Richter authored
    Struct cpu_cf_events is a large data structure and is statically defined
    for each possible CPU. Rework this and replace it by dynamically
    allocated data structures created when a perf_event_open() system call
    is invoked or an access via character device /dev/hwctr takes place.
    
    It is replaced by an array of pointers to all possible CPUs and
    reference counting. The array of pointers is allocated when the first
    event is created. For each online CPU an event is installed on, a struct
    cpu_cf_events is allocated and a pointer to struct cpu_cf_events is
    stored in the array:
    
                       CPU   0   1   2   3  ...  N
                           +---+---+---+---+---+---+
     cpu_cf_root::cpucf--> | * |   |   |   |...|   |
                           +-|-+---+---+---+---+---+
                             |
                             |
                            \|/
                         +-------------+
    		     |cpu_cf_events|
    		     |             |
                         +-------------+
    
    With this approach the large data structure is only allocated when
    an event is actually installed and used.
    Also implement proper reference counting for allocation and removal.
    
    During interrupt processing make sure the pointer to cpu_cf_events
    is valid. The interrupt handler is shared and might be called when
    no event is active.
    This requires checking for a valid pointer to struct cpu_cf_events.
    When the pointer to the per-cpu cpu_cf_events is NULL, simply return.
    Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
    Acked-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
    Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
    Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
    9b9cf3c7
perf_cpum_cf.c 56.6 KB