30 Dec, 2020

1 commit

  • commit 3577afb0052fca65e67efdfc8e0859bb7bac87a6 upstream.

    In commit a2d375eda771 ("dyndbg: refine export, rename to
    dynamic_debug_exec_queries()"), a string is copied before checking it
    isn't NULL. Fix this, report a usage/interface error, and return the
    proper error code.

    Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()")
    Cc: stable@vger.kernel.org
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20201209183625.2432329-1-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

27 Sep, 2020

1 commit


11 Sep, 2020

2 commits

  • This reverts commit 14775b04964264189caa4a0862eac05dab8c0502 as there
    were still some parsing problems with it, and the follow-on patch for
    it.

    Let's revisit it later, just drop it for now.

    Cc:
    Cc: Jim Cromie
    Reported-by: Naresh Kamboju
    Cc: Stephen Rothwell
    Fixes: 14775b049642 ("dyndbg: accept query terms like file=bar and module=foo")
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • This reverts commit 42f07816ac0cc797928119cc039c414ae2b95d34 as it
    still causes problems. It will be resolved later, let's revert it so we
    can also revert the original patch this was supposed to be helping with.

    Reported-by: Naresh Kamboju
    Fixes: 42f07816ac0c ("dyndbg: fix problem parsing format="foo bar"")
    Cc: Jim Cromie
    Cc: Stephen Rothwell
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

04 Sep, 2020

3 commits

  • commit 14775b049642 ("dyndbg: accept query terms like file=bar and
    module=foo") added the combined keyword=value parsing poorly; revert
    most of it, keeping the keyword & arg change.

    Instead, fix the tokenizer for the new input, by terminating the
    keyword (an unquoted word) on '=' as well as space, thus letting the
    tokenizer work on the quoted argument, like it would have previously.

    Also add a few debug-prints to show more parsing context, into
    tokenizer and parse-query, and use "keyword, value" in others.

    Fixes: 14775b049642 ("dyndbg: accept query terms like file=bar and module=foo")
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200831182210.850852-4-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • commit 4c0d77828d4f ("dyndbg: export ddebug_exec_queries") had a few
    problems:
    - broken non DYNAMIC_DEBUG_CORE configs, sparse warning
    - the exported function modifies query string, breaks on RO strings.
    - func name follows internal convention, shouldn't be exposed as is.

    1st is fixed in header with ifdefd function prototype or stub defn.
    Also remove an obsolete HAVE-symbol ifdef-comment, and add others.

    Fix others by wrapping existing internal function with a new one,
    named in accordance with module-prefix naming convention, before
    export hits v5.9.0. In new function, copy query string to a local
    buffer, so users can pass hard-coded/RO queries, and internal function
    can be used unchanged.

    Fixes: 4c0d77828d4f ("dyndbg: export ddebug_exec_queries")
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200831182210.850852-3-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Specify the print-width so log entries line up nicely.

    no functional changes.

    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200831182210.850852-2-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

24 Jul, 2020

16 commits

  • Export ddebug_exec_queries() for use by modules.

    This will allow module authors to control all their *pr_debug*s
    dynamically. And since ddebug_exec_queries() is what implements
    "echo $query >control", it gives the same per-callsite control.

    Virtues of this:
    - simplicity. just an export.
    - full control over any/all subsets of callsites.
    - same "query/command-string" in code and console
    - full callsite selectivity with module file line format

    Format in particular deserves special attention; it is where
    low-hanging fruit will be found.

    Consider: drivers/gpu/drm/amd/display/include/logger_types.h:

    #define DC_LOG_SURFACE(...) pr_debug("[SURFACE]:"__VA_ARGS__)
    #define DC_LOG_HW_LINK_TRAINING(...) pr_debug("[HW_LINK_TRAINING]:"__VA_ARGS__)
    .. 9 more ..

    Thats 11 string prefixes, used in 804 places in drivers/gpu/**
    Clearly this is a systematized classification of those callsites.
    And one I'd expect to see repeated often.

    Using ddebug_exec_queries(), authors can select on those prefixes
    as a unitary set, equivalent to:

    echo "module=MODULE_NAME format=^[SURFACE]: +p" >control

    Trivially, those sets can be subsected with the other query terms too,
    say file=foo, should the author see fit.

    Perhaps as important, users can modify the set of enabled callsites,
    presumably to aid debugging by enabling helpful debug callsites, and
    disabling those that just clutter the info.

    Authors could even alter [fmlt] flags, though I dont see a good reason
    why they would. Perhaps harnessed by bug-logging automation to get
    fuller, or more minimal bug-reports.

    DRM

    drm has both drm.debug, which defines 32 categories of drm_printk
    logging, and entirely separate uses of pr_debug, which are dynamic on
    this i915 laptop, running mainline. So I can observe and report on
    both.

    The i915 driver has 118 dyndbg callsites, with following
    "classifications" defined in drivers/gpu/drm/i915/gvt/**

    $ grep 915 /proc/dynamic_debug/control | cut -d= -f2 | cut -d: -f1,2 | sort -u
    _ "gvt: cmd
    _ "gvt: core
    _ "gvt: dpy
    _ "gvt: el
    _ "gvt: irq
    _ "gvt: mm
    _ "gvt: mmio
    _ "gvt: render
    _ "gvt: sched
    _ "%s for root hub!\012"
    _ "Vendor defined info completion code %u\012"

    This classification is entirely out-of-band for control by drm.debug,
    and is only available to root user at the console. But module authors
    can activate them with ddebug_exec_queries(sprintf("format=^%s +p")),
    and then decide how to expose the groups to the user for max utility.

    drm.debug

    drm.debug has 32 bit-flags, and matching enum drm_debug_category
    values to classify the ~2943 DRM_DEBUG*() callsites in drivers/gpu

    The drm.debug callback could invoke ddebug_exec_queries() with 32
    different hardcoded query strings, needing only (bit) ? " +p" : " -p"
    added.

    I briefly enabled drm.debug=0xff on my i915 laptop, which yielded
    these unique prefixes: (dmesg | cut -c17- | cut -d\] -f1 | sort -u)

    [drm:drm_atomic_check_only [drm
    [drm:drm_atomic_get_crtc_state [drm
    [drm:drm_atomic_get_plane_state [drm
    [drm:drm_atomic_nonblocking_commit [drm
    [drm:drm_atomic_set_fb_for_plane [drm
    [drm:drm_atomic_state_default_clear [drm
    [drm:__drm_atomic_state_free [drm
    [drm:drm_atomic_state_init [drm
    [drm:drm_crtc_vblank_helper_get_vblank_timestamp_internal [drm
    [drm:drm_handle_vblank [drm
    [drm:drm_ioctl [drm
    [drm:drm_mode_addfb2 [drm
    [drm:drm_mode_object_get [drm
    [drm:drm_mode_object_put.part.0 [drm
    [drm:drm_update_vblank_count [drm
    [drm:drm_vblank_enable [drm
    [drm:drm_vblank_restore [drm
    [drm:vblank_disable_fn [drm
    i915 0000:00:02.0: [drm:gen9_set_dc_state [i915
    i915 0000:00:02.0: [drm:intel_atomic_get_global_obj_state [i915
    i915 0000:00:02.0: [drm:__intel_display_power_get_domain.part.0 [i915
    i915 0000:00:02.0: [drm:__intel_display_power_put_domain [i915
    i915 0000:00:02.0: [drm:intel_plane_atomic_calc_changes [i915
    i915 0000:00:02.0: [drm:skl_enable_dc6 [i915

    Several good format=^prefixes are apparent there, and some misses.

    ^[drm:drm_atomic_ # misses: [drm:__drm_atomic_state_free [drm
    ^[drm:drm_ioctl
    ^[drm:drm_mode
    ^[drm:drm_vblank_ # misses: [drm:drm_update_vblank_count & [drm:vblank_disable_fn

    Its not a perfect 1:1 single format-match per class, but the misses
    above can be covered with 1 & 2 additional queries, which can be
    concatenated together with ";" separators and submitted with 1 call.

    Benefits:

    For drm, adapting DRM_DEBUG to use dynamic-debug inside could
    replicate (and thereby obsolete) lots of bit-checking in current
    DRM_DEBUG callsites, at least with JUMP_LABEL optimized code.
    ddebug_exec_queries() and a handful of fixed query-strings can select
    and thereby control the already classified callsites.

    With the classes mapped to queries, the enum type and parameter can be
    eliminated (folded away with macro magic), at least for DYNAMIC_DEBUG
    & JUMP_LABEL builds.

    Is it safe ?

    ddebug_exec_queries() is currently exposed to user space in
    several limited ways;

    1 it is called from module-load callback, where it implements the
    $modname.dyndbg=+p "fake" parameter provided to all modules.

    2 it handles query input via >control directly

    IOW, it is "fully" exposed to local root user; exposing the same
    functionality to other kernel modules is no additional risk.

    The other standard issue to check is locking:

    dyndbg has a single mutex, taken by ddebug_change to handle >control,
    and by ddebug_proc_(start|stop) to span `cat control`. Queries
    submitted via export will typically have module specified, which
    dramatically cuts the scan by ddebug_change vs "module=* +p".
    ISTM this proposed export presents no locking problems.

    TLDR;

    It would be interesting to see how drm.dyndbg=$QUERY and
    drm.debug=$HEXY would interact; it might be order dependent, as
    if given as modprobe args or in /etc/modprobe.d/

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-19-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • For log-message output, reduce column space consumed by current
    pr_fmt by dropping __func__ and shortening "dynamic_debug" to
    "dyndbg". This improves readability on narrow consoles, and better
    matches other kernel boot info messages.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-18-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • This should work:

    echo module=amd* format=^[IF_TRACE]: +p >/proc/dynamic_debug/control

    consider drivers/gpu/drm/amd/display/include/logger_types.h:
    It has 11 defines like:

    #define DC_LOG_IF_TRACE(...) pr_debug("[IF_TRACE]:"__VA_ARGS__)

    These defines are used 804 times at recent count; they are a good use
    case to evaluate existing format-message based classifications of
    *pr_debug*. Those macros prefix the supplied format with a fixed
    string, I'd expect most existing message classification schemes to do
    something similar.

    Hence we want to be able to anchor our match to the beginning of the
    format string, allowing easy construction of clear and precise
    queries, leveraging the existing classification scheme to enable and
    disable those callsites.

    Note that unlike other search terms, formats are implicitly floating
    substring matches, without the need for explicit wildcards.

    This makes no attempt at wider regex features, just the one we need.

    TLDR: Using the anchor also means the []s are less helpful for
    disamiguating the prefix from a random in-message occurrence, allowing
    shorter prefixes.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-17-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • flags & mask are used together everywhere, and are passed around
    together between multiple functions; they belong together in a struct,
    call that struct flag_settings.

    Use struct flag_settings to rework 3 functions:
    - ddebug_exec_query - declares query and flag-settings,
    calls other 2, passing flags
    - ddebug_parse_flags - fills flag_settings and returns
    - ddebug_change - test all callsites against query,
    modify passing sites.

    benefits:
    - bit-banging always needs flags & mask, best together.
    - simpler function signatures
    - 1 less parameter, less stack overhead

    no functional changes

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-16-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Current code expects "keyword" "arg" as 2 words, space separated.
    Change to also accept "keyword=arg" form as well, and drop !(nwords%2)
    requirement. Then in rest of function, use new keyword, arg variables
    instead of word[i], word[i+1]

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-15-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Accept these additional query forms:

    echo "file $filestr +_" > control

    path/to/file.c:100 # as from control, column 1
    path/to/file.c:1-100 # or any legal line-range
    path/to/file.c:func_A # as from an editor/browser
    path/to/file.c:drm_* # wildcards still work
    path/to/file.c:*_foo # lead wildcard too

    1st 2 examples are treated as line-ranges, 3-5 are treated as func's

    Doc these changes, and sprinkle in a few extra wild-card examples and
    trailing # explanation texts.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-14-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • Make the code-block reusable to later handle "file foo.c:101-200" etc.
    This is a 99% code move, with reindent, function wrap&call, +pr_debug.

    no functional changes.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-13-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • reduce word count via gcc ?: extension, no actual code change.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-12-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • loadable modules are the last in on this list, and are the only
    modules that could be removed. ddebug_remove_module() searches from
    head, but ddebug_add_module() uses list_add_tail(). Change it to
    list_add() for a micro-optimization.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-11-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • ddebug_exec_query declares an auto var, and passes it to
    ddebug_parse_query, which memsets it before using it. Drop that
    memset, instead initialize the variable in the caller; let the
    compiler decide how to do it.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-10-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • this pr_err attempts to print the string after the OP, but the string
    has been parsed and chopped up, so looks empty.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-9-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • ddebug_describe_flags() currently fills a caller provided string buffer,
    after testing its size (also passed) in a BUG_ON. Fix this by
    replacing them with a known-big-enough string buffer wrapped in a
    struct, and passing that instead.

    Also simplify ddebug_describe_flags() flags parameter from a struct to
    a member in that struct, and hoist the member deref up to the caller.
    This makes the function reusable (soon) where flags are unpacked.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-8-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • during dyndbg init, verbose logging prints its ram overhead. It
    counted strlens of struct _ddebug's 4 string members, in all callsite
    entries, which would be approximately correct if each had been
    mallocd. But they are pointers into shared .rodata; for example, all
    10 kobject callsites have identical filename, module values.

    Its best not to count that memory at all, since we cannot know they
    were linked in because of CONFIG_DYNAMIC_DEBUG=y, and we want to
    report a number that reflects what ram is saved by deconfiguring it.

    Also fix wording and size under-reporting of the __dyndbg section.

    Heres my overhead, on a virtme-run VM on a fedora-31 laptop:

    dynamic_debug:dynamic_debug_init: 260 modules, 2479 entries \
    and 10400 bytes in ddebug tables, 138824 bytes in __dyndbg section

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-7-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • dyndbg populates its callsite info into __verbose section, change that
    to a more specific and descriptive name, __dyndbg.

    Also, per checkpatch:
    simplify __attribute(..) to __section(__dyndbg) declaration.

    and 1 spelling fix, decriptor

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-6-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • The verbose/debug logging done for `cat $MNT/dynamic_debug/control` is
    voluminous (2 per control file entry + 2 per PAGE). Moreover, it just
    prints pointer and sequence, which is not useful to a dyndbg user.
    So just drop them.

    Also require verbose>=2 for several other debug printks that are a bit
    too chatty for typical needs;

    ddebug_change() prints changes, once per modified callsite. Since
    queries like "+p" will enable ~2300 callsites in a typical laptop, a
    user probably doesn't need to see them often. ddebug_exec_queries()
    still summarizes with verbose=1.

    ddebug_(add|remove)_module() also print 1 line per action on a module,
    not needed by typical modprobe user.

    This leaves verbose=1 better focussed on the >control parsing process.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-5-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • commit 4bad78c55002 ("lib/dynamic_debug.c: use seq_open_private() instead of seq_open()")'

    The commit was one of a tree-wide set which replaced open-coded
    boilerplate with a single tail-call. It therefore obsoleted the
    comment about that boilerplate, clean that up now.

    Acked-by:
    Signed-off-by: Jim Cromie
    Link: https://lore.kernel.org/r/20200719231058.1586423-4-jim.cromie@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

09 Jun, 2020

1 commit

  • Instead of enabling dynamic debug globally with CONFIG_DYNAMIC_DEBUG,
    CONFIG_DYNAMIC_DEBUG_CORE will only enable core function of dynamic
    debug. With the DYNAMIC_DEBUG_MODULE defined for any modules, dynamic
    debug will be tied to them.

    This is useful for people who only want to enable dynamic debug for
    kernel modules without worrying about kernel image size and memory
    consumption is increasing too much.

    [orson.zhai@unisoc.com: v2]
    Link: http://lkml.kernel.org/r/1587408228-10861-1-git-send-email-orson.unisoc@gmail.com

    Signed-off-by: Orson Zhai
    Signed-off-by: Andrew Morton
    Acked-by: Greg Kroah-Hartman
    Acked-by: Petr Mladek
    Cc: Jonathan Corbet
    Cc: Sergey Senozhatsky
    Cc: Steven Rostedt
    Cc: Jason Baron
    Cc: Randy Dunlap
    Link: http://lkml.kernel.org/r/1586521984-5890-1-git-send-email-orson.unisoc@gmail.com
    Signed-off-by: Linus Torvalds

    Orson Zhai
     

08 Apr, 2020

1 commit

  • Clang warns:

    ../lib/dynamic_debug.c:1034:24: warning: array comparison always
    evaluates to false [-Wtautological-compare]
    if (__start___verbose == __stop___verbose) {
    ^
    1 warning generated.

    These are not true arrays, they are linker defined symbols, which are just
    addresses. Using the address of operator silences the warning and does
    not change the resulting assembly with either clang/ld.lld or gcc/ld
    (tested with diff + objdump -Dr).

    Suggested-by: Nick Desaulniers
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Andrew Morton
    Acked-by: Jason Baron
    Link: https://github.com/ClangBuiltLinux/linux/issues/894
    Link: http://lkml.kernel.org/r/20200220051320.10739-1-natechancellor@gmail.com
    Signed-off-by: Linus Torvalds

    Nathan Chancellor
     

13 Feb, 2020

1 commit

  • With the realization that having debugfs enabled on "production" systems
    is generally not a good idea, debugfs is being disabled from more and
    more platforms over time. However, the functionality of dynamic
    debugging still is needed at times, and since it relies on debugfs for
    its user api, having debugfs disabled also forces dynamic debug to be
    disabled.

    To get around this, also create the "control" file for dynamic_debug in
    procfs. This allows people turn on debugging as needed at runtime for
    individual driverfs and subsystems.

    Reported-by: many different companies
    Cc: Jason Baron
    Acked-by: Will Deacon
    Link: https://lore.kernel.org/r/20200210211142.GB1373304@kroah.com
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

18 Jun, 2019

1 commit


02 May, 2019

1 commit

  • Similarly to dev/netdev/etc printk helpers, add standard printk helpers
    for the RDMA subsystem.

    Example output:
    efa 0000:00:06.0 efa_0: Hello World!
    efa_0: Hello World! (no parent device set)
    (NULL ib_device): Hello World! (ibdev is NULL)

    Cc: Jason Baron
    Suggested-by: Jason Gunthorpe
    Suggested-by: Leon Romanovsky
    Signed-off-by: Gal Pressman
    Reviewed-by: Leon Romanovsky
    Reviewed-by: Shiraz Saleem
    Reviewed-by: Dennis Dalessandro
    Signed-off-by: Doug Ledford

    Gal Pressman
     

08 Mar, 2019

4 commits

  • This serves two purposes: First, we get a diagnostic if (though
    extremely unlikely), any of the calls of ddebug_add_module for built-in
    code fails, effectively disabling dynamic_debug. Second, I want to make
    struct _ddebug opaque, and avoid accessing any of its members outside
    dynamic_debug.[ch].

    Link: http://lkml.kernel.org/r/20190212214150.4807-9-linux@rasmusvillemoes.dk
    Signed-off-by: Rasmus Villemoes
    Acked-by: Jason Baron
    Cc: David Sterba
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Petr Mladek
    Cc: "Rafael J . Wysocki"
    Cc: Steven Rostedt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • The only caller of ddebug_{add,remove}_module outside dynamic_debug.c is
    kernel/module.c, which is obviously not itself modular (though it would
    be an interesting exercise to make that happen...). I also fail to see
    how these interfaces can be used by modules, in-tree or not.

    Link: http://lkml.kernel.org/r/20190212214150.4807-8-linux@rasmusvillemoes.dk
    Signed-off-by: Rasmus Villemoes
    Acked-by: Jason Baron
    Cc: David Sterba
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Petr Mladek
    Cc: "Rafael J . Wysocki"
    Cc: Steven Rostedt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Now that we store the passed-in string directly in ddebug_add_module, we
    can use pointer equality instead of strcmp. This is a little more
    efficient, but more importantly, this also makes the code somewhat more
    correct:

    Currently, if one loads and then unloads a module whose name happens to
    match the KBUILD_MODNAME of some built-in functionality (which need not
    even be modular at all), all of their dynamic debug entries vanish along
    with those of the actual module. For example, loading and unloading a
    core.ko hides all pr_debugs from drivers/base/core.c and other built-in
    files called core.c (incidentally, there is an in-tree module whose name
    is core, but I just tested this with an out-of-tree trivial one).

    Link: http://lkml.kernel.org/r/20190212214150.4807-7-linux@rasmusvillemoes.dk
    Signed-off-by: Rasmus Villemoes
    Acked-by: Jason Baron
    Cc: David Sterba
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Petr Mladek
    Cc: "Rafael J . Wysocki"
    Cc: Steven Rostedt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • For built-in modules, we're already reusing the passed-in string via
    kstrdup_const(). But for actual modules (i.e. when we're called from
    dynamic_debug_setup in module.c), the passed-in string (which points at
    the name[] array inside struct module) is also guaranteed to live at
    least as long as the struct ddebug_table, since free_module() calls
    ddebug_remove_module().

    Link: http://lkml.kernel.org/r/20190212214150.4807-6-linux@rasmusvillemoes.dk
    Signed-off-by: Rasmus Villemoes
    Acked-by: Jason Baron
    Cc: David Sterba
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Petr Mladek
    Cc: "Rafael J . Wysocki"
    Cc: Steven Rostedt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     

06 Jan, 2019

1 commit

  • Currently, CONFIG_JUMP_LABEL just means "I _want_ to use jump label".

    The jump label is controlled by HAVE_JUMP_LABEL, which is defined
    like this:

    #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
    # define HAVE_JUMP_LABEL
    #endif

    We can improve this by testing 'asm goto' support in Kconfig, then
    make JUMP_LABEL depend on CC_HAS_ASM_GOTO.

    Ugly #ifdef HAVE_JUMP_LABEL will go away, and CONFIG_JUMP_LABEL will
    match to the real kernel capability.

    Signed-off-by: Masahiro Yamada
    Acked-by: Michael Ellerman (powerpc)
    Tested-by: Sedat Dilek

    Masahiro Yamada
     

18 Nov, 2017

1 commit

  • line-range is supposed to treat "1-" as "1-endoffile", so
    handle the special case by setting last_lineno to UINT_MAX.

    Fixes this error:

    dynamic_debug:ddebug_parse_query: last-line:0 < 1st-line:1
    dynamic_debug:ddebug_exec_query: query parse failed

    Link: http://lkml.kernel.org/r/10a6a101-e2be-209f-1f41-54637824788e@infradead.org
    Signed-off-by: Randy Dunlap
    Acked-by: Jason Baron
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

04 Aug, 2016

1 commit

  • Although dynamic debug is often only used for debug builds, sometimes
    its enabled for production builds as well. Minimize its impact by using
    jump labels. This reduces the text section by 7000+ bytes in the kernel
    image below. It does increase data, but this should only be referenced
    when changing the direction of the branches, and hence usually not in
    cache.

    text data bss dec hex filename
    8194852 4879776 925696 14000324 d5a0c4 vmlinux.pre
    8187337 4960224 925696 14073257 d6bda9 vmlinux.post

    Link: http://lkml.kernel.org/r/d165b465e8c89bc582d973758d40be44c33f018b.1467837322.git.jbaron@akamai.com
    Signed-off-by: Jason Baron
    Cc: "David S. Miller"
    Cc: Arnd Bergmann
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Heiko Carstens
    Cc: Joe Perches
    Cc: Martin Schwidefsky
    Cc: Michael Ellerman
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jason Baron
     

04 Jan, 2016

1 commit


07 Nov, 2015

1 commit


20 May, 2015

1 commit

  • This adds an extra argument onto parse_params() to be used
    as a way to make the unused callback a bit more useful and
    generic by allowing the caller to pass on a data structure
    of its choice. An example use case is to allow us to easily
    make module parameters for every module which we will do
    next.

    @ parse @
    identifier name, args, params, num, level_min, level_max;
    identifier unknown, param, val, doing;
    type s16;
    @@
    extern char *parse_args(const char *name,
    char *args,
    const struct kernel_param *params,
    unsigned num,
    s16 level_min,
    s16 level_max,
    + void *arg,
    int (*unknown)(char *param, char *val,
    const char *doing
    + , void *arg
    ));

    @ parse_mod @
    identifier name, args, params, num, level_min, level_max;
    identifier unknown, param, val, doing;
    type s16;
    @@
    char *parse_args(const char *name,
    char *args,
    const struct kernel_param *params,
    unsigned num,
    s16 level_min,
    s16 level_max,
    + void *arg,
    int (*unknown)(char *param, char *val,
    const char *doing
    + , void *arg
    ))
    {
    ...
    }

    @ parse_args_found @
    expression R, E1, E2, E3, E4, E5, E6;
    identifier func;
    @@

    (
    R =
    parse_args(E1, E2, E3, E4, E5, E6,
    + NULL,
    func);
    |
    R =
    parse_args(E1, E2, E3, E4, E5, E6,
    + NULL,
    &func);
    |
    R =
    parse_args(E1, E2, E3, E4, E5, E6,
    + NULL,
    NULL);
    |
    parse_args(E1, E2, E3, E4, E5, E6,
    + NULL,
    func);
    |
    parse_args(E1, E2, E3, E4, E5, E6,
    + NULL,
    &func);
    |
    parse_args(E1, E2, E3, E4, E5, E6,
    + NULL,
    NULL);
    )

    @ parse_args_unused depends on parse_args_found @
    identifier parse_args_found.func;
    @@

    int func(char *param, char *val, const char *unused
    + , void *arg
    )
    {
    ...
    }

    @ mod_unused depends on parse_args_found @
    identifier parse_args_found.func;
    expression A1, A2, A3;
    @@

    - func(A1, A2, A3);
    + func(A1, A2, A3, NULL);

    Generated-by: Coccinelle SmPL
    Cc: cocci@systeme.lip6.fr
    Cc: Tejun Heo
    Cc: Arjan van de Ven
    Cc: Greg Kroah-Hartman
    Cc: Rusty Russell
    Cc: Christoph Hellwig
    Cc: Felipe Contreras
    Cc: Ewan Milne
    Cc: Jean Delvare
    Cc: Hannes Reinecke
    Cc: Jani Nikula
    Cc: linux-kernel@vger.kernel.org
    Reviewed-by: Tejun Heo
    Acked-by: Rusty Russell
    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Greg Kroah-Hartman

    Luis R. Rodriguez
     

11 Feb, 2015

1 commit

  • Pull trivial tree changes from Jiri Kosina:
    "Patches from trivial.git that keep the world turning around.

    Mostly documentation and comment fixes, and a two corner-case code
    fixes from Alan Cox"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial:
    kexec, Kconfig: spell "architecture" properly
    mm: fix cleancache debugfs directory path
    blackfin: mach-common: ints-priority: remove unused function
    doubletalk: probe failure causes OOPS
    ARM: cache-l2x0.c: Make it clear that cache-l2x0 handles L310 cache controller
    msdos_fs.h: fix 'fields' in comment
    scsi: aic7xxx: fix comment
    ARM: l2c: fix comment
    ibmraid: fix writeable attribute with no store method
    dynamic_debug: fix comment
    doc: usbmon: fix spelling s/unpriviledged/unprivileged/
    x86: init_mem_mapping(): use capital BIOS in comment

    Linus Torvalds
     

02 Jan, 2015

1 commit