← Documents Documentation/process/submitting-patches.rst GitHub 원문 ↗

Linux 6.18.37 · 개발 절차

Linux kernel patch 제출 지침

Base tree 선택, commit message, logical patch 분리, recipient, email review, DCO, review tag와 canonical patch format을 설명합니다.

Source pathDocumentation/process/submitting-patches.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

맞는 maintainer tree를 기준으로 시작한다

submitting-patches.rst:3-41

Mainline repository는 torvalds/linux에서 얻지만 실제 개발 base가 항상 mainline HEAD인 것은 아니다. Subsystem maintainer가 별도 tree를 운영한다면 MAINTAINERS의 T: entry를 확인하고 그 tree의 적절한 branch 위에서 patch를 준비한다. 명시되지 않았다면 maintainer에게 묻는다.

이 문서는 Git으로 patch를 준비한다고 가정한다. Devicetree binding과 maintainer별 workflow에는 추가 지침이 있으므로 해당 handbook과 binding submission 문서를 함께 읽는다.

문제, 사용자 영향과 trade-off를 먼저 설명한다

submitting-patches.rst:45-164

Commit message 첫 문단은 code를 어떻게 바꿨는지가 아니라 왜 읽을 가치가 있는 문제인지 설명한다. Crash, lockup, dmesg, 재현 조건, performance regression과 latency spike처럼 downstream maintainer가 영향받는 product tree를 판단할 정보도 포함한다.

Performance, memory, stack와 binary-size 개선을 주장하면 측정 수치를 제시한다. CPU를 줄이는 대신 memory를 늘리거나 특정 workload를 개선하면서 다른 workload를 악화시키는 non-obvious cost도 함께 밝힌다.

그 뒤 실제 변경과 그것이 문제를 해결하는 원리를 plain language로 설명한다. Resend할 때도 이전 mail이나 URL에 설명을 맡기지 말고 각 version을 self-contained하게 유지하며 imperative mood를 사용한다.

  • Commit을 언급할 때 최소 12자리 hash와 정확한 one-line subject를 함께 쓴다.
  • Mail discussion은 lore.kernel.org의 Message-ID link를 사용하고 실제로 열리는지 확인한다.
  • 외부 Link가 있어도 핵심 결론과 근거는 commit message 안에 요약한다.
  • Public bug를 완전히 고치면 Closes: URL을 사용한다. Private tracker와 invalid URL은 허용되지 않는다.
  • 특정 commit이 bug를 도입했다면 한 줄의 Fixes: <12+ hash> ("subject") tag를 쓴다.

Patch 하나에는 logical change 하나만 둔다

submitting-patches.rst:168-198

Bug fix와 performance 개선, API 추가와 그 API를 쓰는 driver처럼 독립적으로 판단할 수 있는 변경은 분리한다. 반대로 하나의 논리 변경이 여러 file을 건드리면 한 patch에 함께 둔다.

Series의 모든 중간 commit에서 kernel이 build되고 정상 동작해야 한다. git bisect는 series 중간 어느 지점에서도 멈출 수 있다. Dependency가 있으면 description에 명시하고 너무 큰 series는 약 15편씩 나눠 review와 integration을 기다린다.

Style check와 code 이동 분리

submitting-patches.rst:201-228

scripts/checkpatch.pl의 ERROR, WARNING, CHECK를 확인하되 human judgment를 대신하게 하지는 않는다. 남겨 둔 violation은 이유를 설명할 수 있어야 한다.

Code를 다른 file로 옮기는 patch에서는 옮기는 code를 동시에 정리하지 않는다. Move와 semantic edit를 분리해야 reviewer와 history tracking 도구가 실제 차이를 정확히 볼 수 있다.

MAINTAINERS와 history로 recipient를 고른다

submitting-patches.rst:231-275

MAINTAINERS와 file history를 확인하고 scripts/get_maintainer.pl에 patch path를 넘겨 subsystem maintainer와 list를 찾는다. linux-kernel은 기본 공개 list지만 관련 없는 사람과 list를 대량 Cc하지 않는다. 일반 patch를 Linus에게 직접 보내는 경우는 드물다.

  • Exploitable security bug는 public list가 아니라 [email protected] 절차를 따른다.
  • Released kernel의 severe bug fix는 sign-off 영역에 Cc: [email protected]를 넣고 stable rule을 확인한다.
  • Userspace-kernel interface 변경은 linux-api와 man-pages maintainer에게 알리고 man page patch를 준비한다.

Patch는 inline plain text로 보낸다

submitting-patches.rst:278-308

Reviewer가 code 일부를 그대로 quote할 수 있도록 git send-email로 mail body에 inline 전송한다. MIME attachment, compressed attachment와 web link만 보내는 방식은 patch review와 자동 적용을 방해한다.

Mailer가 patch를 손상한다면 먼저 email-clients.rst 설정을 고친다. Word wrapping, format=flowed, tab 변환과 charset 변환을 자신에게 보내는 test로 확인한다. MIME 재전송은 reviewer가 특별히 요청했을 때의 예외다.

Review에 답하고 새 version의 차이를 기록한다

submitting-patches.rst:310-382

모든 review comment에 답한다. Code 변경으로 이어지지 않은 질문도 다음 reviewer가 같은 의문을 반복하지 않도록 source comment나 changelog 설명으로 반영할 수 있다. 새 version에서는 cover letter 또는 각 patch의 version changelog에 이전 version과의 차이를 적고 이전 reviewer를 Cc한다.

Reply는 필요한 인용문 바로 아래에 답하는 trimmed interleaved 형식을 쓴다. Top-posting과 관련 없는 긴 quotation은 discussion 흐름을 흐린다.

최소 1주일은 기다린 뒤 ping하고, 보통 2~3주 동안 답이 없으면 recipient를 다시 확인해 동일 patch를 RESEND로 보낼 수 있다. Code가 바뀐 새 version에는 RESEND를 붙이지 않고 v2, v3를 사용한다.

Developer's Certificate of Origin과 sign-off

submitting-patches.rst:385-454

Subject에는 [PATCH]를 넣는다. Signed-off-by는 contributor가 자신이 만들 권리가 있는 code이거나 적절한 open-source license 아래 받은 code를 제출할 권리가 있고, contribution과 identity가 공개·영구 보존될 수 있음을 인증하는 DCO 1.1 표시다.

Signed-off-by: Real Name <[email protected]>

git commit -s
git revert -s <commit>

Anonymous contribution은 받지 않는다. 첫 SoB는 primary author를 나타내고 뒤 SoB chain은 patch를 실제로 전달한 경로를 시간 순서대로 반영한다. 단순히 내부 승인자를 모두 나열하는 명단이 아니다.

Acked-by, Co-developed-by와 review tag

submitting-patches.rst:456-634
Tag의미
Acked-by영향 code의 maintainer나 stakeholder가 방향과 적용을 받아들인다. Reviewed-by보다 약한 기술 검토일 수 있고 담당 범위에만 적용될 수 있다.
Co-developed-by공동 저자를 표시한다. 바로 다음 줄에 같은 사람의 Signed-off-by가 반드시 온다.
Reported-byBug를 발견·보고한 사람에게 credit을 준다. 보통 public report의 Closes 또는 부분 fix의 Link가 뒤따른다.
Tested-by표시된 사람이 특정 환경에서 patch를 성공적으로 test했다.
Reviewed-byMainline 포함 적합성을 기술적으로 검토했고 제기한 문제에 대한 답을 받아 심각한 잔여 문제가 없다고 판단했다.
Suggested-byPatch idea를 제안한 사람에게 credit을 준다.
FixesBug를 도입한 commit을 추적하고 stable 대상 version 판단을 돕는다. Stable Cc 요구를 대신하지는 않는다.

Tested-by와 Reviewed-by는 새 version의 변경이 작아 검증이 여전히 유효할 때 유지한다. 크게 바뀌었다면 제거하고 version changelog에 이유를 적는다.

Cc, Reported-by, Suggested-by를 제외한 사람 tag는 명시적 허락이 필요하다. 세 예외도 해당 identity가 public lore 또는 commit history에 사용됐고 report·suggestion이 공개된 경우에만 묵시적 허락을 인정한다. Public Bugzilla의 비공개 email을 임의로 노출해서는 안 된다.

Canonical patch message 구조

submitting-patches.rst:638-820
Subject: [PATCH v2 01/04] subsystem: concise summary

From: Patch Author <[email protected]>  # sender와 author가 다를 때

<75-column commit message: 문제, 영향, 해결 원리>

Signed-off-by: Patch Author <[email protected]>
---
<v1 -> v2 변경 사항과 reviewer용 메모>
<diffstat>
<actual diff>

Subject의 subsystem은 영향 영역을, summary는 file 이름이 아니라 무엇을 왜 바꾸는지를 70~75 character 안에 표현한다. Series는 1/4처럼 zero-padded order를 쓰고 RFC와 v2 같은 처리 tag를 [PATCH ...] 안에 둔다.

Explanation은 수개월·수년 뒤 discussion 없이 읽어도 patch 이유를 이해할 수 있어야 한다. Backtrace는 timestamp, register dump와 module list를 전부 붙이지 말고 실제 failure call chain만 남긴다.

--- 아래는 permanent commit log에 들어가지 않는 reviewer용 영역이다. Version별 변경, temporary note와 diffstat을 이곳에 둔다. Patch 적용 도구가 이 영역을 자동으로 제거한다.

Thread와 base-commit 정보

submitting-patches.rst:824-894

관련 bug report에 In-Reply-To를 걸 수 있지만 multi-patch series의 새 version을 모두 이전 series thread 아래 연결하면 reference tree가 복잡해진다. 이전 version은 cover letter의 lore link로 연결하는 편이 낫다.

git checkout -t -b my-topical-branch master
# commits...
git format-patch --base=auto --cover-letter -o outgoing/ master

Cover letter의 base-commit trailer는 reviewer와 CI가 정확한 tree에서 git am하도록 한다. Base는 외부에서 접근 가능한 official mainline 또는 maintainer tree commit이어야 하며 개인 내부 repository hash는 의미가 없다.

b4로 반복 작업 자동화

submitting-patches.rst:896-902

b4는 dependency 추적, checkpatch, patch formatting과 mail 전송 같은 기술 작업을 자동화할 수 있다. 자동화가 problem statement, test 근거와 review 판단을 대신하지는 않지만 message thread와 attestation을 일관되게 관리하는 데 유용하다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. _submittingpatches:
2
3 Submitting patches: the essential guide to getting your code into the kernel
4 ============================================================================
5
6 For a person or company who wishes to submit a change to the Linux
7 kernel, the process can sometimes be daunting if you're not familiar
8 with "the system." This text is a collection of suggestions which
9 can greatly increase the chances of your change being accepted.
10
11 This document contains a large number of suggestions in a relatively terse
12 format. For detailed information on how the kernel development process
13 works, see Documentation/process/development-process.rst. Also, read
14 Documentation/process/submit-checklist.rst
15 for a list of items to check before submitting code.
16 For device tree binding patches, read
17 Documentation/devicetree/bindings/submitting-patches.rst.
18
19 This documentation assumes that you're using ``git`` to prepare your patches.
20 If you're unfamiliar with ``git``, you would be well-advised to learn how to
21 use it, it will make your life as a kernel developer and in general much
22 easier.
23
24 Some subsystems and maintainer trees have additional information about
25 their workflow and expectations, see
26 :ref:`Documentation/process/maintainer-handbooks.rst <maintainer_handbooks_main>`.
27
28 Obtain a current source tree
29 ----------------------------
30
31 If you do not have a repository with the current kernel source handy, use
32 ``git`` to obtain one. You'll want to start with the mainline repository,
33 which can be grabbed with::
34
35 git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
36
37 Note, however, that you may not want to develop against the mainline tree
38 directly. Most subsystem maintainers run their own trees and want to see
39 patches prepared against those trees. See the **T:** entry for the subsystem
40 in the MAINTAINERS file to find that tree, or simply ask the maintainer if
41 the tree is not listed there.
42
43 .. _describe_changes:
44
45 Describe your changes
46 ---------------------
47
48 Describe your problem. Whether your patch is a one-line bug fix or
49 5000 lines of a new feature, there must be an underlying problem that
50 motivated you to do this work. Convince the reviewer that there is a
51 problem worth fixing and that it makes sense for them to read past the
52 first paragraph.
53
54 Describe user-visible impact. Straight up crashes and lockups are
55 pretty convincing, but not all bugs are that blatant. Even if the
56 problem was spotted during code review, describe the impact you think
57 it can have on users. Keep in mind that the majority of Linux
58 installations run kernels from secondary stable trees or
59 vendor/product-specific trees that cherry-pick only specific patches
60 from upstream, so include anything that could help route your change
61 downstream: provoking circumstances, excerpts from dmesg, crash
62 descriptions, performance regressions, latency spikes, lockups, etc.
63
64 Quantify optimizations and trade-offs. If you claim improvements in
65 performance, memory consumption, stack footprint, or binary size,
66 include numbers that back them up. But also describe non-obvious
67 costs. Optimizations usually aren't free but trade-offs between CPU,
68 memory, and readability; or, when it comes to heuristics, between
69 different workloads. Describe the expected downsides of your
70 optimization so that the reviewer can weigh costs against benefits.
71
72 Once the problem is established, describe what you are actually doing
73 about it in technical detail. It's important to describe the change
74 in plain English for the reviewer to verify that the code is behaving
75 as you intend it to.
76
77 The maintainer will thank you if you write your patch description in a
78 form which can be easily pulled into Linux's source code management
79 system, ``git``, as a "commit log". See :ref:`the_canonical_patch_format`.
80
81 Solve only one problem per patch. If your description starts to get
82 long, that's a sign that you probably need to split up your patch.
83 See :ref:`split_changes`.
84
85 When you submit or resubmit a patch or patch series, include the
86 complete patch description and justification for it. Don't just
87 say that this is version N of the patch (series). Don't expect the
88 subsystem maintainer to refer back to earlier patch versions or referenced
89 URLs to find the patch description and put that into the patch.
90 I.e., the patch (series) and its description should be self-contained.
91 This benefits both the maintainers and reviewers. Some reviewers
92 probably didn't even receive earlier versions of the patch.
93
94 Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
95 instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
96 to do frotz", as if you are giving orders to the codebase to change
97 its behaviour.
98
99 If you want to refer to a specific commit, don't just refer to the
100 SHA-1 ID of the commit. Please also include the oneline summary of
101 the commit, to make it easier for reviewers to know what it is about.
102 Example::
103
104 Commit e21d2170f36602ae2708 ("video: remove unnecessary
105 platform_set_drvdata()") removed the unnecessary
106 platform_set_drvdata(), but left the variable "dev" unused,
107 delete it.
108
109 You should also be sure to use at least the first twelve characters of the
110 SHA-1 ID. The kernel repository holds a *lot* of objects, making
111 collisions with shorter IDs a real possibility. Bear in mind that, even if
112 there is no collision with your six-character ID now, that condition may
113 change five years from now.
114
115 If related discussions or any other background information behind the change
116 can be found on the web, add 'Link:' tags pointing to it. If the patch is a
117 result of some earlier mailing list discussions or something documented on the
118 web, point to it.
119
120 When linking to mailing list archives, preferably use the lore.kernel.org
121 message archiver service. To create the link URL, use the contents of the
122 ``Message-ID`` header of the message without the surrounding angle brackets.
123 For example::
124
125 Link: https://lore.kernel.org/[email protected]
126
127 Please check the link to make sure that it is actually working and points
128 to the relevant message.
129
130 However, try to make your explanation understandable without external
131 resources. In addition to giving a URL to a mailing list archive or bug,
132 summarize the relevant points of the discussion that led to the
133 patch as submitted.
134
135 In case your patch fixes a bug, use the 'Closes:' tag with a URL referencing
136 the report in the mailing list archives or a public bug tracker. For example::
137
138 Closes: https://example.com/issues/1234
139
140 Some bug trackers have the ability to close issues automatically when a
141 commit with such a tag is applied. Some bots monitoring mailing lists can
142 also track such tags and take certain actions. Private bug trackers and
143 invalid URLs are forbidden.
144
145 If your patch fixes a bug in a specific commit, e.g. you found an issue using
146 ``git bisect``, please use the 'Fixes:' tag with at least the first 12
147 characters of the SHA-1 ID, and the one line summary. Do not split the tag
148 across multiple lines, tags are exempt from the "wrap at 75 columns" rule in
149 order to simplify parsing scripts. For example::
150
151 Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
152
153 The following ``git config`` settings can be used to add a pretty format for
154 outputting the above style in the ``git log`` or ``git show`` commands::
155
156 [core]
157 abbrev = 12
158 [pretty]
159 fixes = Fixes: %h (\"%s\")
160
161 An example call::
162
163 $ git log -1 --pretty=fixes 54a4f0239f2e
164 Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
165
166 .. _split_changes:
167
168 Separate your changes
169 ---------------------
170
171 Separate each **logical change** into a separate patch.
172
173 For example, if your changes include both bug fixes and performance
174 enhancements for a single driver, separate those changes into two
175 or more patches. If your changes include an API update, and a new
176 driver which uses that new API, separate those into two patches.
177
178 On the other hand, if you make a single change to numerous files,
179 group those changes into a single patch. Thus a single logical change
180 is contained within a single patch.
181
182 The point to remember is that each patch should make an easily understood
183 change that can be verified by reviewers. Each patch should be justifiable
184 on its own merits.
185
186 If one patch depends on another patch in order for a change to be
187 complete, that is OK. Simply note **"this patch depends on patch X"**
188 in your patch description.
189
190 When dividing your change into a series of patches, take special care to
191 ensure that the kernel builds and runs properly after each patch in the
192 series. Developers using ``git bisect`` to track down a problem can end up
193 splitting your patch series at any point; they will not thank you if you
194 introduce bugs in the middle.
195
196 If you cannot condense your patch set into a smaller set of patches,
197 then only post say 15 or so at a time and wait for review and integration.
198
199
200
201 Style-check your changes
202 ------------------------
203
204 Check your patch for basic style violations, details of which can be
205 found in Documentation/process/coding-style.rst.
206 Failure to do so simply wastes
207 the reviewers time and will get your patch rejected, probably
208 without even being read.
209
210 One significant exception is when moving code from one file to
211 another -- in this case you should not modify the moved code at all in
212 the same patch which moves it. This clearly delineates the act of
213 moving the code and your changes. This greatly aids review of the
214 actual differences and allows tools to better track the history of
215 the code itself.
216
217 Check your patches with the patch style checker prior to submission
218 (scripts/checkpatch.pl). Note, though, that the style checker should be
219 viewed as a guide, not as a replacement for human judgment. If your code
220 looks better with a violation then its probably best left alone.
221
222 The checker reports at three levels:
223 - ERROR: things that are very likely to be wrong
224 - WARNING: things requiring careful review
225 - CHECK: things requiring thought
226
227 You should be able to justify all violations that remain in your
228 patch.
229
230
231 Select the recipients for your patch
232 ------------------------------------
233
234 You should always copy the appropriate subsystem maintainer(s) and list(s) on
235 any patch to code that they maintain; look through the MAINTAINERS file and the
236 source code revision history to see who those maintainers are. The script
237 scripts/get_maintainer.pl can be very useful at this step (pass paths to your
238 patches as arguments to scripts/get_maintainer.pl). If you cannot find a
239 maintainer for the subsystem you are working on, Andrew Morton
240 ([email protected]) serves as a maintainer of last resort.
241
242 [email protected] should be used by default for all patches, but the
243 volume on that list has caused a number of developers to tune it out. Please
244 do not spam unrelated lists and unrelated people, though.
245
246 Many kernel-related lists are hosted at kernel.org; you can find a list
247 of them at https://subspace.kernel.org. There are kernel-related lists
248 hosted elsewhere as well, though.
249
250 Linus Torvalds is the final arbiter of all changes accepted into the
251 Linux kernel. His e-mail address is <[email protected]>.
252 He gets a lot of e-mail, and, at this point, very few patches go through
253 Linus directly, so typically you should do your best to -avoid-
254 sending him e-mail.
255
256 If you have a patch that fixes an exploitable security bug, send that patch
257 to [email protected]. For severe bugs, a short embargo may be considered
258 to allow distributors to get the patch out to users; in such cases,
259 obviously, the patch should not be sent to any public lists. See also
260 Documentation/process/security-bugs.rst.
261
262 Patches that fix a severe bug in a released kernel should be directed
263 toward the stable maintainers by putting a line like this::
264
266
267 into the sign-off area of your patch (note, NOT an email recipient). You
268 should also read Documentation/process/stable-kernel-rules.rst
269 in addition to this document.
270
271 If changes affect userland-kernel interfaces, please send the MAN-PAGES
272 maintainer (as listed in the MAINTAINERS file) a man-pages patch, or at
273 least a notification of the change, so that some information makes its way
274 into the manual pages. User-space API changes should also be copied to
276
277
278 No MIME, no links, no compression, no attachments. Just plain text
279 -------------------------------------------------------------------
280
281 Linus and other kernel developers need to be able to read and comment
282 on the changes you are submitting. It is important for a kernel
283 developer to be able to "quote" your changes, using standard e-mail
284 tools, so that they may comment on specific portions of your code.
285
286 For this reason, all patches should be submitted by e-mail "inline". The
287 easiest way to do this is with ``git send-email``, which is strongly
288 recommended. An interactive tutorial for ``git send-email`` is available at
289 https://git-send-email.io.
290
291 If you choose not to use ``git send-email``:
292
293 .. warning::
294
295 Be wary of your editor's word-wrap corrupting your patch,
296 if you choose to cut-n-paste your patch.
297
298 Do not attach the patch as a MIME attachment, compressed or not.
299 Many popular e-mail applications will not always transmit a MIME
300 attachment as plain text, making it impossible to comment on your
301 code. A MIME attachment also takes Linus a bit more time to process,
302 decreasing the likelihood of your MIME-attached change being accepted.
303
304 Exception: If your mailer is mangling patches then someone may ask
305 you to re-send them using MIME.
306
307 See Documentation/process/email-clients.rst for hints about configuring
308 your e-mail client so that it sends your patches untouched.
309
310 Respond to review comments
311 --------------------------
312
313 Your patch will almost certainly get comments from reviewers on ways in
314 which the patch can be improved, in the form of a reply to your email. You must
315 respond to those comments; ignoring reviewers is a good way to get ignored in
316 return. You can simply reply to their emails to answer their comments. Review
317 comments or questions that do not lead to a code change should almost certainly
318 bring about a comment or changelog entry so that the next reviewer better
319 understands what is going on.
320
321 Be sure to tell the reviewers what changes you are making and to thank them
322 for their time. Code review is a tiring and time-consuming process, and
323 reviewers sometimes get grumpy. Even in that case, though, respond
324 politely and address the problems they have pointed out. When sending a next
325 version, add a ``patch changelog`` to the cover letter or to individual patches
326 explaining difference against previous submission (see
327 :ref:`the_canonical_patch_format`).
328 Notify people that commented on your patch about new versions by adding them to
329 the patches CC list.
330
331 See Documentation/process/email-clients.rst for recommendations on email
332 clients and mailing list etiquette.
333
334 .. _interleaved_replies:
335
336 Use trimmed interleaved replies in email discussions
337 ----------------------------------------------------
338 Top-posting is strongly discouraged in Linux kernel development
339 discussions. Interleaved (or "inline") replies make conversations much
340 easier to follow. For more details see:
341 https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
342
343 As is frequently quoted on the mailing list::
344
345 A: http://en.wikipedia.org/wiki/Top_post
346 Q: Where do I find info about this thing called top-posting?
347 A: Because it messes up the order in which people normally read text.
348 Q: Why is top-posting such a bad thing?
349 A: Top-posting.
350 Q: What is the most annoying thing in e-mail?
351
352 Similarly, please trim all unneeded quotations that aren't relevant
353 to your reply. This makes responses easier to find, and saves time and
354 space. For more details see: http://daringfireball.net/2007/07/on_top ::
355
356 A: No.
357 Q: Should I include quotations after my reply?
358
359 .. _resend_reminders:
360
361 Don't get discouraged - or impatient
362 ------------------------------------
363
364 After you have submitted your change, be patient and wait. Reviewers are
365 busy people and may not get to your patch right away.
366
367 Once upon a time, patches used to disappear into the void without comment,
368 but the development process works more smoothly than that now. You should
369 receive comments within a few weeks (typically 2-3); if that does not
370 happen, make sure that you have sent your patches to the right place.
371 Wait for a minimum of one week before resubmitting or pinging reviewers
372 - possibly longer during busy times like merge windows.
373
374 It's also ok to resend the patch or the patch series after a couple of
375 weeks with the word "RESEND" added to the subject line::
376
377 [PATCH Vx RESEND] sub/sys: Condensed patch summary
378
379 Don't add "RESEND" when you are submitting a modified version of your
380 patch or patch series - "RESEND" only applies to resubmission of a
381 patch or patch series which have not been modified in any way from the
382 previous submission.
383
384
385 Include PATCH in the subject
386 -----------------------------
387
388 Due to high e-mail traffic to Linus, and to linux-kernel, it is common
389 convention to prefix your subject line with [PATCH]. This lets Linus
390 and other kernel developers more easily distinguish patches from other
391 e-mail discussions.
392
393 ``git send-email`` will do this for you automatically.
394
395
396 Sign your work - the Developer's Certificate of Origin
397 ------------------------------------------------------
398
399 To improve tracking of who did what, especially with patches that can
400 percolate to their final resting place in the kernel through several
401 layers of maintainers, we've introduced a "sign-off" procedure on
402 patches that are being emailed around.
403
404 The sign-off is a simple line at the end of the explanation for the
405 patch, which certifies that you wrote it or otherwise have the right to
406 pass it on as an open-source patch. The rules are pretty simple: if you
407 can certify the below:
408
409 Developer's Certificate of Origin 1.1
410 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411
412 By making a contribution to this project, I certify that:
413
414 (a) The contribution was created in whole or in part by me and I
415 have the right to submit it under the open source license
416 indicated in the file; or
417
418 (b) The contribution is based upon previous work that, to the best
419 of my knowledge, is covered under an appropriate open source
420 license and I have the right under that license to submit that
421 work with modifications, whether created in whole or in part
422 by me, under the same open source license (unless I am
423 permitted to submit under a different license), as indicated
424 in the file; or
425
426 (c) The contribution was provided directly to me by some other
427 person who certified (a), (b) or (c) and I have not modified
428 it.
429
430 (d) I understand and agree that this project and the contribution
431 are public and that a record of the contribution (including all
432 personal information I submit with it, including my sign-off) is
433 maintained indefinitely and may be redistributed consistent with
434 this project or the open source license(s) involved.
435
436 then you just add a line saying::
437
438 Signed-off-by: Random J Developer <[email protected]>
439
440 using a known identity (sorry, no anonymous contributions.)
441 This will be done for you automatically if you use ``git commit -s``.
442 Reverts should also include "Signed-off-by". ``git revert -s`` does that
443 for you.
444
445 Some people also put extra tags at the end. They'll just be ignored for
446 now, but you can do this to mark internal company procedures or just
447 point out some special detail about the sign-off.
448
449 Any further SoBs (Signed-off-by:'s) following the author's SoB are from
450 people handling and transporting the patch, but were not involved in its
451 development. SoB chains should reflect the **real** route a patch took
452 as it was propagated to the maintainers and ultimately to Linus, with
453 the first SoB entry signalling primary authorship of a single author.
454
455
456 When to use Acked-by:, Cc:, and Co-developed-by:
457 ------------------------------------------------
458
459 The Signed-off-by: tag indicates that the signer was involved in the
460 development of the patch, or that he/she was in the patch's delivery path.
461
462 If a person was not directly involved in the preparation or handling of a
463 patch but wishes to signify and record their approval of it then they can
464 ask to have an Acked-by: line added to the patch's changelog.
465
466 Acked-by: is meant to be used by those responsible for or involved with the
467 affected code in one way or another. Most commonly, the maintainer when that
468 maintainer neither contributed to nor forwarded the patch.
469
470 Acked-by: may also be used by other stakeholders, such as people with domain
471 knowledge (e.g. the original author of the code being modified), userspace-side
472 reviewers for a kernel uAPI patch or key users of a feature. Optionally, in
473 these cases, it can be useful to add a "# Suffix" to clarify its meaning::
474
475 Acked-by: The Stakeholder <[email protected]> # As primary user
476
477 Acked-by: is not as formal as Signed-off-by:. It is a record that the acker
478 has at least reviewed the patch and has indicated acceptance. Hence patch
479 mergers will sometimes manually convert an acker's "yep, looks good to me"
480 into an Acked-by: (but note that it is usually better to ask for an
481 explicit ack).
482
483 Acked-by: is also less formal than Reviewed-by:. For instance, maintainers may
484 use it to signify that they are OK with a patch landing, but they may not have
485 reviewed it as thoroughly as if a Reviewed-by: was provided. Similarly, a key
486 user may not have carried out a technical review of the patch, yet they may be
487 satisfied with the general approach, the feature or the user-facing interface.
488
489 Acked-by: does not necessarily indicate acknowledgement of the entire patch.
490 For example, if a patch affects multiple subsystems and has an Acked-by: from
491 one subsystem maintainer then this usually indicates acknowledgement of just
492 the part which affects that maintainer's code. Judgement should be used here.
493 When in doubt people should refer to the original discussion in the mailing
494 list archives. A "# Suffix" may also be used in this case to clarify.
495
496 If a person has had the opportunity to comment on a patch, but has not
497 provided such comments, you may optionally add a ``Cc:`` tag to the patch.
498 This tag documents that potentially interested parties have been included in
499 the discussion. Note, this is one of only three tags you might be able to use
500 without explicit permission of the person named (see 'Tagging people requires
501 permission' below for details).
502
503 Co-developed-by: states that the patch was co-created by multiple developers;
504 it is used to give attribution to co-authors (in addition to the author
505 attributed by the From: tag) when several people work on a single patch. Since
506 Co-developed-by: denotes authorship, every Co-developed-by: must be immediately
507 followed by a Signed-off-by: of the associated co-author. Standard sign-off
508 procedure applies, i.e. the ordering of Signed-off-by: tags should reflect the
509 chronological history of the patch insofar as possible, regardless of whether
510 the author is attributed via From: or Co-developed-by:. Notably, the last
511 Signed-off-by: must always be that of the developer submitting the patch.
512
513 Note, the From: tag is optional when the From: author is also the person (and
514 email) listed in the From: line of the email header.
515
516 Example of a patch submitted by the From: author::
517
518 <changelog>
519
520 Co-developed-by: First Co-Author <[email protected]>
521 Signed-off-by: First Co-Author <[email protected]>
522 Co-developed-by: Second Co-Author <[email protected]>
523 Signed-off-by: Second Co-Author <[email protected]>
524 Signed-off-by: From Author <[email protected]>
525
526 Example of a patch submitted by a Co-developed-by: author::
527
528 From: From Author <[email protected]>
529
530 <changelog>
531
532 Co-developed-by: Random Co-Author <[email protected]>
533 Signed-off-by: Random Co-Author <[email protected]>
534 Signed-off-by: From Author <[email protected]>
535 Co-developed-by: Submitting Co-Author <[email protected]>
536 Signed-off-by: Submitting Co-Author <[email protected]>
537
538
539 Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes:
540 ----------------------------------------------------------------------
541
542 The Reported-by tag gives credit to people who find bugs and report them and it
543 hopefully inspires them to help us again in the future. The tag is intended for
544 bugs; please do not use it to credit feature requests. The tag should be
545 followed by a Closes: tag pointing to the report, unless the report is not
546 available on the web. The Link: tag can be used instead of Closes: if the patch
547 fixes a part of the issue(s) being reported. Note, the Reported-by tag is one
548 of only three tags you might be able to use without explicit permission of the
549 person named (see 'Tagging people requires permission' below for details).
550
551 A Tested-by: tag indicates that the patch has been successfully tested (in
552 some environment) by the person named. This tag informs maintainers that
553 some testing has been performed, provides a means to locate testers for
554 future patches, and ensures credit for the testers.
555
556 Reviewed-by:, instead, indicates that the patch has been reviewed and found
557 acceptable according to the Reviewer's Statement:
558
559 Reviewer's statement of oversight
560 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
561
562 By offering my Reviewed-by: tag, I state that:
563
564 (a) I have carried out a technical review of this patch to
565 evaluate its appropriateness and readiness for inclusion into
566 the mainline kernel.
567
568 (b) Any problems, concerns, or questions relating to the patch
569 have been communicated back to the submitter. I am satisfied
570 with the submitter's response to my comments.
571
572 (c) While there may be things that could be improved with this
573 submission, I believe that it is, at this time, (1) a
574 worthwhile modification to the kernel, and (2) free of known
575 issues which would argue against its inclusion.
576
577 (d) While I have reviewed the patch and believe it to be sound, I
578 do not (unless explicitly stated elsewhere) make any
579 warranties or guarantees that it will achieve its stated
580 purpose or function properly in any given situation.
581
582 A Reviewed-by tag is a statement of opinion that the patch is an
583 appropriate modification of the kernel without any remaining serious
584 technical issues. Any interested reviewer (who has done the work) can
585 offer a Reviewed-by tag for a patch. This tag serves to give credit to
586 reviewers and to inform maintainers of the degree of review which has been
587 done on the patch. Reviewed-by: tags, when supplied by reviewers known to
588 understand the subject area and to perform thorough reviews, will normally
589 increase the likelihood of your patch getting into the kernel.
590
591 Both Tested-by and Reviewed-by tags, once received on mailing list from tester
592 or reviewer, should be added by author to the applicable patches when sending
593 next versions. However if the patch has changed substantially in following
594 version, these tags might not be applicable anymore and thus should be removed.
595 Usually removal of someone's Tested-by or Reviewed-by tags should be mentioned
596 in the patch changelog (after the '---' separator).
597
598 A Suggested-by: tag indicates that the patch idea is suggested by the person
599 named and ensures credit to the person for the idea: if we diligently credit
600 our idea reporters, they will, hopefully, be inspired to help us again in the
601 future. Note, this is one of only three tags you might be able to use without
602 explicit permission of the person named (see 'Tagging people requires
603 permission' below for details).
604
605 A Fixes: tag indicates that the patch fixes a bug in a previous commit. It
606 is used to make it easy to determine where an issue originated, which can help
607 review a bug fix. This tag also assists the stable kernel team in determining
608 which stable kernel versions should receive your fix. This is the preferred
609 method for indicating a bug fixed by the patch. See :ref:`describe_changes`
610 for more details.
611
612 Note: Attaching a Fixes: tag does not subvert the stable kernel rules
613 process nor the requirement to Cc: [email protected] on all stable
614 patch candidates. For more information, please read
615 Documentation/process/stable-kernel-rules.rst.
616
617 Finally, while providing tags is welcome and typically very appreciated, please
618 note that signers (i.e. submitters and maintainers) may use their discretion in
619 applying offered tags.
620
621 .. _tagging_people:
622
623 Tagging people requires permission
624 ----------------------------------
625
626 Be careful in the addition of the aforementioned tags to your patches, as all
627 except for Cc:, Reported-by:, and Suggested-by: need explicit permission of the
628 person named. For those three implicit permission is sufficient if the person
629 contributed to the Linux kernel using that name and email address according
630 to the lore archives or the commit history -- and in case of Reported-by:
631 and Suggested-by: did the reporting or suggestion in public. Note,
632 bugzilla.kernel.org is a public place in this sense, but email addresses
633 used there are private; so do not expose them in tags, unless the person
634 used them in earlier contributions.
635
636 .. _the_canonical_patch_format:
637
638 The canonical patch format
639 --------------------------
640
641 This section describes how the patch itself should be formatted. Note
642 that, if you have your patches stored in a ``git`` repository, proper patch
643 formatting can be had with ``git format-patch``. The tools cannot create
644 the necessary text, though, so read the instructions below anyway.
645
646 Subject Line
647 ^^^^^^^^^^^^
648
649 The canonical patch subject line is::
650
651 Subject: [PATCH 001/123] subsystem: summary phrase
652
653 The canonical patch message body contains the following:
654
655 - A ``from`` line specifying the patch author, followed by an empty
656 line (only needed if the person sending the patch is not the author).
657
658 - The body of the explanation, line wrapped at 75 columns, which will
659 be copied to the permanent changelog to describe this patch.
660
661 - An empty line.
662
663 - The ``Signed-off-by:`` lines, described above, which will
664 also go in the changelog.
665
666 - A marker line containing simply ``---``.
667
668 - Any additional comments not suitable for the changelog.
669
670 - The actual patch (``diff`` output).
671
672 The Subject line format makes it very easy to sort the emails
673 alphabetically by subject line - pretty much any email reader will
674 support that - since because the sequence number is zero-padded,
675 the numerical and alphabetic sort is the same.
676
677 The ``subsystem`` in the email's Subject should identify which
678 area or subsystem of the kernel is being patched.
679
680 The ``summary phrase`` in the email's Subject should concisely
681 describe the patch which that email contains. The ``summary
682 phrase`` should not be a filename. Do not use the same ``summary
683 phrase`` for every patch in a whole patch series (where a ``patch
684 series`` is an ordered sequence of multiple, related patches).
685
686 Bear in mind that the ``summary phrase`` of your email becomes a
687 globally-unique identifier for that patch. It propagates all the way
688 into the ``git`` changelog. The ``summary phrase`` may later be used in
689 developer discussions which refer to the patch. People will want to
690 google for the ``summary phrase`` to read discussion regarding that
691 patch. It will also be the only thing that people may quickly see
692 when, two or three months later, they are going through perhaps
693 thousands of patches using tools such as ``gitk`` or ``git log
694 --oneline``.
695
696 For these reasons, the ``summary`` must be no more than 70-75
697 characters, and it must describe both what the patch changes, as well
698 as why the patch might be necessary. It is challenging to be both
699 succinct and descriptive, but that is what a well-written summary
700 should do.
701
702 The ``summary phrase`` may be prefixed by tags enclosed in square
703 brackets: "Subject: [PATCH <tag>...] <summary phrase>". The tags are
704 not considered part of the summary phrase, but describe how the patch
705 should be treated. Common tags might include a version descriptor if
706 the multiple versions of the patch have been sent out in response to
707 comments (i.e., "v1, v2, v3"), or "RFC" to indicate a request for
708 comments.
709
710 If there are four patches in a patch series the individual patches may
711 be numbered like this: 1/4, 2/4, 3/4, 4/4. This assures that developers
712 understand the order in which the patches should be applied and that
713 they have reviewed or applied all of the patches in the patch series.
714
715 Here are some good example Subjects::
716
717 Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching
718 Subject: [PATCH v2 01/27] x86: fix eflags tracking
719 Subject: [PATCH v2] sub/sys: Condensed patch summary
720 Subject: [PATCH v2 M/N] sub/sys: Condensed patch summary
721
722 From Line
723 ^^^^^^^^^
724
725 The ``from`` line must be the very first line in the message body,
726 and has the form:
727
728 From: Patch Author <[email protected]>
729
730 The ``from`` line specifies who will be credited as the author of the
731 patch in the permanent changelog. If the ``from`` line is missing,
732 then the ``From:`` line from the email header will be used to determine
733 the patch author in the changelog.
734
735 The author may indicate their affiliation or the sponsor of the work
736 by adding the name of an organization to the ``from`` and ``SoB`` lines,
737 e.g.:
738
739 From: Patch Author (Company) <[email protected]>
740
741 Explanation Body
742 ^^^^^^^^^^^^^^^^
743
744 The explanation body will be committed to the permanent source
745 changelog, so should make sense to a competent reader who has long since
746 forgotten the immediate details of the discussion that might have led to
747 this patch. Including symptoms of the failure which the patch addresses
748 (kernel log messages, oops messages, etc.) are especially useful for
749 people who might be searching the commit logs looking for the applicable
750 patch. The text should be written in such detail so that when read
751 weeks, months or even years later, it can give the reader the needed
752 details to grasp the reasoning for **why** the patch was created.
753
754 If a patch fixes a compile failure, it may not be necessary to include
755 _all_ of the compile failures; just enough that it is likely that
756 someone searching for the patch can find it. As in the ``summary
757 phrase``, it is important to be both succinct as well as descriptive.
758
759 .. _backtraces:
760
761 Backtraces in commit messages
762 """""""""""""""""""""""""""""
763
764 Backtraces help document the call chain leading to a problem. However,
765 not all backtraces are helpful. For example, early boot call chains are
766 unique and obvious. Copying the full dmesg output verbatim, however,
767 adds distracting information like timestamps, module lists, register and
768 stack dumps.
769
770 Therefore, the most useful backtraces should distill the relevant
771 information from the dump, which makes it easier to focus on the real
772 issue. Here is an example of a well-trimmed backtrace::
773
774 unchecked MSR access error: WRMSR to 0xd51 (tried to write 0x0000000000000064)
775 at rIP: 0xffffffffae059994 (native_write_msr+0x4/0x20)
776 Call Trace:
777 mba_wrmsr
778 update_domains
779 rdtgroup_mkdir
780
781 Commentary
782 ^^^^^^^^^^
783
784 The ``---`` marker line serves the essential purpose of marking for
785 patch handling tools where the changelog message ends.
786
787 One good use for the additional comments after the ``---`` marker is
788 for a ``diffstat``, to show what files have changed, and the number of
789 inserted and deleted lines per file. A ``diffstat`` is especially useful
790 on bigger patches. If you are going to include a ``diffstat`` after the
791 ``---`` marker, please use ``diffstat`` options ``-p 1 -w 70`` so that
792 filenames are listed from the top of the kernel source tree and don't
793 use too much horizontal space (easily fit in 80 columns, maybe with some
794 indentation). (``git`` generates appropriate diffstats by default.)
795
796 Other comments relevant only to the moment or the maintainer, not
797 suitable for the permanent changelog, should also go here. A good
798 example of such comments might be ``patch changelogs`` which describe
799 what has changed between the v1 and v2 version of the patch.
800
801 Please put this information **after** the ``---`` line which separates
802 the changelog from the rest of the patch. The version information is
803 not part of the changelog which gets committed to the git tree. It is
804 additional information for the reviewers. If it's placed above the
805 commit tags, it needs manual interaction to remove it. If it is below
806 the separator line, it gets automatically stripped off when applying the
807 patch::
808
809 <commit message>
810 ...
811 Signed-off-by: Author <author@mail>
812 ---
813 V2 -> V3: Removed redundant helper function
814 V1 -> V2: Cleaned up coding style and addressed review comments
815
816 path/to/file | 5+++--
817 ...
818
819 See more details on the proper patch format in the following
820 references.
821
822 .. _explicit_in_reply_to:
823
824 Explicit In-Reply-To headers
825 ----------------------------
826
827 It can be helpful to manually add In-Reply-To: headers to a patch
828 (e.g., when using ``git send-email``) to associate the patch with
829 previous relevant discussion, e.g. to link a bug fix to the email with
830 the bug report. However, for a multi-patch series, it is generally
831 best to avoid using In-Reply-To: to link to older versions of the
832 series. This way multiple versions of the patch don't become an
833 unmanageable forest of references in email clients. If a link is
834 helpful, you can use the https://lore.kernel.org/ redirector (e.g., in
835 the cover email text) to link to an earlier version of the patch series.
836
837
838 Providing base tree information
839 -------------------------------
840
841 When other developers receive your patches and start the review process,
842 it is absolutely necessary for them to know what is the base
843 commit/branch your work applies on, considering the sheer amount of
844 maintainer trees present nowadays. Note again the **T:** entry in the
845 MAINTAINERS file explained above.
846
847 This is even more important for automated CI processes that attempt to
848 run a series of tests in order to establish the quality of your
849 submission before the maintainer starts the review.
850
851 If you are using ``git format-patch`` to generate your patches, you can
852 automatically include the base tree information in your submission by
853 using the ``--base`` flag. The easiest and most convenient way to use
854 this option is with topical branches::
855
856 $ git checkout -t -b my-topical-branch master
857 Branch 'my-topical-branch' set up to track local branch 'master'.
858 Switched to a new branch 'my-topical-branch'
859
860 [perform your edits and commits]
861
862 $ git format-patch --base=auto --cover-letter -o outgoing/ master
863 outgoing/0000-cover-letter.patch
864 outgoing/0001-First-Commit.patch
865 outgoing/...
866
867 When you open ``outgoing/0000-cover-letter.patch`` for editing, you will
868 notice that it will have the ``base-commit:`` trailer at the very
869 bottom, which provides the reviewer and the CI tools enough information
870 to properly perform ``git am`` without worrying about conflicts::
871
872 $ git checkout -b patch-review [base-commit-id]
873 Switched to a new branch 'patch-review'
874 $ git am patches.mbox
875 Applying: First Commit
876 Applying: ...
877
878 Please see ``man git-format-patch`` for more information about this
879 option.
880
881 .. note::
882
883 The ``--base`` feature was introduced in git version 2.9.0.
884
885 If you are not using git to format your patches, you can still include
886 the same ``base-commit`` trailer to indicate the commit hash of the tree
887 on which your work is based. You should add it either in the cover
888 letter or in the first patch of the series and it should be placed
889 either below the ``---`` line or at the very bottom of all other
890 content, right before your email signature.
891
892 Make sure that base commit is in an official maintainer/mainline tree
893 and not in some internal, accessible only to you tree - otherwise it
894 would be worthless.
895
896 Tooling
897 -------
898
899 Many of the technical aspects of this process can be automated using
900 b4, documented at <https://b4.docs.kernel.org/en/latest/>. This can
901 help with things like tracking dependencies, running checkpatch and
902 with formatting and sending mails.
903
904 References
905 ----------
906
907 Andrew Morton, "The perfect patch" (tpp).
908 <https://www.ozlabs.org/~akpm/stuff/tpp.txt>
909
910 Jeff Garzik, "Linux kernel patch submission format".
911 <https://web.archive.org/web/20180829112450/http://linux.yyz.us/patch-format.html>
912
913 Greg Kroah-Hartman, "How to piss off a kernel subsystem maintainer".
914 <http://www.kroah.com/log/linux/maintainer.html>
915
916 <http://www.kroah.com/log/linux/maintainer-02.html>
917
918 <http://www.kroah.com/log/linux/maintainer-03.html>
919
920 <http://www.kroah.com/log/linux/maintainer-04.html>
921
922 <http://www.kroah.com/log/linux/maintainer-05.html>
923
924 <http://www.kroah.com/log/linux/maintainer-06.html>
925
926 Kernel Documentation/process/coding-style.rst
927
928 Linus Torvalds's mail on the canonical patch format:
929 <https://lore.kernel.org/r/[email protected]>
930
931 Andi Kleen, "On submitting kernel patches"
932 Some strategies to get difficult or controversial changes in.
933
934 http://halobates.de/on-submitting-patches.pdf
935

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

현재 source tree와 subsystem workflow 확인

1-42

Linux kernel change를 제출하려는 개인이나 회사는 익숙하지 않은 process를 어렵게 느낄 수 있다. 이 문서는 change가 받아들여질 가능성을 크게 높이는 지침을 간결하게 모은다.

Kernel development process의 자세한 설명은 Documentation/process/development-process.rst, 제출 전 checklist는 Documentation/process/submit-checklist.rst를 본다. Device tree binding patch는 Documentation/devicetree/bindings/submitting-patches.rst를 읽는다. Subsystem·maintainer tree별 추가 workflow는 Documentation/process/maintainer-handbooks.rst에 있다.

이 문서는 git으로 patch를 만든다고 가정한다. Git을 모르면 먼저 익히는 것이 kernel development와 일반 작업을 훨씬 쉽게 만든다.

Current source repository가 없다면 mainline repository를 clone한다.

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

다만 mainline을 직접 base로 쓰지 않을 수 있다. Subsystem maintainer 대부분은 자체 tree를 운영하고 그 tree 기준 patch를 원한다. MAINTAINERS의 해당 subsystem T: entry에서 tree를 찾고 없으면 maintainer에게 묻는다.

Problem, impact, trade-off와 solution 설명

43-165

한 line bug fix든 5,000 line 새 feature든 작업을 시작하게 한 underlying problem이 있어야 한다. Reviewer에게 고칠 가치가 있는 문제이며 첫 paragraph 뒤도 읽을 이유가 있음을 설득한다.

User-visible impact를 설명한다. Crash와 lockup만 impact가 아니다. Code review에서 발견한 문제라도 사용자에게 어떤 영향을 줄지 적는다. Linux 설치 대부분은 upstream에서 일부 patch만 cherry-pick하는 secondary stable tree나 vendor/product tree를 사용하므로 downstream routing에 도움이 되는 정보를 포함한다.

  • 문제가 발생하는 조건
  • dmesg 발췌와 crash description
  • Performance regression과 latency spike
  • Lockup 등 사용자 관측 증상

Performance, memory consumption, stack footprint, binary size 개선을 주장하면 수치로 입증한다. CPU, memory, readability 사이 trade-off나 heuristic이 workload별로 보이는 차이처럼 잘 드러나지 않는 cost도 설명한다. Reviewer가 benefit과 cost를 비교할 수 있어야 한다.

Problem을 세운 뒤 실제로 무엇을 바꾸는지 technical detail을 plain English로 설명한다. Reviewer가 code가 의도대로 동작하는지 검증할 수 있어야 한다. Git commit log로 바로 가져갈 수 있는 형식이면 maintainer에게 도움이 된다.

Patch 하나는 problem 하나만 해결한다. Description이 길어지기 시작하면 patch를 나눌 신호다. 제출·재제출할 때마다 complete description과 justification을 포함한다. 단지 version N이라고 쓰거나 maintainer가 이전 version과 외부 URL에서 설명을 찾아 조합할 것이라 기대하지 않는다. Patch series와 description은 self-contained여야 하며 이전 version을 받지 못한 reviewer에게도 필요하다.

Change description은 “[This patch] makes xyzzy do frotz”나 “[I] changed...” 대신 “make xyzzy do frotz”처럼 codebase에 behavior change를 지시하는 imperative mood로 쓴다.

특정 commit을 가리킬 때 SHA-1만 쓰지 말고 one-line summary도 넣는다. SHA-1은 최소 첫 12 character를 사용한다. Kernel repository object가 매우 많아 짧은 ID는 현재 충돌하지 않아도 몇 년 뒤 충돌할 수 있다.

Commit e21d2170f36602ae2708 ("video: remove unnecessary
platform_set_drvdata()") removed the unnecessary
platform_set_drvdata(), but left the variable "dev" unused,
delete it.

관련 discussion이나 background가 web에 있으면 Link: tag를 추가한다. Mailing list archive는 lore.kernel.org를 선호하며 Message-ID에서 angle bracket을 뺀 값을 URL에 넣는다. Link가 실제 relevant message로 동작하는지 확인한다.

Link: https://lore.kernel.org/[email protected]

External resource 없이도 설명을 이해할 수 있게 한다. URL만 제시하지 말고 제출된 patch로 이어진 discussion 핵심을 요약한다.

Bug fix는 public mailing list archive나 bug tracker report를 Closes: URL로 가리킨다. 일부 tracker는 commit 적용 시 issue를 자동 close하고 mailing list bot도 추적한다. Private tracker와 invalid URL은 금지된다.

Closes: https://example.com/issues/1234

특정 commit의 bug를 고치면 Fixes:에 12자 이상 SHA-1과 one-line summary를 넣고 여러 line으로 나누지 않는다. Tag는 parsing script를 위해 75-column wrap rule의 예외다.

Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")

다음 git config는 git log·show에서 같은 Fixes 형식을 만든다.

[core]
        abbrev = 12
[pretty]
        fixes = Fixes: %h (\"%s\")

$ git log -1 --pretty=fixes 54a4f0239f2e

Logical change 분리와 style check

166-228

각 logical change를 별도 patch로 나눈다. 한 driver의 bug fix와 performance enhancement는 둘 이상 patch로 나누고, API update와 그 API를 쓰는 new driver도 분리한다.

반대로 하나의 logical change가 많은 file을 수정한다면 한 patch에 묶는다. 각 patch는 reviewer가 쉽게 이해하고 검증할 수 있어야 하며 자체 merit로 정당화돼야 한다.

Change 완성에 다른 patch가 필요해도 괜찮다. Description에 “this patch depends on patch X”라고 명시한다.

Series의 각 patch 뒤에 kernel이 정상 build·run되는지 특히 주의한다. git bisect는 series 어느 지점에서든 잘라 test할 수 있으므로 중간 commit이 bug를 만들면 안 된다.

Patch set을 더 줄일 수 없다면 한 번에 약 15개만 게시하고 review와 integration을 기다린다.

Documentation/process/coding-style.rst에 따라 기본 style violation을 검사한다. 하지 않으면 reviewer 시간을 낭비하고 읽히지도 않은 채 거부될 수 있다.

예외는 code를 file 사이에 옮기는 patch다. Move patch에서 moved code 자체를 함께 고치지 않는다. 이동과 수정이 명확히 분리되어 actual difference review와 history tracking이 쉬워진다.

제출 전 scripts/checkpatch.pl을 실행한다. 다만 checker는 human judgment를 대신하지 않는 guide다. Violation이 있어도 code가 더 읽기 좋다면 그대로 둘 수 있지만 남은 모든 violation을 설명할 수 있어야 한다.

Level의미
ERROR잘못됐을 가능성이 매우 높은 항목
WARNING주의 깊은 review가 필요한 항목
CHECK생각해 볼 필요가 있는 항목

Patch recipient 선택

231-276

Maintained code patch에는 적절한 subsystem maintainer와 list를 항상 CC한다. MAINTAINERS와 source revision history를 확인하고 scripts/get_maintainer.pl에 patch path를 argument로 넘겨 활용한다. Maintainer를 찾지 못하면 Andrew Morton([email protected])이 last resort maintainer다.

모든 patch에는 기본적으로 [email protected]를 사용하지만 volume이 커서 일부 developer는 보지 않는다. 관련 없는 list와 사람에게 spam을 보내지 않는다. Kernel.org hosting list는 subspace.kernel.org에서 찾을 수 있고 외부 hosting list도 있다.

Linus Torvalds는 최종 arbiter이며 address는 [email protected]다. Mail이 매우 많고 현재 patch가 Linus에게 직접 가는 경우는 거의 없으므로 보통 직접 보내지 않도록 최선을 다한다.

Exploitable security bug fix는 [email protected]로 보낸다. Severe bug는 distributor가 user에게 patch를 전달할 시간을 주기 위해 짧은 embargo를 둘 수 있으므로 이 경우 public list에 보내지 않는다. Documentation/process/security-bugs.rst를 참고한다.

Released kernel의 severe bug fix는 sign-off area에 Cc: [email protected]를 넣는다. 이는 email recipient가 아니다. Documentation/process/stable-kernel-rules.rst도 읽는다.

Userland-kernel interface change는 MAINTAINERS의 MAN-PAGES maintainer에게 man-page patch 또는 최소한 notification을 보내고 [email protected]도 CC한다.

Plain-text email, review response와 resend

278-395

Patch는 inline plain text로 보낸다

Developer가 standard email tool로 change 일부를 quote해 comment할 수 있어야 한다. 모든 patch를 email 본문 inline으로 보내며 git send-email을 강하게 권장한다.

Cut-and-paste한다면 editor word-wrap이 patch를 훼손하지 않게 한다. Compressed 여부와 상관없이 MIME attachment로 붙이지 않는다. Mail application이 plain text 그대로 전송하지 않아 line comment가 불가능해질 수 있고 처리 시간도 늘어 acceptance 가능성이 낮아진다. Mailer가 patch를 망가뜨리면 누군가 MIME resend를 요청하는 예외는 있다.

Review comment에 답한다

거의 반드시 improvement comment를 받는다. 반드시 답해야 하며 reviewer를 무시하면 자신도 무시당한다. Code change로 이어지지 않은 question과 comment도 다음 reviewer가 이해하도록 code comment나 changelog entry로 남길 가능성이 높다.

어떤 change를 할지 reviewer에게 알리고 시간에 감사한다. Review는 피곤하고 오래 걸려 reviewer가 불친절해질 때도 있지만 정중히 답하고 지적한 문제를 해결한다.

다음 version에는 cover letter나 개별 patch에 이전 submission과의 차이를 설명하는 patch changelog를 넣는다. Comment한 사람을 새 version CC list에 추가해 알린다.

Trimmed interleaved reply

Kernel discussion에서는 top-posting을 강하게 피한다. 필요한 quote 바로 아래에 inline reply를 달고 답과 무관한 quote를 모두 자른다.

A: http://en.wikipedia.org/wiki/Top_post
Q: Where do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

기다림과 RESEND

제출 뒤에는 기다린다. 보통 2~3주 안에 comment를 받는다. 없다면 올바른 곳에 보냈는지 확인한다. Resubmit 또는 ping 전 최소 1주를 기다리고 merge window 같은 busy period에는 더 기다린다.

몇 주 뒤 변경 없이 다시 보내면 subject에 RESEND를 추가한다. 수정한 version에는 RESEND를 쓰지 않는다.

[PATCH Vx RESEND] sub/sys: Condensed patch summary

Mail traffic에서 patch를 구분하도록 subject에 [PATCH]를 붙인다. git send-email이 자동으로 처리한다.

Developer's Certificate of Origin 1.1

396-455

여러 maintainer layer를 거치는 patch에서 누가 무엇을 했는지 추적하도록 sign-off 절차를 사용한다. Patch 설명 끝의 단순한 line으로 자신이 작성했거나 open-source patch로 전달할 권리가 있음을 인증한다.

기여자가 인증하는 내용

(a) Contribution 전부 또는 일부를 자신이 만들었고 file에 표시된 open source license로 제출할 권리가 있다.

(b) 아는 한 contribution이 적절한 open source license가 적용된 prior work에 기반하며, 그 license에 따라 자신이 전부 또는 일부 만든 modification과 함께 file에 표시된 같은 license로 제출할 권리가 있다. 다른 license로 제출할 허가가 있으면 그 license를 사용할 수 있다.

(c) (a), (b), 또는 (c)를 인증한 다른 사람이 contribution을 직접 제공했고 자신은 수정하지 않았다.

(d) Project와 contribution이 public이고 자신이 제출한 모든 personal information과 sign-off를 포함한 contribution record가 무기한 유지되며 project 또는 관련 open source license에 따라 재배포될 수 있음을 이해하고 동의한다.

위 조건을 인증할 수 있으면 known identity로 Signed-off-by를 추가한다. Anonymous contribution은 허용되지 않는다.

Signed-off-by: Random J Developer <[email protected]>

git commit -s가 자동으로 추가하고 revert는 git revert -s를 사용한다. 추가 internal company tag를 끝에 둘 수 있으며 현재는 무시되지만 내부 절차나 sign-off의 특별한 detail을 표시할 수 있다.

Author SoB 뒤의 SoB는 개발에는 참여하지 않고 patch를 처리·운반한 사람의 것이다. Chain은 maintainer와 최종적으로 Linus까지 patch가 실제 이동한 경로를 반영하며 첫 SoB는 single author의 primary authorship을 나타낸다.

Acked-by, Cc와 Co-developed-by

456-537

Signed-off-by는 signer가 patch 개발 또는 delivery path에 참여했음을 뜻한다.

Patch preparation이나 handling에 직접 참여하지 않았지만 approval을 기록하고 싶다면 Acked-by를 요청할 수 있다. 주로 영향받는 code의 책임자나 관계자가 사용한다. Maintainer가 patch를 만들거나 전달하지 않았지만 landing에 동의할 때 흔하다.

Original code author 같은 domain expert, kernel uAPI patch의 userspace reviewer, feature 주요 사용자도 쓸 수 있다. 의미를 분명히 하려면 # Suffix를 붙일 수 있다.

Acked-by: The Stakeholder <[email protected]> # As primary user

Acked-by는 Signed-off-by보다 덜 formal하며 최소한 patch를 보고 acceptance를 표시했다는 기록이다. “looks good” 답을 merger가 Acked-by로 바꾸기도 하지만 explicit ack를 요청하는 편이 좋다.

Reviewed-by보다도 덜 formal하다. Maintainer가 landing에는 동의하지만 thorough technical review는 하지 않았거나 주요 사용자가 general approach와 interface에는 만족하지만 technical review는 하지 않았을 수 있다.

여러 subsystem patch에서 한 maintainer Acked-by는 보통 그 maintainer 영역만 인정한다. Original discussion과 # Suffix를 보고 판단한다.

Comment 기회가 있었지만 comment하지 않은 사람에게는 optional Cc: tag를 붙여 interested party가 discussion에 포함됐음을 기록할 수 있다. Explicit permission 없이 사용할 수 있을 가능성이 있는 tag 세 개 중 하나다.

Co-developed-by는 여러 developer가 patch를 공동 작성했음을 기록한다. Git From: author 외 co-author에게 attribution한다. Authorship이므로 각 Co-developed-by 바로 뒤에 같은 co-author의 Signed-off-by가 반드시 와야 한다.

SOB ordering은 From:과 Co-developed-by 중 어느 방식으로 author를 표시하든 가능한 한 patch의 chronological history를 반영한다. 마지막 Signed-off-by는 항상 실제 submitter다. Email header From과 author name·email이 같으면 body From: tag는 optional이다.

<changelog>

Co-developed-by: First Co-Author <[email protected]>
Signed-off-by: First Co-Author <[email protected]>
Co-developed-by: Second Co-Author <[email protected]>
Signed-off-by: Second Co-Author <[email protected]>
Signed-off-by: From Author <[email protected]>

From: From Author <[email protected]>

<changelog>

Co-developed-by: Random Co-Author <[email protected]>
Signed-off-by: Random Co-Author <[email protected]>
Signed-off-by: From Author <[email protected]>
Co-developed-by: Submitting Co-Author <[email protected]>
Signed-off-by: Submitting Co-Author <[email protected]>

Reported, Tested, Reviewed, Suggested와 Fixes tag

539-620

Reported-by는 bug를 찾아 report한 사람에게 credit을 주고 향후에도 돕도록 장려한다. Feature request credit에는 쓰지 않는다. Web report가 없다면 예외지만 보통 바로 뒤에 report를 가리키는 Closes:가 와야 한다. Report된 issue 일부만 고치면 Link:를 쓸 수 있다. Explicit permission 없이 쓸 수 있을 가능성이 있는 tag 중 하나다.

Tested-by는 표시된 사람이 어떤 environment에서 patch를 성공적으로 test했음을 뜻한다. Maintainer에게 test 사실을 알리고 future patch tester를 찾을 수 있게 하며 tester에게 credit을 준다.

Reviewer's statement of oversight

Reviewed-by를 제공하는 reviewer는 다음을 진술한다.

  • Mainline kernel inclusion의 적절성과 readiness를 평가하기 위해 technical review를 수행했다.
  • Patch 관련 problem, concern, question을 submitter에게 전달했고 comment에 대한 response에 만족한다.
  • 더 개선할 점은 있을 수 있지만 현재 가치 있는 kernel modification이며 inclusion을 반대하게 할 known issue가 없다고 믿는다.
  • Patch가 sound하다고 믿지만 별도 명시가 없는 한 목적 달성이나 모든 상황의 정상 동작을 보증하지 않는다.

Reviewed-by는 심각한 technical issue가 남지 않은 적절한 kernel modification이라는 opinion이다. 실제 review를 수행한 누구나 제공할 수 있다. Reviewer credit과 review 정도를 maintainer에게 알린다. Subject 이해와 thorough review로 알려진 사람의 tag는 merge 가능성을 높인다.

Mailing list에서 받은 Tested-by와 Reviewed-by는 다음 version의 해당 patch에 추가한다. Patch가 크게 바뀌어 더는 적용되지 않으면 제거하고 보통 --- 아래 patch changelog에서 제거 사실을 말한다.

Suggested-by는 patch idea를 제안한 사람에게 credit을 준다. 이 역시 explicit permission 없이 쓸 수 있을 가능성이 있는 세 tag 중 하나다.

Fixes:는 이전 commit의 bug를 고친다는 뜻으로 issue origin 파악과 bug fix review를 돕고 stable team이 적용할 version을 정하는 데도 쓰인다. Fixes:가 stable rule을 우회하지 않으며 stable 후보에는 별도 Cc: [email protected]가 여전히 필요하다.

Tag 제공은 환영받지만 signer, submitter, maintainer는 offered tag 적용 여부를 재량으로 결정할 수 있다.

사람 이름을 tag에 넣기 위한 permission

621-635

Cc:, Reported-by:, Suggested-by:를 제외한 앞의 모든 tag는 이름이 들어가는 사람의 explicit permission이 필요하다.

이 세 tag는 lore archive나 commit history에서 그 name과 email로 Linux kernel에 기여했고, Reported-by와 Suggested-by의 경우 public하게 report 또는 suggestion했다면 implicit permission으로 쓸 수 있다.

bugzilla.kernel.org는 이 의미에서 public place지만 그곳에 사용된 email address는 private이다. 이전 contribution에서 공개적으로 사용한 address가 아니라면 tag에 노출하지 않는다.

Canonical patch format과 subject

636-740

Git repository에 patch가 있다면 git format-patch가 올바른 formatting을 만든다. Tool은 필요한 설명 text를 만들 수 없으므로 지침을 직접 따라야 한다.

Subject: [PATCH 001/123] subsystem: summary phrase

Canonical message body 순서는 sender와 author가 다를 때만 필요한 author From: line, empty line, 75 column로 wrap한 permanent changelog explanation, empty line, Signed-off-by line, --- marker, permanent changelog에 부적합한 comment, 실제 diff다.

그림 1. Canonical patch mail body
Optional From: authorExplanation bodyCommit tags / Signed-off-by--- separatorVersion notes / diffstatPatch diff

Apply tool은 --- 위를 permanent commit message로 가져가고 아래의 version note와 diffstat를 review-only 정보로 제거한다.

Zero-padded sequence number 덕분에 subject alphabetic sort와 numeric sort가 같아 mail reader에서 쉽게 정렬된다.

Subject의 subsystem은 kernel의 대상 area를 식별한다. Summary phrase는 해당 mail patch를 간결히 설명하고 filename이어서는 안 된다. Series 전체 patch에 같은 summary를 반복하지 않는다.

Summary는 patch의 globally unique identifier가 되어 git changelog와 developer discussion에 남고 검색어로 쓰인다. 몇 달 뒤 수천 patch를 gitk나 git log --oneline으로 볼 때 빠르게 보이는 유일한 정보일 수 있다.

Summary는 70~75 character 이내에서 무엇을 바꾸고 왜 필요한지를 모두 나타낸다. 간결하면서 descriptive해야 한다.

[PATCH <tag>...] 형식의 bracket tag는 summary 일부가 아니며 patch 취급 방법을 표시한다. V1, v2, v3는 revision, RFC는 comment request다. Four-patch series는 1/4~4/4로 numbering해 application order와 누락 여부를 알려 준다.

Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching
Subject: [PATCH v2 01/27] x86: fix eflags tracking
Subject: [PATCH v2] sub/sys: Condensed patch summary
Subject: [PATCH v2 M/N] sub/sys: Condensed patch summary

Body의 from line은 첫 line이어야 하며 permanent changelog의 author를 정한다. 없으면 email header From:을 사용한다. Organization 이름을 from과 SoB에 넣어 affiliation 또는 sponsor를 표시할 수 있다.

From: Patch Author <[email protected]>
From: Patch Author (Company) <[email protected]>

Explanation, backtrace와 --- 아래 commentary

741-821

Explanation body는 permanent source changelog에 commit된다. Discussion detail을 오래전에 잊은 competent reader도 이해해야 한다. Kernel log, oops 등 failure symptom은 나중 commit log에서 applicable patch를 찾는 사람에게 특히 유용하다. 몇 주, 몇 달, 몇 년 뒤에도 patch를 만든 이유를 파악할 detail을 남긴다.

Compile failure fix에서 모든 error를 붙일 필요는 없다. Search로 patch를 찾을 만큼만 남기고 간결하면서 descriptive하게 쓴다.

Backtrace는 problem까지의 call chain을 기록하지만 모두 유용하지는 않다. Early boot call chain처럼 unique하고 obvious한 경우가 있고 full dmesg에는 timestamp, module list, register·stack dump가 섞여 집중을 방해한다. Relevant information만 추린다.

unchecked MSR access error: WRMSR to 0xd51 (tried to write 0x0000000000000064)
at rIP: 0xffffffffae059994 (native_write_msr+0x4/0x20)
Call Trace:
mba_wrmsr
update_domains
rdtgroup_mkdir

--- marker는 patch handling tool에 changelog 종료 위치를 알린다. 아래에는 changed file과 insert/delete line 수를 보여 주는 diffstat를 둘 수 있고 큰 patch에서 특히 유용하다. 직접 diffstat를 만들면 -p 1 -w 70으로 source tree root 기준 filename과 좁은 width를 사용한다. Git은 기본적으로 적절히 만든다.

현재 review에만 필요하고 permanent changelog에 부적합한 comment도 --- 아래 둔다. V1과 V2 차이를 설명하는 patch changelog가 대표적이다. 위에 두면 apply 전 수동 제거가 필요하지만 separator 아래면 자동 제거된다.

<commit message>
...
Signed-off-by: Author <author@mail>
---
V2 -> V3: Removed redundant helper function
V1 -> V2: Cleaned up coding style and addressed review comments

path/to/file | 5+++--
...

In-Reply-To와 base tree 정보

822-895

Explicit In-Reply-To

Bug fix를 bug report mail과 연결하는 등 이전 relevant discussion과 patch를 연결하려면 In-Reply-To header를 수동 추가할 수 있다.

Multi-patch series는 old version과 In-Reply-To로 연결하지 않는 편이 좋다. 여러 revision이 mail client에서 관리 불가능한 reference forest가 될 수 있다. 필요하면 cover letter에서 lore.kernel.org redirector로 이전 series를 link한다.

Base commit 명시

Maintainer tree가 매우 많으므로 reviewer는 patch가 적용되는 base commit·branch를 반드시 알아야 한다. MAINTAINERS의 T: entry를 확인한다. Review 전에 test하는 automated CI에는 더 중요하다.

git format-patch의 --base option으로 base tree 정보를 자동 포함할 수 있다. Topical branch에서 사용하는 방법은 다음과 같다.

$ git checkout -t -b my-topical-branch master
Branch 'my-topical-branch' set up to track local branch 'master'.
Switched to a new branch 'my-topical-branch'

[perform your edits and commits]

$ git format-patch --base=auto --cover-letter -o outgoing/ master
outgoing/0000-cover-letter.patch
outgoing/0001-First-Commit.patch
outgoing/...

Cover letter 아래 base-commit: trailer가 생겨 reviewer와 CI가 conflict 걱정 없이 git am할 정보를 제공한다.

$ git checkout -b patch-review [base-commit-id]
Switched to a new branch 'patch-review'
$ git am patches.mbox
Applying: First Commit
Applying: ...

--base는 Git 2.9.0에 도입됐다. Git으로 format하지 않아도 base tree commit hash를 같은 base-commit trailer로 cover letter 또는 series 첫 patch에 넣을 수 있다. --- 아래 또는 email signature 직전 모든 content의 맨 아래에 둔다.

Base commit은 official maintainer/mainline tree에 있어야 하며 자신만 접근 가능한 internal tree commit이면 쓸모가 없다.

Tooling과 참고 자료

896-934

B4는 dependency tracking, checkpatch 실행, mail formatting과 sending 등 process의 많은 technical aspect를 자동화한다.

Documentation/process/coding-style.rst도 참고한다. 마지막 Andi Kleen 자료는 어렵거나 논쟁적인 change를 받아들여지게 하는 전략을 다룬다.