13 May, 2017

1 commit

  • Starting from GCC 7.1, __gcov_exit is a new symbol expected to be
    implemented in a profiling runtime.

    [akpm@linux-foundation.org: coding-style fixes]
    [mliska@suse.cz: v2]
    Link: http://lkml.kernel.org/r/e63a3c59-0149-c97e-4084-20ca8f146b26@suse.cz
    Link: http://lkml.kernel.org/r/8c4084fa-3885-29fe-5fc4-0d4ca199c785@suse.cz
    Signed-off-by: Martin Liska
    Acked-by: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Martin Liska
     

15 Jul, 2016

1 commit


10 May, 2016

1 commit

  • Enabling gcov is counterproductive to compile testing: it significantly
    increases the kernel image size, compile time, and it produces lots
    of false positive "may be used uninitialized" warnings as the result
    of missed optimizations.

    This is in line with how UBSAN_SANITIZE_ALL and PROFILE_ALL_BRANCHES
    work, both of which have similar problems.

    With an ARM allmodconfig kernel, I see the build time drop from
    283 minutes CPU time to 225 minutes, and the vmlinux size drops
    from 43MB to 26MB.

    Signed-off-by: Arnd Bergmann
    Acked-by: Peter Oberparleiter
    Signed-off-by: Michal Marek

    Arnd Bergmann
     

05 Dec, 2015

1 commit

  • An exact mapping would be within_module_core(), but at this stage
    (MODULE_STATE_GOING) the init section is empty, and this is clearer.

    Reviewed-by: Peter Oberparleiter
    Signed-off-by: Rusty Russell
    Signed-off-by: Jiri Kosina

    Rusty Russell
     

01 Jul, 2015

1 commit

  • Fix kernel gcov support for GCC 5.1. Similar to commit a992bf836f9
    ("gcov: add support for GCC 4.9"), this patch takes into account the
    existence of a new gcov counter (see gcc's gcc/gcov-counter.def.)

    Firstly, it increments GCOV_COUNTERS (to 10), which makes the data
    structure struct gcov_info compatible with GCC 5.1.

    Secondly, a corresponding counter function __gcov_merge_icall_topn (Top N
    value tracking for indirect calls) is included in base.c with the other
    gcov counters unused for kernel profiling.

    Signed-off-by: Lorenzo Stoakes
    Cc: Andrey Ryabinin
    Cc: Yuan Pengfei
    Tested-by: Peter Oberparleiter
    Reviewed-by: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lorenzo Stoakes
     

17 Apr, 2015

1 commit

  • gcov profiling if enabled with other heavy compile-time instrumentation
    like KASan could trigger following softlockups:

    NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [swapper/0:1]
    Modules linked in:
    irq event stamp: 22823276
    hardirqs last enabled at (22823275): [] mutex_lock_nested+0x7d9/0x930
    hardirqs last disabled at (22823276): [] apic_timer_interrupt+0x6d/0x80
    softirqs last enabled at (22823172): [] __do_softirq+0x4db/0x729
    softirqs last disabled at (22823167): [] irq_exit+0x7d/0x15b
    CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 3.19.0-05245-gbb33326-dirty #3
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5.1-0-g8936dbb-20141113_115728-nilsson.home.kraxel.org 04/01/2014
    task: ffff88006cba8000 ti: ffff88006cbb0000 task.ti: ffff88006cbb0000
    RIP: kasan_mem_to_shadow+0x1e/0x1f
    Call Trace:
    strcmp+0x28/0x70
    get_node_by_name+0x66/0x99
    gcov_event+0x4f/0x69e
    gcov_enable_events+0x54/0x7b
    gcov_fs_init+0xf8/0x134
    do_one_initcall+0x1b2/0x288
    kernel_init_freeable+0x467/0x580
    kernel_init+0x15/0x18b
    ret_from_fork+0x7c/0xb0
    Kernel panic - not syncing: softlockup: hung tasks

    Fix this by sticking cond_resched() in gcov_enable_events().

    Signed-off-by: Andrey Ryabinin
    Reported-by: Fengguang Wu
    Cc: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     

10 Jan, 2015

4 commits


14 Dec, 2014

1 commit

  • Following the suggestions from Andrew Morton and Stephen Rothwell,
    Dont expand the ARCH list in kernel/gcov/Kconfig. Instead,
    define a ARCH_HAS_GCOV_PROFILE_ALL bool which architectures
    can enable.

    set ARCH_HAS_GCOV_PROFILE_ALL on Architectures where it was
    previously allowed + ARM64 which I tested.

    Signed-off-by: Riku Voipio
    Cc: Peter Oberparleiter
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Riku Voipio
     

30 Oct, 2014

1 commit

  • Following up the arm testing of gcov, turns out gcov on ARM64 works fine
    as well. Only change needed is adding ARM64 to Kconfig depends.

    Tested with qemu and mach-virt

    Signed-off-by: Riku Voipio
    Acked-by: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Riku Voipio
     

26 Sep, 2014

1 commit

  • Enable gcov support for ARM based on original patches by David
    Singleton and George G. Davis

    Riku - updated to patch to current mainline kernel. The patch
    has been submitted in 2010, 2012 - for symmetry, now in 2014 too.

    https://lwn.net/Articles/390419/
    http://marc.info/?l=linux-arm-kernel&m=133823081813044

    v2: remove arch/arm/kernel from gcov disabled files

    Cc: Andrey Ryabinin
    Cc: Naresh Kamboju
    Acked-by: Arnd Bergmann
    Signed-off-by: Riku Voipio
    Signed-off-by: Vincent Sanders
    Signed-off-by: Russell King

    Vincent Sanders
     

09 Aug, 2014

1 commit


11 Jun, 2014

1 commit

  • This patch handles the gcov-related changes in GCC 4.9:

    A new counter (time profile) is added. The total number is 9 now.

    A new profile merge function __gcov_merge_time_profile is added.

    See gcc/gcov-io.h and libgcc/libgcov-merge.c

    For the first change, the layout of struct gcov_info is affected.

    For the second one, a dummy function is added to kernel/gcov/base.c
    similarly.

    Signed-off-by: Yuan Pengfei
    Acked-by: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yuan Pengfei
     

13 Nov, 2013

5 commits

  • To get name of the file from a pathname let's use kbasename() helper.

    Signed-off-by: Andy Shevchenko
    Cc: Jingoo Han
    Cc: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • pr_warning() is deprecated in favor of pr_warn()

    Cc: Andy Gospodarek
    Cc: Arnd Bergmann
    Cc: Frantisek Hrbata
    Cc: Jan Stancek
    Cc: Kees Cook
    Cc: Peter Oberparleiter
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Compile the correct gcov implementation file for the specific gcc version.

    Signed-off-by: Frantisek Hrbata
    Cc: Jan Stancek
    Cc: Kees Cook
    Acked-by: Peter Oberparleiter
    Cc: Rusty Russell
    Cc: Arnd Bergmann
    Cc: Andy Gospodarek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Frantisek Hrbata
     
  • The gcov in-memory format changed in gcc 4.7. The biggest change, which
    requires this special implementation, is that gcov_info no longer contains
    array of counters for each counter type for all functions and gcov_fn_info
    is not used for mapping of function's counters to these arrays(offset).
    Now each gcov_fn_info contans it's counters, which makes things a little
    bit easier.

    This is heavily based on the previous gcc_3_4.c implementation and patches
    provided by Peter Oberparleiter. Specially the buffer gcda implementation
    for iterator.

    [akpm@linux-foundation.org: use kmemdup() and kcalloc()]
    [oberpar@linux.vnet.ibm.com: gcc_4_7.c needs vmalloc.h]
    Signed-off-by: Frantisek Hrbata
    Cc: Jan Stancek
    Cc: Kees Cook
    Reviewed-by: Peter Oberparleiter
    Cc: Rusty Russell
    Cc: Arnd Bergmann
    Cc: Andy Gospodarek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Frantisek Hrbata
     
  • Since also the gcov structures(gcov_info, gcov_fn_info, gcov_ctr_info) can
    change between gcc releases, as shown in gcc 4.7, they cannot be defined
    in a common header and need to be moved to a specific gcc implemention
    file. This also requires to make the gcov_info structure opaque for the
    common code and to introduce simple helpers for accessing data inside
    gcov_info.

    Signed-off-by: Frantisek Hrbata
    Cc: Jan Stancek
    Cc: Kees Cook
    Acked-by: Peter Oberparleiter
    Cc: Rusty Russell
    Cc: Arnd Bergmann
    Cc: Andy Gospodarek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Frantisek Hrbata
     

13 Sep, 2013

1 commit


12 Jan, 2013

1 commit

  • The CONFIG_EXPERIMENTAL config item has not carried much meaning for a
    while now and is almost always enabled by default. As agreed during the
    Linux kernel summit, remove it from any "depends on" lines in Kconfigs.

    Cc: WANG Cong
    Signed-off-by: Kees Cook
    Acked-by: Peter Oberparleiter

    Kees Cook
     

27 Jul, 2011

1 commit

  • Selecting GCOV for UML causing configuration mismatch:

    warning: (GCOV_KERNEL) selects CONSTRUCTORS which has unmet direct dependencies (!UML)

    Constructors are not needed for UML.

    Signed-off-by: Vitaliy Ivanov
    Cc: Peter Oberparleiter
    Acked-by: Richard Weinberger
    Acked-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vitaliy Ivanov
     

16 Jun, 2011

1 commit

  • CONFIG_CONSTRUCTORS controls support for running constructor functions at
    kernel init time. According to commit b99b87f70c7785ab ("kernel:
    constructor support"), gcov (CONFIG_GCOV_KERNEL) needs this. However,
    CONFIG_CONSTRUCTORS currently defaults to y, with no option to disable it,
    and CONFIG_GCOV_KERNEL depends on it. Instead, default it to n and have
    CONFIG_GCOV_KERNEL select it, so that the normal case of
    CONFIG_GCOV_KERNEL=n will result in CONFIG_CONSTRUCTORS=n.

    Observed in the short list of =y values in a minimal kernel configuration.

    Signed-off-by: Josh Triplett
    Acked-by: WANG Cong
    Acked-by: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Josh Triplett
     

21 Mar, 2011

1 commit

  • * 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: (25 commits)
    video: change to new flag variable
    scsi: change to new flag variable
    rtc: change to new flag variable
    rapidio: change to new flag variable
    pps: change to new flag variable
    net: change to new flag variable
    misc: change to new flag variable
    message: change to new flag variable
    memstick: change to new flag variable
    isdn: change to new flag variable
    ieee802154: change to new flag variable
    ide: change to new flag variable
    hwmon: change to new flag variable
    dma: change to new flag variable
    char: change to new flag variable
    fs: change to new flag variable
    xtensa: change to new flag variable
    um: change to new flag variables
    s390: change to new flag variable
    mips: change to new flag variable
    ...

    Fix up trivial conflict in drivers/hwmon/Makefile

    Linus Torvalds
     

17 Mar, 2011

1 commit


15 Feb, 2011

1 commit

  • This patch enables gcov kernel profiling over the whole kernel for sh.
    Profiling of specific files individually already worked. A handful of
    files have to be explicitly excluded from the profiling to avoid
    breaking things, notably pmb.c.

    Signed-off-by: Chris Smith
    Signed-off-by: Stuart Menefy
    Signed-off-by: Paul Mundt

    Chris Smith
     

15 Oct, 2010

1 commit

  • All file_operations should get a .llseek operation so we can make
    nonseekable_open the default for future file operations without a
    .llseek pointer.

    The three cases that we can automatically detect are no_llseek, seq_lseek
    and default_llseek. For cases where we can we can automatically prove that
    the file offset is always ignored, we use noop_llseek, which maintains
    the current behavior of not returning an error from a seek.

    New drivers should normally not use noop_llseek but instead use no_llseek
    and call nonseekable_open at open time. Existing drivers can be converted
    to do the same when the maintainer knows for certain that no user code
    relies on calling seek on the device file.

    The generated code is often incorrectly indented and right now contains
    comments that clarify for each added line why a specific variant was
    chosen. In the version that gets submitted upstream, the comments will
    be gone and I will manually fix the indentation, because there does not
    seem to be a way to do that using coccinelle.

    Some amount of new code is currently sitting in linux-next that should get
    the same modifications, which I will do at the end of the merge window.

    Many thanks to Julia Lawall for helping me learn to write a semantic
    patch that does all this.

    ===== begin semantic patch =====
    // This adds an llseek= method to all file operations,
    // as a preparation for making no_llseek the default.
    //
    // The rules are
    // - use no_llseek explicitly if we do nonseekable_open
    // - use seq_lseek for sequential files
    // - use default_llseek if we know we access f_pos
    // - use noop_llseek if we know we don't access f_pos,
    // but we still want to allow users to call lseek
    //
    @ open1 exists @
    identifier nested_open;
    @@
    nested_open(...)
    {

    }

    @ open exists@
    identifier open_f;
    identifier i, f;
    identifier open1.nested_open;
    @@
    int open_f(struct inode *i, struct file *f)
    {

    }

    @ read disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {

    }

    @ read_no_fpos disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ write @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {

    }

    @ write_no_fpos @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ fops0 @
    identifier fops;
    @@
    struct file_operations fops = {
    ...
    };

    @ has_llseek depends on fops0 @
    identifier fops0.fops;
    identifier llseek_f;
    @@
    struct file_operations fops = {
    ...
    .llseek = llseek_f,
    ...
    };

    @ has_read depends on fops0 @
    identifier fops0.fops;
    identifier read_f;
    @@
    struct file_operations fops = {
    ...
    .read = read_f,
    ...
    };

    @ has_write depends on fops0 @
    identifier fops0.fops;
    identifier write_f;
    @@
    struct file_operations fops = {
    ...
    .write = write_f,
    ...
    };

    @ has_open depends on fops0 @
    identifier fops0.fops;
    identifier open_f;
    @@
    struct file_operations fops = {
    ...
    .open = open_f,
    ...
    };

    // use no_llseek if we call nonseekable_open
    ////////////////////////////////////////////
    @ nonseekable1 depends on !has_llseek && has_open @
    identifier fops0.fops;
    identifier nso ~= "nonseekable_open";
    @@
    struct file_operations fops = {
    ... .open = nso, ...
    +.llseek = no_llseek, /* nonseekable */
    };

    @ nonseekable2 depends on !has_llseek @
    identifier fops0.fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ... .open = open_f, ...
    +.llseek = no_llseek, /* open uses nonseekable */
    };

    // use seq_lseek for sequential files
    /////////////////////////////////////
    @ seq depends on !has_llseek @
    identifier fops0.fops;
    identifier sr ~= "seq_read";
    @@
    struct file_operations fops = {
    ... .read = sr, ...
    +.llseek = seq_lseek, /* we have seq_read */
    };

    // use default_llseek if there is a readdir
    ///////////////////////////////////////////
    @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier readdir_e;
    @@
    // any other fop is used that changes pos
    struct file_operations fops = {
    ... .readdir = readdir_e, ...
    +.llseek = default_llseek, /* readdir is present */
    };

    // use default_llseek if at least one of read/write touches f_pos
    /////////////////////////////////////////////////////////////////
    @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read.read_f;
    @@
    // read fops use offset
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = default_llseek, /* read accesses f_pos */
    };

    @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ... .write = write_f, ...
    + .llseek = default_llseek, /* write accesses f_pos */
    };

    // Use noop_llseek if neither read nor write accesses f_pos
    ///////////////////////////////////////////////////////////

    @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    identifier write_no_fpos.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ...
    .write = write_f,
    .read = read_f,
    ...
    +.llseek = noop_llseek, /* read and write both use no f_pos */
    };

    @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write_no_fpos.write_f;
    @@
    struct file_operations fops = {
    ... .write = write_f, ...
    +.llseek = noop_llseek, /* write uses no f_pos */
    };

    @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    @@
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = noop_llseek, /* read uses no f_pos */
    };

    @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    @@
    struct file_operations fops = {
    ...
    +.llseek = noop_llseek, /* no read or write fn */
    };
    ===== End semantic patch =====

    Signed-off-by: Arnd Bergmann
    Cc: Julia Lawall
    Cc: Christoph Hellwig

    Arnd Bergmann
     

10 Sep, 2010

1 commit

  • The gcov-kernel infrastructure expects that each object file is loaded
    only once. This may not be true, e.g. when loading multiple kernel
    modules which are linked to the same object file. As a result, loading
    such kernel modules will result in incorrect gcov results while unloading
    will cause a null-pointer dereference.

    This patch fixes these problems by changing the gcov-kernel infrastructure
    so that multiple profiling data sets can be associated with one debugfs
    entry. It applies to 2.6.36-rc1.

    Signed-off-by: Peter Oberparleiter
    Reported-by: Werner Spies
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Oberparleiter
     

21 Sep, 2009

1 commit


20 Aug, 2009

1 commit

  • Make it possible to enable GCOV code coverage measurement on powerpc.

    Lightly tested on 64-bit, seems to work as expected.

    Signed-off-by: Michael Ellerman
    Signed-off-by: Benjamin Herrenschmidt

    Michael Ellerman
     

19 Jun, 2009

2 commits

  • Enable gcov profiling of the entire kernel on x86_64. Required changes
    include disabling profiling for:

    * arch/kernel/acpi/realmode and arch/kernel/boot/compressed:
    not linked to main kernel
    * arch/vdso, arch/kernel/vsyscall_64 and arch/kernel/hpet:
    profiling causes segfaults during boot (incompatible context)

    Signed-off-by: Peter Oberparleiter
    Cc: Andi Kleen
    Cc: Huang Ying
    Cc: Li Wei
    Cc: Michael Ellerman
    Cc: Ingo Molnar
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Rusty Russell
    Cc: WANG Cong
    Cc: Sam Ravnborg
    Cc: Jeff Dike
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Oberparleiter
     
  • Enable the use of GCC's coverage testing tool gcov [1] with the Linux
    kernel. gcov may be useful for:

    * debugging (has this code been reached at all?)
    * test improvement (how do I change my test to cover these lines?)
    * minimizing kernel configurations (do I need this option if the
    associated code is never run?)

    The profiling patch incorporates the following changes:

    * change kbuild to include profiling flags
    * provide functions needed by profiling code
    * present profiling data as files in debugfs

    Note that on some architectures, enabling gcc's profiling option
    "-fprofile-arcs" for the entire kernel may trigger compile/link/
    run-time problems, some of which are caused by toolchain bugs and
    others which require adjustment of architecture code.

    For this reason profiling the entire kernel is initially restricted
    to those architectures for which it is known to work without changes.
    This restriction can be lifted once an architecture has been tested
    and found compatible with gcc's profiling. Profiling of single files
    or directories is still available on all platforms (see config help
    text).

    [1] http://gcc.gnu.org/onlinedocs/gcc/Gcov.html

    Signed-off-by: Peter Oberparleiter
    Cc: Andi Kleen
    Cc: Huang Ying
    Cc: Li Wei
    Cc: Michael Ellerman
    Cc: Ingo Molnar
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Rusty Russell
    Cc: WANG Cong
    Cc: Sam Ravnborg
    Cc: Jeff Dike
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Oberparleiter