xref: /OK3568_Linux_fs/kernel/Documentation/process/applying-patches.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. _applying_patches:
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunApplying Patches To The Linux Kernel
4*4882a593Smuzhiyun++++++++++++++++++++++++++++++++++++
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunOriginal by:
7*4882a593Smuzhiyun	Jesper Juhl, August 2005
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun.. note::
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun   This document is obsolete.  In most cases, rather than using ``patch``
12*4882a593Smuzhiyun   manually, you'll almost certainly want to look at using Git instead.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunA frequently asked question on the Linux Kernel Mailing List is how to apply
15*4882a593Smuzhiyuna patch to the kernel or, more specifically, what base kernel a patch for
16*4882a593Smuzhiyunone of the many trees/branches should be applied to. Hopefully this document
17*4882a593Smuzhiyunwill explain this to you.
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunIn addition to explaining how to apply and revert patches, a brief
20*4882a593Smuzhiyundescription of the different kernel trees (and examples of how to apply
21*4882a593Smuzhiyuntheir specific patches) is also provided.
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunWhat is a patch?
25*4882a593Smuzhiyun================
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunA patch is a small text document containing a delta of changes between two
28*4882a593Smuzhiyundifferent versions of a source tree. Patches are created with the ``diff``
29*4882a593Smuzhiyunprogram.
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunTo correctly apply a patch you need to know what base it was generated from
32*4882a593Smuzhiyunand what new version the patch will change the source tree into. These
33*4882a593Smuzhiyunshould both be present in the patch file metadata or be possible to deduce
34*4882a593Smuzhiyunfrom the filename.
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunHow do I apply or revert a patch?
38*4882a593Smuzhiyun=================================
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunYou apply a patch with the ``patch`` program. The patch program reads a diff
41*4882a593Smuzhiyun(or patch) file and makes the changes to the source tree described in it.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunPatches for the Linux kernel are generated relative to the parent directory
44*4882a593Smuzhiyunholding the kernel source dir.
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunThis means that paths to files inside the patch file contain the name of the
47*4882a593Smuzhiyunkernel source directories it was generated against (or some other directory
48*4882a593Smuzhiyunnames like "a/" and "b/").
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunSince this is unlikely to match the name of the kernel source dir on your
51*4882a593Smuzhiyunlocal machine (but is often useful info to see what version an otherwise
52*4882a593Smuzhiyununlabeled patch was generated against) you should change into your kernel
53*4882a593Smuzhiyunsource directory and then strip the first element of the path from filenames
54*4882a593Smuzhiyunin the patch file when applying it (the ``-p1`` argument to ``patch`` does
55*4882a593Smuzhiyunthis).
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunTo revert a previously applied patch, use the -R argument to patch.
58*4882a593SmuzhiyunSo, if you applied a patch like this::
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun	patch -p1 < ../patch-x.y.z
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunYou can revert (undo) it like this::
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun	patch -R -p1 < ../patch-x.y.z
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun
67*4882a593SmuzhiyunHow do I feed a patch/diff file to ``patch``?
68*4882a593Smuzhiyun=============================================
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunThis (as usual with Linux and other UNIX like operating systems) can be
71*4882a593Smuzhiyundone in several different ways.
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunIn all the examples below I feed the file (in uncompressed form) to patch
74*4882a593Smuzhiyunvia stdin using the following syntax::
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun	patch -p1 < path/to/patch-x.y.z
77*4882a593Smuzhiyun
78*4882a593SmuzhiyunIf you just want to be able to follow the examples below and don't want to
79*4882a593Smuzhiyunknow of more than one way to use patch, then you can stop reading this
80*4882a593Smuzhiyunsection here.
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunPatch can also get the name of the file to use via the -i argument, like
83*4882a593Smuzhiyunthis::
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun	patch -p1 -i path/to/patch-x.y.z
86*4882a593Smuzhiyun
87*4882a593SmuzhiyunIf your patch file is compressed with gzip or xz and you don't want to
88*4882a593Smuzhiyununcompress it before applying it, then you can feed it to patch like this
89*4882a593Smuzhiyuninstead::
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun	xzcat path/to/patch-x.y.z.xz | patch -p1
92*4882a593Smuzhiyun	bzcat path/to/patch-x.y.z.gz | patch -p1
93*4882a593Smuzhiyun
94*4882a593SmuzhiyunIf you wish to uncompress the patch file by hand first before applying it
95*4882a593Smuzhiyun(what I assume you've done in the examples below), then you simply run
96*4882a593Smuzhiyungunzip or xz on the file -- like this::
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun	gunzip patch-x.y.z.gz
99*4882a593Smuzhiyun	xz -d patch-x.y.z.xz
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunWhich will leave you with a plain text patch-x.y.z file that you can feed to
102*4882a593Smuzhiyunpatch via stdin or the ``-i`` argument, as you prefer.
103*4882a593Smuzhiyun
104*4882a593SmuzhiyunA few other nice arguments for patch are ``-s`` which causes patch to be silent
105*4882a593Smuzhiyunexcept for errors which is nice to prevent errors from scrolling out of the
106*4882a593Smuzhiyunscreen too fast, and ``--dry-run`` which causes patch to just print a listing of
107*4882a593Smuzhiyunwhat would happen, but doesn't actually make any changes. Finally ``--verbose``
108*4882a593Smuzhiyuntells patch to print more information about the work being done.
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun
111*4882a593SmuzhiyunCommon errors when patching
112*4882a593Smuzhiyun===========================
113*4882a593Smuzhiyun
114*4882a593SmuzhiyunWhen patch applies a patch file it attempts to verify the sanity of the
115*4882a593Smuzhiyunfile in different ways.
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunChecking that the file looks like a valid patch file and checking the code
118*4882a593Smuzhiyunaround the bits being modified matches the context provided in the patch are
119*4882a593Smuzhiyunjust two of the basic sanity checks patch does.
120*4882a593Smuzhiyun
121*4882a593SmuzhiyunIf patch encounters something that doesn't look quite right it has two
122*4882a593Smuzhiyunoptions. It can either refuse to apply the changes and abort or it can try
123*4882a593Smuzhiyunto find a way to make the patch apply with a few minor changes.
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunOne example of something that's not 'quite right' that patch will attempt to
126*4882a593Smuzhiyunfix up is if all the context matches, the lines being changed match, but the
127*4882a593Smuzhiyunline numbers are different. This can happen, for example, if the patch makes
128*4882a593Smuzhiyuna change in the middle of the file but for some reasons a few lines have
129*4882a593Smuzhiyunbeen added or removed near the beginning of the file. In that case
130*4882a593Smuzhiyuneverything looks good it has just moved up or down a bit, and patch will
131*4882a593Smuzhiyunusually adjust the line numbers and apply the patch.
132*4882a593Smuzhiyun
133*4882a593SmuzhiyunWhenever patch applies a patch that it had to modify a bit to make it fit
134*4882a593Smuzhiyunit'll tell you about it by saying the patch applied with **fuzz**.
135*4882a593SmuzhiyunYou should be wary of such changes since even though patch probably got it
136*4882a593Smuzhiyunright it doesn't /always/ get it right, and the result will sometimes be
137*4882a593Smuzhiyunwrong.
138*4882a593Smuzhiyun
139*4882a593SmuzhiyunWhen patch encounters a change that it can't fix up with fuzz it rejects it
140*4882a593Smuzhiyunoutright and leaves a file with a ``.rej`` extension (a reject file). You can
141*4882a593Smuzhiyunread this file to see exactly what change couldn't be applied, so you can
142*4882a593Smuzhiyungo fix it up by hand if you wish.
143*4882a593Smuzhiyun
144*4882a593SmuzhiyunIf you don't have any third-party patches applied to your kernel source, but
145*4882a593Smuzhiyunonly patches from kernel.org and you apply the patches in the correct order,
146*4882a593Smuzhiyunand have made no modifications yourself to the source files, then you should
147*4882a593Smuzhiyunnever see a fuzz or reject message from patch. If you do see such messages
148*4882a593Smuzhiyunanyway, then there's a high risk that either your local source tree or the
149*4882a593Smuzhiyunpatch file is corrupted in some way. In that case you should probably try
150*4882a593Smuzhiyunre-downloading the patch and if things are still not OK then you'd be advised
151*4882a593Smuzhiyunto start with a fresh tree downloaded in full from kernel.org.
152*4882a593Smuzhiyun
153*4882a593SmuzhiyunLet's look a bit more at some of the messages patch can produce.
154*4882a593Smuzhiyun
155*4882a593SmuzhiyunIf patch stops and presents a ``File to patch:`` prompt, then patch could not
156*4882a593Smuzhiyunfind a file to be patched. Most likely you forgot to specify -p1 or you are
157*4882a593Smuzhiyunin the wrong directory. Less often, you'll find patches that need to be
158*4882a593Smuzhiyunapplied with ``-p0`` instead of ``-p1`` (reading the patch file should reveal if
159*4882a593Smuzhiyunthis is the case -- if so, then this is an error by the person who created
160*4882a593Smuzhiyunthe patch but is not fatal).
161*4882a593Smuzhiyun
162*4882a593SmuzhiyunIf you get ``Hunk #2 succeeded at 1887 with fuzz 2 (offset 7 lines).`` or a
163*4882a593Smuzhiyunmessage similar to that, then it means that patch had to adjust the location
164*4882a593Smuzhiyunof the change (in this example it needed to move 7 lines from where it
165*4882a593Smuzhiyunexpected to make the change to make it fit).
166*4882a593Smuzhiyun
167*4882a593SmuzhiyunThe resulting file may or may not be OK, depending on the reason the file
168*4882a593Smuzhiyunwas different than expected.
169*4882a593Smuzhiyun
170*4882a593SmuzhiyunThis often happens if you try to apply a patch that was generated against a
171*4882a593Smuzhiyundifferent kernel version than the one you are trying to patch.
172*4882a593Smuzhiyun
173*4882a593SmuzhiyunIf you get a message like ``Hunk #3 FAILED at 2387.``, then it means that the
174*4882a593Smuzhiyunpatch could not be applied correctly and the patch program was unable to
175*4882a593Smuzhiyunfuzz its way through. This will generate a ``.rej`` file with the change that
176*4882a593Smuzhiyuncaused the patch to fail and also a ``.orig`` file showing you the original
177*4882a593Smuzhiyuncontent that couldn't be changed.
178*4882a593Smuzhiyun
179*4882a593SmuzhiyunIf you get ``Reversed (or previously applied) patch detected!  Assume -R? [n]``
180*4882a593Smuzhiyunthen patch detected that the change contained in the patch seems to have
181*4882a593Smuzhiyunalready been made.
182*4882a593Smuzhiyun
183*4882a593SmuzhiyunIf you actually did apply this patch previously and you just re-applied it
184*4882a593Smuzhiyunin error, then just say [n]o and abort this patch. If you applied this patch
185*4882a593Smuzhiyunpreviously and actually intended to revert it, but forgot to specify -R,
186*4882a593Smuzhiyunthen you can say [**y**]es here to make patch revert it for you.
187*4882a593Smuzhiyun
188*4882a593SmuzhiyunThis can also happen if the creator of the patch reversed the source and
189*4882a593Smuzhiyundestination directories when creating the patch, and in that case reverting
190*4882a593Smuzhiyunthe patch will in fact apply it.
191*4882a593Smuzhiyun
192*4882a593SmuzhiyunA message similar to ``patch: **** unexpected end of file in patch`` or
193*4882a593Smuzhiyun``patch unexpectedly ends in middle of line`` means that patch could make no
194*4882a593Smuzhiyunsense of the file you fed to it. Either your download is broken, you tried to
195*4882a593Smuzhiyunfeed patch a compressed patch file without uncompressing it first, or the patch
196*4882a593Smuzhiyunfile that you are using has been mangled by a mail client or mail transfer
197*4882a593Smuzhiyunagent along the way somewhere, e.g., by splitting a long line into two lines.
198*4882a593SmuzhiyunOften these warnings can easily be fixed by joining (concatenating) the
199*4882a593Smuzhiyuntwo lines that had been split.
200*4882a593Smuzhiyun
201*4882a593SmuzhiyunAs I already mentioned above, these errors should never happen if you apply
202*4882a593Smuzhiyuna patch from kernel.org to the correct version of an unmodified source tree.
203*4882a593SmuzhiyunSo if you get these errors with kernel.org patches then you should probably
204*4882a593Smuzhiyunassume that either your patch file or your tree is broken and I'd advise you
205*4882a593Smuzhiyunto start over with a fresh download of a full kernel tree and the patch you
206*4882a593Smuzhiyunwish to apply.
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun
209*4882a593SmuzhiyunAre there any alternatives to ``patch``?
210*4882a593Smuzhiyun========================================
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun
213*4882a593SmuzhiyunYes there are alternatives.
214*4882a593Smuzhiyun
215*4882a593SmuzhiyunYou can use the ``interdiff`` program (http://cyberelk.net/tim/patchutils/) to
216*4882a593Smuzhiyungenerate a patch representing the differences between two patches and then
217*4882a593Smuzhiyunapply the result.
218*4882a593Smuzhiyun
219*4882a593SmuzhiyunThis will let you move from something like 5.7.2 to 5.7.3 in a single
220*4882a593Smuzhiyunstep. The -z flag to interdiff will even let you feed it patches in gzip or
221*4882a593Smuzhiyunbzip2 compressed form directly without the use of zcat or bzcat or manual
222*4882a593Smuzhiyundecompression.
223*4882a593Smuzhiyun
224*4882a593SmuzhiyunHere's how you'd go from 5.7.2 to 5.7.3 in a single step::
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun	interdiff -z ../patch-5.7.2.gz ../patch-5.7.3.gz | patch -p1
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunAlthough interdiff may save you a step or two you are generally advised to
229*4882a593Smuzhiyundo the additional steps since interdiff can get things wrong in some cases.
230*4882a593Smuzhiyun
231*4882a593SmuzhiyunAnother alternative is ``ketchup``, which is a python script for automatic
232*4882a593Smuzhiyundownloading and applying of patches (https://www.selenic.com/ketchup/).
233*4882a593Smuzhiyun
234*4882a593SmuzhiyunOther nice tools are diffstat, which shows a summary of changes made by a
235*4882a593Smuzhiyunpatch; lsdiff, which displays a short listing of affected files in a patch
236*4882a593Smuzhiyunfile, along with (optionally) the line numbers of the start of each patch;
237*4882a593Smuzhiyunand grepdiff, which displays a list of the files modified by a patch where
238*4882a593Smuzhiyunthe patch contains a given regular expression.
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun
241*4882a593SmuzhiyunWhere can I download the patches?
242*4882a593Smuzhiyun=================================
243*4882a593Smuzhiyun
244*4882a593SmuzhiyunThe patches are available at https://kernel.org/
245*4882a593SmuzhiyunMost recent patches are linked from the front page, but they also have
246*4882a593Smuzhiyunspecific homes.
247*4882a593Smuzhiyun
248*4882a593SmuzhiyunThe 5.x.y (-stable) and 5.x patches live at
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun	https://www.kernel.org/pub/linux/kernel/v5.x/
251*4882a593Smuzhiyun
252*4882a593SmuzhiyunThe -rc patches are not stored on the webserver but are generated on
253*4882a593Smuzhiyundemand from git tags such as
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun	https://git.kernel.org/torvalds/p/v5.1-rc1/v5.0
256*4882a593Smuzhiyun
257*4882a593SmuzhiyunThe stable -rc patches live at
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun	https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/
260*4882a593Smuzhiyun
261*4882a593Smuzhiyun
262*4882a593SmuzhiyunThe 5.x kernels
263*4882a593Smuzhiyun===============
264*4882a593Smuzhiyun
265*4882a593SmuzhiyunThese are the base stable releases released by Linus. The highest numbered
266*4882a593Smuzhiyunrelease is the most recent.
267*4882a593Smuzhiyun
268*4882a593SmuzhiyunIf regressions or other serious flaws are found, then a -stable fix patch
269*4882a593Smuzhiyunwill be released (see below) on top of this base. Once a new 5.x base
270*4882a593Smuzhiyunkernel is released, a patch is made available that is a delta between the
271*4882a593Smuzhiyunprevious 5.x kernel and the new one.
272*4882a593Smuzhiyun
273*4882a593SmuzhiyunTo apply a patch moving from 5.6 to 5.7, you'd do the following (note
274*4882a593Smuzhiyunthat such patches do **NOT** apply on top of 5.x.y kernels but on top of the
275*4882a593Smuzhiyunbase 5.x kernel -- if you need to move from 5.x.y to 5.x+1 you need to
276*4882a593Smuzhiyunfirst revert the 5.x.y patch).
277*4882a593Smuzhiyun
278*4882a593SmuzhiyunHere are some examples::
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun	# moving from 5.6 to 5.7
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun	$ cd ~/linux-5.6		# change to kernel source dir
283*4882a593Smuzhiyun	$ patch -p1 < ../patch-5.7	# apply the 5.7 patch
284*4882a593Smuzhiyun	$ cd ..
285*4882a593Smuzhiyun	$ mv linux-5.6 linux-5.7	# rename source dir
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun	# moving from 5.6.1 to 5.7
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun	$ cd ~/linux-5.6.1		# change to kernel source dir
290*4882a593Smuzhiyun	$ patch -p1 -R < ../patch-5.6.1	# revert the 5.6.1 patch
291*4882a593Smuzhiyun					# source dir is now 5.6
292*4882a593Smuzhiyun	$ patch -p1 < ../patch-5.7	# apply new 5.7 patch
293*4882a593Smuzhiyun	$ cd ..
294*4882a593Smuzhiyun	$ mv linux-5.6.1 linux-5.7	# rename source dir
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun
297*4882a593SmuzhiyunThe 5.x.y kernels
298*4882a593Smuzhiyun=================
299*4882a593Smuzhiyun
300*4882a593SmuzhiyunKernels with 3-digit versions are -stable kernels. They contain small(ish)
301*4882a593Smuzhiyuncritical fixes for security problems or significant regressions discovered
302*4882a593Smuzhiyunin a given 5.x kernel.
303*4882a593Smuzhiyun
304*4882a593SmuzhiyunThis is the recommended branch for users who want the most recent stable
305*4882a593Smuzhiyunkernel and are not interested in helping test development/experimental
306*4882a593Smuzhiyunversions.
307*4882a593Smuzhiyun
308*4882a593SmuzhiyunIf no 5.x.y kernel is available, then the highest numbered 5.x kernel is
309*4882a593Smuzhiyunthe current stable kernel.
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun.. note::
312*4882a593Smuzhiyun
313*4882a593Smuzhiyun The -stable team usually do make incremental patches available as well
314*4882a593Smuzhiyun as patches against the latest mainline release, but I only cover the
315*4882a593Smuzhiyun non-incremental ones below. The incremental ones can be found at
316*4882a593Smuzhiyun https://www.kernel.org/pub/linux/kernel/v5.x/incr/
317*4882a593Smuzhiyun
318*4882a593SmuzhiyunThese patches are not incremental, meaning that for example the 5.7.3
319*4882a593Smuzhiyunpatch does not apply on top of the 5.7.2 kernel source, but rather on top
320*4882a593Smuzhiyunof the base 5.7 kernel source.
321*4882a593Smuzhiyun
322*4882a593SmuzhiyunSo, in order to apply the 5.7.3 patch to your existing 5.7.2 kernel
323*4882a593Smuzhiyunsource you have to first back out the 5.7.2 patch (so you are left with a
324*4882a593Smuzhiyunbase 5.7 kernel source) and then apply the new 5.7.3 patch.
325*4882a593Smuzhiyun
326*4882a593SmuzhiyunHere's a small example::
327*4882a593Smuzhiyun
328*4882a593Smuzhiyun	$ cd ~/linux-5.7.2		# change to the kernel source dir
329*4882a593Smuzhiyun	$ patch -p1 -R < ../patch-5.7.2	# revert the 5.7.2 patch
330*4882a593Smuzhiyun	$ patch -p1 < ../patch-5.7.3	# apply the new 5.7.3 patch
331*4882a593Smuzhiyun	$ cd ..
332*4882a593Smuzhiyun	$ mv linux-5.7.2 linux-5.7.3	# rename the kernel source dir
333*4882a593Smuzhiyun
334*4882a593SmuzhiyunThe -rc kernels
335*4882a593Smuzhiyun===============
336*4882a593Smuzhiyun
337*4882a593SmuzhiyunThese are release-candidate kernels. These are development kernels released
338*4882a593Smuzhiyunby Linus whenever he deems the current git (the kernel's source management
339*4882a593Smuzhiyuntool) tree to be in a reasonably sane state adequate for testing.
340*4882a593Smuzhiyun
341*4882a593SmuzhiyunThese kernels are not stable and you should expect occasional breakage if
342*4882a593Smuzhiyunyou intend to run them. This is however the most stable of the main
343*4882a593Smuzhiyundevelopment branches and is also what will eventually turn into the next
344*4882a593Smuzhiyunstable kernel, so it is important that it be tested by as many people as
345*4882a593Smuzhiyunpossible.
346*4882a593Smuzhiyun
347*4882a593SmuzhiyunThis is a good branch to run for people who want to help out testing
348*4882a593Smuzhiyundevelopment kernels but do not want to run some of the really experimental
349*4882a593Smuzhiyunstuff (such people should see the sections about -next and -mm kernels below).
350*4882a593Smuzhiyun
351*4882a593SmuzhiyunThe -rc patches are not incremental, they apply to a base 5.x kernel, just
352*4882a593Smuzhiyunlike the 5.x.y patches described above. The kernel version before the -rcN
353*4882a593Smuzhiyunsuffix denotes the version of the kernel that this -rc kernel will eventually
354*4882a593Smuzhiyunturn into.
355*4882a593Smuzhiyun
356*4882a593SmuzhiyunSo, 5.8-rc5 means that this is the fifth release candidate for the 5.8
357*4882a593Smuzhiyunkernel and the patch should be applied on top of the 5.7 kernel source.
358*4882a593Smuzhiyun
359*4882a593SmuzhiyunHere are 3 examples of how to apply these patches::
360*4882a593Smuzhiyun
361*4882a593Smuzhiyun	# first an example of moving from 5.7 to 5.8-rc3
362*4882a593Smuzhiyun
363*4882a593Smuzhiyun	$ cd ~/linux-5.7			# change to the 5.7 source dir
364*4882a593Smuzhiyun	$ patch -p1 < ../patch-5.8-rc3		# apply the 5.8-rc3 patch
365*4882a593Smuzhiyun	$ cd ..
366*4882a593Smuzhiyun	$ mv linux-5.7 linux-5.8-rc3		# rename the source dir
367*4882a593Smuzhiyun
368*4882a593Smuzhiyun	# now let's move from 5.8-rc3 to 5.8-rc5
369*4882a593Smuzhiyun
370*4882a593Smuzhiyun	$ cd ~/linux-5.8-rc3			# change to the 5.8-rc3 dir
371*4882a593Smuzhiyun	$ patch -p1 -R < ../patch-5.8-rc3	# revert the 5.8-rc3 patch
372*4882a593Smuzhiyun	$ patch -p1 < ../patch-5.8-rc5		# apply the new 5.8-rc5 patch
373*4882a593Smuzhiyun	$ cd ..
374*4882a593Smuzhiyun	$ mv linux-5.8-rc3 linux-5.8-rc5	# rename the source dir
375*4882a593Smuzhiyun
376*4882a593Smuzhiyun	# finally let's try and move from 5.7.3 to 5.8-rc5
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun	$ cd ~/linux-5.7.3			# change to the kernel source dir
379*4882a593Smuzhiyun	$ patch -p1 -R < ../patch-5.7.3		# revert the 5.7.3 patch
380*4882a593Smuzhiyun	$ patch -p1 < ../patch-5.8-rc5		# apply new 5.8-rc5 patch
381*4882a593Smuzhiyun	$ cd ..
382*4882a593Smuzhiyun	$ mv linux-5.7.3 linux-5.8-rc5		# rename the kernel source dir
383*4882a593Smuzhiyun
384*4882a593Smuzhiyun
385*4882a593SmuzhiyunThe -mm patches and the linux-next tree
386*4882a593Smuzhiyun=======================================
387*4882a593Smuzhiyun
388*4882a593SmuzhiyunThe -mm patches are experimental patches released by Andrew Morton.
389*4882a593Smuzhiyun
390*4882a593SmuzhiyunIn the past, -mm tree were used to also test subsystem patches, but this
391*4882a593Smuzhiyunfunction is now done via the
392*4882a593Smuzhiyun`linux-next <https://www.kernel.org/doc/man-pages/linux-next.html>`
393*4882a593Smuzhiyuntree. The Subsystem maintainers push their patches first to linux-next,
394*4882a593Smuzhiyunand, during the merge window, sends them directly to Linus.
395*4882a593Smuzhiyun
396*4882a593SmuzhiyunThe -mm patches serve as a sort of proving ground for new features and other
397*4882a593Smuzhiyunexperimental patches that aren't merged via a subsystem tree.
398*4882a593SmuzhiyunOnce such patches has proved its worth in -mm for a while Andrew pushes
399*4882a593Smuzhiyunit on to Linus for inclusion in mainline.
400*4882a593Smuzhiyun
401*4882a593SmuzhiyunThe linux-next tree is daily updated, and includes the -mm patches.
402*4882a593SmuzhiyunBoth are in constant flux and contains many experimental features, a
403*4882a593Smuzhiyunlot of debugging patches not appropriate for mainline etc., and is the most
404*4882a593Smuzhiyunexperimental of the branches described in this document.
405*4882a593Smuzhiyun
406*4882a593SmuzhiyunThese patches are not appropriate for use on systems that are supposed to be
407*4882a593Smuzhiyunstable and they are more risky to run than any of the other branches (make
408*4882a593Smuzhiyunsure you have up-to-date backups -- that goes for any experimental kernel but
409*4882a593Smuzhiyuneven more so for -mm patches or using a Kernel from the linux-next tree).
410*4882a593Smuzhiyun
411*4882a593SmuzhiyunTesting of -mm patches and linux-next is greatly appreciated since the whole
412*4882a593Smuzhiyunpoint of those are to weed out regressions, crashes, data corruption bugs,
413*4882a593Smuzhiyunbuild breakage (and any other bug in general) before changes are merged into
414*4882a593Smuzhiyunthe more stable mainline Linus tree.
415*4882a593Smuzhiyun
416*4882a593SmuzhiyunBut testers of -mm and linux-next should be aware that breakages are
417*4882a593Smuzhiyunmore common than in any other tree.
418*4882a593Smuzhiyun
419*4882a593Smuzhiyun
420*4882a593SmuzhiyunThis concludes this list of explanations of the various kernel trees.
421*4882a593SmuzhiyunI hope you are now clear on how to apply the various patches and help testing
422*4882a593Smuzhiyunthe kernel.
423*4882a593Smuzhiyun
424*4882a593SmuzhiyunThank you's to Randy Dunlap, Rolf Eike Beer, Linus Torvalds, Bodo Eggert,
425*4882a593SmuzhiyunJohannes Stezenbach, Grant Coady, Pavel Machek and others that I may have
426*4882a593Smuzhiyunforgotten for their reviews and contributions to this document.
427