mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 08:44:14 +08:00
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>
This commit is contained in:
parent
b4f8623c0c
commit
cfc542411b
@ -425,7 +425,7 @@ static int do_dump(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
unsigned int finfo_rec_size, linfo_rec_size, jited_linfo_rec_size;
|
unsigned int finfo_rec_size, linfo_rec_size, jited_linfo_rec_size;
|
||||||
void *func_info = NULL, *linfo = NULL, *jited_linfo = NULL;
|
void *func_info = NULL, *linfo = NULL, *jited_linfo = NULL;
|
||||||
unsigned int finfo_cnt, linfo_cnt = 0, jited_linfo_cnt = 0;
|
unsigned int nr_finfo, nr_linfo = 0, nr_jited_linfo = 0;
|
||||||
struct bpf_prog_linfo *prog_linfo = NULL;
|
struct bpf_prog_linfo *prog_linfo = NULL;
|
||||||
unsigned long *func_ksyms = NULL;
|
unsigned long *func_ksyms = NULL;
|
||||||
struct bpf_prog_info info = {};
|
struct bpf_prog_info info = {};
|
||||||
@ -537,10 +537,10 @@ static int do_dump(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finfo_cnt = info.func_info_cnt;
|
nr_finfo = info.nr_func_info;
|
||||||
finfo_rec_size = info.func_info_rec_size;
|
finfo_rec_size = info.func_info_rec_size;
|
||||||
if (finfo_cnt && finfo_rec_size) {
|
if (nr_finfo && finfo_rec_size) {
|
||||||
func_info = malloc(finfo_cnt * finfo_rec_size);
|
func_info = malloc(nr_finfo * finfo_rec_size);
|
||||||
if (!func_info) {
|
if (!func_info) {
|
||||||
p_err("mem alloc failed");
|
p_err("mem alloc failed");
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -549,9 +549,9 @@ static int do_dump(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
linfo_rec_size = info.line_info_rec_size;
|
linfo_rec_size = info.line_info_rec_size;
|
||||||
if (info.line_info_cnt && linfo_rec_size && info.btf_id) {
|
if (info.nr_line_info && linfo_rec_size && info.btf_id) {
|
||||||
linfo_cnt = info.line_info_cnt;
|
nr_linfo = info.nr_line_info;
|
||||||
linfo = malloc(linfo_cnt * linfo_rec_size);
|
linfo = malloc(nr_linfo * linfo_rec_size);
|
||||||
if (!linfo) {
|
if (!linfo) {
|
||||||
p_err("mem alloc failed");
|
p_err("mem alloc failed");
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -560,13 +560,13 @@ static int do_dump(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
jited_linfo_rec_size = info.jited_line_info_rec_size;
|
jited_linfo_rec_size = info.jited_line_info_rec_size;
|
||||||
if (info.jited_line_info_cnt &&
|
if (info.nr_jited_line_info &&
|
||||||
jited_linfo_rec_size &&
|
jited_linfo_rec_size &&
|
||||||
info.nr_jited_ksyms &&
|
info.nr_jited_ksyms &&
|
||||||
info.nr_jited_func_lens &&
|
info.nr_jited_func_lens &&
|
||||||
info.btf_id) {
|
info.btf_id) {
|
||||||
jited_linfo_cnt = info.jited_line_info_cnt;
|
nr_jited_linfo = info.nr_jited_line_info;
|
||||||
jited_linfo = malloc(jited_linfo_cnt * jited_linfo_rec_size);
|
jited_linfo = malloc(nr_jited_linfo * jited_linfo_rec_size);
|
||||||
if (!jited_linfo) {
|
if (!jited_linfo) {
|
||||||
p_err("mem alloc failed");
|
p_err("mem alloc failed");
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -582,13 +582,13 @@ static int do_dump(int argc, char **argv)
|
|||||||
info.nr_jited_ksyms = nr_func_ksyms;
|
info.nr_jited_ksyms = nr_func_ksyms;
|
||||||
info.jited_func_lens = ptr_to_u64(func_lens);
|
info.jited_func_lens = ptr_to_u64(func_lens);
|
||||||
info.nr_jited_func_lens = nr_func_lens;
|
info.nr_jited_func_lens = nr_func_lens;
|
||||||
info.func_info_cnt = finfo_cnt;
|
info.nr_func_info = nr_finfo;
|
||||||
info.func_info_rec_size = finfo_rec_size;
|
info.func_info_rec_size = finfo_rec_size;
|
||||||
info.func_info = ptr_to_u64(func_info);
|
info.func_info = ptr_to_u64(func_info);
|
||||||
info.line_info_cnt = linfo_cnt;
|
info.nr_line_info = nr_linfo;
|
||||||
info.line_info_rec_size = linfo_rec_size;
|
info.line_info_rec_size = linfo_rec_size;
|
||||||
info.line_info = ptr_to_u64(linfo);
|
info.line_info = ptr_to_u64(linfo);
|
||||||
info.jited_line_info_cnt = jited_linfo_cnt;
|
info.nr_jited_line_info = nr_jited_linfo;
|
||||||
info.jited_line_info_rec_size = jited_linfo_rec_size;
|
info.jited_line_info_rec_size = jited_linfo_rec_size;
|
||||||
info.jited_line_info = ptr_to_u64(jited_linfo);
|
info.jited_line_info = ptr_to_u64(jited_linfo);
|
||||||
|
|
||||||
@ -614,9 +614,9 @@ static int do_dump(int argc, char **argv)
|
|||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.func_info_cnt != finfo_cnt) {
|
if (info.nr_func_info != nr_finfo) {
|
||||||
p_err("incorrect func_info_cnt %d vs. expected %d",
|
p_err("incorrect nr_func_info %d vs. expected %d",
|
||||||
info.func_info_cnt, finfo_cnt);
|
info.nr_func_info, nr_finfo);
|
||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,12 +630,12 @@ static int do_dump(int argc, char **argv)
|
|||||||
/* kernel.kptr_restrict is set. No func_info available. */
|
/* kernel.kptr_restrict is set. No func_info available. */
|
||||||
free(func_info);
|
free(func_info);
|
||||||
func_info = NULL;
|
func_info = NULL;
|
||||||
finfo_cnt = 0;
|
nr_finfo = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linfo && info.line_info_cnt != linfo_cnt) {
|
if (linfo && info.nr_line_info != nr_linfo) {
|
||||||
p_err("incorrect line_info_cnt %u vs. expected %u",
|
p_err("incorrect nr_line_info %u vs. expected %u",
|
||||||
info.line_info_cnt, linfo_cnt);
|
info.nr_line_info, nr_linfo);
|
||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,9 +645,9 @@ static int do_dump(int argc, char **argv)
|
|||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jited_linfo && info.jited_line_info_cnt != jited_linfo_cnt) {
|
if (jited_linfo && info.nr_jited_line_info != nr_jited_linfo) {
|
||||||
p_err("incorrect jited_line_info_cnt %u vs. expected %u",
|
p_err("incorrect nr_jited_line_info %u vs. expected %u",
|
||||||
info.jited_line_info_cnt, jited_linfo_cnt);
|
info.nr_jited_line_info, nr_jited_linfo);
|
||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +670,7 @@ static int do_dump(int argc, char **argv)
|
|||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linfo_cnt) {
|
if (nr_linfo) {
|
||||||
prog_linfo = bpf_prog_linfo__new(&info);
|
prog_linfo = bpf_prog_linfo__new(&info);
|
||||||
if (!prog_linfo)
|
if (!prog_linfo)
|
||||||
p_info("error in processing bpf_line_info. continue without it.");
|
p_info("error in processing bpf_line_info. continue without it.");
|
||||||
|
@ -105,7 +105,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info)
|
|||||||
struct bpf_prog_linfo *prog_linfo;
|
struct bpf_prog_linfo *prog_linfo;
|
||||||
__u32 nr_linfo, nr_jited_func;
|
__u32 nr_linfo, nr_jited_func;
|
||||||
|
|
||||||
nr_linfo = info->line_info_cnt;
|
nr_linfo = info->nr_line_info;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test !info->line_info because the kernel may NULL
|
* 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)
|
|||||||
nr_jited_func = info->nr_jited_ksyms;
|
nr_jited_func = info->nr_jited_ksyms;
|
||||||
if (!nr_jited_func ||
|
if (!nr_jited_func ||
|
||||||
!info->jited_line_info ||
|
!info->jited_line_info ||
|
||||||
info->jited_line_info_cnt != nr_linfo ||
|
info->nr_jited_line_info != nr_linfo ||
|
||||||
info->jited_line_info_rec_size < sizeof(__u64) ||
|
info->jited_line_info_rec_size < sizeof(__u64) ||
|
||||||
info->nr_jited_func_lens != nr_jited_func ||
|
info->nr_jited_func_lens != nr_jited_func ||
|
||||||
!info->jited_ksyms ||
|
!info->jited_ksyms ||
|
||||||
|
@ -2548,9 +2548,9 @@ static int do_test_file(unsigned int test_num)
|
|||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (CHECK(info.func_info_cnt != 3,
|
if (CHECK(info.nr_func_info != 3,
|
||||||
"incorrect info.func_info_cnt (1st) %d",
|
"incorrect info.nr_func_info (1st) %d",
|
||||||
info.func_info_cnt)) {
|
info.nr_func_info)) {
|
||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -2561,7 +2561,7 @@ static int do_test_file(unsigned int test_num)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
func_info = malloc(info.func_info_cnt * rec_size);
|
func_info = malloc(info.nr_func_info * rec_size);
|
||||||
if (CHECK(!func_info, "out of memory")) {
|
if (CHECK(!func_info, "out of memory")) {
|
||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
@ -2569,7 +2569,7 @@ static int do_test_file(unsigned int test_num)
|
|||||||
|
|
||||||
/* reset info to only retrieve func_info related data */
|
/* reset info to only retrieve func_info related data */
|
||||||
memset(&info, 0, sizeof(info));
|
memset(&info, 0, sizeof(info));
|
||||||
info.func_info_cnt = 3;
|
info.nr_func_info = 3;
|
||||||
info.func_info_rec_size = rec_size;
|
info.func_info_rec_size = rec_size;
|
||||||
info.func_info = ptr_to_u64(func_info);
|
info.func_info = ptr_to_u64(func_info);
|
||||||
|
|
||||||
@ -2580,9 +2580,9 @@ static int do_test_file(unsigned int test_num)
|
|||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (CHECK(info.func_info_cnt != 3,
|
if (CHECK(info.nr_func_info != 3,
|
||||||
"incorrect info.func_info_cnt (2nd) %d",
|
"incorrect info.nr_func_info (2nd) %d",
|
||||||
info.func_info_cnt)) {
|
info.nr_func_info)) {
|
||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -3544,9 +3544,9 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
|
|||||||
fprintf(stderr, "%s\n", btf_log_buf);
|
fprintf(stderr, "%s\n", btf_log_buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (CHECK(info.func_info_cnt != test->func_info_cnt,
|
if (CHECK(info.nr_func_info != test->func_info_cnt,
|
||||||
"incorrect info.func_info_cnt (1st) %d",
|
"incorrect info.nr_func_info (1st) %d",
|
||||||
info.func_info_cnt)) {
|
info.nr_func_info)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3556,16 +3556,16 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.func_info_cnt)
|
if (!info.nr_func_info)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
func_info = malloc(info.func_info_cnt * rec_size);
|
func_info = malloc(info.nr_func_info * rec_size);
|
||||||
if (CHECK(!func_info, "out of memory"))
|
if (CHECK(!func_info, "out of memory"))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* reset info to only retrieve func_info related data */
|
/* reset info to only retrieve func_info related data */
|
||||||
memset(&info, 0, sizeof(info));
|
memset(&info, 0, sizeof(info));
|
||||||
info.func_info_cnt = test->func_info_cnt;
|
info.nr_func_info = test->func_info_cnt;
|
||||||
info.func_info_rec_size = rec_size;
|
info.func_info_rec_size = rec_size;
|
||||||
info.func_info = ptr_to_u64(func_info);
|
info.func_info = ptr_to_u64(func_info);
|
||||||
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len);
|
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,
|
|||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (CHECK(info.func_info_cnt != test->func_info_cnt,
|
if (CHECK(info.nr_func_info != test->func_info_cnt,
|
||||||
"incorrect info.func_info_cnt (2nd) %d",
|
"incorrect info.nr_func_info (2nd) %d",
|
||||||
info.func_info_cnt)) {
|
info.nr_func_info)) {
|
||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -3648,14 +3648,14 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
|
|||||||
nr_jited_func_lens = 1;
|
nr_jited_func_lens = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CHECK(info.line_info_cnt != cnt ||
|
if (CHECK(info.nr_line_info != cnt ||
|
||||||
info.jited_line_info_cnt != jited_cnt ||
|
info.nr_jited_line_info != jited_cnt ||
|
||||||
info.nr_jited_ksyms != nr_jited_ksyms ||
|
info.nr_jited_ksyms != nr_jited_ksyms ||
|
||||||
info.nr_jited_func_lens != nr_jited_func_lens ||
|
info.nr_jited_func_lens != nr_jited_func_lens ||
|
||||||
(!info.line_info_cnt && info.jited_line_info_cnt),
|
(!info.nr_line_info && info.nr_jited_line_info),
|
||||||
"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)",
|
"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)",
|
||||||
info.line_info_cnt, cnt,
|
info.nr_line_info, cnt,
|
||||||
info.jited_line_info_cnt, jited_cnt,
|
info.nr_jited_line_info, jited_cnt,
|
||||||
info.nr_jited_ksyms, nr_jited_ksyms,
|
info.nr_jited_ksyms, nr_jited_ksyms,
|
||||||
info.nr_jited_func_lens, nr_jited_func_lens)) {
|
info.nr_jited_func_lens, nr_jited_func_lens)) {
|
||||||
err = -1;
|
err = -1;
|
||||||
@ -3684,7 +3684,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
|
|||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
info.line_info_cnt = cnt;
|
info.nr_line_info = cnt;
|
||||||
info.line_info_rec_size = rec_size;
|
info.line_info_rec_size = rec_size;
|
||||||
info.line_info = ptr_to_u64(linfo);
|
info.line_info = ptr_to_u64(linfo);
|
||||||
|
|
||||||
@ -3700,7 +3700,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.jited_line_info_cnt = jited_cnt;
|
info.nr_jited_line_info = jited_cnt;
|
||||||
info.jited_line_info_rec_size = jited_rec_size;
|
info.jited_line_info_rec_size = jited_rec_size;
|
||||||
info.jited_line_info = ptr_to_u64(jited_linfo);
|
info.jited_line_info = ptr_to_u64(jited_linfo);
|
||||||
info.nr_jited_ksyms = nr_jited_ksyms;
|
info.nr_jited_ksyms = nr_jited_ksyms;
|
||||||
@ -3717,15 +3717,15 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
|
|||||||
*/
|
*/
|
||||||
if (CHECK(err == -1 ||
|
if (CHECK(err == -1 ||
|
||||||
!info.line_info ||
|
!info.line_info ||
|
||||||
info.line_info_cnt != cnt ||
|
info.nr_line_info != cnt ||
|
||||||
(jited_cnt && !info.jited_line_info) ||
|
(jited_cnt && !info.jited_line_info) ||
|
||||||
info.jited_line_info_cnt != jited_cnt ||
|
info.nr_jited_line_info != jited_cnt ||
|
||||||
info.line_info_rec_size != rec_size ||
|
info.line_info_rec_size != rec_size ||
|
||||||
info.jited_line_info_rec_size != jited_rec_size,
|
info.jited_line_info_rec_size != jited_rec_size,
|
||||||
"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",
|
"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",
|
||||||
err, errno,
|
err, errno,
|
||||||
info.line_info_cnt, cnt,
|
info.nr_line_info, cnt,
|
||||||
info.jited_line_info_cnt, jited_cnt,
|
info.nr_jited_line_info, jited_cnt,
|
||||||
info.line_info_rec_size, rec_size,
|
info.line_info_rec_size, rec_size,
|
||||||
info.jited_line_info_rec_size, jited_rec_size,
|
info.jited_line_info_rec_size, jited_rec_size,
|
||||||
(void *)(long)info.line_info,
|
(void *)(long)info.line_info,
|
||||||
|
Loading…
Reference in New Issue
Block a user