Michal Marek a6afa1
Kernel Repository Guidelines
Michal Marek a6afa1
============================
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Table Of Contents
Michal Marek a6afa1
=================
Michal Marek a6afa1
Michal Marek bc3577
    Getting Started
Michal Marek a6afa1
    Patch Headers
Michal Marek a6afa1
    Before You Commit -- Things To Check
Michal Marek a6afa1
    Config Option Changes
Michal Marek a6afa1
    Committing and Log Messages
Michal Marek a6afa1
    What Is The Kernel ABI?
Michal Marek a6afa1
    Kernel ABI Changes
Michal Marek a6afa1
    Embargoed Patches
Michal Marek a6afa1
    Related Information
Michal Marek a6afa1
Michal Marek bc3577
Getting Started
Michal Marek bc3577
===============
Michal Marek bc3577
Michal Marek bc3577
Make sure you have a decent git version (1.5.x should work) and quilt
Michal Marek bc3577
installed.
Michal Marek bc3577
Michal Marek bc3577
Introduce yourself if you haven't done so already:
Michal Marek bc3577
    $ git config --global user.name "Your Name"
Michal Marek bc3577
    $ git config --global user.email your@email
Michal Marek bc3577
Michal Marek bc3577
If you ommit the --global option, the setting will only apply to this
Michal Marek bc3577
clone.
Michal Marek bc3577
Michal Marek bc3577
Set up some git hooks and helpers:
Michal Marek bc3577
Michal Marek bc3577
    $ ./scripts/install-git-hooks
Michal Marek bc3577
Michal Marek bc3577
To hack on the kernel sources:
Michal Marek bc3577
Michal Marek bc3577
    $ ./scripts/sequence-patch.sh --quilt
Michal Marek bc3577
    $ cd tmp/linux-$version-$branch
Michal Marek bc3577
    $ quilt new patches.fixes/fix-foo-and-bar
Michal Marek bc3577
    $ quilt edit some/file.c
Michal Marek bc3577
    $ ./refresh_patch.sh
Michal Marek bc3577
    $ quilt header -e # see next chapter
Michal Marek bc3577
Michal Marek bc3577
Refer to quilt documentation for details. When you are done, add the new
Michal Marek bc3577
patch to an appropriate place in the series.conf file and run
Jeff Mahoney 35fbce
./scripts/log to commit it. Patches should be named such that they
Jeff Mahoney 35fbce
consist of alphanumeric characters, '-', and '.'. Typically, patches are
Jeff Mahoney 35fbce
named by filtering the Subject of the patch to a lower-case, dash-separated
Jeff Mahoney 35fbce
form like the one in the example above.
Michal Marek bc3577
Michal Marek bc3577
To build rpm packages:
Michal Marek bc3577
Michal Marek bc3577
    $ ./scripts/tar-up.sh
Michal Marek bc3577
Michal Marek bc3577
This creates a source package in the kernel-source directory. Use
Michal Marek de8dd7
Michal Marek de8dd7
    $ ./scripts/osc_wrapper [kernel-source/kernel-$flavor.spec]
Michal Marek de8dd7
Michal Marek de8dd7
to build a kernel package locally, or
Michal Marek de8dd7
Michal Marek de8dd7
    $ ./scripts/osc_wrapper upload [--ibs]
Michal Marek de8dd7
Michal Marek de8dd7
to have all flavors and architectures built by the Open Build Service.
Michal Marek de8dd7
The --ibs option uses the SUSE internal instance.
Michal Marek bc3577
Michal Marek a6afa1
Michal Marek a6afa1
Patch Headers
Michal Marek a6afa1
=============
Michal Marek a6afa1
Michal Marek a6afa1
Each patch must have a RFC822-style header that at a minimum describes
Olaf Hering fbc8e4
what the patch does, who wrote it, and who inside SUSE we'll
Michal Marek a6afa1
"blame" about problems with the patch.  The rules for patch headers are:
Michal Marek a6afa1
Michal Marek a6afa1
 * Each patch must have a From: tag that identifies the author of the
Michal Marek a6afa1
   patch.
Michal Marek a6afa1
Michal Marek a6afa1
 * Each patch must have a Subject: tag that briefly describes what
Michal Marek a6afa1
   the patch does.  A brief summary is it could show up in a change
Michal Marek a6afa1
   log makes the most sense in most cases.
Michal Marek a6afa1
Michal Marek a6afa1
 * Unless the author identified in the From: tag has a @suse.de,
Michal Suchanek 65d0b2
   @suse.com or @suse.cz, address, the patch must include a Signed-off-by:,
Michal Suchanek 65d0b2
   Acked-by: or Reviewed-by: header which identifies the person in one of
Michal Suchanek 65d0b2
   these domains who feels responsible for the patch inside the company.
Michal Marek a6afa1
Michal Marek 067f88
 * The patch must include a Patch-mainline: tag that identifies where
Michal Marek a6afa1
   the patch came from (for backports from mainline), or when it is
Benjamin Poirier 2d0738
   expected to be added to mainline. The format is one of:
Benjamin Poirier 2d0738
Benjamin Poirier 2d0738
   For backports from mainline:
Benjamin Poirier 2d0738
        Patch-mainline: <upstream version, ex. "v3.5-rc1">
Benjamin Poirier 2d0738
        Git-commit: <git hash>
Benjamin Poirier 2d0738
Benjamin Poirier 2d0738
   If the commit is from a maintainer repository or some other
Benjamin Poirier 2d0738
   repository that isn't Linus's:
Benjamin Poirier 2d0738
        Patch-mainline: Queued in subsystem maintainer repository
Benjamin Poirier 2d0738
        Git-repo: <url>
Benjamin Poirier 2d0738
        Git-commit: <git hash>
Benjamin Poirier 2d0738
Benjamin Poirier 2d0738
   If the patch is not upstream, depending on the situation:
Benjamin Poirier 2d0738
        Patch-mainline: Submitted, <timestamp - destination>
Benjamin Poirier 2d0738
Benjamin Poirier 2d0738
        Patch-mainline: Not yet, <reason>
Benjamin Poirier 2d0738
Benjamin Poirier 2d0738
        Patch-mainline: Never, <reason>
Michal Marek a6afa1
Michal Suchanek 65d0b2
 * The patch should include a References: tag that identifies the Bugzilla bug
Michal Suchanek 65d0b2
   number, JIRA epic, etc. where the patch is discussed.  Please prefix
Michal Suchanek 65d0b2
   bugzilla.suse.com bug numbers with bsc# and JIRA epic numbers with jsc#.
Michal Suchanek 65d0b2
   Please make sure you reference a JIRA epic when referencin JIRA features.
Michal Suchanek 65d0b2
   Have a look at
Michal Kubecek 612090
   http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines#Current_set_of_abbreviations
Michal Marek 54439e
   for a full list of abbreviations.
Thomas Zimmermann 097d8f
Michal Marek a6afa1
 * The patch header may (and often, should) include a more extensive
Michal Marek a6afa1
   description of what the patch does, why, and how.  The idea is to
Michal Marek a6afa1
   allow others to quickly identify what each patch is about, and to
Michal Marek a6afa1
   give enough information for reviewing.
Michal Marek a6afa1
Michal Marek a6afa1
More details about valid patch headers can be found in
Michal Marek a6afa1
scripts/patch-tag-template.  The helper script scripts/patch-tag can be
Michal Marek a6afa1
used for managing these tags.  Documentation for patch-tag can be found
Michal Marek a6afa1
at the top of the script itself.
Michal Marek a6afa1
Michal Marek a6afa1
Example usage of scripts/patch-tag-template:
Michal Marek a6afa1
Michal Marek a6afa1
    $ cp scripts/patch-tag-template ~/.patchtag
Michal Marek a6afa1
Michal Marek a6afa1
    Edit ~/.patchtag with any default values you want
Michal Marek a6afa1
Michal Marek a6afa1
    $ patch-tag -e file.diff
Michal Marek a6afa1
Michal Marek a6afa1
Example patch header:
Michal Marek a6afa1
Michal Marek 54439e
    | Date: Fri, Sep 26 2008 15:20:10 +1000
Michal Marek 54439e
    | From: Peter Leckie <pleckie@sgi.com>
Michal Marek 54439e
    | References: SGI:PV986789 bnc#482148
Michal Marek 54439e
    | Subject: Clean up dquot pincount code
Thomas Zimmermann 57b996
    | Patch-mainline: v2.6.28
Thomas Zimmermann 097d8f
    |
Michal Marek 54439e
    | Clean up dquot pincount code.
Thomas Zimmermann 097d8f
    |
Michal Marek 54439e
    | This is a code cleanup and optimization that removes a per mount point
Michal Marek 54439e
    | spinlock from the quota code and cleans up the code.
Thomas Zimmermann 097d8f
    |
Michal Marek 54439e
    | The patch changes the pincount from being an int protected by a spinlock
Michal Marek 54439e
    | to an atomic_t allowing the pincount to be manipulated without holding
Michal Marek 54439e
    | the spinlock.
Thomas Zimmermann 097d8f
    |
Michal Marek 54439e
    | This cleanup also protects against random wakup's of both the aild and
Michal Marek 54439e
    | xfssyncd by reevaluating the pincount after been woken. Two latter patches
Michal Marek 54439e
    | will address the Spurious wakeups.
Thomas Zimmermann 097d8f
    |
Michal Marek 54439e
    | Signed-off-by: Peter Leckie <pleckie@sgi.com>
Michal Marek 54439e
    | Acked-by: Jan Kara <jack@suse.cz>
Michal Marek a6afa1
Benjamin Poirier 636f80
Patch sorting
Benjamin Poirier 636f80
=============
Benjamin Poirier 636f80
Benjamin Poirier 636f80
Patches added to the "sorted patches" section of series.conf must be sorted
Benjamin Poirier 636f80
according to the upstream order of the commit that they backport.
Benjamin Poirier 636f80
Benjamin Poirier 636f80
After you've added a patch file to one of the patches.* directory and added the
Benjamin Poirier 636f80
required tags described in the section "Patch Headers", run
Benjamin Poirier 636f80
Benjamin Poirier 636f80
    $ ./scripts/git_sort/series_insert.py <patch>
Benjamin Poirier 636f80
Benjamin Poirier 636f80
to insert an entry for a new patch file to the sorted section of series.conf.
Benjamin Poirier 636f80
Thomas Zimmermann 097d8f
For more information, please read "scripts/git_sort/README.md".
Benjamin Poirier 636f80
Michal Marek a6afa1
Before You Commit -- Things To Check
Michal Marek a6afa1
====================================
Michal Marek a6afa1
Michal Marek a6afa1
Make sure that all patches still apply after your changes.  One way of
Michal Marek a6afa1
doing this is using scripts/sequence-patch.sh:
Michal Marek a6afa1
Michal Marek a6afa1
    $ export SCRATCH_AREA=/var/tmp/scratch
Michal Marek a6afa1
    $ scripts/sequence-patch.sh
Michal Suchanek b70c29
    Creating tree in /var/tmp/scratch/linux-5.3-SLE15-SP3
Michal Suchanek b70c29
    Cleaning up from previous run
Michal Suchanek b70c29
    Linking from /var/tmp/scratch/linux-5.3.orig
Michal Suchanek b70c29
    Applying 50892 patches using 4 threads...
Michal Suchanek b70c29
    Saving modified files...
Michal Suchanek b70c29
    [ Tree: /var/tmp/scratch/linux-5.3-SLE15-SP3 ]
Michal Suchanek b70c29
    [ Generating Module.supported ]
Michal Suchanek b70c29
    [ Copying config/x86_64/default ]
Michal Suchanek b70c29
Michal Suchanek b70c29
Note the Tree: line output by the sequence-patch.sh script which
Michal Suchanek b70c29
specifies the location of the expanded kernel tree that is configured
Michal Suchanek b70c29
for local build.
Michal Marek a6afa1
Please test-compile the kernel or even test-build kernel packages,
Michal Marek a6afa1
depending on the impact of your changes.  Use scripts/tar-up.sh for
Michal Suchanek b70c29
creating an OBS package directory.
Michal Marek a6afa1
Michal Marek a6afa1
The kernel source tree that scripts/sequence-patch.sh creates can be
Jiri Slaby aef2a2
test-compiled. Before that, make sure all prerequisites are installed.
Jiri Slaby aef2a2
These include libopenssl-devel, libelf-devel, and dwarves (look into
Jiri Slaby aef2a2
rpm/kernel-binary.spec.in for a complete list). Then, the compilation
Jiri Slaby aef2a2
can be done as follows:
Michal Marek a6afa1
Michal Suchanek b70c29
    $ cd /var/tmp/scratch/linux-5.3-SLE15-SP3
Michal Marek a6afa1
    $ make oldconfig
Michal Marek a6afa1
    $ make
Michal Marek a6afa1
Juergen Gross c8c419
When committing a patch series try to make the series easy bisectable,
Juergen Gross c8c419
i.e. when applying only the first x patches (1 <= x <= n, n being the
Juergen Gross c8c419
number of patches in the series) the kernel is still buildable and
Juergen Gross c8c419
functional.
Juergen Gross c8c419
Juergen Gross c8c419
This means especially, that just adding upstream patches unmodified
Juergen Gross c8c419
to a series and doing a cleanup patch at the end of the series to
Juergen Gross c8c419
ensure the kernel is buildable and functional is to be avoided. Each
Juergen Gross c8c419
patch from upstream should be modified as required to fit into the
Juergen Gross c8c419
kernel it is backported to, both for build time and runtime.
Juergen Gross c8c419
Juergen Gross c8c419
In cases where upstream patches did cause a breakage (either build or
Juergen Gross c8c419
functional) which was corrected by a later patch and both patches are
Juergen Gross c8c419
part of the series, try to place the correcting patch as near as
Juergen Gross c8c419
possible to the patch causing breakage.
Michal Marek a6afa1
Michal Marek a6afa1
Config Option Changes
Michal Marek a6afa1
=====================
Michal Marek a6afa1
Michal Marek a6afa1
We are building kernel packages for various architectures and
Michal Marek a6afa1
configurations from the same sources.  Each such kernel has its own
Michal Marek a6afa1
configuration file in config/$ARCH/$FLAVOR.  There are checks in place
Michal Marek a6afa1
that abort the kernel build when those configuration files are missing
Michal Marek a6afa1
config options.
Michal Marek a6afa1
Michal Marek a6afa1
When adding patches that add kernel config options, please also update
Michal Marek a6afa1
all config files as follows:
Michal Marek a6afa1
Michal Marek a6afa1
    $ scripts/sequence-patch.sh
Michal Suchanek b70c29
    $ cd /var/tmp/scratch/linux-5.3-SLE15-SP3
Michal Marek a6afa1
    $ patches/scripts/run_oldconfig.sh
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Committing and Log Messages
Michal Marek a6afa1
===========================
Michal Marek a6afa1
Michal Marek a6afa1
Any commit which affects the kernel package (rather than internals of the
Michal Marek a6afa1
repository such as helper scripts) should be documented in
Michal Marek a6afa1
kernel-source.changes.  The log entry must include the timestamp
Michal Marek a6afa1
(`date`), email address of the committer, and a change summary, and
Michal Marek a6afa1
should include the names of the affected files, as in the following
Michal Marek a6afa1
example:
Michal Marek a6afa1
Michal Marek a6afa1
    | -------------------------------------------------------------------
Michal Marek a6afa1
    | Wed Dec  1 18:29:44 CET 2004 - agruen@suse.de
Thomas Zimmermann 097d8f
    |
Michal Marek a6afa1
    | - patches.fixes/serialize-dgram-read.diff: Serialize dgram read
Michal Marek a6afa1
    |   using semaphore just like stream (#48427).
Thomas Zimmermann 097d8f
    |
Michal Marek a6afa1
Michal Marek a6afa1
There is a simple helper script for creating changelog entries in this
Michal Marek a6afa1
format (/work/src/bin/vc).
Michal Marek a6afa1
Michal Marek a6afa1
An advanced script (scripts/log) for creating changelog entries from
Michal Marek a6afa1
patch headers, and then automatically committing the change, exists as
Michal Marek a6afa1
well.  This script extracts Subject: and References: headers from added
Michal Marek a6afa1
or modified patches and generates a changelog entry proposal that the
Michal Marek a6afa1
user can further modify.  This approach works well for new or removed
Michal Marek a6afa1
patches.  When modifying existing patches, it usually is necessary to
Michal Marek a6afa1
modify the generated changelog entry by hand.  (scripts/log requires the
Michal Marek a6afa1
vc helper script either in the PATH, or in /work/src/bin/).
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
What Is The Kernel ABI?
Michal Marek a6afa1
=======================
Michal Marek a6afa1
Michal Marek a6afa1
All symbols that the kernel exports for use by modules, and all symbols
Michal Marek a6afa1
that modules export for use by other modules, are associated with a
Michal Marek a6afa1
so-called modversion, which is a checksum of the type of the symbol
Michal Marek a6afa1
(including all sub-types involved).  Symbols that a module imports are
Michal Marek a6afa1
associated with the identical checksum.
Michal Marek a6afa1
Michal Marek a6afa1
When a module is loaded, the kernel makes sure that the checksums of the
Michal Marek a6afa1
exported symbols match the checksums of the imported symbols.
Michal Marek a6afa1
Michal Marek a6afa1
The kernel exports a large number of symbols (in the range of 5000).  We
Michal Marek a6afa1
could Provide and Require all those symbols as RPM package dependencies,
Michal Marek a6afa1
so that then those dependencies would make sure that all packages
Michal Marek a6afa1
containing kernel modules would have a matching kernel installed.
Michal Marek a6afa1
Michal Marek a6afa1
RPM does not easily handle such large amounts of dependencies though,
Michal Marek a6afa1
and so instead of modeling dependencies based on individual symbols, we
Michal Marek a6afa1
compute distinct classes of symbols, and we create one "kernel(...)"
Michal Marek a6afa1
RPM dependency per class.
Michal Marek a6afa1
Michal Marek a6afa1
Modifying, adding, or removing kernel exports will also change the
Michal Marek a6afa1
kernel(...) symbols.
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Kernel ABI Changes
Michal Marek a6afa1
==================
Michal Marek a6afa1
Michal Marek a6afa1
During kernel builds, two things related to the kernel ABI happen:
Michal Marek a6afa1
Michal Marek a6afa1
 * If a reference symvers file (/boot/symvers-* in kernel-$FLAVOR
Michal Marek a6afa1
   packages) for the particular architecture and flavor is available, we
Michal Marek a6afa1
   check how severe the ABI changes are compared to this reference.
Michal Marek a6afa1
   These reference files are located in kabi/$ARCH/symvers-$FLAVOR.  Too
Michal Marek a6afa1
   severe changes will abort the build.  See rpm/kernel-binary.spec.in
Michal Marek 2fbe62
   and scripts/kabi-checks (SLES9 - SLES10) or rpm/symsets.pl (SLES11)
Michal Marek 2fbe62
   for details.
Michal Marek a6afa1
Michal Marek a6afa1
 * We want to avoid losing kernel(...) symbols when additional symbols
Michal Marek a6afa1
   are added, but all previous symbols are still available: in this
Michal Marek a6afa1
   case, all modules will continue to load into the new kernel just
Michal Marek a6afa1
   fine.
Thomas Zimmermann 097d8f
Michal Marek a6afa1
   If a reference symsets file (/boot/symsets-* in kernel-$FLAVOR
Michal Marek a6afa1
   packages) for the particular architecture and flavor is available, we
Michal Marek a6afa1
   check which of the symbol sets in the reference file can still be
Michal Marek a6afa1
   exported, even though symbols have meanwhile been added.  We also
Michal Marek a6afa1
   export the kernel(...) symbols from reference symset files.
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek 2fbe62
To update the reference files, use scripts/update-symvers:
Michal Marek a6afa1
Michal Marek 2fbe62
    $ ./scripts/update-symvers kernel-default-2.6.27.25-0.1.1.x86_64.rpm \
Michal Marek 2fbe62
         kernel-default-2.6.27.25-0.1.1.i586.rpm ...
Michal Marek a6afa1
Michal Marek 2fbe62
It is also possible to update only a subset of the symbols, e.g.:
Michal Marek 2fbe62
Michal Marek 2fbe62
    $ ./scripts/update-symvers --filter=fs/xfs ...
Michal Marek 2fbe62
Michal Marek 2fbe62
In either case, ask the branch owner and kernel packager for permission
Michal Marek 2fbe62
before touching the kabi files.
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Ignoring Kernel ABI Changes
Michal Marek a6afa1
---------------------------
Michal Marek a6afa1
Michal Marek a6afa1
Sometimes we want to tolerate particular kernel ABI changes (and not
Michal Marek a6afa1
abort the builds).  At the same time, we do not want to update the
Michal Marek a6afa1
reference symvers and symsets files, because we still want to monitor the
Michal Marek a6afa1
relative changes, and we want to continue preserving all symbol sets
Michal Marek a6afa1
which are still compatible.
Michal Marek a6afa1
Michal Marek a6afa1
Particular kernel can be marked so that kernel ABI changes are ignored.
Michal Marek a6afa1
This is done by creating kabi/$ARCH/ignore-$FLAVOR files (e.g.,
Michal Marek a6afa1
kabi/x86_64/ignore-xen, kabi/s390/ignore-default).  The kernel ABI checks
Michal Marek a6afa1
will still be produced, but the build will not be aborted.  The file
Michal Marek a6afa1
contents d not matter.
Michal Marek a6afa1
Michal Marek a6afa1
All kernel ABI changes in all kernel packages can be ignored by creating
Michal Marek a6afa1
a file called IGNORE-KABI-BADNESS in the kernel-source/ sub-directory of
Michal Marek a6afa1
the repository that scripts/tar-up.sh creates.  (This may be necessary
Michal Marek a6afa1
for PTF kernels occasionally.)
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Embargoed Patches
Michal Marek a6afa1
=================
Michal Marek a6afa1
Michal Marek a6afa1
At certain times during development, the kernel may include "embargoed"
Michal Marek a6afa1
patches, i.e., patches that must not be mad available to parties outside
Olaf Hering fbc8e4
of SUSE before an agreed-upon time.  Such patches usually have a
Michal Marek a6afa1
date of publication that has been coordinated among linux distributors,
Michal Marek f826d5
etc. Such patches must not be committed to the usual branches, because
Michal Marek f826d5
these are pushed to a public mirror, but instead to a branch named with
Michal Marek f826d5
an _EMBARGO suffix, e.g. SLE11_BRANCH_EMBARGO. The KOTD scripts will
Michal Marek f826d5
testbuild such branches, but won't publish them. Once the fix becomes
Michal Marek f826d5
public, the branch needs to be merged back info the "mainline" branch,
Michal Marek f826d5
e.g.:
Michal Marek f826d5
Michal Marek f826d5
    $ git checkout SLE11_BRANCH
Michal Marek f826d5
    $ git merge SLE11_BRANCH_EMBARGO
Michal Marek a6afa1
Michal Marek a6afa1
Michal Marek a6afa1
Related Information
Michal Marek a6afa1
===================
Michal Marek a6afa1
Michal Marek 66f9d2
Internal:
Petr Tesarik 2ee9bf
https://wiki.suse.net/index.php/SUSE-Labs_Publications/Kernel_Building
Petr Tesarik 2ee9bf
https://wiki.suse.net/index.php/SUSE-Labs_Publications/kernel_patches_rules
Michal Marek 66f9d2
Michal Marek 66f9d2
Public:
Michal Marek 66f9d2
TBD