diff options
author | Yonghong Song <yhs@fb.com> | 2018-12-10 17:14:10 -0500 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-12-10 17:51:45 -0500 |
commit | cfc542411bd40ff4f8a70b3d061bd6acdfb05629 (patch) | |
tree | 5821df7fea9335a55010c21dcfba92e704c92d32 | |
parent | b4f8623c0cefdfb818f99b3eb3c1e4c7708dd84e (diff) |
tools/bpf: rename *_info_cnt to nr_*_info
Rename all occurances of *_info_cnt field access
to nr_*_info in tools directory.
The local variables finfo_cnt, linfo_cnt and jited_linfo_cnt
in function do_dump() of tools/bpf/bpftool/prog.c are also
changed to nr_finfo, nr_linfo and nr_jited_linfo to
keep naming convention consistent.
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | tools/bpf/bpftool/prog.c | 48 | ||||
-rw-r--r-- | tools/lib/bpf/bpf_prog_linfo.c | 4 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/test_btf.c | 60 |
3 files changed, 56 insertions, 56 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 9a78ebbcea1d..b73b4e473948 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -425,7 +425,7 @@ static int do_dump(int argc, char **argv) | |||
425 | { | 425 | { |
426 | unsigned int finfo_rec_size, linfo_rec_size, jited_linfo_rec_size; | 426 | unsigned int finfo_rec_size, linfo_rec_size, jited_linfo_rec_size; |
427 | void *func_info = NULL, *linfo = NULL, *jited_linfo = NULL; | 427 | void *func_info = NULL, *linfo = NULL, *jited_linfo = NULL; |
428 | unsigned int finfo_cnt, linfo_cnt = 0, jited_linfo_cnt = 0; | 428 | unsigned int nr_finfo, nr_linfo = 0, nr_jited_linfo = 0; |
429 | struct bpf_prog_linfo *prog_linfo = NULL; | 429 | struct bpf_prog_linfo *prog_linfo = NULL; |
430 | unsigned long *func_ksyms = NULL; | 430 | unsigned long *func_ksyms = NULL; |
431 | struct bpf_prog_info info = {}; | 431 | struct bpf_prog_info info = {}; |
@@ -537,10 +537,10 @@ static int do_dump(int argc, char **argv) | |||
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | finfo_cnt = info.func_info_cnt; | 540 | nr_finfo = info.nr_func_info; |
541 | finfo_rec_size = info.func_info_rec_size; | 541 | finfo_rec_size = info.func_info_rec_size; |
542 | if (finfo_cnt && finfo_rec_size) { | 542 | if (nr_finfo && finfo_rec_size) { |
543 | func_info = malloc(finfo_cnt * finfo_rec_size); | 543 | func_info = malloc(nr_finfo * finfo_rec_size); |
544 | if (!func_info) { | 544 | if (!func_info) { |
545 | p_err("mem alloc failed"); | 545 | p_err("mem alloc failed"); |
546 | close(fd); | 546 | close(fd); |
@@ -549,9 +549,9 @@ static int do_dump(int argc, char **argv) | |||
549 | } | 549 | } |
550 | 550 | ||
551 | linfo_rec_size = info.line_info_rec_size; | 551 | linfo_rec_size = info.line_info_rec_size; |
552 | if (info.line_info_cnt && linfo_rec_size && info.btf_id) { | 552 | if (info.nr_line_info && linfo_rec_size && info.btf_id) { |
553 | linfo_cnt = info.line_info_cnt; | 553 | nr_linfo = info.nr_line_info; |
554 | linfo = malloc(linfo_cnt * linfo_rec_size); | 554 | linfo = malloc(nr_linfo * linfo_rec_size); |
555 | if (!linfo) { | 555 | if (!linfo) { |
556 | p_err("mem alloc failed"); | 556 | p_err("mem alloc failed"); |
557 | close(fd); | 557 | close(fd); |
@@ -560,13 +560,13 @@ static int do_dump(int argc, char **argv) | |||
560 | } | 560 | } |
561 | 561 | ||
562 | jited_linfo_rec_size = info.jited_line_info_rec_size; | 562 | jited_linfo_rec_size = info.jited_line_info_rec_size; |
563 | if (info.jited_line_info_cnt && | 563 | if (info.nr_jited_line_info && |
564 | jited_linfo_rec_size && | 564 | jited_linfo_rec_size && |
565 | info.nr_jited_ksyms && | 565 | info.nr_jited_ksyms && |
566 | info.nr_jited_func_lens && | 566 | info.nr_jited_func_lens && |
567 | info.btf_id) { | 567 | info.btf_id) { |
568 | jited_linfo_cnt = info.jited_line_info_cnt; | 568 | nr_jited_linfo = info.nr_jited_line_info; |
569 | jited_linfo = malloc(jited_linfo_cnt * jited_linfo_rec_size); | 569 | jited_linfo = malloc(nr_jited_linfo * jited_linfo_rec_size); |
570 | if (!jited_linfo) { | 570 | if (!jited_linfo) { |
571 | p_err("mem alloc failed"); | 571 | p_err("mem alloc failed"); |
572 | close(fd); | 572 | close(fd); |
@@ -582,13 +582,13 @@ static int do_dump(int argc, char **argv) | |||
582 | info.nr_jited_ksyms = nr_func_ksyms; | 582 | info.nr_jited_ksyms = nr_func_ksyms; |
583 | info.jited_func_lens = ptr_to_u64(func_lens); | 583 | info.jited_func_lens = ptr_to_u64(func_lens); |
584 | info.nr_jited_func_lens = nr_func_lens; | 584 | info.nr_jited_func_lens = nr_func_lens; |
585 | info.func_info_cnt = finfo_cnt; | 585 | info.nr_func_info = nr_finfo; |
586 | info.func_info_rec_size = finfo_rec_size; | 586 | info.func_info_rec_size = finfo_rec_size; |
587 | info.func_info = ptr_to_u64(func_info); | 587 | info.func_info = ptr_to_u64(func_info); |
588 | info.line_info_cnt = linfo_cnt; | 588 | info.nr_line_info = nr_linfo; |
589 | info.line_info_rec_size = linfo_rec_size; | 589 | info.line_info_rec_size = linfo_rec_size; |
590 | info.line_info = ptr_to_u64(linfo); | 590 | info.line_info = ptr_to_u64(linfo); |
591 | info.jited_line_info_cnt = jited_linfo_cnt; | 591 | info.nr_jited_line_info = nr_jited_linfo; |
592 | info.jited_line_info_rec_size = jited_linfo_rec_size; | 592 | info.jited_line_info_rec_size = jited_linfo_rec_size; |
593 | info.jited_line_info = ptr_to_u64(jited_linfo); | 593 | info.jited_line_info = ptr_to_u64(jited_linfo); |
594 | 594 | ||
@@ -614,9 +614,9 @@ static int do_dump(int argc, char **argv) | |||
614 | goto err_free; | 614 | goto err_free; |
615 | } | 615 | } |
616 | 616 | ||
617 | if (info.func_info_cnt != finfo_cnt) { | 617 | if (info.nr_func_info != nr_finfo) { |
618 | p_err("incorrect func_info_cnt %d vs. expected %d", | 618 | p_err("incorrect nr_func_info %d vs. expected %d", |
619 | info.func_info_cnt, finfo_cnt); | 619 | info.nr_func_info, nr_finfo); |
620 | goto err_free; | 620 | goto err_free; |
621 | } | 621 | } |
622 | 622 | ||
@@ -630,12 +630,12 @@ static int do_dump(int argc, char **argv) | |||
630 | /* kernel.kptr_restrict is set. No func_info available. */ | 630 | /* kernel.kptr_restrict is set. No func_info available. */ |
631 | free(func_info); | 631 | free(func_info); |
632 | func_info = NULL; | 632 | func_info = NULL; |
633 | finfo_cnt = 0; | 633 | nr_finfo = 0; |
634 | } | 634 | } |
635 | 635 | ||
636 | if (linfo && info.line_info_cnt != linfo_cnt) { | 636 | if (linfo && info.nr_line_info != nr_linfo) { |
637 | p_err("incorrect line_info_cnt %u vs. expected %u", | 637 | p_err("incorrect nr_line_info %u vs. expected %u", |
638 | info.line_info_cnt, linfo_cnt); | 638 | info.nr_line_info, nr_linfo); |
639 | goto err_free; | 639 | goto err_free; |
640 | } | 640 | } |
641 | 641 | ||
@@ -645,9 +645,9 @@ static int do_dump(int argc, char **argv) | |||
645 | goto err_free; | 645 | goto err_free; |
646 | } | 646 | } |
647 | 647 | ||
648 | if (jited_linfo && info.jited_line_info_cnt != jited_linfo_cnt) { | 648 | if (jited_linfo && info.nr_jited_line_info != nr_jited_linfo) { |
649 | p_err("incorrect jited_line_info_cnt %u vs. expected %u", | 649 | p_err("incorrect nr_jited_line_info %u vs. expected %u", |
650 | info.jited_line_info_cnt, jited_linfo_cnt); | 650 | info.nr_jited_line_info, nr_jited_linfo); |
651 | goto err_free; | 651 | goto err_free; |
652 | } | 652 | } |
653 | 653 | ||
@@ -670,7 +670,7 @@ static int do_dump(int argc, char **argv) | |||
670 | goto err_free; | 670 | goto err_free; |
671 | } | 671 | } |
672 | 672 | ||
673 | if (linfo_cnt) { | 673 | if (nr_linfo) { |
674 | prog_linfo = bpf_prog_linfo__new(&info); | 674 | prog_linfo = bpf_prog_linfo__new(&info); |
675 | if (!prog_linfo) | 675 | if (!prog_linfo) |
676 | p_info("error in processing bpf_line_info. continue without it."); | 676 | p_info("error in processing bpf_line_info. continue without it."); |
diff --git a/tools/lib/bpf/bpf_prog_linfo.c b/tools/lib/bpf/bpf_prog_linfo.c index b8af65145408..addd6e9971cc 100644 --- a/tools/lib/bpf/bpf_prog_linfo.c +++ b/tools/lib/bpf/bpf_prog_linfo.c | |||
@@ -105,7 +105,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info) | |||
105 | struct bpf_prog_linfo *prog_linfo; | 105 | struct bpf_prog_linfo *prog_linfo; |
106 | __u32 nr_linfo, nr_jited_func; | 106 | __u32 nr_linfo, nr_jited_func; |
107 | 107 | ||
108 | nr_linfo = info->line_info_cnt; | 108 | nr_linfo = info->nr_line_info; |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * Test !info->line_info because the kernel may NULL | 111 | * Test !info->line_info because the kernel may NULL |
@@ -138,7 +138,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info) | |||
138 | nr_jited_func = info->nr_jited_ksyms; | 138 | nr_jited_func = info->nr_jited_ksyms; |
139 | if (!nr_jited_func || | 139 | if (!nr_jited_func || |
140 | !info->jited_line_info || | 140 | !info->jited_line_info || |
141 | info->jited_line_info_cnt != nr_linfo || | 141 | info->nr_jited_line_info != nr_linfo || |
142 | info->jited_line_info_rec_size < sizeof(__u64) || | 142 | info->jited_line_info_rec_size < sizeof(__u64) || |
143 | info->nr_jited_func_lens != nr_jited_func || | 143 | info->nr_jited_func_lens != nr_jited_func || |
144 | !info->jited_ksyms || | 144 | !info->jited_ksyms || |
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index 7707273736ac..d4c63316c862 100644 --- a/tools/testing/selftests/bpf/test_btf.c +++ b/tools/testing/selftests/bpf/test_btf.c | |||
@@ -2548,9 +2548,9 @@ static int do_test_file(unsigned int test_num) | |||
2548 | err = -1; | 2548 | err = -1; |
2549 | goto done; | 2549 | goto done; |
2550 | } | 2550 | } |
2551 | if (CHECK(info.func_info_cnt != 3, | 2551 | if (CHECK(info.nr_func_info != 3, |
2552 | "incorrect info.func_info_cnt (1st) %d", | 2552 | "incorrect info.nr_func_info (1st) %d", |
2553 | info.func_info_cnt)) { | 2553 | info.nr_func_info)) { |
2554 | err = -1; | 2554 | err = -1; |
2555 | goto done; | 2555 | goto done; |
2556 | } | 2556 | } |
@@ -2561,7 +2561,7 @@ static int do_test_file(unsigned int test_num) | |||
2561 | goto done; | 2561 | goto done; |
2562 | } | 2562 | } |
2563 | 2563 | ||
2564 | func_info = malloc(info.func_info_cnt * rec_size); | 2564 | func_info = malloc(info.nr_func_info * rec_size); |
2565 | if (CHECK(!func_info, "out of memory")) { | 2565 | if (CHECK(!func_info, "out of memory")) { |
2566 | err = -1; | 2566 | err = -1; |
2567 | goto done; | 2567 | goto done; |
@@ -2569,7 +2569,7 @@ static int do_test_file(unsigned int test_num) | |||
2569 | 2569 | ||
2570 | /* reset info to only retrieve func_info related data */ | 2570 | /* reset info to only retrieve func_info related data */ |
2571 | memset(&info, 0, sizeof(info)); | 2571 | memset(&info, 0, sizeof(info)); |
2572 | info.func_info_cnt = 3; | 2572 | info.nr_func_info = 3; |
2573 | info.func_info_rec_size = rec_size; | 2573 | info.func_info_rec_size = rec_size; |
2574 | info.func_info = ptr_to_u64(func_info); | 2574 | info.func_info = ptr_to_u64(func_info); |
2575 | 2575 | ||
@@ -2580,9 +2580,9 @@ static int do_test_file(unsigned int test_num) | |||
2580 | err = -1; | 2580 | err = -1; |
2581 | goto done; | 2581 | goto done; |
2582 | } | 2582 | } |
2583 | if (CHECK(info.func_info_cnt != 3, | 2583 | if (CHECK(info.nr_func_info != 3, |
2584 | "incorrect info.func_info_cnt (2nd) %d", | 2584 | "incorrect info.nr_func_info (2nd) %d", |
2585 | info.func_info_cnt)) { | 2585 | info.nr_func_info)) { |
2586 | err = -1; | 2586 | err = -1; |
2587 | goto done; | 2587 | goto done; |
2588 | } | 2588 | } |
@@ -3544,9 +3544,9 @@ static int test_get_finfo(const struct prog_info_raw_test *test, | |||
3544 | fprintf(stderr, "%s\n", btf_log_buf); | 3544 | fprintf(stderr, "%s\n", btf_log_buf); |
3545 | return -1; | 3545 | return -1; |
3546 | } | 3546 | } |
3547 | if (CHECK(info.func_info_cnt != test->func_info_cnt, | 3547 | if (CHECK(info.nr_func_info != test->func_info_cnt, |
3548 | "incorrect info.func_info_cnt (1st) %d", | 3548 | "incorrect info.nr_func_info (1st) %d", |
3549 | info.func_info_cnt)) { | 3549 | info.nr_func_info)) { |
3550 | return -1; | 3550 | return -1; |
3551 | } | 3551 | } |
3552 | 3552 | ||
@@ -3556,16 +3556,16 @@ static int test_get_finfo(const struct prog_info_raw_test *test, | |||
3556 | return -1; | 3556 | return -1; |
3557 | } | 3557 | } |
3558 | 3558 | ||
3559 | if (!info.func_info_cnt) | 3559 | if (!info.nr_func_info) |
3560 | return 0; | 3560 | return 0; |
3561 | 3561 | ||
3562 | func_info = malloc(info.func_info_cnt * rec_size); | 3562 | func_info = malloc(info.nr_func_info * rec_size); |
3563 | if (CHECK(!func_info, "out of memory")) | 3563 | if (CHECK(!func_info, "out of memory")) |
3564 | return -1; | 3564 | return -1; |
3565 | 3565 | ||
3566 | /* reset info to only retrieve func_info related data */ | 3566 | /* reset info to only retrieve func_info related data */ |
3567 | memset(&info, 0, sizeof(info)); | 3567 | memset(&info, 0, sizeof(info)); |
3568 | info.func_info_cnt = test->func_info_cnt; | 3568 | info.nr_func_info = test->func_info_cnt; |
3569 | info.func_info_rec_size = rec_size; | 3569 | info.func_info_rec_size = rec_size; |
3570 | info.func_info = ptr_to_u64(func_info); | 3570 | info.func_info = ptr_to_u64(func_info); |
3571 | err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); | 3571 | err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); |
@@ -3574,9 +3574,9 @@ static int test_get_finfo(const struct prog_info_raw_test *test, | |||
3574 | err = -1; | 3574 | err = -1; |
3575 | goto done; | 3575 | goto done; |
3576 | } | 3576 | } |
3577 | if (CHECK(info.func_info_cnt != test->func_info_cnt, | 3577 | if (CHECK(info.nr_func_info != test->func_info_cnt, |
3578 | "incorrect info.func_info_cnt (2nd) %d", | 3578 | "incorrect info.nr_func_info (2nd) %d", |
3579 | info.func_info_cnt)) { | 3579 | info.nr_func_info)) { |
3580 | err = -1; | 3580 | err = -1; |
3581 | goto done; | 3581 | goto done; |
3582 | } | 3582 | } |
@@ -3648,14 +3648,14 @@ static int test_get_linfo(const struct prog_info_raw_test *test, | |||
3648 | nr_jited_func_lens = 1; | 3648 | nr_jited_func_lens = 1; |
3649 | } | 3649 | } |
3650 | 3650 | ||
3651 | if (CHECK(info.line_info_cnt != cnt || | 3651 | if (CHECK(info.nr_line_info != cnt || |
3652 | info.jited_line_info_cnt != jited_cnt || | 3652 | info.nr_jited_line_info != jited_cnt || |
3653 | info.nr_jited_ksyms != nr_jited_ksyms || | 3653 | info.nr_jited_ksyms != nr_jited_ksyms || |
3654 | info.nr_jited_func_lens != nr_jited_func_lens || | 3654 | info.nr_jited_func_lens != nr_jited_func_lens || |
3655 | (!info.line_info_cnt && info.jited_line_info_cnt), | 3655 | (!info.nr_line_info && info.nr_jited_line_info), |
3656 | "info: line_info_cnt:%u(expected:%u) jited_line_info_cnt:%u(expected:%u) nr_jited_ksyms:%u(expected:%u) nr_jited_func_lens:%u(expected:%u)", | 3656 | "info: nr_line_info:%u(expected:%u) nr_jited_line_info:%u(expected:%u) nr_jited_ksyms:%u(expected:%u) nr_jited_func_lens:%u(expected:%u)", |
3657 | info.line_info_cnt, cnt, | 3657 | info.nr_line_info, cnt, |
3658 | info.jited_line_info_cnt, jited_cnt, | 3658 | info.nr_jited_line_info, jited_cnt, |
3659 | info.nr_jited_ksyms, nr_jited_ksyms, | 3659 | info.nr_jited_ksyms, nr_jited_ksyms, |
3660 | info.nr_jited_func_lens, nr_jited_func_lens)) { | 3660 | info.nr_jited_func_lens, nr_jited_func_lens)) { |
3661 | err = -1; | 3661 | err = -1; |
@@ -3684,7 +3684,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test, | |||
3684 | err = -1; | 3684 | err = -1; |
3685 | goto done; | 3685 | goto done; |
3686 | } | 3686 | } |
3687 | info.line_info_cnt = cnt; | 3687 | info.nr_line_info = cnt; |
3688 | info.line_info_rec_size = rec_size; | 3688 | info.line_info_rec_size = rec_size; |
3689 | info.line_info = ptr_to_u64(linfo); | 3689 | info.line_info = ptr_to_u64(linfo); |
3690 | 3690 | ||
@@ -3700,7 +3700,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test, | |||
3700 | goto done; | 3700 | goto done; |
3701 | } | 3701 | } |
3702 | 3702 | ||
3703 | info.jited_line_info_cnt = jited_cnt; | 3703 | info.nr_jited_line_info = jited_cnt; |
3704 | info.jited_line_info_rec_size = jited_rec_size; | 3704 | info.jited_line_info_rec_size = jited_rec_size; |
3705 | info.jited_line_info = ptr_to_u64(jited_linfo); | 3705 | info.jited_line_info = ptr_to_u64(jited_linfo); |
3706 | info.nr_jited_ksyms = nr_jited_ksyms; | 3706 | info.nr_jited_ksyms = nr_jited_ksyms; |
@@ -3717,15 +3717,15 @@ static int test_get_linfo(const struct prog_info_raw_test *test, | |||
3717 | */ | 3717 | */ |
3718 | if (CHECK(err == -1 || | 3718 | if (CHECK(err == -1 || |
3719 | !info.line_info || | 3719 | !info.line_info || |
3720 | info.line_info_cnt != cnt || | 3720 | info.nr_line_info != cnt || |
3721 | (jited_cnt && !info.jited_line_info) || | 3721 | (jited_cnt && !info.jited_line_info) || |
3722 | info.jited_line_info_cnt != jited_cnt || | 3722 | info.nr_jited_line_info != jited_cnt || |
3723 | info.line_info_rec_size != rec_size || | 3723 | info.line_info_rec_size != rec_size || |
3724 | info.jited_line_info_rec_size != jited_rec_size, | 3724 | info.jited_line_info_rec_size != jited_rec_size, |
3725 | "err:%d errno:%d info: line_info_cnt:%u(expected:%u) jited_line_info_cnt:%u(expected:%u) line_info_rec_size:%u(expected:%u) jited_linfo_rec_size:%u(expected:%u) line_info:%p jited_line_info:%p", | 3725 | "err:%d errno:%d info: nr_line_info:%u(expected:%u) nr_jited_line_info:%u(expected:%u) line_info_rec_size:%u(expected:%u) jited_linfo_rec_size:%u(expected:%u) line_info:%p jited_line_info:%p", |
3726 | err, errno, | 3726 | err, errno, |
3727 | info.line_info_cnt, cnt, | 3727 | info.nr_line_info, cnt, |
3728 | info.jited_line_info_cnt, jited_cnt, | 3728 | info.nr_jited_line_info, jited_cnt, |
3729 | info.line_info_rec_size, rec_size, | 3729 | info.line_info_rec_size, rec_size, |
3730 | info.jited_line_info_rec_size, jited_rec_size, | 3730 | info.jited_line_info_rec_size, jited_rec_size, |
3731 | (void *)(long)info.line_info, | 3731 | (void *)(long)info.line_info, |