1. 04 Aug, 2016 1 commit
    • Jason Baron's avatar
      dynamic_debug: add jump label support · 9049fc74
      Jason Baron authored
      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.comSigned-off-by: default avatarJason Baron <jbaron@akamai.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9049fc74
  2. 04 Jan, 2016 1 commit
  3. 06 Nov, 2015 1 commit
  4. 20 May, 2015 1 commit
    • Luis R. Rodriguez's avatar
      module: add extra argument for parse_params() callback · ecc86170
      Luis R. Rodriguez authored
      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 <tj@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Felipe Contreras <felipe.contreras@gmail.com>
      Cc: Ewan Milne <emilne@redhat.com>
      Cc: Jean Delvare <jdelvare@suse.de>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecc86170
  5. 02 Jan, 2015 1 commit
  6. 10 Dec, 2014 1 commit
  7. 13 Oct, 2014 1 commit
  8. 03 Oct, 2014 1 commit
  9. 20 Jul, 2014 1 commit
  10. 27 Jan, 2014 3 commits
  11. 23 Jan, 2014 1 commit
  12. 28 Aug, 2013 1 commit
  13. 30 Apr, 2013 1 commit
  14. 29 Apr, 2013 1 commit
  15. 17 Jan, 2013 2 commits
  16. 17 Dec, 2012 1 commit
  17. 17 Sep, 2012 4 commits
  18. 07 May, 2012 1 commit
  19. 04 May, 2012 1 commit
  20. 30 Apr, 2012 8 commits
    • Jim Cromie's avatar
      dynamic_debug: init with early_initcall, not arch_initcall · 3ec5652a
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ec5652a
    • Jim Cromie's avatar
      dynamic_debug: add modname arg to exec_query callchain · 8e59b5cf
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e59b5cf
    • Jim Cromie's avatar
      dynamic_debug: print ram usage by ddebug tables if verbose · 41076927
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41076927
    • Jim Cromie's avatar
      dynamic_debug: simplify dynamic_debug_init error exit · af442399
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af442399
    • Jim Cromie's avatar
      dynamic_debug: combine parse_args callbacks together · 6ab676e9
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ab676e9
    • Jim Cromie's avatar
      dynamic_debug: deprecate ddebug_query, suggest dyndbg instead · f0b919d9
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0b919d9
    • Jim Cromie's avatar
      dynamic_debug: make dynamic-debug work for module initialization · b48420c1
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      CC: Thomas Renninger <trenn@suse.de>
      CC: Rusty Russell <rusty@rustcorp.com.au>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b48420c1
    • Jim Cromie's avatar
      dynamic_debug: replace if (verbose) pr_info with macro vpr_info · b8ccd5de
      Jim Cromie authored
      Use vpr_info to declutter code, reduce indenting, and change one
      additional pr_info call in ddebug_exec_queries.
      Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8ccd5de
  21. 24 Jan, 2012 7 commits
    • Jim Cromie's avatar
      dynamic_debug: process multiple debug-queries on a line · 85f7f6c0
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      85f7f6c0
    • Jim Cromie's avatar
      dynamic_debug: factor vpr_info_dq out of ddebug_parse_query · 574b3725
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      574b3725
    • Jim Cromie's avatar
      dynamic_debug: add trim_prefix() to provide source-root relative paths · 2b678319
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      2b678319
    • Jim Cromie's avatar
      dynamic_debug: enlarge command/query write buffer · 7281491c
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      7281491c
    • Jim Cromie's avatar
      dynamic_debug: chop off comments in ddebug_tokenize · 8bd6026e
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      8bd6026e
    • Jim Cromie's avatar
      dynamic_debug: early return if _ddebug table is empty · b5b78f83
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      b5b78f83
    • Jim Cromie's avatar
      dynamic_debug: tighten up error checking on debug queries · 820874c7
      Jim Cromie authored
      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: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      820874c7