diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-13 16:08:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-13 16:08:34 -0400 |
commit | 1904187a694713b80d74186fe058377b067cc195 (patch) | |
tree | 88ead633c1bdc4f6bf5590b178f73a0dadbfe547 /Documentation | |
parent | 32f44d62e463f66307513e90c09b4ceeac13cc22 (diff) | |
parent | f89d7eaf6c34828070f407d0e04b73127f176ec5 (diff) |
Merge branch 'docs-next' of git://git.lwn.net/linux-2.6
* 'docs-next' of git://git.lwn.net/linux-2.6:
Document the debugfs API
Documentation: Add "how to write a good patch summary" to SubmittingPatches
SubmittingPatches: fix typo
docs: Encourage better changelogs in the development process document
Document Reported-by in SubmittingPatches
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/SubmittingPatches | 76 | ||||
-rw-r--r-- | Documentation/development-process/5.Posting | 31 | ||||
-rw-r--r-- | Documentation/filesystems/debugfs.txt | 158 |
3 files changed, 246 insertions, 19 deletions
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index f309d3c6221c..6c456835c1fd 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches | |||
@@ -91,6 +91,10 @@ Be as specific as possible. The WORST descriptions possible include | |||
91 | things like "update driver X", "bug fix for driver X", or "this patch | 91 | things like "update driver X", "bug fix for driver X", or "this patch |
92 | includes updates for subsystem X. Please apply." | 92 | includes updates for subsystem X. Please apply." |
93 | 93 | ||
94 | The maintainer will thank you if you write your patch description in a | ||
95 | form which can be easily pulled into Linux's source code management | ||
96 | system, git, as a "commit log". See #15, below. | ||
97 | |||
94 | If your description starts to get long, that's a sign that you probably | 98 | If your description starts to get long, that's a sign that you probably |
95 | need to split up your patch. See #3, next. | 99 | need to split up your patch. See #3, next. |
96 | 100 | ||
@@ -405,7 +409,14 @@ person it names. This tag documents that potentially interested parties | |||
405 | have been included in the discussion | 409 | have been included in the discussion |
406 | 410 | ||
407 | 411 | ||
408 | 14) Using Tested-by: and Reviewed-by: | 412 | 14) Using Reported-by:, Tested-by: and Reviewed-by: |
413 | |||
414 | If this patch fixes a problem reported by somebody else, consider adding a | ||
415 | Reported-by: tag to credit the reporter for their contribution. Please | ||
416 | note that this tag should not be added without the reporter's permission, | ||
417 | especially if the problem was not reported in a public forum. That said, | ||
418 | if we diligently credit our bug reporters, they will, hopefully, be | ||
419 | inspired to help us again in the future. | ||
409 | 420 | ||
410 | A Tested-by: tag indicates that the patch has been successfully tested (in | 421 | A Tested-by: tag indicates that the patch has been successfully tested (in |
411 | some environment) by the person named. This tag informs maintainers that | 422 | some environment) by the person named. This tag informs maintainers that |
@@ -444,7 +455,7 @@ offer a Reviewed-by tag for a patch. This tag serves to give credit to | |||
444 | reviewers and to inform maintainers of the degree of review which has been | 455 | reviewers and to inform maintainers of the degree of review which has been |
445 | done on the patch. Reviewed-by: tags, when supplied by reviewers known to | 456 | done on the patch. Reviewed-by: tags, when supplied by reviewers known to |
446 | understand the subject area and to perform thorough reviews, will normally | 457 | understand the subject area and to perform thorough reviews, will normally |
447 | increase the liklihood of your patch getting into the kernel. | 458 | increase the likelihood of your patch getting into the kernel. |
448 | 459 | ||
449 | 460 | ||
450 | 15) The canonical patch format | 461 | 15) The canonical patch format |
@@ -485,12 +496,33 @@ phrase" should not be a filename. Do not use the same "summary | |||
485 | phrase" for every patch in a whole patch series (where a "patch | 496 | phrase" for every patch in a whole patch series (where a "patch |
486 | series" is an ordered sequence of multiple, related patches). | 497 | series" is an ordered sequence of multiple, related patches). |
487 | 498 | ||
488 | Bear in mind that the "summary phrase" of your email becomes | 499 | Bear in mind that the "summary phrase" of your email becomes a |
489 | a globally-unique identifier for that patch. It propagates | 500 | globally-unique identifier for that patch. It propagates all the way |
490 | all the way into the git changelog. The "summary phrase" may | 501 | into the git changelog. The "summary phrase" may later be used in |
491 | later be used in developer discussions which refer to the patch. | 502 | developer discussions which refer to the patch. People will want to |
492 | People will want to google for the "summary phrase" to read | 503 | google for the "summary phrase" to read discussion regarding that |
493 | discussion regarding that patch. | 504 | patch. It will also be the only thing that people may quickly see |
505 | when, two or three months later, they are going through perhaps | ||
506 | thousands of patches using tools such as "gitk" or "git log | ||
507 | --oneline". | ||
508 | |||
509 | For these reasons, the "summary" must be no more than 70-75 | ||
510 | characters, and it must describe both what the patch changes, as well | ||
511 | as why the patch might be necessary. It is challenging to be both | ||
512 | succinct and descriptive, but that is what a well-written summary | ||
513 | should do. | ||
514 | |||
515 | The "summary phrase" may be prefixed by tags enclosed in square | ||
516 | brackets: "Subject: [PATCH tag] <summary phrase>". The tags are not | ||
517 | considered part of the summary phrase, but describe how the patch | ||
518 | should be treated. Common tags might include a version descriptor if | ||
519 | the multiple versions of the patch have been sent out in response to | ||
520 | comments (i.e., "v1, v2, v3"), or "RFC" to indicate a request for | ||
521 | comments. If there are four patches in a patch series the individual | ||
522 | patches may be numbered like this: 1/4, 2/4, 3/4, 4/4. This assures | ||
523 | that developers understand the order in which the patches should be | ||
524 | applied and that they have reviewed or applied all of the patches in | ||
525 | the patch series. | ||
494 | 526 | ||
495 | A couple of example Subjects: | 527 | A couple of example Subjects: |
496 | 528 | ||
@@ -510,19 +542,31 @@ the patch author in the changelog. | |||
510 | The explanation body will be committed to the permanent source | 542 | The explanation body will be committed to the permanent source |
511 | changelog, so should make sense to a competent reader who has long | 543 | changelog, so should make sense to a competent reader who has long |
512 | since forgotten the immediate details of the discussion that might | 544 | since forgotten the immediate details of the discussion that might |
513 | have led to this patch. | 545 | have led to this patch. Including symptoms of the failure which the |
546 | patch addresses (kernel log messages, oops messages, etc.) is | ||
547 | especially useful for people who might be searching the commit logs | ||
548 | looking for the applicable patch. If a patch fixes a compile failure, | ||
549 | it may not be necessary to include _all_ of the compile failures; just | ||
550 | enough that it is likely that someone searching for the patch can find | ||
551 | it. As in the "summary phrase", it is important to be both succinct as | ||
552 | well as descriptive. | ||
514 | 553 | ||
515 | The "---" marker line serves the essential purpose of marking for patch | 554 | The "---" marker line serves the essential purpose of marking for patch |
516 | handling tools where the changelog message ends. | 555 | handling tools where the changelog message ends. |
517 | 556 | ||
518 | One good use for the additional comments after the "---" marker is for | 557 | One good use for the additional comments after the "---" marker is for |
519 | a diffstat, to show what files have changed, and the number of inserted | 558 | a diffstat, to show what files have changed, and the number of |
520 | and deleted lines per file. A diffstat is especially useful on bigger | 559 | inserted and deleted lines per file. A diffstat is especially useful |
521 | patches. Other comments relevant only to the moment or the maintainer, | 560 | on bigger patches. Other comments relevant only to the moment or the |
522 | not suitable for the permanent changelog, should also go here. | 561 | maintainer, not suitable for the permanent changelog, should also go |
523 | Use diffstat options "-p 1 -w 70" so that filenames are listed from the | 562 | here. A good example of such comments might be "patch changelogs" |
524 | top of the kernel source tree and don't use too much horizontal space | 563 | which describe what has changed between the v1 and v2 version of the |
525 | (easily fit in 80 columns, maybe with some indentation). | 564 | patch. |
565 | |||
566 | If you are going to include a diffstat after the "---" marker, please | ||
567 | use diffstat options "-p 1 -w 70" so that filenames are listed from | ||
568 | the top of the kernel source tree and don't use too much horizontal | ||
569 | space (easily fit in 80 columns, maybe with some indentation). | ||
526 | 570 | ||
527 | See more details on the proper patch format in the following | 571 | See more details on the proper patch format in the following |
528 | references. | 572 | references. |
diff --git a/Documentation/development-process/5.Posting b/Documentation/development-process/5.Posting index dd48132a74dd..f622c1e9f0f9 100644 --- a/Documentation/development-process/5.Posting +++ b/Documentation/development-process/5.Posting | |||
@@ -119,7 +119,7 @@ which takes quite a bit of time and thought after the "real work" has been | |||
119 | done. When done properly, though, it is time well spent. | 119 | done. When done properly, though, it is time well spent. |
120 | 120 | ||
121 | 121 | ||
122 | 5.4: PATCH FORMATTING | 122 | 5.4: PATCH FORMATTING AND CHANGELOGS |
123 | 123 | ||
124 | So now you have a perfect series of patches for posting, but the work is | 124 | So now you have a perfect series of patches for posting, but the work is |
125 | not done quite yet. Each patch needs to be formatted into a message which | 125 | not done quite yet. Each patch needs to be formatted into a message which |
@@ -146,8 +146,33 @@ that end, each patch will be composed of the following: | |||
146 | - One or more tag lines, with, at a minimum, one Signed-off-by: line from | 146 | - One or more tag lines, with, at a minimum, one Signed-off-by: line from |
147 | the author of the patch. Tags will be described in more detail below. | 147 | the author of the patch. Tags will be described in more detail below. |
148 | 148 | ||
149 | The above three items should, normally, be the text used when committing | 149 | The items above, together, form the changelog for the patch. Writing good |
150 | the change to a revision control system. They are followed by: | 150 | changelogs is a crucial but often-neglected art; it's worth spending |
151 | another moment discussing this issue. When writing a changelog, you should | ||
152 | bear in mind that a number of different people will be reading your words. | ||
153 | These include subsystem maintainers and reviewers who need to decide | ||
154 | whether the patch should be included, distributors and other maintainers | ||
155 | trying to decide whether a patch should be backported to other kernels, bug | ||
156 | hunters wondering whether the patch is responsible for a problem they are | ||
157 | chasing, users who want to know how the kernel has changed, and more. A | ||
158 | good changelog conveys the needed information to all of these people in the | ||
159 | most direct and concise way possible. | ||
160 | |||
161 | To that end, the summary line should describe the effects of and motivation | ||
162 | for the change as well as possible given the one-line constraint. The | ||
163 | detailed description can then amplify on those topics and provide any | ||
164 | needed additional information. If the patch fixes a bug, cite the commit | ||
165 | which introduced the bug if possible. If a problem is associated with | ||
166 | specific log or compiler output, include that output to help others | ||
167 | searching for a solution to the same problem. If the change is meant to | ||
168 | support other changes coming in later patch, say so. If internal APIs are | ||
169 | changed, detail those changes and how other developers should respond. In | ||
170 | general, the more you can put yourself into the shoes of everybody who will | ||
171 | be reading your changelog, the better that changelog (and the kernel as a | ||
172 | whole) will be. | ||
173 | |||
174 | Needless to say, the changelog should be the text used when committing the | ||
175 | change to a revision control system. It will be followed by: | ||
151 | 176 | ||
152 | - The patch itself, in the unified ("-u") patch format. Using the "-p" | 177 | - The patch itself, in the unified ("-u") patch format. Using the "-p" |
153 | option to diff will associate function names with changes, making the | 178 | option to diff will associate function names with changes, making the |
diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt new file mode 100644 index 000000000000..ed52af60c2d8 --- /dev/null +++ b/Documentation/filesystems/debugfs.txt | |||
@@ -0,0 +1,158 @@ | |||
1 | Copyright 2009 Jonathan Corbet <corbet@lwn.net> | ||
2 | |||
3 | Debugfs exists as a simple way for kernel developers to make information | ||
4 | available to user space. Unlike /proc, which is only meant for information | ||
5 | about a process, or sysfs, which has strict one-value-per-file rules, | ||
6 | debugfs has no rules at all. Developers can put any information they want | ||
7 | there. The debugfs filesystem is also intended to not serve as a stable | ||
8 | ABI to user space; in theory, there are no stability constraints placed on | ||
9 | files exported there. The real world is not always so simple, though [1]; | ||
10 | even debugfs interfaces are best designed with the idea that they will need | ||
11 | to be maintained forever. | ||
12 | |||
13 | Debugfs is typically mounted with a command like: | ||
14 | |||
15 | mount -t debugfs none /sys/kernel/debug | ||
16 | |||
17 | (Or an equivalent /etc/fstab line). | ||
18 | |||
19 | Note that the debugfs API is exported GPL-only to modules. | ||
20 | |||
21 | Code using debugfs should include <linux/debugfs.h>. Then, the first order | ||
22 | of business will be to create at least one directory to hold a set of | ||
23 | debugfs files: | ||
24 | |||
25 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); | ||
26 | |||
27 | This call, if successful, will make a directory called name underneath the | ||
28 | indicated parent directory. If parent is NULL, the directory will be | ||
29 | created in the debugfs root. On success, the return value is a struct | ||
30 | dentry pointer which can be used to create files in the directory (and to | ||
31 | clean it up at the end). A NULL return value indicates that something went | ||
32 | wrong. If ERR_PTR(-ENODEV) is returned, that is an indication that the | ||
33 | kernel has been built without debugfs support and none of the functions | ||
34 | described below will work. | ||
35 | |||
36 | The most general way to create a file within a debugfs directory is with: | ||
37 | |||
38 | struct dentry *debugfs_create_file(const char *name, mode_t mode, | ||
39 | struct dentry *parent, void *data, | ||
40 | const struct file_operations *fops); | ||
41 | |||
42 | Here, name is the name of the file to create, mode describes the access | ||
43 | permissions the file should have, parent indicates the directory which | ||
44 | should hold the file, data will be stored in the i_private field of the | ||
45 | resulting inode structure, and fops is a set of file operations which | ||
46 | implement the file's behavior. At a minimum, the read() and/or write() | ||
47 | operations should be provided; others can be included as needed. Again, | ||
48 | the return value will be a dentry pointer to the created file, NULL for | ||
49 | error, or ERR_PTR(-ENODEV) if debugfs support is missing. | ||
50 | |||
51 | In a number of cases, the creation of a set of file operations is not | ||
52 | actually necessary; the debugfs code provides a number of helper functions | ||
53 | for simple situations. Files containing a single integer value can be | ||
54 | created with any of: | ||
55 | |||
56 | struct dentry *debugfs_create_u8(const char *name, mode_t mode, | ||
57 | struct dentry *parent, u8 *value); | ||
58 | struct dentry *debugfs_create_u16(const char *name, mode_t mode, | ||
59 | struct dentry *parent, u16 *value); | ||
60 | struct dentry *debugfs_create_u32(const char *name, mode_t mode, | ||
61 | struct dentry *parent, u32 *value); | ||
62 | struct dentry *debugfs_create_u64(const char *name, mode_t mode, | ||
63 | struct dentry *parent, u64 *value); | ||
64 | |||
65 | These files support both reading and writing the given value; if a specific | ||
66 | file should not be written to, simply set the mode bits accordingly. The | ||
67 | values in these files are in decimal; if hexadecimal is more appropriate, | ||
68 | the following functions can be used instead: | ||
69 | |||
70 | struct dentry *debugfs_create_x8(const char *name, mode_t mode, | ||
71 | struct dentry *parent, u8 *value); | ||
72 | struct dentry *debugfs_create_x16(const char *name, mode_t mode, | ||
73 | struct dentry *parent, u16 *value); | ||
74 | struct dentry *debugfs_create_x32(const char *name, mode_t mode, | ||
75 | struct dentry *parent, u32 *value); | ||
76 | |||
77 | Note that there is no debugfs_create_x64(). | ||
78 | |||
79 | These functions are useful as long as the developer knows the size of the | ||
80 | value to be exported. Some types can have different widths on different | ||
81 | architectures, though, complicating the situation somewhat. There is a | ||
82 | function meant to help out in one special case: | ||
83 | |||
84 | struct dentry *debugfs_create_size_t(const char *name, mode_t mode, | ||
85 | struct dentry *parent, | ||
86 | size_t *value); | ||
87 | |||
88 | As might be expected, this function will create a debugfs file to represent | ||
89 | a variable of type size_t. | ||
90 | |||
91 | Boolean values can be placed in debugfs with: | ||
92 | |||
93 | struct dentry *debugfs_create_bool(const char *name, mode_t mode, | ||
94 | struct dentry *parent, u32 *value); | ||
95 | |||
96 | A read on the resulting file will yield either Y (for non-zero values) or | ||
97 | N, followed by a newline. If written to, it will accept either upper- or | ||
98 | lower-case values, or 1 or 0. Any other input will be silently ignored. | ||
99 | |||
100 | Finally, a block of arbitrary binary data can be exported with: | ||
101 | |||
102 | struct debugfs_blob_wrapper { | ||
103 | void *data; | ||
104 | unsigned long size; | ||
105 | }; | ||
106 | |||
107 | struct dentry *debugfs_create_blob(const char *name, mode_t mode, | ||
108 | struct dentry *parent, | ||
109 | struct debugfs_blob_wrapper *blob); | ||
110 | |||
111 | A read of this file will return the data pointed to by the | ||
112 | debugfs_blob_wrapper structure. Some drivers use "blobs" as a simple way | ||
113 | to return several lines of (static) formatted text output. This function | ||
114 | can be used to export binary information, but there does not appear to be | ||
115 | any code which does so in the mainline. Note that all files created with | ||
116 | debugfs_create_blob() are read-only. | ||
117 | |||
118 | There are a couple of other directory-oriented helper functions: | ||
119 | |||
120 | struct dentry *debugfs_rename(struct dentry *old_dir, | ||
121 | struct dentry *old_dentry, | ||
122 | struct dentry *new_dir, | ||
123 | const char *new_name); | ||
124 | |||
125 | struct dentry *debugfs_create_symlink(const char *name, | ||
126 | struct dentry *parent, | ||
127 | const char *target); | ||
128 | |||
129 | A call to debugfs_rename() will give a new name to an existing debugfs | ||
130 | file, possibly in a different directory. The new_name must not exist prior | ||
131 | to the call; the return value is old_dentry with updated information. | ||
132 | Symbolic links can be created with debugfs_create_symlink(). | ||
133 | |||
134 | There is one important thing that all debugfs users must take into account: | ||
135 | there is no automatic cleanup of any directories created in debugfs. If a | ||
136 | module is unloaded without explicitly removing debugfs entries, the result | ||
137 | will be a lot of stale pointers and no end of highly antisocial behavior. | ||
138 | So all debugfs users - at least those which can be built as modules - must | ||
139 | be prepared to remove all files and directories they create there. A file | ||
140 | can be removed with: | ||
141 | |||
142 | void debugfs_remove(struct dentry *dentry); | ||
143 | |||
144 | The dentry value can be NULL, in which case nothing will be removed. | ||
145 | |||
146 | Once upon a time, debugfs users were required to remember the dentry | ||
147 | pointer for every debugfs file they created so that all files could be | ||
148 | cleaned up. We live in more civilized times now, though, and debugfs users | ||
149 | can call: | ||
150 | |||
151 | void debugfs_remove_recursive(struct dentry *dentry); | ||
152 | |||
153 | If this function is passed a pointer for the dentry corresponding to the | ||
154 | top-level directory, the entire hierarchy below that directory will be | ||
155 | removed. | ||
156 | |||
157 | Notes: | ||
158 | [1] http://lwn.net/Articles/309298/ | ||