Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer runapp02.tex V2 - 09/04/2008 6:09pm Page 1164

Appendix B: Working with the Source Code


}

+static u64 __sched_vslice(unsigned long nr_running)
+{



  • u64 period = __sched_period(nr_running);



  • do_div(period, nr_running);



  • return period;
    +}


  • /*





  • Update the current task’s runtime statistics. Skip current tasks that

  • are not in our scheduling class.


The first three lines of adiffcontain the header information. This indicates which files were handled and
includes the time stamps of both files as a comparison criterion. The second line gives the name of the old
file version, and the third line, the name of the new file version. The first line lists the options with which
thediffutility was invoked. Here, the-upoption is particularly important because it generates diffs
in the easy-to-readunified context format, which also includes the C function name to which the change
applies — all other formats are deprecated in the Linux kernel community.

diffcompares two files line by line to find the differences between them. Isolated sections of the file
where differences are found are referred to ashunks. The preceding example consists of three hunks,
each of which is introduced by two symbols.^6

Each hunk has a header to indicate the position in both files at which the difference occurs. The format of
the header is as follows:

@@ start_old,count_old start_new,count_new @@ C function

start_oldspecifies the line number in the old file to which thediffrefers.count_oldspecifies the
number of lines over which the differences extend.start_newandcount_newhave the same meanings
but relate to the source file. The C function in which the code is contained is also recorded.

The lines following the hunk header indicate what has changed in the file. Lines prefixed with a plus
sign (+) are not present in the old file, and lines prefixed with a minus sign are destined for removal
from the old file. Lines without either sign are identical in both the new file and the old file. They are
used bypatchas a context to move the patch up or down if the file to be patched does not fully match
the original file for which the patch was created. This is useful when, for example, another otherwise
orthogonal patch^7 inserts new code at the start of a file and the patch position is therefore moved down.

ApplyingPatches


Apatchis a collection of diffs that reside in a common file. For example, patches that contain the
differences between two kernel versions are made available atwww.kernel.orgfor updating purposes.
It is then no longer necessary to download the entire source tree, thus saving time and bandwidth.

(^6) If two files are totally different,diffcreates a single large hunk that covers the whole file.
(^7) Patches are referred to asorthogonalif they do not mutually influence each other; that is, if a patch changes only code segments that
do not affect other segments.

Free download pdf