xref: /openbmc/linux/Documentation/process/applying-patches.rst (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1186128f7SMauro Carvalho Chehab.. _applying_patches:
2186128f7SMauro Carvalho Chehab
3186128f7SMauro Carvalho ChehabApplying Patches To The Linux Kernel
4186128f7SMauro Carvalho Chehab++++++++++++++++++++++++++++++++++++
5186128f7SMauro Carvalho Chehab
6186128f7SMauro Carvalho ChehabOriginal by:
7186128f7SMauro Carvalho Chehab	Jesper Juhl, August 2005
8186128f7SMauro Carvalho Chehab
967972a53SJonathan Corbet.. note::
1067972a53SJonathan Corbet
1167972a53SJonathan Corbet   This document is obsolete.  In most cases, rather than using ``patch``
1267972a53SJonathan Corbet   manually, you'll almost certainly want to look at using Git instead.
13186128f7SMauro Carvalho Chehab
14186128f7SMauro Carvalho ChehabA frequently asked question on the Linux Kernel Mailing List is how to apply
15186128f7SMauro Carvalho Chehaba patch to the kernel or, more specifically, what base kernel a patch for
16186128f7SMauro Carvalho Chehabone of the many trees/branches should be applied to. Hopefully this document
17186128f7SMauro Carvalho Chehabwill explain this to you.
18186128f7SMauro Carvalho Chehab
19186128f7SMauro Carvalho ChehabIn addition to explaining how to apply and revert patches, a brief
20186128f7SMauro Carvalho Chehabdescription of the different kernel trees (and examples of how to apply
21186128f7SMauro Carvalho Chehabtheir specific patches) is also provided.
22186128f7SMauro Carvalho Chehab
23186128f7SMauro Carvalho Chehab
24186128f7SMauro Carvalho ChehabWhat is a patch?
25186128f7SMauro Carvalho Chehab================
26186128f7SMauro Carvalho Chehab
27186128f7SMauro Carvalho ChehabA patch is a small text document containing a delta of changes between two
28186128f7SMauro Carvalho Chehabdifferent versions of a source tree. Patches are created with the ``diff``
29186128f7SMauro Carvalho Chehabprogram.
30186128f7SMauro Carvalho Chehab
31186128f7SMauro Carvalho ChehabTo correctly apply a patch you need to know what base it was generated from
32186128f7SMauro Carvalho Chehaband what new version the patch will change the source tree into. These
33186128f7SMauro Carvalho Chehabshould both be present in the patch file metadata or be possible to deduce
34186128f7SMauro Carvalho Chehabfrom the filename.
35186128f7SMauro Carvalho Chehab
36186128f7SMauro Carvalho Chehab
37186128f7SMauro Carvalho ChehabHow do I apply or revert a patch?
38186128f7SMauro Carvalho Chehab=================================
39186128f7SMauro Carvalho Chehab
40186128f7SMauro Carvalho ChehabYou apply a patch with the ``patch`` program. The patch program reads a diff
41186128f7SMauro Carvalho Chehab(or patch) file and makes the changes to the source tree described in it.
42186128f7SMauro Carvalho Chehab
43186128f7SMauro Carvalho ChehabPatches for the Linux kernel are generated relative to the parent directory
44186128f7SMauro Carvalho Chehabholding the kernel source dir.
45186128f7SMauro Carvalho Chehab
46186128f7SMauro Carvalho ChehabThis means that paths to files inside the patch file contain the name of the
47186128f7SMauro Carvalho Chehabkernel source directories it was generated against (or some other directory
48186128f7SMauro Carvalho Chehabnames like "a/" and "b/").
49186128f7SMauro Carvalho Chehab
50186128f7SMauro Carvalho ChehabSince this is unlikely to match the name of the kernel source dir on your
51186128f7SMauro Carvalho Chehablocal machine (but is often useful info to see what version an otherwise
52186128f7SMauro Carvalho Chehabunlabeled patch was generated against) you should change into your kernel
53186128f7SMauro Carvalho Chehabsource directory and then strip the first element of the path from filenames
54186128f7SMauro Carvalho Chehabin the patch file when applying it (the ``-p1`` argument to ``patch`` does
55186128f7SMauro Carvalho Chehabthis).
56186128f7SMauro Carvalho Chehab
57186128f7SMauro Carvalho ChehabTo revert a previously applied patch, use the -R argument to patch.
58186128f7SMauro Carvalho ChehabSo, if you applied a patch like this::
59186128f7SMauro Carvalho Chehab
60186128f7SMauro Carvalho Chehab	patch -p1 < ../patch-x.y.z
61186128f7SMauro Carvalho Chehab
62186128f7SMauro Carvalho ChehabYou can revert (undo) it like this::
63186128f7SMauro Carvalho Chehab
64186128f7SMauro Carvalho Chehab	patch -R -p1 < ../patch-x.y.z
65186128f7SMauro Carvalho Chehab
66186128f7SMauro Carvalho Chehab
67186128f7SMauro Carvalho ChehabHow do I feed a patch/diff file to ``patch``?
68186128f7SMauro Carvalho Chehab=============================================
69186128f7SMauro Carvalho Chehab
70186128f7SMauro Carvalho ChehabThis (as usual with Linux and other UNIX like operating systems) can be
71186128f7SMauro Carvalho Chehabdone in several different ways.
72186128f7SMauro Carvalho Chehab
73186128f7SMauro Carvalho ChehabIn all the examples below I feed the file (in uncompressed form) to patch
74186128f7SMauro Carvalho Chehabvia stdin using the following syntax::
75186128f7SMauro Carvalho Chehab
76186128f7SMauro Carvalho Chehab	patch -p1 < path/to/patch-x.y.z
77186128f7SMauro Carvalho Chehab
78186128f7SMauro Carvalho ChehabIf you just want to be able to follow the examples below and don't want to
79186128f7SMauro Carvalho Chehabknow of more than one way to use patch, then you can stop reading this
80186128f7SMauro Carvalho Chehabsection here.
81186128f7SMauro Carvalho Chehab
82186128f7SMauro Carvalho ChehabPatch can also get the name of the file to use via the -i argument, like
83186128f7SMauro Carvalho Chehabthis::
84186128f7SMauro Carvalho Chehab
85186128f7SMauro Carvalho Chehab	patch -p1 -i path/to/patch-x.y.z
86186128f7SMauro Carvalho Chehab
87186128f7SMauro Carvalho ChehabIf your patch file is compressed with gzip or xz and you don't want to
88186128f7SMauro Carvalho Chehabuncompress it before applying it, then you can feed it to patch like this
89186128f7SMauro Carvalho Chehabinstead::
90186128f7SMauro Carvalho Chehab
91186128f7SMauro Carvalho Chehab	xzcat path/to/patch-x.y.z.xz | patch -p1
92186128f7SMauro Carvalho Chehab	bzcat path/to/patch-x.y.z.gz | patch -p1
93186128f7SMauro Carvalho Chehab
94186128f7SMauro Carvalho ChehabIf you wish to uncompress the patch file by hand first before applying it
95186128f7SMauro Carvalho Chehab(what I assume you've done in the examples below), then you simply run
96186128f7SMauro Carvalho Chehabgunzip or xz on the file -- like this::
97186128f7SMauro Carvalho Chehab
98186128f7SMauro Carvalho Chehab	gunzip patch-x.y.z.gz
99186128f7SMauro Carvalho Chehab	xz -d patch-x.y.z.xz
100186128f7SMauro Carvalho Chehab
101186128f7SMauro Carvalho ChehabWhich will leave you with a plain text patch-x.y.z file that you can feed to
102186128f7SMauro Carvalho Chehabpatch via stdin or the ``-i`` argument, as you prefer.
103186128f7SMauro Carvalho Chehab
104186128f7SMauro Carvalho ChehabA few other nice arguments for patch are ``-s`` which causes patch to be silent
105186128f7SMauro Carvalho Chehabexcept for errors which is nice to prevent errors from scrolling out of the
106186128f7SMauro Carvalho Chehabscreen too fast, and ``--dry-run`` which causes patch to just print a listing of
107186128f7SMauro Carvalho Chehabwhat would happen, but doesn't actually make any changes. Finally ``--verbose``
108186128f7SMauro Carvalho Chehabtells patch to print more information about the work being done.
109186128f7SMauro Carvalho Chehab
110186128f7SMauro Carvalho Chehab
111186128f7SMauro Carvalho ChehabCommon errors when patching
112186128f7SMauro Carvalho Chehab===========================
113186128f7SMauro Carvalho Chehab
114186128f7SMauro Carvalho ChehabWhen patch applies a patch file it attempts to verify the sanity of the
115186128f7SMauro Carvalho Chehabfile in different ways.
116186128f7SMauro Carvalho Chehab
117186128f7SMauro Carvalho ChehabChecking that the file looks like a valid patch file and checking the code
118186128f7SMauro Carvalho Chehabaround the bits being modified matches the context provided in the patch are
119186128f7SMauro Carvalho Chehabjust two of the basic sanity checks patch does.
120186128f7SMauro Carvalho Chehab
121186128f7SMauro Carvalho ChehabIf patch encounters something that doesn't look quite right it has two
122186128f7SMauro Carvalho Chehaboptions. It can either refuse to apply the changes and abort or it can try
123186128f7SMauro Carvalho Chehabto find a way to make the patch apply with a few minor changes.
124186128f7SMauro Carvalho Chehab
125186128f7SMauro Carvalho ChehabOne example of something that's not 'quite right' that patch will attempt to
126186128f7SMauro Carvalho Chehabfix up is if all the context matches, the lines being changed match, but the
127186128f7SMauro Carvalho Chehabline numbers are different. This can happen, for example, if the patch makes
128186128f7SMauro Carvalho Chehaba change in the middle of the file but for some reasons a few lines have
129186128f7SMauro Carvalho Chehabbeen added or removed near the beginning of the file. In that case
130186128f7SMauro Carvalho Chehabeverything looks good it has just moved up or down a bit, and patch will
131186128f7SMauro Carvalho Chehabusually adjust the line numbers and apply the patch.
132186128f7SMauro Carvalho Chehab
133186128f7SMauro Carvalho ChehabWhenever patch applies a patch that it had to modify a bit to make it fit
134186128f7SMauro Carvalho Chehabit'll tell you about it by saying the patch applied with **fuzz**.
135186128f7SMauro Carvalho ChehabYou should be wary of such changes since even though patch probably got it
136186128f7SMauro Carvalho Chehabright it doesn't /always/ get it right, and the result will sometimes be
137186128f7SMauro Carvalho Chehabwrong.
138186128f7SMauro Carvalho Chehab
139186128f7SMauro Carvalho ChehabWhen patch encounters a change that it can't fix up with fuzz it rejects it
140186128f7SMauro Carvalho Chehaboutright and leaves a file with a ``.rej`` extension (a reject file). You can
141186128f7SMauro Carvalho Chehabread this file to see exactly what change couldn't be applied, so you can
142186128f7SMauro Carvalho Chehabgo fix it up by hand if you wish.
143186128f7SMauro Carvalho Chehab
144186128f7SMauro Carvalho ChehabIf you don't have any third-party patches applied to your kernel source, but
145186128f7SMauro Carvalho Chehabonly patches from kernel.org and you apply the patches in the correct order,
146186128f7SMauro Carvalho Chehaband have made no modifications yourself to the source files, then you should
147186128f7SMauro Carvalho Chehabnever see a fuzz or reject message from patch. If you do see such messages
148186128f7SMauro Carvalho Chehabanyway, then there's a high risk that either your local source tree or the
149186128f7SMauro Carvalho Chehabpatch file is corrupted in some way. In that case you should probably try
150186128f7SMauro Carvalho Chehabre-downloading the patch and if things are still not OK then you'd be advised
151186128f7SMauro Carvalho Chehabto start with a fresh tree downloaded in full from kernel.org.
152186128f7SMauro Carvalho Chehab
153186128f7SMauro Carvalho ChehabLet's look a bit more at some of the messages patch can produce.
154186128f7SMauro Carvalho Chehab
155186128f7SMauro Carvalho ChehabIf patch stops and presents a ``File to patch:`` prompt, then patch could not
156186128f7SMauro Carvalho Chehabfind a file to be patched. Most likely you forgot to specify -p1 or you are
157186128f7SMauro Carvalho Chehabin the wrong directory. Less often, you'll find patches that need to be
158186128f7SMauro Carvalho Chehabapplied with ``-p0`` instead of ``-p1`` (reading the patch file should reveal if
159186128f7SMauro Carvalho Chehabthis is the case -- if so, then this is an error by the person who created
160186128f7SMauro Carvalho Chehabthe patch but is not fatal).
161186128f7SMauro Carvalho Chehab
162186128f7SMauro Carvalho ChehabIf you get ``Hunk #2 succeeded at 1887 with fuzz 2 (offset 7 lines).`` or a
163186128f7SMauro Carvalho Chehabmessage similar to that, then it means that patch had to adjust the location
164186128f7SMauro Carvalho Chehabof the change (in this example it needed to move 7 lines from where it
165186128f7SMauro Carvalho Chehabexpected to make the change to make it fit).
166186128f7SMauro Carvalho Chehab
167186128f7SMauro Carvalho ChehabThe resulting file may or may not be OK, depending on the reason the file
168186128f7SMauro Carvalho Chehabwas different than expected.
169186128f7SMauro Carvalho Chehab
170186128f7SMauro Carvalho ChehabThis often happens if you try to apply a patch that was generated against a
171186128f7SMauro Carvalho Chehabdifferent kernel version than the one you are trying to patch.
172186128f7SMauro Carvalho Chehab
173186128f7SMauro Carvalho ChehabIf you get a message like ``Hunk #3 FAILED at 2387.``, then it means that the
174186128f7SMauro Carvalho Chehabpatch could not be applied correctly and the patch program was unable to
175186128f7SMauro Carvalho Chehabfuzz its way through. This will generate a ``.rej`` file with the change that
176186128f7SMauro Carvalho Chehabcaused the patch to fail and also a ``.orig`` file showing you the original
177186128f7SMauro Carvalho Chehabcontent that couldn't be changed.
178186128f7SMauro Carvalho Chehab
179186128f7SMauro Carvalho ChehabIf you get ``Reversed (or previously applied) patch detected!  Assume -R? [n]``
180186128f7SMauro Carvalho Chehabthen patch detected that the change contained in the patch seems to have
181186128f7SMauro Carvalho Chehabalready been made.
182186128f7SMauro Carvalho Chehab
183186128f7SMauro Carvalho ChehabIf you actually did apply this patch previously and you just re-applied it
184186128f7SMauro Carvalho Chehabin error, then just say [n]o and abort this patch. If you applied this patch
185186128f7SMauro Carvalho Chehabpreviously and actually intended to revert it, but forgot to specify -R,
186186128f7SMauro Carvalho Chehabthen you can say [**y**]es here to make patch revert it for you.
187186128f7SMauro Carvalho Chehab
188186128f7SMauro Carvalho ChehabThis can also happen if the creator of the patch reversed the source and
189186128f7SMauro Carvalho Chehabdestination directories when creating the patch, and in that case reverting
190186128f7SMauro Carvalho Chehabthe patch will in fact apply it.
191186128f7SMauro Carvalho Chehab
192186128f7SMauro Carvalho ChehabA message similar to ``patch: **** unexpected end of file in patch`` or
193186128f7SMauro Carvalho Chehab``patch unexpectedly ends in middle of line`` means that patch could make no
194186128f7SMauro Carvalho Chehabsense of the file you fed to it. Either your download is broken, you tried to
195186128f7SMauro Carvalho Chehabfeed patch a compressed patch file without uncompressing it first, or the patch
196186128f7SMauro Carvalho Chehabfile that you are using has been mangled by a mail client or mail transfer
197186128f7SMauro Carvalho Chehabagent along the way somewhere, e.g., by splitting a long line into two lines.
198186128f7SMauro Carvalho ChehabOften these warnings can easily be fixed by joining (concatenating) the
199186128f7SMauro Carvalho Chehabtwo lines that had been split.
200186128f7SMauro Carvalho Chehab
201186128f7SMauro Carvalho ChehabAs I already mentioned above, these errors should never happen if you apply
202186128f7SMauro Carvalho Chehaba patch from kernel.org to the correct version of an unmodified source tree.
203186128f7SMauro Carvalho ChehabSo if you get these errors with kernel.org patches then you should probably
204186128f7SMauro Carvalho Chehabassume that either your patch file or your tree is broken and I'd advise you
205186128f7SMauro Carvalho Chehabto start over with a fresh download of a full kernel tree and the patch you
206186128f7SMauro Carvalho Chehabwish to apply.
207186128f7SMauro Carvalho Chehab
208186128f7SMauro Carvalho Chehab
209186128f7SMauro Carvalho ChehabAre there any alternatives to ``patch``?
210186128f7SMauro Carvalho Chehab========================================
211186128f7SMauro Carvalho Chehab
212186128f7SMauro Carvalho Chehab
213186128f7SMauro Carvalho ChehabYes there are alternatives.
214186128f7SMauro Carvalho Chehab
215186128f7SMauro Carvalho ChehabYou can use the ``interdiff`` program (http://cyberelk.net/tim/patchutils/) to
216186128f7SMauro Carvalho Chehabgenerate a patch representing the differences between two patches and then
217186128f7SMauro Carvalho Chehabapply the result.
218186128f7SMauro Carvalho Chehab
2190358affbSArnd BergmannThis will let you move from something like 5.7.2 to 5.7.3 in a single
220186128f7SMauro Carvalho Chehabstep. The -z flag to interdiff will even let you feed it patches in gzip or
221186128f7SMauro Carvalho Chehabbzip2 compressed form directly without the use of zcat or bzcat or manual
222186128f7SMauro Carvalho Chehabdecompression.
223186128f7SMauro Carvalho Chehab
2240358affbSArnd BergmannHere's how you'd go from 5.7.2 to 5.7.3 in a single step::
225186128f7SMauro Carvalho Chehab
2260358affbSArnd Bergmann	interdiff -z ../patch-5.7.2.gz ../patch-5.7.3.gz | patch -p1
227186128f7SMauro Carvalho Chehab
228186128f7SMauro Carvalho ChehabAlthough interdiff may save you a step or two you are generally advised to
229186128f7SMauro Carvalho Chehabdo the additional steps since interdiff can get things wrong in some cases.
230186128f7SMauro Carvalho Chehab
231186128f7SMauro Carvalho ChehabAnother alternative is ``ketchup``, which is a python script for automatic
23293431e06SAlexander A. Klimovdownloading and applying of patches (https://www.selenic.com/ketchup/).
233186128f7SMauro Carvalho Chehab
234186128f7SMauro Carvalho ChehabOther nice tools are diffstat, which shows a summary of changes made by a
235186128f7SMauro Carvalho Chehabpatch; lsdiff, which displays a short listing of affected files in a patch
236186128f7SMauro Carvalho Chehabfile, along with (optionally) the line numbers of the start of each patch;
237186128f7SMauro Carvalho Chehaband grepdiff, which displays a list of the files modified by a patch where
238186128f7SMauro Carvalho Chehabthe patch contains a given regular expression.
239186128f7SMauro Carvalho Chehab
240186128f7SMauro Carvalho Chehab
241186128f7SMauro Carvalho ChehabWhere can I download the patches?
242186128f7SMauro Carvalho Chehab=================================
243186128f7SMauro Carvalho Chehab
24493431e06SAlexander A. KlimovThe patches are available at https://kernel.org/
245186128f7SMauro Carvalho ChehabMost recent patches are linked from the front page, but they also have
246186128f7SMauro Carvalho Chehabspecific homes.
247186128f7SMauro Carvalho Chehab
2480358affbSArnd BergmannThe 5.x.y (-stable) and 5.x patches live at
249186128f7SMauro Carvalho Chehab
2500358affbSArnd Bergmann	https://www.kernel.org/pub/linux/kernel/v5.x/
251186128f7SMauro Carvalho Chehab
252*fa04150bSBagas SanjayaThe 5.x.y incremental patches live at
253*fa04150bSBagas Sanjaya
254*fa04150bSBagas Sanjaya	https://www.kernel.org/pub/linux/kernel/v5.x/incr/
255*fa04150bSBagas Sanjaya
2560358affbSArnd BergmannThe -rc patches are not stored on the webserver but are generated on
2570358affbSArnd Bergmanndemand from git tags such as
258186128f7SMauro Carvalho Chehab
2590358affbSArnd Bergmann	https://git.kernel.org/torvalds/p/v5.1-rc1/v5.0
2600358affbSArnd Bergmann
2610358affbSArnd BergmannThe stable -rc patches live at
2620358affbSArnd Bergmann
2630358affbSArnd Bergmann	https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/
264186128f7SMauro Carvalho Chehab
265186128f7SMauro Carvalho Chehab
2660358affbSArnd BergmannThe 5.x kernels
267186128f7SMauro Carvalho Chehab===============
268186128f7SMauro Carvalho Chehab
269186128f7SMauro Carvalho ChehabThese are the base stable releases released by Linus. The highest numbered
270186128f7SMauro Carvalho Chehabrelease is the most recent.
271186128f7SMauro Carvalho Chehab
272186128f7SMauro Carvalho ChehabIf regressions or other serious flaws are found, then a -stable fix patch
2730358affbSArnd Bergmannwill be released (see below) on top of this base. Once a new 5.x base
274186128f7SMauro Carvalho Chehabkernel is released, a patch is made available that is a delta between the
2750358affbSArnd Bergmannprevious 5.x kernel and the new one.
276186128f7SMauro Carvalho Chehab
2770358affbSArnd BergmannTo apply a patch moving from 5.6 to 5.7, you'd do the following (note
2780358affbSArnd Bergmannthat such patches do **NOT** apply on top of 5.x.y kernels but on top of the
2790358affbSArnd Bergmannbase 5.x kernel -- if you need to move from 5.x.y to 5.x+1 you need to
2800358affbSArnd Bergmannfirst revert the 5.x.y patch).
281186128f7SMauro Carvalho Chehab
282186128f7SMauro Carvalho ChehabHere are some examples::
283186128f7SMauro Carvalho Chehab
2840358affbSArnd Bergmann	# moving from 5.6 to 5.7
285186128f7SMauro Carvalho Chehab
2860358affbSArnd Bergmann	$ cd ~/linux-5.6		# change to kernel source dir
2870358affbSArnd Bergmann	$ patch -p1 < ../patch-5.7	# apply the 5.7 patch
288186128f7SMauro Carvalho Chehab	$ cd ..
2890358affbSArnd Bergmann	$ mv linux-5.6 linux-5.7	# rename source dir
290186128f7SMauro Carvalho Chehab
2910358affbSArnd Bergmann	# moving from 5.6.1 to 5.7
292186128f7SMauro Carvalho Chehab
2930358affbSArnd Bergmann	$ cd ~/linux-5.6.1		# change to kernel source dir
2940358affbSArnd Bergmann	$ patch -p1 -R < ../patch-5.6.1	# revert the 5.6.1 patch
2950358affbSArnd Bergmann					# source dir is now 5.6
2960358affbSArnd Bergmann	$ patch -p1 < ../patch-5.7	# apply new 5.7 patch
297186128f7SMauro Carvalho Chehab	$ cd ..
2980358affbSArnd Bergmann	$ mv linux-5.6.1 linux-5.7	# rename source dir
299186128f7SMauro Carvalho Chehab
300186128f7SMauro Carvalho Chehab
3010358affbSArnd BergmannThe 5.x.y kernels
302186128f7SMauro Carvalho Chehab=================
303186128f7SMauro Carvalho Chehab
304186128f7SMauro Carvalho ChehabKernels with 3-digit versions are -stable kernels. They contain small(ish)
305186128f7SMauro Carvalho Chehabcritical fixes for security problems or significant regressions discovered
3060358affbSArnd Bergmannin a given 5.x kernel.
307186128f7SMauro Carvalho Chehab
308186128f7SMauro Carvalho ChehabThis is the recommended branch for users who want the most recent stable
309186128f7SMauro Carvalho Chehabkernel and are not interested in helping test development/experimental
310186128f7SMauro Carvalho Chehabversions.
311186128f7SMauro Carvalho Chehab
3120358affbSArnd BergmannIf no 5.x.y kernel is available, then the highest numbered 5.x kernel is
313186128f7SMauro Carvalho Chehabthe current stable kernel.
314186128f7SMauro Carvalho Chehab
315*fa04150bSBagas SanjayaThe -stable team provides normal as well as incremental patches. Below is
316*fa04150bSBagas Sanjayahow to apply these patches.
317186128f7SMauro Carvalho Chehab
318*fa04150bSBagas SanjayaNormal patches
319*fa04150bSBagas Sanjaya~~~~~~~~~~~~~~
320186128f7SMauro Carvalho Chehab
3210358affbSArnd BergmannThese patches are not incremental, meaning that for example the 5.7.3
3220358affbSArnd Bergmannpatch does not apply on top of the 5.7.2 kernel source, but rather on top
3230358affbSArnd Bergmannof the base 5.7 kernel source.
324186128f7SMauro Carvalho Chehab
3250358affbSArnd BergmannSo, in order to apply the 5.7.3 patch to your existing 5.7.2 kernel
3260358affbSArnd Bergmannsource you have to first back out the 5.7.2 patch (so you are left with a
3270358affbSArnd Bergmannbase 5.7 kernel source) and then apply the new 5.7.3 patch.
328186128f7SMauro Carvalho Chehab
329186128f7SMauro Carvalho ChehabHere's a small example::
330186128f7SMauro Carvalho Chehab
3310358affbSArnd Bergmann	$ cd ~/linux-5.7.2		# change to the kernel source dir
3320358affbSArnd Bergmann	$ patch -p1 -R < ../patch-5.7.2	# revert the 5.7.2 patch
3330358affbSArnd Bergmann	$ patch -p1 < ../patch-5.7.3	# apply the new 5.7.3 patch
334186128f7SMauro Carvalho Chehab	$ cd ..
3350358affbSArnd Bergmann	$ mv linux-5.7.2 linux-5.7.3	# rename the kernel source dir
336186128f7SMauro Carvalho Chehab
337*fa04150bSBagas SanjayaIncremental patches
338*fa04150bSBagas Sanjaya~~~~~~~~~~~~~~~~~~~
339*fa04150bSBagas Sanjaya
340*fa04150bSBagas SanjayaIncremental patches are different: instead of being applied on top
341*fa04150bSBagas Sanjayaof base 5.x kernel, they are applied on top of previous stable kernel
342*fa04150bSBagas Sanjaya(5.x.y-1).
343*fa04150bSBagas Sanjaya
344*fa04150bSBagas SanjayaHere's the example to apply these::
345*fa04150bSBagas Sanjaya
346*fa04150bSBagas Sanjaya	$ cd ~/linux-5.7.2		# change to the kernel source dir
347*fa04150bSBagas Sanjaya	$ patch -p1 < ../patch-5.7.2-3	# apply the new 5.7.3 patch
348*fa04150bSBagas Sanjaya	$ cd ..
349*fa04150bSBagas Sanjaya	$ mv linux-5.7.2 linux-5.7.3	# rename the kernel source dir
350*fa04150bSBagas Sanjaya
351*fa04150bSBagas Sanjaya
352186128f7SMauro Carvalho ChehabThe -rc kernels
353186128f7SMauro Carvalho Chehab===============
354186128f7SMauro Carvalho Chehab
355186128f7SMauro Carvalho ChehabThese are release-candidate kernels. These are development kernels released
356186128f7SMauro Carvalho Chehabby Linus whenever he deems the current git (the kernel's source management
357186128f7SMauro Carvalho Chehabtool) tree to be in a reasonably sane state adequate for testing.
358186128f7SMauro Carvalho Chehab
359186128f7SMauro Carvalho ChehabThese kernels are not stable and you should expect occasional breakage if
360186128f7SMauro Carvalho Chehabyou intend to run them. This is however the most stable of the main
361186128f7SMauro Carvalho Chehabdevelopment branches and is also what will eventually turn into the next
362186128f7SMauro Carvalho Chehabstable kernel, so it is important that it be tested by as many people as
363186128f7SMauro Carvalho Chehabpossible.
364186128f7SMauro Carvalho Chehab
365186128f7SMauro Carvalho ChehabThis is a good branch to run for people who want to help out testing
366186128f7SMauro Carvalho Chehabdevelopment kernels but do not want to run some of the really experimental
367f7a6dd84SRandy Dunlapstuff (such people should see the sections about -next and -mm kernels below).
368186128f7SMauro Carvalho Chehab
3690358affbSArnd BergmannThe -rc patches are not incremental, they apply to a base 5.x kernel, just
3700358affbSArnd Bergmannlike the 5.x.y patches described above. The kernel version before the -rcN
371186128f7SMauro Carvalho Chehabsuffix denotes the version of the kernel that this -rc kernel will eventually
372186128f7SMauro Carvalho Chehabturn into.
373186128f7SMauro Carvalho Chehab
3740358affbSArnd BergmannSo, 5.8-rc5 means that this is the fifth release candidate for the 5.8
3750358affbSArnd Bergmannkernel and the patch should be applied on top of the 5.7 kernel source.
376186128f7SMauro Carvalho Chehab
377186128f7SMauro Carvalho ChehabHere are 3 examples of how to apply these patches::
378186128f7SMauro Carvalho Chehab
3790358affbSArnd Bergmann	# first an example of moving from 5.7 to 5.8-rc3
380186128f7SMauro Carvalho Chehab
3810358affbSArnd Bergmann	$ cd ~/linux-5.7			# change to the 5.7 source dir
3820358affbSArnd Bergmann	$ patch -p1 < ../patch-5.8-rc3		# apply the 5.8-rc3 patch
383186128f7SMauro Carvalho Chehab	$ cd ..
3840358affbSArnd Bergmann	$ mv linux-5.7 linux-5.8-rc3		# rename the source dir
385186128f7SMauro Carvalho Chehab
3860358affbSArnd Bergmann	# now let's move from 5.8-rc3 to 5.8-rc5
387186128f7SMauro Carvalho Chehab
3880358affbSArnd Bergmann	$ cd ~/linux-5.8-rc3			# change to the 5.8-rc3 dir
3890358affbSArnd Bergmann	$ patch -p1 -R < ../patch-5.8-rc3	# revert the 5.8-rc3 patch
3900358affbSArnd Bergmann	$ patch -p1 < ../patch-5.8-rc5		# apply the new 5.8-rc5 patch
391186128f7SMauro Carvalho Chehab	$ cd ..
3920358affbSArnd Bergmann	$ mv linux-5.8-rc3 linux-5.8-rc5	# rename the source dir
393186128f7SMauro Carvalho Chehab
3940358affbSArnd Bergmann	# finally let's try and move from 5.7.3 to 5.8-rc5
395186128f7SMauro Carvalho Chehab
3960358affbSArnd Bergmann	$ cd ~/linux-5.7.3			# change to the kernel source dir
3970358affbSArnd Bergmann	$ patch -p1 -R < ../patch-5.7.3		# revert the 5.7.3 patch
3980358affbSArnd Bergmann	$ patch -p1 < ../patch-5.8-rc5		# apply new 5.8-rc5 patch
399186128f7SMauro Carvalho Chehab	$ cd ..
4000358affbSArnd Bergmann	$ mv linux-5.7.3 linux-5.8-rc5		# rename the kernel source dir
401186128f7SMauro Carvalho Chehab
402186128f7SMauro Carvalho Chehab
403186128f7SMauro Carvalho ChehabThe -mm patches and the linux-next tree
404186128f7SMauro Carvalho Chehab=======================================
405186128f7SMauro Carvalho Chehab
406186128f7SMauro Carvalho ChehabThe -mm patches are experimental patches released by Andrew Morton.
407186128f7SMauro Carvalho Chehab
408186128f7SMauro Carvalho ChehabIn the past, -mm tree were used to also test subsystem patches, but this
409186128f7SMauro Carvalho Chehabfunction is now done via the
410d44f571fSSeongJae Park`linux-next` (https://www.kernel.org/doc/man-pages/linux-next.html)
411186128f7SMauro Carvalho Chehabtree. The Subsystem maintainers push their patches first to linux-next,
412186128f7SMauro Carvalho Chehaband, during the merge window, sends them directly to Linus.
413186128f7SMauro Carvalho Chehab
414186128f7SMauro Carvalho ChehabThe -mm patches serve as a sort of proving ground for new features and other
415186128f7SMauro Carvalho Chehabexperimental patches that aren't merged via a subsystem tree.
416186128f7SMauro Carvalho ChehabOnce such patches has proved its worth in -mm for a while Andrew pushes
417186128f7SMauro Carvalho Chehabit on to Linus for inclusion in mainline.
418186128f7SMauro Carvalho Chehab
419186128f7SMauro Carvalho ChehabThe linux-next tree is daily updated, and includes the -mm patches.
420186128f7SMauro Carvalho ChehabBoth are in constant flux and contains many experimental features, a
421186128f7SMauro Carvalho Chehablot of debugging patches not appropriate for mainline etc., and is the most
422186128f7SMauro Carvalho Chehabexperimental of the branches described in this document.
423186128f7SMauro Carvalho Chehab
424186128f7SMauro Carvalho ChehabThese patches are not appropriate for use on systems that are supposed to be
425186128f7SMauro Carvalho Chehabstable and they are more risky to run than any of the other branches (make
426186128f7SMauro Carvalho Chehabsure you have up-to-date backups -- that goes for any experimental kernel but
427186128f7SMauro Carvalho Chehabeven more so for -mm patches or using a Kernel from the linux-next tree).
428186128f7SMauro Carvalho Chehab
429186128f7SMauro Carvalho ChehabTesting of -mm patches and linux-next is greatly appreciated since the whole
430186128f7SMauro Carvalho Chehabpoint of those are to weed out regressions, crashes, data corruption bugs,
431186128f7SMauro Carvalho Chehabbuild breakage (and any other bug in general) before changes are merged into
432186128f7SMauro Carvalho Chehabthe more stable mainline Linus tree.
433186128f7SMauro Carvalho Chehab
434186128f7SMauro Carvalho ChehabBut testers of -mm and linux-next should be aware that breakages are
435186128f7SMauro Carvalho Chehabmore common than in any other tree.
436186128f7SMauro Carvalho Chehab
437186128f7SMauro Carvalho Chehab
438186128f7SMauro Carvalho ChehabThis concludes this list of explanations of the various kernel trees.
439186128f7SMauro Carvalho ChehabI hope you are now clear on how to apply the various patches and help testing
440186128f7SMauro Carvalho Chehabthe kernel.
441186128f7SMauro Carvalho Chehab
442186128f7SMauro Carvalho ChehabThank you's to Randy Dunlap, Rolf Eike Beer, Linus Torvalds, Bodo Eggert,
443186128f7SMauro Carvalho ChehabJohannes Stezenbach, Grant Coady, Pavel Machek and others that I may have
444186128f7SMauro Carvalho Chehabforgotten for their reviews and contributions to this document.
445