Skip to content

Commit 14ebc28

Browse files
Matthew WilcoxJonathan Corbet
authored andcommitted
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>
1 parent aa931b4 commit 14ebc28

4 files changed

Lines changed: 38 additions & 22 deletions

File tree

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
=====================
12
The errseq_t datatype
23
=====================
4+
35
An errseq_t is a way of recording errors in one place, and allowing any
46
number of "subscribers" to tell whether it has changed since a previous
57
point where it was sampled.
@@ -21,12 +23,13 @@ a flag to tell whether the value has been sampled since a new value was
2123
recorded. That allows us to avoid bumping the counter if no one has
2224
sampled it since the last time an error was recorded.
2325

24-
Thus we end up with a value that looks something like this::
26+
Thus we end up with a value that looks something like this:
2527

26-
bit: 31..13 12 11..0
27-
+-----------------+----+----------------+
28-
| counter | SF | errno |
29-
+-----------------+----+----------------+
28+
+--------------------------------------+----+------------------------+
29+
| 31..13 | 12 | 11..0 |
30+
+--------------------------------------+----+------------------------+
31+
| counter | SF | errno |
32+
+--------------------------------------+----+------------------------+
3033

3134
The general idea is for "watchers" to sample an errseq_t value and keep
3235
it 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.
4245

4346
API usage
4447
=========
48+
4549
Let me tell you a story about a worker drone. Now, he's a good worker
4650
overall, but the company is a little...management heavy. He has to
4751
report to 77 supervisors today, and tomorrow the "big boss" is coming in
@@ -125,6 +129,7 @@ not usable by anyone else.
125129

126130
Serializing errseq_t cursor updates
127131
===================================
132+
128133
Note that the errseq_t API does not protect the errseq_t cursor during a
129134
check_and_advance_operation. Only the canonical error code is handled
130135
atomically. 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.::
147152

148153
That avoids the spinlock in the common case where nothing has changed
149154
since the last time it was checked.
155+
156+
Functions
157+
=========
158+
159+
.. kernel-doc:: lib/errseq.c

‎Documentation/core-api/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Core utilities
2222
flexible-arrays
2323
librs
2424
genalloc
25+
errseq
2526
printk-formats
2627

2728
Interfaces for kernel debugging

‎include/linux/errseq.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* See Documentation/errseq.rst and lib/errseq.c
3+
* See Documentation/core-api/errseq.rst and lib/errseq.c
44
*/
55
#ifndef _LINUX_ERRSEQ_H
66
#define _LINUX_ERRSEQ_H

‎lib/errseq.c‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
* @eseq: errseq_t field that should be set
4747
* @err: error to set (must be between -1 and -MAX_ERRNO)
4848
*
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
5050
* if the last sequence was sampled at some point in the past.
5151
*
5252
* Any error set will always overwrite an existing error.
5353
*
54-
* We do return the latest value here, primarily for debugging purposes. The
55-
* return value should not be used as a previously sampled value in later calls
56-
* as it will not have the SEEN flag set.
54+
* Return: The previous value, primarily for debugging purposes. The
55+
* return value should not be used as a previously sampled value in later
56+
* calls as it will not have the SEEN flag set.
5757
*/
5858
errseq_t errseq_set(errseq_t *eseq, int err)
5959
{
@@ -108,11 +108,13 @@ errseq_t errseq_set(errseq_t *eseq, int err)
108108
EXPORT_SYMBOL(errseq_set);
109109

110110
/**
111-
* errseq_sample - grab current errseq_t value
112-
* @eseq: pointer to errseq_t to be sampled
111+
* errseq_sample() - Grab current errseq_t value.
112+
* @eseq: Pointer to errseq_t to be sampled.
113113
*
114114
* This function allows callers to sample an errseq_t value, marking it as
115115
* "seen" if required.
116+
*
117+
* Return: The current errseq value.
116118
*/
117119
errseq_t errseq_sample(errseq_t *eseq)
118120
{
@@ -134,15 +136,15 @@ errseq_t errseq_sample(errseq_t *eseq)
134136
EXPORT_SYMBOL(errseq_sample);
135137

136138
/**
137-
* errseq_check - has an error occurred since a particular sample point?
138-
* @eseq: pointer to errseq_t value to be checked
139-
* @since: previously-sampled errseq_t from which to check
139+
* errseq_check() - Has an error occurred since a particular sample point?
140+
* @eseq: Pointer to errseq_t value to be checked.
141+
* @since: Previously-sampled errseq_t from which to check.
140142
*
141-
* 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
143+
* Grab the value that eseq points to, and see if it has changed @since
144+
* the given value was sampled. The @since value is not advanced, so there
143145
* is no need to mark the value as seen.
144146
*
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.
146148
*/
147149
int errseq_check(errseq_t *eseq, errseq_t since)
148150
{
@@ -155,11 +157,11 @@ int errseq_check(errseq_t *eseq, errseq_t since)
155157
EXPORT_SYMBOL(errseq_check);
156158

157159
/**
158-
* errseq_check_and_advance - check an errseq_t and advance to current value
159-
* @eseq: pointer to value being checked and reported
160-
* @since: pointer to previously-sampled errseq_t to check against and advance
160+
* errseq_check_and_advance() - Check an errseq_t and advance to current value.
161+
* @eseq: Pointer to value being checked and reported.
162+
* @since: Pointer to previously-sampled errseq_t to check against and advance.
161163
*
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
163165
* points to. If it does, then just return 0.
164166
*
165167
* If it doesn't, then the value has changed. Set the "seen" flag, and try to
@@ -170,6 +172,9 @@ EXPORT_SYMBOL(errseq_check);
170172
* value. The caller must provide that if necessary. Because of this, callers
171173
* may want to do a lockless errseq_check before taking the lock and calling
172174
* this.
175+
*
176+
* Return: Negative errno if one has been stored, or 0 if no new error has
177+
* occurred.
173178
*/
174179
int errseq_check_and_advance(errseq_t *eseq, errseq_t *since)
175180
{

0 commit comments

Comments
 (0)