~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/counts.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/util/counts.c (Version linux-6.11.5) and /tools/perf/util/counts.c (Version linux-6.2.16)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 #include <errno.h>                                  2 #include <errno.h>
  3 #include <stdlib.h>                                 3 #include <stdlib.h>
  4 #include <string.h>                                 4 #include <string.h>
  5 #include "evsel.h"                                  5 #include "evsel.h"
  6 #include "counts.h"                                 6 #include "counts.h"
  7 #include <perf/threadmap.h>                         7 #include <perf/threadmap.h>
  8 #include <linux/zalloc.h>                           8 #include <linux/zalloc.h>
  9                                                     9 
 10 struct perf_counts *perf_counts__new(int ncpus     10 struct perf_counts *perf_counts__new(int ncpus, int nthreads)
 11 {                                                  11 {
 12         struct perf_counts *counts = zalloc(si     12         struct perf_counts *counts = zalloc(sizeof(*counts));
 13                                                    13 
 14         if (counts) {                              14         if (counts) {
 15                 struct xyarray *values;            15                 struct xyarray *values;
 16                                                    16 
 17                 values = xyarray__new(ncpus, n     17                 values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
 18                 if (!values) {                     18                 if (!values) {
 19                         free(counts);              19                         free(counts);
 20                         return NULL;               20                         return NULL;
 21                 }                                  21                 }
 22                                                    22 
 23                 counts->values = values;           23                 counts->values = values;
 24                                                    24 
 25                 values = xyarray__new(ncpus, n     25                 values = xyarray__new(ncpus, nthreads, sizeof(bool));
 26                 if (!values) {                     26                 if (!values) {
 27                         xyarray__delete(counts     27                         xyarray__delete(counts->values);
 28                         free(counts);              28                         free(counts);
 29                         return NULL;               29                         return NULL;
 30                 }                                  30                 }
 31                                                    31 
 32                 counts->loaded = values;           32                 counts->loaded = values;
 33         }                                          33         }
 34                                                    34 
 35         return counts;                             35         return counts;
 36 }                                                  36 }
 37                                                    37 
 38 void perf_counts__delete(struct perf_counts *c     38 void perf_counts__delete(struct perf_counts *counts)
 39 {                                                  39 {
 40         if (counts) {                              40         if (counts) {
 41                 xyarray__delete(counts->loaded     41                 xyarray__delete(counts->loaded);
 42                 xyarray__delete(counts->values     42                 xyarray__delete(counts->values);
 43                 free(counts);                      43                 free(counts);
 44         }                                          44         }
 45 }                                                  45 }
 46                                                    46 
 47 void perf_counts__reset(struct perf_counts *co     47 void perf_counts__reset(struct perf_counts *counts)
 48 {                                                  48 {
 49         xyarray__reset(counts->loaded);            49         xyarray__reset(counts->loaded);
 50         xyarray__reset(counts->values);            50         xyarray__reset(counts->values);
 51 }                                                  51 }
 52                                                    52 
 53 void evsel__reset_counts(struct evsel *evsel)      53 void evsel__reset_counts(struct evsel *evsel)
 54 {                                                  54 {
 55         perf_counts__reset(evsel->counts);         55         perf_counts__reset(evsel->counts);
 56 }                                                  56 }
 57                                                    57 
 58 int evsel__alloc_counts(struct evsel *evsel)       58 int evsel__alloc_counts(struct evsel *evsel)
 59 {                                                  59 {
 60         struct perf_cpu_map *cpus = evsel__cpu     60         struct perf_cpu_map *cpus = evsel__cpus(evsel);
 61         int nthreads = perf_thread_map__nr(evs     61         int nthreads = perf_thread_map__nr(evsel->core.threads);
 62                                                    62 
 63         evsel->counts = perf_counts__new(perf_     63         evsel->counts = perf_counts__new(perf_cpu_map__nr(cpus), nthreads);
 64         return evsel->counts != NULL ? 0 : -EN     64         return evsel->counts != NULL ? 0 : -ENOMEM;
 65 }                                                  65 }
 66                                                    66 
 67 void evsel__free_counts(struct evsel *evsel)       67 void evsel__free_counts(struct evsel *evsel)
 68 {                                                  68 {
 69         perf_counts__delete(evsel->counts);        69         perf_counts__delete(evsel->counts);
 70         evsel->counts = NULL;                      70         evsel->counts = NULL;
 71 }                                                  71 }
 72                                                    72 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php