xref: /OK3568_Linux_fs/kernel/Documentation/process/submitting-patches.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. _submittingpatches:
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunSubmitting patches: the essential guide to getting your code into the kernel
4*4882a593Smuzhiyun============================================================================
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunFor a person or company who wishes to submit a change to the Linux
7*4882a593Smuzhiyunkernel, the process can sometimes be daunting if you're not familiar
8*4882a593Smuzhiyunwith "the system."  This text is a collection of suggestions which
9*4882a593Smuzhiyuncan greatly increase the chances of your change being accepted.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunThis document contains a large number of suggestions in a relatively terse
12*4882a593Smuzhiyunformat.  For detailed information on how the kernel development process
13*4882a593Smuzhiyunworks, see :doc:`development-process`. Also, read :doc:`submit-checklist`
14*4882a593Smuzhiyunfor a list of items to check before submitting code.  If you are submitting
15*4882a593Smuzhiyuna driver, also read :doc:`submitting-drivers`; for device tree binding patches,
16*4882a593Smuzhiyunread :doc:`submitting-patches`.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunThis documentation assumes that you're using ``git`` to prepare your patches.
19*4882a593SmuzhiyunIf you're unfamiliar with ``git``, you would be well-advised to learn how to
20*4882a593Smuzhiyunuse it, it will make your life as a kernel developer and in general much
21*4882a593Smuzhiyuneasier.
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunObtain a current source tree
24*4882a593Smuzhiyun----------------------------
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunIf you do not have a repository with the current kernel source handy, use
27*4882a593Smuzhiyun``git`` to obtain one.  You'll want to start with the mainline repository,
28*4882a593Smuzhiyunwhich can be grabbed with::
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun  git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunNote, however, that you may not want to develop against the mainline tree
33*4882a593Smuzhiyundirectly.  Most subsystem maintainers run their own trees and want to see
34*4882a593Smuzhiyunpatches prepared against those trees.  See the **T:** entry for the subsystem
35*4882a593Smuzhiyunin the MAINTAINERS file to find that tree, or simply ask the maintainer if
36*4882a593Smuzhiyunthe tree is not listed there.
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun.. _describe_changes:
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunDescribe your changes
41*4882a593Smuzhiyun---------------------
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunDescribe your problem.  Whether your patch is a one-line bug fix or
44*4882a593Smuzhiyun5000 lines of a new feature, there must be an underlying problem that
45*4882a593Smuzhiyunmotivated you to do this work.  Convince the reviewer that there is a
46*4882a593Smuzhiyunproblem worth fixing and that it makes sense for them to read past the
47*4882a593Smuzhiyunfirst paragraph.
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunDescribe user-visible impact.  Straight up crashes and lockups are
50*4882a593Smuzhiyunpretty convincing, but not all bugs are that blatant.  Even if the
51*4882a593Smuzhiyunproblem was spotted during code review, describe the impact you think
52*4882a593Smuzhiyunit can have on users.  Keep in mind that the majority of Linux
53*4882a593Smuzhiyuninstallations run kernels from secondary stable trees or
54*4882a593Smuzhiyunvendor/product-specific trees that cherry-pick only specific patches
55*4882a593Smuzhiyunfrom upstream, so include anything that could help route your change
56*4882a593Smuzhiyundownstream: provoking circumstances, excerpts from dmesg, crash
57*4882a593Smuzhiyundescriptions, performance regressions, latency spikes, lockups, etc.
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunQuantify optimizations and trade-offs.  If you claim improvements in
60*4882a593Smuzhiyunperformance, memory consumption, stack footprint, or binary size,
61*4882a593Smuzhiyuninclude numbers that back them up.  But also describe non-obvious
62*4882a593Smuzhiyuncosts.  Optimizations usually aren't free but trade-offs between CPU,
63*4882a593Smuzhiyunmemory, and readability; or, when it comes to heuristics, between
64*4882a593Smuzhiyundifferent workloads.  Describe the expected downsides of your
65*4882a593Smuzhiyunoptimization so that the reviewer can weigh costs against benefits.
66*4882a593Smuzhiyun
67*4882a593SmuzhiyunOnce the problem is established, describe what you are actually doing
68*4882a593Smuzhiyunabout it in technical detail.  It's important to describe the change
69*4882a593Smuzhiyunin plain English for the reviewer to verify that the code is behaving
70*4882a593Smuzhiyunas you intend it to.
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunThe maintainer will thank you if you write your patch description in a
73*4882a593Smuzhiyunform which can be easily pulled into Linux's source code management
74*4882a593Smuzhiyunsystem, ``git``, as a "commit log".  See :ref:`the_canonical_patch_format`.
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunSolve only one problem per patch.  If your description starts to get
77*4882a593Smuzhiyunlong, that's a sign that you probably need to split up your patch.
78*4882a593SmuzhiyunSee :ref:`split_changes`.
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunWhen you submit or resubmit a patch or patch series, include the
81*4882a593Smuzhiyuncomplete patch description and justification for it.  Don't just
82*4882a593Smuzhiyunsay that this is version N of the patch (series).  Don't expect the
83*4882a593Smuzhiyunsubsystem maintainer to refer back to earlier patch versions or referenced
84*4882a593SmuzhiyunURLs to find the patch description and put that into the patch.
85*4882a593SmuzhiyunI.e., the patch (series) and its description should be self-contained.
86*4882a593SmuzhiyunThis benefits both the maintainers and reviewers.  Some reviewers
87*4882a593Smuzhiyunprobably didn't even receive earlier versions of the patch.
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunDescribe your changes in imperative mood, e.g. "make xyzzy do frotz"
90*4882a593Smuzhiyuninstead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
91*4882a593Smuzhiyunto do frotz", as if you are giving orders to the codebase to change
92*4882a593Smuzhiyunits behaviour.
93*4882a593Smuzhiyun
94*4882a593SmuzhiyunIf the patch fixes a logged bug entry, refer to that bug entry by
95*4882a593Smuzhiyunnumber and URL.  If the patch follows from a mailing list discussion,
96*4882a593Smuzhiyungive a URL to the mailing list archive; use the https://lkml.kernel.org/
97*4882a593Smuzhiyunredirector with a ``Message-Id``, to ensure that the links cannot become
98*4882a593Smuzhiyunstale.
99*4882a593Smuzhiyun
100*4882a593SmuzhiyunHowever, try to make your explanation understandable without external
101*4882a593Smuzhiyunresources.  In addition to giving a URL to a mailing list archive or
102*4882a593Smuzhiyunbug, summarize the relevant points of the discussion that led to the
103*4882a593Smuzhiyunpatch as submitted.
104*4882a593Smuzhiyun
105*4882a593SmuzhiyunIf you want to refer to a specific commit, don't just refer to the
106*4882a593SmuzhiyunSHA-1 ID of the commit. Please also include the oneline summary of
107*4882a593Smuzhiyunthe commit, to make it easier for reviewers to know what it is about.
108*4882a593SmuzhiyunExample::
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun	Commit e21d2170f36602ae2708 ("video: remove unnecessary
111*4882a593Smuzhiyun	platform_set_drvdata()") removed the unnecessary
112*4882a593Smuzhiyun	platform_set_drvdata(), but left the variable "dev" unused,
113*4882a593Smuzhiyun	delete it.
114*4882a593Smuzhiyun
115*4882a593SmuzhiyunYou should also be sure to use at least the first twelve characters of the
116*4882a593SmuzhiyunSHA-1 ID.  The kernel repository holds a *lot* of objects, making
117*4882a593Smuzhiyuncollisions with shorter IDs a real possibility.  Bear in mind that, even if
118*4882a593Smuzhiyunthere is no collision with your six-character ID now, that condition may
119*4882a593Smuzhiyunchange five years from now.
120*4882a593Smuzhiyun
121*4882a593SmuzhiyunIf your patch fixes a bug in a specific commit, e.g. you found an issue using
122*4882a593Smuzhiyun``git bisect``, please use the 'Fixes:' tag with the first 12 characters of
123*4882a593Smuzhiyunthe SHA-1 ID, and the one line summary.  Do not split the tag across multiple
124*4882a593Smuzhiyunlines, tags are exempt from the "wrap at 75 columns" rule in order to simplify
125*4882a593Smuzhiyunparsing scripts.  For example::
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun	Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunThe following ``git config`` settings can be used to add a pretty format for
130*4882a593Smuzhiyunoutputting the above style in the ``git log`` or ``git show`` commands::
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun	[core]
133*4882a593Smuzhiyun		abbrev = 12
134*4882a593Smuzhiyun	[pretty]
135*4882a593Smuzhiyun		fixes = Fixes: %h (\"%s\")
136*4882a593Smuzhiyun
137*4882a593SmuzhiyunAn example call::
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun	$ git log -1 --pretty=fixes 54a4f0239f2e
140*4882a593Smuzhiyun	Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun.. _split_changes:
143*4882a593Smuzhiyun
144*4882a593SmuzhiyunSeparate your changes
145*4882a593Smuzhiyun---------------------
146*4882a593Smuzhiyun
147*4882a593SmuzhiyunSeparate each **logical change** into a separate patch.
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunFor example, if your changes include both bug fixes and performance
150*4882a593Smuzhiyunenhancements for a single driver, separate those changes into two
151*4882a593Smuzhiyunor more patches.  If your changes include an API update, and a new
152*4882a593Smuzhiyundriver which uses that new API, separate those into two patches.
153*4882a593Smuzhiyun
154*4882a593SmuzhiyunOn the other hand, if you make a single change to numerous files,
155*4882a593Smuzhiyungroup those changes into a single patch.  Thus a single logical change
156*4882a593Smuzhiyunis contained within a single patch.
157*4882a593Smuzhiyun
158*4882a593SmuzhiyunThe point to remember is that each patch should make an easily understood
159*4882a593Smuzhiyunchange that can be verified by reviewers.  Each patch should be justifiable
160*4882a593Smuzhiyunon its own merits.
161*4882a593Smuzhiyun
162*4882a593SmuzhiyunIf one patch depends on another patch in order for a change to be
163*4882a593Smuzhiyuncomplete, that is OK.  Simply note **"this patch depends on patch X"**
164*4882a593Smuzhiyunin your patch description.
165*4882a593Smuzhiyun
166*4882a593SmuzhiyunWhen dividing your change into a series of patches, take special care to
167*4882a593Smuzhiyunensure that the kernel builds and runs properly after each patch in the
168*4882a593Smuzhiyunseries.  Developers using ``git bisect`` to track down a problem can end up
169*4882a593Smuzhiyunsplitting your patch series at any point; they will not thank you if you
170*4882a593Smuzhiyunintroduce bugs in the middle.
171*4882a593Smuzhiyun
172*4882a593SmuzhiyunIf you cannot condense your patch set into a smaller set of patches,
173*4882a593Smuzhiyunthen only post say 15 or so at a time and wait for review and integration.
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun
177*4882a593SmuzhiyunStyle-check your changes
178*4882a593Smuzhiyun------------------------
179*4882a593Smuzhiyun
180*4882a593SmuzhiyunCheck your patch for basic style violations, details of which can be
181*4882a593Smuzhiyunfound in
182*4882a593Smuzhiyun:ref:`Documentation/process/coding-style.rst <codingstyle>`.
183*4882a593SmuzhiyunFailure to do so simply wastes
184*4882a593Smuzhiyunthe reviewers time and will get your patch rejected, probably
185*4882a593Smuzhiyunwithout even being read.
186*4882a593Smuzhiyun
187*4882a593SmuzhiyunOne significant exception is when moving code from one file to
188*4882a593Smuzhiyunanother -- in this case you should not modify the moved code at all in
189*4882a593Smuzhiyunthe same patch which moves it.  This clearly delineates the act of
190*4882a593Smuzhiyunmoving the code and your changes.  This greatly aids review of the
191*4882a593Smuzhiyunactual differences and allows tools to better track the history of
192*4882a593Smuzhiyunthe code itself.
193*4882a593Smuzhiyun
194*4882a593SmuzhiyunCheck your patches with the patch style checker prior to submission
195*4882a593Smuzhiyun(scripts/checkpatch.pl).  Note, though, that the style checker should be
196*4882a593Smuzhiyunviewed as a guide, not as a replacement for human judgment.  If your code
197*4882a593Smuzhiyunlooks better with a violation then its probably best left alone.
198*4882a593Smuzhiyun
199*4882a593SmuzhiyunThe checker reports at three levels:
200*4882a593Smuzhiyun - ERROR: things that are very likely to be wrong
201*4882a593Smuzhiyun - WARNING: things requiring careful review
202*4882a593Smuzhiyun - CHECK: things requiring thought
203*4882a593Smuzhiyun
204*4882a593SmuzhiyunYou should be able to justify all violations that remain in your
205*4882a593Smuzhiyunpatch.
206*4882a593Smuzhiyun
207*4882a593Smuzhiyun
208*4882a593SmuzhiyunSelect the recipients for your patch
209*4882a593Smuzhiyun------------------------------------
210*4882a593Smuzhiyun
211*4882a593SmuzhiyunYou should always copy the appropriate subsystem maintainer(s) on any patch
212*4882a593Smuzhiyunto code that they maintain; look through the MAINTAINERS file and the
213*4882a593Smuzhiyunsource code revision history to see who those maintainers are.  The
214*4882a593Smuzhiyunscript scripts/get_maintainer.pl can be very useful at this step.  If you
215*4882a593Smuzhiyuncannot find a maintainer for the subsystem you are working on, Andrew
216*4882a593SmuzhiyunMorton (akpm@linux-foundation.org) serves as a maintainer of last resort.
217*4882a593Smuzhiyun
218*4882a593SmuzhiyunYou should also normally choose at least one mailing list to receive a copy
219*4882a593Smuzhiyunof your patch set.  linux-kernel@vger.kernel.org functions as a list of
220*4882a593Smuzhiyunlast resort, but the volume on that list has caused a number of developers
221*4882a593Smuzhiyunto tune it out.  Look in the MAINTAINERS file for a subsystem-specific
222*4882a593Smuzhiyunlist; your patch will probably get more attention there.  Please do not
223*4882a593Smuzhiyunspam unrelated lists, though.
224*4882a593Smuzhiyun
225*4882a593SmuzhiyunMany kernel-related lists are hosted on vger.kernel.org; you can find a
226*4882a593Smuzhiyunlist of them at http://vger.kernel.org/vger-lists.html.  There are
227*4882a593Smuzhiyunkernel-related lists hosted elsewhere as well, though.
228*4882a593Smuzhiyun
229*4882a593SmuzhiyunDo not send more than 15 patches at once to the vger mailing lists!!!
230*4882a593Smuzhiyun
231*4882a593SmuzhiyunLinus Torvalds is the final arbiter of all changes accepted into the
232*4882a593SmuzhiyunLinux kernel.  His e-mail address is <torvalds@linux-foundation.org>.
233*4882a593SmuzhiyunHe gets a lot of e-mail, and, at this point, very few patches go through
234*4882a593SmuzhiyunLinus directly, so typically you should do your best to -avoid-
235*4882a593Smuzhiyunsending him e-mail.
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunIf you have a patch that fixes an exploitable security bug, send that patch
238*4882a593Smuzhiyunto security@kernel.org.  For severe bugs, a short embargo may be considered
239*4882a593Smuzhiyunto allow distributors to get the patch out to users; in such cases,
240*4882a593Smuzhiyunobviously, the patch should not be sent to any public lists. See also
241*4882a593Smuzhiyun:doc:`/admin-guide/security-bugs`.
242*4882a593Smuzhiyun
243*4882a593SmuzhiyunPatches that fix a severe bug in a released kernel should be directed
244*4882a593Smuzhiyuntoward the stable maintainers by putting a line like this::
245*4882a593Smuzhiyun
246*4882a593Smuzhiyun  Cc: stable@vger.kernel.org
247*4882a593Smuzhiyun
248*4882a593Smuzhiyuninto the sign-off area of your patch (note, NOT an email recipient).  You
249*4882a593Smuzhiyunshould also read
250*4882a593Smuzhiyun:ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
251*4882a593Smuzhiyunin addition to this file.
252*4882a593Smuzhiyun
253*4882a593SmuzhiyunIf changes affect userland-kernel interfaces, please send the MAN-PAGES
254*4882a593Smuzhiyunmaintainer (as listed in the MAINTAINERS file) a man-pages patch, or at
255*4882a593Smuzhiyunleast a notification of the change, so that some information makes its way
256*4882a593Smuzhiyuninto the manual pages.  User-space API changes should also be copied to
257*4882a593Smuzhiyunlinux-api@vger.kernel.org.
258*4882a593Smuzhiyun
259*4882a593SmuzhiyunFor small patches you may want to CC the Trivial Patch Monkey
260*4882a593Smuzhiyuntrivial@kernel.org which collects "trivial" patches. Have a look
261*4882a593Smuzhiyuninto the MAINTAINERS file for its current manager.
262*4882a593Smuzhiyun
263*4882a593SmuzhiyunTrivial patches must qualify for one of the following rules:
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun- Spelling fixes in documentation
266*4882a593Smuzhiyun- Spelling fixes for errors which could break :manpage:`grep(1)`
267*4882a593Smuzhiyun- Warning fixes (cluttering with useless warnings is bad)
268*4882a593Smuzhiyun- Compilation fixes (only if they are actually correct)
269*4882a593Smuzhiyun- Runtime fixes (only if they actually fix things)
270*4882a593Smuzhiyun- Removing use of deprecated functions/macros
271*4882a593Smuzhiyun- Contact detail and documentation fixes
272*4882a593Smuzhiyun- Non-portable code replaced by portable code (even in arch-specific,
273*4882a593Smuzhiyun  since people copy, as long as it's trivial)
274*4882a593Smuzhiyun- Any fix by the author/maintainer of the file (ie. patch monkey
275*4882a593Smuzhiyun  in re-transmission mode)
276*4882a593Smuzhiyun
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun
279*4882a593SmuzhiyunNo MIME, no links, no compression, no attachments.  Just plain text
280*4882a593Smuzhiyun-------------------------------------------------------------------
281*4882a593Smuzhiyun
282*4882a593SmuzhiyunLinus and other kernel developers need to be able to read and comment
283*4882a593Smuzhiyunon the changes you are submitting.  It is important for a kernel
284*4882a593Smuzhiyundeveloper to be able to "quote" your changes, using standard e-mail
285*4882a593Smuzhiyuntools, so that they may comment on specific portions of your code.
286*4882a593Smuzhiyun
287*4882a593SmuzhiyunFor this reason, all patches should be submitted by e-mail "inline". The
288*4882a593Smuzhiyuneasiest way to do this is with ``git send-email``, which is strongly
289*4882a593Smuzhiyunrecommended.  An interactive tutorial for ``git send-email`` is available at
290*4882a593Smuzhiyunhttps://git-send-email.io.
291*4882a593Smuzhiyun
292*4882a593SmuzhiyunIf you choose not to use ``git send-email``:
293*4882a593Smuzhiyun
294*4882a593Smuzhiyun.. warning::
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun  Be wary of your editor's word-wrap corrupting your patch,
297*4882a593Smuzhiyun  if you choose to cut-n-paste your patch.
298*4882a593Smuzhiyun
299*4882a593SmuzhiyunDo not attach the patch as a MIME attachment, compressed or not.
300*4882a593SmuzhiyunMany popular e-mail applications will not always transmit a MIME
301*4882a593Smuzhiyunattachment as plain text, making it impossible to comment on your
302*4882a593Smuzhiyuncode.  A MIME attachment also takes Linus a bit more time to process,
303*4882a593Smuzhiyundecreasing the likelihood of your MIME-attached change being accepted.
304*4882a593Smuzhiyun
305*4882a593SmuzhiyunException:  If your mailer is mangling patches then someone may ask
306*4882a593Smuzhiyunyou to re-send them using MIME.
307*4882a593Smuzhiyun
308*4882a593SmuzhiyunSee :doc:`/process/email-clients` for hints about configuring your e-mail
309*4882a593Smuzhiyunclient so that it sends your patches untouched.
310*4882a593Smuzhiyun
311*4882a593SmuzhiyunRespond to review comments
312*4882a593Smuzhiyun--------------------------
313*4882a593Smuzhiyun
314*4882a593SmuzhiyunYour patch will almost certainly get comments from reviewers on ways in
315*4882a593Smuzhiyunwhich the patch can be improved, in the form of a reply to your email. You must
316*4882a593Smuzhiyunrespond to those comments; ignoring reviewers is a good way to get ignored in
317*4882a593Smuzhiyunreturn. You can simply reply to their emails to answer their comments. Review
318*4882a593Smuzhiyuncomments or questions that do not lead to a code change should almost certainly
319*4882a593Smuzhiyunbring about a comment or changelog entry so that the next reviewer better
320*4882a593Smuzhiyununderstands what is going on.
321*4882a593Smuzhiyun
322*4882a593SmuzhiyunBe sure to tell the reviewers what changes you are making and to thank them
323*4882a593Smuzhiyunfor their time.  Code review is a tiring and time-consuming process, and
324*4882a593Smuzhiyunreviewers sometimes get grumpy.  Even in that case, though, respond
325*4882a593Smuzhiyunpolitely and address the problems they have pointed out.
326*4882a593Smuzhiyun
327*4882a593SmuzhiyunSee :doc:`email-clients` for recommendations on email
328*4882a593Smuzhiyunclients and mailing list etiquette.
329*4882a593Smuzhiyun
330*4882a593Smuzhiyun
331*4882a593SmuzhiyunDon't get discouraged - or impatient
332*4882a593Smuzhiyun------------------------------------
333*4882a593Smuzhiyun
334*4882a593SmuzhiyunAfter you have submitted your change, be patient and wait.  Reviewers are
335*4882a593Smuzhiyunbusy people and may not get to your patch right away.
336*4882a593Smuzhiyun
337*4882a593SmuzhiyunOnce upon a time, patches used to disappear into the void without comment,
338*4882a593Smuzhiyunbut the development process works more smoothly than that now.  You should
339*4882a593Smuzhiyunreceive comments within a week or so; if that does not happen, make sure
340*4882a593Smuzhiyunthat you have sent your patches to the right place.  Wait for a minimum of
341*4882a593Smuzhiyunone week before resubmitting or pinging reviewers - possibly longer during
342*4882a593Smuzhiyunbusy times like merge windows.
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun
345*4882a593SmuzhiyunInclude PATCH in the subject
346*4882a593Smuzhiyun-----------------------------
347*4882a593Smuzhiyun
348*4882a593SmuzhiyunDue to high e-mail traffic to Linus, and to linux-kernel, it is common
349*4882a593Smuzhiyunconvention to prefix your subject line with [PATCH].  This lets Linus
350*4882a593Smuzhiyunand other kernel developers more easily distinguish patches from other
351*4882a593Smuzhiyune-mail discussions.
352*4882a593Smuzhiyun
353*4882a593Smuzhiyun``git send-email`` will do this for you automatically.
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun
356*4882a593SmuzhiyunSign your work - the Developer's Certificate of Origin
357*4882a593Smuzhiyun------------------------------------------------------
358*4882a593Smuzhiyun
359*4882a593SmuzhiyunTo improve tracking of who did what, especially with patches that can
360*4882a593Smuzhiyunpercolate to their final resting place in the kernel through several
361*4882a593Smuzhiyunlayers of maintainers, we've introduced a "sign-off" procedure on
362*4882a593Smuzhiyunpatches that are being emailed around.
363*4882a593Smuzhiyun
364*4882a593SmuzhiyunThe sign-off is a simple line at the end of the explanation for the
365*4882a593Smuzhiyunpatch, which certifies that you wrote it or otherwise have the right to
366*4882a593Smuzhiyunpass it on as an open-source patch.  The rules are pretty simple: if you
367*4882a593Smuzhiyuncan certify the below:
368*4882a593Smuzhiyun
369*4882a593SmuzhiyunDeveloper's Certificate of Origin 1.1
370*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
371*4882a593Smuzhiyun
372*4882a593SmuzhiyunBy making a contribution to this project, I certify that:
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun        (a) The contribution was created in whole or in part by me and I
375*4882a593Smuzhiyun            have the right to submit it under the open source license
376*4882a593Smuzhiyun            indicated in the file; or
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun        (b) The contribution is based upon previous work that, to the best
379*4882a593Smuzhiyun            of my knowledge, is covered under an appropriate open source
380*4882a593Smuzhiyun            license and I have the right under that license to submit that
381*4882a593Smuzhiyun            work with modifications, whether created in whole or in part
382*4882a593Smuzhiyun            by me, under the same open source license (unless I am
383*4882a593Smuzhiyun            permitted to submit under a different license), as indicated
384*4882a593Smuzhiyun            in the file; or
385*4882a593Smuzhiyun
386*4882a593Smuzhiyun        (c) The contribution was provided directly to me by some other
387*4882a593Smuzhiyun            person who certified (a), (b) or (c) and I have not modified
388*4882a593Smuzhiyun            it.
389*4882a593Smuzhiyun
390*4882a593Smuzhiyun        (d) I understand and agree that this project and the contribution
391*4882a593Smuzhiyun            are public and that a record of the contribution (including all
392*4882a593Smuzhiyun            personal information I submit with it, including my sign-off) is
393*4882a593Smuzhiyun            maintained indefinitely and may be redistributed consistent with
394*4882a593Smuzhiyun            this project or the open source license(s) involved.
395*4882a593Smuzhiyun
396*4882a593Smuzhiyunthen you just add a line saying::
397*4882a593Smuzhiyun
398*4882a593Smuzhiyun	Signed-off-by: Random J Developer <random@developer.example.org>
399*4882a593Smuzhiyun
400*4882a593Smuzhiyunusing your real name (sorry, no pseudonyms or anonymous contributions.)
401*4882a593SmuzhiyunThis will be done for you automatically if you use ``git commit -s``.
402*4882a593Smuzhiyun
403*4882a593SmuzhiyunSome people also put extra tags at the end.  They'll just be ignored for
404*4882a593Smuzhiyunnow, but you can do this to mark internal company procedures or just
405*4882a593Smuzhiyunpoint out some special detail about the sign-off.
406*4882a593Smuzhiyun
407*4882a593Smuzhiyun
408*4882a593SmuzhiyunWhen to use Acked-by:, Cc:, and Co-developed-by:
409*4882a593Smuzhiyun------------------------------------------------
410*4882a593Smuzhiyun
411*4882a593SmuzhiyunThe Signed-off-by: tag indicates that the signer was involved in the
412*4882a593Smuzhiyundevelopment of the patch, or that he/she was in the patch's delivery path.
413*4882a593Smuzhiyun
414*4882a593SmuzhiyunIf a person was not directly involved in the preparation or handling of a
415*4882a593Smuzhiyunpatch but wishes to signify and record their approval of it then they can
416*4882a593Smuzhiyunask to have an Acked-by: line added to the patch's changelog.
417*4882a593Smuzhiyun
418*4882a593SmuzhiyunAcked-by: is often used by the maintainer of the affected code when that
419*4882a593Smuzhiyunmaintainer neither contributed to nor forwarded the patch.
420*4882a593Smuzhiyun
421*4882a593SmuzhiyunAcked-by: is not as formal as Signed-off-by:.  It is a record that the acker
422*4882a593Smuzhiyunhas at least reviewed the patch and has indicated acceptance.  Hence patch
423*4882a593Smuzhiyunmergers will sometimes manually convert an acker's "yep, looks good to me"
424*4882a593Smuzhiyuninto an Acked-by: (but note that it is usually better to ask for an
425*4882a593Smuzhiyunexplicit ack).
426*4882a593Smuzhiyun
427*4882a593SmuzhiyunAcked-by: does not necessarily indicate acknowledgement of the entire patch.
428*4882a593SmuzhiyunFor example, if a patch affects multiple subsystems and has an Acked-by: from
429*4882a593Smuzhiyunone subsystem maintainer then this usually indicates acknowledgement of just
430*4882a593Smuzhiyunthe part which affects that maintainer's code.  Judgement should be used here.
431*4882a593SmuzhiyunWhen in doubt people should refer to the original discussion in the mailing
432*4882a593Smuzhiyunlist archives.
433*4882a593Smuzhiyun
434*4882a593SmuzhiyunIf a person has had the opportunity to comment on a patch, but has not
435*4882a593Smuzhiyunprovided such comments, you may optionally add a ``Cc:`` tag to the patch.
436*4882a593SmuzhiyunThis is the only tag which might be added without an explicit action by the
437*4882a593Smuzhiyunperson it names - but it should indicate that this person was copied on the
438*4882a593Smuzhiyunpatch.  This tag documents that potentially interested parties
439*4882a593Smuzhiyunhave been included in the discussion.
440*4882a593Smuzhiyun
441*4882a593SmuzhiyunCo-developed-by: states that the patch was co-created by multiple developers;
442*4882a593Smuzhiyunit is a used to give attribution to co-authors (in addition to the author
443*4882a593Smuzhiyunattributed by the From: tag) when several people work on a single patch.  Since
444*4882a593SmuzhiyunCo-developed-by: denotes authorship, every Co-developed-by: must be immediately
445*4882a593Smuzhiyunfollowed by a Signed-off-by: of the associated co-author.  Standard sign-off
446*4882a593Smuzhiyunprocedure applies, i.e. the ordering of Signed-off-by: tags should reflect the
447*4882a593Smuzhiyunchronological history of the patch insofar as possible, regardless of whether
448*4882a593Smuzhiyunthe author is attributed via From: or Co-developed-by:.  Notably, the last
449*4882a593SmuzhiyunSigned-off-by: must always be that of the developer submitting the patch.
450*4882a593Smuzhiyun
451*4882a593SmuzhiyunNote, the From: tag is optional when the From: author is also the person (and
452*4882a593Smuzhiyunemail) listed in the From: line of the email header.
453*4882a593Smuzhiyun
454*4882a593SmuzhiyunExample of a patch submitted by the From: author::
455*4882a593Smuzhiyun
456*4882a593Smuzhiyun	<changelog>
457*4882a593Smuzhiyun
458*4882a593Smuzhiyun	Co-developed-by: First Co-Author <first@coauthor.example.org>
459*4882a593Smuzhiyun	Signed-off-by: First Co-Author <first@coauthor.example.org>
460*4882a593Smuzhiyun	Co-developed-by: Second Co-Author <second@coauthor.example.org>
461*4882a593Smuzhiyun	Signed-off-by: Second Co-Author <second@coauthor.example.org>
462*4882a593Smuzhiyun	Signed-off-by: From Author <from@author.example.org>
463*4882a593Smuzhiyun
464*4882a593SmuzhiyunExample of a patch submitted by a Co-developed-by: author::
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun	From: From Author <from@author.example.org>
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun	<changelog>
469*4882a593Smuzhiyun
470*4882a593Smuzhiyun	Co-developed-by: Random Co-Author <random@coauthor.example.org>
471*4882a593Smuzhiyun	Signed-off-by: Random Co-Author <random@coauthor.example.org>
472*4882a593Smuzhiyun	Signed-off-by: From Author <from@author.example.org>
473*4882a593Smuzhiyun	Co-developed-by: Submitting Co-Author <sub@coauthor.example.org>
474*4882a593Smuzhiyun	Signed-off-by: Submitting Co-Author <sub@coauthor.example.org>
475*4882a593Smuzhiyun
476*4882a593Smuzhiyun
477*4882a593SmuzhiyunUsing Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes:
478*4882a593Smuzhiyun----------------------------------------------------------------------
479*4882a593Smuzhiyun
480*4882a593SmuzhiyunThe Reported-by tag gives credit to people who find bugs and report them and it
481*4882a593Smuzhiyunhopefully inspires them to help us again in the future.  Please note that if
482*4882a593Smuzhiyunthe bug was reported in private, then ask for permission first before using the
483*4882a593SmuzhiyunReported-by tag.
484*4882a593Smuzhiyun
485*4882a593SmuzhiyunA Tested-by: tag indicates that the patch has been successfully tested (in
486*4882a593Smuzhiyunsome environment) by the person named.  This tag informs maintainers that
487*4882a593Smuzhiyunsome testing has been performed, provides a means to locate testers for
488*4882a593Smuzhiyunfuture patches, and ensures credit for the testers.
489*4882a593Smuzhiyun
490*4882a593SmuzhiyunReviewed-by:, instead, indicates that the patch has been reviewed and found
491*4882a593Smuzhiyunacceptable according to the Reviewer's Statement:
492*4882a593Smuzhiyun
493*4882a593SmuzhiyunReviewer's statement of oversight
494*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
495*4882a593Smuzhiyun
496*4882a593SmuzhiyunBy offering my Reviewed-by: tag, I state that:
497*4882a593Smuzhiyun
498*4882a593Smuzhiyun	 (a) I have carried out a technical review of this patch to
499*4882a593Smuzhiyun	     evaluate its appropriateness and readiness for inclusion into
500*4882a593Smuzhiyun	     the mainline kernel.
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun	 (b) Any problems, concerns, or questions relating to the patch
503*4882a593Smuzhiyun	     have been communicated back to the submitter.  I am satisfied
504*4882a593Smuzhiyun	     with the submitter's response to my comments.
505*4882a593Smuzhiyun
506*4882a593Smuzhiyun	 (c) While there may be things that could be improved with this
507*4882a593Smuzhiyun	     submission, I believe that it is, at this time, (1) a
508*4882a593Smuzhiyun	     worthwhile modification to the kernel, and (2) free of known
509*4882a593Smuzhiyun	     issues which would argue against its inclusion.
510*4882a593Smuzhiyun
511*4882a593Smuzhiyun	 (d) While I have reviewed the patch and believe it to be sound, I
512*4882a593Smuzhiyun	     do not (unless explicitly stated elsewhere) make any
513*4882a593Smuzhiyun	     warranties or guarantees that it will achieve its stated
514*4882a593Smuzhiyun	     purpose or function properly in any given situation.
515*4882a593Smuzhiyun
516*4882a593SmuzhiyunA Reviewed-by tag is a statement of opinion that the patch is an
517*4882a593Smuzhiyunappropriate modification of the kernel without any remaining serious
518*4882a593Smuzhiyuntechnical issues.  Any interested reviewer (who has done the work) can
519*4882a593Smuzhiyunoffer a Reviewed-by tag for a patch.  This tag serves to give credit to
520*4882a593Smuzhiyunreviewers and to inform maintainers of the degree of review which has been
521*4882a593Smuzhiyundone on the patch.  Reviewed-by: tags, when supplied by reviewers known to
522*4882a593Smuzhiyununderstand the subject area and to perform thorough reviews, will normally
523*4882a593Smuzhiyunincrease the likelihood of your patch getting into the kernel.
524*4882a593Smuzhiyun
525*4882a593SmuzhiyunBoth Tested-by and Reviewed-by tags, once received on mailing list from tester
526*4882a593Smuzhiyunor reviewer, should be added by author to the applicable patches when sending
527*4882a593Smuzhiyunnext versions.  However if the patch has changed substantially in following
528*4882a593Smuzhiyunversion, these tags might not be applicable anymore and thus should be removed.
529*4882a593SmuzhiyunUsually removal of someone's Tested-by or Reviewed-by tags should be mentioned
530*4882a593Smuzhiyunin the patch changelog (after the '---' separator).
531*4882a593Smuzhiyun
532*4882a593SmuzhiyunA Suggested-by: tag indicates that the patch idea is suggested by the person
533*4882a593Smuzhiyunnamed and ensures credit to the person for the idea. Please note that this
534*4882a593Smuzhiyuntag should not be added without the reporter's permission, especially if the
535*4882a593Smuzhiyunidea was not posted in a public forum. That said, if we diligently credit our
536*4882a593Smuzhiyunidea reporters, they will, hopefully, be inspired to help us again in the
537*4882a593Smuzhiyunfuture.
538*4882a593Smuzhiyun
539*4882a593SmuzhiyunA Fixes: tag indicates that the patch fixes an issue in a previous commit. It
540*4882a593Smuzhiyunis used to make it easy to determine where a bug originated, which can help
541*4882a593Smuzhiyunreview a bug fix. This tag also assists the stable kernel team in determining
542*4882a593Smuzhiyunwhich stable kernel versions should receive your fix. This is the preferred
543*4882a593Smuzhiyunmethod for indicating a bug fixed by the patch. See :ref:`describe_changes`
544*4882a593Smuzhiyunfor more details.
545*4882a593Smuzhiyun
546*4882a593Smuzhiyun.. _the_canonical_patch_format:
547*4882a593Smuzhiyun
548*4882a593SmuzhiyunThe canonical patch format
549*4882a593Smuzhiyun--------------------------
550*4882a593Smuzhiyun
551*4882a593SmuzhiyunThis section describes how the patch itself should be formatted.  Note
552*4882a593Smuzhiyunthat, if you have your patches stored in a ``git`` repository, proper patch
553*4882a593Smuzhiyunformatting can be had with ``git format-patch``.  The tools cannot create
554*4882a593Smuzhiyunthe necessary text, though, so read the instructions below anyway.
555*4882a593Smuzhiyun
556*4882a593SmuzhiyunThe canonical patch subject line is::
557*4882a593Smuzhiyun
558*4882a593Smuzhiyun    Subject: [PATCH 001/123] subsystem: summary phrase
559*4882a593Smuzhiyun
560*4882a593SmuzhiyunThe canonical patch message body contains the following:
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun  - A ``from`` line specifying the patch author, followed by an empty
563*4882a593Smuzhiyun    line (only needed if the person sending the patch is not the author).
564*4882a593Smuzhiyun
565*4882a593Smuzhiyun  - The body of the explanation, line wrapped at 75 columns, which will
566*4882a593Smuzhiyun    be copied to the permanent changelog to describe this patch.
567*4882a593Smuzhiyun
568*4882a593Smuzhiyun  - An empty line.
569*4882a593Smuzhiyun
570*4882a593Smuzhiyun  - The ``Signed-off-by:`` lines, described above, which will
571*4882a593Smuzhiyun    also go in the changelog.
572*4882a593Smuzhiyun
573*4882a593Smuzhiyun  - A marker line containing simply ``---``.
574*4882a593Smuzhiyun
575*4882a593Smuzhiyun  - Any additional comments not suitable for the changelog.
576*4882a593Smuzhiyun
577*4882a593Smuzhiyun  - The actual patch (``diff`` output).
578*4882a593Smuzhiyun
579*4882a593SmuzhiyunThe Subject line format makes it very easy to sort the emails
580*4882a593Smuzhiyunalphabetically by subject line - pretty much any email reader will
581*4882a593Smuzhiyunsupport that - since because the sequence number is zero-padded,
582*4882a593Smuzhiyunthe numerical and alphabetic sort is the same.
583*4882a593Smuzhiyun
584*4882a593SmuzhiyunThe ``subsystem`` in the email's Subject should identify which
585*4882a593Smuzhiyunarea or subsystem of the kernel is being patched.
586*4882a593Smuzhiyun
587*4882a593SmuzhiyunThe ``summary phrase`` in the email's Subject should concisely
588*4882a593Smuzhiyundescribe the patch which that email contains.  The ``summary
589*4882a593Smuzhiyunphrase`` should not be a filename.  Do not use the same ``summary
590*4882a593Smuzhiyunphrase`` for every patch in a whole patch series (where a ``patch
591*4882a593Smuzhiyunseries`` is an ordered sequence of multiple, related patches).
592*4882a593Smuzhiyun
593*4882a593SmuzhiyunBear in mind that the ``summary phrase`` of your email becomes a
594*4882a593Smuzhiyunglobally-unique identifier for that patch.  It propagates all the way
595*4882a593Smuzhiyuninto the ``git`` changelog.  The ``summary phrase`` may later be used in
596*4882a593Smuzhiyundeveloper discussions which refer to the patch.  People will want to
597*4882a593Smuzhiyungoogle for the ``summary phrase`` to read discussion regarding that
598*4882a593Smuzhiyunpatch.  It will also be the only thing that people may quickly see
599*4882a593Smuzhiyunwhen, two or three months later, they are going through perhaps
600*4882a593Smuzhiyunthousands of patches using tools such as ``gitk`` or ``git log
601*4882a593Smuzhiyun--oneline``.
602*4882a593Smuzhiyun
603*4882a593SmuzhiyunFor these reasons, the ``summary`` must be no more than 70-75
604*4882a593Smuzhiyuncharacters, and it must describe both what the patch changes, as well
605*4882a593Smuzhiyunas why the patch might be necessary.  It is challenging to be both
606*4882a593Smuzhiyunsuccinct and descriptive, but that is what a well-written summary
607*4882a593Smuzhiyunshould do.
608*4882a593Smuzhiyun
609*4882a593SmuzhiyunThe ``summary phrase`` may be prefixed by tags enclosed in square
610*4882a593Smuzhiyunbrackets: "Subject: [PATCH <tag>...] <summary phrase>".  The tags are
611*4882a593Smuzhiyunnot considered part of the summary phrase, but describe how the patch
612*4882a593Smuzhiyunshould be treated.  Common tags might include a version descriptor if
613*4882a593Smuzhiyunthe multiple versions of the patch have been sent out in response to
614*4882a593Smuzhiyuncomments (i.e., "v1, v2, v3"), or "RFC" to indicate a request for
615*4882a593Smuzhiyuncomments.  If there are four patches in a patch series the individual
616*4882a593Smuzhiyunpatches may be numbered like this: 1/4, 2/4, 3/4, 4/4.  This assures
617*4882a593Smuzhiyunthat developers understand the order in which the patches should be
618*4882a593Smuzhiyunapplied and that they have reviewed or applied all of the patches in
619*4882a593Smuzhiyunthe patch series.
620*4882a593Smuzhiyun
621*4882a593SmuzhiyunA couple of example Subjects::
622*4882a593Smuzhiyun
623*4882a593Smuzhiyun    Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching
624*4882a593Smuzhiyun    Subject: [PATCH v2 01/27] x86: fix eflags tracking
625*4882a593Smuzhiyun
626*4882a593SmuzhiyunThe ``from`` line must be the very first line in the message body,
627*4882a593Smuzhiyunand has the form:
628*4882a593Smuzhiyun
629*4882a593Smuzhiyun        From: Patch Author <author@example.com>
630*4882a593Smuzhiyun
631*4882a593SmuzhiyunThe ``from`` line specifies who will be credited as the author of the
632*4882a593Smuzhiyunpatch in the permanent changelog.  If the ``from`` line is missing,
633*4882a593Smuzhiyunthen the ``From:`` line from the email header will be used to determine
634*4882a593Smuzhiyunthe patch author in the changelog.
635*4882a593Smuzhiyun
636*4882a593SmuzhiyunThe explanation body will be committed to the permanent source
637*4882a593Smuzhiyunchangelog, so should make sense to a competent reader who has long
638*4882a593Smuzhiyunsince forgotten the immediate details of the discussion that might
639*4882a593Smuzhiyunhave led to this patch.  Including symptoms of the failure which the
640*4882a593Smuzhiyunpatch addresses (kernel log messages, oops messages, etc.) is
641*4882a593Smuzhiyunespecially useful for people who might be searching the commit logs
642*4882a593Smuzhiyunlooking for the applicable patch.  If a patch fixes a compile failure,
643*4882a593Smuzhiyunit may not be necessary to include _all_ of the compile failures; just
644*4882a593Smuzhiyunenough that it is likely that someone searching for the patch can find
645*4882a593Smuzhiyunit.  As in the ``summary phrase``, it is important to be both succinct as
646*4882a593Smuzhiyunwell as descriptive.
647*4882a593Smuzhiyun
648*4882a593SmuzhiyunThe ``---`` marker line serves the essential purpose of marking for patch
649*4882a593Smuzhiyunhandling tools where the changelog message ends.
650*4882a593Smuzhiyun
651*4882a593SmuzhiyunOne good use for the additional comments after the ``---`` marker is for
652*4882a593Smuzhiyuna ``diffstat``, to show what files have changed, and the number of
653*4882a593Smuzhiyuninserted and deleted lines per file.  A ``diffstat`` is especially useful
654*4882a593Smuzhiyunon bigger patches.  Other comments relevant only to the moment or the
655*4882a593Smuzhiyunmaintainer, not suitable for the permanent changelog, should also go
656*4882a593Smuzhiyunhere.  A good example of such comments might be ``patch changelogs``
657*4882a593Smuzhiyunwhich describe what has changed between the v1 and v2 version of the
658*4882a593Smuzhiyunpatch.
659*4882a593Smuzhiyun
660*4882a593SmuzhiyunIf you are going to include a ``diffstat`` after the ``---`` marker, please
661*4882a593Smuzhiyunuse ``diffstat`` options ``-p 1 -w 70`` so that filenames are listed from
662*4882a593Smuzhiyunthe top of the kernel source tree and don't use too much horizontal
663*4882a593Smuzhiyunspace (easily fit in 80 columns, maybe with some indentation).  (``git``
664*4882a593Smuzhiyungenerates appropriate diffstats by default.)
665*4882a593Smuzhiyun
666*4882a593SmuzhiyunSee more details on the proper patch format in the following
667*4882a593Smuzhiyunreferences.
668*4882a593Smuzhiyun
669*4882a593Smuzhiyun.. _explicit_in_reply_to:
670*4882a593Smuzhiyun
671*4882a593SmuzhiyunExplicit In-Reply-To headers
672*4882a593Smuzhiyun----------------------------
673*4882a593Smuzhiyun
674*4882a593SmuzhiyunIt can be helpful to manually add In-Reply-To: headers to a patch
675*4882a593Smuzhiyun(e.g., when using ``git send-email``) to associate the patch with
676*4882a593Smuzhiyunprevious relevant discussion, e.g. to link a bug fix to the email with
677*4882a593Smuzhiyunthe bug report.  However, for a multi-patch series, it is generally
678*4882a593Smuzhiyunbest to avoid using In-Reply-To: to link to older versions of the
679*4882a593Smuzhiyunseries.  This way multiple versions of the patch don't become an
680*4882a593Smuzhiyununmanageable forest of references in email clients.  If a link is
681*4882a593Smuzhiyunhelpful, you can use the https://lkml.kernel.org/ redirector (e.g., in
682*4882a593Smuzhiyunthe cover email text) to link to an earlier version of the patch series.
683*4882a593Smuzhiyun
684*4882a593Smuzhiyun
685*4882a593SmuzhiyunProviding base tree information
686*4882a593Smuzhiyun-------------------------------
687*4882a593Smuzhiyun
688*4882a593SmuzhiyunWhen other developers receive your patches and start the review process,
689*4882a593Smuzhiyunit is often useful for them to know where in the tree history they
690*4882a593Smuzhiyunshould place your work. This is particularly useful for automated CI
691*4882a593Smuzhiyunprocesses that attempt to run a series of tests in order to establish
692*4882a593Smuzhiyunthe quality of your submission before the maintainer starts the review.
693*4882a593Smuzhiyun
694*4882a593SmuzhiyunIf you are using ``git format-patch`` to generate your patches, you can
695*4882a593Smuzhiyunautomatically include the base tree information in your submission by
696*4882a593Smuzhiyunusing the ``--base`` flag. The easiest and most convenient way to use
697*4882a593Smuzhiyunthis option is with topical branches::
698*4882a593Smuzhiyun
699*4882a593Smuzhiyun    $ git checkout -t -b my-topical-branch master
700*4882a593Smuzhiyun    Branch 'my-topical-branch' set up to track local branch 'master'.
701*4882a593Smuzhiyun    Switched to a new branch 'my-topical-branch'
702*4882a593Smuzhiyun
703*4882a593Smuzhiyun    [perform your edits and commits]
704*4882a593Smuzhiyun
705*4882a593Smuzhiyun    $ git format-patch --base=auto --cover-letter -o outgoing/ master
706*4882a593Smuzhiyun    outgoing/0000-cover-letter.patch
707*4882a593Smuzhiyun    outgoing/0001-First-Commit.patch
708*4882a593Smuzhiyun    outgoing/...
709*4882a593Smuzhiyun
710*4882a593SmuzhiyunWhen you open ``outgoing/0000-cover-letter.patch`` for editing, you will
711*4882a593Smuzhiyunnotice that it will have the ``base-commit:`` trailer at the very
712*4882a593Smuzhiyunbottom, which provides the reviewer and the CI tools enough information
713*4882a593Smuzhiyunto properly perform ``git am`` without worrying about conflicts::
714*4882a593Smuzhiyun
715*4882a593Smuzhiyun    $ git checkout -b patch-review [base-commit-id]
716*4882a593Smuzhiyun    Switched to a new branch 'patch-review'
717*4882a593Smuzhiyun    $ git am patches.mbox
718*4882a593Smuzhiyun    Applying: First Commit
719*4882a593Smuzhiyun    Applying: ...
720*4882a593Smuzhiyun
721*4882a593SmuzhiyunPlease see ``man git-format-patch`` for more information about this
722*4882a593Smuzhiyunoption.
723*4882a593Smuzhiyun
724*4882a593Smuzhiyun.. note::
725*4882a593Smuzhiyun
726*4882a593Smuzhiyun    The ``--base`` feature was introduced in git version 2.9.0.
727*4882a593Smuzhiyun
728*4882a593SmuzhiyunIf you are not using git to format your patches, you can still include
729*4882a593Smuzhiyunthe same ``base-commit`` trailer to indicate the commit hash of the tree
730*4882a593Smuzhiyunon which your work is based. You should add it either in the cover
731*4882a593Smuzhiyunletter or in the first patch of the series and it should be placed
732*4882a593Smuzhiyuneither below the ``---`` line or at the very bottom of all other
733*4882a593Smuzhiyuncontent, right before your email signature.
734*4882a593Smuzhiyun
735*4882a593Smuzhiyun
736*4882a593SmuzhiyunReferences
737*4882a593Smuzhiyun----------
738*4882a593Smuzhiyun
739*4882a593SmuzhiyunAndrew Morton, "The perfect patch" (tpp).
740*4882a593Smuzhiyun  <https://www.ozlabs.org/~akpm/stuff/tpp.txt>
741*4882a593Smuzhiyun
742*4882a593SmuzhiyunJeff Garzik, "Linux kernel patch submission format".
743*4882a593Smuzhiyun  <https://web.archive.org/web/20180829112450/http://linux.yyz.us/patch-format.html>
744*4882a593Smuzhiyun
745*4882a593SmuzhiyunGreg Kroah-Hartman, "How to piss off a kernel subsystem maintainer".
746*4882a593Smuzhiyun  <http://www.kroah.com/log/linux/maintainer.html>
747*4882a593Smuzhiyun
748*4882a593Smuzhiyun  <http://www.kroah.com/log/linux/maintainer-02.html>
749*4882a593Smuzhiyun
750*4882a593Smuzhiyun  <http://www.kroah.com/log/linux/maintainer-03.html>
751*4882a593Smuzhiyun
752*4882a593Smuzhiyun  <http://www.kroah.com/log/linux/maintainer-04.html>
753*4882a593Smuzhiyun
754*4882a593Smuzhiyun  <http://www.kroah.com/log/linux/maintainer-05.html>
755*4882a593Smuzhiyun
756*4882a593Smuzhiyun  <http://www.kroah.com/log/linux/maintainer-06.html>
757*4882a593Smuzhiyun
758*4882a593SmuzhiyunNO!!!! No more huge patch bombs to linux-kernel@vger.kernel.org people!
759*4882a593Smuzhiyun  <https://lkml.org/lkml/2005/7/11/336>
760*4882a593Smuzhiyun
761*4882a593SmuzhiyunKernel Documentation/process/coding-style.rst:
762*4882a593Smuzhiyun  :ref:`Documentation/process/coding-style.rst <codingstyle>`
763*4882a593Smuzhiyun
764*4882a593SmuzhiyunLinus Torvalds's mail on the canonical patch format:
765*4882a593Smuzhiyun  <http://lkml.org/lkml/2005/4/7/183>
766*4882a593Smuzhiyun
767*4882a593SmuzhiyunAndi Kleen, "On submitting kernel patches"
768*4882a593Smuzhiyun  Some strategies to get difficult or controversial changes in.
769*4882a593Smuzhiyun
770*4882a593Smuzhiyun  http://halobates.de/on-submitting-patches.pdf
771