Project

General

Profile

Submitting Patches to Linux

We currently submit patches for Linux from our next branch. I try to give a short overview about it using some patches submitted to DaveM.

Following steps must always be done:

  • get the linux-integration + batman-adv repository
  • get the newest patches from next and maint
  • check for compat code
  • squash/cleanup patches
  • fix "Fixes: " and other commit id references
  • check if coccinelle prints new warnings
  • check if all versions compile cleanly using sparse (cgcc)
  • do a merge in a temporary branch and compare the result with batman-adv:next.git
  • check commit messages author/signed-off-by of patches
  • check if all patches are checkpatch.pl clean
  • prepare changelog
  • create tag for david which includes the changelog
  • format patches
  • submit cover letter + patches
  • wait until David accepted the pull request
  • update base patches

Rules for patch handling

  • new patches enter batman-adv.git master branch
  • new patches are forwarded to David from master branch
  • master branch is closed whenever net-next is closed
  • new patches for master should be avoided when Linux -rc7/final is near (which will cause the closing of net-next)

Variables

There are different basepoints/references used when preparing the

  • GIT_OM_SERVER
    • server from which the open-mesh.org repositories are retrieved
  • LM_MASTER
    • name of branch in batman-adv.git which points to the latest patch already ported to linux-merge.git:batadv/net-next
  • LM_MAINT
    • name of branch in batman-adv.git which points to the latest patch already ported to linux-merge.git:batadv/net
  • BASE_NETNEXT
    • some recent commit in net-next.git which should be used as base commit for the patches which will be applied (chose wisely)
  • BASE_NET
    • some recent commit in net.git which should be used as base commit for the patches which will be applied (chose wisely)
GIT_OM_SERVER="git+ssh://git@open-mesh.org" 
LM_MASTER=ecsv/lm_master
LM_MAINT=ecsv/lm_maint
BASE_NETNEXT=v4.16-rc1
BASE_NET=v4.16-rc1

get the linux-integration + batman-adv repository

First step is to actually get the repositories and create the branches. You may also use the --reference option for linux-merge to speedup the download when you already have some linux repository on you system

git clone "${GIT_OM_SERVER}/linux-merge.git" linux-merge
git -C linux-merge remote add net-next git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
git -C linux-merge remote add net git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
git -C linux-merge remote update --prune
git -C linux-merge branch base/net --track origin/base/net
git -C linux-merge branch base/net-next --track origin/base/net-next
git -C linux-merge branch batadv/net --track origin/batadv/net
git -C linux-merge branch batadv/net-next --track origin/batadv/net-next
git clone "${GIT_OM_SERVER}/batman-adv.git" batman-adv
git -C batman-adv branch "${LM_MASTER}" --track "origin/${LM_MASTER}" 
git -C batman-adv branch "${LM_MAINT}" --track "origin/${LM_MAINT}" 

The next step is to make sure that out linux-merge.git branches are either on top or equal the chosen. It should also be checked first that it is really a basepoint in the chosen branches

git -C linux-merge remote update --prune
git -C linux-merge branch -r --contains="${BASE_NET}" net/master
git -C linux-merge branch -r --contains="${BASE_NETNEXT}" net-next/master

git -C linux-merge checkout base/net
git -C linux-merge merge --ff-only "origin/base/net" 
git -C linux-merge merge --ff-only "${BASE_NET}" 

git -C linux-merge checkout base/net-next
git -C linux-merge merge --ff-only "origin/base/net-next" 
git -C linux-merge merge --ff-only "${BASE_NETNEXT}" 

git -C linux-merge push origin base/net base/net-next

Problems during this have to either be fixed by using a correct base commit, fixing the local branches or by rebasing the remaining patches on the batadv/* branches on top of the base commits (think twice before rebasing).

The same has to be done for the batman-adv repository. Here it is is important to update the maint branch manually after releases. Otherwise it would look like patches which were already submitted to net-next have to be send again to net. But make sure that there are no actual fixes between ${LM_MAINT} and origin/maint which were missed earlier

git -C batman-adv remote update --prune

git -C batman-adv checkout "${LM_MAINT}" 
git -C batman-adv merge --ff-only "origin/${LM_MAINT}" 

git -C batman-adv checkout "${LM_MASTER}" 
git -C batman-adv merge --ff-only "origin/${LM_MASTER}" 

get the newest patches

from master

cd batman-adv
git checkout -B rebase --no-track origin/master
GIT_SEQUENCE_EDITOR="sh -c 'git rev-list --reverse --no-merges '\\''${LM_MASTER}..origin/master'\\'' --not origin/maint|awk '\\''{ print \"pick \"\$1}'\\'' > \$1' \$@" \
 git rebase -i origin/maint --onto "${LM_MASTER}" --no-ff

This patches have to be cleaned up. First these these changes have to be squashed so that "Fixes: " patches are squashed together with the patches which introduced the problem (when they exist). Also compat code has to be removed. Both things can be identified with git log:

Patches with "Fixes: " lines:

git log --grep='^Fixes: ' "${LM_MASTER}"..rebase

The extra stuff which should not be submitted can be identified via:

git log --stat --oneline "${LM_MASTER}"..rebase -- compat-sources compat-include README.external CHANGELOG Makefile .gitignore .gitattributes compat.h gen-compat-autoconf.sh README

This can all be cleaned up by using git-rebase and then marking the relevant commits for editing. It may also be a good idea to move patches like "Start-new-development-cycle" to the front

git rebase -i "${LM_MASTER}" 

# edit the commit message to point to the correct upstream commit -- just search in linux-merge for the commit name
git commit --amend

# remove changes either reverting to previous versions (new files have to be deleted)
git checkout HEAD~1 compat-sources compat-include README.external CHANGELOG Makefile .gitignore .gitattributes compat.h gen-compat-autoconf.sh README

# delete some new file (example)
git rm -f compat-include/net/genetlink.h

# at the end continue with the rebase to the next commit
git rebase --continue

It is a good idea to check again if some file was missed. It is also a good idea to manually check the commit messages for other commit references:

git log --stat "${LM_MASTER}"..rebase

If everything looks good then these patches should be formatted (make sure that you don't have some old patches in the directory). The branch of already prepared patches has to be updated

git format-patch -s "${LM_MASTER}"..rebase
git checkout "${LM_MASTER}" 
git merge --ff-only origin/master
git push origin "${LM_MASTER}" 

Save the generated patches to a save place. Lets call this place $EXPORTED_PATCHES_MASTER

from maint

Make sure that ${LM_MASTER} was updated after a release correctly and ${LM_MASTER}..origin/maint is containing patches which were send to net-next

The rest of the rebase process works similar to the next process

cd batman-adv
git checkout -B rebase --no-track origin/maint
git rebase -i "${LM_MAINT}" 

This patches have to be cleaned up. First these these changes have to be squashed so that "Fixes: " patches are squashed together with the patches which introduced the problem (when they exist). Also compat code has to be removed. Both things can be identified with git log:

Patches with "Fixes: " lines:

git log --grep='^Fixes: ' "${LM_MAINT}"..rebase

The extra stuff which should not be submitted can be identified via:

git log --stat --oneline "${LM_MAINT}"..rebase -- compat-sources compat-include README.external CHANGELOG Makefile .gitignore .gitattributes compat.h gen-compat-autoconf.sh README

This can all be cleaned up by using git-rebase and then marking the relevant commits for editing. It may also be a good idea to move patches like "Start-new-development-cycle" to the front

git rebase -i "${LM_MAINT}" 

# edit the commit message to point to the correct upstream commit -- just search in linux-merge for the commit name
git commit --amend

# remove changes either reverting to previous versions (new files have to be deleted)
git checkout HEAD~1 compat-sources compat-include README.external CHANGELOG Makefile .gitignore .gitattributes compat.h gen-compat-autoconf.sh README

# delete some new file (example)
git rm -f compat-include/net/genetlink.h

# at the end continue with the rebase to the next commit
git rebase --continue

It is a good idea to check again if some file was missed. It is also a good idea to manually check the commit messages for other commit references or missing signed-off-by:

git log --stat "${LM_MAINT}"..rebase

If everything looks good then these patches should be formatted (make sure that you don't have some old patches in the directory). The branch of already prepared patches has to be updated

git format-patch -s "${LM_MAINT}"..rebase
git checkout "${LM_MAINT}" 
git merge --ff-only origin/maint
git push origin "${LM_MAINT}" 

Save the generated patches to a save place. Lets call this place $EXPORTED_PATCHES_MAINT

Apply patches on linux-merge

from master

The patches were already exported. So they only have to be applied in the correct branch

cd linux-merge
git checkout batadv/net-next
git merge --ff-only origin/batadv/net-next
./scripts/checkpatch --strict "${EXPORTED_PATCHES_MASTER}"/*.patch
git am -s "${EXPORTED_PATCHES_MASTER}"/*.patch
git push origin batadv/net-next

from maint

The patches were already exported. So they only have to be applied in the correct branch

cd linux-merge
git checkout batadv/net
git merge --ff-only origin/batadv/net
./scripts/checkpatch --strict "${EXPORTED_PATCHES_MAINT}"/*.patch
git am -s "${EXPORTED_PATCHES_MAINT}"/*.patch
git push origin batadv/net

check if coccinelle prints new warnings

make coccicheck KBUILD_EXTMOD=net/batman-adv/

check if all versions compile cleanly using sparse (cgcc)

First the linux-merge build environment has to be prepared

make allnoconfig
cat >> .config << EOF
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_SMP=y
CONFIG_EMBEDDED=n
CONFIG_EXPERT=n
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODVERSIONS=y
CONFIG_MODULE_SRCVERSION_ALL=y

CONFIG_CRC16=y
CONFIG_LIBCRC32C=y
CONFIG_NET=y
CONFIG_INET=y
CONFIG_DEBUG_FS=y
CONFIG_IPV6=y
CONFIG_BRIDGE=y
CONFIG_VLAN_8021Q=y
CONFIG_WIRELESS=y
CONFIG_CFG80211=y
CONFIG_CFG80211=y

CONFIG_BATMAN_ADV=y
CONFIG_BATMAN_ADV_BATMAN_V=y
CONFIG_BATMAN_ADV_BLA=y
CONFIG_BATMAN_ADV_DAT=y
CONFIG_BATMAN_ADV_NC=y
CONFIG_BATMAN_ADV_MCAST=y

CONFIG_CC_STACKPROTECTOR_STRONG=y
CONFIG_LOCKUP_DETECTOR=y
CONFIG_DETECT_HUNG_TASK=y
CONFIG_SCHED_STACK_END_CHECK=y
CONFIG_DEBUG_RT_MUTEXES=y
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DEBUG_MUTEXES=y
CONFIG_PROVE_LOCKING=y
CONFIG_LOCK_STAT=y
CONFIG_DEBUG_LOCKDEP=y
CONFIG_DEBUG_ATOMIC_SLEEP=y
CONFIG_DEBUG_LIST=y
CONFIG_DEBUG_PI_LIST=y
CONFIG_DEBUG_SG=y
CONFIG_DEBUG_NOTIFIERS=y
CONFIG_PROVE_RCU_REPEATEDLY=y
CONFIG_SPARSE_RCU_POINTER=y
CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
CONFIG_X86_VERBOSE_BOOTUP=y
CONFIG_DEBUG_RODATA=y
CONFIG_DEBUG_RODATA_TEST=n
CONFIG_DEBUG_SET_MODULE_RONX=y
CONFIG_PAGE_EXTENSION=y
CONFIG_DEBUG_PAGEALLOC=y
CONFIG_DEBUG_OBJECTS=y
CONFIG_DEBUG_OBJECTS_FREE=y
CONFIG_DEBUG_OBJECTS_TIMERS=y
CONFIG_DEBUG_OBJECTS_WORK=y
CONFIG_DEBUG_OBJECTS_RCU_HEAD=y
CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_STACK_USAGE=y
CONFIG_DEBUG_STACKOVERFLOW=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_DWARF4=y
CONFIG_GDB_SCRIPTS=y
CONFIG_READABLE_ASM=y
CONFIG_STACK_VALIDATION=y
CONFIG_WQ_WATCHDOG=y
CONFIG_DEBUG_KOBJECT_RELEASE=y
CONFIG_DEBUG_WQ_FORCE_RR_CPU=y
CONFIG_OPTIMIZE_INLINING=y
EOF
make olddefconfig
make -j$(nproc || echo 1)

Then the rebuild has to be done between batadv/net-next and base/net-next (or between batadv/net and base/net) for each commit:

git checkout batadv/net-next
git rebase -i base/net-next -x 'make C=1'

check if all patches are in linux-merge

TODO

submit patches

TODO

A good commit in has to be chosen. We should not send more than 20 patches for net-next for each pull request. A lower number (6?) of patches should be used for net.

Lets assume a good commit is 4e3e823b5a503235630921287f130e1d8d22d200

TAG=batadv-next-for-davem-20160701
git tag -s ${TAG} 4e3e823b5a503235630921287f130e1d8d22d200
# write a good commit message
git push origin ${TAG}

The patches then have to be prepared and the cover letter has to be created for the pull request. For net-next it would look like:

TAG=batadv-next-for-davem-20160701
git format-patch --cover-letter base/net-next..${TAG}
sed -i '/\*\*\* BLURB HERE \*\*\*/q' 0000-cover-letter.patch
git request-pull base/net-next git://git.open-mesh.org/linux-merge.git ${TAG} >> 0000-cover-letter.patch
# write cover letter
git send-email --to=davem@davemloft.net --cc=netdev@vger.kernel.org --cc=b.a.t.m.a.n@lists.open-mesh.org 00*.patch

or for net:

TAG=batadv-net-for-davem-20160701
git format-patch --cover-letter base/net..${TAG}
sed -i '/\*\*\* BLURB HERE \*\*\*/q' 0000-cover-letter.patch
git request-pull base/net git://git.open-mesh.org/linux-merge.git ${TAG} >> 0000-cover-letter.patch
# write cover letter
git send-email --to=davem@davemloft.net --cc=netdev@vger.kernel.org --cc=b.a.t.m.a.n@lists.open-mesh.org 00*.patch

Now I will write something like

Subject: pull request for net-next: batman-adv 2016-07-01

Hi David,

we are a bit late to submit our feature patches, but I hope we make it in time.
Antonio is taking a pause in his upstream work, so I'll be submitting our
batman-adv patches for now. It is my first time, so please bear with me. 

Please pull or let me know of any problem!

Thank you,
      Simon

The following changes since commit 99860208bc62d8ebd5c57495b84856506fe075bc:

  sched: remove NET_XMIT_POLICED (2016-06-12 22:02:11 -0400)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20160701

for you to fetch changes up to 4e3e823b5a503235630921287f130e1d8d22d200:

  batman-adv: Add debugfs table for mcast flags (2016-06-30 10:29:43 +0200)

----------------------------------------------------------------
This feature patchset includes the following changes:

 - two patches with minimal clean up work by Antonio Quartulli and
   Simon Wunderlich

 - eight patches of B.A.T.M.A.N. V, API and documentation clean
   up work, by Antonio Quartulli and Marek Lindner

 - Andrew Lunn fixed the skb priority adoption when forwarding
   fragmented packets (two patches)

 - Multicast optimization support is now enabled for bridges which
   comes with some protocol updates, by Linus Luessing

----------------------------------------------------------------
Andrew Lunn (2):
  batman-adv: Set skb priority in fragments
  batman-adv: Include frame priority in fragment header

Antonio Quartulli (4):
  batman-adv: statically print gateway table header
  batman-adv: remove ogm_emit and ogm_schedule API calls
  batman-adv: remove useless inline attribute for sysfs helper function
  batman-adv: move GW mode and selection class to private data structure

Linus Lüssing (4):
  batman-adv: Always flood IGMP/MLD reports
  batman-adv: Add multicast optimization support for bridged setups
  batman-adv: Adding logging of mcast flag changes
  batman-adv: Add debugfs table for mcast flags

Marek Lindner (5):
  batman-adv: document sysfs files in alphabetical order
  batman-adv: update elp interval documentation
  batman-adv: refactor batadv_neigh_node_* functions to follow common
    style
  batman-adv: remove unused callback from batadv_algo_ops struct
  batman-adv: init ELP tweaking options only once

Simon Wunderlich (2):
  batman-adv: Start new development cycle
  batman-adv: remove unused vid local variable in tt seq print

 .../ABI/testing/sysfs-class-net-batman-adv         |  20 +-
 net/batman-adv/Kconfig                             |   2 +-
 net/batman-adv/bat_algo.h                          |   7 +-
 net/batman-adv/bat_iv_ogm.c                        |  72 ++-
 net/batman-adv/bat_v.c                             |  29 +-
 net/batman-adv/bat_v_elp.c                         |   4 +-
 net/batman-adv/bat_v_ogm.c                         |   4 +-
 net/batman-adv/debugfs.c                           |  23 +
 net/batman-adv/fragmentation.c                     |  12 +-
 net/batman-adv/gateway_client.c                    |  15 +-
 net/batman-adv/gateway_common.c                    |   6 +-
 net/batman-adv/hard-interface.c                    |   6 +-
 net/batman-adv/main.c                              |   2 -
 net/batman-adv/main.h                              |   6 +-
 net/batman-adv/multicast.c                         | 499 +++++++++++++++++++--
 net/batman-adv/multicast.h                         |   3 +
 net/batman-adv/originator.c                        |  40 +-
 net/batman-adv/originator.h                        |   6 +-
 net/batman-adv/packet.h                            |   7 +-
 net/batman-adv/routing.c                           |   2 +
 net/batman-adv/send.c                              |  61 +--
 net/batman-adv/send.h                              |   4 +-
 net/batman-adv/soft-interface.c                    |  10 +-
 net/batman-adv/sysfs.c                             |  22 +-
 net/batman-adv/translation-table.c                 |   2 -
 net/batman-adv/types.h                             |  32 +-
 26 files changed, 704 insertions(+), 192 deletions(-)

update base patches after successful pull request

TODO