linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] docs: s390: restore content and update s390dbf.rst
@ 2019-07-03 10:19 Steffen Maier
  2019-07-03 10:19 ` [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst Steffen Maier
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Steffen Maier @ 2019-07-03 10:19 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
	linux-kernel

This is based on top of the 3 s390 patches Heiko already queued on our
s390 features branch.
[("Re: [PATCH v3 00/33] Convert files to ReST - part 1")
 https://www.spinics.net/lists/linux-doc/msg66137.html
 https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/log/Documentation/s390?h=features]

If I was not mistaken, some documentation was accidentally lost
and patch 1 restores it.

After having looked closer, I came up with patches 2 and 3.
Rendered successfully on a current Fedora 30 and it looks good:
$ make SPHINXDIRS="s390" htmldocs

Steffen Maier (3):
  docs: s390: restore important non-kdoc parts of s390dbf.rst
  docs: s390: unify and update s390dbf kdocs at debug.c
  docs: s390: s390dbf: typos and formatting, update crash command

 Documentation/s390/s390dbf.rst | 390 +++++++++++++++++++++++++++++++++++++++--
 arch/s390/include/asm/debug.h  | 112 ++----------
 arch/s390/kernel/debug.c       | 105 +++++++++--
 3 files changed, 473 insertions(+), 134 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst
  2019-07-03 10:19 [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Steffen Maier
@ 2019-07-03 10:19 ` Steffen Maier
  2019-07-05 10:53   ` Christian Borntraeger
  2019-07-03 10:19 ` [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c Steffen Maier
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Steffen Maier @ 2019-07-03 10:19 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
	linux-kernel

Complements previous ("s390: include/asm/debug.h add kerneldoc markups")
which seemed to have dropped important non-kdoc parts such as
user space interface (level, size, flush)
as well as views and caution regarding strings in the sprintf view.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
---
 Documentation/s390/s390dbf.rst | 339 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 339 insertions(+)

diff --git a/Documentation/s390/s390dbf.rst b/Documentation/s390/s390dbf.rst
index d2595b548879..01d66251643d 100644
--- a/Documentation/s390/s390dbf.rst
+++ b/Documentation/s390/s390dbf.rst
@@ -112,6 +112,345 @@ Kernel Interfaces:
 Predefined views:
 -----------------
 
+extern struct debug_view debug_hex_ascii_view;
+
+extern struct debug_view debug_raw_view;
+
+extern struct debug_view debug_sprintf_view;
+
+Examples
+--------
+
+::
+
+  /*
+   * hex_ascii- + raw-view Example
+   */
+
+  #include <linux/init.h>
+  #include <asm/debug.h>
+
+  static debug_info_t* debug_info;
+
+  static int init(void)
+  {
+      /* register 4 debug areas with one page each and 4 byte data field */
+
+      debug_info = debug_register ("test", 1, 4, 4 );
+      debug_register_view(debug_info,&debug_hex_ascii_view);
+      debug_register_view(debug_info,&debug_raw_view);
+
+      debug_text_event(debug_info, 4 , "one ");
+      debug_int_exception(debug_info, 4, 4711);
+      debug_event(debug_info, 3, &debug_info, 4);
+
+      return 0;
+  }
+
+  static void cleanup(void)
+  {
+      debug_unregister (debug_info);
+  }
+
+  module_init(init);
+  module_exit(cleanup);
+
+::
+
+  /*
+   * sprintf-view Example
+   */
+
+  #include <linux/init.h>
+  #include <asm/debug.h>
+
+  static debug_info_t* debug_info;
+
+  static int init(void)
+  {
+      /* register 4 debug areas with one page each and data field for */
+      /* format string pointer + 2 varargs (= 3 * sizeof(long))       */
+
+      debug_info = debug_register ("test", 1, 4, sizeof(long) * 3);
+      debug_register_view(debug_info,&debug_sprintf_view);
+
+      debug_sprintf_event(debug_info, 2 , "first event in %s:%i\n",__FILE__,__LINE__);
+      debug_sprintf_exception(debug_info, 1, "pointer to debug info: %p\n",&debug_info);
+
+      return 0;
+  }
+
+  static void cleanup(void)
+  {
+      debug_unregister (debug_info);
+  }
+
+  module_init(init);
+  module_exit(cleanup);
+
+Debugfs Interface
+-----------------
+Views to the debug logs can be investigated through reading the corresponding
+debugfs-files:
+
+Example::
+
+  > ls /sys/kernel/debug/s390dbf/dasd
+  flush  hex_ascii  level pages raw
+  > cat /sys/kernel/debug/s390dbf/dasd/hex_ascii | sort -k2,2 -s
+  00 00974733272:680099 2 - 02 0006ad7e  07 ea 4a 90 | ....
+  00 00974733272:682210 2 - 02 0006ade6  46 52 45 45 | FREE
+  00 00974733272:682213 2 - 02 0006adf6  07 ea 4a 90 | ....
+  00 00974733272:682281 1 * 02 0006ab08  41 4c 4c 43 | EXCP
+  01 00974733272:682284 2 - 02 0006ab16  45 43 4b 44 | ECKD
+  01 00974733272:682287 2 - 02 0006ab28  00 00 00 04 | ....
+  01 00974733272:682289 2 - 02 0006ab3e  00 00 00 20 | ...
+  01 00974733272:682297 2 - 02 0006ad7e  07 ea 4a 90 | ....
+  01 00974733272:684384 2 - 00 0006ade6  46 52 45 45 | FREE
+  01 00974733272:684388 2 - 00 0006adf6  07 ea 4a 90 | ....
+
+See section about predefined views for explanation of the above output!
+
+Changing the debug level
+------------------------
+
+Example::
+
+
+  > cat /sys/kernel/debug/s390dbf/dasd/level
+  3
+  > echo "5" > /sys/kernel/debug/s390dbf/dasd/level
+  > cat /sys/kernel/debug/s390dbf/dasd/level
+  5
+
+Flushing debug areas
+--------------------
+Debug areas can be flushed with piping the number of the desired
+area (0...n) to the debugfs file "flush". When using "-" all debug areas
+are flushed.
+
+Examples:
+
+1. Flush debug area 0::
+
+     > echo "0" > /sys/kernel/debug/s390dbf/dasd/flush
+
+2. Flush all debug areas::
+
+     > echo "-" > /sys/kernel/debug/s390dbf/dasd/flush
+
+Changing the size of debug areas
+------------------------------------
+It is possible the change the size of debug areas through piping
+the number of pages to the debugfs file "pages". The resize request will
+also flush the debug areas.
+
+Example:
+
+Define 4 pages for the debug areas of debug feature "dasd"::
+
+  > echo "4" > /sys/kernel/debug/s390dbf/dasd/pages
+
+Stooping the debug feature
+--------------------------
+Example:
+
+1. Check if stopping is allowed::
+
+     > cat /proc/sys/s390dbf/debug_stoppable
+
+2. Stop debug feature::
+
+     > echo 0 > /proc/sys/s390dbf/debug_active
+
+lcrash Interface
+----------------
+It is planned that the dump analysis tool lcrash gets an additional command
+'s390dbf' to display all the debug logs. With this tool it will be possible
+to investigate the debug logs on a live system and with a memory dump after
+a system crash.
+
+Investigating raw memory
+------------------------
+One last possibility to investigate the debug logs at a live
+system and after a system crash is to look at the raw memory
+under VM or at the Service Element.
+It is possible to find the anker of the debug-logs through
+the 'debug_area_first' symbol in the System map. Then one has
+to follow the correct pointers of the data-structures defined
+in debug.h and find the debug-areas in memory.
+Normally modules which use the debug feature will also have
+a global variable with the pointer to the debug-logs. Following
+this pointer it will also be possible to find the debug logs in
+memory.
+
+For this method it is recommended to use '16 * x + 4' byte (x = 0..n)
+for the length of the data field in debug_register() in
+order to see the debug entries well formatted.
+
+
+Predefined Views
+----------------
+
+There are three predefined views: hex_ascii, raw and sprintf.
+The hex_ascii view shows the data field in hex and ascii representation
+(e.g. '45 43 4b 44 | ECKD').
+The raw view returns a bytestream as the debug areas are stored in memory.
+
+The sprintf view formats the debug entries in the same way as the sprintf
+function would do. The sprintf event/exception functions write to the
+debug entry a pointer to the format string (size = sizeof(long))
+and for each vararg a long value. So e.g. for a debug entry with a format
+string plus two varargs one would need to allocate a (3 * sizeof(long))
+byte data area in the debug_register() function.
+
+IMPORTANT:
+  Using "%s" in sprintf event functions is dangerous. You can only
+  use "%s" in the sprintf event functions, if the memory for the passed string
+  is available as long as the debug feature exists. The reason behind this is
+  that due to performance considerations only a pointer to the string is stored
+  in  the debug feature. If you log a string that is freed afterwards, you will
+  get an OOPS when inspecting the debug feature, because then the debug feature
+  will access the already freed memory.
+
+NOTE:
+  If using the sprintf view do NOT use other event/exception functions
+  than the sprintf-event and -exception functions.
+
+The format of the hex_ascii and sprintf view is as follows:
+
+- Number of area
+- Timestamp (formatted as seconds and microseconds since 00:00:00 Coordinated
+  Universal Time (UTC), January 1, 1970)
+- level of debug entry
+- Exception flag (* = Exception)
+- Cpu-Number of calling task
+- Return Address to caller
+- data field
+
+The format of the raw view is:
+
+- Header as described in debug.h
+- datafield
+
+A typical line of the hex_ascii view will look like the following (first line
+is only for explanation and will not be displayed when 'cating' the view):
+
+area  time           level exception cpu caller    data (hex + ascii)
+--------------------------------------------------------------------------
+00    00964419409:440690 1 -         00  88023fe
+
+
+Defining views
+--------------
+
+Views are specified with the 'debug_view' structure. There are defined
+callback functions which are used for reading and writing the debugfs files::
+
+  struct debug_view {
+	char name[DEBUG_MAX_PROCF_LEN];
+	debug_prolog_proc_t* prolog_proc;
+	debug_header_proc_t* header_proc;
+	debug_format_proc_t* format_proc;
+	debug_input_proc_t*  input_proc;
+	void*                private_data;
+  };
+
+where::
+
+  typedef int (debug_header_proc_t) (debug_info_t* id,
+				     struct debug_view* view,
+				     int area,
+				     debug_entry_t* entry,
+				     char* out_buf);
+
+  typedef int (debug_format_proc_t) (debug_info_t* id,
+				     struct debug_view* view, char* out_buf,
+				     const char* in_buf);
+  typedef int (debug_prolog_proc_t) (debug_info_t* id,
+				     struct debug_view* view,
+				     char* out_buf);
+  typedef int (debug_input_proc_t) (debug_info_t* id,
+				    struct debug_view* view,
+				    struct file* file, const char* user_buf,
+				    size_t in_buf_size, loff_t* offset);
+
+
+The "private_data" member can be used as pointer to view specific data.
+It is not used by the debug feature itself.
+
+The output when reading a debugfs file is structured like this::
+
+  "prolog_proc output"
+
+  "header_proc output 1"  "format_proc output 1"
+  "header_proc output 2"  "format_proc output 2"
+  "header_proc output 3"  "format_proc output 3"
+  ...
+
+When a view is read from the debugfs, the Debug Feature calls the
+'prolog_proc' once for writing the prolog.
+Then 'header_proc' and 'format_proc' are called for each
+existing debug entry.
+
+The input_proc can be used to implement functionality when it is written to
+the view (e.g. like with 'echo "0" > /sys/kernel/debug/s390dbf/dasd/level).
+
+For header_proc there can be used the default function
+debug_dflt_header_fn() which is defined in debug.h.
+and which produces the same header output as the predefined views.
+E.g::
+
+  00 00964419409:440761 2 - 00 88023ec
+
+In order to see how to use the callback functions check the implementation
+of the default views!
+
+Example::
+
+  #include <asm/debug.h>
+
+  #define UNKNOWNSTR "data: %08x"
+
+  const char* messages[] =
+  {"This error...........\n",
+   "That error...........\n",
+   "Problem..............\n",
+   "Something went wrong.\n",
+   "Everything ok........\n",
+   NULL
+  };
+
+  static int debug_test_format_fn(
+     debug_info_t * id, struct debug_view *view,
+     char *out_buf, const char *in_buf
+  )
+  {
+    int i, rc = 0;
+
+    if(id->buf_size >= 4) {
+       int msg_nr = *((int*)in_buf);
+       if(msg_nr < sizeof(messages)/sizeof(char*) - 1)
+	  rc += sprintf(out_buf, "%s", messages[msg_nr]);
+       else
+	  rc += sprintf(out_buf, UNKNOWNSTR, msg_nr);
+    }
+   out:
+     return rc;
+  }
+
+  struct debug_view debug_test_view = {
+    "myview",                 /* name of view */
+    NULL,                     /* no prolog */
+    &debug_dflt_header_fn,    /* default header for each entry */
+    &debug_test_format_fn,    /* our own format function */
+    NULL,                     /* no input function */
+    NULL                      /* no private data */
+  };
+
+test:
+=====
+
 ::
 
   debug_info_t *debug_info;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c
  2019-07-03 10:19 [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Steffen Maier
  2019-07-03 10:19 ` [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst Steffen Maier
@ 2019-07-03 10:19 ` Steffen Maier
  2019-07-05 10:54   ` Christian Borntraeger
  2019-07-05 12:27   ` Vasily Gorbik
  2019-07-03 10:19 ` [PATCH 3/3] docs: s390: s390dbf: typos and formatting, update crash command Steffen Maier
  2019-07-05 12:28 ` [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Vasily Gorbik
  3 siblings, 2 replies; 9+ messages in thread
From: Steffen Maier @ 2019-07-03 10:19 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
	linux-kernel

For non-static-inlines, debug.c already had non-compliant function
header docs. So move the pure prototype kdocs of
("s390: include/asm/debug.h add kerneldoc markups")
from debug.h to debug.c and merge them with the old function docs.
Also, I had the impression that kdoc typically is at the implementation
in the compile unit rather than at the prototype in the header file.

While at it, update the short kdoc description to distinguish the
different functions. And a few more consistency cleanups.

Added a new kdoc for debug_set_critical() since debug.h comments it
as part of the API.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
---
 Documentation/s390/s390dbf.rst |   1 +
 arch/s390/include/asm/debug.h  | 112 ++++++-----------------------------------
 arch/s390/kernel/debug.c       | 105 +++++++++++++++++++++++++++++++-------
 3 files changed, 102 insertions(+), 116 deletions(-)

diff --git a/Documentation/s390/s390dbf.rst b/Documentation/s390/s390dbf.rst
index 01d66251643d..be42892b159e 100644
--- a/Documentation/s390/s390dbf.rst
+++ b/Documentation/s390/s390dbf.rst
@@ -107,6 +107,7 @@ will stay deactivated.
 Kernel Interfaces:
 ------------------
 
+.. kernel-doc:: arch/s390/kernel/debug.c
 .. kernel-doc:: arch/s390/include/asm/debug.h
 
 Predefined views:
diff --git a/arch/s390/include/asm/debug.h b/arch/s390/include/asm/debug.h
index 02c36eedd780..310134015541 100644
--- a/arch/s390/include/asm/debug.h
+++ b/arch/s390/include/asm/debug.h
@@ -95,77 +95,19 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level,
 
 /* Debug Feature API: */
 
-/**
- * debug_register() - allocates memory for a debug log.
- *
- * @name:        Name of debug log (e.g. used for debugfs entry)
- * @pages:       Number of pages, which will be allocated per area
- * @nr_areas:    Number of debug areas
- * @buf_size:    Size of data area in each debug entry
- *
- * Return:
- * - Handler for generated debug area
- * - %NULL if register failed
- *
- * Must not be called within an interrupt handler.
- */
 debug_info_t *debug_register(const char *name, int pages, int nr_areas,
 			     int buf_size);
 
-/**
- * debug_register_mode() - allocates memory for a debug log.
- *
- * @name:	Name of debug log (e.g. used for debugfs entry)
- * @pages:	Number of pages, which will be allocated per area
- * @nr_areas:	Number of debug areas
- * @buf_size:	Size of data area in each debug entry
- * @mode:	File mode for debugfs files. E.g. S_IRWXUGO
- * @uid:	User ID for debugfs files. Currently only 0 is supported.
- * @gid:	Group ID for debugfs files. Currently only 0 is supported.
- *
- * Return:
- * - Handler for generated debug area
- * - %NULL if register failed
- *
- * Must not be called within an interrupt handler
- */
 debug_info_t *debug_register_mode(const char *name, int pages, int nr_areas,
 				  int buf_size, umode_t mode, uid_t uid,
 				  gid_t gid);
 
-/**
- * debug_unregister() - frees memory for a debug log and removes all
- *			registered debug
- * views.
- *
- * @id:		handle for debug log
- *
- * Return:
- *    none
- *
- * Must not be called within an interrupt handler
- */
 void debug_unregister(debug_info_t *id);
 
-/**
- * debug_set_level() -  Sets new actual debug level if new_level is valid.
- *
- * @id:		handle for debug log
- * @new_level:	new debug level
- *
- * Return:
- *    none
- */
 void debug_set_level(debug_info_t *id, int new_level);
 
 void debug_set_critical(void);
 
-/**
- * debug_stop_all() - stops the debug feature if stopping is allowed.
- *
- * Return:
- * -   none
- */
 void debug_stop_all(void);
 
 /**
@@ -184,7 +126,7 @@ static inline bool debug_level_enabled(debug_info_t *id, int level)
 }
 
 /**
- * debug_event() - writes debug entry to active debug area
+ * debug_event() - writes binary debug entry to active debug area
  *		   (if level <= actual debug level)
  *
  * @id:		handle for debug log
@@ -194,6 +136,7 @@ static inline bool debug_level_enabled(debug_info_t *id, int level)
  *
  * Return:
  * - Address of written debug entry
+ * - %NULL if error
  */
 static inline debug_entry_t *debug_event(debug_info_t *id, int level,
 					 void *data, int length)
@@ -204,7 +147,7 @@ static inline debug_entry_t *debug_event(debug_info_t *id, int level,
 }
 
 /**
- * debug_int_event() - writes debug entry to active debug area
+ * debug_int_event() - writes unsigned integer debug entry to active debug area
  *		       (if level <= actual debug level)
  *
  * @id:		handle for debug log
@@ -226,12 +169,12 @@ static inline debug_entry_t *debug_int_event(debug_info_t *id, int level,
 }
 
 /**
- * debug_long_event() - writes debug entry to active debug area
+ * debug_long_event() - writes unsigned long debug entry to active debug area
  *		       (if level <= actual debug level)
  *
  * @id:		handle for debug log
  * @level:	debug level
- * @tag:	integer value for debug entry
+ * @tag:	long integer value for debug entry
  *
  * Return:
  * - Address of written debug entry
@@ -248,7 +191,7 @@ static inline debug_entry_t *debug_long_event(debug_info_t *id, int level,
 }
 
 /**
- * debug_text_event() - writes debug entry in ascii format to active
+ * debug_text_event() - writes string debug entry in ascii format to active
  *			debug area (if level <= actual debug level)
  *
  * @id:		handle for debug log
@@ -306,9 +249,9 @@ static inline debug_entry_t *debug_text_event(debug_info_t *id, int level,
 })
 
 /**
- * debug_exception() - writes debug entry to active debug area
- *		       (if level <= actual debug level) and switches
- *		       to next debug area
+ * debug_exception() - writes binary debug entry to active debug area
+ *		       (if level <= actual debug level)
+ *		       and switches to next debug area
  *
  * @id:		handle for debug log
  * @level:	debug level
@@ -328,7 +271,7 @@ static inline debug_entry_t *debug_exception(debug_info_t *id, int level,
 }
 
 /**
- * debug_int_exception() - writes debug entry to active debug area
+ * debug_int_exception() - writes unsigned int debug entry to active debug area
  *			   (if level <= actual debug level)
  *			   and switches to next debug area
  *
@@ -351,13 +294,13 @@ static inline debug_entry_t *debug_int_exception(debug_info_t *id, int level,
 }
 
 /**
- * debug_long_exception() - writes debug entry to active debug area
+ * debug_long_exception() - writes long debug entry to active debug area
  *			   (if level <= actual debug level)
  *			   and switches to next debug area
  *
  * @id:		handle for debug log
  * @level:	debug level
- * @tag:	integer value for debug entry
+ * @tag:	long integer value for debug entry
  *
  * Return:
  * - Address of written debug entry
@@ -374,9 +317,9 @@ static inline debug_entry_t *debug_long_exception (debug_info_t *id, int level,
 }
 
 /**
- * debug_text_exception() - writes debug entry in ascii format to active
+ * debug_text_exception() - writes string debug entry in ascii format to active
  *			    debug area (if level <= actual debug level)
- *			    and switches to next debug
+ *			    and switches to next debug area
  * area
  *
  * @id:	handle for debug log
@@ -407,7 +350,7 @@ static inline debug_entry_t *debug_text_exception(debug_info_t *id, int level,
 /**
  * debug_sprintf_exception() - writes debug entry with format string and
  *			       varargs (longs) to active debug area
- *			       (if level $<=$ actual debug level)
+ *			       (if level <= actual debug level)
  *			       and switches to next debug area.
  *
  * @_id:	handle for debug log
@@ -435,33 +378,8 @@ static inline debug_entry_t *debug_text_exception(debug_info_t *id, int level,
 	__ret;								\
 })
 
-/**
- * debug_register_view() - registers new debug view and creates debugfs
- *			   dir entry
- *
- * @id:	handle for debug log
- * @view:	pointer to debug view struct
- *
- * Return:
- * -   0  : ok
- * -   < 0: Error
- */
 int debug_register_view(debug_info_t *id, struct debug_view *view);
 
-/**
- * debug_unregister_view()
- *
- * @id:	handle for debug log
- * @view:	pointer to debug view struct
- *
- * Return:
- * -   0  : ok
- * -   < 0: Error
- *
- *
- * unregisters debug view and removes debugfs dir entry
- */
-
 int debug_unregister_view(debug_info_t *id, struct debug_view *view);
 
 /*
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 0ebf08c3b35e..70a44bad625f 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -647,11 +647,23 @@ static int debug_close(struct inode *inode, struct file *file)
 	return 0; /* success */
 }
 
-/*
- * debug_register_mode:
- * - Creates and initializes debug area for the caller
- *   The mode parameter allows to specify access rights for the s390dbf files
- * - Returns handle for debug area
+/**
+ * debug_register_mode() - creates and initializes debug area.
+ *
+ * @name:	Name of debug log (e.g. used for debugfs entry)
+ * @pages_per_area:	Number of pages, which will be allocated per area
+ * @nr_areas:	Number of debug areas
+ * @buf_size:	Size of data area in each debug entry
+ * @mode:	File mode for debugfs files. E.g. S_IRWXUGO
+ * @uid:	User ID for debugfs files. Currently only 0 is supported.
+ * @gid:	Group ID for debugfs files. Currently only 0 is supported.
+ *
+ * Return:
+ * - Handle for generated debug area
+ * - %NULL if register failed
+ *
+ * Allocates memory for a debug log.
+ * Must not be called within an interrupt handler.
  */
 debug_info_t *debug_register_mode(const char *name, int pages_per_area,
 				  int nr_areas, int buf_size, umode_t mode,
@@ -681,10 +693,21 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
 }
 EXPORT_SYMBOL(debug_register_mode);
 
-/*
- * debug_register:
- * - creates and initializes debug area for the caller
- * - returns handle for debug area
+/**
+ * debug_register() - creates and initializes debug area with default file mode.
+ *
+ * @name:	Name of debug log (e.g. used for debugfs entry)
+ * @pages_per_area:	Number of pages, which will be allocated per area
+ * @nr_areas:	Number of debug areas
+ * @buf_size:	Size of data area in each debug entry
+ *
+ * Return:
+ * - Handle for generated debug area
+ * - %NULL if register failed
+ *
+ * Allocates memory for a debug log.
+ * The debugfs file mode access permisions are read and write for user.
+ * Must not be called within an interrupt handler.
  */
 debug_info_t *debug_register(const char *name, int pages_per_area,
 			     int nr_areas, int buf_size)
@@ -694,9 +717,13 @@ debug_info_t *debug_register(const char *name, int pages_per_area,
 }
 EXPORT_SYMBOL(debug_register);
 
-/*
- * debug_unregister:
- * - give back debug area
+/**
+ * debug_unregister() -  give back debug area.
+ *
+ * @id:		handle for debug log
+ *
+ * Return:
+ *    none
  */
 void debug_unregister(debug_info_t *id)
 {
@@ -745,9 +772,14 @@ static int debug_set_size(debug_info_t *id, int nr_areas, int pages_per_area)
 	return rc;
 }
 
-/*
- * debug_set_level:
- * - set actual debug level
+/**
+ * debug_set_level() -  Sets new actual debug level if new_level is valid.
+ *
+ * @id:		handle for debug log
+ * @new_level:	new debug level
+ *
+ * Return:
+ *    none
  */
 void debug_set_level(debug_info_t *id, int new_level)
 {
@@ -873,6 +905,14 @@ static int s390dbf_procactive(struct ctl_table *table, int write,
 
 static struct ctl_table_header *s390dbf_sysctl_header;
 
+/**
+ * debug_stop_all() - stops the debug feature if stopping is allowed.
+ *
+ * Return:
+ * -   none
+ *
+ * Currently used in case of a kernel oops.
+ */
 void debug_stop_all(void)
 {
 	if (debug_stoppable)
@@ -880,6 +920,17 @@ void debug_stop_all(void)
 }
 EXPORT_SYMBOL(debug_stop_all);
 
+/**
+ * debug_set_critical() - event/exception functions try lock instead of spin.
+ *
+ * Return:
+ * -   none
+ *
+ * Currently used in case of stopping all CPUs but the current one.
+ * Once in this state, functions to write a debug entry for an
+ * event or exception no longer spin on the debug area lock,
+ * but only try to get it and fail if they do not get the lock.
+ */
 void debug_set_critical(void)
 {
 	debug_critical = 1;
@@ -1036,8 +1087,16 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri
 }
 EXPORT_SYMBOL(__debug_sprintf_exception);
 
-/*
- * debug_register_view:
+/**
+ * debug_register_view() - registers new debug view and creates debugfs
+ *			   dir entry
+ *
+ * @id:		handle for debug log
+ * @view:	pointer to debug view struct
+ *
+ * Return:
+ * -   0  : ok
+ * -   < 0: Error
  */
 int debug_register_view(debug_info_t *id, struct debug_view *view)
 {
@@ -1077,8 +1136,16 @@ int debug_register_view(debug_info_t *id, struct debug_view *view)
 }
 EXPORT_SYMBOL(debug_register_view);
 
-/*
- * debug_unregister_view:
+/**
+ * debug_unregister_view() - unregisters debug view and removes debugfs
+ *			     dir entry
+ *
+ * @id:		handle for debug log
+ * @view:	pointer to debug view struct
+ *
+ * Return:
+ * -   0  : ok
+ * -   < 0: Error
  */
 int debug_unregister_view(debug_info_t *id, struct debug_view *view)
 {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] docs: s390: s390dbf: typos and formatting, update crash command
  2019-07-03 10:19 [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Steffen Maier
  2019-07-03 10:19 ` [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst Steffen Maier
  2019-07-03 10:19 ` [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c Steffen Maier
@ 2019-07-03 10:19 ` Steffen Maier
  2019-07-05 10:54   ` Christian Borntraeger
  2019-07-05 12:28 ` [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Vasily Gorbik
  3 siblings, 1 reply; 9+ messages in thread
From: Steffen Maier @ 2019-07-03 10:19 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger,
	linux-kernel

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
---
 Documentation/s390/s390dbf.rst | 122 +++++++++++++++++++++++------------------
 1 file changed, 68 insertions(+), 54 deletions(-)

diff --git a/Documentation/s390/s390dbf.rst b/Documentation/s390/s390dbf.rst
index be42892b159e..cdb36842b898 100644
--- a/Documentation/s390/s390dbf.rst
+++ b/Documentation/s390/s390dbf.rst
@@ -23,7 +23,8 @@ The debug feature may also very useful for kernel and driver development.
 Design:
 -------
 Kernel components (e.g. device drivers) can register themselves at the debug
-feature with the function call debug_register(). This function initializes a
+feature with the function call :c:func:`debug_register()`.
+This function initializes a
 debug log for the caller. For each debug log exists a number of debug areas
 where exactly one is active at one time.  Each debug area consists of contiguous
 pages in memory. In the debug areas there are stored debug entries (log records)
@@ -44,8 +45,9 @@ The debug areas themselves are also ordered in form of a ring buffer.
 When an exception is thrown in the last debug area, the following debug
 entries are then written again in the very first area.
 
-There are three versions for the event- and exception-calls: One for
-logging raw data, one for text and one for numbers.
+There are four versions for the event- and exception-calls: One for
+logging raw data, one for text, one for numbers (unsigned int and long),
+and one for sprintf-like formatted strings.
 
 Each debug entry contains the following data:
 
@@ -56,29 +58,29 @@ Each debug entry contains the following data:
 - Flag, if entry is an exception or not
 
 The debug logs can be inspected in a live system through entries in
-the debugfs-filesystem. Under the toplevel directory "s390dbf" there is
+the debugfs-filesystem. Under the toplevel directory "``s390dbf``" there is
 a directory for each registered component, which is named like the
 corresponding component. The debugfs normally should be mounted to
-/sys/kernel/debug therefore the debug feature can be accessed under
-/sys/kernel/debug/s390dbf.
+``/sys/kernel/debug`` therefore the debug feature can be accessed under
+``/sys/kernel/debug/s390dbf``.
 
 The content of the directories are files which represent different views
 to the debug log. Each component can decide which views should be
-used through registering them with the function debug_register_view().
+used through registering them with the function :c:func:`debug_register_view()`.
 Predefined views for hex/ascii, sprintf and raw binary data are provided.
 It is also possible to define other views. The content of
 a view can be inspected simply by reading the corresponding debugfs file.
 
 All debug logs have an actual debug level (range from 0 to 6).
-The default level is 3. Event and Exception functions have a 'level'
+The default level is 3. Event and Exception functions have a :c:data:`level`
 parameter. Only debug entries with a level that is lower or equal
 than the actual level are written to the log. This means, when
 writing events, high priority log entries should have a low level
 value whereas low priority entries should have a high one.
 The actual debug level can be changed with the help of the debugfs-filesystem
-through writing a number string "x" to the 'level' debugfs file which is
+through writing a number string "x" to the ``level`` debugfs file which is
 provided for every debug log. Debugging can be switched off completely
-by using "-" on the 'level' debugfs file.
+by using "-" on the ``level`` debugfs file.
 
 Example::
 
@@ -86,21 +88,21 @@ Example::
 
 It is also possible to deactivate the debug feature globally for every
 debug log. You can change the behavior using  2 sysctl parameters in
-/proc/sys/s390dbf:
+``/proc/sys/s390dbf``:
 
 There are currently 2 possible triggers, which stop the debug feature
-globally. The first possibility is to use the "debug_active" sysctl. If
-set to 1 the debug feature is running. If "debug_active" is set to 0 the
+globally. The first possibility is to use the ``debug_active`` sysctl. If
+set to 1 the debug feature is running. If ``debug_active`` is set to 0 the
 debug feature is turned off.
 
 The second trigger which stops the debug feature is a kernel oops.
 That prevents the debug feature from overwriting debug information that
 happened before the oops. After an oops you can reactivate the debug feature
-by piping 1 to /proc/sys/s390dbf/debug_active. Nevertheless, its not
+by piping 1 to ``/proc/sys/s390dbf/debug_active``. Nevertheless, it's not
 suggested to use an oopsed kernel in a production environment.
 
 If you want to disallow the deactivation of the debug feature, you can use
-the "debug_stoppable" sysctl. If you set "debug_stoppable" to 0 the debug
+the ``debug_stoppable`` sysctl. If you set ``debug_stoppable`` to 0 the debug
 feature cannot be stopped. If the debug feature is already stopped, it
 will stay deactivated.
 
@@ -113,16 +115,18 @@ Kernel Interfaces:
 Predefined views:
 -----------------
 
-extern struct debug_view debug_hex_ascii_view;
+.. code-block:: c
 
-extern struct debug_view debug_raw_view;
+  extern struct debug_view debug_hex_ascii_view;
 
-extern struct debug_view debug_sprintf_view;
+  extern struct debug_view debug_raw_view;
+
+  extern struct debug_view debug_sprintf_view;
 
 Examples
 --------
 
-::
+.. code-block:: c
 
   /*
    * hex_ascii- + raw-view Example
@@ -131,15 +135,15 @@ Examples
   #include <linux/init.h>
   #include <asm/debug.h>
 
-  static debug_info_t* debug_info;
+  static debug_info_t *debug_info;
 
   static int init(void)
   {
       /* register 4 debug areas with one page each and 4 byte data field */
 
-      debug_info = debug_register ("test", 1, 4, 4 );
-      debug_register_view(debug_info,&debug_hex_ascii_view);
-      debug_register_view(debug_info,&debug_raw_view);
+      debug_info = debug_register("test", 1, 4, 4 );
+      debug_register_view(debug_info, &debug_hex_ascii_view);
+      debug_register_view(debug_info, &debug_raw_view);
 
       debug_text_event(debug_info, 4 , "one ");
       debug_int_exception(debug_info, 4, 4711);
@@ -150,13 +154,13 @@ Examples
 
   static void cleanup(void)
   {
-      debug_unregister (debug_info);
+      debug_unregister(debug_info);
   }
 
   module_init(init);
   module_exit(cleanup);
 
-::
+.. code-block:: c
 
   /*
    * sprintf-view Example
@@ -165,15 +169,15 @@ Examples
   #include <linux/init.h>
   #include <asm/debug.h>
 
-  static debug_info_t* debug_info;
+  static debug_info_t *debug_info;
 
   static int init(void)
   {
       /* register 4 debug areas with one page each and data field for */
       /* format string pointer + 2 varargs (= 3 * sizeof(long))       */
 
-      debug_info = debug_register ("test", 1, 4, sizeof(long) * 3);
-      debug_register_view(debug_info,&debug_sprintf_view);
+      debug_info = debug_register("test", 1, 4, sizeof(long) * 3);
+      debug_register_view(debug_info, &debug_sprintf_view);
 
       debug_sprintf_event(debug_info, 2 , "first event in %s:%i\n",__FILE__,__LINE__);
       debug_sprintf_exception(debug_info, 1, "pointer to debug info: %p\n",&debug_info);
@@ -183,7 +187,7 @@ Examples
 
   static void cleanup(void)
   {
-      debug_unregister (debug_info);
+      debug_unregister(debug_info);
   }
 
   module_init(init);
@@ -252,7 +256,7 @@ Define 4 pages for the debug areas of debug feature "dasd"::
 
   > echo "4" > /sys/kernel/debug/s390dbf/dasd/pages
 
-Stooping the debug feature
+Stopping the debug feature
 --------------------------
 Example:
 
@@ -264,10 +268,11 @@ Example:
 
      > echo 0 > /proc/sys/s390dbf/debug_active
 
-lcrash Interface
+crash Interface
 ----------------
-It is planned that the dump analysis tool lcrash gets an additional command
-'s390dbf' to display all the debug logs. With this tool it will be possible
+The ``crash`` tool since v5.1.0 has a built-in command
+``s390dbf`` to display all the debug logs or export them to the file system.
+With this tool it is possible
 to investigate the debug logs on a live system and with a memory dump after
 a system crash.
 
@@ -276,8 +281,8 @@ Investigating raw memory
 One last possibility to investigate the debug logs at a live
 system and after a system crash is to look at the raw memory
 under VM or at the Service Element.
-It is possible to find the anker of the debug-logs through
-the 'debug_area_first' symbol in the System map. Then one has
+It is possible to find the anchor of the debug-logs through
+the ``debug_area_first`` symbol in the System map. Then one has
 to follow the correct pointers of the data-structures defined
 in debug.h and find the debug-areas in memory.
 Normally modules which use the debug feature will also have
@@ -286,7 +291,7 @@ this pointer it will also be possible to find the debug logs in
 memory.
 
 For this method it is recommended to use '16 * x + 4' byte (x = 0..n)
-for the length of the data field in debug_register() in
+for the length of the data field in :c:func:`debug_register()` in
 order to see the debug entries well formatted.
 
 
@@ -295,7 +300,7 @@ Predefined Views
 
 There are three predefined views: hex_ascii, raw and sprintf.
 The hex_ascii view shows the data field in hex and ascii representation
-(e.g. '45 43 4b 44 | ECKD').
+(e.g. ``45 43 4b 44 | ECKD``).
 The raw view returns a bytestream as the debug areas are stored in memory.
 
 The sprintf view formats the debug entries in the same way as the sprintf
@@ -335,18 +340,20 @@ The format of the raw view is:
 - datafield
 
 A typical line of the hex_ascii view will look like the following (first line
-is only for explanation and will not be displayed when 'cating' the view):
+is only for explanation and will not be displayed when 'cating' the view)::
 
-area  time           level exception cpu caller    data (hex + ascii)
---------------------------------------------------------------------------
-00    00964419409:440690 1 -         00  88023fe
+  area  time           level exception cpu caller    data (hex + ascii)
+  --------------------------------------------------------------------------
+  00    00964419409:440690 1 -         00  88023fe
 
 
 Defining views
 --------------
 
 Views are specified with the 'debug_view' structure. There are defined
-callback functions which are used for reading and writing the debugfs files::
+callback functions which are used for reading and writing the debugfs files:
+
+.. code-block:: c
 
   struct debug_view {
 	char name[DEBUG_MAX_PROCF_LEN];
@@ -357,7 +364,9 @@ callback functions which are used for reading and writing the debugfs files::
 	void*                private_data;
   };
 
-where::
+where:
+
+.. code-block:: c
 
   typedef int (debug_header_proc_t) (debug_info_t* id,
 				     struct debug_view* view,
@@ -395,10 +404,10 @@ Then 'header_proc' and 'format_proc' are called for each
 existing debug entry.
 
 The input_proc can be used to implement functionality when it is written to
-the view (e.g. like with 'echo "0" > /sys/kernel/debug/s390dbf/dasd/level).
+the view (e.g. like with ``echo "0" > /sys/kernel/debug/s390dbf/dasd/level``).
 
 For header_proc there can be used the default function
-debug_dflt_header_fn() which is defined in debug.h.
+:c:func:`debug_dflt_header_fn()` which is defined in debug.h.
 and which produces the same header output as the predefined views.
 E.g::
 
@@ -407,7 +416,9 @@ E.g::
 In order to see how to use the callback functions check the implementation
 of the default views!
 
-Example::
+Example:
+
+.. code-block:: c
 
   #include <asm/debug.h>
 
@@ -423,21 +434,20 @@ Example::
   };
 
   static int debug_test_format_fn(
-     debug_info_t * id, struct debug_view *view,
+     debug_info_t *id, struct debug_view *view,
      char *out_buf, const char *in_buf
   )
   {
     int i, rc = 0;
 
-    if(id->buf_size >= 4) {
+    if (id->buf_size >= 4) {
        int msg_nr = *((int*)in_buf);
-       if(msg_nr < sizeof(messages)/sizeof(char*) - 1)
+       if (msg_nr < sizeof(messages) / sizeof(char*) - 1)
 	  rc += sprintf(out_buf, "%s", messages[msg_nr]);
        else
 	  rc += sprintf(out_buf, UNKNOWNSTR, msg_nr);
     }
-   out:
-     return rc;
+    return rc;
   }
 
   struct debug_view debug_test_view = {
@@ -452,13 +462,17 @@ Example::
 test:
 =====
 
-::
+.. code-block:: c
 
   debug_info_t *debug_info;
+  int i;
   ...
-  debug_info = debug_register ("test", 0, 4, 4 ));
+  debug_info = debug_register("test", 0, 4, 4);
   debug_register_view(debug_info, &debug_test_view);
-  for(i = 0; i < 10; i ++) debug_int_event(debug_info, 1, i);
+  for (i = 0; i < 10; i ++)
+    debug_int_event(debug_info, 1, i);
+
+::
 
   > cat /sys/kernel/debug/s390dbf/test/myview
   00 00964419734:611402 1 - 00 88042ca   This error...........
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst
  2019-07-03 10:19 ` [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst Steffen Maier
@ 2019-07-05 10:53   ` Christian Borntraeger
  0 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2019-07-05 10:53 UTC (permalink / raw)
  To: Steffen Maier, linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, linux-kernel



On 03.07.19 12:19, Steffen Maier wrote:
> Complements previous ("s390: include/asm/debug.h add kerneldoc markups")
> which seemed to have dropped important non-kdoc parts such as
> user space interface (level, size, flush)
> as well as views and caution regarding strings in the sprintf view.
> 
> Signed-off-by: Steffen Maier <maier@linux.ibm.com>

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  Documentation/s390/s390dbf.rst | 339 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 339 insertions(+)
> 
> diff --git a/Documentation/s390/s390dbf.rst b/Documentation/s390/s390dbf.rst
> index d2595b548879..01d66251643d 100644
> --- a/Documentation/s390/s390dbf.rst
> +++ b/Documentation/s390/s390dbf.rst
> @@ -112,6 +112,345 @@ Kernel Interfaces:
>  Predefined views:
>  -----------------
>  
> +extern struct debug_view debug_hex_ascii_view;
> +
> +extern struct debug_view debug_raw_view;
> +
> +extern struct debug_view debug_sprintf_view;
> +
> +Examples
> +--------
> +
> +::
> +
> +  /*
> +   * hex_ascii- + raw-view Example
> +   */
> +
> +  #include <linux/init.h>
> +  #include <asm/debug.h>
> +
> +  static debug_info_t* debug_info;
> +
> +  static int init(void)
> +  {
> +      /* register 4 debug areas with one page each and 4 byte data field */
> +
> +      debug_info = debug_register ("test", 1, 4, 4 );
> +      debug_register_view(debug_info,&debug_hex_ascii_view);
> +      debug_register_view(debug_info,&debug_raw_view);
> +
> +      debug_text_event(debug_info, 4 , "one ");
> +      debug_int_exception(debug_info, 4, 4711);
> +      debug_event(debug_info, 3, &debug_info, 4);
> +
> +      return 0;
> +  }
> +
> +  static void cleanup(void)
> +  {
> +      debug_unregister (debug_info);
> +  }
> +
> +  module_init(init);
> +  module_exit(cleanup);
> +
> +::
> +
> +  /*
> +   * sprintf-view Example
> +   */
> +
> +  #include <linux/init.h>
> +  #include <asm/debug.h>
> +
> +  static debug_info_t* debug_info;
> +
> +  static int init(void)
> +  {
> +      /* register 4 debug areas with one page each and data field for */
> +      /* format string pointer + 2 varargs (= 3 * sizeof(long))       */
> +
> +      debug_info = debug_register ("test", 1, 4, sizeof(long) * 3);
> +      debug_register_view(debug_info,&debug_sprintf_view);
> +
> +      debug_sprintf_event(debug_info, 2 , "first event in %s:%i\n",__FILE__,__LINE__);
> +      debug_sprintf_exception(debug_info, 1, "pointer to debug info: %p\n",&debug_info);
> +
> +      return 0;
> +  }
> +
> +  static void cleanup(void)
> +  {
> +      debug_unregister (debug_info);
> +  }
> +
> +  module_init(init);
> +  module_exit(cleanup);
> +
> +Debugfs Interface
> +-----------------
> +Views to the debug logs can be investigated through reading the corresponding
> +debugfs-files:
> +
> +Example::
> +
> +  > ls /sys/kernel/debug/s390dbf/dasd
> +  flush  hex_ascii  level pages raw
> +  > cat /sys/kernel/debug/s390dbf/dasd/hex_ascii | sort -k2,2 -s
> +  00 00974733272:680099 2 - 02 0006ad7e  07 ea 4a 90 | ....
> +  00 00974733272:682210 2 - 02 0006ade6  46 52 45 45 | FREE
> +  00 00974733272:682213 2 - 02 0006adf6  07 ea 4a 90 | ....
> +  00 00974733272:682281 1 * 02 0006ab08  41 4c 4c 43 | EXCP
> +  01 00974733272:682284 2 - 02 0006ab16  45 43 4b 44 | ECKD
> +  01 00974733272:682287 2 - 02 0006ab28  00 00 00 04 | ....
> +  01 00974733272:682289 2 - 02 0006ab3e  00 00 00 20 | ...
> +  01 00974733272:682297 2 - 02 0006ad7e  07 ea 4a 90 | ....
> +  01 00974733272:684384 2 - 00 0006ade6  46 52 45 45 | FREE
> +  01 00974733272:684388 2 - 00 0006adf6  07 ea 4a 90 | ....
> +
> +See section about predefined views for explanation of the above output!
> +
> +Changing the debug level
> +------------------------
> +
> +Example::
> +
> +
> +  > cat /sys/kernel/debug/s390dbf/dasd/level
> +  3
> +  > echo "5" > /sys/kernel/debug/s390dbf/dasd/level
> +  > cat /sys/kernel/debug/s390dbf/dasd/level
> +  5
> +
> +Flushing debug areas
> +--------------------
> +Debug areas can be flushed with piping the number of the desired
> +area (0...n) to the debugfs file "flush". When using "-" all debug areas
> +are flushed.
> +
> +Examples:
> +
> +1. Flush debug area 0::
> +
> +     > echo "0" > /sys/kernel/debug/s390dbf/dasd/flush
> +
> +2. Flush all debug areas::
> +
> +     > echo "-" > /sys/kernel/debug/s390dbf/dasd/flush
> +
> +Changing the size of debug areas
> +------------------------------------
> +It is possible the change the size of debug areas through piping
> +the number of pages to the debugfs file "pages". The resize request will
> +also flush the debug areas.
> +
> +Example:
> +
> +Define 4 pages for the debug areas of debug feature "dasd"::
> +
> +  > echo "4" > /sys/kernel/debug/s390dbf/dasd/pages
> +
> +Stooping the debug feature
> +--------------------------
> +Example:
> +
> +1. Check if stopping is allowed::
> +
> +     > cat /proc/sys/s390dbf/debug_stoppable
> +
> +2. Stop debug feature::
> +
> +     > echo 0 > /proc/sys/s390dbf/debug_active
> +
> +lcrash Interface
> +----------------
> +It is planned that the dump analysis tool lcrash gets an additional command
> +'s390dbf' to display all the debug logs. With this tool it will be possible
> +to investigate the debug logs on a live system and with a memory dump after
> +a system crash.
> +
> +Investigating raw memory
> +------------------------
> +One last possibility to investigate the debug logs at a live
> +system and after a system crash is to look at the raw memory
> +under VM or at the Service Element.
> +It is possible to find the anker of the debug-logs through
> +the 'debug_area_first' symbol in the System map. Then one has
> +to follow the correct pointers of the data-structures defined
> +in debug.h and find the debug-areas in memory.
> +Normally modules which use the debug feature will also have
> +a global variable with the pointer to the debug-logs. Following
> +this pointer it will also be possible to find the debug logs in
> +memory.
> +
> +For this method it is recommended to use '16 * x + 4' byte (x = 0..n)
> +for the length of the data field in debug_register() in
> +order to see the debug entries well formatted.
> +
> +
> +Predefined Views
> +----------------
> +
> +There are three predefined views: hex_ascii, raw and sprintf.
> +The hex_ascii view shows the data field in hex and ascii representation
> +(e.g. '45 43 4b 44 | ECKD').
> +The raw view returns a bytestream as the debug areas are stored in memory.
> +
> +The sprintf view formats the debug entries in the same way as the sprintf
> +function would do. The sprintf event/exception functions write to the
> +debug entry a pointer to the format string (size = sizeof(long))
> +and for each vararg a long value. So e.g. for a debug entry with a format
> +string plus two varargs one would need to allocate a (3 * sizeof(long))
> +byte data area in the debug_register() function.
> +
> +IMPORTANT:
> +  Using "%s" in sprintf event functions is dangerous. You can only
> +  use "%s" in the sprintf event functions, if the memory for the passed string
> +  is available as long as the debug feature exists. The reason behind this is
> +  that due to performance considerations only a pointer to the string is stored
> +  in  the debug feature. If you log a string that is freed afterwards, you will
> +  get an OOPS when inspecting the debug feature, because then the debug feature
> +  will access the already freed memory.
> +
> +NOTE:
> +  If using the sprintf view do NOT use other event/exception functions
> +  than the sprintf-event and -exception functions.
> +
> +The format of the hex_ascii and sprintf view is as follows:
> +
> +- Number of area
> +- Timestamp (formatted as seconds and microseconds since 00:00:00 Coordinated
> +  Universal Time (UTC), January 1, 1970)
> +- level of debug entry
> +- Exception flag (* = Exception)
> +- Cpu-Number of calling task
> +- Return Address to caller
> +- data field
> +
> +The format of the raw view is:
> +
> +- Header as described in debug.h
> +- datafield
> +
> +A typical line of the hex_ascii view will look like the following (first line
> +is only for explanation and will not be displayed when 'cating' the view):
> +
> +area  time           level exception cpu caller    data (hex + ascii)
> +--------------------------------------------------------------------------
> +00    00964419409:440690 1 -         00  88023fe
> +
> +
> +Defining views
> +--------------
> +
> +Views are specified with the 'debug_view' structure. There are defined
> +callback functions which are used for reading and writing the debugfs files::
> +
> +  struct debug_view {
> +	char name[DEBUG_MAX_PROCF_LEN];
> +	debug_prolog_proc_t* prolog_proc;
> +	debug_header_proc_t* header_proc;
> +	debug_format_proc_t* format_proc;
> +	debug_input_proc_t*  input_proc;
> +	void*                private_data;
> +  };
> +
> +where::
> +
> +  typedef int (debug_header_proc_t) (debug_info_t* id,
> +				     struct debug_view* view,
> +				     int area,
> +				     debug_entry_t* entry,
> +				     char* out_buf);
> +
> +  typedef int (debug_format_proc_t) (debug_info_t* id,
> +				     struct debug_view* view, char* out_buf,
> +				     const char* in_buf);
> +  typedef int (debug_prolog_proc_t) (debug_info_t* id,
> +				     struct debug_view* view,
> +				     char* out_buf);
> +  typedef int (debug_input_proc_t) (debug_info_t* id,
> +				    struct debug_view* view,
> +				    struct file* file, const char* user_buf,
> +				    size_t in_buf_size, loff_t* offset);
> +
> +
> +The "private_data" member can be used as pointer to view specific data.
> +It is not used by the debug feature itself.
> +
> +The output when reading a debugfs file is structured like this::
> +
> +  "prolog_proc output"
> +
> +  "header_proc output 1"  "format_proc output 1"
> +  "header_proc output 2"  "format_proc output 2"
> +  "header_proc output 3"  "format_proc output 3"
> +  ...
> +
> +When a view is read from the debugfs, the Debug Feature calls the
> +'prolog_proc' once for writing the prolog.
> +Then 'header_proc' and 'format_proc' are called for each
> +existing debug entry.
> +
> +The input_proc can be used to implement functionality when it is written to
> +the view (e.g. like with 'echo "0" > /sys/kernel/debug/s390dbf/dasd/level).
> +
> +For header_proc there can be used the default function
> +debug_dflt_header_fn() which is defined in debug.h.
> +and which produces the same header output as the predefined views.
> +E.g::
> +
> +  00 00964419409:440761 2 - 00 88023ec
> +
> +In order to see how to use the callback functions check the implementation
> +of the default views!
> +
> +Example::
> +
> +  #include <asm/debug.h>
> +
> +  #define UNKNOWNSTR "data: %08x"
> +
> +  const char* messages[] =
> +  {"This error...........\n",
> +   "That error...........\n",
> +   "Problem..............\n",
> +   "Something went wrong.\n",
> +   "Everything ok........\n",
> +   NULL
> +  };
> +
> +  static int debug_test_format_fn(
> +     debug_info_t * id, struct debug_view *view,
> +     char *out_buf, const char *in_buf
> +  )
> +  {
> +    int i, rc = 0;
> +
> +    if(id->buf_size >= 4) {
> +       int msg_nr = *((int*)in_buf);
> +       if(msg_nr < sizeof(messages)/sizeof(char*) - 1)
> +	  rc += sprintf(out_buf, "%s", messages[msg_nr]);
> +       else
> +	  rc += sprintf(out_buf, UNKNOWNSTR, msg_nr);
> +    }
> +   out:
> +     return rc;
> +  }
> +
> +  struct debug_view debug_test_view = {
> +    "myview",                 /* name of view */
> +    NULL,                     /* no prolog */
> +    &debug_dflt_header_fn,    /* default header for each entry */
> +    &debug_test_format_fn,    /* our own format function */
> +    NULL,                     /* no input function */
> +    NULL                      /* no private data */
> +  };
> +
> +test:
> +=====
> +
>  ::
>  
>    debug_info_t *debug_info;
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c
  2019-07-03 10:19 ` [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c Steffen Maier
@ 2019-07-05 10:54   ` Christian Borntraeger
  2019-07-05 12:27   ` Vasily Gorbik
  1 sibling, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2019-07-05 10:54 UTC (permalink / raw)
  To: Steffen Maier, linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, linux-kernel



On 03.07.19 12:19, Steffen Maier wrote:
> For non-static-inlines, debug.c already had non-compliant function
> header docs. So move the pure prototype kdocs of
> ("s390: include/asm/debug.h add kerneldoc markups")
> from debug.h to debug.c and merge them with the old function docs.
> Also, I had the impression that kdoc typically is at the implementation
> in the compile unit rather than at the prototype in the header file.
> 
> While at it, update the short kdoc description to distinguish the
> different functions. And a few more consistency cleanups.
> 
> Added a new kdoc for debug_set_critical() since debug.h comments it
> as part of the API.
> 
> Signed-off-by: Steffen Maier <maier@linux.ibm.com>

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  Documentation/s390/s390dbf.rst |   1 +
>  arch/s390/include/asm/debug.h  | 112 ++++++-----------------------------------
>  arch/s390/kernel/debug.c       | 105 +++++++++++++++++++++++++++++++-------
>  3 files changed, 102 insertions(+), 116 deletions(-)
> 
> diff --git a/Documentation/s390/s390dbf.rst b/Documentation/s390/s390dbf.rst
> index 01d66251643d..be42892b159e 100644
> --- a/Documentation/s390/s390dbf.rst
> +++ b/Documentation/s390/s390dbf.rst
> @@ -107,6 +107,7 @@ will stay deactivated.
>  Kernel Interfaces:
>  ------------------
>  
> +.. kernel-doc:: arch/s390/kernel/debug.c
>  .. kernel-doc:: arch/s390/include/asm/debug.h
>  
>  Predefined views:
> diff --git a/arch/s390/include/asm/debug.h b/arch/s390/include/asm/debug.h
> index 02c36eedd780..310134015541 100644
> --- a/arch/s390/include/asm/debug.h
> +++ b/arch/s390/include/asm/debug.h
> @@ -95,77 +95,19 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level,
>  
>  /* Debug Feature API: */
>  
> -/**
> - * debug_register() - allocates memory for a debug log.
> - *
> - * @name:        Name of debug log (e.g. used for debugfs entry)
> - * @pages:       Number of pages, which will be allocated per area
> - * @nr_areas:    Number of debug areas
> - * @buf_size:    Size of data area in each debug entry
> - *
> - * Return:
> - * - Handler for generated debug area
> - * - %NULL if register failed
> - *
> - * Must not be called within an interrupt handler.
> - */
>  debug_info_t *debug_register(const char *name, int pages, int nr_areas,
>  			     int buf_size);
>  
> -/**
> - * debug_register_mode() - allocates memory for a debug log.
> - *
> - * @name:	Name of debug log (e.g. used for debugfs entry)
> - * @pages:	Number of pages, which will be allocated per area
> - * @nr_areas:	Number of debug areas
> - * @buf_size:	Size of data area in each debug entry
> - * @mode:	File mode for debugfs files. E.g. S_IRWXUGO
> - * @uid:	User ID for debugfs files. Currently only 0 is supported.
> - * @gid:	Group ID for debugfs files. Currently only 0 is supported.
> - *
> - * Return:
> - * - Handler for generated debug area
> - * - %NULL if register failed
> - *
> - * Must not be called within an interrupt handler
> - */
>  debug_info_t *debug_register_mode(const char *name, int pages, int nr_areas,
>  				  int buf_size, umode_t mode, uid_t uid,
>  				  gid_t gid);
>  
> -/**
> - * debug_unregister() - frees memory for a debug log and removes all
> - *			registered debug
> - * views.
> - *
> - * @id:		handle for debug log
> - *
> - * Return:
> - *    none
> - *
> - * Must not be called within an interrupt handler
> - */
>  void debug_unregister(debug_info_t *id);
>  
> -/**
> - * debug_set_level() -  Sets new actual debug level if new_level is valid.
> - *
> - * @id:		handle for debug log
> - * @new_level:	new debug level
> - *
> - * Return:
> - *    none
> - */
>  void debug_set_level(debug_info_t *id, int new_level);
>  
>  void debug_set_critical(void);
>  
> -/**
> - * debug_stop_all() - stops the debug feature if stopping is allowed.
> - *
> - * Return:
> - * -   none
> - */
>  void debug_stop_all(void);
>  
>  /**
> @@ -184,7 +126,7 @@ static inline bool debug_level_enabled(debug_info_t *id, int level)
>  }
>  
>  /**
> - * debug_event() - writes debug entry to active debug area
> + * debug_event() - writes binary debug entry to active debug area
>   *		   (if level <= actual debug level)
>   *
>   * @id:		handle for debug log
> @@ -194,6 +136,7 @@ static inline bool debug_level_enabled(debug_info_t *id, int level)
>   *
>   * Return:
>   * - Address of written debug entry
> + * - %NULL if error
>   */
>  static inline debug_entry_t *debug_event(debug_info_t *id, int level,
>  					 void *data, int length)
> @@ -204,7 +147,7 @@ static inline debug_entry_t *debug_event(debug_info_t *id, int level,
>  }
>  
>  /**
> - * debug_int_event() - writes debug entry to active debug area
> + * debug_int_event() - writes unsigned integer debug entry to active debug area
>   *		       (if level <= actual debug level)
>   *
>   * @id:		handle for debug log
> @@ -226,12 +169,12 @@ static inline debug_entry_t *debug_int_event(debug_info_t *id, int level,
>  }
>  
>  /**
> - * debug_long_event() - writes debug entry to active debug area
> + * debug_long_event() - writes unsigned long debug entry to active debug area
>   *		       (if level <= actual debug level)
>   *
>   * @id:		handle for debug log
>   * @level:	debug level
> - * @tag:	integer value for debug entry
> + * @tag:	long integer value for debug entry
>   *
>   * Return:
>   * - Address of written debug entry
> @@ -248,7 +191,7 @@ static inline debug_entry_t *debug_long_event(debug_info_t *id, int level,
>  }
>  
>  /**
> - * debug_text_event() - writes debug entry in ascii format to active
> + * debug_text_event() - writes string debug entry in ascii format to active
>   *			debug area (if level <= actual debug level)
>   *
>   * @id:		handle for debug log
> @@ -306,9 +249,9 @@ static inline debug_entry_t *debug_text_event(debug_info_t *id, int level,
>  })
>  
>  /**
> - * debug_exception() - writes debug entry to active debug area
> - *		       (if level <= actual debug level) and switches
> - *		       to next debug area
> + * debug_exception() - writes binary debug entry to active debug area
> + *		       (if level <= actual debug level)
> + *		       and switches to next debug area
>   *
>   * @id:		handle for debug log
>   * @level:	debug level
> @@ -328,7 +271,7 @@ static inline debug_entry_t *debug_exception(debug_info_t *id, int level,
>  }
>  
>  /**
> - * debug_int_exception() - writes debug entry to active debug area
> + * debug_int_exception() - writes unsigned int debug entry to active debug area
>   *			   (if level <= actual debug level)
>   *			   and switches to next debug area
>   *
> @@ -351,13 +294,13 @@ static inline debug_entry_t *debug_int_exception(debug_info_t *id, int level,
>  }
>  
>  /**
> - * debug_long_exception() - writes debug entry to active debug area
> + * debug_long_exception() - writes long debug entry to active debug area
>   *			   (if level <= actual debug level)
>   *			   and switches to next debug area
>   *
>   * @id:		handle for debug log
>   * @level:	debug level
> - * @tag:	integer value for debug entry
> + * @tag:	long integer value for debug entry
>   *
>   * Return:
>   * - Address of written debug entry
> @@ -374,9 +317,9 @@ static inline debug_entry_t *debug_long_exception (debug_info_t *id, int level,
>  }
>  
>  /**
> - * debug_text_exception() - writes debug entry in ascii format to active
> + * debug_text_exception() - writes string debug entry in ascii format to active
>   *			    debug area (if level <= actual debug level)
> - *			    and switches to next debug
> + *			    and switches to next debug area
>   * area
>   *
>   * @id:	handle for debug log
> @@ -407,7 +350,7 @@ static inline debug_entry_t *debug_text_exception(debug_info_t *id, int level,
>  /**
>   * debug_sprintf_exception() - writes debug entry with format string and
>   *			       varargs (longs) to active debug area
> - *			       (if level $<=$ actual debug level)
> + *			       (if level <= actual debug level)
>   *			       and switches to next debug area.
>   *
>   * @_id:	handle for debug log
> @@ -435,33 +378,8 @@ static inline debug_entry_t *debug_text_exception(debug_info_t *id, int level,
>  	__ret;								\
>  })
>  
> -/**
> - * debug_register_view() - registers new debug view and creates debugfs
> - *			   dir entry
> - *
> - * @id:	handle for debug log
> - * @view:	pointer to debug view struct
> - *
> - * Return:
> - * -   0  : ok
> - * -   < 0: Error
> - */
>  int debug_register_view(debug_info_t *id, struct debug_view *view);
>  
> -/**
> - * debug_unregister_view()
> - *
> - * @id:	handle for debug log
> - * @view:	pointer to debug view struct
> - *
> - * Return:
> - * -   0  : ok
> - * -   < 0: Error
> - *
> - *
> - * unregisters debug view and removes debugfs dir entry
> - */
> -
>  int debug_unregister_view(debug_info_t *id, struct debug_view *view);
>  
>  /*
> diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
> index 0ebf08c3b35e..70a44bad625f 100644
> --- a/arch/s390/kernel/debug.c
> +++ b/arch/s390/kernel/debug.c
> @@ -647,11 +647,23 @@ static int debug_close(struct inode *inode, struct file *file)
>  	return 0; /* success */
>  }
>  
> -/*
> - * debug_register_mode:
> - * - Creates and initializes debug area for the caller
> - *   The mode parameter allows to specify access rights for the s390dbf files
> - * - Returns handle for debug area
> +/**
> + * debug_register_mode() - creates and initializes debug area.
> + *
> + * @name:	Name of debug log (e.g. used for debugfs entry)
> + * @pages_per_area:	Number of pages, which will be allocated per area
> + * @nr_areas:	Number of debug areas
> + * @buf_size:	Size of data area in each debug entry
> + * @mode:	File mode for debugfs files. E.g. S_IRWXUGO
> + * @uid:	User ID for debugfs files. Currently only 0 is supported.
> + * @gid:	Group ID for debugfs files. Currently only 0 is supported.
> + *
> + * Return:
> + * - Handle for generated debug area
> + * - %NULL if register failed
> + *
> + * Allocates memory for a debug log.
> + * Must not be called within an interrupt handler.
>   */
>  debug_info_t *debug_register_mode(const char *name, int pages_per_area,
>  				  int nr_areas, int buf_size, umode_t mode,
> @@ -681,10 +693,21 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
>  }
>  EXPORT_SYMBOL(debug_register_mode);
>  
> -/*
> - * debug_register:
> - * - creates and initializes debug area for the caller
> - * - returns handle for debug area
> +/**
> + * debug_register() - creates and initializes debug area with default file mode.
> + *
> + * @name:	Name of debug log (e.g. used for debugfs entry)
> + * @pages_per_area:	Number of pages, which will be allocated per area
> + * @nr_areas:	Number of debug areas
> + * @buf_size:	Size of data area in each debug entry
> + *
> + * Return:
> + * - Handle for generated debug area
> + * - %NULL if register failed
> + *
> + * Allocates memory for a debug log.
> + * The debugfs file mode access permisions are read and write for user.
> + * Must not be called within an interrupt handler.
>   */
>  debug_info_t *debug_register(const char *name, int pages_per_area,
>  			     int nr_areas, int buf_size)
> @@ -694,9 +717,13 @@ debug_info_t *debug_register(const char *name, int pages_per_area,
>  }
>  EXPORT_SYMBOL(debug_register);
>  
> -/*
> - * debug_unregister:
> - * - give back debug area
> +/**
> + * debug_unregister() -  give back debug area.
> + *
> + * @id:		handle for debug log
> + *
> + * Return:
> + *    none
>   */
>  void debug_unregister(debug_info_t *id)
>  {
> @@ -745,9 +772,14 @@ static int debug_set_size(debug_info_t *id, int nr_areas, int pages_per_area)
>  	return rc;
>  }
>  
> -/*
> - * debug_set_level:
> - * - set actual debug level
> +/**
> + * debug_set_level() -  Sets new actual debug level if new_level is valid.
> + *
> + * @id:		handle for debug log
> + * @new_level:	new debug level
> + *
> + * Return:
> + *    none
>   */
>  void debug_set_level(debug_info_t *id, int new_level)
>  {
> @@ -873,6 +905,14 @@ static int s390dbf_procactive(struct ctl_table *table, int write,
>  
>  static struct ctl_table_header *s390dbf_sysctl_header;
>  
> +/**
> + * debug_stop_all() - stops the debug feature if stopping is allowed.
> + *
> + * Return:
> + * -   none
> + *
> + * Currently used in case of a kernel oops.
> + */
>  void debug_stop_all(void)
>  {
>  	if (debug_stoppable)
> @@ -880,6 +920,17 @@ void debug_stop_all(void)
>  }
>  EXPORT_SYMBOL(debug_stop_all);
>  
> +/**
> + * debug_set_critical() - event/exception functions try lock instead of spin.
> + *
> + * Return:
> + * -   none
> + *
> + * Currently used in case of stopping all CPUs but the current one.
> + * Once in this state, functions to write a debug entry for an
> + * event or exception no longer spin on the debug area lock,
> + * but only try to get it and fail if they do not get the lock.
> + */
>  void debug_set_critical(void)
>  {
>  	debug_critical = 1;
> @@ -1036,8 +1087,16 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri
>  }
>  EXPORT_SYMBOL(__debug_sprintf_exception);
>  
> -/*
> - * debug_register_view:
> +/**
> + * debug_register_view() - registers new debug view and creates debugfs
> + *			   dir entry
> + *
> + * @id:		handle for debug log
> + * @view:	pointer to debug view struct
> + *
> + * Return:
> + * -   0  : ok
> + * -   < 0: Error
>   */
>  int debug_register_view(debug_info_t *id, struct debug_view *view)
>  {
> @@ -1077,8 +1136,16 @@ int debug_register_view(debug_info_t *id, struct debug_view *view)
>  }
>  EXPORT_SYMBOL(debug_register_view);
>  
> -/*
> - * debug_unregister_view:
> +/**
> + * debug_unregister_view() - unregisters debug view and removes debugfs
> + *			     dir entry
> + *
> + * @id:		handle for debug log
> + * @view:	pointer to debug view struct
> + *
> + * Return:
> + * -   0  : ok
> + * -   < 0: Error
>   */
>  int debug_unregister_view(debug_info_t *id, struct debug_view *view)
>  {
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] docs: s390: s390dbf: typos and formatting, update crash command
  2019-07-03 10:19 ` [PATCH 3/3] docs: s390: s390dbf: typos and formatting, update crash command Steffen Maier
@ 2019-07-05 10:54   ` Christian Borntraeger
  0 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2019-07-05 10:54 UTC (permalink / raw)
  To: Steffen Maier, linux-doc
  Cc: linux-s390, Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Heiko Carstens, Vasily Gorbik, linux-kernel

On 03.07.19 12:19, Steffen Maier wrote:
> Signed-off-by: Steffen Maier <maier@linux.ibm.com>

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  Documentation/s390/s390dbf.rst | 122 +++++++++++++++++++++++------------------
>  1 file changed, 68 insertions(+), 54 deletions(-)
> 
> diff --git a/Documentation/s390/s390dbf.rst b/Documentation/s390/s390dbf.rst
> index be42892b159e..cdb36842b898 100644
> --- a/Documentation/s390/s390dbf.rst
> +++ b/Documentation/s390/s390dbf.rst
> @@ -23,7 +23,8 @@ The debug feature may also very useful for kernel and driver development.
>  Design:
>  -------
>  Kernel components (e.g. device drivers) can register themselves at the debug
> -feature with the function call debug_register(). This function initializes a
> +feature with the function call :c:func:`debug_register()`.
> +This function initializes a
>  debug log for the caller. For each debug log exists a number of debug areas
>  where exactly one is active at one time.  Each debug area consists of contiguous
>  pages in memory. In the debug areas there are stored debug entries (log records)
> @@ -44,8 +45,9 @@ The debug areas themselves are also ordered in form of a ring buffer.
>  When an exception is thrown in the last debug area, the following debug
>  entries are then written again in the very first area.
>  
> -There are three versions for the event- and exception-calls: One for
> -logging raw data, one for text and one for numbers.
> +There are four versions for the event- and exception-calls: One for
> +logging raw data, one for text, one for numbers (unsigned int and long),
> +and one for sprintf-like formatted strings.
>  
>  Each debug entry contains the following data:
>  
> @@ -56,29 +58,29 @@ Each debug entry contains the following data:
>  - Flag, if entry is an exception or not
>  
>  The debug logs can be inspected in a live system through entries in
> -the debugfs-filesystem. Under the toplevel directory "s390dbf" there is
> +the debugfs-filesystem. Under the toplevel directory "``s390dbf``" there is
>  a directory for each registered component, which is named like the
>  corresponding component. The debugfs normally should be mounted to
> -/sys/kernel/debug therefore the debug feature can be accessed under
> -/sys/kernel/debug/s390dbf.
> +``/sys/kernel/debug`` therefore the debug feature can be accessed under
> +``/sys/kernel/debug/s390dbf``.
>  
>  The content of the directories are files which represent different views
>  to the debug log. Each component can decide which views should be
> -used through registering them with the function debug_register_view().
> +used through registering them with the function :c:func:`debug_register_view()`.
>  Predefined views for hex/ascii, sprintf and raw binary data are provided.
>  It is also possible to define other views. The content of
>  a view can be inspected simply by reading the corresponding debugfs file.
>  
>  All debug logs have an actual debug level (range from 0 to 6).
> -The default level is 3. Event and Exception functions have a 'level'
> +The default level is 3. Event and Exception functions have a :c:data:`level`
>  parameter. Only debug entries with a level that is lower or equal
>  than the actual level are written to the log. This means, when
>  writing events, high priority log entries should have a low level
>  value whereas low priority entries should have a high one.
>  The actual debug level can be changed with the help of the debugfs-filesystem
> -through writing a number string "x" to the 'level' debugfs file which is
> +through writing a number string "x" to the ``level`` debugfs file which is
>  provided for every debug log. Debugging can be switched off completely
> -by using "-" on the 'level' debugfs file.
> +by using "-" on the ``level`` debugfs file.
>  
>  Example::
>  
> @@ -86,21 +88,21 @@ Example::
>  
>  It is also possible to deactivate the debug feature globally for every
>  debug log. You can change the behavior using  2 sysctl parameters in
> -/proc/sys/s390dbf:
> +``/proc/sys/s390dbf``:
>  
>  There are currently 2 possible triggers, which stop the debug feature
> -globally. The first possibility is to use the "debug_active" sysctl. If
> -set to 1 the debug feature is running. If "debug_active" is set to 0 the
> +globally. The first possibility is to use the ``debug_active`` sysctl. If
> +set to 1 the debug feature is running. If ``debug_active`` is set to 0 the
>  debug feature is turned off.
>  
>  The second trigger which stops the debug feature is a kernel oops.
>  That prevents the debug feature from overwriting debug information that
>  happened before the oops. After an oops you can reactivate the debug feature
> -by piping 1 to /proc/sys/s390dbf/debug_active. Nevertheless, its not
> +by piping 1 to ``/proc/sys/s390dbf/debug_active``. Nevertheless, it's not
>  suggested to use an oopsed kernel in a production environment.
>  
>  If you want to disallow the deactivation of the debug feature, you can use
> -the "debug_stoppable" sysctl. If you set "debug_stoppable" to 0 the debug
> +the ``debug_stoppable`` sysctl. If you set ``debug_stoppable`` to 0 the debug
>  feature cannot be stopped. If the debug feature is already stopped, it
>  will stay deactivated.
>  
> @@ -113,16 +115,18 @@ Kernel Interfaces:
>  Predefined views:
>  -----------------
>  
> -extern struct debug_view debug_hex_ascii_view;
> +.. code-block:: c
>  
> -extern struct debug_view debug_raw_view;
> +  extern struct debug_view debug_hex_ascii_view;
>  
> -extern struct debug_view debug_sprintf_view;
> +  extern struct debug_view debug_raw_view;
> +
> +  extern struct debug_view debug_sprintf_view;
>  
>  Examples
>  --------
>  
> -::
> +.. code-block:: c
>  
>    /*
>     * hex_ascii- + raw-view Example
> @@ -131,15 +135,15 @@ Examples
>    #include <linux/init.h>
>    #include <asm/debug.h>
>  
> -  static debug_info_t* debug_info;
> +  static debug_info_t *debug_info;
>  
>    static int init(void)
>    {
>        /* register 4 debug areas with one page each and 4 byte data field */
>  
> -      debug_info = debug_register ("test", 1, 4, 4 );
> -      debug_register_view(debug_info,&debug_hex_ascii_view);
> -      debug_register_view(debug_info,&debug_raw_view);
> +      debug_info = debug_register("test", 1, 4, 4 );
> +      debug_register_view(debug_info, &debug_hex_ascii_view);
> +      debug_register_view(debug_info, &debug_raw_view);
>  
>        debug_text_event(debug_info, 4 , "one ");
>        debug_int_exception(debug_info, 4, 4711);
> @@ -150,13 +154,13 @@ Examples
>  
>    static void cleanup(void)
>    {
> -      debug_unregister (debug_info);
> +      debug_unregister(debug_info);
>    }
>  
>    module_init(init);
>    module_exit(cleanup);
>  
> -::
> +.. code-block:: c
>  
>    /*
>     * sprintf-view Example
> @@ -165,15 +169,15 @@ Examples
>    #include <linux/init.h>
>    #include <asm/debug.h>
>  
> -  static debug_info_t* debug_info;
> +  static debug_info_t *debug_info;
>  
>    static int init(void)
>    {
>        /* register 4 debug areas with one page each and data field for */
>        /* format string pointer + 2 varargs (= 3 * sizeof(long))       */
>  
> -      debug_info = debug_register ("test", 1, 4, sizeof(long) * 3);
> -      debug_register_view(debug_info,&debug_sprintf_view);
> +      debug_info = debug_register("test", 1, 4, sizeof(long) * 3);
> +      debug_register_view(debug_info, &debug_sprintf_view);
>  
>        debug_sprintf_event(debug_info, 2 , "first event in %s:%i\n",__FILE__,__LINE__);
>        debug_sprintf_exception(debug_info, 1, "pointer to debug info: %p\n",&debug_info);
> @@ -183,7 +187,7 @@ Examples
>  
>    static void cleanup(void)
>    {
> -      debug_unregister (debug_info);
> +      debug_unregister(debug_info);
>    }
>  
>    module_init(init);
> @@ -252,7 +256,7 @@ Define 4 pages for the debug areas of debug feature "dasd"::
>  
>    > echo "4" > /sys/kernel/debug/s390dbf/dasd/pages
>  
> -Stooping the debug feature
> +Stopping the debug feature
>  --------------------------
>  Example:
>  
> @@ -264,10 +268,11 @@ Example:
>  
>       > echo 0 > /proc/sys/s390dbf/debug_active
>  
> -lcrash Interface
> +crash Interface
>  ----------------
> -It is planned that the dump analysis tool lcrash gets an additional command
> -'s390dbf' to display all the debug logs. With this tool it will be possible
> +The ``crash`` tool since v5.1.0 has a built-in command
> +``s390dbf`` to display all the debug logs or export them to the file system.
> +With this tool it is possible
>  to investigate the debug logs on a live system and with a memory dump after
>  a system crash.
>  
> @@ -276,8 +281,8 @@ Investigating raw memory
>  One last possibility to investigate the debug logs at a live
>  system and after a system crash is to look at the raw memory
>  under VM or at the Service Element.
> -It is possible to find the anker of the debug-logs through
> -the 'debug_area_first' symbol in the System map. Then one has
> +It is possible to find the anchor of the debug-logs through
> +the ``debug_area_first`` symbol in the System map. Then one has
>  to follow the correct pointers of the data-structures defined
>  in debug.h and find the debug-areas in memory.
>  Normally modules which use the debug feature will also have
> @@ -286,7 +291,7 @@ this pointer it will also be possible to find the debug logs in
>  memory.
>  
>  For this method it is recommended to use '16 * x + 4' byte (x = 0..n)
> -for the length of the data field in debug_register() in
> +for the length of the data field in :c:func:`debug_register()` in
>  order to see the debug entries well formatted.
>  
>  
> @@ -295,7 +300,7 @@ Predefined Views
>  
>  There are three predefined views: hex_ascii, raw and sprintf.
>  The hex_ascii view shows the data field in hex and ascii representation
> -(e.g. '45 43 4b 44 | ECKD').
> +(e.g. ``45 43 4b 44 | ECKD``).
>  The raw view returns a bytestream as the debug areas are stored in memory.
>  
>  The sprintf view formats the debug entries in the same way as the sprintf
> @@ -335,18 +340,20 @@ The format of the raw view is:
>  - datafield
>  
>  A typical line of the hex_ascii view will look like the following (first line
> -is only for explanation and will not be displayed when 'cating' the view):
> +is only for explanation and will not be displayed when 'cating' the view)::
>  
> -area  time           level exception cpu caller    data (hex + ascii)
> ---------------------------------------------------------------------------
> -00    00964419409:440690 1 -         00  88023fe
> +  area  time           level exception cpu caller    data (hex + ascii)
> +  --------------------------------------------------------------------------
> +  00    00964419409:440690 1 -         00  88023fe
>  
>  
>  Defining views
>  --------------
>  
>  Views are specified with the 'debug_view' structure. There are defined
> -callback functions which are used for reading and writing the debugfs files::
> +callback functions which are used for reading and writing the debugfs files:
> +
> +.. code-block:: c
>  
>    struct debug_view {
>  	char name[DEBUG_MAX_PROCF_LEN];
> @@ -357,7 +364,9 @@ callback functions which are used for reading and writing the debugfs files::
>  	void*                private_data;
>    };
>  
> -where::
> +where:
> +
> +.. code-block:: c
>  
>    typedef int (debug_header_proc_t) (debug_info_t* id,
>  				     struct debug_view* view,
> @@ -395,10 +404,10 @@ Then 'header_proc' and 'format_proc' are called for each
>  existing debug entry.
>  
>  The input_proc can be used to implement functionality when it is written to
> -the view (e.g. like with 'echo "0" > /sys/kernel/debug/s390dbf/dasd/level).
> +the view (e.g. like with ``echo "0" > /sys/kernel/debug/s390dbf/dasd/level``).
>  
>  For header_proc there can be used the default function
> -debug_dflt_header_fn() which is defined in debug.h.
> +:c:func:`debug_dflt_header_fn()` which is defined in debug.h.
>  and which produces the same header output as the predefined views.
>  E.g::
>  
> @@ -407,7 +416,9 @@ E.g::
>  In order to see how to use the callback functions check the implementation
>  of the default views!
>  
> -Example::
> +Example:
> +
> +.. code-block:: c
>  
>    #include <asm/debug.h>
>  
> @@ -423,21 +434,20 @@ Example::
>    };
>  
>    static int debug_test_format_fn(
> -     debug_info_t * id, struct debug_view *view,
> +     debug_info_t *id, struct debug_view *view,
>       char *out_buf, const char *in_buf
>    )
>    {
>      int i, rc = 0;
>  
> -    if(id->buf_size >= 4) {
> +    if (id->buf_size >= 4) {
>         int msg_nr = *((int*)in_buf);
> -       if(msg_nr < sizeof(messages)/sizeof(char*) - 1)
> +       if (msg_nr < sizeof(messages) / sizeof(char*) - 1)
>  	  rc += sprintf(out_buf, "%s", messages[msg_nr]);
>         else
>  	  rc += sprintf(out_buf, UNKNOWNSTR, msg_nr);
>      }
> -   out:
> -     return rc;
> +    return rc;
>    }
>  
>    struct debug_view debug_test_view = {
> @@ -452,13 +462,17 @@ Example::
>  test:
>  =====
>  
> -::
> +.. code-block:: c
>  
>    debug_info_t *debug_info;
> +  int i;
>    ...
> -  debug_info = debug_register ("test", 0, 4, 4 ));
> +  debug_info = debug_register("test", 0, 4, 4);
>    debug_register_view(debug_info, &debug_test_view);
> -  for(i = 0; i < 10; i ++) debug_int_event(debug_info, 1, i);
> +  for (i = 0; i < 10; i ++)
> +    debug_int_event(debug_info, 1, i);
> +
> +::
>  
>    > cat /sys/kernel/debug/s390dbf/test/myview
>    00 00964419734:611402 1 - 00 88042ca   This error...........
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c
  2019-07-03 10:19 ` [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c Steffen Maier
  2019-07-05 10:54   ` Christian Borntraeger
@ 2019-07-05 12:27   ` Vasily Gorbik
  1 sibling, 0 replies; 9+ messages in thread
From: Vasily Gorbik @ 2019-07-05 12:27 UTC (permalink / raw)
  To: Steffen Maier
  Cc: linux-doc, linux-s390, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, linux-kernel

On Wed, Jul 03, 2019 at 12:19:48PM +0200, Steffen Maier wrote:
> For non-static-inlines, debug.c already had non-compliant function
> header docs. So move the pure prototype kdocs of
> ("s390: include/asm/debug.h add kerneldoc markups")
> from debug.h to debug.c and merge them with the old function docs.
> Also, I had the impression that kdoc typically is at the implementation
> in the compile unit rather than at the prototype in the header file.
> 
> While at it, update the short kdoc description to distinguish the
> different functions. And a few more consistency cleanups.
> 
> Added a new kdoc for debug_set_critical() since debug.h comments it
> as part of the API.
> 
> Signed-off-by: Steffen Maier <maier@linux.ibm.com>
> ---
>  Documentation/s390/s390dbf.rst |   1 +
>  arch/s390/include/asm/debug.h  | 112 ++++++-----------------------------------
>  arch/s390/kernel/debug.c       | 105 +++++++++++++++++++++++++++++++-------
>  3 files changed, 102 insertions(+), 116 deletions(-)
> 
Applied with "permisions->permissions" and couple of whitespaces removed, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] docs: s390: restore content and update s390dbf.rst
  2019-07-03 10:19 [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Steffen Maier
                   ` (2 preceding siblings ...)
  2019-07-03 10:19 ` [PATCH 3/3] docs: s390: s390dbf: typos and formatting, update crash command Steffen Maier
@ 2019-07-05 12:28 ` Vasily Gorbik
  3 siblings, 0 replies; 9+ messages in thread
From: Vasily Gorbik @ 2019-07-05 12:28 UTC (permalink / raw)
  To: Steffen Maier
  Cc: linux-doc, linux-s390, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, linux-kernel

On Wed, Jul 03, 2019 at 12:19:46PM +0200, Steffen Maier wrote:
> This is based on top of the 3 s390 patches Heiko already queued on our
> s390 features branch.
> [("Re: [PATCH v3 00/33] Convert files to ReST - part 1")
>  https://www.spinics.net/lists/linux-doc/msg66137.html
>  https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/log/Documentation/s390?h=features]
> 
> If I was not mistaken, some documentation was accidentally lost
> and patch 1 restores it.
> 
> After having looked closer, I came up with patches 2 and 3.
> Rendered successfully on a current Fedora 30 and it looks good:
> $ make SPHINXDIRS="s390" htmldocs
> 
> Steffen Maier (3):
>   docs: s390: restore important non-kdoc parts of s390dbf.rst
>   docs: s390: unify and update s390dbf kdocs at debug.c
>   docs: s390: s390dbf: typos and formatting, update crash command
> 
>  Documentation/s390/s390dbf.rst | 390 +++++++++++++++++++++++++++++++++++++++--
>  arch/s390/include/asm/debug.h  | 112 ++----------
>  arch/s390/kernel/debug.c       | 105 +++++++++--
>  3 files changed, 473 insertions(+), 134 deletions(-)
> 
> -- 
> 1.8.3.1
> 
Applied, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-07-05 12:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 10:19 [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Steffen Maier
2019-07-03 10:19 ` [PATCH 1/3] docs: s390: restore important non-kdoc parts of s390dbf.rst Steffen Maier
2019-07-05 10:53   ` Christian Borntraeger
2019-07-03 10:19 ` [PATCH 2/3] docs: s390: unify and update s390dbf kdocs at debug.c Steffen Maier
2019-07-05 10:54   ` Christian Borntraeger
2019-07-05 12:27   ` Vasily Gorbik
2019-07-03 10:19 ` [PATCH 3/3] docs: s390: s390dbf: typos and formatting, update crash command Steffen Maier
2019-07-05 10:54   ` Christian Borntraeger
2019-07-05 12:28 ` [PATCH 0/3] docs: s390: restore content and update s390dbf.rst Vasily Gorbik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).