162306a36Sopenharmony_ci.. _submittingpatches:
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciSubmitting patches: the essential guide to getting your code into the kernel
462306a36Sopenharmony_ci============================================================================
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciFor a person or company who wishes to submit a change to the Linux
762306a36Sopenharmony_cikernel, the process can sometimes be daunting if you're not familiar
862306a36Sopenharmony_ciwith "the system."  This text is a collection of suggestions which
962306a36Sopenharmony_cican greatly increase the chances of your change being accepted.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciThis document contains a large number of suggestions in a relatively terse
1262306a36Sopenharmony_ciformat.  For detailed information on how the kernel development process
1362306a36Sopenharmony_ciworks, see Documentation/process/development-process.rst. Also, read
1462306a36Sopenharmony_ciDocumentation/process/submit-checklist.rst
1562306a36Sopenharmony_cifor a list of items to check before submitting code.
1662306a36Sopenharmony_ciFor device tree binding patches, read
1762306a36Sopenharmony_ciDocumentation/devicetree/bindings/submitting-patches.rst.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciThis documentation assumes that you're using ``git`` to prepare your patches.
2062306a36Sopenharmony_ciIf you're unfamiliar with ``git``, you would be well-advised to learn how to
2162306a36Sopenharmony_ciuse it, it will make your life as a kernel developer and in general much
2262306a36Sopenharmony_cieasier.
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciSome subsystems and maintainer trees have additional information about
2562306a36Sopenharmony_citheir workflow and expectations, see
2662306a36Sopenharmony_ci:ref:`Documentation/process/maintainer-handbooks.rst <maintainer_handbooks_main>`.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciObtain a current source tree
2962306a36Sopenharmony_ci----------------------------
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciIf you do not have a repository with the current kernel source handy, use
3262306a36Sopenharmony_ci``git`` to obtain one.  You'll want to start with the mainline repository,
3362306a36Sopenharmony_ciwhich can be grabbed with::
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci  git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciNote, however, that you may not want to develop against the mainline tree
3862306a36Sopenharmony_cidirectly.  Most subsystem maintainers run their own trees and want to see
3962306a36Sopenharmony_cipatches prepared against those trees.  See the **T:** entry for the subsystem
4062306a36Sopenharmony_ciin the MAINTAINERS file to find that tree, or simply ask the maintainer if
4162306a36Sopenharmony_cithe tree is not listed there.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci.. _describe_changes:
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciDescribe your changes
4662306a36Sopenharmony_ci---------------------
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciDescribe your problem.  Whether your patch is a one-line bug fix or
4962306a36Sopenharmony_ci5000 lines of a new feature, there must be an underlying problem that
5062306a36Sopenharmony_cimotivated you to do this work.  Convince the reviewer that there is a
5162306a36Sopenharmony_ciproblem worth fixing and that it makes sense for them to read past the
5262306a36Sopenharmony_cifirst paragraph.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciDescribe user-visible impact.  Straight up crashes and lockups are
5562306a36Sopenharmony_cipretty convincing, but not all bugs are that blatant.  Even if the
5662306a36Sopenharmony_ciproblem was spotted during code review, describe the impact you think
5762306a36Sopenharmony_ciit can have on users.  Keep in mind that the majority of Linux
5862306a36Sopenharmony_ciinstallations run kernels from secondary stable trees or
5962306a36Sopenharmony_civendor/product-specific trees that cherry-pick only specific patches
6062306a36Sopenharmony_cifrom upstream, so include anything that could help route your change
6162306a36Sopenharmony_cidownstream: provoking circumstances, excerpts from dmesg, crash
6262306a36Sopenharmony_cidescriptions, performance regressions, latency spikes, lockups, etc.
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciQuantify optimizations and trade-offs.  If you claim improvements in
6562306a36Sopenharmony_ciperformance, memory consumption, stack footprint, or binary size,
6662306a36Sopenharmony_ciinclude numbers that back them up.  But also describe non-obvious
6762306a36Sopenharmony_cicosts.  Optimizations usually aren't free but trade-offs between CPU,
6862306a36Sopenharmony_cimemory, and readability; or, when it comes to heuristics, between
6962306a36Sopenharmony_cidifferent workloads.  Describe the expected downsides of your
7062306a36Sopenharmony_cioptimization so that the reviewer can weigh costs against benefits.
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciOnce the problem is established, describe what you are actually doing
7362306a36Sopenharmony_ciabout it in technical detail.  It's important to describe the change
7462306a36Sopenharmony_ciin plain English for the reviewer to verify that the code is behaving
7562306a36Sopenharmony_cias you intend it to.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciThe maintainer will thank you if you write your patch description in a
7862306a36Sopenharmony_ciform which can be easily pulled into Linux's source code management
7962306a36Sopenharmony_cisystem, ``git``, as a "commit log".  See :ref:`the_canonical_patch_format`.
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ciSolve only one problem per patch.  If your description starts to get
8262306a36Sopenharmony_cilong, that's a sign that you probably need to split up your patch.
8362306a36Sopenharmony_ciSee :ref:`split_changes`.
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ciWhen you submit or resubmit a patch or patch series, include the
8662306a36Sopenharmony_cicomplete patch description and justification for it.  Don't just
8762306a36Sopenharmony_cisay that this is version N of the patch (series).  Don't expect the
8862306a36Sopenharmony_cisubsystem maintainer to refer back to earlier patch versions or referenced
8962306a36Sopenharmony_ciURLs to find the patch description and put that into the patch.
9062306a36Sopenharmony_ciI.e., the patch (series) and its description should be self-contained.
9162306a36Sopenharmony_ciThis benefits both the maintainers and reviewers.  Some reviewers
9262306a36Sopenharmony_ciprobably didn't even receive earlier versions of the patch.
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ciDescribe your changes in imperative mood, e.g. "make xyzzy do frotz"
9562306a36Sopenharmony_ciinstead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
9662306a36Sopenharmony_cito do frotz", as if you are giving orders to the codebase to change
9762306a36Sopenharmony_ciits behaviour.
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ciIf you want to refer to a specific commit, don't just refer to the
10062306a36Sopenharmony_ciSHA-1 ID of the commit. Please also include the oneline summary of
10162306a36Sopenharmony_cithe commit, to make it easier for reviewers to know what it is about.
10262306a36Sopenharmony_ciExample::
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	Commit e21d2170f36602ae2708 ("video: remove unnecessary
10562306a36Sopenharmony_ci	platform_set_drvdata()") removed the unnecessary
10662306a36Sopenharmony_ci	platform_set_drvdata(), but left the variable "dev" unused,
10762306a36Sopenharmony_ci	delete it.
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ciYou should also be sure to use at least the first twelve characters of the
11062306a36Sopenharmony_ciSHA-1 ID.  The kernel repository holds a *lot* of objects, making
11162306a36Sopenharmony_cicollisions with shorter IDs a real possibility.  Bear in mind that, even if
11262306a36Sopenharmony_cithere is no collision with your six-character ID now, that condition may
11362306a36Sopenharmony_cichange five years from now.
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ciIf related discussions or any other background information behind the change
11662306a36Sopenharmony_cican be found on the web, add 'Link:' tags pointing to it. If the patch is a
11762306a36Sopenharmony_ciresult of some earlier mailing list discussions or something documented on the
11862306a36Sopenharmony_ciweb, point to it.
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ciWhen linking to mailing list archives, preferably use the lore.kernel.org
12162306a36Sopenharmony_cimessage archiver service. To create the link URL, use the contents of the
12262306a36Sopenharmony_ci``Message-Id`` header of the message without the surrounding angle brackets.
12362306a36Sopenharmony_ciFor example::
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci    Link: https://lore.kernel.org/r/30th.anniversary.repost@klaava.Helsinki.FI/
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciPlease check the link to make sure that it is actually working and points
12862306a36Sopenharmony_cito the relevant message.
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ciHowever, try to make your explanation understandable without external
13162306a36Sopenharmony_ciresources. In addition to giving a URL to a mailing list archive or bug,
13262306a36Sopenharmony_cisummarize the relevant points of the discussion that led to the
13362306a36Sopenharmony_cipatch as submitted.
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ciIn case your patch fixes a bug, use the 'Closes:' tag with a URL referencing
13662306a36Sopenharmony_cithe report in the mailing list archives or a public bug tracker. For example::
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci	Closes: https://example.com/issues/1234
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ciSome bug trackers have the ability to close issues automatically when a
14162306a36Sopenharmony_cicommit with such a tag is applied. Some bots monitoring mailing lists can
14262306a36Sopenharmony_cialso track such tags and take certain actions. Private bug trackers and
14362306a36Sopenharmony_ciinvalid URLs are forbidden.
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ciIf your patch fixes a bug in a specific commit, e.g. you found an issue using
14662306a36Sopenharmony_ci``git bisect``, please use the 'Fixes:' tag with the first 12 characters of
14762306a36Sopenharmony_cithe SHA-1 ID, and the one line summary.  Do not split the tag across multiple
14862306a36Sopenharmony_cilines, tags are exempt from the "wrap at 75 columns" rule in order to simplify
14962306a36Sopenharmony_ciparsing scripts.  For example::
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci	Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ciThe following ``git config`` settings can be used to add a pretty format for
15462306a36Sopenharmony_cioutputting the above style in the ``git log`` or ``git show`` commands::
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci	[core]
15762306a36Sopenharmony_ci		abbrev = 12
15862306a36Sopenharmony_ci	[pretty]
15962306a36Sopenharmony_ci		fixes = Fixes: %h (\"%s\")
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ciAn example call::
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci	$ git log -1 --pretty=fixes 54a4f0239f2e
16462306a36Sopenharmony_ci	Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed")
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci.. _split_changes:
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ciSeparate your changes
16962306a36Sopenharmony_ci---------------------
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ciSeparate each **logical change** into a separate patch.
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ciFor example, if your changes include both bug fixes and performance
17462306a36Sopenharmony_cienhancements for a single driver, separate those changes into two
17562306a36Sopenharmony_cior more patches.  If your changes include an API update, and a new
17662306a36Sopenharmony_cidriver which uses that new API, separate those into two patches.
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ciOn the other hand, if you make a single change to numerous files,
17962306a36Sopenharmony_cigroup those changes into a single patch.  Thus a single logical change
18062306a36Sopenharmony_ciis contained within a single patch.
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ciThe point to remember is that each patch should make an easily understood
18362306a36Sopenharmony_cichange that can be verified by reviewers.  Each patch should be justifiable
18462306a36Sopenharmony_cion its own merits.
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ciIf one patch depends on another patch in order for a change to be
18762306a36Sopenharmony_cicomplete, that is OK.  Simply note **"this patch depends on patch X"**
18862306a36Sopenharmony_ciin your patch description.
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ciWhen dividing your change into a series of patches, take special care to
19162306a36Sopenharmony_ciensure that the kernel builds and runs properly after each patch in the
19262306a36Sopenharmony_ciseries.  Developers using ``git bisect`` to track down a problem can end up
19362306a36Sopenharmony_cisplitting your patch series at any point; they will not thank you if you
19462306a36Sopenharmony_ciintroduce bugs in the middle.
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ciIf you cannot condense your patch set into a smaller set of patches,
19762306a36Sopenharmony_cithen only post say 15 or so at a time and wait for review and integration.
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ciStyle-check your changes
20262306a36Sopenharmony_ci------------------------
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ciCheck your patch for basic style violations, details of which can be
20562306a36Sopenharmony_cifound in Documentation/process/coding-style.rst.
20662306a36Sopenharmony_ciFailure to do so simply wastes
20762306a36Sopenharmony_cithe reviewers time and will get your patch rejected, probably
20862306a36Sopenharmony_ciwithout even being read.
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ciOne significant exception is when moving code from one file to
21162306a36Sopenharmony_cianother -- in this case you should not modify the moved code at all in
21262306a36Sopenharmony_cithe same patch which moves it.  This clearly delineates the act of
21362306a36Sopenharmony_cimoving the code and your changes.  This greatly aids review of the
21462306a36Sopenharmony_ciactual differences and allows tools to better track the history of
21562306a36Sopenharmony_cithe code itself.
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ciCheck your patches with the patch style checker prior to submission
21862306a36Sopenharmony_ci(scripts/checkpatch.pl).  Note, though, that the style checker should be
21962306a36Sopenharmony_civiewed as a guide, not as a replacement for human judgment.  If your code
22062306a36Sopenharmony_cilooks better with a violation then its probably best left alone.
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ciThe checker reports at three levels:
22362306a36Sopenharmony_ci - ERROR: things that are very likely to be wrong
22462306a36Sopenharmony_ci - WARNING: things requiring careful review
22562306a36Sopenharmony_ci - CHECK: things requiring thought
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ciYou should be able to justify all violations that remain in your
22862306a36Sopenharmony_cipatch.
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ciSelect the recipients for your patch
23262306a36Sopenharmony_ci------------------------------------
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ciYou should always copy the appropriate subsystem maintainer(s) and list(s) on
23562306a36Sopenharmony_ciany patch to code that they maintain; look through the MAINTAINERS file and the
23662306a36Sopenharmony_cisource code revision history to see who those maintainers are.  The script
23762306a36Sopenharmony_ciscripts/get_maintainer.pl can be very useful at this step (pass paths to your
23862306a36Sopenharmony_cipatches as arguments to scripts/get_maintainer.pl).  If you cannot find a
23962306a36Sopenharmony_cimaintainer for the subsystem you are working on, Andrew Morton
24062306a36Sopenharmony_ci(akpm@linux-foundation.org) serves as a maintainer of last resort.
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_cilinux-kernel@vger.kernel.org should be used by default for all patches, but the
24362306a36Sopenharmony_civolume on that list has caused a number of developers to tune it out.  Please
24462306a36Sopenharmony_cido not spam unrelated lists and unrelated people, though.
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ciMany kernel-related lists are hosted on vger.kernel.org; you can find a
24762306a36Sopenharmony_cilist of them at http://vger.kernel.org/vger-lists.html.  There are
24862306a36Sopenharmony_cikernel-related lists hosted elsewhere as well, though.
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ciDo not send more than 15 patches at once to the vger mailing lists!!!
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ciLinus Torvalds is the final arbiter of all changes accepted into the
25362306a36Sopenharmony_ciLinux kernel.  His e-mail address is <torvalds@linux-foundation.org>.
25462306a36Sopenharmony_ciHe gets a lot of e-mail, and, at this point, very few patches go through
25562306a36Sopenharmony_ciLinus directly, so typically you should do your best to -avoid-
25662306a36Sopenharmony_cisending him e-mail.
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ciIf you have a patch that fixes an exploitable security bug, send that patch
25962306a36Sopenharmony_cito security@kernel.org.  For severe bugs, a short embargo may be considered
26062306a36Sopenharmony_cito allow distributors to get the patch out to users; in such cases,
26162306a36Sopenharmony_ciobviously, the patch should not be sent to any public lists. See also
26262306a36Sopenharmony_ciDocumentation/process/security-bugs.rst.
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ciPatches that fix a severe bug in a released kernel should be directed
26562306a36Sopenharmony_citoward the stable maintainers by putting a line like this::
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci  Cc: stable@vger.kernel.org
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ciinto the sign-off area of your patch (note, NOT an email recipient).  You
27062306a36Sopenharmony_cishould also read Documentation/process/stable-kernel-rules.rst
27162306a36Sopenharmony_ciin addition to this document.
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ciIf changes affect userland-kernel interfaces, please send the MAN-PAGES
27462306a36Sopenharmony_cimaintainer (as listed in the MAINTAINERS file) a man-pages patch, or at
27562306a36Sopenharmony_cileast a notification of the change, so that some information makes its way
27662306a36Sopenharmony_ciinto the manual pages.  User-space API changes should also be copied to
27762306a36Sopenharmony_cilinux-api@vger.kernel.org.
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ciNo MIME, no links, no compression, no attachments.  Just plain text
28162306a36Sopenharmony_ci-------------------------------------------------------------------
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ciLinus and other kernel developers need to be able to read and comment
28462306a36Sopenharmony_cion the changes you are submitting.  It is important for a kernel
28562306a36Sopenharmony_cideveloper to be able to "quote" your changes, using standard e-mail
28662306a36Sopenharmony_citools, so that they may comment on specific portions of your code.
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ciFor this reason, all patches should be submitted by e-mail "inline". The
28962306a36Sopenharmony_cieasiest way to do this is with ``git send-email``, which is strongly
29062306a36Sopenharmony_cirecommended.  An interactive tutorial for ``git send-email`` is available at
29162306a36Sopenharmony_cihttps://git-send-email.io.
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ciIf you choose not to use ``git send-email``:
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci.. warning::
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci  Be wary of your editor's word-wrap corrupting your patch,
29862306a36Sopenharmony_ci  if you choose to cut-n-paste your patch.
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ciDo not attach the patch as a MIME attachment, compressed or not.
30162306a36Sopenharmony_ciMany popular e-mail applications will not always transmit a MIME
30262306a36Sopenharmony_ciattachment as plain text, making it impossible to comment on your
30362306a36Sopenharmony_cicode.  A MIME attachment also takes Linus a bit more time to process,
30462306a36Sopenharmony_cidecreasing the likelihood of your MIME-attached change being accepted.
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_ciException:  If your mailer is mangling patches then someone may ask
30762306a36Sopenharmony_ciyou to re-send them using MIME.
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ciSee Documentation/process/email-clients.rst for hints about configuring
31062306a36Sopenharmony_ciyour e-mail client so that it sends your patches untouched.
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ciRespond to review comments
31362306a36Sopenharmony_ci--------------------------
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ciYour patch will almost certainly get comments from reviewers on ways in
31662306a36Sopenharmony_ciwhich the patch can be improved, in the form of a reply to your email. You must
31762306a36Sopenharmony_cirespond to those comments; ignoring reviewers is a good way to get ignored in
31862306a36Sopenharmony_cireturn. You can simply reply to their emails to answer their comments. Review
31962306a36Sopenharmony_cicomments or questions that do not lead to a code change should almost certainly
32062306a36Sopenharmony_cibring about a comment or changelog entry so that the next reviewer better
32162306a36Sopenharmony_ciunderstands what is going on.
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ciBe sure to tell the reviewers what changes you are making and to thank them
32462306a36Sopenharmony_cifor their time.  Code review is a tiring and time-consuming process, and
32562306a36Sopenharmony_cireviewers sometimes get grumpy.  Even in that case, though, respond
32662306a36Sopenharmony_cipolitely and address the problems they have pointed out.  When sending a next
32762306a36Sopenharmony_civersion, add a ``patch changelog`` to the cover letter or to individual patches
32862306a36Sopenharmony_ciexplaining difference against previous submission (see
32962306a36Sopenharmony_ci:ref:`the_canonical_patch_format`).
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ciSee Documentation/process/email-clients.rst for recommendations on email
33262306a36Sopenharmony_ciclients and mailing list etiquette.
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci.. _interleaved_replies:
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ciUse trimmed interleaved replies in email discussions
33762306a36Sopenharmony_ci----------------------------------------------------
33862306a36Sopenharmony_ciTop-posting is strongly discouraged in Linux kernel development
33962306a36Sopenharmony_cidiscussions. Interleaved (or "inline") replies make conversations much
34062306a36Sopenharmony_cieasier to follow. For more details see:
34162306a36Sopenharmony_cihttps://en.wikipedia.org/wiki/Posting_style#Interleaved_style
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ciAs is frequently quoted on the mailing list::
34462306a36Sopenharmony_ci
34562306a36Sopenharmony_ci  A: http://en.wikipedia.org/wiki/Top_post
34662306a36Sopenharmony_ci  Q: Were do I find info about this thing called top-posting?
34762306a36Sopenharmony_ci  A: Because it messes up the order in which people normally read text.
34862306a36Sopenharmony_ci  Q: Why is top-posting such a bad thing?
34962306a36Sopenharmony_ci  A: Top-posting.
35062306a36Sopenharmony_ci  Q: What is the most annoying thing in e-mail?
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ciSimilarly, please trim all unneeded quotations that aren't relevant
35362306a36Sopenharmony_cito your reply. This makes responses easier to find, and saves time and
35462306a36Sopenharmony_cispace. For more details see: http://daringfireball.net/2007/07/on_top ::
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci  A: No.
35762306a36Sopenharmony_ci  Q: Should I include quotations after my reply?
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_ci.. _resend_reminders:
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ciDon't get discouraged - or impatient
36262306a36Sopenharmony_ci------------------------------------
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ciAfter you have submitted your change, be patient and wait.  Reviewers are
36562306a36Sopenharmony_cibusy people and may not get to your patch right away.
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ciOnce upon a time, patches used to disappear into the void without comment,
36862306a36Sopenharmony_cibut the development process works more smoothly than that now.  You should
36962306a36Sopenharmony_cireceive comments within a week or so; if that does not happen, make sure
37062306a36Sopenharmony_cithat you have sent your patches to the right place.  Wait for a minimum of
37162306a36Sopenharmony_cione week before resubmitting or pinging reviewers - possibly longer during
37262306a36Sopenharmony_cibusy times like merge windows.
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_ciIt's also ok to resend the patch or the patch series after a couple of
37562306a36Sopenharmony_ciweeks with the word "RESEND" added to the subject line::
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ci   [PATCH Vx RESEND] sub/sys: Condensed patch summary
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ciDon't add "RESEND" when you are submitting a modified version of your
38062306a36Sopenharmony_cipatch or patch series - "RESEND" only applies to resubmission of a
38162306a36Sopenharmony_cipatch or patch series which have not been modified in any way from the
38262306a36Sopenharmony_ciprevious submission.
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_ciInclude PATCH in the subject
38662306a36Sopenharmony_ci-----------------------------
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ciDue to high e-mail traffic to Linus, and to linux-kernel, it is common
38962306a36Sopenharmony_ciconvention to prefix your subject line with [PATCH].  This lets Linus
39062306a36Sopenharmony_ciand other kernel developers more easily distinguish patches from other
39162306a36Sopenharmony_cie-mail discussions.
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ci``git send-email`` will do this for you automatically.
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_ciSign your work - the Developer's Certificate of Origin
39762306a36Sopenharmony_ci------------------------------------------------------
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ciTo improve tracking of who did what, especially with patches that can
40062306a36Sopenharmony_cipercolate to their final resting place in the kernel through several
40162306a36Sopenharmony_cilayers of maintainers, we've introduced a "sign-off" procedure on
40262306a36Sopenharmony_cipatches that are being emailed around.
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_ciThe sign-off is a simple line at the end of the explanation for the
40562306a36Sopenharmony_cipatch, which certifies that you wrote it or otherwise have the right to
40662306a36Sopenharmony_cipass it on as an open-source patch.  The rules are pretty simple: if you
40762306a36Sopenharmony_cican certify the below:
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ciDeveloper's Certificate of Origin 1.1
41062306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ciBy making a contribution to this project, I certify that:
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci        (a) The contribution was created in whole or in part by me and I
41562306a36Sopenharmony_ci            have the right to submit it under the open source license
41662306a36Sopenharmony_ci            indicated in the file; or
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci        (b) The contribution is based upon previous work that, to the best
41962306a36Sopenharmony_ci            of my knowledge, is covered under an appropriate open source
42062306a36Sopenharmony_ci            license and I have the right under that license to submit that
42162306a36Sopenharmony_ci            work with modifications, whether created in whole or in part
42262306a36Sopenharmony_ci            by me, under the same open source license (unless I am
42362306a36Sopenharmony_ci            permitted to submit under a different license), as indicated
42462306a36Sopenharmony_ci            in the file; or
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_ci        (c) The contribution was provided directly to me by some other
42762306a36Sopenharmony_ci            person who certified (a), (b) or (c) and I have not modified
42862306a36Sopenharmony_ci            it.
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci        (d) I understand and agree that this project and the contribution
43162306a36Sopenharmony_ci            are public and that a record of the contribution (including all
43262306a36Sopenharmony_ci            personal information I submit with it, including my sign-off) is
43362306a36Sopenharmony_ci            maintained indefinitely and may be redistributed consistent with
43462306a36Sopenharmony_ci            this project or the open source license(s) involved.
43562306a36Sopenharmony_ci
43662306a36Sopenharmony_cithen you just add a line saying::
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci	Signed-off-by: Random J Developer <random@developer.example.org>
43962306a36Sopenharmony_ci
44062306a36Sopenharmony_ciusing a known identity (sorry, no anonymous contributions.)
44162306a36Sopenharmony_ciThis will be done for you automatically if you use ``git commit -s``.
44262306a36Sopenharmony_ciReverts should also include "Signed-off-by". ``git revert -s`` does that
44362306a36Sopenharmony_cifor you.
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ciSome people also put extra tags at the end.  They'll just be ignored for
44662306a36Sopenharmony_cinow, but you can do this to mark internal company procedures or just
44762306a36Sopenharmony_cipoint out some special detail about the sign-off.
44862306a36Sopenharmony_ci
44962306a36Sopenharmony_ciAny further SoBs (Signed-off-by:'s) following the author's SoB are from
45062306a36Sopenharmony_cipeople handling and transporting the patch, but were not involved in its
45162306a36Sopenharmony_cidevelopment. SoB chains should reflect the **real** route a patch took
45262306a36Sopenharmony_cias it was propagated to the maintainers and ultimately to Linus, with
45362306a36Sopenharmony_cithe first SoB entry signalling primary authorship of a single author.
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ciWhen to use Acked-by:, Cc:, and Co-developed-by:
45762306a36Sopenharmony_ci------------------------------------------------
45862306a36Sopenharmony_ci
45962306a36Sopenharmony_ciThe Signed-off-by: tag indicates that the signer was involved in the
46062306a36Sopenharmony_cidevelopment of the patch, or that he/she was in the patch's delivery path.
46162306a36Sopenharmony_ci
46262306a36Sopenharmony_ciIf a person was not directly involved in the preparation or handling of a
46362306a36Sopenharmony_cipatch but wishes to signify and record their approval of it then they can
46462306a36Sopenharmony_ciask to have an Acked-by: line added to the patch's changelog.
46562306a36Sopenharmony_ci
46662306a36Sopenharmony_ciAcked-by: is often used by the maintainer of the affected code when that
46762306a36Sopenharmony_cimaintainer neither contributed to nor forwarded the patch.
46862306a36Sopenharmony_ci
46962306a36Sopenharmony_ciAcked-by: is not as formal as Signed-off-by:.  It is a record that the acker
47062306a36Sopenharmony_cihas at least reviewed the patch and has indicated acceptance.  Hence patch
47162306a36Sopenharmony_cimergers will sometimes manually convert an acker's "yep, looks good to me"
47262306a36Sopenharmony_ciinto an Acked-by: (but note that it is usually better to ask for an
47362306a36Sopenharmony_ciexplicit ack).
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_ciAcked-by: does not necessarily indicate acknowledgement of the entire patch.
47662306a36Sopenharmony_ciFor example, if a patch affects multiple subsystems and has an Acked-by: from
47762306a36Sopenharmony_cione subsystem maintainer then this usually indicates acknowledgement of just
47862306a36Sopenharmony_cithe part which affects that maintainer's code.  Judgement should be used here.
47962306a36Sopenharmony_ciWhen in doubt people should refer to the original discussion in the mailing
48062306a36Sopenharmony_cilist archives.
48162306a36Sopenharmony_ci
48262306a36Sopenharmony_ciIf a person has had the opportunity to comment on a patch, but has not
48362306a36Sopenharmony_ciprovided such comments, you may optionally add a ``Cc:`` tag to the patch.
48462306a36Sopenharmony_ciThis is the only tag which might be added without an explicit action by the
48562306a36Sopenharmony_ciperson it names - but it should indicate that this person was copied on the
48662306a36Sopenharmony_cipatch.  This tag documents that potentially interested parties
48762306a36Sopenharmony_cihave been included in the discussion.
48862306a36Sopenharmony_ci
48962306a36Sopenharmony_ciCo-developed-by: states that the patch was co-created by multiple developers;
49062306a36Sopenharmony_ciit is used to give attribution to co-authors (in addition to the author
49162306a36Sopenharmony_ciattributed by the From: tag) when several people work on a single patch.  Since
49262306a36Sopenharmony_ciCo-developed-by: denotes authorship, every Co-developed-by: must be immediately
49362306a36Sopenharmony_cifollowed by a Signed-off-by: of the associated co-author.  Standard sign-off
49462306a36Sopenharmony_ciprocedure applies, i.e. the ordering of Signed-off-by: tags should reflect the
49562306a36Sopenharmony_cichronological history of the patch insofar as possible, regardless of whether
49662306a36Sopenharmony_cithe author is attributed via From: or Co-developed-by:.  Notably, the last
49762306a36Sopenharmony_ciSigned-off-by: must always be that of the developer submitting the patch.
49862306a36Sopenharmony_ci
49962306a36Sopenharmony_ciNote, the From: tag is optional when the From: author is also the person (and
50062306a36Sopenharmony_ciemail) listed in the From: line of the email header.
50162306a36Sopenharmony_ci
50262306a36Sopenharmony_ciExample of a patch submitted by the From: author::
50362306a36Sopenharmony_ci
50462306a36Sopenharmony_ci	<changelog>
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci	Co-developed-by: First Co-Author <first@coauthor.example.org>
50762306a36Sopenharmony_ci	Signed-off-by: First Co-Author <first@coauthor.example.org>
50862306a36Sopenharmony_ci	Co-developed-by: Second Co-Author <second@coauthor.example.org>
50962306a36Sopenharmony_ci	Signed-off-by: Second Co-Author <second@coauthor.example.org>
51062306a36Sopenharmony_ci	Signed-off-by: From Author <from@author.example.org>
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ciExample of a patch submitted by a Co-developed-by: author::
51362306a36Sopenharmony_ci
51462306a36Sopenharmony_ci	From: From Author <from@author.example.org>
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_ci	<changelog>
51762306a36Sopenharmony_ci
51862306a36Sopenharmony_ci	Co-developed-by: Random Co-Author <random@coauthor.example.org>
51962306a36Sopenharmony_ci	Signed-off-by: Random Co-Author <random@coauthor.example.org>
52062306a36Sopenharmony_ci	Signed-off-by: From Author <from@author.example.org>
52162306a36Sopenharmony_ci	Co-developed-by: Submitting Co-Author <sub@coauthor.example.org>
52262306a36Sopenharmony_ci	Signed-off-by: Submitting Co-Author <sub@coauthor.example.org>
52362306a36Sopenharmony_ci
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ciUsing Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes:
52662306a36Sopenharmony_ci----------------------------------------------------------------------
52762306a36Sopenharmony_ci
52862306a36Sopenharmony_ciThe Reported-by tag gives credit to people who find bugs and report them and it
52962306a36Sopenharmony_cihopefully inspires them to help us again in the future. The tag is intended for
53062306a36Sopenharmony_cibugs; please do not use it to credit feature requests. The tag should be
53162306a36Sopenharmony_cifollowed by a Closes: tag pointing to the report, unless the report is not
53262306a36Sopenharmony_ciavailable on the web. The Link: tag can be used instead of Closes: if the patch
53362306a36Sopenharmony_cifixes a part of the issue(s) being reported. Please note that if the bug was
53462306a36Sopenharmony_cireported in private, then ask for permission first before using the Reported-by
53562306a36Sopenharmony_citag.
53662306a36Sopenharmony_ci
53762306a36Sopenharmony_ciA Tested-by: tag indicates that the patch has been successfully tested (in
53862306a36Sopenharmony_cisome environment) by the person named.  This tag informs maintainers that
53962306a36Sopenharmony_cisome testing has been performed, provides a means to locate testers for
54062306a36Sopenharmony_cifuture patches, and ensures credit for the testers.
54162306a36Sopenharmony_ci
54262306a36Sopenharmony_ciReviewed-by:, instead, indicates that the patch has been reviewed and found
54362306a36Sopenharmony_ciacceptable according to the Reviewer's Statement:
54462306a36Sopenharmony_ci
54562306a36Sopenharmony_ciReviewer's statement of oversight
54662306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54762306a36Sopenharmony_ci
54862306a36Sopenharmony_ciBy offering my Reviewed-by: tag, I state that:
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci	 (a) I have carried out a technical review of this patch to
55162306a36Sopenharmony_ci	     evaluate its appropriateness and readiness for inclusion into
55262306a36Sopenharmony_ci	     the mainline kernel.
55362306a36Sopenharmony_ci
55462306a36Sopenharmony_ci	 (b) Any problems, concerns, or questions relating to the patch
55562306a36Sopenharmony_ci	     have been communicated back to the submitter.  I am satisfied
55662306a36Sopenharmony_ci	     with the submitter's response to my comments.
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_ci	 (c) While there may be things that could be improved with this
55962306a36Sopenharmony_ci	     submission, I believe that it is, at this time, (1) a
56062306a36Sopenharmony_ci	     worthwhile modification to the kernel, and (2) free of known
56162306a36Sopenharmony_ci	     issues which would argue against its inclusion.
56262306a36Sopenharmony_ci
56362306a36Sopenharmony_ci	 (d) While I have reviewed the patch and believe it to be sound, I
56462306a36Sopenharmony_ci	     do not (unless explicitly stated elsewhere) make any
56562306a36Sopenharmony_ci	     warranties or guarantees that it will achieve its stated
56662306a36Sopenharmony_ci	     purpose or function properly in any given situation.
56762306a36Sopenharmony_ci
56862306a36Sopenharmony_ciA Reviewed-by tag is a statement of opinion that the patch is an
56962306a36Sopenharmony_ciappropriate modification of the kernel without any remaining serious
57062306a36Sopenharmony_citechnical issues.  Any interested reviewer (who has done the work) can
57162306a36Sopenharmony_cioffer a Reviewed-by tag for a patch.  This tag serves to give credit to
57262306a36Sopenharmony_cireviewers and to inform maintainers of the degree of review which has been
57362306a36Sopenharmony_cidone on the patch.  Reviewed-by: tags, when supplied by reviewers known to
57462306a36Sopenharmony_ciunderstand the subject area and to perform thorough reviews, will normally
57562306a36Sopenharmony_ciincrease the likelihood of your patch getting into the kernel.
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ciBoth Tested-by and Reviewed-by tags, once received on mailing list from tester
57862306a36Sopenharmony_cior reviewer, should be added by author to the applicable patches when sending
57962306a36Sopenharmony_cinext versions.  However if the patch has changed substantially in following
58062306a36Sopenharmony_civersion, these tags might not be applicable anymore and thus should be removed.
58162306a36Sopenharmony_ciUsually removal of someone's Tested-by or Reviewed-by tags should be mentioned
58262306a36Sopenharmony_ciin the patch changelog (after the '---' separator).
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_ciA Suggested-by: tag indicates that the patch idea is suggested by the person
58562306a36Sopenharmony_cinamed and ensures credit to the person for the idea. Please note that this
58662306a36Sopenharmony_citag should not be added without the reporter's permission, especially if the
58762306a36Sopenharmony_ciidea was not posted in a public forum. That said, if we diligently credit our
58862306a36Sopenharmony_ciidea reporters, they will, hopefully, be inspired to help us again in the
58962306a36Sopenharmony_cifuture.
59062306a36Sopenharmony_ci
59162306a36Sopenharmony_ciA Fixes: tag indicates that the patch fixes an issue in a previous commit. It
59262306a36Sopenharmony_ciis used to make it easy to determine where a bug originated, which can help
59362306a36Sopenharmony_cireview a bug fix. This tag also assists the stable kernel team in determining
59462306a36Sopenharmony_ciwhich stable kernel versions should receive your fix. This is the preferred
59562306a36Sopenharmony_cimethod for indicating a bug fixed by the patch. See :ref:`describe_changes`
59662306a36Sopenharmony_cifor more details.
59762306a36Sopenharmony_ci
59862306a36Sopenharmony_ciNote: Attaching a Fixes: tag does not subvert the stable kernel rules
59962306a36Sopenharmony_ciprocess nor the requirement to Cc: stable@vger.kernel.org on all stable
60062306a36Sopenharmony_cipatch candidates. For more information, please read
60162306a36Sopenharmony_ciDocumentation/process/stable-kernel-rules.rst.
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci.. _the_canonical_patch_format:
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ciThe canonical patch format
60662306a36Sopenharmony_ci--------------------------
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_ciThis section describes how the patch itself should be formatted.  Note
60962306a36Sopenharmony_cithat, if you have your patches stored in a ``git`` repository, proper patch
61062306a36Sopenharmony_ciformatting can be had with ``git format-patch``.  The tools cannot create
61162306a36Sopenharmony_cithe necessary text, though, so read the instructions below anyway.
61262306a36Sopenharmony_ci
61362306a36Sopenharmony_ciThe canonical patch subject line is::
61462306a36Sopenharmony_ci
61562306a36Sopenharmony_ci    Subject: [PATCH 001/123] subsystem: summary phrase
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_ciThe canonical patch message body contains the following:
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_ci  - A ``from`` line specifying the patch author, followed by an empty
62062306a36Sopenharmony_ci    line (only needed if the person sending the patch is not the author).
62162306a36Sopenharmony_ci
62262306a36Sopenharmony_ci  - The body of the explanation, line wrapped at 75 columns, which will
62362306a36Sopenharmony_ci    be copied to the permanent changelog to describe this patch.
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_ci  - An empty line.
62662306a36Sopenharmony_ci
62762306a36Sopenharmony_ci  - The ``Signed-off-by:`` lines, described above, which will
62862306a36Sopenharmony_ci    also go in the changelog.
62962306a36Sopenharmony_ci
63062306a36Sopenharmony_ci  - A marker line containing simply ``---``.
63162306a36Sopenharmony_ci
63262306a36Sopenharmony_ci  - Any additional comments not suitable for the changelog.
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ci  - The actual patch (``diff`` output).
63562306a36Sopenharmony_ci
63662306a36Sopenharmony_ciThe Subject line format makes it very easy to sort the emails
63762306a36Sopenharmony_cialphabetically by subject line - pretty much any email reader will
63862306a36Sopenharmony_cisupport that - since because the sequence number is zero-padded,
63962306a36Sopenharmony_cithe numerical and alphabetic sort is the same.
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ciThe ``subsystem`` in the email's Subject should identify which
64262306a36Sopenharmony_ciarea or subsystem of the kernel is being patched.
64362306a36Sopenharmony_ci
64462306a36Sopenharmony_ciThe ``summary phrase`` in the email's Subject should concisely
64562306a36Sopenharmony_cidescribe the patch which that email contains.  The ``summary
64662306a36Sopenharmony_ciphrase`` should not be a filename.  Do not use the same ``summary
64762306a36Sopenharmony_ciphrase`` for every patch in a whole patch series (where a ``patch
64862306a36Sopenharmony_ciseries`` is an ordered sequence of multiple, related patches).
64962306a36Sopenharmony_ci
65062306a36Sopenharmony_ciBear in mind that the ``summary phrase`` of your email becomes a
65162306a36Sopenharmony_ciglobally-unique identifier for that patch.  It propagates all the way
65262306a36Sopenharmony_ciinto the ``git`` changelog.  The ``summary phrase`` may later be used in
65362306a36Sopenharmony_cideveloper discussions which refer to the patch.  People will want to
65462306a36Sopenharmony_cigoogle for the ``summary phrase`` to read discussion regarding that
65562306a36Sopenharmony_cipatch.  It will also be the only thing that people may quickly see
65662306a36Sopenharmony_ciwhen, two or three months later, they are going through perhaps
65762306a36Sopenharmony_cithousands of patches using tools such as ``gitk`` or ``git log
65862306a36Sopenharmony_ci--oneline``.
65962306a36Sopenharmony_ci
66062306a36Sopenharmony_ciFor these reasons, the ``summary`` must be no more than 70-75
66162306a36Sopenharmony_cicharacters, and it must describe both what the patch changes, as well
66262306a36Sopenharmony_cias why the patch might be necessary.  It is challenging to be both
66362306a36Sopenharmony_cisuccinct and descriptive, but that is what a well-written summary
66462306a36Sopenharmony_cishould do.
66562306a36Sopenharmony_ci
66662306a36Sopenharmony_ciThe ``summary phrase`` may be prefixed by tags enclosed in square
66762306a36Sopenharmony_cibrackets: "Subject: [PATCH <tag>...] <summary phrase>".  The tags are
66862306a36Sopenharmony_cinot considered part of the summary phrase, but describe how the patch
66962306a36Sopenharmony_cishould be treated.  Common tags might include a version descriptor if
67062306a36Sopenharmony_cithe multiple versions of the patch have been sent out in response to
67162306a36Sopenharmony_cicomments (i.e., "v1, v2, v3"), or "RFC" to indicate a request for
67262306a36Sopenharmony_cicomments.
67362306a36Sopenharmony_ci
67462306a36Sopenharmony_ciIf there are four patches in a patch series the individual patches may
67562306a36Sopenharmony_cibe numbered like this: 1/4, 2/4, 3/4, 4/4. This assures that developers
67662306a36Sopenharmony_ciunderstand the order in which the patches should be applied and that
67762306a36Sopenharmony_cithey have reviewed or applied all of the patches in the patch series.
67862306a36Sopenharmony_ci
67962306a36Sopenharmony_ciHere are some good example Subjects::
68062306a36Sopenharmony_ci
68162306a36Sopenharmony_ci    Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching
68262306a36Sopenharmony_ci    Subject: [PATCH v2 01/27] x86: fix eflags tracking
68362306a36Sopenharmony_ci    Subject: [PATCH v2] sub/sys: Condensed patch summary
68462306a36Sopenharmony_ci    Subject: [PATCH v2 M/N] sub/sys: Condensed patch summary
68562306a36Sopenharmony_ci
68662306a36Sopenharmony_ciThe ``from`` line must be the very first line in the message body,
68762306a36Sopenharmony_ciand has the form:
68862306a36Sopenharmony_ci
68962306a36Sopenharmony_ci        From: Patch Author <author@example.com>
69062306a36Sopenharmony_ci
69162306a36Sopenharmony_ciThe ``from`` line specifies who will be credited as the author of the
69262306a36Sopenharmony_cipatch in the permanent changelog.  If the ``from`` line is missing,
69362306a36Sopenharmony_cithen the ``From:`` line from the email header will be used to determine
69462306a36Sopenharmony_cithe patch author in the changelog.
69562306a36Sopenharmony_ci
69662306a36Sopenharmony_ciThe explanation body will be committed to the permanent source
69762306a36Sopenharmony_cichangelog, so should make sense to a competent reader who has long since
69862306a36Sopenharmony_ciforgotten the immediate details of the discussion that might have led to
69962306a36Sopenharmony_cithis patch. Including symptoms of the failure which the patch addresses
70062306a36Sopenharmony_ci(kernel log messages, oops messages, etc.) are especially useful for
70162306a36Sopenharmony_cipeople who might be searching the commit logs looking for the applicable
70262306a36Sopenharmony_cipatch. The text should be written in such detail so that when read
70362306a36Sopenharmony_ciweeks, months or even years later, it can give the reader the needed
70462306a36Sopenharmony_cidetails to grasp the reasoning for **why** the patch was created.
70562306a36Sopenharmony_ci
70662306a36Sopenharmony_ciIf a patch fixes a compile failure, it may not be necessary to include
70762306a36Sopenharmony_ci_all_ of the compile failures; just enough that it is likely that
70862306a36Sopenharmony_cisomeone searching for the patch can find it. As in the ``summary
70962306a36Sopenharmony_ciphrase``, it is important to be both succinct as well as descriptive.
71062306a36Sopenharmony_ci
71162306a36Sopenharmony_ciThe ``---`` marker line serves the essential purpose of marking for
71262306a36Sopenharmony_cipatch handling tools where the changelog message ends.
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_ciOne good use for the additional comments after the ``---`` marker is
71562306a36Sopenharmony_cifor a ``diffstat``, to show what files have changed, and the number of
71662306a36Sopenharmony_ciinserted and deleted lines per file. A ``diffstat`` is especially useful
71762306a36Sopenharmony_cion bigger patches. If you are going to include a ``diffstat`` after the
71862306a36Sopenharmony_ci``---`` marker, please use ``diffstat`` options ``-p 1 -w 70`` so that
71962306a36Sopenharmony_cifilenames are listed from the top of the kernel source tree and don't
72062306a36Sopenharmony_ciuse too much horizontal space (easily fit in 80 columns, maybe with some
72162306a36Sopenharmony_ciindentation). (``git`` generates appropriate diffstats by default.)
72262306a36Sopenharmony_ci
72362306a36Sopenharmony_ciOther comments relevant only to the moment or the maintainer, not
72462306a36Sopenharmony_cisuitable for the permanent changelog, should also go here. A good
72562306a36Sopenharmony_ciexample of such comments might be ``patch changelogs`` which describe
72662306a36Sopenharmony_ciwhat has changed between the v1 and v2 version of the patch.
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_ciPlease put this information **after** the ``---`` line which separates
72962306a36Sopenharmony_cithe changelog from the rest of the patch. The version information is
73062306a36Sopenharmony_cinot part of the changelog which gets committed to the git tree. It is
73162306a36Sopenharmony_ciadditional information for the reviewers. If it's placed above the
73262306a36Sopenharmony_cicommit tags, it needs manual interaction to remove it. If it is below
73362306a36Sopenharmony_cithe separator line, it gets automatically stripped off when applying the
73462306a36Sopenharmony_cipatch::
73562306a36Sopenharmony_ci
73662306a36Sopenharmony_ci  <commit message>
73762306a36Sopenharmony_ci  ...
73862306a36Sopenharmony_ci  Signed-off-by: Author <author@mail>
73962306a36Sopenharmony_ci  ---
74062306a36Sopenharmony_ci  V2 -> V3: Removed redundant helper function
74162306a36Sopenharmony_ci  V1 -> V2: Cleaned up coding style and addressed review comments
74262306a36Sopenharmony_ci
74362306a36Sopenharmony_ci  path/to/file | 5+++--
74462306a36Sopenharmony_ci  ...
74562306a36Sopenharmony_ci
74662306a36Sopenharmony_ciSee more details on the proper patch format in the following
74762306a36Sopenharmony_cireferences.
74862306a36Sopenharmony_ci
74962306a36Sopenharmony_ci.. _backtraces:
75062306a36Sopenharmony_ci
75162306a36Sopenharmony_ciBacktraces in commit messages
75262306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75362306a36Sopenharmony_ci
75462306a36Sopenharmony_ciBacktraces help document the call chain leading to a problem. However,
75562306a36Sopenharmony_cinot all backtraces are helpful. For example, early boot call chains are
75662306a36Sopenharmony_ciunique and obvious. Copying the full dmesg output verbatim, however,
75762306a36Sopenharmony_ciadds distracting information like timestamps, module lists, register and
75862306a36Sopenharmony_cistack dumps.
75962306a36Sopenharmony_ci
76062306a36Sopenharmony_ciTherefore, the most useful backtraces should distill the relevant
76162306a36Sopenharmony_ciinformation from the dump, which makes it easier to focus on the real
76262306a36Sopenharmony_ciissue. Here is an example of a well-trimmed backtrace::
76362306a36Sopenharmony_ci
76462306a36Sopenharmony_ci  unchecked MSR access error: WRMSR to 0xd51 (tried to write 0x0000000000000064)
76562306a36Sopenharmony_ci  at rIP: 0xffffffffae059994 (native_write_msr+0x4/0x20)
76662306a36Sopenharmony_ci  Call Trace:
76762306a36Sopenharmony_ci  mba_wrmsr
76862306a36Sopenharmony_ci  update_domains
76962306a36Sopenharmony_ci  rdtgroup_mkdir
77062306a36Sopenharmony_ci
77162306a36Sopenharmony_ci.. _explicit_in_reply_to:
77262306a36Sopenharmony_ci
77362306a36Sopenharmony_ciExplicit In-Reply-To headers
77462306a36Sopenharmony_ci----------------------------
77562306a36Sopenharmony_ci
77662306a36Sopenharmony_ciIt can be helpful to manually add In-Reply-To: headers to a patch
77762306a36Sopenharmony_ci(e.g., when using ``git send-email``) to associate the patch with
77862306a36Sopenharmony_ciprevious relevant discussion, e.g. to link a bug fix to the email with
77962306a36Sopenharmony_cithe bug report.  However, for a multi-patch series, it is generally
78062306a36Sopenharmony_cibest to avoid using In-Reply-To: to link to older versions of the
78162306a36Sopenharmony_ciseries.  This way multiple versions of the patch don't become an
78262306a36Sopenharmony_ciunmanageable forest of references in email clients.  If a link is
78362306a36Sopenharmony_cihelpful, you can use the https://lore.kernel.org/ redirector (e.g., in
78462306a36Sopenharmony_cithe cover email text) to link to an earlier version of the patch series.
78562306a36Sopenharmony_ci
78662306a36Sopenharmony_ci
78762306a36Sopenharmony_ciProviding base tree information
78862306a36Sopenharmony_ci-------------------------------
78962306a36Sopenharmony_ci
79062306a36Sopenharmony_ciWhen other developers receive your patches and start the review process,
79162306a36Sopenharmony_ciit is often useful for them to know where in the tree history they
79262306a36Sopenharmony_cishould place your work. This is particularly useful for automated CI
79362306a36Sopenharmony_ciprocesses that attempt to run a series of tests in order to establish
79462306a36Sopenharmony_cithe quality of your submission before the maintainer starts the review.
79562306a36Sopenharmony_ci
79662306a36Sopenharmony_ciIf you are using ``git format-patch`` to generate your patches, you can
79762306a36Sopenharmony_ciautomatically include the base tree information in your submission by
79862306a36Sopenharmony_ciusing the ``--base`` flag. The easiest and most convenient way to use
79962306a36Sopenharmony_cithis option is with topical branches::
80062306a36Sopenharmony_ci
80162306a36Sopenharmony_ci    $ git checkout -t -b my-topical-branch master
80262306a36Sopenharmony_ci    Branch 'my-topical-branch' set up to track local branch 'master'.
80362306a36Sopenharmony_ci    Switched to a new branch 'my-topical-branch'
80462306a36Sopenharmony_ci
80562306a36Sopenharmony_ci    [perform your edits and commits]
80662306a36Sopenharmony_ci
80762306a36Sopenharmony_ci    $ git format-patch --base=auto --cover-letter -o outgoing/ master
80862306a36Sopenharmony_ci    outgoing/0000-cover-letter.patch
80962306a36Sopenharmony_ci    outgoing/0001-First-Commit.patch
81062306a36Sopenharmony_ci    outgoing/...
81162306a36Sopenharmony_ci
81262306a36Sopenharmony_ciWhen you open ``outgoing/0000-cover-letter.patch`` for editing, you will
81362306a36Sopenharmony_cinotice that it will have the ``base-commit:`` trailer at the very
81462306a36Sopenharmony_cibottom, which provides the reviewer and the CI tools enough information
81562306a36Sopenharmony_cito properly perform ``git am`` without worrying about conflicts::
81662306a36Sopenharmony_ci
81762306a36Sopenharmony_ci    $ git checkout -b patch-review [base-commit-id]
81862306a36Sopenharmony_ci    Switched to a new branch 'patch-review'
81962306a36Sopenharmony_ci    $ git am patches.mbox
82062306a36Sopenharmony_ci    Applying: First Commit
82162306a36Sopenharmony_ci    Applying: ...
82262306a36Sopenharmony_ci
82362306a36Sopenharmony_ciPlease see ``man git-format-patch`` for more information about this
82462306a36Sopenharmony_cioption.
82562306a36Sopenharmony_ci
82662306a36Sopenharmony_ci.. note::
82762306a36Sopenharmony_ci
82862306a36Sopenharmony_ci    The ``--base`` feature was introduced in git version 2.9.0.
82962306a36Sopenharmony_ci
83062306a36Sopenharmony_ciIf you are not using git to format your patches, you can still include
83162306a36Sopenharmony_cithe same ``base-commit`` trailer to indicate the commit hash of the tree
83262306a36Sopenharmony_cion which your work is based. You should add it either in the cover
83362306a36Sopenharmony_ciletter or in the first patch of the series and it should be placed
83462306a36Sopenharmony_cieither below the ``---`` line or at the very bottom of all other
83562306a36Sopenharmony_cicontent, right before your email signature.
83662306a36Sopenharmony_ci
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_ciReferences
83962306a36Sopenharmony_ci----------
84062306a36Sopenharmony_ci
84162306a36Sopenharmony_ciAndrew Morton, "The perfect patch" (tpp).
84262306a36Sopenharmony_ci  <https://www.ozlabs.org/~akpm/stuff/tpp.txt>
84362306a36Sopenharmony_ci
84462306a36Sopenharmony_ciJeff Garzik, "Linux kernel patch submission format".
84562306a36Sopenharmony_ci  <https://web.archive.org/web/20180829112450/http://linux.yyz.us/patch-format.html>
84662306a36Sopenharmony_ci
84762306a36Sopenharmony_ciGreg Kroah-Hartman, "How to piss off a kernel subsystem maintainer".
84862306a36Sopenharmony_ci  <http://www.kroah.com/log/linux/maintainer.html>
84962306a36Sopenharmony_ci
85062306a36Sopenharmony_ci  <http://www.kroah.com/log/linux/maintainer-02.html>
85162306a36Sopenharmony_ci
85262306a36Sopenharmony_ci  <http://www.kroah.com/log/linux/maintainer-03.html>
85362306a36Sopenharmony_ci
85462306a36Sopenharmony_ci  <http://www.kroah.com/log/linux/maintainer-04.html>
85562306a36Sopenharmony_ci
85662306a36Sopenharmony_ci  <http://www.kroah.com/log/linux/maintainer-05.html>
85762306a36Sopenharmony_ci
85862306a36Sopenharmony_ci  <http://www.kroah.com/log/linux/maintainer-06.html>
85962306a36Sopenharmony_ci
86062306a36Sopenharmony_ciNO!!!! No more huge patch bombs to linux-kernel@vger.kernel.org people!
86162306a36Sopenharmony_ci  <https://lore.kernel.org/r/20050711.125305.08322243.davem@davemloft.net>
86262306a36Sopenharmony_ci
86362306a36Sopenharmony_ciKernel Documentation/process/coding-style.rst
86462306a36Sopenharmony_ci
86562306a36Sopenharmony_ciLinus Torvalds's mail on the canonical patch format:
86662306a36Sopenharmony_ci  <https://lore.kernel.org/r/Pine.LNX.4.58.0504071023190.28951@ppc970.osdl.org>
86762306a36Sopenharmony_ci
86862306a36Sopenharmony_ciAndi Kleen, "On submitting kernel patches"
86962306a36Sopenharmony_ci  Some strategies to get difficult or controversial changes in.
87062306a36Sopenharmony_ci
87162306a36Sopenharmony_ci  http://halobates.de/on-submitting-patches.pdf
872