aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-12-22 09:32:16 -0500
committerJonathan Corbet <corbet@lwn.net>2018-01-01 14:40:27 -0500
commit14ebc28e07e68ff412aa42f7d8b67969e2f63d00 (patch)
tree7d5aa02eba4a70f4d8da61e51eae16e0c7956567
parentaa931b44ae3e32329b054e3cd8ba1a4f1aa9e0d8 (diff)
errseq: Add to documentation tree
- Move errseq.rst into core-api - Add errseq to the core-api index - Promote the header to a more prominent header type, otherwise we get three entries in the table of contents. - Reformat the table to look nicer and be a little more proportional in terms of horizontal width per bit (the SF bit is still disproportionately large, but there's no way to fix that). - Include errseq kernel-doc in the errseq.rst - Neaten some kernel-doc markup Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rw-r--r--Documentation/core-api/errseq.rst (renamed from Documentation/errseq.rst)20
-rw-r--r--Documentation/core-api/index.rst1
-rw-r--r--include/linux/errseq.h2
-rw-r--r--lib/errseq.c37
4 files changed, 38 insertions, 22 deletions
diff --git a/Documentation/errseq.rst b/Documentation/core-api/errseq.rst
index 4c29bd5afbc5..ff332e272405 100644
--- a/Documentation/errseq.rst
+++ b/Documentation/core-api/errseq.rst
@@ -1,5 +1,7 @@
1=====================
1The errseq_t datatype 2The errseq_t datatype
2===================== 3=====================
4
3An errseq_t is a way of recording errors in one place, and allowing any 5An errseq_t is a way of recording errors in one place, and allowing any
4number of "subscribers" to tell whether it has changed since a previous 6number of "subscribers" to tell whether it has changed since a previous
5point where it was sampled. 7point where it was sampled.
@@ -21,12 +23,13 @@ a flag to tell whether the value has been sampled since a new value was
21recorded. That allows us to avoid bumping the counter if no one has 23recorded. That allows us to avoid bumping the counter if no one has
22sampled it since the last time an error was recorded. 24sampled it since the last time an error was recorded.
23 25
24Thus we end up with a value that looks something like this:: 26Thus we end up with a value that looks something like this:
25 27
26 bit: 31..13 12 11..0 28+--------------------------------------+----+------------------------+
27 +-----------------+----+----------------+ 29| 31..13 | 12 | 11..0 |
28 | counter | SF | errno | 30+--------------------------------------+----+------------------------+
29 +-----------------+----+----------------+ 31| counter | SF | errno |
32+--------------------------------------+----+------------------------+
30 33
31The general idea is for "watchers" to sample an errseq_t value and keep 34The general idea is for "watchers" to sample an errseq_t value and keep
32it as a running cursor. That value can later be used to tell whether 35it as a running cursor. That value can later be used to tell whether
@@ -42,6 +45,7 @@ has ever been an error set since it was first initialized.
42 45
43API usage 46API usage
44========= 47=========
48
45Let me tell you a story about a worker drone. Now, he's a good worker 49Let me tell you a story about a worker drone. Now, he's a good worker
46overall, but the company is a little...management heavy. He has to 50overall, but the company is a little...management heavy. He has to
47report to 77 supervisors today, and tomorrow the "big boss" is coming in 51report to 77 supervisors today, and tomorrow the "big boss" is coming in
@@ -125,6 +129,7 @@ not usable by anyone else.
125 129
126Serializing errseq_t cursor updates 130Serializing errseq_t cursor updates
127=================================== 131===================================
132
128Note that the errseq_t API does not protect the errseq_t cursor during a 133Note that the errseq_t API does not protect the errseq_t cursor during a
129check_and_advance_operation. Only the canonical error code is handled 134check_and_advance_operation. Only the canonical error code is handled
130atomically. In a situation where more than one task might be using the 135atomically. In a situation where more than one task might be using the
@@ -147,3 +152,8 @@ errseq_check_and_advance after taking the lock. e.g.::
147 152
148That avoids the spinlock in the common case where nothing has changed 153That avoids the spinlock in the common case where nothing has changed
149since the last time it was checked. 154since the last time it was checked.
155
156Functions
157=========
158
159.. kernel-doc:: lib/errseq.c
diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst
index d55ee6b006ed..1b1fd01990b5 100644
--- a/Documentation/core-api/index.rst
+++ b/Documentation/core-api/index.rst
@@ -22,6 +22,7 @@ Core utilities
22 flexible-arrays 22 flexible-arrays
23 librs 23 librs
24 genalloc 24 genalloc
25 errseq
25 printk-formats 26 printk-formats
26 27
27Interfaces for kernel debugging 28Interfaces for kernel debugging
diff --git a/include/linux/errseq.h b/include/linux/errseq.h
index 6ffae9c5052d..fc2777770768 100644
--- a/include/linux/errseq.h
+++ b/include/linux/errseq.h
@@ -1,6 +1,6 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0 */
2/* 2/*
3 * See Documentation/errseq.rst and lib/errseq.c 3 * See Documentation/core-api/errseq.rst and lib/errseq.c
4 */ 4 */
5#ifndef _LINUX_ERRSEQ_H 5#ifndef _LINUX_ERRSEQ_H
6#define _LINUX_ERRSEQ_H 6#define _LINUX_ERRSEQ_H
diff --git a/lib/errseq.c b/lib/errseq.c
index 79cc66897db4..df782418b333 100644
--- a/lib/errseq.c
+++ b/lib/errseq.c
@@ -46,14 +46,14 @@
46 * @eseq: errseq_t field that should be set 46 * @eseq: errseq_t field that should be set
47 * @err: error to set (must be between -1 and -MAX_ERRNO) 47 * @err: error to set (must be between -1 and -MAX_ERRNO)
48 * 48 *
49 * This function sets the error in *eseq, and increments the sequence counter 49 * This function sets the error in @eseq, and increments the sequence counter
50 * if the last sequence was sampled at some point in the past. 50 * if the last sequence was sampled at some point in the past.
51 * 51 *
52 * Any error set will always overwrite an existing error. 52 * Any error set will always overwrite an existing error.
53 * 53 *
54 * We do return the latest value here, primarily for debugging purposes. The 54 * Return: The previous value, primarily for debugging purposes. The
55 * return value should not be used as a previously sampled value in later calls 55 * return value should not be used as a previously sampled value in later
56 * as it will not have the SEEN flag set. 56 * calls as it will not have the SEEN flag set.
57 */ 57 */
58errseq_t errseq_set(errseq_t *eseq, int err) 58errseq_t errseq_set(errseq_t *eseq, int err)
59{ 59{
@@ -108,11 +108,13 @@ errseq_t errseq_set(errseq_t *eseq, int err)
108EXPORT_SYMBOL(errseq_set); 108EXPORT_SYMBOL(errseq_set);
109 109
110/** 110/**
111 * errseq_sample - grab current errseq_t value 111 * errseq_sample() - Grab current errseq_t value.
112 * @eseq: pointer to errseq_t to be sampled 112 * @eseq: Pointer to errseq_t to be sampled.
113 * 113 *
114 * This function allows callers to sample an errseq_t value, marking it as 114 * This function allows callers to sample an errseq_t value, marking it as
115 * "seen" if required. 115 * "seen" if required.
116 *
117 * Return: The current errseq value.
116 */ 118 */
117errseq_t errseq_sample(errseq_t *eseq) 119errseq_t errseq_sample(errseq_t *eseq)
118{ 120{
@@ -134,15 +136,15 @@ errseq_t errseq_sample(errseq_t *eseq)
134EXPORT_SYMBOL(errseq_sample); 136EXPORT_SYMBOL(errseq_sample);
135 137
136/** 138/**
137 * errseq_check - has an error occurred since a particular sample point? 139 * errseq_check() - Has an error occurred since a particular sample point?
138 * @eseq: pointer to errseq_t value to be checked 140 * @eseq: Pointer to errseq_t value to be checked.
139 * @since: previously-sampled errseq_t from which to check 141 * @since: Previously-sampled errseq_t from which to check.
140 * 142 *
141 * Grab the value that eseq points to, and see if it has changed "since" 143 * Grab the value that eseq points to, and see if it has changed @since
142 * the given value was sampled. The "since" value is not advanced, so there 144 * the given value was sampled. The @since value is not advanced, so there
143 * is no need to mark the value as seen. 145 * is no need to mark the value as seen.
144 * 146 *
145 * Returns the latest error set in the errseq_t or 0 if it hasn't changed. 147 * Return: The latest error set in the errseq_t or 0 if it hasn't changed.
146 */ 148 */
147int errseq_check(errseq_t *eseq, errseq_t since) 149int errseq_check(errseq_t *eseq, errseq_t since)
148{ 150{
@@ -155,11 +157,11 @@ int errseq_check(errseq_t *eseq, errseq_t since)
155EXPORT_SYMBOL(errseq_check); 157EXPORT_SYMBOL(errseq_check);
156 158
157/** 159/**
158 * errseq_check_and_advance - check an errseq_t and advance to current value 160 * errseq_check_and_advance() - Check an errseq_t and advance to current value.
159 * @eseq: pointer to value being checked and reported 161 * @eseq: Pointer to value being checked and reported.
160 * @since: pointer to previously-sampled errseq_t to check against and advance 162 * @since: Pointer to previously-sampled errseq_t to check against and advance.
161 * 163 *
162 * Grab the eseq value, and see whether it matches the value that "since" 164 * Grab the eseq value, and see whether it matches the value that @since
163 * points to. If it does, then just return 0. 165 * points to. If it does, then just return 0.
164 * 166 *
165 * If it doesn't, then the value has changed. Set the "seen" flag, and try to 167 * If it doesn't, then the value has changed. Set the "seen" flag, and try to
@@ -170,6 +172,9 @@ EXPORT_SYMBOL(errseq_check);
170 * value. The caller must provide that if necessary. Because of this, callers 172 * value. The caller must provide that if necessary. Because of this, callers
171 * may want to do a lockless errseq_check before taking the lock and calling 173 * may want to do a lockless errseq_check before taking the lock and calling
172 * this. 174 * this.
175 *
176 * Return: Negative errno if one has been stored, or 0 if no new error has
177 * occurred.
173 */ 178 */
174int errseq_check_and_advance(errseq_t *eseq, errseq_t *since) 179int errseq_check_and_advance(errseq_t *eseq, errseq_t *since)
175{ 180{