2

System: Ubuntu 14.04 Kernel 4.10.12

So I'm in the process of trying to understand how FTrace works, but something I noticed is derailing me a bit:

available_filter_functions can be used to filter what's being traced to certain functions. But the function I'm trying to trace (in this case, KSM's main worker function ksm_do_scan) isn't showing up in the list.

Here is the list of available functions (filtered by ksm-functions):

root@test:/sys/kernel/debug/tracing# cat available_filter_functions | grep             
ksm

ksm_memory_callback
break_ksm
unmerge_ksm_pages
get_ksm_page
try_to_merge_with_ksm_page
ksm_scan_thread (calls ksm_do_scan)
__ksm_enter
ksm_madvise
__ksm_exit
ksm_might_need_to_copy
rmap_walk_ksm
ksm_migrate_page

And here is what ksm_do_scan looks like:

static void ksm_do_scan(unsigned int scan_npages)
{
    struct rmap_item *rmap_item;
    struct page *uninitialized_var(page);

    while (scan_npages-- && likely(!freezing(current))) {
            cond_resched();
            rmap_item = scan_get_next_rmap_item(&page);
            if (!rmap_item)
                    return;
            cmp_and_merge_page(page, rmap_item);
            put_page(page);
    }
}

I tested this on another system that had been setup with Kernel version 4.4.0-31, and ksm_do_scan() showed up on the list of available_filter_functions. So I figured it must have something to do with how The 4.10.12 Kernel was configured, but I'm not sure. All of recommended .config options that I've seen so far are enabled:

CONFIG_FUNCTION_TRACER=y
CONFIG_FUNCTION_GRAPH_TRACER=y
CONFIG_STACK_TRACER=y
CONFIG_DYNAMIC_FTRACE=y

Finally, I know that ftrace black lists functions that are annotated with __init and __devinit because kernel init functions are loaded during initialization and removed when initialization is done, but ksm_do_scan doesn't contain either of those annotations.

1 Answer 1

2

Straight from horse's mouth (from irc chat with Steven Rostedt)

"they are all functions that are white listed and are not inlined or marked "notrace". now in my next release, init functions will be able to be traced on boot up but not module init functions yet"

To answer your question: gcc may inline any static function that is used in a single place, regardless of size. So try adding "noinline" in that function.

This worked for me.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .