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    donot 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
37531c9d7c8SThomas Gleixner   For referring to an email on LKML or other kernel mailing lists,
376a9d85efbSThorsten Leemhuis   please use the lore.kernel.org redirector URL::
37731c9d7c8SThomas Gleixner
378a9d85efbSThorsten Leemhuis     https://lore.kernel.org/r/email-message@id
37931c9d7c8SThomas Gleixner
38031c9d7c8SThomas Gleixner   The kernel.org redirector is considered a stable URL, unlike other email
38131c9d7c8SThomas Gleixner   archives.
38231c9d7c8SThomas Gleixner
38331c9d7c8SThomas Gleixner   Maintainers will add a Link tag referencing the email of the patch
38431c9d7c8SThomas Gleixner   submission when they apply a patch to the tip tree. This tag is useful
38531c9d7c8SThomas Gleixner   for later reference and is also used for commit notifications.
38631c9d7c8SThomas Gleixner
38731c9d7c8SThomas GleixnerPlease do not use combined tags, e.g. ``Reported-and-tested-by``, as
38831c9d7c8SThomas Gleixnerthey just complicate automated extraction of tags.
38931c9d7c8SThomas Gleixner
39031c9d7c8SThomas Gleixner
39131c9d7c8SThomas GleixnerLinks to documentation
39231c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^
39331c9d7c8SThomas Gleixner
39431c9d7c8SThomas GleixnerProviding links to documentation in the changelog is a great help to later
39531c9d7c8SThomas Gleixnerdebugging and analysis.  Unfortunately, URLs often break very quickly
39631c9d7c8SThomas Gleixnerbecause companies restructure their websites frequently.  Non-'volatile'
39731c9d7c8SThomas Gleixnerexceptions include the Intel SDM and the AMD APM.
39831c9d7c8SThomas Gleixner
39931c9d7c8SThomas GleixnerTherefore, for 'volatile' documents, please create an entry in the kernel
40031c9d7c8SThomas Gleixnerbugzilla https://bugzilla.kernel.org and attach a copy of these documents
40131c9d7c8SThomas Gleixnerto the bugzilla entry. Finally, provide the URL of the bugzilla entry in
40231c9d7c8SThomas Gleixnerthe changelog.
40331c9d7c8SThomas Gleixner
40431c9d7c8SThomas GleixnerPatch resend or reminders
40531c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^
40631c9d7c8SThomas Gleixner
40731c9d7c8SThomas GleixnerSee :ref:`resend_reminders`.
40831c9d7c8SThomas Gleixner
40931c9d7c8SThomas GleixnerMerge window
41031c9d7c8SThomas Gleixner^^^^^^^^^^^^
41131c9d7c8SThomas Gleixner
412*bdc42c8bSDave HansenPlease do not expect patches to be reviewed or merged by tip
413*bdc42c8bSDave Hansenmaintainers around or during the merge window.  The trees are closed
414*bdc42c8bSDave Hansento all but urgent fixes during this time.  They reopen once the merge
415*bdc42c8bSDave Hansenwindow closes and a new -rc1 kernel has been released.
416*bdc42c8bSDave Hansen
417*bdc42c8bSDave HansenLarge series should be submitted in mergeable state *at* *least* a week
418*bdc42c8bSDave Hansenbefore the merge window opens.  Exceptions are made for bug fixes and
419*bdc42c8bSDave Hansen*sometimes* for small standalone drivers for new hardware or minimally
420*bdc42c8bSDave Hanseninvasive patches for hardware enablement.
42131c9d7c8SThomas Gleixner
42231c9d7c8SThomas GleixnerDuring the merge window, the maintainers instead focus on following the
42331c9d7c8SThomas Gleixnerupstream changes, fixing merge window fallout, collecting bug fixes, and
42431c9d7c8SThomas Gleixnerallowing themselves a breath. Please respect that.
42531c9d7c8SThomas Gleixner
4264f119255SChristian KujauSo called _urgent_ branches will be merged into mainline during the
4274f119255SChristian Kujaustabilization phase of each release.
4284f119255SChristian Kujau
42931c9d7c8SThomas Gleixner
43031c9d7c8SThomas GleixnerGit
43131c9d7c8SThomas Gleixner^^^
43231c9d7c8SThomas Gleixner
43331c9d7c8SThomas GleixnerThe tip maintainers accept git pull requests from maintainers who provide
43431c9d7c8SThomas Gleixnersubsystem changes for aggregation in the tip tree.
43531c9d7c8SThomas Gleixner
43631c9d7c8SThomas GleixnerPull requests for new patch submissions are usually not accepted and do not
43731c9d7c8SThomas Gleixnerreplace proper patch submission to the mailing list. The main reason for
43831c9d7c8SThomas Gleixnerthis is that the review workflow is email based.
43931c9d7c8SThomas Gleixner
44031c9d7c8SThomas GleixnerIf you submit a larger patch series it is helpful to provide a git branch
44131c9d7c8SThomas Gleixnerin a private repository which allows interested people to easily pull the
44231c9d7c8SThomas Gleixnerseries for testing. The usual way to offer this is a git URL in the cover
44331c9d7c8SThomas Gleixnerletter of the patch series.
44431c9d7c8SThomas Gleixner
4459b5a7f4aSDave HansenTesting
4469b5a7f4aSDave Hansen^^^^^^^
4479b5a7f4aSDave Hansen
4489b5a7f4aSDave HansenCode should be tested before submitting to the tip maintainers.  Anything
4499b5a7f4aSDave Hansenother than minor changes should be built, booted and tested with
4509b5a7f4aSDave Hansencomprehensive (and heavyweight) kernel debugging options enabled.
4519b5a7f4aSDave Hansen
4529b5a7f4aSDave HansenThese debugging options can be found in kernel/configs/x86_debug.config
4539b5a7f4aSDave Hansenand can be added to an existing kernel config by running:
4549b5a7f4aSDave Hansen
4559b5a7f4aSDave Hansen	make x86_debug.config
4569b5a7f4aSDave Hansen
4579b5a7f4aSDave HansenSome of these options are x86-specific and can be left out when testing
4589b5a7f4aSDave Hansenon other architectures.
45931c9d7c8SThomas Gleixner
460b7dac767SSean Christopherson.. _maintainer-tip-coding-style:
461b7dac767SSean Christopherson
46231c9d7c8SThomas GleixnerCoding style notes
46331c9d7c8SThomas Gleixner------------------
46431c9d7c8SThomas Gleixner
46531c9d7c8SThomas GleixnerComment style
46631c9d7c8SThomas Gleixner^^^^^^^^^^^^^
46731c9d7c8SThomas Gleixner
46831c9d7c8SThomas GleixnerSentences in comments start with an uppercase letter.
46931c9d7c8SThomas Gleixner
47031c9d7c8SThomas GleixnerSingle line comments::
47131c9d7c8SThomas Gleixner
47231c9d7c8SThomas Gleixner	/* This is a single line comment */
47331c9d7c8SThomas Gleixner
47431c9d7c8SThomas GleixnerMulti-line comments::
47531c9d7c8SThomas Gleixner
47631c9d7c8SThomas Gleixner	/*
47731c9d7c8SThomas Gleixner	 * This is a properly formatted
47831c9d7c8SThomas Gleixner	 * multi-line comment.
47931c9d7c8SThomas Gleixner	 *
48031c9d7c8SThomas Gleixner	 * Larger multi-line comments should be split into paragraphs.
48131c9d7c8SThomas Gleixner	 */
48231c9d7c8SThomas Gleixner
4837dd0a21cSBorislav Petkov (AMD)No tail comments (see below):
48431c9d7c8SThomas Gleixner
48531c9d7c8SThomas Gleixner  Please refrain from using tail comments. Tail comments disturb the
48631c9d7c8SThomas Gleixner  reading flow in almost all contexts, but especially in code::
48731c9d7c8SThomas Gleixner
48831c9d7c8SThomas Gleixner	if (somecondition_is_true) /* Don't put a comment here */
48931c9d7c8SThomas Gleixner		dostuff(); /* Neither here */
49031c9d7c8SThomas Gleixner
49131c9d7c8SThomas Gleixner	seed = MAGIC_CONSTANT; /* Nor here */
49231c9d7c8SThomas Gleixner
49331c9d7c8SThomas Gleixner  Use freestanding comments instead::
49431c9d7c8SThomas Gleixner
49531c9d7c8SThomas Gleixner	/* This condition is not obvious without a comment */
49631c9d7c8SThomas Gleixner	if (somecondition_is_true) {
49731c9d7c8SThomas Gleixner		/* This really needs to be documented */
49831c9d7c8SThomas Gleixner		dostuff();
49931c9d7c8SThomas Gleixner	}
50031c9d7c8SThomas Gleixner
50131c9d7c8SThomas Gleixner	/* This magic initialization needs a comment. Maybe not? */
50231c9d7c8SThomas Gleixner	seed = MAGIC_CONSTANT;
50331c9d7c8SThomas Gleixner
5047dd0a21cSBorislav Petkov (AMD)  Use C++ style, tail comments when documenting structs in headers to
5057dd0a21cSBorislav Petkov (AMD)  achieve a more compact layout and better readability::
5067dd0a21cSBorislav Petkov (AMD)
5077dd0a21cSBorislav Petkov (AMD)        // eax
5087dd0a21cSBorislav Petkov (AMD)        u32     x2apic_shift    :  5, // Number of bits to shift APIC ID right
5097dd0a21cSBorislav Petkov (AMD)                                      // for the topology ID at the next level
5107dd0a21cSBorislav Petkov (AMD)                                : 27; // Reserved
5117dd0a21cSBorislav Petkov (AMD)        // ebx
5127dd0a21cSBorislav Petkov (AMD)        u32     num_processors  : 16, // Number of processors at current level
5137dd0a21cSBorislav Petkov (AMD)                                : 16; // Reserved
5147dd0a21cSBorislav Petkov (AMD)
5157dd0a21cSBorislav Petkov (AMD)  versus::
5167dd0a21cSBorislav Petkov (AMD)
5177dd0a21cSBorislav Petkov (AMD)	/* eax */
5187dd0a21cSBorislav Petkov (AMD)	        /*
5197dd0a21cSBorislav Petkov (AMD)	         * Number of bits to shift APIC ID right for the topology ID
5207dd0a21cSBorislav Petkov (AMD)	         * at the next level
5217dd0a21cSBorislav Petkov (AMD)	         */
5227dd0a21cSBorislav Petkov (AMD)         u32     x2apic_shift    :  5,
5237dd0a21cSBorislav Petkov (AMD)		 /* Reserved */
5247dd0a21cSBorislav Petkov (AMD)				 : 27;
5257dd0a21cSBorislav Petkov (AMD)
5267dd0a21cSBorislav Petkov (AMD)	/* ebx */
5277dd0a21cSBorislav Petkov (AMD)		/* Number of processors at current level */
5287dd0a21cSBorislav Petkov (AMD)	u32     num_processors  : 16,
5297dd0a21cSBorislav Petkov (AMD)		/* Reserved */
5307dd0a21cSBorislav Petkov (AMD)				: 16;
5317dd0a21cSBorislav Petkov (AMD)
53231c9d7c8SThomas GleixnerComment the important things:
53331c9d7c8SThomas Gleixner
53431c9d7c8SThomas Gleixner  Comments should be added where the operation is not obvious. Documenting
53531c9d7c8SThomas Gleixner  the obvious is just a distraction::
53631c9d7c8SThomas Gleixner
53731c9d7c8SThomas Gleixner	/* Decrement refcount and check for zero */
53831c9d7c8SThomas Gleixner	if (refcount_dec_and_test(&p->refcnt)) {
53931c9d7c8SThomas Gleixner		do;
54031c9d7c8SThomas Gleixner		lots;
54131c9d7c8SThomas Gleixner		of;
54231c9d7c8SThomas Gleixner		magic;
54331c9d7c8SThomas Gleixner		things;
54431c9d7c8SThomas Gleixner	}
54531c9d7c8SThomas Gleixner
54631c9d7c8SThomas Gleixner  Instead, comments should explain the non-obvious details and document
54731c9d7c8SThomas Gleixner  constraints::
54831c9d7c8SThomas Gleixner
54931c9d7c8SThomas Gleixner	if (refcount_dec_and_test(&p->refcnt)) {
55031c9d7c8SThomas Gleixner		/*
55131c9d7c8SThomas Gleixner		 * Really good explanation why the magic things below
55231c9d7c8SThomas Gleixner		 * need to be done, ordering and locking constraints,
55331c9d7c8SThomas Gleixner		 * etc..
55431c9d7c8SThomas Gleixner		 */
55531c9d7c8SThomas Gleixner		do;
55631c9d7c8SThomas Gleixner		lots;
55731c9d7c8SThomas Gleixner		of;
55831c9d7c8SThomas Gleixner		magic;
55931c9d7c8SThomas Gleixner		/* Needs to be the last operation because ... */
56031c9d7c8SThomas Gleixner		things;
56131c9d7c8SThomas Gleixner	}
56231c9d7c8SThomas Gleixner
56331c9d7c8SThomas GleixnerFunction documentation comments:
56431c9d7c8SThomas Gleixner
56531c9d7c8SThomas Gleixner  To document functions and their arguments please use kernel-doc format
56631c9d7c8SThomas Gleixner  and not free form comments::
56731c9d7c8SThomas Gleixner
56831c9d7c8SThomas Gleixner	/**
56931c9d7c8SThomas Gleixner	 * magic_function - Do lots of magic stuff
57031c9d7c8SThomas Gleixner	 * @magic:	Pointer to the magic data to operate on
57131c9d7c8SThomas Gleixner	 * @offset:	Offset in the data array of @magic
57231c9d7c8SThomas Gleixner	 *
57331c9d7c8SThomas Gleixner	 * Deep explanation of mysterious things done with @magic along
57431c9d7c8SThomas Gleixner         * with documentation of the return values.
57531c9d7c8SThomas Gleixner	 *
57631c9d7c8SThomas Gleixner	 * Note, that the argument descriptors above are arranged
57731c9d7c8SThomas Gleixner	 * in a tabular fashion.
57831c9d7c8SThomas Gleixner	 */
57931c9d7c8SThomas Gleixner
58031c9d7c8SThomas Gleixner  This applies especially to globally visible functions and inline
58131c9d7c8SThomas Gleixner  functions in public header files. It might be overkill to use kernel-doc
58231c9d7c8SThomas Gleixner  format for every (static) function which needs a tiny explanation. The
58331c9d7c8SThomas Gleixner  usage of descriptive function names often replaces these tiny comments.
58431c9d7c8SThomas Gleixner  Apply common sense as always.
58531c9d7c8SThomas Gleixner
58631c9d7c8SThomas Gleixner
58731c9d7c8SThomas GleixnerDocumenting locking requirements
58831c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58931c9d7c8SThomas Gleixner  Documenting locking requirements is a good thing, but comments are not
59031c9d7c8SThomas Gleixner  necessarily the best choice. Instead of writing::
59131c9d7c8SThomas Gleixner
59231c9d7c8SThomas Gleixner	/* Caller must hold foo->lock */
59331c9d7c8SThomas Gleixner	void func(struct foo *foo)
59431c9d7c8SThomas Gleixner	{
59531c9d7c8SThomas Gleixner		...
59631c9d7c8SThomas Gleixner	}
59731c9d7c8SThomas Gleixner
59831c9d7c8SThomas Gleixner  Please use::
59931c9d7c8SThomas Gleixner
60031c9d7c8SThomas Gleixner	void func(struct foo *foo)
60131c9d7c8SThomas Gleixner	{
60231c9d7c8SThomas Gleixner		lockdep_assert_held(&foo->lock);
60331c9d7c8SThomas Gleixner		...
60431c9d7c8SThomas Gleixner	}
60531c9d7c8SThomas Gleixner
60631c9d7c8SThomas Gleixner  In PROVE_LOCKING kernels, lockdep_assert_held() emits a warning
60731c9d7c8SThomas Gleixner  if the caller doesn't hold the lock.  Comments can't do that.
60831c9d7c8SThomas Gleixner
60931c9d7c8SThomas GleixnerBracket rules
61031c9d7c8SThomas Gleixner^^^^^^^^^^^^^
61131c9d7c8SThomas Gleixner
61231c9d7c8SThomas GleixnerBrackets should be omitted only if the statement which follows 'if', 'for',
61331c9d7c8SThomas Gleixner'while' etc. is truly a single line::
61431c9d7c8SThomas Gleixner
61531c9d7c8SThomas Gleixner	if (foo)
61631c9d7c8SThomas Gleixner		do_something();
61731c9d7c8SThomas Gleixner
61831c9d7c8SThomas GleixnerThe following is not considered to be a single line statement even
61931c9d7c8SThomas Gleixnerthough C does not require brackets::
62031c9d7c8SThomas Gleixner
62131c9d7c8SThomas Gleixner	for (i = 0; i < end; i++)
62231c9d7c8SThomas Gleixner		if (foo[i])
62331c9d7c8SThomas Gleixner			do_something(foo[i]);
62431c9d7c8SThomas Gleixner
62531c9d7c8SThomas GleixnerAdding brackets around the outer loop enhances the reading flow::
62631c9d7c8SThomas Gleixner
62731c9d7c8SThomas Gleixner	for (i = 0; i < end; i++) {
62831c9d7c8SThomas Gleixner		if (foo[i])
62931c9d7c8SThomas Gleixner			do_something(foo[i]);
63031c9d7c8SThomas Gleixner	}
63131c9d7c8SThomas Gleixner
63231c9d7c8SThomas Gleixner
63331c9d7c8SThomas GleixnerVariable declarations
63431c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^
63531c9d7c8SThomas Gleixner
63631c9d7c8SThomas GleixnerThe preferred ordering of variable declarations at the beginning of a
63731c9d7c8SThomas Gleixnerfunction is reverse fir tree order::
63831c9d7c8SThomas Gleixner
63931c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
64031c9d7c8SThomas Gleixner	unsigned long foo, bar;
64131c9d7c8SThomas Gleixner	unsigned int tmp;
64231c9d7c8SThomas Gleixner	int ret;
64331c9d7c8SThomas Gleixner
64431c9d7c8SThomas GleixnerThe above is faster to parse than the reverse ordering::
64531c9d7c8SThomas Gleixner
64631c9d7c8SThomas Gleixner	int ret;
64731c9d7c8SThomas Gleixner	unsigned int tmp;
64831c9d7c8SThomas Gleixner	unsigned long foo, bar;
64931c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
65031c9d7c8SThomas Gleixner
65131c9d7c8SThomas GleixnerAnd even more so than random ordering::
65231c9d7c8SThomas Gleixner
65331c9d7c8SThomas Gleixner	unsigned long foo, bar;
65431c9d7c8SThomas Gleixner	int ret;
65531c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
65631c9d7c8SThomas Gleixner	unsigned int tmp;
65731c9d7c8SThomas Gleixner
65831c9d7c8SThomas GleixnerAlso please try to aggregate variables of the same type into a single
65931c9d7c8SThomas Gleixnerline. There is no point in wasting screen space::
66031c9d7c8SThomas Gleixner
66131c9d7c8SThomas Gleixner	unsigned long a;
66231c9d7c8SThomas Gleixner	unsigned long b;
66331c9d7c8SThomas Gleixner	unsigned long c;
66431c9d7c8SThomas Gleixner	unsigned long d;
66531c9d7c8SThomas Gleixner
66631c9d7c8SThomas GleixnerIt's really sufficient to do::
66731c9d7c8SThomas Gleixner
66831c9d7c8SThomas Gleixner	unsigned long a, b, c, d;
66931c9d7c8SThomas Gleixner
67031c9d7c8SThomas GleixnerPlease also refrain from introducing line splits in variable declarations::
67131c9d7c8SThomas Gleixner
67231c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name = container_of(bar,
67331c9d7c8SThomas Gleixner						      struct long_struct_name,
67431c9d7c8SThomas Gleixner	                                              member);
67531c9d7c8SThomas Gleixner	struct foobar foo;
67631c9d7c8SThomas Gleixner
67731c9d7c8SThomas GleixnerIt's way better to move the initialization to a separate line after the
67831c9d7c8SThomas Gleixnerdeclarations::
67931c9d7c8SThomas Gleixner
68031c9d7c8SThomas Gleixner	struct long_struct_name *descriptive_name;
68131c9d7c8SThomas Gleixner	struct foobar foo;
68231c9d7c8SThomas Gleixner
68331c9d7c8SThomas Gleixner	descriptive_name = container_of(bar, struct long_struct_name, member);
68431c9d7c8SThomas Gleixner
68531c9d7c8SThomas Gleixner
68631c9d7c8SThomas GleixnerVariable types
68731c9d7c8SThomas Gleixner^^^^^^^^^^^^^^
68831c9d7c8SThomas Gleixner
68931c9d7c8SThomas GleixnerPlease use the proper u8, u16, u32, u64 types for variables which are meant
69031c9d7c8SThomas Gleixnerto describe hardware or are used as arguments for functions which access
69131c9d7c8SThomas Gleixnerhardware. These types are clearly defining the bit width and avoid
69231c9d7c8SThomas Gleixnertruncation, expansion and 32/64-bit confusion.
69331c9d7c8SThomas Gleixner
69431c9d7c8SThomas Gleixneru64 is also recommended in code which would become ambiguous for 32-bit
69531c9d7c8SThomas Gleixnerkernels when 'unsigned long' would be used instead. While in such
69631c9d7c8SThomas Gleixnersituations 'unsigned long long' could be used as well, u64 is shorter
69731c9d7c8SThomas Gleixnerand also clearly shows that the operation is required to be 64 bits wide
69831c9d7c8SThomas Gleixnerindependent of the target CPU.
69931c9d7c8SThomas Gleixner
70031c9d7c8SThomas GleixnerPlease use 'unsigned int' instead of 'unsigned'.
70131c9d7c8SThomas Gleixner
70231c9d7c8SThomas Gleixner
70331c9d7c8SThomas GleixnerConstants
70431c9d7c8SThomas Gleixner^^^^^^^^^
70531c9d7c8SThomas Gleixner
70631c9d7c8SThomas GleixnerPlease do not use literal (hexa)decimal numbers in code or initializers.
70731c9d7c8SThomas GleixnerEither use proper defines which have descriptive names or consider using
70831c9d7c8SThomas Gleixneran enum.
70931c9d7c8SThomas Gleixner
71031c9d7c8SThomas Gleixner
71131c9d7c8SThomas GleixnerStruct declarations and initializers
71231c9d7c8SThomas Gleixner^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71331c9d7c8SThomas Gleixner
71431c9d7c8SThomas GleixnerStruct declarations should align the struct member names in a tabular
71531c9d7c8SThomas Gleixnerfashion::
71631c9d7c8SThomas Gleixner
71731c9d7c8SThomas Gleixner	struct bar_order {
71831c9d7c8SThomas Gleixner		unsigned int	guest_id;
71931c9d7c8SThomas Gleixner		int		ordered_item;
72031c9d7c8SThomas Gleixner		struct menu	*menu;
72131c9d7c8SThomas Gleixner	};
72231c9d7c8SThomas Gleixner
72331c9d7c8SThomas GleixnerPlease avoid documenting struct members within the declaration, because
72431c9d7c8SThomas Gleixnerthis often results in strangely formatted comments and the struct members
72531c9d7c8SThomas Gleixnerbecome obfuscated::
72631c9d7c8SThomas Gleixner
72731c9d7c8SThomas Gleixner	struct bar_order {
72831c9d7c8SThomas Gleixner		unsigned int	guest_id; /* Unique guest id */
72931c9d7c8SThomas Gleixner		int		ordered_item;
73031c9d7c8SThomas Gleixner		/* Pointer to a menu instance which contains all the drinks */
73131c9d7c8SThomas Gleixner		struct menu	*menu;
73231c9d7c8SThomas Gleixner	};
73331c9d7c8SThomas Gleixner
73431c9d7c8SThomas GleixnerInstead, please consider using the kernel-doc format in a comment preceding
73531c9d7c8SThomas Gleixnerthe struct declaration, which is easier to read and has the added advantage
73631c9d7c8SThomas Gleixnerof including the information in the kernel documentation, for example, as
73731c9d7c8SThomas Gleixnerfollows::
73831c9d7c8SThomas Gleixner
73931c9d7c8SThomas Gleixner
74031c9d7c8SThomas Gleixner	/**
74131c9d7c8SThomas Gleixner	 * struct bar_order - Description of a bar order
74231c9d7c8SThomas Gleixner	 * @guest_id:		Unique guest id
74331c9d7c8SThomas Gleixner	 * @ordered_item:	The item number from the menu
74431c9d7c8SThomas Gleixner	 * @menu:		Pointer to the menu from which the item
74531c9d7c8SThomas Gleixner	 *  			was ordered
74631c9d7c8SThomas Gleixner	 *
74731c9d7c8SThomas Gleixner	 * Supplementary information for using the struct.
74831c9d7c8SThomas Gleixner	 *
74931c9d7c8SThomas Gleixner	 * Note, that the struct member descriptors above are arranged
75031c9d7c8SThomas Gleixner	 * in a tabular fashion.
75131c9d7c8SThomas Gleixner	 */
75231c9d7c8SThomas Gleixner	struct bar_order {
75331c9d7c8SThomas Gleixner		unsigned int	guest_id;
75431c9d7c8SThomas Gleixner		int		ordered_item;
75531c9d7c8SThomas Gleixner		struct menu	*menu;
75631c9d7c8SThomas Gleixner	};
75731c9d7c8SThomas Gleixner
75831c9d7c8SThomas GleixnerStatic struct initializers must use C99 initializers and should also be
75931c9d7c8SThomas Gleixneraligned in a tabular fashion::
76031c9d7c8SThomas Gleixner
76131c9d7c8SThomas Gleixner	static struct foo statfoo = {
76231c9d7c8SThomas Gleixner		.a		= 0,
76331c9d7c8SThomas Gleixner		.plain_integer	= CONSTANT_DEFINE_OR_ENUM,
76431c9d7c8SThomas Gleixner		.bar		= &statbar,
76531c9d7c8SThomas Gleixner	};
76631c9d7c8SThomas Gleixner
76731c9d7c8SThomas GleixnerNote that while C99 syntax allows the omission of the final comma,
76831c9d7c8SThomas Gleixnerwe recommend the use of a comma on the last line because it makes
76931c9d7c8SThomas Gleixnerreordering and addition of new lines easier, and makes such future
77031c9d7c8SThomas Gleixnerpatches slightly easier to read as well.
77131c9d7c8SThomas Gleixner
77231c9d7c8SThomas GleixnerLine breaks
77331c9d7c8SThomas Gleixner^^^^^^^^^^^
77431c9d7c8SThomas Gleixner
77531c9d7c8SThomas GleixnerRestricting line length to 80 characters makes deeply indented code hard to
77631c9d7c8SThomas Gleixnerread.  Consider breaking out code into helper functions to avoid excessive
77731c9d7c8SThomas Gleixnerline breaking.
77831c9d7c8SThomas Gleixner
77931c9d7c8SThomas GleixnerThe 80 character rule is not a strict rule, so please use common sense when
78031c9d7c8SThomas Gleixnerbreaking lines. Especially format strings should never be broken up.
78131c9d7c8SThomas Gleixner
78231c9d7c8SThomas GleixnerWhen splitting function declarations or function calls, then please align
78331c9d7c8SThomas Gleixnerthe first argument in the second line with the first argument in the first
78431c9d7c8SThomas Gleixnerline::
78531c9d7c8SThomas Gleixner
78631c9d7c8SThomas Gleixner  static int long_function_name(struct foobar *barfoo, unsigned int id,
78731c9d7c8SThomas Gleixner				unsigned int offset)
78831c9d7c8SThomas Gleixner  {
78931c9d7c8SThomas Gleixner
79031c9d7c8SThomas Gleixner	if (!id) {
79131c9d7c8SThomas Gleixner		ret = longer_function_name(barfoo, DEFAULT_BARFOO_ID,
79231c9d7c8SThomas Gleixner					   offset);
79331c9d7c8SThomas Gleixner	...
79431c9d7c8SThomas Gleixner
79531c9d7c8SThomas GleixnerNamespaces
79631c9d7c8SThomas Gleixner^^^^^^^^^^
79731c9d7c8SThomas Gleixner
79831c9d7c8SThomas GleixnerFunction/variable namespaces improve readability and allow easy
79931c9d7c8SThomas Gleixnergrepping. These namespaces are string prefixes for globally visible
80031c9d7c8SThomas Gleixnerfunction and variable names, including inlines. These prefixes should
80131c9d7c8SThomas Gleixnercombine the subsystem and the component name such as 'x86_comp\_',
80231c9d7c8SThomas Gleixner'sched\_', 'irq\_', and 'mutex\_'.
80331c9d7c8SThomas Gleixner
80431c9d7c8SThomas GleixnerThis also includes static file scope functions that are immediately put
80531c9d7c8SThomas Gleixnerinto globally visible driver templates - it's useful for those symbols
80631c9d7c8SThomas Gleixnerto carry a good prefix as well, for backtrace readability.
80731c9d7c8SThomas Gleixner
80831c9d7c8SThomas GleixnerNamespace prefixes may be omitted for local static functions and
80931c9d7c8SThomas Gleixnervariables. Truly local functions, only called by other local functions,
81031c9d7c8SThomas Gleixnercan have shorter descriptive names - our primary concern is greppability
81131c9d7c8SThomas Gleixnerand backtrace readability.
81231c9d7c8SThomas Gleixner
81331c9d7c8SThomas GleixnerPlease note that 'xxx_vendor\_' and 'vendor_xxx_` prefixes are not
81431c9d7c8SThomas Gleixnerhelpful for static functions in vendor-specific files. After all, it
81531c9d7c8SThomas Gleixneris already clear that the code is vendor-specific. In addition, vendor
81631c9d7c8SThomas Gleixnernames should only be for truly vendor-specific functionality.
81731c9d7c8SThomas Gleixner
81831c9d7c8SThomas GleixnerAs always apply common sense and aim for consistency and readability.
81931c9d7c8SThomas Gleixner
82031c9d7c8SThomas Gleixner
82131c9d7c8SThomas GleixnerCommit notifications
82231c9d7c8SThomas Gleixner--------------------
82331c9d7c8SThomas Gleixner
82431c9d7c8SThomas GleixnerThe tip tree is monitored by a bot for new commits. The bot sends an email
82531c9d7c8SThomas Gleixnerfor each new commit to a dedicated mailing list
82631c9d7c8SThomas Gleixner(``linux-tip-commits@vger.kernel.org``) and Cc's all people who are
82731c9d7c8SThomas Gleixnermentioned in one of the commit tags. It uses the email message ID from the
82831c9d7c8SThomas GleixnerLink tag at the end of the tag list to set the In-Reply-To email header so
82931c9d7c8SThomas Gleixnerthe message is properly threaded with the patch submission email.
83031c9d7c8SThomas Gleixner
83131c9d7c8SThomas GleixnerThe tip maintainers and submaintainers try to reply to the submitter
83231c9d7c8SThomas Gleixnerwhen merging a patch, but they sometimes forget or it does not fit the
83331c9d7c8SThomas Gleixnerworkflow of the moment. While the bot message is purely mechanical, it
83431c9d7c8SThomas Gleixneralso implies a 'Thank you! Applied.'.
835