diff options
| author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-02-26 15:34:42 -0500 |
|---|---|---|
| committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-02-26 15:34:42 -0500 |
| commit | 8e22e1b3499a446df48c2b26667ca36c55bf864c (patch) | |
| tree | 5329f98b3eb3c95a9dcbab0fa4f9b6e62f0e788d /tools | |
| parent | 00d3c14f14d51babd8aeafd5fa734ccf04f5ca3d (diff) | |
| parent | 64a577196d66b44e37384bc5c4d78c61f59d5b2a (diff) | |
Merge airlied/drm-next into drm-misc-next
Backmerge the main pull request to sync up with all the newly landed
drivers. Otherwise we'll have chaos even before 4.12 started in
earnest.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/objtool/arch/x86/decode.c | 2 | ||||
| -rw-r--r-- | tools/perf/builtin-diff.c | 2 | ||||
| -rw-r--r-- | tools/perf/ui/hist.c | 10 | ||||
| -rw-r--r-- | tools/perf/util/callchain.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/callchain.h | 6 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 7 | ||||
| -rw-r--r-- | tools/perf/util/hist.h | 7 | ||||
| -rw-r--r-- | tools/testing/selftests/bpf/test_lru_map.c | 53 |
8 files changed, 68 insertions, 30 deletions
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 5e0dea2cdc01..039636ffb6c8 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c | |||
| @@ -150,9 +150,9 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, | |||
| 150 | *type = INSN_RETURN; | 150 | *type = INSN_RETURN; |
| 151 | break; | 151 | break; |
| 152 | 152 | ||
| 153 | case 0xc5: /* iret */ | ||
| 154 | case 0xca: /* retf */ | 153 | case 0xca: /* retf */ |
| 155 | case 0xcb: /* retf */ | 154 | case 0xcb: /* retf */ |
| 155 | case 0xcf: /* iret */ | ||
| 156 | *type = INSN_CONTEXT_SWITCH; | 156 | *type = INSN_CONTEXT_SWITCH; |
| 157 | break; | 157 | break; |
| 158 | 158 | ||
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 9ff0db4e2d0c..933aeec46f4a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -1199,7 +1199,7 @@ static int ui_init(void) | |||
| 1199 | BUG_ON(1); | 1199 | BUG_ON(1); |
| 1200 | } | 1200 | } |
| 1201 | 1201 | ||
| 1202 | perf_hpp__register_sort_field(fmt); | 1202 | perf_hpp__prepend_sort_field(fmt); |
| 1203 | return 0; | 1203 | return 0; |
| 1204 | } | 1204 | } |
| 1205 | 1205 | ||
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 37388397b5bc..18cfcdc90356 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
| @@ -521,6 +521,12 @@ void perf_hpp_list__register_sort_field(struct perf_hpp_list *list, | |||
| 521 | list_add_tail(&format->sort_list, &list->sorts); | 521 | list_add_tail(&format->sort_list, &list->sorts); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list, | ||
| 525 | struct perf_hpp_fmt *format) | ||
| 526 | { | ||
| 527 | list_add(&format->sort_list, &list->sorts); | ||
| 528 | } | ||
| 529 | |||
| 524 | void perf_hpp__column_unregister(struct perf_hpp_fmt *format) | 530 | void perf_hpp__column_unregister(struct perf_hpp_fmt *format) |
| 525 | { | 531 | { |
| 526 | list_del(&format->list); | 532 | list_del(&format->list); |
| @@ -560,6 +566,10 @@ void perf_hpp__setup_output_field(struct perf_hpp_list *list) | |||
| 560 | perf_hpp_list__for_each_sort_list(list, fmt) { | 566 | perf_hpp_list__for_each_sort_list(list, fmt) { |
| 561 | struct perf_hpp_fmt *pos; | 567 | struct perf_hpp_fmt *pos; |
| 562 | 568 | ||
| 569 | /* skip sort-only fields ("sort_compute" in perf diff) */ | ||
| 570 | if (!fmt->entry && !fmt->color) | ||
| 571 | continue; | ||
| 572 | |||
| 563 | perf_hpp_list__for_each_format(list, pos) { | 573 | perf_hpp_list__for_each_format(list, pos) { |
| 564 | if (fmt_equal(fmt, pos)) | 574 | if (fmt_equal(fmt, pos)) |
| 565 | goto next; | 575 | goto next; |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 42922512c1c6..8b610dd9e2f6 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
| @@ -437,7 +437,7 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor) | |||
| 437 | } | 437 | } |
| 438 | call->ip = cursor_node->ip; | 438 | call->ip = cursor_node->ip; |
| 439 | call->ms.sym = cursor_node->sym; | 439 | call->ms.sym = cursor_node->sym; |
| 440 | call->ms.map = cursor_node->map; | 440 | call->ms.map = map__get(cursor_node->map); |
| 441 | 441 | ||
| 442 | if (cursor_node->branch) { | 442 | if (cursor_node->branch) { |
| 443 | call->branch_count = 1; | 443 | call->branch_count = 1; |
| @@ -477,6 +477,7 @@ add_child(struct callchain_node *parent, | |||
| 477 | 477 | ||
| 478 | list_for_each_entry_safe(call, tmp, &new->val, list) { | 478 | list_for_each_entry_safe(call, tmp, &new->val, list) { |
| 479 | list_del(&call->list); | 479 | list_del(&call->list); |
| 480 | map__zput(call->ms.map); | ||
| 480 | free(call); | 481 | free(call); |
| 481 | } | 482 | } |
| 482 | free(new); | 483 | free(new); |
| @@ -761,6 +762,7 @@ merge_chain_branch(struct callchain_cursor *cursor, | |||
| 761 | list->ms.map, list->ms.sym, | 762 | list->ms.map, list->ms.sym, |
| 762 | false, NULL, 0, 0); | 763 | false, NULL, 0, 0); |
| 763 | list_del(&list->list); | 764 | list_del(&list->list); |
| 765 | map__zput(list->ms.map); | ||
| 764 | free(list); | 766 | free(list); |
| 765 | } | 767 | } |
| 766 | 768 | ||
| @@ -811,7 +813,8 @@ int callchain_cursor_append(struct callchain_cursor *cursor, | |||
| 811 | } | 813 | } |
| 812 | 814 | ||
| 813 | node->ip = ip; | 815 | node->ip = ip; |
| 814 | node->map = map; | 816 | map__zput(node->map); |
| 817 | node->map = map__get(map); | ||
| 815 | node->sym = sym; | 818 | node->sym = sym; |
| 816 | node->branch = branch; | 819 | node->branch = branch; |
| 817 | node->nr_loop_iter = nr_loop_iter; | 820 | node->nr_loop_iter = nr_loop_iter; |
| @@ -1142,11 +1145,13 @@ static void free_callchain_node(struct callchain_node *node) | |||
| 1142 | 1145 | ||
| 1143 | list_for_each_entry_safe(list, tmp, &node->parent_val, list) { | 1146 | list_for_each_entry_safe(list, tmp, &node->parent_val, list) { |
| 1144 | list_del(&list->list); | 1147 | list_del(&list->list); |
| 1148 | map__zput(list->ms.map); | ||
| 1145 | free(list); | 1149 | free(list); |
| 1146 | } | 1150 | } |
| 1147 | 1151 | ||
| 1148 | list_for_each_entry_safe(list, tmp, &node->val, list) { | 1152 | list_for_each_entry_safe(list, tmp, &node->val, list) { |
| 1149 | list_del(&list->list); | 1153 | list_del(&list->list); |
| 1154 | map__zput(list->ms.map); | ||
| 1150 | free(list); | 1155 | free(list); |
| 1151 | } | 1156 | } |
| 1152 | 1157 | ||
| @@ -1210,6 +1215,7 @@ int callchain_node__make_parent_list(struct callchain_node *node) | |||
| 1210 | goto out; | 1215 | goto out; |
| 1211 | *new = *chain; | 1216 | *new = *chain; |
| 1212 | new->has_children = false; | 1217 | new->has_children = false; |
| 1218 | map__get(new->ms.map); | ||
| 1213 | list_add_tail(&new->list, &head); | 1219 | list_add_tail(&new->list, &head); |
| 1214 | } | 1220 | } |
| 1215 | parent = parent->parent; | 1221 | parent = parent->parent; |
| @@ -1230,6 +1236,7 @@ int callchain_node__make_parent_list(struct callchain_node *node) | |||
| 1230 | out: | 1236 | out: |
| 1231 | list_for_each_entry_safe(chain, new, &head, list) { | 1237 | list_for_each_entry_safe(chain, new, &head, list) { |
| 1232 | list_del(&chain->list); | 1238 | list_del(&chain->list); |
| 1239 | map__zput(chain->ms.map); | ||
| 1233 | free(chain); | 1240 | free(chain); |
| 1234 | } | 1241 | } |
| 1235 | return -ENOMEM; | 1242 | return -ENOMEM; |
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 35c8e379530f..4f4b60f1558a 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <linux/list.h> | 5 | #include <linux/list.h> |
| 6 | #include <linux/rbtree.h> | 6 | #include <linux/rbtree.h> |
| 7 | #include "event.h" | 7 | #include "event.h" |
| 8 | #include "map.h" | ||
| 8 | #include "symbol.h" | 9 | #include "symbol.h" |
| 9 | 10 | ||
| 10 | #define HELP_PAD "\t\t\t\t" | 11 | #define HELP_PAD "\t\t\t\t" |
| @@ -184,8 +185,13 @@ int callchain_merge(struct callchain_cursor *cursor, | |||
| 184 | */ | 185 | */ |
| 185 | static inline void callchain_cursor_reset(struct callchain_cursor *cursor) | 186 | static inline void callchain_cursor_reset(struct callchain_cursor *cursor) |
| 186 | { | 187 | { |
| 188 | struct callchain_cursor_node *node; | ||
| 189 | |||
| 187 | cursor->nr = 0; | 190 | cursor->nr = 0; |
| 188 | cursor->last = &cursor->first; | 191 | cursor->last = &cursor->first; |
| 192 | |||
| 193 | for (node = cursor->first; node != NULL; node = node->next) | ||
| 194 | map__zput(node->map); | ||
| 189 | } | 195 | } |
| 190 | 196 | ||
| 191 | int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, | 197 | int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 6770a9645609..7d1b7d33e644 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "util.h" | 1 | #include "util.h" |
| 2 | #include "build-id.h" | 2 | #include "build-id.h" |
| 3 | #include "hist.h" | 3 | #include "hist.h" |
| 4 | #include "map.h" | ||
| 4 | #include "session.h" | 5 | #include "session.h" |
| 5 | #include "sort.h" | 6 | #include "sort.h" |
| 6 | #include "evlist.h" | 7 | #include "evlist.h" |
| @@ -1019,6 +1020,10 @@ int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, | |||
| 1019 | int max_stack_depth, void *arg) | 1020 | int max_stack_depth, void *arg) |
| 1020 | { | 1021 | { |
| 1021 | int err, err2; | 1022 | int err, err2; |
| 1023 | struct map *alm = NULL; | ||
| 1024 | |||
| 1025 | if (al && al->map) | ||
| 1026 | alm = map__get(al->map); | ||
| 1022 | 1027 | ||
| 1023 | err = sample__resolve_callchain(iter->sample, &callchain_cursor, &iter->parent, | 1028 | err = sample__resolve_callchain(iter->sample, &callchain_cursor, &iter->parent, |
| 1024 | iter->evsel, al, max_stack_depth); | 1029 | iter->evsel, al, max_stack_depth); |
| @@ -1058,6 +1063,8 @@ out: | |||
| 1058 | if (!err) | 1063 | if (!err) |
| 1059 | err = err2; | 1064 | err = err2; |
| 1060 | 1065 | ||
| 1066 | map__put(alm); | ||
| 1067 | |||
| 1061 | return err; | 1068 | return err; |
| 1062 | } | 1069 | } |
| 1063 | 1070 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index d4b6514eeef5..28c216e3d5b7 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
| @@ -283,6 +283,8 @@ void perf_hpp_list__column_register(struct perf_hpp_list *list, | |||
| 283 | struct perf_hpp_fmt *format); | 283 | struct perf_hpp_fmt *format); |
| 284 | void perf_hpp_list__register_sort_field(struct perf_hpp_list *list, | 284 | void perf_hpp_list__register_sort_field(struct perf_hpp_list *list, |
| 285 | struct perf_hpp_fmt *format); | 285 | struct perf_hpp_fmt *format); |
| 286 | void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list, | ||
| 287 | struct perf_hpp_fmt *format); | ||
| 286 | 288 | ||
| 287 | static inline void perf_hpp__column_register(struct perf_hpp_fmt *format) | 289 | static inline void perf_hpp__column_register(struct perf_hpp_fmt *format) |
| 288 | { | 290 | { |
| @@ -294,6 +296,11 @@ static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format) | |||
| 294 | perf_hpp_list__register_sort_field(&perf_hpp_list, format); | 296 | perf_hpp_list__register_sort_field(&perf_hpp_list, format); |
| 295 | } | 297 | } |
| 296 | 298 | ||
| 299 | static inline void perf_hpp__prepend_sort_field(struct perf_hpp_fmt *format) | ||
| 300 | { | ||
| 301 | perf_hpp_list__prepend_sort_field(&perf_hpp_list, format); | ||
| 302 | } | ||
| 303 | |||
| 297 | #define perf_hpp_list__for_each_format(_list, format) \ | 304 | #define perf_hpp_list__for_each_format(_list, format) \ |
| 298 | list_for_each_entry(format, &(_list)->fields, list) | 305 | list_for_each_entry(format, &(_list)->fields, list) |
| 299 | 306 | ||
diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c index b13fed534d76..9f7bd1915c21 100644 --- a/tools/testing/selftests/bpf/test_lru_map.c +++ b/tools/testing/selftests/bpf/test_lru_map.c | |||
| @@ -67,21 +67,23 @@ static int map_equal(int lru_map, int expected) | |||
| 67 | return map_subset(lru_map, expected) && map_subset(expected, lru_map); | 67 | return map_subset(lru_map, expected) && map_subset(expected, lru_map); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static int sched_next_online(int pid, int next_to_try) | 70 | static int sched_next_online(int pid, int *next_to_try) |
| 71 | { | 71 | { |
| 72 | cpu_set_t cpuset; | 72 | cpu_set_t cpuset; |
| 73 | int next = *next_to_try; | ||
| 74 | int ret = -1; | ||
| 73 | 75 | ||
| 74 | if (next_to_try == nr_cpus) | 76 | while (next < nr_cpus) { |
| 75 | return -1; | ||
| 76 | |||
| 77 | while (next_to_try < nr_cpus) { | ||
| 78 | CPU_ZERO(&cpuset); | 77 | CPU_ZERO(&cpuset); |
| 79 | CPU_SET(next_to_try++, &cpuset); | 78 | CPU_SET(next++, &cpuset); |
| 80 | if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) | 79 | if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) { |
| 80 | ret = 0; | ||
| 81 | break; | 81 | break; |
| 82 | } | ||
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | return next_to_try; | 85 | *next_to_try = next; |
| 86 | return ret; | ||
| 85 | } | 87 | } |
| 86 | 88 | ||
| 87 | /* Size of the LRU amp is 2 | 89 | /* Size of the LRU amp is 2 |
| @@ -96,11 +98,12 @@ static void test_lru_sanity0(int map_type, int map_flags) | |||
| 96 | { | 98 | { |
| 97 | unsigned long long key, value[nr_cpus]; | 99 | unsigned long long key, value[nr_cpus]; |
| 98 | int lru_map_fd, expected_map_fd; | 100 | int lru_map_fd, expected_map_fd; |
| 101 | int next_cpu = 0; | ||
| 99 | 102 | ||
| 100 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, | 103 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, |
| 101 | map_flags); | 104 | map_flags); |
| 102 | 105 | ||
| 103 | assert(sched_next_online(0, 0) != -1); | 106 | assert(sched_next_online(0, &next_cpu) != -1); |
| 104 | 107 | ||
| 105 | if (map_flags & BPF_F_NO_COMMON_LRU) | 108 | if (map_flags & BPF_F_NO_COMMON_LRU) |
| 106 | lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus); | 109 | lru_map_fd = create_map(map_type, map_flags, 2 * nr_cpus); |
| @@ -183,6 +186,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free) | |||
| 183 | int lru_map_fd, expected_map_fd; | 186 | int lru_map_fd, expected_map_fd; |
| 184 | unsigned int batch_size; | 187 | unsigned int batch_size; |
| 185 | unsigned int map_size; | 188 | unsigned int map_size; |
| 189 | int next_cpu = 0; | ||
| 186 | 190 | ||
| 187 | if (map_flags & BPF_F_NO_COMMON_LRU) | 191 | if (map_flags & BPF_F_NO_COMMON_LRU) |
| 188 | /* Ther percpu lru list (i.e each cpu has its own LRU | 192 | /* Ther percpu lru list (i.e each cpu has its own LRU |
| @@ -196,7 +200,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free) | |||
| 196 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, | 200 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, |
| 197 | map_flags); | 201 | map_flags); |
| 198 | 202 | ||
| 199 | assert(sched_next_online(0, 0) != -1); | 203 | assert(sched_next_online(0, &next_cpu) != -1); |
| 200 | 204 | ||
| 201 | batch_size = tgt_free / 2; | 205 | batch_size = tgt_free / 2; |
| 202 | assert(batch_size * 2 == tgt_free); | 206 | assert(batch_size * 2 == tgt_free); |
| @@ -262,6 +266,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free) | |||
| 262 | int lru_map_fd, expected_map_fd; | 266 | int lru_map_fd, expected_map_fd; |
| 263 | unsigned int batch_size; | 267 | unsigned int batch_size; |
| 264 | unsigned int map_size; | 268 | unsigned int map_size; |
| 269 | int next_cpu = 0; | ||
| 265 | 270 | ||
| 266 | if (map_flags & BPF_F_NO_COMMON_LRU) | 271 | if (map_flags & BPF_F_NO_COMMON_LRU) |
| 267 | /* Ther percpu lru list (i.e each cpu has its own LRU | 272 | /* Ther percpu lru list (i.e each cpu has its own LRU |
| @@ -275,7 +280,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free) | |||
| 275 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, | 280 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, |
| 276 | map_flags); | 281 | map_flags); |
| 277 | 282 | ||
| 278 | assert(sched_next_online(0, 0) != -1); | 283 | assert(sched_next_online(0, &next_cpu) != -1); |
| 279 | 284 | ||
| 280 | batch_size = tgt_free / 2; | 285 | batch_size = tgt_free / 2; |
| 281 | assert(batch_size * 2 == tgt_free); | 286 | assert(batch_size * 2 == tgt_free); |
| @@ -370,11 +375,12 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free) | |||
| 370 | int lru_map_fd, expected_map_fd; | 375 | int lru_map_fd, expected_map_fd; |
| 371 | unsigned int batch_size; | 376 | unsigned int batch_size; |
| 372 | unsigned int map_size; | 377 | unsigned int map_size; |
| 378 | int next_cpu = 0; | ||
| 373 | 379 | ||
| 374 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, | 380 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, |
| 375 | map_flags); | 381 | map_flags); |
| 376 | 382 | ||
| 377 | assert(sched_next_online(0, 0) != -1); | 383 | assert(sched_next_online(0, &next_cpu) != -1); |
| 378 | 384 | ||
| 379 | batch_size = tgt_free / 2; | 385 | batch_size = tgt_free / 2; |
| 380 | assert(batch_size * 2 == tgt_free); | 386 | assert(batch_size * 2 == tgt_free); |
| @@ -430,11 +436,12 @@ static void test_lru_sanity4(int map_type, int map_flags, unsigned int tgt_free) | |||
| 430 | int lru_map_fd, expected_map_fd; | 436 | int lru_map_fd, expected_map_fd; |
| 431 | unsigned long long key, value[nr_cpus]; | 437 | unsigned long long key, value[nr_cpus]; |
| 432 | unsigned long long end_key; | 438 | unsigned long long end_key; |
| 439 | int next_cpu = 0; | ||
| 433 | 440 | ||
| 434 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, | 441 | printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type, |
| 435 | map_flags); | 442 | map_flags); |
| 436 | 443 | ||
| 437 | assert(sched_next_online(0, 0) != -1); | 444 | assert(sched_next_online(0, &next_cpu) != -1); |
| 438 | 445 | ||
| 439 | if (map_flags & BPF_F_NO_COMMON_LRU) | 446 | if (map_flags & BPF_F_NO_COMMON_LRU) |
| 440 | lru_map_fd = create_map(map_type, map_flags, | 447 | lru_map_fd = create_map(map_type, map_flags, |
| @@ -502,9 +509,8 @@ static void do_test_lru_sanity5(unsigned long long last_key, int map_fd) | |||
| 502 | static void test_lru_sanity5(int map_type, int map_flags) | 509 | static void test_lru_sanity5(int map_type, int map_flags) |
| 503 | { | 510 | { |
| 504 | unsigned long long key, value[nr_cpus]; | 511 | unsigned long long key, value[nr_cpus]; |
| 505 | int next_sched_cpu = 0; | 512 | int next_cpu = 0; |
| 506 | int map_fd; | 513 | int map_fd; |
| 507 | int i; | ||
| 508 | 514 | ||
| 509 | if (map_flags & BPF_F_NO_COMMON_LRU) | 515 | if (map_flags & BPF_F_NO_COMMON_LRU) |
| 510 | return; | 516 | return; |
| @@ -519,27 +525,20 @@ static void test_lru_sanity5(int map_type, int map_flags) | |||
| 519 | key = 0; | 525 | key = 0; |
| 520 | assert(!bpf_map_update(map_fd, &key, value, BPF_NOEXIST)); | 526 | assert(!bpf_map_update(map_fd, &key, value, BPF_NOEXIST)); |
| 521 | 527 | ||
| 522 | for (i = 0; i < nr_cpus; i++) { | 528 | while (sched_next_online(0, &next_cpu) != -1) { |
| 523 | pid_t pid; | 529 | pid_t pid; |
| 524 | 530 | ||
| 525 | pid = fork(); | 531 | pid = fork(); |
| 526 | if (pid == 0) { | 532 | if (pid == 0) { |
| 527 | next_sched_cpu = sched_next_online(0, next_sched_cpu); | 533 | do_test_lru_sanity5(key, map_fd); |
| 528 | if (next_sched_cpu != -1) | ||
| 529 | do_test_lru_sanity5(key, map_fd); | ||
| 530 | exit(0); | 534 | exit(0); |
| 531 | } else if (pid == -1) { | 535 | } else if (pid == -1) { |
| 532 | printf("couldn't spawn #%d process\n", i); | 536 | printf("couldn't spawn process to test key:%llu\n", |
| 537 | key); | ||
| 533 | exit(1); | 538 | exit(1); |
| 534 | } else { | 539 | } else { |
| 535 | int status; | 540 | int status; |
| 536 | 541 | ||
| 537 | /* It is mostly redundant and just allow the parent | ||
| 538 | * process to update next_shced_cpu for the next child | ||
| 539 | * process | ||
| 540 | */ | ||
| 541 | next_sched_cpu = sched_next_online(pid, next_sched_cpu); | ||
| 542 | |||
| 543 | assert(waitpid(pid, &status, 0) == pid); | 542 | assert(waitpid(pid, &status, 0) == pid); |
| 544 | assert(status == 0); | 543 | assert(status == 0); |
| 545 | key++; | 544 | key++; |
| @@ -547,6 +546,8 @@ static void test_lru_sanity5(int map_type, int map_flags) | |||
| 547 | } | 546 | } |
| 548 | 547 | ||
| 549 | close(map_fd); | 548 | close(map_fd); |
| 549 | /* At least one key should be tested */ | ||
| 550 | assert(key > 0); | ||
| 550 | 551 | ||
| 551 | printf("Pass\n"); | 552 | printf("Pass\n"); |
| 552 | } | 553 | } |
