Re: [PATCH 8/9] perf tools: add kcore to the object code reading test

From: Namhyung Kim
Date: Tue Jul 30 2013 - 01:25:30 EST


On Thu, 25 Jul 2013 17:01:29 +0300, Adrian Hunter wrote:
> Make the "object code reading" test attempt to read from
> kcore.
>
> The test uses objdump which struggles with kcore. i.e.
> doesn't always work, sometimes takes a long time.
> The test has been made to work around those issues.
>
[SNIP]

> - if (al.map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) {
> + if (al.map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS &&
> + !dso__is_kcore(al.map->dso)) {

I was confused. So this means that the symbols came from the kallsyms
but actual binary data came from the kcore, right?


> pr_debug("Unexpected kernel address - skipping\n");
> return 0;
> }

[SNIP]
> +
> + /* 2nd time through we just try kcore */
> + if (try_kcore && !have_kcore)
> + return TEST_CODE_READING_NO_KCORE;
> +
> + /* No point getting kernel events if there is no kernel object */
> + if (!have_vmlinux && !have_kcore)
> excl_kernel = true;
>
> threads = thread_map__new_by_tid(pid);
> @@ -457,8 +502,12 @@ static int do_test_code_reading(void)
> if (ret < 0)
> goto out_err;
>
> - if (!have_vmlinux)
> + if (!have_vmlinux && !have_kcore && !try_kcore)
> + err = TEST_CODE_READING_NO_KERNEL_OBJ;
> + else if (!have_vmlinux && !try_kcore)
> err = TEST_CODE_READING_NO_VMLINUX;
> + else if (!have_kcore && try_kcore)
> + err = TEST_CODE_READING_NO_KCORE;

It seems that the above line is not reachable since we already bailed
out the second test if we don't have kcore.


> else if (excl_kernel)
> err = TEST_CODE_READING_NO_ACCESS;
> else
> @@ -485,7 +534,9 @@ int test__code_reading(void)
> {
> int ret;
>
> - ret = do_test_code_reading();
> + ret = do_test_code_reading(false);
> + if (!ret)

Shouldn't it be

if (ret)
?

Thanks,
Namhyung


> + ret = do_test_code_reading(true);
>
> switch (ret) {
> case TEST_CODE_READING_OK:
> @@ -493,9 +544,15 @@ int test__code_reading(void)
> case TEST_CODE_READING_NO_VMLINUX:
> fprintf(stderr, " (no vmlinux)");
> return 0;
> + case TEST_CODE_READING_NO_KCORE:
> + fprintf(stderr, " (no kcore)");
> + return 0;
> case TEST_CODE_READING_NO_ACCESS:
> fprintf(stderr, " (no access)");
> return 0;
> + case TEST_CODE_READING_NO_KERNEL_OBJ:
> + fprintf(stderr, " (no kernel obj)");
> + return 0;
> default:
> return -1;
> };
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/