22

For each Linux kernel version, there is a patch file available for download. For instance, linux-3.12.22 has a corresponding patch-3.12.22.

What is the purpose of that patch? To always patch the corresponding kernel before compiling it, or to bring a former kernel version up-to-date with the kernel that the patch matches (3.12.22, in this case)?

Braiam
  • 35,380
  • 25
  • 108
  • 167
Eleno
  • 1,849
  • 4
  • 27
  • 39

2 Answers2

32

The purpose is to save lots of traffic.

The Linux tarball is around 75MB, whereas the patches usually just have a few KB.

So if you compile your own kernel, and update to each new minor version the day it is released, instead of redownloading a new 75MB tarball for each minor update, you just download (for example) the main tarball for a given version once and then the patch for the version you actually want. When there is an update you re-use the already downloaded main tarball.

linux-3.14.tar.xz + patch-3.14.{1..n}.xz is below 100MB in total.

linux-3.14.tar.xz + linux-3.14.{1..n}.tar.xz is several times 100MB.

There is no downside to patching, the final result is identical, unless you do something wrong.

frostschutz
  • 47,228
  • 5
  • 112
  • 159
  • 9
    As written, this doesn't quite answer the question. To be explicit, the *purpose* of the patch is that applying it to version n-1 of the source "upgrades" it to version n. The *advantage* is that it saves a lot of traffic, as the answer describes. – David Richerby Jun 22 '14 at 17:39
  • 1
    I'm not a native speaker. But advantage sounds too weak to me somehow. Saving bandwidth/traffic is important for any server. It has purpose. – frostschutz Jun 23 '14 at 07:27
  • The part you didn't answer explicitly is, "To always patch the corresponding kernel before compiling it, or to bring a former kernel version up-to-date with the kernel that the patch matches (3.12.22, in this case)?" patch-3.12.22 is to upgrade from version 3.12.21 to .22, not to be applied to the 3.12.22 sources before compiling them. – David Richerby Jun 23 '14 at 08:15
  • Patches are usually for `.0`, e.g. `VERSION = 3 PATCHLEVEL = 12 -SUBLEVEL = 0 +SUBLEVEL = 22`. It would be annoying to go through 20 patches... – frostschutz Jun 23 '14 at 10:21
  • How would such traffic saving scheme be better than e.g. having a git clone of the repository and doing `git pull` when a new version gets released? – Ruslan Jun 23 '14 at 11:09
  • @Ruslan: a patch is hard to beat in size; unlike a version control with full history, it can provide the final result without any intermediate steps. – frostschutz Jun 24 '14 at 13:06
  • Yes, patch is against the base version. To update 3.12.21 to 3.12.22, you should first reverse-apply patch-3.12.21 to make it 3.12 and then apply patch-3.12.22 to upgrade to 3.12.22. – Chan Kim Feb 02 '21 at 06:26
6

These are called "patchset". Patchset are groups of patches that serves the same functionality, are related, or implement a function in steps. These in particular, are the difference between a major revision of the kernel (X.Y) and subsequent minor/maintenance revisions (X.Y.Z) with several proposes:

  • Save space on the servers.
  • Save bandwidth.
  • Being easily applicable and distributable

Remember that those patchsets are incremental. You first have to apply patch .1 before patch .2, and after that you can apply .3.

Braiam
  • 35,380
  • 25
  • 108
  • 167