Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'docs-4.9' of git://git.lwn.net/linux

Pull documentation updates from Jonathan Corbet:
"This is the documentation update pull for the 4.9 merge window.

The Sphinx transition is still creating a fair amount of work. Here we
have a number of fixes and, importantly, a proper PDF output solution,
thanks to Jani Nikula, Mauro Carvalho Chehab and Markus Heiser.

I've started a couple of new books: a driver API book (based on the
old device-drivers.tmpl) and a development tools book. Both are meant
to show how we can integrate together our existing documentation into
a more coherent and accessible whole. It involves moving some stuff
around and formatting changes, but, I think, the results are worth it.
The good news is that most of our existing Documentation/*.txt files
are *almost* in RST format already; the amount of messing around
required is minimal.

And, of course, there's the usual set of updates, typo fixes, and
more"

* tag 'docs-4.9' of git://git.lwn.net/linux: (120 commits)
URL changed for Linux Foundation TAB
dax : Fix documentation with respect to struct pages
iio: Documentation: Correct the path used to create triggers.
docs: Remove space-before-label guidance from CodingStyle
docs-rst: add inter-document cross references
Documentation/email-clients.txt: convert it to ReST markup
Documentation/kernel-docs.txt: reorder based on timestamp
Documentation/kernel-docs.txt: Add dates for online docs
Documentation/kernel-docs.txt: get rid of broken docs
Documentation/kernel-docs.txt: move in-kernel docs
Documentation/kernel-docs.txt: remove more legacy references
Documentation/kernel-docs.txt: add two published books
Documentation/kernel-docs.txt: sort books per publication date
Documentation/kernel-docs.txt: adjust LDD references
Documentation/kernel-docs.txt: some improvements on the ReST output
Documentation/kernel-docs.txt: Consistent indenting: 4 spaces
Documentation/kernel-docs.txt: Add 4 paper/book references
Documentation/kernel-docs.txt: Improve layouting of book list
Documentation/kernel-docs.txt: Remove offline or outdated entries
docs: Clean up bare :: lines
...

+5131 -3901
+168 -94
Documentation/Changes
··· 1 + .. _changes: 2 + 3 + Minimal requerements to compile the Kernel 4 + ++++++++++++++++++++++++++++++++++++++++++ 5 + 1 6 Intro 2 7 ===== 3 8 4 9 This document is designed to provide a list of the minimum levels of 5 - software necessary to run the 3.0 kernels. 10 + software necessary to run the 4.x kernels. 6 11 7 12 This document is originally based on my "Changes" file for 2.0.x kernels 8 13 and therefore owes credit to the same people as that file (Jared Mauch, ··· 15 10 'net). 16 11 17 12 Current Minimal Requirements 18 - ============================ 13 + **************************** 19 14 20 - Upgrade to at *least* these software revisions before thinking you've 15 + Upgrade to at **least** these software revisions before thinking you've 21 16 encountered a bug! If you're unsure what version you're currently 22 17 running, the suggested command should tell you. 23 18 ··· 26 21 systems; obviously, if you don't have any ISDN hardware, for example, 27 22 you probably needn't concern yourself with isdn4k-utils. 28 23 29 - o GNU C 3.2 # gcc --version 30 - o GNU make 3.80 # make --version 31 - o binutils 2.12 # ld -v 32 - o util-linux 2.10o # fdformat --version 33 - o module-init-tools 0.9.10 # depmod -V 34 - o e2fsprogs 1.41.4 # e2fsck -V 35 - o jfsutils 1.1.3 # fsck.jfs -V 36 - o reiserfsprogs 3.6.3 # reiserfsck -V 37 - o xfsprogs 2.6.0 # xfs_db -V 38 - o squashfs-tools 4.0 # mksquashfs -version 39 - o btrfs-progs 0.18 # btrfsck 40 - o pcmciautils 004 # pccardctl -V 41 - o quota-tools 3.09 # quota -V 42 - o PPP 2.4.0 # pppd --version 43 - o isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version 44 - o nfs-utils 1.0.5 # showmount --version 45 - o procps 3.2.0 # ps --version 46 - o oprofile 0.9 # oprofiled --version 47 - o udev 081 # udevd --version 48 - o grub 0.93 # grub --version || grub-install --version 49 - o mcelog 0.6 # mcelog --version 50 - o iptables 1.4.2 # iptables -V 51 - o openssl & libcrypto 1.0.0 # openssl version 52 - o bc 1.06.95 # bc --version 24 + ====================== =============== ======================================== 25 + Program Minimal version Command to check the version 26 + ====================== =============== ======================================== 27 + GNU C 3.2 gcc --version 28 + GNU make 3.80 make --version 29 + binutils 2.12 ld -v 30 + util-linux 2.10o fdformat --version 31 + module-init-tools 0.9.10 depmod -V 32 + e2fsprogs 1.41.4 e2fsck -V 33 + jfsutils 1.1.3 fsck.jfs -V 34 + reiserfsprogs 3.6.3 reiserfsck -V 35 + xfsprogs 2.6.0 xfs_db -V 36 + squashfs-tools 4.0 mksquashfs -version 37 + btrfs-progs 0.18 btrfsck 38 + pcmciautils 004 pccardctl -V 39 + quota-tools 3.09 quota -V 40 + PPP 2.4.0 pppd --version 41 + isdn4k-utils 3.1pre1 isdnctrl 2>&1|grep version 42 + nfs-utils 1.0.5 showmount --version 43 + procps 3.2.0 ps --version 44 + oprofile 0.9 oprofiled --version 45 + udev 081 udevd --version 46 + grub 0.93 grub --version || grub-install --version 47 + mcelog 0.6 mcelog --version 48 + iptables 1.4.2 iptables -V 49 + openssl & libcrypto 1.0.0 openssl version 50 + bc 1.06.95 bc --version 51 + Sphinx\ [#f1]_ 1.2 sphinx-build --version 52 + ====================== =============== ======================================== 53 53 54 + .. [#f1] Sphinx is needed only to build the Kernel documentation 54 55 55 56 Kernel compilation 56 - ================== 57 + ****************** 57 58 58 59 GCC 59 60 --- ··· 75 64 Binutils 76 65 -------- 77 66 78 - Linux on IA-32 has recently switched from using as86 to using gas for 79 - assembling the 16-bit boot code, removing the need for as86 to compile 67 + Linux on IA-32 has recently switched from using ``as86`` to using ``gas`` for 68 + assembling the 16-bit boot code, removing the need for ``as86`` to compile 80 69 your kernel. This change does, however, mean that you need a recent 81 70 release of binutils. 82 71 83 72 Perl 84 73 ---- 85 74 86 - You will need perl 5 and the following modules: Getopt::Long, Getopt::Std, 87 - File::Basename, and File::Find to build the kernel. 75 + You will need perl 5 and the following modules: ``Getopt::Long``, 76 + ``Getopt::Std``, ``File::Basename``, and ``File::Find`` to build the kernel. 88 77 89 78 BC 90 79 -- ··· 104 93 105 94 106 95 System utilities 107 - ================ 96 + **************** 108 97 109 98 Architectural changes 110 99 --------------------- ··· 126 115 Util-linux 127 116 ---------- 128 117 129 - New versions of util-linux provide *fdisk support for larger disks, 118 + New versions of util-linux provide ``fdisk`` support for larger disks, 130 119 support new options to mount, recognize more supported partition 131 120 types, have a fdformat which works with 2.4 kernels, and similar goodies. 132 121 You'll probably want to upgrade. ··· 136 125 137 126 If the unthinkable happens and your kernel oopses, you may need the 138 127 ksymoops tool to decode it, but in most cases you don't. 139 - It is generally preferred to build the kernel with CONFIG_KALLSYMS so 128 + It is generally preferred to build the kernel with ``CONFIG_KALLSYMS`` so 140 129 that it produces readable dumps that can be used as-is (this also 141 130 produces better output than ksymoops). If for some reason your kernel 142 - is not build with CONFIG_KALLSYMS and you have no way to rebuild and 131 + is not build with ``CONFIG_KALLSYMS`` and you have no way to rebuild and 143 132 reproduce the Oops with that option, then you can still decode that Oops 144 133 with ksymoops. 145 134 146 135 Module-Init-Tools 147 136 ----------------- 148 137 149 - A new module loader is now in the kernel that requires module-init-tools 138 + A new module loader is now in the kernel that requires ``module-init-tools`` 150 139 to use. It is backward compatible with the 2.4.x series kernels. 151 140 152 141 Mkinitrd 153 142 -------- 154 143 155 - These changes to the /lib/modules file tree layout also require that 144 + These changes to the ``/lib/modules`` file tree layout also require that 156 145 mkinitrd be upgraded. 157 146 158 147 E2fsprogs 159 148 --------- 160 149 161 - The latest version of e2fsprogs fixes several bugs in fsck and 150 + The latest version of ``e2fsprogs`` fixes several bugs in fsck and 162 151 debugfs. Obviously, it's a good idea to upgrade. 163 152 164 153 JFSutils 165 154 -------- 166 155 167 - The jfsutils package contains the utilities for the file system. 156 + The ``jfsutils`` package contains the utilities for the file system. 168 157 The following utilities are available: 169 - o fsck.jfs - initiate replay of the transaction log, and check 158 + 159 + - ``fsck.jfs`` - initiate replay of the transaction log, and check 170 160 and repair a JFS formatted partition. 171 - o mkfs.jfs - create a JFS formatted partition. 172 - o other file system utilities are also available in this package. 161 + 162 + - ``mkfs.jfs`` - create a JFS formatted partition. 163 + 164 + - other file system utilities are also available in this package. 173 165 174 166 Reiserfsprogs 175 167 ------------- 176 168 177 169 The reiserfsprogs package should be used for reiserfs-3.6.x 178 170 (Linux kernels 2.4.x). It is a combined package and contains working 179 - versions of mkreiserfs, resize_reiserfs, debugreiserfs and 180 - reiserfsck. These utils work on both i386 and alpha platforms. 171 + versions of ``mkreiserfs``, ``resize_reiserfs``, ``debugreiserfs`` and 172 + ``reiserfsck``. These utils work on both i386 and alpha platforms. 181 173 182 174 Xfsprogs 183 175 -------- 184 176 185 - The latest version of xfsprogs contains mkfs.xfs, xfs_db, and the 186 - xfs_repair utilities, among others, for the XFS filesystem. It is 177 + The latest version of ``xfsprogs`` contains ``mkfs.xfs``, ``xfs_db``, and the 178 + ``xfs_repair`` utilities, among others, for the XFS filesystem. It is 187 179 architecture independent and any version from 2.0.0 onward should 188 180 work correctly with this version of the XFS kernel code (2.6.0 or 189 181 later is recommended, due to some significant improvements). ··· 194 180 PCMCIAutils 195 181 ----------- 196 182 197 - PCMCIAutils replaces pcmcia-cs. It properly sets up 183 + PCMCIAutils replaces ``pcmcia-cs``. It properly sets up 198 184 PCMCIA sockets at system startup and loads the appropriate modules 199 185 for 16-bit PCMCIA devices if the kernel is modularized and the hotplug 200 186 subsystem is used. ··· 212 198 213 199 A driver has been added to allow updating of Intel IA32 microcode, 214 200 accessible as a normal (misc) character device. If you are not using 215 - udev you may need to: 201 + udev you may need to:: 216 202 217 - mkdir /dev/cpu 218 - mknod /dev/cpu/microcode c 10 184 219 - chmod 0644 /dev/cpu/microcode 203 + mkdir /dev/cpu 204 + mknod /dev/cpu/microcode c 10 184 205 + chmod 0644 /dev/cpu/microcode 220 206 221 207 as root before you can use this. You'll probably also want to 222 208 get the user-space microcode_ctl utility to use with this. 223 209 224 210 udev 225 211 ---- 226 - udev is a userspace application for populating /dev dynamically with 227 - only entries for devices actually present. udev replaces the basic 212 + 213 + ``udev`` is a userspace application for populating ``/dev`` dynamically with 214 + only entries for devices actually present. ``udev`` replaces the basic 228 215 functionality of devfs, while allowing persistent device naming for 229 216 devices. 230 217 ··· 233 218 ---- 234 219 235 220 Needs libfuse 2.4.0 or later. Absolute minimum is 2.3.0 but mount 236 - options 'direct_io' and 'kernel_cache' won't work. 221 + options ``direct_io`` and ``kernel_cache`` won't work. 237 222 238 223 Networking 239 - ========== 224 + ********** 240 225 241 226 General changes 242 227 --------------- ··· 258 243 upgrade pppd to at least 2.4.0. 259 244 260 245 If you are not using udev, you must have the device file /dev/ppp 261 - which can be made by: 246 + which can be made by:: 262 247 263 - mknod /dev/ppp c 108 0 248 + mknod /dev/ppp c 108 0 264 249 265 250 as root. 266 251 ··· 275 260 276 261 In ancient (2.4 and earlier) kernels, the nfs server needed to know 277 262 about any client that expected to be able to access files via NFS. This 278 - information would be given to the kernel by "mountd" when the client 279 - mounted the filesystem, or by "exportfs" at system startup. exportfs 280 - would take information about active clients from /var/lib/nfs/rmtab. 263 + information would be given to the kernel by ``mountd`` when the client 264 + mounted the filesystem, or by ``exportfs`` at system startup. exportfs 265 + would take information about active clients from ``/var/lib/nfs/rmtab``. 281 266 282 267 This approach is quite fragile as it depends on rmtab being correct 283 268 which is not always easy, particularly when trying to implement 284 - fail-over. Even when the system is working well, rmtab suffers from 269 + fail-over. Even when the system is working well, ``rmtab`` suffers from 285 270 getting lots of old entries that never get removed. 286 271 287 272 With modern kernels we have the option of having the kernel tell mountd 288 273 when it gets a request from an unknown host, and mountd can give 289 274 appropriate export information to the kernel. This removes the 290 - dependency on rmtab and means that the kernel only needs to know about 275 + dependency on ``rmtab`` and means that the kernel only needs to know about 291 276 currently active clients. 292 277 293 - To enable this new functionality, you need to: 278 + To enable this new functionality, you need to:: 294 279 295 280 mount -t nfsd nfsd /proc/fs/nfsd 296 281 ··· 302 287 ------ 303 288 304 289 On x86 kernels the mcelog utility is needed to process and log machine check 305 - events when CONFIG_X86_MCE is enabled. Machine check events are errors reported 306 - by the CPU. Processing them is strongly encouraged. 290 + events when ``CONFIG_X86_MCE`` is enabled. Machine check events are errors 291 + reported by the CPU. Processing them is strongly encouraged. 292 + 293 + Kernel documentation 294 + ******************** 295 + 296 + Sphinx 297 + ------ 298 + 299 + The ReST markups currently used by the Documentation/ files are meant to be 300 + built with ``Sphinx`` version 1.2 or upper. If you're desiring to build 301 + PDF outputs, it is recommended to use version 1.4.6. 302 + 303 + .. note:: 304 + 305 + Please notice that, for PDF and LaTeX output, you'll also need ``XeLaTeX`` 306 + version 3.14159265. Depending on the distribution, you may also need 307 + to install a series of ``texlive`` packages that provide the minimal 308 + set of functionalities required for ``XeLaTex`` to work. 309 + 310 + Other tools 311 + ----------- 312 + 313 + In order to produce documentation from DocBook, you'll also need ``xmlto``. 314 + Please notice, however, that we're currently migrating all documents to use 315 + ``Sphinx``. 307 316 308 317 Getting updated software 309 318 ======================== ··· 337 298 338 299 gcc 339 300 --- 340 - o <ftp://ftp.gnu.org/gnu/gcc/> 301 + 302 + - <ftp://ftp.gnu.org/gnu/gcc/> 341 303 342 304 Make 343 305 ---- 344 - o <ftp://ftp.gnu.org/gnu/make/> 306 + 307 + - <ftp://ftp.gnu.org/gnu/make/> 345 308 346 309 Binutils 347 310 -------- 348 - o <ftp://ftp.kernel.org/pub/linux/devel/binutils/> 311 + 312 + - <ftp://ftp.kernel.org/pub/linux/devel/binutils/> 349 313 350 314 OpenSSL 351 315 ------- 352 - o <https://www.openssl.org/> 316 + 317 + - <https://www.openssl.org/> 353 318 354 319 System utilities 355 320 **************** 356 321 357 322 Util-linux 358 323 ---------- 359 - o <ftp://ftp.kernel.org/pub/linux/utils/util-linux/> 324 + 325 + - <ftp://ftp.kernel.org/pub/linux/utils/util-linux/> 360 326 361 327 Ksymoops 362 328 -------- 363 - o <ftp://ftp.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/> 329 + 330 + - <ftp://ftp.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/> 364 331 365 332 Module-Init-Tools 366 333 ----------------- 367 - o <ftp://ftp.kernel.org/pub/linux/kernel/people/rusty/modules/> 334 + 335 + - <ftp://ftp.kernel.org/pub/linux/kernel/people/rusty/modules/> 368 336 369 337 Mkinitrd 370 338 -------- 371 - o <https://code.launchpad.net/initrd-tools/main> 339 + 340 + - <https://code.launchpad.net/initrd-tools/main> 372 341 373 342 E2fsprogs 374 343 --------- 375 - o <http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.29.tar.gz> 344 + 345 + - <http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.29.tar.gz> 376 346 377 347 JFSutils 378 348 -------- 379 - o <http://jfs.sourceforge.net/> 349 + 350 + - <http://jfs.sourceforge.net/> 380 351 381 352 Reiserfsprogs 382 353 ------------- 383 - o <http://www.kernel.org/pub/linux/utils/fs/reiserfs/> 354 + 355 + - <http://www.kernel.org/pub/linux/utils/fs/reiserfs/> 384 356 385 357 Xfsprogs 386 358 -------- 387 - o <ftp://oss.sgi.com/projects/xfs/> 359 + 360 + - <ftp://oss.sgi.com/projects/xfs/> 388 361 389 362 Pcmciautils 390 363 ----------- 391 - o <ftp://ftp.kernel.org/pub/linux/utils/kernel/pcmcia/> 364 + 365 + - <ftp://ftp.kernel.org/pub/linux/utils/kernel/pcmcia/> 392 366 393 367 Quota-tools 394 - ---------- 395 - o <http://sourceforge.net/projects/linuxquota/> 368 + ----------- 369 + 370 + - <http://sourceforge.net/projects/linuxquota/> 396 371 397 372 DocBook Stylesheets 398 373 ------------------- 399 - o <http://sourceforge.net/projects/docbook/files/docbook-dsssl/> 374 + 375 + - <http://sourceforge.net/projects/docbook/files/docbook-dsssl/> 400 376 401 377 XMLTO XSLT Frontend 402 378 ------------------- 403 - o <http://cyberelk.net/tim/xmlto/> 379 + 380 + - <http://cyberelk.net/tim/xmlto/> 404 381 405 382 Intel P6 microcode 406 383 ------------------ 407 - o <https://downloadcenter.intel.com/> 384 + 385 + - <https://downloadcenter.intel.com/> 408 386 409 387 udev 410 388 ---- 411 - o <http://www.freedesktop.org/software/systemd/man/udev.html> 389 + 390 + - <http://www.freedesktop.org/software/systemd/man/udev.html> 412 391 413 392 FUSE 414 393 ---- 415 - o <http://sourceforge.net/projects/fuse> 394 + 395 + - <http://sourceforge.net/projects/fuse> 416 396 417 397 mcelog 418 398 ------ 419 - o <http://www.mcelog.org/> 399 + 400 + - <http://www.mcelog.org/> 420 401 421 402 Networking 422 403 ********** 423 404 424 405 PPP 425 406 --- 426 - o <ftp://ftp.samba.org/pub/ppp/> 407 + 408 + - <ftp://ftp.samba.org/pub/ppp/> 427 409 428 410 Isdn4k-utils 429 411 ------------ 430 - o <ftp://ftp.isdn4linux.de/pub/isdn4linux/utils/> 412 + 413 + - <ftp://ftp.isdn4linux.de/pub/isdn4linux/utils/> 431 414 432 415 NFS-utils 433 416 --------- 434 - o <http://sourceforge.net/project/showfiles.php?group_id=14> 417 + 418 + - <http://sourceforge.net/project/showfiles.php?group_id=14> 435 419 436 420 Iptables 437 421 -------- 438 - o <http://www.iptables.org/downloads.html> 422 + 423 + - <http://www.iptables.org/downloads.html> 439 424 440 425 Ip-route2 441 426 --------- 442 - o <https://www.kernel.org/pub/linux/utils/net/iproute2/> 427 + 428 + - <https://www.kernel.org/pub/linux/utils/net/iproute2/> 443 429 444 430 OProfile 445 431 -------- 446 - o <http://oprofile.sf.net/download/> 432 + 433 + - <http://oprofile.sf.net/download/> 447 434 448 435 NFS-Utils 449 436 --------- 450 - o <http://nfs.sourceforge.net/> 437 + 438 + - <http://nfs.sourceforge.net/> 439 + 440 + Kernel documentation 441 + ******************** 442 + 443 + Sphinx 444 + ------ 445 + 446 + - <http://www.sphinx-doc.org/>
+1 -1
Documentation/CodeOfConflict
··· 19 19 will work to resolve the issue to the best of their ability. For more 20 20 information on who is on the Technical Advisory Board and what their 21 21 role is, please see: 22 - http://www.linuxfoundation.org/programs/advisory-councils/tab 22 + http://www.linuxfoundation.org/projects/linux/tab 23 23 24 24 As a reviewer of code, please strive to keep things civil and focused on 25 25 the technical issues involved. We are all humans, and frustrations can
+258 -142
Documentation/CodingStyle
··· 1 + .. _codingstyle: 1 2 2 - Linux kernel coding style 3 + Linux kernel coding style 4 + ========================= 3 5 4 6 This is a short document describing the preferred coding style for the 5 - linux kernel. Coding style is very personal, and I won't _force_ my 7 + linux kernel. Coding style is very personal, and I won't **force** my 6 8 views on anybody, but this is what goes for anything that I have to be 7 9 able to maintain, and I'd prefer it for most other things too. Please 8 10 at least consider the points made here. ··· 15 13 Anyway, here goes: 16 14 17 15 18 - Chapter 1: Indentation 16 + 1) Indentation 17 + -------------- 19 18 20 19 Tabs are 8 characters, and thus indentations are also 8 characters. 21 20 There are heretic movements that try to make indentations 4 (or even 2!) ··· 39 36 Heed that warning. 40 37 41 38 The preferred way to ease multiple indentation levels in a switch statement is 42 - to align the "switch" and its subordinate "case" labels in the same column 43 - instead of "double-indenting" the "case" labels. E.g.: 39 + to align the ``switch`` and its subordinate ``case`` labels in the same column 40 + instead of ``double-indenting`` the ``case`` labels. E.g.: 41 + 42 + .. code-block:: c 44 43 45 44 switch (suffix) { 46 45 case 'G': ··· 64 59 Don't put multiple statements on a single line unless you have 65 60 something to hide: 66 61 62 + .. code-block:: c 63 + 67 64 if (condition) do_this; 68 65 do_something_everytime; 69 66 ··· 78 71 Get a decent editor and don't leave whitespace at the end of lines. 79 72 80 73 81 - Chapter 2: Breaking long lines and strings 74 + 2) Breaking long lines and strings 75 + ---------------------------------- 82 76 83 77 Coding style is all about readability and maintainability using commonly 84 78 available tools. ··· 95 87 printk messages, because that breaks the ability to grep for them. 96 88 97 89 98 - Chapter 3: Placing Braces and Spaces 90 + 3) Placing Braces and Spaces 91 + ---------------------------- 99 92 100 93 The other issue that always comes up in C styling is the placement of 101 94 braces. Unlike the indent size, there are few technical reasons to ··· 104 95 shown to us by the prophets Kernighan and Ritchie, is to put the opening 105 96 brace last on the line, and put the closing brace first, thusly: 106 97 98 + .. code-block:: c 99 + 107 100 if (x is true) { 108 101 we do y 109 102 } 110 103 111 104 This applies to all non-function statement blocks (if, switch, for, 112 105 while, do). E.g.: 106 + 107 + .. code-block:: c 113 108 114 109 switch (action) { 115 110 case KOBJ_ADD: ··· 129 116 However, there is one special case, namely functions: they have the 130 117 opening brace at the beginning of the next line, thus: 131 118 119 + .. code-block:: c 120 + 132 121 int function(int x) 133 122 { 134 123 body of function ··· 138 123 139 124 Heretic people all over the world have claimed that this inconsistency 140 125 is ... well ... inconsistent, but all right-thinking people know that 141 - (a) K&R are _right_ and (b) K&R are right. Besides, functions are 126 + (a) K&R are **right** and (b) K&R are right. Besides, functions are 142 127 special anyway (you can't nest them in C). 143 128 144 - Note that the closing brace is empty on a line of its own, _except_ in 129 + Note that the closing brace is empty on a line of its own, **except** in 145 130 the cases where it is followed by a continuation of the same statement, 146 - ie a "while" in a do-statement or an "else" in an if-statement, like 131 + ie a ``while`` in a do-statement or an ``else`` in an if-statement, like 147 132 this: 133 + 134 + .. code-block:: c 148 135 149 136 do { 150 137 body of do-loop 151 138 } while (condition); 152 139 153 140 and 141 + 142 + .. code-block:: c 154 143 155 144 if (x == y) { 156 145 .. ··· 174 155 175 156 Do not unnecessarily use braces where a single statement will do. 176 157 158 + .. code-block:: c 159 + 177 160 if (condition) 178 161 action(); 179 162 180 163 and 164 + 165 + .. code-block:: none 181 166 182 167 if (condition) 183 168 do_this(); ··· 191 168 This does not apply if only one branch of a conditional statement is a single 192 169 statement; in the latter case use braces in both branches: 193 170 171 + .. code-block:: c 172 + 194 173 if (condition) { 195 174 do_this(); 196 175 do_that(); ··· 200 175 otherwise(); 201 176 } 202 177 203 - 3.1: Spaces 178 + 3.1) Spaces 179 + *********** 204 180 205 181 Linux kernel style for use of spaces depends (mostly) on 206 182 function-versus-keyword usage. Use a space after (most) keywords. The 207 183 notable exceptions are sizeof, typeof, alignof, and __attribute__, which look 208 184 somewhat like functions (and are usually used with parentheses in Linux, 209 - although they are not required in the language, as in: "sizeof info" after 210 - "struct fileinfo info;" is declared). 185 + although they are not required in the language, as in: ``sizeof info`` after 186 + ``struct fileinfo info;`` is declared). 211 187 212 - So use a space after these keywords: 188 + So use a space after these keywords:: 213 189 214 190 if, switch, case, for, do, while 215 191 216 192 but not with sizeof, typeof, alignof, or __attribute__. E.g., 217 193 194 + .. code-block:: c 195 + 196 + 218 197 s = sizeof(struct file); 219 198 220 199 Do not add spaces around (inside) parenthesized expressions. This example is 221 - *bad*: 200 + **bad**: 201 + 202 + .. code-block:: c 203 + 222 204 223 205 s = sizeof( struct file ); 224 206 225 207 When declaring pointer data or a function that returns a pointer type, the 226 - preferred use of '*' is adjacent to the data name or function name and not 208 + preferred use of ``*`` is adjacent to the data name or function name and not 227 209 adjacent to the type name. Examples: 210 + 211 + .. code-block:: c 212 + 228 213 229 214 char *linux_banner; 230 215 unsigned long long memparse(char *ptr, char **retptr); 231 216 char *match_strdup(substring_t *s); 232 217 233 218 Use one space around (on each side of) most binary and ternary operators, 234 - such as any of these: 219 + such as any of these:: 235 220 236 221 = + - < > * / % | & ^ <= >= == != ? : 237 222 238 - but no space after unary operators: 223 + but no space after unary operators:: 239 224 240 225 & * + - ~ ! sizeof typeof alignof __attribute__ defined 241 226 242 - no space before the postfix increment & decrement unary operators: 227 + no space before the postfix increment & decrement unary operators:: 243 228 244 229 ++ -- 245 230 246 - no space after the prefix increment & decrement unary operators: 231 + no space after the prefix increment & decrement unary operators:: 247 232 248 233 ++ -- 249 234 250 - and no space around the '.' and "->" structure member operators. 235 + and no space around the ``.`` and ``->`` structure member operators. 251 236 252 237 Do not leave trailing whitespace at the ends of lines. Some editors with 253 - "smart" indentation will insert whitespace at the beginning of new lines as 238 + ``smart`` indentation will insert whitespace at the beginning of new lines as 254 239 appropriate, so you can start typing the next line of code right away. 255 240 However, some such editors do not remove the whitespace if you end up not 256 241 putting a line of code there, such as if you leave a blank line. As a result, ··· 272 237 context lines. 273 238 274 239 275 - Chapter 4: Naming 240 + 4) Naming 241 + --------- 276 242 277 243 C is a Spartan language, and so should your naming be. Unlike Modula-2 278 244 and Pascal programmers, C programmers do not use cute names like 279 245 ThisVariableIsATemporaryCounter. A C programmer would call that 280 - variable "tmp", which is much easier to write, and not the least more 246 + variable ``tmp``, which is much easier to write, and not the least more 281 247 difficult to understand. 282 248 283 249 HOWEVER, while mixed-case names are frowned upon, descriptive names for 284 - global variables are a must. To call a global function "foo" is a 250 + global variables are a must. To call a global function ``foo`` is a 285 251 shooting offense. 286 252 287 - GLOBAL variables (to be used only if you _really_ need them) need to 253 + GLOBAL variables (to be used only if you **really** need them) need to 288 254 have descriptive names, as do global functions. If you have a function 289 255 that counts the number of active users, you should call that 290 - "count_active_users()" or similar, you should _not_ call it "cntusr()". 256 + ``count_active_users()`` or similar, you should **not** call it ``cntusr()``. 291 257 292 258 Encoding the type of a function into the name (so-called Hungarian 293 259 notation) is brain damaged - the compiler knows the types anyway and can ··· 296 260 makes buggy programs. 297 261 298 262 LOCAL variable names should be short, and to the point. If you have 299 - some random integer loop counter, it should probably be called "i". 300 - Calling it "loop_counter" is non-productive, if there is no chance of it 301 - being mis-understood. Similarly, "tmp" can be just about any type of 263 + some random integer loop counter, it should probably be called ``i``. 264 + Calling it ``loop_counter`` is non-productive, if there is no chance of it 265 + being mis-understood. Similarly, ``tmp`` can be just about any type of 302 266 variable that is used to hold a temporary value. 303 267 304 268 If you are afraid to mix up your local variable names, you have another ··· 306 270 See chapter 6 (Functions). 307 271 308 272 309 - Chapter 5: Typedefs 273 + 5) Typedefs 274 + ----------- 310 275 311 - Please don't use things like "vps_t". 312 - It's a _mistake_ to use typedef for structures and pointers. When you see a 276 + Please don't use things like ``vps_t``. 277 + It's a **mistake** to use typedef for structures and pointers. When you see a 278 + 279 + .. code-block:: c 280 + 313 281 314 282 vps_t a; 315 283 316 284 in the source, what does it mean? 317 285 In contrast, if it says 318 286 287 + .. code-block:: c 288 + 319 289 struct virtual_container *a; 320 290 321 - you can actually tell what "a" is. 291 + you can actually tell what ``a`` is. 322 292 323 - Lots of people think that typedefs "help readability". Not so. They are 293 + Lots of people think that typedefs ``help readability``. Not so. They are 324 294 useful only for: 325 295 326 - (a) totally opaque objects (where the typedef is actively used to _hide_ 296 + (a) totally opaque objects (where the typedef is actively used to **hide** 327 297 what the object is). 328 298 329 - Example: "pte_t" etc. opaque objects that you can only access using 299 + Example: ``pte_t`` etc. opaque objects that you can only access using 330 300 the proper accessor functions. 331 301 332 - NOTE! Opaqueness and "accessor functions" are not good in themselves. 333 - The reason we have them for things like pte_t etc. is that there 334 - really is absolutely _zero_ portably accessible information there. 302 + .. note:: 335 303 336 - (b) Clear integer types, where the abstraction _helps_ avoid confusion 337 - whether it is "int" or "long". 304 + Opaqueness and ``accessor functions`` are not good in themselves. 305 + The reason we have them for things like pte_t etc. is that there 306 + really is absolutely **zero** portably accessible information there. 307 + 308 + (b) Clear integer types, where the abstraction **helps** avoid confusion 309 + whether it is ``int`` or ``long``. 338 310 339 311 u8/u16/u32 are perfectly fine typedefs, although they fit into 340 312 category (d) better than here. 341 313 342 - NOTE! Again - there needs to be a _reason_ for this. If something is 343 - "unsigned long", then there's no reason to do 314 + .. note:: 315 + 316 + Again - there needs to be a **reason** for this. If something is 317 + ``unsigned long``, then there's no reason to do 344 318 345 319 typedef unsigned long myflags_t; 346 320 347 321 but if there is a clear reason for why it under certain circumstances 348 - might be an "unsigned int" and under other configurations might be 349 - "unsigned long", then by all means go ahead and use a typedef. 322 + might be an ``unsigned int`` and under other configurations might be 323 + ``unsigned long``, then by all means go ahead and use a typedef. 350 324 351 - (c) when you use sparse to literally create a _new_ type for 325 + (c) when you use sparse to literally create a **new** type for 352 326 type-checking. 353 327 354 328 (d) New types which are identical to standard C99 types, in certain 355 329 exceptional circumstances. 356 330 357 331 Although it would only take a short amount of time for the eyes and 358 - brain to become accustomed to the standard types like 'uint32_t', 332 + brain to become accustomed to the standard types like ``uint32_t``, 359 333 some people object to their use anyway. 360 334 361 - Therefore, the Linux-specific 'u8/u16/u32/u64' types and their 335 + Therefore, the Linux-specific ``u8/u16/u32/u64`` types and their 362 336 signed equivalents which are identical to standard types are 363 337 permitted -- although they are not mandatory in new code of your 364 338 own. ··· 379 333 (e) Types safe for use in userspace. 380 334 381 335 In certain structures which are visible to userspace, we cannot 382 - require C99 types and cannot use the 'u32' form above. Thus, we 336 + require C99 types and cannot use the ``u32`` form above. Thus, we 383 337 use __u32 and similar types in all structures which are shared 384 338 with userspace. 385 339 ··· 387 341 EVER use a typedef unless you can clearly match one of those rules. 388 342 389 343 In general, a pointer, or a struct that has elements that can reasonably 390 - be directly accessed should _never_ be a typedef. 344 + be directly accessed should **never** be a typedef. 391 345 392 346 393 - Chapter 6: Functions 347 + 6) Functions 348 + ------------ 394 349 395 350 Functions should be short and sweet, and do just one thing. They should 396 351 fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, ··· 419 372 to understand what you did 2 weeks from now. 420 373 421 374 In source files, separate functions with one blank line. If the function is 422 - exported, the EXPORT* macro for it should follow immediately after the closing 423 - function brace line. E.g.: 375 + exported, the **EXPORT** macro for it should follow immediately after the 376 + closing function brace line. E.g.: 377 + 378 + .. code-block:: c 424 379 425 380 int system_is_up(void) 426 381 { ··· 435 386 because it is a simple way to add valuable information for the reader. 436 387 437 388 438 - Chapter 7: Centralized exiting of functions 389 + 7) Centralized exiting of functions 390 + ----------------------------------- 439 391 440 392 Albeit deprecated by some people, the equivalent of the goto statement is 441 393 used frequently by compilers in form of the unconditional jump instruction. ··· 446 396 cleanup needed then just return directly. 447 397 448 398 Choose label names which say what the goto does or why the goto exists. An 449 - example of a good name could be "out_buffer:" if the goto frees "buffer". Avoid 450 - using GW-BASIC names like "err1:" and "err2:". Also don't name them after the 451 - goto location like "err_kmalloc_failed:" 399 + example of a good name could be ``out_free_buffer:`` if the goto frees ``buffer``. 400 + Avoid using GW-BASIC names like ``err1:`` and ``err2:``, as you would have to 401 + renumber them if you ever add or remove exit paths, and they make correctness 402 + difficult to verify anyway. 452 403 453 404 The rationale for using gotos is: 454 405 455 406 - unconditional statements are easier to understand and follow 456 407 - nesting is reduced 457 408 - errors by not updating individual exit points when making 458 - modifications are prevented 409 + modifications are prevented 459 410 - saves the compiler work to optimize redundant code away ;) 411 + 412 + .. code-block:: c 460 413 461 414 int fun(int a) 462 415 { ··· 478 425 goto out_buffer; 479 426 } 480 427 ... 481 - out_buffer: 428 + out_free_buffer: 482 429 kfree(buffer); 483 430 return result; 484 431 } 485 432 486 - A common type of bug to be aware of is "one err bugs" which look like this: 433 + A common type of bug to be aware of is ``one err bugs`` which look like this: 434 + 435 + .. code-block:: c 487 436 488 437 err: 489 438 kfree(foo->bar); 490 439 kfree(foo); 491 440 return ret; 492 441 493 - The bug in this code is that on some exit paths "foo" is NULL. Normally the 494 - fix for this is to split it up into two error labels "err_bar:" and "err_foo:". 442 + The bug in this code is that on some exit paths ``foo`` is NULL. Normally the 443 + fix for this is to split it up into two error labels ``err_free_bar:`` and 444 + ``err_free_foo:``: 445 + 446 + .. code-block:: c 447 + 448 + err_free_bar: 449 + kfree(foo->bar); 450 + err_free_foo: 451 + kfree(foo); 452 + return ret; 453 + 454 + Ideally you should simulate errors to test all exit paths. 495 455 496 456 497 - Chapter 8: Commenting 457 + 8) Commenting 458 + ------------- 498 459 499 460 Comments are good, but there is also a danger of over-commenting. NEVER 500 461 try to explain HOW your code works in a comment: it's much better to 501 - write the code so that the _working_ is obvious, and it's a waste of 462 + write the code so that the **working** is obvious, and it's a waste of 502 463 time to explain badly written code. 503 464 504 465 Generally, you want your comments to tell WHAT your code does, not HOW. ··· 528 461 See the files Documentation/kernel-documentation.rst and scripts/kernel-doc 529 462 for details. 530 463 531 - Linux style for comments is the C89 "/* ... */" style. 532 - Don't use C99-style "// ..." comments. 533 - 534 464 The preferred style for long (multi-line) comments is: 465 + 466 + .. code-block:: c 535 467 536 468 /* 537 469 * This is the preferred style for multi-line ··· 543 477 544 478 For files in net/ and drivers/net/ the preferred style for long (multi-line) 545 479 comments is a little different. 480 + 481 + .. code-block:: c 546 482 547 483 /* The preferred comment style for files in net/ and drivers/net 548 484 * looks like this. ··· 559 491 item, explaining its use. 560 492 561 493 562 - Chapter 9: You've made a mess of it 494 + 9) You've made a mess of it 495 + --------------------------- 563 496 564 497 That's OK, we all do. You've probably been told by your long-time Unix 565 - user helper that "GNU emacs" automatically formats the C sources for 498 + user helper that ``GNU emacs`` automatically formats the C sources for 566 499 you, and you've noticed that yes, it does do that, but the defaults it 567 500 uses are less than desirable (in fact, they are worse than random 568 501 typing - an infinite number of monkeys typing into GNU emacs would never ··· 572 503 So, you can either get rid of GNU emacs, or change it to use saner 573 504 values. To do the latter, you can stick the following in your .emacs file: 574 505 575 - (defun c-lineup-arglist-tabs-only (ignored) 576 - "Line up argument lists by tabs, not spaces" 577 - (let* ((anchor (c-langelem-pos c-syntactic-element)) 578 - (column (c-langelem-2nd-pos c-syntactic-element)) 579 - (offset (- (1+ column) anchor)) 580 - (steps (floor offset c-basic-offset))) 581 - (* (max steps 1) 582 - c-basic-offset))) 506 + .. code-block:: none 583 507 584 - (add-hook 'c-mode-common-hook 585 - (lambda () 586 - ;; Add kernel style 587 - (c-add-style 588 - "linux-tabs-only" 589 - '("linux" (c-offsets-alist 590 - (arglist-cont-nonempty 591 - c-lineup-gcc-asm-reg 592 - c-lineup-arglist-tabs-only)))))) 508 + (defun c-lineup-arglist-tabs-only (ignored) 509 + "Line up argument lists by tabs, not spaces" 510 + (let* ((anchor (c-langelem-pos c-syntactic-element)) 511 + (column (c-langelem-2nd-pos c-syntactic-element)) 512 + (offset (- (1+ column) anchor)) 513 + (steps (floor offset c-basic-offset))) 514 + (* (max steps 1) 515 + c-basic-offset))) 593 516 594 - (add-hook 'c-mode-hook 595 - (lambda () 596 - (let ((filename (buffer-file-name))) 597 - ;; Enable kernel mode for the appropriate files 598 - (when (and filename 599 - (string-match (expand-file-name "~/src/linux-trees") 600 - filename)) 601 - (setq indent-tabs-mode t) 602 - (setq show-trailing-whitespace t) 603 - (c-set-style "linux-tabs-only"))))) 517 + (add-hook 'c-mode-common-hook 518 + (lambda () 519 + ;; Add kernel style 520 + (c-add-style 521 + "linux-tabs-only" 522 + '("linux" (c-offsets-alist 523 + (arglist-cont-nonempty 524 + c-lineup-gcc-asm-reg 525 + c-lineup-arglist-tabs-only)))))) 526 + 527 + (add-hook 'c-mode-hook 528 + (lambda () 529 + (let ((filename (buffer-file-name))) 530 + ;; Enable kernel mode for the appropriate files 531 + (when (and filename 532 + (string-match (expand-file-name "~/src/linux-trees") 533 + filename)) 534 + (setq indent-tabs-mode t) 535 + (setq show-trailing-whitespace t) 536 + (c-set-style "linux-tabs-only"))))) 604 537 605 538 This will make emacs go better with the kernel coding style for C 606 - files below ~/src/linux-trees. 539 + files below ``~/src/linux-trees``. 607 540 608 541 But even if you fail in getting emacs to do sane formatting, not 609 - everything is lost: use "indent". 542 + everything is lost: use ``indent``. 610 543 611 544 Now, again, GNU indent has the same brain-dead settings that GNU emacs 612 545 has, which is why you need to give it a few command line options. 613 546 However, that's not too bad, because even the makers of GNU indent 614 547 recognize the authority of K&R (the GNU people aren't evil, they are 615 548 just severely misguided in this matter), so you just give indent the 616 - options "-kr -i8" (stands for "K&R, 8 character indents"), or use 617 - "scripts/Lindent", which indents in the latest style. 549 + options ``-kr -i8`` (stands for ``K&R, 8 character indents``), or use 550 + ``scripts/Lindent``, which indents in the latest style. 618 551 619 - "indent" has a lot of options, and especially when it comes to comment 552 + ``indent`` has a lot of options, and especially when it comes to comment 620 553 re-formatting you may want to take a look at the man page. But 621 - remember: "indent" is not a fix for bad programming. 554 + remember: ``indent`` is not a fix for bad programming. 622 555 623 556 624 - Chapter 10: Kconfig configuration files 557 + 10) Kconfig configuration files 558 + ------------------------------- 625 559 626 560 For all of the Kconfig* configuration files throughout the source tree, 627 - the indentation is somewhat different. Lines under a "config" definition 561 + the indentation is somewhat different. Lines under a ``config`` definition 628 562 are indented with one tab, while help text is indented an additional two 629 - spaces. Example: 563 + spaces. Example:: 630 564 631 - config AUDIT 565 + config AUDIT 632 566 bool "Auditing support" 633 567 depends on NET 634 568 help ··· 641 569 auditing without CONFIG_AUDITSYSCALL. 642 570 643 571 Seriously dangerous features (such as write support for certain 644 - filesystems) should advertise this prominently in their prompt string: 572 + filesystems) should advertise this prominently in their prompt string:: 645 573 646 - config ADFS_FS_RW 574 + config ADFS_FS_RW 647 575 bool "ADFS write support (DANGEROUS)" 648 576 depends on ADFS_FS 649 577 ... ··· 652 580 Documentation/kbuild/kconfig-language.txt. 653 581 654 582 655 - Chapter 11: Data structures 583 + 11) Data structures 584 + ------------------- 656 585 657 586 Data structures that have visibility outside the single-threaded 658 587 environment they are created and destroyed in should always have 659 588 reference counts. In the kernel, garbage collection doesn't exist (and 660 589 outside the kernel garbage collection is slow and inefficient), which 661 - means that you absolutely _have_ to reference count all your uses. 590 + means that you absolutely **have** to reference count all your uses. 662 591 663 592 Reference counting means that you can avoid locking, and allows multiple 664 593 users to have access to the data structure in parallel - and not having 665 594 to worry about the structure suddenly going away from under them just 666 595 because they slept or did something else for a while. 667 596 668 - Note that locking is _not_ a replacement for reference counting. 597 + Note that locking is **not** a replacement for reference counting. 669 598 Locking is used to keep data structures coherent, while reference 670 599 counting is a memory management technique. Usually both are needed, and 671 600 they are not to be confused with each other. 672 601 673 602 Many data structures can indeed have two levels of reference counting, 674 - when there are users of different "classes". The subclass count counts 603 + when there are users of different ``classes``. The subclass count counts 675 604 the number of subclass users, and decrements the global count just once 676 605 when the subclass count goes to zero. 677 606 678 - Examples of this kind of "multi-level-reference-counting" can be found in 679 - memory management ("struct mm_struct": mm_users and mm_count), and in 680 - filesystem code ("struct super_block": s_count and s_active). 607 + Examples of this kind of ``multi-level-reference-counting`` can be found in 608 + memory management (``struct mm_struct``: mm_users and mm_count), and in 609 + filesystem code (``struct super_block``: s_count and s_active). 681 610 682 611 Remember: if another thread can find your data structure, and you don't 683 612 have a reference count on it, you almost certainly have a bug. 684 613 685 614 686 - Chapter 12: Macros, Enums and RTL 615 + 12) Macros, Enums and RTL 616 + ------------------------- 687 617 688 618 Names of macros defining constants and labels in enums are capitalized. 619 + 620 + .. code-block:: c 689 621 690 622 #define CONSTANT 0x12345 691 623 ··· 702 626 703 627 Macros with multiple statements should be enclosed in a do - while block: 704 628 705 - #define macrofun(a, b, c) \ 629 + .. code-block:: c 630 + 631 + #define macrofun(a, b, c) \ 706 632 do { \ 707 633 if (a == 5) \ 708 634 do_this(b, c); \ ··· 714 636 715 637 1) macros that affect control flow: 716 638 639 + .. code-block:: c 640 + 717 641 #define FOO(x) \ 718 642 do { \ 719 643 if (blah(x) < 0) \ 720 644 return -EBUGGERED; \ 721 645 } while (0) 722 646 723 - is a _very_ bad idea. It looks like a function call but exits the "calling" 647 + is a **very** bad idea. It looks like a function call but exits the ``calling`` 724 648 function; don't break the internal parsers of those who will read the code. 725 649 726 650 2) macros that depend on having a local variable with a magic name: 651 + 652 + .. code-block:: c 727 653 728 654 #define FOO(val) bar(index, val) 729 655 ··· 741 659 must enclose the expression in parentheses. Beware of similar issues with 742 660 macros using parameters. 743 661 662 + .. code-block:: c 663 + 744 664 #define CONSTANT 0x4000 745 665 #define CONSTEXP (CONSTANT | 3) 746 666 747 667 5) namespace collisions when defining local variables in macros resembling 748 668 functions: 749 669 750 - #define FOO(x) \ 751 - ({ \ 752 - typeof(x) ret; \ 753 - ret = calc_ret(x); \ 754 - (ret); \ 755 - }) 670 + .. code-block:: c 671 + 672 + #define FOO(x) \ 673 + ({ \ 674 + typeof(x) ret; \ 675 + ret = calc_ret(x); \ 676 + (ret); \ 677 + }) 756 678 757 679 ret is a common name for a local variable - __foo_ret is less likely 758 680 to collide with an existing variable. ··· 765 679 covers RTL which is used frequently with assembly language in the kernel. 766 680 767 681 768 - Chapter 13: Printing kernel messages 682 + 13) Printing kernel messages 683 + ---------------------------- 769 684 770 685 Kernel developers like to be seen as literate. Do mind the spelling 771 686 of kernel messages to make a good impression. Do not use crippled 772 - words like "dont"; use "do not" or "don't" instead. Make the messages 687 + words like ``dont``; use ``do not`` or ``don't`` instead. Make the messages 773 688 concise, clear, and unambiguous. 774 689 775 690 Kernel messages do not have to be terminated with a period. ··· 800 713 used. 801 714 802 715 803 - Chapter 14: Allocating memory 716 + 14) Allocating memory 717 + --------------------- 804 718 805 719 The kernel provides the following general purpose memory allocators: 806 720 kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), and ··· 809 721 about them. 810 722 811 723 The preferred form for passing a size of a struct is the following: 724 + 725 + .. code-block:: c 812 726 813 727 p = kmalloc(sizeof(*p), ...); 814 728 ··· 824 734 825 735 The preferred form for allocating an array is the following: 826 736 737 + .. code-block:: c 738 + 827 739 p = kmalloc_array(n, sizeof(...), ...); 828 740 829 741 The preferred form for allocating a zeroed array is the following: 742 + 743 + .. code-block:: c 830 744 831 745 p = kcalloc(n, sizeof(...), ...); 832 746 ··· 838 744 and return NULL if that occurred. 839 745 840 746 841 - Chapter 15: The inline disease 747 + 15) The inline disease 748 + ---------------------- 842 749 843 750 There appears to be a common misperception that gcc has a magic "make me 844 - faster" speedup option called "inline". While the use of inlines can be 751 + faster" speedup option called ``inline``. While the use of inlines can be 845 752 appropriate (for example as a means of replacing macros, see Chapter 12), it 846 753 very often is not. Abundant use of the inline keyword leads to a much bigger 847 754 kernel, which in turn slows the system as a whole down, due to a bigger ··· 866 771 something it would have done anyway. 867 772 868 773 869 - Chapter 16: Function return values and names 774 + 16) Function return values and names 775 + ------------------------------------ 870 776 871 777 Functions can return values of many different kinds, and one of the 872 778 most common is a value indicating whether the function succeeded or 873 779 failed. Such a value can be represented as an error-code integer 874 - (-Exxx = failure, 0 = success) or a "succeeded" boolean (0 = failure, 780 + (-Exxx = failure, 0 = success) or a ``succeeded`` boolean (0 = failure, 875 781 non-zero = success). 876 782 877 783 Mixing up these two sorts of representations is a fertile source of 878 784 difficult-to-find bugs. If the C language included a strong distinction 879 785 between integers and booleans then the compiler would find these mistakes 880 786 for us... but it doesn't. To help prevent such bugs, always follow this 881 - convention: 787 + convention:: 882 788 883 789 If the name of a function is an action or an imperative command, 884 790 the function should return an error-code integer. If the name 885 791 is a predicate, the function should return a "succeeded" boolean. 886 792 887 - For example, "add work" is a command, and the add_work() function returns 0 888 - for success or -EBUSY for failure. In the same way, "PCI device present" is 793 + For example, ``add work`` is a command, and the add_work() function returns 0 794 + for success or -EBUSY for failure. In the same way, ``PCI device present`` is 889 795 a predicate, and the pci_dev_present() function returns 1 if it succeeds in 890 796 finding a matching device or 0 if it doesn't. 891 797 ··· 901 805 NULL or the ERR_PTR mechanism to report failure. 902 806 903 807 904 - Chapter 17: Don't re-invent the kernel macros 808 + 17) Don't re-invent the kernel macros 809 + ------------------------------------- 905 810 906 811 The header file include/linux/kernel.h contains a number of macros that 907 812 you should use, rather than explicitly coding some variant of them yourself. 908 813 For example, if you need to calculate the length of an array, take advantage 909 814 of the macro 910 815 816 + .. code-block:: c 817 + 911 818 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 912 819 913 820 Similarly, if you need to calculate the size of some structure member, use 821 + 822 + .. code-block:: c 914 823 915 824 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 916 825 ··· 924 823 defined that you shouldn't reproduce in your code. 925 824 926 825 927 - Chapter 18: Editor modelines and other cruft 826 + 18) Editor modelines and other cruft 827 + ------------------------------------ 928 828 929 829 Some editors can interpret configuration information embedded in source files, 930 830 indicated with special markers. For example, emacs interprets lines marked 931 831 like this: 932 832 833 + .. code-block:: c 834 + 933 835 -*- mode: c -*- 934 836 935 837 Or like this: 838 + 839 + .. code-block:: c 936 840 937 841 /* 938 842 Local Variables: ··· 946 840 */ 947 841 948 842 Vim interprets markers that look like this: 843 + 844 + .. code-block:: c 949 845 950 846 /* vim:set sw=8 noet */ 951 847 ··· 958 850 work correctly. 959 851 960 852 961 - Chapter 19: Inline assembly 853 + 19) Inline assembly 854 + ------------------- 962 855 963 856 In architecture-specific code, you may need to use inline assembly to interface 964 857 with CPU or platform functionality. Don't hesitate to do so when necessary. ··· 972 863 973 864 Large, non-trivial assembly functions should go in .S files, with corresponding 974 865 C prototypes defined in C header files. The C prototypes for assembly 975 - functions should use "asmlinkage". 866 + functions should use ``asmlinkage``. 976 867 977 868 You may need to mark your asm statement as volatile, to prevent GCC from 978 869 removing it if GCC doesn't notice any side effects. You don't always need to ··· 983 874 string, and end each string except the last with \n\t to properly indent the 984 875 next instruction in the assembly output: 985 876 877 + .. code-block:: c 878 + 986 879 asm ("magic %reg1, #42\n\t" 987 880 "more_magic %reg2, %reg3" 988 881 : /* outputs */ : /* inputs */ : /* clobbers */); 989 882 990 883 991 - Chapter 20: Conditional Compilation 884 + 20) Conditional Compilation 885 + --------------------------- 992 886 993 887 Wherever possible, don't use preprocessor conditionals (#if, #ifdef) in .c 994 888 files; doing so makes code harder to read and logic harder to follow. Instead, ··· 1015 903 Within code, where possible, use the IS_ENABLED macro to convert a Kconfig 1016 904 symbol into a C boolean expression, and use it in a normal C conditional: 1017 905 906 + .. code-block:: c 907 + 1018 908 if (IS_ENABLED(CONFIG_SOMETHING)) { 1019 909 ... 1020 910 } ··· 1032 918 place a comment after the #endif on the same line, noting the conditional 1033 919 expression used. For instance: 1034 920 921 + .. code-block:: c 922 + 1035 923 #ifdef CONFIG_SOMETHING 1036 924 ... 1037 925 #endif /* CONFIG_SOMETHING */ 1038 926 1039 927 1040 - Appendix I: References 928 + Appendix I) References 929 + ---------------------- 1041 930 1042 931 The C Programming Language, Second Edition 1043 932 by Brian W. Kernighan and Dennis M. Ritchie. ··· 1060 943 1061 944 Kernel CodingStyle, by greg@kroah.com at OLS 2002: 1062 945 http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ 1063 -
+3 -5
Documentation/DMA-API-HOWTO.txt
··· 699 699 dma_addr_t mapping; 700 700 701 701 mapping = dma_map_single(cp->dev, buffer, len, DMA_FROM_DEVICE); 702 - if (dma_mapping_error(cp->dev, dma_handle)) { 702 + if (dma_mapping_error(cp->dev, mapping)) { 703 703 /* 704 704 * reduce current DMA mapping usage, 705 705 * delay and try again later or ··· 931 931 932 932 1) Struct scatterlist requirements. 933 933 934 - Don't invent the architecture specific struct scatterlist; just use 935 - <asm-generic/scatterlist.h>. You need to enable 936 - CONFIG_NEED_SG_DMA_LENGTH if the architecture supports IOMMUs 937 - (including software IOMMU). 934 + You need to enable CONFIG_NEED_SG_DMA_LENGTH if the architecture 935 + supports IOMMUs (including software IOMMU). 938 936 939 937 2) ARCH_DMA_MINALIGN 940 938
+10 -2
Documentation/DocBook/Makefile
··· 6 6 # To add a new book the only step required is to add the book to the 7 7 # list of DOCBOOKS. 8 8 9 - DOCBOOKS := z8530book.xml device-drivers.xml \ 9 + DOCBOOKS := z8530book.xml \ 10 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 11 11 writing_usb_driver.xml networking.xml \ 12 12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \ ··· 22 22 # Skip DocBook build if the user explicitly requested no DOCBOOKS. 23 23 .DEFAULT: 24 24 @echo " SKIP DocBook $@ target (DOCBOOKS=\"\" specified)." 25 - 26 25 else 26 + ifneq ($(SPHINXDIRS),) 27 + 28 + # Skip DocBook build if the user explicitly requested a sphinx dir 29 + .DEFAULT: 30 + @echo " SKIP DocBook $@ target (SPHINXDIRS specified)." 31 + else 32 + 27 33 28 34 ### 29 35 # The build process is as follows (targets): ··· 72 66 73 67 # no-op for the DocBook toolchain 74 68 epubdocs: 69 + latexdocs: 75 70 76 71 ### 77 72 #External programs used ··· 228 221 echo "</programlisting>") > $@ 229 222 230 223 endif # DOCBOOKS="" 224 + endif # SPHINDIR=... 231 225 232 226 ### 233 227 # Help targets as used by the top-level makefile
-521
Documentation/DocBook/device-drivers.tmpl
··· 1 - <?xml version="1.0" encoding="UTF-8"?> 2 - <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 3 - "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> 4 - 5 - <book id="LinuxDriversAPI"> 6 - <bookinfo> 7 - <title>Linux Device Drivers</title> 8 - 9 - <legalnotice> 10 - <para> 11 - This documentation is free software; you can redistribute 12 - it and/or modify it under the terms of the GNU General Public 13 - License as published by the Free Software Foundation; either 14 - version 2 of the License, or (at your option) any later 15 - version. 16 - </para> 17 - 18 - <para> 19 - This program is distributed in the hope that it will be 20 - useful, but WITHOUT ANY WARRANTY; without even the implied 21 - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 - See the GNU General Public License for more details. 23 - </para> 24 - 25 - <para> 26 - You should have received a copy of the GNU General Public 27 - License along with this program; if not, write to the Free 28 - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 29 - MA 02111-1307 USA 30 - </para> 31 - 32 - <para> 33 - For more details see the file COPYING in the source 34 - distribution of Linux. 35 - </para> 36 - </legalnotice> 37 - </bookinfo> 38 - 39 - <toc></toc> 40 - 41 - <chapter id="Basics"> 42 - <title>Driver Basics</title> 43 - <sect1><title>Driver Entry and Exit points</title> 44 - !Iinclude/linux/init.h 45 - </sect1> 46 - 47 - <sect1><title>Atomic and pointer manipulation</title> 48 - !Iarch/x86/include/asm/atomic.h 49 - </sect1> 50 - 51 - <sect1><title>Delaying, scheduling, and timer routines</title> 52 - !Iinclude/linux/sched.h 53 - !Ekernel/sched/core.c 54 - !Ikernel/sched/cpupri.c 55 - !Ikernel/sched/fair.c 56 - !Iinclude/linux/completion.h 57 - !Ekernel/time/timer.c 58 - </sect1> 59 - <sect1><title>Wait queues and Wake events</title> 60 - !Iinclude/linux/wait.h 61 - !Ekernel/sched/wait.c 62 - </sect1> 63 - <sect1><title>High-resolution timers</title> 64 - !Iinclude/linux/ktime.h 65 - !Iinclude/linux/hrtimer.h 66 - !Ekernel/time/hrtimer.c 67 - </sect1> 68 - <sect1><title>Workqueues and Kevents</title> 69 - !Iinclude/linux/workqueue.h 70 - !Ekernel/workqueue.c 71 - </sect1> 72 - <sect1><title>Internal Functions</title> 73 - !Ikernel/exit.c 74 - !Ikernel/signal.c 75 - !Iinclude/linux/kthread.h 76 - !Ekernel/kthread.c 77 - </sect1> 78 - 79 - <sect1><title>Kernel objects manipulation</title> 80 - <!-- 81 - X!Iinclude/linux/kobject.h 82 - --> 83 - !Elib/kobject.c 84 - </sect1> 85 - 86 - <sect1><title>Kernel utility functions</title> 87 - !Iinclude/linux/kernel.h 88 - !Ekernel/printk/printk.c 89 - !Ekernel/panic.c 90 - !Ekernel/sys.c 91 - !Ekernel/rcu/srcu.c 92 - !Ekernel/rcu/tree.c 93 - !Ekernel/rcu/tree_plugin.h 94 - !Ekernel/rcu/update.c 95 - </sect1> 96 - 97 - <sect1><title>Device Resource Management</title> 98 - !Edrivers/base/devres.c 99 - </sect1> 100 - 101 - </chapter> 102 - 103 - <chapter id="devdrivers"> 104 - <title>Device drivers infrastructure</title> 105 - <sect1><title>The Basic Device Driver-Model Structures </title> 106 - !Iinclude/linux/device.h 107 - </sect1> 108 - <sect1><title>Device Drivers Base</title> 109 - !Idrivers/base/init.c 110 - !Edrivers/base/driver.c 111 - !Edrivers/base/core.c 112 - !Edrivers/base/syscore.c 113 - !Edrivers/base/class.c 114 - !Idrivers/base/node.c 115 - !Edrivers/base/firmware_class.c 116 - !Edrivers/base/transport_class.c 117 - <!-- Cannot be included, because 118 - attribute_container_add_class_device_adapter 119 - and attribute_container_classdev_to_container 120 - exceed allowed 44 characters maximum 121 - X!Edrivers/base/attribute_container.c 122 - --> 123 - !Edrivers/base/dd.c 124 - <!-- 125 - X!Edrivers/base/interface.c 126 - --> 127 - !Iinclude/linux/platform_device.h 128 - !Edrivers/base/platform.c 129 - !Edrivers/base/bus.c 130 - </sect1> 131 - <sect1> 132 - <title>Buffer Sharing and Synchronization</title> 133 - <para> 134 - The dma-buf subsystem provides the framework for sharing buffers 135 - for hardware (DMA) access across multiple device drivers and 136 - subsystems, and for synchronizing asynchronous hardware access. 137 - </para> 138 - <para> 139 - This is used, for example, by drm "prime" multi-GPU support, but 140 - is of course not limited to GPU use cases. 141 - </para> 142 - <para> 143 - The three main components of this are: (1) dma-buf, representing 144 - a sg_table and exposed to userspace as a file descriptor to allow 145 - passing between devices, (2) fence, which provides a mechanism 146 - to signal when one device as finished access, and (3) reservation, 147 - which manages the shared or exclusive fence(s) associated with 148 - the buffer. 149 - </para> 150 - <sect2><title>dma-buf</title> 151 - !Edrivers/dma-buf/dma-buf.c 152 - !Iinclude/linux/dma-buf.h 153 - </sect2> 154 - <sect2><title>reservation</title> 155 - !Pdrivers/dma-buf/reservation.c Reservation Object Overview 156 - !Edrivers/dma-buf/reservation.c 157 - !Iinclude/linux/reservation.h 158 - </sect2> 159 - <sect2><title>fence</title> 160 - !Edrivers/dma-buf/fence.c 161 - !Iinclude/linux/fence.h 162 - !Edrivers/dma-buf/seqno-fence.c 163 - !Iinclude/linux/seqno-fence.h 164 - !Edrivers/dma-buf/fence-array.c 165 - !Iinclude/linux/fence-array.h 166 - !Edrivers/dma-buf/reservation.c 167 - !Iinclude/linux/reservation.h 168 - !Edrivers/dma-buf/sync_file.c 169 - !Iinclude/linux/sync_file.h 170 - </sect2> 171 - </sect1> 172 - <sect1><title>Device Drivers DMA Management</title> 173 - !Edrivers/base/dma-coherent.c 174 - !Edrivers/base/dma-mapping.c 175 - </sect1> 176 - <sect1><title>Device Drivers Power Management</title> 177 - !Edrivers/base/power/main.c 178 - </sect1> 179 - <sect1><title>Device Drivers ACPI Support</title> 180 - <!-- Internal functions only 181 - X!Edrivers/acpi/sleep/main.c 182 - X!Edrivers/acpi/sleep/wakeup.c 183 - X!Edrivers/acpi/motherboard.c 184 - X!Edrivers/acpi/bus.c 185 - --> 186 - !Edrivers/acpi/scan.c 187 - !Idrivers/acpi/scan.c 188 - <!-- No correct structured comments 189 - X!Edrivers/acpi/pci_bind.c 190 - --> 191 - </sect1> 192 - <sect1><title>Device drivers PnP support</title> 193 - !Idrivers/pnp/core.c 194 - <!-- No correct structured comments 195 - X!Edrivers/pnp/system.c 196 - --> 197 - !Edrivers/pnp/card.c 198 - !Idrivers/pnp/driver.c 199 - !Edrivers/pnp/manager.c 200 - !Edrivers/pnp/support.c 201 - </sect1> 202 - <sect1><title>Userspace IO devices</title> 203 - !Edrivers/uio/uio.c 204 - !Iinclude/linux/uio_driver.h 205 - </sect1> 206 - </chapter> 207 - 208 - <chapter id="parportdev"> 209 - <title>Parallel Port Devices</title> 210 - !Iinclude/linux/parport.h 211 - !Edrivers/parport/ieee1284.c 212 - !Edrivers/parport/share.c 213 - !Idrivers/parport/daisy.c 214 - </chapter> 215 - 216 - <chapter id="message_devices"> 217 - <title>Message-based devices</title> 218 - <sect1><title>Fusion message devices</title> 219 - !Edrivers/message/fusion/mptbase.c 220 - !Idrivers/message/fusion/mptbase.c 221 - !Edrivers/message/fusion/mptscsih.c 222 - !Idrivers/message/fusion/mptscsih.c 223 - !Idrivers/message/fusion/mptctl.c 224 - !Idrivers/message/fusion/mptspi.c 225 - !Idrivers/message/fusion/mptfc.c 226 - !Idrivers/message/fusion/mptlan.c 227 - </sect1> 228 - </chapter> 229 - 230 - <chapter id="snddev"> 231 - <title>Sound Devices</title> 232 - !Iinclude/sound/core.h 233 - !Esound/sound_core.c 234 - !Iinclude/sound/pcm.h 235 - !Esound/core/pcm.c 236 - !Esound/core/device.c 237 - !Esound/core/info.c 238 - !Esound/core/rawmidi.c 239 - !Esound/core/sound.c 240 - !Esound/core/memory.c 241 - !Esound/core/pcm_memory.c 242 - !Esound/core/init.c 243 - !Esound/core/isadma.c 244 - !Esound/core/control.c 245 - !Esound/core/pcm_lib.c 246 - !Esound/core/hwdep.c 247 - !Esound/core/pcm_native.c 248 - !Esound/core/memalloc.c 249 - <!-- FIXME: Removed for now since no structured comments in source 250 - X!Isound/sound_firmware.c 251 - --> 252 - </chapter> 253 - 254 - 255 - <chapter id="uart16x50"> 256 - <title>16x50 UART Driver</title> 257 - !Edrivers/tty/serial/serial_core.c 258 - !Edrivers/tty/serial/8250/8250_core.c 259 - </chapter> 260 - 261 - <chapter id="fbdev"> 262 - <title>Frame Buffer Library</title> 263 - 264 - <para> 265 - The frame buffer drivers depend heavily on four data structures. 266 - These structures are declared in include/linux/fb.h. They are 267 - fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs. 268 - The last three can be made available to and from userland. 269 - </para> 270 - 271 - <para> 272 - fb_info defines the current state of a particular video card. 273 - Inside fb_info, there exists a fb_ops structure which is a 274 - collection of needed functions to make fbdev and fbcon work. 275 - fb_info is only visible to the kernel. 276 - </para> 277 - 278 - <para> 279 - fb_var_screeninfo is used to describe the features of a video card 280 - that are user defined. With fb_var_screeninfo, things such as 281 - depth and the resolution may be defined. 282 - </para> 283 - 284 - <para> 285 - The next structure is fb_fix_screeninfo. This defines the 286 - properties of a card that are created when a mode is set and can't 287 - be changed otherwise. A good example of this is the start of the 288 - frame buffer memory. This "locks" the address of the frame buffer 289 - memory, so that it cannot be changed or moved. 290 - </para> 291 - 292 - <para> 293 - The last structure is fb_monospecs. In the old API, there was 294 - little importance for fb_monospecs. This allowed for forbidden things 295 - such as setting a mode of 800x600 on a fix frequency monitor. With 296 - the new API, fb_monospecs prevents such things, and if used 297 - correctly, can prevent a monitor from being cooked. fb_monospecs 298 - will not be useful until kernels 2.5.x. 299 - </para> 300 - 301 - <sect1><title>Frame Buffer Memory</title> 302 - !Edrivers/video/fbdev/core/fbmem.c 303 - </sect1> 304 - <!-- 305 - <sect1><title>Frame Buffer Console</title> 306 - X!Edrivers/video/console/fbcon.c 307 - </sect1> 308 - --> 309 - <sect1><title>Frame Buffer Colormap</title> 310 - !Edrivers/video/fbdev/core/fbcmap.c 311 - </sect1> 312 - <!-- FIXME: 313 - drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment 314 - out until somebody adds docs. KAO 315 - <sect1><title>Frame Buffer Generic Functions</title> 316 - X!Idrivers/video/fbgen.c 317 - </sect1> 318 - KAO --> 319 - <sect1><title>Frame Buffer Video Mode Database</title> 320 - !Idrivers/video/fbdev/core/modedb.c 321 - !Edrivers/video/fbdev/core/modedb.c 322 - </sect1> 323 - <sect1><title>Frame Buffer Macintosh Video Mode Database</title> 324 - !Edrivers/video/fbdev/macmodes.c 325 - </sect1> 326 - <sect1><title>Frame Buffer Fonts</title> 327 - <para> 328 - Refer to the file lib/fonts/fonts.c for more information. 329 - </para> 330 - <!-- FIXME: Removed for now since no structured comments in source 331 - X!Ilib/fonts/fonts.c 332 - --> 333 - </sect1> 334 - </chapter> 335 - 336 - <chapter id="input_subsystem"> 337 - <title>Input Subsystem</title> 338 - <sect1><title>Input core</title> 339 - !Iinclude/linux/input.h 340 - !Edrivers/input/input.c 341 - !Edrivers/input/ff-core.c 342 - !Edrivers/input/ff-memless.c 343 - </sect1> 344 - <sect1><title>Multitouch Library</title> 345 - !Iinclude/linux/input/mt.h 346 - !Edrivers/input/input-mt.c 347 - </sect1> 348 - <sect1><title>Polled input devices</title> 349 - !Iinclude/linux/input-polldev.h 350 - !Edrivers/input/input-polldev.c 351 - </sect1> 352 - <sect1><title>Matrix keyboards/keypads</title> 353 - !Iinclude/linux/input/matrix_keypad.h 354 - </sect1> 355 - <sect1><title>Sparse keymap support</title> 356 - !Iinclude/linux/input/sparse-keymap.h 357 - !Edrivers/input/sparse-keymap.c 358 - </sect1> 359 - </chapter> 360 - 361 - <chapter id="spi"> 362 - <title>Serial Peripheral Interface (SPI)</title> 363 - <para> 364 - SPI is the "Serial Peripheral Interface", widely used with 365 - embedded systems because it is a simple and efficient 366 - interface: basically a multiplexed shift register. 367 - Its three signal wires hold a clock (SCK, often in the range 368 - of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and 369 - a "Master In, Slave Out" (MISO) data line. 370 - SPI is a full duplex protocol; for each bit shifted out the 371 - MOSI line (one per clock) another is shifted in on the MISO line. 372 - Those bits are assembled into words of various sizes on the 373 - way to and from system memory. 374 - An additional chipselect line is usually active-low (nCS); 375 - four signals are normally used for each peripheral, plus 376 - sometimes an interrupt. 377 - </para> 378 - <para> 379 - The SPI bus facilities listed here provide a generalized 380 - interface to declare SPI busses and devices, manage them 381 - according to the standard Linux driver model, and perform 382 - input/output operations. 383 - At this time, only "master" side interfaces are supported, 384 - where Linux talks to SPI peripherals and does not implement 385 - such a peripheral itself. 386 - (Interfaces to support implementing SPI slaves would 387 - necessarily look different.) 388 - </para> 389 - <para> 390 - The programming interface is structured around two kinds of driver, 391 - and two kinds of device. 392 - A "Controller Driver" abstracts the controller hardware, which may 393 - be as simple as a set of GPIO pins or as complex as a pair of FIFOs 394 - connected to dual DMA engines on the other side of the SPI shift 395 - register (maximizing throughput). Such drivers bridge between 396 - whatever bus they sit on (often the platform bus) and SPI, and 397 - expose the SPI side of their device as a 398 - <structname>struct spi_master</structname>. 399 - SPI devices are children of that master, represented as a 400 - <structname>struct spi_device</structname> and manufactured from 401 - <structname>struct spi_board_info</structname> descriptors which 402 - are usually provided by board-specific initialization code. 403 - A <structname>struct spi_driver</structname> is called a 404 - "Protocol Driver", and is bound to a spi_device using normal 405 - driver model calls. 406 - </para> 407 - <para> 408 - The I/O model is a set of queued messages. Protocol drivers 409 - submit one or more <structname>struct spi_message</structname> 410 - objects, which are processed and completed asynchronously. 411 - (There are synchronous wrappers, however.) Messages are 412 - built from one or more <structname>struct spi_transfer</structname> 413 - objects, each of which wraps a full duplex SPI transfer. 414 - A variety of protocol tweaking options are needed, because 415 - different chips adopt very different policies for how they 416 - use the bits transferred with SPI. 417 - </para> 418 - !Iinclude/linux/spi/spi.h 419 - !Fdrivers/spi/spi.c spi_register_board_info 420 - !Edrivers/spi/spi.c 421 - </chapter> 422 - 423 - <chapter id="i2c"> 424 - <title>I<superscript>2</superscript>C and SMBus Subsystem</title> 425 - 426 - <para> 427 - I<superscript>2</superscript>C (or without fancy typography, "I2C") 428 - is an acronym for the "Inter-IC" bus, a simple bus protocol which is 429 - widely used where low data rate communications suffice. 430 - Since it's also a licensed trademark, some vendors use another 431 - name (such as "Two-Wire Interface", TWI) for the same bus. 432 - I2C only needs two signals (SCL for clock, SDA for data), conserving 433 - board real estate and minimizing signal quality issues. 434 - Most I2C devices use seven bit addresses, and bus speeds of up 435 - to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet 436 - found wide use. 437 - I2C is a multi-master bus; open drain signaling is used to 438 - arbitrate between masters, as well as to handshake and to 439 - synchronize clocks from slower clients. 440 - </para> 441 - 442 - <para> 443 - The Linux I2C programming interfaces support only the master 444 - side of bus interactions, not the slave side. 445 - The programming interface is structured around two kinds of driver, 446 - and two kinds of device. 447 - An I2C "Adapter Driver" abstracts the controller hardware; it binds 448 - to a physical device (perhaps a PCI device or platform_device) and 449 - exposes a <structname>struct i2c_adapter</structname> representing 450 - each I2C bus segment it manages. 451 - On each I2C bus segment will be I2C devices represented by a 452 - <structname>struct i2c_client</structname>. Those devices will 453 - be bound to a <structname>struct i2c_driver</structname>, 454 - which should follow the standard Linux driver model. 455 - (At this writing, a legacy model is more widely used.) 456 - There are functions to perform various I2C protocol operations; at 457 - this writing all such functions are usable only from task context. 458 - </para> 459 - 460 - <para> 461 - The System Management Bus (SMBus) is a sibling protocol. Most SMBus 462 - systems are also I2C conformant. The electrical constraints are 463 - tighter for SMBus, and it standardizes particular protocol messages 464 - and idioms. Controllers that support I2C can also support most 465 - SMBus operations, but SMBus controllers don't support all the protocol 466 - options that an I2C controller will. 467 - There are functions to perform various SMBus protocol operations, 468 - either using I2C primitives or by issuing SMBus commands to 469 - i2c_adapter devices which don't support those I2C operations. 470 - </para> 471 - 472 - !Iinclude/linux/i2c.h 473 - !Fdrivers/i2c/i2c-boardinfo.c i2c_register_board_info 474 - !Edrivers/i2c/i2c-core.c 475 - </chapter> 476 - 477 - <chapter id="hsi"> 478 - <title>High Speed Synchronous Serial Interface (HSI)</title> 479 - 480 - <para> 481 - High Speed Synchronous Serial Interface (HSI) is a 482 - serial interface mainly used for connecting application 483 - engines (APE) with cellular modem engines (CMT) in cellular 484 - handsets. 485 - 486 - HSI provides multiplexing for up to 16 logical channels, 487 - low-latency and full duplex communication. 488 - </para> 489 - 490 - !Iinclude/linux/hsi/hsi.h 491 - !Edrivers/hsi/hsi_core.c 492 - </chapter> 493 - 494 - <chapter id="pwm"> 495 - <title>Pulse-Width Modulation (PWM)</title> 496 - <para> 497 - Pulse-width modulation is a modulation technique primarily used to 498 - control power supplied to electrical devices. 499 - </para> 500 - <para> 501 - The PWM framework provides an abstraction for providers and consumers 502 - of PWM signals. A controller that provides one or more PWM signals is 503 - registered as <structname>struct pwm_chip</structname>. Providers are 504 - expected to embed this structure in a driver-specific structure. This 505 - structure contains fields that describe a particular chip. 506 - </para> 507 - <para> 508 - A chip exposes one or more PWM signal sources, each of which exposed 509 - as a <structname>struct pwm_device</structname>. Operations can be 510 - performed on PWM devices to control the period, duty cycle, polarity 511 - and active state of the signal. 512 - </para> 513 - <para> 514 - Note that PWM devices are exclusive resources: they can always only be 515 - used by one consumer at a time. 516 - </para> 517 - !Iinclude/linux/pwm.h 518 - !Edrivers/pwm/core.c 519 - </chapter> 520 - 521 - </book>
+98 -50
Documentation/HOWTO
··· 1 1 HOWTO do Linux kernel development 2 - --------------------------------- 2 + ================================= 3 3 4 4 This is the be-all, end-all document on this topic. It contains 5 5 instructions on how to become a Linux kernel developer and how to learn ··· 28 28 you plan to do low-level development for that architecture. Though they 29 29 are not a good substitute for a solid C education and/or years of 30 30 experience, the following books are good for, if anything, reference: 31 + 31 32 - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall] 32 33 - "Practical C Programming" by Steve Oualline [O'Reilly] 33 34 - "C: A Reference Manual" by Harbison and Steele [Prentice Hall] ··· 65 64 their statements on legal matters. 66 65 67 66 For common questions and answers about the GPL, please see: 68 - http://www.gnu.org/licenses/gpl-faq.html 67 + 68 + https://www.gnu.org/licenses/gpl-faq.html 69 69 70 70 71 71 Documentation ··· 84 82 85 83 Here is a list of files that are in the kernel source tree that are 86 84 required reading: 85 + 87 86 README 88 87 This file gives a short background on the Linux kernel and describes 89 88 what is necessary to do to configure and build the kernel. People 90 89 who are new to the kernel should start here. 91 90 92 - Documentation/Changes 91 + :ref:`Documentation/Changes <changes>` 93 92 This file gives a list of the minimum levels of various software 94 93 packages that are necessary to build and run the kernel 95 94 successfully. 96 95 97 - Documentation/CodingStyle 96 + :ref:`Documentation/CodingStyle <codingstyle>` 98 97 This describes the Linux kernel coding style, and some of the 99 98 rationale behind it. All new code is expected to follow the 100 99 guidelines in this document. Most maintainers will only accept 101 100 patches if these rules are followed, and many people will only 102 101 review code if it is in the proper style. 103 102 104 - Documentation/SubmittingPatches 105 - Documentation/SubmittingDrivers 103 + :ref:`Documentation/SubmittingPatches <submittingpatches>` and :ref:`Documentation/SubmittingDrivers <submittingdrivers>` 106 104 These files describe in explicit detail how to successfully create 107 105 and send a patch, including (but not limited to): 106 + 108 107 - Email contents 109 108 - Email format 110 109 - Who to send it to 110 + 111 111 Following these rules will not guarantee success (as all patches are 112 112 subject to scrutiny for content and style), but not following them 113 113 will almost always prevent it. 114 114 115 115 Other excellent descriptions of how to create patches properly are: 116 + 116 117 "The Perfect Patch" 117 - http://www.ozlabs.org/~akpm/stuff/tpp.txt 118 + https://www.ozlabs.org/~akpm/stuff/tpp.txt 119 + 118 120 "Linux kernel patch submission format" 119 121 http://linux.yyz.us/patch-format.html 120 122 121 - Documentation/stable_api_nonsense.txt 123 + :ref:`Documentation/stable_api_nonsense.txt <stable_api_nonsense>` 122 124 This file describes the rationale behind the conscious decision to 123 125 not have a stable API within the kernel, including things like: 126 + 124 127 - Subsystem shim-layers (for compatibility?) 125 128 - Driver portability between Operating Systems. 126 129 - Mitigating rapid change within the kernel source tree (or 127 130 preventing rapid change) 131 + 128 132 This document is crucial for understanding the Linux development 129 133 philosophy and is very important for people moving to Linux from 130 134 development on other Operating Systems. 131 135 132 - Documentation/SecurityBugs 136 + :ref:`Documentation/SecurityBugs <securitybugs>` 133 137 If you feel you have found a security problem in the Linux kernel, 134 138 please follow the steps in this document to help notify the kernel 135 139 developers, and help solve the issue. 136 140 137 - Documentation/ManagementStyle 141 + :ref:`Documentation/ManagementStyle <managementstyle>` 138 142 This document describes how Linux kernel maintainers operate and the 139 143 shared ethos behind their methodologies. This is important reading 140 144 for anyone new to kernel development (or anyone simply curious about 141 145 it), as it resolves a lot of common misconceptions and confusion 142 146 about the unique behavior of kernel maintainers. 143 147 144 - Documentation/stable_kernel_rules.txt 148 + :ref:`Documentation/stable_kernel_rules.txt <stable_kernel_rules>` 145 149 This file describes the rules on how the stable kernel releases 146 150 happen, and what to do if you want to get a change into one of these 147 151 releases. 148 152 149 - Documentation/kernel-docs.txt 153 + :ref:`Documentation/kernel-docs.txt <kernel_docs>` 150 154 A list of external documentation that pertains to kernel 151 155 development. Please consult this list if you do not find what you 152 156 are looking for within the in-kernel documentation. 153 157 154 - Documentation/applying-patches.txt 158 + :ref:`Documentation/applying-patches.txt <applying_patches>` 155 159 A good introduction describing exactly what a patch is and how to 156 160 apply it to the different development branches of the kernel. 157 161 158 162 The kernel also has a large number of documents that can be 159 - automatically generated from the source code itself. This includes a 163 + automatically generated from the source code itself or from 164 + ReStructuredText markups (ReST), like this one. This includes a 160 165 full description of the in-kernel API, and rules on how to handle 161 - locking properly. The documents will be created in the 162 - Documentation/DocBook/ directory and can be generated as PDF, 163 - Postscript, HTML, and man pages by running: 166 + locking properly. 167 + 168 + All such documents can be generated as PDF or HTML by running:: 169 + 164 170 make pdfdocs 165 - make psdocs 166 171 make htmldocs 167 - make mandocs 172 + 168 173 respectively from the main kernel source directory. 169 174 175 + The documents that uses ReST markup will be generated at Documentation/output. 176 + They can also be generated on LaTeX and ePub formats with:: 177 + 178 + make latexdocs 179 + make epubdocs 180 + 181 + Currently, there are some documents written on DocBook that are in 182 + the process of conversion to ReST. Such documents will be created in the 183 + Documentation/DocBook/ directory and can be generated also as 184 + Postscript or man pages by running:: 185 + 186 + make psdocs 187 + make mandocs 170 188 171 189 Becoming A Kernel Developer 172 190 --------------------------- 173 191 174 192 If you do not know anything about Linux kernel development, you should 175 193 look at the Linux KernelNewbies project: 176 - http://kernelnewbies.org 194 + 195 + https://kernelnewbies.org 196 + 177 197 It consists of a helpful mailing list where you can ask almost any type 178 198 of basic kernel development question (make sure to search the archives 179 199 first, before asking something that has already been answered in the ··· 211 187 If you do not know where you want to start, but you want to look for 212 188 some task to start doing to join into the kernel development community, 213 189 go to the Linux Kernel Janitor's project: 214 - http://kernelnewbies.org/KernelJanitors 190 + 191 + https://kernelnewbies.org/KernelJanitors 192 + 215 193 It is a great place to start. It describes a list of relatively simple 216 194 problems that need to be cleaned up and fixed within the Linux kernel 217 195 source tree. Working with the developers in charge of this project, you ··· 225 199 tree, but need some help getting it in the proper form, the 226 200 kernel-mentors project was created to help you out with this. It is a 227 201 mailing list, and can be found at: 228 - http://selenic.com/mailman/listinfo/kernel-mentors 202 + 203 + https://selenic.com/mailman/listinfo/kernel-mentors 229 204 230 205 Before making any actual modifications to the Linux kernel code, it is 231 206 imperative to understand how the code in question works. For this ··· 236 209 Cross-Reference project, which is able to present source code in a 237 210 self-referential, indexed webpage format. An excellent up-to-date 238 211 repository of the kernel code may be found at: 212 + 239 213 http://lxr.free-electrons.com/ 240 214 241 215 ··· 246 218 Linux kernel development process currently consists of a few different 247 219 main kernel "branches" and lots of different subsystem-specific kernel 248 220 branches. These different branches are: 221 + 249 222 - main 4.x kernel tree 250 223 - 4.x.y -stable kernel tree 251 224 - 4.x -git kernel patches ··· 256 227 4.x kernel tree 257 228 ----------------- 258 229 4.x kernels are maintained by Linus Torvalds, and can be found on 259 - kernel.org in the pub/linux/kernel/v4.x/ directory. Its development 230 + https://kernel.org in the pub/linux/kernel/v4.x/ directory. Its development 260 231 process is as follows: 232 + 261 233 - As soon as a new kernel is released a two weeks window is open, 262 234 during this period of time maintainers can submit big diffs to 263 235 Linus, usually the patches that have already been included in the 264 236 -next kernel for a few weeks. The preferred way to submit big changes 265 237 is using git (the kernel's source management tool, more information 266 - can be found at http://git-scm.com/) but plain patches are also just 238 + can be found at https://git-scm.com/) but plain patches are also just 267 239 fine. 268 240 - After two weeks a -rc1 kernel is released it is now possible to push 269 241 only patches that do not include new features that could affect the ··· 283 253 284 254 It is worth mentioning what Andrew Morton wrote on the linux-kernel 285 255 mailing list about kernel releases: 286 - "Nobody knows when a kernel will be released, because it's 256 + 257 + *"Nobody knows when a kernel will be released, because it's 287 258 released according to perceived bug status, not according to a 288 - preconceived timeline." 259 + preconceived timeline."* 289 260 290 261 4.x.y -stable kernel tree 291 262 ------------------------- ··· 332 301 Most of these repositories are git trees, but there are also other SCMs 333 302 in use, or patch queues being published as quilt series. Addresses of 334 303 these subsystem repositories are listed in the MAINTAINERS file. Many 335 - of them can be browsed at http://git.kernel.org/. 304 + of them can be browsed at https://git.kernel.org/. 336 305 337 306 Before a proposed patch is committed to such a subsystem tree, it is 338 307 subject to review which primarily happens on mailing lists (see the ··· 341 310 interface which shows patch postings, any comments on a patch or 342 311 revisions to it, and maintainers can mark patches as under review, 343 312 accepted, or rejected. Most of these patchwork sites are listed at 344 - http://patchwork.kernel.org/. 313 + https://patchwork.kernel.org/. 345 314 346 315 4.x -next kernel tree for integration tests 347 316 ------------------------------------------- ··· 349 318 tree, they need to be integration-tested. For this purpose, a special 350 319 testing repository exists into which virtually all subsystem trees are 351 320 pulled on an almost daily basis: 352 - http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git 321 + 322 + https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git 353 323 354 324 This way, the -next kernel gives a summary outlook onto what will be 355 325 expected to go into the mainline kernel at the next merge period. ··· 360 328 Bug Reporting 361 329 ------------- 362 330 363 - bugzilla.kernel.org is where the Linux kernel developers track kernel 331 + https://bugzilla.kernel.org is where the Linux kernel developers track kernel 364 332 bugs. Users are encouraged to report all bugs that they find in this 365 333 tool. For details on how to use the kernel bugzilla, please see: 366 - http://bugzilla.kernel.org/page.cgi?id=faq.html 334 + 335 + https://bugzilla.kernel.org/page.cgi?id=faq.html 367 336 368 337 The file REPORTING-BUGS in the main kernel source directory has a good 369 338 template for how to report a possible kernel bug, and details what kind ··· 382 349 bugs is one of the best ways to get merits among other developers, because 383 350 not many people like wasting time fixing other people's bugs. 384 351 385 - To work in the already reported bug reports, go to http://bugzilla.kernel.org. 352 + To work in the already reported bug reports, go to https://bugzilla.kernel.org. 386 353 If you want to be advised of the future bug reports, you can subscribe to the 387 354 bugme-new mailing list (only new bug reports are mailed here) or to the 388 355 bugme-janitor mailing list (every change in the bugzilla is mailed here) 389 356 390 - http://lists.linux-foundation.org/mailman/listinfo/bugme-new 391 - http://lists.linux-foundation.org/mailman/listinfo/bugme-janitors 357 + https://lists.linux-foundation.org/mailman/listinfo/bugme-new 358 + 359 + https://lists.linux-foundation.org/mailman/listinfo/bugme-janitors 392 360 393 361 394 362 ··· 399 365 As some of the above documents describe, the majority of the core kernel 400 366 developers participate on the Linux Kernel Mailing list. Details on how 401 367 to subscribe and unsubscribe from the list can be found at: 368 + 402 369 http://vger.kernel.org/vger-lists.html#linux-kernel 370 + 403 371 There are archives of the mailing list on the web in many different 404 372 places. Use a search engine to find these archives. For example: 373 + 405 374 http://dir.gmane.org/gmane.linux.kernel 375 + 406 376 It is highly recommended that you search the archives about the topic 407 377 you want to bring up, before you post it to the list. A lot of things 408 378 already discussed in detail are only recorded at the mailing list ··· 419 381 420 382 Many of the lists are hosted on kernel.org. Information on them can be 421 383 found at: 384 + 422 385 http://vger.kernel.org/vger-lists.html 423 386 424 387 Please remember to follow good behavioral habits when using the lists. 425 388 Though a bit cheesy, the following URL has some simple guidelines for 426 389 interacting with the list (or any list): 390 + 427 391 http://www.albion.com/netiquette/ 428 392 429 393 If multiple people respond to your mail, the CC: list of recipients may ··· 440 400 writing at the top of the mail. 441 401 442 402 If you add patches to your mail, make sure they are plain readable text 443 - as stated in Documentation/SubmittingPatches. Kernel developers don't 444 - want to deal with attachments or compressed patches; they may want 445 - to comment on individual lines of your patch, which works only that way. 446 - Make sure you use a mail program that does not mangle spaces and tab 447 - characters. A good first test is to send the mail to yourself and try 448 - to apply your own patch by yourself. If that doesn't work, get your 449 - mail program fixed or change it until it works. 403 + as stated in Documentation/SubmittingPatches. 404 + Kernel developers don't want to deal with 405 + attachments or compressed patches; they may want to comment on 406 + individual lines of your patch, which works only that way. Make sure you 407 + use a mail program that does not mangle spaces and tab characters. A 408 + good first test is to send the mail to yourself and try to apply your 409 + own patch by yourself. If that doesn't work, get your mail program fixed 410 + or change it until it works. 450 411 451 412 Above all, please remember to show respect to other subscribers. 452 413 ··· 459 418 there is. When you submit a patch for acceptance, it will be reviewed 460 419 on its technical merits and those alone. So, what should you be 461 420 expecting? 421 + 462 422 - criticism 463 423 - comments 464 424 - requests for change ··· 474 432 again, sometimes things get lost in the huge volume. 475 433 476 434 What should you not do? 435 + 477 436 - expect your patch to be accepted without question 478 437 - become defensive 479 438 - ignore comments ··· 488 445 toward a solution that is right. 489 446 490 447 It is normal that the answers to your first patch might simply be a list 491 - of a dozen things you should correct. This does _not_ imply that your 492 - patch will not be accepted, and it is _not_ meant against you 448 + of a dozen things you should correct. This does **not** imply that your 449 + patch will not be accepted, and it is **not** meant against you 493 450 personally. Simply correct all issues raised against your patch and 494 451 resend it. 495 452 ··· 500 457 The kernel community works differently than most traditional corporate 501 458 development environments. Here are a list of things that you can try to 502 459 do to avoid problems: 460 + 503 461 Good things to say regarding your proposed changes: 462 + 504 463 - "This solves multiple problems." 505 464 - "This deletes 2000 lines of code." 506 465 - "Here is a patch that explains what I am trying to describe." ··· 511 466 - "This increases performance on typical machines..." 512 467 513 468 Bad things you should avoid saying: 469 + 514 470 - "We did it this way in AIX/ptx/Solaris, so therefore it must be 515 471 good..." 516 472 - "I've being doing this for 20 years, so..." ··· 573 527 and simplify (or simply re-order) patches before submitting them. 574 528 575 529 Here is an analogy from kernel developer Al Viro: 576 - "Think of a teacher grading homework from a math student. The 530 + 531 + *"Think of a teacher grading homework from a math student. The 577 532 teacher does not want to see the student's trials and errors 578 533 before they came up with the solution. They want to see the 579 534 cleanest, most elegant answer. A good student knows this, and 580 535 would never submit her intermediate work before the final 581 - solution." 536 + solution.* 582 537 583 - The same is true of kernel development. The maintainers and 538 + *The same is true of kernel development. The maintainers and 584 539 reviewers do not want to see the thought process behind the 585 540 solution to the problem one is solving. They want to see a 586 - simple and elegant solution." 541 + simple and elegant solution."* 587 542 588 543 It may be challenging to keep the balance between presenting an elegant 589 544 solution and working together with the community and discussing your ··· 612 565 the text in your email. This information will become the ChangeLog 613 566 information for the patch, and will be preserved for everyone to see for 614 567 all time. It should describe the patch completely, containing: 568 + 615 569 - why the change is necessary 616 570 - the overall design approach in the patch 617 571 - implementation details ··· 620 572 621 573 For more details on what this should all look like, please see the 622 574 ChangeLog section of the document: 575 + 623 576 "The Perfect Patch" 624 577 http://www.ozlabs.org/~akpm/stuff/tpp.txt 625 - 626 - 627 578 628 579 629 580 All of these things are sometimes very hard to do. It can take years to ··· 635 588 636 589 637 590 ---------- 591 + 638 592 Thanks to Paolo Ciarrocchi who allowed the "Development Process" 639 - (http://lwn.net/Articles/94386/) section 593 + (https://lwn.net/Articles/94386/) section 640 594 to be based on text he had written, and to Randy Dunlap and Gerrit 641 595 Huizenga for some of the list of things you should and should not say. 642 596 Also thanks to Pat Mochel, Hanna Linder, Randy Dunlap, Kay Sievers,
+49 -15
Documentation/Makefile.sphinx
··· 5 5 # You can set these variables from the command line. 6 6 SPHINXBUILD = sphinx-build 7 7 SPHINXOPTS = 8 + SPHINXDIRS = . 9 + _SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py)) 10 + SPHINX_CONF = conf.py 8 11 PAPER = 9 12 BUILDDIR = $(obj)/output 10 13 ··· 28 25 29 26 else # HAVE_SPHINX 30 27 31 - # User-friendly check for rst2pdf 32 - HAVE_RST2PDF := $(shell if python -c "import rst2pdf" >/dev/null 2>&1; then echo 1; else echo 0; fi) 28 + # User-friendly check for pdflatex 29 + HAVE_PDFLATEX := $(shell if which xelatex >/dev/null 2>&1; then echo 1; else echo 0; fi) 33 30 34 31 # Internal variables. 35 32 PAPEROPT_a4 = -D latex_paper_size=a4 36 33 PAPEROPT_letter = -D latex_paper_size=letter 37 34 KERNELDOC = $(srctree)/scripts/kernel-doc 38 35 KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC) 39 - ALLSPHINXOPTS = -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) -d $(BUILDDIR)/.doctrees $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) -c $(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src) 36 + ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) 40 37 # the i18n builder cannot share the environment and doctrees with the others 41 38 I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 42 39 43 - quiet_cmd_sphinx = SPHINX $@ 44 - cmd_sphinx = BUILDDIR=$(BUILDDIR) $(SPHINXBUILD) -b $2 $(ALLSPHINXOPTS) $(BUILDDIR)/$2 40 + # commands; the 'cmd' from scripts/Kbuild.include is not *loopable* 41 + loop_cmd = $(echo-cmd) $(cmd_$(1)) 42 + 43 + # $2 sphinx builder e.g. "html" 44 + # $3 name of the build subfolder / e.g. "media", used as: 45 + # * dest folder relative to $(BUILDDIR) and 46 + # * cache folder relative to $(BUILDDIR)/.doctrees 47 + # $4 dest subfolder e.g. "man" for man pages at media/man 48 + # $5 reST source folder relative to $(srctree)/$(src), 49 + # e.g. "media" for the linux-tv book-set at ./Documentation/media 50 + 51 + quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4); 52 + cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media all;\ 53 + BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \ 54 + $(SPHINXBUILD) \ 55 + -b $2 \ 56 + -c $(abspath $(srctree)/$(src)) \ 57 + -d $(abspath $(BUILDDIR)/.doctrees/$3) \ 58 + -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \ 59 + $(ALLSPHINXOPTS) \ 60 + $(abspath $(srctree)/$(src)/$5) \ 61 + $(abspath $(BUILDDIR)/$3/$4); 45 62 46 63 htmldocs: 47 - $(MAKE) BUILDDIR=$(BUILDDIR) -f $(srctree)/Documentation/media/Makefile $@ 48 - $(call cmd,sphinx,html) 64 + @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) 49 65 50 - pdfdocs: 51 - ifeq ($(HAVE_RST2PDF),0) 52 - $(warning The Python 'rst2pdf' module was not found. Make sure you have the module installed to produce PDF output.) 66 + latexdocs: 67 + ifeq ($(HAVE_PDFLATEX),0) 68 + $(warning The 'xelatex' command was not found. Make sure you have it installed and in PATH to produce PDF output.) 53 69 @echo " SKIP Sphinx $@ target." 54 - else # HAVE_RST2PDF 55 - $(call cmd,sphinx,pdf) 56 - endif # HAVE_RST2PDF 70 + else # HAVE_PDFLATEX 71 + @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var))) 72 + endif # HAVE_PDFLATEX 73 + 74 + pdfdocs: latexdocs 75 + ifneq ($(HAVE_PDFLATEX),0) 76 + $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex) 77 + endif # HAVE_PDFLATEX 57 78 58 79 epubdocs: 59 - $(call cmd,sphinx,epub) 80 + @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var))) 60 81 61 82 xmldocs: 62 - $(call cmd,sphinx,xml) 83 + @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var))) 63 84 64 85 # no-ops for the Sphinx toolchain 65 86 sgmldocs: ··· 99 72 dochelp: 100 73 @echo ' Linux kernel internal documentation in different formats (Sphinx):' 101 74 @echo ' htmldocs - HTML' 75 + @echo ' latexdocs - LaTeX' 102 76 @echo ' pdfdocs - PDF' 103 77 @echo ' epubdocs - EPUB' 104 78 @echo ' xmldocs - XML' 105 79 @echo ' cleandocs - clean all generated files' 80 + @echo 81 + @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2' 82 + @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)' 83 + @echo 84 + @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build' 85 + @echo ' configuration. This is e.g. useful to build with nit-picking config.'
+83 -71
Documentation/ManagementStyle
··· 1 + .. _managementstyle: 1 2 2 - Linux kernel management style 3 + Linux kernel management style 4 + ============================= 3 5 4 6 This is a short document describing the preferred (or made up, depending 5 7 on who you ask) management style for the linux kernel. It's meant to 6 8 mirror the CodingStyle document to some degree, and mainly written to 7 - avoid answering (*) the same (or similar) questions over and over again. 9 + avoid answering [#f1]_ the same (or similar) questions over and over again. 8 10 9 11 Management style is very personal and much harder to quantify than 10 12 simple coding style rules, so this document may or may not have anything ··· 16 14 Btw, when talking about "kernel manager", it's all about the technical 17 15 lead persons, not the people who do traditional management inside 18 16 companies. If you sign purchase orders or you have any clue about the 19 - budget of your group, you're almost certainly not a kernel manager. 20 - These suggestions may or may not apply to you. 17 + budget of your group, you're almost certainly not a kernel manager. 18 + These suggestions may or may not apply to you. 21 19 22 20 First off, I'd suggest buying "Seven Habits of Highly Effective 23 - People", and NOT read it. Burn it, it's a great symbolic gesture. 21 + People", and NOT read it. Burn it, it's a great symbolic gesture. 24 22 25 - (*) This document does so not so much by answering the question, but by 26 - making it painfully obvious to the questioner that we don't have a clue 27 - to what the answer is. 23 + .. [#f1] This document does so not so much by answering the question, but by 24 + making it painfully obvious to the questioner that we don't have a clue 25 + to what the answer is. 28 26 29 27 Anyway, here goes: 30 28 29 + .. _decisions: 31 30 32 - Chapter 1: Decisions 31 + 1) Decisions 32 + ------------ 33 33 34 34 Everybody thinks managers make decisions, and that decision-making is 35 35 important. The bigger and more painful the decision, the bigger the 36 36 manager must be to make it. That's very deep and obvious, but it's not 37 - actually true. 37 + actually true. 38 38 39 - The name of the game is to _avoid_ having to make a decision. In 39 + The name of the game is to **avoid** having to make a decision. In 40 40 particular, if somebody tells you "choose (a) or (b), we really need you 41 41 to decide on this", you're in trouble as a manager. The people you 42 42 manage had better know the details better than you, so if they come to 43 43 you for a technical decision, you're screwed. You're clearly not 44 - competent to make that decision for them. 44 + competent to make that decision for them. 45 45 46 46 (Corollary:if the people you manage don't know the details better than 47 - you, you're also screwed, although for a totally different reason. 48 - Namely that you are in the wrong job, and that _they_ should be managing 49 - your brilliance instead). 47 + you, you're also screwed, although for a totally different reason. 48 + Namely that you are in the wrong job, and that **they** should be managing 49 + your brilliance instead). 50 50 51 - So the name of the game is to _avoid_ decisions, at least the big and 51 + So the name of the game is to **avoid** decisions, at least the big and 52 52 painful ones. Making small and non-consequential decisions is fine, and 53 53 makes you look like you know what you're doing, so what a kernel manager 54 54 needs to do is to turn the big and painful ones into small things where 55 - nobody really cares. 55 + nobody really cares. 56 56 57 57 It helps to realize that the key difference between a big decision and a 58 58 small one is whether you can fix your decision afterwards. Any decision 59 59 can be made small by just always making sure that if you were wrong (and 60 - you _will_ be wrong), you can always undo the damage later by 60 + you **will** be wrong), you can always undo the damage later by 61 61 backtracking. Suddenly, you get to be doubly managerial for making 62 - _two_ inconsequential decisions - the wrong one _and_ the right one. 62 + **two** inconsequential decisions - the wrong one **and** the right one. 63 63 64 64 And people will even see that as true leadership (*cough* bullshit 65 65 *cough*). ··· 69 65 Thus the key to avoiding big decisions becomes to just avoiding to do 70 66 things that can't be undone. Don't get ushered into a corner from which 71 67 you cannot escape. A cornered rat may be dangerous - a cornered manager 72 - is just pitiful. 68 + is just pitiful. 73 69 74 70 It turns out that since nobody would be stupid enough to ever really let 75 - a kernel manager have huge fiscal responsibility _anyway_, it's usually 71 + a kernel manager have huge fiscal responsibility **anyway**, it's usually 76 72 fairly easy to backtrack. Since you're not going to be able to waste 77 73 huge amounts of money that you might not be able to repay, the only 78 74 thing you can backtrack on is a technical decision, and there ··· 80 76 incompetent nincompoop, say you're sorry, and undo all the worthless 81 77 work you had people work on for the last year. Suddenly the decision 82 78 you made a year ago wasn't a big decision after all, since it could be 83 - easily undone. 79 + easily undone. 84 80 85 81 It turns out that some people have trouble with this approach, for two 86 82 reasons: 83 + 87 84 - admitting you were an idiot is harder than it looks. We all like to 88 85 maintain appearances, and coming out in public to say that you were 89 - wrong is sometimes very hard indeed. 86 + wrong is sometimes very hard indeed. 90 87 - having somebody tell you that what you worked on for the last year 91 88 wasn't worthwhile after all can be hard on the poor lowly engineers 92 - too, and while the actual _work_ was easy enough to undo by just 89 + too, and while the actual **work** was easy enough to undo by just 93 90 deleting it, you may have irrevocably lost the trust of that 94 91 engineer. And remember: "irrevocable" was what we tried to avoid in 95 92 the first place, and your decision ended up being a big one after 96 - all. 93 + all. 97 94 98 95 Happily, both of these reasons can be mitigated effectively by just 99 96 admitting up-front that you don't have a friggin' clue, and telling 100 97 people ahead of the fact that your decision is purely preliminary, and 101 98 might be the wrong thing. You should always reserve the right to change 102 - your mind, and make people very _aware_ of that. And it's much easier 103 - to admit that you are stupid when you haven't _yet_ done the really 99 + your mind, and make people very **aware** of that. And it's much easier 100 + to admit that you are stupid when you haven't **yet** done the really 104 101 stupid thing. 105 102 106 103 Then, when it really does turn out to be stupid, people just roll their 107 - eyes and say "Oops, he did it again". 104 + eyes and say "Oops, he did it again". 108 105 109 106 This preemptive admission of incompetence might also make the people who 110 107 actually do the work also think twice about whether it's worth doing or 111 - not. After all, if _they_ aren't certain whether it's a good idea, you 108 + not. After all, if **they** aren't certain whether it's a good idea, you 112 109 sure as hell shouldn't encourage them by promising them that what they 113 110 work on will be included. Make them at least think twice before they 114 - embark on a big endeavor. 111 + embark on a big endeavor. 115 112 116 113 Remember: they'd better know more about the details than you do, and 117 114 they usually already think they have the answer to everything. The best 118 115 thing you can do as a manager is not to instill confidence, but rather a 119 - healthy dose of critical thinking on what they do. 116 + healthy dose of critical thinking on what they do. 120 117 121 118 Btw, another way to avoid a decision is to plaintively just whine "can't 122 119 we just do both?" and look pitiful. Trust me, it works. If it's not 123 120 clear which approach is better, they'll eventually figure it out. The 124 121 answer may end up being that both teams get so frustrated by the 125 - situation that they just give up. 122 + situation that they just give up. 126 123 127 124 That may sound like a failure, but it's usually a sign that there was 128 125 something wrong with both projects, and the reason the people involved 129 126 couldn't decide was that they were both wrong. You end up coming up 130 127 smelling like roses, and you avoided yet another decision that you could 131 - have screwed up on. 128 + have screwed up on. 132 129 133 130 134 - Chapter 2: People 131 + 2) People 132 + --------- 135 133 136 134 Most people are idiots, and being a manager means you'll have to deal 137 - with it, and perhaps more importantly, that _they_ have to deal with 138 - _you_. 135 + with it, and perhaps more importantly, that **they** have to deal with 136 + **you**. 139 137 140 138 It turns out that while it's easy to undo technical mistakes, it's not 141 139 as easy to undo personality disorders. You just have to live with 142 - theirs - and yours. 140 + theirs - and yours. 143 141 144 142 However, in order to prepare yourself as a kernel manager, it's best to 145 143 remember not to burn any bridges, bomb any innocent villagers, or 146 144 alienate too many kernel developers. It turns out that alienating people 147 145 is fairly easy, and un-alienating them is hard. Thus "alienating" 148 146 immediately falls under the heading of "not reversible", and becomes a 149 - no-no according to Chapter 1. 147 + no-no according to :ref:`decisions`. 150 148 151 149 There's just a few simple rules here: 150 + 152 151 (1) don't call people d*ckheads (at least not in public) 153 152 (2) learn how to apologize when you forgot rule (1) 154 153 155 154 The problem with #1 is that it's very easy to do, since you can say 156 - "you're a d*ckhead" in millions of different ways (*), sometimes without 155 + "you're a d*ckhead" in millions of different ways [#f2]_, sometimes without 157 156 even realizing it, and almost always with a white-hot conviction that 158 - you are right. 157 + you are right. 159 158 160 159 And the more convinced you are that you are right (and let's face it, 161 - you can call just about _anybody_ a d*ckhead, and you often _will_ be 162 - right), the harder it ends up being to apologize afterwards. 160 + you can call just about **anybody** a d*ckhead, and you often **will** be 161 + right), the harder it ends up being to apologize afterwards. 163 162 164 163 To solve this problem, you really only have two options: 164 + 165 165 - get really good at apologies 166 166 - spread the "love" out so evenly that nobody really ends up feeling 167 167 like they get unfairly targeted. Make it inventive enough, and they 168 - might even be amused. 168 + might even be amused. 169 169 170 170 The option of being unfailingly polite really doesn't exist. Nobody will 171 171 trust somebody who is so clearly hiding his true character. 172 172 173 - (*) Paul Simon sang "Fifty Ways to Leave Your Lover", because quite 174 - frankly, "A Million Ways to Tell a Developer He Is a D*ckhead" doesn't 175 - scan nearly as well. But I'm sure he thought about it. 173 + .. [#f2] Paul Simon sang "Fifty Ways to Leave Your Lover", because quite 174 + frankly, "A Million Ways to Tell a Developer He Is a D*ckhead" doesn't 175 + scan nearly as well. But I'm sure he thought about it. 176 176 177 177 178 - Chapter 3: People II - the Good Kind 178 + 3) People II - the Good Kind 179 + ---------------------------- 179 180 180 181 While it turns out that most people are idiots, the corollary to that is 181 182 sadly that you are one too, and that while we can all bask in the secure 182 183 knowledge that we're better than the average person (let's face it, 183 184 nobody ever believes that they're average or below-average), we should 184 185 also admit that we're not the sharpest knife around, and there will be 185 - other people that are less of an idiot than you are. 186 + other people that are less of an idiot than you are. 186 187 187 - Some people react badly to smart people. Others take advantage of them. 188 + Some people react badly to smart people. Others take advantage of them. 188 189 189 - Make sure that you, as a kernel maintainer, are in the second group. 190 + Make sure that you, as a kernel maintainer, are in the second group. 190 191 Suck up to them, because they are the people who will make your job 191 192 easier. In particular, they'll be able to make your decisions for you, 192 193 which is what the game is all about. ··· 200 191 management responsibilities largely become ones of saying "Sounds like a 201 192 good idea - go wild", or "That sounds good, but what about xxx?". The 202 193 second version in particular is a great way to either learn something 203 - new about "xxx" or seem _extra_ managerial by pointing out something the 194 + new about "xxx" or seem **extra** managerial by pointing out something the 204 195 smarter person hadn't thought about. In either case, you win. 205 196 206 197 One thing to look out for is to realize that greatness in one area does ··· 208 199 specific directions, but let's face it, they might be good at what they 209 200 do, and suck at everything else. The good news is that people tend to 210 201 naturally gravitate back to what they are good at, so it's not like you 211 - are doing something irreversible when you _do_ prod them in some 202 + are doing something irreversible when you **do** prod them in some 212 203 direction, just don't push too hard. 213 204 214 205 215 - Chapter 4: Placing blame 206 + 4) Placing blame 207 + ---------------- 216 208 217 209 Things will go wrong, and people want somebody to blame. Tag, you're it. 218 210 219 211 It's not actually that hard to accept the blame, especially if people 220 - kind of realize that it wasn't _all_ your fault. Which brings us to the 212 + kind of realize that it wasn't **all** your fault. Which brings us to the 221 213 best way of taking the blame: do it for another guy. You'll feel good 222 214 for taking the fall, he'll feel good about not getting blamed, and the 223 215 guy who lost his whole 36GB porn-collection because of your incompetence 224 216 will grudgingly admit that you at least didn't try to weasel out of it. 225 217 226 218 Then make the developer who really screwed up (if you can find him) know 227 - _in_private_ that he screwed up. Not just so he can avoid it in the 219 + **in_private** that he screwed up. Not just so he can avoid it in the 228 220 future, but so that he knows he owes you one. And, perhaps even more 229 221 importantly, he's also likely the person who can fix it. Because, let's 230 - face it, it sure ain't you. 222 + face it, it sure ain't you. 231 223 232 - Taking the blame is also why you get to be manager in the first place. 224 + Taking the blame is also why you get to be manager in the first place. 233 225 It's part of what makes people trust you, and allow you the potential 234 226 glory, because you're the one who gets to say "I screwed up". And if 235 227 you've followed the previous rules, you'll be pretty good at saying that 236 - by now. 228 + by now. 237 229 238 230 239 - Chapter 5: Things to avoid 231 + 5) Things to avoid 232 + ------------------ 240 233 241 234 There's one thing people hate even more than being called "d*ckhead", 242 235 and that is being called a "d*ckhead" in a sanctimonious voice. The 243 236 first you can apologize for, the second one you won't really get the 244 237 chance. They likely will no longer be listening even if you otherwise 245 - do a good job. 238 + do a good job. 246 239 247 240 We all think we're better than anybody else, which means that when 248 - somebody else puts on airs, it _really_ rubs us the wrong way. You may 241 + somebody else puts on airs, it **really** rubs us the wrong way. You may 249 242 be morally and intellectually superior to everybody around you, but 250 - don't try to make it too obvious unless you really _intend_ to irritate 251 - somebody (*). 243 + don't try to make it too obvious unless you really **intend** to irritate 244 + somebody [#f3]_. 252 245 253 246 Similarly, don't be too polite or subtle about things. Politeness easily 254 247 ends up going overboard and hiding the problem, and as they say, "On the ··· 262 251 overboard to the point of being ridiculous can drive a point home 263 252 without making it painful to the recipient, who just thinks you're being 264 253 silly. It can thus help get through the personal mental block we all 265 - have about criticism. 254 + have about criticism. 266 255 267 - (*) Hint: internet newsgroups that are not directly related to your work 268 - are great ways to take out your frustrations at other people. Write 269 - insulting posts with a sneer just to get into a good flame every once in 270 - a while, and you'll feel cleansed. Just don't crap too close to home. 256 + .. [#f3] Hint: internet newsgroups that are not directly related to your work 257 + are great ways to take out your frustrations at other people. Write 258 + insulting posts with a sneer just to get into a good flame every once in 259 + a while, and you'll feel cleansed. Just don't crap too close to home. 271 260 272 261 273 - Chapter 6: Why me? 262 + 6) Why me? 263 + ---------- 274 264 275 265 Since your main responsibility seems to be to take the blame for other 276 266 peoples mistakes, and make it painfully obvious to everybody else that ··· 280 268 281 269 First off, while you may or may not get screaming teenage girls (or 282 270 boys, let's not be judgmental or sexist here) knocking on your dressing 283 - room door, you _will_ get an immense feeling of personal accomplishment 271 + room door, you **will** get an immense feeling of personal accomplishment 284 272 for being "in charge". Never mind the fact that you're really leading 285 273 by trying to keep up with everybody else and running after them as fast 286 - as you can. Everybody will still think you're the person in charge. 274 + as you can. Everybody will still think you're the person in charge. 287 275 288 276 It's a great job if you can hack it.
+8
Documentation/SecurityBugs
··· 1 + .. _securitybugs: 2 + 3 + Security bugs 4 + ============= 5 + 1 6 Linux kernel developers take security very seriously. As such, we'd 2 7 like to know when a security bug is found so that it can be fixed and 3 8 disclosed as quickly as possible. Please report security bugs to the 4 9 Linux kernel security team. 5 10 6 11 1) Contact 12 + ---------- 7 13 8 14 The Linux kernel security team can be contacted by email at 9 15 <security@kernel.org>. This is a private list of security officers ··· 24 18 consent from the reporter unless it has already been made public. 25 19 26 20 2) Disclosure 21 + ------------- 27 22 28 23 The goal of the Linux kernel security team is to work with the 29 24 bug submitter to bug resolution as well as disclosure. We prefer ··· 40 33 disclosure date to be on the order of 7 days. 41 34 42 35 3) Non-disclosure agreements 36 + ---------------------------- 43 37 44 38 The Linux kernel security team is not a formal body and therefore unable 45 39 to enter any non-disclosure agreements.
+69 -58
Documentation/SubmitChecklist
··· 1 + .. _submitchecklist: 2 + 1 3 Linux Kernel patch submission checklist 2 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 5 4 6 Here are some basic things that developers should do if they want to see their 5 7 kernel patch submissions accepted more quickly. 6 8 7 9 These are all above and beyond the documentation that is provided in 8 - Documentation/SubmittingPatches and elsewhere regarding submitting Linux 9 - kernel patches. 10 + :ref:`Documentation/SubmittingPatches <submittingpatches>` 11 + and elsewhere regarding submitting Linux kernel patches. 10 12 11 13 12 - 1: If you use a facility then #include the file that defines/declares 14 + 1) If you use a facility then #include the file that defines/declares 13 15 that facility. Don't depend on other header files pulling in ones 14 16 that you use. 15 17 16 - 2: Builds cleanly with applicable or modified CONFIG options =y, =m, and 17 - =n. No gcc warnings/errors, no linker warnings/errors. 18 + 2) Builds cleanly: 18 19 19 - 2b: Passes allnoconfig, allmodconfig 20 + a) with applicable or modified ``CONFIG`` options ``=y``, ``=m``, and 21 + ``=n``. No ``gcc`` warnings/errors, no linker warnings/errors. 20 22 21 - 2c: Builds successfully when using O=builddir 23 + b) Passes ``allnoconfig``, ``allmodconfig`` 22 24 23 - 3: Builds on multiple CPU architectures by using local cross-compile tools 25 + c) Builds successfully when using ``O=builddir`` 26 + 27 + 3) Builds on multiple CPU architectures by using local cross-compile tools 24 28 or some other build farm. 25 29 26 - 4: ppc64 is a good architecture for cross-compilation checking because it 27 - tends to use `unsigned long' for 64-bit quantities. 30 + 4) ppc64 is a good architecture for cross-compilation checking because it 31 + tends to use ``unsigned long`` for 64-bit quantities. 28 32 29 - 5: Check your patch for general style as detailed in 30 - Documentation/CodingStyle. Check for trivial violations with the 31 - patch style checker prior to submission (scripts/checkpatch.pl). 33 + 5) Check your patch for general style as detailed in 34 + :ref:`Documentation/CodingStyle <codingstyle>`. 35 + Check for trivial violations with the patch style checker prior to 36 + submission (``scripts/checkpatch.pl``). 32 37 You should be able to justify all violations that remain in 33 38 your patch. 34 39 35 - 6: Any new or modified CONFIG options don't muck up the config menu. 40 + 6) Any new or modified ``CONFIG`` options don't muck up the config menu. 36 41 37 - 7: All new Kconfig options have help text. 42 + 7) All new ``Kconfig`` options have help text. 38 43 39 - 8: Has been carefully reviewed with respect to relevant Kconfig 44 + 8) Has been carefully reviewed with respect to relevant ``Kconfig`` 40 45 combinations. This is very hard to get right with testing -- brainpower 41 46 pays off here. 42 47 43 - 9: Check cleanly with sparse. 48 + 9) Check cleanly with sparse. 44 49 45 - 10: Use 'make checkstack' and 'make namespacecheck' and fix any problems 46 - that they find. Note: checkstack does not point out problems explicitly, 47 - but any one function that uses more than 512 bytes on the stack is a 48 - candidate for change. 50 + 10) Use ``make checkstack`` and ``make namespacecheck`` and fix any problems 51 + that they find. 49 52 50 - 11: Include kernel-doc to document global kernel APIs. (Not required for 51 - static functions, but OK there also.) Use 'make htmldocs' or 'make 52 - mandocs' to check the kernel-doc and fix any issues. 53 + .. note:: 53 54 54 - 12: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, 55 - CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, 56 - CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEP, CONFIG_PROVE_RCU 57 - and CONFIG_DEBUG_OBJECTS_RCU_HEAD all simultaneously enabled. 55 + ``checkstack`` does not point out problems explicitly, 56 + but any one function that uses more than 512 bytes on the stack is a 57 + candidate for change. 58 58 59 - 13: Has been build- and runtime tested with and without CONFIG_SMP and 60 - CONFIG_PREEMPT. 59 + 11) Include :ref:`kernel-doc <kernel_doc>` to document global kernel APIs. 60 + (Not required for static functions, but OK there also.) Use 61 + ``make htmldocs`` or ``make pdfdocs`` to check the 62 + :ref:`kernel-doc <kernel_doc>` and fix any issues. 61 63 62 - 14: If the patch affects IO/Disk, etc: has been tested with and without 63 - CONFIG_LBDAF. 64 + 12) Has been tested with ``CONFIG_PREEMPT``, ``CONFIG_DEBUG_PREEMPT``, 65 + ``CONFIG_DEBUG_SLAB``, ``CONFIG_DEBUG_PAGEALLOC``, ``CONFIG_DEBUG_MUTEXES``, 66 + ``CONFIG_DEBUG_SPINLOCK``, ``CONFIG_DEBUG_ATOMIC_SLEEP``, 67 + ``CONFIG_PROVE_RCU`` and ``CONFIG_DEBUG_OBJECTS_RCU_HEAD`` all 68 + simultaneously enabled. 64 69 65 - 15: All codepaths have been exercised with all lockdep features enabled. 70 + 13) Has been build- and runtime tested with and without ``CONFIG_SMP`` and 71 + ``CONFIG_PREEMPT.`` 66 72 67 - 16: All new /proc entries are documented under Documentation/ 73 + 14) If the patch affects IO/Disk, etc: has been tested with and without 74 + ``CONFIG_LBDAF.`` 68 75 69 - 17: All new kernel boot parameters are documented in 70 - Documentation/kernel-parameters.txt. 76 + 15) All codepaths have been exercised with all lockdep features enabled. 71 77 72 - 18: All new module parameters are documented with MODULE_PARM_DESC() 78 + 16) All new ``/proc`` entries are documented under ``Documentation/`` 73 79 74 - 19: All new userspace interfaces are documented in Documentation/ABI/. 75 - See Documentation/ABI/README for more information. 80 + 17) All new kernel boot parameters are documented in 81 + ``Documentation/kernel-parameters.txt``. 82 + 83 + 18) All new module parameters are documented with ``MODULE_PARM_DESC()`` 84 + 85 + 19) All new userspace interfaces are documented in ``Documentation/ABI/``. 86 + See ``Documentation/ABI/README`` for more information. 76 87 Patches that change userspace interfaces should be CCed to 77 88 linux-api@vger.kernel.org. 78 89 79 - 20: Check that it all passes `make headers_check'. 90 + 20) Check that it all passes ``make headers_check``. 80 91 81 - 21: Has been checked with injection of at least slab and page-allocation 82 - failures. See Documentation/fault-injection/. 92 + 21) Has been checked with injection of at least slab and page-allocation 93 + failures. See ``Documentation/fault-injection/``. 83 94 84 95 If the new code is substantial, addition of subsystem-specific fault 85 96 injection might be appropriate. 86 97 87 - 22: Newly-added code has been compiled with `gcc -W' (use "make 88 - EXTRA_CFLAGS=-W"). This will generate lots of noise, but is good for 89 - finding bugs like "warning: comparison between signed and unsigned". 98 + 22) Newly-added code has been compiled with ``gcc -W`` (use 99 + ``make EXTRA_CFLAGS=-W``). This will generate lots of noise, but is good 100 + for finding bugs like "warning: comparison between signed and unsigned". 90 101 91 - 23: Tested after it has been merged into the -mm patchset to make sure 102 + 23) Tested after it has been merged into the -mm patchset to make sure 92 103 that it still works with all of the other queued patches and various 93 104 changes in the VM, VFS, and other subsystems. 94 105 95 - 24: All memory barriers {e.g., barrier(), rmb(), wmb()} need a comment in the 96 - source code that explains the logic of what they are doing and why. 106 + 24) All memory barriers {e.g., ``barrier()``, ``rmb()``, ``wmb()``} need a 107 + comment in the source code that explains the logic of what they are doing 108 + and why. 97 109 98 - 25: If any ioctl's are added by the patch, then also update 99 - Documentation/ioctl/ioctl-number.txt. 110 + 25) If any ioctl's are added by the patch, then also update 111 + ``Documentation/ioctl/ioctl-number.txt``. 100 112 101 - 26: If your modified source code depends on or uses any of the kernel 102 - APIs or features that are related to the following kconfig symbols, 103 - then test multiple builds with the related kconfig symbols disabled 104 - and/or =m (if that option is available) [not all of these at the 113 + 26) If your modified source code depends on or uses any of the kernel 114 + APIs or features that are related to the following ``Kconfig`` symbols, 115 + then test multiple builds with the related ``Kconfig`` symbols disabled 116 + and/or ``=m`` (if that option is available) [not all of these at the 105 117 same time, just various/random combinations of them]: 106 118 107 - CONFIG_SMP, CONFIG_SYSFS, CONFIG_PROC_FS, CONFIG_INPUT, CONFIG_PCI, 108 - CONFIG_BLOCK, CONFIG_PM, CONFIG_MAGIC_SYSRQ, 109 - CONFIG_NET, CONFIG_INET=n (but latter with CONFIG_NET=y) 119 + ``CONFIG_SMP``, ``CONFIG_SYSFS``, ``CONFIG_PROC_FS``, ``CONFIG_INPUT``, ``CONFIG_PCI``, ``CONFIG_BLOCK``, ``CONFIG_PM``, ``CONFIG_MAGIC_SYSRQ``, 120 + ``CONFIG_NET``, ``CONFIG_INET=n`` (but latter with ``CONFIG_NET=y``).
+37 -17
Documentation/SubmittingDrivers
··· 1 + .. _submittingdrivers: 2 + 1 3 Submitting Drivers For The Linux Kernel 2 - --------------------------------------- 4 + ======================================= 3 5 4 6 This document is intended to explain how to submit device drivers to the 5 7 various kernel trees. Note that if you are interested in video card drivers ··· 40 38 maintainer does not respond or you cannot find the appropriate 41 39 maintainer then please contact Willy Tarreau <w@1wt.eu>. 42 40 43 - Linux 2.6: 41 + Linux 2.6 and upper: 44 42 The same rules apply as 2.4 except that you should follow linux-kernel 45 - to track changes in API's. The final contact point for Linux 2.6 43 + to track changes in API's. The final contact point for Linux 2.6+ 46 44 submissions is Andrew Morton. 47 45 48 46 What Criteria Determine Acceptance 49 47 ---------------------------------- 50 48 51 - Licensing: The code must be released to us under the 49 + Licensing: 50 + The code must be released to us under the 52 51 GNU General Public License. We don't insist on any kind 53 52 of exclusive GPL licensing, and if you wish the driver 54 53 to be useful to other communities such as BSD you may well 55 54 wish to release under multiple licenses. 56 55 See accepted licenses at include/linux/module.h 57 56 58 - Copyright: The copyright owner must agree to use of GPL. 57 + Copyright: 58 + The copyright owner must agree to use of GPL. 59 59 It's best if the submitter and copyright owner 60 60 are the same person/entity. If not, the name of 61 61 the person/entity authorizing use of GPL should be 62 62 listed in case it's necessary to verify the will of 63 63 the copyright owner. 64 64 65 - Interfaces: If your driver uses existing interfaces and behaves like 65 + Interfaces: 66 + If your driver uses existing interfaces and behaves like 66 67 other drivers in the same class it will be much more likely 67 68 to be accepted than if it invents gratuitous new ones. 68 69 If you need to implement a common API over Linux and NT 69 70 drivers do it in userspace. 70 71 71 - Code: Please use the Linux style of code formatting as documented 72 - in Documentation/CodingStyle. If you have sections of code 72 + Code: 73 + Please use the Linux style of code formatting as documented 74 + in :ref:`Documentation/CodingStyle <codingStyle>`. 75 + If you have sections of code 73 76 that need to be in other formats, for example because they 74 77 are shared with a windows driver kit and you want to 75 78 maintain them just once separate them out nicely and note 76 79 this fact. 77 80 78 - Portability: Pointers are not always 32bits, not all computers are little 81 + Portability: 82 + Pointers are not always 32bits, not all computers are little 79 83 endian, people do not all have floating point and you 80 84 shouldn't use inline x86 assembler in your driver without 81 85 careful thought. Pure x86 drivers generally are not popular. ··· 89 81 but it is easy to make sure the code can easily be made 90 82 portable. 91 83 92 - Clarity: It helps if anyone can see how to fix the driver. It helps 84 + Clarity: 85 + It helps if anyone can see how to fix the driver. It helps 93 86 you because you get patches not bug reports. If you submit a 94 87 driver that intentionally obfuscates how the hardware works 95 88 it will go in the bitbucket. 96 89 97 - PM support: Since Linux is used on many portable and desktop systems, your 90 + PM support: 91 + Since Linux is used on many portable and desktop systems, your 98 92 driver is likely to be used on such a system and therefore it 99 93 should support basic power management by implementing, if 100 94 necessary, the .suspend and .resume methods used during the ··· 111 101 complete overview of the power management issues related to 112 102 drivers see Documentation/power/devices.txt . 113 103 114 - Control: In general if there is active maintenance of a driver by 104 + Control: 105 + In general if there is active maintenance of a driver by 115 106 the author then patches will be redirected to them unless 116 107 they are totally obvious and without need of checking. 117 108 If you want to be the contact and update point for the ··· 122 111 What Criteria Do Not Determine Acceptance 123 112 ----------------------------------------- 124 113 125 - Vendor: Being the hardware vendor and maintaining the driver is 114 + Vendor: 115 + Being the hardware vendor and maintaining the driver is 126 116 often a good thing. If there is a stable working driver from 127 117 other people already in the tree don't expect 'we are the 128 118 vendor' to get your driver chosen. Ideally work with the 129 119 existing driver author to build a single perfect driver. 130 120 131 - Author: It doesn't matter if a large Linux company wrote the driver, 121 + Author: 122 + It doesn't matter if a large Linux company wrote the driver, 132 123 or you did. Nobody has any special access to the kernel 133 124 tree. Anyone who tells you otherwise isn't telling the 134 125 whole story. ··· 140 127 --------- 141 128 142 129 Linux kernel master tree: 143 - ftp.??.kernel.org:/pub/linux/kernel/... 144 - ?? == your country code, such as "us", "uk", "fr", etc. 130 + ftp.\ *country_code*\ .kernel.org:/pub/linux/kernel/... 131 + 132 + where *country_code* == your country code, such as 133 + **us**, **uk**, **fr**, etc. 145 134 146 135 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git 147 136 ··· 156 141 157 142 LWN.net: 158 143 Weekly summary of kernel development activity - http://lwn.net/ 144 + 159 145 2.6 API changes: 146 + 160 147 http://lwn.net/Articles/2.6-kernel-api/ 148 + 161 149 Porting drivers from prior kernels to 2.6: 150 + 162 151 http://lwn.net/Articles/driver-porting/ 163 152 164 153 KernelNewbies: 165 154 Documentation and assistance for new kernel programmers 166 - http://kernelnewbies.org/ 155 + 156 + http://kernelnewbies.org/ 167 157 168 158 Linux USB project: 169 159 http://www.linux-usb.org/
+166 -146
Documentation/SubmittingPatches
··· 1 + .. _submittingpatches: 1 2 2 - How to Get Your Change Into the Linux Kernel 3 - or 4 - Care And Operation Of Your Linus Torvalds 5 - 6 - 3 + How to Get Your Change Into the Linux Kernel or Care And Operation Of Your Linus Torvalds 4 + ========================================================================================= 7 5 8 6 For a person or company who wishes to submit a change to the Linux 9 7 kernel, the process can sometimes be daunting if you're not familiar ··· 10 12 11 13 This document contains a large number of suggestions in a relatively terse 12 14 format. For detailed information on how the kernel development process 13 - works, see Documentation/development-process. Also, read 14 - Documentation/SubmitChecklist for a list of items to check before 15 + works, see :ref:`Documentation/development-process <development_process_main>`. 16 + Also, read :ref:`Documentation/SubmitChecklist <submitchecklist>` 17 + for a list of items to check before 15 18 submitting code. If you are submitting a driver, also read 16 - Documentation/SubmittingDrivers; for device tree binding patches, read 19 + :ref:`Documentation/SubmittingDrivers <submittingdrivers>`; 20 + for device tree binding patches, read 17 21 Documentation/devicetree/bindings/submitting-patches.txt. 18 22 19 - Many of these steps describe the default behavior of the git version 20 - control system; if you use git to prepare your patches, you'll find much 23 + Many of these steps describe the default behavior of the ``git`` version 24 + control system; if you use ``git`` to prepare your patches, you'll find much 21 25 of the mechanical work done for you, though you'll still need to prepare 22 - and document a sensible set of patches. In general, use of git will make 26 + and document a sensible set of patches. In general, use of ``git`` will make 23 27 your life as a kernel developer easier. 24 28 25 - -------------------------------------------- 26 - SECTION 1 - CREATING AND SENDING YOUR CHANGE 27 - -------------------------------------------- 29 + Creating and Sending your Change 30 + ******************************** 28 31 29 32 30 33 0) Obtain a current source tree 31 34 ------------------------------- 32 35 33 36 If you do not have a repository with the current kernel source handy, use 34 - git to obtain one. You'll want to start with the mainline repository, 35 - which can be grabbed with: 37 + ``git`` to obtain one. You'll want to start with the mainline repository, 38 + which can be grabbed with:: 36 39 37 - git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 40 + git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 38 41 39 42 Note, however, that you may not want to develop against the mainline tree 40 43 directly. Most subsystem maintainers run their own trees and want to see 41 - patches prepared against those trees. See the "T:" entry for the subsystem 44 + patches prepared against those trees. See the **T:** entry for the subsystem 42 45 in the MAINTAINERS file to find that tree, or simply ask the maintainer if 43 46 the tree is not listed there. 44 47 45 48 It is still possible to download kernel releases via tarballs (as described 46 49 in the next section), but that is the hard way to do kernel development. 47 50 48 - 1) "diff -up" 49 - ------------ 51 + 1) ``diff -up`` 52 + --------------- 50 53 51 - If you must generate your patches by hand, use "diff -up" or "diff -uprN" 54 + If you must generate your patches by hand, use ``diff -up`` or ``diff -uprN`` 52 55 to create patches. Git generates patches in this form by default; if 53 - you're using git, you can skip this section entirely. 56 + you're using ``git``, you can skip this section entirely. 54 57 55 58 All changes to the Linux kernel occur in the form of patches, as 56 - generated by diff(1). When creating your patch, make sure to create it 57 - in "unified diff" format, as supplied by the '-u' argument to diff(1). 58 - Also, please use the '-p' argument which shows which C function each 59 - change is in - that makes the resultant diff a lot easier to read. 59 + generated by :manpage:`diff(1)`. When creating your patch, make sure to 60 + create it in "unified diff" format, as supplied by the ``-u`` argument 61 + to :manpage:`diff(1)`. 62 + Also, please use the ``-p`` argument which shows which C function each 63 + change is in - that makes the resultant ``diff`` a lot easier to read. 60 64 Patches should be based in the root kernel source directory, 61 65 not in any lower subdirectory. 62 66 63 - To create a patch for a single file, it is often sufficient to do: 67 + To create a patch for a single file, it is often sufficient to do:: 64 68 65 69 SRCTREE= linux 66 70 MYFILE= drivers/net/mydriver.c ··· 74 74 diff -up $SRCTREE/$MYFILE{.orig,} > /tmp/patch 75 75 76 76 To create a patch for multiple files, you should unpack a "vanilla", 77 - or unmodified kernel source tree, and generate a diff against your 78 - own source tree. For example: 77 + or unmodified kernel source tree, and generate a ``diff`` against your 78 + own source tree. For example:: 79 79 80 80 MYSRC= /devel/linux 81 81 ··· 84 84 diff -uprN -X linux-3.19-vanilla/Documentation/dontdiff \ 85 85 linux-3.19-vanilla $MYSRC > /tmp/patch 86 86 87 - "dontdiff" is a list of files which are generated by the kernel during 88 - the build process, and should be ignored in any diff(1)-generated 87 + ``dontdiff`` is a list of files which are generated by the kernel during 88 + the build process, and should be ignored in any :manpage:`diff(1)`-generated 89 89 patch. 90 90 91 91 Make sure your patch does not include any extra files which do not 92 92 belong in a patch submission. Make sure to review your patch -after- 93 - generating it with diff(1), to ensure accuracy. 93 + generating it with :manpage:`diff(1)`, to ensure accuracy. 94 94 95 95 If your changes produce a lot of deltas, you need to split them into 96 - individual patches which modify things in logical stages; see section 97 - #3. This will facilitate review by other kernel developers, 96 + individual patches which modify things in logical stages; see 97 + :ref:`split_changes`. This will facilitate review by other kernel developers, 98 98 very important if you want your patch accepted. 99 99 100 - If you're using git, "git rebase -i" can help you with this process. If 101 - you're not using git, quilt <http://savannah.nongnu.org/projects/quilt> 100 + If you're using ``git``, ``git rebase -i`` can help you with this process. If 101 + you're not using ``git``, ``quilt`` <http://savannah.nongnu.org/projects/quilt> 102 102 is another popular alternative. 103 103 104 + .. _describe_changes: 104 105 105 - 106 - 2) Describe your changes. 107 - ------------------------- 106 + 2) Describe your changes 107 + ------------------------ 108 108 109 109 Describe your problem. Whether your patch is a one-line bug fix or 110 110 5000 lines of a new feature, there must be an underlying problem that ··· 137 137 138 138 The maintainer will thank you if you write your patch description in a 139 139 form which can be easily pulled into Linux's source code management 140 - system, git, as a "commit log". See #15, below. 140 + system, ``git``, as a "commit log". See :ref:`explicit_in_reply_to`. 141 141 142 142 Solve only one problem per patch. If your description starts to get 143 143 long, that's a sign that you probably need to split up your patch. 144 - See #3, next. 144 + See :ref:`split_changes`. 145 145 146 146 When you submit or resubmit a patch or patch series, include the 147 147 complete patch description and justification for it. Don't just ··· 160 160 If the patch fixes a logged bug entry, refer to that bug entry by 161 161 number and URL. If the patch follows from a mailing list discussion, 162 162 give a URL to the mailing list archive; use the https://lkml.kernel.org/ 163 - redirector with a Message-Id, to ensure that the links cannot become 163 + redirector with a ``Message-Id``, to ensure that the links cannot become 164 164 stale. 165 165 166 166 However, try to make your explanation understandable without external ··· 171 171 If you want to refer to a specific commit, don't just refer to the 172 172 SHA-1 ID of the commit. Please also include the oneline summary of 173 173 the commit, to make it easier for reviewers to know what it is about. 174 - Example: 174 + Example:: 175 175 176 176 Commit e21d2170f36602ae2708 ("video: remove unnecessary 177 177 platform_set_drvdata()") removed the unnecessary ··· 185 185 change five years from now. 186 186 187 187 If your patch fixes a bug in a specific commit, e.g. you found an issue using 188 - git-bisect, please use the 'Fixes:' tag with the first 12 characters of the 189 - SHA-1 ID, and the one line summary. For example: 188 + ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of 189 + the SHA-1 ID, and the one line summary. For example:: 190 190 191 191 Fixes: e21d2170f366 ("video: remove unnecessary platform_set_drvdata()") 192 192 193 - The following git-config settings can be used to add a pretty format for 194 - outputting the above style in the git log or git show commands 193 + The following ``git config`` settings can be used to add a pretty format for 194 + outputting the above style in the ``git log`` or ``git show`` commands:: 195 195 196 196 [core] 197 197 abbrev = 12 198 198 [pretty] 199 199 fixes = Fixes: %h (\"%s\") 200 200 201 - 3) Separate your changes. 202 - ------------------------- 201 + .. _split_changes: 203 202 204 - Separate each _logical change_ into a separate patch. 203 + 3) Separate your changes 204 + ------------------------ 205 + 206 + Separate each **logical change** into a separate patch. 205 207 206 208 For example, if your changes include both bug fixes and performance 207 209 enhancements for a single driver, separate those changes into two ··· 219 217 on its own merits. 220 218 221 219 If one patch depends on another patch in order for a change to be 222 - complete, that is OK. Simply note "this patch depends on patch X" 220 + complete, that is OK. Simply note **"this patch depends on patch X"** 223 221 in your patch description. 224 222 225 223 When dividing your change into a series of patches, take special care to 226 224 ensure that the kernel builds and runs properly after each patch in the 227 - series. Developers using "git bisect" to track down a problem can end up 225 + series. Developers using ``git bisect`` to track down a problem can end up 228 226 splitting your patch series at any point; they will not thank you if you 229 227 introduce bugs in the middle. 230 228 ··· 233 231 234 232 235 233 236 - 4) Style-check your changes. 237 - ---------------------------- 234 + 4) Style-check your changes 235 + --------------------------- 238 236 239 237 Check your patch for basic style violations, details of which can be 240 - found in Documentation/CodingStyle. Failure to do so simply wastes 238 + found in 239 + :ref:`Documentation/CodingStyle <codingstyle>`. 240 + Failure to do so simply wastes 241 241 the reviewers time and will get your patch rejected, probably 242 242 without even being read. 243 243 ··· 264 260 patch. 265 261 266 262 267 - 5) Select the recipients for your patch. 268 - ---------------------------------------- 263 + 5) Select the recipients for your patch 264 + --------------------------------------- 269 265 270 266 You should always copy the appropriate subsystem maintainer(s) on any patch 271 267 to code that they maintain; look through the MAINTAINERS file and the ··· 299 295 obviously, the patch should not be sent to any public lists. 300 296 301 297 Patches that fix a severe bug in a released kernel should be directed 302 - toward the stable maintainers by putting a line like this: 298 + toward the stable maintainers by putting a line like this:: 303 299 304 300 Cc: stable@vger.kernel.org 305 301 306 302 into the sign-off area of your patch (note, NOT an email recipient). You 307 - should also read Documentation/stable_kernel_rules.txt in addition to this 308 - file. 303 + should also read 304 + :ref:`Documentation/stable_kernel_rules.txt <stable_kernel_rules>` 305 + in addition to this file. 309 306 310 307 Note, however, that some subsystem maintainers want to come to their own 311 308 conclusions on which patches should go to the stable trees. The networking ··· 317 312 maintainer (as listed in the MAINTAINERS file) a man-pages patch, or at 318 313 least a notification of the change, so that some information makes its way 319 314 into the manual pages. User-space API changes should also be copied to 320 - linux-api@vger.kernel.org. 315 + linux-api@vger.kernel.org. 321 316 322 317 For small patches you may want to CC the Trivial Patch Monkey 323 318 trivial@kernel.org which collects "trivial" patches. Have a look 324 319 into the MAINTAINERS file for its current manager. 320 + 325 321 Trivial patches must qualify for one of the following rules: 326 - Spelling fixes in documentation 327 - Spelling fixes for errors which could break grep(1) 328 - Warning fixes (cluttering with useless warnings is bad) 329 - Compilation fixes (only if they are actually correct) 330 - Runtime fixes (only if they actually fix things) 331 - Removing use of deprecated functions/macros 332 - Contact detail and documentation fixes 333 - Non-portable code replaced by portable code (even in arch-specific, 334 - since people copy, as long as it's trivial) 335 - Any fix by the author/maintainer of the file (ie. patch monkey 336 - in re-transmission mode) 322 + 323 + - Spelling fixes in documentation 324 + - Spelling fixes for errors which could break :manpage:`grep(1)` 325 + - Warning fixes (cluttering with useless warnings is bad) 326 + - Compilation fixes (only if they are actually correct) 327 + - Runtime fixes (only if they actually fix things) 328 + - Removing use of deprecated functions/macros 329 + - Contact detail and documentation fixes 330 + - Non-portable code replaced by portable code (even in arch-specific, 331 + since people copy, as long as it's trivial) 332 + - Any fix by the author/maintainer of the file (ie. patch monkey 333 + in re-transmission mode) 337 334 338 335 339 336 340 - 6) No MIME, no links, no compression, no attachments. Just plain text. 341 - ----------------------------------------------------------------------- 337 + 6) No MIME, no links, no compression, no attachments. Just plain text 338 + ---------------------------------------------------------------------- 342 339 343 340 Linus and other kernel developers need to be able to read and comment 344 341 on the changes you are submitting. It is important for a kernel ··· 348 341 tools, so that they may comment on specific portions of your code. 349 342 350 343 For this reason, all patches should be submitted by e-mail "inline". 351 - WARNING: Be wary of your editor's word-wrap corrupting your patch, 352 - if you choose to cut-n-paste your patch. 344 + 345 + .. warning:: 346 + 347 + Be wary of your editor's word-wrap corrupting your patch, 348 + if you choose to cut-n-paste your patch. 353 349 354 350 Do not attach the patch as a MIME attachment, compressed or not. 355 351 Many popular e-mail applications will not always transmit a MIME ··· 363 353 Exception: If your mailer is mangling patches then someone may ask 364 354 you to re-send them using MIME. 365 355 366 - See Documentation/email-clients.txt for hints about configuring 367 - your e-mail client so that it sends your patches untouched. 356 + See :ref:`Documentation/email-clients.txt <email_clients>` 357 + for hints about configuring your e-mail client so that it sends your patches 358 + untouched. 368 359 369 - 7) E-mail size. 370 - --------------- 360 + 7) E-mail size 361 + -------------- 371 362 372 363 Large changes are not appropriate for mailing lists, and some 373 364 maintainers. If your patch, uncompressed, exceeds 300 kB in size, ··· 377 366 that if your patch exceeds 300 kB, it almost certainly needs to be broken up 378 367 anyway. 379 368 380 - 8) Respond to review comments. 381 - ------------------------------ 369 + 8) Respond to review comments 370 + ----------------------------- 382 371 383 372 Your patch will almost certainly get comments from reviewers on ways in 384 373 which the patch can be improved. You must respond to those comments; ··· 393 382 politely and address the problems they have pointed out. 394 383 395 384 396 - 9) Don't get discouraged - or impatient. 397 - ---------------------------------------- 385 + 9) Don't get discouraged - or impatient 386 + --------------------------------------- 398 387 399 388 After you have submitted your change, be patient and wait. Reviewers are 400 389 busy people and may not get to your patch right away. ··· 430 419 pass it on as an open-source patch. The rules are pretty simple: if you 431 420 can certify the below: 432 421 433 - Developer's Certificate of Origin 1.1 422 + Developer's Certificate of Origin 1.1 423 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 434 424 435 - By making a contribution to this project, I certify that: 425 + By making a contribution to this project, I certify that: 436 426 437 427 (a) The contribution was created in whole or in part by me and I 438 428 have the right to submit it under the open source license ··· 457 445 maintained indefinitely and may be redistributed consistent with 458 446 this project or the open source license(s) involved. 459 447 460 - then you just add a line saying 448 + then you just add a line saying:: 461 449 462 450 Signed-off-by: Random J Developer <random@developer.example.org> 463 451 ··· 478 466 the nature of your changes. While there is nothing mandatory about this, it 479 467 seems like prepending the description with your mail and/or name, all 480 468 enclosed in square brackets, is noticeable enough to make it obvious that 481 - you are responsible for last-minute changes. Example : 469 + you are responsible for last-minute changes. Example:: 482 470 483 471 Signed-off-by: Random J Developer <random@developer.example.org> 484 472 [lucky@maintainer.example.org: struct foo moved from foo.c to foo.h] ··· 493 481 Special note to back-porters: It seems to be a common and useful practice 494 482 to insert an indication of the origin of a patch at the top of the commit 495 483 message (just after the subject line) to facilitate tracking. For instance, 496 - here's what we see in a 3.x-stable release: 484 + here's what we see in a 3.x-stable release:: 497 485 498 - Date: Tue Oct 7 07:26:38 2014 -0400 486 + Date: Tue Oct 7 07:26:38 2014 -0400 499 487 500 488 libata: Un-break ATA blacklist 501 489 502 490 commit 1c40279960bcd7d52dbdf1d466b20d24b99176c8 upstream. 503 491 504 - And here's what might appear in an older kernel once a patch is backported: 492 + And here's what might appear in an older kernel once a patch is backported:: 505 493 506 494 Date: Tue May 13 22:12:27 2008 +0200 507 495 ··· 541 529 list archives. 542 530 543 531 If a person has had the opportunity to comment on a patch, but has not 544 - provided such comments, you may optionally add a "Cc:" tag to the patch. 532 + provided such comments, you may optionally add a ``Cc:`` tag to the patch. 545 533 This is the only tag which might be added without an explicit action by the 546 534 person it names - but it should indicate that this person was copied on the 547 535 patch. This tag documents that potentially interested parties ··· 564 552 Reviewed-by:, instead, indicates that the patch has been reviewed and found 565 553 acceptable according to the Reviewer's Statement: 566 554 567 - Reviewer's statement of oversight 555 + Reviewer's statement of oversight 556 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 568 557 569 - By offering my Reviewed-by: tag, I state that: 558 + By offering my Reviewed-by: tag, I state that: 570 559 571 - (a) I have carried out a technical review of this patch to 560 + (a) I have carried out a technical review of this patch to 572 561 evaluate its appropriateness and readiness for inclusion into 573 562 the mainline kernel. 574 563 ··· 607 594 is used to make it easy to determine where a bug originated, which can help 608 595 review a bug fix. This tag also assists the stable kernel team in determining 609 596 which stable kernel versions should receive your fix. This is the preferred 610 - method for indicating a bug fixed by the patch. See #2 above for more details. 597 + method for indicating a bug fixed by the patch. See :ref:`describe_changes` 598 + for more details. 611 599 612 600 613 601 14) The canonical patch format 614 602 ------------------------------ 615 603 616 604 This section describes how the patch itself should be formatted. Note 617 - that, if you have your patches stored in a git repository, proper patch 618 - formatting can be had with "git format-patch". The tools cannot create 605 + that, if you have your patches stored in a ``git`` repository, proper patch 606 + formatting can be had with ``git format-patch``. The tools cannot create 619 607 the necessary text, though, so read the instructions below anyway. 620 608 621 - The canonical patch subject line is: 609 + The canonical patch subject line is:: 622 610 623 611 Subject: [PATCH 001/123] subsystem: summary phrase 624 612 625 613 The canonical patch message body contains the following: 626 614 627 - - A "from" line specifying the patch author (only needed if the person 615 + - A ``from`` line specifying the patch author (only needed if the person 628 616 sending the patch is not the author). 629 617 630 618 - An empty line. ··· 633 619 - The body of the explanation, line wrapped at 75 columns, which will 634 620 be copied to the permanent changelog to describe this patch. 635 621 636 - - The "Signed-off-by:" lines, described above, which will 622 + - The ``Signed-off-by:`` lines, described above, which will 637 623 also go in the changelog. 638 624 639 - - A marker line containing simply "---". 625 + - A marker line containing simply ``---``. 640 626 641 627 - Any additional comments not suitable for the changelog. 642 628 643 - - The actual patch (diff output). 629 + - The actual patch (``diff`` output). 644 630 645 631 The Subject line format makes it very easy to sort the emails 646 632 alphabetically by subject line - pretty much any email reader will 647 633 support that - since because the sequence number is zero-padded, 648 634 the numerical and alphabetic sort is the same. 649 635 650 - The "subsystem" in the email's Subject should identify which 636 + The ``subsystem`` in the email's Subject should identify which 651 637 area or subsystem of the kernel is being patched. 652 638 653 - The "summary phrase" in the email's Subject should concisely 654 - describe the patch which that email contains. The "summary 655 - phrase" should not be a filename. Do not use the same "summary 656 - phrase" for every patch in a whole patch series (where a "patch 657 - series" is an ordered sequence of multiple, related patches). 639 + The ``summary phrase`` in the email's Subject should concisely 640 + describe the patch which that email contains. The ``summary 641 + phrase`` should not be a filename. Do not use the same ``summary 642 + phrase`` for every patch in a whole patch series (where a ``patch 643 + series`` is an ordered sequence of multiple, related patches). 658 644 659 - Bear in mind that the "summary phrase" of your email becomes a 645 + Bear in mind that the ``summary phrase`` of your email becomes a 660 646 globally-unique identifier for that patch. It propagates all the way 661 - into the git changelog. The "summary phrase" may later be used in 647 + into the ``git`` changelog. The ``summary phrase`` may later be used in 662 648 developer discussions which refer to the patch. People will want to 663 - google for the "summary phrase" to read discussion regarding that 649 + google for the ``summary phrase`` to read discussion regarding that 664 650 patch. It will also be the only thing that people may quickly see 665 651 when, two or three months later, they are going through perhaps 666 - thousands of patches using tools such as "gitk" or "git log 667 - --oneline". 652 + thousands of patches using tools such as ``gitk`` or ``git log 653 + --oneline``. 668 654 669 - For these reasons, the "summary" must be no more than 70-75 655 + For these reasons, the ``summary`` must be no more than 70-75 670 656 characters, and it must describe both what the patch changes, as well 671 657 as why the patch might be necessary. It is challenging to be both 672 658 succinct and descriptive, but that is what a well-written summary 673 659 should do. 674 660 675 - The "summary phrase" may be prefixed by tags enclosed in square 661 + The ``summary phrase`` may be prefixed by tags enclosed in square 676 662 brackets: "Subject: [PATCH <tag>...] <summary phrase>". The tags are 677 663 not considered part of the summary phrase, but describe how the patch 678 664 should be treated. Common tags might include a version descriptor if ··· 684 670 applied and that they have reviewed or applied all of the patches in 685 671 the patch series. 686 672 687 - A couple of example Subjects: 673 + A couple of example Subjects:: 688 674 689 675 Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching 690 676 Subject: [PATCH v2 01/27] x86: fix eflags tracking 691 677 692 - The "from" line must be the very first line in the message body, 678 + The ``from`` line must be the very first line in the message body, 693 679 and has the form: 694 680 695 681 From: Original Author <author@example.com> 696 682 697 - The "from" line specifies who will be credited as the author of the 698 - patch in the permanent changelog. If the "from" line is missing, 699 - then the "From:" line from the email header will be used to determine 683 + The ``from`` line specifies who will be credited as the author of the 684 + patch in the permanent changelog. If the ``from`` line is missing, 685 + then the ``From:`` line from the email header will be used to determine 700 686 the patch author in the changelog. 701 687 702 688 The explanation body will be committed to the permanent source ··· 708 694 looking for the applicable patch. If a patch fixes a compile failure, 709 695 it may not be necessary to include _all_ of the compile failures; just 710 696 enough that it is likely that someone searching for the patch can find 711 - it. As in the "summary phrase", it is important to be both succinct as 697 + it. As in the ``summary phrase``, it is important to be both succinct as 712 698 well as descriptive. 713 699 714 - The "---" marker line serves the essential purpose of marking for patch 700 + The ``---`` marker line serves the essential purpose of marking for patch 715 701 handling tools where the changelog message ends. 716 702 717 - One good use for the additional comments after the "---" marker is for 718 - a diffstat, to show what files have changed, and the number of 719 - inserted and deleted lines per file. A diffstat is especially useful 703 + One good use for the additional comments after the ``---`` marker is for 704 + a ``diffstat``, to show what files have changed, and the number of 705 + inserted and deleted lines per file. A ``diffstat`` is especially useful 720 706 on bigger patches. Other comments relevant only to the moment or the 721 707 maintainer, not suitable for the permanent changelog, should also go 722 - here. A good example of such comments might be "patch changelogs" 708 + here. A good example of such comments might be ``patch changelogs`` 723 709 which describe what has changed between the v1 and v2 version of the 724 710 patch. 725 711 726 - If you are going to include a diffstat after the "---" marker, please 727 - use diffstat options "-p 1 -w 70" so that filenames are listed from 712 + If you are going to include a ``diffstat`` after the ``---`` marker, please 713 + use ``diffstat`` options ``-p 1 -w 70`` so that filenames are listed from 728 714 the top of the kernel source tree and don't use too much horizontal 729 - space (easily fit in 80 columns, maybe with some indentation). (git 715 + space (easily fit in 80 columns, maybe with some indentation). (``git`` 730 716 generates appropriate diffstats by default.) 731 717 732 718 See more details on the proper patch format in the following 733 719 references. 734 720 721 + .. _explicit_in_reply_to: 722 + 735 723 15) Explicit In-Reply-To headers 736 724 -------------------------------- 737 725 738 726 It can be helpful to manually add In-Reply-To: headers to a patch 739 - (e.g., when using "git send-email") to associate the patch with 727 + (e.g., when using ``git send-email``) to associate the patch with 740 728 previous relevant discussion, e.g. to link a bug fix to the email with 741 729 the bug report. However, for a multi-patch series, it is generally 742 730 best to avoid using In-Reply-To: to link to older versions of the ··· 748 732 the cover email text) to link to an earlier version of the patch series. 749 733 750 734 751 - 16) Sending "git pull" requests 752 - ------------------------------- 735 + 16) Sending ``git pull`` requests 736 + --------------------------------- 753 737 754 738 If you have a series of patches, it may be most convenient to have the 755 739 maintainer pull them directly into the subsystem repository with a 756 - "git pull" operation. Note, however, that pulling patches from a developer 740 + ``git pull`` operation. Note, however, that pulling patches from a developer 757 741 requires a higher degree of trust than taking patches from a mailing list. 758 742 As a result, many subsystem maintainers are reluctant to take pull 759 743 requests, especially from new, unknown developers. If in doubt you can use ··· 762 746 763 747 A pull request should have [GIT] or [PULL] in the subject line. The 764 748 request itself should include the repository name and the branch of 765 - interest on a single line; it should look something like: 749 + interest on a single line; it should look something like:: 766 750 767 751 Please pull from 768 752 ··· 771 755 to get these changes: 772 756 773 757 A pull request should also include an overall message saying what will be 774 - included in the request, a "git shortlog" listing of the patches 775 - themselves, and a diffstat showing the overall effect of the patch series. 758 + included in the request, a ``git shortlog`` listing of the patches 759 + themselves, and a ``diffstat`` showing the overall effect of the patch series. 776 760 The easiest way to get all this information together is, of course, to let 777 - git do it for you with the "git request-pull" command. 761 + ``git`` do it for you with the ``git request-pull`` command. 778 762 779 763 Some maintainers (including Linus) want to see pull requests from signed 780 764 commits; that increases their confidence that the request actually came ··· 786 770 new developers, but there is no way around it. Attending conferences can 787 771 be a good way to find developers who can sign your key. 788 772 789 - Once you have prepared a patch series in git that you wish to have somebody 790 - pull, create a signed tag with "git tag -s". This will create a new tag 773 + Once you have prepared a patch series in ``git`` that you wish to have somebody 774 + pull, create a signed tag with ``git tag -s``. This will create a new tag 791 775 identifying the last commit in the series and containing a signature 792 776 created with your private key. You will also have the opportunity to add a 793 777 changelog-style message to the tag; this is an ideal place to describe the ··· 798 782 public tree. 799 783 800 784 When generating your pull request, use the signed tag as the target. A 801 - command like this will do the trick: 785 + command like this will do the trick:: 802 786 803 787 git request-pull master git://my.public.tree/linux.git my-signed-tag 804 788 805 789 806 - ---------------------- 807 - SECTION 2 - REFERENCES 808 - ---------------------- 790 + REFERENCES 791 + ********** 809 792 810 793 Andrew Morton, "The perfect patch" (tpp). 811 794 <http://www.ozlabs.org/~akpm/stuff/tpp.txt> ··· 814 799 815 800 Greg Kroah-Hartman, "How to piss off a kernel subsystem maintainer". 816 801 <http://www.kroah.com/log/linux/maintainer.html> 802 + 817 803 <http://www.kroah.com/log/linux/maintainer-02.html> 804 + 818 805 <http://www.kroah.com/log/linux/maintainer-03.html> 806 + 819 807 <http://www.kroah.com/log/linux/maintainer-04.html> 808 + 820 809 <http://www.kroah.com/log/linux/maintainer-05.html> 810 + 821 811 <http://www.kroah.com/log/linux/maintainer-06.html> 822 812 823 813 NO!!!! No more huge patch bombs to linux-kernel@vger.kernel.org people! 824 814 <https://lkml.org/lkml/2005/7/11/336> 825 815 826 816 Kernel Documentation/CodingStyle: 827 - <Documentation/CodingStyle> 817 + :ref:`Documentation/CodingStyle <codingstyle>` 828 818 829 819 Linus Torvalds's mail on the canonical patch format: 830 820 <http://lkml.org/lkml/2005/4/7/183> 831 821 832 822 Andi Kleen, "On submitting kernel patches" 833 823 Some strategies to get difficult or controversial changes in. 824 + 834 825 http://halobates.de/on-submitting-patches.pdf 835 826 836 - --
+210 -199
Documentation/applying-patches.txt
··· 1 + .. _applying_patches: 1 2 2 - Applying Patches To The Linux Kernel 3 - ------------------------------------ 3 + Applying Patches To The Linux Kernel 4 + ++++++++++++++++++++++++++++++++++++ 4 5 5 - Original by: Jesper Juhl, August 2005 6 - Last update: 2006-01-05 6 + Original by: 7 + Jesper Juhl, August 2005 8 + 9 + Last update: 10 + 2016-09-14 7 11 8 12 9 13 A frequently asked question on the Linux Kernel Mailing List is how to apply ··· 21 17 22 18 23 19 What is a patch? 24 - --- 25 - A patch is a small text document containing a delta of changes between two 26 - different versions of a source tree. Patches are created with the `diff' 20 + ================ 21 + 22 + A patch is a small text document containing a delta of changes between two 23 + different versions of a source tree. Patches are created with the ``diff`` 27 24 program. 25 + 28 26 To correctly apply a patch you need to know what base it was generated from 29 27 and what new version the patch will change the source tree into. These 30 28 should both be present in the patch file metadata or be possible to deduce ··· 34 28 35 29 36 30 How do I apply or revert a patch? 37 - --- 38 - You apply a patch with the `patch' program. The patch program reads a diff 31 + ================================= 32 + 33 + You apply a patch with the ``patch`` program. The patch program reads a diff 39 34 (or patch) file and makes the changes to the source tree described in it. 40 35 41 36 Patches for the Linux kernel are generated relative to the parent directory ··· 45 38 This means that paths to files inside the patch file contain the name of the 46 39 kernel source directories it was generated against (or some other directory 47 40 names like "a/" and "b/"). 41 + 48 42 Since this is unlikely to match the name of the kernel source dir on your 49 43 local machine (but is often useful info to see what version an otherwise 50 44 unlabeled patch was generated against) you should change into your kernel 51 45 source directory and then strip the first element of the path from filenames 52 - in the patch file when applying it (the -p1 argument to `patch' does this). 46 + in the patch file when applying it (the ``-p1`` argument to ``patch`` does 47 + this). 53 48 54 49 To revert a previously applied patch, use the -R argument to patch. 55 - So, if you applied a patch like this: 50 + So, if you applied a patch like this:: 51 + 56 52 patch -p1 < ../patch-x.y.z 57 53 58 - You can revert (undo) it like this: 54 + You can revert (undo) it like this:: 55 + 59 56 patch -R -p1 < ../patch-x.y.z 60 57 61 58 62 - How do I feed a patch/diff file to `patch'? 63 - --- 64 - This (as usual with Linux and other UNIX like operating systems) can be 59 + How do I feed a patch/diff file to ``patch``? 60 + ============================================= 61 + 62 + This (as usual with Linux and other UNIX like operating systems) can be 65 63 done in several different ways. 64 + 66 65 In all the examples below I feed the file (in uncompressed form) to patch 67 - via stdin using the following syntax: 66 + via stdin using the following syntax:: 67 + 68 68 patch -p1 < path/to/patch-x.y.z 69 69 70 70 If you just want to be able to follow the examples below and don't want to ··· 79 65 section here. 80 66 81 67 Patch can also get the name of the file to use via the -i argument, like 82 - this: 68 + this:: 69 + 83 70 patch -p1 -i path/to/patch-x.y.z 84 71 85 - If your patch file is compressed with gzip or bzip2 and you don't want to 72 + If your patch file is compressed with gzip or xz and you don't want to 86 73 uncompress it before applying it, then you can feed it to patch like this 87 - instead: 88 - zcat path/to/patch-x.y.z.gz | patch -p1 89 - bzcat path/to/patch-x.y.z.bz2 | patch -p1 74 + instead:: 75 + 76 + xzcat path/to/patch-x.y.z.xz | patch -p1 77 + bzcat path/to/patch-x.y.z.gz | patch -p1 90 78 91 79 If you wish to uncompress the patch file by hand first before applying it 92 80 (what I assume you've done in the examples below), then you simply run 93 - gunzip or bunzip2 on the file -- like this: 81 + gunzip or xz on the file -- like this:: 82 + 94 83 gunzip patch-x.y.z.gz 95 - bunzip2 patch-x.y.z.bz2 84 + xz -d patch-x.y.z.xz 96 85 97 86 Which will leave you with a plain text patch-x.y.z file that you can feed to 98 - patch via stdin or the -i argument, as you prefer. 87 + patch via stdin or the ``-i`` argument, as you prefer. 99 88 100 - A few other nice arguments for patch are -s which causes patch to be silent 89 + A few other nice arguments for patch are ``-s`` which causes patch to be silent 101 90 except for errors which is nice to prevent errors from scrolling out of the 102 - screen too fast, and --dry-run which causes patch to just print a listing of 103 - what would happen, but doesn't actually make any changes. Finally --verbose 91 + screen too fast, and ``--dry-run`` which causes patch to just print a listing of 92 + what would happen, but doesn't actually make any changes. Finally ``--verbose`` 104 93 tells patch to print more information about the work being done. 105 94 106 95 107 96 Common errors when patching 108 - --- 109 - When patch applies a patch file it attempts to verify the sanity of the 97 + =========================== 98 + 99 + When patch applies a patch file it attempts to verify the sanity of the 110 100 file in different ways. 101 + 111 102 Checking that the file looks like a valid patch file and checking the code 112 103 around the bits being modified matches the context provided in the patch are 113 104 just two of the basic sanity checks patch does. ··· 130 111 usually adjust the line numbers and apply the patch. 131 112 132 113 Whenever patch applies a patch that it had to modify a bit to make it fit 133 - it'll tell you about it by saying the patch applied with 'fuzz'. 114 + it'll tell you about it by saying the patch applied with **fuzz**. 134 115 You should be wary of such changes since even though patch probably got it 135 116 right it doesn't /always/ get it right, and the result will sometimes be 136 117 wrong. 137 118 138 119 When patch encounters a change that it can't fix up with fuzz it rejects it 139 - outright and leaves a file with a .rej extension (a reject file). You can 120 + outright and leaves a file with a ``.rej`` extension (a reject file). You can 140 121 read this file to see exactly what change couldn't be applied, so you can 141 122 go fix it up by hand if you wish. 142 123 ··· 151 132 152 133 Let's look a bit more at some of the messages patch can produce. 153 134 154 - If patch stops and presents a "File to patch:" prompt, then patch could not 135 + If patch stops and presents a ``File to patch:`` prompt, then patch could not 155 136 find a file to be patched. Most likely you forgot to specify -p1 or you are 156 137 in the wrong directory. Less often, you'll find patches that need to be 157 - applied with -p0 instead of -p1 (reading the patch file should reveal if 138 + applied with ``-p0`` instead of ``-p1`` (reading the patch file should reveal if 158 139 this is the case -- if so, then this is an error by the person who created 159 140 the patch but is not fatal). 160 141 161 - If you get "Hunk #2 succeeded at 1887 with fuzz 2 (offset 7 lines)." or a 142 + If you get ``Hunk #2 succeeded at 1887 with fuzz 2 (offset 7 lines).`` or a 162 143 message similar to that, then it means that patch had to adjust the location 163 144 of the change (in this example it needed to move 7 lines from where it 164 145 expected to make the change to make it fit). 146 + 165 147 The resulting file may or may not be OK, depending on the reason the file 166 148 was different than expected. 149 + 167 150 This often happens if you try to apply a patch that was generated against a 168 151 different kernel version than the one you are trying to patch. 169 152 170 - If you get a message like "Hunk #3 FAILED at 2387.", then it means that the 153 + If you get a message like ``Hunk #3 FAILED at 2387.``, then it means that the 171 154 patch could not be applied correctly and the patch program was unable to 172 - fuzz its way through. This will generate a .rej file with the change that 173 - caused the patch to fail and also a .orig file showing you the original 155 + fuzz its way through. This will generate a ``.rej`` file with the change that 156 + caused the patch to fail and also a ``.orig`` file showing you the original 174 157 content that couldn't be changed. 175 158 176 - If you get "Reversed (or previously applied) patch detected! Assume -R? [n]" 159 + If you get ``Reversed (or previously applied) patch detected! Assume -R? [n]`` 177 160 then patch detected that the change contained in the patch seems to have 178 161 already been made. 162 + 179 163 If you actually did apply this patch previously and you just re-applied it 180 164 in error, then just say [n]o and abort this patch. If you applied this patch 181 165 previously and actually intended to revert it, but forgot to specify -R, 182 - then you can say [y]es here to make patch revert it for you. 166 + then you can say [**y**]es here to make patch revert it for you. 167 + 183 168 This can also happen if the creator of the patch reversed the source and 184 169 destination directories when creating the patch, and in that case reverting 185 170 the patch will in fact apply it. 186 171 187 - A message similar to "patch: **** unexpected end of file in patch" or "patch 188 - unexpectedly ends in middle of line" means that patch could make no sense of 189 - the file you fed to it. Either your download is broken, you tried to feed 190 - patch a compressed patch file without uncompressing it first, or the patch 172 + A message similar to ``patch: **** unexpected end of file in patch`` or 173 + ``patch unexpectedly ends in middle of line`` means that patch could make no 174 + sense of the file you fed to it. Either your download is broken, you tried to 175 + feed patch a compressed patch file without uncompressing it first, or the patch 191 176 file that you are using has been mangled by a mail client or mail transfer 192 177 agent along the way somewhere, e.g., by splitting a long line into two lines. 193 178 Often these warnings can easily be fixed by joining (concatenating) the ··· 205 182 wish to apply. 206 183 207 184 208 - Are there any alternatives to `patch'? 209 - --- 210 - Yes there are alternatives. 185 + Are there any alternatives to ``patch``? 186 + ======================================== 211 187 212 - You can use the `interdiff' program (http://cyberelk.net/tim/patchutils/) to 188 + 189 + Yes there are alternatives. 190 + 191 + You can use the ``interdiff`` program (http://cyberelk.net/tim/patchutils/) to 213 192 generate a patch representing the differences between two patches and then 214 193 apply the result. 215 - This will let you move from something like 2.6.12.2 to 2.6.12.3 in a single 194 + 195 + This will let you move from something like 4.7.2 to 4.7.3 in a single 216 196 step. The -z flag to interdiff will even let you feed it patches in gzip or 217 197 bzip2 compressed form directly without the use of zcat or bzcat or manual 218 198 decompression. 219 199 220 - Here's how you'd go from 2.6.12.2 to 2.6.12.3 in a single step: 221 - interdiff -z ../patch-2.6.12.2.bz2 ../patch-2.6.12.3.gz | patch -p1 200 + Here's how you'd go from 4.7.2 to 4.7.3 in a single step:: 201 + 202 + interdiff -z ../patch-4.7.2.gz ../patch-4.7.3.gz | patch -p1 222 203 223 204 Although interdiff may save you a step or two you are generally advised to 224 205 do the additional steps since interdiff can get things wrong in some cases. 225 206 226 - Another alternative is `ketchup', which is a python script for automatic 207 + Another alternative is ``ketchup``, which is a python script for automatic 227 208 downloading and applying of patches (http://www.selenic.com/ketchup/). 228 209 229 - Other nice tools are diffstat, which shows a summary of changes made by a 210 + Other nice tools are diffstat, which shows a summary of changes made by a 230 211 patch; lsdiff, which displays a short listing of affected files in a patch 231 212 file, along with (optionally) the line numbers of the start of each patch; 232 213 and grepdiff, which displays a list of the files modified by a patch where ··· 238 211 239 212 240 213 Where can I download the patches? 241 - --- 242 - The patches are available at http://kernel.org/ 214 + ================================= 215 + 216 + The patches are available at http://kernel.org/ 243 217 Most recent patches are linked from the front page, but they also have 244 218 specific homes. 245 219 246 - The 2.6.x.y (-stable) and 2.6.x patches live at 247 - ftp://ftp.kernel.org/pub/linux/kernel/v2.6/ 220 + The 4.x.y (-stable) and 4.x patches live at 221 + 222 + ftp://ftp.kernel.org/pub/linux/kernel/v4.x/ 248 223 249 224 The -rc patches live at 250 - ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing/ 251 225 252 - The -git patches live at 253 - ftp://ftp.kernel.org/pub/linux/kernel/v2.6/snapshots/ 226 + ftp://ftp.kernel.org/pub/linux/kernel/v4.x/testing/ 254 227 255 - The -mm kernels live at 256 - ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/ 257 - 258 - In place of ftp.kernel.org you can use ftp.cc.kernel.org, where cc is a 228 + In place of ``ftp.kernel.org`` you can use ``ftp.cc.kernel.org``, where cc is a 259 229 country code. This way you'll be downloading from a mirror site that's most 260 230 likely geographically closer to you, resulting in faster downloads for you, 261 231 less bandwidth used globally and less load on the main kernel.org servers -- 262 232 these are good things, so do use mirrors when possible. 263 233 264 234 265 - The 2.6.x kernels 266 - --- 267 - These are the base stable releases released by Linus. The highest numbered 235 + The 4.x kernels 236 + =============== 237 + 238 + These are the base stable releases released by Linus. The highest numbered 268 239 release is the most recent. 269 240 270 241 If regressions or other serious flaws are found, then a -stable fix patch 271 - will be released (see below) on top of this base. Once a new 2.6.x base 242 + will be released (see below) on top of this base. Once a new 4.x base 272 243 kernel is released, a patch is made available that is a delta between the 273 - previous 2.6.x kernel and the new one. 244 + previous 4.x kernel and the new one. 274 245 275 - To apply a patch moving from 2.6.11 to 2.6.12, you'd do the following (note 276 - that such patches do *NOT* apply on top of 2.6.x.y kernels but on top of the 277 - base 2.6.x kernel -- if you need to move from 2.6.x.y to 2.6.x+1 you need to 278 - first revert the 2.6.x.y patch). 246 + To apply a patch moving from 4.6 to 4.7, you'd do the following (note 247 + that such patches do **NOT** apply on top of 4.x.y kernels but on top of the 248 + base 4.x kernel -- if you need to move from 4.x.y to 4.x+1 you need to 249 + first revert the 4.x.y patch). 279 250 280 - Here are some examples: 251 + Here are some examples:: 281 252 282 - # moving from 2.6.11 to 2.6.12 283 - $ cd ~/linux-2.6.11 # change to kernel source dir 284 - $ patch -p1 < ../patch-2.6.12 # apply the 2.6.12 patch 285 - $ cd .. 286 - $ mv linux-2.6.11 linux-2.6.12 # rename source dir 253 + # moving from 4.6 to 4.7 287 254 288 - # moving from 2.6.11.1 to 2.6.12 289 - $ cd ~/linux-2.6.11.1 # change to kernel source dir 290 - $ patch -p1 -R < ../patch-2.6.11.1 # revert the 2.6.11.1 patch 291 - # source dir is now 2.6.11 292 - $ patch -p1 < ../patch-2.6.12 # apply new 2.6.12 patch 293 - $ cd .. 294 - $ mv linux-2.6.11.1 linux-2.6.12 # rename source dir 255 + $ cd ~/linux-4.6 # change to kernel source dir 256 + $ patch -p1 < ../patch-4.7 # apply the 4.7 patch 257 + $ cd .. 258 + $ mv linux-4.6 linux-4.7 # rename source dir 259 + 260 + # moving from 4.6.1 to 4.7 261 + 262 + $ cd ~/linux-4.6.1 # change to kernel source dir 263 + $ patch -p1 -R < ../patch-4.6.1 # revert the 4.6.1 patch 264 + # source dir is now 4.6 265 + $ patch -p1 < ../patch-4.7 # apply new 4.7 patch 266 + $ cd .. 267 + $ mv linux-4.6.1 linux-4.7 # rename source dir 295 268 296 269 297 - The 2.6.x.y kernels 298 - --- 299 - Kernels with 4-digit versions are -stable kernels. They contain small(ish) 270 + The 4.x.y kernels 271 + ================= 272 + 273 + Kernels with 3-digit versions are -stable kernels. They contain small(ish) 300 274 critical fixes for security problems or significant regressions discovered 301 - in a given 2.6.x kernel. 275 + in a given 4.x kernel. 302 276 303 277 This is the recommended branch for users who want the most recent stable 304 278 kernel and are not interested in helping test development/experimental 305 279 versions. 306 280 307 - If no 2.6.x.y kernel is available, then the highest numbered 2.6.x kernel is 281 + If no 4.x.y kernel is available, then the highest numbered 4.x kernel is 308 282 the current stable kernel. 309 283 310 - note: the -stable team usually do make incremental patches available as well 284 + .. note:: 285 + 286 + The -stable team usually do make incremental patches available as well 311 287 as patches against the latest mainline release, but I only cover the 312 288 non-incremental ones below. The incremental ones can be found at 313 - ftp://ftp.kernel.org/pub/linux/kernel/v2.6/incr/ 289 + ftp://ftp.kernel.org/pub/linux/kernel/v4.x/incr/ 314 290 315 - These patches are not incremental, meaning that for example the 2.6.12.3 316 - patch does not apply on top of the 2.6.12.2 kernel source, but rather on top 317 - of the base 2.6.12 kernel source . 318 - So, in order to apply the 2.6.12.3 patch to your existing 2.6.12.2 kernel 319 - source you have to first back out the 2.6.12.2 patch (so you are left with a 320 - base 2.6.12 kernel source) and then apply the new 2.6.12.3 patch. 291 + These patches are not incremental, meaning that for example the 4.7.3 292 + patch does not apply on top of the 4.7.2 kernel source, but rather on top 293 + of the base 4.7 kernel source. 321 294 322 - Here's a small example: 295 + So, in order to apply the 4.7.3 patch to your existing 4.7.2 kernel 296 + source you have to first back out the 4.7.2 patch (so you are left with a 297 + base 4.7 kernel source) and then apply the new 4.7.3 patch. 323 298 324 - $ cd ~/linux-2.6.12.2 # change into the kernel source dir 325 - $ patch -p1 -R < ../patch-2.6.12.2 # revert the 2.6.12.2 patch 326 - $ patch -p1 < ../patch-2.6.12.3 # apply the new 2.6.12.3 patch 327 - $ cd .. 328 - $ mv linux-2.6.12.2 linux-2.6.12.3 # rename the kernel source dir 299 + Here's a small example:: 329 300 301 + $ cd ~/linux-4.7.2 # change to the kernel source dir 302 + $ patch -p1 -R < ../patch-4.7.2 # revert the 4.7.2 patch 303 + $ patch -p1 < ../patch-4.7.3 # apply the new 4.7.3 patch 304 + $ cd .. 305 + $ mv linux-4.7.2 linux-4.7.3 # rename the kernel source dir 330 306 331 307 The -rc kernels 332 - --- 333 - These are release-candidate kernels. These are development kernels released 308 + =============== 309 + 310 + These are release-candidate kernels. These are development kernels released 334 311 by Linus whenever he deems the current git (the kernel's source management 335 312 tool) tree to be in a reasonably sane state adequate for testing. 336 313 ··· 348 317 development kernels but do not want to run some of the really experimental 349 318 stuff (such people should see the sections about -git and -mm kernels below). 350 319 351 - The -rc patches are not incremental, they apply to a base 2.6.x kernel, just 352 - like the 2.6.x.y patches described above. The kernel version before the -rcN 320 + The -rc patches are not incremental, they apply to a base 4.x kernel, just 321 + like the 4.x.y patches described above. The kernel version before the -rcN 353 322 suffix denotes the version of the kernel that this -rc kernel will eventually 354 323 turn into. 355 - So, 2.6.13-rc5 means that this is the fifth release candidate for the 2.6.13 356 - kernel and the patch should be applied on top of the 2.6.12 kernel source. 357 324 358 - Here are 3 examples of how to apply these patches: 325 + So, 4.8-rc5 means that this is the fifth release candidate for the 4.8 326 + kernel and the patch should be applied on top of the 4.7 kernel source. 359 327 360 - # first an example of moving from 2.6.12 to 2.6.13-rc3 361 - $ cd ~/linux-2.6.12 # change into the 2.6.12 source dir 362 - $ patch -p1 < ../patch-2.6.13-rc3 # apply the 2.6.13-rc3 patch 363 - $ cd .. 364 - $ mv linux-2.6.12 linux-2.6.13-rc3 # rename the source dir 328 + Here are 3 examples of how to apply these patches:: 365 329 366 - # now let's move from 2.6.13-rc3 to 2.6.13-rc5 367 - $ cd ~/linux-2.6.13-rc3 # change into the 2.6.13-rc3 dir 368 - $ patch -p1 -R < ../patch-2.6.13-rc3 # revert the 2.6.13-rc3 patch 369 - $ patch -p1 < ../patch-2.6.13-rc5 # apply the new 2.6.13-rc5 patch 370 - $ cd .. 371 - $ mv linux-2.6.13-rc3 linux-2.6.13-rc5 # rename the source dir 330 + # first an example of moving from 4.7 to 4.8-rc3 372 331 373 - # finally let's try and move from 2.6.12.3 to 2.6.13-rc5 374 - $ cd ~/linux-2.6.12.3 # change to the kernel source dir 375 - $ patch -p1 -R < ../patch-2.6.12.3 # revert the 2.6.12.3 patch 376 - $ patch -p1 < ../patch-2.6.13-rc5 # apply new 2.6.13-rc5 patch 377 - $ cd .. 378 - $ mv linux-2.6.12.3 linux-2.6.13-rc5 # rename the kernel source dir 332 + $ cd ~/linux-4.7 # change to the 4.7 source dir 333 + $ patch -p1 < ../patch-4.8-rc3 # apply the 4.8-rc3 patch 334 + $ cd .. 335 + $ mv linux-4.7 linux-4.8-rc3 # rename the source dir 336 + 337 + # now let's move from 4.8-rc3 to 4.8-rc5 338 + 339 + $ cd ~/linux-4.8-rc3 # change to the 4.8-rc3 dir 340 + $ patch -p1 -R < ../patch-4.8-rc3 # revert the 4.8-rc3 patch 341 + $ patch -p1 < ../patch-4.8-rc5 # apply the new 4.8-rc5 patch 342 + $ cd .. 343 + $ mv linux-4.8-rc3 linux-4.8-rc5 # rename the source dir 344 + 345 + # finally let's try and move from 4.7.3 to 4.8-rc5 346 + 347 + $ cd ~/linux-4.7.3 # change to the kernel source dir 348 + $ patch -p1 -R < ../patch-4.7.3 # revert the 4.7.3 patch 349 + $ patch -p1 < ../patch-4.8-rc5 # apply new 4.8-rc5 patch 350 + $ cd .. 351 + $ mv linux-4.7.3 linux-4.8-rc5 # rename the kernel source dir 379 352 380 353 381 354 The -git kernels 382 - --- 383 - These are daily snapshots of Linus' kernel tree (managed in a git 355 + ================ 356 + 357 + These are daily snapshots of Linus' kernel tree (managed in a git 384 358 repository, hence the name). 385 359 386 360 These patches are usually released daily and represent the current state of ··· 393 357 generated automatically without even a cursory glance to see if they are 394 358 sane. 395 359 396 - -git patches are not incremental and apply either to a base 2.6.x kernel or 397 - a base 2.6.x-rc kernel -- you can see which from their name. 398 - A patch named 2.6.12-git1 applies to the 2.6.12 kernel source and a patch 399 - named 2.6.13-rc3-git2 applies to the source of the 2.6.13-rc3 kernel. 360 + -git patches are not incremental and apply either to a base 4.x kernel or 361 + a base 4.x-rc kernel -- you can see which from their name. 362 + A patch named 4.7-git1 applies to the 4.7 kernel source and a patch 363 + named 4.8-rc3-git2 applies to the source of the 4.8-rc3 kernel. 400 364 401 - Here are some examples of how to apply these patches: 365 + Here are some examples of how to apply these patches:: 402 366 403 - # moving from 2.6.12 to 2.6.12-git1 404 - $ cd ~/linux-2.6.12 # change to the kernel source dir 405 - $ patch -p1 < ../patch-2.6.12-git1 # apply the 2.6.12-git1 patch 406 - $ cd .. 407 - $ mv linux-2.6.12 linux-2.6.12-git1 # rename the kernel source dir 367 + # moving from 4.7 to 4.7-git1 408 368 409 - # moving from 2.6.12-git1 to 2.6.13-rc2-git3 410 - $ cd ~/linux-2.6.12-git1 # change to the kernel source dir 411 - $ patch -p1 -R < ../patch-2.6.12-git1 # revert the 2.6.12-git1 patch 412 - # we now have a 2.6.12 kernel 413 - $ patch -p1 < ../patch-2.6.13-rc2 # apply the 2.6.13-rc2 patch 414 - # the kernel is now 2.6.13-rc2 415 - $ patch -p1 < ../patch-2.6.13-rc2-git3 # apply the 2.6.13-rc2-git3 patch 416 - # the kernel is now 2.6.13-rc2-git3 417 - $ cd .. 418 - $ mv linux-2.6.12-git1 linux-2.6.13-rc2-git3 # rename source dir 369 + $ cd ~/linux-4.7 # change to the kernel source dir 370 + $ patch -p1 < ../patch-4.7-git1 # apply the 4.7-git1 patch 371 + $ cd .. 372 + $ mv linux-4.7 linux-4.7-git1 # rename the kernel source dir 373 + 374 + # moving from 4.7-git1 to 4.8-rc2-git3 375 + 376 + $ cd ~/linux-4.7-git1 # change to the kernel source dir 377 + $ patch -p1 -R < ../patch-4.7-git1 # revert the 4.7-git1 patch 378 + # we now have a 4.7 kernel 379 + $ patch -p1 < ../patch-4.8-rc2 # apply the 4.8-rc2 patch 380 + # the kernel is now 4.8-rc2 381 + $ patch -p1 < ../patch-4.8-rc2-git3 # apply the 4.8-rc2-git3 patch 382 + # the kernel is now 4.8-rc2-git3 383 + $ cd .. 384 + $ mv linux-4.7-git1 linux-4.8-rc2-git3 # rename source dir 419 385 420 386 421 - The -mm kernels 422 - --- 423 - These are experimental kernels released by Andrew Morton. 387 + The -mm patches and the linux-next tree 388 + ======================================= 424 389 425 - The -mm tree serves as a sort of proving ground for new features and other 426 - experimental patches. 427 - Once a patch has proved its worth in -mm for a while Andrew pushes it on to 428 - Linus for inclusion in mainline. 390 + The -mm patches are experimental patches released by Andrew Morton. 429 391 430 - Although it's encouraged that patches flow to Linus via the -mm tree, this 431 - is not always enforced. 432 - Subsystem maintainers (or individuals) sometimes push their patches directly 433 - to Linus, even though (or after) they have been merged and tested in -mm (or 434 - sometimes even without prior testing in -mm). 392 + In the past, -mm tree were used to also test subsystem patches, but this 393 + function is now done via the 394 + :ref:`linux-next <https://www.kernel.org/doc/man-pages/linux-next.html>` 395 + tree. The Subsystem maintainers push their patches first to linux-next, 396 + and, during the merge window, sends them directly to Linus. 435 397 436 - You should generally strive to get your patches into mainline via -mm to 437 - ensure maximum testing. 398 + The -mm patches serve as a sort of proving ground for new features and other 399 + experimental patches that aren't merged via a subsystem tree. 400 + Once such patches has proved its worth in -mm for a while Andrew pushes 401 + it on to Linus for inclusion in mainline. 438 402 439 - This branch is in constant flux and contains many experimental features, a 403 + The linux-next tree is daily updated, and includes the -mm patches. 404 + Both are in constant flux and contains many experimental features, a 440 405 lot of debugging patches not appropriate for mainline etc., and is the most 441 406 experimental of the branches described in this document. 442 407 443 - These kernels are not appropriate for use on systems that are supposed to be 408 + These patches are not appropriate for use on systems that are supposed to be 444 409 stable and they are more risky to run than any of the other branches (make 445 410 sure you have up-to-date backups -- that goes for any experimental kernel but 446 - even more so for -mm kernels). 411 + even more so for -mm patches or using a Kernel from the linux-next tree). 447 412 448 - These kernels in addition to all the other experimental patches they contain 449 - usually also contain any changes in the mainline -git kernels available at 450 - the time of release. 413 + Testing of -mm patches and linux-next is greatly appreciated since the whole 414 + point of those are to weed out regressions, crashes, data corruption bugs, 415 + build breakage (and any other bug in general) before changes are merged into 416 + the more stable mainline Linus tree. 451 417 452 - Testing of -mm kernels is greatly appreciated since the whole point of the 453 - tree is to weed out regressions, crashes, data corruption bugs, build 454 - breakage (and any other bug in general) before changes are merged into the 455 - more stable mainline Linus tree. 456 - But testers of -mm should be aware that breakage in this tree is more common 457 - than in any other tree. 458 - 459 - The -mm kernels are not released on a fixed schedule, but usually a few -mm 460 - kernels are released in between each -rc kernel (1 to 3 is common). 461 - The -mm kernels apply to either a base 2.6.x kernel (when no -rc kernels 462 - have been released yet) or to a Linus -rc kernel. 463 - 464 - Here are some examples of applying the -mm patches: 465 - 466 - # moving from 2.6.12 to 2.6.12-mm1 467 - $ cd ~/linux-2.6.12 # change to the 2.6.12 source dir 468 - $ patch -p1 < ../2.6.12-mm1 # apply the 2.6.12-mm1 patch 469 - $ cd .. 470 - $ mv linux-2.6.12 linux-2.6.12-mm1 # rename the source appropriately 471 - 472 - # moving from 2.6.12-mm1 to 2.6.13-rc3-mm3 473 - $ cd ~/linux-2.6.12-mm1 474 - $ patch -p1 -R < ../2.6.12-mm1 # revert the 2.6.12-mm1 patch 475 - # we now have a 2.6.12 source 476 - $ patch -p1 < ../patch-2.6.13-rc3 # apply the 2.6.13-rc3 patch 477 - # we now have a 2.6.13-rc3 source 478 - $ patch -p1 < ../2.6.13-rc3-mm3 # apply the 2.6.13-rc3-mm3 patch 479 - $ cd .. 480 - $ mv linux-2.6.12-mm1 linux-2.6.13-rc3-mm3 # rename the source dir 418 + But testers of -mm and linux-next should be aware that breakages are 419 + more common than in any other tree. 481 420 482 421 483 422 This concludes this list of explanations of the various kernel trees.
+10 -1
Documentation/arm/sunxi/README
··· 73 73 * Octa ARM Cortex-A7 based SoCs 74 74 - Allwinner A83T 75 75 + Datasheet 76 - http://dl.linux-sunxi.org/A83T/A83T_datasheet_Revision_1.1.pdf 76 + https://github.com/allwinner-zh/documents/raw/master/A83T/A83T_Datasheet_v1.3_20150510.pdf 77 + + User Manual 78 + https://github.com/allwinner-zh/documents/raw/master/A83T/A83T_User_Manual_v1.5.1_20150513.pdf 79 + 80 + * Quad ARM Cortex-A53 based SoCs 81 + - Allwinner A64 82 + + Datasheet 83 + http://dl.linux-sunxi.org/A64/A64_Datasheet_V1.1.pdf 84 + + User Manual 85 + http://dl.linux-sunxi.org/A64/Allwinner%20A64%20User%20Manual%20v1.0.pdf
+22 -20
Documentation/clk.txt
··· 31 31 hardware-specific bits for the hypothetical "foo" hardware. 32 32 33 33 Tying the two halves of this interface together is struct clk_hw, which 34 - is defined in struct clk_foo and pointed to within struct clk. This 34 + is defined in struct clk_foo and pointed to within struct clk_core. This 35 35 allows for easy navigation between the two discrete halves of the common 36 36 clock interface. 37 37 38 38 Part 2 - common data structures and api 39 39 40 - Below is the common struct clk definition from 41 - include/linux/clk-private.h, modified for brevity: 40 + Below is the common struct clk_core definition from 41 + drivers/clk/clk.c, modified for brevity: 42 42 43 - struct clk { 43 + struct clk_core { 44 44 const char *name; 45 45 const struct clk_ops *ops; 46 46 struct clk_hw *hw; 47 - char **parent_names; 48 - struct clk **parents; 49 - struct clk *parent; 50 - struct hlist_head children; 51 - struct hlist_node child_node; 47 + struct module *owner; 48 + struct clk_core *parent; 49 + const char **parent_names; 50 + struct clk_core **parents; 51 + u8 num_parents; 52 + u8 new_parent_index; 52 53 ... 53 54 }; 54 55 ··· 57 56 api itself defines several driver-facing functions which operate on 58 57 struct clk. That api is documented in include/linux/clk.h. 59 58 60 - Platforms and devices utilizing the common struct clk use the struct 61 - clk_ops pointer in struct clk to perform the hardware-specific parts of 62 - the operations defined in clk.h: 59 + Platforms and devices utilizing the common struct clk_core use the struct 60 + clk_ops pointer in struct clk_core to perform the hardware-specific parts of 61 + the operations defined in clk-provider.h: 63 62 64 63 struct clk_ops { 65 64 int (*prepare)(struct clk_hw *hw); 66 65 void (*unprepare)(struct clk_hw *hw); 66 + int (*is_prepared)(struct clk_hw *hw); 67 + void (*unprepare_unused)(struct clk_hw *hw); 67 68 int (*enable)(struct clk_hw *hw); 68 69 void (*disable)(struct clk_hw *hw); 69 70 int (*is_enabled)(struct clk_hw *hw); 71 + void (*disable_unused)(struct clk_hw *hw); 70 72 unsigned long (*recalc_rate)(struct clk_hw *hw, 71 73 unsigned long parent_rate); 72 74 long (*round_rate)(struct clk_hw *hw, ··· 88 84 u8 index); 89 85 unsigned long (*recalc_accuracy)(struct clk_hw *hw, 90 86 unsigned long parent_accuracy); 87 + int (*get_phase)(struct clk_hw *hw); 88 + int (*set_phase)(struct clk_hw *hw, int degrees); 91 89 void (*init)(struct clk_hw *hw); 92 90 int (*debug_init)(struct clk_hw *hw, 93 91 struct dentry *dentry); ··· 97 91 98 92 Part 3 - hardware clk implementations 99 93 100 - The strength of the common struct clk comes from its .ops and .hw pointers 94 + The strength of the common struct clk_core comes from its .ops and .hw pointers 101 95 which abstract the details of struct clk from the hardware-specific bits, and 102 96 vice versa. To illustrate consider the simple gateable clk implementation in 103 97 drivers/clk/clk-gate.c: ··· 113 107 knowledge about which register and bit controls this clk's gating. 114 108 Nothing about clock topology or accounting, such as enable_count or 115 109 notifier_count, is needed here. That is all handled by the common 116 - framework code and struct clk. 110 + framework code and struct clk_core. 117 111 118 112 Let's walk through enabling this clk from driver code: 119 113 ··· 145 139 146 140 Note that to_clk_gate is defined as: 147 141 148 - #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, clk) 142 + #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) 149 143 150 144 This pattern of abstraction is used for every clock hardware 151 145 representation. 152 146 153 147 Part 4 - supporting your own clk hardware 154 148 155 - When implementing support for a new type of clock it only necessary to 149 + When implementing support for a new type of clock it is only necessary to 156 150 include the following header: 157 151 158 152 #include <linux/clk-provider.h> 159 - 160 - include/linux/clk.h is included within that header and clk-private.h 161 - must never be included from the code which implements the operations for 162 - a clock. More on that below in Part 5. 163 153 164 154 To construct a clk hardware structure for your platform you must define 165 155 the following:
+190 -169
Documentation/coccinelle.txt Documentation/dev-tools/coccinelle.rst
··· 1 - Copyright 2010 Nicolas Palix <npalix@diku.dk> 2 - Copyright 2010 Julia Lawall <julia@diku.dk> 3 - Copyright 2010 Gilles Muller <Gilles.Muller@lip6.fr> 1 + .. Copyright 2010 Nicolas Palix <npalix@diku.dk> 2 + .. Copyright 2010 Julia Lawall <julia@diku.dk> 3 + .. Copyright 2010 Gilles Muller <Gilles.Muller@lip6.fr> 4 4 5 + .. highlight:: none 5 6 6 - Getting Coccinelle 7 - ~~~~~~~~~~~~~~~~~~~~ 7 + Coccinelle 8 + ========== 9 + 10 + Coccinelle is a tool for pattern matching and text transformation that has 11 + many uses in kernel development, including the application of complex, 12 + tree-wide patches and detection of problematic programming patterns. 13 + 14 + Getting Coccinelle 15 + ------------------- 8 16 9 17 The semantic patches included in the kernel use features and options 10 18 which are provided by Coccinelle version 1.0.0-rc11 and above. ··· 30 22 - NetBSD 31 23 - FreeBSD 32 24 33 - 34 25 You can get the latest version released from the Coccinelle homepage at 35 26 http://coccinelle.lip6.fr/ 36 27 37 28 Information and tips about Coccinelle are also provided on the wiki 38 29 pages at http://cocci.ekstranet.diku.dk/wiki/doku.php 39 30 40 - Once you have it, run the following command: 31 + Once you have it, run the following command:: 41 32 42 33 ./configure 43 34 make 44 35 45 - as a regular user, and install it with 36 + as a regular user, and install it with:: 46 37 47 38 sudo make install 48 39 49 - Supplemental documentation 50 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 40 + Supplemental documentation 41 + --------------------------- 51 42 52 43 For supplemental documentation refer to the wiki: 53 44 ··· 54 47 55 48 The wiki documentation always refers to the linux-next version of the script. 56 49 57 - Using Coccinelle on the Linux kernel 58 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 50 + Using Coccinelle on the Linux kernel 51 + ------------------------------------ 59 52 60 53 A Coccinelle-specific target is defined in the top level 61 - Makefile. This target is named 'coccicheck' and calls the 'coccicheck' 62 - front-end in the 'scripts' directory. 54 + Makefile. This target is named ``coccicheck`` and calls the ``coccicheck`` 55 + front-end in the ``scripts`` directory. 63 56 64 - Four basic modes are defined: patch, report, context, and org. The mode to 65 - use is specified by setting the MODE variable with 'MODE=<mode>'. 57 + Four basic modes are defined: ``patch``, ``report``, ``context``, and 58 + ``org``. The mode to use is specified by setting the MODE variable with 59 + ``MODE=<mode>``. 66 60 67 - 'patch' proposes a fix, when possible. 61 + - ``patch`` proposes a fix, when possible. 68 62 69 - 'report' generates a list in the following format: 63 + - ``report`` generates a list in the following format: 70 64 file:line:column-column: message 71 65 72 - 'context' highlights lines of interest and their context in a 73 - diff-like style.Lines of interest are indicated with '-'. 66 + - ``context`` highlights lines of interest and their context in a 67 + diff-like style.Lines of interest are indicated with ``-``. 74 68 75 - 'org' generates a report in the Org mode format of Emacs. 69 + - ``org`` generates a report in the Org mode format of Emacs. 76 70 77 71 Note that not all semantic patches implement all modes. For easy use 78 72 of Coccinelle, the default mode is "report". 79 73 80 74 Two other modes provide some common combinations of these modes. 81 75 82 - 'chain' tries the previous modes in the order above until one succeeds. 76 + - ``chain`` tries the previous modes in the order above until one succeeds. 83 77 84 - 'rep+ctxt' runs successively the report mode and the context mode. 85 - It should be used with the C option (described later) 86 - which checks the code on a file basis. 78 + - ``rep+ctxt`` runs successively the report mode and the context mode. 79 + It should be used with the C option (described later) 80 + which checks the code on a file basis. 87 81 88 - Examples: 89 - To make a report for every semantic patch, run the following command: 82 + Examples 83 + ~~~~~~~~ 84 + 85 + To make a report for every semantic patch, run the following command:: 90 86 91 87 make coccicheck MODE=report 92 88 93 - To produce patches, run: 89 + To produce patches, run:: 94 90 95 91 make coccicheck MODE=patch 96 92 97 93 98 94 The coccicheck target applies every semantic patch available in the 99 - sub-directories of 'scripts/coccinelle' to the entire Linux kernel. 95 + sub-directories of ``scripts/coccinelle`` to the entire Linux kernel. 100 96 101 97 For each semantic patch, a commit message is proposed. It gives a 102 98 description of the problem being checked by the semantic patch, and ··· 109 99 positives. Thus, reports must be carefully checked, and patches 110 100 reviewed. 111 101 112 - To enable verbose messages set the V= variable, for example: 102 + To enable verbose messages set the V= variable, for example:: 113 103 114 104 make coccicheck MODE=report V=1 115 105 116 - Coccinelle parallelization 117 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 106 + Coccinelle parallelization 107 + --------------------------- 118 108 119 109 By default, coccicheck tries to run as parallel as possible. To change 120 - the parallelism, set the J= variable. For example, to run across 4 CPUs: 110 + the parallelism, set the J= variable. For example, to run across 4 CPUs:: 121 111 122 112 make coccicheck MODE=report J=4 123 113 ··· 125 115 if support for this is detected you will benefit from parmap parallelization. 126 116 127 117 When parmap is enabled coccicheck will enable dynamic load balancing by using 128 - '--chunksize 1' argument, this ensures we keep feeding threads with work 118 + ``--chunksize 1`` argument, this ensures we keep feeding threads with work 129 119 one by one, so that we avoid the situation where most work gets done by only 130 120 a few threads. With dynamic load balancing, if a thread finishes early we keep 131 121 feeding it more work. 132 122 133 123 When parmap is enabled, if an error occurs in Coccinelle, this error 134 - value is propagated back, the return value of the 'make coccicheck' 124 + value is propagated back, the return value of the ``make coccicheck`` 135 125 captures this return value. 136 126 137 - Using Coccinelle with a single semantic patch 138 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 + Using Coccinelle with a single semantic patch 128 + --------------------------------------------- 139 129 140 130 The optional make variable COCCI can be used to check a single 141 131 semantic patch. In that case, the variable must be initialized with 142 132 the name of the semantic patch to apply. 143 133 144 - For instance: 134 + For instance:: 145 135 146 136 make coccicheck COCCI=<my_SP.cocci> MODE=patch 147 - or 137 + 138 + or:: 139 + 148 140 make coccicheck COCCI=<my_SP.cocci> MODE=report 149 141 150 142 151 - Controlling Which Files are Processed by Coccinelle 152 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 143 + Controlling Which Files are Processed by Coccinelle 144 + --------------------------------------------------- 145 + 153 146 By default the entire kernel source tree is checked. 154 147 155 - To apply Coccinelle to a specific directory, M= can be used. 156 - For example, to check drivers/net/wireless/ one may write: 148 + To apply Coccinelle to a specific directory, ``M=`` can be used. 149 + For example, to check drivers/net/wireless/ one may write:: 157 150 158 151 make coccicheck M=drivers/net/wireless/ 159 152 160 153 To apply Coccinelle on a file basis, instead of a directory basis, the 161 - following command may be used: 154 + following command may be used:: 162 155 163 156 make C=1 CHECK="scripts/coccicheck" 164 157 165 - To check only newly edited code, use the value 2 for the C flag, i.e. 158 + To check only newly edited code, use the value 2 for the C flag, i.e.:: 166 159 167 160 make C=2 CHECK="scripts/coccicheck" 168 161 ··· 179 166 The "report" mode is the default. You can select another one with the 180 167 MODE variable explained above. 181 168 182 - Debugging Coccinelle SmPL patches 183 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 169 + Debugging Coccinelle SmPL patches 170 + --------------------------------- 184 171 185 172 Using coccicheck is best as it provides in the spatch command line 186 173 include options matching the options used when we compile the kernel. ··· 190 177 Alternatively you can debug running Coccinelle against SmPL patches 191 178 by asking for stderr to be redirected to stderr, by default stderr 192 179 is redirected to /dev/null, if you'd like to capture stderr you 193 - can specify the DEBUG_FILE="file.txt" option to coccicheck. For 194 - instance: 180 + can specify the ``DEBUG_FILE="file.txt"`` option to coccicheck. For 181 + instance:: 195 182 196 183 rm -f cocci.err 197 184 make coccicheck COCCI=scripts/coccinelle/free/kfree.cocci MODE=report DEBUG_FILE=cocci.err ··· 199 186 200 187 You can use SPFLAGS to add debugging flags, for instance you may want to 201 188 add both --profile --show-trying to SPFLAGS when debugging. For instance 202 - you may want to use: 189 + you may want to use:: 203 190 204 191 rm -f err.log 205 192 export COCCI=scripts/coccinelle/misc/irqf_oneshot.cocci ··· 211 198 212 199 DEBUG_FILE support is only supported when using coccinelle >= 1.2. 213 200 214 - .cocciconfig support 215 - ~~~~~~~~~~~~~~~~~~~~~~ 201 + .cocciconfig support 202 + -------------------- 216 203 217 204 Coccinelle supports reading .cocciconfig for default Coccinelle options that 218 205 should be used every time spatch is spawned, the order of precedence for 219 206 variables for .cocciconfig is as follows: 220 207 221 - o Your current user's home directory is processed first 222 - o Your directory from which spatch is called is processed next 223 - o The directory provided with the --dir option is processed last, if used 208 + - Your current user's home directory is processed first 209 + - Your directory from which spatch is called is processed next 210 + - The directory provided with the --dir option is processed last, if used 224 211 225 212 Since coccicheck runs through make, it naturally runs from the kernel 226 213 proper dir, as such the second rule above would be implied for picking up a 227 - .cocciconfig when using 'make coccicheck'. 214 + .cocciconfig when using ``make coccicheck``. 228 215 229 - 'make coccicheck' also supports using M= targets.If you do not supply 216 + ``make coccicheck`` also supports using M= targets.If you do not supply 230 217 any M= target, it is assumed you want to target the entire kernel. 231 - The kernel coccicheck script has: 218 + The kernel coccicheck script has:: 232 219 233 220 if [ "$KBUILD_EXTMOD" = "" ] ; then 234 221 OPTIONS="--dir $srctree $COCCIINCLUDE" ··· 248 235 249 236 We help Coccinelle when used against Linux with a set of sensible defaults 250 237 options for Linux with our own Linux .cocciconfig. This hints to coccinelle 251 - git can be used for 'git grep' queries over coccigrep. A timeout of 200 238 + git can be used for ``git grep`` queries over coccigrep. A timeout of 200 252 239 seconds should suffice for now. 253 240 254 241 The options picked up by coccinelle when reading a .cocciconfig do not appear 255 242 as arguments to spatch processes running on your system, to confirm what 256 - options will be used by Coccinelle run: 243 + options will be used by Coccinelle run:: 257 244 258 245 spatch --print-options-only 259 246 ··· 265 252 desired. See below section "Additional flags" for more details on how to use 266 253 idutils. 267 254 268 - Additional flags 269 - ~~~~~~~~~~~~~~~~~~ 255 + Additional flags 256 + ---------------- 270 257 271 258 Additional flags can be passed to spatch through the SPFLAGS 272 259 variable. This works as Coccinelle respects the last flags 273 - given to it when options are in conflict. 260 + given to it when options are in conflict. :: 274 261 275 262 make SPFLAGS=--use-glimpse coccicheck 276 263 277 264 Coccinelle supports idutils as well but requires coccinelle >= 1.0.6. 278 265 When no ID file is specified coccinelle assumes your ID database file 279 266 is in the file .id-utils.index on the top level of the kernel, coccinelle 280 - carries a script scripts/idutils_index.sh which creates the database with 267 + carries a script scripts/idutils_index.sh which creates the database with:: 281 268 282 269 mkid -i C --output .id-utils.index 283 270 284 271 If you have another database filename you can also just symlink with this 285 - name. 272 + name. :: 286 273 287 274 make SPFLAGS=--use-idutils coccicheck 288 275 289 276 Alternatively you can specify the database filename explicitly, for 290 - instance: 277 + instance:: 291 278 292 279 make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck 293 280 294 - See spatch --help to learn more about spatch options. 281 + See ``spatch --help`` to learn more about spatch options. 295 282 296 - Note that the '--use-glimpse' and '--use-idutils' options 283 + Note that the ``--use-glimpse`` and ``--use-idutils`` options 297 284 require external tools for indexing the code. None of them is 298 285 thus active by default. However, by indexing the code with 299 286 one of these tools, and according to the cocci file used, 300 287 spatch could proceed the entire code base more quickly. 301 288 302 - SmPL patch specific options 303 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289 + SmPL patch specific options 290 + --------------------------- 304 291 305 292 SmPL patches can have their own requirements for options passed 306 293 to Coccinelle. SmPL patch specific options can be provided by 307 - providing them at the top of the SmPL patch, for instance: 294 + providing them at the top of the SmPL patch, for instance:: 308 295 309 - // Options: --no-includes --include-headers 296 + // Options: --no-includes --include-headers 310 297 311 - SmPL patch Coccinelle requirements 312 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298 + SmPL patch Coccinelle requirements 299 + ---------------------------------- 313 300 314 301 As Coccinelle features get added some more advanced SmPL patches 315 302 may require newer versions of Coccinelle. If an SmPL patch requires 316 303 at least a version of Coccinelle, this can be specified as follows, 317 - as an example if requiring at least Coccinelle >= 1.0.5: 304 + as an example if requiring at least Coccinelle >= 1.0.5:: 318 305 319 - // Requires: 1.0.5 306 + // Requires: 1.0.5 320 307 321 - Proposing new semantic patches 322 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 308 + Proposing new semantic patches 309 + ------------------------------- 323 310 324 311 New semantic patches can be proposed and submitted by kernel 325 312 developers. For sake of clarity, they should be organized in the 326 - sub-directories of 'scripts/coccinelle/'. 313 + sub-directories of ``scripts/coccinelle/``. 327 314 328 315 329 - Detailed description of the 'report' mode 330 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 + Detailed description of the ``report`` mode 317 + ------------------------------------------- 331 318 332 - 'report' generates a list in the following format: 319 + ``report`` generates a list in the following format:: 320 + 333 321 file:line:column-column: message 334 322 335 - Example: 323 + Example 324 + ~~~~~~~ 336 325 337 - Running 326 + Running:: 338 327 339 328 make coccicheck MODE=report COCCI=scripts/coccinelle/api/err_cast.cocci 340 329 341 - will execute the following part of the SmPL script. 330 + will execute the following part of the SmPL script:: 342 331 343 - <smpl> 344 - @r depends on !context && !patch && (org || report)@ 345 - expression x; 346 - position p; 347 - @@ 332 + <smpl> 333 + @r depends on !context && !patch && (org || report)@ 334 + expression x; 335 + position p; 336 + @@ 348 337 349 - ERR_PTR@p(PTR_ERR(x)) 338 + ERR_PTR@p(PTR_ERR(x)) 350 339 351 - @script:python depends on report@ 352 - p << r.p; 353 - x << r.x; 354 - @@ 340 + @script:python depends on report@ 341 + p << r.p; 342 + x << r.x; 343 + @@ 355 344 356 - msg="ERR_CAST can be used with %s" % (x) 357 - coccilib.report.print_report(p[0], msg) 358 - </smpl> 345 + msg="ERR_CAST can be used with %s" % (x) 346 + coccilib.report.print_report(p[0], msg) 347 + </smpl> 359 348 360 349 This SmPL excerpt generates entries on the standard output, as 361 - illustrated below: 350 + illustrated below:: 362 351 363 - /home/user/linux/crypto/ctr.c:188:9-16: ERR_CAST can be used with alg 364 - /home/user/linux/crypto/authenc.c:619:9-16: ERR_CAST can be used with auth 365 - /home/user/linux/crypto/xts.c:227:9-16: ERR_CAST can be used with alg 352 + /home/user/linux/crypto/ctr.c:188:9-16: ERR_CAST can be used with alg 353 + /home/user/linux/crypto/authenc.c:619:9-16: ERR_CAST can be used with auth 354 + /home/user/linux/crypto/xts.c:227:9-16: ERR_CAST can be used with alg 366 355 367 356 368 - Detailed description of the 'patch' mode 369 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 + Detailed description of the ``patch`` mode 358 + ------------------------------------------ 370 359 371 - When the 'patch' mode is available, it proposes a fix for each problem 360 + When the ``patch`` mode is available, it proposes a fix for each problem 372 361 identified. 373 362 374 - Example: 363 + Example 364 + ~~~~~~~ 375 365 376 - Running 366 + Running:: 367 + 377 368 make coccicheck MODE=patch COCCI=scripts/coccinelle/api/err_cast.cocci 378 369 379 - will execute the following part of the SmPL script. 370 + will execute the following part of the SmPL script:: 380 371 381 - <smpl> 382 - @ depends on !context && patch && !org && !report @ 383 - expression x; 384 - @@ 372 + <smpl> 373 + @ depends on !context && patch && !org && !report @ 374 + expression x; 375 + @@ 385 376 386 - - ERR_PTR(PTR_ERR(x)) 387 - + ERR_CAST(x) 388 - </smpl> 377 + - ERR_PTR(PTR_ERR(x)) 378 + + ERR_CAST(x) 379 + </smpl> 389 380 390 381 This SmPL excerpt generates patch hunks on the standard output, as 391 - illustrated below: 382 + illustrated below:: 392 383 393 - diff -u -p a/crypto/ctr.c b/crypto/ctr.c 394 - --- a/crypto/ctr.c 2010-05-26 10:49:38.000000000 +0200 395 - +++ b/crypto/ctr.c 2010-06-03 23:44:49.000000000 +0200 396 - @@ -185,7 +185,7 @@ static struct crypto_instance *crypto_ct 384 + diff -u -p a/crypto/ctr.c b/crypto/ctr.c 385 + --- a/crypto/ctr.c 2010-05-26 10:49:38.000000000 +0200 386 + +++ b/crypto/ctr.c 2010-06-03 23:44:49.000000000 +0200 387 + @@ -185,7 +185,7 @@ static struct crypto_instance *crypto_ct 397 388 alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER, 398 389 CRYPTO_ALG_TYPE_MASK); 399 390 if (IS_ERR(alg)) 400 - - return ERR_PTR(PTR_ERR(alg)); 401 - + return ERR_CAST(alg); 402 - 391 + - return ERR_PTR(PTR_ERR(alg)); 392 + + return ERR_CAST(alg); 393 + 403 394 /* Block size must be >= 4 bytes. */ 404 395 err = -EINVAL; 405 396 406 - Detailed description of the 'context' mode 407 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 397 + Detailed description of the ``context`` mode 398 + -------------------------------------------- 408 399 409 - 'context' highlights lines of interest and their context 400 + ``context`` highlights lines of interest and their context 410 401 in a diff-like style. 411 402 412 - NOTE: The diff-like output generated is NOT an applicable patch. The 413 - intent of the 'context' mode is to highlight the important lines 414 - (annotated with minus, '-') and gives some surrounding context 403 + **NOTE**: The diff-like output generated is NOT an applicable patch. The 404 + intent of the ``context`` mode is to highlight the important lines 405 + (annotated with minus, ``-``) and gives some surrounding context 415 406 lines around. This output can be used with the diff mode of 416 407 Emacs to review the code. 417 408 418 - Example: 409 + Example 410 + ~~~~~~~ 419 411 420 - Running 412 + Running:: 413 + 421 414 make coccicheck MODE=context COCCI=scripts/coccinelle/api/err_cast.cocci 422 415 423 - will execute the following part of the SmPL script. 416 + will execute the following part of the SmPL script:: 424 417 425 - <smpl> 426 - @ depends on context && !patch && !org && !report@ 427 - expression x; 428 - @@ 418 + <smpl> 419 + @ depends on context && !patch && !org && !report@ 420 + expression x; 421 + @@ 429 422 430 - * ERR_PTR(PTR_ERR(x)) 431 - </smpl> 423 + * ERR_PTR(PTR_ERR(x)) 424 + </smpl> 432 425 433 426 This SmPL excerpt generates diff hunks on the standard output, as 434 - illustrated below: 427 + illustrated below:: 435 428 436 - diff -u -p /home/user/linux/crypto/ctr.c /tmp/nothing 437 - --- /home/user/linux/crypto/ctr.c 2010-05-26 10:49:38.000000000 +0200 438 - +++ /tmp/nothing 439 - @@ -185,7 +185,6 @@ static struct crypto_instance *crypto_ct 429 + diff -u -p /home/user/linux/crypto/ctr.c /tmp/nothing 430 + --- /home/user/linux/crypto/ctr.c 2010-05-26 10:49:38.000000000 +0200 431 + +++ /tmp/nothing 432 + @@ -185,7 +185,6 @@ static struct crypto_instance *crypto_ct 440 433 alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER, 441 434 CRYPTO_ALG_TYPE_MASK); 442 435 if (IS_ERR(alg)) 443 - - return ERR_PTR(PTR_ERR(alg)); 444 - 436 + - return ERR_PTR(PTR_ERR(alg)); 437 + 445 438 /* Block size must be >= 4 bytes. */ 446 439 err = -EINVAL; 447 440 448 - Detailed description of the 'org' mode 449 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 441 + Detailed description of the ``org`` mode 442 + ---------------------------------------- 450 443 451 - 'org' generates a report in the Org mode format of Emacs. 444 + ``org`` generates a report in the Org mode format of Emacs. 452 445 453 - Example: 446 + Example 447 + ~~~~~~~ 454 448 455 - Running 449 + Running:: 450 + 456 451 make coccicheck MODE=org COCCI=scripts/coccinelle/api/err_cast.cocci 457 452 458 - will execute the following part of the SmPL script. 453 + will execute the following part of the SmPL script:: 459 454 460 - <smpl> 461 - @r depends on !context && !patch && (org || report)@ 462 - expression x; 463 - position p; 464 - @@ 455 + <smpl> 456 + @r depends on !context && !patch && (org || report)@ 457 + expression x; 458 + position p; 459 + @@ 465 460 466 - ERR_PTR@p(PTR_ERR(x)) 461 + ERR_PTR@p(PTR_ERR(x)) 467 462 468 - @script:python depends on org@ 469 - p << r.p; 470 - x << r.x; 471 - @@ 463 + @script:python depends on org@ 464 + p << r.p; 465 + x << r.x; 466 + @@ 472 467 473 - msg="ERR_CAST can be used with %s" % (x) 474 - msg_safe=msg.replace("[","@(").replace("]",")") 475 - coccilib.org.print_todo(p[0], msg_safe) 476 - </smpl> 468 + msg="ERR_CAST can be used with %s" % (x) 469 + msg_safe=msg.replace("[","@(").replace("]",")") 470 + coccilib.org.print_todo(p[0], msg_safe) 471 + </smpl> 477 472 478 473 This SmPL excerpt generates Org entries on the standard output, as 479 - illustrated below: 474 + illustrated below:: 480 475 481 - * TODO [[view:/home/user/linux/crypto/ctr.c::face=ovl-face1::linb=188::colb=9::cole=16][ERR_CAST can be used with alg]] 482 - * TODO [[view:/home/user/linux/crypto/authenc.c::face=ovl-face1::linb=619::colb=9::cole=16][ERR_CAST can be used with auth]] 483 - * TODO [[view:/home/user/linux/crypto/xts.c::face=ovl-face1::linb=227::colb=9::cole=16][ERR_CAST can be used with alg]] 476 + * TODO [[view:/home/user/linux/crypto/ctr.c::face=ovl-face1::linb=188::colb=9::cole=16][ERR_CAST can be used with alg]] 477 + * TODO [[view:/home/user/linux/crypto/authenc.c::face=ovl-face1::linb=619::colb=9::cole=16][ERR_CAST can be used with auth]] 478 + * TODO [[view:/home/user/linux/crypto/xts.c::face=ovl-face1::linb=227::colb=9::cole=16][ERR_CAST can be used with alg]]
+91 -13
Documentation/conf.py
··· 14 14 15 15 import sys 16 16 import os 17 + import sphinx 18 + 19 + # Get Sphinx version 20 + major, minor, patch = map(int, sphinx.__version__.split(".")) 21 + 17 22 18 23 # If extensions (or modules to document with autodoc) are in another directory, 19 24 # add these directories to sys.path here. If the directory is relative to the 20 25 # documentation root, use os.path.abspath to make it absolute, like shown here. 21 26 sys.path.insert(0, os.path.abspath('sphinx')) 27 + from load_config import loadConfig 22 28 23 29 # -- General configuration ------------------------------------------------ 24 30 ··· 34 28 # Add any Sphinx extension module names here, as strings. They can be 35 29 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 36 30 # ones. 37 - extensions = ['kernel-doc', 'rstFlatTable', 'kernel_include'] 31 + extensions = ['kernel-doc', 'rstFlatTable', 'kernel_include', 'cdomain'] 38 32 39 - # Gracefully handle missing rst2pdf. 40 - try: 41 - import rst2pdf 42 - extensions += ['rst2pdf.pdfbuilder'] 43 - except ImportError: 44 - pass 33 + # The name of the math extension changed on Sphinx 1.4 34 + if minor > 3: 35 + extensions.append("sphinx.ext.imgmath") 36 + else: 37 + extensions.append("sphinx.ext.pngmath") 45 38 46 39 # Add any paths that contain templates here, relative to this directory. 47 40 templates_path = ['_templates'] ··· 257 252 258 253 latex_elements = { 259 254 # The paper size ('letterpaper' or 'a4paper'). 260 - #'papersize': 'letterpaper', 255 + 'papersize': 'a4paper', 261 256 262 257 # The font size ('10pt', '11pt' or '12pt'). 263 - #'pointsize': '10pt', 264 - 265 - # Additional stuff for the LaTeX preamble. 266 - #'preamble': '', 258 + 'pointsize': '8pt', 267 259 268 260 # Latex figure (float) alignment 269 261 #'figure_align': 'htbp', 262 + 263 + # Don't mangle with UTF-8 chars 264 + 'inputenc': '', 265 + 'utf8extra': '', 266 + 267 + # Additional stuff for the LaTeX preamble. 268 + 'preamble': ''' 269 + % Adjust margins 270 + \\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry} 271 + 272 + % Allow generate some pages in landscape 273 + \\usepackage{lscape} 274 + 275 + % Put notes in color and let them be inside a table 276 + \\definecolor{NoteColor}{RGB}{204,255,255} 277 + \\definecolor{WarningColor}{RGB}{255,204,204} 278 + \\definecolor{AttentionColor}{RGB}{255,255,204} 279 + \\definecolor{OtherColor}{RGB}{204,204,204} 280 + \\newlength{\\mynoticelength} 281 + \\makeatletter\\newenvironment{coloredbox}[1]{% 282 + \\setlength{\\fboxrule}{1pt} 283 + \\setlength{\\fboxsep}{7pt} 284 + \\setlength{\\mynoticelength}{\\linewidth} 285 + \\addtolength{\\mynoticelength}{-2\\fboxsep} 286 + \\addtolength{\\mynoticelength}{-2\\fboxrule} 287 + \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\mynoticelength}}{\\end{minipage}\\end{lrbox}% 288 + \\ifthenelse% 289 + {\\equal{\\py@noticetype}{note}}% 290 + {\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}% 291 + {% 292 + \\ifthenelse% 293 + {\\equal{\\py@noticetype}{warning}}% 294 + {\\colorbox{WarningColor}{\\usebox{\\@tempboxa}}}% 295 + {% 296 + \\ifthenelse% 297 + {\\equal{\\py@noticetype}{attention}}% 298 + {\\colorbox{AttentionColor}{\\usebox{\\@tempboxa}}}% 299 + {\\colorbox{OtherColor}{\\usebox{\\@tempboxa}}}% 300 + }% 301 + }% 302 + }\\makeatother 303 + 304 + \\makeatletter 305 + \\renewenvironment{notice}[2]{% 306 + \\def\\py@noticetype{#1} 307 + \\begin{coloredbox}{#1} 308 + \\bf\\it 309 + \\par\\strong{#2} 310 + \\csname py@noticestart@#1\\endcsname 311 + } 312 + { 313 + \\csname py@noticeend@\\py@noticetype\\endcsname 314 + \\end{coloredbox} 315 + } 316 + \\makeatother 317 + 318 + % Use some font with UTF-8 support with XeLaTeX 319 + \\usepackage{fontspec} 320 + \\setsansfont{DejaVu Serif} 321 + \\setromanfont{DejaVu Sans} 322 + \\setmonofont{DejaVu Sans Mono} 323 + 324 + % To allow adjusting table sizes 325 + \\usepackage{adjustbox} 326 + 327 + ''' 270 328 } 271 329 272 330 # Grouping the document tree into LaTeX files. List of tuples 273 331 # (source start file, target name, title, 274 332 # author, documentclass [howto, manual, or own class]). 275 333 latex_documents = [ 276 - (master_doc, 'TheLinuxKernel.tex', 'The Linux Kernel Documentation', 334 + ('kernel-documentation', 'kernel-documentation.tex', 'The Linux Kernel Documentation', 335 + 'The kernel development community', 'manual'), 336 + ('development-process/index', 'development-process.tex', 'Linux Kernel Development Documentation', 337 + 'The kernel development community', 'manual'), 338 + ('gpu/index', 'gpu.tex', 'Linux GPU Driver Developer\'s Guide', 277 339 'The kernel development community', 'manual'), 278 340 ] 279 341 ··· 491 419 # line arguments. 492 420 kerneldoc_bin = '../scripts/kernel-doc' 493 421 kerneldoc_srctree = '..' 422 + 423 + # ------------------------------------------------------------------------------ 424 + # Since loadConfig overwrites settings from the global namespace, it has to be 425 + # the last statement in the conf.py file 426 + # ------------------------------------------------------------------------------ 427 + loadConfig(globals())
+256
Documentation/dev-tools/gcov.rst
··· 1 + Using gcov with the Linux kernel 2 + ================================ 3 + 4 + gcov profiling kernel support enables the use of GCC's coverage testing 5 + tool gcov_ with the Linux kernel. Coverage data of a running kernel 6 + is exported in gcov-compatible format via the "gcov" debugfs directory. 7 + To get coverage data for a specific file, change to the kernel build 8 + directory and use gcov with the ``-o`` option as follows (requires root):: 9 + 10 + # cd /tmp/linux-out 11 + # gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c 12 + 13 + This will create source code files annotated with execution counts 14 + in the current directory. In addition, graphical gcov front-ends such 15 + as lcov_ can be used to automate the process of collecting data 16 + for the entire kernel and provide coverage overviews in HTML format. 17 + 18 + Possible uses: 19 + 20 + * debugging (has this line been reached at all?) 21 + * test improvement (how do I change my test to cover these lines?) 22 + * minimizing kernel configurations (do I need this option if the 23 + associated code is never run?) 24 + 25 + .. _gcov: http://gcc.gnu.org/onlinedocs/gcc/Gcov.html 26 + .. _lcov: http://ltp.sourceforge.net/coverage/lcov.php 27 + 28 + 29 + Preparation 30 + ----------- 31 + 32 + Configure the kernel with:: 33 + 34 + CONFIG_DEBUG_FS=y 35 + CONFIG_GCOV_KERNEL=y 36 + 37 + select the gcc's gcov format, default is autodetect based on gcc version:: 38 + 39 + CONFIG_GCOV_FORMAT_AUTODETECT=y 40 + 41 + and to get coverage data for the entire kernel:: 42 + 43 + CONFIG_GCOV_PROFILE_ALL=y 44 + 45 + Note that kernels compiled with profiling flags will be significantly 46 + larger and run slower. Also CONFIG_GCOV_PROFILE_ALL may not be supported 47 + on all architectures. 48 + 49 + Profiling data will only become accessible once debugfs has been 50 + mounted:: 51 + 52 + mount -t debugfs none /sys/kernel/debug 53 + 54 + 55 + Customization 56 + ------------- 57 + 58 + To enable profiling for specific files or directories, add a line 59 + similar to the following to the respective kernel Makefile: 60 + 61 + - For a single file (e.g. main.o):: 62 + 63 + GCOV_PROFILE_main.o := y 64 + 65 + - For all files in one directory:: 66 + 67 + GCOV_PROFILE := y 68 + 69 + To exclude files from being profiled even when CONFIG_GCOV_PROFILE_ALL 70 + is specified, use:: 71 + 72 + GCOV_PROFILE_main.o := n 73 + 74 + and:: 75 + 76 + GCOV_PROFILE := n 77 + 78 + Only files which are linked to the main kernel image or are compiled as 79 + kernel modules are supported by this mechanism. 80 + 81 + 82 + Files 83 + ----- 84 + 85 + The gcov kernel support creates the following files in debugfs: 86 + 87 + ``/sys/kernel/debug/gcov`` 88 + Parent directory for all gcov-related files. 89 + 90 + ``/sys/kernel/debug/gcov/reset`` 91 + Global reset file: resets all coverage data to zero when 92 + written to. 93 + 94 + ``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda`` 95 + The actual gcov data file as understood by the gcov 96 + tool. Resets file coverage data to zero when written to. 97 + 98 + ``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno`` 99 + Symbolic link to a static data file required by the gcov 100 + tool. This file is generated by gcc when compiling with 101 + option ``-ftest-coverage``. 102 + 103 + 104 + Modules 105 + ------- 106 + 107 + Kernel modules may contain cleanup code which is only run during 108 + module unload time. The gcov mechanism provides a means to collect 109 + coverage data for such code by keeping a copy of the data associated 110 + with the unloaded module. This data remains available through debugfs. 111 + Once the module is loaded again, the associated coverage counters are 112 + initialized with the data from its previous instantiation. 113 + 114 + This behavior can be deactivated by specifying the gcov_persist kernel 115 + parameter:: 116 + 117 + gcov_persist=0 118 + 119 + At run-time, a user can also choose to discard data for an unloaded 120 + module by writing to its data file or the global reset file. 121 + 122 + 123 + Separated build and test machines 124 + --------------------------------- 125 + 126 + The gcov kernel profiling infrastructure is designed to work out-of-the 127 + box for setups where kernels are built and run on the same machine. In 128 + cases where the kernel runs on a separate machine, special preparations 129 + must be made, depending on where the gcov tool is used: 130 + 131 + a) gcov is run on the TEST machine 132 + 133 + The gcov tool version on the test machine must be compatible with the 134 + gcc version used for kernel build. Also the following files need to be 135 + copied from build to test machine: 136 + 137 + from the source tree: 138 + - all C source files + headers 139 + 140 + from the build tree: 141 + - all C source files + headers 142 + - all .gcda and .gcno files 143 + - all links to directories 144 + 145 + It is important to note that these files need to be placed into the 146 + exact same file system location on the test machine as on the build 147 + machine. If any of the path components is symbolic link, the actual 148 + directory needs to be used instead (due to make's CURDIR handling). 149 + 150 + b) gcov is run on the BUILD machine 151 + 152 + The following files need to be copied after each test case from test 153 + to build machine: 154 + 155 + from the gcov directory in sysfs: 156 + - all .gcda files 157 + - all links to .gcno files 158 + 159 + These files can be copied to any location on the build machine. gcov 160 + must then be called with the -o option pointing to that directory. 161 + 162 + Example directory setup on the build machine:: 163 + 164 + /tmp/linux: kernel source tree 165 + /tmp/out: kernel build directory as specified by make O= 166 + /tmp/coverage: location of the files copied from the test machine 167 + 168 + [user@build] cd /tmp/out 169 + [user@build] gcov -o /tmp/coverage/tmp/out/init main.c 170 + 171 + 172 + Troubleshooting 173 + --------------- 174 + 175 + Problem 176 + Compilation aborts during linker step. 177 + 178 + Cause 179 + Profiling flags are specified for source files which are not 180 + linked to the main kernel or which are linked by a custom 181 + linker procedure. 182 + 183 + Solution 184 + Exclude affected source files from profiling by specifying 185 + ``GCOV_PROFILE := n`` or ``GCOV_PROFILE_basename.o := n`` in the 186 + corresponding Makefile. 187 + 188 + Problem 189 + Files copied from sysfs appear empty or incomplete. 190 + 191 + Cause 192 + Due to the way seq_file works, some tools such as cp or tar 193 + may not correctly copy files from sysfs. 194 + 195 + Solution 196 + Use ``cat``' to read ``.gcda`` files and ``cp -d`` to copy links. 197 + Alternatively use the mechanism shown in Appendix B. 198 + 199 + 200 + Appendix A: gather_on_build.sh 201 + ------------------------------ 202 + 203 + Sample script to gather coverage meta files on the build machine 204 + (see 6a):: 205 + 206 + #!/bin/bash 207 + 208 + KSRC=$1 209 + KOBJ=$2 210 + DEST=$3 211 + 212 + if [ -z "$KSRC" ] || [ -z "$KOBJ" ] || [ -z "$DEST" ]; then 213 + echo "Usage: $0 <ksrc directory> <kobj directory> <output.tar.gz>" >&2 214 + exit 1 215 + fi 216 + 217 + KSRC=$(cd $KSRC; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) 218 + KOBJ=$(cd $KOBJ; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) 219 + 220 + find $KSRC $KOBJ \( -name '*.gcno' -o -name '*.[ch]' -o -type l \) -a \ 221 + -perm /u+r,g+r | tar cfz $DEST -P -T - 222 + 223 + if [ $? -eq 0 ] ; then 224 + echo "$DEST successfully created, copy to test system and unpack with:" 225 + echo " tar xfz $DEST -P" 226 + else 227 + echo "Could not create file $DEST" 228 + fi 229 + 230 + 231 + Appendix B: gather_on_test.sh 232 + ----------------------------- 233 + 234 + Sample script to gather coverage data files on the test machine 235 + (see 6b):: 236 + 237 + #!/bin/bash -e 238 + 239 + DEST=$1 240 + GCDA=/sys/kernel/debug/gcov 241 + 242 + if [ -z "$DEST" ] ; then 243 + echo "Usage: $0 <output.tar.gz>" >&2 244 + exit 1 245 + fi 246 + 247 + TEMPDIR=$(mktemp -d) 248 + echo Collecting data.. 249 + find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \; 250 + find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \; 251 + find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \; 252 + tar czf $DEST -C $TEMPDIR sys 253 + rm -rf $TEMPDIR 254 + 255 + echo "$DEST successfully created, copy to build system and unpack with:" 256 + echo " tar xfz $DEST"
+173
Documentation/dev-tools/kasan.rst
··· 1 + The Kernel Address Sanitizer (KASAN) 2 + ==================================== 3 + 4 + Overview 5 + -------- 6 + 7 + KernelAddressSANitizer (KASAN) is a dynamic memory error detector. It provides 8 + a fast and comprehensive solution for finding use-after-free and out-of-bounds 9 + bugs. 10 + 11 + KASAN uses compile-time instrumentation for checking every memory access, 12 + therefore you will need a GCC version 4.9.2 or later. GCC 5.0 or later is 13 + required for detection of out-of-bounds accesses to stack or global variables. 14 + 15 + Currently KASAN is supported only for the x86_64 and arm64 architectures. 16 + 17 + Usage 18 + ----- 19 + 20 + To enable KASAN configure kernel with:: 21 + 22 + CONFIG_KASAN = y 23 + 24 + and choose between CONFIG_KASAN_OUTLINE and CONFIG_KASAN_INLINE. Outline and 25 + inline are compiler instrumentation types. The former produces smaller binary 26 + the latter is 1.1 - 2 times faster. Inline instrumentation requires a GCC 27 + version 5.0 or later. 28 + 29 + KASAN works with both SLUB and SLAB memory allocators. 30 + For better bug detection and nicer reporting, enable CONFIG_STACKTRACE. 31 + 32 + To disable instrumentation for specific files or directories, add a line 33 + similar to the following to the respective kernel Makefile: 34 + 35 + - For a single file (e.g. main.o):: 36 + 37 + KASAN_SANITIZE_main.o := n 38 + 39 + - For all files in one directory:: 40 + 41 + KASAN_SANITIZE := n 42 + 43 + Error reports 44 + ~~~~~~~~~~~~~ 45 + 46 + A typical out of bounds access report looks like this:: 47 + 48 + ================================================================== 49 + BUG: AddressSanitizer: out of bounds access in kmalloc_oob_right+0x65/0x75 [test_kasan] at addr ffff8800693bc5d3 50 + Write of size 1 by task modprobe/1689 51 + ============================================================================= 52 + BUG kmalloc-128 (Not tainted): kasan error 53 + ----------------------------------------------------------------------------- 54 + 55 + Disabling lock debugging due to kernel taint 56 + INFO: Allocated in kmalloc_oob_right+0x3d/0x75 [test_kasan] age=0 cpu=0 pid=1689 57 + __slab_alloc+0x4b4/0x4f0 58 + kmem_cache_alloc_trace+0x10b/0x190 59 + kmalloc_oob_right+0x3d/0x75 [test_kasan] 60 + init_module+0x9/0x47 [test_kasan] 61 + do_one_initcall+0x99/0x200 62 + load_module+0x2cb3/0x3b20 63 + SyS_finit_module+0x76/0x80 64 + system_call_fastpath+0x12/0x17 65 + INFO: Slab 0xffffea0001a4ef00 objects=17 used=7 fp=0xffff8800693bd728 flags=0x100000000004080 66 + INFO: Object 0xffff8800693bc558 @offset=1368 fp=0xffff8800693bc720 67 + 68 + Bytes b4 ffff8800693bc548: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ 69 + Object ffff8800693bc558: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 70 + Object ffff8800693bc568: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 71 + Object ffff8800693bc578: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 72 + Object ffff8800693bc588: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 73 + Object ffff8800693bc598: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 74 + Object ffff8800693bc5a8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 75 + Object ffff8800693bc5b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 76 + Object ffff8800693bc5c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk. 77 + Redzone ffff8800693bc5d8: cc cc cc cc cc cc cc cc ........ 78 + Padding ffff8800693bc718: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ 79 + CPU: 0 PID: 1689 Comm: modprobe Tainted: G B 3.18.0-rc1-mm1+ #98 80 + Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 81 + ffff8800693bc000 0000000000000000 ffff8800693bc558 ffff88006923bb78 82 + ffffffff81cc68ae 00000000000000f3 ffff88006d407600 ffff88006923bba8 83 + ffffffff811fd848 ffff88006d407600 ffffea0001a4ef00 ffff8800693bc558 84 + Call Trace: 85 + [<ffffffff81cc68ae>] dump_stack+0x46/0x58 86 + [<ffffffff811fd848>] print_trailer+0xf8/0x160 87 + [<ffffffffa00026a7>] ? kmem_cache_oob+0xc3/0xc3 [test_kasan] 88 + [<ffffffff811ff0f5>] object_err+0x35/0x40 89 + [<ffffffffa0002065>] ? kmalloc_oob_right+0x65/0x75 [test_kasan] 90 + [<ffffffff8120b9fa>] kasan_report_error+0x38a/0x3f0 91 + [<ffffffff8120a79f>] ? kasan_poison_shadow+0x2f/0x40 92 + [<ffffffff8120b344>] ? kasan_unpoison_shadow+0x14/0x40 93 + [<ffffffff8120a79f>] ? kasan_poison_shadow+0x2f/0x40 94 + [<ffffffffa00026a7>] ? kmem_cache_oob+0xc3/0xc3 [test_kasan] 95 + [<ffffffff8120a995>] __asan_store1+0x75/0xb0 96 + [<ffffffffa0002601>] ? kmem_cache_oob+0x1d/0xc3 [test_kasan] 97 + [<ffffffffa0002065>] ? kmalloc_oob_right+0x65/0x75 [test_kasan] 98 + [<ffffffffa0002065>] kmalloc_oob_right+0x65/0x75 [test_kasan] 99 + [<ffffffffa00026b0>] init_module+0x9/0x47 [test_kasan] 100 + [<ffffffff810002d9>] do_one_initcall+0x99/0x200 101 + [<ffffffff811e4e5c>] ? __vunmap+0xec/0x160 102 + [<ffffffff81114f63>] load_module+0x2cb3/0x3b20 103 + [<ffffffff8110fd70>] ? m_show+0x240/0x240 104 + [<ffffffff81115f06>] SyS_finit_module+0x76/0x80 105 + [<ffffffff81cd3129>] system_call_fastpath+0x12/0x17 106 + Memory state around the buggy address: 107 + ffff8800693bc300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 108 + ffff8800693bc380: fc fc 00 00 00 00 00 00 00 00 00 00 00 00 00 fc 109 + ffff8800693bc400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 110 + ffff8800693bc480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 111 + ffff8800693bc500: fc fc fc fc fc fc fc fc fc fc fc 00 00 00 00 00 112 + >ffff8800693bc580: 00 00 00 00 00 00 00 00 00 00 03 fc fc fc fc fc 113 + ^ 114 + ffff8800693bc600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 115 + ffff8800693bc680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 116 + ffff8800693bc700: fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb fb 117 + ffff8800693bc780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb 118 + ffff8800693bc800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb 119 + ================================================================== 120 + 121 + The header of the report discribe what kind of bug happened and what kind of 122 + access caused it. It's followed by the description of the accessed slub object 123 + (see 'SLUB Debug output' section in Documentation/vm/slub.txt for details) and 124 + the description of the accessed memory page. 125 + 126 + In the last section the report shows memory state around the accessed address. 127 + Reading this part requires some understanding of how KASAN works. 128 + 129 + The state of each 8 aligned bytes of memory is encoded in one shadow byte. 130 + Those 8 bytes can be accessible, partially accessible, freed or be a redzone. 131 + We use the following encoding for each shadow byte: 0 means that all 8 bytes 132 + of the corresponding memory region are accessible; number N (1 <= N <= 7) means 133 + that the first N bytes are accessible, and other (8 - N) bytes are not; 134 + any negative value indicates that the entire 8-byte word is inaccessible. 135 + We use different negative values to distinguish between different kinds of 136 + inaccessible memory like redzones or freed memory (see mm/kasan/kasan.h). 137 + 138 + In the report above the arrows point to the shadow byte 03, which means that 139 + the accessed address is partially accessible. 140 + 141 + 142 + Implementation details 143 + ---------------------- 144 + 145 + From a high level, our approach to memory error detection is similar to that 146 + of kmemcheck: use shadow memory to record whether each byte of memory is safe 147 + to access, and use compile-time instrumentation to check shadow memory on each 148 + memory access. 149 + 150 + AddressSanitizer dedicates 1/8 of kernel memory to its shadow memory 151 + (e.g. 16TB to cover 128TB on x86_64) and uses direct mapping with a scale and 152 + offset to translate a memory address to its corresponding shadow address. 153 + 154 + Here is the function which translates an address to its corresponding shadow 155 + address:: 156 + 157 + static inline void *kasan_mem_to_shadow(const void *addr) 158 + { 159 + return ((unsigned long)addr >> KASAN_SHADOW_SCALE_SHIFT) 160 + + KASAN_SHADOW_OFFSET; 161 + } 162 + 163 + where ``KASAN_SHADOW_SCALE_SHIFT = 3``. 164 + 165 + Compile-time instrumentation used for checking memory accesses. Compiler inserts 166 + function calls (__asan_load*(addr), __asan_store*(addr)) before each memory 167 + access of size 1, 2, 4, 8 or 16. These functions check whether memory access is 168 + valid or not by checking corresponding shadow memory. 169 + 170 + GCC 5.0 has possibility to perform inline instrumentation. Instead of making 171 + function calls GCC directly inserts the code to check the shadow memory. 172 + This option significantly enlarges kernel but it gives x1.1-x2 performance 173 + boost over outline instrumented kernel.
+733
Documentation/dev-tools/kmemcheck.rst
··· 1 + Getting started with kmemcheck 2 + ============================== 3 + 4 + Vegard Nossum <vegardno@ifi.uio.no> 5 + 6 + 7 + Introduction 8 + ------------ 9 + 10 + kmemcheck is a debugging feature for the Linux Kernel. More specifically, it 11 + is a dynamic checker that detects and warns about some uses of uninitialized 12 + memory. 13 + 14 + Userspace programmers might be familiar with Valgrind's memcheck. The main 15 + difference between memcheck and kmemcheck is that memcheck works for userspace 16 + programs only, and kmemcheck works for the kernel only. The implementations 17 + are of course vastly different. Because of this, kmemcheck is not as accurate 18 + as memcheck, but it turns out to be good enough in practice to discover real 19 + programmer errors that the compiler is not able to find through static 20 + analysis. 21 + 22 + Enabling kmemcheck on a kernel will probably slow it down to the extent that 23 + the machine will not be usable for normal workloads such as e.g. an 24 + interactive desktop. kmemcheck will also cause the kernel to use about twice 25 + as much memory as normal. For this reason, kmemcheck is strictly a debugging 26 + feature. 27 + 28 + 29 + Downloading 30 + ----------- 31 + 32 + As of version 2.6.31-rc1, kmemcheck is included in the mainline kernel. 33 + 34 + 35 + Configuring and compiling 36 + ------------------------- 37 + 38 + kmemcheck only works for the x86 (both 32- and 64-bit) platform. A number of 39 + configuration variables must have specific settings in order for the kmemcheck 40 + menu to even appear in "menuconfig". These are: 41 + 42 + - ``CONFIG_CC_OPTIMIZE_FOR_SIZE=n`` 43 + This option is located under "General setup" / "Optimize for size". 44 + 45 + Without this, gcc will use certain optimizations that usually lead to 46 + false positive warnings from kmemcheck. An example of this is a 16-bit 47 + field in a struct, where gcc may load 32 bits, then discard the upper 48 + 16 bits. kmemcheck sees only the 32-bit load, and may trigger a 49 + warning for the upper 16 bits (if they're uninitialized). 50 + 51 + - ``CONFIG_SLAB=y`` or ``CONFIG_SLUB=y`` 52 + This option is located under "General setup" / "Choose SLAB 53 + allocator". 54 + 55 + - ``CONFIG_FUNCTION_TRACER=n`` 56 + This option is located under "Kernel hacking" / "Tracers" / "Kernel 57 + Function Tracer" 58 + 59 + When function tracing is compiled in, gcc emits a call to another 60 + function at the beginning of every function. This means that when the 61 + page fault handler is called, the ftrace framework will be called 62 + before kmemcheck has had a chance to handle the fault. If ftrace then 63 + modifies memory that was tracked by kmemcheck, the result is an 64 + endless recursive page fault. 65 + 66 + - ``CONFIG_DEBUG_PAGEALLOC=n`` 67 + This option is located under "Kernel hacking" / "Memory Debugging" 68 + / "Debug page memory allocations". 69 + 70 + In addition, I highly recommend turning on ``CONFIG_DEBUG_INFO=y``. This is also 71 + located under "Kernel hacking". With this, you will be able to get line number 72 + information from the kmemcheck warnings, which is extremely valuable in 73 + debugging a problem. This option is not mandatory, however, because it slows 74 + down the compilation process and produces a much bigger kernel image. 75 + 76 + Now the kmemcheck menu should be visible (under "Kernel hacking" / "Memory 77 + Debugging" / "kmemcheck: trap use of uninitialized memory"). Here follows 78 + a description of the kmemcheck configuration variables: 79 + 80 + - ``CONFIG_KMEMCHECK`` 81 + This must be enabled in order to use kmemcheck at all... 82 + 83 + - ``CONFIG_KMEMCHECK_``[``DISABLED`` | ``ENABLED`` | ``ONESHOT``]``_BY_DEFAULT`` 84 + This option controls the status of kmemcheck at boot-time. "Enabled" 85 + will enable kmemcheck right from the start, "disabled" will boot the 86 + kernel as normal (but with the kmemcheck code compiled in, so it can 87 + be enabled at run-time after the kernel has booted), and "one-shot" is 88 + a special mode which will turn kmemcheck off automatically after 89 + detecting the first use of uninitialized memory. 90 + 91 + If you are using kmemcheck to actively debug a problem, then you 92 + probably want to choose "enabled" here. 93 + 94 + The one-shot mode is mostly useful in automated test setups because it 95 + can prevent floods of warnings and increase the chances of the machine 96 + surviving in case something is really wrong. In other cases, the one- 97 + shot mode could actually be counter-productive because it would turn 98 + itself off at the very first error -- in the case of a false positive 99 + too -- and this would come in the way of debugging the specific 100 + problem you were interested in. 101 + 102 + If you would like to use your kernel as normal, but with a chance to 103 + enable kmemcheck in case of some problem, it might be a good idea to 104 + choose "disabled" here. When kmemcheck is disabled, most of the run- 105 + time overhead is not incurred, and the kernel will be almost as fast 106 + as normal. 107 + 108 + - ``CONFIG_KMEMCHECK_QUEUE_SIZE`` 109 + Select the maximum number of error reports to store in an internal 110 + (fixed-size) buffer. Since errors can occur virtually anywhere and in 111 + any context, we need a temporary storage area which is guaranteed not 112 + to generate any other page faults when accessed. The queue will be 113 + emptied as soon as a tasklet may be scheduled. If the queue is full, 114 + new error reports will be lost. 115 + 116 + The default value of 64 is probably fine. If some code produces more 117 + than 64 errors within an irqs-off section, then the code is likely to 118 + produce many, many more, too, and these additional reports seldom give 119 + any more information (the first report is usually the most valuable 120 + anyway). 121 + 122 + This number might have to be adjusted if you are not using serial 123 + console or similar to capture the kernel log. If you are using the 124 + "dmesg" command to save the log, then getting a lot of kmemcheck 125 + warnings might overflow the kernel log itself, and the earlier reports 126 + will get lost in that way instead. Try setting this to 10 or so on 127 + such a setup. 128 + 129 + - ``CONFIG_KMEMCHECK_SHADOW_COPY_SHIFT`` 130 + Select the number of shadow bytes to save along with each entry of the 131 + error-report queue. These bytes indicate what parts of an allocation 132 + are initialized, uninitialized, etc. and will be displayed when an 133 + error is detected to help the debugging of a particular problem. 134 + 135 + The number entered here is actually the logarithm of the number of 136 + bytes that will be saved. So if you pick for example 5 here, kmemcheck 137 + will save 2^5 = 32 bytes. 138 + 139 + The default value should be fine for debugging most problems. It also 140 + fits nicely within 80 columns. 141 + 142 + - ``CONFIG_KMEMCHECK_PARTIAL_OK`` 143 + This option (when enabled) works around certain GCC optimizations that 144 + produce 32-bit reads from 16-bit variables where the upper 16 bits are 145 + thrown away afterwards. 146 + 147 + The default value (enabled) is recommended. This may of course hide 148 + some real errors, but disabling it would probably produce a lot of 149 + false positives. 150 + 151 + - ``CONFIG_KMEMCHECK_BITOPS_OK`` 152 + This option silences warnings that would be generated for bit-field 153 + accesses where not all the bits are initialized at the same time. This 154 + may also hide some real bugs. 155 + 156 + This option is probably obsolete, or it should be replaced with 157 + the kmemcheck-/bitfield-annotations for the code in question. The 158 + default value is therefore fine. 159 + 160 + Now compile the kernel as usual. 161 + 162 + 163 + How to use 164 + ---------- 165 + 166 + Booting 167 + ~~~~~~~ 168 + 169 + First some information about the command-line options. There is only one 170 + option specific to kmemcheck, and this is called "kmemcheck". It can be used 171 + to override the default mode as chosen by the ``CONFIG_KMEMCHECK_*_BY_DEFAULT`` 172 + option. Its possible settings are: 173 + 174 + - ``kmemcheck=0`` (disabled) 175 + - ``kmemcheck=1`` (enabled) 176 + - ``kmemcheck=2`` (one-shot mode) 177 + 178 + If SLUB debugging has been enabled in the kernel, it may take precedence over 179 + kmemcheck in such a way that the slab caches which are under SLUB debugging 180 + will not be tracked by kmemcheck. In order to ensure that this doesn't happen 181 + (even though it shouldn't by default), use SLUB's boot option ``slub_debug``, 182 + like this: ``slub_debug=-`` 183 + 184 + In fact, this option may also be used for fine-grained control over SLUB vs. 185 + kmemcheck. For example, if the command line includes 186 + ``kmemcheck=1 slub_debug=,dentry``, then SLUB debugging will be used only 187 + for the "dentry" slab cache, and with kmemcheck tracking all the other 188 + caches. This is advanced usage, however, and is not generally recommended. 189 + 190 + 191 + Run-time enable/disable 192 + ~~~~~~~~~~~~~~~~~~~~~~~ 193 + 194 + When the kernel has booted, it is possible to enable or disable kmemcheck at 195 + run-time. WARNING: This feature is still experimental and may cause false 196 + positive warnings to appear. Therefore, try not to use this. If you find that 197 + it doesn't work properly (e.g. you see an unreasonable amount of warnings), I 198 + will be happy to take bug reports. 199 + 200 + Use the file ``/proc/sys/kernel/kmemcheck`` for this purpose, e.g.:: 201 + 202 + $ echo 0 > /proc/sys/kernel/kmemcheck # disables kmemcheck 203 + 204 + The numbers are the same as for the ``kmemcheck=`` command-line option. 205 + 206 + 207 + Debugging 208 + ~~~~~~~~~ 209 + 210 + A typical report will look something like this:: 211 + 212 + WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff88003e4a2024) 213 + 80000000000000000000000000000000000000000088ffff0000000000000000 214 + i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u 215 + ^ 216 + 217 + Pid: 1856, comm: ntpdate Not tainted 2.6.29-rc5 #264 945P-A 218 + RIP: 0010:[<ffffffff8104ede8>] [<ffffffff8104ede8>] __dequeue_signal+0xc8/0x190 219 + RSP: 0018:ffff88003cdf7d98 EFLAGS: 00210002 220 + RAX: 0000000000000030 RBX: ffff88003d4ea968 RCX: 0000000000000009 221 + RDX: ffff88003e5d6018 RSI: ffff88003e5d6024 RDI: ffff88003cdf7e84 222 + RBP: ffff88003cdf7db8 R08: ffff88003e5d6000 R09: 0000000000000000 223 + R10: 0000000000000080 R11: 0000000000000000 R12: 000000000000000e 224 + R13: ffff88003cdf7e78 R14: ffff88003d530710 R15: ffff88003d5a98c8 225 + FS: 0000000000000000(0000) GS:ffff880001982000(0063) knlGS:00000 226 + CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 227 + CR2: ffff88003f806ea0 CR3: 000000003c036000 CR4: 00000000000006a0 228 + DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 229 + DR3: 0000000000000000 DR6: 00000000ffff4ff0 DR7: 0000000000000400 230 + [<ffffffff8104f04e>] dequeue_signal+0x8e/0x170 231 + [<ffffffff81050bd8>] get_signal_to_deliver+0x98/0x390 232 + [<ffffffff8100b87d>] do_notify_resume+0xad/0x7d0 233 + [<ffffffff8100c7b5>] int_signal+0x12/0x17 234 + [<ffffffffffffffff>] 0xffffffffffffffff 235 + 236 + The single most valuable information in this report is the RIP (or EIP on 32- 237 + bit) value. This will help us pinpoint exactly which instruction that caused 238 + the warning. 239 + 240 + If your kernel was compiled with ``CONFIG_DEBUG_INFO=y``, then all we have to do 241 + is give this address to the addr2line program, like this:: 242 + 243 + $ addr2line -e vmlinux -i ffffffff8104ede8 244 + arch/x86/include/asm/string_64.h:12 245 + include/asm-generic/siginfo.h:287 246 + kernel/signal.c:380 247 + kernel/signal.c:410 248 + 249 + The "``-e vmlinux``" tells addr2line which file to look in. **IMPORTANT:** 250 + This must be the vmlinux of the kernel that produced the warning in the 251 + first place! If not, the line number information will almost certainly be 252 + wrong. 253 + 254 + The "``-i``" tells addr2line to also print the line numbers of inlined 255 + functions. In this case, the flag was very important, because otherwise, 256 + it would only have printed the first line, which is just a call to 257 + ``memcpy()``, which could be called from a thousand places in the kernel, and 258 + is therefore not very useful. These inlined functions would not show up in 259 + the stack trace above, simply because the kernel doesn't load the extra 260 + debugging information. This technique can of course be used with ordinary 261 + kernel oopses as well. 262 + 263 + In this case, it's the caller of ``memcpy()`` that is interesting, and it can be 264 + found in ``include/asm-generic/siginfo.h``, line 287:: 265 + 266 + 281 static inline void copy_siginfo(struct siginfo *to, struct siginfo *from) 267 + 282 { 268 + 283 if (from->si_code < 0) 269 + 284 memcpy(to, from, sizeof(*to)); 270 + 285 else 271 + 286 /* _sigchld is currently the largest know union member */ 272 + 287 memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld)); 273 + 288 } 274 + 275 + Since this was a read (kmemcheck usually warns about reads only, though it can 276 + warn about writes to unallocated or freed memory as well), it was probably the 277 + "from" argument which contained some uninitialized bytes. Following the chain 278 + of calls, we move upwards to see where "from" was allocated or initialized, 279 + ``kernel/signal.c``, line 380:: 280 + 281 + 359 static void collect_signal(int sig, struct sigpending *list, siginfo_t *info) 282 + 360 { 283 + ... 284 + 367 list_for_each_entry(q, &list->list, list) { 285 + 368 if (q->info.si_signo == sig) { 286 + 369 if (first) 287 + 370 goto still_pending; 288 + 371 first = q; 289 + ... 290 + 377 if (first) { 291 + 378 still_pending: 292 + 379 list_del_init(&first->list); 293 + 380 copy_siginfo(info, &first->info); 294 + 381 __sigqueue_free(first); 295 + ... 296 + 392 } 297 + 393 } 298 + 299 + Here, it is ``&first->info`` that is being passed on to ``copy_siginfo()``. The 300 + variable ``first`` was found on a list -- passed in as the second argument to 301 + ``collect_signal()``. We continue our journey through the stack, to figure out 302 + where the item on "list" was allocated or initialized. We move to line 410:: 303 + 304 + 395 static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, 305 + 396 siginfo_t *info) 306 + 397 { 307 + ... 308 + 410 collect_signal(sig, pending, info); 309 + ... 310 + 414 } 311 + 312 + Now we need to follow the ``pending`` pointer, since that is being passed on to 313 + ``collect_signal()`` as ``list``. At this point, we've run out of lines from the 314 + "addr2line" output. Not to worry, we just paste the next addresses from the 315 + kmemcheck stack dump, i.e.:: 316 + 317 + [<ffffffff8104f04e>] dequeue_signal+0x8e/0x170 318 + [<ffffffff81050bd8>] get_signal_to_deliver+0x98/0x390 319 + [<ffffffff8100b87d>] do_notify_resume+0xad/0x7d0 320 + [<ffffffff8100c7b5>] int_signal+0x12/0x17 321 + 322 + $ addr2line -e vmlinux -i ffffffff8104f04e ffffffff81050bd8 \ 323 + ffffffff8100b87d ffffffff8100c7b5 324 + kernel/signal.c:446 325 + kernel/signal.c:1806 326 + arch/x86/kernel/signal.c:805 327 + arch/x86/kernel/signal.c:871 328 + arch/x86/kernel/entry_64.S:694 329 + 330 + Remember that since these addresses were found on the stack and not as the 331 + RIP value, they actually point to the _next_ instruction (they are return 332 + addresses). This becomes obvious when we look at the code for line 446:: 333 + 334 + 422 int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) 335 + 423 { 336 + ... 337 + 431 signr = __dequeue_signal(&tsk->signal->shared_pending, 338 + 432 mask, info); 339 + 433 /* 340 + 434 * itimer signal ? 341 + 435 * 342 + 436 * itimers are process shared and we restart periodic 343 + 437 * itimers in the signal delivery path to prevent DoS 344 + 438 * attacks in the high resolution timer case. This is 345 + 439 * compliant with the old way of self restarting 346 + 440 * itimers, as the SIGALRM is a legacy signal and only 347 + 441 * queued once. Changing the restart behaviour to 348 + 442 * restart the timer in the signal dequeue path is 349 + 443 * reducing the timer noise on heavy loaded !highres 350 + 444 * systems too. 351 + 445 */ 352 + 446 if (unlikely(signr == SIGALRM)) { 353 + ... 354 + 489 } 355 + 356 + So instead of looking at 446, we should be looking at 431, which is the line 357 + that executes just before 446. Here we see that what we are looking for is 358 + ``&tsk->signal->shared_pending``. 359 + 360 + Our next task is now to figure out which function that puts items on this 361 + ``shared_pending`` list. A crude, but efficient tool, is ``git grep``:: 362 + 363 + $ git grep -n 'shared_pending' kernel/ 364 + ... 365 + kernel/signal.c:828: pending = group ? &t->signal->shared_pending : &t->pending; 366 + kernel/signal.c:1339: pending = group ? &t->signal->shared_pending : &t->pending; 367 + ... 368 + 369 + There were more results, but none of them were related to list operations, 370 + and these were the only assignments. We inspect the line numbers more closely 371 + and find that this is indeed where items are being added to the list:: 372 + 373 + 816 static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 374 + 817 int group) 375 + 818 { 376 + ... 377 + 828 pending = group ? &t->signal->shared_pending : &t->pending; 378 + ... 379 + 851 q = __sigqueue_alloc(t, GFP_ATOMIC, (sig < SIGRTMIN && 380 + 852 (is_si_special(info) || 381 + 853 info->si_code >= 0))); 382 + 854 if (q) { 383 + 855 list_add_tail(&q->list, &pending->list); 384 + ... 385 + 890 } 386 + 387 + and:: 388 + 389 + 1309 int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group) 390 + 1310 { 391 + .... 392 + 1339 pending = group ? &t->signal->shared_pending : &t->pending; 393 + 1340 list_add_tail(&q->list, &pending->list); 394 + .... 395 + 1347 } 396 + 397 + In the first case, the list element we are looking for, ``q``, is being 398 + returned from the function ``__sigqueue_alloc()``, which looks like an 399 + allocation function. Let's take a look at it:: 400 + 401 + 187 static struct sigqueue *__sigqueue_alloc(struct task_struct *t, gfp_t flags, 402 + 188 int override_rlimit) 403 + 189 { 404 + 190 struct sigqueue *q = NULL; 405 + 191 struct user_struct *user; 406 + 192 407 + 193 /* 408 + 194 * We won't get problems with the target's UID changing under us 409 + 195 * because changing it requires RCU be used, and if t != current, the 410 + 196 * caller must be holding the RCU readlock (by way of a spinlock) and 411 + 197 * we use RCU protection here 412 + 198 */ 413 + 199 user = get_uid(__task_cred(t)->user); 414 + 200 atomic_inc(&user->sigpending); 415 + 201 if (override_rlimit || 416 + 202 atomic_read(&user->sigpending) <= 417 + 203 t->signal->rlim[RLIMIT_SIGPENDING].rlim_cur) 418 + 204 q = kmem_cache_alloc(sigqueue_cachep, flags); 419 + 205 if (unlikely(q == NULL)) { 420 + 206 atomic_dec(&user->sigpending); 421 + 207 free_uid(user); 422 + 208 } else { 423 + 209 INIT_LIST_HEAD(&q->list); 424 + 210 q->flags = 0; 425 + 211 q->user = user; 426 + 212 } 427 + 213 428 + 214 return q; 429 + 215 } 430 + 431 + We see that this function initializes ``q->list``, ``q->flags``, and 432 + ``q->user``. It seems that now is the time to look at the definition of 433 + ``struct sigqueue``, e.g.:: 434 + 435 + 14 struct sigqueue { 436 + 15 struct list_head list; 437 + 16 int flags; 438 + 17 siginfo_t info; 439 + 18 struct user_struct *user; 440 + 19 }; 441 + 442 + And, you might remember, it was a ``memcpy()`` on ``&first->info`` that 443 + caused the warning, so this makes perfect sense. It also seems reasonable 444 + to assume that it is the caller of ``__sigqueue_alloc()`` that has the 445 + responsibility of filling out (initializing) this member. 446 + 447 + But just which fields of the struct were uninitialized? Let's look at 448 + kmemcheck's report again:: 449 + 450 + WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff88003e4a2024) 451 + 80000000000000000000000000000000000000000088ffff0000000000000000 452 + i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u 453 + ^ 454 + 455 + These first two lines are the memory dump of the memory object itself, and 456 + the shadow bytemap, respectively. The memory object itself is in this case 457 + ``&first->info``. Just beware that the start of this dump is NOT the start 458 + of the object itself! The position of the caret (^) corresponds with the 459 + address of the read (ffff88003e4a2024). 460 + 461 + The shadow bytemap dump legend is as follows: 462 + 463 + - i: initialized 464 + - u: uninitialized 465 + - a: unallocated (memory has been allocated by the slab layer, but has not 466 + yet been handed off to anybody) 467 + - f: freed (memory has been allocated by the slab layer, but has been freed 468 + by the previous owner) 469 + 470 + In order to figure out where (relative to the start of the object) the 471 + uninitialized memory was located, we have to look at the disassembly. For 472 + that, we'll need the RIP address again:: 473 + 474 + RIP: 0010:[<ffffffff8104ede8>] [<ffffffff8104ede8>] __dequeue_signal+0xc8/0x190 475 + 476 + $ objdump -d --no-show-raw-insn vmlinux | grep -C 8 ffffffff8104ede8: 477 + ffffffff8104edc8: mov %r8,0x8(%r8) 478 + ffffffff8104edcc: test %r10d,%r10d 479 + ffffffff8104edcf: js ffffffff8104ee88 <__dequeue_signal+0x168> 480 + ffffffff8104edd5: mov %rax,%rdx 481 + ffffffff8104edd8: mov $0xc,%ecx 482 + ffffffff8104eddd: mov %r13,%rdi 483 + ffffffff8104ede0: mov $0x30,%eax 484 + ffffffff8104ede5: mov %rdx,%rsi 485 + ffffffff8104ede8: rep movsl %ds:(%rsi),%es:(%rdi) 486 + ffffffff8104edea: test $0x2,%al 487 + ffffffff8104edec: je ffffffff8104edf0 <__dequeue_signal+0xd0> 488 + ffffffff8104edee: movsw %ds:(%rsi),%es:(%rdi) 489 + ffffffff8104edf0: test $0x1,%al 490 + ffffffff8104edf2: je ffffffff8104edf5 <__dequeue_signal+0xd5> 491 + ffffffff8104edf4: movsb %ds:(%rsi),%es:(%rdi) 492 + ffffffff8104edf5: mov %r8,%rdi 493 + ffffffff8104edf8: callq ffffffff8104de60 <__sigqueue_free> 494 + 495 + As expected, it's the "``rep movsl``" instruction from the ``memcpy()`` 496 + that causes the warning. We know about ``REP MOVSL`` that it uses the register 497 + ``RCX`` to count the number of remaining iterations. By taking a look at the 498 + register dump again (from the kmemcheck report), we can figure out how many 499 + bytes were left to copy:: 500 + 501 + RAX: 0000000000000030 RBX: ffff88003d4ea968 RCX: 0000000000000009 502 + 503 + By looking at the disassembly, we also see that ``%ecx`` is being loaded 504 + with the value ``$0xc`` just before (ffffffff8104edd8), so we are very 505 + lucky. Keep in mind that this is the number of iterations, not bytes. And 506 + since this is a "long" operation, we need to multiply by 4 to get the 507 + number of bytes. So this means that the uninitialized value was encountered 508 + at 4 * (0xc - 0x9) = 12 bytes from the start of the object. 509 + 510 + We can now try to figure out which field of the "``struct siginfo``" that 511 + was not initialized. This is the beginning of the struct:: 512 + 513 + 40 typedef struct siginfo { 514 + 41 int si_signo; 515 + 42 int si_errno; 516 + 43 int si_code; 517 + 44 518 + 45 union { 519 + .. 520 + 92 } _sifields; 521 + 93 } siginfo_t; 522 + 523 + On 64-bit, the int is 4 bytes long, so it must the union member that has 524 + not been initialized. We can verify this using gdb:: 525 + 526 + $ gdb vmlinux 527 + ... 528 + (gdb) p &((struct siginfo *) 0)->_sifields 529 + $1 = (union {...} *) 0x10 530 + 531 + Actually, it seems that the union member is located at offset 0x10 -- which 532 + means that gcc has inserted 4 bytes of padding between the members ``si_code`` 533 + and ``_sifields``. We can now get a fuller picture of the memory dump:: 534 + 535 + _----------------------------=> si_code 536 + / _--------------------=> (padding) 537 + | / _------------=> _sifields(._kill._pid) 538 + | | / _----=> _sifields(._kill._uid) 539 + | | | / 540 + -------|-------|-------|-------| 541 + 80000000000000000000000000000000000000000088ffff0000000000000000 542 + i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u 543 + 544 + This allows us to realize another important fact: ``si_code`` contains the 545 + value 0x80. Remember that x86 is little endian, so the first 4 bytes 546 + "80000000" are really the number 0x00000080. With a bit of research, we 547 + find that this is actually the constant ``SI_KERNEL`` defined in 548 + ``include/asm-generic/siginfo.h``:: 549 + 550 + 144 #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ 551 + 552 + This macro is used in exactly one place in the x86 kernel: In ``send_signal()`` 553 + in ``kernel/signal.c``:: 554 + 555 + 816 static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 556 + 817 int group) 557 + 818 { 558 + ... 559 + 828 pending = group ? &t->signal->shared_pending : &t->pending; 560 + ... 561 + 851 q = __sigqueue_alloc(t, GFP_ATOMIC, (sig < SIGRTMIN && 562 + 852 (is_si_special(info) || 563 + 853 info->si_code >= 0))); 564 + 854 if (q) { 565 + 855 list_add_tail(&q->list, &pending->list); 566 + 856 switch ((unsigned long) info) { 567 + ... 568 + 865 case (unsigned long) SEND_SIG_PRIV: 569 + 866 q->info.si_signo = sig; 570 + 867 q->info.si_errno = 0; 571 + 868 q->info.si_code = SI_KERNEL; 572 + 869 q->info.si_pid = 0; 573 + 870 q->info.si_uid = 0; 574 + 871 break; 575 + ... 576 + 890 } 577 + 578 + Not only does this match with the ``.si_code`` member, it also matches the place 579 + we found earlier when looking for where siginfo_t objects are enqueued on the 580 + ``shared_pending`` list. 581 + 582 + So to sum up: It seems that it is the padding introduced by the compiler 583 + between two struct fields that is uninitialized, and this gets reported when 584 + we do a ``memcpy()`` on the struct. This means that we have identified a false 585 + positive warning. 586 + 587 + Normally, kmemcheck will not report uninitialized accesses in ``memcpy()`` calls 588 + when both the source and destination addresses are tracked. (Instead, we copy 589 + the shadow bytemap as well). In this case, the destination address clearly 590 + was not tracked. We can dig a little deeper into the stack trace from above:: 591 + 592 + arch/x86/kernel/signal.c:805 593 + arch/x86/kernel/signal.c:871 594 + arch/x86/kernel/entry_64.S:694 595 + 596 + And we clearly see that the destination siginfo object is located on the 597 + stack:: 598 + 599 + 782 static void do_signal(struct pt_regs *regs) 600 + 783 { 601 + 784 struct k_sigaction ka; 602 + 785 siginfo_t info; 603 + ... 604 + 804 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 605 + ... 606 + 854 } 607 + 608 + And this ``&info`` is what eventually gets passed to ``copy_siginfo()`` as the 609 + destination argument. 610 + 611 + Now, even though we didn't find an actual error here, the example is still a 612 + good one, because it shows how one would go about to find out what the report 613 + was all about. 614 + 615 + 616 + Annotating false positives 617 + ~~~~~~~~~~~~~~~~~~~~~~~~~~ 618 + 619 + There are a few different ways to make annotations in the source code that 620 + will keep kmemcheck from checking and reporting certain allocations. Here 621 + they are: 622 + 623 + - ``__GFP_NOTRACK_FALSE_POSITIVE`` 624 + This flag can be passed to ``kmalloc()`` or ``kmem_cache_alloc()`` 625 + (therefore also to other functions that end up calling one of 626 + these) to indicate that the allocation should not be tracked 627 + because it would lead to a false positive report. This is a "big 628 + hammer" way of silencing kmemcheck; after all, even if the false 629 + positive pertains to particular field in a struct, for example, we 630 + will now lose the ability to find (real) errors in other parts of 631 + the same struct. 632 + 633 + Example:: 634 + 635 + /* No warnings will ever trigger on accessing any part of x */ 636 + x = kmalloc(sizeof *x, GFP_KERNEL | __GFP_NOTRACK_FALSE_POSITIVE); 637 + 638 + - ``kmemcheck_bitfield_begin(name)``/``kmemcheck_bitfield_end(name)`` and 639 + ``kmemcheck_annotate_bitfield(ptr, name)`` 640 + The first two of these three macros can be used inside struct 641 + definitions to signal, respectively, the beginning and end of a 642 + bitfield. Additionally, this will assign the bitfield a name, which 643 + is given as an argument to the macros. 644 + 645 + Having used these markers, one can later use 646 + kmemcheck_annotate_bitfield() at the point of allocation, to indicate 647 + which parts of the allocation is part of a bitfield. 648 + 649 + Example:: 650 + 651 + struct foo { 652 + int x; 653 + 654 + kmemcheck_bitfield_begin(flags); 655 + int flag_a:1; 656 + int flag_b:1; 657 + kmemcheck_bitfield_end(flags); 658 + 659 + int y; 660 + }; 661 + 662 + struct foo *x = kmalloc(sizeof *x); 663 + 664 + /* No warnings will trigger on accessing the bitfield of x */ 665 + kmemcheck_annotate_bitfield(x, flags); 666 + 667 + Note that ``kmemcheck_annotate_bitfield()`` can be used even before the 668 + return value of ``kmalloc()`` is checked -- in other words, passing NULL 669 + as the first argument is legal (and will do nothing). 670 + 671 + 672 + Reporting errors 673 + ---------------- 674 + 675 + As we have seen, kmemcheck will produce false positive reports. Therefore, it 676 + is not very wise to blindly post kmemcheck warnings to mailing lists and 677 + maintainers. Instead, I encourage maintainers and developers to find errors 678 + in their own code. If you get a warning, you can try to work around it, try 679 + to figure out if it's a real error or not, or simply ignore it. Most 680 + developers know their own code and will quickly and efficiently determine the 681 + root cause of a kmemcheck report. This is therefore also the most efficient 682 + way to work with kmemcheck. 683 + 684 + That said, we (the kmemcheck maintainers) will always be on the lookout for 685 + false positives that we can annotate and silence. So whatever you find, 686 + please drop us a note privately! Kernel configs and steps to reproduce (if 687 + available) are of course a great help too. 688 + 689 + Happy hacking! 690 + 691 + 692 + Technical description 693 + --------------------- 694 + 695 + kmemcheck works by marking memory pages non-present. This means that whenever 696 + somebody attempts to access the page, a page fault is generated. The page 697 + fault handler notices that the page was in fact only hidden, and so it calls 698 + on the kmemcheck code to make further investigations. 699 + 700 + When the investigations are completed, kmemcheck "shows" the page by marking 701 + it present (as it would be under normal circumstances). This way, the 702 + interrupted code can continue as usual. 703 + 704 + But after the instruction has been executed, we should hide the page again, so 705 + that we can catch the next access too! Now kmemcheck makes use of a debugging 706 + feature of the processor, namely single-stepping. When the processor has 707 + finished the one instruction that generated the memory access, a debug 708 + exception is raised. From here, we simply hide the page again and continue 709 + execution, this time with the single-stepping feature turned off. 710 + 711 + kmemcheck requires some assistance from the memory allocator in order to work. 712 + The memory allocator needs to 713 + 714 + 1. Tell kmemcheck about newly allocated pages and pages that are about to 715 + be freed. This allows kmemcheck to set up and tear down the shadow memory 716 + for the pages in question. The shadow memory stores the status of each 717 + byte in the allocation proper, e.g. whether it is initialized or 718 + uninitialized. 719 + 720 + 2. Tell kmemcheck which parts of memory should be marked uninitialized. 721 + There are actually a few more states, such as "not yet allocated" and 722 + "recently freed". 723 + 724 + If a slab cache is set up using the SLAB_NOTRACK flag, it will never return 725 + memory that can take page faults because of kmemcheck. 726 + 727 + If a slab cache is NOT set up using the SLAB_NOTRACK flag, callers can still 728 + request memory with the __GFP_NOTRACK or __GFP_NOTRACK_FALSE_POSITIVE flags. 729 + This does not prevent the page faults from occurring, however, but marks the 730 + object in question as being initialized so that no warnings will ever be 731 + produced for this object. 732 + 733 + Currently, the SLAB and SLUB allocators are supported by kmemcheck.
+25
Documentation/dev-tools/tools.rst
··· 1 + ================================ 2 + Development tools for the kernel 3 + ================================ 4 + 5 + This document is a collection of documents about development tools that can 6 + be used to work on the kernel. For now, the documents have been pulled 7 + together without any significant effot to integrate them into a coherent 8 + whole; patches welcome! 9 + 10 + .. class:: toc-title 11 + 12 + Table of contents 13 + 14 + .. toctree:: 15 + :maxdepth: 2 16 + 17 + coccinelle 18 + sparse 19 + kcov 20 + gcov 21 + kasan 22 + ubsan 23 + kmemleak 24 + kmemcheck 25 + gdb-kernel-debugging
+30 -38
Documentation/development-process/1.Intro Documentation/development-process/1.Intro.rst
··· 1 - 1: A GUIDE TO THE KERNEL DEVELOPMENT PROCESS 1 + Introdution 2 + =========== 2 3 3 - The purpose of this document is to help developers (and their managers) 4 - work with the development community with a minimum of frustration. It is 5 - an attempt to document how this community works in a way which is 6 - accessible to those who are not intimately familiar with Linux kernel 7 - development (or, indeed, free software development in general). While 8 - there is some technical material here, this is very much a process-oriented 9 - discussion which does not require a deep knowledge of kernel programming to 10 - understand. 11 - 12 - 13 - 1.1: EXECUTIVE SUMMARY 4 + Executive summary 5 + ----------------- 14 6 15 7 The rest of this section covers the scope of the kernel development process 16 8 and the kinds of frustrations that developers and their employers can ··· 12 20 influence the direction of kernel development. Code contributed to the 13 21 Linux kernel must be made available under a GPL-compatible license. 14 22 15 - Section 2 introduces the development process, the kernel release cycle, and 16 - the mechanics of the merge window. The various phases in the patch 17 - development, review, and merging cycle are covered. There is some 23 + :ref:`development_process` introduces the development process, the kernel 24 + release cycle, and the mechanics of the merge window. The various phases in 25 + the patch development, review, and merging cycle are covered. There is some 18 26 discussion of tools and mailing lists. Developers wanting to get started 19 27 with kernel development are encouraged to track down and fix bugs as an 20 28 initial exercise. 21 29 22 - Section 3 covers early-stage project planning, with an emphasis on 23 - involving the development community as soon as possible. 30 + :ref:`development_early_stage` covers early-stage project planning, with an 31 + emphasis on involving the development community as soon as possible. 24 32 25 - Section 4 is about the coding process; several pitfalls which have been 26 - encountered by other developers are discussed. Some requirements for 33 + :ref:`development_coding` is about the coding process; several pitfalls which 34 + have been encountered by other developers are discussed. Some requirements for 27 35 patches are covered, and there is an introduction to some of the tools 28 36 which can help to ensure that kernel patches are correct. 29 37 30 - Section 5 talks about the process of posting patches for review. To be 31 - taken seriously by the development community, patches must be properly 32 - formatted and described, and they must be sent to the right place. 38 + :ref:`development_posting` talks about the process of posting patches for 39 + review. To be taken seriously by the development community, patches must be 40 + properly formatted and described, and they must be sent to the right place. 33 41 Following the advice in this section should help to ensure the best 34 42 possible reception for your work. 35 43 36 - Section 6 covers what happens after posting patches; the job is far from 37 - done at that point. Working with reviewers is a crucial part of the 38 - development process; this section offers a number of tips on how to avoid 39 - problems at this important stage. Developers are cautioned against 44 + :ref:`development_followthrough` covers what happens after posting patches; the 45 + job is far from done at that point. Working with reviewers is a crucial part 46 + of the development process; this section offers a number of tips on how to 47 + avoid problems at this important stage. Developers are cautioned against 40 48 assuming that the job is done when a patch is merged into the mainline. 41 49 42 - Section 7 introduces a couple of "advanced" topics: managing patches with 43 - git and reviewing patches posted by others. 50 + :ref:`development_advancedtopics` introduces a couple of "advanced" topics: 51 + managing patches with git and reviewing patches posted by others. 44 52 45 - Section 8 concludes the document with pointers to sources for more 46 - information on kernel development. 53 + :ref:`development_conclusion` concludes the document with pointers to sources 54 + for more information on kernel development. 47 55 48 - 49 - 1.2: WHAT THIS DOCUMENT IS ABOUT 56 + What this document is about 57 + --------------------------- 50 58 51 59 The Linux kernel, at over 8 million lines of code and well over 1000 52 60 contributors to each release, is one of the largest and most active free ··· 100 108 better; the following text should help you - or those who work for you - 101 109 join our community. 102 110 103 - 104 - 1.3: CREDITS 111 + Credits 112 + ------- 105 113 106 114 This document was written by Jonathan Corbet, corbet@lwn.net. It has been 107 115 improved by comments from Johannes Berg, James Berry, Alex Chiang, Roland ··· 112 120 This work was supported by the Linux Foundation; thanks especially to 113 121 Amanda McPherson, who saw the value of this effort and made it all happen. 114 122 115 - 116 - 1.4: THE IMPORTANCE OF GETTING CODE INTO THE MAINLINE 123 + The importance of getting code into the mainline 124 + ------------------------------------------------ 117 125 118 126 Some companies and developers occasionally wonder why they should bother 119 127 learning how to work with the kernel community and get their code into the ··· 225 233 point, vendors whose code is in the mainline and well maintained will be 226 234 much better positioned to get the new product ready for market quickly. 227 235 228 - 229 - 1.5: LICENSING 236 + Licensing 237 + --------- 230 238 231 239 Code is contributed to the Linux kernel under a number of licenses, but all 232 240 code must be compatible with version 2 of the GNU General Public License
+30 -11
Documentation/development-process/2.Process Documentation/development-process/2.Process.rst
··· 1 - 2: HOW THE DEVELOPMENT PROCESS WORKS 1 + .. _development_process: 2 + 3 + How the development process works 4 + ================================= 2 5 3 6 Linux kernel development in the early 1990's was a pretty loose affair, 4 7 with relatively small numbers of users and developers involved. With a ··· 10 7 processes to keep development happening smoothly. A solid understanding of 11 8 how the process works is required in order to be an effective part of it. 12 9 13 - 14 - 2.1: THE BIG PICTURE 10 + The big picture 11 + --------------- 15 12 16 13 The kernel developers use a loosely time-based release process, with a new 17 14 major kernel release happening every two or three months. The recent 18 15 release history looks like this: 19 16 17 + ====== ================= 20 18 2.6.38 March 14, 2011 21 19 2.6.37 January 4, 2011 22 20 2.6.36 October 20, 2010 23 21 2.6.35 August 1, 2010 24 22 2.6.34 May 15, 2010 25 23 2.6.33 February 24, 2010 24 + ====== ================= 26 25 27 26 Every 2.6.x release is a major kernel release with new features, internal 28 27 API changes, and more. A typical 2.6 release can contain nearly 10,000 ··· 73 68 As an example, here is how the 2.6.38 development cycle went (all dates in 74 69 2011): 75 70 71 + ============== =============================== 76 72 January 4 2.6.37 stable release 77 73 January 18 2.6.38-rc1, merge window closes 78 74 January 21 2.6.38-rc2 ··· 84 78 March 1 2.6.38-rc7 85 79 March 7 2.6.38-rc8 86 80 March 14 2.6.38 stable release 81 + ============== =============================== 87 82 88 83 How do the developers decide when to close the development cycle and create 89 84 the stable release? The most significant metric used is the list of ··· 112 105 a little more than one development cycle past their initial release. So, 113 106 for example, the 2.6.36 kernel's history looked like: 114 107 108 + ============== =============================== 115 109 October 10 2.6.36 stable release 116 110 November 22 2.6.36.1 117 111 December 9 2.6.36.2 118 112 January 7 2.6.36.3 119 113 February 17 2.6.36.4 114 + ============== =============================== 120 115 121 116 2.6.36.4 was the final stable update for the 2.6.36 release. 122 117 ··· 126 117 for a longer period. As of this writing, the current long term kernels 127 118 and their maintainers are: 128 119 120 + ====== ====================== =========================== 129 121 2.6.27 Willy Tarreau (Deep-frozen stable kernel) 130 122 2.6.32 Greg Kroah-Hartman 131 123 2.6.35 Andi Kleen (Embedded flag kernel) 124 + ====== ====================== =========================== 132 125 133 126 The selection of a kernel for long-term support is purely a matter of a 134 127 maintainer having the need and the time to maintain that release. There ··· 138 127 release. 139 128 140 129 141 - 2.2: THE LIFECYCLE OF A PATCH 130 + The lifecycle of a patch 131 + ------------------------ 142 132 143 133 Patches do not go directly from the developer's keyboard into the mainline 144 134 kernel. There is, instead, a somewhat involved (if somewhat informal) ··· 207 195 step. This approach invariably leads to frustration for everybody 208 196 involved. 209 197 210 - 211 - 2.3: HOW PATCHES GET INTO THE KERNEL 198 + How patches get into the Kernel 199 + ------------------------------- 212 200 213 201 There is exactly one person who can merge patches into the mainline kernel 214 202 repository: Linus Torvalds. But, of the over 9,500 patches which went ··· 254 242 normally the right way to go. 255 243 256 244 257 - 2.4: NEXT TREES 245 + Next trees 246 + ---------- 258 247 259 248 The chain of subsystem trees guides the flow of patches into the kernel, 260 249 but it also raises an interesting question: what if somebody wants to look ··· 307 294 their way into linux-next some time before the merge window opens. 308 295 309 296 310 - 2.4.1: STAGING TREES 297 + Staging trees 298 + ------------- 311 299 312 300 The kernel source tree contains the drivers/staging/ directory, where 313 301 many sub-directories for drivers or filesystems that are on their way to ··· 336 322 a proper mainline driver. 337 323 338 324 339 - 2.5: TOOLS 325 + Tools 326 + ----- 340 327 341 328 As can be seen from the above text, the kernel development process depends 342 329 heavily on the ability to herd collections of patches in various ··· 383 368 quilt is the best tool for the job. 384 369 385 370 386 - 2.6: MAILING LISTS 371 + Mailing lists 372 + ------------- 387 373 388 374 A great deal of Linux kernel development work is done by way of mailing 389 375 lists. It is hard to be a fully-functioning member of the community ··· 452 436 in the MAINTAINERS file packaged with the kernel source. 453 437 454 438 455 - 2.7: GETTING STARTED WITH KERNEL DEVELOPMENT 439 + Getting started with Kernel development 440 + --------------------------------------- 456 441 457 442 Questions about how to get started with the kernel development process are 458 443 common - from both individuals and companies. Equally common are missteps ··· 479 462 they wish for by these means. 480 463 481 464 Andrew Morton gives this advice for aspiring kernel developers 465 + 466 + :: 482 467 483 468 The #1 project for all kernel beginners should surely be "make sure 484 469 that the kernel runs perfectly at all times on all machines which
+16 -6
Documentation/development-process/3.Early-stage Documentation/development-process/3.Early-stage.rst
··· 1 - 3: EARLY-STAGE PLANNING 1 + .. _development_early_stage: 2 + 3 + Early-stage planning 4 + ==================== 2 5 3 6 When contemplating a Linux kernel development project, it can be tempting 4 7 to jump right in and start coding. As with any significant project, ··· 10 7 communication can save far more time later on. 11 8 12 9 13 - 3.1: SPECIFYING THE PROBLEM 10 + Specifying the problem 11 + ---------------------- 14 12 15 13 Like any engineering project, a successful kernel enhancement starts with a 16 14 clear description of the problem to be solved. In some cases, this step is ··· 68 64 Only then does it make sense to start considering possible solutions. 69 65 70 66 71 - 3.2: EARLY DISCUSSION 67 + Early discussion 68 + ---------------- 72 69 73 70 When planning a kernel development project, it makes great sense to hold 74 71 discussions with the community before launching into implementation. Early ··· 122 117 avoided with some early discussion with the kernel developers. 123 118 124 119 125 - 3.3: WHO DO YOU TALK TO? 120 + Who do you talk to? 121 + ------------------- 126 122 127 123 When developers decide to take their plans public, the next question will 128 124 be: where do we start? The answer is to find the right mailing list(s) and ··· 147 141 The task of finding the right maintainer is sometimes challenging enough 148 142 that the kernel developers have added a script to ease the process: 149 143 144 + :: 145 + 150 146 .../scripts/get_maintainer.pl 151 147 152 148 This script will return the current maintainer(s) for a given file or ··· 163 155 track down a maintainer for a specific piece of code. 164 156 165 157 166 - 3.4: WHEN TO POST? 158 + When to post? 159 + ------------- 167 160 168 161 If possible, posting your plans during the early stages can only be 169 162 helpful. Describe the problem being solved and any plans that have been ··· 188 179 community informed as you go. 189 180 190 181 191 - 3.5: GETTING OFFICIAL BUY-IN 182 + Getting official buy-in 183 + ----------------------- 192 184 193 185 If your work is being done in a corporate environment - as most Linux 194 186 kernel work is - you must, obviously, have permission from suitably
+30 -16
Documentation/development-process/4.Coding Documentation/development-process/4.Coding.rst
··· 1 - 4: GETTING THE CODE RIGHT 1 + .. _development_coding: 2 + 3 + Getting the code right 4 + ====================== 2 5 3 6 While there is much to be said for a solid and community-oriented design 4 7 process, the proof of any kernel development project is in the resulting ··· 15 12 quest. 16 13 17 14 18 - 4.1: PITFALLS 15 + Pitfalls 16 + --------- 19 17 20 - * Coding style 18 + Coding style 19 + ************ 21 20 22 21 The kernel has long had a standard coding style, described in 23 22 Documentation/CodingStyle. For much of that time, the policies described ··· 59 54 80-column limit, for example), just do it. 60 55 61 56 62 - * Abstraction layers 57 + Abstraction layers 58 + ****************** 63 59 64 60 Computer Science professors teach students to make extensive use of 65 61 abstraction layers in the name of flexibility and information hiding. ··· 93 87 replicating the same code throughout the kernel. 94 88 95 89 96 - * #ifdef and preprocessor use in general 90 + #ifdef and preprocessor use in general 91 + ************************************** 97 92 98 93 The C preprocessor seems to present a powerful temptation to some C 99 94 programmers, who see it as a way to efficiently encode a great deal of ··· 120 113 the compiler to perform type checking on the arguments and return value. 121 114 122 115 123 - * Inline functions 116 + Inline functions 117 + **************** 124 118 125 119 Inline functions present a hazard of their own, though. Programmers can 126 120 become enamored of the perceived efficiency inherent in avoiding a function ··· 145 137 irrelevant. 146 138 147 139 148 - * Locking 140 + Locking 141 + ******* 149 142 150 143 In May, 2006, the "Devicescape" networking stack was, with great 151 144 fanfare, released under the GPL and made available for inclusion in the ··· 160 151 corporate doors. But one large problem in particular was that it was not 161 152 designed to work on multiprocessor systems. Before this networking stack 162 153 (now called mac80211) could be merged, a locking scheme needed to be 163 - retrofitted onto it. 154 + retrofitted onto it. 164 155 165 156 Once upon a time, Linux kernel code could be developed without thinking 166 157 about the concurrency issues presented by multiprocessor systems. Now, ··· 178 169 attention to concurrency will have a difficult path into the mainline. 179 170 180 171 181 - * Regressions 172 + Regressions 173 + *********** 182 174 183 175 One final hazard worth mentioning is this: it can be tempting to make a 184 176 change (which may bring big improvements) which causes something to break ··· 194 184 change if it brings new functionality to ten systems for each one it 195 185 breaks? The best answer to this question was expressed by Linus in July, 196 186 2007: 187 + 188 + :: 197 189 198 190 So we don't fix bugs by introducing new problems. That way lies 199 191 madness, and nobody ever knows if you actually make any real ··· 213 201 user-space interfaces is always required. 214 202 215 203 216 - 217 - 4.2: CODE CHECKING TOOLS 204 + Code checking tools 205 + ------------------- 218 206 219 207 For now, at least, the writing of error-free code remains an ideal that few 220 208 of us can reach. What we can hope to do, though, is to catch and fix as ··· 262 250 There are quite a few other debugging options, some of which will be 263 251 discussed below. Some of them have a significant performance impact and 264 252 should not be used all of the time. But some time spent learning the 265 - available options will likely be paid back many times over in short order. 253 + available options will likely be paid back many times over in short order. 266 254 267 255 One of the heavier debugging tools is the locking checker, or "lockdep." 268 256 This tool will track the acquisition and release of every lock (spinlock or ··· 275 263 developers and users) in a deployed system; lockdep allows them to be found 276 264 in an automated manner ahead of time. Code with any sort of non-trivial 277 265 locking should be run with lockdep enabled before being submitted for 278 - inclusion. 266 + inclusion. 279 267 280 268 As a diligent kernel programmer, you will, beyond doubt, check the return 281 269 status of any operation (such as a memory allocation) which can fail. The ··· 312 300 Other kinds of portability errors are best found by compiling your code for 313 301 other architectures. If you do not happen to have an S/390 system or a 314 302 Blackfin development board handy, you can still perform the compilation 315 - step. A large set of cross compilers for x86 systems can be found at 303 + step. A large set of cross compilers for x86 systems can be found at 316 304 317 305 http://www.kernel.org/pub/tools/crosstool/ 318 306 ··· 320 308 embarrassment later. 321 309 322 310 323 - 4.3: DOCUMENTATION 311 + Documentation 312 + ------------- 324 313 325 314 Documentation has often been more the exception than the rule with kernel 326 315 development. Even so, adequate documentation will help to ease the merging ··· 377 364 "cleanup" needs a comment saying why it is done the way it is. And so on. 378 365 379 366 380 - 4.4: INTERNAL API CHANGES 367 + Internal API changes 368 + -------------------- 381 369 382 370 The binary interface provided by the kernel to user space cannot be broken 383 371 except under the most severe circumstances. The kernel's internal
+20 -6
Documentation/development-process/5.Posting Documentation/development-process/5.Posting.rst
··· 1 - 5: POSTING PATCHES 1 + .. _development_posting: 2 + 3 + Posting patches 4 + =============== 2 5 3 6 Sooner or later, the time comes when your work is ready to be presented to 4 7 the community for review and, eventually, inclusion into the mainline ··· 14 11 directory. 15 12 16 13 17 - 5.1: WHEN TO POST 14 + When to post 15 + ------------ 18 16 19 17 There is a constant temptation to avoid posting patches before they are 20 18 completely "ready." For simple patches, that is not a problem. If the ··· 31 27 with the idea that they can help you drive the work in the right direction. 32 28 33 29 34 - 5.2: BEFORE CREATING PATCHES 30 + Before creating patches 31 + ----------------------- 35 32 36 33 There are a number of things which should be done before you consider 37 34 sending patches to the development community. These include: ··· 57 52 always pays back the effort in short order. 58 53 59 54 60 - 5.3: PATCH PREPARATION 55 + Patch preparation 56 + ----------------- 61 57 62 58 The preparation of patches for posting can be a surprising amount of work, 63 59 but, once again, attempting to save time here is not generally advisable ··· 128 122 done. When done properly, though, it is time well spent. 129 123 130 124 131 - 5.4: PATCH FORMATTING AND CHANGELOGS 125 + Patch formatting and changelogs 126 + ------------------------------- 132 127 133 128 So now you have a perfect series of patches for posting, but the work is 134 129 not done quite yet. Each patch needs to be formatted into a message which ··· 146 139 changelogs. This message is usually formatted with the relevant 147 140 subsystem name first, followed by the purpose of the patch. For 148 141 example: 142 + 143 + :: 149 144 150 145 gpio: fix build on CONFIG_GPIO_SYSFS=n 151 146 ··· 201 192 detail in the SubmittingPatches document; what follows here is a brief 202 193 summary. Each of these lines has the format: 203 194 195 + :: 196 + 204 197 tag: Full Name <email address> optional-other-stuff 205 198 206 199 The tags in common use are: ··· 236 225 for addition without the explicit permission of the person named. 237 226 238 227 239 - 5.5: SENDING THE PATCH 228 + Sending the patch 229 + ----------------- 240 230 241 231 Before you mail your patches, there are a couple of other things you should 242 232 take care of: ··· 298 286 299 287 Patches need good subject lines. The canonical format for a patch line is 300 288 something like: 289 + 290 + :: 301 291 302 292 [PATCH nn/mm] subsys: one-line description of the patch 303 293
+10 -4
Documentation/development-process/6.Followthrough Documentation/development-process/6.Followthrough.rst
··· 1 - 6: FOLLOWTHROUGH 1 + .. _development_followthrough: 2 + 3 + Followthrough 4 + ============= 2 5 3 6 At this point, you have followed the guidelines given so far and, with the 4 7 addition of your own engineering skills, have posted a perfect series of ··· 19 16 prevent the inclusion of your patches into the mainline. 20 17 21 18 22 - 6.1: WORKING WITH REVIEWERS 19 + Working with reviewers 20 + ---------------------- 23 21 24 22 A patch of any significance will result in a number of comments from other 25 23 developers as they review the code. Working with reviewers can be, for ··· 101 97 in mind, of course, that he may not agree with you either. 102 98 103 99 104 - 6.2: WHAT HAPPENS NEXT 100 + What happens next 101 + ----------------- 105 102 106 103 If a patch is considered to be a good thing to add to the kernel, and once 107 104 most of the review issues have been resolved, the next step is usually ··· 182 177 afterward. 183 178 184 179 185 - 6.3: OTHER THINGS THAT CAN HAPPEN 180 + Other things that can happen 181 + ----------------------------- 186 182 187 183 One day, you may open your mail client and see that somebody has mailed you 188 184 a patch to your code. That is one of the advantages of having your code
+10 -3
Documentation/development-process/7.AdvancedTopics Documentation/development-process/7.AdvancedTopics.rst
··· 1 - 7: ADVANCED TOPICS 1 + .. _development_advancedtopics: 2 + 3 + Advanced topics 4 + =============== 2 5 3 6 At this point, hopefully, you have a handle on how the development process 4 7 works. There is still more to learn, however! This section will cover a 5 8 number of topics which can be helpful for developers wanting to become a 6 9 regular part of the Linux kernel development process. 7 10 8 - 7.1: MANAGING PATCHES WITH GIT 11 + Managing patches with git 12 + ------------------------- 9 13 10 14 The use of distributed version control for the kernel began in early 2002, 11 15 when Linus first started playing with the proprietary BitKeeper ··· 118 114 thing happening; putting up a git tree with unreviewed or off-topic patches 119 115 can affect your ability to get trees pulled in the future. Quoting Linus: 120 116 117 + :: 118 + 121 119 You can send me patches, but for me to pull a git patch from you, I 122 120 need to know that you know what you're doing, and I need to be able 123 121 to trust things *without* then having to go and check every ··· 147 141 sure that you have remembered to push those changes to the public server. 148 142 149 143 150 - 7.2: REVIEWING PATCHES 144 + Reviewing patches 145 + ----------------- 151 146 152 147 Some readers will certainly object to putting this section with "advanced 153 148 topics" on the grounds that even beginning kernel developers should be
+6 -2
Documentation/development-process/8.Conclusion Documentation/development-process/8.Conclusion.rst
··· 1 - 8: FOR MORE INFORMATION 1 + .. _development_conclusion: 2 + 3 + For more information 4 + ==================== 2 5 3 6 There are numerous sources of information on Linux kernel development and 4 7 related topics. First among those will always be the Documentation ··· 50 47 http://www.kernel.org/pub/software/scm/git/docs/user-manual.html 51 48 52 49 53 - 9: CONCLUSION 50 + Conclusion 51 + ========== 54 52 55 53 Congratulations to anybody who has made it through this long-winded 56 54 document. Hopefully it has provided a helpful understanding of how the
+10
Documentation/development-process/conf.py
··· 1 + # -*- coding: utf-8; mode: python -*- 2 + 3 + project = 'Linux Kernel Development Documentation' 4 + 5 + tags.add("subproject") 6 + 7 + latex_documents = [ 8 + ('index', 'development-process.tex', 'Linux Kernel Development Documentation', 9 + 'The kernel development community', 'manual'), 10 + ]
+29
Documentation/development-process/development-process.rst
··· 1 + .. _development_process_main: 2 + 3 + A guide to the Kernel Development Process 4 + ========================================= 5 + 6 + Contents: 7 + 8 + .. toctree:: 9 + :numbered: 10 + :maxdepth: 2 11 + 12 + 1.Intro 13 + 2.Process 14 + 3.Early-stage 15 + 4.Coding 16 + 5.Posting 17 + 6.Followthrough 18 + 7.AdvancedTopics 19 + 8.Conclusion 20 + 21 + The purpose of this document is to help developers (and their managers) 22 + work with the development community with a minimum of frustration. It is 23 + an attempt to document how this community works in a way which is 24 + accessible to those who are not intimately familiar with Linux kernel 25 + development (or, indeed, free software development in general). While 26 + there is some technical material here, this is very much a process-oriented 27 + discussion which does not require a deep knowledge of kernel programming to 28 + understand. 29 +
+9
Documentation/development-process/index.rst
··· 1 + Linux Kernel Development Documentation 2 + ====================================== 3 + 4 + Contents: 5 + 6 + .. toctree:: 7 + :maxdepth: 2 8 + 9 + development-process
+7
Documentation/docutils.conf
··· 1 + # -*- coding: utf-8 mode: conf-colon -*- 2 + # 3 + # docutils configuration file 4 + # http://docutils.sourceforge.net/docs/user/config.html 5 + 6 + [general] 7 + halt_level: severe
+120
Documentation/driver-api/basics.rst
··· 1 + Driver Basics 2 + ============= 3 + 4 + Driver Entry and Exit points 5 + ---------------------------- 6 + 7 + .. kernel-doc:: include/linux/init.h 8 + :internal: 9 + 10 + Atomic and pointer manipulation 11 + ------------------------------- 12 + 13 + .. kernel-doc:: arch/x86/include/asm/atomic.h 14 + :internal: 15 + 16 + Delaying, scheduling, and timer routines 17 + ---------------------------------------- 18 + 19 + .. kernel-doc:: include/linux/sched.h 20 + :internal: 21 + 22 + .. kernel-doc:: kernel/sched/core.c 23 + :export: 24 + 25 + .. kernel-doc:: kernel/sched/cpupri.c 26 + :internal: 27 + 28 + .. kernel-doc:: kernel/sched/fair.c 29 + :internal: 30 + 31 + .. kernel-doc:: include/linux/completion.h 32 + :internal: 33 + 34 + .. kernel-doc:: kernel/time/timer.c 35 + :export: 36 + 37 + Wait queues and Wake events 38 + --------------------------- 39 + 40 + .. kernel-doc:: include/linux/wait.h 41 + :internal: 42 + 43 + .. kernel-doc:: kernel/sched/wait.c 44 + :export: 45 + 46 + High-resolution timers 47 + ---------------------- 48 + 49 + .. kernel-doc:: include/linux/ktime.h 50 + :internal: 51 + 52 + .. kernel-doc:: include/linux/hrtimer.h 53 + :internal: 54 + 55 + .. kernel-doc:: kernel/time/hrtimer.c 56 + :export: 57 + 58 + Workqueues and Kevents 59 + ---------------------- 60 + 61 + .. kernel-doc:: include/linux/workqueue.h 62 + :internal: 63 + 64 + .. kernel-doc:: kernel/workqueue.c 65 + :export: 66 + 67 + Internal Functions 68 + ------------------ 69 + 70 + .. kernel-doc:: kernel/exit.c 71 + :internal: 72 + 73 + .. kernel-doc:: kernel/signal.c 74 + :internal: 75 + 76 + .. kernel-doc:: include/linux/kthread.h 77 + :internal: 78 + 79 + .. kernel-doc:: kernel/kthread.c 80 + :export: 81 + 82 + Kernel objects manipulation 83 + --------------------------- 84 + 85 + .. kernel-doc:: lib/kobject.c 86 + :export: 87 + 88 + Kernel utility functions 89 + ------------------------ 90 + 91 + .. kernel-doc:: include/linux/kernel.h 92 + :internal: 93 + 94 + .. kernel-doc:: kernel/printk/printk.c 95 + :export: 96 + 97 + .. kernel-doc:: kernel/panic.c 98 + :export: 99 + 100 + .. kernel-doc:: kernel/sys.c 101 + :export: 102 + 103 + .. kernel-doc:: kernel/rcu/srcu.c 104 + :export: 105 + 106 + .. kernel-doc:: kernel/rcu/tree.c 107 + :export: 108 + 109 + .. kernel-doc:: kernel/rcu/tree_plugin.h 110 + :export: 111 + 112 + .. kernel-doc:: kernel/rcu/update.c 113 + :export: 114 + 115 + Device Resource Management 116 + -------------------------- 117 + 118 + .. kernel-doc:: drivers/base/devres.c 119 + :export: 120 +
+62
Documentation/driver-api/frame-buffer.rst
··· 1 + Frame Buffer Library 2 + ==================== 3 + 4 + The frame buffer drivers depend heavily on four data structures. These 5 + structures are declared in include/linux/fb.h. They are fb_info, 6 + fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs. The last 7 + three can be made available to and from userland. 8 + 9 + fb_info defines the current state of a particular video card. Inside 10 + fb_info, there exists a fb_ops structure which is a collection of 11 + needed functions to make fbdev and fbcon work. fb_info is only visible 12 + to the kernel. 13 + 14 + fb_var_screeninfo is used to describe the features of a video card 15 + that are user defined. With fb_var_screeninfo, things such as depth 16 + and the resolution may be defined. 17 + 18 + The next structure is fb_fix_screeninfo. This defines the properties 19 + of a card that are created when a mode is set and can't be changed 20 + otherwise. A good example of this is the start of the frame buffer 21 + memory. This "locks" the address of the frame buffer memory, so that it 22 + cannot be changed or moved. 23 + 24 + The last structure is fb_monospecs. In the old API, there was little 25 + importance for fb_monospecs. This allowed for forbidden things such as 26 + setting a mode of 800x600 on a fix frequency monitor. With the new API, 27 + fb_monospecs prevents such things, and if used correctly, can prevent a 28 + monitor from being cooked. fb_monospecs will not be useful until 29 + kernels 2.5.x. 30 + 31 + Frame Buffer Memory 32 + ------------------- 33 + 34 + .. kernel-doc:: drivers/video/fbdev/core/fbmem.c 35 + :export: 36 + 37 + Frame Buffer Colormap 38 + --------------------- 39 + 40 + .. kernel-doc:: drivers/video/fbdev/core/fbcmap.c 41 + :export: 42 + 43 + Frame Buffer Video Mode Database 44 + -------------------------------- 45 + 46 + .. kernel-doc:: drivers/video/fbdev/core/modedb.c 47 + :internal: 48 + 49 + .. kernel-doc:: drivers/video/fbdev/core/modedb.c 50 + :export: 51 + 52 + Frame Buffer Macintosh Video Mode Database 53 + ------------------------------------------ 54 + 55 + .. kernel-doc:: drivers/video/fbdev/macmodes.c 56 + :export: 57 + 58 + Frame Buffer Fonts 59 + ------------------ 60 + 61 + Refer to the file lib/fonts/fonts.c for more information. 62 +
+88
Documentation/driver-api/hsi.rst
··· 1 + High Speed Synchronous Serial Interface (HSI) 2 + ============================================= 3 + 4 + Introduction 5 + --------------- 6 + 7 + High Speed Syncronous Interface (HSI) is a fullduplex, low latency protocol, 8 + that is optimized for die-level interconnect between an Application Processor 9 + and a Baseband chipset. It has been specified by the MIPI alliance in 2003 and 10 + implemented by multiple vendors since then. 11 + 12 + The HSI interface supports full duplex communication over multiple channels 13 + (typically 8) and is capable of reaching speeds up to 200 Mbit/s. 14 + 15 + The serial protocol uses two signals, DATA and FLAG as combined data and clock 16 + signals and an additional READY signal for flow control. An additional WAKE 17 + signal can be used to wakeup the chips from standby modes. The signals are 18 + commonly prefixed by AC for signals going from the application die to the 19 + cellular die and CA for signals going the other way around. 20 + 21 + :: 22 + 23 + +------------+ +---------------+ 24 + | Cellular | | Application | 25 + | Die | | Die | 26 + | | - - - - - - CAWAKE - - - - - - >| | 27 + | T|------------ CADATA ------------>|R | 28 + | X|------------ CAFLAG ------------>|X | 29 + | |<----------- ACREADY ------------| | 30 + | | | | 31 + | | | | 32 + | |< - - - - - ACWAKE - - - - - - -| | 33 + | R|<----------- ACDATA -------------|T | 34 + | X|<----------- ACFLAG -------------|X | 35 + | |------------ CAREADY ----------->| | 36 + | | | | 37 + | | | | 38 + +------------+ +---------------+ 39 + 40 + HSI Subsystem in Linux 41 + ------------------------- 42 + 43 + In the Linux kernel the hsi subsystem is supposed to be used for HSI devices. 44 + The hsi subsystem contains drivers for hsi controllers including support for 45 + multi-port controllers and provides a generic API for using the HSI ports. 46 + 47 + It also contains HSI client drivers, which make use of the generic API to 48 + implement a protocol used on the HSI interface. These client drivers can 49 + use an arbitrary number of channels. 50 + 51 + hsi-char Device 52 + ------------------ 53 + 54 + Each port automatically registers a generic client driver called hsi_char, 55 + which provides a charecter device for userspace representing the HSI port. 56 + It can be used to communicate via HSI from userspace. Userspace may 57 + configure the hsi_char device using the following ioctl commands: 58 + 59 + HSC_RESET 60 + flush the HSI port 61 + 62 + HSC_SET_PM 63 + enable or disable the client. 64 + 65 + HSC_SEND_BREAK 66 + send break 67 + 68 + HSC_SET_RX 69 + set RX configuration 70 + 71 + HSC_GET_RX 72 + get RX configuration 73 + 74 + HSC_SET_TX 75 + set TX configuration 76 + 77 + HSC_GET_TX 78 + get TX configuration 79 + 80 + The kernel HSI API 81 + ------------------ 82 + 83 + .. kernel-doc:: include/linux/hsi/hsi.h 84 + :internal: 85 + 86 + .. kernel-doc:: drivers/hsi/hsi_core.c 87 + :export: 88 +
+46
Documentation/driver-api/i2c.rst
··· 1 + I\ :sup:`2`\ C and SMBus Subsystem 2 + ================================== 3 + 4 + I\ :sup:`2`\ C (or without fancy typography, "I2C") is an acronym for 5 + the "Inter-IC" bus, a simple bus protocol which is widely used where low 6 + data rate communications suffice. Since it's also a licensed trademark, 7 + some vendors use another name (such as "Two-Wire Interface", TWI) for 8 + the same bus. I2C only needs two signals (SCL for clock, SDA for data), 9 + conserving board real estate and minimizing signal quality issues. Most 10 + I2C devices use seven bit addresses, and bus speeds of up to 400 kHz; 11 + there's a high speed extension (3.4 MHz) that's not yet found wide use. 12 + I2C is a multi-master bus; open drain signaling is used to arbitrate 13 + between masters, as well as to handshake and to synchronize clocks from 14 + slower clients. 15 + 16 + The Linux I2C programming interfaces support only the master side of bus 17 + interactions, not the slave side. The programming interface is 18 + structured around two kinds of driver, and two kinds of device. An I2C 19 + "Adapter Driver" abstracts the controller hardware; it binds to a 20 + physical device (perhaps a PCI device or platform_device) and exposes a 21 + :c:type:`struct i2c_adapter <i2c_adapter>` representing each 22 + I2C bus segment it manages. On each I2C bus segment will be I2C devices 23 + represented by a :c:type:`struct i2c_client <i2c_client>`. 24 + Those devices will be bound to a :c:type:`struct i2c_driver 25 + <i2c_driver>`, which should follow the standard Linux driver 26 + model. (At this writing, a legacy model is more widely used.) There are 27 + functions to perform various I2C protocol operations; at this writing 28 + all such functions are usable only from task context. 29 + 30 + The System Management Bus (SMBus) is a sibling protocol. Most SMBus 31 + systems are also I2C conformant. The electrical constraints are tighter 32 + for SMBus, and it standardizes particular protocol messages and idioms. 33 + Controllers that support I2C can also support most SMBus operations, but 34 + SMBus controllers don't support all the protocol options that an I2C 35 + controller will. There are functions to perform various SMBus protocol 36 + operations, either using I2C primitives or by issuing SMBus commands to 37 + i2c_adapter devices which don't support those I2C operations. 38 + 39 + .. kernel-doc:: include/linux/i2c.h 40 + :internal: 41 + 42 + .. kernel-doc:: drivers/i2c/i2c-boardinfo.c 43 + :functions: i2c_register_board_info 44 + 45 + .. kernel-doc:: drivers/i2c/i2c-core.c 46 + :export:
+26
Documentation/driver-api/index.rst
··· 1 + ======================================== 2 + The Linux driver implementer's API guide 3 + ======================================== 4 + 5 + The kernel offers a wide variety of interfaces to support the development 6 + of device drivers. This document is an only somewhat organized collection 7 + of some of those interfaces — it will hopefully get better over time! The 8 + available subsections can be seen below. 9 + 10 + .. class:: toc-title 11 + 12 + Table of contents 13 + 14 + .. toctree:: 15 + :maxdepth: 2 16 + 17 + basics 18 + infrastructure 19 + message-based 20 + sound 21 + frame-buffer 22 + input 23 + spi 24 + i2c 25 + hsi 26 + miscellaneous
+169
Documentation/driver-api/infrastructure.rst
··· 1 + Device drivers infrastructure 2 + ============================= 3 + 4 + The Basic Device Driver-Model Structures 5 + ---------------------------------------- 6 + 7 + .. kernel-doc:: include/linux/device.h 8 + :internal: 9 + 10 + Device Drivers Base 11 + ------------------- 12 + 13 + .. kernel-doc:: drivers/base/init.c 14 + :internal: 15 + 16 + .. kernel-doc:: drivers/base/driver.c 17 + :export: 18 + 19 + .. kernel-doc:: drivers/base/core.c 20 + :export: 21 + 22 + .. kernel-doc:: drivers/base/syscore.c 23 + :export: 24 + 25 + .. kernel-doc:: drivers/base/class.c 26 + :export: 27 + 28 + .. kernel-doc:: drivers/base/node.c 29 + :internal: 30 + 31 + .. kernel-doc:: drivers/base/firmware_class.c 32 + :export: 33 + 34 + .. kernel-doc:: drivers/base/transport_class.c 35 + :export: 36 + 37 + .. kernel-doc:: drivers/base/dd.c 38 + :export: 39 + 40 + .. kernel-doc:: include/linux/platform_device.h 41 + :internal: 42 + 43 + .. kernel-doc:: drivers/base/platform.c 44 + :export: 45 + 46 + .. kernel-doc:: drivers/base/bus.c 47 + :export: 48 + 49 + Buffer Sharing and Synchronization 50 + ---------------------------------- 51 + 52 + The dma-buf subsystem provides the framework for sharing buffers for 53 + hardware (DMA) access across multiple device drivers and subsystems, and 54 + for synchronizing asynchronous hardware access. 55 + 56 + This is used, for example, by drm "prime" multi-GPU support, but is of 57 + course not limited to GPU use cases. 58 + 59 + The three main components of this are: (1) dma-buf, representing a 60 + sg_table and exposed to userspace as a file descriptor to allow passing 61 + between devices, (2) fence, which provides a mechanism to signal when 62 + one device as finished access, and (3) reservation, which manages the 63 + shared or exclusive fence(s) associated with the buffer. 64 + 65 + dma-buf 66 + ~~~~~~~ 67 + 68 + .. kernel-doc:: drivers/dma-buf/dma-buf.c 69 + :export: 70 + 71 + .. kernel-doc:: include/linux/dma-buf.h 72 + :internal: 73 + 74 + reservation 75 + ~~~~~~~~~~~ 76 + 77 + .. kernel-doc:: drivers/dma-buf/reservation.c 78 + :doc: Reservation Object Overview 79 + 80 + .. kernel-doc:: drivers/dma-buf/reservation.c 81 + :export: 82 + 83 + .. kernel-doc:: include/linux/reservation.h 84 + :internal: 85 + 86 + fence 87 + ~~~~~ 88 + 89 + .. kernel-doc:: drivers/dma-buf/fence.c 90 + :export: 91 + 92 + .. kernel-doc:: include/linux/fence.h 93 + :internal: 94 + 95 + .. kernel-doc:: drivers/dma-buf/seqno-fence.c 96 + :export: 97 + 98 + .. kernel-doc:: include/linux/seqno-fence.h 99 + :internal: 100 + 101 + .. kernel-doc:: drivers/dma-buf/fence-array.c 102 + :export: 103 + 104 + .. kernel-doc:: include/linux/fence-array.h 105 + :internal: 106 + 107 + .. kernel-doc:: drivers/dma-buf/reservation.c 108 + :export: 109 + 110 + .. kernel-doc:: include/linux/reservation.h 111 + :internal: 112 + 113 + .. kernel-doc:: drivers/dma-buf/sync_file.c 114 + :export: 115 + 116 + .. kernel-doc:: include/linux/sync_file.h 117 + :internal: 118 + 119 + Device Drivers DMA Management 120 + ----------------------------- 121 + 122 + .. kernel-doc:: drivers/base/dma-coherent.c 123 + :export: 124 + 125 + .. kernel-doc:: drivers/base/dma-mapping.c 126 + :export: 127 + 128 + Device Drivers Power Management 129 + ------------------------------- 130 + 131 + .. kernel-doc:: drivers/base/power/main.c 132 + :export: 133 + 134 + Device Drivers ACPI Support 135 + --------------------------- 136 + 137 + .. kernel-doc:: drivers/acpi/scan.c 138 + :export: 139 + 140 + .. kernel-doc:: drivers/acpi/scan.c 141 + :internal: 142 + 143 + Device drivers PnP support 144 + -------------------------- 145 + 146 + .. kernel-doc:: drivers/pnp/core.c 147 + :internal: 148 + 149 + .. kernel-doc:: drivers/pnp/card.c 150 + :export: 151 + 152 + .. kernel-doc:: drivers/pnp/driver.c 153 + :internal: 154 + 155 + .. kernel-doc:: drivers/pnp/manager.c 156 + :export: 157 + 158 + .. kernel-doc:: drivers/pnp/support.c 159 + :export: 160 + 161 + Userspace IO devices 162 + -------------------- 163 + 164 + .. kernel-doc:: drivers/uio/uio.c 165 + :export: 166 + 167 + .. kernel-doc:: include/linux/uio_driver.h 168 + :internal: 169 +
+51
Documentation/driver-api/input.rst
··· 1 + Input Subsystem 2 + =============== 3 + 4 + Input core 5 + ---------- 6 + 7 + .. kernel-doc:: include/linux/input.h 8 + :internal: 9 + 10 + .. kernel-doc:: drivers/input/input.c 11 + :export: 12 + 13 + .. kernel-doc:: drivers/input/ff-core.c 14 + :export: 15 + 16 + .. kernel-doc:: drivers/input/ff-memless.c 17 + :export: 18 + 19 + Multitouch Library 20 + ------------------ 21 + 22 + .. kernel-doc:: include/linux/input/mt.h 23 + :internal: 24 + 25 + .. kernel-doc:: drivers/input/input-mt.c 26 + :export: 27 + 28 + Polled input devices 29 + -------------------- 30 + 31 + .. kernel-doc:: include/linux/input-polldev.h 32 + :internal: 33 + 34 + .. kernel-doc:: drivers/input/input-polldev.c 35 + :export: 36 + 37 + Matrix keyboards/keypads 38 + ------------------------ 39 + 40 + .. kernel-doc:: include/linux/input/matrix_keypad.h 41 + :internal: 42 + 43 + Sparse keymap support 44 + --------------------- 45 + 46 + .. kernel-doc:: include/linux/input/sparse-keymap.h 47 + :internal: 48 + 49 + .. kernel-doc:: drivers/input/sparse-keymap.c 50 + :export: 51 +
+12
Documentation/driver-api/message-based.rst
··· 1 + Message-based devices 2 + ===================== 3 + 4 + Fusion message devices 5 + ---------------------- 6 + 7 + .. kernel-doc:: drivers/message/fusion/mptbase.c 8 + :export: 9 + 10 + .. kernel-doc:: drivers/message/fusion/mptscsih.c 11 + :export: 12 +
+50
Documentation/driver-api/miscellaneous.rst
··· 1 + Parallel Port Devices 2 + ===================== 3 + 4 + .. kernel-doc:: include/linux/parport.h 5 + :internal: 6 + 7 + .. kernel-doc:: drivers/parport/ieee1284.c 8 + :export: 9 + 10 + .. kernel-doc:: drivers/parport/share.c 11 + :export: 12 + 13 + .. kernel-doc:: drivers/parport/daisy.c 14 + :internal: 15 + 16 + 16x50 UART Driver 17 + ================= 18 + 19 + .. kernel-doc:: drivers/tty/serial/serial_core.c 20 + :export: 21 + 22 + .. kernel-doc:: drivers/tty/serial/8250/8250_core.c 23 + :export: 24 + 25 + Pulse-Width Modulation (PWM) 26 + ============================ 27 + 28 + Pulse-width modulation is a modulation technique primarily used to 29 + control power supplied to electrical devices. 30 + 31 + The PWM framework provides an abstraction for providers and consumers of 32 + PWM signals. A controller that provides one or more PWM signals is 33 + registered as :c:type:`struct pwm_chip <pwm_chip>`. Providers 34 + are expected to embed this structure in a driver-specific structure. 35 + This structure contains fields that describe a particular chip. 36 + 37 + A chip exposes one or more PWM signal sources, each of which exposed as 38 + a :c:type:`struct pwm_device <pwm_device>`. Operations can be 39 + performed on PWM devices to control the period, duty cycle, polarity and 40 + active state of the signal. 41 + 42 + Note that PWM devices are exclusive resources: they can always only be 43 + used by one consumer at a time. 44 + 45 + .. kernel-doc:: include/linux/pwm.h 46 + :internal: 47 + 48 + .. kernel-doc:: drivers/pwm/core.c 49 + :export: 50 +
+54
Documentation/driver-api/sound.rst
··· 1 + Sound Devices 2 + ============= 3 + 4 + .. kernel-doc:: include/sound/core.h 5 + :internal: 6 + 7 + .. kernel-doc:: sound/sound_core.c 8 + :export: 9 + 10 + .. kernel-doc:: include/sound/pcm.h 11 + :internal: 12 + 13 + .. kernel-doc:: sound/core/pcm.c 14 + :export: 15 + 16 + .. kernel-doc:: sound/core/device.c 17 + :export: 18 + 19 + .. kernel-doc:: sound/core/info.c 20 + :export: 21 + 22 + .. kernel-doc:: sound/core/rawmidi.c 23 + :export: 24 + 25 + .. kernel-doc:: sound/core/sound.c 26 + :export: 27 + 28 + .. kernel-doc:: sound/core/memory.c 29 + :export: 30 + 31 + .. kernel-doc:: sound/core/pcm_memory.c 32 + :export: 33 + 34 + .. kernel-doc:: sound/core/init.c 35 + :export: 36 + 37 + .. kernel-doc:: sound/core/isadma.c 38 + :export: 39 + 40 + .. kernel-doc:: sound/core/control.c 41 + :export: 42 + 43 + .. kernel-doc:: sound/core/pcm_lib.c 44 + :export: 45 + 46 + .. kernel-doc:: sound/core/hwdep.c 47 + :export: 48 + 49 + .. kernel-doc:: sound/core/pcm_native.c 50 + :export: 51 + 52 + .. kernel-doc:: sound/core/memalloc.c 53 + :export: 54 +
+53
Documentation/driver-api/spi.rst
··· 1 + Serial Peripheral Interface (SPI) 2 + ================================= 3 + 4 + SPI is the "Serial Peripheral Interface", widely used with embedded 5 + systems because it is a simple and efficient interface: basically a 6 + multiplexed shift register. Its three signal wires hold a clock (SCK, 7 + often in the range of 1-20 MHz), a "Master Out, Slave In" (MOSI) data 8 + line, and a "Master In, Slave Out" (MISO) data line. SPI is a full 9 + duplex protocol; for each bit shifted out the MOSI line (one per clock) 10 + another is shifted in on the MISO line. Those bits are assembled into 11 + words of various sizes on the way to and from system memory. An 12 + additional chipselect line is usually active-low (nCS); four signals are 13 + normally used for each peripheral, plus sometimes an interrupt. 14 + 15 + The SPI bus facilities listed here provide a generalized interface to 16 + declare SPI busses and devices, manage them according to the standard 17 + Linux driver model, and perform input/output operations. At this time, 18 + only "master" side interfaces are supported, where Linux talks to SPI 19 + peripherals and does not implement such a peripheral itself. (Interfaces 20 + to support implementing SPI slaves would necessarily look different.) 21 + 22 + The programming interface is structured around two kinds of driver, and 23 + two kinds of device. A "Controller Driver" abstracts the controller 24 + hardware, which may be as simple as a set of GPIO pins or as complex as 25 + a pair of FIFOs connected to dual DMA engines on the other side of the 26 + SPI shift register (maximizing throughput). Such drivers bridge between 27 + whatever bus they sit on (often the platform bus) and SPI, and expose 28 + the SPI side of their device as a :c:type:`struct spi_master 29 + <spi_master>`. SPI devices are children of that master, 30 + represented as a :c:type:`struct spi_device <spi_device>` and 31 + manufactured from :c:type:`struct spi_board_info 32 + <spi_board_info>` descriptors which are usually provided by 33 + board-specific initialization code. A :c:type:`struct spi_driver 34 + <spi_driver>` is called a "Protocol Driver", and is bound to a 35 + spi_device using normal driver model calls. 36 + 37 + The I/O model is a set of queued messages. Protocol drivers submit one 38 + or more :c:type:`struct spi_message <spi_message>` objects, 39 + which are processed and completed asynchronously. (There are synchronous 40 + wrappers, however.) Messages are built from one or more 41 + :c:type:`struct spi_transfer <spi_transfer>` objects, each of 42 + which wraps a full duplex SPI transfer. A variety of protocol tweaking 43 + options are needed, because different chips adopt very different 44 + policies for how they use the bits transferred with SPI. 45 + 46 + .. kernel-doc:: include/linux/spi/spi.h 47 + :internal: 48 + 49 + .. kernel-doc:: drivers/spi/spi.c 50 + :functions: spi_register_board_info 51 + 52 + .. kernel-doc:: drivers/spi/spi.c 53 + :export:
+1 -1
Documentation/driver-model/device.txt
··· 50 50 Please see Documentation/filesystems/sysfs.txt for more information 51 51 on how sysfs works. 52 52 53 - As explained in Documentation/kobject.txt, device attributes must be be 53 + As explained in Documentation/kobject.txt, device attributes must be 54 54 created before the KOBJ_ADD uevent is generated. The only way to realize 55 55 that is by defining an attribute group. 56 56
+116 -96
Documentation/email-clients.txt
··· 1 + .. _email_clients: 2 + 1 3 Email clients info for Linux 2 - ====================================================================== 4 + ============================ 3 5 4 6 Git 5 - ---------------------------------------------------------------------- 6 - These days most developers use `git send-email` instead of regular 7 - email clients. The man page for this is quite good. On the receiving 8 - end, maintainers use `git am` to apply the patches. 7 + --- 9 8 10 - If you are new to git then send your first patch to yourself. Save it 11 - as raw text including all the headers. Run `git am raw_email.txt` and 12 - then review the changelog with `git log`. When that works then send 9 + These days most developers use ``git send-email`` instead of regular 10 + email clients. The man page for this is quite good. On the receiving 11 + end, maintainers use ``git am`` to apply the patches. 12 + 13 + If you are new to ``git`` then send your first patch to yourself. Save it 14 + as raw text including all the headers. Run ``git am raw_email.txt`` and 15 + then review the changelog with ``git log``. When that works then send 13 16 the patch to the appropriate mailing list(s). 14 17 15 18 General Preferences 16 - ---------------------------------------------------------------------- 19 + ------------------- 20 + 17 21 Patches for the Linux kernel are submitted via email, preferably as 18 22 inline text in the body of the email. Some maintainers accept 19 23 attachments, but then the attachments should have content-type 20 - "text/plain". However, attachments are generally frowned upon because 24 + ``text/plain``. However, attachments are generally frowned upon because 21 25 it makes quoting portions of the patch more difficult in the patch 22 26 review process. 23 27 ··· 29 25 patch text untouched. For example, they should not modify or delete tabs 30 26 or spaces, even at the beginning or end of lines. 31 27 32 - Don't send patches with "format=flowed". This can cause unexpected 28 + Don't send patches with ``format=flowed``. This can cause unexpected 33 29 and unwanted line breaks. 34 30 35 31 Don't let your email client do automatic word wrapping for you. ··· 58 54 59 55 60 56 Some email client (MUA) hints 61 - ---------------------------------------------------------------------- 57 + ----------------------------- 58 + 62 59 Here are some specific MUA configuration hints for editing and sending 63 60 patches for the Linux kernel. These are not meant to be complete 64 61 software package configuration summaries. 65 62 66 - Legend: 67 - TUI = text-based user interface 68 - GUI = graphical user interface 69 63 70 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 + Legend: 65 + 66 + - TUI = text-based user interface 67 + - GUI = graphical user interface 68 + 71 69 Alpine (TUI) 70 + ************ 72 71 73 72 Config options: 74 - In the "Sending Preferences" section: 75 73 76 - - "Do Not Send Flowed Text" must be enabled 77 - - "Strip Whitespace Before Sending" must be disabled 74 + In the :menuselection:`Sending Preferences` section: 75 + 76 + - :menuselection:`Do Not Send Flowed Text` must be ``enabled`` 77 + - :menuselection:`Strip Whitespace Before Sending` must be ``disabled`` 78 78 79 79 When composing the message, the cursor should be placed where the patch 80 - should appear, and then pressing CTRL-R let you specify the patch file 80 + should appear, and then pressing :kbd:`CTRL-R` let you specify the patch file 81 81 to insert into the message. 82 82 83 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 84 83 Claws Mail (GUI) 84 + **************** 85 85 86 86 Works. Some people use this successfully for patches. 87 87 88 - To insert a patch use Message->Insert File (CTRL+i) or an external editor. 88 + To insert a patch use :menuselection:`Message-->Insert` File (:kbd:`CTRL-I`) 89 + or an external editor. 89 90 90 91 If the inserted patch has to be edited in the Claws composition window 91 - "Auto wrapping" in Configuration->Preferences->Compose->Wrapping should be 92 + "Auto wrapping" in 93 + :menuselection:`Configuration-->Preferences-->Compose-->Wrapping` should be 92 94 disabled. 93 95 94 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 95 96 Evolution (GUI) 97 + *************** 96 98 97 99 Some people use this successfully for patches. 98 100 99 101 When composing mail select: Preformat 100 - from Format->Paragraph Style->Preformatted (Ctrl-7) 102 + from :menuselection:`Format-->Paragraph Style-->Preformatted` (:kbd:`CTRL-7`) 101 103 or the toolbar 102 104 103 105 Then use: 104 - Insert->Text File... (Alt-n x) 106 + :menuselection:`Insert-->Text File...` (:kbd:`ALT-N x`) 105 107 to insert the patch. 106 108 107 - You can also "diff -Nru old.c new.c | xclip", select Preformat, then 108 - paste with the middle button. 109 + You can also ``diff -Nru old.c new.c | xclip``, select 110 + :menuselection:`Preformat`, then paste with the middle button. 109 111 110 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 112 Kmail (GUI) 113 + *********** 112 114 113 115 Some people use Kmail successfully for patches. 114 116 ··· 130 120 wrapping. 131 121 132 122 At the bottom of your email, put the commonly-used patch delimiter before 133 - inserting your patch: three hyphens (---). 123 + inserting your patch: three hyphens (``---``). 134 124 135 - Then from the "Message" menu item, select insert file and choose your patch. 125 + Then from the :menuselection:`Message` menu item, select insert file and 126 + choose your patch. 136 127 As an added bonus you can customise the message creation toolbar menu 137 - and put the "insert file" icon there. 128 + and put the :menuselection:`insert file` icon there. 138 129 139 130 Make the composer window wide enough so that no lines wrap. As of 140 131 KMail 1.13.5 (KDE 4.5.4), KMail will apply word wrapping when sending ··· 150 139 151 140 If you absolutely must send patches as attachments instead of inlining 152 141 them as text, right click on the attachment and select properties, and 153 - highlight "Suggest automatic display" to make the attachment inlined to 154 - make it more viewable. 142 + highlight :menuselection:`Suggest automatic display` to make the attachment 143 + inlined to make it more viewable. 155 144 156 145 When saving patches that are sent as inlined text, select the email that 157 146 contains the patch from the message list pane, right click and select 158 - "save as". You can use the whole email unmodified as a patch if it was 159 - properly composed. There is no option currently to save the email when you 160 - are actually viewing it in its own window -- there has been a request filed 161 - at kmail's bugzilla and hopefully this will be addressed. Emails are saved 162 - as read-write for user only so you will have to chmod them to make them 147 + :menuselection:`save as`. You can use the whole email unmodified as a patch 148 + if it was properly composed. There is no option currently to save the email 149 + when you are actually viewing it in its own window -- there has been a request 150 + filed at kmail's bugzilla and hopefully this will be addressed. Emails are 151 + saved as read-write for user only so you will have to chmod them to make them 163 152 group and world readable if you copy them elsewhere. 164 153 165 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 166 154 Lotus Notes (GUI) 155 + ***************** 167 156 168 157 Run away from it. 169 158 170 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 171 159 Mutt (TUI) 160 + ********** 172 161 173 - Plenty of Linux developers use mutt, so it must work pretty well. 162 + Plenty of Linux developers use ``mutt``, so it must work pretty well. 174 163 175 164 Mutt doesn't come with an editor, so whatever editor you use should be 176 165 used in a way that there are no automatic linebreaks. Most editors have 177 - an "insert file" option that inserts the contents of a file unaltered. 166 + an :menuselection:`insert file` option that inserts the contents of a file 167 + unaltered. 178 168 179 - To use 'vim' with mutt: 169 + To use ``vim`` with mutt:: 170 + 180 171 set editor="vi" 181 172 182 - If using xclip, type the command 173 + If using xclip, type the command:: 174 + 183 175 :set paste 184 - before middle button or shift-insert or use 176 + 177 + before middle button or shift-insert or use:: 178 + 185 179 :r filename 186 180 187 181 if you want to include the patch inline. 188 - (a)ttach works fine without "set paste". 182 + (a)ttach works fine without ``set paste``. 189 183 190 - You can also generate patches with 'git format-patch' and then use Mutt 191 - to send them: 184 + You can also generate patches with ``git format-patch`` and then use Mutt 185 + to send them:: 186 + 192 187 $ mutt -H 0001-some-bug-fix.patch 193 188 194 189 Config options: 190 + 195 191 It should work with default settings. 196 - However, it's a good idea to set the "send_charset" to: 192 + However, it's a good idea to set the ``send_charset`` to:: 193 + 197 194 set send_charset="us-ascii:utf-8" 198 195 199 196 Mutt is highly customizable. Here is a minimum configuration to start 200 - using Mutt to send patches through Gmail: 197 + using Mutt to send patches through Gmail:: 201 198 202 - # .muttrc 203 - # ================ IMAP ==================== 204 - set imap_user = 'yourusername@gmail.com' 205 - set imap_pass = 'yourpassword' 206 - set spoolfile = imaps://imap.gmail.com/INBOX 207 - set folder = imaps://imap.gmail.com/ 208 - set record="imaps://imap.gmail.com/[Gmail]/Sent Mail" 209 - set postponed="imaps://imap.gmail.com/[Gmail]/Drafts" 210 - set mbox="imaps://imap.gmail.com/[Gmail]/All Mail" 199 + # .muttrc 200 + # ================ IMAP ==================== 201 + set imap_user = 'yourusername@gmail.com' 202 + set imap_pass = 'yourpassword' 203 + set spoolfile = imaps://imap.gmail.com/INBOX 204 + set folder = imaps://imap.gmail.com/ 205 + set record="imaps://imap.gmail.com/[Gmail]/Sent Mail" 206 + set postponed="imaps://imap.gmail.com/[Gmail]/Drafts" 207 + set mbox="imaps://imap.gmail.com/[Gmail]/All Mail" 211 208 212 - # ================ SMTP ==================== 213 - set smtp_url = "smtp://username@smtp.gmail.com:587/" 214 - set smtp_pass = $imap_pass 215 - set ssl_force_tls = yes # Require encrypted connection 209 + # ================ SMTP ==================== 210 + set smtp_url = "smtp://username@smtp.gmail.com:587/" 211 + set smtp_pass = $imap_pass 212 + set ssl_force_tls = yes # Require encrypted connection 216 213 217 - # ================ Composition ==================== 218 - set editor = `echo \$EDITOR` 219 - set edit_headers = yes # See the headers when editing 220 - set charset = UTF-8 # value of $LANG; also fallback for send_charset 221 - # Sender, email address, and sign-off line must match 222 - unset use_domain # because joe@localhost is just embarrassing 223 - set realname = "YOUR NAME" 224 - set from = "username@gmail.com" 225 - set use_from = yes 214 + # ================ Composition ==================== 215 + set editor = `echo \$EDITOR` 216 + set edit_headers = yes # See the headers when editing 217 + set charset = UTF-8 # value of $LANG; also fallback for send_charset 218 + # Sender, email address, and sign-off line must match 219 + unset use_domain # because joe@localhost is just embarrassing 220 + set realname = "YOUR NAME" 221 + set from = "username@gmail.com" 222 + set use_from = yes 226 223 227 224 The Mutt docs have lots more information: 225 + 228 226 http://dev.mutt.org/trac/wiki/UseCases/Gmail 227 + 229 228 http://dev.mutt.org/doc/manual.html 230 229 231 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 232 230 Pine (TUI) 231 + ********** 233 232 234 233 Pine has had some whitespace truncation issues in the past, but these 235 234 should all be fixed now. ··· 247 226 Use alpine (pine's successor) if you can. 248 227 249 228 Config options: 250 - - quell-flowed-text is needed for recent versions 251 - - the "no-strip-whitespace-before-send" option is needed 229 + 230 + - ``quell-flowed-text`` is needed for recent versions 231 + - the ``no-strip-whitespace-before-send`` option is needed 252 232 253 233 254 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 255 234 Sylpheed (GUI) 235 + ************** 256 236 257 237 - Works well for inlining text (or using attachments). 258 238 - Allows use of an external editor. ··· 263 241 - Adding addresses to address book doesn't understand the display name 264 242 properly. 265 243 266 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 267 244 Thunderbird (GUI) 245 + ***************** 268 246 269 247 Thunderbird is an Outlook clone that likes to mangle text, but there are ways 270 248 to coerce it into behaving. 271 249 272 250 - Allow use of an external editor: 273 251 The easiest thing to do with Thunderbird and patches is to use an 274 - "external editor" extension and then just use your favorite $EDITOR 252 + "external editor" extension and then just use your favorite ``$EDITOR`` 275 253 for reading/merging patches into the body text. To do this, download 276 254 and install the extension, then add a button for it using 277 - View->Toolbars->Customize... and finally just click on it when in the 278 - Compose dialog. 255 + :menuselection:`View-->Toolbars-->Customize...` and finally just click on it 256 + when in the :menuselection:`Compose` dialog. 279 257 280 258 Please note that "external editor" requires that your editor must not 281 259 fork, or in other words, the editor must not return before closing. 282 260 You may have to pass additional flags or change the settings of your 283 261 editor. Most notably if you are using gvim then you must pass the -f 284 - option to gvim by putting "/usr/bin/gvim -f" (if the binary is in 285 - /usr/bin) to the text editor field in "external editor" settings. If you 286 - are using some other editor then please read its manual to find out how 287 - to do this. 262 + option to gvim by putting ``/usr/bin/gvim -f`` (if the binary is in 263 + ``/usr/bin``) to the text editor field in :menuselection:`external editor` 264 + settings. If you are using some other editor then please read its manual 265 + to find out how to do this. 288 266 289 267 To beat some sense out of the internal editor, do this: 290 268 291 - - Edit your Thunderbird config settings so that it won't use format=flowed. 292 - Go to "edit->preferences->advanced->config editor" to bring up the 293 - thunderbird's registry editor. 269 + - Edit your Thunderbird config settings so that it won't use ``format=flowed``. 270 + Go to :menuselection:`edit-->preferences-->advanced-->config editor` to bring up 271 + the thunderbird's registry editor. 294 272 295 - - Set "mailnews.send_plaintext_flowed" to "false" 273 + - Set ``mailnews.send_plaintext_flowed`` to ``false`` 296 274 297 - - Set "mailnews.wraplength" from "72" to "0" 275 + - Set ``mailnews.wraplength`` from ``72`` to ``0`` 298 276 299 - - "View" > "Message Body As" > "Plain Text" 277 + - :menuselection:`View-->Message Body As-->Plain Text` 300 278 301 - - "View" > "Character Encoding" > "Unicode (UTF-8)" 279 + - :menuselection:`View-->Character Encoding-->Unicode (UTF-8)` 302 280 303 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 304 281 TkRat (GUI) 282 + *********** 305 283 306 284 Works. Use "Insert file..." or external editor. 307 285 308 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 309 286 Gmail (Web GUI) 287 + *************** 310 288 311 289 Does not work for sending patches. 312 290 ··· 317 295 318 296 Another problem is that Gmail will base64-encode any message that has a 319 297 non-ASCII character. That includes things like European names. 320 - 321 - ###
+9 -6
Documentation/filesystems/dax.txt
··· 123 123 mapped caches such as ARM, MIPS and SPARC. 124 124 125 125 Calling get_user_pages() on a range of user memory that has been mmaped 126 - from a DAX file will fail as there are no 'struct page' to describe 127 - those pages. This problem is being worked on. That means that O_DIRECT 128 - reads/writes to those memory ranges from a non-DAX file will fail (note 129 - that O_DIRECT reads/writes _of a DAX file_ do work, it is the memory 130 - that is being accessed that is key here). Other things that will not 131 - work include RDMA, sendfile() and splice(). 126 + from a DAX file will fail when there are no 'struct page' to describe 127 + those pages. This problem has been addressed in some device drivers 128 + by adding optional struct page support for pages under the control of 129 + the driver (see CONFIG_NVDIMM_PFN in drivers/nvdimm for an example of 130 + how to do this). In the non struct page cases O_DIRECT reads/writes to 131 + those memory ranges from a non-DAX file will fail (note that O_DIRECT 132 + reads/writes _of a DAX file_ do work, it is the memory that is being 133 + accessed that is key here). Other things that will not work in the 134 + non struct page case include RDMA, sendfile() and splice().
+1 -1
Documentation/filesystems/proc.txt
··· 145 145 symbol the task is blocked in - or "0" if not blocked. 146 146 pagemap Page table 147 147 stack Report full stack trace, enable via CONFIG_STACKTRACE 148 - smaps a extension based on maps, showing the memory consumption of 148 + smaps an extension based on maps, showing the memory consumption of 149 149 each mapping and flags associated with it 150 150 numa_maps an extension based on maps, showing the memory locality and 151 151 binding policy as well as mem usage (in pages) of each mapping.
-257
Documentation/gcov.txt
··· 1 - Using gcov with the Linux kernel 2 - ================================ 3 - 4 - 1. Introduction 5 - 2. Preparation 6 - 3. Customization 7 - 4. Files 8 - 5. Modules 9 - 6. Separated build and test machines 10 - 7. Troubleshooting 11 - Appendix A: sample script: gather_on_build.sh 12 - Appendix B: sample script: gather_on_test.sh 13 - 14 - 15 - 1. Introduction 16 - =============== 17 - 18 - gcov profiling kernel support enables the use of GCC's coverage testing 19 - tool gcov [1] with the Linux kernel. Coverage data of a running kernel 20 - is exported in gcov-compatible format via the "gcov" debugfs directory. 21 - To get coverage data for a specific file, change to the kernel build 22 - directory and use gcov with the -o option as follows (requires root): 23 - 24 - # cd /tmp/linux-out 25 - # gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c 26 - 27 - This will create source code files annotated with execution counts 28 - in the current directory. In addition, graphical gcov front-ends such 29 - as lcov [2] can be used to automate the process of collecting data 30 - for the entire kernel and provide coverage overviews in HTML format. 31 - 32 - Possible uses: 33 - 34 - * debugging (has this line been reached at all?) 35 - * test improvement (how do I change my test to cover these lines?) 36 - * minimizing kernel configurations (do I need this option if the 37 - associated code is never run?) 38 - 39 - -- 40 - 41 - [1] http://gcc.gnu.org/onlinedocs/gcc/Gcov.html 42 - [2] http://ltp.sourceforge.net/coverage/lcov.php 43 - 44 - 45 - 2. Preparation 46 - ============== 47 - 48 - Configure the kernel with: 49 - 50 - CONFIG_DEBUG_FS=y 51 - CONFIG_GCOV_KERNEL=y 52 - 53 - select the gcc's gcov format, default is autodetect based on gcc version: 54 - 55 - CONFIG_GCOV_FORMAT_AUTODETECT=y 56 - 57 - and to get coverage data for the entire kernel: 58 - 59 - CONFIG_GCOV_PROFILE_ALL=y 60 - 61 - Note that kernels compiled with profiling flags will be significantly 62 - larger and run slower. Also CONFIG_GCOV_PROFILE_ALL may not be supported 63 - on all architectures. 64 - 65 - Profiling data will only become accessible once debugfs has been 66 - mounted: 67 - 68 - mount -t debugfs none /sys/kernel/debug 69 - 70 - 71 - 3. Customization 72 - ================ 73 - 74 - To enable profiling for specific files or directories, add a line 75 - similar to the following to the respective kernel Makefile: 76 - 77 - For a single file (e.g. main.o): 78 - GCOV_PROFILE_main.o := y 79 - 80 - For all files in one directory: 81 - GCOV_PROFILE := y 82 - 83 - To exclude files from being profiled even when CONFIG_GCOV_PROFILE_ALL 84 - is specified, use: 85 - 86 - GCOV_PROFILE_main.o := n 87 - and: 88 - GCOV_PROFILE := n 89 - 90 - Only files which are linked to the main kernel image or are compiled as 91 - kernel modules are supported by this mechanism. 92 - 93 - 94 - 4. Files 95 - ======== 96 - 97 - The gcov kernel support creates the following files in debugfs: 98 - 99 - /sys/kernel/debug/gcov 100 - Parent directory for all gcov-related files. 101 - 102 - /sys/kernel/debug/gcov/reset 103 - Global reset file: resets all coverage data to zero when 104 - written to. 105 - 106 - /sys/kernel/debug/gcov/path/to/compile/dir/file.gcda 107 - The actual gcov data file as understood by the gcov 108 - tool. Resets file coverage data to zero when written to. 109 - 110 - /sys/kernel/debug/gcov/path/to/compile/dir/file.gcno 111 - Symbolic link to a static data file required by the gcov 112 - tool. This file is generated by gcc when compiling with 113 - option -ftest-coverage. 114 - 115 - 116 - 5. Modules 117 - ========== 118 - 119 - Kernel modules may contain cleanup code which is only run during 120 - module unload time. The gcov mechanism provides a means to collect 121 - coverage data for such code by keeping a copy of the data associated 122 - with the unloaded module. This data remains available through debugfs. 123 - Once the module is loaded again, the associated coverage counters are 124 - initialized with the data from its previous instantiation. 125 - 126 - This behavior can be deactivated by specifying the gcov_persist kernel 127 - parameter: 128 - 129 - gcov_persist=0 130 - 131 - At run-time, a user can also choose to discard data for an unloaded 132 - module by writing to its data file or the global reset file. 133 - 134 - 135 - 6. Separated build and test machines 136 - ==================================== 137 - 138 - The gcov kernel profiling infrastructure is designed to work out-of-the 139 - box for setups where kernels are built and run on the same machine. In 140 - cases where the kernel runs on a separate machine, special preparations 141 - must be made, depending on where the gcov tool is used: 142 - 143 - a) gcov is run on the TEST machine 144 - 145 - The gcov tool version on the test machine must be compatible with the 146 - gcc version used for kernel build. Also the following files need to be 147 - copied from build to test machine: 148 - 149 - from the source tree: 150 - - all C source files + headers 151 - 152 - from the build tree: 153 - - all C source files + headers 154 - - all .gcda and .gcno files 155 - - all links to directories 156 - 157 - It is important to note that these files need to be placed into the 158 - exact same file system location on the test machine as on the build 159 - machine. If any of the path components is symbolic link, the actual 160 - directory needs to be used instead (due to make's CURDIR handling). 161 - 162 - b) gcov is run on the BUILD machine 163 - 164 - The following files need to be copied after each test case from test 165 - to build machine: 166 - 167 - from the gcov directory in sysfs: 168 - - all .gcda files 169 - - all links to .gcno files 170 - 171 - These files can be copied to any location on the build machine. gcov 172 - must then be called with the -o option pointing to that directory. 173 - 174 - Example directory setup on the build machine: 175 - 176 - /tmp/linux: kernel source tree 177 - /tmp/out: kernel build directory as specified by make O= 178 - /tmp/coverage: location of the files copied from the test machine 179 - 180 - [user@build] cd /tmp/out 181 - [user@build] gcov -o /tmp/coverage/tmp/out/init main.c 182 - 183 - 184 - 7. Troubleshooting 185 - ================== 186 - 187 - Problem: Compilation aborts during linker step. 188 - Cause: Profiling flags are specified for source files which are not 189 - linked to the main kernel or which are linked by a custom 190 - linker procedure. 191 - Solution: Exclude affected source files from profiling by specifying 192 - GCOV_PROFILE := n or GCOV_PROFILE_basename.o := n in the 193 - corresponding Makefile. 194 - 195 - Problem: Files copied from sysfs appear empty or incomplete. 196 - Cause: Due to the way seq_file works, some tools such as cp or tar 197 - may not correctly copy files from sysfs. 198 - Solution: Use 'cat' to read .gcda files and 'cp -d' to copy links. 199 - Alternatively use the mechanism shown in Appendix B. 200 - 201 - 202 - Appendix A: gather_on_build.sh 203 - ============================== 204 - 205 - Sample script to gather coverage meta files on the build machine 206 - (see 6a): 207 - #!/bin/bash 208 - 209 - KSRC=$1 210 - KOBJ=$2 211 - DEST=$3 212 - 213 - if [ -z "$KSRC" ] || [ -z "$KOBJ" ] || [ -z "$DEST" ]; then 214 - echo "Usage: $0 <ksrc directory> <kobj directory> <output.tar.gz>" >&2 215 - exit 1 216 - fi 217 - 218 - KSRC=$(cd $KSRC; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) 219 - KOBJ=$(cd $KOBJ; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) 220 - 221 - find $KSRC $KOBJ \( -name '*.gcno' -o -name '*.[ch]' -o -type l \) -a \ 222 - -perm /u+r,g+r | tar cfz $DEST -P -T - 223 - 224 - if [ $? -eq 0 ] ; then 225 - echo "$DEST successfully created, copy to test system and unpack with:" 226 - echo " tar xfz $DEST -P" 227 - else 228 - echo "Could not create file $DEST" 229 - fi 230 - 231 - 232 - Appendix B: gather_on_test.sh 233 - ============================= 234 - 235 - Sample script to gather coverage data files on the test machine 236 - (see 6b): 237 - 238 - #!/bin/bash -e 239 - 240 - DEST=$1 241 - GCDA=/sys/kernel/debug/gcov 242 - 243 - if [ -z "$DEST" ] ; then 244 - echo "Usage: $0 <output.tar.gz>" >&2 245 - exit 1 246 - fi 247 - 248 - TEMPDIR=$(mktemp -d) 249 - echo Collecting data.. 250 - find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \; 251 - find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \; 252 - find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \; 253 - tar czf $DEST -C $TEMPDIR sys 254 - rm -rf $TEMPDIR 255 - 256 - echo "$DEST successfully created, copy to build system and unpack with:" 257 - echo " tar xfz $DEST"
+45 -32
Documentation/gdb-kernel-debugging.txt Documentation/dev-tools/gdb-kernel-debugging.rst
··· 1 + .. highlight:: none 2 + 1 3 Debugging kernel and modules via gdb 2 4 ==================================== 3 5 ··· 15 13 Requirements 16 14 ------------ 17 15 18 - o gdb 7.2+ (recommended: 7.4+) with python support enabled (typically true 19 - for distributions) 16 + - gdb 7.2+ (recommended: 7.4+) with python support enabled (typically true 17 + for distributions) 20 18 21 19 22 20 Setup 23 21 ----- 24 22 25 - o Create a virtual Linux machine for QEMU/KVM (see www.linux-kvm.org and 26 - www.qemu.org for more details). For cross-development, 27 - http://landley.net/aboriginal/bin keeps a pool of machine images and 28 - toolchains that can be helpful to start from. 23 + - Create a virtual Linux machine for QEMU/KVM (see www.linux-kvm.org and 24 + www.qemu.org for more details). For cross-development, 25 + http://landley.net/aboriginal/bin keeps a pool of machine images and 26 + toolchains that can be helpful to start from. 29 27 30 - o Build the kernel with CONFIG_GDB_SCRIPTS enabled, but leave 31 - CONFIG_DEBUG_INFO_REDUCED off. If your architecture supports 32 - CONFIG_FRAME_POINTER, keep it enabled. 28 + - Build the kernel with CONFIG_GDB_SCRIPTS enabled, but leave 29 + CONFIG_DEBUG_INFO_REDUCED off. If your architecture supports 30 + CONFIG_FRAME_POINTER, keep it enabled. 33 31 34 - o Install that kernel on the guest. 32 + - Install that kernel on the guest. 33 + Alternatively, QEMU allows to boot the kernel directly using -kernel, 34 + -append, -initrd command line switches. This is generally only useful if 35 + you do not depend on modules. See QEMU documentation for more details on 36 + this mode. 35 37 36 - Alternatively, QEMU allows to boot the kernel directly using -kernel, 37 - -append, -initrd command line switches. This is generally only useful if 38 - you do not depend on modules. See QEMU documentation for more details on 39 - this mode. 38 + - Enable the gdb stub of QEMU/KVM, either 40 39 41 - o Enable the gdb stub of QEMU/KVM, either 42 40 - at VM startup time by appending "-s" to the QEMU command line 43 - or 41 + 42 + or 43 + 44 44 - during runtime by issuing "gdbserver" from the QEMU monitor 45 45 console 46 46 47 - o cd /path/to/linux-build 47 + - cd /path/to/linux-build 48 48 49 - o Start gdb: gdb vmlinux 49 + - Start gdb: gdb vmlinux 50 50 51 - Note: Some distros may restrict auto-loading of gdb scripts to known safe 52 - directories. In case gdb reports to refuse loading vmlinux-gdb.py, add 51 + Note: Some distros may restrict auto-loading of gdb scripts to known safe 52 + directories. In case gdb reports to refuse loading vmlinux-gdb.py, add:: 53 53 54 54 add-auto-load-safe-path /path/to/linux-build 55 55 56 - to ~/.gdbinit. See gdb help for more details. 56 + to ~/.gdbinit. See gdb help for more details. 57 57 58 - o Attach to the booted guest: 58 + - Attach to the booted guest:: 59 + 59 60 (gdb) target remote :1234 60 61 61 62 62 63 Examples of using the Linux-provided gdb helpers 63 64 ------------------------------------------------ 64 65 65 - o Load module (and main kernel) symbols: 66 + - Load module (and main kernel) symbols:: 67 + 66 68 (gdb) lx-symbols 67 69 loading vmlinux 68 70 scanning for modules in /home/user/linux/build ··· 78 72 ... 79 73 loading @0xffffffffa0000000: /home/user/linux/build/drivers/ata/ata_generic.ko 80 74 81 - o Set a breakpoint on some not yet loaded module function, e.g.: 75 + - Set a breakpoint on some not yet loaded module function, e.g.:: 76 + 82 77 (gdb) b btrfs_init_sysfs 83 78 Function "btrfs_init_sysfs" not defined. 84 79 Make breakpoint pending on future shared library load? (y or [n]) y 85 80 Breakpoint 1 (btrfs_init_sysfs) pending. 86 81 87 - o Continue the target 82 + - Continue the target:: 83 + 88 84 (gdb) c 89 85 90 - o Load the module on the target and watch the symbols being loaded as well as 91 - the breakpoint hit: 86 + - Load the module on the target and watch the symbols being loaded as well as 87 + the breakpoint hit:: 88 + 92 89 loading @0xffffffffa0034000: /home/user/linux/build/lib/libcrc32c.ko 93 90 loading @0xffffffffa0050000: /home/user/linux/build/lib/lzo/lzo_compress.ko 94 91 loading @0xffffffffa006e000: /home/user/linux/build/lib/zlib_deflate/zlib_deflate.ko ··· 100 91 Breakpoint 1, btrfs_init_sysfs () at /home/user/linux/fs/btrfs/sysfs.c:36 101 92 36 btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj); 102 93 103 - o Dump the log buffer of the target kernel: 94 + - Dump the log buffer of the target kernel:: 95 + 104 96 (gdb) lx-dmesg 105 97 [ 0.000000] Initializing cgroup subsys cpuset 106 98 [ 0.000000] Initializing cgroup subsys cpu ··· 112 102 [ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved 113 103 .... 114 104 115 - o Examine fields of the current task struct: 105 + - Examine fields of the current task struct:: 106 + 116 107 (gdb) p $lx_current().pid 117 108 $1 = 4998 118 109 (gdb) p $lx_current().comm 119 110 $2 = "modprobe\000\000\000\000\000\000\000" 120 111 121 - o Make use of the per-cpu function for the current or a specified CPU: 112 + - Make use of the per-cpu function for the current or a specified CPU:: 113 + 122 114 (gdb) p $lx_per_cpu("runqueues").nr_running 123 115 $3 = 1 124 116 (gdb) p $lx_per_cpu("runqueues", 2).nr_running 125 117 $4 = 0 126 118 127 - o Dig into hrtimers using the container_of helper: 119 + - Dig into hrtimers using the container_of helper:: 120 + 128 121 (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next 129 122 (gdb) p *$container_of($next, "struct hrtimer", "node") 130 123 $5 = { ··· 157 144 ------------------------------ 158 145 159 146 The number of commands and convenience functions may evolve over the time, 160 - this is just a snapshot of the initial version: 147 + this is just a snapshot of the initial version:: 161 148 162 149 (gdb) apropos lx 163 150 function lx_current -- Return current task
+5
Documentation/gpu/conf.py
··· 1 + # -*- coding: utf-8; mode: python -*- 2 + 3 + project = "Linux GPU Driver Developer's Guide" 4 + 5 + tags.add("subproject")
+7
Documentation/gpu/index.rst
··· 12 12 drm-uapi 13 13 i915 14 14 vga-switcheroo 15 + 16 + .. only:: subproject 17 + 18 + Indices 19 + ======= 20 + 21 + * :ref:`genindex`
-75
Documentation/hsi.txt
··· 1 - HSI - High-speed Synchronous Serial Interface 2 - 3 - 1. Introduction 4 - ~~~~~~~~~~~~~~~ 5 - 6 - High Speed Syncronous Interface (HSI) is a fullduplex, low latency protocol, 7 - that is optimized for die-level interconnect between an Application Processor 8 - and a Baseband chipset. It has been specified by the MIPI alliance in 2003 and 9 - implemented by multiple vendors since then. 10 - 11 - The HSI interface supports full duplex communication over multiple channels 12 - (typically 8) and is capable of reaching speeds up to 200 Mbit/s. 13 - 14 - The serial protocol uses two signals, DATA and FLAG as combined data and clock 15 - signals and an additional READY signal for flow control. An additional WAKE 16 - signal can be used to wakeup the chips from standby modes. The signals are 17 - commonly prefixed by AC for signals going from the application die to the 18 - cellular die and CA for signals going the other way around. 19 - 20 - +------------+ +---------------+ 21 - | Cellular | | Application | 22 - | Die | | Die | 23 - | | - - - - - - CAWAKE - - - - - - >| | 24 - | T|------------ CADATA ------------>|R | 25 - | X|------------ CAFLAG ------------>|X | 26 - | |<----------- ACREADY ------------| | 27 - | | | | 28 - | | | | 29 - | |< - - - - - ACWAKE - - - - - - -| | 30 - | R|<----------- ACDATA -------------|T | 31 - | X|<----------- ACFLAG -------------|X | 32 - | |------------ CAREADY ----------->| | 33 - | | | | 34 - | | | | 35 - +------------+ +---------------+ 36 - 37 - 2. HSI Subsystem in Linux 38 - ~~~~~~~~~~~~~~~~~~~~~~~~~ 39 - 40 - In the Linux kernel the hsi subsystem is supposed to be used for HSI devices. 41 - The hsi subsystem contains drivers for hsi controllers including support for 42 - multi-port controllers and provides a generic API for using the HSI ports. 43 - 44 - It also contains HSI client drivers, which make use of the generic API to 45 - implement a protocol used on the HSI interface. These client drivers can 46 - use an arbitrary number of channels. 47 - 48 - 3. hsi-char Device 49 - ~~~~~~~~~~~~~~~~~~ 50 - 51 - Each port automatically registers a generic client driver called hsi_char, 52 - which provides a charecter device for userspace representing the HSI port. 53 - It can be used to communicate via HSI from userspace. Userspace may 54 - configure the hsi_char device using the following ioctl commands: 55 - 56 - * HSC_RESET: 57 - - flush the HSI port 58 - 59 - * HSC_SET_PM 60 - - enable or disable the client. 61 - 62 - * HSC_SEND_BREAK 63 - - send break 64 - 65 - * HSC_SET_RX 66 - - set RX configuration 67 - 68 - * HSC_GET_RX 69 - - get RX configuration 70 - 71 - * HSC_SET_TX 72 - - set TX configuration 73 - 74 - * HSC_GET_TX 75 - - get TX configuration
+2 -2
Documentation/iio/iio_configfs.txt
··· 82 82 83 83 e.g: 84 84 85 - $ mkdir /config/triggers/hrtimer/instance1 86 - $ rmdir /config/triggers/hrtimer/instance1 85 + $ mkdir /config/iio/triggers/hrtimer/instance1 86 + $ rmdir /config/iio/triggers/hrtimer/instance1 87 87 88 88 Each trigger can have one or more attributes specific to the trigger type. 89 89
+4 -7
Documentation/index.rst
··· 6 6 Welcome to The Linux Kernel's documentation! 7 7 ============================================ 8 8 9 - Nothing for you to see here *yet*. Please move along. 10 - 11 9 Contents: 12 10 13 11 .. toctree:: 14 12 :maxdepth: 2 15 13 16 14 kernel-documentation 17 - media/media_uapi 18 - media/media_kapi 19 - media/dvb-drivers/index 20 - media/v4l-drivers/index 15 + development-process/index 16 + dev-tools/tools 17 + driver-api/index 18 + media/index 21 19 gpu/index 22 20 23 21 Indices and tables 24 22 ================== 25 23 26 24 * :ref:`genindex` 27 - * :ref:`search`
+8 -5
Documentation/ioctl/botching-up-ioctls.txt
··· 34 34 64-bit platforms do. So we always need padding to the natural size to get 35 35 this right. 36 36 37 - * Pad the entire struct to a multiple of 64-bits - the structure size will 38 - otherwise differ on 32-bit versus 64-bit. Having a different structure size 39 - hurts when passing arrays of structures to the kernel, or if the kernel 40 - checks the structure size, which e.g. the drm core does. 37 + * Pad the entire struct to a multiple of 64-bits if the structure contains 38 + 64-bit types - the structure size will otherwise differ on 32-bit versus 39 + 64-bit. Having a different structure size hurts when passing arrays of 40 + structures to the kernel, or if the kernel checks the structure size, which 41 + e.g. the drm core does. 41 42 42 43 * Pointers are __u64, cast from/to a uintprt_t on the userspace side and 43 44 from/to a void __user * in the kernel. Try really hard not to delay this 44 45 conversion or worse, fiddle the raw __u64 through your code since that 45 - diminishes the checking tools like sparse can provide. 46 + diminishes the checking tools like sparse can provide. The macro 47 + u64_to_user_ptr can be used in the kernel to avoid warnings about integers 48 + and pointres of different sizes. 46 49 47 50 48 51 Basics
-171
Documentation/kasan.txt
··· 1 - KernelAddressSanitizer (KASAN) 2 - ============================== 3 - 4 - 0. Overview 5 - =========== 6 - 7 - KernelAddressSANitizer (KASAN) is a dynamic memory error detector. It provides 8 - a fast and comprehensive solution for finding use-after-free and out-of-bounds 9 - bugs. 10 - 11 - KASAN uses compile-time instrumentation for checking every memory access, 12 - therefore you will need a GCC version 4.9.2 or later. GCC 5.0 or later is 13 - required for detection of out-of-bounds accesses to stack or global variables. 14 - 15 - Currently KASAN is supported only for x86_64 architecture. 16 - 17 - 1. Usage 18 - ======== 19 - 20 - To enable KASAN configure kernel with: 21 - 22 - CONFIG_KASAN = y 23 - 24 - and choose between CONFIG_KASAN_OUTLINE and CONFIG_KASAN_INLINE. Outline and 25 - inline are compiler instrumentation types. The former produces smaller binary 26 - the latter is 1.1 - 2 times faster. Inline instrumentation requires a GCC 27 - version 5.0 or later. 28 - 29 - KASAN works with both SLUB and SLAB memory allocators. 30 - For better bug detection and nicer reporting, enable CONFIG_STACKTRACE. 31 - 32 - To disable instrumentation for specific files or directories, add a line 33 - similar to the following to the respective kernel Makefile: 34 - 35 - For a single file (e.g. main.o): 36 - KASAN_SANITIZE_main.o := n 37 - 38 - For all files in one directory: 39 - KASAN_SANITIZE := n 40 - 41 - 1.1 Error reports 42 - ================= 43 - 44 - A typical out of bounds access report looks like this: 45 - 46 - ================================================================== 47 - BUG: AddressSanitizer: out of bounds access in kmalloc_oob_right+0x65/0x75 [test_kasan] at addr ffff8800693bc5d3 48 - Write of size 1 by task modprobe/1689 49 - ============================================================================= 50 - BUG kmalloc-128 (Not tainted): kasan error 51 - ----------------------------------------------------------------------------- 52 - 53 - Disabling lock debugging due to kernel taint 54 - INFO: Allocated in kmalloc_oob_right+0x3d/0x75 [test_kasan] age=0 cpu=0 pid=1689 55 - __slab_alloc+0x4b4/0x4f0 56 - kmem_cache_alloc_trace+0x10b/0x190 57 - kmalloc_oob_right+0x3d/0x75 [test_kasan] 58 - init_module+0x9/0x47 [test_kasan] 59 - do_one_initcall+0x99/0x200 60 - load_module+0x2cb3/0x3b20 61 - SyS_finit_module+0x76/0x80 62 - system_call_fastpath+0x12/0x17 63 - INFO: Slab 0xffffea0001a4ef00 objects=17 used=7 fp=0xffff8800693bd728 flags=0x100000000004080 64 - INFO: Object 0xffff8800693bc558 @offset=1368 fp=0xffff8800693bc720 65 - 66 - Bytes b4 ffff8800693bc548: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ 67 - Object ffff8800693bc558: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 68 - Object ffff8800693bc568: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 69 - Object ffff8800693bc578: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 70 - Object ffff8800693bc588: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 71 - Object ffff8800693bc598: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 72 - Object ffff8800693bc5a8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 73 - Object ffff8800693bc5b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk 74 - Object ffff8800693bc5c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk. 75 - Redzone ffff8800693bc5d8: cc cc cc cc cc cc cc cc ........ 76 - Padding ffff8800693bc718: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ 77 - CPU: 0 PID: 1689 Comm: modprobe Tainted: G B 3.18.0-rc1-mm1+ #98 78 - Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 79 - ffff8800693bc000 0000000000000000 ffff8800693bc558 ffff88006923bb78 80 - ffffffff81cc68ae 00000000000000f3 ffff88006d407600 ffff88006923bba8 81 - ffffffff811fd848 ffff88006d407600 ffffea0001a4ef00 ffff8800693bc558 82 - Call Trace: 83 - [<ffffffff81cc68ae>] dump_stack+0x46/0x58 84 - [<ffffffff811fd848>] print_trailer+0xf8/0x160 85 - [<ffffffffa00026a7>] ? kmem_cache_oob+0xc3/0xc3 [test_kasan] 86 - [<ffffffff811ff0f5>] object_err+0x35/0x40 87 - [<ffffffffa0002065>] ? kmalloc_oob_right+0x65/0x75 [test_kasan] 88 - [<ffffffff8120b9fa>] kasan_report_error+0x38a/0x3f0 89 - [<ffffffff8120a79f>] ? kasan_poison_shadow+0x2f/0x40 90 - [<ffffffff8120b344>] ? kasan_unpoison_shadow+0x14/0x40 91 - [<ffffffff8120a79f>] ? kasan_poison_shadow+0x2f/0x40 92 - [<ffffffffa00026a7>] ? kmem_cache_oob+0xc3/0xc3 [test_kasan] 93 - [<ffffffff8120a995>] __asan_store1+0x75/0xb0 94 - [<ffffffffa0002601>] ? kmem_cache_oob+0x1d/0xc3 [test_kasan] 95 - [<ffffffffa0002065>] ? kmalloc_oob_right+0x65/0x75 [test_kasan] 96 - [<ffffffffa0002065>] kmalloc_oob_right+0x65/0x75 [test_kasan] 97 - [<ffffffffa00026b0>] init_module+0x9/0x47 [test_kasan] 98 - [<ffffffff810002d9>] do_one_initcall+0x99/0x200 99 - [<ffffffff811e4e5c>] ? __vunmap+0xec/0x160 100 - [<ffffffff81114f63>] load_module+0x2cb3/0x3b20 101 - [<ffffffff8110fd70>] ? m_show+0x240/0x240 102 - [<ffffffff81115f06>] SyS_finit_module+0x76/0x80 103 - [<ffffffff81cd3129>] system_call_fastpath+0x12/0x17 104 - Memory state around the buggy address: 105 - ffff8800693bc300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 106 - ffff8800693bc380: fc fc 00 00 00 00 00 00 00 00 00 00 00 00 00 fc 107 - ffff8800693bc400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 108 - ffff8800693bc480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 109 - ffff8800693bc500: fc fc fc fc fc fc fc fc fc fc fc 00 00 00 00 00 110 - >ffff8800693bc580: 00 00 00 00 00 00 00 00 00 00 03 fc fc fc fc fc 111 - ^ 112 - ffff8800693bc600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 113 - ffff8800693bc680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 114 - ffff8800693bc700: fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb fb 115 - ffff8800693bc780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb 116 - ffff8800693bc800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb 117 - ================================================================== 118 - 119 - The header of the report discribe what kind of bug happened and what kind of 120 - access caused it. It's followed by the description of the accessed slub object 121 - (see 'SLUB Debug output' section in Documentation/vm/slub.txt for details) and 122 - the description of the accessed memory page. 123 - 124 - In the last section the report shows memory state around the accessed address. 125 - Reading this part requires some understanding of how KASAN works. 126 - 127 - The state of each 8 aligned bytes of memory is encoded in one shadow byte. 128 - Those 8 bytes can be accessible, partially accessible, freed or be a redzone. 129 - We use the following encoding for each shadow byte: 0 means that all 8 bytes 130 - of the corresponding memory region are accessible; number N (1 <= N <= 7) means 131 - that the first N bytes are accessible, and other (8 - N) bytes are not; 132 - any negative value indicates that the entire 8-byte word is inaccessible. 133 - We use different negative values to distinguish between different kinds of 134 - inaccessible memory like redzones or freed memory (see mm/kasan/kasan.h). 135 - 136 - In the report above the arrows point to the shadow byte 03, which means that 137 - the accessed address is partially accessible. 138 - 139 - 140 - 2. Implementation details 141 - ========================= 142 - 143 - From a high level, our approach to memory error detection is similar to that 144 - of kmemcheck: use shadow memory to record whether each byte of memory is safe 145 - to access, and use compile-time instrumentation to check shadow memory on each 146 - memory access. 147 - 148 - AddressSanitizer dedicates 1/8 of kernel memory to its shadow memory 149 - (e.g. 16TB to cover 128TB on x86_64) and uses direct mapping with a scale and 150 - offset to translate a memory address to its corresponding shadow address. 151 - 152 - Here is the function which translates an address to its corresponding shadow 153 - address: 154 - 155 - static inline void *kasan_mem_to_shadow(const void *addr) 156 - { 157 - return ((unsigned long)addr >> KASAN_SHADOW_SCALE_SHIFT) 158 - + KASAN_SHADOW_OFFSET; 159 - } 160 - 161 - where KASAN_SHADOW_SCALE_SHIFT = 3. 162 - 163 - Compile-time instrumentation used for checking memory accesses. Compiler inserts 164 - function calls (__asan_load*(addr), __asan_store*(addr)) before each memory 165 - access of size 1, 2, 4, 8 or 16. These functions check whether memory access is 166 - valid or not by checking corresponding shadow memory. 167 - 168 - GCC 5.0 has possibility to perform inline instrumentation. Instead of making 169 - function calls GCC directly inserts the code to check the shadow memory. 170 - This option significantly enlarges kernel but it gives x1.1-x2 performance 171 - boost over outline instrumented kernel.
+38 -1
Documentation/kbuild/kconfig-language.txt
··· 274 274 275 275 This is similar to the simple config entry above, but it also gives a 276 276 hint to front ends, that all suboptions should be displayed as a 277 - separate list of options. 277 + separate list of options. To make sure all the suboptions will really 278 + show up under the menuconfig entry and not outside of it, every item 279 + from the <config options> list must depend on the menuconfig symbol. 280 + In practice, this is achieved by using one of the next two constructs: 281 + 282 + (1): 283 + menuconfig M 284 + if M 285 + config C1 286 + config C2 287 + endif 288 + 289 + (2): 290 + menuconfig M 291 + config C1 292 + depends on M 293 + config C2 294 + depends on M 295 + 296 + In the following examples (3) and (4), C1 and C2 still have the M 297 + dependency, but will not appear under menuconfig M anymore, because 298 + of C0, which doesn't depend on M: 299 + 300 + (3): 301 + menuconfig M 302 + config C0 303 + if M 304 + config C1 305 + config C2 306 + endif 307 + 308 + (4): 309 + menuconfig M 310 + config C0 311 + config C1 312 + depends on M 313 + config C2 314 + depends on M 278 315 279 316 choices: 280 317
+37 -37
Documentation/kcov.txt Documentation/dev-tools/kcov.rst
··· 12 12 and instrumentation of some inherently non-deterministic parts of kernel is 13 13 disbled (e.g. scheduler, locking). 14 14 15 - Usage: 16 - ====== 15 + Usage 16 + ----- 17 17 18 - Configure kernel with: 18 + Configure the kernel with:: 19 19 20 20 CONFIG_KCOV=y 21 21 22 22 CONFIG_KCOV requires gcc built on revision 231296 or later. 23 - Profiling data will only become accessible once debugfs has been mounted: 23 + Profiling data will only become accessible once debugfs has been mounted:: 24 24 25 25 mount -t debugfs none /sys/kernel/debug 26 26 27 - The following program demonstrates kcov usage from within a test program: 27 + The following program demonstrates kcov usage from within a test program:: 28 28 29 - #include <stdio.h> 30 - #include <stddef.h> 31 - #include <stdint.h> 32 - #include <stdlib.h> 33 - #include <sys/types.h> 34 - #include <sys/stat.h> 35 - #include <sys/ioctl.h> 36 - #include <sys/mman.h> 37 - #include <unistd.h> 38 - #include <fcntl.h> 29 + #include <stdio.h> 30 + #include <stddef.h> 31 + #include <stdint.h> 32 + #include <stdlib.h> 33 + #include <sys/types.h> 34 + #include <sys/stat.h> 35 + #include <sys/ioctl.h> 36 + #include <sys/mman.h> 37 + #include <unistd.h> 38 + #include <fcntl.h> 39 39 40 - #define KCOV_INIT_TRACE _IOR('c', 1, unsigned long) 41 - #define KCOV_ENABLE _IO('c', 100) 42 - #define KCOV_DISABLE _IO('c', 101) 43 - #define COVER_SIZE (64<<10) 40 + #define KCOV_INIT_TRACE _IOR('c', 1, unsigned long) 41 + #define KCOV_ENABLE _IO('c', 100) 42 + #define KCOV_DISABLE _IO('c', 101) 43 + #define COVER_SIZE (64<<10) 44 44 45 - int main(int argc, char **argv) 46 - { 45 + int main(int argc, char **argv) 46 + { 47 47 int fd; 48 48 unsigned long *cover, n, i; 49 49 ··· 83 83 if (close(fd)) 84 84 perror("close"), exit(1); 85 85 return 0; 86 - } 86 + } 87 87 88 - After piping through addr2line output of the program looks as follows: 88 + After piping through addr2line output of the program looks as follows:: 89 89 90 - SyS_read 91 - fs/read_write.c:562 92 - __fdget_pos 93 - fs/file.c:774 94 - __fget_light 95 - fs/file.c:746 96 - __fget_light 97 - fs/file.c:750 98 - __fget_light 99 - fs/file.c:760 100 - __fdget_pos 101 - fs/file.c:784 102 - SyS_read 103 - fs/read_write.c:562 90 + SyS_read 91 + fs/read_write.c:562 92 + __fdget_pos 93 + fs/file.c:774 94 + __fget_light 95 + fs/file.c:746 96 + __fget_light 97 + fs/file.c:750 98 + __fget_light 99 + fs/file.c:760 100 + __fdget_pos 101 + fs/file.c:784 102 + SyS_read 103 + fs/read_write.c:562 104 104 105 105 If a program needs to collect coverage from several threads (independently), 106 106 it needs to open /sys/kernel/debug/kcov in each thread separately.
+9
Documentation/kdump/kdump.txt
··· 393 393 * We generally don' have to bring up a SMP kernel just to capture the 394 394 dump. Hence generally it is useful either to build a UP dump-capture 395 395 kernel or specify maxcpus=1 option while loading dump-capture kernel. 396 + Note, though maxcpus always works, you had better replace it with 397 + nr_cpus to save memory if supported by the current ARCH, such as x86. 398 + 399 + * You should enable multi-cpu support in dump-capture kernel if you intend 400 + to use multi-thread programs with it, such as parallel dump feature of 401 + makedumpfile. Otherwise, the multi-thread program may have a great 402 + performance degradation. To enable multi-cpu support, you should bring up an 403 + SMP dump-capture kernel and specify maxcpus/nr_cpus, disable_cpu_apicid=[X] 404 + options while loading it. 396 405 397 406 * For s390x there are two kdump modes: If a ELF header is specified with 398 407 the elfcorehdr= kernel parameter, it is used by the kdump kernel as it
+593 -672
Documentation/kernel-docs.txt
··· 1 + .. _kernel_docs: 1 2 2 - Index of Documentation for People Interested in Writing and/or 3 - 4 - Understanding the Linux Kernel. 3 + Index of Documentation for People Interested in Writing and/or Understanding the Linux Kernel 4 + ============================================================================================= 5 5 6 6 Juan-Mariano de Goyeneche <jmseyas@dit.upm.es> 7 7 8 - /* 9 - * The latest version of this document may be found at: 10 - * http://www.dit.upm.es/~jmseyas/linux/kernel/hackers-docs.html 11 - */ 8 + The need for a document like this one became apparent in the 9 + linux-kernel mailing list as the same questions, asking for pointers 10 + to information, appeared again and again. 12 11 13 - The need for a document like this one became apparent in the 14 - linux-kernel mailing list as the same questions, asking for pointers 15 - to information, appeared again and again. 16 - 17 - Fortunately, as more and more people get to GNU/Linux, more and more 18 - get interested in the Kernel. But reading the sources is not always 19 - enough. It is easy to understand the code, but miss the concepts, the 20 - philosophy and design decisions behind this code. 21 - 22 - Unfortunately, not many documents are available for beginners to 23 - start. And, even if they exist, there was no "well-known" place which 24 - kept track of them. These lines try to cover this lack. All documents 25 - available on line known by the author are listed, while some reference 26 - books are also mentioned. 27 - 28 - PLEASE, if you know any paper not listed here or write a new document, 29 - send me an e-mail, and I'll include a reference to it here. Any 30 - corrections, ideas or comments are also welcomed. 31 - 32 - The papers that follow are listed in no particular order. All are 33 - cataloged with the following fields: the document's "Title", the 34 - "Author"/s, the "URL" where they can be found, some "Keywords" helpful 35 - when searching for specific topics, and a brief "Description" of the 36 - Document. 37 - 38 - Enjoy! 39 - 40 - ON-LINE DOCS: 41 - 42 - * Title: "Linux Device Drivers, Third Edition" 43 - Author: Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman 44 - URL: http://lwn.net/Kernel/LDD3/ 45 - Description: A 600-page book covering the (2.6.10) driver 46 - programming API and kernel hacking in general. Available under the 47 - Creative Commons Attribution-ShareAlike 2.0 license. 12 + Fortunately, as more and more people get to GNU/Linux, more and more 13 + get interested in the Kernel. But reading the sources is not always 14 + enough. It is easy to understand the code, but miss the concepts, the 15 + philosophy and design decisions behind this code. 48 16 49 - * Title: "The Linux Kernel" 50 - Author: David A. Rusling. 51 - URL: http://www.tldp.org/LDP/tlk/tlk.html 52 - Keywords: everything!, book. 53 - Description: On line, 200 pages book describing most aspects of 54 - the Linux Kernel. Probably, the first reference for beginners. 55 - Lots of illustrations explaining data structures use and 56 - relationships in the purest Richard W. Stevens' style. Contents: 57 - "1.-Hardware Basics, 2.-Software Basics, 3.-Memory Management, 58 - 4.-Processes, 5.-Interprocess Communication Mechanisms, 6.-PCI, 59 - 7.-Interrupts and Interrupt Handling, 8.-Device Drivers, 9.-The 60 - File system, 10.-Networks, 11.-Kernel Mechanisms, 12.-Modules, 61 - 13.-The Linux Kernel Sources, A.-Linux Data Structures, B.-The 62 - Alpha AXP Processor, C.-Useful Web and FTP Sites, D.-The GNU 63 - General Public License, Glossary". In short: a must have. 17 + Unfortunately, not many documents are available for beginners to 18 + start. And, even if they exist, there was no "well-known" place which 19 + kept track of them. These lines try to cover this lack. All documents 20 + available on line known by the author are listed, while some reference 21 + books are also mentioned. 64 22 65 - * Title: "Linux Device Drivers, 2nd Edition" 66 - Author: Alessandro Rubini and Jonathan Corbet. 67 - URL: http://www.xml.com/ldd/chapter/book/index.html 68 - Keywords: device drivers, modules, debugging, memory, hardware, 69 - interrupt handling, char drivers, block drivers, kmod, mmap, DMA, 70 - buses. 71 - Description: O'Reilly's popular book, now also on-line under the 72 - GNU Free Documentation License. 73 - Notes: You can also buy it in paper-form from O'Reilly. See below 74 - under BOOKS (Not on-line). 23 + PLEASE, if you know any paper not listed here or write a new document, 24 + send me an e-mail, and I'll include a reference to it here. Any 25 + corrections, ideas or comments are also welcomed. 75 26 76 - * Title: "Conceptual Architecture of the Linux Kernel" 77 - Author: Ivan T. Bowman. 78 - URL: http://plg.uwaterloo.ca/ 79 - Keywords: conceptual software architecture, extracted design, 80 - reverse engineering, system structure. 81 - Description: Conceptual software architecture of the Linux kernel, 82 - automatically extracted from the source code. Very detailed. Good 83 - figures. Gives good overall kernel understanding. 27 + The papers that follow are listed in no particular order. All are 28 + cataloged with the following fields: the document's "Title", the 29 + "Author"/s, the "URL" where they can be found, some "Keywords" helpful 30 + when searching for specific topics, and a brief "Description" of the 31 + Document. 84 32 85 - * Title: "Concrete Architecture of the Linux Kernel" 86 - Author: Ivan T. Bowman, Saheem Siddiqi, and Meyer C. Tanuan. 87 - URL: http://plg.uwaterloo.ca/ 88 - Keywords: concrete architecture, extracted design, reverse 89 - engineering, system structure, dependencies. 90 - Description: Concrete architecture of the Linux kernel, 91 - automatically extracted from the source code. Very detailed. Good 92 - figures. Gives good overall kernel understanding. This papers 93 - focus on lower details than its predecessor (files, variables...). 33 + Enjoy! 94 34 95 - * Title: "Linux as a Case Study: Its Extracted Software 96 - Architecture" 97 - Author: Ivan T. Bowman, Richard C. Holt and Neil V. Brewster. 98 - URL: http://plg.uwaterloo.ca/ 99 - Keywords: software architecture, architecture recovery, 100 - redocumentation. 101 - Description: Paper appeared at ICSE'99, Los Angeles, May 16-22, 102 - 1999. A mixture of the previous two documents from the same 103 - author. 35 + .. note:: 104 36 105 - * Title: "Overview of the Virtual File System" 106 - Author: Richard Gooch. 107 - URL: http://www.mjmwired.net/kernel/Documentation/filesystems/vfs.txt 108 - Keywords: VFS, File System, mounting filesystems, opening files, 109 - dentries, dcache. 110 - Description: Brief introduction to the Linux Virtual File System. 111 - What is it, how it works, operations taken when opening a file or 112 - mounting a file system and description of important data 113 - structures explaining the purpose of each of their entries. 37 + The documents on each section of this document are ordered by its 38 + published date, from the newest to the oldest. 114 39 115 - * Title: "The Linux RAID-1, 4, 5 Code" 116 - Author: Ingo Molnar, Gadi Oxman and Miguel de Icaza. 117 - URL: http://www.linuxjournal.com/article.php?sid=2391 118 - Keywords: RAID, MD driver. 119 - Description: Linux Journal Kernel Korner article. Here is its 120 - abstract: "A description of the implementation of the RAID-1, 121 - RAID-4 and RAID-5 personalities of the MD device driver in the 122 - Linux kernel, providing users with high performance and reliable, 123 - secondary-storage capability using software". 40 + Docs at the Linux Kernel tree 41 + ----------------------------- 124 42 125 - * Title: "Dynamic Kernels: Modularized Device Drivers" 126 - Author: Alessandro Rubini. 127 - URL: http://www.linuxjournal.com/article.php?sid=1219 128 - Keywords: device driver, module, loading/unloading modules, 129 - allocating resources. 130 - Description: Linux Journal Kernel Korner article. Here is its 131 - abstract: "This is the first of a series of four articles 132 - co-authored by Alessandro Rubini and Georg Zezchwitz which present 133 - a practical approach to writing Linux device drivers as kernel 134 - loadable modules. This installment presents an introduction to the 135 - topic, preparing the reader to understand next month's 136 - installment". 43 + The DocBook books should be built with ``make {htmldocs | psdocs | pdfdocs}``. 44 + The Sphinx books should be built with ``make {htmldocs | pdfdocs | epubdocs}``. 137 45 138 - * Title: "Dynamic Kernels: Discovery" 139 - Author: Alessandro Rubini. 140 - URL: http://www.linuxjournal.com/article.php?sid=1220 141 - Keywords: character driver, init_module, clean_up module, 142 - autodetection, mayor number, minor number, file operations, 143 - open(), close(). 144 - Description: Linux Journal Kernel Korner article. Here is its 145 - abstract: "This article, the second of four, introduces part of 146 - the actual code to create custom module implementing a character 147 - device driver. It describes the code for module initialization and 148 - cleanup, as well as the open() and close() system calls". 46 + * Name: **linux/Documentation** 149 47 150 - * Title: "The Devil's in the Details" 151 - Author: Georg v. Zezschwitz and Alessandro Rubini. 152 - URL: http://www.linuxjournal.com/article.php?sid=1221 153 - Keywords: read(), write(), select(), ioctl(), blocking/non 154 - blocking mode, interrupt handler. 155 - Description: Linux Journal Kernel Korner article. Here is its 156 - abstract: "This article, the third of four on writing character 157 - device drivers, introduces concepts of reading, writing, and using 158 - ioctl-calls". 48 + :Author: Many. 49 + :Location: Documentation/ 50 + :Keywords: text files, Sphinx, DocBook. 51 + :Description: Documentation that comes with the kernel sources, 52 + inside the Documentation directory. Some pages from this document 53 + (including this document itself) have been moved there, and might 54 + be more up to date than the web version. 159 55 160 - * Title: "Dissecting Interrupts and Browsing DMA" 161 - Author: Alessandro Rubini and Georg v. Zezschwitz. 162 - URL: http://www.linuxjournal.com/article.php?sid=1222 163 - Keywords: interrupts, irqs, DMA, bottom halves, task queues. 164 - Description: Linux Journal Kernel Korner article. Here is its 165 - abstract: "This is the fourth in a series of articles about 166 - writing character device drivers as loadable kernel modules. This 167 - month, we further investigate the field of interrupt handling. 168 - Though it is conceptually simple, practical limitations and 169 - constraints make this an ``interesting'' part of device driver 170 - writing, and several different facilities have been provided for 171 - different situations. We also investigate the complex topic of 172 - DMA". 56 + * Title: **The Kernel Hacking HOWTO** 173 57 174 - * Title: "Device Drivers Concluded" 175 - Author: Georg v. Zezschwitz. 176 - URL: http://www.linuxjournal.com/article.php?sid=1287 177 - Keywords: address spaces, pages, pagination, page management, 178 - demand loading, swapping, memory protection, memory mapping, mmap, 179 - virtual memory areas (VMAs), vremap, PCI. 180 - Description: Finally, the above turned out into a five articles 181 - series. This latest one's introduction reads: "This is the last of 182 - five articles about character device drivers. In this final 183 - section, Georg deals with memory mapping devices, beginning with 184 - an overall description of the Linux memory management concepts". 58 + :Author: Various Talented People, and Rusty. 59 + :Location: Documentation/DocBook/kernel-hacking.tmpl 60 + :Keywords: HOWTO, kernel contexts, deadlock, locking, modules, 61 + symbols, return conventions. 62 + :Description: From the Introduction: "Please understand that I 63 + never wanted to write this document, being grossly underqualified, 64 + but I always wanted to read it, and this was the only way. I 65 + simply explain some best practices, and give reading entry-points 66 + into the kernel sources. I avoid implementation details: that's 67 + what the code is for, and I ignore whole tracts of useful 68 + routines. This document assumes familiarity with C, and an 69 + understanding of what the kernel is, and how it is used. It was 70 + originally written for the 2.3 kernels, but nearly all of it 71 + applies to 2.2 too; 2.0 is slightly different". 185 72 186 - * Title: "Network Buffers And Memory Management" 187 - Author: Alan Cox. 188 - URL: http://www.linuxjournal.com/article.php?sid=1312 189 - Keywords: sk_buffs, network devices, protocol/link layer 190 - variables, network devices flags, transmit, receive, 191 - configuration, multicast. 192 - Description: Linux Journal Kernel Korner. Here is the abstract: 193 - "Writing a network device driver for Linux is fundamentally 194 - simple---most of the complexity (other than talking to the 195 - hardware) involves managing network packets in memory". 196 - 197 - * Title: "Linux Kernel Hackers' Guide" 198 - Author: Michael K. Johnson. 199 - URL: http://www.tldp.org/LDP/khg/HyperNews/get/khg.html 200 - Keywords: device drivers, files, VFS, kernel interface, character vs 201 - block devices, hardware interrupts, scsi, DMA, access to user memory, 202 - memory allocation, timers. 203 - Description: A guide designed to help you get up to speed on the 204 - concepts that are not intuitevly obvious, and to document the internal 205 - structures of Linux. 206 - 207 - * Title: "The Venus kernel interface" 208 - Author: Peter J. Braam. 209 - URL: 210 - http://www.coda.cs.cmu.edu/doc/html/kernel-venus-protocol.html 211 - Keywords: coda, filesystem, venus, cache manager. 212 - Description: "This document describes the communication between 213 - Venus and kernel level file system code needed for the operation 214 - of the Coda filesystem. This version document is meant to describe 215 - the current interface (version 1.0) as well as improvements we 216 - envisage". 73 + * Title: **Linux Kernel Locking HOWTO** 217 74 218 - * Title: "Programming PCI-Devices under Linux" 219 - Author: Claus Schroeter. 220 - URL: 221 - ftp://ftp.llp.fu-berlin.de/pub/linux/LINUX-LAB/whitepapers/pcip.ps.gz 222 - Keywords: PCI, device, busmastering. 223 - Description: 6 pages tutorial on PCI programming under Linux. 224 - Gives the basic concepts on the architecture of the PCI subsystem, 225 - as long as basic functions and macros to read/write the devices 226 - and perform busmastering. 75 + :Author: Various Talented People, and Rusty. 76 + :Location: Documentation/DocBook/kernel-locking.tmpl 77 + :Keywords: locks, locking, spinlock, semaphore, atomic, race 78 + condition, bottom halves, tasklets, softirqs. 79 + :Description: The title says it all: document describing the 80 + locking system in the Linux Kernel either in uniprocessor or SMP 81 + systems. 82 + :Notes: "It was originally written for the later (>2.3.47) 2.3 83 + kernels, but most of it applies to 2.2 too; 2.0 is slightly 84 + different". Freely redistributable under the conditions of the GNU 85 + General Public License. 227 86 228 - * Title: "Writing Character Device Driver for Linux" 229 - Author: R. Baruch and C. Schroeter. 230 - URL: 231 - ftp://ftp.llp.fu-berlin.de/pub/linux/LINUX-LAB/whitepapers/drivers.ps.gz 232 - Keywords: character device drivers, I/O, signals, DMA, accessing 233 - ports in user space, kernel environment. 234 - Description: 68 pages paper on writing character drivers. A little 235 - bit old (1.993, 1.994) although still useful. 87 + On-line docs 88 + ------------ 236 89 237 - * Title: "Design and Implementation of the Second Extended 238 - Filesystem" 239 - Author: Rémy Card, Theodore Ts'o, Stephen Tweedie. 240 - URL: http://web.mit.edu/tytso/www/linux/ext2intro.html 241 - Keywords: ext2, linux fs history, inode, directory, link, devices, 242 - VFS, physical structure, performance, benchmarks, ext2fs library, 243 - ext2fs tools, e2fsck. 244 - Description: Paper written by three of the top ext2 hackers. 245 - Covers Linux filesystems history, ext2 motivation, ext2 features, 246 - design, physical structure on disk, performance, benchmarks, 247 - e2fsck's passes description... A must read! 248 - Notes: This paper was first published in the Proceedings of the 249 - First Dutch International Symposium on Linux, ISBN 90-367-0385-9. 90 + * Title: **Linux Kernel Mailing List Glossary** 250 91 251 - * Title: "Analysis of the Ext2fs structure" 252 - Author: Louis-Dominique Dubeau. 253 - URL: http://teaching.csse.uwa.edu.au/units/CITS2002/fs-ext2/ 254 - Keywords: ext2, filesystem, ext2fs. 255 - Description: Description of ext2's blocks, directories, inodes, 256 - bitmaps, invariants... 92 + :Author: various 93 + :URL: http://kernelnewbies.org/glossary/ 94 + :Date: rolling version 95 + :Keywords: glossary, terms, linux-kernel. 96 + :Description: From the introduction: "This glossary is intended as 97 + a brief description of some of the acronyms and terms you may hear 98 + during discussion of the Linux kernel". 257 99 258 - * Title: "Journaling the Linux ext2fs Filesystem" 259 - Author: Stephen C. Tweedie. 260 - URL: 261 - ftp://ftp.uk.linux.org/pub/linux/sct/fs/jfs/journal-design.ps.gz 262 - Keywords: ext3, journaling. 263 - Description: Excellent 8-pages paper explaining the journaling 264 - capabilities added to ext2 by the author, showing different 265 - problems faced and the alternatives chosen. 100 + * Title: **Tracing the Way of Data in a TCP Connection through the Linux Kernel** 266 101 267 - * Title: "Kernel API changes from 2.0 to 2.2" 268 - Author: Richard Gooch. 269 - URL: http://www.safe-mbox.com/~rgooch/linux/docs/porting-to-2.2.html 270 - Keywords: 2.2, changes. 271 - Description: Kernel functions/structures/variables which changed 272 - from 2.0.x to 2.2.x. 102 + :Author: Richard Sailer 103 + :URL: https://archive.org/details/linux_kernel_data_flow_short_paper 104 + :Date: 2016 105 + :Keywords: Linux Kernel Networking, TCP, tracing, ftrace 106 + :Description: A seminar paper explaining ftrace and how to use it for 107 + understanding linux kernel internals, 108 + illustrated at tracing the way of a TCP packet through the kernel. 109 + :Abstract: *This short paper outlines the usage of ftrace a tracing framework 110 + as a tool to understand a running Linux system. 111 + Having obtained a trace-log a kernel hacker can read and understand 112 + source code more determined and with context. 113 + In a detailed example this approach is demonstrated in tracing 114 + and the way of data in a TCP Connection through the kernel. 115 + Finally this trace-log is used as base for more a exact conceptual 116 + exploration and description of the Linux TCP/IP implementation.* 273 117 274 - * Title: "Kernel API changes from 2.2 to 2.4" 275 - Author: Richard Gooch. 276 - URL: http://www.safe-mbox.com/~rgooch/linux/docs/porting-to-2.4.html 277 - Keywords: 2.4, changes. 278 - Description: Kernel functions/structures/variables which changed 279 - from 2.2.x to 2.4.x. 280 - 281 - * Title: "Linux Kernel Module Programming Guide" 282 - Author: Ori Pomerantz. 283 - URL: http://tldp.org/LDP/lkmpg/2.6/html/index.html 284 - Keywords: modules, GPL book, /proc, ioctls, system calls, 285 - interrupt handlers . 286 - Description: Very nice 92 pages GPL book on the topic of modules 287 - programming. Lots of examples. 288 - 289 - * Title: "I/O Event Handling Under Linux" 290 - Author: Richard Gooch. 291 - Keywords: IO, I/O, select(2), poll(2), FDs, aio_read(2), readiness 292 - event queues. 293 - Description: From the Introduction: "I/O Event handling is about 294 - how your Operating System allows you to manage a large number of 295 - open files (file descriptors in UNIX/POSIX, or FDs) in your 296 - application. You want the OS to notify you when FDs become active 297 - (have data ready to be read or are ready for writing). Ideally you 298 - want a mechanism that is scalable. This means a large number of 299 - inactive FDs cost very little in memory and CPU time to manage". 300 - 301 - * Title: "The Kernel Hacking HOWTO" 302 - Author: Various Talented People, and Rusty. 303 - Location: in kernel tree, Documentation/DocBook/kernel-hacking.tmpl 304 - (must be built as "make {htmldocs | psdocs | pdfdocs}) 305 - Keywords: HOWTO, kernel contexts, deadlock, locking, modules, 306 - symbols, return conventions. 307 - Description: From the Introduction: "Please understand that I 308 - never wanted to write this document, being grossly underqualified, 309 - but I always wanted to read it, and this was the only way. I 310 - simply explain some best practices, and give reading entry-points 311 - into the kernel sources. I avoid implementation details: that's 312 - what the code is for, and I ignore whole tracts of useful 313 - routines. This document assumes familiarity with C, and an 314 - understanding of what the kernel is, and how it is used. It was 315 - originally written for the 2.3 kernels, but nearly all of it 316 - applies to 2.2 too; 2.0 is slightly different". 317 - 318 - * Title: "Writing an ALSA Driver" 319 - Author: Takashi Iwai <tiwai@suse.de> 320 - URL: http://www.alsa-project.org/~iwai/writing-an-alsa-driver/index.html 321 - Keywords: ALSA, sound, soundcard, driver, lowlevel, hardware. 322 - Description: Advanced Linux Sound Architecture for developers, 323 - both at kernel and user-level sides. ALSA is the Linux kernel 324 - sound architecture in the 2.6 kernel version. 325 - 326 - * Title: "Programming Guide for Linux USB Device Drivers" 327 - Author: Detlef Fliegl. 328 - URL: http://usb.in.tum.de/usbdoc/ 329 - Keywords: USB, universal serial bus. 330 - Description: A must-read. From the Preface: "This document should 331 - give detailed information about the current state of the USB 332 - subsystem and its API for USB device drivers. The first section 333 - will deal with the basics of USB devices. You will learn about 334 - different types of devices and their properties. Going into detail 335 - you will see how USB devices communicate on the bus. The second 336 - section gives an overview of the Linux USB subsystem [2] and the 337 - device driver framework. Then the API and its data structures will 338 - be explained step by step. The last section of this document 339 - contains a reference of all API calls and their return codes". 340 - Notes: Beware: the main page states: "This document may not be 341 - published, printed or used in excerpts without explicit permission 342 - of the author". Fortunately, it may still be read... 118 + * Title: **On submitting kernel Patches** 343 119 344 - * Title: "Linux Kernel Mailing List Glossary" 345 - Author: various 346 - URL: http://kernelnewbies.org/glossary/ 347 - Keywords: glossary, terms, linux-kernel. 348 - Description: From the introduction: "This glossary is intended as 349 - a brief description of some of the acronyms and terms you may hear 350 - during discussion of the Linux kernel". 351 - 352 - * Title: "Linux Kernel Locking HOWTO" 353 - Author: Various Talented People, and Rusty. 354 - Location: in kernel tree, Documentation/DocBook/kernel-locking.tmpl 355 - (must be built as "make {htmldocs | psdocs | pdfdocs}) 356 - Keywords: locks, locking, spinlock, semaphore, atomic, race 357 - condition, bottom halves, tasklets, softirqs. 358 - Description: The title says it all: document describing the 359 - locking system in the Linux Kernel either in uniprocessor or SMP 360 - systems. 361 - Notes: "It was originally written for the later (>2.3.47) 2.3 362 - kernels, but most of it applies to 2.2 too; 2.0 is slightly 363 - different". Freely redistributable under the conditions of the GNU 364 - General Public License. 120 + :Author: Andi Kleen 121 + :URL: http://halobates.de/on-submitting-kernel-patches.pdf 122 + :Date: 2008 123 + :Keywords: patches, review process, types of submissions, basic rules, case studies 124 + :Description: This paper gives several experience values on what types of patches 125 + there are and how likley they get merged. 126 + :Abstract: 127 + [...]. This paper examines some common problems for 128 + submitting larger changes and some strategies to avoid problems. 365 129 366 - * Title: "Global spinlock list and usage" 367 - Author: Rick Lindsley. 368 - URL: http://lse.sourceforge.net/lockhier/global-spin-lock 369 - Keywords: spinlock. 370 - Description: This is an attempt to document both the existence and 371 - usage of the spinlocks in the Linux 2.4.5 kernel. Comprehensive 372 - list of spinlocks showing when they are used, which functions 373 - access them, how each lock is acquired, under what conditions it 374 - is held, whether interrupts can occur or not while it is held... 130 + * Title: **Overview of the Virtual File System** 375 131 376 - * Title: "Porting Linux 2.0 Drivers To Linux 2.2: Changes and New 377 - Features " 378 - Author: Alan Cox. 379 - URL: http://www.linux-mag.com/1999-05/gear_01.html 380 - Keywords: ports, porting. 381 - Description: Article from Linux Magazine on porting from 2.0 to 382 - 2.2 kernels. 132 + :Author: Richard Gooch. 133 + :URL: http://www.mjmwired.net/kernel/Documentation/filesystems/vfs.txt 134 + :Date: 2007 135 + :Keywords: VFS, File System, mounting filesystems, opening files, 136 + dentries, dcache. 137 + :Description: Brief introduction to the Linux Virtual File System. 138 + What is it, how it works, operations taken when opening a file or 139 + mounting a file system and description of important data 140 + structures explaining the purpose of each of their entries. 383 141 384 - * Title: "Porting Device Drivers To Linux 2.2: part II" 385 - Author: Alan Cox. 386 - URL: http://www.linux-mag.com/id/238 387 - Keywords: ports, porting. 388 - Description: Second part on porting from 2.0 to 2.2 kernels. 142 + * Title: **Linux Device Drivers, Third Edition** 389 143 390 - * Title: "How To Make Sure Your Driver Will Work On The Power 391 - Macintosh" 392 - Author: Paul Mackerras. 393 - URL: http://www.linux-mag.com/id/261 394 - Keywords: Mac, Power Macintosh, porting, drivers, compatibility. 395 - Description: The title says it all. 144 + :Author: Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman 145 + :URL: http://lwn.net/Kernel/LDD3/ 146 + :Date: 2005 147 + :Description: A 600-page book covering the (2.6.10) driver 148 + programming API and kernel hacking in general. Available under the 149 + Creative Commons Attribution-ShareAlike 2.0 license. 150 + :note: You can also :ref:`purchase a copy from O'Reilly or elsewhere <ldd3_published>`. 396 151 397 - * Title: "An Introduction to SCSI Drivers" 398 - Author: Alan Cox. 399 - URL: http://www.linux-mag.com/id/284 400 - Keywords: SCSI, device, driver. 401 - Description: The title says it all. 152 + * Title: **Writing an ALSA Driver** 402 153 403 - * Title: "Advanced SCSI Drivers And Other Tales" 404 - Author: Alan Cox. 405 - URL: http://www.linux-mag.com/id/307 406 - Keywords: SCSI, device, driver, advanced. 407 - Description: The title says it all. 154 + :Author: Takashi Iwai <tiwai@suse.de> 155 + :URL: http://www.alsa-project.org/~iwai/writing-an-alsa-driver/index.html 156 + :Date: 2005 157 + :Keywords: ALSA, sound, soundcard, driver, lowlevel, hardware. 158 + :Description: Advanced Linux Sound Architecture for developers, 159 + both at kernel and user-level sides. ALSA is the Linux kernel 160 + sound architecture in the 2.6 kernel version. 408 161 409 - * Title: "Writing Linux Mouse Drivers" 410 - Author: Alan Cox. 411 - URL: http://www.linux-mag.com/id/330 412 - Keywords: mouse, driver, gpm. 413 - Description: The title says it all. 162 + * Title: **Linux PCMCIA Programmer's Guide** 414 163 415 - * Title: "More on Mouse Drivers" 416 - Author: Alan Cox. 417 - URL: http://www.linux-mag.com/id/356 418 - Keywords: mouse, driver, gpm, races, asynchronous I/O. 419 - Description: The title still says it all. 164 + :Author: David Hinds. 165 + :URL: http://pcmcia-cs.sourceforge.net/ftp/doc/PCMCIA-PROG.html 166 + :Date: 2003 167 + :Keywords: PCMCIA. 168 + :Description: "This document describes how to write kernel device 169 + drivers for the Linux PCMCIA Card Services interface. It also 170 + describes how to write user-mode utilities for communicating with 171 + Card Services. 420 172 421 - * Title: "Writing Video4linux Radio Driver" 422 - Author: Alan Cox. 423 - URL: http://www.linux-mag.com/id/381 424 - Keywords: video4linux, driver, radio, radio devices. 425 - Description: The title says it all. 173 + * Title: **Linux Kernel Module Programming Guide** 426 174 427 - * Title: "Video4linux Drivers, Part 1: Video-Capture Device" 428 - Author: Alan Cox. 429 - URL: http://www.linux-mag.com/id/406 430 - Keywords: video4linux, driver, video capture, capture devices, 431 - camera driver. 432 - Description: The title says it all. 175 + :Author: Ori Pomerantz. 176 + :URL: http://tldp.org/LDP/lkmpg/2.6/html/index.html 177 + :Date: 2001 178 + :Keywords: modules, GPL book, /proc, ioctls, system calls, 179 + interrupt handlers . 180 + :Description: Very nice 92 pages GPL book on the topic of modules 181 + programming. Lots of examples. 433 182 434 - * Title: "Video4linux Drivers, Part 2: Video-capture Devices" 435 - Author: Alan Cox. 436 - URL: http://www.linux-mag.com/id/429 437 - Keywords: video4linux, driver, video capture, capture devices, 438 - camera driver, control, query capabilities, capability, facility. 439 - Description: The title says it all. 183 + * Title: **Global spinlock list and usage** 440 184 441 - * Title: "PCI Management in Linux 2.2" 442 - Author: Alan Cox. 443 - URL: http://www.linux-mag.com/id/452 444 - Keywords: PCI, bus, bus-mastering. 445 - Description: The title says it all. 185 + :Author: Rick Lindsley. 186 + :URL: http://lse.sourceforge.net/lockhier/global-spin-lock 187 + :Date: 2001 188 + :Keywords: spinlock. 189 + :Description: This is an attempt to document both the existence and 190 + usage of the spinlocks in the Linux 2.4.5 kernel. Comprehensive 191 + list of spinlocks showing when they are used, which functions 192 + access them, how each lock is acquired, under what conditions it 193 + is held, whether interrupts can occur or not while it is held... 446 194 447 - * Title: "Linux 2.4 Kernel Internals" 448 - Author: Tigran Aivazian and Christoph Hellwig. 449 - URL: http://www.moses.uklinux.net/patches/lki.html 450 - Keywords: Linux, kernel, booting, SMB boot, VFS, page cache. 451 - Description: A little book used for a short training course. 452 - Covers building the kernel image, booting (including SMP bootup), 453 - process management, VFS and more. 195 + * Title: **A Linux vm README** 454 196 455 - * Title: "Linux IP Networking. A Guide to the Implementation and 456 - Modification of the Linux Protocol Stack." 457 - Author: Glenn Herrin. 458 - URL: http://www.cs.unh.edu/cnrg/gherrin 459 - Keywords: network, networking, protocol, IP, UDP, TCP, connection, 460 - socket, receiving, transmitting, forwarding, routing, packets, 461 - modules, /proc, sk_buff, FIB, tags. 462 - Description: Excellent paper devoted to the Linux IP Networking, 463 - explaining anything from the kernel's to the user space 464 - configuration tools' code. Very good to get a general overview of 465 - the kernel networking implementation and understand all steps 466 - packets follow from the time they are received at the network 467 - device till they are delivered to applications. The studied kernel 468 - code is from 2.2.14 version. Provides code for a working packet 469 - dropper example. 470 - 471 - * Title: "Get those boards talking under Linux." 472 - Author: Alex Ivchenko. 473 - URL: http://www.edn.com/article/CA46968.html 474 - Keywords: data-acquisition boards, drivers, modules, interrupts, 475 - memory allocation. 476 - Description: Article written for people wishing to make their data 477 - acquisition boards work on their GNU/Linux machines. Gives a basic 478 - overview on writing drivers, from the naming of functions to 479 - interrupt handling. 480 - Notes: Two-parts article. Part II is at 481 - URL: http://www.edn.com/article/CA46998.html 482 - 483 - * Title: "Linux PCMCIA Programmer's Guide" 484 - Author: David Hinds. 485 - URL: http://pcmcia-cs.sourceforge.net/ftp/doc/PCMCIA-PROG.html 486 - Keywords: PCMCIA. 487 - Description: "This document describes how to write kernel device 488 - drivers for the Linux PCMCIA Card Services interface. It also 489 - describes how to write user-mode utilities for communicating with 490 - Card Services. 197 + :Author: Kanoj Sarcar. 198 + :URL: http://kos.enix.org/pub/linux-vmm.html 199 + :Date: 2001 200 + :Keywords: virtual memory, mm, pgd, vma, page, page flags, page 201 + cache, swap cache, kswapd. 202 + :Description: Telegraphic, short descriptions and definitions 203 + relating the Linux virtual memory implementation. 491 204 492 - * Title: "The Linux Kernel NFSD Implementation" 493 - Author: Neil Brown. 494 - URL: 495 - http://www.cse.unsw.edu.au/~neilb/oss/linux-commentary/nfsd.html 496 - Keywords: knfsd, nfsd, NFS, RPC, lockd, mountd, statd. 497 - Description: The title says it all. 498 - Notes: Covers knfsd's version 1.4.7 (patch against 2.2.7 kernel). 499 - 500 - * Title: "A Linux vm README" 501 - Author: Kanoj Sarcar. 502 - URL: http://kos.enix.org/pub/linux-vmm.html 503 - Keywords: virtual memory, mm, pgd, vma, page, page flags, page 504 - cache, swap cache, kswapd. 505 - Description: Telegraphic, short descriptions and definitions 506 - relating the Linux virtual memory implementation. 507 - 508 - * Title: "(nearly) Complete Linux Loadable Kernel Modules. The 509 - definitive guide for hackers, virus coders and system 510 - administrators." 511 - Author: pragmatic/THC. 512 - URL: http://packetstormsecurity.org/docs/hack/LKM_HACKING.html 513 - Keywords: syscalls, intercept, hide, abuse, symbol table. 514 - Description: Interesting paper on how to abuse the Linux kernel in 515 - order to intercept and modify syscalls, make 516 - files/directories/processes invisible, become root, hijack ttys, 517 - write kernel modules based virus... and solutions for admins to 518 - avoid all those abuses. 519 - Notes: For 2.0.x kernels. Gives guidances to port it to 2.2.x 520 - kernels. 521 - 522 - BOOKS: (Not on-line) 523 - 524 - * Title: "Linux Device Drivers" 525 - Author: Alessandro Rubini. 526 - Publisher: O'Reilly & Associates. 527 - Date: 1998. 528 - Pages: 439. 529 - ISBN: 1-56592-292-1 530 - 531 - * Title: "Linux Device Drivers, 2nd Edition" 532 - Author: Alessandro Rubini and Jonathan Corbet. 533 - Publisher: O'Reilly & Associates. 534 - Date: 2001. 535 - Pages: 586. 536 - ISBN: 0-59600-008-1 537 - Notes: Further information in 538 - http://www.oreilly.com/catalog/linuxdrive2/ 205 + * Title: **Video4linux Drivers, Part 1: Video-Capture Device** 539 206 540 - * Title: "Linux Device Drivers, 3rd Edition" 541 - Authors: Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman 542 - Publisher: O'Reilly & Associates. 543 - Date: 2005. 544 - Pages: 636. 545 - ISBN: 0-596-00590-3 546 - Notes: Further information in 547 - http://www.oreilly.com/catalog/linuxdrive3/ 548 - PDF format, URL: http://lwn.net/Kernel/LDD3/ 207 + :Author: Alan Cox. 208 + :URL: http://www.linux-mag.com/id/406 209 + :Date: 2000 210 + :Keywords: video4linux, driver, video capture, capture devices, 211 + camera driver. 212 + :Description: The title says it all. 549 213 550 - * Title: "Linux Kernel Internals" 551 - Author: Michael Beck. 552 - Publisher: Addison-Wesley. 553 - Date: 1997. 554 - ISBN: 0-201-33143-8 (second edition) 555 - 556 - * Title: "The Design of the UNIX Operating System" 557 - Author: Maurice J. Bach. 558 - Publisher: Prentice Hall. 559 - Date: 1986. 560 - Pages: 471. 561 - ISBN: 0-13-201757-1 562 - 563 - * Title: "The Design and Implementation of the 4.3 BSD UNIX 564 - Operating System" 565 - Author: Samuel J. Leffler, Marshall Kirk McKusick, Michael J. 566 - Karels, John S. Quarterman. 567 - Publisher: Addison-Wesley. 568 - Date: 1989 (reprinted with corrections on October, 1990). 569 - ISBN: 0-201-06196-1 570 - 571 - * Title: "The Design and Implementation of the 4.4 BSD UNIX 572 - Operating System" 573 - Author: Marshall Kirk McKusick, Keith Bostic, Michael J. Karels, 574 - John S. Quarterman. 575 - Publisher: Addison-Wesley. 576 - Date: 1996. 577 - ISBN: 0-201-54979-4 578 - 579 - * Title: "Programmation Linux 2.0 API systeme et fonctionnement du 580 - noyau" 581 - Author: Remy Card, Eric Dumas, Franck Mevel. 582 - Publisher: Eyrolles. 583 - Date: 1997. 584 - Pages: 520. 585 - ISBN: 2-212-08932-5 586 - Notes: French. 214 + * Title: **Video4linux Drivers, Part 2: Video-capture Devices** 587 215 588 - * Title: "Unix internals -- the new frontiers" 589 - Author: Uresh Vahalia. 590 - Publisher: Prentice Hall. 591 - Date: 1996. 592 - Pages: 600. 593 - ISBN: 0-13-101908-2 216 + :Author: Alan Cox. 217 + :URL: http://www.linux-mag.com/id/429 218 + :Date: 2000 219 + :Keywords: video4linux, driver, video capture, capture devices, 220 + camera driver, control, query capabilities, capability, facility. 221 + :Description: The title says it all. 594 222 595 - * Title: "Programming for the real world - POSIX.4" 596 - Author: Bill O. Gallmeister. 597 - Publisher: O'Reilly & Associates, Inc.. 598 - Date: 1995. 599 - Pages: ???. 600 - ISBN: I-56592-074-0 601 - Notes: Though not being directly about Linux, Linux aims to be 602 - POSIX. Good reference. 223 + * Title: **Linux IP Networking. A Guide to the Implementation and Modification of the Linux Protocol Stack.** 603 224 604 - * Title: "UNIX Systems for Modern Architectures: Symmetric 605 - Multiprocessing and Caching for Kernel Programmers" 606 - Author: Curt Schimmel. 607 - Publisher: Addison Wesley. 608 - Date: June, 1994. 609 - Pages: 432. 610 - ISBN: 0-201-63338-8 225 + :Author: Glenn Herrin. 226 + :URL: http://www.cs.unh.edu/cnrg/gherrin 227 + :Date: 2000 228 + :Keywords: network, networking, protocol, IP, UDP, TCP, connection, 229 + socket, receiving, transmitting, forwarding, routing, packets, 230 + modules, /proc, sk_buff, FIB, tags. 231 + :Description: Excellent paper devoted to the Linux IP Networking, 232 + explaining anything from the kernel's to the user space 233 + configuration tools' code. Very good to get a general overview of 234 + the kernel networking implementation and understand all steps 235 + packets follow from the time they are received at the network 236 + device till they are delivered to applications. The studied kernel 237 + code is from 2.2.14 version. Provides code for a working packet 238 + dropper example. 611 239 612 - * Title: "Linux Kernel Development, 3rd Edition" 613 - Author: Robert Love 614 - Publisher: Addison-Wesley. 615 - Date: July, 2010 616 - Pages: 440 617 - ISBN: 978-0672329463 240 + * Title: **How To Make Sure Your Driver Will Work On The Power Macintosh** 618 241 619 - MISCELLANEOUS: 242 + :Author: Paul Mackerras. 243 + :URL: http://www.linux-mag.com/id/261 244 + :Date: 1999 245 + :Keywords: Mac, Power Macintosh, porting, drivers, compatibility. 246 + :Description: The title says it all. 620 247 621 - * Name: linux/Documentation 622 - Author: Many. 623 - URL: Just look inside your kernel sources. 624 - Keywords: anything, DocBook. 625 - Description: Documentation that comes with the kernel sources, 626 - inside the Documentation directory. Some pages from this document 627 - (including this document itself) have been moved there, and might 628 - be more up to date than the web version. 248 + * Title: **An Introduction to SCSI Drivers** 629 249 630 - * Name: "Linux Kernel Source Reference" 631 - Author: Thomas Graichen. 632 - URL: http://marc.info/?l=linux-kernel&m=96446640102205&w=4 633 - Keywords: CVS, web, cvsweb, browsing source code. 634 - Description: Web interface to a CVS server with the kernel 635 - sources. "Here you can have a look at any file of the Linux kernel 636 - sources of any version starting from 1.0 up to the (daily updated) 637 - current version available. Also you can check the differences 638 - between two versions of a file". 250 + :Author: Alan Cox. 251 + :URL: http://www.linux-mag.com/id/284 252 + :Date: 1999 253 + :Keywords: SCSI, device, driver. 254 + :Description: The title says it all. 639 255 640 - * Name: "Cross-Referencing Linux" 641 - URL: http://lxr.free-electrons.com/ 642 - Keywords: Browsing source code. 643 - Description: Another web-based Linux kernel source code browser. 644 - Lots of cross references to variables and functions. You can see 645 - where they are defined and where they are used. 256 + * Title: **Advanced SCSI Drivers And Other Tales** 646 257 647 - * Name: "Linux Weekly News" 648 - URL: http://lwn.net 649 - Keywords: latest kernel news. 650 - Description: The title says it all. There's a fixed kernel section 651 - summarizing developers' work, bug fixes, new features and versions 652 - produced during the week. Published every Thursday. 258 + :Author: Alan Cox. 259 + :URL: http://www.linux-mag.com/id/307 260 + :Date: 1999 261 + :Keywords: SCSI, device, driver, advanced. 262 + :Description: The title says it all. 653 263 654 - * Name: "Kernel Traffic" 655 - URL: http://kt.earth.li/kernel-traffic/index.html 656 - Keywords: linux-kernel mailing list, weekly kernel news. 657 - Description: Weekly newsletter covering the most relevant 658 - discussions of the linux-kernel mailing list. 264 + * Title: **Writing Linux Mouse Drivers** 659 265 660 - * Name: "CuTTiNG.eDGe.LiNuX" 661 - URL: http://edge.kernelnotes.org 662 - Keywords: changelist. 663 - Description: Site which provides the changelist for every kernel 664 - release. What's new, what's better, what's changed. Myrdraal reads 665 - the patches and describes them. Pointers to the patches are there, 666 - too. 266 + :Author: Alan Cox. 267 + :URL: http://www.linux-mag.com/id/330 268 + :Date: 1999 269 + :Keywords: mouse, driver, gpm. 270 + :Description: The title says it all. 667 271 668 - * Name: "New linux-kernel Mailing List FAQ" 669 - URL: http://www.tux.org/lkml/ 670 - Keywords: linux-kernel mailing list FAQ. 671 - Description: linux-kernel is a mailing list for developers to 672 - communicate. This FAQ builds on the previous linux-kernel mailing 673 - list FAQ maintained by Frohwalt Egerer, who no longer maintains 674 - it. Read it to see how to join the mailing list. Dozens of 675 - interesting questions regarding the list, Linux, developers (who 676 - is ...?), terms (what is...?) are answered here too. Just read it. 272 + * Title: **More on Mouse Drivers** 677 273 678 - * Name: "Linux Virtual File System" 679 - Author: Peter J. Braam. 680 - URL: http://www.coda.cs.cmu.edu/doc/talks/linuxvfs/ 681 - Keywords: slides, VFS, inode, superblock, dentry, dcache. 682 - Description: Set of slides, presumably from a presentation on the 683 - Linux VFS layer. Covers version 2.1.x, with dentries and the 684 - dcache. 274 + :Author: Alan Cox. 275 + :URL: http://www.linux-mag.com/id/356 276 + :Date: 1999 277 + :Keywords: mouse, driver, gpm, races, asynchronous I/O. 278 + :Description: The title still says it all. 685 279 686 - * Name: "Gary's Encyclopedia - The Linux Kernel" 687 - Author: Gary (I suppose...). 688 - URL: http://slencyclopedia.berlios.de/index.html 689 - Keywords: linux, community, everything! 690 - Description: Gary's Encyclopedia exists to allow the rapid finding 691 - of documentation and other information of interest to GNU/Linux 692 - users. It has about 4000 links to external pages in 150 major 693 - categories. This link is for kernel-specific links, documents, 694 - sites... This list is now hosted by developer.Berlios.de, 695 - but seems not to have been updated since sometime in 1999. 280 + * Title: **Writing Video4linux Radio Driver** 696 281 697 - * Name: "The home page of Linux-MM" 698 - Author: The Linux-MM team. 699 - URL: http://linux-mm.org/ 700 - Keywords: memory management, Linux-MM, mm patches, TODO, docs, 701 - mailing list. 702 - Description: Site devoted to Linux Memory Management development. 703 - Memory related patches, HOWTOs, links, mm developers... Don't miss 704 - it if you are interested in memory management development! 282 + :Author: Alan Cox. 283 + :URL: http://www.linux-mag.com/id/381 284 + :Date: 1999 285 + :Keywords: video4linux, driver, radio, radio devices. 286 + :Description: The title says it all. 705 287 706 - * Name: "Kernel Newbies IRC Channel and Website" 707 - URL: http://www.kernelnewbies.org 708 - Keywords: IRC, newbies, channel, asking doubts. 709 - Description: #kernelnewbies on irc.oftc.net. 710 - #kernelnewbies is an IRC network dedicated to the 'newbie' 711 - kernel hacker. The audience mostly consists of people who are 712 - learning about the kernel, working on kernel projects or 713 - professional kernel hackers that want to help less seasoned kernel 714 - people. 715 - #kernelnewbies is on the OFTC IRC Network. 716 - Try irc.oftc.net as your server and then /join #kernelnewbies. 717 - The kernelnewbies website also hosts articles, documents, FAQs... 718 - 719 - * Name: "linux-kernel mailing list archives and search engines" 720 - URL: http://vger.kernel.org/vger-lists.html 721 - URL: http://www.uwsg.indiana.edu/hypermail/linux/kernel/index.html 722 - URL: http://marc.theaimsgroup.com/?l=linux-kernel 723 - URL: http://groups.google.com/group/mlist.linux.kernel 724 - URL: http://www.cs.helsinki.fi/linux/linux-kernel/ 725 - URL: http://www.lib.uaa.alaska.edu/linux-kernel/ 726 - Keywords: linux-kernel, archives, search. 727 - Description: Some of the linux-kernel mailing list archivers. If 728 - you have a better/another one, please let me know. 729 - _________________________________________________________________ 730 - 731 - Document last updated on Sat 2005-NOV-19 288 + * Title: **I/O Event Handling Under Linux** 289 + 290 + :Author: Richard Gooch. 291 + :URL: http://web.mit.edu/~yandros/doc/io-events.html 292 + :Date: 1999 293 + :Keywords: IO, I/O, select(2), poll(2), FDs, aio_read(2), readiness 294 + event queues. 295 + :Description: From the Introduction: "I/O Event handling is about 296 + how your Operating System allows you to manage a large number of 297 + open files (file descriptors in UNIX/POSIX, or FDs) in your 298 + application. You want the OS to notify you when FDs become active 299 + (have data ready to be read or are ready for writing). Ideally you 300 + want a mechanism that is scalable. This means a large number of 301 + inactive FDs cost very little in memory and CPU time to manage". 302 + 303 + * Title: **(nearly) Complete Linux Loadable Kernel Modules. The definitive guide for hackers, virus coders and system administrators.** 304 + 305 + :Author: pragmatic/THC. 306 + :URL: http://packetstormsecurity.org/docs/hack/LKM_HACKING.html 307 + :Date: 1999 308 + :Keywords: syscalls, intercept, hide, abuse, symbol table. 309 + :Description: Interesting paper on how to abuse the Linux kernel in 310 + order to intercept and modify syscalls, make 311 + files/directories/processes invisible, become root, hijack ttys, 312 + write kernel modules based virus... and solutions for admins to 313 + avoid all those abuses. 314 + :Notes: For 2.0.x kernels. Gives guidances to port it to 2.2.x 315 + kernels. 316 + 317 + * Name: **Linux Virtual File System** 318 + 319 + :Author: Peter J. Braam. 320 + :URL: http://www.coda.cs.cmu.edu/doc/talks/linuxvfs/ 321 + :Date: 1998 322 + :Keywords: slides, VFS, inode, superblock, dentry, dcache. 323 + :Description: Set of slides, presumably from a presentation on the 324 + Linux VFS layer. Covers version 2.1.x, with dentries and the 325 + dcache. 326 + 327 + * Title: **The Venus kernel interface** 328 + 329 + :Author: Peter J. Braam. 330 + :URL: http://www.coda.cs.cmu.edu/doc/html/kernel-venus-protocol.html 331 + :Date: 1998 332 + :Keywords: coda, filesystem, venus, cache manager. 333 + :Description: "This document describes the communication between 334 + Venus and kernel level file system code needed for the operation 335 + of the Coda filesystem. This version document is meant to describe 336 + the current interface (version 1.0) as well as improvements we 337 + envisage". 338 + 339 + * Title: **Design and Implementation of the Second Extended Filesystem** 340 + 341 + :Author: Rémy Card, Theodore Ts'o, Stephen Tweedie. 342 + :URL: http://web.mit.edu/tytso/www/linux/ext2intro.html 343 + :Date: 1998 344 + :Keywords: ext2, linux fs history, inode, directory, link, devices, 345 + VFS, physical structure, performance, benchmarks, ext2fs library, 346 + ext2fs tools, e2fsck. 347 + :Description: Paper written by three of the top ext2 hackers. 348 + Covers Linux filesystems history, ext2 motivation, ext2 features, 349 + design, physical structure on disk, performance, benchmarks, 350 + e2fsck's passes description... A must read! 351 + :Notes: This paper was first published in the Proceedings of the 352 + First Dutch International Symposium on Linux, ISBN 90-367-0385-9. 353 + 354 + * Title: **The Linux RAID-1, 4, 5 Code** 355 + 356 + :Author: Ingo Molnar, Gadi Oxman and Miguel de Icaza. 357 + :URL: http://www.linuxjournal.com/article.php?sid=2391 358 + :Date: 1997 359 + :Keywords: RAID, MD driver. 360 + :Description: Linux Journal Kernel Korner article. Here is its 361 + :Abstract: *A description of the implementation of the RAID-1, 362 + RAID-4 and RAID-5 personalities of the MD device driver in the 363 + Linux kernel, providing users with high performance and reliable, 364 + secondary-storage capability using software*. 365 + 366 + * Title: **Linux Kernel Hackers' Guide** 367 + 368 + :Author: Michael K. Johnson. 369 + :URL: http://www.tldp.org/LDP/khg/HyperNews/get/khg.html 370 + :Date: 1997 371 + :Keywords: device drivers, files, VFS, kernel interface, character vs 372 + block devices, hardware interrupts, scsi, DMA, access to user memory, 373 + memory allocation, timers. 374 + :Description: A guide designed to help you get up to speed on the 375 + concepts that are not intuitevly obvious, and to document the internal 376 + structures of Linux. 377 + 378 + * Title: **Dynamic Kernels: Modularized Device Drivers** 379 + 380 + :Author: Alessandro Rubini. 381 + :URL: http://www.linuxjournal.com/article.php?sid=1219 382 + :Date: 1996 383 + :Keywords: device driver, module, loading/unloading modules, 384 + allocating resources. 385 + :Description: Linux Journal Kernel Korner article. Here is its 386 + :Abstract: *This is the first of a series of four articles 387 + co-authored by Alessandro Rubini and Georg Zezchwitz which present 388 + a practical approach to writing Linux device drivers as kernel 389 + loadable modules. This installment presents an introduction to the 390 + topic, preparing the reader to understand next month's 391 + installment*. 392 + 393 + * Title: **Dynamic Kernels: Discovery** 394 + 395 + :Author: Alessandro Rubini. 396 + :URL: http://www.linuxjournal.com/article.php?sid=1220 397 + :Date: 1996 398 + :Keywords: character driver, init_module, clean_up module, 399 + autodetection, mayor number, minor number, file operations, 400 + open(), close(). 401 + :Description: Linux Journal Kernel Korner article. Here is its 402 + :Abstract: *This article, the second of four, introduces part of 403 + the actual code to create custom module implementing a character 404 + device driver. It describes the code for module initialization and 405 + cleanup, as well as the open() and close() system calls*. 406 + 407 + * Title: **The Devil's in the Details** 408 + 409 + :Author: Georg v. Zezschwitz and Alessandro Rubini. 410 + :URL: http://www.linuxjournal.com/article.php?sid=1221 411 + :Date: 1996 412 + :Keywords: read(), write(), select(), ioctl(), blocking/non 413 + blocking mode, interrupt handler. 414 + :Description: Linux Journal Kernel Korner article. Here is its 415 + :Abstract: *This article, the third of four on writing character 416 + device drivers, introduces concepts of reading, writing, and using 417 + ioctl-calls*. 418 + 419 + * Title: **Dissecting Interrupts and Browsing DMA** 420 + 421 + :Author: Alessandro Rubini and Georg v. Zezschwitz. 422 + :URL: http://www.linuxjournal.com/article.php?sid=1222 423 + :Date: 1996 424 + :Keywords: interrupts, irqs, DMA, bottom halves, task queues. 425 + :Description: Linux Journal Kernel Korner article. Here is its 426 + :Abstract: *This is the fourth in a series of articles about 427 + writing character device drivers as loadable kernel modules. This 428 + month, we further investigate the field of interrupt handling. 429 + Though it is conceptually simple, practical limitations and 430 + constraints make this an ''interesting'' part of device driver 431 + writing, and several different facilities have been provided for 432 + different situations. We also investigate the complex topic of 433 + DMA*. 434 + 435 + * Title: **Device Drivers Concluded** 436 + 437 + :Author: Georg v. Zezschwitz. 438 + :URL: http://www.linuxjournal.com/article.php?sid=1287 439 + :Date: 1996 440 + :Keywords: address spaces, pages, pagination, page management, 441 + demand loading, swapping, memory protection, memory mapping, mmap, 442 + virtual memory areas (VMAs), vremap, PCI. 443 + :Description: Finally, the above turned out into a five articles 444 + series. This latest one's introduction reads: "This is the last of 445 + five articles about character device drivers. In this final 446 + section, Georg deals with memory mapping devices, beginning with 447 + an overall description of the Linux memory management concepts". 448 + 449 + * Title: **Network Buffers And Memory Management** 450 + 451 + :Author: Alan Cox. 452 + :URL: http://www.linuxjournal.com/article.php?sid=1312 453 + :Date: 1996 454 + :Keywords: sk_buffs, network devices, protocol/link layer 455 + variables, network devices flags, transmit, receive, 456 + configuration, multicast. 457 + :Description: Linux Journal Kernel Korner. 458 + :Abstract: *Writing a network device driver for Linux is fundamentally 459 + simple---most of the complexity (other than talking to the 460 + hardware) involves managing network packets in memory*. 461 + 462 + * Title: **Analysis of the Ext2fs structure** 463 + 464 + :Author: Louis-Dominique Dubeau. 465 + :URL: http://teaching.csse.uwa.edu.au/units/CITS2002/fs-ext2/ 466 + :Date: 1994 467 + :Keywords: ext2, filesystem, ext2fs. 468 + :Description: Description of ext2's blocks, directories, inodes, 469 + bitmaps, invariants... 470 + 471 + Published books 472 + --------------- 473 + 474 + * Title: **Linux Treiber entwickeln** 475 + 476 + :Author: Jürgen Quade, Eva-Katharina Kunst 477 + :Publisher: dpunkt.verlag 478 + :Date: Oct 2015 (4th edition) 479 + :Pages: 688 480 + :ISBN: 978-3-86490-288-8 481 + :Note: German. The third edition from 2011 is 482 + much cheaper and still quite up-to-date. 483 + 484 + * Title: **Linux Kernel Networking: Implementation and Theory** 485 + 486 + :Author: Rami Rosen 487 + :Publisher: Apress 488 + :Date: December 22, 2013 489 + :Pages: 648 490 + :ISBN: 978-1430261964 491 + 492 + * Title: **Embedded Linux Primer: A practical Real-World Approach, 2nd Edition** 493 + 494 + :Author: Christopher Hallinan 495 + :Publisher: Pearson 496 + :Date: November, 2010 497 + :Pages: 656 498 + :ISBN: 978-0137017836 499 + 500 + * Title: **Linux Kernel Development, 3rd Edition** 501 + 502 + :Author: Robert Love 503 + :Publisher: Addison-Wesley 504 + :Date: July, 2010 505 + :Pages: 440 506 + :ISBN: 978-0672329463 507 + 508 + * Title: **Essential Linux Device Drivers** 509 + 510 + :Author: Sreekrishnan Venkateswaran 511 + :Published: Prentice Hall 512 + :Date: April, 2008 513 + :Pages: 744 514 + :ISBN: 978-0132396554 515 + 516 + .. _ldd3_published: 517 + 518 + * Title: **Linux Device Drivers, 3rd Edition** 519 + 520 + :Authors: Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman 521 + :Publisher: O'Reilly & Associates 522 + :Date: 2005 523 + :Pages: 636 524 + :ISBN: 0-596-00590-3 525 + :Notes: Further information in 526 + http://www.oreilly.com/catalog/linuxdrive3/ 527 + PDF format, URL: http://lwn.net/Kernel/LDD3/ 528 + 529 + * Title: **Linux Kernel Internals** 530 + 531 + :Author: Michael Beck 532 + :Publisher: Addison-Wesley 533 + :Date: 1997 534 + :ISBN: 0-201-33143-8 (second edition) 535 + 536 + * Title: **Programmation Linux 2.0 API systeme et fonctionnement du noyau** 537 + 538 + :Author: Remy Card, Eric Dumas, Franck Mevel 539 + :Publisher: Eyrolles 540 + :Date: 1997 541 + :Pages: 520 542 + :ISBN: 2-212-08932-5 543 + :Notes: French 544 + 545 + * Title: **The Design and Implementation of the 4.4 BSD UNIX Operating System** 546 + 547 + :Author: Marshall Kirk McKusick, Keith Bostic, Michael J. Karels, 548 + John S. Quarterman 549 + :Publisher: Addison-Wesley 550 + :Date: 1996 551 + :ISBN: 0-201-54979-4 552 + 553 + * Title: **Unix internals -- the new frontiers** 554 + 555 + :Author: Uresh Vahalia 556 + :Publisher: Prentice Hall 557 + :Date: 1996 558 + :Pages: 600 559 + :ISBN: 0-13-101908-2 560 + 561 + * Title: **Programming for the real world - POSIX.4** 562 + 563 + :Author: Bill O. Gallmeister 564 + :Publisher: O'Reilly & Associates, Inc 565 + :Date: 1995 566 + :Pages: 552 567 + :ISBN: I-56592-074-0 568 + :Notes: Though not being directly about Linux, Linux aims to be 569 + POSIX. Good reference. 570 + 571 + * Title: **UNIX Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers** 572 + 573 + :Author: Curt Schimmel 574 + :Publisher: Addison Wesley 575 + :Date: June, 1994 576 + :Pages: 432 577 + :ISBN: 0-201-63338-8 578 + 579 + * Title: **The Design and Implementation of the 4.3 BSD UNIX Operating System** 580 + 581 + :Author: Samuel J. Leffler, Marshall Kirk McKusick, Michael J 582 + Karels, John S. Quarterman 583 + :Publisher: Addison-Wesley 584 + :Date: 1989 (reprinted with corrections on October, 1990) 585 + :ISBN: 0-201-06196-1 586 + 587 + * Title: **The Design of the UNIX Operating System** 588 + 589 + :Author: Maurice J. Bach 590 + :Publisher: Prentice Hall 591 + :Date: 1986 592 + :Pages: 471 593 + :ISBN: 0-13-201757-1 594 + 595 + Miscellaneous 596 + ------------- 597 + 598 + * Name: **Cross-Referencing Linux** 599 + 600 + :URL: http://lxr.free-electrons.com/ 601 + :Keywords: Browsing source code. 602 + :Description: Another web-based Linux kernel source code browser. 603 + Lots of cross references to variables and functions. You can see 604 + where they are defined and where they are used. 605 + 606 + * Name: **Linux Weekly News** 607 + 608 + :URL: http://lwn.net 609 + :Keywords: latest kernel news. 610 + :Description: The title says it all. There's a fixed kernel section 611 + summarizing developers' work, bug fixes, new features and versions 612 + produced during the week. Published every Thursday. 613 + 614 + * Name: **The home page of Linux-MM** 615 + 616 + :Author: The Linux-MM team. 617 + :URL: http://linux-mm.org/ 618 + :Keywords: memory management, Linux-MM, mm patches, TODO, docs, 619 + mailing list. 620 + :Description: Site devoted to Linux Memory Management development. 621 + Memory related patches, HOWTOs, links, mm developers... Don't miss 622 + it if you are interested in memory management development! 623 + 624 + * Name: **Kernel Newbies IRC Channel and Website** 625 + 626 + :URL: http://www.kernelnewbies.org 627 + :Keywords: IRC, newbies, channel, asking doubts. 628 + :Description: #kernelnewbies on irc.oftc.net. 629 + #kernelnewbies is an IRC network dedicated to the 'newbie' 630 + kernel hacker. The audience mostly consists of people who are 631 + learning about the kernel, working on kernel projects or 632 + professional kernel hackers that want to help less seasoned kernel 633 + people. 634 + #kernelnewbies is on the OFTC IRC Network. 635 + Try irc.oftc.net as your server and then /join #kernelnewbies. 636 + The kernelnewbies website also hosts articles, documents, FAQs... 637 + 638 + * Name: **linux-kernel mailing list archives and search engines** 639 + 640 + :URL: http://vger.kernel.org/vger-lists.html 641 + :URL: http://www.uwsg.indiana.edu/hypermail/linux/kernel/index.html 642 + :URL: http://groups.google.com/group/mlist.linux.kernel 643 + :Keywords: linux-kernel, archives, search. 644 + :Description: Some of the linux-kernel mailing list archivers. If 645 + you have a better/another one, please let me know. 646 + 647 + ------- 648 + 649 + Document last updated on Tue 2016-Sep-20 650 + 651 + This document is based on: 652 + http://www.dit.upm.es/~jmseyas/linux/kernel/hackers-docs.html
+31
Documentation/kernel-documentation.rst
··· 107 107 the order as encountered."), having the higher levels the same overall makes 108 108 it easier to follow the documents. 109 109 110 + 111 + the C domain 112 + ------------ 113 + 114 + The `Sphinx C Domain`_ (name c) is suited for documentation of C API. E.g. a 115 + function prototype: 116 + 117 + .. code-block:: rst 118 + 119 + .. c:function:: int ioctl( int fd, int request ) 120 + 121 + The C domain of the kernel-doc has some additional features. E.g. you can 122 + *rename* the reference name of a function with a common name like ``open`` or 123 + ``ioctl``: 124 + 125 + .. code-block:: rst 126 + 127 + .. c:function:: int ioctl( int fd, int request ) 128 + :name: VIDIOC_LOG_STATUS 129 + 130 + The func-name (e.g. ioctl) remains in the output but the ref-name changed from 131 + ``ioctl`` to ``VIDIOC_LOG_STATUS``. The index entry for this function is also 132 + changed to ``VIDIOC_LOG_STATUS`` and the function can now referenced by: 133 + 134 + .. code-block:: rst 135 + 136 + :c:func:`VIDIOC_LOG_STATUS` 137 + 138 + 110 139 list tables 111 140 ----------- 112 141 ··· 293 264 ``Documentation/sphinx/kernel-doc.py``. Internally, it uses the 294 265 ``scripts/kernel-doc`` script to extract the documentation comments from the 295 266 source. 267 + 268 + .. _kernel_doc: 296 269 297 270 Writing kernel-doc comments 298 271 ===========================
+14 -10
Documentation/kernel-parameters.txt
··· 1698 1698 1699 1699 intel_idle.max_cstate= [KNL,HW,ACPI,X86] 1700 1700 0 disables intel_idle and fall back on acpi_idle. 1701 - 1 to 6 specify maximum depth of C-state. 1701 + 1 to 9 specify maximum depth of C-state. 1702 1702 1703 1703 intel_pstate= [X86] 1704 1704 disable ··· 2171 2171 than or equal to this physical address is ignored. 2172 2172 2173 2173 maxcpus= [SMP] Maximum number of processors that an SMP kernel 2174 - should make use of. maxcpus=n : n >= 0 limits the 2175 - kernel to using 'n' processors. n=0 is a special case, 2176 - it is equivalent to "nosmp", which also disables 2177 - the IO APIC. 2174 + will bring up during bootup. maxcpus=n : n >= 0 limits 2175 + the kernel to bring up 'n' processors. Surely after 2176 + bootup you can bring up the other plugged cpu by executing 2177 + "echo 1 > /sys/devices/system/cpu/cpuX/online". So maxcpus 2178 + only takes effect during system bootup. 2179 + While n=0 is a special case, it is equivalent to "nosmp", 2180 + which also disables the IO APIC. 2178 2181 2179 2182 max_loop= [LOOP] The number of loop block devices that get 2180 2183 (loop.max_loop) unconditionally pre-created at init time. The default ··· 2584 2581 2585 2582 nodelayacct [KNL] Disable per-task delay accounting 2586 2583 2587 - nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects. 2588 - 2589 2584 nodsp [SH] Disable hardware DSP at boot time. 2590 2585 2591 2586 noefi Disable EFI runtime services support. ··· 2784 2783 2785 2784 nr_cpus= [SMP] Maximum number of processors that an SMP kernel 2786 2785 could support. nr_cpus=n : n >= 1 limits the kernel to 2787 - supporting 'n' processors. Later in runtime you can not 2788 - use hotplug cpu feature to put more cpu back to online. 2789 - just like you compile the kernel NR_CPUS=n 2786 + support 'n' processors. It could be larger than the 2787 + number of already plugged CPU during bootup, later in 2788 + runtime you can physically add extra cpu until it reaches 2789 + n. So during boot up some boot time memory for per-cpu 2790 + variables need be pre-allocated for later physical cpu 2791 + hot plugging. 2790 2792 2791 2793 nr_uarts= [SERIAL] maximum number of UARTs to be registered. 2792 2794
-754
Documentation/kmemcheck.txt
··· 1 - GETTING STARTED WITH KMEMCHECK 2 - ============================== 3 - 4 - Vegard Nossum <vegardno@ifi.uio.no> 5 - 6 - 7 - Contents 8 - ======== 9 - 0. Introduction 10 - 1. Downloading 11 - 2. Configuring and compiling 12 - 3. How to use 13 - 3.1. Booting 14 - 3.2. Run-time enable/disable 15 - 3.3. Debugging 16 - 3.4. Annotating false positives 17 - 4. Reporting errors 18 - 5. Technical description 19 - 20 - 21 - 0. Introduction 22 - =============== 23 - 24 - kmemcheck is a debugging feature for the Linux Kernel. More specifically, it 25 - is a dynamic checker that detects and warns about some uses of uninitialized 26 - memory. 27 - 28 - Userspace programmers might be familiar with Valgrind's memcheck. The main 29 - difference between memcheck and kmemcheck is that memcheck works for userspace 30 - programs only, and kmemcheck works for the kernel only. The implementations 31 - are of course vastly different. Because of this, kmemcheck is not as accurate 32 - as memcheck, but it turns out to be good enough in practice to discover real 33 - programmer errors that the compiler is not able to find through static 34 - analysis. 35 - 36 - Enabling kmemcheck on a kernel will probably slow it down to the extent that 37 - the machine will not be usable for normal workloads such as e.g. an 38 - interactive desktop. kmemcheck will also cause the kernel to use about twice 39 - as much memory as normal. For this reason, kmemcheck is strictly a debugging 40 - feature. 41 - 42 - 43 - 1. Downloading 44 - ============== 45 - 46 - As of version 2.6.31-rc1, kmemcheck is included in the mainline kernel. 47 - 48 - 49 - 2. Configuring and compiling 50 - ============================ 51 - 52 - kmemcheck only works for the x86 (both 32- and 64-bit) platform. A number of 53 - configuration variables must have specific settings in order for the kmemcheck 54 - menu to even appear in "menuconfig". These are: 55 - 56 - o CONFIG_CC_OPTIMIZE_FOR_SIZE=n 57 - 58 - This option is located under "General setup" / "Optimize for size". 59 - 60 - Without this, gcc will use certain optimizations that usually lead to 61 - false positive warnings from kmemcheck. An example of this is a 16-bit 62 - field in a struct, where gcc may load 32 bits, then discard the upper 63 - 16 bits. kmemcheck sees only the 32-bit load, and may trigger a 64 - warning for the upper 16 bits (if they're uninitialized). 65 - 66 - o CONFIG_SLAB=y or CONFIG_SLUB=y 67 - 68 - This option is located under "General setup" / "Choose SLAB 69 - allocator". 70 - 71 - o CONFIG_FUNCTION_TRACER=n 72 - 73 - This option is located under "Kernel hacking" / "Tracers" / "Kernel 74 - Function Tracer" 75 - 76 - When function tracing is compiled in, gcc emits a call to another 77 - function at the beginning of every function. This means that when the 78 - page fault handler is called, the ftrace framework will be called 79 - before kmemcheck has had a chance to handle the fault. If ftrace then 80 - modifies memory that was tracked by kmemcheck, the result is an 81 - endless recursive page fault. 82 - 83 - o CONFIG_DEBUG_PAGEALLOC=n 84 - 85 - This option is located under "Kernel hacking" / "Memory Debugging" 86 - / "Debug page memory allocations". 87 - 88 - In addition, I highly recommend turning on CONFIG_DEBUG_INFO=y. This is also 89 - located under "Kernel hacking". With this, you will be able to get line number 90 - information from the kmemcheck warnings, which is extremely valuable in 91 - debugging a problem. This option is not mandatory, however, because it slows 92 - down the compilation process and produces a much bigger kernel image. 93 - 94 - Now the kmemcheck menu should be visible (under "Kernel hacking" / "Memory 95 - Debugging" / "kmemcheck: trap use of uninitialized memory"). Here follows 96 - a description of the kmemcheck configuration variables: 97 - 98 - o CONFIG_KMEMCHECK 99 - 100 - This must be enabled in order to use kmemcheck at all... 101 - 102 - o CONFIG_KMEMCHECK_[DISABLED | ENABLED | ONESHOT]_BY_DEFAULT 103 - 104 - This option controls the status of kmemcheck at boot-time. "Enabled" 105 - will enable kmemcheck right from the start, "disabled" will boot the 106 - kernel as normal (but with the kmemcheck code compiled in, so it can 107 - be enabled at run-time after the kernel has booted), and "one-shot" is 108 - a special mode which will turn kmemcheck off automatically after 109 - detecting the first use of uninitialized memory. 110 - 111 - If you are using kmemcheck to actively debug a problem, then you 112 - probably want to choose "enabled" here. 113 - 114 - The one-shot mode is mostly useful in automated test setups because it 115 - can prevent floods of warnings and increase the chances of the machine 116 - surviving in case something is really wrong. In other cases, the one- 117 - shot mode could actually be counter-productive because it would turn 118 - itself off at the very first error -- in the case of a false positive 119 - too -- and this would come in the way of debugging the specific 120 - problem you were interested in. 121 - 122 - If you would like to use your kernel as normal, but with a chance to 123 - enable kmemcheck in case of some problem, it might be a good idea to 124 - choose "disabled" here. When kmemcheck is disabled, most of the run- 125 - time overhead is not incurred, and the kernel will be almost as fast 126 - as normal. 127 - 128 - o CONFIG_KMEMCHECK_QUEUE_SIZE 129 - 130 - Select the maximum number of error reports to store in an internal 131 - (fixed-size) buffer. Since errors can occur virtually anywhere and in 132 - any context, we need a temporary storage area which is guaranteed not 133 - to generate any other page faults when accessed. The queue will be 134 - emptied as soon as a tasklet may be scheduled. If the queue is full, 135 - new error reports will be lost. 136 - 137 - The default value of 64 is probably fine. If some code produces more 138 - than 64 errors within an irqs-off section, then the code is likely to 139 - produce many, many more, too, and these additional reports seldom give 140 - any more information (the first report is usually the most valuable 141 - anyway). 142 - 143 - This number might have to be adjusted if you are not using serial 144 - console or similar to capture the kernel log. If you are using the 145 - "dmesg" command to save the log, then getting a lot of kmemcheck 146 - warnings might overflow the kernel log itself, and the earlier reports 147 - will get lost in that way instead. Try setting this to 10 or so on 148 - such a setup. 149 - 150 - o CONFIG_KMEMCHECK_SHADOW_COPY_SHIFT 151 - 152 - Select the number of shadow bytes to save along with each entry of the 153 - error-report queue. These bytes indicate what parts of an allocation 154 - are initialized, uninitialized, etc. and will be displayed when an 155 - error is detected to help the debugging of a particular problem. 156 - 157 - The number entered here is actually the logarithm of the number of 158 - bytes that will be saved. So if you pick for example 5 here, kmemcheck 159 - will save 2^5 = 32 bytes. 160 - 161 - The default value should be fine for debugging most problems. It also 162 - fits nicely within 80 columns. 163 - 164 - o CONFIG_KMEMCHECK_PARTIAL_OK 165 - 166 - This option (when enabled) works around certain GCC optimizations that 167 - produce 32-bit reads from 16-bit variables where the upper 16 bits are 168 - thrown away afterwards. 169 - 170 - The default value (enabled) is recommended. This may of course hide 171 - some real errors, but disabling it would probably produce a lot of 172 - false positives. 173 - 174 - o CONFIG_KMEMCHECK_BITOPS_OK 175 - 176 - This option silences warnings that would be generated for bit-field 177 - accesses where not all the bits are initialized at the same time. This 178 - may also hide some real bugs. 179 - 180 - This option is probably obsolete, or it should be replaced with 181 - the kmemcheck-/bitfield-annotations for the code in question. The 182 - default value is therefore fine. 183 - 184 - Now compile the kernel as usual. 185 - 186 - 187 - 3. How to use 188 - ============= 189 - 190 - 3.1. Booting 191 - ============ 192 - 193 - First some information about the command-line options. There is only one 194 - option specific to kmemcheck, and this is called "kmemcheck". It can be used 195 - to override the default mode as chosen by the CONFIG_KMEMCHECK_*_BY_DEFAULT 196 - option. Its possible settings are: 197 - 198 - o kmemcheck=0 (disabled) 199 - o kmemcheck=1 (enabled) 200 - o kmemcheck=2 (one-shot mode) 201 - 202 - If SLUB debugging has been enabled in the kernel, it may take precedence over 203 - kmemcheck in such a way that the slab caches which are under SLUB debugging 204 - will not be tracked by kmemcheck. In order to ensure that this doesn't happen 205 - (even though it shouldn't by default), use SLUB's boot option "slub_debug", 206 - like this: slub_debug=- 207 - 208 - In fact, this option may also be used for fine-grained control over SLUB vs. 209 - kmemcheck. For example, if the command line includes "kmemcheck=1 210 - slub_debug=,dentry", then SLUB debugging will be used only for the "dentry" 211 - slab cache, and with kmemcheck tracking all the other caches. This is advanced 212 - usage, however, and is not generally recommended. 213 - 214 - 215 - 3.2. Run-time enable/disable 216 - ============================ 217 - 218 - When the kernel has booted, it is possible to enable or disable kmemcheck at 219 - run-time. WARNING: This feature is still experimental and may cause false 220 - positive warnings to appear. Therefore, try not to use this. If you find that 221 - it doesn't work properly (e.g. you see an unreasonable amount of warnings), I 222 - will be happy to take bug reports. 223 - 224 - Use the file /proc/sys/kernel/kmemcheck for this purpose, e.g.: 225 - 226 - $ echo 0 > /proc/sys/kernel/kmemcheck # disables kmemcheck 227 - 228 - The numbers are the same as for the kmemcheck= command-line option. 229 - 230 - 231 - 3.3. Debugging 232 - ============== 233 - 234 - A typical report will look something like this: 235 - 236 - WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff88003e4a2024) 237 - 80000000000000000000000000000000000000000088ffff0000000000000000 238 - i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u 239 - ^ 240 - 241 - Pid: 1856, comm: ntpdate Not tainted 2.6.29-rc5 #264 945P-A 242 - RIP: 0010:[<ffffffff8104ede8>] [<ffffffff8104ede8>] __dequeue_signal+0xc8/0x190 243 - RSP: 0018:ffff88003cdf7d98 EFLAGS: 00210002 244 - RAX: 0000000000000030 RBX: ffff88003d4ea968 RCX: 0000000000000009 245 - RDX: ffff88003e5d6018 RSI: ffff88003e5d6024 RDI: ffff88003cdf7e84 246 - RBP: ffff88003cdf7db8 R08: ffff88003e5d6000 R09: 0000000000000000 247 - R10: 0000000000000080 R11: 0000000000000000 R12: 000000000000000e 248 - R13: ffff88003cdf7e78 R14: ffff88003d530710 R15: ffff88003d5a98c8 249 - FS: 0000000000000000(0000) GS:ffff880001982000(0063) knlGS:00000 250 - CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 251 - CR2: ffff88003f806ea0 CR3: 000000003c036000 CR4: 00000000000006a0 252 - DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 253 - DR3: 0000000000000000 DR6: 00000000ffff4ff0 DR7: 0000000000000400 254 - [<ffffffff8104f04e>] dequeue_signal+0x8e/0x170 255 - [<ffffffff81050bd8>] get_signal_to_deliver+0x98/0x390 256 - [<ffffffff8100b87d>] do_notify_resume+0xad/0x7d0 257 - [<ffffffff8100c7b5>] int_signal+0x12/0x17 258 - [<ffffffffffffffff>] 0xffffffffffffffff 259 - 260 - The single most valuable information in this report is the RIP (or EIP on 32- 261 - bit) value. This will help us pinpoint exactly which instruction that caused 262 - the warning. 263 - 264 - If your kernel was compiled with CONFIG_DEBUG_INFO=y, then all we have to do 265 - is give this address to the addr2line program, like this: 266 - 267 - $ addr2line -e vmlinux -i ffffffff8104ede8 268 - arch/x86/include/asm/string_64.h:12 269 - include/asm-generic/siginfo.h:287 270 - kernel/signal.c:380 271 - kernel/signal.c:410 272 - 273 - The "-e vmlinux" tells addr2line which file to look in. IMPORTANT: This must 274 - be the vmlinux of the kernel that produced the warning in the first place! If 275 - not, the line number information will almost certainly be wrong. 276 - 277 - The "-i" tells addr2line to also print the line numbers of inlined functions. 278 - In this case, the flag was very important, because otherwise, it would only 279 - have printed the first line, which is just a call to memcpy(), which could be 280 - called from a thousand places in the kernel, and is therefore not very useful. 281 - These inlined functions would not show up in the stack trace above, simply 282 - because the kernel doesn't load the extra debugging information. This 283 - technique can of course be used with ordinary kernel oopses as well. 284 - 285 - In this case, it's the caller of memcpy() that is interesting, and it can be 286 - found in include/asm-generic/siginfo.h, line 287: 287 - 288 - 281 static inline void copy_siginfo(struct siginfo *to, struct siginfo *from) 289 - 282 { 290 - 283 if (from->si_code < 0) 291 - 284 memcpy(to, from, sizeof(*to)); 292 - 285 else 293 - 286 /* _sigchld is currently the largest know union member */ 294 - 287 memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld)); 295 - 288 } 296 - 297 - Since this was a read (kmemcheck usually warns about reads only, though it can 298 - warn about writes to unallocated or freed memory as well), it was probably the 299 - "from" argument which contained some uninitialized bytes. Following the chain 300 - of calls, we move upwards to see where "from" was allocated or initialized, 301 - kernel/signal.c, line 380: 302 - 303 - 359 static void collect_signal(int sig, struct sigpending *list, siginfo_t *info) 304 - 360 { 305 - ... 306 - 367 list_for_each_entry(q, &list->list, list) { 307 - 368 if (q->info.si_signo == sig) { 308 - 369 if (first) 309 - 370 goto still_pending; 310 - 371 first = q; 311 - ... 312 - 377 if (first) { 313 - 378 still_pending: 314 - 379 list_del_init(&first->list); 315 - 380 copy_siginfo(info, &first->info); 316 - 381 __sigqueue_free(first); 317 - ... 318 - 392 } 319 - 393 } 320 - 321 - Here, it is &first->info that is being passed on to copy_siginfo(). The 322 - variable "first" was found on a list -- passed in as the second argument to 323 - collect_signal(). We continue our journey through the stack, to figure out 324 - where the item on "list" was allocated or initialized. We move to line 410: 325 - 326 - 395 static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, 327 - 396 siginfo_t *info) 328 - 397 { 329 - ... 330 - 410 collect_signal(sig, pending, info); 331 - ... 332 - 414 } 333 - 334 - Now we need to follow the "pending" pointer, since that is being passed on to 335 - collect_signal() as "list". At this point, we've run out of lines from the 336 - "addr2line" output. Not to worry, we just paste the next addresses from the 337 - kmemcheck stack dump, i.e.: 338 - 339 - [<ffffffff8104f04e>] dequeue_signal+0x8e/0x170 340 - [<ffffffff81050bd8>] get_signal_to_deliver+0x98/0x390 341 - [<ffffffff8100b87d>] do_notify_resume+0xad/0x7d0 342 - [<ffffffff8100c7b5>] int_signal+0x12/0x17 343 - 344 - $ addr2line -e vmlinux -i ffffffff8104f04e ffffffff81050bd8 \ 345 - ffffffff8100b87d ffffffff8100c7b5 346 - kernel/signal.c:446 347 - kernel/signal.c:1806 348 - arch/x86/kernel/signal.c:805 349 - arch/x86/kernel/signal.c:871 350 - arch/x86/kernel/entry_64.S:694 351 - 352 - Remember that since these addresses were found on the stack and not as the 353 - RIP value, they actually point to the _next_ instruction (they are return 354 - addresses). This becomes obvious when we look at the code for line 446: 355 - 356 - 422 int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) 357 - 423 { 358 - ... 359 - 431 signr = __dequeue_signal(&tsk->signal->shared_pending, 360 - 432 mask, info); 361 - 433 /* 362 - 434 * itimer signal ? 363 - 435 * 364 - 436 * itimers are process shared and we restart periodic 365 - 437 * itimers in the signal delivery path to prevent DoS 366 - 438 * attacks in the high resolution timer case. This is 367 - 439 * compliant with the old way of self restarting 368 - 440 * itimers, as the SIGALRM is a legacy signal and only 369 - 441 * queued once. Changing the restart behaviour to 370 - 442 * restart the timer in the signal dequeue path is 371 - 443 * reducing the timer noise on heavy loaded !highres 372 - 444 * systems too. 373 - 445 */ 374 - 446 if (unlikely(signr == SIGALRM)) { 375 - ... 376 - 489 } 377 - 378 - So instead of looking at 446, we should be looking at 431, which is the line 379 - that executes just before 446. Here we see that what we are looking for is 380 - &tsk->signal->shared_pending. 381 - 382 - Our next task is now to figure out which function that puts items on this 383 - "shared_pending" list. A crude, but efficient tool, is git grep: 384 - 385 - $ git grep -n 'shared_pending' kernel/ 386 - ... 387 - kernel/signal.c:828: pending = group ? &t->signal->shared_pending : &t->pending; 388 - kernel/signal.c:1339: pending = group ? &t->signal->shared_pending : &t->pending; 389 - ... 390 - 391 - There were more results, but none of them were related to list operations, 392 - and these were the only assignments. We inspect the line numbers more closely 393 - and find that this is indeed where items are being added to the list: 394 - 395 - 816 static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 396 - 817 int group) 397 - 818 { 398 - ... 399 - 828 pending = group ? &t->signal->shared_pending : &t->pending; 400 - ... 401 - 851 q = __sigqueue_alloc(t, GFP_ATOMIC, (sig < SIGRTMIN && 402 - 852 (is_si_special(info) || 403 - 853 info->si_code >= 0))); 404 - 854 if (q) { 405 - 855 list_add_tail(&q->list, &pending->list); 406 - ... 407 - 890 } 408 - 409 - and: 410 - 411 - 1309 int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group) 412 - 1310 { 413 - .... 414 - 1339 pending = group ? &t->signal->shared_pending : &t->pending; 415 - 1340 list_add_tail(&q->list, &pending->list); 416 - .... 417 - 1347 } 418 - 419 - In the first case, the list element we are looking for, "q", is being returned 420 - from the function __sigqueue_alloc(), which looks like an allocation function. 421 - Let's take a look at it: 422 - 423 - 187 static struct sigqueue *__sigqueue_alloc(struct task_struct *t, gfp_t flags, 424 - 188 int override_rlimit) 425 - 189 { 426 - 190 struct sigqueue *q = NULL; 427 - 191 struct user_struct *user; 428 - 192 429 - 193 /* 430 - 194 * We won't get problems with the target's UID changing under us 431 - 195 * because changing it requires RCU be used, and if t != current, the 432 - 196 * caller must be holding the RCU readlock (by way of a spinlock) and 433 - 197 * we use RCU protection here 434 - 198 */ 435 - 199 user = get_uid(__task_cred(t)->user); 436 - 200 atomic_inc(&user->sigpending); 437 - 201 if (override_rlimit || 438 - 202 atomic_read(&user->sigpending) <= 439 - 203 t->signal->rlim[RLIMIT_SIGPENDING].rlim_cur) 440 - 204 q = kmem_cache_alloc(sigqueue_cachep, flags); 441 - 205 if (unlikely(q == NULL)) { 442 - 206 atomic_dec(&user->sigpending); 443 - 207 free_uid(user); 444 - 208 } else { 445 - 209 INIT_LIST_HEAD(&q->list); 446 - 210 q->flags = 0; 447 - 211 q->user = user; 448 - 212 } 449 - 213 450 - 214 return q; 451 - 215 } 452 - 453 - We see that this function initializes q->list, q->flags, and q->user. It seems 454 - that now is the time to look at the definition of "struct sigqueue", e.g.: 455 - 456 - 14 struct sigqueue { 457 - 15 struct list_head list; 458 - 16 int flags; 459 - 17 siginfo_t info; 460 - 18 struct user_struct *user; 461 - 19 }; 462 - 463 - And, you might remember, it was a memcpy() on &first->info that caused the 464 - warning, so this makes perfect sense. It also seems reasonable to assume that 465 - it is the caller of __sigqueue_alloc() that has the responsibility of filling 466 - out (initializing) this member. 467 - 468 - But just which fields of the struct were uninitialized? Let's look at 469 - kmemcheck's report again: 470 - 471 - WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff88003e4a2024) 472 - 80000000000000000000000000000000000000000088ffff0000000000000000 473 - i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u 474 - ^ 475 - 476 - These first two lines are the memory dump of the memory object itself, and the 477 - shadow bytemap, respectively. The memory object itself is in this case 478 - &first->info. Just beware that the start of this dump is NOT the start of the 479 - object itself! The position of the caret (^) corresponds with the address of 480 - the read (ffff88003e4a2024). 481 - 482 - The shadow bytemap dump legend is as follows: 483 - 484 - i - initialized 485 - u - uninitialized 486 - a - unallocated (memory has been allocated by the slab layer, but has not 487 - yet been handed off to anybody) 488 - f - freed (memory has been allocated by the slab layer, but has been freed 489 - by the previous owner) 490 - 491 - In order to figure out where (relative to the start of the object) the 492 - uninitialized memory was located, we have to look at the disassembly. For 493 - that, we'll need the RIP address again: 494 - 495 - RIP: 0010:[<ffffffff8104ede8>] [<ffffffff8104ede8>] __dequeue_signal+0xc8/0x190 496 - 497 - $ objdump -d --no-show-raw-insn vmlinux | grep -C 8 ffffffff8104ede8: 498 - ffffffff8104edc8: mov %r8,0x8(%r8) 499 - ffffffff8104edcc: test %r10d,%r10d 500 - ffffffff8104edcf: js ffffffff8104ee88 <__dequeue_signal+0x168> 501 - ffffffff8104edd5: mov %rax,%rdx 502 - ffffffff8104edd8: mov $0xc,%ecx 503 - ffffffff8104eddd: mov %r13,%rdi 504 - ffffffff8104ede0: mov $0x30,%eax 505 - ffffffff8104ede5: mov %rdx,%rsi 506 - ffffffff8104ede8: rep movsl %ds:(%rsi),%es:(%rdi) 507 - ffffffff8104edea: test $0x2,%al 508 - ffffffff8104edec: je ffffffff8104edf0 <__dequeue_signal+0xd0> 509 - ffffffff8104edee: movsw %ds:(%rsi),%es:(%rdi) 510 - ffffffff8104edf0: test $0x1,%al 511 - ffffffff8104edf2: je ffffffff8104edf5 <__dequeue_signal+0xd5> 512 - ffffffff8104edf4: movsb %ds:(%rsi),%es:(%rdi) 513 - ffffffff8104edf5: mov %r8,%rdi 514 - ffffffff8104edf8: callq ffffffff8104de60 <__sigqueue_free> 515 - 516 - As expected, it's the "rep movsl" instruction from the memcpy() that causes 517 - the warning. We know about REP MOVSL that it uses the register RCX to count 518 - the number of remaining iterations. By taking a look at the register dump 519 - again (from the kmemcheck report), we can figure out how many bytes were left 520 - to copy: 521 - 522 - RAX: 0000000000000030 RBX: ffff88003d4ea968 RCX: 0000000000000009 523 - 524 - By looking at the disassembly, we also see that %ecx is being loaded with the 525 - value $0xc just before (ffffffff8104edd8), so we are very lucky. Keep in mind 526 - that this is the number of iterations, not bytes. And since this is a "long" 527 - operation, we need to multiply by 4 to get the number of bytes. So this means 528 - that the uninitialized value was encountered at 4 * (0xc - 0x9) = 12 bytes 529 - from the start of the object. 530 - 531 - We can now try to figure out which field of the "struct siginfo" that was not 532 - initialized. This is the beginning of the struct: 533 - 534 - 40 typedef struct siginfo { 535 - 41 int si_signo; 536 - 42 int si_errno; 537 - 43 int si_code; 538 - 44 539 - 45 union { 540 - .. 541 - 92 } _sifields; 542 - 93 } siginfo_t; 543 - 544 - On 64-bit, the int is 4 bytes long, so it must the union member that has 545 - not been initialized. We can verify this using gdb: 546 - 547 - $ gdb vmlinux 548 - ... 549 - (gdb) p &((struct siginfo *) 0)->_sifields 550 - $1 = (union {...} *) 0x10 551 - 552 - Actually, it seems that the union member is located at offset 0x10 -- which 553 - means that gcc has inserted 4 bytes of padding between the members si_code 554 - and _sifields. We can now get a fuller picture of the memory dump: 555 - 556 - _----------------------------=> si_code 557 - / _--------------------=> (padding) 558 - | / _------------=> _sifields(._kill._pid) 559 - | | / _----=> _sifields(._kill._uid) 560 - | | | / 561 - -------|-------|-------|-------| 562 - 80000000000000000000000000000000000000000088ffff0000000000000000 563 - i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u 564 - 565 - This allows us to realize another important fact: si_code contains the value 566 - 0x80. Remember that x86 is little endian, so the first 4 bytes "80000000" are 567 - really the number 0x00000080. With a bit of research, we find that this is 568 - actually the constant SI_KERNEL defined in include/asm-generic/siginfo.h: 569 - 570 - 144 #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ 571 - 572 - This macro is used in exactly one place in the x86 kernel: In send_signal() 573 - in kernel/signal.c: 574 - 575 - 816 static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 576 - 817 int group) 577 - 818 { 578 - ... 579 - 828 pending = group ? &t->signal->shared_pending : &t->pending; 580 - ... 581 - 851 q = __sigqueue_alloc(t, GFP_ATOMIC, (sig < SIGRTMIN && 582 - 852 (is_si_special(info) || 583 - 853 info->si_code >= 0))); 584 - 854 if (q) { 585 - 855 list_add_tail(&q->list, &pending->list); 586 - 856 switch ((unsigned long) info) { 587 - ... 588 - 865 case (unsigned long) SEND_SIG_PRIV: 589 - 866 q->info.si_signo = sig; 590 - 867 q->info.si_errno = 0; 591 - 868 q->info.si_code = SI_KERNEL; 592 - 869 q->info.si_pid = 0; 593 - 870 q->info.si_uid = 0; 594 - 871 break; 595 - ... 596 - 890 } 597 - 598 - Not only does this match with the .si_code member, it also matches the place 599 - we found earlier when looking for where siginfo_t objects are enqueued on the 600 - "shared_pending" list. 601 - 602 - So to sum up: It seems that it is the padding introduced by the compiler 603 - between two struct fields that is uninitialized, and this gets reported when 604 - we do a memcpy() on the struct. This means that we have identified a false 605 - positive warning. 606 - 607 - Normally, kmemcheck will not report uninitialized accesses in memcpy() calls 608 - when both the source and destination addresses are tracked. (Instead, we copy 609 - the shadow bytemap as well). In this case, the destination address clearly 610 - was not tracked. We can dig a little deeper into the stack trace from above: 611 - 612 - arch/x86/kernel/signal.c:805 613 - arch/x86/kernel/signal.c:871 614 - arch/x86/kernel/entry_64.S:694 615 - 616 - And we clearly see that the destination siginfo object is located on the 617 - stack: 618 - 619 - 782 static void do_signal(struct pt_regs *regs) 620 - 783 { 621 - 784 struct k_sigaction ka; 622 - 785 siginfo_t info; 623 - ... 624 - 804 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 625 - ... 626 - 854 } 627 - 628 - And this &info is what eventually gets passed to copy_siginfo() as the 629 - destination argument. 630 - 631 - Now, even though we didn't find an actual error here, the example is still a 632 - good one, because it shows how one would go about to find out what the report 633 - was all about. 634 - 635 - 636 - 3.4. Annotating false positives 637 - =============================== 638 - 639 - There are a few different ways to make annotations in the source code that 640 - will keep kmemcheck from checking and reporting certain allocations. Here 641 - they are: 642 - 643 - o __GFP_NOTRACK_FALSE_POSITIVE 644 - 645 - This flag can be passed to kmalloc() or kmem_cache_alloc() (therefore 646 - also to other functions that end up calling one of these) to indicate 647 - that the allocation should not be tracked because it would lead to 648 - a false positive report. This is a "big hammer" way of silencing 649 - kmemcheck; after all, even if the false positive pertains to 650 - particular field in a struct, for example, we will now lose the 651 - ability to find (real) errors in other parts of the same struct. 652 - 653 - Example: 654 - 655 - /* No warnings will ever trigger on accessing any part of x */ 656 - x = kmalloc(sizeof *x, GFP_KERNEL | __GFP_NOTRACK_FALSE_POSITIVE); 657 - 658 - o kmemcheck_bitfield_begin(name)/kmemcheck_bitfield_end(name) and 659 - kmemcheck_annotate_bitfield(ptr, name) 660 - 661 - The first two of these three macros can be used inside struct 662 - definitions to signal, respectively, the beginning and end of a 663 - bitfield. Additionally, this will assign the bitfield a name, which 664 - is given as an argument to the macros. 665 - 666 - Having used these markers, one can later use 667 - kmemcheck_annotate_bitfield() at the point of allocation, to indicate 668 - which parts of the allocation is part of a bitfield. 669 - 670 - Example: 671 - 672 - struct foo { 673 - int x; 674 - 675 - kmemcheck_bitfield_begin(flags); 676 - int flag_a:1; 677 - int flag_b:1; 678 - kmemcheck_bitfield_end(flags); 679 - 680 - int y; 681 - }; 682 - 683 - struct foo *x = kmalloc(sizeof *x); 684 - 685 - /* No warnings will trigger on accessing the bitfield of x */ 686 - kmemcheck_annotate_bitfield(x, flags); 687 - 688 - Note that kmemcheck_annotate_bitfield() can be used even before the 689 - return value of kmalloc() is checked -- in other words, passing NULL 690 - as the first argument is legal (and will do nothing). 691 - 692 - 693 - 4. Reporting errors 694 - =================== 695 - 696 - As we have seen, kmemcheck will produce false positive reports. Therefore, it 697 - is not very wise to blindly post kmemcheck warnings to mailing lists and 698 - maintainers. Instead, I encourage maintainers and developers to find errors 699 - in their own code. If you get a warning, you can try to work around it, try 700 - to figure out if it's a real error or not, or simply ignore it. Most 701 - developers know their own code and will quickly and efficiently determine the 702 - root cause of a kmemcheck report. This is therefore also the most efficient 703 - way to work with kmemcheck. 704 - 705 - That said, we (the kmemcheck maintainers) will always be on the lookout for 706 - false positives that we can annotate and silence. So whatever you find, 707 - please drop us a note privately! Kernel configs and steps to reproduce (if 708 - available) are of course a great help too. 709 - 710 - Happy hacking! 711 - 712 - 713 - 5. Technical description 714 - ======================== 715 - 716 - kmemcheck works by marking memory pages non-present. This means that whenever 717 - somebody attempts to access the page, a page fault is generated. The page 718 - fault handler notices that the page was in fact only hidden, and so it calls 719 - on the kmemcheck code to make further investigations. 720 - 721 - When the investigations are completed, kmemcheck "shows" the page by marking 722 - it present (as it would be under normal circumstances). This way, the 723 - interrupted code can continue as usual. 724 - 725 - But after the instruction has been executed, we should hide the page again, so 726 - that we can catch the next access too! Now kmemcheck makes use of a debugging 727 - feature of the processor, namely single-stepping. When the processor has 728 - finished the one instruction that generated the memory access, a debug 729 - exception is raised. From here, we simply hide the page again and continue 730 - execution, this time with the single-stepping feature turned off. 731 - 732 - kmemcheck requires some assistance from the memory allocator in order to work. 733 - The memory allocator needs to 734 - 735 - 1. Tell kmemcheck about newly allocated pages and pages that are about to 736 - be freed. This allows kmemcheck to set up and tear down the shadow memory 737 - for the pages in question. The shadow memory stores the status of each 738 - byte in the allocation proper, e.g. whether it is initialized or 739 - uninitialized. 740 - 741 - 2. Tell kmemcheck which parts of memory should be marked uninitialized. 742 - There are actually a few more states, such as "not yet allocated" and 743 - "recently freed". 744 - 745 - If a slab cache is set up using the SLAB_NOTRACK flag, it will never return 746 - memory that can take page faults because of kmemcheck. 747 - 748 - If a slab cache is NOT set up using the SLAB_NOTRACK flag, callers can still 749 - request memory with the __GFP_NOTRACK or __GFP_NOTRACK_FALSE_POSITIVE flags. 750 - This does not prevent the page faults from occurring, however, but marks the 751 - object in question as being initialized so that no warnings will ever be 752 - produced for this object. 753 - 754 - Currently, the SLAB and SLUB allocators are supported by kmemcheck.
+48 -41
Documentation/kmemleak.txt Documentation/dev-tools/kmemleak.rst
··· 1 1 Kernel Memory Leak Detector 2 2 =========================== 3 3 4 - Introduction 5 - ------------ 6 - 7 4 Kmemleak provides a way of detecting possible kernel memory leaks in a 8 5 way similar to a tracing garbage collector 9 6 (https://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29#Tracing_garbage_collectors), 10 7 with the difference that the orphan objects are not freed but only 11 8 reported via /sys/kernel/debug/kmemleak. A similar method is used by the 12 - Valgrind tool (memcheck --leak-check) to detect the memory leaks in 9 + Valgrind tool (``memcheck --leak-check``) to detect the memory leaks in 13 10 user-space applications. 14 11 Kmemleak is supported on x86, arm, powerpc, sparc, sh, microblaze, ppc, mips, s390, metag and tile. 15 12 ··· 16 19 CONFIG_DEBUG_KMEMLEAK in "Kernel hacking" has to be enabled. A kernel 17 20 thread scans the memory every 10 minutes (by default) and prints the 18 21 number of new unreferenced objects found. To display the details of all 19 - the possible memory leaks: 22 + the possible memory leaks:: 20 23 21 24 # mount -t debugfs nodev /sys/kernel/debug/ 22 25 # cat /sys/kernel/debug/kmemleak 23 26 24 - To trigger an intermediate memory scan: 27 + To trigger an intermediate memory scan:: 25 28 26 29 # echo scan > /sys/kernel/debug/kmemleak 27 30 28 - To clear the list of all current possible memory leaks: 31 + To clear the list of all current possible memory leaks:: 29 32 30 33 # echo clear > /sys/kernel/debug/kmemleak 31 34 32 - New leaks will then come up upon reading /sys/kernel/debug/kmemleak 35 + New leaks will then come up upon reading ``/sys/kernel/debug/kmemleak`` 33 36 again. 34 37 35 38 Note that the orphan objects are listed in the order they were allocated ··· 37 40 objects to be reported as orphan. 38 41 39 42 Memory scanning parameters can be modified at run-time by writing to the 40 - /sys/kernel/debug/kmemleak file. The following parameters are supported: 43 + ``/sys/kernel/debug/kmemleak`` file. The following parameters are supported: 41 44 42 - off - disable kmemleak (irreversible) 43 - stack=on - enable the task stacks scanning (default) 44 - stack=off - disable the tasks stacks scanning 45 - scan=on - start the automatic memory scanning thread (default) 46 - scan=off - stop the automatic memory scanning thread 47 - scan=<secs> - set the automatic memory scanning period in seconds 48 - (default 600, 0 to stop the automatic scanning) 49 - scan - trigger a memory scan 50 - clear - clear list of current memory leak suspects, done by 51 - marking all current reported unreferenced objects grey, 52 - or free all kmemleak objects if kmemleak has been disabled. 53 - dump=<addr> - dump information about the object found at <addr> 45 + - off 46 + disable kmemleak (irreversible) 47 + - stack=on 48 + enable the task stacks scanning (default) 49 + - stack=off 50 + disable the tasks stacks scanning 51 + - scan=on 52 + start the automatic memory scanning thread (default) 53 + - scan=off 54 + stop the automatic memory scanning thread 55 + - scan=<secs> 56 + set the automatic memory scanning period in seconds 57 + (default 600, 0 to stop the automatic scanning) 58 + - scan 59 + trigger a memory scan 60 + - clear 61 + clear list of current memory leak suspects, done by 62 + marking all current reported unreferenced objects grey, 63 + or free all kmemleak objects if kmemleak has been disabled. 64 + - dump=<addr> 65 + dump information about the object found at <addr> 54 66 55 - Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on 67 + Kmemleak can also be disabled at boot-time by passing ``kmemleak=off`` on 56 68 the kernel command line. 57 69 58 70 Memory may be allocated or freed before kmemleak is initialised and ··· 69 63 is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option. 70 64 71 65 If CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF are enabled, the kmemleak is 72 - disabled by default. Passing "kmemleak=on" on the kernel command 66 + disabled by default. Passing ``kmemleak=on`` on the kernel command 73 67 line enables the function. 74 68 75 69 Basic Algorithm 76 70 --------------- 77 71 78 - The memory allocations via kmalloc, vmalloc, kmem_cache_alloc and 72 + The memory allocations via :c:func:`kmalloc`, :c:func:`vmalloc`, 73 + :c:func:`kmem_cache_alloc` and 79 74 friends are traced and the pointers, together with additional 80 75 information like size and stack trace, are stored in a rbtree. 81 76 The corresponding freeing function calls are tracked and the pointers ··· 120 113 you can find new unreferenced objects; this should help with testing 121 114 specific sections of code. 122 115 123 - To test a critical section on demand with a clean kmemleak do: 116 + To test a critical section on demand with a clean kmemleak do:: 124 117 125 118 # echo clear > /sys/kernel/debug/kmemleak 126 119 ... test your kernel or modules ... 127 120 # echo scan > /sys/kernel/debug/kmemleak 128 121 129 - Then as usual to get your report with: 122 + Then as usual to get your report with:: 130 123 131 124 # cat /sys/kernel/debug/kmemleak 132 125 ··· 138 131 won't be freed when kmemleak is disabled, and those objects may occupy 139 132 a large part of physical memory. 140 133 141 - In this situation, you may reclaim memory with: 134 + In this situation, you may reclaim memory with:: 142 135 143 136 # echo clear > /sys/kernel/debug/kmemleak 144 137 ··· 147 140 148 141 See the include/linux/kmemleak.h header for the functions prototype. 149 142 150 - kmemleak_init - initialize kmemleak 151 - kmemleak_alloc - notify of a memory block allocation 152 - kmemleak_alloc_percpu - notify of a percpu memory block allocation 153 - kmemleak_free - notify of a memory block freeing 154 - kmemleak_free_part - notify of a partial memory block freeing 155 - kmemleak_free_percpu - notify of a percpu memory block freeing 156 - kmemleak_update_trace - update object allocation stack trace 157 - kmemleak_not_leak - mark an object as not a leak 158 - kmemleak_ignore - do not scan or report an object as leak 159 - kmemleak_scan_area - add scan areas inside a memory block 160 - kmemleak_no_scan - do not scan a memory block 161 - kmemleak_erase - erase an old value in a pointer variable 162 - kmemleak_alloc_recursive - as kmemleak_alloc but checks the recursiveness 163 - kmemleak_free_recursive - as kmemleak_free but checks the recursiveness 143 + - ``kmemleak_init`` - initialize kmemleak 144 + - ``kmemleak_alloc`` - notify of a memory block allocation 145 + - ``kmemleak_alloc_percpu`` - notify of a percpu memory block allocation 146 + - ``kmemleak_free`` - notify of a memory block freeing 147 + - ``kmemleak_free_part`` - notify of a partial memory block freeing 148 + - ``kmemleak_free_percpu`` - notify of a percpu memory block freeing 149 + - ``kmemleak_update_trace`` - update object allocation stack trace 150 + - ``kmemleak_not_leak`` - mark an object as not a leak 151 + - ``kmemleak_ignore`` - do not scan or report an object as leak 152 + - ``kmemleak_scan_area`` - add scan areas inside a memory block 153 + - ``kmemleak_no_scan`` - do not scan a memory block 154 + - ``kmemleak_erase`` - erase an old value in a pointer variable 155 + - ``kmemleak_alloc_recursive`` - as kmemleak_alloc but checks the recursiveness 156 + - ``kmemleak_free_recursive`` - as kmemleak_free but checks the recursiveness 164 157 165 158 Dealing with false positives/negatives 166 159 --------------------------------------
+10
Documentation/kprobes.txt
··· 103 103 or in registers. The jprobe will work in either case, so long as the 104 104 handler's prototype matches that of the probed function. 105 105 106 + Note that in some architectures (e.g.: arm64 and sparc64) the stack 107 + copy is not done, as the actual location of stacked parameters may be 108 + outside of a reasonable MAX_STACK_SIZE value and because that location 109 + cannot be determined by the jprobes code. In this case the jprobes 110 + user must be careful to make certain the calling signature of the 111 + function does not cause parameters to be passed on the stack (e.g.: 112 + more than eight function arguments, an argument of more than sixteen 113 + bytes, or more than 64 bytes of argument data, depending on 114 + architecture). 115 + 106 116 1.3 Return Probes 107 117 108 118 1.3.1 How Does a Return Probe Work?
+2 -1
Documentation/media/Makefile
··· 10 10 11 11 TARGETS := $(addprefix $(BUILDDIR)/, $(FILES)) 12 12 13 - htmldocs: $(BUILDDIR) ${TARGETS} 13 + .PHONY: all 14 + all: $(BUILDDIR) ${TARGETS} 14 15 15 16 $(BUILDDIR): 16 17 $(Q)mkdir -p $@
+10
Documentation/media/conf.py
··· 1 + # -*- coding: utf-8; mode: python -*- 2 + 3 + project = 'Linux Media Subsystem Documentation' 4 + 5 + tags.add("subproject") 6 + 7 + latex_documents = [ 8 + ('index', 'media.tex', 'Linux Media Subsystem Documentation', 9 + 'The kernel development community', 'manual'), 10 + ]
+93
Documentation/media/conf_nitpick.py
··· 1 + # -*- coding: utf-8; mode: python -*- 2 + 3 + project = 'Linux Media Subsystem Documentation' 4 + 5 + # It is possible to run Sphinx in nickpick mode with: 6 + nitpicky = True 7 + 8 + # within nit-picking build, do not refer to any intersphinx object 9 + intersphinx_mapping = {} 10 + 11 + # In nickpick mode, it will complain about lots of missing references that 12 + # 13 + # 1) are just typedefs like: bool, __u32, etc; 14 + # 2) It will complain for things like: enum, NULL; 15 + # 3) It will complain for symbols that should be on different 16 + # books (but currently aren't ported to ReST) 17 + # 18 + # The list below has a list of such symbols to be ignored in nitpick mode 19 + # 20 + nitpick_ignore = [ 21 + ("c:func", "clock_gettime"), 22 + ("c:func", "close"), 23 + ("c:func", "container_of"), 24 + ("c:func", "determine_valid_ioctls"), 25 + ("c:func", "ERR_PTR"), 26 + ("c:func", "ioctl"), 27 + ("c:func", "IS_ERR"), 28 + ("c:func", "mmap"), 29 + ("c:func", "open"), 30 + ("c:func", "pci_name"), 31 + ("c:func", "poll"), 32 + ("c:func", "PTR_ERR"), 33 + ("c:func", "read"), 34 + ("c:func", "release"), 35 + ("c:func", "set"), 36 + ("c:func", "struct fd_set"), 37 + ("c:func", "struct pollfd"), 38 + ("c:func", "usb_make_path"), 39 + ("c:func", "write"), 40 + ("c:type", "atomic_t"), 41 + ("c:type", "bool"), 42 + ("c:type", "buf_queue"), 43 + ("c:type", "device"), 44 + ("c:type", "device_driver"), 45 + ("c:type", "device_node"), 46 + ("c:type", "enum"), 47 + ("c:type", "file"), 48 + ("c:type", "i2c_adapter"), 49 + ("c:type", "i2c_board_info"), 50 + ("c:type", "i2c_client"), 51 + ("c:type", "ktime_t"), 52 + ("c:type", "led_classdev_flash"), 53 + ("c:type", "list_head"), 54 + ("c:type", "lock_class_key"), 55 + ("c:type", "module"), 56 + ("c:type", "mutex"), 57 + ("c:type", "pci_dev"), 58 + ("c:type", "pdvbdev"), 59 + ("c:type", "poll_table_struct"), 60 + ("c:type", "s32"), 61 + ("c:type", "s64"), 62 + ("c:type", "sd"), 63 + ("c:type", "spi_board_info"), 64 + ("c:type", "spi_device"), 65 + ("c:type", "spi_master"), 66 + ("c:type", "struct fb_fix_screeninfo"), 67 + ("c:type", "struct pollfd"), 68 + ("c:type", "struct timeval"), 69 + ("c:type", "struct video_capability"), 70 + ("c:type", "u16"), 71 + ("c:type", "u32"), 72 + ("c:type", "u64"), 73 + ("c:type", "u8"), 74 + ("c:type", "union"), 75 + ("c:type", "usb_device"), 76 + 77 + ("cpp:type", "boolean"), 78 + ("cpp:type", "fd"), 79 + ("cpp:type", "fd_set"), 80 + ("cpp:type", "int16_t"), 81 + ("cpp:type", "NULL"), 82 + ("cpp:type", "off_t"), 83 + ("cpp:type", "pollfd"), 84 + ("cpp:type", "size_t"), 85 + ("cpp:type", "ssize_t"), 86 + ("cpp:type", "timeval"), 87 + ("cpp:type", "__u16"), 88 + ("cpp:type", "__u32"), 89 + ("cpp:type", "__u64"), 90 + ("cpp:type", "uint16_t"), 91 + ("cpp:type", "uint32_t"), 92 + ("cpp:type", "video_system_t"), 93 + ]
+19
Documentation/media/index.rst
··· 1 + Linux Media Subsystem Documentation 2 + =================================== 3 + 4 + Contents: 5 + 6 + .. toctree:: 7 + :maxdepth: 2 8 + 9 + media_uapi 10 + media_kapi 11 + dvb-drivers/index 12 + v4l-drivers/index 13 + 14 + .. only:: subproject 15 + 16 + Indices 17 + ======= 18 + 19 + * :ref:`genindex`
+1 -1
Documentation/media/uapi/cec/cec-func-open.rst
··· 32 32 Open flags. Access mode must be ``O_RDWR``. 33 33 34 34 When the ``O_NONBLOCK`` flag is given, the 35 - :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls 35 + :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :c:func:`CEC_DQEVENT` ioctls 36 36 will return the ``EAGAIN`` error code when no message or event is available, and 37 37 ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`, 38 38 :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and
+3 -2
Documentation/media/uapi/cec/cec-ioc-dqevent.rst
··· 15 15 Synopsis 16 16 ======== 17 17 18 - .. cpp:function:: int ioctl( int fd, int request, struct cec_event *argp ) 18 + .. c:function:: int ioctl( int fd, int request, struct cec_event *argp ) 19 + :name: CEC_DQEVENT 19 20 20 21 Arguments 21 22 ========= ··· 37 36 and is currently only available as a staging kernel module. 38 37 39 38 CEC devices can send asynchronous events. These can be retrieved by 40 - calling :ref:`ioctl CEC_DQEVENT <CEC_DQEVENT>`. If the file descriptor is in 39 + calling :c:func:`CEC_DQEVENT`. If the file descriptor is in 41 40 non-blocking mode and no event is pending, then it will return -1 and 42 41 set errno to the ``EAGAIN`` error code. 43 42
-2
Documentation/scsi/scsi-parameters.txt
··· 79 79 80 80 ncr53c8xx= [HW,SCSI] 81 81 82 - nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects. 83 - 84 82 osst= [HW,SCSI] SCSI Tape Driver 85 83 Format: <buffer_size>,<write_threshold> 86 84 See also Documentation/scsi/st.txt.
+2 -3
Documentation/serial/serial-rs485.txt
··· 45 45 46 46 #include <linux/serial.h> 47 47 48 - /* RS485 ioctls: */ 49 - #define TIOCGRS485 0x542E 50 - #define TIOCSRS485 0x542F 48 + /* Include definition for RS485 ioctls: TIOCGRS485 and TIOCSRS485 */ 49 + #include <sys/ioctl.h> 51 50 52 51 /* Open your specific device (e.g., /dev/mydevice): */ 53 52 int fd = open ("/dev/mydevice", O_RDWR);
+24 -15
Documentation/sparse.txt Documentation/dev-tools/sparse.rst
··· 1 - Copyright 2004 Linus Torvalds 2 - Copyright 2004 Pavel Machek <pavel@ucw.cz> 3 - Copyright 2006 Bob Copeland <me@bobcopeland.com> 1 + .. Copyright 2004 Linus Torvalds 2 + .. Copyright 2004 Pavel Machek <pavel@ucw.cz> 3 + .. Copyright 2006 Bob Copeland <me@bobcopeland.com> 4 + 5 + Sparse 6 + ====== 7 + 8 + Sparse is a semantic checker for C programs; it can be used to find a 9 + number of potential problems with kernel code. See 10 + https://lwn.net/Articles/689907/ for an overview of sparse; this document 11 + contains some kernel-specific sparse information. 12 + 4 13 5 14 Using sparse for typechecking 6 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 15 + ----------------------------- 7 16 8 - "__bitwise" is a type attribute, so you have to do something like this: 17 + "__bitwise" is a type attribute, so you have to do something like this:: 9 18 10 19 typedef int __bitwise pm_request_t; 11 20 ··· 29 20 the enum values are all the same type, now "enum pm_request" will be that 30 21 type too. 31 22 32 - And with gcc, all the __bitwise/__force stuff goes away, and it all ends 33 - up looking just like integers to gcc. 23 + And with gcc, all the "__bitwise"/"__force stuff" goes away, and it all 24 + ends up looking just like integers to gcc. 34 25 35 26 Quite frankly, you don't need the enum there. The above all really just 36 27 boils down to one special "int __bitwise" type. 37 28 38 - So the simpler way is to just do 29 + So the simpler way is to just do:: 39 30 40 31 typedef int __bitwise pm_request_t; 41 32 ··· 59 50 don't want to drown in noise unless we'd explicitly asked for it. 60 51 61 52 Using sparse for lock checking 62 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 53 + ------------------------------ 63 54 64 55 The following macros are undefined for gcc and defined during a sparse 65 56 run to use the "context" tracking feature of sparse, applied to ··· 78 69 sparse would otherwise report a context imbalance. 79 70 80 71 Getting sparse 81 - ~~~~~~~~~~~~~~ 72 + -------------- 82 73 83 74 You can get latest released versions from the Sparse homepage at 84 75 https://sparse.wiki.kernel.org/index.php/Main_Page 85 76 86 77 Alternatively, you can get snapshots of the latest development version 87 - of sparse using git to clone.. 78 + of sparse using git to clone:: 88 79 89 80 git://git.kernel.org/pub/scm/devel/sparse/sparse.git 90 81 91 - DaveJ has hourly generated tarballs of the git tree available at.. 82 + DaveJ has hourly generated tarballs of the git tree available at:: 92 83 93 84 http://www.codemonkey.org.uk/projects/git-snapshots/sparse/ 94 85 95 86 96 - Once you have it, just do 87 + Once you have it, just do:: 97 88 98 89 make 99 90 make install ··· 101 92 as a regular user, and it will install sparse in your ~/bin directory. 102 93 103 94 Using sparse 104 - ~~~~~~~~~~~~ 95 + ------------ 105 96 106 97 Do a kernel make with "make C=1" to run sparse on all the C files that get 107 98 recompiled, or use "make C=2" to run sparse on the files whether they need to ··· 110 101 111 102 The optional make variable CF can be used to pass arguments to sparse. The 112 103 build system passes -Wbitwise to sparse automatically. To perform endianness 113 - checks, you may define __CHECK_ENDIAN__: 104 + checks, you may define __CHECK_ENDIAN__:: 114 105 115 106 make C=2 CF="-D__CHECK_ENDIAN__" 116 107
+14 -1
Documentation/sphinx-static/theme_overrides.css
··· 42 42 caption a.headerlink { opacity: 0; } 43 43 caption a.headerlink:hover { opacity: 1; } 44 44 45 + /* Menu selection and keystrokes */ 46 + 47 + span.menuselection { 48 + color: blue; 49 + font-family: "Courier New", Courier, monospace 50 + } 51 + 52 + code.kbd, code.kbd span { 53 + color: white; 54 + background-color: darkblue; 55 + font-weight: bold; 56 + font-family: "Courier New", Courier, monospace 57 + } 58 + 45 59 /* inline literal: drop the borderbox, padding and red color */ 46 60 47 61 code, .rst-content tt, .rst-content code { ··· 69 55 .rst-content tt.literal,.rst-content tt.literal,.rst-content code.literal { 70 56 color: inherit; 71 57 } 72 - 73 58 }
+165
Documentation/sphinx/cdomain.py
··· 1 + # -*- coding: utf-8; mode: python -*- 2 + # pylint: disable=W0141,C0113,C0103,C0325 3 + u""" 4 + cdomain 5 + ~~~~~~~ 6 + 7 + Replacement for the sphinx c-domain. 8 + 9 + :copyright: Copyright (C) 2016 Markus Heiser 10 + :license: GPL Version 2, June 1991 see Linux/COPYING for details. 11 + 12 + List of customizations: 13 + 14 + * Moved the *duplicate C object description* warnings for function 15 + declarations in the nitpicky mode. See Sphinx documentation for 16 + the config values for ``nitpick`` and ``nitpick_ignore``. 17 + 18 + * Add option 'name' to the "c:function:" directive. With option 'name' the 19 + ref-name of a function can be modified. E.g.:: 20 + 21 + .. c:function:: int ioctl( int fd, int request ) 22 + :name: VIDIOC_LOG_STATUS 23 + 24 + The func-name (e.g. ioctl) remains in the output but the ref-name changed 25 + from 'ioctl' to 'VIDIOC_LOG_STATUS'. The function is referenced by:: 26 + 27 + * :c:func:`VIDIOC_LOG_STATUS` or 28 + * :any:`VIDIOC_LOG_STATUS` (``:any:`` needs sphinx 1.3) 29 + 30 + * Handle signatures of function-like macros well. Don't try to deduce 31 + arguments types of function-like macros. 32 + 33 + """ 34 + 35 + from docutils import nodes 36 + from docutils.parsers.rst import directives 37 + 38 + import sphinx 39 + from sphinx import addnodes 40 + from sphinx.domains.c import c_funcptr_sig_re, c_sig_re 41 + from sphinx.domains.c import CObject as Base_CObject 42 + from sphinx.domains.c import CDomain as Base_CDomain 43 + 44 + __version__ = '1.0' 45 + 46 + # Get Sphinx version 47 + major, minor, patch = map(int, sphinx.__version__.split(".")) 48 + 49 + def setup(app): 50 + 51 + app.override_domain(CDomain) 52 + 53 + return dict( 54 + version = __version__, 55 + parallel_read_safe = True, 56 + parallel_write_safe = True 57 + ) 58 + 59 + class CObject(Base_CObject): 60 + 61 + """ 62 + Description of a C language object. 63 + """ 64 + option_spec = { 65 + "name" : directives.unchanged 66 + } 67 + 68 + def handle_func_like_macro(self, sig, signode): 69 + u"""Handles signatures of function-like macros. 70 + 71 + If the objtype is 'function' and the the signature ``sig`` is a 72 + function-like macro, the name of the macro is returned. Otherwise 73 + ``False`` is returned. """ 74 + 75 + if not self.objtype == 'function': 76 + return False 77 + 78 + m = c_funcptr_sig_re.match(sig) 79 + if m is None: 80 + m = c_sig_re.match(sig) 81 + if m is None: 82 + raise ValueError('no match') 83 + 84 + rettype, fullname, arglist, _const = m.groups() 85 + arglist = arglist.strip() 86 + if rettype or not arglist: 87 + return False 88 + 89 + arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup 90 + arglist = [a.strip() for a in arglist.split(",")] 91 + 92 + # has the first argument a type? 93 + if len(arglist[0].split(" ")) > 1: 94 + return False 95 + 96 + # This is a function-like macro, it's arguments are typeless! 97 + signode += addnodes.desc_name(fullname, fullname) 98 + paramlist = addnodes.desc_parameterlist() 99 + signode += paramlist 100 + 101 + for argname in arglist: 102 + param = addnodes.desc_parameter('', '', noemph=True) 103 + # separate by non-breaking space in the output 104 + param += nodes.emphasis(argname, argname) 105 + paramlist += param 106 + 107 + return fullname 108 + 109 + def handle_signature(self, sig, signode): 110 + """Transform a C signature into RST nodes.""" 111 + 112 + fullname = self.handle_func_like_macro(sig, signode) 113 + if not fullname: 114 + fullname = super(CObject, self).handle_signature(sig, signode) 115 + 116 + if "name" in self.options: 117 + if self.objtype == 'function': 118 + fullname = self.options["name"] 119 + else: 120 + # FIXME: handle :name: value of other declaration types? 121 + pass 122 + return fullname 123 + 124 + def add_target_and_index(self, name, sig, signode): 125 + # for C API items we add a prefix since names are usually not qualified 126 + # by a module name and so easily clash with e.g. section titles 127 + targetname = 'c.' + name 128 + if targetname not in self.state.document.ids: 129 + signode['names'].append(targetname) 130 + signode['ids'].append(targetname) 131 + signode['first'] = (not self.names) 132 + self.state.document.note_explicit_target(signode) 133 + inv = self.env.domaindata['c']['objects'] 134 + if (name in inv and self.env.config.nitpicky): 135 + if self.objtype == 'function': 136 + if ('c:func', name) not in self.env.config.nitpick_ignore: 137 + self.state_machine.reporter.warning( 138 + 'duplicate C object description of %s, ' % name + 139 + 'other instance in ' + self.env.doc2path(inv[name][0]), 140 + line=self.lineno) 141 + inv[name] = (self.env.docname, self.objtype) 142 + 143 + indextext = self.get_index_text(name) 144 + if indextext: 145 + if major == 1 and minor < 4: 146 + # indexnode's tuple changed in 1.4 147 + # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c 148 + self.indexnode['entries'].append( 149 + ('single', indextext, targetname, '')) 150 + else: 151 + self.indexnode['entries'].append( 152 + ('single', indextext, targetname, '', None)) 153 + 154 + class CDomain(Base_CDomain): 155 + 156 + """C language domain.""" 157 + name = 'c' 158 + label = 'C' 159 + directives = { 160 + 'function': CObject, 161 + 'member': CObject, 162 + 'macro': CObject, 163 + 'type': CObject, 164 + 'var': CObject, 165 + }
+8
Documentation/sphinx/kernel-doc.py
··· 39 39 from sphinx.util.compat import Directive 40 40 from sphinx.ext.autodoc import AutodocReporter 41 41 42 + __version__ = '1.0' 43 + 42 44 class KernelDocDirective(Directive): 43 45 """Extract kernel-doc comments from the specified file""" 44 46 required_argument = 1 ··· 141 139 app.add_config_value('kerneldoc_verbosity', 1, 'env') 142 140 143 141 app.add_directive('kernel-doc', KernelDocDirective) 142 + 143 + return dict( 144 + version = __version__, 145 + parallel_read_safe = True, 146 + parallel_write_safe = True 147 + )
+7
Documentation/sphinx/kernel_include.py
··· 39 39 from docutils.parsers.rst.directives.body import CodeBlock, NumberLines 40 40 from docutils.parsers.rst.directives.misc import Include 41 41 42 + __version__ = '1.0' 43 + 42 44 # ============================================================================== 43 45 def setup(app): 44 46 # ============================================================================== 45 47 46 48 app.add_directive("kernel-include", KernelInclude) 49 + return dict( 50 + version = __version__, 51 + parallel_read_safe = True, 52 + parallel_write_safe = True 53 + ) 47 54 48 55 # ============================================================================== 49 56 class KernelInclude(Include):
+32
Documentation/sphinx/load_config.py
··· 1 + # -*- coding: utf-8; mode: python -*- 2 + # pylint: disable=R0903, C0330, R0914, R0912, E0401 3 + 4 + import os 5 + import sys 6 + from sphinx.util.pycompat import execfile_ 7 + 8 + # ------------------------------------------------------------------------------ 9 + def loadConfig(namespace): 10 + # ------------------------------------------------------------------------------ 11 + 12 + u"""Load an additional configuration file into *namespace*. 13 + 14 + The name of the configuration file is taken from the environment 15 + ``SPHINX_CONF``. The external configuration file extends (or overwrites) the 16 + configuration values from the origin ``conf.py``. With this you are able to 17 + maintain *build themes*. """ 18 + 19 + config_file = os.environ.get("SPHINX_CONF", None) 20 + if (config_file is not None 21 + and os.path.normpath(namespace["__file__"]) != os.path.normpath(config_file) ): 22 + config_file = os.path.abspath(config_file) 23 + 24 + if os.path.isfile(config_file): 25 + sys.stdout.write("load additional sphinx-config: %s\n" % config_file) 26 + config = namespace.copy() 27 + config['__file__'] = config_file 28 + execfile_(config_file, config) 29 + del config['__file__'] 30 + namespace.update(config) 31 + else: 32 + sys.stderr.write("WARNING: additional sphinx-config not found: %s\n" % config_file)
+1 -1
Documentation/sphinx/parse-headers.pl
··· 220 220 # 221 221 # Add escape codes for special characters 222 222 # 223 - $data =~ s,([\_\`\*\<\>\&\\\\:\/\|]),\\$1,g; 223 + $data =~ s,([\_\`\*\<\>\&\\\\:\/\|\%\$\#\{\}\~\^]),\\$1,g; 224 224 225 225 $data =~ s,DEPRECATED,**DEPRECATED**,g; 226 226
+6
Documentation/sphinx/rstFlatTable.py
··· 73 73 roles.register_local_role('cspan', c_span) 74 74 roles.register_local_role('rspan', r_span) 75 75 76 + return dict( 77 + version = __version__, 78 + parallel_read_safe = True, 79 + parallel_write_safe = True 80 + ) 81 + 76 82 # ============================================================================== 77 83 def c_span(name, rawtext, text, lineno, inliner, options=None, content=None): 78 84 # ==============================================================================
+26 -11
Documentation/stable_api_nonsense.txt
··· 1 + .. _stable_api_nonsense: 2 + 1 3 The Linux Kernel Driver Interface 4 + ================================== 5 + 2 6 (all of your questions answered and then some) 3 7 4 8 Greg Kroah-Hartman <greg@kroah.com> 5 9 6 - This is being written to try to explain why Linux does not have a binary 7 - kernel interface, nor does it have a stable kernel interface. Please 8 - realize that this article describes the _in kernel_ interfaces, not the 9 - kernel to userspace interfaces. The kernel to userspace interface is 10 - the one that application programs use, the syscall interface. That 11 - interface is _very_ stable over time, and will not break. I have old 12 - programs that were built on a pre 0.9something kernel that still work 13 - just fine on the latest 2.6 kernel release. That interface is the one 14 - that users and application programmers can count on being stable. 10 + This is being written to try to explain why Linux **does not have a binary 11 + kernel interface, nor does it have a stable kernel interface**. 12 + 13 + .. note:: 14 + 15 + Please realize that this article describes the **in kernel** interfaces, not 16 + the kernel to userspace interfaces. 17 + 18 + The kernel to userspace interface is the one that application programs use, 19 + the syscall interface. That interface is **very** stable over time, and 20 + will not break. I have old programs that were built on a pre 0.9something 21 + kernel that still work just fine on the latest 2.6 kernel release. 22 + That interface is the one that users and application programmers can count 23 + on being stable. 15 24 16 25 17 26 Executive Summary ··· 42 33 the world, they neither see this interface, nor do they care about it at 43 34 all. 44 35 45 - First off, I'm not going to address _any_ legal issues about closed 36 + First off, I'm not going to address **any** legal issues about closed 46 37 source, hidden source, binary blobs, source wrappers, or any other term 47 38 that describes kernel drivers that do not have their source code 48 39 released under the GPL. Please consult a lawyer if you have any legal ··· 60 51 Assuming that we had a stable kernel source interface for the kernel, a 61 52 binary interface would naturally happen too, right? Wrong. Please 62 53 consider the following facts about the Linux kernel: 54 + 63 55 - Depending on the version of the C compiler you use, different kernel 64 56 data structures will contain different alignment of structures, and 65 57 possibly include different functions in different ways (putting 66 58 functions inline or not.) The individual function organization 67 59 isn't that important, but the different data structure padding is 68 60 very important. 61 + 69 62 - Depending on what kernel build options you select, a wide range of 70 63 different things can be assumed by the kernel: 64 + 71 65 - different structures can contain different fields 72 66 - Some functions may not be implemented at all, (i.e. some locks 73 67 compile away to nothing for non-SMP builds.) 74 68 - Memory within the kernel can be aligned in different ways, 75 69 depending on the build options. 70 + 76 71 - Linux runs on a wide range of different processor architectures. 77 72 There is no way that binary drivers from one architecture will run 78 73 on another architecture properly. ··· 118 105 undergone at least three different reworks over the lifetime of this 119 106 subsystem. These reworks were done to address a number of different 120 107 issues: 108 + 121 109 - A change from a synchronous model of data streams to an asynchronous 122 110 one. This reduced the complexity of a number of drivers and 123 111 increased the throughput of all USB drivers such that we are now ··· 180 166 181 167 The very good side effects of having your driver in the main kernel tree 182 168 are: 169 + 183 170 - The quality of the driver will rise as the maintenance costs (to the 184 171 original developer) will decrease. 185 172 - Other developers will add features to your driver. ··· 190 175 changes require it. 191 176 - The driver automatically gets shipped in all Linux distributions 192 177 without having to ask the distros to add it. 193 - 178 + 194 179 As Linux supports a larger number of different devices "out of the box" 195 180 than any other operating system, and it supports these devices on more 196 181 different processor architectures than any other operating system, this
+75 -35
Documentation/stable_kernel_rules.txt
··· 1 - Everything you ever wanted to know about Linux -stable releases. 1 + .. _stable_kernel_rules: 2 + 3 + Everything you ever wanted to know about Linux -stable releases 4 + =============================================================== 2 5 3 6 Rules on what kind of patches are accepted, and which ones are not, into the 4 7 "-stable" tree: ··· 26 23 race can be exploited is also provided. 27 24 - It cannot contain any "trivial" fixes in it (spelling changes, 28 25 whitespace cleanups, etc). 29 - - It must follow the Documentation/SubmittingPatches rules. 26 + - It must follow the 27 + :ref:`Documentation/SubmittingPatches <submittingpatches>` 28 + rules. 30 29 - It or an equivalent fix must already exist in Linus' tree (upstream). 31 30 32 31 33 - Procedure for submitting patches to the -stable tree: 32 + Procedure for submitting patches to the -stable tree 33 + ---------------------------------------------------- 34 34 35 35 - If the patch covers files in net/ or drivers/net please follow netdev stable 36 36 submission guidelines as described in 37 37 Documentation/networking/netdev-FAQ.txt 38 38 - Security patches should not be handled (solely) by the -stable review 39 - process but should follow the procedures in Documentation/SecurityBugs. 39 + process but should follow the procedures in 40 + :ref:`Documentation/SecurityBugs <securitybugs>`. 40 41 41 - For all other submissions, choose one of the following procedures: 42 + For all other submissions, choose one of the following procedures 43 + ----------------------------------------------------------------- 42 44 43 - --- Option 1 --- 45 + .. _option_1: 44 46 45 - To have the patch automatically included in the stable tree, add the tag 47 + Option 1 48 + ******** 49 + 50 + To have the patch automatically included in the stable tree, add the tag 51 + 52 + .. code-block:: none 53 + 46 54 Cc: stable@vger.kernel.org 47 - in the sign-off area. Once the patch is merged it will be applied to 48 - the stable tree without anything else needing to be done by the author 49 - or subsystem maintainer. 50 55 51 - --- Option 2 --- 56 + in the sign-off area. Once the patch is merged it will be applied to 57 + the stable tree without anything else needing to be done by the author 58 + or subsystem maintainer. 52 59 53 - After the patch has been merged to Linus' tree, send an email to 54 - stable@vger.kernel.org containing the subject of the patch, the commit ID, 55 - why you think it should be applied, and what kernel version you wish it to 56 - be applied to. 60 + .. _option_2: 57 61 58 - --- Option 3 --- 62 + Option 2 63 + ******** 59 64 60 - Send the patch, after verifying that it follows the above rules, to 61 - stable@vger.kernel.org. You must note the upstream commit ID in the 62 - changelog of your submission, as well as the kernel version you wish 63 - it to be applied to. 65 + After the patch has been merged to Linus' tree, send an email to 66 + stable@vger.kernel.org containing the subject of the patch, the commit ID, 67 + why you think it should be applied, and what kernel version you wish it to 68 + be applied to. 64 69 65 - Option 1 is *strongly* preferred, is the easiest and most common. Options 2 and 66 - 3 are more useful if the patch isn't deemed worthy at the time it is applied to 67 - a public git tree (for instance, because it deserves more regression testing 68 - first). Option 3 is especially useful if the patch needs some special handling 69 - to apply to an older kernel (e.g., if API's have changed in the meantime). 70 + .. _option_3: 70 71 71 - Note that for Option 3, if the patch deviates from the original upstream patch 72 - (for example because it had to be backported) this must be very clearly 73 - documented and justified in the patch description. 72 + Option 3 73 + ******** 74 + 75 + Send the patch, after verifying that it follows the above rules, to 76 + stable@vger.kernel.org. You must note the upstream commit ID in the 77 + changelog of your submission, as well as the kernel version you wish 78 + it to be applied to. 79 + 80 + :ref:`option_1` is **strongly** preferred, is the easiest and most common. 81 + :ref:`option_2` and :ref:`option_3` are more useful if the patch isn't deemed 82 + worthy at the time it is applied to a public git tree (for instance, because 83 + it deserves more regression testing first). :ref:`option_3` is especially 84 + useful if the patch needs some special handling to apply to an older kernel 85 + (e.g., if API's have changed in the meantime). 86 + 87 + Note that for :ref:`option_3`, if the patch deviates from the original 88 + upstream patch (for example because it had to be backported) this must be very 89 + clearly documented and justified in the patch description. 74 90 75 91 The upstream commit ID must be specified with a separate line above the commit 76 92 text, like this: 93 + 94 + .. code-block:: none 77 95 78 96 commit <sha1> upstream. 79 97 ··· 102 78 prerequisites which can be cherry-picked. This can be specified in the following 103 79 format in the sign-off area: 104 80 81 + .. code-block:: none 82 + 105 83 Cc: <stable@vger.kernel.org> # 3.3.x: a1f84a3: sched: Check for idle 106 84 Cc: <stable@vger.kernel.org> # 3.3.x: 1b9508f: sched: Rate-limit newidle 107 85 Cc: <stable@vger.kernel.org> # 3.3.x: fd21073: sched: Fix affinity logic 108 86 Cc: <stable@vger.kernel.org> # 3.3.x 109 - Signed-off-by: Ingo Molnar <mingo@elte.hu> 87 + Signed-off-by: Ingo Molnar <mingo@elte.hu> 110 88 111 - The tag sequence has the meaning of: 89 + The tag sequence has the meaning of: 90 + 91 + .. code-block:: none 92 + 112 93 git cherry-pick a1f84a3 113 94 git cherry-pick 1b9508f 114 95 git cherry-pick fd21073 ··· 122 93 Also, some patches may have kernel version prerequisites. This can be 123 94 specified in the following format in the sign-off area: 124 95 96 + .. code-block:: none 97 + 125 98 Cc: <stable@vger.kernel.org> # 3.3.x- 126 99 127 - The tag has the meaning of: 100 + The tag has the meaning of: 101 + 102 + .. code-block:: none 103 + 128 104 git cherry-pick <this commit> 129 105 130 - For each "-stable" tree starting with the specified version. 106 + For each "-stable" tree starting with the specified version. 131 107 132 108 Following the submission: 133 109 ··· 143 109 other developers and by the relevant subsystem maintainer. 144 110 145 111 146 - Review cycle: 112 + Review cycle 113 + ------------ 147 114 148 115 - When the -stable maintainers decide for a review cycle, the patches will be 149 116 sent to the review committee, and the maintainer of the affected area of ··· 160 125 security kernel team, and not go through the normal review cycle. 161 126 Contact the kernel security team for more details on this procedure. 162 127 163 - Trees: 128 + Trees 129 + ----- 164 130 165 131 - The queues of patches, for both completed versions and in progress 166 132 versions can be found at: 133 + 167 134 http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git 135 + 168 136 - The finalized and tagged releases of all stable kernels can be found 169 137 in separate branches per version at: 138 + 170 139 http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git 171 140 172 141 173 - Review committee: 142 + Review committee 143 + ---------------- 174 144 175 145 - This is made up of a number of kernel developers who have volunteered for 176 146 this task, and a few that haven't.
+23 -19
Documentation/ubsan.txt Documentation/dev-tools/ubsan.rst
··· 1 - Undefined Behavior Sanitizer - UBSAN 2 - 3 - Overview 4 - -------- 1 + The Undefined Behavior Sanitizer - UBSAN 2 + ======================================== 5 3 6 4 UBSAN is a runtime undefined behaviour checker. 7 5 ··· 8 10 that may cause UB. If check fails (i.e. UB detected) __ubsan_handle_* 9 11 function called to print error message. 10 12 11 - GCC has that feature since 4.9.x [1] (see -fsanitize=undefined option and 12 - its suboptions). GCC 5.x has more checkers implemented [2]. 13 + GCC has that feature since 4.9.x [1_] (see ``-fsanitize=undefined`` option and 14 + its suboptions). GCC 5.x has more checkers implemented [2_]. 13 15 14 16 Report example 15 - --------------- 17 + -------------- 18 + 19 + :: 16 20 17 21 ================================================================================ 18 22 UBSAN: Undefined behaviour in ../include/linux/bitops.h:110:33 ··· 47 47 Usage 48 48 ----- 49 49 50 - To enable UBSAN configure kernel with: 50 + To enable UBSAN configure kernel with:: 51 51 52 52 CONFIG_UBSAN=y 53 53 54 - and to check the entire kernel: 54 + and to check the entire kernel:: 55 55 56 56 CONFIG_UBSAN_SANITIZE_ALL=y 57 57 58 58 To enable instrumentation for specific files or directories, add a line 59 59 similar to the following to the respective kernel Makefile: 60 60 61 - For a single file (e.g. main.o): 62 - UBSAN_SANITIZE_main.o := y 61 + - For a single file (e.g. main.o):: 63 62 64 - For all files in one directory: 65 - UBSAN_SANITIZE := y 63 + UBSAN_SANITIZE_main.o := y 64 + 65 + - For all files in one directory:: 66 + 67 + UBSAN_SANITIZE := y 66 68 67 69 To exclude files from being instrumented even if 68 - CONFIG_UBSAN_SANITIZE_ALL=y, use: 70 + ``CONFIG_UBSAN_SANITIZE_ALL=y``, use:: 69 71 70 - UBSAN_SANITIZE_main.o := n 71 - and: 72 - UBSAN_SANITIZE := n 72 + UBSAN_SANITIZE_main.o := n 73 + 74 + and:: 75 + 76 + UBSAN_SANITIZE := n 73 77 74 78 Detection of unaligned accesses controlled through the separate option - 75 79 CONFIG_UBSAN_ALIGNMENT. It's off by default on architectures that support ··· 84 80 References 85 81 ---------- 86 82 87 - [1] - https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html 88 - [2] - https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html 83 + .. _1: https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html 84 + .. _2: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
+3 -3
Documentation/x86/x86_64/mm.txt
··· 12 12 ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole 13 13 ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB) 14 14 ... unused hole ... 15 - ffffec0000000000 - fffffc0000000000 (=44 bits) kasan shadow memory (16TB) 15 + ffffec0000000000 - fffffbffffffffff (=44 bits) kasan shadow memory (16TB) 16 16 ... unused hole ... 17 17 ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks 18 18 ... unused hole ... 19 - ffffffef00000000 - ffffffff00000000 (=64 GB) EFI region mapping space 19 + ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space 20 20 ... unused hole ... 21 - ffffffff80000000 - ffffffffa0000000 (=512 MB) kernel text mapping, from phys 0 21 + ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0 22 22 ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space 23 23 ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls 24 24 ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
+6 -6
MAINTAINERS
··· 3139 3139 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git misc 3140 3140 W: http://coccinelle.lip6.fr/ 3141 3141 S: Supported 3142 - F: Documentation/coccinelle.txt 3142 + F: Documentation/dev-tools/coccinelle.rst 3143 3143 F: scripts/coccinelle/ 3144 3144 F: scripts/coccicheck 3145 3145 ··· 5148 5148 M: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> 5149 5149 S: Maintained 5150 5150 F: kernel/gcov/ 5151 - F: Documentation/gcov.txt 5151 + F: Documentation/dev-tools/gcov.rst 5152 5152 5153 5153 GDT SCSI DISK ARRAY CONTROLLER DRIVER 5154 5154 M: Achim Leubner <achim_leubner@adaptec.com> ··· 5636 5636 T: git git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi.git 5637 5637 S: Maintained 5638 5638 F: Documentation/ABI/testing/sysfs-bus-hsi 5639 - F: Documentation/hsi.txt 5639 + F: Documentation/device-drivers/serial-interfaces.rst 5640 5640 F: drivers/hsi/ 5641 5641 F: include/linux/hsi/ 5642 5642 F: include/uapi/linux/hsi/ ··· 6617 6617 S: Maintained 6618 6618 F: arch/*/include/asm/kasan.h 6619 6619 F: arch/*/mm/kasan_init* 6620 - F: Documentation/kasan.txt 6620 + F: Documentation/dev-tools/kasan.rst 6621 6621 F: include/linux/kasan*.h 6622 6622 F: lib/test_kasan.c 6623 6623 F: mm/kasan/ ··· 6833 6833 M: Vegard Nossum <vegardno@ifi.uio.no> 6834 6834 M: Pekka Enberg <penberg@kernel.org> 6835 6835 S: Maintained 6836 - F: Documentation/kmemcheck.txt 6836 + F: Documentation/dev-tools/kmemcheck.rst 6837 6837 F: arch/x86/include/asm/kmemcheck.h 6838 6838 F: arch/x86/mm/kmemcheck/ 6839 6839 F: include/linux/kmemcheck.h ··· 6842 6842 KMEMLEAK 6843 6843 M: Catalin Marinas <catalin.marinas@arm.com> 6844 6844 S: Maintained 6845 - F: Documentation/kmemleak.txt 6845 + F: Documentation/dev-tools/kmemleak.rst 6846 6846 F: include/linux/kmemleak.h 6847 6847 F: mm/kmemleak.c 6848 6848 F: mm/kmemleak-test.c
+1 -1
Makefile
··· 1425 1425 1426 1426 # Documentation targets 1427 1427 # --------------------------------------------------------------------------- 1428 - DOC_TARGETS := xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs epubdocs cleandocs 1428 + DOC_TARGETS := xmldocs sgmldocs psdocs latexdocs pdfdocs htmldocs mandocs installmandocs epubdocs cleandocs 1429 1429 PHONY += $(DOC_TARGETS) 1430 1430 $(DOC_TARGETS): scripts_basic FORCE 1431 1431 $(Q)$(MAKE) $(build)=scripts build_docproc build_check-lc_ctype
+2 -6
README
··· 229 229 under some circumstances lead to problems: probing for a 230 230 nonexistent controller card may confuse your other controllers 231 231 232 - - Compiling the kernel with "Processor type" set higher than 386 233 - will result in a kernel that does NOT work on a 386. The 234 - kernel will detect this on bootup, and give up. 235 - 236 232 - A kernel with math-emulation compiled in will still use the 237 233 coprocessor if one is present: the math emulation will just 238 234 never get used in that case. The kernel will be slightly larger, ··· 285 289 LOCALVERSION can be set in the "General Setup" menu. 286 290 287 291 - In order to boot your new kernel, you'll need to copy the kernel 288 - image (e.g. .../linux/arch/i386/boot/bzImage after compilation) 292 + image (e.g. .../linux/arch/x86/boot/bzImage after compilation) 289 293 to the place where your regular bootable kernel is found. 290 294 291 295 - Booting a kernel directly from a floppy without the assistance of a ··· 387 391 388 392 - Alternatively, you can use gdb on a running kernel. (read-only; i.e. you 389 393 cannot change values or set break points.) To do this, first compile the 390 - kernel with -g; edit arch/i386/Makefile appropriately, then do a "make 394 + kernel with -g; edit arch/x86/Makefile appropriately, then do a "make 391 395 clean". You'll also need to enable CONFIG_PROC_FS (via "make config"). 392 396 393 397 After you've rebooted with the new kernel, do "gdb vmlinux /proc/kcore".
+32 -16
scripts/kernel-doc
··· 212 212 my $type_constant = '\%([-_\w]+)'; 213 213 my $type_func = '(\w+)\(\)'; 214 214 my $type_param = '\@(\w+)'; 215 + my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params 215 216 my $type_struct = '\&((struct\s*)*[_\w]+)'; 216 217 my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)'; 217 218 my $type_env = '(\$\w+)'; ··· 293 292 # Note: need to escape () to avoid func matching later 294 293 [$type_member_func, "\\:c\\:type\\:`\$1\$2\\\\(\\\\) <\$1>`"], 295 294 [$type_member, "\\:c\\:type\\:`\$1\$2 <\$1>`"], 295 + [$type_fp_param, "**\$1\\\\(\\\\)**"], 296 296 [$type_func, "\\:c\\:func\\:`\$1()`"], 297 297 [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 298 298 [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], ··· 414 412 my $doc_decl = $doc_com . '(\w+)'; 415 413 # @params and a strictly limited set of supported section names 416 414 my $doc_sect = $doc_com . 417 - '\s*(\@\w+|description|context|returns?|notes?|examples?)\s*:(.*)'; 415 + '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)'; 418 416 my $doc_content = $doc_com_body . '(.*)'; 419 417 my $doc_block = $doc_com . 'DOC:\s*(.*)?'; 420 418 my $doc_inline_start = '^\s*/\*\*\s*$'; ··· 1833 1831 my %args = %{$_[0]}; 1834 1832 my ($parameter, $section); 1835 1833 my $oldprefix = $lineprefix; 1836 - my $start; 1834 + my $start = ""; 1837 1835 1838 - print ".. c:function:: "; 1839 - if ($args{'functiontype'} ne "") { 1840 - $start = $args{'functiontype'} . " " . $args{'function'} . " ("; 1836 + if ($args{'typedef'}) { 1837 + print ".. c:type:: ". $args{'function'} . "\n\n"; 1838 + print_lineno($declaration_start_line); 1839 + print " **Typedef**: "; 1840 + $lineprefix = ""; 1841 + output_highlight_rst($args{'purpose'}); 1842 + $start = "\n\n**Syntax**\n\n ``"; 1841 1843 } else { 1842 - $start = $args{'function'} . " ("; 1844 + print ".. c:function:: "; 1845 + } 1846 + if ($args{'functiontype'} ne "") { 1847 + $start .= $args{'functiontype'} . " " . $args{'function'} . " ("; 1848 + } else { 1849 + $start .= $args{'function'} . " ("; 1843 1850 } 1844 1851 print $start; 1845 1852 ··· 1860 1849 $count++; 1861 1850 $type = $args{'parametertypes'}{$parameter}; 1862 1851 1863 - # RST doesn't like address_space tags at function prototypes 1864 - $type =~ s/__(user|kernel|iomem|percpu|pmem|rcu)\s*//; 1865 - 1866 1852 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { 1867 1853 # pointer-to-function 1868 1854 print $1 . $parameter . ") (" . $2; ··· 1867 1859 print $type . " " . $parameter; 1868 1860 } 1869 1861 } 1870 - print ")\n\n"; 1871 - print_lineno($declaration_start_line); 1872 - $lineprefix = " "; 1873 - output_highlight_rst($args{'purpose'}); 1874 - print "\n"; 1862 + if ($args{'typedef'}) { 1863 + print ");``\n\n"; 1864 + } else { 1865 + print ")\n\n"; 1866 + print_lineno($declaration_start_line); 1867 + $lineprefix = " "; 1868 + output_highlight_rst($args{'purpose'}); 1869 + print "\n"; 1870 + } 1875 1871 1876 1872 print "**Parameters**\n\n"; 1877 1873 $lineprefix = " "; ··· 2015 2003 ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; 2016 2004 $type = $args{'parametertypes'}{$parameter}; 2017 2005 print_lineno($parameterdesc_start_lines{$parameter_name}); 2018 - print "``$type $parameter``\n"; 2006 + print "``" . $parameter . "``\n"; 2019 2007 output_highlight_rst($args{'parameterdescs'}{$parameter_name}); 2020 2008 print "\n"; 2021 2009 } ··· 2205 2193 $x =~ s@/\*.*?\*/@@gos; # strip comments. 2206 2194 2207 2195 # Parse function prototypes 2208 - if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/) { 2196 + if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ || 2197 + $x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) { 2198 + 2209 2199 # Function typedefs 2210 2200 $return_type = $1; 2211 2201 $declaration_name = $2; ··· 2218 2204 output_declaration($declaration_name, 2219 2205 'function', 2220 2206 {'function' => $declaration_name, 2207 + 'typedef' => 1, 2221 2208 'module' => $modulename, 2222 2209 'functiontype' => $return_type, 2223 2210 'parameterlist' => \@parameterlist, ··· 2353 2338 2354 2339 if ($type eq "" && $param =~ /\.\.\.$/) 2355 2340 { 2341 + $param = "..."; 2356 2342 if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") { 2357 2343 $parameterdescs{$param} = "variable arguments"; 2358 2344 }