xref: /linux/Documentation/process/maintainer-tip.rst (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
131c9d7c8SThomas Gleixner.. SPDX-License-Identifier: GPL-2.0
231c9d7c8SThomas Gleixner
331c9d7c8SThomas GleixnerThe tip tree handbook
431c9d7c8SThomas Gleixner=====================
531c9d7c8SThomas Gleixner
631c9d7c8SThomas GleixnerWhat is the tip tree?
731c9d7c8SThomas Gleixner---------------------
831c9d7c8SThomas Gleixner
931c9d7c8SThomas GleixnerThe tip tree is a collection of several subsystems and areas of
1031c9d7c8SThomas Gleixnerdevelopment. The tip tree is both a direct development tree and a
1131c9d7c8SThomas Gleixneraggregation tree for several sub-maintainer trees. The tip tree gitweb URL
1231c9d7c8SThomas Gleixneris: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
1331c9d7c8SThomas Gleixner
1431c9d7c8SThomas GleixnerThe tip tree contains the following subsystems:
1531c9d7c8SThomas Gleixner
1631c9d7c8SThomas Gleixner   - **x86 architecture**
1731c9d7c8SThomas Gleixner
1831c9d7c8SThomas Gleixner     The x86 architecture development takes place in the tip tree except
1931c9d7c8SThomas Gleixner     for the x86 KVM and XEN specific parts which are maintained in the
2031c9d7c8SThomas Gleixner     corresponding subsystems and routed directly to mainline from
2131c9d7c8SThomas Gleixner     there. It's still good practice to Cc the x86 maintainers on
2231c9d7c8SThomas Gleixner     x86-specific KVM and XEN patches.
2331c9d7c8SThomas Gleixner
2431c9d7c8SThomas Gleixner     Some x86 subsystems have their own maintainers in addition to the
2531c9d7c8SThomas Gleixner     overall x86 maintainers.  Please Cc the overall x86 maintainers on
2631c9d7c8SThomas Gleixner     patches touching files in arch/x86 even when they are not called out
2731c9d7c8SThomas Gleixner     by the MAINTAINER file.
2831c9d7c8SThomas Gleixner
2931c9d7c8SThomas Gleixner     Note, that ``x86@kernel.org`` is not a mailing list. It is merely a
3031c9d7c8SThomas Gleixner     mail alias which distributes mails to the x86 top-level maintainer
3131c9d7c8SThomas Gleixner     team. Please always Cc the Linux Kernel mailing list (LKML)
3231c9d7c8SThomas Gleixner     ``linux-kernel@vger.kernel.org``, otherwise your mail ends up only in
3331c9d7c8SThomas Gleixner     the private inboxes of the maintainers.
3431c9d7c8SThomas Gleixner
3531c9d7c8SThomas Gleixner   - **Scheduler**
3631c9d7c8SThomas Gleixner
3731c9d7c8SThomas Gleixner     Scheduler development takes place in the -tip tree, in the
3831c9d7c8SThomas Gleixner     sched/core branch - with occasional sub-topic trees for
3931c9d7c8SThomas Gleixner     work-in-progress patch-sets.
4031c9d7c8SThomas Gleixner
4131c9d7c8SThomas Gleixner   - **Locking and atomics**
4231c9d7c8SThomas Gleixner
4331c9d7c8SThomas Gleixner     Locking development (including atomics and other synchronization
4431c9d7c8SThomas Gleixner     primitives that are connected to locking) takes place in the -tip
4531c9d7c8SThomas Gleixner     tree, in the locking/core branch - with occasional sub-topic trees
4631c9d7c8SThomas Gleixner     for work-in-progress patch-sets.
4731c9d7c8SThomas Gleixner
4831c9d7c8SThomas Gleixner   - **Generic interrupt subsystem and interrupt chip drivers**:
4931c9d7c8SThomas Gleixner
5031c9d7c8SThomas Gleixner     - interrupt core development happens in the irq/core branch
5131c9d7c8SThomas Gleixner
5231c9d7c8SThomas Gleixner     - interrupt chip driver development also happens in the irq/core
5331c9d7c8SThomas Gleixner       branch, but the patches are usually applied in a separate maintainer
5431c9d7c8SThomas Gleixner       tree and then aggregated into irq/core
5531c9d7c8SThomas Gleixner
5631c9d7c8SThomas Gleixner   - **Time, timers, timekeeping, NOHZ and related chip drivers**:
5731c9d7c8SThomas Gleixner
5831c9d7c8SThomas Gleixner     - timekeeping, clocksource core, NTP and alarmtimer development
5931c9d7c8SThomas Gleixner       happens in the timers/core branch, but patches are usually applied in
6031c9d7c8SThomas Gleixner       a separate maintainer tree and then aggregated into timers/core
6131c9d7c8SThomas Gleixner
6231c9d7c8SThomas Gleixner     - clocksource/event driver development happens in the timers/core
6331c9d7c8SThomas Gleixner       branch, but patches are mostly applied in a separate maintainer tree
6431c9d7c8SThomas Gleixner       and then aggregated into timers/core
6531c9d7c8SThomas Gleixner
6631c9d7c8SThomas Gleixner   - **Performance counters core, architecture support and tooling**:
6731c9d7c8SThomas Gleixner
6831c9d7c8SThomas Gleixner     - perf core and architecture support development happens in the
6931c9d7c8SThomas Gleixner       perf/core branch
7031c9d7c8SThomas Gleixner
7131c9d7c8SThomas Gleixner     - perf tooling development happens in the perf tools maintainer
7231c9d7c8SThomas Gleixner       tree and is aggregated into the tip tree.
7331c9d7c8SThomas Gleixner
7431c9d7c8SThomas Gleixner   - **CPU hotplug core**
7531c9d7c8SThomas Gleixner
7631c9d7c8SThomas Gleixner   - **RAS core**
7731c9d7c8SThomas Gleixner
7831c9d7c8SThomas Gleixner     Mostly x86-specific RAS patches are collected in the tip ras/core
7931c9d7c8SThomas Gleixner     branch.
8031c9d7c8SThomas Gleixner
8131c9d7c8SThomas Gleixner   - **EFI core**
8231c9d7c8SThomas Gleixner
8331c9d7c8SThomas Gleixner     EFI development in the efi git tree. The collected patches are
8431c9d7c8SThomas Gleixner     aggregated in the tip efi/core branch.
8531c9d7c8SThomas Gleixner
8631c9d7c8SThomas Gleixner   - **RCU**
8731c9d7c8SThomas Gleixner
8831c9d7c8SThomas Gleixner     RCU development happens in the linux-rcu tree. The resulting changes
8931c9d7c8SThomas Gleixner     are aggregated into the tip core/rcu branch.
9031c9d7c8SThomas Gleixner
9131c9d7c8SThomas Gleixner   - **Various core code components**:
9231c9d7c8SThomas Gleixner
9331c9d7c8SThomas Gleixner       - debugobjects
9431c9d7c8SThomas Gleixner
9531c9d7c8SThomas Gleixner       - objtool
9631c9d7c8SThomas Gleixner
9731c9d7c8SThomas Gleixner       - random bits and pieces
9831c9d7c8SThomas Gleixner
9931c9d7c8SThomas Gleixner
10031c9d7c8SThomas GleixnerPatch submission notes
10131c9d7c8SThomas Gleixner----------------------
10231c9d7c8SThomas Gleixner
10331c9d7c8SThomas GleixnerSelecting the tree/branch
10431c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^
10531c9d7c8SThomas Gleixner
10631c9d7c8SThomas GleixnerIn general, development against the head of the tip tree master branch is
10731c9d7c8SThomas Gleixnerfine, but for the subsystems which are maintained separately, have their
10831c9d7c8SThomas Gleixnerown git tree and are only aggregated into the tip tree, development should
10931c9d7c8SThomas Gleixnertake place against the relevant subsystem tree or branch.
11031c9d7c8SThomas Gleixner
11131c9d7c8SThomas GleixnerBug fixes which target mainline should always be applicable against the
11231c9d7c8SThomas Gleixnermainline kernel tree. Potential conflicts against changes which are already
11331c9d7c8SThomas Gleixnerqueued in the tip tree are handled by the maintainers.
11431c9d7c8SThomas Gleixner
11531c9d7c8SThomas GleixnerPatch subject
11631c9d7c8SThomas Gleixner^^^^^^^^^^^^^
11731c9d7c8SThomas Gleixner
11831c9d7c8SThomas GleixnerThe tip tree preferred format for patch subject prefixes is
11931c9d7c8SThomas Gleixner'subsys/component:', e.g. 'x86/apic:', 'x86/mm/fault:', 'sched/fair:',
12031c9d7c8SThomas Gleixner'genirq/core:'. Please do not use file names or complete file paths as
12131c9d7c8SThomas Gleixnerprefix. 'git log path/to/file' should give you a reasonable hint in most
12231c9d7c8SThomas Gleixnercases.
12331c9d7c8SThomas Gleixner
12431c9d7c8SThomas GleixnerThe condensed patch description in the subject line should start with a
12531c9d7c8SThomas Gleixneruppercase letter and should be written in imperative tone.
12631c9d7c8SThomas Gleixner
12731c9d7c8SThomas Gleixner
12831c9d7c8SThomas GleixnerChangelog
12931c9d7c8SThomas Gleixner^^^^^^^^^
13031c9d7c8SThomas Gleixner
1310c4ff6f6SBagas SanjayaThe general rules about changelogs in the :ref:`Submitting patches guide
1320c4ff6f6SBagas Sanjaya<describe_changes>`, apply.
13331c9d7c8SThomas Gleixner
13431c9d7c8SThomas GleixnerThe tip tree maintainers set value on following these rules, especially on
13531c9d7c8SThomas Gleixnerthe request to write changelogs in imperative mood and not impersonating
13631c9d7c8SThomas Gleixnercode or the execution of it. This is not just a whim of the
13731c9d7c8SThomas Gleixnermaintainers. Changelogs written in abstract words are more precise and
13831c9d7c8SThomas Gleixnertend to be less confusing than those written in the form of novels.
13931c9d7c8SThomas Gleixner
14031c9d7c8SThomas GleixnerIt's also useful to structure the changelog into several paragraphs and not
14131c9d7c8SThomas Gleixnerlump everything together into a single one. A good structure is to explain
14231c9d7c8SThomas Gleixnerthe context, the problem and the solution in separate paragraphs and this
14331c9d7c8SThomas Gleixnerorder.
14431c9d7c8SThomas Gleixner
14531c9d7c8SThomas GleixnerExamples for illustration:
14631c9d7c8SThomas Gleixner
14731c9d7c8SThomas Gleixner  Example 1::
14831c9d7c8SThomas Gleixner
14931c9d7c8SThomas Gleixner    x86/intel_rdt/mbm: Fix MBM overflow handler during hot cpu
15031c9d7c8SThomas Gleixner
15131c9d7c8SThomas Gleixner    When a CPU is dying, we cancel the worker and schedule a new worker on a
15231c9d7c8SThomas Gleixner    different CPU on the same domain. But if the timer is already about to
15331c9d7c8SThomas Gleixner    expire (say 0.99s) then we essentially double the interval.
15431c9d7c8SThomas Gleixner
15531c9d7c8SThomas Gleixner    We modify the hot cpu handling to cancel the delayed work on the dying
15631c9d7c8SThomas Gleixner    cpu and run the worker immediately on a different cpu in same domain. We
15731c9d7c8SThomas Gleixner    do not flush the worker because the MBM overflow worker reschedules the
15831c9d7c8SThomas Gleixner    worker on same CPU and scans the domain->cpu_mask to get the domain
15931c9d7c8SThomas Gleixner    pointer.
16031c9d7c8SThomas Gleixner
16131c9d7c8SThomas Gleixner  Improved version::
16231c9d7c8SThomas Gleixner
16331c9d7c8SThomas Gleixner    x86/intel_rdt/mbm: Fix MBM overflow handler during CPU hotplug
16431c9d7c8SThomas Gleixner
16531c9d7c8SThomas Gleixner    When a CPU is dying, the overflow worker is canceled and rescheduled on a
16631c9d7c8SThomas Gleixner    different CPU in the same domain. But if the timer is already about to
16731c9d7c8SThomas Gleixner    expire this essentially doubles the interval which might result in a non
16831c9d7c8SThomas Gleixner    detected overflow.
16931c9d7c8SThomas Gleixner
17031c9d7c8SThomas Gleixner    Cancel the overflow worker and reschedule it immediately on a different CPU
17131c9d7c8SThomas Gleixner    in the same domain. The work could be flushed as well, but that would
17231c9d7c8SThomas Gleixner    reschedule it on the same CPU.
17331c9d7c8SThomas Gleixner
17431c9d7c8SThomas Gleixner  Example 2::
17531c9d7c8SThomas Gleixner
17631c9d7c8SThomas Gleixner    time: POSIX CPU timers: Ensure that variable is initialized
17731c9d7c8SThomas Gleixner
17831c9d7c8SThomas Gleixner    If cpu_timer_sample_group returns -EINVAL, it will not have written into
17931c9d7c8SThomas Gleixner    *sample. Checking for cpu_timer_sample_group's return value precludes the
18031c9d7c8SThomas Gleixner    potential use of an uninitialized value of now in the following block.
18131c9d7c8SThomas Gleixner    Given an invalid clock_idx, the previous code could otherwise overwrite
18231c9d7c8SThomas Gleixner    *oldval in an undefined manner. This is now prevented. We also exploit
18331c9d7c8SThomas Gleixner    short-circuiting of && to sample the timer only if the result will
18431c9d7c8SThomas Gleixner    actually be used to update *oldval.
18531c9d7c8SThomas Gleixner
18631c9d7c8SThomas Gleixner  Improved version::
18731c9d7c8SThomas Gleixner
18831c9d7c8SThomas Gleixner    posix-cpu-timers: Make set_process_cpu_timer() more robust
18931c9d7c8SThomas Gleixner
19031c9d7c8SThomas Gleixner    Because the return value of cpu_timer_sample_group() is not checked,
19131c9d7c8SThomas Gleixner    compilers and static checkers can legitimately warn about a potential use
19231c9d7c8SThomas Gleixner    of the uninitialized variable 'now'. This is not a runtime issue as all
19331c9d7c8SThomas Gleixner    call sites hand in valid clock ids.
19431c9d7c8SThomas Gleixner
19531c9d7c8SThomas Gleixner    Also cpu_timer_sample_group() is invoked unconditionally even when the
19631c9d7c8SThomas Gleixner    result is not used because *oldval is NULL.
19731c9d7c8SThomas Gleixner
19831c9d7c8SThomas Gleixner    Make the invocation conditional and check the return value.
19931c9d7c8SThomas Gleixner
20031c9d7c8SThomas Gleixner  Example 3::
20131c9d7c8SThomas Gleixner
20231c9d7c8SThomas Gleixner    The entity can also be used for other purposes.
20331c9d7c8SThomas Gleixner
20431c9d7c8SThomas Gleixner    Let's rename it to be more generic.
20531c9d7c8SThomas Gleixner
20631c9d7c8SThomas Gleixner  Improved version::
20731c9d7c8SThomas Gleixner
20831c9d7c8SThomas Gleixner    The entity can also be used for other purposes.
20931c9d7c8SThomas Gleixner
21031c9d7c8SThomas Gleixner    Rename it to be more generic.
21131c9d7c8SThomas Gleixner
21231c9d7c8SThomas Gleixner
21331c9d7c8SThomas GleixnerFor complex scenarios, especially race conditions and memory ordering
21431c9d7c8SThomas Gleixnerissues, it is valuable to depict the scenario with a table which shows
21531c9d7c8SThomas Gleixnerthe parallelism and the temporal order of events. Here is an example::
21631c9d7c8SThomas Gleixner
21731c9d7c8SThomas Gleixner    CPU0                            CPU1
21831c9d7c8SThomas Gleixner    free_irq(X)                     interrupt X
21931c9d7c8SThomas Gleixner                                    spin_lock(desc->lock)
22031c9d7c8SThomas Gleixner                                    wake irq thread()
22131c9d7c8SThomas Gleixner                                    spin_unlock(desc->lock)
22231c9d7c8SThomas Gleixner    spin_lock(desc->lock)
22331c9d7c8SThomas Gleixner    remove action()
22431c9d7c8SThomas Gleixner    shutdown_irq()
22531c9d7c8SThomas Gleixner    release_resources()             thread_handler()
22631c9d7c8SThomas Gleixner    spin_unlock(desc->lock)           access released resources.
22731c9d7c8SThomas Gleixner                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
22831c9d7c8SThomas Gleixner    synchronize_irq()
22931c9d7c8SThomas Gleixner
23031c9d7c8SThomas GleixnerLockdep provides similar useful output to depict a possible deadlock
23131c9d7c8SThomas Gleixnerscenario::
23231c9d7c8SThomas Gleixner
23331c9d7c8SThomas Gleixner    CPU0                                    CPU1
23431c9d7c8SThomas Gleixner    rtmutex_lock(&rcu->rt_mutex)
23531c9d7c8SThomas Gleixner      spin_lock(&rcu->rt_mutex.wait_lock)
23631c9d7c8SThomas Gleixner                                            local_irq_disable()
23731c9d7c8SThomas Gleixner                                            spin_lock(&timer->it_lock)
23831c9d7c8SThomas Gleixner                                            spin_lock(&rcu->mutex.wait_lock)
23931c9d7c8SThomas Gleixner    --> Interrupt
24031c9d7c8SThomas Gleixner        spin_lock(&timer->it_lock)
24131c9d7c8SThomas Gleixner
24231c9d7c8SThomas Gleixner
24331c9d7c8SThomas GleixnerFunction references in changelogs
24431c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24531c9d7c8SThomas Gleixner
24631c9d7c8SThomas GleixnerWhen a function is mentioned in the changelog, either the text body or the
24731c9d7c8SThomas Gleixnersubject line, please use the format 'function_name()'. Omitting the
24831c9d7c8SThomas Gleixnerbrackets after the function name can be ambiguous::
24931c9d7c8SThomas Gleixner
25031c9d7c8SThomas Gleixner  Subject: subsys/component: Make reservation_count static
25131c9d7c8SThomas Gleixner
25231c9d7c8SThomas Gleixner  reservation_count is only used in reservation_stats. Make it static.
25331c9d7c8SThomas Gleixner
25431c9d7c8SThomas GleixnerThe variant with brackets is more precise::
25531c9d7c8SThomas Gleixner
25631c9d7c8SThomas Gleixner  Subject: subsys/component: Make reservation_count() static
25731c9d7c8SThomas Gleixner
25831c9d7c8SThomas Gleixner  reservation_count() is only called from reservation_stats(). Make it
25931c9d7c8SThomas Gleixner  static.
26031c9d7c8SThomas Gleixner
26131c9d7c8SThomas Gleixner
26231c9d7c8SThomas GleixnerBacktraces in changelogs
26331c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^
26431c9d7c8SThomas Gleixner
26531c9d7c8SThomas GleixnerSee :ref:`backtraces`.
26631c9d7c8SThomas Gleixner
26731c9d7c8SThomas GleixnerOrdering of commit tags
26831c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^
26931c9d7c8SThomas Gleixner
27031c9d7c8SThomas GleixnerTo have a uniform view of the commit tags, the tip maintainers use the
27131c9d7c8SThomas Gleixnerfollowing tag ordering scheme:
27231c9d7c8SThomas Gleixner
27331c9d7c8SThomas Gleixner - Fixes: 12char-SHA1 ("sub/sys: Original subject line")
27431c9d7c8SThomas Gleixner
27531c9d7c8SThomas Gleixner   A Fixes tag should be added even for changes which do not need to be
27631c9d7c8SThomas Gleixner   backported to stable kernels, i.e. when addressing a recently introduced
27731c9d7c8SThomas Gleixner   issue which only affects tip or the current head of mainline. These tags
27831c9d7c8SThomas Gleixner   are helpful to identify the original commit and are much more valuable
27931c9d7c8SThomas Gleixner   than prominently mentioning the commit which introduced a problem in the
28031c9d7c8SThomas Gleixner   text of the changelog itself because they can be automatically
28131c9d7c8SThomas Gleixner   extracted.
28231c9d7c8SThomas Gleixner
28331c9d7c8SThomas Gleixner   The following example illustrates the difference::
28431c9d7c8SThomas Gleixner
28531c9d7c8SThomas Gleixner     Commit
28631c9d7c8SThomas Gleixner
28731c9d7c8SThomas Gleixner       abcdef012345678 ("x86/xxx: Replace foo with bar")
28831c9d7c8SThomas Gleixner
28931c9d7c8SThomas Gleixner     left an unused instance of variable foo around. Remove it.
29031c9d7c8SThomas Gleixner
29131c9d7c8SThomas Gleixner     Signed-off-by: J.Dev <j.dev@mail>
29231c9d7c8SThomas Gleixner
29331c9d7c8SThomas Gleixner   Please say instead::
29431c9d7c8SThomas Gleixner
29531c9d7c8SThomas Gleixner     The recent replacement of foo with bar left an unused instance of
29631c9d7c8SThomas Gleixner     variable foo around. Remove it.
29731c9d7c8SThomas Gleixner
29831c9d7c8SThomas Gleixner     Fixes: abcdef012345678 ("x86/xxx: Replace foo with bar")
29931c9d7c8SThomas Gleixner     Signed-off-by: J.Dev <j.dev@mail>
30031c9d7c8SThomas Gleixner
30131c9d7c8SThomas Gleixner   The latter puts the information about the patch into the focus and
30231c9d7c8SThomas Gleixner   amends it with the reference to the commit which introduced the issue
30331c9d7c8SThomas Gleixner   rather than putting the focus on the original commit in the first place.
30431c9d7c8SThomas Gleixner
30531c9d7c8SThomas Gleixner - Reported-by: ``Reporter <reporter@mail>``
30631c9d7c8SThomas Gleixner
307b37bf5efSBorislav Petkov (AMD) - Closes: ``URL or Message-ID of the bug report this is fixing``
308b37bf5efSBorislav Petkov (AMD)
30931c9d7c8SThomas Gleixner - Originally-by: ``Original author <original-author@mail>``
31031c9d7c8SThomas Gleixner
31131c9d7c8SThomas Gleixner - Suggested-by: ``Suggester <suggester@mail>``
31231c9d7c8SThomas Gleixner
31331c9d7c8SThomas Gleixner - Co-developed-by: ``Co-author <co-author@mail>``
31431c9d7c8SThomas Gleixner
315b37bf5efSBorislav Petkov (AMD)   Signed-off-by: ``Co-author <co-author@mail>``
31631c9d7c8SThomas Gleixner
31731c9d7c8SThomas Gleixner   Note, that Co-developed-by and Signed-off-by of the co-author(s) must
31831c9d7c8SThomas Gleixner   come in pairs.
31931c9d7c8SThomas Gleixner
32031c9d7c8SThomas Gleixner - Signed-off-by: ``Author <author@mail>``
32131c9d7c8SThomas Gleixner
32231c9d7c8SThomas Gleixner   The first Signed-off-by (SOB) after the last Co-developed-by/SOB pair is the
32331c9d7c8SThomas Gleixner   author SOB, i.e. the person flagged as author by git.
32431c9d7c8SThomas Gleixner
32531c9d7c8SThomas Gleixner - Signed-off-by: ``Patch handler <handler@mail>``
32631c9d7c8SThomas Gleixner
32731c9d7c8SThomas Gleixner   SOBs after the author SOB are from people handling and transporting
32831c9d7c8SThomas Gleixner   the patch, but were not involved in development. SOB chains should
32931c9d7c8SThomas Gleixner   reflect the **real** route a patch took as it was propagated to us,
33031c9d7c8SThomas Gleixner   with the first SOB entry signalling primary authorship of a single
33131c9d7c8SThomas Gleixner   author. Acks should be given as Acked-by lines and review approvals
33231c9d7c8SThomas Gleixner   as Reviewed-by lines.
33331c9d7c8SThomas Gleixner
33431c9d7c8SThomas Gleixner   If the handler made modifications to the patch or the changelog, then
33531c9d7c8SThomas Gleixner   this should be mentioned **after** the changelog text and **above**
33631c9d7c8SThomas Gleixner   all commit tags in the following format::
33731c9d7c8SThomas Gleixner
33831c9d7c8SThomas Gleixner     ... changelog text ends.
33931c9d7c8SThomas Gleixner
34031c9d7c8SThomas Gleixner     [ handler: Replaced foo by bar and updated changelog ]
34131c9d7c8SThomas Gleixner
34231c9d7c8SThomas Gleixner     First-tag: .....
34331c9d7c8SThomas Gleixner
34431c9d7c8SThomas Gleixner   Note the two empty new lines which separate the changelog text and the
34531c9d7c8SThomas Gleixner   commit tags from that notice.
34631c9d7c8SThomas Gleixner
34731c9d7c8SThomas Gleixner   If a patch is sent to the mailing list by a handler then the author has
34831c9d7c8SThomas Gleixner   to be noted in the first line of the changelog with::
34931c9d7c8SThomas Gleixner
35031c9d7c8SThomas Gleixner     From: Author <author@mail>
35131c9d7c8SThomas Gleixner
35231c9d7c8SThomas Gleixner     Changelog text starts here....
35331c9d7c8SThomas Gleixner
35431c9d7c8SThomas Gleixner   so the authorship is preserved. The 'From:' line has to be followed
35531c9d7c8SThomas Gleixner   by a empty newline. If that 'From:' line is missing, then the patch
35631c9d7c8SThomas Gleixner   would be attributed to the person who sent (transported, handled) it.
35731c9d7c8SThomas Gleixner   The 'From:' line is automatically removed when the patch is applied
35831c9d7c8SThomas Gleixner   and does not show up in the final git changelog. It merely affects
35931c9d7c8SThomas Gleixner   the authorship information of the resulting Git commit.
36031c9d7c8SThomas Gleixner
36131c9d7c8SThomas Gleixner - Tested-by: ``Tester <tester@mail>``
36231c9d7c8SThomas Gleixner
36331c9d7c8SThomas Gleixner - Reviewed-by: ``Reviewer <reviewer@mail>``
36431c9d7c8SThomas Gleixner
36531c9d7c8SThomas Gleixner - Acked-by: ``Acker <acker@mail>``
36631c9d7c8SThomas Gleixner
36731c9d7c8SThomas Gleixner - Cc: ``cc-ed-person <person@mail>``
36831c9d7c8SThomas Gleixner
36931c9d7c8SThomas Gleixner   If the patch should be backported to stable, then please add a '``Cc:
37031c9d7c8SThomas Gleixner   stable@vger.kernel.org``' tag, but do not Cc stable when sending your
37131c9d7c8SThomas Gleixner   mail.
37231c9d7c8SThomas Gleixner
37331c9d7c8SThomas Gleixner - Link: ``https://link/to/information``
37431c9d7c8SThomas Gleixner
375*127734e2SKonstantin Ryabitsev   For referring to an email posted to the kernel mailing lists, please
376*127734e2SKonstantin Ryabitsev   use the lore.kernel.org redirector URL::
37731c9d7c8SThomas Gleixner
378*127734e2SKonstantin Ryabitsev     Link: https://lore.kernel.org/email-message-id@here
37931c9d7c8SThomas Gleixner
380*127734e2SKonstantin Ryabitsev   This URL should be used when referring to relevant mailing list
381*127734e2SKonstantin Ryabitsev   topics, related patch sets, or other notable discussion threads.
382*127734e2SKonstantin Ryabitsev   A convenient way to associate ``Link:`` trailers with the commit
383*127734e2SKonstantin Ryabitsev   message is to use markdown-like bracketed notation, for example::
38431c9d7c8SThomas Gleixner
385*127734e2SKonstantin Ryabitsev     A similar approach was attempted before as part of a different
386*127734e2SKonstantin Ryabitsev     effort [1], but the initial implementation caused too many
387*127734e2SKonstantin Ryabitsev     regressions [2], so it was backed out and reimplemented.
388*127734e2SKonstantin Ryabitsev
389*127734e2SKonstantin Ryabitsev     Link: https://lore.kernel.org/some-msgid@here # [1]
390*127734e2SKonstantin Ryabitsev     Link: https://bugzilla.example.org/bug/12345  # [2]
391*127734e2SKonstantin Ryabitsev
392*127734e2SKonstantin Ryabitsev   You can also use ``Link:`` trailers to indicate the origin of the
393*127734e2SKonstantin Ryabitsev   patch when applying it to your git tree. In that case, please use the
394*127734e2SKonstantin Ryabitsev   dedicated ``patch.msgid.link`` domain instead of ``lore.kernel.org``.
395*127734e2SKonstantin Ryabitsev   This practice makes it possible for automated tooling to identify
396*127734e2SKonstantin Ryabitsev   which link to use to retrieve the original patch submission. For
397*127734e2SKonstantin Ryabitsev   example::
398*127734e2SKonstantin Ryabitsev
399*127734e2SKonstantin Ryabitsev     Link: https://patch.msgid.link/patch-source-message-id@here
40031c9d7c8SThomas Gleixner
40131c9d7c8SThomas GleixnerPlease do not use combined tags, e.g. ``Reported-and-tested-by``, as
40231c9d7c8SThomas Gleixnerthey just complicate automated extraction of tags.
40331c9d7c8SThomas Gleixner
40431c9d7c8SThomas Gleixner
40531c9d7c8SThomas GleixnerLinks to documentation
40631c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^
40731c9d7c8SThomas Gleixner
40831c9d7c8SThomas GleixnerProviding links to documentation in the changelog is a great help to later
40931c9d7c8SThomas Gleixnerdebugging and analysis.  Unfortunately, URLs often break very quickly
41031c9d7c8SThomas Gleixnerbecause companies restructure their websites frequently.  Non-'volatile'
41131c9d7c8SThomas Gleixnerexceptions include the Intel SDM and the AMD APM.
41231c9d7c8SThomas Gleixner
41331c9d7c8SThomas GleixnerTherefore, for 'volatile' documents, please create an entry in the kernel
41431c9d7c8SThomas Gleixnerbugzilla https://bugzilla.kernel.org and attach a copy of these documents
41531c9d7c8SThomas Gleixnerto the bugzilla entry. Finally, provide the URL of the bugzilla entry in
41631c9d7c8SThomas Gleixnerthe changelog.
41731c9d7c8SThomas Gleixner
41831c9d7c8SThomas GleixnerPatch resend or reminders
41931c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^
42031c9d7c8SThomas Gleixner
42131c9d7c8SThomas GleixnerSee :ref:`resend_reminders`.
42231c9d7c8SThomas Gleixner
42331c9d7c8SThomas GleixnerMerge window
42431c9d7c8SThomas Gleixner^^^^^^^^^^^^
42531c9d7c8SThomas Gleixner
426bdc42c8bSDave HansenPlease do not expect patches to be reviewed or merged by tip
427bdc42c8bSDave Hansenmaintainers around or during the merge window.  The trees are closed
428bdc42c8bSDave Hansento all but urgent fixes during this time.  They reopen once the merge
429bdc42c8bSDave Hansenwindow closes and a new -rc1 kernel has been released.
430bdc42c8bSDave Hansen
431bdc42c8bSDave HansenLarge series should be submitted in mergeable state *at* *least* a week
432bdc42c8bSDave Hansenbefore the merge window opens.  Exceptions are made for bug fixes and
433bdc42c8bSDave Hansen*sometimes* for small standalone drivers for new hardware or minimally
434bdc42c8bSDave Hanseninvasive patches for hardware enablement.
43531c9d7c8SThomas Gleixner
43631c9d7c8SThomas GleixnerDuring the merge window, the maintainers instead focus on following the
43731c9d7c8SThomas Gleixnerupstream changes, fixing merge window fallout, collecting bug fixes, and
43831c9d7c8SThomas Gleixnerallowing themselves a breath. Please respect that.
43931c9d7c8SThomas Gleixner
4404f119255SChristian KujauSo called _urgent_ branches will be merged into mainline during the
4414f119255SChristian Kujaustabilization phase of each release.
4424f119255SChristian Kujau
44331c9d7c8SThomas Gleixner
44431c9d7c8SThomas GleixnerGit
44531c9d7c8SThomas Gleixner^^^
44631c9d7c8SThomas Gleixner
44731c9d7c8SThomas GleixnerThe tip maintainers accept git pull requests from maintainers who provide
44831c9d7c8SThomas Gleixnersubsystem changes for aggregation in the tip tree.
44931c9d7c8SThomas Gleixner
45031c9d7c8SThomas GleixnerPull requests for new patch submissions are usually not accepted and do not
45131c9d7c8SThomas Gleixnerreplace proper patch submission to the mailing list. The main reason for
45231c9d7c8SThomas Gleixnerthis is that the review workflow is email based.
45331c9d7c8SThomas Gleixner
45431c9d7c8SThomas GleixnerIf you submit a larger patch series it is helpful to provide a git branch
45531c9d7c8SThomas Gleixnerin a private repository which allows interested people to easily pull the
45631c9d7c8SThomas Gleixnerseries for testing. The usual way to offer this is a git URL in the cover
45731c9d7c8SThomas Gleixnerletter of the patch series.
45831c9d7c8SThomas Gleixner
4599b5a7f4aSDave HansenTesting
4609b5a7f4aSDave Hansen^^^^^^^
4619b5a7f4aSDave Hansen
4629b5a7f4aSDave HansenCode should be tested before submitting to the tip maintainers.  Anything
4639b5a7f4aSDave Hansenother than minor changes should be built, booted and tested with
4649b5a7f4aSDave Hansencomprehensive (and heavyweight) kernel debugging options enabled.
4659b5a7f4aSDave Hansen
4669b5a7f4aSDave HansenThese debugging options can be found in kernel/configs/x86_debug.config
4679b5a7f4aSDave Hansenand can be added to an existing kernel config by running:
4689b5a7f4aSDave Hansen
4699b5a7f4aSDave Hansen	make x86_debug.config
4709b5a7f4aSDave Hansen
4719b5a7f4aSDave HansenSome of these options are x86-specific and can be left out when testing
4729b5a7f4aSDave Hansenon other architectures.
47331c9d7c8SThomas Gleixner
474b7dac767SSean Christopherson.. _maintainer-tip-coding-style:
475b7dac767SSean Christopherson
47631c9d7c8SThomas GleixnerCoding style notes
47731c9d7c8SThomas Gleixner------------------
47831c9d7c8SThomas Gleixner
47931c9d7c8SThomas GleixnerComment style
48031c9d7c8SThomas Gleixner^^^^^^^^^^^^^
48131c9d7c8SThomas Gleixner
48231c9d7c8SThomas GleixnerSentences in comments start with an uppercase letter.
48331c9d7c8SThomas Gleixner
48431c9d7c8SThomas GleixnerSingle line comments::
48531c9d7c8SThomas Gleixner
48631c9d7c8SThomas Gleixner	/* This is a single line comment */
48731c9d7c8SThomas Gleixner
48831c9d7c8SThomas GleixnerMulti-line comments::
48931c9d7c8SThomas Gleixner
49031c9d7c8SThomas Gleixner	/*
49131c9d7c8SThomas Gleixner	 * This is a properly formatted
49231c9d7c8SThomas Gleixner	 * multi-line comment.
49331c9d7c8SThomas Gleixner	 *
49431c9d7c8SThomas Gleixner	 * Larger multi-line comments should be split into paragraphs.
49531c9d7c8SThomas Gleixner	 */
49631c9d7c8SThomas Gleixner
4977dd0a21cSBorislav Petkov (AMD)No tail comments (see below):
49831c9d7c8SThomas Gleixner
49931c9d7c8SThomas Gleixner  Please refrain from using tail comments. Tail comments disturb the
50031c9d7c8SThomas Gleixner  reading flow in almost all contexts, but especially in code::
50131c9d7c8SThomas Gleixner
50231c9d7c8SThomas Gleixner	if (somecondition_is_true) /* Don't put a comment here */
50331c9d7c8SThomas Gleixner		dostuff(); /* Neither here */
50431c9d7c8SThomas Gleixner
50531c9d7c8SThomas Gleixner	seed = MAGIC_CONSTANT; /* Nor here */
50631c9d7c8SThomas Gleixner
50731c9d7c8SThomas Gleixner  Use freestanding comments instead::
50831c9d7c8SThomas Gleixner
50931c9d7c8SThomas Gleixner	/* This condition is not obvious without a comment */
51031c9d7c8SThomas Gleixner	if (somecondition_is_true) {
51131c9d7c8SThomas Gleixner		/* This really needs to be documented */
51231c9d7c8SThomas Gleixner		dostuff();
51331c9d7c8SThomas Gleixner	}
51431c9d7c8SThomas Gleixner
51531c9d7c8SThomas Gleixner	/* This magic initialization needs a comment. Maybe not? */
51631c9d7c8SThomas Gleixner	seed = MAGIC_CONSTANT;
51731c9d7c8SThomas Gleixner
5187dd0a21cSBorislav Petkov (AMD)  Use C++ style, tail comments when documenting structs in headers to
5197dd0a21cSBorislav Petkov (AMD)  achieve a more compact layout and better readability::
5207dd0a21cSBorislav Petkov (AMD)
5217dd0a21cSBorislav Petkov (AMD)        // eax
5227dd0a21cSBorislav Petkov (AMD)        u32     x2apic_shift    :  5, // Number of bits to shift APIC ID right
5237dd0a21cSBorislav Petkov (AMD)                                      // for the topology ID at the next level
5247dd0a21cSBorislav Petkov (AMD)                                : 27; // Reserved
5257dd0a21cSBorislav Petkov (AMD)        // ebx
5267dd0a21cSBorislav Petkov (AMD)        u32     num_processors  : 16, // Number of processors at current level
5277dd0a21cSBorislav Petkov (AMD)                                : 16; // Reserved
5287dd0a21cSBorislav Petkov (AMD)
5297dd0a21cSBorislav Petkov (AMD)  versus::
5307dd0a21cSBorislav Petkov (AMD)
5317dd0a21cSBorislav Petkov (AMD)	/* eax */
5327dd0a21cSBorislav Petkov (AMD)	        /*
5337dd0a21cSBorislav Petkov (AMD)	         * Number of bits to shift APIC ID right for the topology ID
5347dd0a21cSBorislav Petkov (AMD)	         * at the next level
5357dd0a21cSBorislav Petkov (AMD)	         */
5367dd0a21cSBorislav Petkov (AMD)         u32     x2apic_shift    :  5,
5377dd0a21cSBorislav Petkov (AMD)		 /* Reserved */
5387dd0a21cSBorislav Petkov (AMD)				 : 27;
5397dd0a21cSBorislav Petkov (AMD)
5407dd0a21cSBorislav Petkov (AMD)	/* ebx */
5417dd0a21cSBorislav Petkov (AMD)		/* Number of processors at current level */
5427dd0a21cSBorislav Petkov (AMD)	u32     num_processors  : 16,
5437dd0a21cSBorislav Petkov (AMD)		/* Reserved */
5447dd0a21cSBorislav Petkov (AMD)				: 16;
5457dd0a21cSBorislav Petkov (AMD)
54631c9d7c8SThomas GleixnerComment the important things:
54731c9d7c8SThomas Gleixner
54831c9d7c8SThomas Gleixner  Comments should be added where the operation is not obvious. Documenting
54931c9d7c8SThomas Gleixner  the obvious is just a distraction::
55031c9d7c8SThomas Gleixner
55131c9d7c8SThomas Gleixner	/* Decrement refcount and check for zero */
55231c9d7c8SThomas Gleixner	if (refcount_dec_and_test(&p->refcnt)) {
55331c9d7c8SThomas Gleixner		do;
55431c9d7c8SThomas Gleixner		lots;
55531c9d7c8SThomas Gleixner		of;
55631c9d7c8SThomas Gleixner		magic;
55731c9d7c8SThomas Gleixner		things;
55831c9d7c8SThomas Gleixner	}
55931c9d7c8SThomas Gleixner
56031c9d7c8SThomas Gleixner  Instead, comments should explain the non-obvious details and document
56131c9d7c8SThomas Gleixner  constraints::
56231c9d7c8SThomas Gleixner
56331c9d7c8SThomas Gleixner	if (refcount_dec_and_test(&p->refcnt)) {
56431c9d7c8SThomas Gleixner		/*
56531c9d7c8SThomas Gleixner		 * Really good explanation why the magic things below
56631c9d7c8SThomas Gleixner		 * need to be done, ordering and locking constraints,
56731c9d7c8SThomas Gleixner		 * etc..
56831c9d7c8SThomas Gleixner		 */
56931c9d7c8SThomas Gleixner		do;
57031c9d7c8SThomas Gleixner		lots;
57131c9d7c8SThomas Gleixner		of;
57231c9d7c8SThomas Gleixner		magic;
57331c9d7c8SThomas Gleixner		/* Needs to be the last operation because ... */
57431c9d7c8SThomas Gleixner		things;
57531c9d7c8SThomas Gleixner	}
57631c9d7c8SThomas Gleixner
57731c9d7c8SThomas GleixnerFunction documentation comments:
57831c9d7c8SThomas Gleixner
57931c9d7c8SThomas Gleixner  To document functions and their arguments please use kernel-doc format
58031c9d7c8SThomas Gleixner  and not free form comments::
58131c9d7c8SThomas Gleixner
58231c9d7c8SThomas Gleixner	/**
58331c9d7c8SThomas Gleixner	 * magic_function - Do lots of magic stuff
58431c9d7c8SThomas Gleixner	 * @magic:	Pointer to the magic data to operate on
58531c9d7c8SThomas Gleixner	 * @offset:	Offset in the data array of @magic
58631c9d7c8SThomas Gleixner	 *
58731c9d7c8SThomas Gleixner	 * Deep explanation of mysterious things done with @magic along
58831c9d7c8SThomas Gleixner         * with documentation of the return values.
58931c9d7c8SThomas Gleixner	 *
59031c9d7c8SThomas Gleixner	 * Note, that the argument descriptors above are arranged
59131c9d7c8SThomas Gleixner	 * in a tabular fashion.
59231c9d7c8SThomas Gleixner	 */
59331c9d7c8SThomas Gleixner
59431c9d7c8SThomas Gleixner  This applies especially to globally visible functions and inline
59531c9d7c8SThomas Gleixner  functions in public header files. It might be overkill to use kernel-doc
59631c9d7c8SThomas Gleixner  format for every (static) function which needs a tiny explanation. The
59731c9d7c8SThomas Gleixner  usage of descriptive function names often replaces these tiny comments.
59831c9d7c8SThomas Gleixner  Apply common sense as always.
59931c9d7c8SThomas Gleixner
60031c9d7c8SThomas Gleixner
60131c9d7c8SThomas GleixnerDocumenting locking requirements
60231c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60331c9d7c8SThomas Gleixner  Documenting locking requirements is a good thing, but comments are not
60431c9d7c8SThomas Gleixner  necessarily the best choice. Instead of writing::
60531c9d7c8SThomas Gleixner
60631c9d7c8SThomas Gleixner	/* Caller must hold foo->lock */
60731c9d7c8SThomas Gleixner	void func(struct foo *foo)
60831c9d7c8SThomas Gleixner	{
60931c9d7c8SThomas Gleixner		...
61031c9d7c8SThomas Gleixner	}
61131c9d7c8SThomas Gleixner
61231c9d7c8SThomas Gleixner  Please use::
61331c9d7c8SThomas Gleixner
61431c9d7c8SThomas Gleixner	void func(struct foo *foo)
61531c9d7c8SThomas Gleixner	{
61631c9d7c8SThomas Gleixner		lockdep_assert_held(&foo->lock);
61731c9d7c8SThomas Gleixner		...
61831c9d7c8SThomas Gleixner	}
61931c9d7c8SThomas Gleixner
62031c9d7c8SThomas Gleixner  In PROVE_LOCKING kernels, lockdep_assert_held() emits a warning
62131c9d7c8SThomas Gleixner  if the caller doesn't hold the lock.  Comments can't do that.
62231c9d7c8SThomas Gleixner
62331c9d7c8SThomas GleixnerBracket rules
62431c9d7c8SThomas Gleixner^^^^^^^^^^^^^
62531c9d7c8SThomas Gleixner
62631c9d7c8SThomas GleixnerBrackets should be omitted only if the statement which follows 'if', 'for',
62731c9d7c8SThomas Gleixner'while' etc. is truly a single line::
62831c9d7c8SThomas Gleixner
62931c9d7c8SThomas Gleixner	if (foo)
63031c9d7c8SThomas Gleixner		do_something();
63131c9d7c8SThomas Gleixner
63231c9d7c8SThomas GleixnerThe following is not considered to be a single line statement even
63331c9d7c8SThomas Gleixnerthough C does not require brackets::
63431c9d7c8SThomas Gleixner
63531c9d7c8SThomas Gleixner	for (i = 0; i < end; i++)
63631c9d7c8SThomas Gleixner		if (foo[i])
63731c9d7c8SThomas Gleixner			do_something(foo[i]);
63831c9d7c8SThomas Gleixner
63931c9d7c8SThomas GleixnerAdding brackets around the outer loop enhances the reading flow::
64031c9d7c8SThomas Gleixner
64131c9d7c8SThomas Gleixner	for (i = 0; i < end; i++) {
64231c9d7c8SThomas Gleixner		if (foo[i])
64331c9d7c8SThomas Gleixner			do_something(foo[i]);
64431c9d7c8SThomas Gleixner	}
64531c9d7c8SThomas Gleixner
64631c9d7c8SThomas Gleixner
64731c9d7c8SThomas GleixnerVariable declarations
64831c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^
64931c9d7c8SThomas Gleixner
65031c9d7c8SThomas GleixnerThe preferred ordering of variable declarations at the beginning of a
65131c9d7c8SThomas Gleixnerfunction is reverse fir tree order::
65231c9d7c8SThomas Gleixner
65331c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
65431c9d7c8SThomas Gleixner	unsigned long foo, bar;
65531c9d7c8SThomas Gleixner	unsigned int tmp;
65631c9d7c8SThomas Gleixner	int ret;
65731c9d7c8SThomas Gleixner
65831c9d7c8SThomas GleixnerThe above is faster to parse than the reverse ordering::
65931c9d7c8SThomas Gleixner
66031c9d7c8SThomas Gleixner	int ret;
66131c9d7c8SThomas Gleixner	unsigned int tmp;
66231c9d7c8SThomas Gleixner	unsigned long foo, bar;
66331c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
66431c9d7c8SThomas Gleixner
66531c9d7c8SThomas GleixnerAnd even more so than random ordering::
66631c9d7c8SThomas Gleixner
66731c9d7c8SThomas Gleixner	unsigned long foo, bar;
66831c9d7c8SThomas Gleixner	int ret;
66931c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
67031c9d7c8SThomas Gleixner	unsigned int tmp;
67131c9d7c8SThomas Gleixner
67231c9d7c8SThomas GleixnerAlso please try to aggregate variables of the same type into a single
67331c9d7c8SThomas Gleixnerline. There is no point in wasting screen space::
67431c9d7c8SThomas Gleixner
67531c9d7c8SThomas Gleixner	unsigned long a;
67631c9d7c8SThomas Gleixner	unsigned long b;
67731c9d7c8SThomas Gleixner	unsigned long c;
67831c9d7c8SThomas Gleixner	unsigned long d;
67931c9d7c8SThomas Gleixner
68031c9d7c8SThomas GleixnerIt's really sufficient to do::
68131c9d7c8SThomas Gleixner
68231c9d7c8SThomas Gleixner	unsigned long a, b, c, d;
68331c9d7c8SThomas Gleixner
68431c9d7c8SThomas GleixnerPlease also refrain from introducing line splits in variable declarations::
68531c9d7c8SThomas Gleixner
68631c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name = container_of(bar,
68731c9d7c8SThomas Gleixner						      struct long_struct_name,
68831c9d7c8SThomas Gleixner	                                              member);
68931c9d7c8SThomas Gleixner	struct foobar foo;
69031c9d7c8SThomas Gleixner
69131c9d7c8SThomas GleixnerIt's way better to move the initialization to a separate line after the
69231c9d7c8SThomas Gleixnerdeclarations::
69331c9d7c8SThomas Gleixner
69431c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
69531c9d7c8SThomas Gleixner	struct foobar foo;
69631c9d7c8SThomas Gleixner
69731c9d7c8SThomas Gleixner	descriptive_name = container_of(bar, struct long_struct_name, member);
69831c9d7c8SThomas Gleixner
69931c9d7c8SThomas Gleixner
70031c9d7c8SThomas GleixnerVariable types
70131c9d7c8SThomas Gleixner^^^^^^^^^^^^^^
70231c9d7c8SThomas Gleixner
70331c9d7c8SThomas GleixnerPlease use the proper u8, u16, u32, u64 types for variables which are meant
70431c9d7c8SThomas Gleixnerto describe hardware or are used as arguments for functions which access
70531c9d7c8SThomas Gleixnerhardware. These types are clearly defining the bit width and avoid
70631c9d7c8SThomas Gleixnertruncation, expansion and 32/64-bit confusion.
70731c9d7c8SThomas Gleixner
70831c9d7c8SThomas Gleixneru64 is also recommended in code which would become ambiguous for 32-bit
70931c9d7c8SThomas Gleixnerkernels when 'unsigned long' would be used instead. While in such
71031c9d7c8SThomas Gleixnersituations 'unsigned long long' could be used as well, u64 is shorter
71131c9d7c8SThomas Gleixnerand also clearly shows that the operation is required to be 64 bits wide
71231c9d7c8SThomas Gleixnerindependent of the target CPU.
71331c9d7c8SThomas Gleixner
71431c9d7c8SThomas GleixnerPlease use 'unsigned int' instead of 'unsigned'.
71531c9d7c8SThomas Gleixner
71631c9d7c8SThomas Gleixner
71731c9d7c8SThomas GleixnerConstants
71831c9d7c8SThomas Gleixner^^^^^^^^^
71931c9d7c8SThomas Gleixner
72031c9d7c8SThomas GleixnerPlease do not use literal (hexa)decimal numbers in code or initializers.
72131c9d7c8SThomas GleixnerEither use proper defines which have descriptive names or consider using
72231c9d7c8SThomas Gleixneran enum.
72331c9d7c8SThomas Gleixner
72431c9d7c8SThomas Gleixner
72531c9d7c8SThomas GleixnerStruct declarations and initializers
72631c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72731c9d7c8SThomas Gleixner
72831c9d7c8SThomas GleixnerStruct declarations should align the struct member names in a tabular
72931c9d7c8SThomas Gleixnerfashion::
73031c9d7c8SThomas Gleixner
73131c9d7c8SThomas Gleixner	struct bar_order {
73231c9d7c8SThomas Gleixner		unsigned int	guest_id;
73331c9d7c8SThomas Gleixner		int		ordered_item;
73431c9d7c8SThomas Gleixner		struct menu	*menu;
73531c9d7c8SThomas Gleixner	};
73631c9d7c8SThomas Gleixner
73731c9d7c8SThomas GleixnerPlease avoid documenting struct members within the declaration, because
73831c9d7c8SThomas Gleixnerthis often results in strangely formatted comments and the struct members
73931c9d7c8SThomas Gleixnerbecome obfuscated::
74031c9d7c8SThomas Gleixner
74131c9d7c8SThomas Gleixner	struct bar_order {
74231c9d7c8SThomas Gleixner		unsigned int	guest_id; /* Unique guest id */
74331c9d7c8SThomas Gleixner		int		ordered_item;
74431c9d7c8SThomas Gleixner		/* Pointer to a menu instance which contains all the drinks */
74531c9d7c8SThomas Gleixner		struct menu	*menu;
74631c9d7c8SThomas Gleixner	};
74731c9d7c8SThomas Gleixner
74831c9d7c8SThomas GleixnerInstead, please consider using the kernel-doc format in a comment preceding
74931c9d7c8SThomas Gleixnerthe struct declaration, which is easier to read and has the added advantage
75031c9d7c8SThomas Gleixnerof including the information in the kernel documentation, for example, as
75131c9d7c8SThomas Gleixnerfollows::
75231c9d7c8SThomas Gleixner
75331c9d7c8SThomas Gleixner
75431c9d7c8SThomas Gleixner	/**
75531c9d7c8SThomas Gleixner	 * struct bar_order - Description of a bar order
75631c9d7c8SThomas Gleixner	 * @guest_id:		Unique guest id
75731c9d7c8SThomas Gleixner	 * @ordered_item:	The item number from the menu
75831c9d7c8SThomas Gleixner	 * @menu:		Pointer to the menu from which the item
75931c9d7c8SThomas Gleixner	 *  			was ordered
76031c9d7c8SThomas Gleixner	 *
76131c9d7c8SThomas Gleixner	 * Supplementary information for using the struct.
76231c9d7c8SThomas Gleixner	 *
76331c9d7c8SThomas Gleixner	 * Note, that the struct member descriptors above are arranged
76431c9d7c8SThomas Gleixner	 * in a tabular fashion.
76531c9d7c8SThomas Gleixner	 */
76631c9d7c8SThomas Gleixner	struct bar_order {
76731c9d7c8SThomas Gleixner		unsigned int	guest_id;
76831c9d7c8SThomas Gleixner		int		ordered_item;
76931c9d7c8SThomas Gleixner		struct menu	*menu;
77031c9d7c8SThomas Gleixner	};
77131c9d7c8SThomas Gleixner
77231c9d7c8SThomas GleixnerStatic struct initializers must use C99 initializers and should also be
77331c9d7c8SThomas Gleixneraligned in a tabular fashion::
77431c9d7c8SThomas Gleixner
77531c9d7c8SThomas Gleixner	static struct foo statfoo = {
77631c9d7c8SThomas Gleixner		.a		= 0,
77731c9d7c8SThomas Gleixner		.plain_integer	= CONSTANT_DEFINE_OR_ENUM,
77831c9d7c8SThomas Gleixner		.bar		= &statbar,
77931c9d7c8SThomas Gleixner	};
78031c9d7c8SThomas Gleixner
78131c9d7c8SThomas GleixnerNote that while C99 syntax allows the omission of the final comma,
78231c9d7c8SThomas Gleixnerwe recommend the use of a comma on the last line because it makes
78331c9d7c8SThomas Gleixnerreordering and addition of new lines easier, and makes such future
78431c9d7c8SThomas Gleixnerpatches slightly easier to read as well.
78531c9d7c8SThomas Gleixner
78631c9d7c8SThomas GleixnerLine breaks
78731c9d7c8SThomas Gleixner^^^^^^^^^^^
78831c9d7c8SThomas Gleixner
78931c9d7c8SThomas GleixnerRestricting line length to 80 characters makes deeply indented code hard to
79031c9d7c8SThomas Gleixnerread.  Consider breaking out code into helper functions to avoid excessive
79131c9d7c8SThomas Gleixnerline breaking.
79231c9d7c8SThomas Gleixner
79331c9d7c8SThomas GleixnerThe 80 character rule is not a strict rule, so please use common sense when
79431c9d7c8SThomas Gleixnerbreaking lines. Especially format strings should never be broken up.
79531c9d7c8SThomas Gleixner
79631c9d7c8SThomas GleixnerWhen splitting function declarations or function calls, then please align
79731c9d7c8SThomas Gleixnerthe first argument in the second line with the first argument in the first
79831c9d7c8SThomas Gleixnerline::
79931c9d7c8SThomas Gleixner
80031c9d7c8SThomas Gleixner  static int long_function_name(struct foobar *barfoo, unsigned int id,
80131c9d7c8SThomas Gleixner				unsigned int offset)
80231c9d7c8SThomas Gleixner  {
80331c9d7c8SThomas Gleixner
80431c9d7c8SThomas Gleixner	if (!id) {
80531c9d7c8SThomas Gleixner		ret = longer_function_name(barfoo, DEFAULT_BARFOO_ID,
80631c9d7c8SThomas Gleixner					   offset);
80731c9d7c8SThomas Gleixner	...
80831c9d7c8SThomas Gleixner
80931c9d7c8SThomas GleixnerNamespaces
81031c9d7c8SThomas Gleixner^^^^^^^^^^
81131c9d7c8SThomas Gleixner
81231c9d7c8SThomas GleixnerFunction/variable namespaces improve readability and allow easy
81331c9d7c8SThomas Gleixnergrepping. These namespaces are string prefixes for globally visible
81431c9d7c8SThomas Gleixnerfunction and variable names, including inlines. These prefixes should
81531c9d7c8SThomas Gleixnercombine the subsystem and the component name such as 'x86_comp\_',
81631c9d7c8SThomas Gleixner'sched\_', 'irq\_', and 'mutex\_'.
81731c9d7c8SThomas Gleixner
81831c9d7c8SThomas GleixnerThis also includes static file scope functions that are immediately put
81931c9d7c8SThomas Gleixnerinto globally visible driver templates - it's useful for those symbols
82031c9d7c8SThomas Gleixnerto carry a good prefix as well, for backtrace readability.
82131c9d7c8SThomas Gleixner
82231c9d7c8SThomas GleixnerNamespace prefixes may be omitted for local static functions and
82331c9d7c8SThomas Gleixnervariables. Truly local functions, only called by other local functions,
82431c9d7c8SThomas Gleixnercan have shorter descriptive names - our primary concern is greppability
82531c9d7c8SThomas Gleixnerand backtrace readability.
82631c9d7c8SThomas Gleixner
82731c9d7c8SThomas GleixnerPlease note that 'xxx_vendor\_' and 'vendor_xxx_` prefixes are not
82831c9d7c8SThomas Gleixnerhelpful for static functions in vendor-specific files. After all, it
82931c9d7c8SThomas Gleixneris already clear that the code is vendor-specific. In addition, vendor
83031c9d7c8SThomas Gleixnernames should only be for truly vendor-specific functionality.
83131c9d7c8SThomas Gleixner
83231c9d7c8SThomas GleixnerAs always apply common sense and aim for consistency and readability.
83331c9d7c8SThomas Gleixner
83431c9d7c8SThomas Gleixner
83531c9d7c8SThomas GleixnerCommit notifications
83631c9d7c8SThomas Gleixner--------------------
83731c9d7c8SThomas Gleixner
83831c9d7c8SThomas GleixnerThe tip tree is monitored by a bot for new commits. The bot sends an email
83931c9d7c8SThomas Gleixnerfor each new commit to a dedicated mailing list
84031c9d7c8SThomas Gleixner(``linux-tip-commits@vger.kernel.org``) and Cc's all people who are
84131c9d7c8SThomas Gleixnermentioned in one of the commit tags. It uses the email message ID from the
84231c9d7c8SThomas GleixnerLink tag at the end of the tag list to set the In-Reply-To email header so
84331c9d7c8SThomas Gleixnerthe message is properly threaded with the patch submission email.
84431c9d7c8SThomas Gleixner
84531c9d7c8SThomas GleixnerThe tip maintainers and submaintainers try to reply to the submitter
84631c9d7c8SThomas Gleixnerwhen merging a patch, but they sometimes forget or it does not fit the
84731c9d7c8SThomas Gleixnerworkflow of the moment. While the bot message is purely mechanical, it
84831c9d7c8SThomas Gleixneralso implies a 'Thank you! Applied.'.
849