Maintaining an Out-of-Tree Driver and an Upstream Driver - - PowerPoint PPT Presentation

maintaining an out of tree driver and an upstream driver
SMART_READER_LITE
LIVE PREVIEW

Maintaining an Out-of-Tree Driver and an Upstream Driver - - PowerPoint PPT Presentation

Maintaining an Out-of-Tree Driver and an Upstream Driver Simultaneously (with minimal pain) Catherine Sullivan Intel LinuxCon 2015 Me Intel ND Linux 40G product line Ethernet drivers A little 10G 2 Network Platforms Group 2 Overview


slide-1
SLIDE 1

Maintaining an Out-of-Tree Driver and an Upstream Driver Simultaneously

(with minimal pain)

Catherine Sullivan

Intel LinuxCon 2015

slide-2
SLIDE 2

Network Platforms Group 2

Intel ND Linux Ethernet drivers 40G product line A little 10G

Me

2

slide-3
SLIDE 3

Network Platforms Group 3

Why do we need two drivers? How ixgbe and igb maintain two drivers The problems we had with that method How i40e maintains two drivers The advantages to the new method What our continuing problems are Future steps

Overview

slide-4
SLIDE 4

Network Platforms Group 4

Why do we need two drivers?

Out-of-tree

OEMs need a driver for the CD they ship with the hardware Backwards kernel compatibility Sandbox to play

Silicon validation Emulation platforms A0 hardware

Stand-alone driver

Upstream

Distros pull driver patches from the kernel Easier for customers using the latest kernel to have the driver built in

slide-5
SLIDE 5

Network Platforms Group 5

We submit patches to intel-wired-lan list which are tracked by patchwork Jeff Kirsher applies them to his queue on kernel.org Our validation engineer tests the patch Jeff submits the patches to net(-next)

How ND submits patches upstream

slide-6
SLIDE 6

Network Platforms Group 6

The developer is responsible

The developer has to generate two patches, one for each driver and submit them

Community patches get pulled into the Out- Of-Tree driver by the development team

How ixgbeand igbwork

slide-7
SLIDE 7

Network Platforms Group 7

Easy to miss patches – no one is checking that everything is upstream No easy way to compare drivers Community patches often get missed because no one person is responsible for them

The problems with this method

slide-8
SLIDE 8

Network Platforms Group 8

The BIG Problem

Duplicate work becomes much worse when there is more work to duplicate

slide-9
SLIDE 9

Network Platforms Group 9

The new method used for i40e

Automation - https://xkcd.com/1319/

slide-10
SLIDE 10

Network Platforms Group 10 10

Kernel stripped build of Out-Of-Tree driver

Build flags to strip/transform code ixgbe and igb actually have this but don’t use it this way

kernelpatch.sh

Script to generate upstream patches between two tags

Human

Apply and fix-up patches

The new method used for i40e

slide-11
SLIDE 11

Network Platforms Group 11

Kernel stripped build of Out-Of-Tree driver

Strip Flags Keep Flags unifdef BUILD=KERNEL flag

Legacy Interrupts VXLAN

11

# build.mk # Makefile for generating stripped source for various build types # # Strip flags: if preceded by a –D, removes #ifdefs but leaves code # removes #ifndefs and code # if preceded by a –U, removes #ifdefs and code # removes #ifndefs but leaves code # Keep flags: if not specified removes all #ifdefs and code # removes all #ifndefs but leaves code # if specified leaves #ifdef and code # leaves #ifndefs and code # if prefixed with - removes #ifdefs but leaves code # removes #ifndefs and code # Note that strip flags always apply first!

slide-12
SLIDE 12

Network Platforms Group 12

Coccinelle patches

Semantic patches to make code more upstream conformant

Script to fix duplicate definitions in i40e and i40evf

Kernel stripped build of Out-Of-Tree driver

12

// put parens around the ‘-’ match in order to make the parser not leave // extraneous () around ((ret == I40E_SUCCESS) && foo) transforms @@ expression E; @@

  • (E == I40E_SUCCESS)

+ !E @@ expression E; @@

  • (E !=I40E_SUCCESS)

+ E

slide-13
SLIDE 13

Network Platforms Group 13

kernelpatch.sh

Takes one or two tags as arguments Check the tags exist in the repos Reset to first tag Save i40e(vf)-a Iterate over patches

Checkout next patch Save i40e(vf)-b Check parent

git rev-parse --verify “$SHA^”

Save diff of A and B, the patch description, and sha Save the title into list Save B into A Clean the directory

13

slide-14
SLIDE 14

Network Platforms Group 14 14

Remove reverted patches Remove empty patches Create list of ALL patch titles Additional options

Email patches to author & maintainer Generate a single patch

kernelpatch.sh

14

function usage() { echo “Usage: $0 <prevtag> [<stoptag>] \ [email <name> [test]] [single <core|shared>]” }

slide-15
SLIDE 15

Network Platforms Group 15 15

Apply patch

Resolve conflicts

Squash patches if necessary

Patches in the same series that touch the same code is frowned upon

test.sh

Compiles i40e & i40evf Sparse check checkpatch.pl Check patch description

Human

slide-16
SLIDE 16

Network Platforms Group 16 16

testall.sh <n>

Git rebase interactive, execute test.sh on each patch

Format and email patches to intel-wired-lan

Human

slide-17
SLIDE 17

Network Platforms Group 17 17

git rebase –i

Reorder, squish, change description, edit patch, execute a command Edit and cleanup the stack of patches

git notes

Add notes to a commit without changing the commit Helpful noting that a future patch has to be squashed with this patch

Tools that help

slide-18
SLIDE 18

Network Platforms Group 18 18

git cola

GUI Git tool Helpful for splitting code into multiple patches

Meld

Visual diff Great for comparing BUILD=KERNEL driver to upstream driver

Tools that help

slide-19
SLIDE 19

Network Platforms Group 19

Advantages

Still extra work but not double - more is automated Harder to miss a patch because every patch is generated for you Can diff BUILD=KERNEL and upstream to see difference (hopefully none) Have a good starting point to automate more going forward

slide-20
SLIDE 20

Network Platforms Group 20

Problems that still exist

Hard to catch up if we fall behind

Becomes vicious circle

Currently still need a human

Merge conflicts still regularly occur Not everyone runs upstream checks

20

Delicious - https://xkcd.com/140/

slide-21
SLIDE 21

Network Platforms Group 21 21

Pulling patches down in the other direction

Currently we still rely on developers to pull a patch down from upstream into the Out-Of-Tree driver Need to automate this because patches get missed

Still need validation resources for every patch

Problems that still exist

slide-22
SLIDE 22

Network Platforms Group 22 22

Unit testing on every patch submitted to the Out-Of-Tree driver

Checkpatch.pl Sparse check Upstream compile check

Add a squash flag that can be recognized by the script and automatically squash anything necessary During nightly builds for the Out-Of-Tree driver, run kernelpatch.sh with the email option

Future Work –Automate!

slide-23
SLIDE 23

Network Platforms Group 23 23

Eventually, get to the point where we can automatically apply the patches

send the maintainer an email if there is a conflict send the patches out for review if there are no conflicts

Extend the new process to other drivers

Future Work –Automate!

slide-24
SLIDE 24

Network Platforms Group 24 24

slide-25
SLIDE 25

Network Platforms Group 25 25

Intel-wired-lan mailing list

https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Intel-wired-lan patchwork

https://patchwork.ozlabs.org/project/intel-wired-lan/list/

Jeff Kirsher’s net tree

https://git.kernel.org/cgit/linux/kernel/git/jkirsher/net-queue.git/log/?h=dev- queue

Jeff Kirsher’s next tree

https://git.kernel.org/cgit/linux/kernel/git/jkirsher/next- queue.git/log/?h=dev-queue

Helpful Links

slide-26
SLIDE 26

Maintaining two drivers simultaneously doesn’t have to mean doubling the workload – automation is our friend.