30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

17 Aug, 2009

1 commit

  • One entry is missing in the output of a stat file.

    The cause is, when stat_seq_start() is called the 2nd time, we
    should start from the (pos-1)th elem in the rbtree but not pos,
    because pos == 0 is the header.

    Signed-off-by: Li Zefan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

11 Aug, 2009

1 commit


23 Jul, 2009

1 commit


10 Jul, 2009

1 commit

  • Add stat_release() callback to struct tracer_stat, so a stat tracer
    can release it's entries after the stat file has been read out.

    Signed-off-by: Lai Jiangshan
    Signed-off-by: Li Zefan
    Cc: Lai Jiangshan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Lai Jiangshan
     

24 Jun, 2009

1 commit

  • It's wrong to increment @pos in stat_seq_start(). It causes some
    stat entries lost when reading stat file, if the output of the file
    is larger than PAGE_SIZE.

    Reviewed-by: Liming Wang
    Signed-off-by: Li Zefan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

02 Jun, 2009

6 commits

  • register_stat_tracer() uses list_for_each_entry_safe
    to check whether a tracer is already present in the list.
    But we don't delete anything from the list here, so
    we don't need the safe version

    [ Impact: cleanup list use is stat tracing ]

    Signed-off-by: Frederic Weisbecker

    Frederic Weisbecker
     
  • - remove duplicate code in stat_seq_init()
    - update comments to reflect the change from stat list to stat rbtree

    [ Impact: clean up ]

    Signed-off-by: Li Zefan
    Signed-off-by: Frederic Weisbecker

    Li Zefan
     
  • When closing a trace_stat file, we destroy the rbtree constructed during
    file open, but there is memory leak that the root node is not freed.

    [ Impact: fix memory leak when closing a trace_stat file ]

    Signed-off-by: Li Zefan
    Signed-off-by: Frederic Weisbecker

    Li Zefan
     
  • Currently the output of trace_stat/workqueues is totally reversed:

    # cat /debug/tracing/trace_stat/workqueues
    ...
    1 17 17 210 37 `-blk_unplug_work+0x0/0x57
    1 3779 3779 181 11 |-cfq_kick_queue+0x0/0x2f
    1 3796 3796 kblockd/1:120
    ...

    The correct output should be:

    1 3796 3796 kblockd/1:120
    1 3779 3779 181 11 |-cfq_kick_queue+0x0/0x2f
    1 17 17 210 37 `-blk_unplug_work+0x0/0x57

    It's caused by "tracing/stat: replace linked list by an rbtree for
    sorting"
    (53059c9b67a62a3dc8c80204d3da42b9267ea5a0).

    dummpy_cmp() should return -1, so rb_node will always be inserted as
    right-most node in the rbtree, thus we sort the output in ascending
    order.

    [ Impact: fix the output of trace_stat/workqueues ]

    Signed-off-by: Li Zefan
    Signed-off-by: Frederic Weisbecker

    Li Zefan
     
  • When the stat tracing framework prepares the entries from a tracer
    to output them to the user, it starts by computing a linear sort
    through a linked list to give the entries ordered by relevance
    to the user.

    This is quite ugly and causes a small latency when we begin to
    read the file.

    This patch changes that by turning the linked list into a red-black
    tree. Athough the whole iteration using the start and next tracer
    callbacks while opening the file remain the same, it is now much
    more fast and scalable.

    The rbtree guarantees O(log(n)) insertions whereas a linked
    list with linear sorting brought us a O(n) despair. Now the
    (visible) latency has disapeared.

    [ Impact: kill the latency while starting to read a stat tracer file ]

    Signed-off-by: Frederic Weisbecker

    Frederic Weisbecker
     
  • The "trace" prefix in struct trace_stat_session type is annoying while
    reading the trace_stat.c file. It makes the lines longer, and
    is not that much useful to explain the sense of this type.

    Just keep "struct stat_session" for this type.

    [ Impact: make the code a bit more readable ]

    Signed-off-by: Frederic Weisbecker

    Frederic Weisbecker
     

07 Apr, 2009

1 commit


26 Mar, 2009

2 commits

  • Impact: make trace_stat files show items with the original order

    trace_stat tracer reverse the items, it makes the output
    looks a little ugly.

    Example, when we read trace_stat/workqueues, we get cpu#7's stat.
    at first, and then cpu#6... cpu#0.

    Signed-off-by: Lai Jiangshan
    Acked-by: Steven Rostedt
    Acked-by: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Lai Jiangshan
     
  • Impact: Fix incorrect way using seq_file's API

    Use SEQ_START_TOKEN instead of calling ->stat_headers()
    int seq_operation->start().

    Signed-off-by: Lai Jiangshan
    Acked-by: Steven Rostedt
    Cc: Alexey Dobriyan
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Lai Jiangshan
     

25 Mar, 2009

1 commit

  • Currently, if a trace_stat user wants a handle to some private data,
    the trace_stat infrastructure does not supply a way to do that.

    This patch passes the trace_stat structure to the start function of
    the trace_stat code.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

24 Mar, 2009

1 commit

  • If the function profiler does not have any items recorded and one were
    to cat the function stat file, the kernel would take a BUG with a NULL
    pointer dereference.

    Looking further into this, I found that returning NULL from stat_start
    did not stop the stat logic, and would later call stat_next. This breaks
    from the way seq_file works, so I looked into fixing the stat code.

    This is where I noticed that the last next_entry is never freed.
    It is allocated, and if the stat_next returns NULL, the code breaks out
    of the loop, unlocks the mutex and exits. We never link the next_entry
    nor do we free it. Thus it is a real memory leak.

    This patch rearranges the code a bit to not only fix the memory leak,
    but also to act more like seq_file where nothing is printed if there
    is nothing to print. That is, stat_start returns NULL.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

18 Feb, 2009

1 commit


15 Jan, 2009

2 commits


14 Jan, 2009

1 commit

  • Impact: tracing's Api change

    Currently, the stat tracing depends on the events tracing.
    When you switch to a new tracer, the stats files of the previous tracer
    will disappear. But it's more scalable to separate those two engines.
    This way, we can keep the stat files of one or several tracers when we
    want, without bothering of multiple tracer stat files or tracer switching.

    To build/destroys its stats files, a tracer just have to call
    register_stat_tracer/unregister_stat_tracer everytimes it wants to.

    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

11 Jan, 2009

1 commit

  • Impact: new API for tracers

    Make the stat tracing API reentrant. And also provide the new directory
    /debugfs/tracing/trace_stat which will contain all the stat files for the
    current active tracer.

    Now a tracer will, if desired, want to provide a zero terminated array of
    tracer_stat structures.
    Each one contains the callbacks necessary for one stat file.
    It have to provide at least a name for its stat file, an iterator with
    stat_start/start_next callback and an output callback for one stat entry.

    Also adapt the branch tracer to this new API.
    We create two files "all" and "annotated" inside the /debugfs/tracing/trace_stat
    directory, making the both stats simultaneously available instead of needing
    to change an option to switch from one stat file to another.

    The output of these stats haven't changed.

    Changes in v2:

    _ Apply the previous memory leak fix (rebase against tip/master)

    Changes in v3:

    _ Merge the patch that adapted the branch tracer to this Api in this patch to
    not break the kernel build.

    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

07 Jan, 2009

2 commits

  • Impact: clean up

    Andrew Morton pointed out that the entry assignment in stat_seq_show
    did not need to be done in the declaration, causing funny line breaks.

    This patch makes it a bit more pleasing on the eyes.

    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     
  • Impact: fix memory leak

    This patch fixes a memory leak inside reset_stat_list(). The freeing
    loop iterated only once.

    Also turn the stat_list into a simple struct list_head, which
    simplify the code and avoid an unused static pointer.

    Reported-by: Steven Rostedt
    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

29 Dec, 2008

1 commit

  • Impact: extend the tracing API

    The goal of this patch is to normalize and make more easy the
    implementation of statistical (histogram) tracing.

    It implements a trace_stat file into the /debugfs/tracing directory where
    one can print a one-shot output of statistics/histogram entries.

    A tracer has to provide two basic iterator callbacks:

    stat_start() => the first entry
    stat_next(prev, idx) => the next one.

    Note that it is adapted for arrays or hash tables or lists.... since it
    provides a pointer to the previous entry and the current index of the
    iterator.

    These two callbacks are called to get a snapshot of the statistics at each
    opening of the trace_stat file because. The values are so updated between
    two "cat trace_stat". And the tracer is free to lock its datas during the
    iteration to keep consistent values.

    Since it is almost always interesting to sort statisticals values to
    address the problems by priority, this infrastructure provides a "sorting"
    of the stat entries too if desired. A tracer has just to provide a
    stat_cmp callback to compare two entries and the stat tracing
    infrastructure will build a sorted list of the given entries.

    A last callback, called stat_headers, can be implemented by a tracer to
    output headers on its trace.

    If one of these callbacks is changed on runtime, it just have to signal it
    to the stat tracing API by calling the init_tracer_stat() helper.

    Changes in V2:

    - Fix a memory leak if the user opens multiple times the trace_stat file
    without closing it. Now we always free our list before rebuilding it.

    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker