08 May, 2012

1 commit


05 May, 2012

1 commit


01 May, 2012

8 commits

  • 1- Call dynamic_debug_init() from early_initcall, not arch_initcall.
    2- Call dynamic_debug_init_debugfs() from fs_initcall, not module_init.

    RFC: This works for me on a 64 bit desktop and a i586 SBC, but is
    untested on other arches. I presume there is or was a reason
    original code used arch_initcall, maybe the constraints have changed.

    This makes facility available as soon as possible.

    2nd change has a downside when dynamic_debug.verbose=1; all the
    vpr_info()s called in the proc-fs code are activated, causing
    voluminous output from dmesg. TBD: Im unsure of this explanation, but
    the output is there. This could be fixed by changing those callsites
    to v2pr_info(if verbose > 1).

    1st change is still not early enough to enable pr_debugs in
    kernel/params, so parsing of boot-args isnt logged. The reparse of
    those args is however visible after params.dyndbg="+p" is processed.

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Pass module name into ddebug_exec_queries(), ddebug_exec_query(), and
    ddebug_parse_query() as separate parameter. In ddebug_parse_query(),
    the module name is added into the query struct before the query-string
    is parsed. This allows the query-string to be shorter:

    instead of:
    $modname.dyndbg="module $modname +fp"
    do this:
    $modname.dyndbg="+fp"

    Omitting "module $modname" from the query string is actually required
    for $modname.dyndbg rules; the set-only-once check added in a previous
    patch will throw an error if its added again. ddebug_query="..." has
    no $modname associated with it, so the query string may include it.

    This also fixes redundant "module $modname" otherwise needed to handle
    multiple queries per string:

    $modname.dyndbg="func foo +fp; func bar +fp"

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Print ram usage of dynamic-debug tables and verbose section so user
    knows cost of enabling CONFIG_DYNAMIC_DEBUG. This only counts the
    size of the _ddebug tables for builtins and the __verbose section that
    they refer to, not those used in loadable modules.

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • We dont want errors while parsing ddebug_query to unload ddebug
    tables, so set success after tables are loaded, and return 0 after
    query parsing is done.

    Simplify error handling code since its no longer used for success,
    and change goto label to out_err to clarify this.

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Refactor ddebug_dyndbg_boot_param_cb and ddebug_dyndbg_module_param_cb
    into a common helper function, and call it from both. The handling of
    foo.dyndbg is unneeded by the latter, but harmless.

    The 2 callers differ only by pr_info and the return code they pass to
    the helper for when an unknown param is handled. I could slightly
    reduce dmesg clutter by putting the vpr_info in the common helper,
    after the return on_err, but that loses __func__ context, is overly
    silent on module_cb unknown param errors, and the clutter is only when
    dynamic_debug.verbose=1 anyway.

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • With ddebug_dyndbg_boot_params_cb() handling bare dyndbg params, we
    dont need ddebug_query param anymore. Add a warning when processing
    ddebug_query= param that it is deprecated, and to change it to dyndbg=

    Add a deprecation notice for v3.8 to feature-removal-schedule.txt, and
    add a suggested deprecation period of 3 releases to the header.

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • This introduces a fake module param $module.dyndbg. Its based upon
    Thomas Renninger's $module.ddebug boot-time debugging patch from
    https://lkml.org/lkml/2010/9/15/397

    The 'fake' module parameter is provided for all modules, whether or
    not they need it. It is not explicitly added to each module, but is
    implemented in callbacks invoked from parse_args.

    For builtin modules, dynamic_debug_init() now directly calls
    parse_args(..., &ddebug_dyndbg_boot_params_cb), to process the params
    undeclared in the modules, just after the ddebug tables are processed.

    While its slightly weird to reprocess the boot params, parse_args() is
    already called repeatedly by do_initcall_levels(). More importantly,
    the dyndbg queries (given in ddebug_query or dyndbg params) cannot be
    activated until after the ddebug tables are ready, and reusing
    parse_args is cleaner than doing an ad-hoc parse. This reparse would
    break options like inc_verbosity, but they probably should be params,
    like verbosity=3.

    ddebug_dyndbg_boot_params_cb() handles both bare dyndbg (aka:
    ddebug_query) and module-prefixed dyndbg params, and ignores all other
    parameters. For example, the following will enable pr_debug()s in 4
    builtin modules, in the order given:

    dyndbg="module params +p; module aio +p" module.dyndbg=+p pci.dyndbg

    For loadable modules, parse_args() in load_module() calls
    ddebug_dyndbg_module_params_cb(). This handles bare dyndbg params as
    passed from modprobe, and errors on other unknown params.

    Note that modprobe reads /proc/cmdline, so "modprobe foo" grabs all
    foo.params, strips the "foo.", and passes these to the kernel.
    ddebug_dyndbg_module_params_cb() is again called for the unknown
    params; it handles dyndbg, and errors on others. The "doing" arg
    added previously contains the module name.

    For non CONFIG_DYNAMIC_DEBUG builds, the stub function accepts
    and ignores $module.dyndbg params, other unknowns get -ENOENT.

    If no param value is given (as in pci.dyndbg example above), "+p" is
    assumed, which enables all pr_debug callsites in the module.

    The dyndbg fake parameter is not shown in /sys/module/*/parameters,
    thus it does not use any resources. Changes to it are made via the
    control file.

    Also change pr_info in ddebug_exec_queries to vpr_info,
    no need to see it all the time.

    Signed-off-by: Jim Cromie
    CC: Thomas Renninger
    CC: Rusty Russell
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Use vpr_info to declutter code, reduce indenting, and change one
    additional pr_info call in ddebug_exec_queries.

    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

25 Jan, 2012

14 commits

  • Insert ddebug_exec_queries() in place of ddebug_exec_query(). It
    splits the query string on [;\n], and calls ddebug_exec_query() on
    each. All queries are processed independent of errors, allowing a
    query to fail, for example when a module is not installed. Empty
    lines and comments are skipped. Errors are counted, and the last
    error seen (negative) or the number of callsites found (0 or positive)
    is returned. Return code checks are altered accordingly.

    With this, multiple queries can be given in ddebug_query, allowing
    more selective enabling of callsites. As a side effect, a set of
    commands can be batched in:

    cat cmd-file > $DBGMT/dynamic_debug/control

    We dont want a ddebug_query syntax error to kill the dynamic debug
    facility, so dynamic_debug_init() zeros ddebug_exec_queries()'s return
    code after logging the appropriate message, so that ddebug tables are
    preserved and $DBGMT/dynamic_debug/control file is created. This
    would be appropriate even without accepting multiple queries.

    This patch also alters ddebug_change() to return number of callsites
    matched (which typically is the same as number of callsites changed).
    ddebug_exec_query() also returns the number found, or a negative value
    if theres a parse error on the query.

    Splitting on [;\n] prevents their use in format-specs, but selecting
    callsites on punctuation is brittle anyway, meaningful and selective
    substrings are more typical.

    Note: splitting queries on ';' before handling trailing #comments
    means that a ';' also terminates a comment, and text after the ';' is
    treated as another query. This trailing query will almost certainly
    result in a parse error and thus have no effect other than the error
    message. The double corner case with unexpected results is:

    ddebug_query="func foo +p # enable foo ; +p"

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Factor pr_info(query) out of ddebug_parse_query, into vpr_info_dq(),
    for reuse later. Also change the printed labels: file, func to agree
    with the query-spec keywords accepted in the control file. Pass ""
    when string is null, to avoid "(null)" output from sprintf. For
    format print, use precision to skip last char, assuming its '\n', no
    great harm if not, its a debug msg.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • trim_prefix(path) skips past the absolute source path root, and
    returns the pointer to the relative path from there. It is used to
    shorten the displayed path in $DBGMT/dynamic_debug/control via
    ddebug_proc_show(), and in ddebug_change() to allow relative filenames
    to be used in applied queries. For example:

    ~# echo file kernel/freezer.c +p > $DBGMT/dynamic_debug/control

    kernel/freezer.c:128 [freezer]cancel_freezing p " clean up: %s\012"

    trim_prefix(path) insures common prefix before trimming it, so
    out-of-tree module paths are shown as full absolute paths.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Current query write buffer is 256 bytes, on stack. In comparison, the
    ddebug_query boot-arg is 1024. Allocate the buffer off heap, and
    enlarge it to 4096 bytes, big enough for ~100 queries (at 40 bytes
    each), and error out if not. This makes it play nicely with large
    query sets (to be added later). The buffer should be enough for most
    uses, and others should probably be split into subsets.

    [jbaron@redhat.com: changed USER_BUF_PAGE from 4095 -> 4096 ]
    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • If a token begins with #, the remainder of query string is a comment,
    so drop it. Doing it here avoids '#' in quoted strings.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • If _ddebug table is empty (in a CONFIG_DYNAMIC_DEBUG build this
    shouldn't happen), then warn (error?) and return early. This skips
    empty table scan and parsing of setup-string, including the pr_info
    call noting the parse. By inspection, copy return-code handling from
    1st ddebug_add_module() callsite to 2nd.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Issue error when a match-spec is given multiple times in a rule.
    Previous code kept last one, but was silent about it. Docs imply only
    one is allowed by saying match-specs are ANDed together, given that
    module M cannot match both A and B. Also error when last_line < 1st_line.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Change describe_flags() to emit '=[pmflt_]+' for current callsite
    flags, or just '=_' when they're disabled. Having '=' in output
    allows a more selective grep expression; in contrast '-' may appear
    in filenames, line-ranges, and format-strings. '=' also has better
    mnemonics, saying; "the current setting is equal to ".

    This allows grep "=_" /dynamic_debug/control to see disabled
    callsites while avoiding the many occurrences of " = " seen in format
    strings.

    Enlarge flagsbufs to handle additional flag char, and alter
    ddebug_parse_flags() to allow flags=0, so that user can turn off all
    debug flags via:

    ~# echo =_ > /dynamic_debug/control

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Convert 'if (x !=NULL)' checks into 'if (x)'.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Issue keyword/parsing errors even w/o verbose set;
    uncover otherwize mysterious non-functionality.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Replace strcpy with strlcpy, and add define for the size constant.

    [jbaron@redhat.com: Use DDEBUG_STRING_SIZE for overflow check]
    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Allow changing dynamic_debug verbosity at run-time, to ease debugging
    of ddebug queries as you add them, improving usability.

    at boot time: dynamic_debug.verbose=1
    at runtime:
    root@voyage:~# echo 1 > /sys/module/dynamic_debug/parameters/verbose

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Currently any enabled dynamic-debug flag on a pr_debug callsite will
    enable printing, even if _DPRINTK_FLAGS_PRINT is off. Checking print
    flag directly allows "-p" to disable callsites without fussing with
    other flags, so the following disables everything, without altering
    flags user may have set:

    echo -p > $DBGFS/dynamic_debug/control

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Style cleanups.

    Signed-off-by: Jim Cromie
    Signed-off-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

25 Oct, 2011

1 commit

  • * 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (38 commits)
    mm: memory hotplug: Check if pages are correctly reserved on a per-section basis
    Revert "memory hotplug: Correct page reservation checking"
    Update email address for stable patch submission
    dynamic_debug: fix undefined reference to `__netdev_printk'
    dynamic_debug: use a single printk() to emit messages
    dynamic_debug: remove num_enabled accounting
    dynamic_debug: consolidate repetitive struct _ddebug descriptor definitions
    uio: Support physical addresses >32 bits on 32-bit systems
    sysfs: add unsigned long cast to prevent compile warning
    drivers: base: print rejected matches with DEBUG_DRIVER
    memory hotplug: Correct page reservation checking
    memory hotplug: Refuse to add unaligned memory regions
    remove the messy code file Documentation/zh_CN/SubmitChecklist
    ARM: mxc: convert device creation to use platform_device_register_full
    new helper to create platform devices with dma mask
    docs/driver-model: Update device class docs
    docs/driver-model: Document device.groups
    kobj_uevent: Ignore if some listeners cannot handle message
    dynamic_debug: make netif_dbg() call __netdev_printk()
    dynamic_debug: make netdev_dbg() call __netdev_printk()
    ...

    Linus Torvalds
     

19 Oct, 2011

3 commits

  • Dynamic debug recently added support for netdev_printk. It uses
    __netdev_printk() to support this functionality. However, when CONFIG_NET
    is not set, we get the following error:

    lib/built-in.o: In function `__dynamic_netdev_dbg':
    (.text+0x9fda): undefined reference to `__netdev_printk'

    Fix this by making the call to netdev_printk() contingent upon CONFIG_NET.
    We could have fixed this by defining netdev_printk() to a 'no-op' in the
    !CONFIG_NET case. However, this is not consistent with how the networking
    layer uses netdev_printk. For example, CONFIG_NET is not set,
    netdev_printk() does not have a 'no-op' definition defined.

    Signed-off-by: Jason Baron
    Acked-by: Randy Dunlap
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Jason Baron
     
  • We were using KERN_CONT to combine messages with their prefix. However,
    KERN_CONT is not smp safe, in the sense that it can interleave messages.
    This interleaving can result in printks coming out at the wrong loglevel.
    With the high frequency of printks that dynamic debug can produce this is
    not desirable.

    So make dynamic_emit_prefix() fill a char buf[64] instead of doing a
    printk directly. If we enable printing out of function, module, line, or
    pid info, they are placed in this 64 byte buffer. In my testing 64 bytes
    was enough size to fulfill all requests. Even if it's not, we can match
    up the printk itself to see where it's from, so to me this is no big deal.

    [akpm@linux-foundation.org: convert dangerous macro to C]
    Signed-off-by: Jason Baron
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Jason Baron
     
  • The num_enabled accounting isn't actually used anywhere - remove them.

    Signed-off-by: Jason Baron
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Jason Baron
     

15 Sep, 2011

1 commit


23 Aug, 2011

5 commits


04 Feb, 2011

2 commits


08 Jan, 2011

1 commit

  • On older gcc (3.3) dynamic debug fails to compile:

    include/net/inet_connection_sock.h: In function `inet_csk_reset_xmit_timer':
    include/net/inet_connection_sock.h:236: error: duplicate label declaration `do_printk'
    include/net/inet_connection_sock.h:219: error: this is a previous declaration
    include/net/inet_connection_sock.h:236: error: duplicate label declaration `out'
    include/net/inet_connection_sock.h:219: error: this is a previous declaration
    include/net/inet_connection_sock.h:236: error: duplicate label `do_printk'
    include/net/inet_connection_sock.h:236: error: duplicate label `out'

    Fix, by reverting the usage of JUMP_LABEL() in dynamic debug for now.

    Cc:
    Reported-by: Tetsuo Handa
    Tested-by: Tetsuo Handa
    Signed-off-by: Jason Baron
    Signed-off-by: Steven Rostedt

    Jason Baron
     

23 Oct, 2010

3 commits

  • * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (31 commits)
    driver core: Display error codes when class suspend fails
    Driver core: Add section count to memory_block struct
    Driver core: Add mutex for adding/removing memory blocks
    Driver core: Move find_memory_block routine
    hpilo: Despecificate driver from iLO generation
    driver core: Convert link_mem_sections to use find_memory_block_hinted.
    driver core: Introduce find_memory_block_hinted which utilizes kset_find_obj_hinted.
    kobject: Introduce kset_find_obj_hinted.
    driver core: fix build for CONFIG_BLOCK not enabled
    driver-core: base: change to new flag variable
    sysfs: only access bin file vm_ops with the active lock
    sysfs: Fail bin file mmap if vma close is implemented.
    FW_LOADER: fix kconfig dependency warning on HOTPLUG
    uio: Statically allocate uio_class and use class .dev_attrs.
    uio: Support 2^MINOR_BITS minors
    uio: Cleanup irq handling.
    uio: Don't clear driver data
    uio: Fix lack of locking in init_uio_class
    SYSFS: Allow boot time switching between deprecated and modern sysfs layout
    driver core: remove CONFIG_SYSFS_DEPRECATED_V2 but keep it for block devices
    ...

    Linus Torvalds
     
  • Having the ddebug_query= boot parameter it makes sense to set up
    dynamic debug as soon as possible.

    I expect sysfs files cannot be set up via an arch_initcall, because
    this one is even before fs_initcall. Therefore I splitted the
    dynamic_debug_init function into an early one and a later one providing
    /sys/../dynamic_debug/control file.

    Possibly dynamic_debug can be initialized even earlier, not sure whether
    this still makes sense then. I picked up arch_initcall as it covers
    quite a lot already.

    Dynamic debug needs to allocate memory, therefore it's not easily possible to
    set it up even before the command line gets parsed.
    Therefore the boot param query string is stored in a temp string which is
    applied when dynamic debug gets set up.

    This has been tested with ddebug_query="file ec.c +p"
    and I could retrieve pr_debug() messages early at boot during ACPI setup:
    ACPI: EC: Look up EC in DSDT
    ACPI: EC: ---> status = 0x08
    ACPI: EC: transaction start
    ACPI: EC: interrupt
    ACPI: EC: ---> status = 0x08
    ACPI: EC: status = 0x00
    ACPI: EC: transaction start
    ACPI: EC:
    Acked-by: jbaron@redhat.com
    Acked-by: Pekka Enberg
    CC: linux-acpi@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Thomas Renninger
     
  • Dynamic debug lacks the ability to enable debug messages at boot time.
    One could patch initramfs or service startup scripts to write to
    /sys/../dynamic_debug/control, but this sucks.

    This patch makes it possible to pass a query in the same format one can
    write to /sys/../dynamic_debug/control via boot param.
    When dynamic debug gets initialized, this query will automatically be
    applied.

    Signed-off-by: Thomas Renninger
    Acked-by: jbaron@redhat.com
    Acked-by: Pekka Enberg
    Signed-off-by: Greg Kroah-Hartman

    Thomas Renninger