diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/perf/scripts/python/net_dropmonitor.py | 39 | ||||
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 54 | ||||
-rw-r--r-- | tools/testing/selftests/Makefile | 1 | ||||
-rw-r--r-- | tools/testing/selftests/soft-dirty/Makefile | 10 | ||||
-rw-r--r-- | tools/testing/selftests/soft-dirty/soft-dirty.c | 114 |
5 files changed, 74 insertions, 144 deletions
diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py index a4ffc9500023..b5740599aabd 100755 --- a/tools/perf/scripts/python/net_dropmonitor.py +++ b/tools/perf/scripts/python/net_dropmonitor.py | |||
@@ -15,35 +15,38 @@ kallsyms = [] | |||
15 | 15 | ||
16 | def get_kallsyms_table(): | 16 | def get_kallsyms_table(): |
17 | global kallsyms | 17 | global kallsyms |
18 | |||
18 | try: | 19 | try: |
19 | f = open("/proc/kallsyms", "r") | 20 | f = open("/proc/kallsyms", "r") |
20 | linecount = 0 | ||
21 | for line in f: | ||
22 | linecount = linecount+1 | ||
23 | f.seek(0) | ||
24 | except: | 21 | except: |
25 | return | 22 | return |
26 | 23 | ||
27 | |||
28 | j = 0 | ||
29 | for line in f: | 24 | for line in f: |
30 | loc = int(line.split()[0], 16) | 25 | loc = int(line.split()[0], 16) |
31 | name = line.split()[2] | 26 | name = line.split()[2] |
32 | j = j +1 | 27 | kallsyms.append((loc, name)) |
33 | if ((j % 100) == 0): | ||
34 | print "\r" + str(j) + "/" + str(linecount), | ||
35 | kallsyms.append({ 'loc': loc, 'name' : name}) | ||
36 | |||
37 | print "\r" + str(j) + "/" + str(linecount) | ||
38 | kallsyms.sort() | 28 | kallsyms.sort() |
39 | return | ||
40 | 29 | ||
41 | def get_sym(sloc): | 30 | def get_sym(sloc): |
42 | loc = int(sloc) | 31 | loc = int(sloc) |
43 | for i in kallsyms: | 32 | |
44 | if (i['loc'] >= loc): | 33 | # Invariant: kallsyms[i][0] <= loc for all 0 <= i <= start |
45 | return (i['name'], i['loc']-loc) | 34 | # kallsyms[i][0] > loc for all end <= i < len(kallsyms) |
46 | return (None, 0) | 35 | start, end = -1, len(kallsyms) |
36 | while end != start + 1: | ||
37 | pivot = (start + end) // 2 | ||
38 | if loc < kallsyms[pivot][0]: | ||
39 | end = pivot | ||
40 | else: | ||
41 | start = pivot | ||
42 | |||
43 | # Now (start == -1 or kallsyms[start][0] <= loc) | ||
44 | # and (start == len(kallsyms) - 1 or loc < kallsyms[start + 1][0]) | ||
45 | if start >= 0: | ||
46 | symloc, name = kallsyms[start] | ||
47 | return (name, loc - symloc) | ||
48 | else: | ||
49 | return (None, 0) | ||
47 | 50 | ||
48 | def print_drop_table(): | 51 | def print_drop_table(): |
49 | print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT") | 52 | print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT") |
@@ -64,7 +67,7 @@ def trace_end(): | |||
64 | 67 | ||
65 | # called from perf, when it finds a correspoinding event | 68 | # called from perf, when it finds a correspoinding event |
66 | def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, | 69 | def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, |
67 | skbaddr, protocol, location): | 70 | skbaddr, location, protocol): |
68 | slocation = str(location) | 71 | slocation = str(location) |
69 | try: | 72 | try: |
70 | drop_log[slocation] = drop_log[slocation] + 1 | 73 | drop_log[slocation] = drop_log[slocation] + 1 |
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 321e066a0753..9e9d34871195 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -46,6 +46,7 @@ unsigned int skip_c0; | |||
46 | unsigned int skip_c1; | 46 | unsigned int skip_c1; |
47 | unsigned int do_nhm_cstates; | 47 | unsigned int do_nhm_cstates; |
48 | unsigned int do_snb_cstates; | 48 | unsigned int do_snb_cstates; |
49 | unsigned int do_c8_c9_c10; | ||
49 | unsigned int has_aperf; | 50 | unsigned int has_aperf; |
50 | unsigned int has_epb; | 51 | unsigned int has_epb; |
51 | unsigned int units = 1000000000; /* Ghz etc */ | 52 | unsigned int units = 1000000000; /* Ghz etc */ |
@@ -120,6 +121,9 @@ struct pkg_data { | |||
120 | unsigned long long pc3; | 121 | unsigned long long pc3; |
121 | unsigned long long pc6; | 122 | unsigned long long pc6; |
122 | unsigned long long pc7; | 123 | unsigned long long pc7; |
124 | unsigned long long pc8; | ||
125 | unsigned long long pc9; | ||
126 | unsigned long long pc10; | ||
123 | unsigned int package_id; | 127 | unsigned int package_id; |
124 | unsigned int energy_pkg; /* MSR_PKG_ENERGY_STATUS */ | 128 | unsigned int energy_pkg; /* MSR_PKG_ENERGY_STATUS */ |
125 | unsigned int energy_dram; /* MSR_DRAM_ENERGY_STATUS */ | 129 | unsigned int energy_dram; /* MSR_DRAM_ENERGY_STATUS */ |
@@ -282,6 +286,11 @@ void print_header(void) | |||
282 | outp += sprintf(outp, " %%pc6"); | 286 | outp += sprintf(outp, " %%pc6"); |
283 | if (do_snb_cstates) | 287 | if (do_snb_cstates) |
284 | outp += sprintf(outp, " %%pc7"); | 288 | outp += sprintf(outp, " %%pc7"); |
289 | if (do_c8_c9_c10) { | ||
290 | outp += sprintf(outp, " %%pc8"); | ||
291 | outp += sprintf(outp, " %%pc9"); | ||
292 | outp += sprintf(outp, " %%pc10"); | ||
293 | } | ||
285 | 294 | ||
286 | if (do_rapl & RAPL_PKG) | 295 | if (do_rapl & RAPL_PKG) |
287 | outp += sprintf(outp, " Pkg_W"); | 296 | outp += sprintf(outp, " Pkg_W"); |
@@ -336,6 +345,9 @@ int dump_counters(struct thread_data *t, struct core_data *c, | |||
336 | fprintf(stderr, "pc3: %016llX\n", p->pc3); | 345 | fprintf(stderr, "pc3: %016llX\n", p->pc3); |
337 | fprintf(stderr, "pc6: %016llX\n", p->pc6); | 346 | fprintf(stderr, "pc6: %016llX\n", p->pc6); |
338 | fprintf(stderr, "pc7: %016llX\n", p->pc7); | 347 | fprintf(stderr, "pc7: %016llX\n", p->pc7); |
348 | fprintf(stderr, "pc8: %016llX\n", p->pc8); | ||
349 | fprintf(stderr, "pc9: %016llX\n", p->pc9); | ||
350 | fprintf(stderr, "pc10: %016llX\n", p->pc10); | ||
339 | fprintf(stderr, "Joules PKG: %0X\n", p->energy_pkg); | 351 | fprintf(stderr, "Joules PKG: %0X\n", p->energy_pkg); |
340 | fprintf(stderr, "Joules COR: %0X\n", p->energy_cores); | 352 | fprintf(stderr, "Joules COR: %0X\n", p->energy_cores); |
341 | fprintf(stderr, "Joules GFX: %0X\n", p->energy_gfx); | 353 | fprintf(stderr, "Joules GFX: %0X\n", p->energy_gfx); |
@@ -493,6 +505,11 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
493 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc); | 505 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc); |
494 | if (do_snb_cstates) | 506 | if (do_snb_cstates) |
495 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); | 507 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); |
508 | if (do_c8_c9_c10) { | ||
509 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc8/t->tsc); | ||
510 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc9/t->tsc); | ||
511 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc10/t->tsc); | ||
512 | } | ||
496 | 513 | ||
497 | /* | 514 | /* |
498 | * If measurement interval exceeds minimum RAPL Joule Counter range, | 515 | * If measurement interval exceeds minimum RAPL Joule Counter range, |
@@ -569,6 +586,9 @@ delta_package(struct pkg_data *new, struct pkg_data *old) | |||
569 | old->pc3 = new->pc3 - old->pc3; | 586 | old->pc3 = new->pc3 - old->pc3; |
570 | old->pc6 = new->pc6 - old->pc6; | 587 | old->pc6 = new->pc6 - old->pc6; |
571 | old->pc7 = new->pc7 - old->pc7; | 588 | old->pc7 = new->pc7 - old->pc7; |
589 | old->pc8 = new->pc8 - old->pc8; | ||
590 | old->pc9 = new->pc9 - old->pc9; | ||
591 | old->pc10 = new->pc10 - old->pc10; | ||
572 | old->pkg_temp_c = new->pkg_temp_c; | 592 | old->pkg_temp_c = new->pkg_temp_c; |
573 | 593 | ||
574 | DELTA_WRAP32(new->energy_pkg, old->energy_pkg); | 594 | DELTA_WRAP32(new->energy_pkg, old->energy_pkg); |
@@ -702,6 +722,9 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data | |||
702 | p->pc3 = 0; | 722 | p->pc3 = 0; |
703 | p->pc6 = 0; | 723 | p->pc6 = 0; |
704 | p->pc7 = 0; | 724 | p->pc7 = 0; |
725 | p->pc8 = 0; | ||
726 | p->pc9 = 0; | ||
727 | p->pc10 = 0; | ||
705 | 728 | ||
706 | p->energy_pkg = 0; | 729 | p->energy_pkg = 0; |
707 | p->energy_dram = 0; | 730 | p->energy_dram = 0; |
@@ -740,6 +763,9 @@ int sum_counters(struct thread_data *t, struct core_data *c, | |||
740 | average.packages.pc3 += p->pc3; | 763 | average.packages.pc3 += p->pc3; |
741 | average.packages.pc6 += p->pc6; | 764 | average.packages.pc6 += p->pc6; |
742 | average.packages.pc7 += p->pc7; | 765 | average.packages.pc7 += p->pc7; |
766 | average.packages.pc8 += p->pc8; | ||
767 | average.packages.pc9 += p->pc9; | ||
768 | average.packages.pc10 += p->pc10; | ||
743 | 769 | ||
744 | average.packages.energy_pkg += p->energy_pkg; | 770 | average.packages.energy_pkg += p->energy_pkg; |
745 | average.packages.energy_dram += p->energy_dram; | 771 | average.packages.energy_dram += p->energy_dram; |
@@ -781,6 +807,10 @@ void compute_average(struct thread_data *t, struct core_data *c, | |||
781 | average.packages.pc3 /= topo.num_packages; | 807 | average.packages.pc3 /= topo.num_packages; |
782 | average.packages.pc6 /= topo.num_packages; | 808 | average.packages.pc6 /= topo.num_packages; |
783 | average.packages.pc7 /= topo.num_packages; | 809 | average.packages.pc7 /= topo.num_packages; |
810 | |||
811 | average.packages.pc8 /= topo.num_packages; | ||
812 | average.packages.pc9 /= topo.num_packages; | ||
813 | average.packages.pc10 /= topo.num_packages; | ||
784 | } | 814 | } |
785 | 815 | ||
786 | static unsigned long long rdtsc(void) | 816 | static unsigned long long rdtsc(void) |
@@ -880,6 +910,14 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
880 | if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) | 910 | if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) |
881 | return -12; | 911 | return -12; |
882 | } | 912 | } |
913 | if (do_c8_c9_c10) { | ||
914 | if (get_msr(cpu, MSR_PKG_C8_RESIDENCY, &p->pc8)) | ||
915 | return -13; | ||
916 | if (get_msr(cpu, MSR_PKG_C9_RESIDENCY, &p->pc9)) | ||
917 | return -13; | ||
918 | if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10)) | ||
919 | return -13; | ||
920 | } | ||
883 | if (do_rapl & RAPL_PKG) { | 921 | if (do_rapl & RAPL_PKG) { |
884 | if (get_msr(cpu, MSR_PKG_ENERGY_STATUS, &msr)) | 922 | if (get_msr(cpu, MSR_PKG_ENERGY_STATUS, &msr)) |
885 | return -13; | 923 | return -13; |
@@ -1762,6 +1800,19 @@ int is_snb(unsigned int family, unsigned int model) | |||
1762 | return 0; | 1800 | return 0; |
1763 | } | 1801 | } |
1764 | 1802 | ||
1803 | int has_c8_c9_c10(unsigned int family, unsigned int model) | ||
1804 | { | ||
1805 | if (!genuine_intel) | ||
1806 | return 0; | ||
1807 | |||
1808 | switch (model) { | ||
1809 | case 0x45: | ||
1810 | return 1; | ||
1811 | } | ||
1812 | return 0; | ||
1813 | } | ||
1814 | |||
1815 | |||
1765 | double discover_bclk(unsigned int family, unsigned int model) | 1816 | double discover_bclk(unsigned int family, unsigned int model) |
1766 | { | 1817 | { |
1767 | if (is_snb(family, model)) | 1818 | if (is_snb(family, model)) |
@@ -1918,6 +1969,7 @@ void check_cpuid() | |||
1918 | do_nhm_cstates = genuine_intel; /* all Intel w/ non-stop TSC have NHM counters */ | 1969 | do_nhm_cstates = genuine_intel; /* all Intel w/ non-stop TSC have NHM counters */ |
1919 | do_smi = do_nhm_cstates; | 1970 | do_smi = do_nhm_cstates; |
1920 | do_snb_cstates = is_snb(family, model); | 1971 | do_snb_cstates = is_snb(family, model); |
1972 | do_c8_c9_c10 = has_c8_c9_c10(family, model); | ||
1921 | bclk = discover_bclk(family, model); | 1973 | bclk = discover_bclk(family, model); |
1922 | 1974 | ||
1923 | do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model); | 1975 | do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model); |
@@ -2279,7 +2331,7 @@ int main(int argc, char **argv) | |||
2279 | cmdline(argc, argv); | 2331 | cmdline(argc, argv); |
2280 | 2332 | ||
2281 | if (verbose) | 2333 | if (verbose) |
2282 | fprintf(stderr, "turbostat v3.3 March 15, 2013" | 2334 | fprintf(stderr, "turbostat v3.4 April 17, 2013" |
2283 | " - Len Brown <lenb@kernel.org>\n"); | 2335 | " - Len Brown <lenb@kernel.org>\n"); |
2284 | 2336 | ||
2285 | turbostat_init(); | 2337 | turbostat_init(); |
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index d4abc59ce1d9..0a63658065f0 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -6,7 +6,6 @@ TARGETS += memory-hotplug | |||
6 | TARGETS += mqueue | 6 | TARGETS += mqueue |
7 | TARGETS += net | 7 | TARGETS += net |
8 | TARGETS += ptrace | 8 | TARGETS += ptrace |
9 | TARGETS += soft-dirty | ||
10 | TARGETS += vm | 9 | TARGETS += vm |
11 | 10 | ||
12 | all: | 11 | all: |
diff --git a/tools/testing/selftests/soft-dirty/Makefile b/tools/testing/selftests/soft-dirty/Makefile deleted file mode 100644 index a9cdc823d6e0..000000000000 --- a/tools/testing/selftests/soft-dirty/Makefile +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | CFLAGS += -iquote../../../../include/uapi -Wall | ||
2 | soft-dirty: soft-dirty.c | ||
3 | |||
4 | all: soft-dirty | ||
5 | |||
6 | clean: | ||
7 | rm -f soft-dirty | ||
8 | |||
9 | run_tests: all | ||
10 | @./soft-dirty || echo "soft-dirty selftests: [FAIL]" | ||
diff --git a/tools/testing/selftests/soft-dirty/soft-dirty.c b/tools/testing/selftests/soft-dirty/soft-dirty.c deleted file mode 100644 index aba4f87f87f0..000000000000 --- a/tools/testing/selftests/soft-dirty/soft-dirty.c +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <stdio.h> | ||
3 | #include <sys/mman.h> | ||
4 | #include <unistd.h> | ||
5 | #include <fcntl.h> | ||
6 | #include <sys/types.h> | ||
7 | |||
8 | typedef unsigned long long u64; | ||
9 | |||
10 | #define PME_PRESENT (1ULL << 63) | ||
11 | #define PME_SOFT_DIRTY (1Ull << 55) | ||
12 | |||
13 | #define PAGES_TO_TEST 3 | ||
14 | #ifndef PAGE_SIZE | ||
15 | #define PAGE_SIZE 4096 | ||
16 | #endif | ||
17 | |||
18 | static void get_pagemap2(char *mem, u64 *map) | ||
19 | { | ||
20 | int fd; | ||
21 | |||
22 | fd = open("/proc/self/pagemap2", O_RDONLY); | ||
23 | if (fd < 0) { | ||
24 | perror("Can't open pagemap2"); | ||
25 | exit(1); | ||
26 | } | ||
27 | |||
28 | lseek(fd, (unsigned long)mem / PAGE_SIZE * sizeof(u64), SEEK_SET); | ||
29 | read(fd, map, sizeof(u64) * PAGES_TO_TEST); | ||
30 | close(fd); | ||
31 | } | ||
32 | |||
33 | static inline char map_p(u64 map) | ||
34 | { | ||
35 | return map & PME_PRESENT ? 'p' : '-'; | ||
36 | } | ||
37 | |||
38 | static inline char map_sd(u64 map) | ||
39 | { | ||
40 | return map & PME_SOFT_DIRTY ? 'd' : '-'; | ||
41 | } | ||
42 | |||
43 | static int check_pte(int step, int page, u64 *map, u64 want) | ||
44 | { | ||
45 | if ((map[page] & want) != want) { | ||
46 | printf("Step %d Page %d has %c%c, want %c%c\n", | ||
47 | step, page, | ||
48 | map_p(map[page]), map_sd(map[page]), | ||
49 | map_p(want), map_sd(want)); | ||
50 | return 1; | ||
51 | } | ||
52 | |||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | static void clear_refs(void) | ||
57 | { | ||
58 | int fd; | ||
59 | char *v = "4"; | ||
60 | |||
61 | fd = open("/proc/self/clear_refs", O_WRONLY); | ||
62 | if (write(fd, v, 3) < 3) { | ||
63 | perror("Can't clear soft-dirty bit"); | ||
64 | exit(1); | ||
65 | } | ||
66 | close(fd); | ||
67 | } | ||
68 | |||
69 | int main(void) | ||
70 | { | ||
71 | char *mem, x; | ||
72 | u64 map[PAGES_TO_TEST]; | ||
73 | |||
74 | mem = mmap(NULL, PAGES_TO_TEST * PAGE_SIZE, | ||
75 | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0); | ||
76 | |||
77 | x = mem[0]; | ||
78 | mem[2 * PAGE_SIZE] = 'c'; | ||
79 | get_pagemap2(mem, map); | ||
80 | |||
81 | if (check_pte(1, 0, map, PME_PRESENT)) | ||
82 | return 1; | ||
83 | if (check_pte(1, 1, map, 0)) | ||
84 | return 1; | ||
85 | if (check_pte(1, 2, map, PME_PRESENT | PME_SOFT_DIRTY)) | ||
86 | return 1; | ||
87 | |||
88 | clear_refs(); | ||
89 | get_pagemap2(mem, map); | ||
90 | |||
91 | if (check_pte(2, 0, map, PME_PRESENT)) | ||
92 | return 1; | ||
93 | if (check_pte(2, 1, map, 0)) | ||
94 | return 1; | ||
95 | if (check_pte(2, 2, map, PME_PRESENT)) | ||
96 | return 1; | ||
97 | |||
98 | mem[0] = 'a'; | ||
99 | mem[PAGE_SIZE] = 'b'; | ||
100 | x = mem[2 * PAGE_SIZE]; | ||
101 | get_pagemap2(mem, map); | ||
102 | |||
103 | if (check_pte(3, 0, map, PME_PRESENT | PME_SOFT_DIRTY)) | ||
104 | return 1; | ||
105 | if (check_pte(3, 1, map, PME_PRESENT | PME_SOFT_DIRTY)) | ||
106 | return 1; | ||
107 | if (check_pte(3, 2, map, PME_PRESENT)) | ||
108 | return 1; | ||
109 | |||
110 | (void)x; /* gcc warn */ | ||
111 | |||
112 | printf("PASS\n"); | ||
113 | return 0; | ||
114 | } | ||