History

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

Pull documentation updates from Jonathan Corbet: "It's been a relatively busy cycle in docsland, though more than usually well contained to Documentation/ itself. Highlights include: - The Chinese translators have been busy and show no signs of stopping anytime soon. Italian has also caught up. - Aditya Srivastava has been working on improvements to the kernel-doc script. - Thorsten continues his work on reporting-issues.rst and related documentation around regression reporting. - Lots of documentation updates, typo fixes, etc. as usual" * tag 'docs-5.13' of git://git.lwn.net/linux: (139 commits) docs/zh_CN: add openrisc translation to zh_CN index docs/zh_CN: add openrisc index.rst translation docs/zh_CN: add openrisc todo.rst translation docs/zh_CN: add openrisc openrisc_port.rst translation docs/zh_CN: add core api translation to zh_CN index docs/zh_CN: add core-api index.rst translation docs/zh_CN: add core-api irq index.rst translation docs/zh_CN: add core-api irq irqflags-tracing.rst translation docs/zh_CN: add core-api irq irq-domain.rst translation docs/zh_CN: add core-api irq irq-affinity.rst translation docs/zh_CN: add core-api irq concepts.rst translation docs: sphinx-pre-install: don't barf on beta Sphinx releases scripts: kernel-doc: improve parsing for kernel-doc comments syntax docs/zh_CN: two minor fixes in zh_CN/doc-guide/ Documentation: dev-tools: Add Testing Overview docs/zh_CN: add translations in zh_CN/dev-tools/gcov docs: reporting-issues: make people CC the regressions list MAINTAINERS: add regressions mailing list doc:it_IT: align Italian documentation docs/zh_CN: sync reporting-issues.rst ...

Linus Torvalds committed 5 years ago

Commit 2f9ef052 parents 0c85556 441ca97133 files · +9868 −2059Browse files

Unified · Split

133 files
  1. .mailmap +3 −2
  2. CREDITS +1 −1
  3. Documentation/admin-guide/LSM/LoadPin.rst +3 −3
  4. Documentation/admin-guide/cgroup-v1/memory.rst +5 −2
  5. Documentation/admin-guide/dynamic-debug-howto.rst +1 −1
  6. Documentation/admin-guide/index.rst +0 −1
  7. Documentation/admin-guide/kernel-parameters.rst +1 −0
  8. Documentation/admin-guide/kernel-parameters.txt +2 −1
  9. Documentation/admin-guide/kernel-per-CPU-kthreads.rst +0 −20
  10. Documentation/admin-guide/mm/numaperf.rst +1 −1
  11. Documentation/admin-guide/reporting-bugs.rst +0 −187
  12. Documentation/admin-guide/reporting-issues.rst +620 −497
  13. Documentation/admin-guide/sysrq.rst +2 −2
  14. Documentation/arch.rst +26 −0
  15. Documentation/arm/marvell.rst +80 −79
  16. Documentation/arm/uefi.rst +7 −0
  17. Documentation/conf.py +19 −12
  18. Documentation/core-api/rbtree.rst +1 −1
  19. Documentation/dev-tools/checkpatch.rst +755 −0
  20. Documentation/dev-tools/gcov.rst +6 −2
  21. Documentation/dev-tools/index.rst +5 −0
  22. Documentation/dev-tools/testing-overview.rst +117 −0
  23. Documentation/devicetree/bindings/submitting-patches.rst +2 −2
  24. Documentation/driver-api/driver-model/class.rst +0 −149
  25. Documentation/driver-api/driver-model/device.rst +17 −6
  26. Documentation/driver-api/driver-model/index.rst +0 −1
  27. Documentation/driver-api/gpio/intro.rst +1 −1
  28. Documentation/fb/fbcon.rst +2 −2
  29. Documentation/features/arch-support.txt +1 −0
  30. Documentation/features/vm/TLB/arch-support.txt +1 −1
  31. Documentation/filesystems/api-summary.rst +9 −0
  32. Documentation/filesystems/proc.rst +4 −0
  33. Documentation/filesystems/vfat.rst +1 −1
  34. Documentation/hid/intel-ish-hid.rst +1 −1
  35. Documentation/index.rst +2 −18
  36. Documentation/input/event-codes.rst +5 −5
  37. Documentation/input/ff.rst +3 −3
  38. Documentation/input/gameport-programming.rst +23 −12
  39. Documentation/input/input-programming.rst +10 −10
  40. Documentation/input/input.rst +4 −4
  41. Documentation/input/multi-touch-protocol.rst +4 −4
  42. Documentation/input/notifier.rst +2 −1
  43. Documentation/input/uinput.rst +1 −1
  44. Documentation/leds/leds-lm3556.rst +14 −14
  45. Documentation/livepatch/shadow-vars.rst +2 −2
  46. Documentation/powerpc/booting.rst +1 −1
  47. Documentation/powerpc/dawr-power9.rst +1 −1
  48. Documentation/powerpc/eeh-pci-error-recovery.rst +1 −1
  49. Documentation/powerpc/elfnote.rst +1 −1
  50. Documentation/powerpc/firmware-assisted-dump.rst +2 −2
  51. Documentation/powerpc/kaslr-booke32.rst +1 −1
  52. Documentation/powerpc/mpc52xx.rst +1 −1
  53. Documentation/powerpc/papr_hcalls.rst +2 −2
  54. Documentation/powerpc/transactional_memory.rst +2 −2
  55. Documentation/process/submitting-patches.rst +67 −34
  56. Documentation/scsi/ChangeLog.megaraid +1 −1
  57. Documentation/sphinx/rstFlatTable.py +2 −2
  58. Documentation/spi/butterfly.rst +1 −1
  59. Documentation/translations/it_IT/doc-guide/sphinx.rst +28 −19
  60. Documentation/translations/it_IT/kernel-hacking/hacking.rst +1 −1
  61. Documentation/translations/it_IT/kernel-hacking/locking.rst +4 −8
  62. Documentation/translations/it_IT/process/4.Coding.rst +4 −5
  63. Documentation/translations/it_IT/process/adding-syscalls.rst +1 −1
  64. Documentation/translations/it_IT/process/coding-style.rst +19 −3
  65. Documentation/translations/it_IT/process/howto.rst +12 −13
  66. Documentation/translations/it_IT/process/magic-number.rst +0 −2
  67. Documentation/translations/it_IT/process/submit-checklist.rst +11 −10
  68. Documentation/translations/it_IT/process/submitting-patches.rst +80 −18
  69. Documentation/translations/ja_JP/SubmitChecklist +3 −5
  70. Documentation/translations/ko_KR/howto.rst +9 −9
  71. Documentation/translations/zh_CN/admin-guide/README.rst +347 −0
  72. Documentation/translations/zh_CN/admin-guide/bug-bisect.rst +81 −0
  73. Documentation/translations/zh_CN/admin-guide/bug-hunting.rst +340 −0
  74. Documentation/translations/zh_CN/admin-guide/index.rst +14 −5
  75. Documentation/translations/zh_CN/admin-guide/init.rst +54 −0
  76. Documentation/translations/zh_CN/admin-guide/reporting-issues.rst +1335 −0
  77. Documentation/translations/zh_CN/admin-guide/security-bugs.rst +74 −0
  78. Documentation/translations/zh_CN/admin-guide/tainted-kernels.rst +157 −0
  79. Documentation/translations/zh_CN/admin-guide/unicode.rst +170 −0
  80. Documentation/translations/zh_CN/core-api/index.rst +126 −0
  81. Documentation/translations/zh_CN/core-api/irq/concepts.rst +24 −0
  82. Documentation/translations/zh_CN/core-api/irq/index.rst +19 −0
  83. Documentation/translations/zh_CN/core-api/irq/irq-affinity.rst +76 −0
  84. Documentation/translations/zh_CN/core-api/irq/irq-domain.rst +227 −0
  85. Documentation/translations/zh_CN/core-api/irq/irqflags-tracing.rst +45 −0
  86. Documentation/translations/zh_CN/cpu-freq/core.rst +105 −0
  87. Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst +259 −0
  88. Documentation/translations/zh_CN/cpu-freq/cpufreq-stats.rst +130 −0
  89. Documentation/translations/zh_CN/cpu-freq/index.rst +45 −0
  90. Documentation/translations/zh_CN/dev-tools/gcov.rst +264 −0
  91. Documentation/translations/zh_CN/dev-tools/index.rst +35 −0
  92. Documentation/translations/zh_CN/disclaimer-zh_CN.rst +1 −1
  93. Documentation/translations/zh_CN/doc-guide/contributing.rst +238 −0
  94. Documentation/translations/zh_CN/doc-guide/index.rst +27 −0
  95. Documentation/translations/zh_CN/doc-guide/kernel-doc.rst +499 −0
  96. Documentation/translations/zh_CN/doc-guide/maintainer-profile.rst +43 −0
  97. Documentation/translations/zh_CN/doc-guide/parse-headers.rst +187 −0
  98. Documentation/translations/zh_CN/doc-guide/sphinx.rst +415 −0
  99. Documentation/translations/zh_CN/index.rst +10 −0
  100. Documentation/translations/zh_CN/kernel-hacking/hacking.rst +708 −0
  101. Documentation/translations/zh_CN/kernel-hacking/index.rst +22 −0
  102. Documentation/translations/zh_CN/openrisc/index.rst +30 −0
  103. Documentation/translations/zh_CN/openrisc/openrisc_port.rst +124 −0
  104. Documentation/translations/zh_CN/openrisc/todo.rst +20 −0
  105. Documentation/translations/zh_CN/process/1.Intro.rst +102 −93
  106. Documentation/translations/zh_CN/process/2.Process.rst +175 −170
  107. Documentation/translations/zh_CN/process/3.Early-stage.rst +73 −66
  108. Documentation/translations/zh_CN/process/4.Coding.rst +141 −138
  109. Documentation/translations/zh_CN/process/5.Posting.rst +125 −118
  110. Documentation/translations/zh_CN/process/6.Followthrough.rst +86 −79
  111. Documentation/translations/zh_CN/process/7.AdvancedTopics.rst +75 −66
  112. Documentation/translations/zh_CN/process/8.Conclusion.rst +33 −27
  113. Documentation/translations/zh_CN/process/index.rst +5 −5
  114. Documentation/translations/zh_CN/process/submit-checklist.rst +6 −8
  115. Documentation/translations/zh_CN/riscv/boot-image-header.rst +67 −0
  116. Documentation/translations/zh_CN/riscv/index.rst +28 −0
  117. Documentation/translations/zh_CN/riscv/patch-acceptance.rst +31 −0
  118. Documentation/translations/zh_CN/riscv/pmu.rst +233 −0
  119. Documentation/translations/zh_CN/sound/hd-audio/controls.rst +102 −0
  120. Documentation/translations/zh_CN/sound/hd-audio/index.rst +14 −0
  121. Documentation/translations/zh_CN/sound/index.rst +22 −0
  122. Documentation/userspace-api/ioctl/ioctl-number.rst +1 −0
  123. Documentation/virt/kvm/api.rst +1 −1
  124. Documentation/watchdog/pcwd-watchdog.rst +1 −1
  125. MAINTAINERS +21 −3
  126. fs/eventpoll.c +26 −26
  127. fs/namespace.c +8 −6
  128. scripts/checkpatch.pl +113 −20
  129. scripts/get_abi.pl +53 −21
  130. scripts/kernel-doc +52 −8
  131. scripts/sphinx-pre-install +1 −1
  132. tools/debugging/kernel-chktaint +1 −1
  133. tools/scripts/Makefile.include +2 −1
.mailmap+3−2
@@ -25,8 +25,9 @@ Alexandre Belloni <alexandre.belloni@bootlin.com> <alexandre.belloni@free-electr · 24 unmodified lines
25Alexei Starovoitov <ast@kernel.org> <alexei.starovoitov@gmail.com>25Alexei Starovoitov <ast@kernel.org> <alexei.starovoitov@gmail.com>
26Alexei Starovoitov <ast@kernel.org> <ast@fb.com>26Alexei Starovoitov <ast@kernel.org> <ast@fb.com>
27Alexei Starovoitov <ast@kernel.org> <ast@plumgrid.com>27Alexei Starovoitov <ast@kernel.org> <ast@plumgrid.com>
28Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@intel.com>28Alex Shi <alexs@kernel.org> <alex.shi@intel.com>
29Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@linaro.org>29Alex Shi <alexs@kernel.org> <alex.shi@linaro.org>
30Alex Shi <alexs@kernel.org> <alex.shi@linux.alibaba.com>
30Al Viro <viro@ftp.linux.org.uk>31Al Viro <viro@ftp.linux.org.uk>
31Al Viro <viro@zenIV.linux.org.uk>32Al Viro <viro@zenIV.linux.org.uk>
32Andi Kleen <ak@linux.intel.com> <ak@suse.de>33Andi Kleen <ak@linux.intel.com> <ak@suse.de>
CREDITS+1−1
@@ -550,7 +550,7 @@ D: gadget layers, SPI subsystem, GPIO subsystem, and more than a few · 549 unmodified lines
550D: device drivers. His encouragement also helped many engineers get550D: device drivers. His encouragement also helped many engineers get
551D: started working on the Linux kernel. David passed away in early551D: started working on the Linux kernel. David passed away in early
552D: 2011, and will be greatly missed.552D: 2011, and will be greatly missed.
553W: https://lkml.org/lkml/2011/4/5/36553W: https://lore.kernel.org/lkml/20110405034819.GA7872@kroah.com
554 554
555N: Gary Brubaker555N: Gary Brubaker
556E: xavyer@ix.netcom.com556E: xavyer@ix.netcom.com
Documentation/admin-guide/LSM/LoadPin.rst+3−3
@@ -11,8 +11,8 @@ restrictions without needing to sign the files individually. · 10 unmodified lines
11 11
12The LSM is selectable at build-time with ``CONFIG_SECURITY_LOADPIN``, and12The LSM is selectable at build-time with ``CONFIG_SECURITY_LOADPIN``, and
13can be controlled at boot-time with the kernel command line option13can be controlled at boot-time with the kernel command line option
14"``loadpin.enabled``". By default, it is enabled, but can be disabled at14"``loadpin.enforce``". By default, it is enabled, but can be disabled at
15boot ("``loadpin.enabled=0``").15boot ("``loadpin.enforce=0``").
16 16
17LoadPin starts pinning when it sees the first file loaded. If the17LoadPin starts pinning when it sees the first file loaded. If the
18block device backing the filesystem is not read-only, a sysctl is18block device backing the filesystem is not read-only, a sysctl is
@@ -28,4 +28,4 @@ different mechanisms such as ``CONFIG_MODULE_SIG`` and · 9 unmodified lines
28``CONFIG_KEXEC_VERIFY_SIG`` to verify kernel module and kernel image while28``CONFIG_KEXEC_VERIFY_SIG`` to verify kernel module and kernel image while
29still use LoadPin to protect the integrity of other files kernel loads. The29still use LoadPin to protect the integrity of other files kernel loads. The
30full list of valid file types can be found in ``kernel_read_file_str``30full list of valid file types can be found in ``kernel_read_file_str``
31defined in ``include/linux/fs.h``.31defined in ``include/linux/kernel_read_file.h``.
Documentation/admin-guide/cgroup-v1/memory.rst+5−2
@@ -360,8 +360,8 @@ U != 0, K = unlimited: · 359 unmodified lines
360 360
361U != 0, K < U:361U != 0, K < U:
362 Kernel memory is a subset of the user memory. This setup is useful in362 Kernel memory is a subset of the user memory. This setup is useful in
363 deployments where the total amount of memory per-cgroup is overcommited.363 deployments where the total amount of memory per-cgroup is overcommitted.
364 Overcommiting kernel memory limits is definitely not recommended, since the364 Overcommitting kernel memory limits is definitely not recommended, since the
365 box can still run out of non-reclaimable memory.365 box can still run out of non-reclaimable memory.
366 In this case, the admin could set up K so that the sum of all groups is366 In this case, the admin could set up K so that the sum of all groups is
367 never greater than the total memory, and freely set U at the cost of his367 never greater than the total memory, and freely set U at the cost of his
@@ -851,6 +851,9 @@ At reading, current status of OOM is shown. · 483 unmodified lines
851 (if 1, oom-killer is disabled)851 (if 1, oom-killer is disabled)
852 - under_oom 0 or 1852 - under_oom 0 or 1
853 (if 1, the memory cgroup is under OOM, tasks may be stopped.)853 (if 1, the memory cgroup is under OOM, tasks may be stopped.)
854 - oom_kill integer counter
855 The number of processes belonging to this cgroup killed by any
856 kind of OOM killer.
854 857
85511. Memory Pressure85811. Memory Pressure
856===================859===================
Documentation/admin-guide/dynamic-debug-howto.rst+1−1
@@ -347,7 +347,7 @@ Examples · 346 unmodified lines
347 <debugfs>/dynamic_debug/control347 <debugfs>/dynamic_debug/control
348 348
349 // enable messages in files of which the paths include string "usb"349 // enable messages in files of which the paths include string "usb"
350 nullarbor:~ # echo -n '*usb* +p' > <debugfs>/dynamic_debug/control350 nullarbor:~ # echo -n 'file *usb* +p' > <debugfs>/dynamic_debug/control
351 351
352 // enable all messages352 // enable all messages
353 nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control353 nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
Documentation/admin-guide/index.rst+0−1
@@ -35,7 +35,6 @@ problems and bugs in particular. · 34 unmodified lines
35 :maxdepth: 135 :maxdepth: 1
36 36
37 reporting-issues37 reporting-issues
38 Reporting bugs (obsolete) <reporting-bugs>
39 security-bugs38 security-bugs
40 bug-hunting39 bug-hunting
41 bug-bisect40 bug-bisect
Documentation/admin-guide/kernel-parameters.rst+1−0
@@ -140,6 +140,7 @@ parameter is applicable:: · 139 unmodified lines
140 PPT Parallel port support is enabled.140 PPT Parallel port support is enabled.
141 PS2 Appropriate PS/2 support is enabled.141 PS2 Appropriate PS/2 support is enabled.
142 RAM RAM disk support is enabled.142 RAM RAM disk support is enabled.
143 RISCV RISCV architecture is enabled.
143 RDT Intel Resource Director Technology.144 RDT Intel Resource Director Technology.
144 S390 S390 architecture is enabled.145 S390 S390 architecture is enabled.
145 SCSI Appropriate SCSI support is enabled.146 SCSI Appropriate SCSI support is enabled.
Documentation/admin-guide/kernel-parameters.txt+2−1
@@ -3471,7 +3471,8 @@ · 3470 unmodified lines
3471 3471
3472 nr_uarts= [SERIAL] maximum number of UARTs to be registered.3472 nr_uarts= [SERIAL] maximum number of UARTs to be registered.
3473 3473
3474 numa_balancing= [KNL,X86] Enable or disable automatic NUMA balancing.3474 numa_balancing= [KNL,ARM64,PPC,RISCV,S390,X86] Enable or disable automatic
3475 NUMA balancing.
3475 Allowed values are enable and disable3476 Allowed values are enable and disable
3476 3477
3477 numa_zonelist_order= [KNL, BOOT] Select zonelist order for NUMA.3478 numa_zonelist_order= [KNL, BOOT] Select zonelist order for NUMA.
Documentation/admin-guide/kernel-per-CPU-kthreads.rst+0−20
@@ -332,23 +332,3 @@ To reduce its OS jitter, do at least one of the following: · 331 unmodified lines
332 kthreads from being created in the first place. However, please332 kthreads from being created in the first place. However, please
333 note that this will not eliminate OS jitter, but will instead333 note that this will not eliminate OS jitter, but will instead
334 shift it to RCU_SOFTIRQ.334 shift it to RCU_SOFTIRQ.
335
336Name:
337 watchdog/%u
338
339Purpose:
340 Detect software lockups on each CPU.
341
342To reduce its OS jitter, do at least one of the following:
343
3441. Build with CONFIG_LOCKUP_DETECTOR=n, which will prevent these
345 kthreads from being created in the first place.
3462. Boot with "nosoftlockup=0", which will also prevent these kthreads
347 from being created. Other related watchdog and softlockup boot
348 parameters may be found in Documentation/admin-guide/kernel-parameters.rst
349 and Documentation/watchdog/watchdog-parameters.rst.
3503. Echo a zero to /proc/sys/kernel/watchdog to disable the
351 watchdog timer.
3524. Echo a large number of /proc/sys/kernel/watchdog_thresh in
353 order to reduce the frequency of OS jitter due to the watchdog
354 timer down to a level that is acceptable for your workload.
Documentation/admin-guide/mm/numaperf.rst+1−1
@@ -151,7 +151,7 @@ Each cache level's directory provides its attributes. For example, the · 150 unmodified lines
151following shows a single cache level and the attributes available for151following shows a single cache level and the attributes available for
152software to query::152software to query::
153 153
154 # tree sys/devices/system/node/node0/memory_side_cache/154 # tree /sys/devices/system/node/node0/memory_side_cache/
155 /sys/devices/system/node/node0/memory_side_cache/155 /sys/devices/system/node/node0/memory_side_cache/
156 |-- index1156 |-- index1
157 | |-- indexing157 | |-- indexing
Documentation/admin-guide/reporting-bugs.rst+0−187
@@ -1,187 +0,0 @@
1.. _reportingbugs:
2
3.. note::
4
5 This document is obsolete, and will be replaced by
6 'Documentation/admin-guide/reporting-issues.rst' in the near future.
7
8Reporting bugs
9++++++++++++++
10
11Background
12==========
13
14The upstream Linux kernel maintainers only fix bugs for specific kernel
15versions. Those versions include the current "release candidate" (or -rc)
16kernel, any "stable" kernel versions, and any "long term" kernels.
17
18Please see https://www.kernel.org/ for a list of supported kernels. Any
19kernel marked with [EOL] is "end of life" and will not have any fixes
20backported to it.
21
22If you've found a bug on a kernel version that isn't listed on kernel.org,
23contact your Linux distribution or embedded vendor for support.
24Alternatively, you can attempt to run one of the supported stable or -rc
25kernels, and see if you can reproduce the bug on that. It's preferable
26to reproduce the bug on the latest -rc kernel.
27
28
29How to report Linux kernel bugs
30===============================
31
32
33Identify the problematic subsystem
34----------------------------------
35
36Identifying which part of the Linux kernel might be causing your issue
37increases your chances of getting your bug fixed. Simply posting to the
38generic linux-kernel mailing list (LKML) may cause your bug report to be
39lost in the noise of a mailing list that gets 1000+ emails a day.
40
41Instead, try to figure out which kernel subsystem is causing the issue,
42and email that subsystem's maintainer and mailing list. If the subsystem
43maintainer doesn't answer, then expand your scope to mailing lists like
44LKML.
45
46
47Identify who to notify
48----------------------
49
50Once you know the subsystem that is causing the issue, you should send a
51bug report. Some maintainers prefer bugs to be reported via bugzilla
52(https://bugzilla.kernel.org), while others prefer that bugs be reported
53via the subsystem mailing list.
54
55To find out where to send an emailed bug report, find your subsystem or
56device driver in the MAINTAINERS file. Search in the file for relevant
57entries, and send your bug report to the person(s) listed in the "M:"
58lines, making sure to Cc the mailing list(s) in the "L:" lines. When the
59maintainer replies to you, make sure to 'Reply-all' in order to keep the
60public mailing list(s) in the email thread.
61
62If you know which driver is causing issues, you can pass one of the driver
63files to the get_maintainer.pl script::
64
65 perl scripts/get_maintainer.pl -f <filename>
66
67If it is a security bug, please copy the Security Contact listed in the
68MAINTAINERS file. They can help coordinate bugfix and disclosure. See
69:ref:`Documentation/admin-guide/security-bugs.rst <securitybugs>` for more information.
70
71If you can't figure out which subsystem caused the issue, you should file
72a bug in kernel.org bugzilla and send email to
73linux-kernel@vger.kernel.org, referencing the bugzilla URL. (For more
74information on the linux-kernel mailing list see
75http://vger.kernel.org/lkml/).
76
77
78Tips for reporting bugs
79-----------------------
80
81If you haven't reported a bug before, please read:
82
83 https://www.chiark.greenend.org.uk/~sgtatham/bugs.html
84
85 http://www.catb.org/esr/faqs/smart-questions.html
86
87It's REALLY important to report bugs that seem unrelated as separate email
88threads or separate bugzilla entries. If you report several unrelated
89bugs at once, it's difficult for maintainers to tease apart the relevant
90data.
91
92
93Gather information
94------------------
95
96The most important information in a bug report is how to reproduce the
97bug. This includes system information, and (most importantly)
98step-by-step instructions for how a user can trigger the bug.
99
100If the failure includes an "OOPS:", take a picture of the screen, capture
101a netconsole trace, or type the message from your screen into the bug
102report. Please read "Documentation/admin-guide/bug-hunting.rst" before posting your
103bug report. This explains what you should do with the "Oops" information
104to make it useful to the recipient.
105
106This is a suggested format for a bug report sent via email or bugzilla.
107Having a standardized bug report form makes it easier for you not to
108overlook things, and easier for the developers to find the pieces of
109information they're really interested in. If some information is not
110relevant to your bug, feel free to exclude it.
111
112First run the ver_linux script included as scripts/ver_linux, which
113reports the version of some important subsystems. Run this script with
114the command ``awk -f scripts/ver_linux``.
115
116Use that information to fill in all fields of the bug report form, and
117post it to the mailing list with a subject of "PROBLEM: <one line
118summary from [1.]>" for easy identification by the developers::
119
120 [1.] One line summary of the problem:
121 [2.] Full description of the problem/report:
122 [3.] Keywords (i.e., modules, networking, kernel):
123 [4.] Kernel information
124 [4.1.] Kernel version (from /proc/version):
125 [4.2.] Kernel .config file:
126 [5.] Most recent kernel version which did not have the bug:
127 [6.] Output of Oops.. message (if applicable) with symbolic information
128 resolved (see Documentation/admin-guide/bug-hunting.rst)
129 [7.] A small shell script or example program which triggers the
130 problem (if possible)
131 [8.] Environment
132 [8.1.] Software (add the output of the ver_linux script here)
133 [8.2.] Processor information (from /proc/cpuinfo):
134 [8.3.] Module information (from /proc/modules):
135 [8.4.] Loaded driver and hardware information (/proc/ioports, /proc/iomem)
136 [8.5.] PCI information ('lspci -vvv' as root)
137 [8.6.] SCSI information (from /proc/scsi/scsi)
138 [8.7.] Other information that might be relevant to the problem
139 (please look in /proc and include all information that you
140 think to be relevant):
141 [X.] Other notes, patches, fixes, workarounds:
142
143
144Follow up
145=========
146
147Expectations for bug reporters
148------------------------------
149
150Linux kernel maintainers expect bug reporters to be able to follow up on
151bug reports. That may include running new tests, applying patches,
152recompiling your kernel, and/or re-triggering your bug. The most
153frustrating thing for maintainers is for someone to report a bug, and then
154never follow up on a request to try out a fix.
155
156That said, it's still useful for a kernel maintainer to know a bug exists
157on a supported kernel, even if you can't follow up with retests. Follow
158up reports, such as replying to the email thread with "I tried the latest
159kernel and I can't reproduce my bug anymore" are also helpful, because
160maintainers have to assume silence means things are still broken.
161
162Expectations for kernel maintainers
163-----------------------------------
164
165Linux kernel maintainers are busy, overworked human beings. Some times
166they may not be able to address your bug in a day, a week, or two weeks.
167If they don't answer your email, they may be on vacation, or at a Linux
168conference. Check the conference schedule at https://LWN.net for more info:
169
170 https://lwn.net/Calendar/
171
172In general, kernel maintainers take 1 to 5 business days to respond to
173bugs. The majority of kernel maintainers are employed to work on the
174kernel, and they may not work on the weekends. Maintainers are scattered
175around the world, and they may not work in your time zone. Unless you
176have a high priority bug, please wait at least a week after the first bug
177report before sending the maintainer a reminder email.
178
179The exceptions to this rule are regressions, kernel crashes, security holes,
180or userspace breakage caused by new kernel behavior. Those bugs should be
181addressed by the maintainers ASAP. If you suspect a maintainer is not
182responding to these types of bugs in a timely manner (especially during a
183merge window), escalate the bug to LKML and Linus Torvalds.
184
185Thank you!
186
187[Some of this is taken from Frohwalt Egerer's original linux-kernel FAQ]
Documentation/admin-guide/reporting-issues.rst+620−497
@@ -9,25 +9,6 @@ · 8 unmodified lines
9 (for example by the kernel's build system) might contain content taken from9 (for example by the kernel's build system) might contain content taken from
10 files which use a more restrictive license.10 files which use a more restrictive license.
11 11
12.. important::
13
14 This document is being prepared to replace
15 'Documentation/admin-guide/reporting-bugs.rst'. The main work is done and
16 you are already free to follow its instructions when reporting issues to the
17 Linux kernel developers. But keep in mind, below text still needs a few
18 finishing touches and review. It was merged to the Linux kernel sources at
19 this stage to make this process easier and increase the text's visibility.
20
21 Any improvements for the text or other feedback is thus very much welcome.
22 Please send it to 'Thorsten Leemhuis <linux@leemhuis.info>' and 'Jonathan
23 Corbet <corbet@lwn.net>', ideally with 'Linux kernel mailing list (LKML)
24 <linux-kernel@vger.kernel.org>' and the 'Linux Kernel Documentation List
25 <linux-doc@vger.kernel.org>' in CC.
26
27 Areas in the text that still need work or discussion contain a hint like this
28 which point out the remaining issues; all of them start with the word "FIXME"
29 to make them easy to find.
30
31 12
32Reporting issues13Reporting issues
33++++++++++++++++14++++++++++++++++
@@ -36,46 +17,43 @@ Reporting issues · 2 unmodified lines
36The short guide (aka TL;DR)17The short guide (aka TL;DR)
37===========================18===========================
38 19
39If you're facing multiple issues with the Linux kernel at once, report each20Are you facing a regression with vanilla kernels from the same stable or
40separately to its developers. Try your best guess which kernel part might be21longterm series? One still supported? Then search the `LKML
41causing the issue. Check the :ref:`MAINTAINERS <maintainers>` file for how its22<https://lore.kernel.org/lkml/>`_ and the `Linux stable mailing list
42developers expect to be told about issues. Note, it's rarely23<https://lore.kernel.org/stable/>`_ archives for matching reports to join. If
43`bugzilla.kernel.org <https://bugzilla.kernel.org/>`_, as in almost all cases24you don't find any, install `the latest release from that series
44the report needs to be sent by email!25<https://kernel.org/>`_. If it still shows the issue, report it to the stable
45 26mailing list (stable@vger.kernel.org) and CC the regressions list
46Check the destination thoroughly for existing reports; also search the LKML27(regressions@lists.linux.dev).
47archives and the web. Join existing discussion if you find matches. If you28
48don't find any, install `the latest Linux mainline kernel29In all other cases try your best guess which kernel part might be causing the
49<https://kernel.org/>`_. Make sure it's vanilla, thus is not patched or using30issue. Check the :ref:`MAINTAINERS <maintainers>` file for how its developers
50add-on kernel modules. Also ensure the kernel is running in a healthy31expect to be told about problems, which most of the time will be by email with a
51environment and is not already tainted before the issue occurs.32mailing list in CC. Check the destination's archives for matching reports;
52 33search the `LKML <https://lore.kernel.org/lkml/>`_ and the web, too. If you
53If you can reproduce your issue with the mainline kernel, send a report to the34don't find any to join, install `the latest mainline kernel
54destination you determined earlier. Make sure it includes all relevant35<https://kernel.org/>`_. If the issue is present there, send a report.
55information, which in case of a regression should mention the change that's36
56causing it which can often can be found with a bisection. Also ensure the37The issue was fixed there, but you would like to see it resolved in a still
57report reaches all people that need to know about it, for example the security38supported stable or longterm series as well? Then install its latest release.
58team, the stable maintainers or the developers of the patch that causes a39If it shows the problem, search for the change that fixed it in mainline and
59regression. Once the report is out, answer any questions that might be raised40check if backporting is in the works or was discarded; if it's neither, ask
60and help where you can. That includes keeping the ball rolling: every time a41those who handled the change for it.
61new rc1 mainline kernel is released, check if the issue is still happening42
62there and attach a status update to your initial report.43**General remarks**: When installing and testing a kernel as outlined above,
63 44ensure it's vanilla (IOW: not patched and not using add-on modules). Also make
64If you can not reproduce the issue with the mainline kernel, consider sticking45sure it's built and running in a healthy environment and not already tainted
65with it; if you'd like to use an older version line and want to see it fixed46before the issue occurs.
66there, first make sure it's still supported. Install its latest release as47
67vanilla kernel. If you cannot reproduce the issue there, try to find the commit48If you are facing multiple issues with the Linux kernel at once, report each
68that fixed it in mainline or any discussion preceding it: those will often49separately. While writing your report, include all information relevant to the
69mention if backporting is planed or considered too complex. If backporting was50issue, like the kernel and the distro used. In case of a regression, CC the
70not discussed, ask if it's in the cards. In case you don't find any commits or51regressions mailing list (regressions@lists.linux.dev) to your report; also try
71a preceding discussion, see the Linux-stable mailing list archives for existing52to include the commit-id of the change causing it, which a bisection can find.
72reports, as it might be a regression specific to the version line. If it is,53
73report it like you would report a problem in mainline (including the54Once the report is out, answer any questions that come up and help where you
74bisection).55can. That includes keeping the ball rolling by occasionally retesting with newer
75 56releases and sending a status update afterwards.
76If you reached this point without a solution, ask for advice one the
77subsystem's mailing list.
78
79 57
80Step-by-step guide how to report issues to the kernel maintainers58Step-by-step guide how to report issues to the kernel maintainers
81=================================================================59=================================================================
@@ -94,28 +72,23 @@ early if an issue that looks like a Linux kernel problem is actually caused by · 12 unmodified lines
94something else. These steps thus help to ensure the time you invest in this72something else. These steps thus help to ensure the time you invest in this
95process won't feel wasted in the end:73process won't feel wasted in the end:
96 74
97 * Stop reading this document and report the problem to your vendor instead,75 * Are you facing an issue with a Linux kernel a hardware or software vendor
98 unless you are running the latest mainline kernel already or are willing to76 provided? Then in almost all cases you are better off to stop reading this
99 install it. This kernel must not be modified or enhanced in any way, and77 document and reporting the issue to your vendor instead, unless you are
100 thus be considered 'vanilla'.78 willing to install the latest Linux version yourself. Be aware the latter
79 will often be needed anyway to hunt down and fix issues.
80
81 * Perform a rough search for existing reports with your favorite internet
82 search engine; additionally, check the archives of the `Linux Kernel Mailing
83 List (LKML) <https://lore.kernel.org/lkml/>`_. If you find matching reports,
84 join the discussion instead of sending a new one.
101 85
102 * See if the issue you are dealing with qualifies as regression, security86 * See if the issue you are dealing with qualifies as regression, security
103 issue, or a really severe problem: those are 'issues of high priority' that87 issue, or a really severe problem: those are 'issues of high priority' that
104 need special handling in some steps that are about to follow.88 need special handling in some steps that are about to follow.
105 89
106 * Check if your kernel was 'tainted' when the issue occurred, as the event90 * Make sure it's not the kernel's surroundings that are causing the issue
107 that made the kernel set this flag might be causing the issue you face.91 you face.
108
109 * Locate the driver or kernel subsystem that seems to be causing the issue.
110 Find out how and where its developers expect reports. Note: most of the
111 time this won't be bugzilla.kernel.org, as issues typically need to be sent
112 by mail to a maintainer and a public mailing list.
113
114 * Search the archives of the bug tracker or mailing list in question
115 thoroughly for reports that might match your issue. Also check if you find
116 something with your favorite internet search engine or in the Linux Kernel
117 Mailing List (LKML) archives. If you find anything, join the discussion
118 instead of sending a new report.
119 92
120 * Create a fresh backup and put system repair and restore tools at hand.93 * Create a fresh backup and put system repair and restore tools at hand.
121 94
@@ -123,8 +96,8 @@ process won't feel wasted in the end: · 1 unmodified line
123 kernel modules on-the-fly, which solutions like DKMS might be doing locally96 kernel modules on-the-fly, which solutions like DKMS might be doing locally
124 without your knowledge.97 without your knowledge.
125 98
126 * Make sure it's not the kernel's surroundings that are causing the issue99 * Check if your kernel was 'tainted' when the issue occurred, as the event
127 you face.100 that made the kernel set this flag might be causing the issue you face.
128 101
129 * Write down coarsely how to reproduce the issue. If you deal with multiple102 * Write down coarsely how to reproduce the issue. If you deal with multiple
130 issues at once, create separate notes for each of them and make sure they103 issues at once, create separate notes for each of them and make sure they
@@ -132,20 +105,35 @@ process won't feel wasted in the end: · 1 unmodified line
132 needs to get reported to the kernel developers separately, unless they are105 needs to get reported to the kernel developers separately, unless they are
133 strongly entangled.106 strongly entangled.
134 107
108 * If you are facing a regression within a stable or longterm version line
109 (say something broke when updating from 5.10.4 to 5.10.5), scroll down to
110 'Dealing with regressions within a stable and longterm kernel line'.
111
112 * Locate the driver or kernel subsystem that seems to be causing the issue.
113 Find out how and where its developers expect reports. Note: most of the
114 time this won't be bugzilla.kernel.org, as issues typically need to be sent
115 by mail to a maintainer and a public mailing list.
116
117 * Search the archives of the bug tracker or mailing list in question
118 thoroughly for reports that might match your issue. If you find anything,
119 join the discussion instead of sending a new report.
120
135After these preparations you'll now enter the main part:121After these preparations you'll now enter the main part:
136 122
137 * Install the latest Linux mainline kernel: that's where all issues get123 * Unless you are already running the latest 'mainline' Linux kernel, better
138 fixed first, because it's the version line the kernel developers mainly124 go and install it for the reporting process. Testing and reporting with
139 care about. Testing and reporting with the latest Linux stable kernel can125 the latest 'stable' Linux can be an acceptable alternative in some
140 be an acceptable alternative in some situations, for example during the126 situations; during the merge window that actually might be even the best
141 merge window; but during that period you might want to suspend your efforts127 approach, but in that development phase it can be an even better idea to
142 till its end anyway.128 suspend your efforts for a few days anyway. Whatever version you choose,
129 ideally use a 'vanilla' build. Ignoring these advices will dramatically
130 increase the risk your report will be rejected or ignored.
143 131
144 * Ensure the kernel you just installed does not 'taint' itself when132 * Ensure the kernel you just installed does not 'taint' itself when
145 running.133 running.
146 134
147 * Reproduce the issue with the kernel you just installed. If it doesn't show135 * Reproduce the issue with the kernel you just installed. If it doesn't show
148 up there, head over to the instructions for issues only happening with136 up there, scroll down to the instructions for issues only happening with
149 stable and longterm kernels.137 stable and longterm kernels.
150 138
151 * Optimize your notes: try to find and write the most straightforward way to139 * Optimize your notes: try to find and write the most straightforward way to
@@ -154,8 +142,8 @@ After these preparations you'll now enter the main part: · 2 unmodified lines
154 that hear about it for the first time. And if you learned something in this142 that hear about it for the first time. And if you learned something in this
155 process, consider searching again for existing reports about the issue.143 process, consider searching again for existing reports about the issue.
156 144
157 * If the failure includes a stack dump, like an Oops does, consider decoding145 * If your failure involves a 'panic', 'Oops', 'warning', or 'BUG', consider
158 it to find the offending line of code.146 decoding the kernel log to find the line of code that triggered the error.
159 147
160 * If your problem is a regression, try to narrow down when the issue was148 * If your problem is a regression, try to narrow down when the issue was
161 introduced as much as possible.149 introduced as much as possible.
@@ -184,28 +172,54 @@ After these preparations you'll now enter the main part: · 22 unmodified lines
184 help yourself, if you don't get any help or if it's unsatisfying.172 help yourself, if you don't get any help or if it's unsatisfying.
185 173
186 174
175Reporting regressions within a stable and longterm kernel line
176--------------------------------------------------------------
177
178This subsection is for you, if you followed above process and got sent here at
179the point about regression within a stable or longterm kernel version line. You
180face one of those if something breaks when updating from 5.10.4 to 5.10.5 (a
181switch from 5.9.15 to 5.10.5 does not qualify). The developers want to fix such
182regressions as quickly as possible, hence there is a streamlined process to
183report them:
184
185 * Check if the kernel developers still maintain the Linux kernel version
186 line you care about: go to the `front page of kernel.org
187 <https://kernel.org/>`_ and make sure it mentions
188 the latest release of the particular version line without an '[EOL]' tag.
189
190 * Check the archives of the `Linux stable mailing list
191 <https://lore.kernel.org/stable/>`_ for existing reports.
192
193 * Install the latest release from the particular version line as a vanilla
194 kernel. Ensure this kernel is not tainted and still shows the problem, as
195 the issue might have already been fixed there. If you first noticed the
196 problem with a vendor kernel, check a vanilla build of the last version
197 known to work performs fine as well.
198
199 * Send a short problem report to the Linux stable mailing list
200 (stable@vger.kernel.org) and CC the Linux regressions mailing list
201 (regressions@lists.linux.dev). Roughly describe the issue and ideally
202 explain how to reproduce it. Mention the first version that shows the
203 problem and the last version that's working fine. Then wait for further
204 instructions.
205
206The reference section below explains each of these steps in more detail.
207
208
187Reporting issues only occurring in older kernel version lines209Reporting issues only occurring in older kernel version lines
188-------------------------------------------------------------210-------------------------------------------------------------
189 211
190This section is for you, if you tried the latest mainline kernel as outlined212This subsection is for you, if you tried the latest mainline kernel as outlined
191above, but failed to reproduce your issue there; at the same time you want to213above, but failed to reproduce your issue there; at the same time you want to
192see the issue fixed in older version lines or a vendor kernel that's regularly214see the issue fixed in a still supported stable or longterm series or vendor
193rebased on new stable or longterm releases. If that case follow these steps:215kernels regularly rebased on those. If that the case, follow these steps:
194 216
195 * Prepare yourself for the possibility that going through the next few steps217 * Prepare yourself for the possibility that going through the next few steps
196 might not get the issue solved in older releases: the fix might be too big218 might not get the issue solved in older releases: the fix might be too big
197 or risky to get backported there.219 or risky to get backported there.
198 220
199 * Check if the kernel developers still maintain the Linux kernel version221 * Perform the first three steps in the section "Dealing with regressions
200 line you care about: go to the front page of kernel.org and make sure it222 within a stable and longterm kernel line" above.
201 mentions the latest release of the particular version line without an
202 '[EOL]' tag.
203
204 * Check the archives of the Linux stable mailing list for existing reports.
205
206 * Install the latest release from the particular version line as a vanilla
207 kernel. Ensure this kernel is not tainted and still shows the problem, as
208 the issue might have already been fixed there.
209 223
210 * Search the Linux kernel version control system for the change that fixed224 * Search the Linux kernel version control system for the change that fixed
211 the issue in mainline, as its commit message might tell you if the fix is225 the issue in mainline, as its commit message might tell you if the fix is
@@ -215,22 +229,13 @@ rebased on new stable or longterm releases. If that case follow these steps: · 3 unmodified lines
215 deemed unsuitable for backporting. If backporting was not considered at229 deemed unsuitable for backporting. If backporting was not considered at
216 all, join the newest discussion, asking if it's in the cards.230 all, join the newest discussion, asking if it's in the cards.
217 231
218 * Check if you're dealing with a regression that was never present in
219 mainline by installing the first release of the version line you care
220 about. If the issue doesn't show up with it, you basically need to report
221 the issue with this version like you would report a problem with mainline
222 (see above). This ideally includes a bisection followed by a search for
223 existing reports on the net; with the help of the subject and the two
224 relevant commit-ids. If that doesn't turn up anything, write the report; CC
225 or forward the report to the stable maintainers, the stable mailing list,
226 and those who authored the change. Include the shortened commit-id if you
227 found the change that causes it.
228
229 * One of the former steps should lead to a solution. If that doesn't work232 * One of the former steps should lead to a solution. If that doesn't work
230 out, ask the maintainers for the subsystem that seems to be causing the233 out, ask the maintainers for the subsystem that seems to be causing the
231 issue for advice; CC the mailing list for the particular subsystem as well234 issue for advice; CC the mailing list for the particular subsystem as well
232 as the stable mailing list.235 as the stable mailing list.
233 236
237The reference section below explains each of these steps in more detail.
238
234 239
235Reference section: Reporting issues to the kernel maintainers240Reference section: Reporting issues to the kernel maintainers
236=============================================================241=============================================================
@@ -276,54 +281,103 @@ issues to the Linux kernel developers. · 39 unmodified lines
276Make sure you're using the upstream Linux kernel281Make sure you're using the upstream Linux kernel
277------------------------------------------------282------------------------------------------------
278 283
279 *Stop reading this document and report the problem to your vendor instead,284 *Are you facing an issue with a Linux kernel a hardware or software vendor
280 unless you are running the latest mainline kernel already or are willing to285 provided? Then in almost all cases you are better off to stop reading this
281 install it. This kernel must not be modified or enhanced in any way, and286 document and reporting the issue to your vendor instead, unless you are
282 thus be considered 'vanilla'.*287 willing to install the latest Linux version yourself. Be aware the latter
288 will often be needed anyway to hunt down and fix issues.*
283 289
284Like most programmers, Linux kernel developers don't like to spend time dealing290Like most programmers, Linux kernel developers don't like to spend time dealing
285with reports for issues that don't even happen with the source code they291with reports for issues that don't even happen with their current code. It's
286maintain: it's just a waste everybody's time, yours included. That's why you292just a waste everybody's time, especially yours. Unfortunately such situations
287later will have to test your issue with the latest 'vanilla' kernel: a kernel293easily happen when it comes to the kernel and often leads to frustration on both
288that was build using the Linux sources taken straight from `kernel.org294sides. That's because almost all Linux-based kernels pre-installed on devices
289<https://kernel.org/>`_ and not modified or enhanced in any way.295(Computers, Laptops, Smartphones, Routers, …) and most shipped by Linux
290 296distributors are quite distant from the official Linux kernel as distributed by
291Almost all kernels used in devices (Computers, Laptops, Smartphones, Routers,297kernel.org: these kernels from these vendors are often ancient from the point of
292…) and most kernels shipped by Linux distributors are ancient from the point of298Linux development or heavily modified, often both.
293kernel development and heavily modified. They thus do not qualify for reporting299
294an issue to the Linux kernel developers: the issue you face with such a kernel300Most of these vendor kernels are quite unsuitable for reporting issues to the
295might be fixed already or caused by the changes or additions, even if they look301Linux kernel developers: an issue you face with one of them might have been
296small or totally unrelated. That's why issues with such kernels need to be302fixed by the Linux kernel developers months or years ago already; additionally,
297reported to the vendor that distributed it. Its developers should look into the303the modifications and enhancements by the vendor might be causing the issue you
304face, even if they look small or totally unrelated. That's why you should report
305issues with these kernels to the vendor. Its developers should look into the
298report and, in case it turns out to be an upstream issue, fix it directly306report and, in case it turns out to be an upstream issue, fix it directly
299upstream or report it there. In practice that sometimes does not work out. If307upstream or forward the report there. In practice that often does not work out
300that the case, you might want to circumvent the vendor by installing the latest308or might not what you want. You thus might want to consider circumventing the
301mainline kernel yourself and reporting the issue as outlined in this document;309vendor by installing the very latest Linux kernel core yourself. If that's an
302just make sure to use really fresh kernel (see below).310option for you move ahead in this process, as a later step in this guide will
303 311explain how to do that once it rules out other potential causes for your issue.
304 312
305.. note::313Note, the previous paragraph is starting with the word 'most', as sometimes
306 314developers in fact are willing to handle reports about issues occurring with
307 FIXME: Should we accept reports for issues with kernel images that are pretty315vendor kernels. If they do in the end highly depends on the developers and the
308 close to vanilla? But when are they close enough and how to put that line in316issue in question. Your chances are quite good if the distributor applied only
309 words? Maybe something like this?317small modifications to a kernel based on a recent Linux version; that for
318example often holds true for the mainline kernels shipped by Debian GNU/Linux
319Sid or Fedora Rawhide. Some developers will also accept reports about issues
320with kernels from distributions shipping the latest stable kernel, as long as
321its only slightly modified; that for example is often the case for Arch Linux,
322regular Fedora releases, and openSUSE Tumbleweed. But keep in mind, you better
323want to use a mainline Linux and avoid using a stable kernel for this
324process, as outlined in the section 'Install a fresh kernel for testing' in more
325detail.
326
327Obviously you are free to ignore all this advice and report problems with an old
328or heavily modified vendor kernel to the upstream Linux developers. But note,
329those often get rejected or ignored, so consider yourself warned. But it's still
330better than not reporting the issue at all: sometimes such reports directly or
331indirectly will help to get the issue fixed over time.
332
333
334Search for existing reports, first run
335--------------------------------------
336
337 *Perform a rough search for existing reports with your favorite internet
338 search engine; additionally, check the archives of the Linux Kernel Mailing
339 List (LKML). If you find matching reports, join the discussion instead of
340 sending a new one.*
341
342Reporting an issue that someone else already brought forward is often a waste of
343time for everyone involved, especially you as the reporter. So it's in your own
344interest to thoroughly check if somebody reported the issue already. At this
345step of the process it's okay to just perform a rough search: a later step will
346tell you to perform a more detailed search once you know where your issue needs
347to be reported to. Nevertheless, do not hurry with this step of the reporting
348process, it can save you time and trouble.
349
350Simply search the internet with your favorite search engine first. Afterwards,
351search the `Linux Kernel Mailing List (LKML) archives
352<https://lore.kernel.org/lkml/>`_.
310 353
311 *Note: Some Linux kernel developers accept reports from vendor kernels that354If you get flooded with results consider telling your search engine to limit
312 are known to be close to upstream. That for example is often the case for355search timeframe to the past month or year. And wherever you search, make sure
313 the kernels that Debian GNU/Linux Sid or Fedora Rawhide ship, which are356to use good search terms; vary them a few times, too. While doing so try to
314 normally following mainline closely and carry only a few patches. So a357look at the issue from the perspective of someone else: that will help you to
315 report with one of these might be accepted by the developers that need to358come up with other words to use as search terms. Also make sure not to use too
316 handle it. But if they do, depends heavily on the individual developers and359many search terms at once. Remember to search with and without information like
317 the issue at hand. That's why installing a mainline vanilla kernel is the360the name of the kernel driver or the name of the affected hardware component.
318 safe bet.*361But its exact brand name (say 'ASUS Red Devil Radeon RX 5700 XT Gaming OC')
362often is not much helpful, as it is too specific. Instead try search terms like
363the model line (Radeon 5700 or Radeon 5000) and the code name of the main chip
364('Navi' or 'Navi10') with and without its manufacturer ('AMD').
319 365
320 *Arch Linux, other Fedora releases, and openSUSE Tumbleweed often use quite366In case you find an existing report about your issue, join the discussion, as
321 recent stable kernels that are pretty close to upstream, too. Some367you might be able to provide valuable additional information. That can be
322 developers accept bugs from them as well. But note that you normally should368important even when a fix is prepared or in its final stages already, as
323 avoid stable kernels for reporting issues and use a mainline kernel instead369developers might look for people that can provide additional information or
324 (see below).*370test a proposed fix. Jump to the section 'Duties after the report went out' for
371details on how to get properly involved.
325 372
326 Are there any other major Linux distributions that should be mentioned here?373Note, searching `bugzilla.kernel.org <https://bugzilla.kernel.org/>`_ might also
374be a good idea, as that might provide valuable insights or turn up matching
375reports. If you find the latter, just keep in mind: most subsystems expect
376reports in different places, as described below in the section "Check where you
377need to report your issue". The developers that should take care of the issue
378thus might not even be aware of the bugzilla ticket. Hence, check the ticket if
379the issue already got reported as outlined in this document and if not consider
380doing so.
327 381
328 382
329Issue of high priority?383Issue of high priority?
@@ -365,6 +419,75 @@ fatal error where the kernel stop itself) with a 'Oops' (a recoverable error), · 35 unmodified lines
365as the kernel remains running after the latter.419as the kernel remains running after the latter.
366 420
367 421
422Ensure a healthy environment
423----------------------------
424
425 *Make sure it's not the kernel's surroundings that are causing the issue
426 you face.*
427
428Problems that look a lot like a kernel issue are sometimes caused by build or
429runtime environment. It's hard to rule out that problem completely, but you
430should minimize it:
431
432 * Use proven tools when building your kernel, as bugs in the compiler or the
433 binutils can cause the resulting kernel to misbehave.
434
435 * Ensure your computer components run within their design specifications;
436 that's especially important for the main processor, the main memory, and the
437 motherboard. Therefore, stop undervolting or overclocking when facing a
438 potential kernel issue.
439
440 * Try to make sure it's not faulty hardware that is causing your issue. Bad
441 main memory for example can result in a multitude of issues that will
442 manifest itself in problems looking like kernel issues.
443
444 * If you're dealing with a filesystem issue, you might want to check the file
445 system in question with ``fsck``, as it might be damaged in a way that leads
446 to unexpected kernel behavior.
447
448 * When dealing with a regression, make sure it's not something else that
449 changed in parallel to updating the kernel. The problem for example might be
450 caused by other software that was updated at the same time. It can also
451 happen that a hardware component coincidentally just broke when you rebooted
452 into a new kernel for the first time. Updating the systems BIOS or changing
453 something in the BIOS Setup can also lead to problems that on look a lot
454 like a kernel regression.
455
456
457Prepare for emergencies
458-----------------------
459
460 *Create a fresh backup and put system repair and restore tools at hand.*
461
462Reminder, you are dealing with computers, which sometimes do unexpected things,
463especially if you fiddle with crucial parts like the kernel of its operating
464system. That's what you are about to do in this process. Thus, make sure to
465create a fresh backup; also ensure you have all tools at hand to repair or
466reinstall the operating system as well as everything you need to restore the
467backup.
468
469
470Make sure your kernel doesn't get enhanced
471------------------------------------------
472
473 *Ensure your system does not enhance its kernels by building additional
474 kernel modules on-the-fly, which solutions like DKMS might be doing locally
475 without your knowledge.*
476
477The risk your issue report gets ignored or rejected dramatically increases if
478your kernel gets enhanced in any way. That's why you should remove or disable
479mechanisms like akmods and DKMS: those build add-on kernel modules
480automatically, for example when you install a new Linux kernel or boot it for
481the first time. Also remove any modules they might have installed. Then reboot
482before proceeding.
483
484Note, you might not be aware that your system is using one of these solutions:
485they often get set up silently when you install Nvidia's proprietary graphics
486driver, VirtualBox, or other software that requires a some support from a
487module not part of the Linux kernel. That why your might need to uninstall the
488packages with such software to get rid of any 3rd party kernel module.
489
490
368Check 'taint' flag491Check 'taint' flag
369------------------492------------------
370 493
@@ -433,9 +556,52 @@ three things: · 62 unmodified lines
433 the name of the module in question).556 the name of the module in question).
434 557
435 558
436Locate kernel area that causes the issue559Document how to reproduce issue
560-------------------------------
561
562 *Write down coarsely how to reproduce the issue. If you deal with multiple
563 issues at once, create separate notes for each of them and make sure they
564 work independently on a freshly booted system. That's needed, as each issue
565 needs to get reported to the kernel developers separately, unless they are
566 strongly entangled.*
567
568If you deal with multiple issues at once, you'll have to report each of them
569separately, as they might be handled by different developers. Describing
570various issues in one report also makes it quite difficult for others to tear
571it apart. Hence, only combine issues in one report if they are very strongly
572entangled.
573
574Additionally, during the reporting process you will have to test if the issue
575happens with other kernel versions. Therefore, it will make your work easier if
576you know exactly how to reproduce an issue quickly on a freshly booted system.
577
578Note: it's often fruitless to report issues that only happened once, as they
579might be caused by a bit flip due to cosmic radiation. That's why you should
580try to rule that out by reproducing the issue before going further. Feel free
581to ignore this advice if you are experienced enough to tell a one-time error
582due to faulty hardware apart from a kernel issue that rarely happens and thus
583is hard to reproduce.
584
585
586Regression in stable or longterm kernel?
437----------------------------------------587----------------------------------------
438 588
589 *If you are facing a regression within a stable or longterm version line
590 (say something broke when updating from 5.10.4 to 5.10.5), scroll down to
591 'Dealing with regressions within a stable and longterm kernel line'.*
592
593Regression within a stable and longterm kernel version line are something the
594Linux developers want to fix badly, as such issues are even more unwanted than
595regression in the main development branch, as they can quickly affect a lot of
596people. The developers thus want to learn about such issues as quickly as
597possible, hence there is a streamlined process to report them. Note,
598regressions with newer kernel version line (say something broke when switching
599from 5.9.15 to 5.10.5) do not qualify.
600
601
602Check where you need to report your issue
603-----------------------------------------
604
439 *Locate the driver or kernel subsystem that seems to be causing the issue.605 *Locate the driver or kernel subsystem that seems to be causing the issue.
440 Find out how and where its developers expect reports. Note: most of the606 Find out how and where its developers expect reports. Note: most of the
441 time this won't be bugzilla.kernel.org, as issues typically need to be sent607 time this won't be bugzilla.kernel.org, as issues typically need to be sent
@@ -526,26 +692,6 @@ example above does not have such a line. That is the case for most sections, as · 84 unmodified lines
526Linux kernel development is completely driven by mail. Very few subsystems use692Linux kernel development is completely driven by mail. Very few subsystems use
527a bug tracker, and only some of those rely on bugzilla.kernel.org.693a bug tracker, and only some of those rely on bugzilla.kernel.org.
528 694
529
530.. note::
531
532 FIXME: The old text took a totally different approach to bugzilla.kernel.org,
533 as it mentions it as the place to file issue for people that don't known how
534 to contact the appropriate people. The new one mentions it rarely; and when
535 it does like here, it warns users that it's often the wrong place to go.
536
537 This approach was chosen as the main author of this document noticed quite a
538 few users (or even a lot?) get no reply to the bugs they file in bugzilla.
539 That's kind of expected, as quite a few (many? most?) of the maintainers
540 don't even get notified when reports for their subsystem get filed there. And
541 not getting a single reply to report is something that is just annoying for
542 users and might make them angry. Improving bugzilla.k.o would be an option,
543 but on the kernel and maintainers summit 2017 it was agreed on to first go
544 this route (sorry it took so long): it's easier to achieve and less
545 controversial, as putting additional burden on already overworked maintainers
546 is unlikely to get well received.
547
548
549In this and many other cases you thus have to look for lines starting with695In this and many other cases you thus have to look for lines starting with
550'Mail:' instead. Those mention the name and the email addresses for the696'Mail:' instead. Those mention the name and the email addresses for the
551maintainers of the particular code. Also look for a line starting with 'Mailing697maintainers of the particular code. Also look for a line starting with 'Mailing
@@ -558,21 +704,6 @@ and might leave some work for other developers on the subsystem specific list; · 6 unmodified lines
558and LKML is important to have one place where all issue reports can be found.704and LKML is important to have one place where all issue reports can be found.
559 705
560 706
561.. note::
562
563 FIXME: Above section tells users to always CC LKML. These days it's a kind of
564 "catch-all" list anyway, which nearly nobody seems to follow closely. So it
565 seems appropriate to go "all in" and make people send their reports here,
566 too, as everything (reports, fixes, ...) then can be found in one place (at
567 least for all reports sent by mail and all subsystems that CC LKML).
568
569 Related: Should we create mailing list like 'linux-issues@vger.kernel.org'
570 and tell users above to always CC it when reporting issues? Then there would
571 be one central place reporters could search for existing reports (at least
572 for issues reported by mail) without getting regular LKML traffic mixed into
573 the results.
574
575
576Finding the maintainers with the help of a script707Finding the maintainers with the help of a script
577~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~708~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
578 709
@@ -611,205 +742,87 @@ modified during tree-wide cleanups by developers that do not care about the · 32 unmodified lines
611particular driver at all.742particular driver at all.
612 743
613 744
614Search for existing reports745Search for existing reports, second run
615---------------------------746---------------------------------------
616 747
617 *Search the archives of the bug tracker or mailing list in question748 *Search the archives of the bug tracker or mailing list in question
618 thoroughly for reports that might match your issue. Also check if you find749 thoroughly for reports that might match your issue. If you find anything,
619 something with your favorite internet search engine or in the Linux Kernel750 join the discussion instead of sending a new report.*
620 Mailing List (LKML) archives. If you find anything, join the discussion751
621 instead of sending a new report.*752As mentioned earlier already: reporting an issue that someone else already
622 753brought forward is often a waste of time for everyone involved, especially you
623Reporting an issue that someone else already brought forward is often a waste754as the reporter. That's why you should search for existing report again, now
624of time for everyone involved, especially you as the reporter. So it's in your755that you know where they need to be reported to. If it's mailing list, you will
625own interest to thoroughly check if somebody reported the issue already. Thus756often find its archives on `lore.kernel.org <https://lore.kernel.org/>`_.
626do not hurry with this step of the reporting process. Spending 30 to 60 minutes757
627or even more time can save you and others quite a lot of time and trouble.758But some list are hosted in different places. That for example is the case for
628 759the ath10k WiFi driver used as example in the previous step. But you'll often
629The best place to search is the bug tracker or the mailing list where your760find the archives for these lists easily on the net. Searching for 'archive
630report needs to be filed. You'll find quite a few of those lists on761ath10k@lists.infradead.org' for example will lead you to the `Info page for the
631`lore.kernel.org <https://lore.kernel.org/>`_, but some are hosted in762ath10k mailing list <https://lists.infradead.org/mailman/listinfo/ath10k>`_,
632different places. That for example is the case for the ath10k WiFi driver used763which at the top links to its
633as example in the previous step. But you'll often find the archives for these764`list archives <https://lists.infradead.org/pipermail/ath10k/>`_. Sadly this and
634lists easily on the net. Searching for 'archive ath10k@lists.infradead.org' for765quite a few other lists miss a way to search the archives. In those cases use a
635example will quickly lead you to the `Info page for the ath10k mailing list766regular internet search engine and add something like
636<https://lists.infradead.org/mailman/listinfo/ath10k>`_, which at the top links
637to its `list archives <https://lists.infradead.org/pipermail/ath10k/>`_.
638
639Sadly this and quite a few other lists miss a way to search the archives. In
640those cases use a regular internet search engine and add something like
641'site:lists.infradead.org/pipermail/ath10k/' to your search terms, which limits767'site:lists.infradead.org/pipermail/ath10k/' to your search terms, which limits
642the results to the archives at that URL.768the results to the archives at that URL.
643 769
644Additionally, search the internet and the `Linux Kernel Mailing List (LKML)770It's also wise to check the internet, LKML and maybe bugzilla.kernel.org again
645archives <https://lore.kernel.org/lkml/>`_, as maybe the real culprit might be771at this point.
646in some other subsystem. Searching in `bugzilla.kernel.org
647<https://bugzilla.kernel.org/>`_ might also be a good idea, but if you find
648anything there keep in mind: most subsystems expect reports in different
649places, hence those you find there might have not even reached the people
650responsible for the subsystem in question. Nevertheless, the data there might
651provide valuable insights.
652
653If you get flooded with results consider telling your search engine to limit
654search timeframe to the past month or year. And wherever you search, make sure
655to use good search terms; vary them a few times, too. While doing so try to
656look at the issue from the perspective of someone else: that will help you to
657come up with other words to use as search terms. Also make sure not to use too
658many search terms at once. Remember to search with and without information like
659the name of the kernel driver or the name of the affected hardware component.
660But its exact brand name (say 'ASUS Red Devil Radeon RX 5700 XT Gaming OC')
661often is not much helpful, as it is too specific. Instead try search terms like
662the model line (Radeon 5700 or Radeon 5000) and the code name of the main chip
663('Navi' or 'Navi10') with and without its manufacturer ('AMD').
664
665In case you find an existing report about your issue, join the discussion, as
666you might be able to provide valuable additional information. That can be
667important even when a fix is prepared or in its final stages already, as
668developers might look for people that can provide additional information or
669test a proposed fix. Jump to the section 'Duties after the report went out' for
670details on how to get properly involved.
671
672
673Prepare for emergencies
674-----------------------
675
676 *Create a fresh backup and put system repair and restore tools at hand.*
677
678Reminder, you are dealing with computers, which sometimes do unexpected things,
679especially if you fiddle with crucial parts like the kernel of its operating
680system. That's what you are about to do in this process. Thus, make sure to
681create a fresh backup; also ensure you have all tools at hand to repair or
682reinstall the operating system as well as everything you need to restore the
683backup.
684
685
686Make sure your kernel doesn't get enhanced
687------------------------------------------
688
689 *Ensure your system does not enhance its kernels by building additional
690 kernel modules on-the-fly, which solutions like DKMS might be doing locally
691 without your knowledge.*
692
693Your kernel must be 'vanilla' when reporting an issue, but stops being pure as
694soon as it loads a kernel module not built from the sources used to compile the
695kernel image itself. That's why you need to ensure your Linux kernel stays
696vanilla by removing or disabling mechanisms like akmods and DKMS: those might
697build additional kernel modules automatically, for example when your boot into
698a newly installed Linux kernel the first time. Reboot after removing them and
699any modules they installed.
700
701Note, you might not be aware that your system is using one of these solutions:
702they often get set up silently when you install Nvidia's proprietary graphics
703driver, VirtualBox, or other software that requires a some support from a
704module not part of the Linux kernel. That why your might need to uninstall the
705packages with such software to get rid of any 3rd party kernel module.
706
707
708Ensure a healthy environment
709----------------------------
710
711 *Make sure it's not the kernel's surroundings that are causing the issue
712 you face.*
713
714Problems that look a lot like a kernel issue are sometimes caused by build or
715runtime environment. It's hard to rule out that problem completely, but you
716should minimize it:
717
718 * Use proven tools when building your kernel, as bugs in the compiler or the
719 binutils can cause the resulting kernel to misbehave.
720
721 * Ensure your computer components run within their design specifications;
722 that's especially important for the main processor, the main memory, and the
723 motherboard. Therefore, stop undervolting or overclocking when facing a
724 potential kernel issue.
725
726 * Try to make sure it's not faulty hardware that is causing your issue. Bad
727 main memory for example can result in a multitude of issues that will
728 manifest itself in problems looking like kernel issues.
729
730 * If you're dealing with a filesystem issue, you might want to check the file
731 system in question with ``fsck``, as it might be damaged in a way that leads
732 to unexpected kernel behavior.
733
734 * When dealing with a regression, make sure it's not something else that
735 changed in parallel to updating the kernel. The problem for example might be
736 caused by other software that was updated at the same time. It can also
737 happen that a hardware component coincidentally just broke when you rebooted
738 into a new kernel for the first time. Updating the systems BIOS or changing
739 something in the BIOS Setup can also lead to problems that on look a lot
740 like a kernel regression.
741
742 772
743Document how to reproduce issue773For details how to search and what to do if you find matching reports see
744-------------------------------774"Search for existing reports, first run" above.
745 775
746 *Write down coarsely how to reproduce the issue. If you deal with multiple776Do not hurry with this step of the reporting process: spending 30 to 60 minutes
747 issues at once, create separate notes for each of them and make sure they777or even more time can save you and others quite a lot of time and trouble.
748 work independently on a freshly booted system. That's needed, as each issue
749 needs to get reported to the kernel developers separately, unless they are
750 strongly entangled.*
751
752If you deal with multiple issues at once, you'll have to report each of them
753separately, as they might be handled by different developers. Describing
754various issues in one report also makes it quite difficult for others to tear
755it apart. Hence, only combine issues in one report if they are very strongly
756entangled.
757
758Additionally, during the reporting process you will have to test if the issue
759happens with other kernel versions. Therefore, it will make your work easier if
760you know exactly how to reproduce an issue quickly on a freshly booted system.
761
762Note: it's often fruitless to report issues that only happened once, as they
763might be caused by a bit flip due to cosmic radiation. That's why you should
764try to rule that out by reproducing the issue before going further. Feel free
765to ignore this advice if you are experienced enough to tell a one-time error
766due to faulty hardware apart from a kernel issue that rarely happens and thus
767is hard to reproduce.
768 778
769 779
770Install a fresh kernel for testing780Install a fresh kernel for testing
771----------------------------------781----------------------------------
772 782
773 *Install the latest Linux mainline kernel: that's where all issues get783 *Unless you are already running the latest 'mainline' Linux kernel, better
774 fixed first, because it's the version line the kernel developers mainly784 go and install it for the reporting process. Testing and reporting with
775 care about. Testing and reporting with the latest Linux stable kernel can785 the latest 'stable' Linux can be an acceptable alternative in some
776 be an acceptable alternative in some situations, for example during the786 situations; during the merge window that actually might be even the best
777 merge window; but during that period you might want to suspend your efforts787 approach, but in that development phase it can be an even better idea to
778 till its end anyway.*788 suspend your efforts for a few days anyway. Whatever version you choose,
779 789 ideally use a 'vanilla' built. Ignoring these advices will dramatically
780Reporting an issue to the Linux kernel developers they fixed weeks or months790 increase the risk your report will be rejected or ignored.*
781ago is annoying for them and wasting their and your time. That's why it's in791
782everybody's interest to check if the issue occurs with the latest codebase792As mentioned in the detailed explanation for the first step already: Like most
783before reporting it.793programmers, Linux kernel developers don't like to spend time dealing with
784 794reports for issues that don't even happen with the current code. It's just a
785In the scope of the Linux kernel the term 'latest' means: a kernel version795waste everybody's time, especially yours. That's why it's in everybody's
786recently created from the main line of development, as this 'mainline' tree is796interest that you confirm the issue still exists with the latest upstream code
787where developers first apply fixes; only after that are they are allowed to get797before reporting it. You are free to ignore this advice, but as outlined
788backported to older, still supported version lines called 'stable' and798earlier: doing so dramatically increases the risk that your issue report might
789'longterm' kernels. That's why you should check a recent mainline kernel, even799get rejected or simply ignored.
790if you deal with an issue you only want to see fixed in an older version line.800
791Another reason: some fixes are only applied to mainline or recent version801In the scope of the kernel "latest upstream" normally means:
792lines, as it's too hard or risky to backport them to older versions. If that802
793the case, reporting the issue again is unlikely to change anything.803 * Install a mainline kernel; the latest stable kernel can be an option, but
794 804 most of the time is better avoided. Longterm kernels (sometimes called 'LTS
795Longterm kernels (sometimes called "LTS kernels") are therefore unsuitable for805 kernels') are unsuitable at this point of the process. The next subsection
796testing; they simply are too distant from current development. Even the latest806 explains all of this in more detail.
797Linux 'stable' kernel is a significant bit behind and thus better avoided. At807
798least most of the time, as sometimes a stable kernel can the best choice; but808 * The over next subsection describes way to obtain and install such a kernel.
799in those situations you might want to wait a few days anyway:809 It also outlines that using a pre-compiled kernel are fine, but better are
800 810 vanilla, which means: it was built using Linux sources taken straight `from
801Choosing between mainline, stable and waiting811 kernel.org <https://kernel.org/>`_ and not modified or enhanced in any way.
802~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~812
803 813Choosing the right version for testing
804Head over to `kernel.org <https://kernel.org/>`_ to decide which version to814~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
805use. Ignore the big yellow button that says 'Latest release' and look a little815
806lower for a table. At its top you'll see a line starting with 'mainline', which816Head over to `kernel.org <https://kernel.org/>`_ to find out which version you
807most of the time will point to a pre-release with a version number like817want to use for testing. Ignore the big yellow button that says 'Latest release'
808'5.8-rc2'. If that's the case, you'll want to use this mainline kernel for818and look a little lower at the table. At its top you'll see a line starting with
809testing. Do not let that 'rc' scare you, these 'development kernels' are pretty819mainline, which most of the time will point to a pre-release with a version
810reliable — and you made a backup, as you were instructed above, didn't you?820number like '5.8-rc2'. If that's the case, you'll want to use this mainline
811 821kernel for testing, as that where all fixes have to be applied first. Do not let
812In about two out of every nine to ten weeks, 'mainline' might point you to a822that 'rc' scare you, these 'development kernels' are pretty reliable — and you
823made a backup, as you were instructed above, didn't you?
824
825In about two out of every nine to ten weeks, mainline might point you to a
813proper release with a version number like '5.7'. If that happens, consider826proper release with a version number like '5.7'. If that happens, consider
814suspending the reporting process until the first pre-release of the next827suspending the reporting process until the first pre-release of the next
815version (5.8-rc1) shows up on kernel.org. That's because the Linux development828version (5.8-rc1) shows up on kernel.org. That's because the Linux development
@@ -830,45 +843,79 @@ case mainline for some reason does currently not work for you. An in general: · 14 unmodified lines
830using it for reproducing the issue is also better than not reporting it issue843using it for reproducing the issue is also better than not reporting it issue
831at all.844at all.
832 845
846Better avoid using the latest stable kernel outside merge windows, as all fixes
847must be applied to mainline first. That's why checking the latest mainline
848kernel is so important: any issue you want to see fixed in older version lines
849needs to be fixed in mainline first before it can get backported, which can
850take a few days or weeks. Another reason: the fix you hope for might be too
851hard or risky for backporting; reporting the issue again hence is unlikely to
852change anything.
853
854These aspects are also why longterm kernels (sometimes called "LTS kernels")
855are unsuitable for this part of the reporting process: they are to distant from
856the current code. Hence go and test mainline first and follow the process
857further: if the issue doesn't occur with mainline it will guide you how to get
858it fixed in older version lines, if that's in the cards for the fix in question.
859
833How to obtain a fresh Linux kernel860How to obtain a fresh Linux kernel
834~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~861~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
835 862
836You can use pre-built or self-compiled kernel for testing; if you choose the863**Using a pre-compiled kernel**: This is often the quickest, easiest, and safest
837latter approach, you can either obtain the source code using git or download it864way for testing — especially is you are unfamiliar with the Linux kernel. The
838as tar archive.865problem: most of those shipped by distributors or add-on repositories are build
839 866from modified Linux sources. They are thus not vanilla and therefore often
840Using a pre-compiled kernel for testing is often the quickest, easiest, and867unsuitable for testing and issue reporting: the changes might cause the issue
841safest way – especially is you are unfamiliar with the Linux kernel. But it868you face or influence it somehow.
842needs to be a vanilla kernel, which can be hard to come buy. You are in luck if869
843you are using a popular Linux distribution: for quite a few of them you'll find870But you are in luck if you are using a popular Linux distribution: for quite a
844repositories on the net that contain packages with the latest mainline or871few of them you'll find repositories on the net that contain packages with the
845stable kernels in vanilla fashion. It's totally okay to use these, just make872latest mainline or stable Linux built as vanilla kernel. It's totally okay to
846sure from the repository's documentation they are really vanilla. And ensure873use these, just make sure from the repository's description they are vanilla or
847the packages contain the latest versions as offered on kernel.org; they are874at least close to it. Additionally ensure the packages contain the latest
848likely unsuitable if the package is older than a week, as new mainline and875versions as offered on kernel.org. The packages are likely unsuitable if they
849stable kernels typically get released at least once a week. And be aware that876are older than a week, as new mainline and stable kernels typically get released
850you might need to get build your own kernel later anyway when it comes to877at least once a week.
851helping test fixes, as described later in this document.878
852 879Please note that you might need to build your own kernel manually later: that's
853Developers and experienced Linux users familiar with git are often best served880sometimes needed for debugging or testing fixes, as described later in this
854by obtaining the latest Linux kernel sources straight from the `official881document. Also be aware that pre-compiled kernels might lack debug symbols that
855development repository on kernel.org882are needed to decode messages the kernel prints when a panic, Oops, warning, or
883BUG occurs; if you plan to decode those, you might be better off compiling a
884kernel yourself (see the end of this subsection and the section titled 'Decode
885failure messages' for details).
886
887**Using git**: Developers and experienced Linux users familiar with git are
888often best served by obtaining the latest Linux kernel sources straight from the
889`official development repository on kernel.org
856<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/>`_.890<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/>`_.
857Those are likely a bit ahead of the latest mainline pre-release. Don't worry891Those are likely a bit ahead of the latest mainline pre-release. Don't worry
858about it: they are as reliable as a proper pre-release, unless the kernel's892about it: they are as reliable as a proper pre-release, unless the kernel's
859development cycle is currently in the middle of a merge window. But even then893development cycle is currently in the middle of a merge window. But even then
860they are quite reliable.894they are quite reliable.
861 895
862People unfamiliar with git are often best served by downloading the sources as896**Conventional**: People unfamiliar with git are often best served by
863tarball from `kernel.org <https://kernel.org/>`_.897downloading the sources as tarball from `kernel.org <https://kernel.org/>`_.
864 898
865How to actually build a kernel isnot described here, as many websites explain899How to actually build a kernel is not described here, as many websites explain
866the necessary steps already. If you are new to it, consider following one of900the necessary steps already. If you are new to it, consider following one of
867those how-to's that suggest to use ``make localmodconfig``, as that tries to901those how-to's that suggest to use ``make localmodconfig``, as that tries to
868pick up the configuration of your current kernel and then tries to adjust it902pick up the configuration of your current kernel and then tries to adjust it
869somewhat for your system. That does not make the resulting kernel any better,903somewhat for your system. That does not make the resulting kernel any better,
870but quicker to compile.904but quicker to compile.
871 905
906Note: If you are dealing with a panic, Oops, warning, or BUG from the kernel,
907please try to enable CONFIG_KALLSYMS when configuring your kernel.
908Additionally, enable CONFIG_DEBUG_KERNEL and CONFIG_DEBUG_INFO, too; the
909latter is the relevant one of those two, but can only be reached if you enable
910the former. Be aware CONFIG_DEBUG_INFO increases the storage space required to
911build a kernel by quite a bit. But that's worth it, as these options will allow
912you later to pinpoint the exact line of code that triggers your issue. The
913section 'Decode failure messages' below explains this in more detail.
914
915But keep in mind: Always keep a record of the issue encountered in case it is
916hard to reproduce. Sending an undecoded report is better than not reporting
917the issue at all.
918
872 919
873Check 'taint' flag920Check 'taint' flag
874------------------921------------------
@@ -888,7 +935,7 @@ Reproduce issue with the fresh kernel · 13 unmodified lines
888-------------------------------------935-------------------------------------
889 936
890 *Reproduce the issue with the kernel you just installed. If it doesn't show937 *Reproduce the issue with the kernel you just installed. If it doesn't show
891 up there, head over to the instructions for issues only happening with938 up there, scroll down to the instructions for issues only happening with
892 stable and longterm kernels.*939 stable and longterm kernels.*
893 940
894Check if the issue occurs with the fresh Linux kernel version you just941Check if the issue occurs with the fresh Linux kernel version you just
@@ -923,31 +970,55 @@ instead you can join. · 28 unmodified lines
923Decode failure messages970Decode failure messages
924-----------------------971-----------------------
925 972
926.. note::973 *If your failure involves a 'panic', 'Oops', 'warning', or 'BUG', consider
974 decoding the kernel log to find the line of code that triggered the error.*
927 975
928 FIXME: The text in this section is a placeholder for now and quite similar to976When the kernel detects an internal problem, it will log some information about
929 the old text found in 'Documentation/admin-guide/reporting-bugs.rst'977the executed code. This makes it possible to pinpoint the exact line in the
930 currently. It and the document it references are known to be outdated and978source code that triggered the issue and shows how it was called. But that only
931 thus need to be revisited. Thus consider this note a request for help: if you979works if you enabled CONFIG_DEBUG_INFO and CONFIG_KALLSYMS when configuring
932 are familiar with this topic, please write a few lines that would fit here.980your kernel. If you did so, consider to decode the information from the
933 Alternatively, simply outline the current situation roughly to the main981kernel's log. That will make it a lot easier to understand what lead to the
934 authors of this document (see intro), as they might be able to write982'panic', 'Oops', 'warning', or 'BUG', which increases the chances that someone
935 something then.983can provide a fix.
936 984
937 This section in the end should answer questions like "when is this actually985Decoding can be done with a script you find in the Linux source tree. If you
938 needed", "what .config options to ideally set earlier to make this step easy986are running a kernel you compiled yourself earlier, call it like this::
939 or unnecessary?" (likely CONFIG_UNWINDER_ORC when it's available, otherwise
940 CONFIG_UNWINDER_FRAME_POINTER; but is there anything else needed?).
941 987
942..988 [user@something ~]$ sudo dmesg | ./linux-5.10.5/scripts/decode_stacktrace.sh ./linux-5.10.5/vmlinux
989
990If you are running a packaged vanilla kernel, you will likely have to install
991the corresponding packages with debug symbols. Then call the script (which you
992might need to get from the Linux sources if your distro does not package it)
993like this::
994
995 [user@something ~]$ sudo dmesg | ./linux-5.10.5/scripts/decode_stacktrace.sh \
996 /usr/lib/debug/lib/modules/5.10.10-4.1.x86_64/vmlinux /usr/src/kernels/5.10.10-4.1.x86_64/
997
998The script will work on log lines like the following, which show the address of
999the code the kernel was executing when the error occurred::
1000
1001 [ 68.387301] RIP: 0010:test_module_init+0x5/0xffa [test_module]
1002
1003Once decoded, these lines will look like this::
943 1004
944 *If the failure includes a stack dump, like an Oops does, consider decoding1005 [ 68.387301] RIP: 0010:test_module_init (/home/username/linux-5.10.5/test-module/test-module.c:16) test_module
945 it to find the offending line of code.*
946 1006
947When the kernel detects an error, it will print a stack dump that allows to1007In this case the executed code was built from the file
948identify the exact line of code where the issue happens. But that information1008'~/linux-5.10.5/test-module/test-module.c' and the error occurred by the
949sometimes needs to get decoded to be readable, which is explained in1009instructions found in line '16'.
950admin-guide/bug-hunting.rst.1010
1011The script will similarly decode the addresses mentioned in the section
1012starting with 'Call trace', which show the path to the function where the
1013problem occurred. Additionally, the script will show the assembler output for
1014the code section the kernel was executing.
1015
1016Note, if you can't get this to work, simply skip this step and mention the
1017reason for it in the report. If you're lucky, it might not be needed. And if it
1018is, someone might help you to get things going. Also be aware this is just one
1019of several ways to decode kernel stack traces. Sometimes different steps will
1020be required to retrieve the relevant details. Don't worry about that, if that's
1021needed in your case, developers will tell you what to do.
951 1022
952 1023
953Special care for regressions1024Special care for regressions
@@ -1000,8 +1071,7 @@ In the whole process keep in mind: an issue only qualifies as regression if the · 46 unmodified lines
1000older and the newer kernel got built with a similar configuration. The best way1071older and the newer kernel got built with a similar configuration. The best way
1001to archive this: copy the configuration file (``.config``) from the old working1072to archive this: copy the configuration file (``.config``) from the old working
1002kernel freshly to each newer kernel version you try. Afterwards run ``make1073kernel freshly to each newer kernel version you try. Afterwards run ``make
1003oldnoconfig`` to adjust it for the needs of the new version without enabling1074olddefconfig`` to adjust it for the needs of the new version.
1004any new feature, as those are allowed to cause regressions.
1005 1075
1006 1076
1007Write and send the report1077Write and send the report
@@ -1166,17 +1236,26 @@ Special handling for high priority issues · 158 unmodified lines
1166 1236
1167Reports for high priority issues need special handling.1237Reports for high priority issues need special handling.
1168 1238
1169**Severe bugs**: make sure the subject or ticket title as well as the first1239**Severe issues**: make sure the subject or ticket title as well as the first
1170paragraph makes the severeness obvious.1240paragraph makes the severeness obvious.
1171 1241
1172**Regressions**: If the issue is a regression add [REGRESSION] to the mail's1242**Regressions**: make the report's subject start with '[REGRESSION]'.
1173subject or the title in the bug-tracker. If you did not perform a bisection1243
1174mention at least the latest mainline version you tested that worked fine (say1244In case you performed a successful bisection, use the title of the change that
11755.7) and the oldest where the issue occurs (say 5.8). If you did a successful1245introduced the regression as the second part of your subject. Make the report
1176bisection mention the commit id and subject of the change that causes the1246also mention the commit id of the culprit. In case of an unsuccessful bisection,
1177regression. Also make sure to add the author of that change to your report; if1247make your report mention the latest tested version that's working fine (say 5.7)
1178you need to file your bug in a bug-tracker forward the report to him in a1248and the oldest where the issue occurs (say 5.8-rc1).
1179private mail and mention where your filed it.1249
1250When sending the report by mail, CC the Linux regressions mailing list
1251(regressions@lists.linux.dev). In case the report needs to be filed to some web
1252tracker, proceed to do so; once filed, forward the report by mail to the
1253regressions list. Make sure to inline the forwarded report, hence do not attach
1254it. Also add a short note at the top where you mention the URL to the ticket.
1255
1256When mailing or forwarding the report, in case of a successful bisection add the
1257author of the culprit to the recipients; also CC everyone in the signed-off-by
1258chain, which you find at the end of its commit message.
1180 1259
1181**Security issues**: for these issues your will have to evaluate if a1260**Security issues**: for these issues your will have to evaluate if a
1182short-term risk to other users would arise if details were publicly disclosed.1261short-term risk to other users would arise if details were publicly disclosed.
@@ -1255,7 +1334,7 @@ you never have heard of yet; or you might be asked to apply a patch to the · 72 unmodified lines
1255Linux kernel sources to test if it helps. In some cases it will be fine sending1334Linux kernel sources to test if it helps. In some cases it will be fine sending
1256a reply asking for instructions how to do that. But before going that route try1335a reply asking for instructions how to do that. But before going that route try
1257to find the answer own your own by searching the internet; alternatively1336to find the answer own your own by searching the internet; alternatively
1258consider asking in other places for advice. For example ask a fried or post1337consider asking in other places for advice. For example ask a friend or post
1259about it to a chatroom or forum you normally hang out.1338about it to a chatroom or forum you normally hang out.
1260 1339
1261**Be patient**: If you are really lucky you might get a reply to your report1340**Be patient**: If you are really lucky you might get a reply to your report
@@ -1390,32 +1469,11 @@ easier. And with a bit of luck there might be someone in the team that knows a · 128 unmodified lines
1390bit about programming and might be able to write a fix.1469bit about programming and might be able to write a fix.
1391 1470
1392 1471
1393Details about reporting issues only occurring in older kernel version lines1472Reference for "Reporting regressions within a stable and longterm kernel line"
1394---------------------------------------------------------------------------1473------------------------------------------------------------------------------
1395 1474
1396This subsection provides details for steps you need to take if you could not1475This subsection provides details for the steps you need to perform if you face
1397reproduce your issue with a mainline kernel, but want to see it fixed in older1476a regression within a stable and longterm kernel line.
1398version lines (aka stable and longterm kernels).
1399
1400Some fixes are too complex
1401~~~~~~~~~~~~~~~~~~~~~~~~~~
1402
1403 *Prepare yourself for the possibility that going through the next few steps
1404 might not get the issue solved in older releases: the fix might be too big
1405 or risky to get backported there.*
1406
1407Even small and seemingly obvious code-changes sometimes introduce new and
1408totally unexpected problems. The maintainers of the stable and longterm kernels
1409are very aware of that and thus only apply changes to these kernels that are
1410within rules outlined in 'Documentation/process/stable-kernel-rules.rst'.
1411
1412Complex or risky changes for example do not qualify and thus only get applied
1413to mainline. Other fixes are easy to get backported to the newest stable and
1414longterm kernels, but too risky to integrate into older ones. So be aware the
1415fix you are hoping for might be one of those that won't be backported to the
1416version line your care about. In that case you'll have no other choice then to
1417live with the issue or switch to a newer Linux version, unless you want to
1418patch the fix into your kernels yourself.
1419 1477
1420Make sure the particular version line still gets support1478Make sure the particular version line still gets support
1421~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1479~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1431,7 +1489,7 @@ chosen and gets supported for at least two years (often six). That's why you · 9 unmodified lines
1431need to check if the kernel developers still support the version line you care1489need to check if the kernel developers still support the version line you care
1432for.1490for.
1433 1491
1434Note, if kernel.org lists two 'stable' version lines on the front page, you1492Note, if kernel.org lists two stable version lines on the front page, you
1435should consider switching to the newer one and forget about the older one:1493should consider switching to the newer one and forget about the older one:
1436support for it is likely to be abandoned soon. Then it will get a "end-of-life"1494support for it is likely to be abandoned soon. Then it will get a "end-of-life"
1437(EOL) stamp. Version lines that reached that point still get mentioned on the1495(EOL) stamp. Version lines that reached that point still get mentioned on the
@@ -1454,12 +1512,103 @@ Reproduce issue with the newest release · 16 unmodified lines
1454 1512
1455 *Install the latest release from the particular version line as a vanilla1513 *Install the latest release from the particular version line as a vanilla
1456 kernel. Ensure this kernel is not tainted and still shows the problem, as1514 kernel. Ensure this kernel is not tainted and still shows the problem, as
1457 the issue might have already been fixed there.*1515 the issue might have already been fixed there. If you first noticed the
1516 problem with a vendor kernel, check a vanilla build of the last version
1517 known to work performs fine as well.*
1458 1518
1459Before investing any more time in this process you want to check if the issue1519Before investing any more time in this process you want to check if the issue
1460was already fixed in the latest release of version line you're interested in.1520was already fixed in the latest release of version line you're interested in.
1461This kernel needs to be vanilla and shouldn't be tainted before the issue1521This kernel needs to be vanilla and shouldn't be tainted before the issue
1462happens, as detailed outlined already above in the process of testing mainline.1522happens, as detailed outlined already above in the section "Install a fresh
1523kernel for testing".
1524
1525Did you first notice the regression with a vendor kernel? Then changes the
1526vendor applied might be interfering. You need to rule that out by performing
1527a recheck. Say something broke when you updated from 5.10.4-vendor.42 to
15285.10.5-vendor.43. Then after testing the latest 5.10 release as outlined in
1529the previous paragraph check if a vanilla build of Linux 5.10.4 works fine as
1530well. If things are broken there, the issue does not qualify as upstream
1531regression and you need switch back to the main step-by-step guide to report
1532the issue.
1533
1534Report the regression
1535~~~~~~~~~~~~~~~~~~~~~
1536
1537 *Send a short problem report to the Linux stable mailing list
1538 (stable@vger.kernel.org) and CC the Linux regressions mailing list
1539 (regressions@lists.linux.dev). Roughly describe the issue and ideally
1540 explain how to reproduce it. Mention the first version that shows the
1541 problem and the last version that's working fine. Then wait for further
1542 instructions.*
1543
1544When reporting a regression that happens within a stable or longterm kernel
1545line (say when updating from 5.10.4 to 5.10.5) a brief report is enough for
1546the start to get the issue reported quickly. Hence a rough description is all
1547it takes.
1548
1549But note, it helps developers a great deal if you can specify the exact version
1550that introduced the problem. Hence if possible within a reasonable time frame,
1551try to find that version using vanilla kernels. Lets assume something broke when
1552your distributor released a update from Linux kernel 5.10.5 to 5.10.8. Then as
1553instructed above go and check the latest kernel from that version line, say
15545.10.9. If it shows the problem, try a vanilla 5.10.5 to ensure that no patches
1555the distributor applied interfere. If the issue doesn't manifest itself there,
1556try 5.10.7 and then (depending on the outcome) 5.10.8 or 5.10.6 to find the
1557first version where things broke. Mention it in the report and state that 5.10.9
1558is still broken.
1559
1560What the previous paragraph outlines is basically a rough manual 'bisection'.
1561Once your report is out your might get asked to do a proper one, as it allows to
1562pinpoint the exact change that causes the issue (which then can easily get
1563reverted to fix the issue quickly). Hence consider to do a proper bisection
1564right away if time permits. See the section 'Special care for regressions' and
1565the document 'Documentation/admin-guide/bug-bisect.rst' for details how to
1566perform one.
1567
1568
1569Reference for "Reporting issues only occurring in older kernel version lines"
1570-----------------------------------------------------------------------------
1571
1572This section provides details for the steps you need to take if you could not
1573reproduce your issue with a mainline kernel, but want to see it fixed in older
1574version lines (aka stable and longterm kernels).
1575
1576Some fixes are too complex
1577~~~~~~~~~~~~~~~~~~~~~~~~~~
1578
1579 *Prepare yourself for the possibility that going through the next few steps
1580 might not get the issue solved in older releases: the fix might be too big
1581 or risky to get backported there.*
1582
1583Even small and seemingly obvious code-changes sometimes introduce new and
1584totally unexpected problems. The maintainers of the stable and longterm kernels
1585are very aware of that and thus only apply changes to these kernels that are
1586within rules outlined in 'Documentation/process/stable-kernel-rules.rst'.
1587
1588Complex or risky changes for example do not qualify and thus only get applied
1589to mainline. Other fixes are easy to get backported to the newest stable and
1590longterm kernels, but too risky to integrate into older ones. So be aware the
1591fix you are hoping for might be one of those that won't be backported to the
1592version line your care about. In that case you'll have no other choice then to
1593live with the issue or switch to a newer Linux version, unless you want to
1594patch the fix into your kernels yourself.
1595
1596Common preparations
1597~~~~~~~~~~~~~~~~~~~
1598
1599 *Perform the first three steps in the section "Reporting issues only
1600 occurring in older kernel version lines" above.*
1601
1602You need to carry out a few steps already described in another section of this
1603guide. Those steps will let you:
1604
1605 * Check if the kernel developers still maintain the Linux kernel version line
1606 you care about.
1607
1608 * Search the Linux stable mailing list for exiting reports.
1609
1610 * Check with the latest release.
1611
1463 1612
1464Check code history and search for existing discussions1613Check code history and search for existing discussions
1465~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1614~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1513,41 +1662,6 @@ discussions abound it. · 47 unmodified lines
1513 join the discussion: mention the version where you face the issue and that1662 join the discussion: mention the version where you face the issue and that
1514 you would like to see it fixed, if suitable.1663 you would like to see it fixed, if suitable.
1515 1664
1516Check if it's a regression specific to stable or longterm kernels
1517~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1518
1519 *Check if you're dealing with a regression that was never present in
1520 mainline by installing the first release of the version line you care
1521 about. If the issue doesn't show up with it, you basically need to report
1522 the issue with this version like you would report a problem with mainline
1523 (see above). This ideally includes a bisection followed by a search for
1524 existing reports on the net; with the help of the subject and the two
1525 relevant commit-ids. If that doesn't turn up anything, write the report; CC
1526 or forward the report to the stable maintainers, the stable mailing list,
1527 and those who authored the change. Include the shortened commit-id if you
1528 found the change that causes it.*
1529
1530Sometimes you won't find anything in the previous step: the issue you face
1531might have never occurred in mainline, as it is caused by some change that is
1532incomplete or not correctly applied. To check this, install the first release
1533from version line you care about, e.g., if you care about 5.4.x, install 5.4.
1534
1535If the issue doesn't show itself there, it's a regression specific to the
1536particular version line. In that case you need to report it like an issue
1537happening in mainline, like the last few steps in the main section in the above
1538outline.
1539
1540One of them suggests doing a bisection, which you are strongly advised to do in
1541this case. After finding the culprit, search the net for existing reports
1542again: not only search for the exact subject and the commit-id (proper and
1543shortened to twelve characters) of the change, but also for the commit-id
1544(proper and shortened) mentioned as 'Upstream commit' in the commit message.
1545
1546Write the report; just keep a few specialties in mind: CC or forward the report
1547to the stable maintainers, the stable mailing list, which the :ref:`MAINTAINERS
1548<maintainers>` file mentions in the section "STABLE BRANCH". If you performed a
1549successful bisection, CC the author of the change and include its subject and
1550the shortened commit-id.
1551 1665
1552Ask for advice1666Ask for advice
1553~~~~~~~~~~~~~~1667~~~~~~~~~~~~~~
@@ -1560,8 +1674,7 @@ Ask for advice · 6 unmodified lines
1560If the previous three steps didn't get you closer to a solution there is only1674If the previous three steps didn't get you closer to a solution there is only
1561one option left: ask for advice. Do that in a mail you sent to the maintainers1675one option left: ask for advice. Do that in a mail you sent to the maintainers
1562for the subsystem where the issue seems to have its roots; CC the mailing list1676for the subsystem where the issue seems to have its roots; CC the mailing list
1563for the subsystem as well as the stable mailing list the :ref:`MAINTAINERS1677for the subsystem as well as the stable mailing list (stable@vger.kernel.org).
1564<maintainers>` file mention in the section "STABLE BRANCH".
1565 1678
1566 1679
1567Why some issues won't get any reaction or remain unfixed after being reported1680Why some issues won't get any reaction or remain unfixed after being reported
@@ -1629,3 +1742,13 @@ issues to the Linux kernel developers: the length and complexity of this · 61 unmodified lines
1629document and the implications between the lines illustrate that. But that's how1742document and the implications between the lines illustrate that. But that's how
1630it is for now. The main author of this text hopes documenting the state of the1743it is for now. The main author of this text hopes documenting the state of the
1631art will lay some groundwork to improve the situation over time.1744art will lay some groundwork to improve the situation over time.
1745
1746
1747..
1748 This text is maintained by Thorsten Leemhuis <linux@leemhuis.info>. If you
1749 spot a typo or small mistake, feel free to let him know directly and he'll
1750 fix it. You are free to do the same in a mostly informal way if you want
1751 to contribute changes to the text, but for copyright reasons please CC
1752 linux-doc@vger.kernel.org and "sign-off" your contribution as
1753 Documentation/process/submitting-patches.rst outlines in the section "Sign
1754 your work - the Developer's Certificate of Origin".
Documentation/admin-guide/sysrq.rst+2−2
@@ -90,8 +90,8 @@ Command Function · 89 unmodified lines
90``b`` Will immediately reboot the system without syncing or unmounting90``b`` Will immediately reboot the system without syncing or unmounting
91 your disks.91 your disks.
92 92
93``c`` Will perform a system crash by a NULL pointer dereference.93``c`` Will perform a system crash and a crashdump will be taken
94 A crashdump will be taken if configured.94 if configured.
95 95
96``d`` Shows all locks that are held.96``d`` Shows all locks that are held.
97 97
Documentation/arch.rst+26−0
@@ -0,0 +1,26 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3CPU Architectures
4=================
5
6These books provide programming details about architecture-specific
7implementation.
8
9.. toctree::
10 :maxdepth: 2
11
12 arm/index
13 arm64/index
14 ia64/index
15 m68k/index
16 mips/index
17 nios2/index
18 openrisc/index
19 parisc/index
20 powerpc/index
21 riscv/index
22 s390/index
23 sh/index
24 sparc/index
25 x86/index
26 xtensa/index
Documentation/arm/marvell.rst+80−79
@@ -18,12 +18,12 @@ Orion family · 17 unmodified lines
18 - 88F5181L18 - 88F5181L
19 - 88F518219 - 88F5182
20 20
21 - Datasheet: http://www.embeddedarm.com/documentation/third-party/MV88F5182-datasheet.pdf21 - Datasheet: https://web.archive.org/web/20210124231420/http://csclub.uwaterloo.ca/~board/ts7800/MV88F5182-datasheet.pdf
22 - Programmer's User Guide: http://www.embeddedarm.com/documentation/third-party/MV88F5182-opensource-manual.pdf22 - Programmer's User Guide: https://web.archive.org/web/20210124231536/http://csclub.uwaterloo.ca/~board/ts7800/MV88F5182-opensource-manual.pdf
23 - User Manual: http://www.embeddedarm.com/documentation/third-party/MV88F5182-usermanual.pdf23 - User Manual: https://web.archive.org/web/20210124231631/http://csclub.uwaterloo.ca/~board/ts7800/MV88F5182-usermanual.pdf
24 - 88F528124 - 88F5281
25 25
26 - Datasheet: http://www.ocmodshop.com/images/reviews/networking/qnap_ts409u/marvel_88f5281_data_sheet.pdf26 - Datasheet: https://web.archive.org/web/20131028144728/http://www.ocmodshop.com/images/reviews/networking/qnap_ts409u/marvel_88f5281_data_sheet.pdf
27 - 88F618327 - 88F6183
28 Core:28 Core:
29 Feroceon 88fr331 (88f51xx) or 88fr531-vd (88f52xx) ARMv5 compatible29 Feroceon 88fr331 (88f51xx) or 88fr531-vd (88f52xx) ARMv5 compatible
@@ -38,33 +38,33 @@ Kirkwood family · 8 unmodified lines
38 Flavors:38 Flavors:
39 - 88F6282 a.k.a Armada 30039 - 88F6282 a.k.a Armada 300
40 40
41 - Product Brief : http://www.marvell.com/embedded-processors/armada-300/assets/armada_310.pdf41 - Product Brief : https://web.archive.org/web/20111027032509/http://www.marvell.com/embedded-processors/armada-300/assets/armada_310.pdf
42 - 88F6283 a.k.a Armada 31042 - 88F6283 a.k.a Armada 310
43 43
44 - Product Brief : http://www.marvell.com/embedded-processors/armada-300/assets/armada_310.pdf44 - Product Brief : https://web.archive.org/web/20111027032509/http://www.marvell.com/embedded-processors/armada-300/assets/armada_310.pdf
45 - 88F619045 - 88F6190
46 46
47 - Product Brief : http://www.marvell.com/embedded-processors/kirkwood/assets/88F6190-003_WEB.pdf47 - Product Brief : https://web.archive.org/web/20130730072715/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6190-003_WEB.pdf
48 - Hardware Spec : http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf48 - Hardware Spec : https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
49 - Functional Spec: http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf49 - Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
50 - 88F619250 - 88F6192
51 51
52 - Product Brief : http://www.marvell.com/embedded-processors/kirkwood/assets/88F6192-003_ver1.pdf52 - Product Brief : https://web.archive.org/web/20131113121446/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6192-003_ver1.pdf
53 - Hardware Spec : http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf53 - Hardware Spec : https://web.archive.org/web/20121021182835/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F619x_OpenSource.pdf
54 - Functional Spec: http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf54 - Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
55 - 88F618255 - 88F6182
56 - 88F618056 - 88F6180
57 57
58 - Product Brief : http://www.marvell.com/embedded-processors/kirkwood/assets/88F6180-003_ver1.pdf58 - Product Brief : https://web.archive.org/web/20120616201621/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6180-003_ver1.pdf
59 - Hardware Spec : http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf59 - Hardware Spec : https://web.archive.org/web/20130730091654/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6180_OpenSource.pdf
60 - Functional Spec: http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf60 - Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
61 - 88F628161 - 88F6281
62 62
63 - Product Brief : http://www.marvell.com/embedded-processors/kirkwood/assets/88F6281-004_ver1.pdf63 - Product Brief : https://web.archive.org/web/20120131133709/http://www.marvell.com/embedded-processors/kirkwood/assets/88F6281-004_ver1.pdf
64 - Hardware Spec : http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf64 - Hardware Spec : https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
65 - Functional Spec: http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf65 - Functional Spec: https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
66 Homepage:66 Homepage:
67 http://www.marvell.com/embedded-processors/kirkwood/67 https://web.archive.org/web/20160513194943/http://www.marvell.com/embedded-processors/kirkwood/
68 Core:68 Core:
69 Feroceon 88fr131 ARMv5 compatible69 Feroceon 88fr131 ARMv5 compatible
70 Linux kernel mach directory:70 Linux kernel mach directory:
@@ -78,14 +78,15 @@ Discovery family · 7 unmodified lines
78 Flavors:78 Flavors:
79 - MV7810079 - MV78100
80 80
81 - Product Brief : http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV78100-003_WEB.pdf81 - Product Brief : https://web.archive.org/web/20120616194711/http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV78100-003_WEB.pdf
82 - Hardware Spec : http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV78100_OpenSource.pdf82 - Hardware Spec : https://web.archive.org/web/20141005120451/http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV78100_OpenSource.pdf
83 - Functional Spec: http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf83 - Functional Spec: https://web.archive.org/web/20111110081125/http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf
84 - MV7820084 - MV78200
85 85
86 - Product Brief : http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV78200-002_WEB.pdf86 - Product Brief : https://web.archive.org/web/20140801121623/http://www.marvell.com/embedded-processors/discovery-innovation/assets/MV78200-002_WEB.pdf
87 - Hardware Spec : http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV78200_OpenSource.pdf87 - Hardware Spec : https://web.archive.org/web/20141005120458/http://www.marvell.com/embedded-processors/discovery-innovation/assets/HW_MV78200_OpenSource.pdf
88 - Functional Spec: http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf88 - Functional Spec: https://web.archive.org/web/20111110081125/http://www.marvell.com/embedded-processors/discovery-innovation/assets/FS_MV76100_78100_78200_OpenSource.pdf
89
89 - MV7610090 - MV76100
90 91
91 Not supported by the Linux kernel.92 Not supported by the Linux kernel.
@@ -106,9 +107,9 @@ EBU Armada family · 14 unmodified lines
106 - 88F6707107 - 88F6707
107 - 88F6W11108 - 88F6W11
108 109
109 - Product Brief: http://www.marvell.com/embedded-processors/armada-300/assets/Marvell_ARMADA_370_SoC.pdf110 - Product Brief: https://web.archive.org/web/20121115063038/http://www.marvell.com/embedded-processors/armada-300/assets/Marvell_ARMADA_370_SoC.pdf
110 - Hardware Spec: http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA370-datasheet.pdf111 - Hardware Spec: https://web.archive.org/web/20140617183747/http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA370-datasheet.pdf
111 - Functional Spec: http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA370-FunctionalSpec-datasheet.pdf112 - Functional Spec: https://web.archive.org/web/20140617183701/http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA370-FunctionalSpec-datasheet.pdf
112 113
113 Core:114 Core:
114 Sheeva ARMv7 compatible PJ4B115 Sheeva ARMv7 compatible PJ4B
@@ -116,7 +117,7 @@ EBU Armada family · 1 unmodified line
116 Armada 375 Flavors:117 Armada 375 Flavors:
117 - 88F6720118 - 88F6720
118 119
119 - Product Brief: http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA_375_SoC-01_product_brief.pdf120 - Product Brief: https://web.archive.org/web/20131216023516/http://www.marvell.com/embedded-processors/armada-300/assets/ARMADA_375_SoC-01_product_brief.pdf
120 121
121 Core:122 Core:
122 ARM Cortex-A9123 ARM Cortex-A9
@@ -126,8 +127,8 @@ EBU Armada family · 3 unmodified lines
126 - 88F6820 Armada 385127 - 88F6820 Armada 385
127 - 88F6828 Armada 388128 - 88F6828 Armada 388
128 129
129 - Product infos: http://www.marvell.com/embedded-processors/armada-38x/130 - Product infos: https://web.archive.org/web/20181006144616/http://www.marvell.com/embedded-processors/armada-38x/
130 - Functional Spec: http://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-38x-functional-specifications-2015-11.pdf131 - Functional Spec: https://web.archive.org/web/20200420191927/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-38x-functional-specifications-2015-11.pdf
131 132
132 Core:133 Core:
133 ARM Cortex-A9134 ARM Cortex-A9
@@ -136,7 +137,7 @@ EBU Armada family · 2 unmodified lines
136 - 88F6920 Armada 390137 - 88F6920 Armada 390
137 - 88F6928 Armada 398138 - 88F6928 Armada 398
138 139
139 - Product infos: http://www.marvell.com/embedded-processors/armada-39x/140 - Product infos: https://web.archive.org/web/20181020222559/http://www.marvell.com/embedded-processors/armada-39x/
140 141
141 Core:142 Core:
142 ARM Cortex-A9143 ARM Cortex-A9
@@ -150,16 +151,16 @@ EBU Armada family · 7 unmodified lines
150 not to be confused with the non-SMP 78xx0 SoCs151 not to be confused with the non-SMP 78xx0 SoCs
151 152
152 Product Brief:153 Product Brief:
153 http://www.marvell.com/embedded-processors/armada-xp/assets/Marvell-ArmadaXP-SoC-product%20brief.pdf154 https://web.archive.org/web/20121021173528/http://www.marvell.com/embedded-processors/armada-xp/assets/Marvell-ArmadaXP-SoC-product%20brief.pdf
154 155
155 Functional Spec:156 Functional Spec:
156 http://www.marvell.com/embedded-processors/armada-xp/assets/ARMADA-XP-Functional-SpecDatasheet.pdf157 https://web.archive.org/web/20180829171131/http://www.marvell.com/embedded-processors/armada-xp/assets/ARMADA-XP-Functional-SpecDatasheet.pdf
157 158
158 - Hardware Specs:159 - Hardware Specs:
159 160
160 - http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78230_OS.PDF161 - https://web.archive.org/web/20141127013651/http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78230_OS.PDF
161 - http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78260_OS.PDF162 - https://web.archive.org/web/20141222000224/http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78260_OS.PDF
162 - http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78460_OS.PDF163 - https://web.archive.org/web/20141222000230/http://www.marvell.com/embedded-processors/armada-xp/assets/HW_MV78460_OS.PDF
163 164
164 Core:165 Core:
165 Sheeva ARMv7 compatible Dual-core or Quad-core PJ4B-MP166 Sheeva ARMv7 compatible Dual-core or Quad-core PJ4B-MP
@@ -180,13 +181,13 @@ EBU Armada family ARMv8 · 14 unmodified lines
180 ARM Cortex A53 (ARMv8)181 ARM Cortex A53 (ARMv8)
181 182
182 Homepage:183 Homepage:
183 http://www.marvell.com/embedded-processors/armada-3700/184 https://web.archive.org/web/20181103003602/http://www.marvell.com/embedded-processors/armada-3700/
184 185
185 Product Brief:186 Product Brief:
186 http://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-37xx-product-brief-2016-01.pdf187 https://web.archive.org/web/20210121194810/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-37xx-product-brief-2016-01.pdf
187 188
188 Hardware Spec:189 Hardware Spec:
189 http://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-37xx-hardware-specifications-2019-09.pdf190 https://web.archive.org/web/20210202162011/http://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-37xx-hardware-specifications-2019-09.pdf
190 191
191 Device tree files:192 Device tree files:
192 arch/arm64/boot/dts/marvell/armada-37*193 arch/arm64/boot/dts/marvell/armada-37*
@@ -198,11 +199,11 @@ EBU Armada family ARMv8 · 5 unmodified lines
198 Core: ARM Cortex A72199 Core: ARM Cortex A72
199 200
200 Homepage:201 Homepage:
201 http://www.marvell.com/embedded-processors/armada-70xx/202 https://web.archive.org/web/20181020222606/http://www.marvell.com/embedded-processors/armada-70xx/
202 203
203 Product Brief:204 Product Brief:
204 - http://www.marvell.com/embedded-processors/assets/Armada7020PB-Jan2016.pdf205 - https://web.archive.org/web/20161010105541/http://www.marvell.com/embedded-processors/assets/Armada7020PB-Jan2016.pdf
205 - http://www.marvell.com/embedded-processors/assets/Armada7040PB-Jan2016.pdf206 - https://web.archive.org/web/20160928154533/http://www.marvell.com/embedded-processors/assets/Armada7040PB-Jan2016.pdf
206 207
207 Device tree files:208 Device tree files:
208 arch/arm64/boot/dts/marvell/armada-70*209 arch/arm64/boot/dts/marvell/armada-70*
@@ -214,11 +215,11 @@ EBU Armada family ARMv8 · 5 unmodified lines
214 ARM Cortex A72215 ARM Cortex A72
215 216
216 Homepage:217 Homepage:
217 http://www.marvell.com/embedded-processors/armada-80xx/218 https://web.archive.org/web/20181022004830/http://www.marvell.com/embedded-processors/armada-80xx/
218 219
219 Product Brief:220 Product Brief:
220 - http://www.marvell.com/embedded-processors/assets/Armada8020PB-Jan2016.pdf221 - https://web.archive.org/web/20210124233728/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-8020-product-brief-2017-12.pdf
221 - http://www.marvell.com/embedded-processors/assets/Armada8040PB-Jan2016.pdf222 - https://web.archive.org/web/20161010105532/http://www.marvell.com/embedded-processors/assets/Armada8040PB-Jan2016.pdf
222 223
223 Device tree files:224 Device tree files:
224 arch/arm64/boot/dts/marvell/armada-80*225 arch/arm64/boot/dts/marvell/armada-80*
@@ -233,10 +234,10 @@ Avanta family · 8 unmodified lines
233 - 88F6560234 - 88F6560
234 235
235 Homepage:236 Homepage:
236 http://www.marvell.com/broadband/237 https://web.archive.org/web/20181005145041/http://www.marvell.com/broadband/
237 238
238 Product Brief:239 Product Brief:
239 http://www.marvell.com/broadband/assets/Marvell_Avanta_88F6510_305_060-001_product_brief.pdf240 https://web.archive.org/web/20180829171057/http://www.marvell.com/broadband/assets/Marvell_Avanta_88F6510_305_060-001_product_brief.pdf
240 241
241 No public datasheet available.242 No public datasheet available.
242 243
@@ -255,7 +256,7 @@ Storage family · 12 unmodified lines
255 - 88RC1580256 - 88RC1580
256 257
257 Product infos:258 Product infos:
258 http://www.marvell.com/storage/armada-sp/259 https://web.archive.org/web/20191129073953/http://www.marvell.com/storage/armada-sp/
259 260
260 Core:261 Core:
261 Sheeva ARMv7 comatible Quad-core PJ4C262 Sheeva ARMv7 comatible Quad-core PJ4C
@@ -269,16 +270,16 @@ Dove family (application processor) · 7 unmodified lines
269 - 88AP510 a.k.a Armada 510270 - 88AP510 a.k.a Armada 510
270 271
271 Product Brief:272 Product Brief:
272 http://www.marvell.com/application-processors/armada-500/assets/Marvell_Armada510_SoC.pdf273 https://web.archive.org/web/20111102020643/http://www.marvell.com/application-processors/armada-500/assets/Marvell_Armada510_SoC.pdf
273 274
274 Hardware Spec:275 Hardware Spec:
275 http://www.marvell.com/application-processors/armada-500/assets/Armada-510-Hardware-Spec.pdf276 https://web.archive.org/web/20160428160231/http://www.marvell.com/application-processors/armada-500/assets/Armada-510-Hardware-Spec.pdf
276 277
277 Functional Spec:278 Functional Spec:
278 http://www.marvell.com/application-processors/armada-500/assets/Armada-510-Functional-Spec.pdf279 https://web.archive.org/web/20120130172443/http://www.marvell.com/application-processors/armada-500/assets/Armada-510-Functional-Spec.pdf
279 280
280 Homepage:281 Homepage:
281 http://www.marvell.com/application-processors/armada-500/282 https://web.archive.org/web/20160822232651/http://www.marvell.com/application-processors/armada-500/
282 283
283 Core:284 Core:
284 ARMv7 compatible285 ARMv7 compatible
@@ -295,22 +296,22 @@ PXA 2xx/3xx/93x/95x family · 10 unmodified lines
295 - Application processor only296 - Application processor only
296 - Core: ARMv5 XScale1 core297 - Core: ARMv5 XScale1 core
297 - PXA270, PXA271, PXA272298 - PXA270, PXA271, PXA272
298 - Product Brief : http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_pb.pdf299 - Product Brief : https://web.archive.org/web/20150927135510/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_pb.pdf
299 - Design guide : http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_design_guide.pdf300 - Design guide : https://web.archive.org/web/20120111181937/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_design_guide.pdf
300 - Developers manual : http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_dev_man.pdf301 - Developers manual : https://web.archive.org/web/20150927164805/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_dev_man.pdf
301 - Specification : http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_emts.pdf302 - Specification : https://web.archive.org/web/20140211221535/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_emts.pdf
302 - Specification update : http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_spec_update.pdf303 - Specification update : https://web.archive.org/web/20120111104906/http://www.marvell.com/application-processors/pxa-family/assets/pxa_27x_spec_update.pdf
303 - Application processor only304 - Application processor only
304 - Core: ARMv5 XScale2 core305 - Core: ARMv5 XScale2 core
305 - PXA300, PXA310, PXA320306 - PXA300, PXA310, PXA320
306 - PXA 300 Product Brief : http://www.marvell.com/application-processors/pxa-family/assets/PXA300_PB_R4.pdf307 - PXA 300 Product Brief : https://web.archive.org/web/20120111121203/http://www.marvell.com/application-processors/pxa-family/assets/PXA300_PB_R4.pdf
307 - PXA 310 Product Brief : http://www.marvell.com/application-processors/pxa-family/assets/PXA310_PB_R4.pdf308 - PXA 310 Product Brief : https://web.archive.org/web/20120111104515/http://www.marvell.com/application-processors/pxa-family/assets/PXA310_PB_R4.pdf
308 - PXA 320 Product Brief : http://www.marvell.com/application-processors/pxa-family/assets/PXA320_PB_R4.pdf309 - PXA 320 Product Brief : https://web.archive.org/web/20121021182826/http://www.marvell.com/application-processors/pxa-family/assets/PXA320_PB_R4.pdf
309 - Design guide : http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Design_Guide.pdf310 - Design guide : https://web.archive.org/web/20130727144625/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Design_Guide.pdf
310 - Developers manual : http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Developers_Manual.zip311 - Developers manual : https://web.archive.org/web/20130727144605/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Developers_Manual.zip
311 - Specifications : http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_EMTS.pdf312 - Specifications : https://web.archive.org/web/20130727144559/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_EMTS.pdf
312 - Specification Update : http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Spec_Update.zip313 - Specification Update : https://web.archive.org/web/20150927183411/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_Spec_Update.zip
313 - Reference Manual : http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_TavorP_BootROM_Ref_Manual.pdf314 - Reference Manual : https://web.archive.org/web/20120111103844/http://www.marvell.com/application-processors/pxa-family/assets/PXA3xx_TavorP_BootROM_Ref_Manual.pdf
314 - Application processor only315 - Application processor only
315 - Core: ARMv5 XScale3 core316 - Core: ARMv5 XScale3 core
316 - PXA930, PXA935317 - PXA930, PXA935
@@ -341,26 +342,26 @@ MMP/MMP2/MMP3 family (communication processor) · 24 unmodified lines
341 342
342 Flavors:343 Flavors:
343 - PXA168, a.k.a Armada 168344 - PXA168, a.k.a Armada 168
344 - Homepage : http://www.marvell.com/application-processors/armada-100/armada-168.jsp345 - Homepage : https://web.archive.org/web/20110926014256/http://www.marvell.com/application-processors/armada-100/armada-168.jsp
345 - Product brief : http://www.marvell.com/application-processors/armada-100/assets/pxa_168_pb.pdf346 - Product brief : https://web.archive.org/web/20111102030100/http://www.marvell.com/application-processors/armada-100/assets/pxa_168_pb.pdf
346 - Hardware manual : http://www.marvell.com/application-processors/armada-100/assets/armada_16x_datasheet.pdf347 - Hardware manual : https://web.archive.org/web/20160428165359/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_datasheet.pdf
347 - Software manual : http://www.marvell.com/application-processors/armada-100/assets/armada_16x_software_manual.pdf348 - Software manual : https://web.archive.org/web/20160428154454/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_software_manual.pdf
348 - Specification update : http://www.marvell.com/application-processors/armada-100/assets/ARMADA16x_Spec_update.pdf349 - Specification update : https://web.archive.org/web/20150927160338/http://www.marvell.com/application-processors/armada-100/assets/ARMADA16x_Spec_update.pdf
349 - Boot ROM manual : http://www.marvell.com/application-processors/armada-100/assets/armada_16x_ref_manual.pdf350 - Boot ROM manual : https://web.archive.org/web/20130727205559/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_ref_manual.pdf
350 - App node package : http://www.marvell.com/application-processors/armada-100/assets/armada_16x_app_note_package.pdf351 - App node package : https://web.archive.org/web/20141005090706/http://www.marvell.com/application-processors/armada-100/assets/armada_16x_app_note_package.pdf
351 - Application processor only352 - Application processor only
352 - Core: ARMv5 compatible Marvell PJ1 88sv331 (Mohawk)353 - Core: ARMv5 compatible Marvell PJ1 88sv331 (Mohawk)
353 - PXA910/PXA920354 - PXA910/PXA920
354 - Homepage : http://www.marvell.com/communication-processors/pxa910/355 - Homepage : https://web.archive.org/web/20150928121236/http://www.marvell.com/communication-processors/pxa910/
355 - Product Brief : http://www.marvell.com/communication-processors/pxa910/assets/Marvell_PXA910_Platform-001_PB_final.pdf356 - Product Brief : https://archive.org/download/marvell-pxa910-pb/Marvell_PXA910_Platform-001_PB.pdf
356 - Application processor with Communication processor357 - Application processor with Communication processor
357 - Core: ARMv5 compatible Marvell PJ1 88sv331 (Mohawk)358 - Core: ARMv5 compatible Marvell PJ1 88sv331 (Mohawk)
358 - PXA688, a.k.a. MMP2, a.k.a Armada 610359 - PXA688, a.k.a. MMP2, a.k.a Armada 610 (OLPC XO-1.75)
359 - Product Brief : http://www.marvell.com/application-processors/armada-600/assets/armada610_pb.pdf360 - Product Brief : https://web.archive.org/web/20111102023255/http://www.marvell.com/application-processors/armada-600/assets/armada610_pb.pdf
360 - Application processor only361 - Application processor only
361 - Core: ARMv7 compatible Sheeva PJ4 88sv581x core362 - Core: ARMv7 compatible Sheeva PJ4 88sv581x core
362 - PXA2128, a.k.a. MMP3 (OLPC XO4, Linux support not upstream)363 - PXA2128, a.k.a. MMP3, a.k.a Armada 620 (OLPC XO-4)
363 - Product Brief : http://www.marvell.com/application-processors/armada/pxa2128/assets/Marvell-ARMADA-PXA2128-SoC-PB.pdf364 - Product Brief : https://web.archive.org/web/20120824055155/http://www.marvell.com/application-processors/armada/pxa2128/assets/Marvell-ARMADA-PXA2128-SoC-PB.pdf
364 - Application processor only365 - Application processor only
365 - Core: Dual-core ARMv7 compatible Sheeva PJ4C core366 - Core: Dual-core ARMv7 compatible Sheeva PJ4C core
366 - PXA960/PXA968/PXA978 (Linux support not upstream)367 - PXA960/PXA968/PXA978 (Linux support not upstream)
Documentation/arm/uefi.rst+7−0
@@ -64,4 +64,11 @@ linux,uefi-mmap-desc-size 32-bit Size in bytes of each entry in the UEFI · 63 unmodified lines
64 memory map.64 memory map.
65 65
66linux,uefi-mmap-desc-ver 32-bit Version of the mmap descriptor format.66linux,uefi-mmap-desc-ver 32-bit Version of the mmap descriptor format.
67
68linux,initrd-start 64-bit Physical start address of an initrd
69
70linux,initrd-end 64-bit Physical end address of an initrd
71
72kaslr-seed 64-bit Entropy used to randomize the kernel image
73 base address location.
67========================== ====== ===========================================74========================== ====== ===========================================
Documentation/conf.py+19−12
@@ -331,27 +331,34 @@ htmlhelp_basename = 'TheLinuxKerneldoc' · 330 unmodified lines
331# -- Options for LaTeX output ---------------------------------------------331# -- Options for LaTeX output ---------------------------------------------
332 332
333latex_elements = {333latex_elements = {
334# The paper size ('letterpaper' or 'a4paper').334 # The paper size ('letterpaper' or 'a4paper').
335'papersize': 'a4paper',335 'papersize': 'a4paper',
336 336
337# The font size ('10pt', '11pt' or '12pt').337 # The font size ('10pt', '11pt' or '12pt').
338'pointsize': '11pt',338 'pointsize': '11pt',
339 339
340# Latex figure (float) alignment340 # Latex figure (float) alignment
341#'figure_align': 'htbp',341 #'figure_align': 'htbp',
342 342
343# Don't mangle with UTF-8 chars343 # Don't mangle with UTF-8 chars
344'inputenc': '',344 'inputenc': '',
345'utf8extra': '',345 'utf8extra': '',
346 346
347# Additional stuff for the LaTeX preamble.347 # Set document margins
348 'sphinxsetup': '''
349 hmargin=0.5in, vmargin=1in,
350 parsedliteralwraps=true,
351 verbatimhintsturnover=false,
352 ''',
353
354 # Additional stuff for the LaTeX preamble.
348 'preamble': '''355 'preamble': '''
349 % Use some font with UTF-8 support with XeLaTeX356 % Use some font with UTF-8 support with XeLaTeX
350 \\usepackage{fontspec}357 \\usepackage{fontspec}
351 \\setsansfont{DejaVu Sans}358 \\setsansfont{DejaVu Sans}
352 \\setromanfont{DejaVu Serif}359 \\setromanfont{DejaVu Serif}
353 \\setmonofont{DejaVu Sans Mono}360 \\setmonofont{DejaVu Sans Mono}
354 '''361 ''',
355}362}
356 363
357# At least one book (translations) may have Asian characters364# At least one book (translations) may have Asian characters
Documentation/core-api/rbtree.rst+1−1
@@ -201,7 +201,7 @@ search trees, such as for traversals or users relying on a the particular · 200 unmodified lines
201order for their own logic. To this end, users can use 'struct rb_root_cached'201order for their own logic. To this end, users can use 'struct rb_root_cached'
202to optimize O(logN) rb_first() calls to a simple pointer fetch avoiding202to optimize O(logN) rb_first() calls to a simple pointer fetch avoiding
203potentially expensive tree iterations. This is done at negligible runtime203potentially expensive tree iterations. This is done at negligible runtime
204overhead for maintanence; albeit larger memory footprint.204overhead for maintenance; albeit larger memory footprint.
205 205
206Similar to the rb_root structure, cached rbtrees are initialized to be206Similar to the rb_root structure, cached rbtrees are initialized to be
207empty via::207empty via::
Documentation/dev-tools/checkpatch.rst+755−0
@@ -0,0 +1,755 @@
1.. SPDX-License-Identifier: GPL-2.0-only
2
3==========
4Checkpatch
5==========
6
7Checkpatch (scripts/checkpatch.pl) is a perl script which checks for trivial
8style violations in patches and optionally corrects them. Checkpatch can
9also be run on file contexts and without the kernel tree.
10
11Checkpatch is not always right. Your judgement takes precedence over checkpatch
12messages. If your code looks better with the violations, then its probably
13best left alone.
14
15
16Options
17=======
18
19This section will describe the options checkpatch can be run with.
20
21Usage::
22
23 ./scripts/checkpatch.pl [OPTION]... [FILE]...
24
25Available options:
26
27 - -q, --quiet
28
29 Enable quiet mode.
30
31 - -v, --verbose
32 Enable verbose mode. Additional verbose test descriptions are output
33 so as to provide information on why that particular message is shown.
34
35 - --no-tree
36
37 Run checkpatch without the kernel tree.
38
39 - --no-signoff
40
41 Disable the 'Signed-off-by' line check. The sign-off is a simple line at
42 the end of the explanation for the patch, which certifies that you wrote it
43 or otherwise have the right to pass it on as an open-source patch.
44
45 Example::
46
47 Signed-off-by: Random J Developer <random@developer.example.org>
48
49 Setting this flag effectively stops a message for a missing signed-off-by
50 line in a patch context.
51
52 - --patch
53
54 Treat FILE as a patch. This is the default option and need not be
55 explicitly specified.
56
57 - --emacs
58
59 Set output to emacs compile window format. This allows emacs users to jump
60 from the error in the compile window directly to the offending line in the
61 patch.
62
63 - --terse
64
65 Output only one line per report.
66
67 - --showfile
68
69 Show the diffed file position instead of the input file position.
70
71 - -g, --git
72
73 Treat FILE as a single commit or a git revision range.
74
75 Single commit with:
76
77 - <rev>
78 - <rev>^
79 - <rev>~n
80
81 Multiple commits with:
82
83 - <rev1>..<rev2>
84 - <rev1>...<rev2>
85 - <rev>-<count>
86
87 - -f, --file
88
89 Treat FILE as a regular source file. This option must be used when running
90 checkpatch on source files in the kernel.
91
92 - --subjective, --strict
93
94 Enable stricter tests in checkpatch. By default the tests emitted as CHECK
95 do not activate by default. Use this flag to activate the CHECK tests.
96
97 - --list-types
98
99 Every message emitted by checkpatch has an associated TYPE. Add this flag
100 to display all the types in checkpatch.
101
102 Note that when this flag is active, checkpatch does not read the input FILE,
103 and no message is emitted. Only a list of types in checkpatch is output.
104
105 - --types TYPE(,TYPE2...)
106
107 Only display messages with the given types.
108
109 Example::
110
111 ./scripts/checkpatch.pl mypatch.patch --types EMAIL_SUBJECT,BRACES
112
113 - --ignore TYPE(,TYPE2...)
114
115 Checkpatch will not emit messages for the specified types.
116
117 Example::
118
119 ./scripts/checkpatch.pl mypatch.patch --ignore EMAIL_SUBJECT,BRACES
120
121 - --show-types
122
123 By default checkpatch doesn't display the type associated with the messages.
124 Set this flag to show the message type in the output.
125
126 - --max-line-length=n
127
128 Set the max line length (default 100). If a line exceeds the specified
129 length, a LONG_LINE message is emitted.
130
131
132 The message level is different for patch and file contexts. For patches,
133 a WARNING is emitted. While a milder CHECK is emitted for files. So for
134 file contexts, the --strict flag must also be enabled.
135
136 - --min-conf-desc-length=n
137
138 Set the Kconfig entry minimum description length, if shorter, warn.
139
140 - --tab-size=n
141
142 Set the number of spaces for tab (default 8).
143
144 - --root=PATH
145
146 PATH to the kernel tree root.
147
148 This option must be specified when invoking checkpatch from outside
149 the kernel root.
150
151 - --no-summary
152
153 Suppress the per file summary.
154
155 - --mailback
156
157 Only produce a report in case of Warnings or Errors. Milder Checks are
158 excluded from this.
159
160 - --summary-file
161
162 Include the filename in summary.
163
164 - --debug KEY=[0|1]
165
166 Turn on/off debugging of KEY, where KEY is one of 'values', 'possible',
167 'type', and 'attr' (default is all off).
168
169 - --fix
170
171 This is an EXPERIMENTAL feature. If correctable errors exists, a file
172 <inputfile>.EXPERIMENTAL-checkpatch-fixes is created which has the
173 automatically fixable errors corrected.
174
175 - --fix-inplace
176
177 EXPERIMENTAL - Similar to --fix but input file is overwritten with fixes.
178
179 DO NOT USE this flag unless you are absolutely sure and you have a backup
180 in place.
181
182 - --ignore-perl-version
183
184 Override checking of perl version. Runtime errors maybe encountered after
185 enabling this flag if the perl version does not meet the minimum specified.
186
187 - --codespell
188
189 Use the codespell dictionary for checking spelling errors.
190
191 - --codespellfile
192
193 Use the specified codespell file.
194 Default is '/usr/share/codespell/dictionary.txt'.
195
196 - --typedefsfile
197
198 Read additional types from this file.
199
200 - --color[=WHEN]
201
202 Use colors 'always', 'never', or only when output is a terminal ('auto').
203 Default is 'auto'.
204
205 - --kconfig-prefix=WORD
206
207 Use WORD as a prefix for Kconfig symbols (default is `CONFIG_`).
208
209 - -h, --help, --version
210
211 Display the help text.
212
213Message Levels
214==============
215
216Messages in checkpatch are divided into three levels. The levels of messages
217in checkpatch denote the severity of the error. They are:
218
219 - ERROR
220
221 This is the most strict level. Messages of type ERROR must be taken
222 seriously as they denote things that are very likely to be wrong.
223
224 - WARNING
225
226 This is the next stricter level. Messages of type WARNING requires a
227 more careful review. But it is milder than an ERROR.
228
229 - CHECK
230
231 This is the mildest level. These are things which may require some thought.
232
233Type Descriptions
234=================
235
236This section contains a description of all the message types in checkpatch.
237
238.. Types in this section are also parsed by checkpatch.
239.. The types are grouped into subsections based on use.
240
241
242Allocation style
243----------------
244
245 **ALLOC_ARRAY_ARGS**
246 The first argument for kcalloc or kmalloc_array should be the
247 number of elements. sizeof() as the first argument is generally
248 wrong.
249 See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
250
251 **ALLOC_SIZEOF_STRUCT**
252 The allocation style is bad. In general for family of
253 allocation functions using sizeof() to get memory size,
254 constructs like::
255
256 p = alloc(sizeof(struct foo), ...)
257
258 should be::
259
260 p = alloc(sizeof(*p), ...)
261
262 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#allocating-memory
263
264 **ALLOC_WITH_MULTIPLY**
265 Prefer kmalloc_array/kcalloc over kmalloc/kzalloc with a
266 sizeof multiply.
267 See: https://www.kernel.org/doc/html/latest/core-api/memory-allocation.html
268
269
270API usage
271---------
272
273 **ARCH_DEFINES**
274 Architecture specific defines should be avoided wherever
275 possible.
276
277 **ARCH_INCLUDE_LINUX**
278 Whenever asm/file.h is included and linux/file.h exists, a
279 conversion can be made when linux/file.h includes asm/file.h.
280 However this is not always the case (See signal.h).
281 This message type is emitted only for includes from arch/.
282
283 **AVOID_BUG**
284 BUG() or BUG_ON() should be avoided totally.
285 Use WARN() and WARN_ON() instead, and handle the "impossible"
286 error condition as gracefully as possible.
287 See: https://www.kernel.org/doc/html/latest/process/deprecated.html#bug-and-bug-on
288
289 **CONSIDER_KSTRTO**
290 The simple_strtol(), simple_strtoll(), simple_strtoul(), and
291 simple_strtoull() functions explicitly ignore overflows, which
292 may lead to unexpected results in callers. The respective kstrtol(),
293 kstrtoll(), kstrtoul(), and kstrtoull() functions tend to be the
294 correct replacements.
295 See: https://www.kernel.org/doc/html/latest/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull
296
297 **LOCKDEP**
298 The lockdep_no_validate class was added as a temporary measure to
299 prevent warnings on conversion of device->sem to device->mutex.
300 It should not be used for any other purpose.
301 See: https://lore.kernel.org/lkml/1268959062.9440.467.camel@laptop/
302
303 **MALFORMED_INCLUDE**
304 The #include statement has a malformed path. This has happened
305 because the author has included a double slash "//" in the pathname
306 accidentally.
307
308 **USE_LOCKDEP**
309 lockdep_assert_held() annotations should be preferred over
310 assertions based on spin_is_locked()
311 See: https://www.kernel.org/doc/html/latest/locking/lockdep-design.html#annotations
312
313 **UAPI_INCLUDE**
314 No #include statements in include/uapi should use a uapi/ path.
315
316
317Comment style
318-------------
319
320 **BLOCK_COMMENT_STYLE**
321 The comment style is incorrect. The preferred style for multi-
322 line comments is::
323
324 /*
325 * This is the preferred style
326 * for multi line comments.
327 */
328
329 The networking comment style is a bit different, with the first line
330 not empty like the former::
331
332 /* This is the preferred comment style
333 * for files in net/ and drivers/net/
334 */
335
336 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#commenting
337
338 **C99_COMMENTS**
339 C99 style single line comments (//) should not be used.
340 Prefer the block comment style instead.
341 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#commenting
342
343
344Commit message
345--------------
346
347 **BAD_SIGN_OFF**
348 The signed-off-by line does not fall in line with the standards
349 specified by the community.
350 See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#developer-s-certificate-of-origin-1-1
351
352 **BAD_STABLE_ADDRESS_STYLE**
353 The email format for stable is incorrect.
354 Some valid options for stable address are::
355
356 1. stable@vger.kernel.org
357 2. stable@kernel.org
358
359 For adding version info, the following comment style should be used::
360
361 stable@vger.kernel.org # version info
362
363 **COMMIT_COMMENT_SYMBOL**
364 Commit log lines starting with a '#' are ignored by git as
365 comments. To solve this problem addition of a single space
366 infront of the log line is enough.
367
368 **COMMIT_MESSAGE**
369 The patch is missing a commit description. A brief
370 description of the changes made by the patch should be added.
371 See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
372
373 **MISSING_SIGN_OFF**
374 The patch is missing a Signed-off-by line. A signed-off-by
375 line should be added according to Developer's certificate of
376 Origin.
377 See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
378
379 **NO_AUTHOR_SIGN_OFF**
380 The author of the patch has not signed off the patch. It is
381 required that a simple sign off line should be present at the
382 end of explanation of the patch to denote that the author has
383 written it or otherwise has the rights to pass it on as an open
384 source patch.
385 See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
386
387 **DIFF_IN_COMMIT_MSG**
388 Avoid having diff content in commit message.
389 This causes problems when one tries to apply a file containing both
390 the changelog and the diff because patch(1) tries to apply the diff
391 which it found in the changelog.
392 See: https://lore.kernel.org/lkml/20150611134006.9df79a893e3636019ad2759e@linux-foundation.org/
393
394 **GERRIT_CHANGE_ID**
395 To be picked up by gerrit, the footer of the commit message might
396 have a Change-Id like::
397
398 Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
399 Signed-off-by: A. U. Thor <author@example.com>
400
401 The Change-Id line must be removed before submitting.
402
403 **GIT_COMMIT_ID**
404 The proper way to reference a commit id is:
405 commit <12+ chars of sha1> ("<title line>")
406
407 An example may be::
408
409 Commit e21d2170f36602ae2708 ("video: remove unnecessary
410 platform_set_drvdata()") removed the unnecessary
411 platform_set_drvdata(), but left the variable "dev" unused,
412 delete it.
413
414 See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
415
416
417Comparison style
418----------------
419
420 **ASSIGN_IN_IF**
421 Do not use assignments in if condition.
422 Example::
423
424 if ((foo = bar(...)) < BAZ) {
425
426 should be written as::
427
428 foo = bar(...);
429 if (foo < BAZ) {
430
431 **BOOL_COMPARISON**
432 Comparisons of A to true and false are better written
433 as A and !A.
434 See: https://lore.kernel.org/lkml/1365563834.27174.12.camel@joe-AO722/
435
436 **COMPARISON_TO_NULL**
437 Comparisons to NULL in the form (foo == NULL) or (foo != NULL)
438 are better written as (!foo) and (foo).
439
440 **CONSTANT_COMPARISON**
441 Comparisons with a constant or upper case identifier on the left
442 side of the test should be avoided.
443
444
445Macros, Attributes and Symbols
446------------------------------
447
448 **ARRAY_SIZE**
449 The ARRAY_SIZE(foo) macro should be preferred over
450 sizeof(foo)/sizeof(foo[0]) for finding number of elements in an
451 array.
452
453 The macro is defined in include/linux/kernel.h::
454
455 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
456
457 **AVOID_EXTERNS**
458 Function prototypes don't need to be declared extern in .h
459 files. It's assumed by the compiler and is unnecessary.
460
461 **AVOID_L_PREFIX**
462 Local symbol names that are prefixed with `.L` should be avoided,
463 as this has special meaning for the assembler; a symbol entry will
464 not be emitted into the symbol table. This can prevent `objtool`
465 from generating correct unwind info.
466
467 Symbols with STB_LOCAL binding may still be used, and `.L` prefixed
468 local symbol names are still generally usable within a function,
469 but `.L` prefixed local symbol names should not be used to denote
470 the beginning or end of code regions via
471 `SYM_CODE_START_LOCAL`/`SYM_CODE_END`
472
473 **BIT_MACRO**
474 Defines like: 1 << <digit> could be BIT(digit).
475 The BIT() macro is defined in include/linux/bitops.h::
476
477 #define BIT(nr) (1UL << (nr))
478
479 **CONST_READ_MOSTLY**
480 When a variable is tagged with the __read_mostly annotation, it is a
481 signal to the compiler that accesses to the variable will be mostly
482 reads and rarely(but NOT never) a write.
483
484 const __read_mostly does not make any sense as const data is already
485 read-only. The __read_mostly annotation thus should be removed.
486
487 **DATE_TIME**
488 It is generally desirable that building the same source code with
489 the same set of tools is reproducible, i.e. the output is always
490 exactly the same.
491
492 The kernel does *not* use the ``__DATE__`` and ``__TIME__`` macros,
493 and enables warnings if they are used as they can lead to
494 non-deterministic builds.
495 See: https://www.kernel.org/doc/html/latest/kbuild/reproducible-builds.html#timestamps
496
497 **DEFINE_ARCH_HAS**
498 The ARCH_HAS_xyz and ARCH_HAVE_xyz patterns are wrong.
499
500 For big conceptual features use Kconfig symbols instead. And for
501 smaller things where we have compatibility fallback functions but
502 want architectures able to override them with optimized ones, we
503 should either use weak functions (appropriate for some cases), or
504 the symbol that protects them should be the same symbol we use.
505 See: https://lore.kernel.org/lkml/CA+55aFycQ9XJvEOsiM3txHL5bjUc8CeKWJNR_H+MiicaddB42Q@mail.gmail.com/
506
507 **INIT_ATTRIBUTE**
508 Const init definitions should use __initconst instead of
509 __initdata.
510
511 Similarly init definitions without const require a separate
512 use of const.
513
514 **INLINE_LOCATION**
515 The inline keyword should sit between storage class and type.
516
517 For example, the following segment::
518
519 inline static int example_function(void)
520 {
521 ...
522 }
523
524 should be::
525
526 static inline int example_function(void)
527 {
528 ...
529 }
530
531 **MULTISTATEMENT_MACRO_USE_DO_WHILE**
532 Macros with multiple statements should be enclosed in a
533 do - while block. Same should also be the case for macros
534 starting with `if` to avoid logic defects::
535
536 #define macrofun(a, b, c) \
537 do { \
538 if (a == 5) \
539 do_this(b, c); \
540 } while (0)
541
542 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl
543
544 **WEAK_DECLARATION**
545 Using weak declarations like __attribute__((weak)) or __weak
546 can have unintended link defects. Avoid using them.
547
548
549Functions and Variables
550-----------------------
551
552 **CAMELCASE**
553 Avoid CamelCase Identifiers.
554 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
555
556 **FUNCTION_WITHOUT_ARGS**
557 Function declarations without arguments like::
558
559 int foo()
560
561 should be::
562
563 int foo(void)
564
565 **GLOBAL_INITIALISERS**
566 Global variables should not be initialized explicitly to
567 0 (or NULL, false, etc.). Your compiler (or rather your
568 loader, which is responsible for zeroing out the relevant
569 sections) automatically does it for you.
570
571 **INITIALISED_STATIC**
572 Static variables should not be initialized explicitly to zero.
573 Your compiler (or rather your loader) automatically does
574 it for you.
575
576 **RETURN_PARENTHESES**
577 return is not a function and as such doesn't need parentheses::
578
579 return (bar);
580
581 can simply be::
582
583 return bar;
584
585
586Spacing and Brackets
587--------------------
588
589 **ASSIGNMENT_CONTINUATIONS**
590 Assignment operators should not be written at the start of a
591 line but should follow the operand at the previous line.
592
593 **BRACES**
594 The placement of braces is stylistically incorrect.
595 The preferred way is to put the opening brace last on the line,
596 and put the closing brace first::
597
598 if (x is true) {
599 we do y
600 }
601
602 This applies for all non-functional blocks.
603 However, there is one special case, namely functions: they have the
604 opening brace at the beginning of the next line, thus::
605
606 int function(int x)
607 {
608 body of function
609 }
610
611 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
612
613 **BRACKET_SPACE**
614 Whitespace before opening bracket '[' is prohibited.
615 There are some exceptions:
616
617 1. With a type on the left::
618
619 ;int [] a;
620
621 2. At the beginning of a line for slice initialisers::
622
623 [0...10] = 5,
624
625 3. Inside a curly brace::
626
627 = { [0...10] = 5 }
628
629 **CODE_INDENT**
630 Code indent should use tabs instead of spaces.
631 Outside of comments, documentation and Kconfig,
632 spaces are never used for indentation.
633 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#indentation
634
635 **CONCATENATED_STRING**
636 Concatenated elements should have a space in between.
637 Example::
638
639 printk(KERN_INFO"bar");
640
641 should be::
642
643 printk(KERN_INFO "bar");
644
645 **ELSE_AFTER_BRACE**
646 `else {` should follow the closing block `}` on the same line.
647 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
648
649 **LINE_SPACING**
650 Vertical space is wasted given the limited number of lines an
651 editor window can display when multiple blank lines are used.
652 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#spaces
653
654 **OPEN_BRACE**
655 The opening brace should be following the function definitions on the
656 next line. For any non-functional block it should be on the same line
657 as the last construct.
658 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
659
660 **POINTER_LOCATION**
661 When using pointer data or a function that returns a pointer type,
662 the preferred use of * is adjacent to the data name or function name
663 and not adjacent to the type name.
664 Examples::
665
666 char *linux_banner;
667 unsigned long long memparse(char *ptr, char **retptr);
668 char *match_strdup(substring_t *s);
669
670 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#spaces
671
672 **SPACING**
673 Whitespace style used in the kernel sources is described in kernel docs.
674 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#spaces
675
676 **SWITCH_CASE_INDENT_LEVEL**
677 switch should be at the same indent as case.
678 Example::
679
680 switch (suffix) {
681 case 'G':
682 case 'g':
683 mem <<= 30;
684 break;
685 case 'M':
686 case 'm':
687 mem <<= 20;
688 break;
689 case 'K':
690 case 'k':
691 mem <<= 10;
692 /* fall through */
693 default:
694 break;
695 }
696
697 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#indentation
698
699 **TRAILING_WHITESPACE**
700 Trailing whitespace should always be removed.
701 Some editors highlight the trailing whitespace and cause visual
702 distractions when editing files.
703 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#spaces
704
705 **WHILE_AFTER_BRACE**
706 while should follow the closing bracket on the same line::
707
708 do {
709 ...
710 } while(something);
711
712 See: https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
713
714
715Others
716------
717
718 **CONFIG_DESCRIPTION**
719 Kconfig symbols should have a help text which fully describes
720 it.
721
722 **CORRUPTED_PATCH**
723 The patch seems to be corrupted or lines are wrapped.
724 Please regenerate the patch file before sending it to the maintainer.
725
726 **DOS_LINE_ENDINGS**
727 For DOS-formatted patches, there are extra ^M symbols at the end of
728 the line. These should be removed.
729
730 **EXECUTE_PERMISSIONS**
731 There is no reason for source files to be executable. The executable
732 bit can be removed safely.
733
734 **NON_OCTAL_PERMISSIONS**
735 Permission bits should use 4 digit octal permissions (like 0700 or 0444).
736 Avoid using any other base like decimal.
737
738 **NOT_UNIFIED_DIFF**
739 The patch file does not appear to be in unified-diff format. Please
740 regenerate the patch file before sending it to the maintainer.
741
742 **PRINTF_0XDECIMAL**
743 Prefixing 0x with decimal output is defective and should be corrected.
744
745 **TRAILING_STATEMENTS**
746 Trailing statements (for example after any conditional) should be
747 on the next line.
748 Like::
749
750 if (x == y) break;
751
752 should be::
753
754 if (x == y)
755 break;
Documentation/dev-tools/gcov.rst+6−2
@@ -124,6 +124,8 @@ box for setups where kernels are built and run on the same machine. In · 123 unmodified lines
124cases where the kernel runs on a separate machine, special preparations124cases where the kernel runs on a separate machine, special preparations
125must be made, depending on where the gcov tool is used:125must be made, depending on where the gcov tool is used:
126 126
127.. _gcov-test:
128
127a) gcov is run on the TEST machine129a) gcov is run on the TEST machine
128 130
129 The gcov tool version on the test machine must be compatible with the131 The gcov tool version on the test machine must be compatible with the
@@ -143,6 +145,8 @@ a) gcov is run on the TEST machine · 13 unmodified lines
143 machine. If any of the path components is symbolic link, the actual145 machine. If any of the path components is symbolic link, the actual
144 directory needs to be used instead (due to make's CURDIR handling).146 directory needs to be used instead (due to make's CURDIR handling).
145 147
148.. _gcov-build:
149
146b) gcov is run on the BUILD machine150b) gcov is run on the BUILD machine
147 151
148 The following files need to be copied after each test case from test152 The following files need to be copied after each test case from test
@@ -211,7 +215,7 @@ Appendix A: gather_on_build.sh · 62 unmodified lines
211------------------------------215------------------------------
212 216
213Sample script to gather coverage meta files on the build machine217Sample script to gather coverage meta files on the build machine
214(see 6a):218(see :ref:`Separated build and test machines a. <gcov-test>`):
215 219
216.. code-block:: sh220.. code-block:: sh
217 221
@@ -244,7 +248,7 @@ Appendix B: gather_on_test.sh · 26 unmodified lines
244-----------------------------248-----------------------------
245 249
246Sample script to gather coverage data files on the test machine250Sample script to gather coverage data files on the test machine
247(see 6b):251(see :ref:`Separated build and test machines b. <gcov-build>`):
248 252
249.. code-block:: sh253.. code-block:: sh
250 254
Documentation/dev-tools/index.rst+5−0
@@ -7,6 +7,9 @@ be used to work on the kernel. For now, the documents have been pulled · 6 unmodified lines
7together without any significant effort to integrate them into a coherent7together without any significant effort to integrate them into a coherent
8whole; patches welcome!8whole; patches welcome!
9 9
10A brief overview of testing-specific tools can be found in
11Documentation/dev-tools/testing-overview.rst
12
10.. class:: toc-title13.. class:: toc-title
11 14
12 Table of contents15 Table of contents
@@ -14,6 +17,8 @@ whole; patches welcome! · 1 unmodified line
14.. toctree::17.. toctree::
15 :maxdepth: 218 :maxdepth: 2
16 19
20 testing-overview
21 checkpatch
17 coccinelle22 coccinelle
18 sparse23 sparse
19 kcov24 kcov
Documentation/dev-tools/testing-overview.rst+117−0
@@ -0,0 +1,117 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3====================
4Kernel Testing Guide
5====================
6
7
8There are a number of different tools for testing the Linux kernel, so knowing
9when to use each of them can be a challenge. This document provides a rough
10overview of their differences, and how they fit together.
11
12
13Writing and Running Tests
14=========================
15
16The bulk of kernel tests are written using either the kselftest or KUnit
17frameworks. These both provide infrastructure to help make running tests and
18groups of tests easier, as well as providing helpers to aid in writing new
19tests.
20
21If you're looking to verify the behaviour of the Kernel — particularly specific
22parts of the kernel — then you'll want to use KUnit or kselftest.
23
24
25The Difference Between KUnit and kselftest
26------------------------------------------
27
28KUnit (Documentation/dev-tools/kunit/index.rst) is an entirely in-kernel system
29for "white box" testing: because test code is part of the kernel, it can access
30internal structures and functions which aren't exposed to userspace.
31
32KUnit tests therefore are best written against small, self-contained parts
33of the kernel, which can be tested in isolation. This aligns well with the
34concept of 'unit' testing.
35
36For example, a KUnit test might test an individual kernel function (or even a
37single codepath through a function, such as an error handling case), rather
38than a feature as a whole.
39
40This also makes KUnit tests very fast to build and run, allowing them to be
41run frequently as part of the development process.
42
43There is a KUnit test style guide which may give further pointers in
44Documentation/dev-tools/kunit/style.rst
45
46
47kselftest (Documentation/dev-tools/kselftest.rst), on the other hand, is
48largely implemented in userspace, and tests are normal userspace scripts or
49programs.
50
51This makes it easier to write more complicated tests, or tests which need to
52manipulate the overall system state more (e.g., spawning processes, etc.).
53However, it's not possible to call kernel functions directly from kselftest.
54This means that only kernel functionality which is exposed to userspace somehow
55(e.g. by a syscall, device, filesystem, etc.) can be tested with kselftest. To
56work around this, some tests include a companion kernel module which exposes
57more information or functionality. If a test runs mostly or entirely within the
58kernel, however, KUnit may be the more appropriate tool.
59
60kselftest is therefore suited well to tests of whole features, as these will
61expose an interface to userspace, which can be tested, but not implementation
62details. This aligns well with 'system' or 'end-to-end' testing.
63
64For example, all new system calls should be accompanied by kselftest tests.
65
66Code Coverage Tools
67===================
68
69The Linux Kernel supports two different code coverage measurement tools. These
70can be used to verify that a test is executing particular functions or lines
71of code. This is useful for determining how much of the kernel is being tested,
72and for finding corner-cases which are not covered by the appropriate test.
73
74:doc:`gcov` is GCC's coverage testing tool, which can be used with the kernel
75to get global or per-module coverage. Unlike KCOV, it does not record per-task
76coverage. Coverage data can be read from debugfs, and interpreted using the
77usual gcov tooling.
78
79:doc:`kcov` is a feature which can be built in to the kernel to allow
80capturing coverage on a per-task level. It's therefore useful for fuzzing and
81other situations where information about code executed during, for example, a
82single syscall is useful.
83
84
85Dynamic Analysis Tools
86======================
87
88The kernel also supports a number of dynamic analysis tools, which attempt to
89detect classes of issues when they occur in a running kernel. These typically
90each look for a different class of bugs, such as invalid memory accesses,
91concurrency issues such as data races, or other undefined behaviour like
92integer overflows.
93
94Some of these tools are listed below:
95
96* kmemleak detects possible memory leaks. See
97 Documentation/dev-tools/kmemleak.rst
98* KASAN detects invalid memory accesses such as out-of-bounds and
99 use-after-free errors. See Documentation/dev-tools/kasan.rst
100* UBSAN detects behaviour that is undefined by the C standard, like integer
101 overflows. See Documentation/dev-tools/ubsan.rst
102* KCSAN detects data races. See Documentation/dev-tools/kcsan.rst
103* KFENCE is a low-overhead detector of memory issues, which is much faster than
104 KASAN and can be used in production. See Documentation/dev-tools/kfence.rst
105* lockdep is a locking correctness validator. See
106 Documentation/locking/lockdep-design.rst
107* There are several other pieces of debug instrumentation in the kernel, many
108 of which can be found in lib/Kconfig.debug
109
110These tools tend to test the kernel as a whole, and do not "pass" like
111kselftest or KUnit tests. They can be combined with KUnit or kselftest by
112running tests on a kernel with these tools enabled: you can then be sure
113that none of these errors are occurring during the test.
114
115Some of these tools integrate with KUnit or kselftest and will
116automatically fail tests if an issue is detected.
117
Documentation/devicetree/bindings/submitting-patches.rst+2−2
@@ -75,8 +75,8 @@ II. For kernel maintainers · 74 unmodified lines
75 binding, and it hasn't received an Acked-by from the devicetree75 binding, and it hasn't received an Acked-by from the devicetree
76 maintainers after a few weeks, go ahead and take it.76 maintainers after a few weeks, go ahead and take it.
77 77
78 Subsystem bindings (anything affecting more than a single device)78 For subsystem bindings (anything affecting more than a single device),
79 then getting a devicetree maintainer to review it is required.79 getting a devicetree maintainer to review it is required.
80 80
81 3) For a series going though multiple trees, the binding patch should be81 3) For a series going though multiple trees, the binding patch should be
82 kept with the driver using the binding.82 kept with the driver using the binding.
Documentation/driver-api/driver-model/class.rst+0−149
@@ -1,149 +0,0 @@
1==============
2Device Classes
3==============
4
5Introduction
6~~~~~~~~~~~~
7A device class describes a type of device, like an audio or network
8device. The following device classes have been identified:
9
10<Insert List of Device Classes Here>
11
12
13Each device class defines a set of semantics and a programming interface
14that devices of that class adhere to. Device drivers are the
15implementation of that programming interface for a particular device on
16a particular bus.
17
18Device classes are agnostic with respect to what bus a device resides
19on.
20
21
22Programming Interface
23~~~~~~~~~~~~~~~~~~~~~
24The device class structure looks like::
25
26
27 typedef int (*devclass_add)(struct device *);
28 typedef void (*devclass_remove)(struct device *);
29
30See the kerneldoc for the struct class.
31
32A typical device class definition would look like::
33
34 struct device_class input_devclass = {
35 .name = "input",
36 .add_device = input_add_device,
37 .remove_device = input_remove_device,
38 };
39
40Each device class structure should be exported in a header file so it
41can be used by drivers, extensions and interfaces.
42
43Device classes are registered and unregistered with the core using::
44
45 int devclass_register(struct device_class * cls);
46 void devclass_unregister(struct device_class * cls);
47
48
49Devices
50~~~~~~~
51As devices are bound to drivers, they are added to the device class
52that the driver belongs to. Before the driver model core, this would
53typically happen during the driver's probe() callback, once the device
54has been initialized. It now happens after the probe() callback
55finishes from the core.
56
57The device is enumerated in the class. Each time a device is added to
58the class, the class's devnum field is incremented and assigned to the
59device. The field is never decremented, so if the device is removed
60from the class and re-added, it will receive a different enumerated
61value.
62
63The class is allowed to create a class-specific structure for the
64device and store it in the device's class_data pointer.
65
66There is no list of devices in the device class. Each driver has a
67list of devices that it supports. The device class has a list of
68drivers of that particular class. To access all of the devices in the
69class, iterate over the device lists of each driver in the class.
70
71
72Device Drivers
73~~~~~~~~~~~~~~
74Device drivers are added to device classes when they are registered
75with the core. A driver specifies the class it belongs to by setting
76the struct device_driver::devclass field.
77
78
79sysfs directory structure
80~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81There is a top-level sysfs directory named 'class'.
82
83Each class gets a directory in the class directory, along with two
84default subdirectories::
85
86 class/
87 `-- input
88 |-- devices
89 `-- drivers
90
91
92Drivers registered with the class get a symlink in the drivers/ directory
93that points to the driver's directory (under its bus directory)::
94
95 class/
96 `-- input
97 |-- devices
98 `-- drivers
99 `-- usb:usb_mouse -> ../../../bus/drivers/usb_mouse/
100
101
102Each device gets a symlink in the devices/ directory that points to the
103device's directory in the physical hierarchy::
104
105 class/
106 `-- input
107 |-- devices
108 | `-- 1 -> ../../../root/pci0/00:1f.0/usb_bus/00:1f.2-1:0/
109 `-- drivers
110
111
112Exporting Attributes
113~~~~~~~~~~~~~~~~~~~~
114
115::
116
117 struct devclass_attribute {
118 struct attribute attr;
119 ssize_t (*show)(struct device_class *, char * buf, size_t count, loff_t off);
120 ssize_t (*store)(struct device_class *, const char * buf, size_t count, loff_t off);
121 };
122
123Class drivers can export attributes using the DEVCLASS_ATTR macro that works
124similarly to the DEVICE_ATTR macro for devices. For example, a definition
125like this::
126
127 static DEVCLASS_ATTR(debug,0644,show_debug,store_debug);
128
129is equivalent to declaring::
130
131 static devclass_attribute devclass_attr_debug;
132
133The bus driver can add and remove the attribute from the class's
134sysfs directory using::
135
136 int devclass_create_file(struct device_class *, struct devclass_attribute *);
137 void devclass_remove_file(struct device_class *, struct devclass_attribute *);
138
139In the example above, the file will be named 'debug' in placed in the
140class's directory in sysfs.
141
142
143Interfaces
144~~~~~~~~~~
145There may exist multiple mechanisms for accessing the same device of a
146particular class type. Device interfaces describe these mechanisms.
147
148When a device is added to a device class, the core attempts to add it
149to every interface that is registered with the device class.
Documentation/driver-api/driver-model/device.rst+17−6
@@ -63,8 +63,14 @@ Attributes are declared using a macro called DEVICE_ATTR:: · 62 unmodified lines
63 63
64Example:::64Example:::
65 65
66 static DEVICE_ATTR(type, 0444, show_type, NULL);66 static DEVICE_ATTR(type, 0444, type_show, NULL);
67 static DEVICE_ATTR(power, 0644, show_power, store_power);67 static DEVICE_ATTR(power, 0644, power_show, power_store);
68
69Helper macros are available for common values of mode, so the above examples
70can be simplified to:::
71
72 static DEVICE_ATTR_RO(type);
73 static DEVICE_ATTR_RW(power);
68 74
69This declares two structures of type struct device_attribute with respective75This declares two structures of type struct device_attribute with respective
70names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be76names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be
@@ -76,19 +82,24 @@ organized as follows into a group:: · 5 unmodified lines
76 NULL,82 NULL,
77 };83 };
78 84
79 static struct attribute_group dev_attr_group = {85 static struct attribute_group dev_group = {
80 .attrs = dev_attrs,86 .attrs = dev_attrs,
81 };87 };
82 88
83 static const struct attribute_group *dev_attr_groups[] = {89 static const struct attribute_group *dev_groups[] = {
84 &dev_attr_group,90 &dev_group,
85 NULL,91 NULL,
86 };92 };
87 93
94A helper macro is available for the common case of a single group, so the
95above two structures can be declared using:::
96
97 ATTRIBUTE_GROUPS(dev);
98
88This array of groups can then be associated with a device by setting the99This array of groups can then be associated with a device by setting the
89group pointer in struct device before device_register() is invoked::100group pointer in struct device before device_register() is invoked::
90 101
91 dev->groups = dev_attr_groups;102 dev->groups = dev_groups;
92 device_register(dev);103 device_register(dev);
93 104
94The device_register() function will use the 'groups' pointer to create the105The device_register() function will use the 'groups' pointer to create the
Documentation/driver-api/driver-model/index.rst+0−1
@@ -7,7 +7,6 @@ Driver Model · 6 unmodified lines
7 7
8 binding8 binding
9 bus9 bus
10 class
11 design-patterns10 design-patterns
12 device11 device
13 devres12 devres
Documentation/driver-api/gpio/intro.rst+1−1
@@ -27,7 +27,7 @@ What is a GPIO? · 26 unmodified lines
27===============27===============
28 28
29A "General Purpose Input/Output" (GPIO) is a flexible software-controlled29A "General Purpose Input/Output" (GPIO) is a flexible software-controlled
30digital signal. They are provided from many kinds of chip, and are familiar30digital signal. They are provided from many kinds of chips, and are familiar
31to Linux developers working with embedded and custom hardware. Each GPIO31to Linux developers working with embedded and custom hardware. Each GPIO
32represents a bit connected to a particular pin, or "ball" on Ball Grid Array32represents a bit connected to a particular pin, or "ball" on Ball Grid Array
33(BGA) packages. Board schematics show which external hardware connects to33(BGA) packages. Board schematics show which external hardware connects to
Documentation/fb/fbcon.rst+2−2
@@ -207,9 +207,9 @@ Documentation/driver-api/console.rst. To summarize: · 206 unmodified lines
207Echo a value to the bind file that represents the framebuffer console207Echo a value to the bind file that represents the framebuffer console
208driver. So assuming vtcon1 represents fbcon, then::208driver. So assuming vtcon1 represents fbcon, then::
209 209
210 echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console to210 echo 1 > /sys/class/vtconsole/vtcon1/bind - attach framebuffer console to
211 console layer211 console layer
212 echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from212 echo 0 > /sys/class/vtconsole/vtcon1/bind - detach framebuffer console from
213 console layer213 console layer
214 214
215If fbcon is detached from the console layer, your boot console driver (which is215If fbcon is detached from the console layer, your boot console driver (which is
Documentation/features/arch-support.txt+1−0
@@ -8,4 +8,5 @@ The meaning of entries in the tables is: · 7 unmodified lines
8 | ok | # feature supported by the architecture8 | ok | # feature supported by the architecture
9 |TODO| # feature not yet supported by the architecture9 |TODO| # feature not yet supported by the architecture
10 | .. | # feature cannot be supported by the hardware10 | .. | # feature cannot be supported by the hardware
11 | N/A| # feature doesn't apply to the architecture
11 12
Documentation/features/vm/TLB/arch-support.txt+1−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
9 | alpha: | TODO |9 | alpha: | TODO |
10 | arc: | TODO |10 | arc: | TODO |
11 | arm: | TODO |11 | arm: | TODO |
12 | arm64: | TODO |12 | arm64: | N/A |
13 | csky: | TODO |13 | csky: | TODO |
14 | h8300: | .. |14 | h8300: | .. |
15 | hexagon: | TODO |15 | hexagon: | TODO |
Documentation/filesystems/api-summary.rst+9−0
@@ -101,6 +101,9 @@ Other Functions · 100 unmodified lines
101.. kernel-doc:: fs/xattr.c101.. kernel-doc:: fs/xattr.c
102 :export:102 :export:
103 103
104.. kernel-doc:: fs/namespace.c
105 :export:
106
104The proc filesystem107The proc filesystem
105===================108===================
106 109
@@ -122,6 +125,12 @@ Events based on file descriptors · 15 unmodified lines
122.. kernel-doc:: fs/eventfd.c125.. kernel-doc:: fs/eventfd.c
123 :export:126 :export:
124 127
128eventpoll (epoll) interfaces
129============================
130
131.. kernel-doc:: fs/eventpoll.c
132 :internal:
133
125The Filesystem for Exporting Kernel Objects134The Filesystem for Exporting Kernel Objects
126===========================================135===========================================
127 136
Documentation/filesystems/proc.rst+4−0
@@ -540,7 +540,9 @@ encoded manner. The codes are the following: · 539 unmodified lines
540 ac area is accountable540 ac area is accountable
541 nr swap space is not reserved for the area541 nr swap space is not reserved for the area
542 ht area uses huge tlb pages542 ht area uses huge tlb pages
543 sf synchronous page fault
543 ar architecture specific flag544 ar architecture specific flag
545 wf wipe on fork
544 dd do not include area into core dump546 dd do not include area into core dump
545 sd soft dirty flag547 sd soft dirty flag
546 mm mixed map area548 mm mixed map area
@@ -549,6 +551,8 @@ encoded manner. The codes are the following: · 2 unmodified lines
549 mg mergable advise flag551 mg mergable advise flag
550 bt arm64 BTI guarded page552 bt arm64 BTI guarded page
551 mt arm64 MTE allocation tags are enabled553 mt arm64 MTE allocation tags are enabled
554 um userfaultfd missing tracking
555 uw userfaultfd wr-protect tracking
552 == =======================================556 == =======================================
553 557
554Note that there is no guarantee that every flag and associated mnemonic will558Note that there is no guarantee that every flag and associated mnemonic will
Documentation/filesystems/vfat.rst+1−1
@@ -189,7 +189,7 @@ VFAT MOUNT OPTIONS · 188 unmodified lines
189**discard**189**discard**
190 If set, issues discard/TRIM commands to the block190 If set, issues discard/TRIM commands to the block
191 device when blocks are freed. This is useful for SSD devices191 device when blocks are freed. This is useful for SSD devices
192 and sparse/thinly-provisoned LUNs.192 and sparse/thinly-provisioned LUNs.
193 193
194**nfs=stale_rw|nostale_ro**194**nfs=stale_rw|nostale_ro**
195 Enable this only if you want to export the FAT filesystem195 Enable this only if you want to export the FAT filesystem
Documentation/hid/intel-ish-hid.rst+1−1
@@ -345,7 +345,7 @@ Documentation/ABI/testing/sysfs-bus-iio for IIO ABIs to user space. · 344 unmodified lines
345To debug ISH, event tracing mechanism is used. To enable debug logs::345To debug ISH, event tracing mechanism is used. To enable debug logs::
346 346
347 echo 1 > /sys/kernel/debug/tracing/events/intel_ish/enable347 echo 1 > /sys/kernel/debug/tracing/events/intel_ish/enable
348 cat sys/kernel/debug/tracing/trace348 cat /sys/kernel/debug/tracing/trace
349 349
3503.8 ISH IIO sysfs Example on Lenovo thinkpad Yoga 2603503.8 ISH IIO sysfs Example on Lenovo thinkpad Yoga 260
351-----------------------------------------------------351-----------------------------------------------------
Documentation/index.rst+2−18
@@ -149,27 +149,11 @@ Architecture-agnostic documentation · 148 unmodified lines
149Architecture-specific documentation149Architecture-specific documentation
150-----------------------------------150-----------------------------------
151 151
152These books provide programming details about architecture-specific
153implementation.
154
155.. toctree::152.. toctree::
156 :maxdepth: 2153 :maxdepth: 2
157 154
158 arm/index155 arch
159 arm64/index156
160 ia64/index
161 m68k/index
162 mips/index
163 nios2/index
164 openrisc/index
165 parisc/index
166 powerpc/index
167 riscv/index
168 s390/index
169 sh/index
170 sparc/index
171 x86/index
172 xtensa/index
173 157
174Other documentation158Other documentation
175-------------------159-------------------
Documentation/input/event-codes.rst+5−5
@@ -246,9 +246,9 @@ A few EV_ABS codes have special meanings: · 245 unmodified lines
246 246
247 A device should set the resolution of the axis to indicate whether the247 A device should set the resolution of the axis to indicate whether the
248 pressure is in measurable units. If the resolution is zero, the248 pressure is in measurable units. If the resolution is zero, the
249 pressure data is in arbitrary units. If the resolution is nonzero, the249 pressure data is in arbitrary units. If the resolution is non-zero, the
250 pressure data is in units/gram. For example, a value of 10 with a250 pressure data is in units/gram. For example, a value of 10 with a
251 resolution of 1 represents 10 gram, a value of 10 with a resolution on251 resolution of 1 represents 10 gram, a value of 10 with a resolution of
252 1000 represents 10 microgram.252 1000 represents 10 microgram.
253 253
254EV_SW254EV_SW
@@ -344,7 +344,7 @@ INPUT_PROP_BUTTONPAD · 89 unmodified lines
344 344
345For touchpads where the button is placed beneath the surface, such that345For touchpads where the button is placed beneath the surface, such that
346pressing down on the pad causes a button click, this property should be346pressing down on the pad causes a button click, this property should be
347set. Common in clickpad notebooks and macbooks from 2009 and onwards.347set. Common in Clickpad notebooks and Macbooks from 2009 and onwards.
348 348
349Originally, the buttonpad property was coded into the bcm5974 driver349Originally, the buttonpad property was coded into the bcm5974 driver
350version field under the name integrated button. For backwards350version field under the name integrated button. For backwards
@@ -356,7 +356,7 @@ INPUT_PROP_SEMI_MT · 5 unmodified lines
356Some touchpads, most common between 2008 and 2011, can detect the presence356Some touchpads, most common between 2008 and 2011, can detect the presence
357of multiple contacts without resolving the individual positions; only the357of multiple contacts without resolving the individual positions; only the
358number of contacts and a rectangular shape is known. For such358number of contacts and a rectangular shape is known. For such
359touchpads, the semi-mt property should be set.359touchpads, the SEMI_MT property should be set.
360 360
361Depending on the device, the rectangle may enclose all touches, like a361Depending on the device, the rectangle may enclose all touches, like a
362bounding box, or just some of them, for instance the two most recent362bounding box, or just some of them, for instance the two most recent
@@ -394,7 +394,7 @@ Guidelines · 31 unmodified lines
394==========394==========
395 395
396The guidelines below ensure proper single-touch and multi-finger functionality.396The guidelines below ensure proper single-touch and multi-finger functionality.
397For multi-touch functionality, see the multi-touch-protocol.txt document for397For multi-touch functionality, see the multi-touch-protocol.rst document for
398more information.398more information.
399 399
400Mice400Mice
Documentation/input/ff.rst+3−3
@@ -16,8 +16,8 @@ goal is not to support these devices as if they were simple input-only devices · 15 unmodified lines
16(as it is already the case), but to really enable the rendering of force16(as it is already the case), but to really enable the rendering of force
17effects.17effects.
18This document only describes the force feedback part of the Linux input18This document only describes the force feedback part of the Linux input
19interface. Please read joystick.txt and input.txt before reading further this19interface. Please read joydev/joystick.rst and input.rst before reading further
20document.20this document.
21 21
22Instructions to the user22Instructions to the user
23~~~~~~~~~~~~~~~~~~~~~~~~23~~~~~~~~~~~~~~~~~~~~~~~~
@@ -36,7 +36,7 @@ should keep a hand on your device, in order to avoid it to break down if · 12 unmodified lines
36something goes wrong.36something goes wrong.
37 37
38If you have a serial iforce device, you need to start inputattach. See38If you have a serial iforce device, you need to start inputattach. See
39joystick.txt for details.39joydev/joystick.rst for details.
40 40
41Does it work ?41Does it work ?
42--------------42--------------
Documentation/input/gameport-programming.rst+23−12
@@ -21,7 +21,7 @@ choose which one to program the hardware to, starting from the more exotic · 20 unmodified lines
21addresses is preferred, because the likelihood of clashing with the standard21addresses is preferred, because the likelihood of clashing with the standard
220x201 address is smaller.220x201 address is smaller.
23 23
24Eg. if your driver supports addresses 0x200, 0x208, 0x210 and 0x218, then24E.g. if your driver supports addresses 0x200, 0x208, 0x210 and 0x218, then
250x218 would be the address of first choice.250x218 would be the address of first choice.
26 26
27If your hardware supports a gameport address that is not mapped to ISA io27If your hardware supports a gameport address that is not mapped to ISA io
@@ -78,7 +78,7 @@ the gameport. To register a cooked gameport:: · 50 unmodified lines
78 78
79 for (i = 0; i < 4; i++)79 for (i = 0; i < 4; i++)
80 axes[i] = my_mmio[i];80 axes[i] = my_mmio[i];
81 buttons[i] = my_mmio[4];81 buttons[0] = my_mmio[4];
82 }82 }
83 83
84 int my_open(struct gameport *gameport, int mode)84 int my_open(struct gameport *gameport, int mode)
@@ -117,25 +117,28 @@ Simple:: · 32 unmodified lines
117The gameport structure117The gameport structure
118~~~~~~~~~~~~~~~~~~~~~~118~~~~~~~~~~~~~~~~~~~~~~
119 119
120.. note::
121
122 This section is outdated. There are several fields here that don't
123 match what's there at include/linux/gameport.h.
124
125::120::
126 121
127 struct gameport {122 struct gameport {
128 123
129 void *private;124 void *port_data;
130 125
131A private pointer for free use in the gameport driver. (Not the joystick126A private pointer for free use in the gameport driver. (Not the joystick
132driver!)127driver!)
133 128
134::129::
135 130
136 int number;131 char name[32];
132
133Driver's name as set by driver calling gameport_set_name(). Informational
134purpose only.
135
136::
137
138 char phys[32];
137 139
138Number assigned to the gameport when registered. Informational purpose only.140gameport's physical name/description as set by driver calling gameport_set_phys().
141Informational purpose only.
139 142
140::143::
141 144
@@ -210,8 +213,16 @@ gameport. · 68 unmodified lines
210 213
211::214::
212 215
213 struct gameport_dev *dev;216 struct timer_list poll_timer;
214 struct gameport *next;217 unsigned int poll_interval; /* in msecs */
218 spinlock_t timer_lock;
219 unsigned int poll_cnt;
220 void (*poll_handler)(struct gameport *);
221 struct gameport *parent, *child;
222 struct gameport_driver *drv;
223 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
224 struct device dev;
225 struct list_head node;
215 226
216For internal use by the gameport layer.227For internal use by the gameport layer.
217 228
Documentation/input/input-programming.rst+10−10
@@ -120,7 +120,7 @@ Then there is the:: · 119 unmodified lines
120 120
121call to tell those who receive the events that we've sent a complete report.121call to tell those who receive the events that we've sent a complete report.
122This doesn't seem important in the one button case, but is quite important122This doesn't seem important in the one button case, but is quite important
123for for example mouse movement, where you don't want the X and Y values123for example for mouse movement, where you don't want the X and Y values
124to be interpreted separately, because that'd result in a different movement.124to be interpreted separately, because that'd result in a different movement.
125 125
126dev->open() and dev->close()126dev->open() and dev->close()
@@ -128,7 +128,7 @@ dev->open() and dev->close() · 1 unmodified line
128 128
129In case the driver has to repeatedly poll the device, because it doesn't129In case the driver has to repeatedly poll the device, because it doesn't
130have an interrupt coming from it and the polling is too expensive to be done130have an interrupt coming from it and the polling is too expensive to be done
131all the time, or if the device uses a valuable resource (eg. interrupt), it131all the time, or if the device uses a valuable resource (e.g. interrupt), it
132can use the open and close callback to know when it can stop polling or132can use the open and close callback to know when it can stop polling or
133release the interrupt and when it must resume polling or grab the interrupt133release the interrupt and when it must resume polling or grab the interrupt
134again. To do that, we would add this to our example driver::134again. To do that, we would add this to our example driver::
@@ -161,7 +161,7 @@ makes sure that dev->open() is called only when the first user connects · 26 unmodified lines
161to the device and that dev->close() is called when the very last user161to the device and that dev->close() is called when the very last user
162disconnects. Calls to both callbacks are serialized.162disconnects. Calls to both callbacks are serialized.
163 163
164The open() callback should return a 0 in case of success or any nonzero value164The open() callback should return a 0 in case of success or any non-zero value
165in case of failure. The close() callback (which is void) must always succeed.165in case of failure. The close() callback (which is void) must always succeed.
166 166
167Inhibiting input devices167Inhibiting input devices
@@ -182,8 +182,8 @@ providing events to the input core. · 14 unmodified lines
182 182
183Calling the device's close() method on inhibit (if there are users) allows the183Calling the device's close() method on inhibit (if there are users) allows the
184driver to save power. Either by directly powering down the device or by184driver to save power. Either by directly powering down the device or by
185releasing the runtime-pm reference it got in open() when the driver is using185releasing the runtime-PM reference it got in open() when the driver is using
186runtime-pm.186runtime-PM.
187 187
188Inhibiting and uninhibiting are orthogonal to opening and closing the device by188Inhibiting and uninhibiting are orthogonal to opening and closing the device by
189input handlers. Userspace might want to inhibit a device in anticipation before189input handlers. Userspace might want to inhibit a device in anticipation before
@@ -219,8 +219,8 @@ It's reported to the input system via:: · 29 unmodified lines
219 input_report_key(struct input_dev *dev, int code, int value)219 input_report_key(struct input_dev *dev, int code, int value)
220 220
221See uapi/linux/input-event-codes.h for the allowable values of code (from 0 to221See uapi/linux/input-event-codes.h for the allowable values of code (from 0 to
222KEY_MAX). Value is interpreted as a truth value, ie any nonzero value means key222KEY_MAX). Value is interpreted as a truth value, i.e. any non-zero value means
223pressed, zero value means key released. The input code generates events only223key pressed, zero value means key released. The input code generates events only
224in case the value is different from before.224in case the value is different from before.
225 225
226In addition to EV_KEY, there are two more basic event types: EV_REL and226In addition to EV_KEY, there are two more basic event types: EV_REL and
@@ -231,12 +231,12 @@ because it doesn't have any absolute coordinate system to work in. Absolute · 4 unmodified lines
231events are namely for joysticks and digitizers - devices that do work in an231events are namely for joysticks and digitizers - devices that do work in an
232absolute coordinate systems.232absolute coordinate systems.
233 233
234Having the device report EV_REL buttons is as simple as with EV_KEY, simply234Having the device report EV_REL buttons is as simple as with EV_KEY; simply
235set the corresponding bits and call the::235set the corresponding bits and call the::
236 236
237 input_report_rel(struct input_dev *dev, int code, int value)237 input_report_rel(struct input_dev *dev, int code, int value)
238 238
239function. Events are generated only for nonzero value.239function. Events are generated only for non-zero values.
240 240
241However EV_ABS requires a little special care. Before calling241However EV_ABS requires a little special care. Before calling
242input_register_device, you have to fill additional fields in the input_dev242input_register_device, you have to fill additional fields in the input_dev
@@ -280,7 +280,7 @@ device driver. It's a string like 'Generic button device' containing a · 37 unmodified lines
280user friendly name of the device.280user friendly name of the device.
281 281
282The id* fields contain the bus ID (PCI, USB, ...), vendor ID and device ID282The id* fields contain the bus ID (PCI, USB, ...), vendor ID and device ID
283of the device. The bus IDs are defined in input.h. The vendor and device ids283of the device. The bus IDs are defined in input.h. The vendor and device IDs
284are defined in pci_ids.h, usb_ids.h and similar include files. These fields284are defined in pci_ids.h, usb_ids.h and similar include files. These fields
285should be set by the input device driver before registering it.285should be set by the input device driver before registering it.
286 286
Documentation/input/input.rst+4−4
@@ -9,7 +9,7 @@ Introduction · 8 unmodified lines
9Architecture9Architecture
10============10============
11 11
12Input subsystem a collection of drivers that is designed to support12Input subsystem is a collection of drivers that is designed to support
13all input devices under Linux. Most of the drivers reside in13all input devices under Linux. Most of the drivers reside in
14drivers/input, although quite a few live in drivers/hid and14drivers/input, although quite a few live in drivers/hid and
15drivers/platform.15drivers/platform.
@@ -50,7 +50,7 @@ will be available as a character device on major 13, minor 63:: · 34 unmodified lines
50 50
51 crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice51 crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice
52 52
53This device usually created automatically by the system. The commands53This device is usually created automatically by the system. The commands
54to create it by hand are::54to create it by hand are::
55 55
56 cd /dev56 cd /dev
@@ -180,7 +180,7 @@ whole suite. It handles all HID devices, and because there is a very · 123 unmodified lines
180wide variety of them, and because the USB HID specification isn't180wide variety of them, and because the USB HID specification isn't
181simple, it needs to be this big.181simple, it needs to be this big.
182 182
183Currently, it handles USB mice, joysticks, gamepads, steering wheels183Currently, it handles USB mice, joysticks, gamepads, steering wheels,
184keyboards, trackballs and digitizers.184keyboards, trackballs and digitizers.
185 185
186However, USB uses HID also for monitor controls, speaker controls, UPSs,186However, USB uses HID also for monitor controls, speaker controls, UPSs,
@@ -268,7 +268,7 @@ events on a read. Their layout is:: · 81 unmodified lines
268 };268 };
269 269
270``time`` is the timestamp, it returns the time at which the event happened.270``time`` is the timestamp, it returns the time at which the event happened.
271Type is for example EV_REL for relative moment, EV_KEY for a keypress or271Type is for example EV_REL for relative movement, EV_KEY for a keypress or
272release. More types are defined in include/uapi/linux/input-event-codes.h.272release. More types are defined in include/uapi/linux/input-event-codes.h.
273 273
274``code`` is event code, for example REL_X or KEY_BACKSPACE, again a complete274``code`` is event code, for example REL_X or KEY_BACKSPACE, again a complete
Documentation/input/multi-touch-protocol.rst+4−4
@@ -261,7 +261,7 @@ ABS_MT_PRESSURE · 260 unmodified lines
261 signal intensity distribution.261 signal intensity distribution.
262 262
263 If the resolution is zero, the pressure data is in arbitrary units.263 If the resolution is zero, the pressure data is in arbitrary units.
264 If the resolution is nonzero, the pressure data is in units/gram. See264 If the resolution is non-zero, the pressure data is in units/gram. See
265 :ref:`input-event-codes` for details.265 :ref:`input-event-codes` for details.
266 266
267ABS_MT_DISTANCE267ABS_MT_DISTANCE
@@ -279,14 +279,14 @@ ABS_MT_ORIENTATION · 11 unmodified lines
279 max should be returned; when aligned with the X axis in the negative279 max should be returned; when aligned with the X axis in the negative
280 direction, the range -max should be returned.280 direction, the range -max should be returned.
281 281
282 Touch ellipsis are symmetrical by default. For devices capable of true 360282 Touch ellipses are symmetrical by default. For devices capable of true 360
283 degree orientation, the reported orientation must exceed the range max to283 degree orientation, the reported orientation must exceed the range max to
284 indicate more than a quarter of a revolution. For an upside-down finger,284 indicate more than a quarter of a revolution. For an upside-down finger,
285 range max * 2 should be returned.285 range max * 2 should be returned.
286 286
287 Orientation can be omitted if the touch area is circular, or if the287 Orientation can be omitted if the touch area is circular, or if the
288 information is not available in the kernel driver. Partial orientation288 information is not available in the kernel driver. Partial orientation
289 support is possible if the device can distinguish between the two axis, but289 support is possible if the device can distinguish between the two axes, but
290 not (uniquely) any values in between. In such cases, the range of290 not (uniquely) any values in between. In such cases, the range of
291 ABS_MT_ORIENTATION should be [0, 1] [#f4]_.291 ABS_MT_ORIENTATION should be [0, 1] [#f4]_.
292 292
@@ -356,7 +356,7 @@ The range of ABS_MT_ORIENTATION should be set to [0, 1], to indicate that · 63 unmodified lines
356the device can distinguish between a finger along the Y axis (0) and a356the device can distinguish between a finger along the Y axis (0) and a
357finger along the X axis (1).357finger along the X axis (1).
358 358
359For win8 devices with both T and C coordinates, the position mapping is::359For Win8 devices with both T and C coordinates, the position mapping is::
360 360
361 ABS_MT_POSITION_X := T_X361 ABS_MT_POSITION_X := T_X
362 ABS_MT_POSITION_Y := T_Y362 ABS_MT_POSITION_Y := T_Y
Documentation/input/notifier.rst+2−1
@@ -4,11 +4,12 @@ Keyboard notifier · 3 unmodified lines
4 4
5One can use register_keyboard_notifier to get called back on keyboard5One can use register_keyboard_notifier to get called back on keyboard
6events (see kbd_keycode() function for details). The passed structure is6events (see kbd_keycode() function for details). The passed structure is
7keyboard_notifier_param:7keyboard_notifier_param (see <linux/keyboard.h>):
8 8
9- 'vc' always provide the VC for which the keyboard event applies;9- 'vc' always provide the VC for which the keyboard event applies;
10- 'down' is 1 for a key press event, 0 for a key release;10- 'down' is 1 for a key press event, 0 for a key release;
11- 'shift' is the current modifier state, mask bit indexes are KG_*;11- 'shift' is the current modifier state, mask bit indexes are KG_*;
12- 'ledstate' is the current LED state;
12- 'value' depends on the type of event.13- 'value' depends on the type of event.
13 14
14- KBD_KEYCODE events are always sent before other events, value is the keycode.15- KBD_KEYCODE events are always sent before other events, value is the keycode.
Documentation/input/uinput.rst+1−1
@@ -179,7 +179,7 @@ uinput old interface · 178 unmodified lines
179--------------------179--------------------
180 180
181Before uinput version 5, there wasn't a dedicated ioctl to set up a virtual181Before uinput version 5, there wasn't a dedicated ioctl to set up a virtual
182device. Programs supportinf older versions of uinput interface need to fill182device. Programs supporting older versions of uinput interface need to fill
183a uinput_user_dev structure and write it to the uinput file descriptor to183a uinput_user_dev structure and write it to the uinput file descriptor to
184configure the new uinput device. New code should not use the old interface184configure the new uinput device. New code should not use the old interface
185but interact with uinput via ioctl calls, or use libevdev.185but interact with uinput via ioctl calls, or use libevdev.
Documentation/leds/leds-lm3556.rst+14−14
@@ -23,7 +23,7 @@ from 93.75 mA to 1500 mA.The Flash currents are adjusted via the CURRENT · 22 unmodified lines
23CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A),23CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A),
24or by pulling the STROBE pin HIGH.24or by pulling the STROBE pin HIGH.
25 25
26LM3556 Flash can be controlled through sys/class/leds/flash/brightness file26LM3556 Flash can be controlled through /sys/class/leds/flash/brightness file
27 27
28* if STROBE pin is enabled, below example control brightness only, and28* if STROBE pin is enabled, below example control brightness only, and
29 ON / OFF will be controlled by STROBE pin.29 ON / OFF will be controlled by STROBE pin.
@@ -32,17 +32,17 @@ Flash Example: · 2 unmodified lines
32 32
33OFF::33OFF::
34 34
35 #echo 0 > sys/class/leds/flash/brightness35 #echo 0 > /sys/class/leds/flash/brightness
36 36
3793.75 mA::3793.75 mA::
38 38
39 #echo 1 > sys/class/leds/flash/brightness39 #echo 1 > /sys/class/leds/flash/brightness
40 40
41...41...
42 42
431500 mA::431500 mA::
44 44
45 #echo 16 > sys/class/leds/flash/brightness45 #echo 16 > /sys/class/leds/flash/brightness
46 46
47Torch Mode47Torch Mode
48^^^^^^^^^^48^^^^^^^^^^
@@ -51,7 +51,7 @@ In Torch Mode, the current source(LED) is programmed via the CURRENT CONTROL · 2 unmodified lines
51REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the51REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the
52hardware TORCH input.52hardware TORCH input.
53 53
54LM3556 torch can be controlled through sys/class/leds/torch/brightness file.54LM3556 torch can be controlled through /sys/class/leds/torch/brightness file.
55* if TORCH pin is enabled, below example control brightness only,55* if TORCH pin is enabled, below example control brightness only,
56and ON / OFF will be controlled by TORCH pin.56and ON / OFF will be controlled by TORCH pin.
57 57
@@ -59,22 +59,22 @@ Torch Example: · 1 unmodified line
59 59
60OFF::60OFF::
61 61
62 #echo 0 > sys/class/leds/torch/brightness62 #echo 0 > /sys/class/leds/torch/brightness
63 63
6446.88 mA::6446.88 mA::
65 65
66 #echo 1 > sys/class/leds/torch/brightness66 #echo 1 > /sys/class/leds/torch/brightness
67 67
68...68...
69 69
70375 mA::70375 mA::
71 71
72 #echo 8 > sys/class/leds/torch/brightness72 #echo 8 > /sys/class/leds/torch/brightness
73 73
74Indicator Mode74Indicator Mode
75^^^^^^^^^^^^^^75^^^^^^^^^^^^^^
76 76
77Indicator pattern can be set through sys/class/leds/indicator/pattern file,77Indicator pattern can be set through /sys/class/leds/indicator/pattern file,
78and 4 patterns are pre-defined in indicator_pattern array.78and 4 patterns are pre-defined in indicator_pattern array.
79 79
80According to N-lank, Pulse time and N Period values, different pattern wiill80According to N-lank, Pulse time and N Period values, different pattern wiill
@@ -87,13 +87,13 @@ Indicator pattern example: · 6 unmodified lines
87 87
88pattern 0::88pattern 0::
89 89
90 #echo 0 > sys/class/leds/indicator/pattern90 #echo 0 > /sys/class/leds/indicator/pattern
91 91
92...92...
93 93
94pattern 3::94pattern 3::
95 95
96 #echo 3 > sys/class/leds/indicator/pattern96 #echo 3 > /sys/class/leds/indicator/pattern
97 97
98Indicator brightness can be controlled through98Indicator brightness can be controlled through
99sys/class/leds/indicator/brightness file.99sys/class/leds/indicator/brightness file.
@@ -102,17 +102,17 @@ Example: · 2 unmodified lines
102 102
103OFF::103OFF::
104 104
105 #echo 0 > sys/class/leds/indicator/brightness105 #echo 0 > /sys/class/leds/indicator/brightness
106 106
1075.86 mA::1075.86 mA::
108 108
109 #echo 1 > sys/class/leds/indicator/brightness109 #echo 1 > /sys/class/leds/indicator/brightness
110 110
111...111...
112 112
11346.875mA::11346.875mA::
114 114
115 #echo 8 > sys/class/leds/indicator/brightness115 #echo 8 > /sys/class/leds/indicator/brightness
116 116
117Notes117Notes
118-----118-----
Documentation/livepatch/shadow-vars.rst+2−2
@@ -165,8 +165,8 @@ In-flight parent objects · 164 unmodified lines
165 165
166Sometimes it may not be convenient or possible to allocate shadow166Sometimes it may not be convenient or possible to allocate shadow
167variables alongside their parent objects. Or a livepatch fix may167variables alongside their parent objects. Or a livepatch fix may
168require shadow varibles to only a subset of parent object instances. In168require shadow variables for only a subset of parent object instances.
169these cases, the klp_shadow_get_or_alloc() call can be used to attach169In these cases, the klp_shadow_get_or_alloc() call can be used to attach
170shadow variables to parents already in-flight.170shadow variables to parents already in-flight.
171 171
172For commit 1d147bfa6429, a good spot to allocate a shadow spinlock is172For commit 1d147bfa6429, a good spot to allocate a shadow spinlock is
Documentation/powerpc/booting.rst+1−1
@@ -94,7 +94,7 @@ should: · 93 unmodified lines
94 94
95 a) add your platform support as a _boolean_ option in95 a) add your platform support as a _boolean_ option in
96 arch/powerpc/Kconfig, following the example of PPC_PSERIES,96 arch/powerpc/Kconfig, following the example of PPC_PSERIES,
97 PPC_PMAC and PPC_MAPLE. The later is probably a good97 PPC_PMAC and PPC_MAPLE. The latter is probably a good
98 example of a board support to start from.98 example of a board support to start from.
99 99
100 b) create your main platform file as100 b) create your main platform file as
Documentation/powerpc/dawr-power9.rst+1−1
@@ -4,7 +4,7 @@ DAWR issues on POWER9 · 3 unmodified lines
4 4
5On POWER9 the Data Address Watchpoint Register (DAWR) can cause a checkstop5On POWER9 the Data Address Watchpoint Register (DAWR) can cause a checkstop
6if it points to cache inhibited (CI) memory. Currently Linux has no way to6if it points to cache inhibited (CI) memory. Currently Linux has no way to
7disinguish CI memory when configuring the DAWR, so (for now) the DAWR is7distinguish CI memory when configuring the DAWR, so (for now) the DAWR is
8disabled by this commit::8disabled by this commit::
9 9
10 commit 9654153158d3e0684a1bdb76dbababdb7111d5a010 commit 9654153158d3e0684a1bdb76dbababdb7111d5a0
Documentation/powerpc/eeh-pci-error-recovery.rst+1−1
@@ -73,7 +73,7 @@ return all-ff's (0xff, 0xffff, 0xffffffff for 8/16/32-bit reads). · 72 unmodified lines
73This value was chosen because it is the same value you would73This value was chosen because it is the same value you would
74get if the device was physically unplugged from the slot.74get if the device was physically unplugged from the slot.
75This includes access to PCI memory, I/O space, and PCI config75This includes access to PCI memory, I/O space, and PCI config
76space. Interrupts; however, will continued to be delivered.76space. Interrupts; however, will continue to be delivered.
77 77
78Detection and recovery are performed with the aid of ppc6478Detection and recovery are performed with the aid of ppc64
79firmware. The programming interfaces in the Linux kernel79firmware. The programming interfaces in the Linux kernel
Documentation/powerpc/elfnote.rst+1−1
@@ -8,7 +8,7 @@ capabilities and information which can be used by a bootloader or userland. · 7 unmodified lines
8Types and Descriptors8Types and Descriptors
9---------------------9---------------------
10 10
11The types to be used with the "PowerPC" namesapce are defined in [#f1]_.11The types to be used with the "PowerPC" namespace are defined in [#f1]_.
12 12
13 1) PPC_ELFNOTE_CAPABILITIES13 1) PPC_ELFNOTE_CAPABILITIES
14 14
Documentation/powerpc/firmware-assisted-dump.rst+2−2
@@ -171,7 +171,7 @@ that were present in CMA region:: · 170 unmodified lines
171 (meta area) |171 (meta area) |
172 |172 |
173 |173 |
174 Metadata: This area holds a metadata struture whose174 Metadata: This area holds a metadata structure whose
175 address is registered with f/w and retrieved in the175 address is registered with f/w and retrieved in the
176 second kernel after crash, on platforms that support176 second kernel after crash, on platforms that support
177 tags (OPAL). Having such structure with info needed177 tags (OPAL). Having such structure with info needed
@@ -207,7 +207,7 @@ Currently the dump will be copied from /proc/vmcore to a new file upon · 29 unmodified lines
207user intervention. The dump data available through /proc/vmcore will be207user intervention. The dump data available through /proc/vmcore will be
208in ELF format. Hence the existing kdump infrastructure (kdump scripts)208in ELF format. Hence the existing kdump infrastructure (kdump scripts)
209to save the dump works fine with minor modifications. KDump scripts on209to save the dump works fine with minor modifications. KDump scripts on
210major Distro releases have already been modified to work seemlessly (no210major Distro releases have already been modified to work seamlessly (no
211user intervention in saving the dump) when FADump is used, instead of211user intervention in saving the dump) when FADump is used, instead of
212KDump, as dump mechanism.212KDump, as dump mechanism.
213 213
Documentation/powerpc/kaslr-booke32.rst+1−1
@@ -38,5 +38,5 @@ bit of the entropy to decide the index of the 64M zone. Then we chose a · 37 unmodified lines
38 38
39 kernstart_virt_addr39 kernstart_virt_addr
40 40
41To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enable and you41To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enabled and you
42want to disable it at runtime, add "nokaslr" to the kernel cmdline.42want to disable it at runtime, add "nokaslr" to the kernel cmdline.
Documentation/powerpc/mpc52xx.rst+1−1
@@ -34,7 +34,7 @@ To compile/use : · 33 unmodified lines
34Some remarks:34Some remarks:
35 35
36 - The port is named mpc52xxx, and config options are PPC_MPC52xx. The MGT510036 - The port is named mpc52xxx, and config options are PPC_MPC52xx. The MGT5100
37 is not supported, and I'm not sure anyone is interesting in working on it37 is not supported, and I'm not sure anyone is interested in working on it
38 so. I didn't took 5xxx because there's apparently a lot of 5xxx that have38 so. I didn't took 5xxx because there's apparently a lot of 5xxx that have
39 nothing to do with the MPC5200. I also included the 'MPC' for the same39 nothing to do with the MPC5200. I also included the 'MPC' for the same
40 reason.40 reason.
Documentation/powerpc/papr_hcalls.rst+2−2
@@ -40,7 +40,7 @@ and any in-arguments for the hcall are provided in registers *r4-r12*. If values · 39 unmodified lines
40have to be passed through a memory buffer, the data stored in that buffer should be40have to be passed through a memory buffer, the data stored in that buffer should be
41in Big-endian byte order.41in Big-endian byte order.
42 42
43Once control is returns back to the guest after hypervisor has serviced the43Once control returns back to the guest after hypervisor has serviced the
44'HVCS' instruction the return value of the hcall is available in *r3* and any44'HVCS' instruction the return value of the hcall is available in *r3* and any
45out values are returned in registers *r4-r12*. Again like in case of in-arguments,45out values are returned in registers *r4-r12*. Again like in case of in-arguments,
46any out values stored in a memory buffer will be in Big-endian byte order.46any out values stored in a memory buffer will be in Big-endian byte order.
@@ -147,7 +147,7 @@ corresponding opcode values please look into the arch specific header [4]_: · 100 unmodified lines
147| Out: *numBytesRead*147| Out: *numBytesRead*
148| Return Value: *H_Success, H_Parameter, H_P2, H_P3, H_Hardware*148| Return Value: *H_Success, H_Parameter, H_P2, H_P3, H_Hardware*
149 149
150Given a DRC Index of an NVDIMM, read N-bytes from the the metadata area150Given a DRC Index of an NVDIMM, read N-bytes from the metadata area
151associated with it, at a specified offset and copy it to provided buffer.151associated with it, at a specified offset and copy it to provided buffer.
152The metadata area stores configuration information such as label information,152The metadata area stores configuration information such as label information,
153bad-blocks etc. The metadata area is located out-of-band of NVDIMM storage153bad-blocks etc. The metadata area is located out-of-band of NVDIMM storage
Documentation/powerpc/transactional_memory.rst+2−2
@@ -189,7 +189,7 @@ kernel aborted a transaction: · 188 unmodified lines
189 ====================== ================================189 ====================== ================================
190 190
191These can be checked by the user program's abort handler as TEXASR[0:7]. If191These can be checked by the user program's abort handler as TEXASR[0:7]. If
192bit 7 is set, it indicates that the error is consider persistent. For example192bit 7 is set, it indicates that the error is considered persistent. For example
193a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.193a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.
194 194
195GDB195GDB
@@ -271,4 +271,4 @@ with these lines: · 75 unmodified lines
271 271
272hrfid and mtmsrd have the same quirk.272hrfid and mtmsrd have the same quirk.
273 273
274The Linux kernel uses this quirk in it's early exception handling.274The Linux kernel uses this quirk in its early exception handling.
Documentation/process/submitting-patches.rst+67−34
@@ -341,6 +341,16 @@ that you have sent your patches to the right place. Wait for a minimum of · 340 unmodified lines
341one week before resubmitting or pinging reviewers - possibly longer during341one week before resubmitting or pinging reviewers - possibly longer during
342busy times like merge windows.342busy times like merge windows.
343 343
344It's also ok to resend the patch or the patch series after a couple of
345weeks with the word "RESEND" added to the subject line::
346
347 [PATCH Vx RESEND] sub/sys: Condensed patch summary
348
349Don't add "RESEND" when you are submitting a modified version of your
350patch or patch series - "RESEND" only applies to resubmission of a
351patch or patch series which have not been modified in any way from the
352previous submission.
353
344 354
345Include PATCH in the subject355Include PATCH in the subject
346-----------------------------356-----------------------------
@@ -625,16 +635,19 @@ not considered part of the summary phrase, but describe how the patch · 278 unmodified lines
625should be treated. Common tags might include a version descriptor if635should be treated. Common tags might include a version descriptor if
626the multiple versions of the patch have been sent out in response to636the multiple versions of the patch have been sent out in response to
627comments (i.e., "v1, v2, v3"), or "RFC" to indicate a request for637comments (i.e., "v1, v2, v3"), or "RFC" to indicate a request for
628comments. If there are four patches in a patch series the individual638comments.
629patches may be numbered like this: 1/4, 2/4, 3/4, 4/4. This assures
630that developers understand the order in which the patches should be
631applied and that they have reviewed or applied all of the patches in
632the patch series.
633 639
634A couple of example Subjects::640If there are four patches in a patch series the individual patches may
641be numbered like this: 1/4, 2/4, 3/4, 4/4. This assures that developers
642understand the order in which the patches should be applied and that
643they have reviewed or applied all of the patches in the patch series.
644
645Here are some good example Subjects::
635 646
636 Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching647 Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching
637 Subject: [PATCH v2 01/27] x86: fix eflags tracking648 Subject: [PATCH v2 01/27] x86: fix eflags tracking
649 Subject: [PATCH v2] sub/sys: Condensed patch summary
650 Subject: [PATCH v2 M/N] sub/sys: Condensed patch summary
638 651
639The ``from`` line must be the very first line in the message body,652The ``from`` line must be the very first line in the message body,
640and has the form:653and has the form:
@@ -647,34 +660,54 @@ then the ``From:`` line from the email header will be used to determine · 6 unmodified lines
647the patch author in the changelog.660the patch author in the changelog.
648 661
649The explanation body will be committed to the permanent source662The explanation body will be committed to the permanent source
650changelog, so should make sense to a competent reader who has long663changelog, so should make sense to a competent reader who has long since
651since forgotten the immediate details of the discussion that might664forgotten the immediate details of the discussion that might have led to
652have led to this patch. Including symptoms of the failure which the665this patch. Including symptoms of the failure which the patch addresses
653patch addresses (kernel log messages, oops messages, etc.) is666(kernel log messages, oops messages, etc.) are especially useful for
654especially useful for people who might be searching the commit logs667people who might be searching the commit logs looking for the applicable
655looking for the applicable patch. If a patch fixes a compile failure,668patch. The text should be written in such detail so that when read
656it may not be necessary to include _all_ of the compile failures; just669weeks, months or even years later, it can give the reader the needed
657enough that it is likely that someone searching for the patch can find670details to grasp the reasoning for **why** the patch was created.
658it. As in the ``summary phrase``, it is important to be both succinct as671
659well as descriptive.672If a patch fixes a compile failure, it may not be necessary to include
660 673_all_ of the compile failures; just enough that it is likely that
661The ``---`` marker line serves the essential purpose of marking for patch674someone searching for the patch can find it. As in the ``summary
662handling tools where the changelog message ends.675phrase``, it is important to be both succinct as well as descriptive.
663 676
664One good use for the additional comments after the ``---`` marker is for677The ``---`` marker line serves the essential purpose of marking for
665a ``diffstat``, to show what files have changed, and the number of678patch handling tools where the changelog message ends.
666inserted and deleted lines per file. A ``diffstat`` is especially useful679
667on bigger patches. Other comments relevant only to the moment or the680One good use for the additional comments after the ``---`` marker is
668maintainer, not suitable for the permanent changelog, should also go681for a ``diffstat``, to show what files have changed, and the number of
669here. A good example of such comments might be ``patch changelogs``682inserted and deleted lines per file. A ``diffstat`` is especially useful
670which describe what has changed between the v1 and v2 version of the683on bigger patches. If you are going to include a ``diffstat`` after the
671patch.684``---`` marker, please use ``diffstat`` options ``-p 1 -w 70`` so that
672 685filenames are listed from the top of the kernel source tree and don't
673If you are going to include a ``diffstat`` after the ``---`` marker, please686use too much horizontal space (easily fit in 80 columns, maybe with some
674use ``diffstat`` options ``-p 1 -w 70`` so that filenames are listed from687indentation). (``git`` generates appropriate diffstats by default.)
675the top of the kernel source tree and don't use too much horizontal688
676space (easily fit in 80 columns, maybe with some indentation). (``git``689Other comments relevant only to the moment or the maintainer, not
677generates appropriate diffstats by default.)690suitable for the permanent changelog, should also go here. A good
691example of such comments might be ``patch changelogs`` which describe
692what has changed between the v1 and v2 version of the patch.
693
694Please put this information **after** the ``---`` line which separates
695the changelog from the rest of the patch. The version information is
696not part of the changelog which gets committed to the git tree. It is
697additional information for the reviewers. If it's placed above the
698commit tags, it needs manual interaction to remove it. If it is below
699the separator line, it gets automatically stripped off when applying the
700patch::
701
702 <commit message>
703 ...
704 Signed-off-by: Author <author@mail>
705 ---
706 V2 -> V3: Removed redundant helper function
707 V1 -> V2: Cleaned up coding style and addressed review comments
708
709 path/to/file | 5+++--
710 ...
678 711
679See more details on the proper patch format in the following712See more details on the proper patch format in the following
680references.713references.
Documentation/scsi/ChangeLog.megaraid+1−1
@@ -220,7 +220,7 @@ Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) · 219 unmodified lines
220 220
2214. Use the pre defined DMA mask constants from dma-mapping.h2214. Use the pre defined DMA mask constants from dma-mapping.h
222 Use the DMA_{64,32}BIT_MASK constants from dma-mapping.h when calling222 Use the DMA_{64,32}BIT_MASK constants from dma-mapping.h when calling
223 pci_set_dma_mask() or pci_set_consistend_dma_mask(). See223 pci_set_dma_mask() or pci_set_consistent_dma_mask(). See
224 http://marc.theaimsgroup.com/?t=108001993000001&r=1&w=2 for more224 http://marc.theaimsgroup.com/?t=108001993000001&r=1&w=2 for more
225 details.225 details.
226 Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch>226 Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch>
Documentation/sphinx/rstFlatTable.py+2−2
@@ -22,7 +22,7 @@ u""" · 21 unmodified lines
22 22
23 * *auto span* rightmost cell of a table row over the missing cells on the23 * *auto span* rightmost cell of a table row over the missing cells on the
24 right side of that table-row. With Option ``:fill-cells:`` this behavior24 right side of that table-row. With Option ``:fill-cells:`` this behavior
25 can changed from *auto span* to *auto fill*, which automaticly inserts25 can be changed from *auto span* to *auto fill*, which automatically inserts
26 (empty) cells instead of spanning the last cell.26 (empty) cells instead of spanning the last cell.
27 27
28 Options:28 Options:
@@ -161,7 +161,7 @@ class ListTableBuilder(object): · 132 unmodified lines
161 for colwidth in colwidths:161 for colwidth in colwidths:
162 colspec = nodes.colspec(colwidth=colwidth)162 colspec = nodes.colspec(colwidth=colwidth)
163 # FIXME: It seems, that the stub method only works well in the163 # FIXME: It seems, that the stub method only works well in the
164 # absence of rowspan (observed by the html buidler, the docutils-xml164 # absence of rowspan (observed by the html builder, the docutils-xml
165 # build seems OK). This is not extraordinary, because there exists165 # build seems OK). This is not extraordinary, because there exists
166 # no table directive (except *this* flat-table) which allows to166 # no table directive (except *this* flat-table) which allows to
167 # define coexistent of rowspan and stubs (there was no use-case167 # define coexistent of rowspan and stubs (there was no use-case
Documentation/spi/butterfly.rst+1−1
@@ -11,7 +11,7 @@ develop firmware for this, and flash it using this adapter cable. · 10 unmodified lines
11 11
12You can make this adapter from an old printer cable and solder things12You can make this adapter from an old printer cable and solder things
13directly to the Butterfly. Or (if you have the parts and skills) you13directly to the Butterfly. Or (if you have the parts and skills) you
14can come up with something fancier, providing ciruit protection to the14can come up with something fancier, providing circuit protection to the
15Butterfly and the printer port, or with a better power supply than two15Butterfly and the printer port, or with a better power supply than two
16signal pins from the printer port. Or for that matter, you can use16signal pins from the printer port. Or for that matter, you can use
17similar cables to talk to many AVR boards, even a breadboard.17similar cables to talk to many AVR boards, even a breadboard.
Documentation/translations/it_IT/doc-guide/sphinx.rst+28−19
@@ -330,17 +330,17 @@ la lista di celle che compongono la *riga* stessa. Fanno eccezione i *commenti* · 329 unmodified lines
330 - head col 3330 - head col 3
331 - head col 4331 - head col 4
332 332
333 * - column 1333 * - row 1
334 - field 1.1334 - field 1.1
335 - field 1.2 with autospan335 - field 1.2 with autospan
336 336
337 * - column 2337 * - row 2
338 - field 2.1338 - field 2.1
339 - :rspan:`1` :cspan:`1` field 2.2 - 3.3339 - :rspan:`1` :cspan:`1` field 2.2 - 3.3
340 340
341 * .. _`it last row`:341 * .. _`it last row`:
342 342
343 - column 3343 - row 3
344 344
345Che verrà rappresentata nel seguente modo:345Che verrà rappresentata nel seguente modo:
346 346
@@ -352,37 +352,46 @@ Che verrà rappresentata nel seguente modo: · 5 unmodified lines
352 - head col 3352 - head col 3
353 - head col 4353 - head col 4
354 354
355 * - column 1355 * - row 1
356 - field 1.1356 - field 1.1
357 - field 1.2 with autospan357 - field 1.2 with autospan
358 358
359 * - column 2359 * - row 2
360 - field 2.1360 - field 2.1
361 - :rspan:`1` :cspan:`1` field 2.2 - 3.3361 - :rspan:`1` :cspan:`1` field 2.2 - 3.3
362 362
363 * .. _`it last row`:363 * .. _`it last row`:
364 364
365 - column 3365 - row 3
366 366
367Riferimenti incrociati367Riferimenti incrociati
368----------------------368----------------------
369 369
370Per fare dei riferimenti incrociati da una pagina ad un'altra370Aggiungere un riferimento incrociato da una pagina della
371specificando il percorso a partire dalla cartella *Documentation*.371documentazione ad un'altra può essere fatto scrivendo il percorso al
372Per esempio, se volete aggiungere un riferimento a questa pagina372file corrispondende, non serve alcuna sintassi speciale. Si possono
373(l'estensione .rst è opzionale)::373usare sia percorsi assoluti che relativi. Quelli assoluti iniziano con
374"documentation/". Per esempio, potete fare riferimento a questo
375documento in uno dei seguenti modi (da notare che l'estensione
376``.rst`` è necessaria)::
374 377
375 See Documentation/translations/it_IT/doc-guide/sphinx.rst.378 Vedere Documentation/doc-guide/sphinx.rst. Questo funziona sempre
379 Guardate pshinx.rst, che si trova nella stessa cartella.
380 Leggete ../sphinx.rst, che si trova nella cartella precedente.
376 381
377Se preferite usare un percorso relative allora vi serve la direttiva382Se volete che il collegamento abbia un testo diverso rispetto al
378Sphinx ``doc``. Per esempio, se volete aggiungere un riferimento a383titolo del documento, allora dovrete usare la direttiva Sphinx
379questa pagina dalla stessa cartella::384``doc``. Per esempio::
380 385
381 See :doc:`sphinx`.386 Vedere :doc:`il mio testo per il collegamento <sphinx>`.
382 387
383Per maggiori informazioni su come aggiungere riferimenti incrociati a388Nella maggioranza dei casi si consiglia il primo metodo perché è più
384commenti kernel-doc di funzioni o tipi, leggete389pulito ed adatto a chi legge dai sorgenti. Se incontrare un ``:doc:``
385Documentation/translations/it_IT/doc-guide/sphinx.rst.390che non da alcun valore, sentitevi liberi di convertirlo in un
391percorso al documento.
392
393Per informazioni riguardo ai riferimenti incrociati ai commenti
394kernel-doc per funzioni o tipi, consultate
386 395
387.. _it_sphinx_kfigure:396.. _it_sphinx_kfigure:
388 397
@@ -391,7 +400,7 @@ Figure ed immagini · 2 unmodified lines
391 400
392Se volete aggiungere un'immagine, utilizzate le direttive ``kernel-figure``401Se volete aggiungere un'immagine, utilizzate le direttive ``kernel-figure``
393e ``kernel-image``. Per esempio, per inserire una figura di un'immagine in402e ``kernel-image``. Per esempio, per inserire una figura di un'immagine in
394formato SVG::403formato SVG (:ref:`it_svg_image_example`)::
395 404
396 .. kernel-figure:: ../../../doc-guide/svg_image.svg405 .. kernel-figure:: ../../../doc-guide/svg_image.svg
397 :alt: una semplice immagine SVG406 :alt: una semplice immagine SVG
Documentation/translations/it_IT/kernel-hacking/hacking.rst+1−1
@@ -369,7 +369,7 @@ all'inizio dell'avvio del sistema è attraverso la procedura · 368 unmodified lines
369Prima di inventare la vostra cache per gli oggetti più usati, considerate369Prima di inventare la vostra cache per gli oggetti più usati, considerate
370l'uso di una cache slab disponibile in ``include/linux/slab.h``.370l'uso di una cache slab disponibile in ``include/linux/slab.h``.
371 371
372:c:func:`current()`372:c:macro:`current`
373-------------------373-------------------
374 374
375Definita in ``include/asm/current.h``375Definita in ``include/asm/current.h``
Documentation/translations/it_IT/kernel-hacking/locking.rst+4−8
@@ -127,11 +127,11 @@ il vostro processo si auto-sospenderà; verrà riattivato quando il mutex · 126 unmodified lines
127verrà rilasciato. Questo significa che il processore potrà occuparsi d'altro127verrà rilasciato. Questo significa che il processore potrà occuparsi d'altro
128mentre il vostro processo è in attesa. Esistono molti casi in cui non potete128mentre il vostro processo è in attesa. Esistono molti casi in cui non potete
129permettervi di sospendere un processo (vedere129permettervi di sospendere un processo (vedere
130:ref:`Quali funzioni possono essere chiamate in modo sicuro dalle interruzioni? <it_sleeping-things>`)130`Quali funzioni possono essere chiamate in modo sicuro dalle interruzioni?`_)
131e quindi dovrete utilizzare gli spinlock.131e quindi dovrete utilizzare gli spinlock.
132 132
133Nessuno di questi *lock* è ricorsivo: vedere133Nessuno di questi *lock* è ricorsivo: vedere
134:ref:`Stallo: semplice ed avanzato <it_deadlock>`134`Stallo: semplice ed avanzato`_
135 135
136I *lock* e i kernel per sistemi monoprocessore136I *lock* e i kernel per sistemi monoprocessore
137----------------------------------------------137----------------------------------------------
@@ -190,7 +190,7 @@ perfetto questa funzione si chiamerebbe 'spin_lock_softirq()'). · 52 unmodified lines
190 190
191Da notare che in questo caso potete utilizzare anche spin_lock_irq()191Da notare che in questo caso potete utilizzare anche spin_lock_irq()
192o spin_lock_irqsave(), queste fermano anche le interruzioni hardware:192o spin_lock_irqsave(), queste fermano anche le interruzioni hardware:
193vedere :ref:`Contesto di interruzione hardware <it_hardirq-context>`.193vedere `Contesto di interruzione hardware`_.
194 194
195Questo funziona alla perfezione anche sui sistemi monoprocessore: gli spinlock195Questo funziona alla perfezione anche sui sistemi monoprocessore: gli spinlock
196svaniscono e questa macro diventa semplicemente local_bh_disable()196svaniscono e questa macro diventa semplicemente local_bh_disable()
@@ -241,7 +241,7 @@ Lo stesso softirq · 44 unmodified lines
241 241
242Lo stesso softirq può essere eseguito su un diverso processore: allo scopo242Lo stesso softirq può essere eseguito su un diverso processore: allo scopo
243di migliorare le prestazioni potete utilizzare dati riservati ad ogni243di migliorare le prestazioni potete utilizzare dati riservati ad ogni
244processore (vedere :ref:`Dati per processore <it_per-cpu>`). Se siete arrivati244processore (vedere `Dati per processore`_). Se siete arrivati
245fino a questo punto nell'uso dei softirq, probabilmente tenete alla scalabilità245fino a questo punto nell'uso dei softirq, probabilmente tenete alla scalabilità
246delle prestazioni abbastanza da giustificarne la complessità aggiuntiva.246delle prestazioni abbastanza da giustificarne la complessità aggiuntiva.
247 247
@@ -896,8 +896,6 @@ leggendo solamente il codice. E come dice Alan Cox: “Lock data, not code”. · 648 unmodified lines
896Problemi comuni896Problemi comuni
897===============897===============
898 898
899.. _`it_deadlock`:
900
901Stallo: semplice ed avanzato899Stallo: semplice ed avanzato
902----------------------------900----------------------------
903 901
@@ -1282,7 +1280,6 @@ Il beneficio qui sta nel fatto che il contatore di riferimenti no · 378 unmodified lines
1282viene scritto: l'oggetto non viene alterato in alcun modo e quindi diventa1280viene scritto: l'oggetto non viene alterato in alcun modo e quindi diventa
1283molto più veloce su sistemi molti-processore grazie alla loro memoria cache.1281molto più veloce su sistemi molti-processore grazie alla loro memoria cache.
1284 1282
1285.. _`it_per-cpu`:
1286 1283
1287Dati per processore1284Dati per processore
1288-------------------1285-------------------
@@ -1333,7 +1330,6 @@ Naturalmente, questo è più lento della semplice chiamata · 44 unmodified lines
1333spin_lock_irq(), quindi ha senso solo se questo genere di accesso1330spin_lock_irq(), quindi ha senso solo se questo genere di accesso
1334è estremamente raro.1331è estremamente raro.
1335 1332
1336.. _`it_sleeping-things`:
1337 1333
1338Quali funzioni possono essere chiamate in modo sicuro dalle interruzioni?1334Quali funzioni possono essere chiamate in modo sicuro dalle interruzioni?
1339=========================================================================1335=========================================================================
Documentation/translations/it_IT/process/4.Coding.rst+4−5
@@ -264,11 +264,10 @@ La maggior parte di queste opzioni possono essere attivate per qualsiasi · 263 unmodified lines
264kernel utilizzato per lo sviluppo o a scopo di test. In particolare dovreste264kernel utilizzato per lo sviluppo o a scopo di test. In particolare dovreste
265attivare:265attivare:
266 266
267 - ENABLE_MUST_CHECK e FRAME_WARN per ottenere degli267 - FRAME_WARN per ottenere degli avvertimenti su stack frame più
268 avvertimenti dedicati a problemi come l'uso di interfacce deprecate o268 grandi di un dato valore. Il risultato generato da questi
269 l'ignorare un importante valore di ritorno di una funzione. Il risultato269 avvertimenti può risultare verboso, ma non bisogna preoccuparsi per
270 generato da questi avvertimenti può risultare verboso, ma non bisogna270 gli avvertimenti provenienti da altre parti del kernel.
271 preoccuparsi per gli avvertimenti provenienti da altre parti del kernel.
272 271
273 - DEBUG_OBJECTS aggiungerà un codice per tracciare il ciclo di vita di272 - DEBUG_OBJECTS aggiungerà un codice per tracciare il ciclo di vita di
274 diversi oggetti creati dal kernel e avvisa quando qualcosa viene eseguito273 diversi oggetti creati dal kernel e avvisa quando qualcosa viene eseguito
Documentation/translations/it_IT/process/adding-syscalls.rst+1−1
@@ -562,7 +562,7 @@ kernel. Se la nuova funzionalità è utile all'interno del kernel, per esempio · 561 unmodified lines
562dev'essere condivisa fra una vecchia e una nuova chiamata di sistema o562dev'essere condivisa fra una vecchia e una nuova chiamata di sistema o
563dev'essere utilizzata da una chiamata di sistema e la sua variante compatibile,563dev'essere utilizzata da una chiamata di sistema e la sua variante compatibile,
564allora dev'essere implementata come una funzione di supporto564allora dev'essere implementata come una funzione di supporto
565(*helper function*) (per esempio ``kern_xyzzy()``). Questa funzione potrà565(*helper function*) (per esempio ``ksys_xyzzy()``). Questa funzione potrà
566essere chiamata dallo *stub* (``sys_xyzzy()``), dalla variante compatibile566essere chiamata dallo *stub* (``sys_xyzzy()``), dalla variante compatibile
567(``compat_sys_xyzzy()``), e/o da altri parti del kernel.567(``compat_sys_xyzzy()``), e/o da altri parti del kernel.
568 568
Documentation/translations/it_IT/process/coding-style.rst+19−3
@@ -75,9 +75,26 @@ stessa riga: · 74 unmodified lines
75 if (condition) do_this;75 if (condition) do_this;
76 do_something_everytime;76 do_something_everytime;
77 77
78né mettete più assegnamenti sulla stessa riga. Lo stile del kernel78Non usate le virgole per evitare le parentesi:
79
80.. code-block:: c
81
82 if (condition)
83 do_this(), do_that();
84
85Invece, usate sempre le parentesi per racchiudere più istruzioni.
86
87.. code-block:: c
88
89 if (condition) {
90 do_this();
91 do_that();
92 }
93
94Non mettete nemmeno più assegnamenti sulla stessa riga. Lo stile del kernel
79è ultrasemplice. Evitate espressioni intricate.95è ultrasemplice. Evitate espressioni intricate.
80 96
97
81Al di fuori dei commenti, della documentazione ed escludendo i Kconfig, gli98Al di fuori dei commenti, della documentazione ed escludendo i Kconfig, gli
82spazi non vengono mai usati per l'indentazione, e l'esempio qui sopra è99spazi non vengono mai usati per l'indentazione, e l'esempio qui sopra è
83volutamente errato.100volutamente errato.
@@ -320,8 +337,7 @@ qualcosa di simile, **non** dovreste chiamarla ``cntusr()``. · 236 unmodified lines
320 337
321Codificare il tipo di funzione nel suo nome (quella cosa chiamata notazione338Codificare il tipo di funzione nel suo nome (quella cosa chiamata notazione
322ungherese) è stupido - il compilatore conosce comunque il tipo e339ungherese) è stupido - il compilatore conosce comunque il tipo e
323può verificarli, e inoltre confonde i programmatori. Non c'è da340può verificarli, e inoltre confonde i programmatori.
324sorprendersi che MicroSoft faccia programmi bacati.
325 341
326Le variabili LOCALI dovrebbero avere nomi corti, e significativi. Se avete342Le variabili LOCALI dovrebbero avere nomi corti, e significativi. Se avete
327un qualsiasi contatore di ciclo, probabilmente sarà chiamato ``i``.343un qualsiasi contatore di ciclo, probabilmente sarà chiamato ``i``.
Documentation/translations/it_IT/process/howto.rst+12−13
@@ -357,17 +357,10 @@ benvenuti. · 356 unmodified lines
357Riportare Bug357Riportare Bug
358-------------358-------------
359 359
360https://bugzilla.kernel.org è dove gli sviluppatori del kernel Linux tracciano360Il file 'Documentation/admin-guide/reporting-issues.rst' nella
361i bachi del kernel. Gli utenti sono incoraggiati nel riportare tutti i bachi361cartella principale del kernel spiega come segnalare un baco nel
362che trovano utilizzando questo strumento.362kernel, e fornisce dettagli su quali informazioni sono necessarie agli
363Per maggiori dettagli su come usare il bugzilla del kernel, guardare:363sviluppatori del kernel per poter studiare il problema.
364
365 https://bugzilla.kernel.org/page.cgi?id=faq.html
366
367Il file admin-guide/reporting-bugs.rst nella cartella principale del kernel
368fornisce un buon modello sul come segnalare un baco nel kernel, e spiega quali
369informazioni sono necessarie agli sviluppatori per poter aiutare il
370rintracciamento del problema.
371 364
372Gestire i rapporti sui bug365Gestire i rapporti sui bug
373--------------------------366--------------------------
@@ -380,8 +373,14 @@ al corrente della vostra presenza. Riparare bachi è una delle migliori vie per · 6 unmodified lines
380acquisire meriti tra gli altri sviluppatori, perchè non a molte persone piace373acquisire meriti tra gli altri sviluppatori, perchè non a molte persone piace
381perdere tempo a sistemare i bachi di altri.374perdere tempo a sistemare i bachi di altri.
382 375
383Per lavorare sui rapporti di bachi già riportati, andate su376Per lavorare sui bachi già segnalati, per prima cosa cercate il
384https://bugzilla.kernel.org.377sottosistema che vi interessa. Poi, verificate nel file MAINTAINERS
378dove vengono collezionati solitamente i bachi per quel sottosistema;
379spesso sarà una lista di discussione, raramente un bugtracker. Cercate
380bachi nell'archivio e aiutate dove credete di poterlo fare. Potete
381anche consultare https://bugzilla.kernel.org; però, solo una manciata di
382sottosistemi lo usano attivamente, ciò nonostante i bachi che
383coinvolgono l'intero kernel sono sempre riportati lì.
385 384
386Liste di discussione385Liste di discussione
387--------------------386--------------------
Documentation/translations/it_IT/process/magic-number.rst+0−2
@@ -101,7 +101,6 @@ RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/ · 100 unmodified lines
101USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h``101USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h``
102CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h``102CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h``
103LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c``103LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c``
104GDTIOCTL_MAGIC 0x06030f07 gdth_iowr_str ``drivers/scsi/gdth_ioctl.h``
105RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c``104RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c``
106NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h``105NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h``
107RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c``106RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c``
@@ -144,7 +143,6 @@ PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/me · 36 unmodified lines
144NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h``143NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h``
145ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h``144ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h``
146CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h``145CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h``
147DPMEM_MAGIC 0xc0ffee11 gdt_pci_sram ``drivers/scsi/gdth.h``
148YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c``146YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c``
149CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``147CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
150QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c``148QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c``
Documentation/translations/it_IT/process/submit-checklist.rst+11−10
@@ -28,6 +28,10 @@ sottomissione delle patch, in particolare · 27 unmodified lines
28 28
29 c) quando si usa ``O=builddir``29 c) quando si usa ``O=builddir``
30 30
31 d) Qualsiasi modifica in Documentation/ deve compilare con successo senza
32 avvisi o errori. Usare ``make htmldocs`` o ``make pdfdocs`` per verificare
33 e correggere i problemi
34
313) Compilare per diverse architetture di processore usando strumenti per353) Compilare per diverse architetture di processore usando strumenti per
32 la cross-compilazione o altri.36 la cross-compilazione o altri.
33 37
@@ -54,8 +58,7 @@ sottomissione delle patch, in particolare · 20 unmodified lines
54 58
559) Verificare con sparse.599) Verificare con sparse.
56 60
5710) Usare ``make checkstack`` e ``make namespacecheck`` e correggere tutti i6110) Usare ``make checkstack`` e correggere tutti i problemi rilevati.
58 problemi rilevati.
59 62
60 .. note::63 .. note::
61 64
@@ -95,31 +98,29 @@ sottomissione delle patch, in particolare · 33 unmodified lines
95 informazioni. Le patch che modificano le interfacce utente dovrebbero98 informazioni. Le patch che modificano le interfacce utente dovrebbero
96 essere inviate in copia anche a linux-api@vger.kernel.org.99 essere inviate in copia anche a linux-api@vger.kernel.org.
97 100
9820) Verifica che il kernel passi con successo ``make headers_check``10120) La patch è stata verificata con l'iniezione di fallimenti in slab e
99
10021) La patch è stata verificata con l'iniezione di fallimenti in slab e
101 nell'allocazione di pagine. Vedere ``Documentation/fault-injection/``.102 nell'allocazione di pagine. Vedere ``Documentation/fault-injection/``.
102 103
103 Se il nuovo codice è corposo, potrebbe essere opportuno aggiungere104 Se il nuovo codice è corposo, potrebbe essere opportuno aggiungere
104 l'iniezione di fallimenti specifici per il sottosistema.105 l'iniezione di fallimenti specifici per il sottosistema.
105 106
10622) Il nuovo codice è stato compilato con ``gcc -W`` (usate10721) Il nuovo codice è stato compilato con ``gcc -W`` (usate
107 ``make KCFLAGS=-W``). Questo genererà molti avvisi, ma è ottimo108 ``make KCFLAGS=-W``). Questo genererà molti avvisi, ma è ottimo
108 per scovare bachi come "warning: comparison between signed and unsigned".109 per scovare bachi come "warning: comparison between signed and unsigned".
109 110
11023) La patch è stata verificata dopo essere stata inclusa nella serie di patch11122) La patch è stata verificata dopo essere stata inclusa nella serie di patch
111 -mm; questo al fine di assicurarsi che continui a funzionare assieme a112 -mm; questo al fine di assicurarsi che continui a funzionare assieme a
112 tutte le altre patch in coda e i vari cambiamenti nei sottosistemi VM, VFS113 tutte le altre patch in coda e i vari cambiamenti nei sottosistemi VM, VFS
113 e altri.114 e altri.
114 115
11524) Tutte le barriere di sincronizzazione {per esempio, ``barrier()``,11623) Tutte le barriere di sincronizzazione {per esempio, ``barrier()``,
116 ``rmb()``, ``wmb()``} devono essere accompagnate da un commento nei117 ``rmb()``, ``wmb()``} devono essere accompagnate da un commento nei
117 sorgenti che ne spieghi la logica: cosa fanno e perché.118 sorgenti che ne spieghi la logica: cosa fanno e perché.
118 119
11925) Se la patch aggiunge nuove chiamate ioctl, allora aggiornate12024) Se la patch aggiunge nuove chiamate ioctl, allora aggiornate
120 ``Documentation/userspace-api/ioctl/ioctl-number.rst``.121 ``Documentation/userspace-api/ioctl/ioctl-number.rst``.
121 122
12226) Se il codice che avete modificato dipende o usa una qualsiasi interfaccia o12325) Se il codice che avete modificato dipende o usa una qualsiasi interfaccia o
123 funzionalità del kernel che è associata a uno dei seguenti simboli124 funzionalità del kernel che è associata a uno dei seguenti simboli
124 ``Kconfig``, allora verificate che il kernel compili con diverse125 ``Kconfig``, allora verificate che il kernel compili con diverse
125 configurazioni dove i simboli sono disabilitati e/o ``=m`` (se c'è la126 configurazioni dove i simboli sono disabilitati e/o ``=m`` (se c'è la
Documentation/translations/it_IT/process/submitting-patches.rst+80−18
@@ -433,6 +433,14 @@ Alcune persone aggiungono delle etichette alla fine. Per ora queste verranno · 432 unmodified lines
433ignorate, ma potete farlo per meglio identificare procedure aziendali interne o433ignorate, ma potete farlo per meglio identificare procedure aziendali interne o
434per aggiungere dettagli circa la firma.434per aggiungere dettagli circa la firma.
435 435
436In seguito al SoB (Signed-off-by:) dell'autore ve ne sono altri da
437parte di tutte quelle persone che si sono occupate della gestione e
438del trasporto della patch. Queste però non sono state coinvolte nello
439sviluppo, ma la loro sequenza d'apparizione ci racconta il percorso
440**reale** che una patch a intrapreso dallo sviluppatore, fino al
441manutentore, per poi giungere a Linus.
442
443
436Quando utilizzare Acked-by:, Cc:, e Co-developed-by:444Quando utilizzare Acked-by:, Cc:, e Co-developed-by:
437----------------------------------------------------445----------------------------------------------------
438 446
@@ -574,6 +582,10 @@ kernel stabili al fine di capire quale kernel deve ricevere la correzione. · 135 unmodified lines
574Questo è il modo suggerito per indicare che un baco è stato corretto nella582Questo è il modo suggerito per indicare che un baco è stato corretto nella
575patch. Per maggiori dettagli leggete :ref:`it_describe_changes`583patch. Per maggiori dettagli leggete :ref:`it_describe_changes`
576 584
585Da notare che aggiungere un tag "Fixes:" non esime dalle regole
586previste per i kernel stabili, e nemmeno dalla necessità di aggiungere
587in copia conoscenza stable@vger.kernel.org su tutte le patch per
588suddetti kernel.
577 589
578Il formato canonico delle patch590Il formato canonico delle patch
579-------------------------------591-------------------------------
@@ -642,16 +654,20 @@ Le etichette non verranno considerate come parte della frase riassuntiva, ma · 62 unmodified lines
642indicano come la patch dovrebbe essere trattata. Fra le etichette più comuni654indicano come la patch dovrebbe essere trattata. Fra le etichette più comuni
643ci sono quelle di versione che vengono usate quando una patch è stata inviata655ci sono quelle di versione che vengono usate quando una patch è stata inviata
644più volte (per esempio, "v1, v2, v3"); oppure "RFC" per indicare che si656più volte (per esempio, "v1, v2, v3"); oppure "RFC" per indicare che si
645attendono dei commenti (*Request For Comments*). Se ci sono quattro patch657attendono dei commenti (*Request For Comments*).
646nella serie, queste dovrebbero essere enumerate così: 1/4, 2/4, 3/4, 4/4.658
647Questo assicura che gli sviluppatori capiranno l'ordine in cui le patch659Se ci sono quattro patch nella serie, queste dovrebbero essere
648dovrebbero essere applicate, e per tracciare quelle che hanno revisionate o660enumerate così: 1/4, 2/4, 3/4, 4/4. Questo assicura che gli
649che hanno applicato.661sviluppatori capiranno l'ordine in cui le patch dovrebbero essere
662applicate, e per tracciare quelle che hanno revisionate o che hanno
663applicato.
650 664
651Un paio di esempi di oggetti::665Un paio di esempi di oggetti::
652 666
653 Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching667 Subject: [PATCH 2/5] ext2: improve scalability of bitmap searching
654 Subject: [PATCH v2 01/27] x86: fix eflags tracking668 Subject: [PATCH v2 01/27] x86: fix eflags tracking
669 Subject: [PATCH v2] sub/sys: Condensed patch summary
670 Subject: [PATCH v2 M/N] sub/sys: Condensed patch summary
655 671
656La riga ``from`` dev'essere la prima nel corpo del messaggio ed è nel672La riga ``from`` dev'essere la prima nel corpo del messaggio ed è nel
657formato:673formato:
@@ -668,30 +684,76 @@ deve aver senso per un lettore esperto che è ha dimenticato i dettagli della · 10 unmodified lines
668discussione che hanno portato alla patch. L'inclusione di informazioni684discussione che hanno portato alla patch. L'inclusione di informazioni
669sui problemi oggetto dalla patch (messaggi del kernel, messaggi di oops,685sui problemi oggetto dalla patch (messaggi del kernel, messaggi di oops,
670eccetera) è particolarmente utile per le persone che potrebbero cercare fra686eccetera) è particolarmente utile per le persone che potrebbero cercare fra
671i messaggi di log per la patch che li tratta. Se la patch corregge un errore687i messaggi di log per la patch che li tratta. Il testo dovrebbe essere scritto
672di compilazione, non sarà necessario includere proprio _tutto_ quello che688con abbastanza dettagli da far capire al lettore **perché** quella
673è uscito dal compilatore; aggiungete solo quello che è necessario per far si689patch fu creata, e questo a distanza di settimane, mesi, o addirittura
674che la vostra patch venga trovata. Come nella ``summary phrase``, è importante690anni.
675essere sia brevi che descrittivi.691
692Se la patch corregge un errore di compilazione, non sarà necessario
693includere proprio _tutto_ quello che è uscito dal compilatore;
694aggiungete solo quello che è necessario per far si che la vostra patch
695venga trovata. Come nella ``summary phrase``, è importante essere sia
696brevi che descrittivi.
676 697
677La linea di demarcazione ``---`` serve essenzialmente a segnare dove finisce698La linea di demarcazione ``---`` serve essenzialmente a segnare dove finisce
678il messaggio di changelog.699il messaggio di changelog.
679 700
680Aggiungere il ``diffstat`` dopo ``---`` è un buon uso di questo spazio, per701Aggiungere il ``diffstat`` dopo ``---`` è un buon uso di questo spazio, per
681mostrare i file che sono cambiati, e il numero di file aggiunto o rimossi.702mostrare i file che sono cambiati, e il numero di file aggiunto o rimossi.
682Un ``diffstat`` è particolarmente utile per le patch grandi. Altri commenti703Un ``diffstat`` è particolarmente utile per le patch grandi. Se
683che sono importanti solo per i manutentori, quindi inadatti al changelog704includete un ``diffstat`` dopo ``---``, usate le opzioni ``-p 1 -w70``
684permanente, dovrebbero essere messi qui. Un buon esempio per questo tipo705cosicché i nomi dei file elencati non occupino troppo spazio
685di commenti potrebbe essere quello di descrivere le differenze fra le versioni706(facilmente rientreranno negli 80 caratteri, magari con qualche
707indentazione). (``git`` genera di base dei diffstat adatti).
708
709I commenti che sono importanti solo per i manutentori, quindi
710inadatti al changelog permanente, dovrebbero essere messi qui. Un
711buon esempio per questo tipo di commenti potrebbe essere il cosiddetto
712``patch changelogs`` che descrivere le differenze fra le versioni
686della patch.713della patch.
687 714
688Se includete un ``diffstat`` dopo ``---``, usate le opzioni ``-p 1 -w70``715Queste informazioni devono andare **dopo** la linea ``---`` che separa
689cosicché i nomi dei file elencati non occupino troppo spazio (facilmente716il *changelog* dal resto della patch. Le informazioni riguardanti la
690rientreranno negli 80 caratteri, magari con qualche indentazione).717versione di una patch non sono parte del *chagelog* che viene incluso
691(``git`` genera di base dei diffstat adatti).718in git. Queste sono informazioni utili solo ai revisori. Se venissero
719messe sopra la riga, qualcuno dovrà fare del lavoro manuale per
720rimuoverle; cosa che invece viene fatta automaticamente quando vengono
721messe correttamente oltre la riga.::
722
723 <commit message>
724 ...
725 Signed-off-by: Author <author@mail>
726 ---
727 V2 -> V3: Removed redundant helper function
728 V1 -> V2: Cleaned up coding style and addressed review comments
729
730 path/to/file | 5+++--
731 ...
692 732
693Maggiori dettagli sul formato delle patch nei riferimenti qui di seguito.733Maggiori dettagli sul formato delle patch nei riferimenti qui di seguito.
694 734
735Aggiungere i *backtrace* nei messaggi di commit
736^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
737
738I *backtrace* aiutano a documentare la sequenza di chiamate a funzione
739che portano ad un problema. Tuttavia, non tutti i *backtrace* sono
740davvero utili. Per esempio, le sequenze iniziali di avvio sono uniche
741e ovvie. Copiare integralmente l'output di ``dmesg`` aggiunge tante
742informazioni che distraggono dal vero problema (per esempio, i
743marcatori temporali, la lista dei moduli, la lista dei registri, lo
744stato dello stack).
745
746Quindi, per rendere utile un *backtrace* dovreste eliminare le
747informazioni inutili, cosicché ci si possa focalizzare sul
748problema. Ecco un esempio di un *backtrace* essenziale::
749
750 unchecked MSR access error: WRMSR to 0xd51 (tried to write 0x0000000000000064)
751 at rIP: 0xffffffffae059994 (native_write_msr+0x4/0x20)
752 Call Trace:
753 mba_wrmsr
754 update_domains
755 rdtgroup_mkdir
756
695.. _it_explicit_in_reply_to:757.. _it_explicit_in_reply_to:
696 758
697Usare esplicitamente In-Reply-To nell'intestazione759Usare esplicitamente In-Reply-To nell'intestazione
Documentation/translations/ja_JP/SubmitChecklist+3−5
@@ -88,20 +88,18 @@ Linux カーネルパッチ投稿者向けチェックリスト · 87 unmodified lines
8818: 新しいuserspaceインタフェースを作成した場合には、Documentation/ABI/ に8818: 新しいuserspaceインタフェースを作成した場合には、Documentation/ABI/ に
89 Documentation/ABI/README を参考にして必ずドキュメントを追加してください。89 Documentation/ABI/README を参考にして必ずドキュメントを追加してください。
90 90
9119: 'make headers_check'を実行して全く問題がないことを確認してください。9119: 少なくともslabアロケーションとpageアロケーションに失敗した場合の
92
9320: 少なくともslabアロケーションとpageアロケーションに失敗した場合の
94 挙動について、fault-injectionを利用して確認してください。92 挙動について、fault-injectionを利用して確認してください。
95 Documentation/fault-injection/ を参照してください。93 Documentation/fault-injection/ を参照してください。
96 94
97 追加したコードがかなりの量であったならば、サブシステム特有の95 追加したコードがかなりの量であったならば、サブシステム特有の
98 fault-injectionを追加したほうが良いかもしれません。96 fault-injectionを追加したほうが良いかもしれません。
99 97
10021: 新たに追加したコードは、`gcc -W'でコンパイルしてください。9820: 新たに追加したコードは、`gcc -W'でコンパイルしてください。
101 このオプションは大量の不要なメッセージを出力しますが、99 このオプションは大量の不要なメッセージを出力しますが、
102 "warning: comparison between signed and unsigned" のようなメッセージは、100 "warning: comparison between signed and unsigned" のようなメッセージは、
103 バグを見つけるのに役に立ちます。101 バグを見つけるのに役に立ちます。
104 102
10522: 投稿したパッチが -mm パッチセットにマージされた後、全ての既存のパッチや10321: 投稿したパッチが -mm パッチセットにマージされた後、全ての既存のパッチや
106 VM, VFS およびその他のサブシステムに関する様々な変更と、現時点でも共存104 VM, VFS およびその他のサブシステムに関する様々な変更と、現時点でも共存
107 できることを確認するテストを行ってください。105 できることを確認するテストを行ってください。
Documentation/translations/ko_KR/howto.rst+9−9
@@ -339,14 +339,8 @@ Andrew Morton의 글이 있다. · 338 unmodified lines
339버그 보고339버그 보고
340---------340---------
341 341
342https://bugzilla.kernel.org 는 리눅스 커널 개발자들이 커널의 버그를 추적하는
343곳이다. 사용자들은 발견한 모든 버그들을 보고하기 위하여 이 툴을 사용할 것을
344권장한다. kernel bugzilla를 사용하는 자세한 방법은 다음을 참조하라.
345
346 https://bugzilla.kernel.org/page.cgi?id=faq.html
347
348메인 커널 소스 디렉토리에 있는 'Documentation/admin-guide/reporting-issues.rst'342메인 커널 소스 디렉토리에 있는 'Documentation/admin-guide/reporting-issues.rst'
349파일은 커널 버그라고 생각되는 것을 보고하는 방법에 관한 좋은 템플릿이며 문제를343파일은 커널 버그라고 생각되는 것을 어떻게 보고하면 되는지, 그리고 문제를
350추적하기 위해서 커널 개발자들이 필요로 하는 정보가 무엇들인지를 상세히 설명하고344추적하기 위해서 커널 개발자들이 필요로 하는 정보가 무엇들인지를 상세히 설명하고
351있다.345있다.
352 346
@@ -362,8 +356,14 @@ https://bugzilla.kernel.org 는 리눅스 커널 개발자들이 커널의 버 · 9 unmodified lines
362점수를 얻을 수 있는 가장 좋은 방법중의 하나이다. 왜냐하면 많은 사람들은356점수를 얻을 수 있는 가장 좋은 방법중의 하나이다. 왜냐하면 많은 사람들은
363다른 사람들의 버그들을 수정하기 위하여 시간을 낭비하지 않기 때문이다.357다른 사람들의 버그들을 수정하기 위하여 시간을 낭비하지 않기 때문이다.
364 358
365이미 보고된 버그 리포트들을 가지고 작업하기 위해서 https://bugzilla.kernel.org359이미 보고된 버그 리포트들을 가지고 작업하기 위해서는 여러분이 관심있는
366를 참조하라.360서브시스템을 찾아라. 해당 서브시스템의 버그들이 어디로 리포트 되는지
361MAINTAINERS 파일을 체크하라; 그건 대부분 메일링 리스트이고, 가끔은 버그 추적
362시스템이다. 그 장소에 있는 최근 버그 리포트 기록들을 검색하고 여러분이 보기에
363적합하다 싶은 것을 도와라. 여러분은 버그 리포트를 위해
364https://bugzilla.kernel.org 를 체크하고자 할 수도 있다; 소수의 커널
365서브시스템들만이 버그 신고와 추적을 위해 해당 시스템을 실제로 사용하고 있지만,
366전체 커널의 버그들이 그곳에 정리된다.
367 367
368 368
369메일링 리스트들369메일링 리스트들
Documentation/translations/zh_CN/admin-guide/README.rst+347−0
@@ -0,0 +1,347 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/admin-guide/README.rst
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9Linux内核5.x版本 <http://kernel.org/>
10=========================================
11
12以下是Linux版本5的发行注记。仔细阅读它们,
13它们会告诉你这些都是什么,解释如何安装内核,以及遇到问题时该如何做。
14
15什么是Linux?
16---------------
17
18 Linux是Unix操作系统的克隆版本,由Linus Torvalds在一个松散的网络黑客
19 (Hacker,无贬义)团队的帮助下从头开始编写。它旨在实现兼容POSIX和
20 单一UNIX规范。
21
22 它具有在现代成熟的Unix中应当具有的所有功能,包括真正的多任务处理、虚拟内存、
23 共享库、按需加载、共享的写时拷贝(COW)可执行文件、恰当的内存管理以及包括
24 IPv4和IPv6在内的复合网络栈。
25
26 Linux在GNU通用公共许可证,版本2(GNU GPLv2)下分发,详见随附的COPYING文件。
27
28它能在什么样的硬件上运行?
29-----------------------------
30
31 虽然Linux最初是为32位的x86 PC机(386或更高版本)开发的,但今天它也能运行在
32 (至少)Compaq Alpha AXP、Sun SPARC与UltraSPARC、Motorola 68000、PowerPC、
33 PowerPC64、ARM、Hitachi SuperH、Cell、IBM S/390、MIPS、HP PA-RISC、Intel
34 IA-64、DEC VAX、AMD x86-64 Xtensa和ARC架构上。
35
36 Linux很容易移植到大多数通用的32位或64位体系架构,只要它们有一个分页内存管理
37 单元(PMMU)和一个移植的GNU C编译器(gcc;GNU Compiler Collection,GCC的一
38 部分)。Linux也被移植到许多没有PMMU的体系架构中,尽管功能显然受到了一定的
39 限制。
40 Linux也被移植到了其自己上。现在可以将内核作为用户空间应用程序运行——这被
41 称为用户模式Linux(UML)。
42
43文档
44-----
45因特网上和书籍上都有大量的电子文档,既有Linux专属文档,也有与一般UNIX问题相关
46的文档。我建议在任何Linux FTP站点上查找LDP(Linux文档项目)书籍的文档子目录。
47本自述文件并不是关于系统的文档:有更好的可用资源。
48
49 - 因特网上和书籍上都有大量的(电子)文档,既有Linux专属文档,也有与普通
50 UNIX问题相关的文档。我建议在任何有LDP(Linux文档项目)书籍的Linux FTP
51 站点上查找文档子目录。本自述文件并不是关于系统的文档:有更好的可用资源。
52
53 - 文档/子目录中有各种自述文件:例如,这些文件通常包含一些特定驱动程序的
54 内核安装说明。请阅读
55 :ref:`Documentation/process/changes.rst <changes>` 文件,它包含了升级内核
56 可能会导致的问题的相关信息。
57
58安装内核源代码
59---------------
60
61 - 如果您要安装完整的源代码,请把内核tar档案包放在您有权限的目录中(例如您
62 的主目录)并将其解包::
63
64 xz -cd linux-5.x.tar.xz | tar xvf -
65
66 将“X”替换成最新内核的版本号。
67
68 【不要】使用 /usr/src/linux 目录!这里有一组库头文件使用的内核头文件
69 (通常是不完整的)。它们应该与库匹配,而不是被内核的变化搞得一团糟。
70
71 - 您还可以通过打补丁在5.x版本之间升级。补丁以xz格式分发。要通过打补丁进行
72 安装,请获取所有较新的补丁文件,进入内核源代码(linux-5.x)的目录并
73 执行::
74
75 xz -cd ../patch-5.x.xz | patch -p1
76
77 请【按顺序】替换所有大于当前源代码树版本的“x”,这样就可以了。您可能想要
78 删除备份文件(文件名类似xxx~ 或 xxx.orig),并确保没有失败的补丁(文件名
79 类似xxx# 或 xxx.rej)。如果有,不是你就是我犯了错误。
80
81 与5.x内核的补丁不同,5.x.y内核(也称为稳定版内核)的补丁不是增量的,而是
82 直接应用于基本的5.x内核。例如,如果您的基本内核是5.0,并且希望应用5.0.3
83 补丁,则不应先应用5.0.1和5.0.2的补丁。类似地,如果您运行的是5.0.2内核,
84 并且希望跳转到5.0.3,那么在应用5.0.3补丁之前,必须首先撤销5.0.2补丁
85 (即patch -R)。更多关于这方面的内容,请阅读
86 :ref:`Documentation/process/applying-patches.rst <applying_patches>` 。
87
88 或者,脚本 patch-kernel 可以用来自动化这个过程。它能确定当前内核版本并
89 应用找到的所有补丁::
90
91 linux/scripts/patch-kernel linux
92
93 上面命令中的第一个参数是内核源代码的位置。补丁是在当前目录应用的,但是
94 可以将另一个目录指定为第二个参数。
95
96 - 确保没有过时的 .o 文件和依赖项::
97
98 cd linux
99 make mrproper
100
101 现在您应该已经正确安装了源代码。
102
103软件要求
104---------
105
106 编译和运行5.x内核需要各种软件包的最新版本。请参考
107 :ref:`Documentation/process/changes.rst <changes>`
108 来了解最低版本要求以及如何升级软件包。请注意,使用过旧版本的这些包可能会
109 导致很难追踪的间接错误,因此不要以为在生成或操作过程中出现明显问题时可以
110 只更新包。
111
112为内核建立目录
113---------------
114
115 编译内核时,默认情况下所有输出文件都将与内核源代码放在一起。使用
116 ``make O=output/dir`` 选项可以为输出文件(包括 .config)指定备用位置。
117 例如::
118
119 kernel source code: /usr/src/linux-5.x
120 build directory: /home/name/build/kernel
121
122 要配置和构建内核,请使用::
123
124 cd /usr/src/linux-5.x
125 make O=/home/name/build/kernel menuconfig
126 make O=/home/name/build/kernel
127 sudo make O=/home/name/build/kernel modules_install install
128
129 请注意:如果使用了 ``O=output/dir`` 选项,那么它必须用于make的所有调用。
130
131配置内核
132---------
133
134 即使只升级一个小版本,也不要跳过此步骤。每个版本中都会添加新的配置选项,
135 如果配置文件没有按预定设置,就会出现奇怪的问题。如果您想以最少的工作量
136 将现有配置升级到新版本,请使用 ``makeoldconfig`` ,它只会询问您新配置
137 选项的答案。
138
139 - 其他配置命令包括::
140
141 "make config" 纯文本界面。
142
143 "make menuconfig" 基于文本的彩色菜单、选项列表和对话框。
144
145 "make nconfig" 增强的基于文本的彩色菜单。
146
147 "make xconfig" 基于Qt的配置工具。
148
149 "make gconfig" 基于GTK+的配置工具。
150
151 "make oldconfig" 基于现有的 ./.config 文件选择所有选项,并询问
152 新配置选项。
153
154 "make olddefconfig"
155 类似上一个,但不询问直接将新选项设置为默认值。
156
157 "make defconfig" 根据体系架构,使用arch/$arch/defconfig或
158 arch/$arch/configs/${PLATFORM}_defconfig中的
159 默认选项值创建./.config文件。
160
161 "make ${PLATFORM}_defconfig"
162 使用arch/$arch/configs/${PLATFORM}_defconfig中
163 的默认选项值创建一个./.config文件。
164 用“makehelp”来获取您体系架构中所有可用平台的列表。
165
166 "make allyesconfig"
167 通过尽可能将选项值设置为“y”,创建一个
168 ./.config文件。
169
170 "make allmodconfig"
171 通过尽可能将选项值设置为“m”,创建一个
172 ./.config文件。
173
174 "make allnoconfig" 通过尽可能将选项值设置为“n”,创建一个
175 ./.config文件。
176
177 "make randconfig" 通过随机设置选项值来创建./.config文件。
178
179 "make localmodconfig" 基于当前配置和加载的模块(lsmod)创建配置。禁用
180 已加载的模块不需要的任何模块选项。
181
182 要为另一台计算机创建localmodconfig,请将该计算机
183 的lsmod存储到一个文件中,并将其作为lsmod参数传入。
184
185 此外,通过在参数LMC_KEEP中指定模块的路径,可以将
186 模块保留在某些文件夹或kconfig文件中。
187
188 target$ lsmod > /tmp/mylsmod
189 target$ scp /tmp/mylsmod host:/tmp
190
191 host$ make LSMOD=/tmp/mylsmod \
192 LMC_KEEP="drivers/usb:drivers/gpu:fs" \
193 localmodconfig
194
195 上述方法在交叉编译时也适用。
196
197 "make localyesconfig" 与localmodconfig类似,只是它会将所有模块选项转换
198 为内置(=y)。你可以同时通过LMC_KEEP保留模块。
199
200 "make kvmconfig" 为kvm客体内核支持启用其他选项。
201
202 "make xenconfig" 为xen dom0客体内核支持启用其他选项。
203
204 "make tinyconfig" 配置尽可能小的内核。
205
206 更多关于使用Linux内核配置工具的信息,见文档
207 Documentation/kbuild/kconfig.rst。
208
209 - ``make config`` 注意事项:
210
211 - 包含不必要的驱动程序会使内核变大,并且在某些情况下会导致问题:
212 探测不存在的控制器卡可能会混淆其他控制器。
213
214 - 如果存在协处理器,则编译了数学仿真的内核仍将使用协处理器:在
215 这种情况下,数学仿真永远不会被使用。内核会稍微大一点,但不管
216 是否有数学协处理器,都可以在不同的机器上工作。
217
218 - “kernel hacking”配置细节通常会导致更大或更慢的内核(或两者
219 兼而有之),甚至可以通过配置一些例程来主动尝试破坏坏代码以发现
220 内核问题,从而降低内核的稳定性(kmalloc())。因此,您可能应该
221 用于研究“开发”、“实验”或“调试”特性相关问题。
222
223编译内核
224---------
225
226 - 确保您至少有gcc 4.9可用。
227 有关更多信息,请参阅 :ref:`Documentation/process/changes.rst <changes>` 。
228
229 请注意,您仍然可以使用此内核运行a.out用户程序。
230
231 - 执行 ``make`` 来创建压缩内核映像。如果您安装了lilo以适配内核makefile,
232 那么也可以进行 ``makeinstall`` ,但是您可能需要先检查特定的lilo设置。
233
234 实际安装必须以root身份执行,但任何正常构建都不需要。
235 无须徒然使用root身份。
236
237 - 如果您将内核的任何部分配置为模块,那么还必须执行 ``make modules_install`` 。
238
239 - 详细的内核编译/生成输出:
240
241 通常,内核构建系统在相当安静的模式下运行(但不是完全安静)。但是有时您或
242 其他内核开发人员需要看到编译、链接或其他命令的执行过程。为此,可使用
243 “verbose(详细)”构建模式。
244 向 ``make`` 命令传递 ``V=1`` 来实现,例如::
245
246 make V=1 all
247
248 如需构建系统也给出内个目标重建的愿意,请使用 ``V=2`` 。默认为 ``V=0`` 。
249
250 - 准备一个备份内核以防出错。对于开发版本尤其如此,因为每个新版本都包含
251 尚未调试的新代码。也要确保保留与该内核对应的模块的备份。如果要安装
252 与工作内核版本号相同的新内核,请在进行 ``make modules_install`` 安装
253 之前备份modules目录。
254
255 或者,在编译之前,使用内核配置选项“LOCALVERSION”向常规内核版本附加
256 一个唯一的后缀。LOCALVERSION可以在“General Setup”菜单中设置。
257
258 - 为了引导新内核,您需要将内核映像(例如编译后的
259 .../linux/arch/x86/boot/bzImage)复制到常规可引导内核的位置。
260
261 - 不再支持在没有LILO等启动装载程序帮助的情况下直接从软盘引导内核。
262
263 如果从硬盘引导Linux,很可能使用LILO,它使用/etc/lilo.conf文件中
264 指定的内核映像文件。内核映像文件通常是/vmlinuz、/boot/vmlinuz、
265 /bzImage或/boot/bzImage。使用新内核前,请保存旧映像的副本,并复制
266 新映像覆盖旧映像。然后您【必须重新运行LILO】来更新加载映射!否则,
267 将无法启动新的内核映像。
268
269 重新安装LILO通常需要运行/sbin/LILO。您可能希望编辑/etc/lilo.conf
270 文件为旧内核映像指定一个条目(例如/vmlinux.old)防止新的不能正常
271 工作。有关更多信息,请参阅LILO文档。
272
273 重新安装LILO之后,您应该就已经准备好了。关闭系统,重新启动,尽情
274 享受吧!
275
276 如果需要更改内核映像中的默认根设备、视频模式等,请在适当的地方使用
277 启动装载程序的引导选项。无需重新编译内核即可更改这些参数。
278
279 - 使用新内核重新启动并享受它吧。
280
281若遇到问题
282-----------
283
284 - 如果您发现了一些可能由于内核缺陷所导致的问题,请检查MAINTAINERS(维护者)
285 文件看看是否有人与令您遇到麻烦的内核部分相关。如果无人在此列出,那么第二
286 个最好的方案就是把它们发给我(torvalds@linux-foundation.org),也可能发送
287 到任何其他相关的邮件列表或新闻组。
288
289 - 在所有的缺陷报告中,【请】告诉我们您在说什么内核,如何复现问题,以及您的
290 设置是什么的(使用您的常识)。如果问题是新的,请告诉我;如果问题是旧的,
291 请尝试告诉我您什么时候首次注意到它。
292
293 - 如果缺陷导致如下消息::
294
295 unable to handle kernel paging request at address C0000010
296 Oops: 0002
297 EIP: 0010:XXXXXXXX
298 eax: xxxxxxxx ebx: xxxxxxxx ecx: xxxxxxxx edx: xxxxxxxx
299 esi: xxxxxxxx edi: xxxxxxxx ebp: xxxxxxxx
300 ds: xxxx es: xxxx fs: xxxx gs: xxxx
301 Pid: xx, process nr: xx
302 xx xx xx xx xx xx xx xx xx xx
303
304 或者类似的内核调试信息显示在屏幕上或在系统日志里,请【如实】复制它。
305 可能对你来说转储(dump)看起来不可理解,但它确实包含可能有助于调试问题的
306 信息。转储上方的文本也很重要:它说明了内核转储代码的原因(在上面的示例中,
307 是由于内核指针错误)。更多关于如何理解转储的信息,请参见
308 Documentation/admin-guide/bug-hunting.rst。
309
310 - 如果使用 CONFIG_KALLSYMS 编译内核,则可以按原样发送转储,否则必须使用
311 ``ksymoops`` 程序来理解转储(但通常首选使用CONFIG_KALLSYMS编译)。
312 此实用程序可从
313 https://www.kernel.org/pub/linux/utils/kernel/ksymoops/ 下载。
314 或者,您可以手动执行转储查找:
315
316 - 在调试像上面这样的转储时,如果您可以查找EIP值的含义,这将非常有帮助。
317 十六进制值本身对我或其他任何人都没有太大帮助:它会取决于特定的内核设置。
318 您应该做的是从EIP行获取十六进制值(忽略 ``0010:`` ),然后在内核名字列表
319 中查找它,以查看哪个内核函数包含有问题的地址。
320
321 要找到内核函数名,您需要找到与显示症状的内核相关联的系统二进制文件。就是
322 文件“linux/vmlinux”。要提取名字列表并将其与内核崩溃中的EIP进行匹配,
323 请执行::
324
325 nm vmlinux | sort | less
326
327 这将为您提供一个按升序排序的内核地址列表,从中很容易找到包含有问题的地址
328 的函数。请注意,内核调试消息提供的地址不一定与函数地址完全匹配(事实上,
329 这是不可能的),因此您不能只“grep”列表:不过列表将为您提供每个内核函数
330 的起点,因此通过查找起始地址低于你正在搜索的地址,但后一个函数的高于的
331 函数,你会找到您想要的。实际上,在您的问题报告中加入一些“上下文”可能是
332 一个好主意,给出相关的上下几行。
333
334 如果您由于某些原因无法完成上述操作(如您使用预编译的内核映像或类似的映像),
335 请尽可能多地告诉我您的相关设置信息,这会有所帮助。有关详细信息请阅读
336 ‘Documentation/admin-guide/reporting-issues.rst’。
337
338 - 或者,您可以在正在运行的内核上使用gdb(只读的;即不能更改值或设置断点)。
339 为此,请首先使用-g编译内核;适当地编辑arch/x86/Makefile,然后执行 ``make
340 clean`` 。您还需要启用CONFIG_PROC_FS(通过 ``make config`` )。
341
342 使用新内核重新启动后,执行 ``gdb vmlinux /proc/kcore`` 。现在可以使用所有
343 普通的gdb命令。查找系统崩溃点的命令是 ``l *0xXXXXXXXX`` (将xxx替换为EIP
344 值)。
345
346 用gdb无法调试一个当前未运行的内核是由于gdb(错误地)忽略了编译内核的起始
347 偏移量。
Documentation/translations/zh_CN/admin-guide/bug-bisect.rst+81−0
@@ -0,0 +1,81 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../admin-guide/bug-bisect`
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9二分(bisect)缺陷
10+++++++++++++++++++
11
12(英文版)最后更新:2016年10月28日
13
14引言
15=====
16
17始终尝试由来自kernel.org的源代码构建的最新内核。如果您没有信心这样做,请将
18错误报告给您的发行版供应商,而不是内核开发人员。
19
20找到缺陷(bug)并不总是那么容易,不过仍然得去找。如果你找不到它,不要放弃。
21尽可能多的向相关维护人员报告您发现的信息。请参阅MAINTAINERS文件以了解您所
22关注的子系统的维护人员。
23
24在提交错误报告之前,请阅读“Documentation/admin-guide/reporting-issues.rst”。
25
26设备未出现(Devices not appearing)
27====================================
28
29这通常是由udev/systemd引起的。在将其归咎于内核之前先检查一下。
30
31查找导致缺陷的补丁
32===================
33
34使用 ``git`` 提供的工具可以很容易地找到缺陷,只要缺陷是可复现的。
35
36操作步骤:
37
38- 从git源代码构建内核
39- 以此开始二分 [#f1]_::
40
41 $ git bisect start
42
43- 标记损坏的变更集::
44
45 $ git bisect bad [commit]
46
47- 标记正常工作的变更集::
48
49 $ git bisect good [commit]
50
51- 重新构建内核并测试
52- 使用以下任一与git bisect进行交互::
53
54 $ git bisect good
55
56 或::
57
58 $ git bisect bad
59
60 这取决于您测试的变更集上是否有缺陷
61- 在一些交互之后,git bisect将给出可能导致缺陷的变更集。
62
63- 例如,如果您知道当前版本有问题,而4.8版本是正常的,则可以执行以下操作::
64
65 $ git bisect start
66 $ git bisect bad # Current version is bad
67 $ git bisect good v4.8
68
69
70.. [#f1] 您可以(可选地)在开始git bisect的时候提供good或bad参数
71 ``git bisect start [BAD] [GOOD]``
72
73如需进一步参考,请阅读:
74
75- ``git-bisect`` 的手册页
76- `Fighting regressions with git bisect(用git bisect解决回归)
77 <https://www.kernel.org/pub/software/scm/git/docs/git-bisect-lk2009.html>`_
78- `Fully automated bisecting with "git bisect run"(使用git bisect run
79 来全自动二分) <https://lwn.net/Articles/317154>`_
80- `Using Git bisect to figure out when brokenness was introduced
81 (使用Git二分来找出何时引入了错误) <http://webchick.net/node/99>`_
Documentation/translations/zh_CN/admin-guide/bug-hunting.rst+340−0
@@ -0,0 +1,340 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../admin-guide/bug-hunting`
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9追踪缺陷
10=========
11
12内核错误报告通常附带如下堆栈转储::
13
14 ------------[ cut here ]------------
15 WARNING: CPU: 1 PID: 28102 at kernel/module.c:1108 module_put+0x57/0x70
16 Modules linked in: dvb_usb_gp8psk(-) dvb_usb dvb_core nvidia_drm(PO) nvidia_modeset(PO) snd_hda_codec_hdmi snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd soundcore nvidia(PO) [last unloaded: rc_core]
17 CPU: 1 PID: 28102 Comm: rmmod Tainted: P WC O 4.8.4-build.1 #1
18 Hardware name: MSI MS-7309/MS-7309, BIOS V1.12 02/23/2009
19 00000000 c12ba080 00000000 00000000 c103ed6a c1616014 00000001 00006dc6
20 c1615862 00000454 c109e8a7 c109e8a7 00000009 ffffffff 00000000 f13f6a10
21 f5f5a600 c103ee33 00000009 00000000 00000000 c109e8a7 f80ca4d0 c109f617
22 Call Trace:
23 [<c12ba080>] ? dump_stack+0x44/0x64
24 [<c103ed6a>] ? __warn+0xfa/0x120
25 [<c109e8a7>] ? module_put+0x57/0x70
26 [<c109e8a7>] ? module_put+0x57/0x70
27 [<c103ee33>] ? warn_slowpath_null+0x23/0x30
28 [<c109e8a7>] ? module_put+0x57/0x70
29 [<f80ca4d0>] ? gp8psk_fe_set_frontend+0x460/0x460 [dvb_usb_gp8psk]
30 [<c109f617>] ? symbol_put_addr+0x27/0x50
31 [<f80bc9ca>] ? dvb_usb_adapter_frontend_exit+0x3a/0x70 [dvb_usb]
32 [<f80bb3bf>] ? dvb_usb_exit+0x2f/0xd0 [dvb_usb]
33 [<c13d03bc>] ? usb_disable_endpoint+0x7c/0xb0
34 [<f80bb48a>] ? dvb_usb_device_exit+0x2a/0x50 [dvb_usb]
35 [<c13d2882>] ? usb_unbind_interface+0x62/0x250
36 [<c136b514>] ? __pm_runtime_idle+0x44/0x70
37 [<c13620d8>] ? __device_release_driver+0x78/0x120
38 [<c1362907>] ? driver_detach+0x87/0x90
39 [<c1361c48>] ? bus_remove_driver+0x38/0x90
40 [<c13d1c18>] ? usb_deregister+0x58/0xb0
41 [<c109fbb0>] ? SyS_delete_module+0x130/0x1f0
42 [<c1055654>] ? task_work_run+0x64/0x80
43 [<c1000fa5>] ? exit_to_usermode_loop+0x85/0x90
44 [<c10013f0>] ? do_fast_syscall_32+0x80/0x130
45 [<c1549f43>] ? sysenter_past_esp+0x40/0x6a
46 ---[ end trace 6ebc60ef3981792f ]---
47
48这样的堆栈跟踪提供了足够的信息来识别内核源代码中发生错误的那一行。根据问题的
49严重性,它还可能包含 **“Oops”** 一词,比如::
50
51 BUG: unable to handle kernel NULL pointer dereference at (null)
52 IP: [<c06969d4>] iret_exc+0x7d0/0xa59
53 *pdpt = 000000002258a001 *pde = 0000000000000000
54 Oops: 0002 [#1] PREEMPT SMP
55 ...
56
57尽管有 **Oops** 或其他类型的堆栈跟踪,但通常需要找到出问题的行来识别和处理缺
58陷。在本章中,我们将参考“Oops”来了解需要分析的各种堆栈跟踪。
59
60如果内核是用 ``CONFIG_DEBUG_INFO`` 编译的,那么可以使用文件:
61`scripts/decode_stacktrace.sh` 。
62
63链接的模块
64-----------
65
66受到污染或正在加载/卸载的模块用“(…)”标记,污染标志在
67`Documentation/admin-guide/tainted-kernels.rst` 文件中进行了描述,“正在被加
68载”用“+”标注,“正在被卸载”用“-”标注。
69
70
71Oops消息在哪?
72---------------
73
74通常,Oops文本由klogd从内核缓冲区读取,然后交给 ``syslogd`` ,后者将其写入
75syslog文件,通常是 ``/var/log/messages`` (取决于 ``/etc/syslog.conf`` )。
76在使用systemd的系统上,它也可以由 ``journald`` 守护进程存储,并通过运行
77``journalctl`` 命令进行访问。
78
79有时 ``klogd`` 会挂掉,这种情况下您可以运行 ``dmesg > file`` 从内核缓冲区
80读取数据并保存它。或者您可以 ``cat /proc/kmsg > file`` ,但是您必须适时
81中断以停止传输,因为 ``kmsg`` 是一个“永无止境的文件”。
82
83如果机器严重崩溃,无法输入命令或磁盘不可用,那还有三个选项:
84
85(1) 手动复制屏幕上的文本,并在机器重新启动后输入。很难受,但这是突然崩溃下
86 唯一的选择。或者你可以用数码相机拍下屏幕——虽然不那么好,但总比什么都没
87 有好。如果消息滚动超出控制台顶部,使用更高分辨率(例如 ``vga=791`` )
88 引导启动将允许您阅读更多文本。(警告:这需要 ``vesafb`` ,因此对“早期”
89 的Oppses没有帮助)
90
91(2) 从串口终端启动(参见
92 :ref:`Documentation/admin-guide/serial-console.rst <serial_console>` ),
93 在另一台机器上运行调制解调器然后用你喜欢的通信程序捕获输出。
94 Minicom运行良好。
95
96(3) 使用Kdump(参阅 Documentation/admin-guide/kdump/kdump.rst ),使用
97 Documentation/admin-guide/kdump/gdbmacros.txt 中的dmesg gdbmacro从旧内存
98 中提取内核环形缓冲区。
99
100找到缺陷位置
101-------------
102
103如果你能指出缺陷在内核源代码中的位置,则报告缺陷的效果会非常好。这有两种方法。
104通常来说使用 ``gdb`` 会比较容易,不过内核需要用调试信息来预编译。
105
106gdb
107^^^^
108
109GNU 调试器(GNU debugger, ``gdb`` )是从 ``vmlinux`` 文件中找出OOPS的确切
110文件和行号的最佳方法。
111
112在使用 ``CONFIG_DEBUG_INFO`` 编译的内核上使用gdb效果最好。可通过运行以下命令
113进行设置::
114
115 $ ./scripts/config -d COMPILE_TEST -e DEBUG_KERNEL -e DEBUG_INFO
116
117在用 ``CONFIG_DEBUG_INFO`` 编译的内核上,你可以直接从OOPS复制EIP值::
118
119 EIP: 0060:[<c021e50e>] Not tainted VLI
120
121并使用GDB来将其翻译成可读形式::
122
123 $ gdb vmlinux
124 (gdb) l *0xc021e50e
125
126如果没有启用 ``CONFIG_DEBUG_INFO`` ,则使用OOPS的函数偏移::
127
128 EIP is at vt_ioctl+0xda8/0x1482
129
130并在启用 ``CONFIG_DEBUG_INFO`` 的情况下重新编译内核::
131
132 $ ./scripts/config -d COMPILE_TEST -e DEBUG_KERNEL -e DEBUG_INFO
133 $ make vmlinux
134 $ gdb vmlinux
135 (gdb) l *vt_ioctl+0xda8
136 0x1888 is in vt_ioctl (drivers/tty/vt/vt_ioctl.c:293).
137 288 {
138 289 struct vc_data *vc = NULL;
139 290 int ret = 0;
140 291
141 292 console_lock();
142 293 if (VT_BUSY(vc_num))
143 294 ret = -EBUSY;
144 295 else if (vc_num)
145 296 vc = vc_deallocate(vc_num);
146 297 console_unlock();
147
148或者若您想要更详细的显示::
149
150 (gdb) p vt_ioctl
151 $1 = {int (struct tty_struct *, unsigned int, unsigned long)} 0xae0 <vt_ioctl>
152 (gdb) l *0xae0+0xda8
153
154您也可以使用对象文件作为替代::
155
156 $ make drivers/tty/
157 $ gdb drivers/tty/vt/vt_ioctl.o
158 (gdb) l *vt_ioctl+0xda8
159
160如果你有调用跟踪,类似::
161
162 Call Trace:
163 [<ffffffff8802c8e9>] :jbd:log_wait_commit+0xa3/0xf5
164 [<ffffffff810482d9>] autoremove_wake_function+0x0/0x2e
165 [<ffffffff8802770b>] :jbd:journal_stop+0x1be/0x1ee
166 ...
167
168这表明问题可能在 :jbd: 模块中。您可以在gdb中加载该模块并列出相关代码::
169
170 $ gdb fs/jbd/jbd.ko
171 (gdb) l *log_wait_commit+0xa3
172
173.. note::
174
175 您还可以对堆栈跟踪处的任何函数调用执行相同的操作,例如::
176
177 [<f80bc9ca>] ? dvb_usb_adapter_frontend_exit+0x3a/0x70 [dvb_usb]
178
179 上述调用发生的位置可以通过以下方式看到::
180
181 $ gdb drivers/media/usb/dvb-usb/dvb-usb.o
182 (gdb) l *dvb_usb_adapter_frontend_exit+0x3a
183
184objdump
185^^^^^^^^
186
187要调试内核,请使用objdump并从崩溃输出中查找十六进制偏移,以找到有效的代码/汇
188编行。如果没有调试符号,您将看到所示例程的汇编程序代码,但是如果内核有调试
189符号,C代码也将可见(调试符号可以在内核配置菜单的hacking项中启用)。例如::
190
191 $ objdump -r -S -l --disassemble net/dccp/ipv4.o
192
193.. note::
194
195 您需要处于内核树的顶层以便此获得您的C文件。
196
197如果您无法访问源代码,仍然可以使用以下方法调试一些崩溃转储(如Dave Miller的
198示例崩溃转储输出所示)::
199
200 EIP is at +0x14/0x4c0
201 ...
202 Code: 44 24 04 e8 6f 05 00 00 e9 e8 fe ff ff 8d 76 00 8d bc 27 00 00
203 00 00 55 57 56 53 81 ec bc 00 00 00 8b ac 24 d0 00 00 00 8b 5d 08
204 <8b> 83 3c 01 00 00 89 44 24 14 8b 45 28 85 c0 89 44 24 18 0f 85
205
206 Put the bytes into a "foo.s" file like this:
207
208 .text
209 .globl foo
210 foo:
211 .byte .... /* bytes from Code: part of OOPS dump */
212
213 Compile it with "gcc -c -o foo.o foo.s" then look at the output of
214 "objdump --disassemble foo.o".
215
216 Output:
217
218 ip_queue_xmit:
219 push %ebp
220 push %edi
221 push %esi
222 push %ebx
223 sub $0xbc, %esp
224 mov 0xd0(%esp), %ebp ! %ebp = arg0 (skb)
225 mov 0x8(%ebp), %ebx ! %ebx = skb->sk
226 mov 0x13c(%ebx), %eax ! %eax = inet_sk(sk)->opt
227
228`scripts/decodecode` 文件可以用来自动完成大部分工作,这取决于正在调试的CPU
229体系结构。
230
231报告缺陷
232---------
233
234一旦你通过定位缺陷找到了其发生的地方,你可以尝试自己修复它或者向上游报告它。
235
236为了向上游报告,您应该找出用于开发受影响代码的邮件列表。这可以使用 ``get_maintainer.pl`` 。
237
238
239例如,您在gspca的sonixj.c文件中发现一个缺陷,则可以通过以下方法找到它的维护者::
240
241 $ ./scripts/get_maintainer.pl -f drivers/media/usb/gspca/sonixj.c
242 Hans Verkuil <hverkuil@xs4all.nl> (odd fixer:GSPCA USB WEBCAM DRIVER,commit_signer:1/1=100%)
243 Mauro Carvalho Chehab <mchehab@kernel.org> (maintainer:MEDIA INPUT INFRASTRUCTURE (V4L/DVB),commit_signer:1/1=100%)
244 Tejun Heo <tj@kernel.org> (commit_signer:1/1=100%)
245 Bhaktipriya Shridhar <bhaktipriya96@gmail.com> (commit_signer:1/1=100%,authored:1/1=100%,added_lines:4/4=100%,removed_lines:9/9=100%)
246 linux-media@vger.kernel.org (open list:GSPCA USB WEBCAM DRIVER)
247 linux-kernel@vger.kernel.org (open list)
248
249请注意它将指出:
250
251- 最后接触源代码的开发人员(如果这是在git树中完成的)。在上面的例子中是Tejun
252 和Bhaktipriya(在这个特定的案例中,没有人真正参与这个文件的开发);
253- 驱动维护人员(Hans Verkuil);
254- 子系统维护人员(Mauro Carvalho Chehab);
255- 驱动程序和/或子系统邮件列表(linux-media@vger.kernel.org);
256- Linux内核邮件列表(linux-kernel@vger.kernel.org)。
257
258通常,修复缺陷的最快方法是将它报告给用于开发相关代码的邮件列表(linux-media
259ML),抄送驱动程序维护者(Hans)。
260
261如果你完全不知道该把报告寄给谁,且 ``get_maintainer.pl`` 也没有提供任何有用
262的信息,请发送到linux-kernel@vger.kernel.org。
263
264感谢您的帮助,这使Linux尽可能稳定:-)
265
266修复缺陷
267---------
268
269如果你懂得编程,你不仅可以通过报告错误来帮助我们,还可以提供一个解决方案。
270毕竟,开源就是分享你的工作,你不想因为你的天才而被认可吗?
271
272如果你决定这样做,请在制定解决方案后将其提交到上游。
273
274请务必阅读
275:ref:`Documentation/process/submitting-patches.rst <submittingpatches>` ,
276以帮助您的代码被接受。
277
278
279---------------------------------------------------------------------------
280
281用 ``klogd`` 进行Oops跟踪的注意事项
282------------------------------------
283
284为了帮助Linus和其他内核开发人员, ``klogd`` 对保护故障的处理提供了大量支持。
285为了完整支持地址解析,至少应该使用 ``sysklogd`` 包的1.3-pl3版本。
286
287当发生保护故障时, ``klogd`` 守护进程会自动将内核日志消息中的重要地址转换为
288它们的等效符号。然后通过 ``klogd`` 使用的任何报告机制来转发这个已翻译的内核
289消息。保护错误消息可以直接从消息文件中剪切出来并转发给内核开发人员。
290
291``klogd`` 执行两种类型的地址解析,静态翻译和动态翻译。静态翻译使用System.map
292文件。为了进行静态转换, ``klogd`` 守护进程必须能够在守护进程初始化时找到系
293统映射文件。有关 ``klogd`` 如何搜索映射文件的信息,请参见klogd手册页。
294
295当使用内核可加载模块时,动态地址转换非常重要。由于内核模块的内存是从内核的
296动态内存池中分配的,因此无论是模块的开头还是模块中的函数和符号都没有固定的
297位置。
298
299内核支持系统调用,允许程序确定加载哪些模块及其在内存中的位置。klogd守护进程
300使用这些系统调用构建了一个符号表,可用于调试可加载内核模块中发生的保护错误。
301
302klogd至少会提供产生保护故障的模块的名称。如果可加载模块的开发人员选择从模块
303导出符号信息,则可能会有其他可用的符号信息。
304
305由于内核模块环境可以是动态的,因此当模块环境发生变化时,必须有一种通知
306``klogd`` 守护进程的机制。有一些可用的命令行选项允许klogd向当前正在执行的守
307护进程发出信号示意应该刷新符号信息。有关更多信息,请参阅 ``klogd`` 手册页。
308
309sysklogd发行版附带了一个补丁,它修改了 ``modules-2.0.0`` 包,以便在加载或
310卸载模块时自动向klogd发送信号。应用此补丁基本上可无缝支持调试内核可加载模块
311发生的保护故障。
312
313以下是 ``klogd`` 处理的可加载模块中的保护故障示例::
314
315 Aug 29 09:51:01 blizard kernel: Unable to handle kernel paging request at virtual address f15e97cc
316 Aug 29 09:51:01 blizard kernel: current->tss.cr3 = 0062d000, %cr3 = 0062d000
317 Aug 29 09:51:01 blizard kernel: *pde = 00000000
318 Aug 29 09:51:01 blizard kernel: Oops: 0002
319 Aug 29 09:51:01 blizard kernel: CPU: 0
320 Aug 29 09:51:01 blizard kernel: EIP: 0010:[oops:_oops+16/3868]
321 Aug 29 09:51:01 blizard kernel: EFLAGS: 00010212
322 Aug 29 09:51:01 blizard kernel: eax: 315e97cc ebx: 003a6f80 ecx: 001be77b edx: 00237c0c
323 Aug 29 09:51:01 blizard kernel: esi: 00000000 edi: bffffdb3 ebp: 00589f90 esp: 00589f8c
324 Aug 29 09:51:01 blizard kernel: ds: 0018 es: 0018 fs: 002b gs: 002b ss: 0018
325 Aug 29 09:51:01 blizard kernel: Process oops_test (pid: 3374, process nr: 21, stackpage=00589000)
326 Aug 29 09:51:01 blizard kernel: Stack: 315e97cc 00589f98 0100b0b4 bffffed4 0012e38e 00240c64 003a6f80 00000001
327 Aug 29 09:51:01 blizard kernel: 00000000 00237810 bfffff00 0010a7fa 00000003 00000001 00000000 bfffff00
328 Aug 29 09:51:01 blizard kernel: bffffdb3 bffffed4 ffffffda 0000002b 0007002b 0000002b 0000002b 00000036
329 Aug 29 09:51:01 blizard kernel: Call Trace: [oops:_oops_ioctl+48/80] [_sys_ioctl+254/272] [_system_call+82/128]
330 Aug 29 09:51:01 blizard kernel: Code: c7 00 05 00 00 00 eb 08 90 90 90 90 90 90 90 90 89 ec 5d c3
331
332---------------------------------------------------------------------------
333
334::
335
336 Dr. G.W. Wettstein Oncology Research Div. Computing Facility
337 Roger Maris Cancer Center INTERNET: greg@wind.rmcc.com
338 820 4th St. N.
339 Fargo, ND 58122
340 Phone: 701-234-7556
Documentation/translations/zh_CN/admin-guide/index.rst+14−5
@@ -13,9 +13,13 @@ Linux 内核用户和管理员指南 · 12 unmodified lines
13 13
14这个初始部分包含总体信息,包括描述内核的README, 关于内核参数的文档等。14这个初始部分包含总体信息,包括描述内核的README, 关于内核参数的文档等。
15 15
16Todolist:16.. toctree::
17 :maxdepth: 1
17 18
18 README19 README
20
21Todolist:
22
19 kernel-parameters23 kernel-parameters
20 devices24 devices
21 sysctl/index25 sysctl/index
@@ -28,16 +32,21 @@ Todolist: · 6 unmodified lines
28 32
29下面的一组文档,针对的是试图跟踪问题和bug的用户。33下面的一组文档,针对的是试图跟踪问题和bug的用户。
30 34
31Todolist:35.. toctree::
36 :maxdepth: 1
32 37
33 reporting-bugs38 reporting-issues
34 security-bugs39 security-bugs
35 bug-hunting40 bug-hunting
36 bug-bisect41 bug-bisect
37 tainted-kernels42 tainted-kernels
43 init
44
45Todolist:
46
47 reporting-bugs
38 ramoops48 ramoops
39 dynamic-debug-howto49 dynamic-debug-howto
40 init
41 kdump/index50 kdump/index
42 perf/index51 perf/index
43 52
@@ -56,6 +65,7 @@ Todolist: · 12 unmodified lines
56 65
57 clearing-warn-once66 clearing-warn-once
58 cpu-load67 cpu-load
68 unicode
59 69
60Todolist:70Todolist:
61 71
@@ -111,7 +121,6 @@ Todolist: · 49 unmodified lines
111 sysrq121 sysrq
112 thunderbolt122 thunderbolt
113 ufs123 ufs
114 unicode
115 vga-softcursor124 vga-softcursor
116 video-output125 video-output
117 xfs126 xfs
Documentation/translations/zh_CN/admin-guide/init.rst+54−0
@@ -0,0 +1,54 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../admin-guide/init`
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9解释“No working init found.”启动挂起消息
10=========================================
11
12:作者:
13
14 Andreas Mohr <andi at lisas period de>
15
16 Cristian Souza <cristianmsbr at gmail period com>
17
18本文档提供了加载初始化二进制(init binary)失败的一些高层级原因(大致按执行
19顺序列出)。
20
211) **无法挂载根文件系统Unable to mount root FS** :请设置“debug”内核参数(在
22 引导加载程序bootloader配置文件或CONFIG_CMDLINE)以获取更详细的内核消息。
23
242) **初始化二进制不存在于根文件系统上init binary doesn't exist on rootfs** :
25 确保您的根文件系统类型正确(并且 ``root=`` 内核参数指向正确的分区);拥有
26 所需的驱动程序,例如SCSI或USB等存储硬件;文件系统(ext3、jffs2等)是内建的
27 (或者作为模块由initrd预加载)。
28
293) **控制台设备损坏Broken console device** : ``console= setup`` 中可能存在
30 冲突 --> 初始控制台不可用(initial console unavailable)。例如,由于串行
31 IRQ问题(如缺少基于中断的配置)导致的某些串行控制台不可靠。尝试使用不同的
32 ``console= device`` 或像 ``netconsole=`` 。
33
344) **二进制存在但依赖项不可用Binary exists but dependencies not available** :
35 例如初始化二进制的必需库依赖项,像 ``/lib/ld-linux.so.2`` 丢失或损坏。使用
36 ``readelf -d <INIT>|grep NEEDED`` 找出需要哪些库。
37
385) **无法加载二进制Binary cannot be loaded** :请确保二进制的体系结构与您的
39 硬件匹配。例如i386不匹配x86_64,或者尝试在ARM硬件上加载x86。如果您尝试在
40 此处加载非二进制文件(shell脚本?),您应该确保脚本在其工作头(shebang
41 header)行 ``#!/...`` 中指定能正常工作的解释器(包括其库依赖项)。在处理
42 脚本之前,最好先测试一个简单的非脚本二进制文件,比如 ``/bin/sh`` ,并确认
43 它能成功执行。要了解更多信息,请将代码添加到 ``init/main.c`` 以显示
44 kernel_execve()的返回值。
45
46当您发现新的失败原因时,请扩展本解释(毕竟加载初始化二进制是一个 **关键** 且
47艰难的过渡步骤,需要尽可能无痛地进行),然后向LKML提交一个补丁。
48
49待办事项:
50
51- 通过一个可以存储 ``kernel_execve()`` 结果值的结构体数组实现各种
52 ``run_init_process()`` 调用,并在失败时通过迭代 **所有** 结果来记录一切
53 (非常重要的可用性修复)。
54- 试着使实现本身在一般情况下更有帮助,例如在受影响的地方提供额外的错误消息。
Documentation/translations/zh_CN/admin-guide/reporting-issues.rst+1335−0
@@ -0,0 +1,1335 @@
1.. SPDX-License-Identifier: (GPL-2.0+ OR CC-BY-4.0)
2..
3 If you want to distribute this text under CC-BY-4.0 only, please use 'The
4 Linux kernel developers' for author attribution and link this as source:
5 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/admin-guide/reporting-issues.rst
6..
7 Note: Only the content of this RST file as found in the Linux kernel sources
8 is available under CC-BY-4.0, as versions of this text that were processed
9 (for example by the kernel's build system) might contain content taken from
10 files which use a more restrictive license.
11
12.. include:: ../disclaimer-zh_CN.rst
13
14:Original: Documentation/admin-guide/reporting-issues.rst
15
16:译者:
17
18 吴想成 Wu XiangCheng <bobwxc@email.cn>
19
20
21报告问题
22+++++++++
23
24
25简明指南(亦即 太长不看)
26==========================
27
28您面临的是否为同系列稳定版或长期支持内核的普通内核的回归?是否仍然受支持?
29请搜索 `LKML内核邮件列表 <https://lore.kernel.org/lkml/>`_ 和
30`Linux稳定版邮件列表 <https://lore.kernel.org/stable/>`_ 存档中匹配的报告并
31加入讨论。如果找不到匹配的报告,请安装该系列的最新版本。如果它仍然出现问题,
32报告给稳定版邮件列表(stable@vger.kernel.org)。
33
34在所有其他情况下,请尽可能猜测是哪个内核部分导致了问题。查看MAINTAINERS文件,
35了解开发人员希望如何得知问题,大多数情况下,报告问题都是通过电子邮件和抄送
36相关邮件列表进行的。检查报告目的地的存档中是否已有匹配的报告;也请搜索
37`LKML <https://lore.kernel.org/lkml/>`_ 和网络。如果找不到可加入的讨论,请
38安装 `最新的主线内核 <https://kernel.org/>`_ 。如果仍存在问题,请发送报告。
39
40问题已经解决了,但是您希望看到它在一个仍然支持的稳定版或长期支持系列中得到
41解决?请安装其最新版本。如果它出现了问题,那么在主线中搜索修复它的更改,并
42检查是否正在回传(backporting)或者已放弃;如果两者都没有,那么可询问处理
43更改的人员。
44
45**通用提醒** :当安装和测试上述内核时,请确保它是普通的(即:没有补丁,也没
46有使用附加模块)。还要确保它是在一个正常的环境中构建和运行,并且在问题发生
47之前没有被污染(tainted)。
48
49在编写报告时,要涵盖与问题相关的所有信息,如使用的内核和发行版。在碰见回归时,
50尝试给出引入它的更改的提交ID,二分可以找到它。如果您同时面临Linux内核的多个
51问题,请分别报告每个问题。
52
53一旦报告发出,请回答任何出现的问题,并尽可能地提供帮助。这包括通过不时重新
54测试新版本并发送状态更新来推动进展。
55
56
57如何向内核维护人员报告问题的逐步指南
58=====================================
59
60上面的简明指南概述了如何向Linux内核开发人员报告问题。对于已经熟悉向自由和开
61源软件(FLOSS)项目报告问题的人来说,这可能是他们所需要的全部内容。对于其他
62人,本部分更为详细,并一步一步地描述。为了便于阅读,它仍然尽量简洁,并省略
63了许多细节;这些在逐步指南后的参考章节中进行了描述,该章节更详细地解释了每
64个步骤。
65
66注意:本节涉及的方面比简明指南多,顺序也稍有不同。这符合你的利益,以确保您
67尽早意识到看起来像Linux内核毛病的问题可能实际上是由其他原因引起的。这些步骤
68可以确保你最终不会觉得在这一过程中投入的时间是浪费:
69
70 * 您是否面临硬件或软件供应商提供的Linux内核的问题?那么基本上您最好停止阅读
71 本文档,转而向您的供应商报告问题,除非您愿意自己安装最新的Linux版本。寻找
72 和解决问题往往需要后者。
73
74 * 使用您喜爱的网络搜索引擎对现有报告进行粗略搜索;此外,请检查
75 `Linux内核邮件列表(LKML) <https://lore.kernel.org/lkml/>`_ 的存档。如果
76 找到匹配的报告,请加入讨论而不是发送新报告。
77
78 * 看看你正在处理的问题是否为回归问题、安全问题或非常严重的问题:这些都是需
79 要在接下来的一些步骤中特别处理的“高优先级问题”。
80
81 * 确保不是内核环境导致了您面临的问题。
82
83 * 创建一个新的备份,并将系统修复和恢复工具放在手边。
84
85 * 确保您的系统不会通过动态构建额外的内核模块来增强其内核,像DKMS这样的解决
86 方案可能在您不知情的情况下就在本地进行了这样的工作。
87
88 * 当问题发生时,检查您的内核是否被“污染”,因为使内核设置这个标志的事件可能
89 会导致您面临的问题。
90
91 * 粗略地写下如何重现这个问题。如果您同时处理多个问题,请为每个问题单独写注
92 释,并确保它们在新启动的系统上独立出现。这是必要的,因为每个问题都需要分
93 别报告给内核开发人员,除非它们严重纠缠在一起。
94
95 * 如果您正面临稳定版或长期支持版本线的回归(例如从5.10.4更新到5.10.5时出现
96 故障),请查看后文“报告稳定版和长期支持内核线的回归”小节。
97
98 * 定位可能引起问题的驱动程序或内核子系统。找出其开发人员期望的报告的方式和
99 位置。注意:大多数情况下不会是 bugzilla.kernel.org,因为问题通常需要通
100 过邮件发送给维护人员和公共邮件列表。
101
102 * 在缺陷追踪器或问题相关邮件列表的存档中彻底搜索可能与您的问题匹配的报告。
103 如果你发现了一些相关讨论,请加入讨论而不是发送新的报告。
104
105在完成这些准备之后,你将进入主要部分:
106
107 * 除非您已经在运行最新的“主线”Linux内核,否则最好在报告流程前安装它。在某些
108 情况下,使用最新的“稳定版”Linux进行测试和报告也是可以接受的替代方案;在
109 合并窗口期间,这实际上可能是最好的方法,但在开发阶段最好还是暂停几天。无论
110 你选择什么版本,最好使用“普通”构建。忽略这些建议会大大增加您的报告被拒绝
111 或忽略的风险。
112
113 * 确保您刚刚安装的内核在运行时不会“污染”自己。
114
115 * 在您刚刚安装的内核中复现这个问题。如果它没有出现,请查看下方只发生在
116 稳定版和长期支持内核的问题的说明。
117
118 * 优化你的笔记:试着找到并写出最直接的复现问题的方法。确保最终结果包含所有
119 重要的细节,同时让第一次听说的人容易阅读和理解。如果您在此过程中学到了一
120 些东西,请考虑再次搜索关于该问题的现有报告。
121
122 * 如果失败涉及“panic”、“Oops”、“warning”或“BUG”,请考虑解码内核日志以查找触
123 发错误的代码行。
124
125 * 如果您的问题是回归问题,请尽可能缩小引入问题时的范围。
126
127 * 通过详细描述问题来开始编写报告。记得包括以下条目:您为复现而安装的最新内
128 核版本、使用的Linux发行版以及关于如何复现该问题的说明。如果可能,将内核
129 构建配置(.config)和 ``dmesg`` 的输出放在网上的某个地方,并链接到它。包
130 含或上传所有其他可能相关的信息,如Oops的输出/截图或来自 ``lspci`` 的输出
131 。一旦你写完了这个主要部分,请在上方插入一个正常长度的段落快速概述问题和
132 影响。再在此之上添加一个简单描述问题的句子,以得到人们的阅读。现在给出一
133 个更短的描述性标题或主题。然后就可以像MAINTAINERS文件告诉你的那样发送或
134 提交报告了,除非你在处理一个“高优先级问题”:它们需要按照下面“高优先级问
135 题的特殊处理”所述特别关照。
136
137 * 等待别人的反应,继续推进事情,直到你能够接受这样或那样的结果。因此,请公
138 开和及时地回应任何询问。测试提出的修复。积极地测试:至少重新测试每个新主
139 线版本的首个候选版本(RC),并报告你的结果。如果出现拖延,就友好地提醒一
140 下。如果你没有得到任何帮助或者未能满意,请试着自己帮助自己。
141
142
143报告稳定版和长期支持内核线的回归
144----------------------------------
145
146如果您发现了稳定版或长期支持内核版本线中的回归问题并按上述流程跳到这里,那么
147请阅读本小节。即例如您在从5.10.4更新到5.10.5时出现了问题(从5.9.15到5.10.5则
148不是)。开发人员希望尽快修复此类回归,因此有一个简化流程来报告它们:
149
150 * 检查内核开发人员是否仍然维护你关心的Linux内核版本线:去 `kernel.org 的首页
151 <https://kernel.org/>`_ ,确保此特定版本线的最新版没有“[EOL]”标记。
152
153 * 检查 `Linux稳定版邮件列表 <https://lore.kernel.org/stable/>`_ 中的现有报告。
154
155 * 从特定的版本线安装最新版本作为纯净内核。确保这个内核没有被污染,并且仍然
156 存在问题,因为问题可能已经在那里被修复了。如果您第一次发现供应商内核的问题,
157 请检查已知最新版本的普通构建是否可以正常运行。
158
159 * 向Linux稳定版邮件列表发送一个简短的问题报告(stable@vger.kernel.org)。大致
160 描述问题,并解释如何复现。讲清楚首个出现问题的版本和最后一个工作正常的版本。
161 然后等待进一步的指示。
162
163下面的参考章节部分详细解释了这些步骤中的每一步。
164
165
166报告只发生在较旧内核版本线的问题
167----------------------------------
168
169若您尝试了上述的最新主线内核,但未能在那里复现问题,那么本小节适用于您;以下
170流程有助于使问题在仍然支持的稳定版或长期支持版本线,或者定期基于最新稳定版或
171长期支持内核的供应商内核中得到修复。如果是这种情况,请执行以下步骤:
172
173 * 请做好准备,接下来的几个步骤可能无法在旧版本中解决问题:修复可能太大或太
174 冒险,无法移植到那里。
175
176 * 执行前节“报告稳定版和长期支持内核线的回归”中的前三个步骤。
177
178 * 在Linux内核版本控制系统中搜索修复主线问题的更改,因为它的提交消息可能会
179 告诉你修复是否已经计划好了支持。如果你没有找到,搜索适当的邮件列表,寻找
180 讨论此类问题或同行评议可能修复的帖子;然后检查讨论是否认为修复不适合支持。
181 如果支持根本不被考虑,加入最新的讨论,询问是否有可能。
182
183 * 前面的步骤之一应该会给出一个解决方案。如果仍未能成功,请向可能引起问题的
184 子系统的维护人员询问建议;抄送特定子系统的邮件列表以及稳定版邮件列表
185
186下面的参考章节部分详细解释了这些步骤中的每一步。
187
188
189参考章节:向内核维护者报告问题
190===============================
191
192上面的详细指南简要地列出了所有主要步骤,这对大多数人来说应该足够了。但有时,
193即使是有经验的用户也可能想知道如何实际执行这些步骤之一。这就是本节的目的,
194因为它将提供关于上述每个步骤的更多细节。请将此作为参考文档:可以从头到尾
195阅读它。但它主要是为了浏览和查找如何实际执行这些步骤的详细信息。
196
197在深入挖掘细节之前,我想先给你一些一般性建议:
198
199 * Linux内核开发人员很清楚这个过程很复杂,比其他的FLOSS项目要求更多。我们很
200 希望让它更简单。但这需要在不同的地方以及一些基础设施上付诸努力,这些基础
201 设施需要持续的维护;尚未有人站出来做这些工作,所以目前情况就是这样。
202
203 * 与某些供应商签订的保证或支持合同并不能使您有权要求上游Linux内核社区的开
204 发人员进行修复:这样的合同完全在Linux内核、其开发社区和本文档的范围之外。
205 这就是为什么在这种情况下,你不能要求任何契约保证,即使开发人员处理的问
206 题对供应商有效。如果您想主张您的权利,使用供应商的支持渠道代替。当这样做
207 的时候,你可能想提出你希望看到这个问题在上游Linux内核中修复;可以这是确
208 保最终修复将被纳入所有Linux发行版的唯一方法来鼓励他们。
209
210 * 如果您从未向FLOSS项目报告过任何问题,那么您应该考虑阅读 `如何有效地报告
211 缺陷 <https://www.chiark.greenend.org.uk/~sgtatham/bugs.html>`_ , `如何
212 以明智的方式提问 <http://www.catb.org/esr/faqs/smart-questions.html>`_ ,
213 和 `如何提出好问题 <https://jvns.ca/blog/good-questions/>`_ 。
214
215解决这些问题之后,可以在下面找到如何正确地向Linux内核报告问题的详细信息。
216
217
218确保您使用的是上游Linux内核
219----------------------------
220
221 *您是否面临硬件或软件供应商提供的Linux内核的问题?那么基本上您最好停止阅
222 读本文档,转而向您的供应商报告问题,除非您愿意自己安装最新的Linux版本。
223 寻找和解决问题往往需要后者。*
224
225与大多数程序员一样,Linux内核开发人员不喜欢花时间处理他们维护的源代码中根本
226不会发生的问题的报告。这只会浪费每个人的时间,尤其是你的时间。不幸的是,当
227涉及到内核时,这样的情况很容易发生,并且常常导致双方气馁。这是因为几乎所有预
228装在设备(台式机、笔记本电脑、智能手机、路由器等)上的Linux内核,以及大多数
229由Linux发行商提供的内核,都与由kernel.org发行的官方Linux内核相距甚远:从Linux
230开发的角度来看,这些供应商提供的内核通常是古老的或者经过了大量修改,通常两点
231兼具。
232
233大多数供应商内核都不适合用来向Linux内核开发人员报告问题:您在其中遇到的问题
234可能已经由Linux内核开发人员在数月或数年前修复;此外,供应商的修改和增强可能
235会导致您面临的问题,即使它们看起来很小或者完全不相关。这就是为什么您应该向
236供应商报告这些内核的问题。它的开发者应该查看报告,如果它是一个上游问题,直接
237于上游修复或将报告转发到那里。在实践中,这有时行不通。因此,您可能需要考虑
238通过自己安装最新的Linux内核内核来绕过供应商。如果如果您选择此方法,那么本指
239南后面的步骤将解释如何在排除了其他可能导致您的问题的原因后执行此操作。
240
241注意前段使用的词语是“大多数”,因为有时候开发人员实际上愿意处理供应商内核出现
242的问题报告。他们是否这么做很大程度上取决于开发人员和相关问题。如果发行版只
243根据最近的Linux版本对内核进行了较小修改,那么机会就比较大;例如对于Debian
244GNU/Linux Sid或Fedora Rawhide所提供的主线内核。一些开发人员还将接受基于最新
245稳定内核的发行版内核问题报告,只要它改动不大;例如Arch Linux、常规Fedora版本
246和openSUSE Turboweed。但是请记住,您最好使用主线Linux,并避免在此流程中使用
247稳定版内核,如“安装一个新的内核进行测试”一节中所详述。
248
249当然,您可以忽略所有这些建议,并向上游Linux开发人员报告旧的或经过大量修改的
250供应商内核的问题。但是注意,这样的报告经常被拒绝或忽视,所以自行小心考虑一下。
251不过这还是比根本不报告问题要好:有时候这样的报告会直接或间接地帮助解决之后的
252问题。
253
254
255搜索现有报告(第一部分)
256-------------------------
257
258 *使用您喜爱的网络搜索引擎对现有报告进行粗略搜索;此外,请检查Linux内核
259 邮件列表(LKML)的存档。如果找到匹配的报告,请加入讨论而不是发送新报告。*
260
261报告一个别人已经提出的问题,对每个人来说都是浪费时间,尤其是作为报告人的你。
262所以彻底检查是否有人已经报告了这个问题,这对你自己是有利的。在流程中的这一步,
263可以只执行一个粗略的搜索:一旦您知道您的问题需要报告到哪里,稍后的步骤将告诉
264您如何详细搜索。尽管如此,不要仓促完成这一步,它可以节省您的时间和减少麻烦。
265
266只需先用你最喜欢的搜索引擎在互联网上搜索。然后再搜索Linux内核邮件列表(LKML)
267存档。
268
269如果搜索结果实在太多,可以考虑让你的搜索引擎将搜索时间范围限制在过去的一个
270月或一年。而且无论你在哪里搜索,一定要用恰当的搜索关键词;也要变化几次关键
271词。同时,试着从别人的角度看问题:这将帮助你想出其他的关键词。另外,一定不
272要同时使用过多的关键词。记住搜索时要同时尝试包含和不包含内核驱动程序的名称
273或受影响的硬件组件的名称等信息。但其确切的品牌名称(比如说“华硕红魔 Radeon
274RX 5700 XT Gaming OC”)往往帮助不大,因为它太具体了。相反,尝试搜索术语,如
275型号(Radeon 5700 或 Radeon 5000)和核心代号(“Navi”或“Navi10”),以及包含
276和不包含其制造商(“AMD”)。
277
278如果你发现了关于你的问题的现有报告,请加入讨论,因为你可能会提供有价值的额
279外信息。这一点很重要,即使是在修复程序已经准备好或处于最后阶段,因为开发人
280员可能会寻找能够提供额外信息或测试建议修复程序的人。跳到“发布报告后的责任”
281一节,了解有关如何正确参与的细节。
282
283注意,搜索 `bugzilla.kernel.org <https://bugzilla.kernel.org/>`_ 网站可能
284也是一个好主意,因为这可能会提供有价值的见解或找到匹配的报告。如果您发现后者,
285请记住:大多数子系统都希望在不同的位置报告,如下面“你需要将问题报告到何处”
286一节中所述。因此本应处理这个问题的开发人员甚至可能不知道bugzilla的工单。所以
287请检查工单中的问题是否已经按照本文档所述得到报告,如果没有,请考虑这样做。
288
289高优先级的问题?
290-----------------
291
292 *看看你正在处理的问题是否是回归问题、安全问题或非常严重的问题:这些都是
293 需要在接下来的一些步骤中特别处理的“高优先级问题”。*
294
295Linus Torvalds和主要的Linux内核开发人员希望看到一些问题尽快得到解决,因此在
296报告过程中有一些“高优先级问题”的处理略有不同。有三种情况符合条件:回归、安全
297问题和非常严重的问题。
298
299如果在旧版本的Linux内核中工作的东西不能在新版本的Linux内核中工作,或者某种
300程度上在新版本的Linux内核中工作得更差,那么你就需要处理“回归”。因此,当一个
301在Linux 5.7中表现良好的WiFi驱动程序在5.8中表现不佳或根本不能工作时,这是一
302种回归。如果应用程序在新的内核中出现不稳定的现象,这也是一种回归,这可能是
303由于内核和用户空间之间的接口(如procfs和sysfs)发生不兼容的更改造成的。显著
304的性能降低或功耗增加也可以称为回归。但是请记住:新内核需要使用与旧内核相似的
305配置来构建(参见下面如何实现这一点)。这是因为内核开发人员在实现新特性时有
306时无法避免不兼容性;但是为了避免回归,这些特性必须在构建配置期间显式地启用。
307
308什么是安全问题留给您自己判断。在继续之前,请考虑阅读
309“Documentation/translations/zh_CN/admin-guide/security-bugs.rst”,
310因为它提供了如何最恰当地处理安全问题的额外细节。
311
312当发生了完全无法接受的糟糕事情时,此问题就是一个“非常严重的问题”。例如,
313Linux内核破坏了它处理的数据或损坏了它运行的硬件。当内核突然显示错误消息
314(“kernel panic”)并停止工作,或者根本没有任何停止信息时,您也在处理一个严重
315的问题。注意:不要混淆“panic”(内核停止自身的致命错误)和“Oops”(可恢复错误),
316因为显示后者之后内核仍然在运行。
317
318
319确保环境健康
320--------------
321
322 *确保不是内核所处环境导致了你所面临的问题。*
323
324看起来很像内核问题的问题有时是由构建或运行时环境引起的。很难完全排除这种问
325题,但你应该尽量减少这种问题:
326
327 * 构建内核时,请使用经过验证的工具,因为编译器或二进制文件中的错误可能会导
328 致内核出现错误行为。
329
330 * 确保您的计算机组件在其设计规范内运行;这对处理器、内存和主板尤为重要。因
331 此,当面临潜在的内核问题时,停止低电压或超频。
332
333 * 尽量确保不是硬件故障导致了你的问题。例如,内存损坏会导致大量的问题,这些
334 问题会表现为看起来像内核问题。
335
336 * 如果你正在处理一个文件系统问题,你可能需要用 ``fsck`` 检查一下文件系统,
337 因为它可能会以某种方式被损坏,从而导致无法预期的内核行为。
338
339 * 在处理回归问题时,要确保没有在更新内核的同时发生了其他变化。例如,这个问
340 题可能是由同时更新的其他软件引起的。也有可能是在你第一次重启进入新内核时,
341 某个硬件巧合地坏了。更新系统 BIOS 或改变 BIOS 设置中的某些内容也会导致
342 一些看起来很像内核回归的问题。
343
344
345为紧急情况做好准备
346-------------------
347
348 *创建一个全新的备份,并将系统修复和还原工具放在手边*
349
350我得提醒您,您正在和计算机打交道,计算机有时会出现意想不到的事情,尤其是当
351您折腾其操作系统的内核等关键部件时。而这就是你在这个过程中要做的事情。因此,
352一定要创建一个全新的备份;还要确保你手头有修复或重装操作系统的所有工具,
353以及恢复备份所需的一切。
354
355
356确保你的内核不会被增强
357------------------------
358
359 *确保您的系统不会通过动态构建额外的内核模块来增强其内核,像DKMS这样的解
360 决方案可能在您不知情的情况下就在本地进行了这样的工作。*
361
362如果内核以任何方式得到增强,那么问题报告被忽略或拒绝的风险就会急剧增加。这就
363是为什么您应该删除或禁用像akmods和DKMS这样的机制:这些机制会自动构建额外内核
364模块,例如当您安装新的Linux内核或第一次引导它时。也要记得同时删除他们可能安装
365的任何模块。然后重新启动再继续。
366
367注意,你可能不知道你的系统正在使用这些解决方案之一:当你安装 Nvidia 专有图
368形驱动程序、VirtualBox 或其他需要 Linux 内核以外的模块支持的软件时,它们通
369常会静默设置。这就是为什么你可能需要卸载这些软件的软件包,以摆脱任何第三方
370内核模块。
371
372
373检查“污染”标志
374----------------
375
376 *当问题发生时,检查您的内核是否被“污染”,因为使内核设置这个标志的事件可
377 能会导致您面临的问题。*
378
379当某些可能会导致看起来完全不相关的后续错误的事情发生时,内核会用“污染
380(taint)”标志标记自己。如果您的内核受到污染,那么您面临的可能是这样的错误。
381因此在投入更多时间到这个过程中之前,尽早排除此情况可能对你有好处。这是这个
382步骤出现在这里的唯一原因,因为这个过程稍后会告诉您安装最新的主线内核;然后
383您将需要再次检查污染标志,因为当它出问题的时候内核报告会关注它。
384
385在正在运行的系统上检查内核是否污染非常容易:如果 ``cat /proc/sys/kernel/tainted``
386返回“0”,那么内核没有被污染,一切正常。在某些情况下无法检查该文件;这就是
387为什么当内核报告内部问题(“kernel bug”)、可恢复错误(“kernel Oops”)或停止
388操作前不可恢复的错误(“kernel panic”)时,它也会提到污染状态。当其中一个错
389误发生时,查看打印的错误消息的顶部,搜索以“CPU:”开头的行。如果发现问题时内
390核未被污染,那么它应该以“Not infected”结束;如果你看到“Tainted:”且后跟一些
391空格和字母,那就被污染了。
392
393如果你的内核被污染了,请阅读“Documentation/translations/zh_CN/admin-guide/tainted-kernels.rst”
394以找出原因。设法消除污染因素。通常是由以下三种因素之一引起的:
395
396 1. 发生了一个可恢复的错误(“kernel Oops”),内核污染了自己,因为内核知道在
397 此之后它可能会出现奇怪的行为错乱。在这种情况下,检查您的内核或系统日志,
398 并寻找以下列文字开头的部分::
399
400 Oops: 0000 [#1] SMP
401
402 如方括号中的“#1”所示,这是自启动以来的第一次Oops。每个Oops和此后发生的
403 任何其他问题都可能是首个Oops的后续问题,即使这两个问题看起来完全不相关。
404 通过消除首个Oops的原因并在之后复现该问题,可以排除这种情况。有时仅仅
405 重新启动就足够了,有时更改配置后重新启动可以消除Oops。但是在这个流程中
406 不要花费太多时间在这一点上,因为引起Oops的原因可能已经在您稍后将按流程
407 安装的新Linux内核版本中修复了。
408
409 2. 您的系统使用的软件安装了自己的内核模块,例如Nvidia的专有图形驱动程序或
410 VirtualBox。当内核从外部源(即使它们是开源的)加载此类模块时,它会污染
411 自己:它们有时会在不相关的内核区域导致错误,从而可能导致您面临的问题。
412 因此,当您想要向Linux内核开发人员报告问题时,您必须阻止这些模块加载。
413 大多数情况下最简单的方法是:临时卸载这些软件,包括它们可能已经安装的任
414 何模块。之后重新启动。
415
416 3. 当内核加载驻留在Linux内核源代码staging树中的模块时,它也会污染自身。这
417 是一个特殊的区域,代码(主要是驱动程序)还没有达到正常Linux内核的质量
418 标准。当您报告此种模块的问题时,内核受到污染显然是没有问题的;只需确保
419 问题模块是造成污染的唯一原因。如果问题发生在一个不相关的区域,重新启动
420 并通过指定 ``foo.blacklist=1`` 作为内核参数临时阻止该模块被加载(用有
421 问题的模块名替换“foo”)。
422
423
424记录如何重现问题
425------------------
426
427 *粗略地写下如何重现这个问题。如果您同时处理多个问题,请为每个问题单独写
428 注释,并确保它们在新启动的系统上独立出现。这是必要的,因为每个问题都需
429 要分别报告给内核开发人员,除非它们严重纠缠在一起。*
430
431如果你同时处理多个问题,必须分别报告每个问题,因为它们可能由不同的开发人员
432处理。在一份报告中描述多种问题,也会让其他人难以将其分开。因此只有在问题严
433重纠缠的情况下,才能将问题合并在一份报告中。
434
435此外,在报告过程中,你必须测试该问题是否发生在其他内核版本上。因此,如果您
436知道如何在一个新启动的系统上快速重现问题,将使您的工作更加轻松。
437
438注意:报告只发生过一次的问题往往是没有结果的,因为它们可能是由于宇宙辐射导
439致的位翻转。所以你应该尝试通过重现问题来排除这种情况,然后再继续。如果你有
440足够的经验来区分由于硬件故障引起的一次性错误和难以重现的罕见内核问题,可以
441忽略这个建议。
442
443
444稳定版或长期支持内核的回归?
445-----------------------------
446
447 *如果您正面临稳定版或长期支持版本线的回归(例如从5.10.4更新到5.10.5时出现
448 故障),请查看后文“报告稳定版和长期支持内核线的回归”小节。*
449
450稳定版和长期支持内核版本线中的回归是Linux开发人员非常希望解决的问题,这样的
451问题甚至比主线开发分支中的回归更不应出现,因为它们会很快影响到很多人。开发人员
452希望尽快了解此类问题,因此有一个简化流程来报告这些问题。注意,使用更新内核版
453本线的回归(比如从5.9.15切换到5.10.5时出现故障)不符合条件。
454
455
456你需要将问题报告到何处
457------------------------
458
459 *定位可能引起问题的驱动程序或内核子系统。找出其开发人员期望的报告的方式
460 和位置。注意:大多数情况下不会是bugzilla.kernel.org,因为问题通常需要通
461 过邮件发送给维护人员和公共邮件列表。*
462
463将报告发送给合适的人是至关重要的,因为Linux内核是一个大项目,大多数开发人员
464只熟悉其中的一小部分。例如,相当多的程序员只关心一个驱动程序,比如一个WiFi
465芯片驱动程序;它的开发人员可能对疏远的或不相关的“子系统”(如TCP堆栈、
466PCIe/PCI子系统、内存管理或文件系统)的内部知识了解很少或完全不了解。
467
468问题在于:Linux内核缺少一个,可以简单地将问题归档并让需要了解它的开发人员了
469解它的,中心化缺陷跟踪器。这就是为什么你必须找到正确的途径来自己报告问题。
470您可以在脚本的帮助下做到这一点(见下文),但它主要针对的是内核开发人员和专
471家。对于其他人来说,MAINTAINERS(维护人员)文件是更好的选择。
472
473如何阅读MAINTAINERS维护者文件
474~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
475
476为了说明如何使用 :ref:`MAINTAINERS <maintainers>` 文件,让我们假设您的笔记
477本电脑中的WiFi在更新内核后突然出现了错误行为。这种情况下可能是WiFi驱动的问
478题。显然,它也可能由于驱动基于的某些代码,但除非你怀疑有这样的东西会附着在
479驱动程序上。如果真的是其他的问题,驱动程序的开发人员会让合适的人参与进来。
480
481遗憾的是,没有通用且简单的办法来检查哪个代码驱动了特定硬件组件。
482
483在WiFi驱动出现问题的情况下,你可能想查看 ``lspci -k`` 的输出,因为它列出了
484PCI/PCIe总线上的设备和驱动它的内核模块::
485
486 [user@something ~]$ lspci -k
487 [...]
488 3a:00.0 Network controller: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter (rev 32)
489 Subsystem: Bigfoot Networks, Inc. Device 1535
490 Kernel driver in use: ath10k_pci
491 Kernel modules: ath10k_pci
492 [...]
493
494但如果你的WiFi芯片通过USB或其他内部总线连接,这种方法就行不通了。在这种情况
495下,您可能需要检查您的WiFi管理器或 ``ip link`` 的输出。寻找有问题的网络接口
496的名称,它可能类似于“wlp58s0”。此名称可以用来找到驱动它的模块::
497
498 [user@something ~]$ realpath --relative-to=/sys/module//sys/class/net/wlp58s0/device/driver/module
499 ath10k_pci
500
501如果这些技巧不能进一步帮助您,请尝试在网上搜索如何缩小相关驱动程序或子系统
502的范围。如果你不确定是哪一个:试着猜一下,即使你猜得不好,也会有人会帮助你
503的。
504
505一旦您知道了相应的驱动程序或子系统,您就希望在MAINTAINERS文件中搜索它。如果
506是“ath10k_pci”,您不会找到任何东西,因为名称太具体了。有时你需要在网上寻找
507帮助;但在此之前,请尝试使用一个稍短或修改过的名称来搜索MAINTAINERS文件,因
508为这样你可能会发现类似这样的东西::
509
510 QUALCOMM ATHEROS ATH10K WIRELESS DRIVER
511 Mail: A. Some Human <shuman@example.com>
512 Mailing list: ath10k@lists.infradead.org
513 Status: Supported
514 Web-page: https://wireless.wiki.kernel.org/en/users/Drivers/ath10k
515 SCM: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
516 Files: drivers/net/wireless/ath/ath10k/
517
518注意:如果您阅读在Linux源代码树的根目录中找到的原始维护者文件,则行描述将是
519缩写。例如,“Mail:(邮件)”将是“M:”,“Mailing list:(邮件列表)”将是“L”,
520“Status:(状态)”将是“S:”。此文件顶部有一段解释了这些和其他缩写。
521
522首先查看“Status”状态行。理想情况下,它应该得到“Supported(支持)”或
523“Maintained(维护)”。如果状态为“Obsolete(过时的)”,那么你在使用一些过时的
524方法,需要转换到新的解决方案上。有时候,只有在感到有动力时,才会有人为代码
525提供“Odd Fixes”。如果碰见“Orphan”,你就完全不走运了,因为再也没有人关心代码
526了,只剩下这些选项:准备好与问题共存,自己修复它,或者找一个愿意修复它的程序员。
527
528检查状态后,寻找以“bug:”开头的一行:它将告诉你在哪里可以找到子系统特定的缺
529陷跟踪器来提交你的问题。上面的例子没有此行。大多数部分都是这样,因为 Linux
530内核的开发完全是由邮件驱动的。很少有子系统使用缺陷跟踪器,且其中只有一部分
531依赖于 bugzilla.kernel.org。
532
533在这种以及其他很多情况下,你必须寻找以“Mail:”开头的行。这些行提到了特定代码
534的维护者的名字和电子邮件地址。也可以查找以“Mailing list:”开头的行,它告诉你
535开发代码的公共邮件列表。你的报告之后需要通过邮件发到这些地址。另外,对于所有
536通过电子邮件发送的问题报告,一定要抄送 Linux Kernel Mailing List(LKML)
537<linux-kernel@vger.kernel.org>。在以后通过邮件发送问题报告时,不要遗漏任何
538一个邮件列表!维护者都是大忙人,可能会把一些工作留给子系统特定列表上的其他开
539发者;而 LKML 很重要,因为需要一个可以找到所有问题报告的地方。
540
541
542借助脚本找到维护者
543~~~~~~~~~~~~~~~~~~~~
544
545对于手头有Linux源码的人来说,有第二个可以找到合适的报告地点的选择:脚本
546“scripts/get_maintainer.pl”,它尝试找到所有要联系的人。它会查询MAINTAINERS
547文件,并需要用相关源代码的路径来调用。对于编译成模块的驱动程序,经常可以用
548这样的命令找到::
549
550 $ modinfo ath10k_pci | grep filename | sed 's!/lib/modules/.*/kernel/!!; s!filename:!!; s!\.ko\(\|\.xz\)!!'
551 drivers/net/wireless/ath/ath10k/ath10k_pci.ko
552
553将其中的部分内容传递给脚本::
554
555 $ ./scripts/get_maintainer.pl -f drivers/net/wireless/ath/ath10k*
556 Some Human <shuman@example.com> (supporter:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER)
557 Another S. Human <asomehuman@example.com> (maintainer:NETWORKING DRIVERS)
558 ath10k@lists.infradead.org (open list:QUALCOMM ATHEROS ATH10K WIRELESS DRIVER)
559 linux-wireless@vger.kernel.org (open list:NETWORKING DRIVERS (WIRELESS))
560 netdev@vger.kernel.org (open list:NETWORKING DRIVERS)
561 linux-kernel@vger.kernel.org (open list)
562
563不要把你的报告发给所有的人。发送给维护者,脚本称之为“supporter:”;另外抄送
564代码最相关的邮件列表,以及 Linux 内核邮件列表(LKML)。在此例中,你需要将报
565告发送给 “Some Human <shuman@example.com>” ,并抄送
566“ath10k@lists.infradead.org”和“linux-kernel@vger.kernel.org”。
567
568注意:如果你用 git 克隆了 Linux 源代码,你可能需要用--git 再次调用
569get_maintainer.pl。脚本会查看提交历史,以找到最近哪些人参与了相关代码的编写,
570因为他们可能会提供帮助。但要小心使用这些结果,因为它很容易让你误入歧途。
571例如,这种情况常常会发生在很少被修改的地方(比如老旧的或未维护的驱动程序):
572有时这样的代码会在树级清理期间被根本不关心此驱动程序的开发者修改。
573
574
575搜索现有报告(第二部分)
576--------------------------
577
578 *在缺陷追踪器或问题相关邮件列表的存档中彻底搜索可能与您的问题匹配的报告。
579 如果找到匹配的报告,请加入讨论而不是发送新报告。*
580
581如前所述:报告一个别人已经提出的问题,对每个人来说都是浪费时间,尤其是作为报告
582人的你。这就是为什么你应该再次搜索现有的报告。现在你已经知道问题需要报告到哪里。
583如果是邮件列表,那么一般在 `lore.kernel.org <https://lore.kernel.org/>`_ 可以
584找到相应存档。
585
586但有些列表运行在其他地方。例如前面步骤中当例子的ath10k WiFi驱动程序就是这种
587情况。但是你通常可以在网上很容易地找到这些列表的档案。例如搜索“archive
588ath10k@lists.infradead.org”,将引导您到ath10k邮件列表的信息页,该页面顶部链接
589到其 `列表存档 <https://lists.infradead.org/pipermail/ath10k/>`_ 。遗憾的是,
590这个列表和其他一些列表缺乏搜索其存档的功能。在这种情况下可以使用常规的互联网
591搜索引擎,并添加类似“site:lists.infadead.org/pipermail/ath10k/”这
592样的搜索条件,这会把结果限制在该链接中的档案。
593
594也请进一步搜索网络、LKML和bugzilla.kernel.org网站。
595
596有关如何搜索以及在找到匹配报告时如何操作的详细信息,请参阅上面的“搜索现有报告
597(第一部分)”。
598
599不要急着完成报告过程的这一步:花30到60分钟甚至更多的时间可以为你和其他人节省 /
600减少相当多的时间和麻烦。
601
602
603安装一个新的内核进行测试
604--------------------------
605
606 *除非您已经在运行最新的“主线”Linux内核,否则最好在报告流程前安装它。在
607 某些情况下,使用最新的“稳定版”Linux进行测试和报告也是可以接受的替代方案;
608 在合并窗口期间,这实际上可能是最好的方法,但在开发阶段最好还是暂停几天。
609 无论你选择什么版本,最好使用“普通”构建。忽略这些建议会大大增加您的报告
610 被拒绝或忽略的风险。*
611
612正如第一步的详细解释中所提到的:与大多数程序员一样,与大多数程序员一样,Linux
613内核开发人员不喜欢花时间处理他们维护的源代码中根本不会发生的问题的报告。这只
614会浪费每个人的时间,尤其是你的时间。这就是为什么在报告问题之前,您必须先确认
615问题仍然存在于最新的上游代码中,这符合每个人的利益。您可以忽略此建议,但如前
616所述:这样做会极大地增加问题报告被拒绝或被忽略的风险。
617
618内核“最新上游”的范围通常指:
619
620 * 安装一个主线内核;最新的稳定版内核也可以是一个选择,但大多数时候都最好避免。
621 长期支持内核(有时称为“LTS内核”)不适合此流程。下一小节将更详细地解释所有
622 这些。
623
624 * 下一小节描述获取和安装这样一个内核的方法。它还指出了使用预编译内核是可以的,
625 但普通的内核更好,这意味着:它是直接使用从 `kernel.org <https://kernel.org/>`_
626 获得的Linux源代码构建并且没有任何方式修改或增强。
627
628
629选择适合测试的版本
630~~~~~~~~~~~~~~~~~~~~
631
632前往 `kernel.org <https://kernel.org/>`_ 来决定使用哪个版本。忽略那个写着
633“Latest release最新版本”的巨大黄色按钮,往下看有一个表格。在表格的顶部,你会
634看到一行以“mainline”开头的字样,大多数情况下它会指向一个版本号类似“5.8-rc2”
635的预发布版本。如果是这样的话,你将需要使用这个主线内核进行测试。不要让“rc”
636吓到你,这些“开发版内核”实际上非常可靠——而且你已经按照上面的指示做了备份,
637不是吗?
638
639大概每九到十周,“mainline”可能会给你指出一个版本号类似“5.7”的正式版本。如果
640碰见这种情况,请考虑暂停报告过程,直到下一个版本的第一个预发布(5.8-rc1)出
641现在 `kernel.org <https://kernel.org/>`_ 上。这是因为 Linux 的开发周期正在
642两周的“合并窗口”内。大部分的改动和所有干扰性的改动都会在这段时间内被合并到
643下一个版本中。在此期间使用主线是比较危险的。内核开发者通常也很忙,可能没有
644多余的时间来处理问题报告。这也是很有可能在合并窗口中应用了许多修改来修复你
645所面临的问题;这就是为什么你很快就得用一个新的内核版本重新测试,就像下面“发
646布报告后的责任”一节中所述的那样。
647
648这就是为什么要等到合并窗口结束后才去做。但是如果你处理的是一些不应该等待的
649东西,则无需这样做。在这种情况下,可以考虑通过 git 获取最新的主线内核(见下
650文),或者使用 kernel.org 上提供的最新稳定版本。如果 mainline 因为某些原因
651不无法正常工作,那么使用它也是可以接受的。总的来说:用它来重现问题也比完全
652不报告问题要好。
653
654最好避免在合并窗口外使用最新的稳定版内核,因为所有修复都必须首先应用于主线。
655这就是为什么检查最新的主线内核是如此重要:你希望看到在旧版本线修复的任何问题
656需要先在主线修复,然后才能得到回传,这可能需要几天或几周。另一个原因是:您
657希望的修复对于回传来说可能太难或太冒险;因此再次报告问题不太可能改变任何事情。
658
659这些方面也部分表明了为什么长期支持内核(有时称为“LTS内核”)不适合报告流程:
660它们与当前代码的距离太远。因此,先去测试主线,然后再按流程走:如果主线没有
661出现问题,流程将指导您如何在旧版本线中修复它。
662
663如何获得新的 Linux 内核
664~~~~~~~~~~~~~~~~~~~~~~~~~
665
666你可以使用预编译或自编译的内核进行测试;如果你选择后者,可以使用 git 获取源
667代码,或者下载其 tar 存档包。
668
669**使用预编译的内核** :这往往是最快速、最简单、最安全的方法——尤其是在你不熟
670悉 Linux 内核的情况下。问题是:发行商或附加存储库提供的大多数版本都是从修改
671过的Linux源代码构建的。因此它们不是普通的,通常不适合于测试和问题报告:这些
672更改可能会导致您面临的问题或以某种方式影响问题。
673
674但是如果您使用的是流行的Linux发行版,那么您就很幸运了:对于大部分的发行版,
675您可以在网上找到包含最新主线或稳定版本Linux内核包的存储库。使用这些是完全可
676以的,只要从存储库的描述中确认它们是普通的或者至少接近普通。此外,请确保软件
677包包含kernel.org上提供的最新版本内核。如果这些软件包的时间超过一周,那么它们
678可能就不合适了,因为新的主线和稳定版内核通常至少每周发布一次。
679
680请注意,您以后可能需要手动构建自己的内核:有时这是调试或测试修复程序所必需的,
681如后文所述。还要注意,预编译的内核可能缺少在出现panic、Oops、warning或BUG时
682解码内核打印的消息所需的调试符号;如果您计划解码这些消息,最好自己编译内核
683(有关详细信息,请参阅本小节结尾和“解码失败信息”小节)。
684
685**使用git** :熟悉 git 的开发者和有经验的 Linux 用户通常最好直接从
686`kernel.org 上的官方开发仓库
687<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/>`_
688中获取最新的 Linux 内核源代码。这些很可能比最新的主线预发布版本更新一些。不
689用担心:它们和正式的预发布版本一样可靠,除非内核的开发周期目前正处于合并窗
690口中。不过即便如此,它们也是相当可靠的。
691
692**常规方法** :不熟悉 git 的人通常最好从 `kernel.org <https://kernel.org/>`_
693下载源码的tar 存档包。
694
695如何实际构建一个内核并不在这里描述,因为许多网站已经解释了必要的步骤。如果
696你是新手,可以考虑按照那些建议使用 ``make localmodconfig`` 来做,它将尝试获
697取你当前内核的配置,然后根据你的系统进行一些调整。这样做并不能使编译出来的
698内核更好,但可以更快地编译。
699
700注意:如果您正在处理来自内核的pannc、Oops、warning或BUG,请在配置内核时尝试
701启用 CONFIG_KALLSYMS 选项。此外,还可以启用 CONFIG_DEBUG_KERNEL 和
702CONFIG_DEBUG_INFO;后者是相关选项,但只有启用前者才能开启。请注意,
703CONFIG_DEBUG_INFO 会需要更多储存空间来构建内核。但这是值得的,因为这些选项将
704允许您稍后精确定位触发问题的确切代码行。下面的“解码失败信息”一节对此进行了更
705详细的解释。
706
707但请记住:始终记录遇到的问题,以防难以重现。发送未解码的报告总比不报告要好。
708
709
710检查“污染”标志
711----------------
712
713 *确保您刚刚安装的内核在运行时不会“污染”自己。*
714
715正如上面已经详细介绍过的:当发生一些可能会导致一些看起来完全不相关的后续错
716误的事情时,内核会设置一个“污染”标志。这就是为什么你需要检查你刚刚安装的内
717核是否有设置此标志。如果有的话,几乎在任何情况下你都需要在报告问题之前先消
718除它。详细的操作方法请看上面的章节。
719
720
721用新内核重现问题
722------------------
723
724 *在您刚刚安装的内核中复现这个问题。如果它没有出现,请查看下方只发生在
725 稳定版和长期支持内核的问题的说明。*
726
727检查这个问题是否发生在你刚刚安装的新 Linux 内核版本上。如果新内核已经修复了,
728可以考虑使用此版本线,放弃报告问题。但是请记住,只要它没有在 `kernel.org
729<https://kernel.org/>`_ 的稳定版和长期版(以及由这些版本衍生出来的厂商内核)
730中得到修复,其他用户可能仍然会受到它的困扰。如果你喜欢使用其中的一个,或
731者只是想帮助它们的用户,请前往下面的“报告只发生在较旧内核版本线的问题”一节。
732
733
734优化复现问题的描述
735--------------------
736
737 *优化你的笔记:试着找到并写出最直接的复现问题的方法。确保最终结果包含所
738 有重要的细节,同时让第一次听说的人容易阅读和理解。如果您在此过程中学到
739 了一些东西,请考虑再次搜索关于该问题的现有报告。*
740
741过于复杂的报告会让别人很难理解。因此请尽量找到一个可以直接描述、易于以书面
742形式理解的再现方法。包含所有重要的细节,但同时也要尽量保持简短。
743
744在这在前面的步骤中,你很可能已经了解了一些关于你所面临的问题的点。利用这些
745知识,再次搜索可以转而加入的现有报告。
746
747
748解码失败信息
749-------------
750
751 *如果失败涉及“panic”、“Oops”、“warning”或“BUG”,请考虑解码内核日志以查找
752 触发错误的代码行。*
753
754当内核检测到内部问题时,它会记录一些有关已执行代码的信息。这使得在源代码中精
755确定位触发问题的行并显示如何调用它成为可能。但只有在配置内核时启用了
756CONFIG_DEBUG_INFO 和 CONFIG_KALLSYMS选项时,这种方法才起效。如果已启用此选项,
757请考虑解码内核日志中的信息。这将使我们更容易理解是什么导致了“panic”、“Oops”、
758“warning”或“BUG”,从而增加了有人提供修复的几率。
759
760解码可以通过Linux源代码树中的脚本来完成。如果您运行的内核是之前自己编译的,
761这样这样调用它::
762
763 [user@something ~]$ sudo dmesg | ./linux-5.10.5/scripts/decode_stacktrace.sh ./linux-5.10.5/vmlinux
764 /usr/lib/debug/lib/modules/5.10.10-4.1.x86_64/vmlinux /usr/src/kernels/5.10.10-4.1.x86_64/
765
766如果您运行的是打包好的普通内核,则可能需要安装带有调试符号的相应包。然后按以下
767方式调用脚本(如果发行版未打包,则可能需要从Linux源代码获取)::
768
769 [user@something ~]$ sudo dmesg | ./linux-5.10.5/scripts/decode_stacktrace.sh \
770 /usr/lib/debug/lib/modules/5.10.10-4.1.x86_64/vmlinux /usr/src/kernels/5.10.10-4.1.x86_64/
771
772脚本将解码如下的日志行,这些日志行显示内核在发生错误时正在执行的代码的地址::
773
774 [ 68.387301] RIP: 0010:test_module_init+0x5/0xffa [test_module]
775
776解码之后,这些行将变成这样::
777
778 [ 68.387301] RIP: 0010:test_module_init (/home/username/linux-5.10.5/test-module/test-module.c:16) test_module
779
780在本例中,执行的代码是从文件“~/linux-5.10.5/test-module/test-module.c”构建的,
781错误出现在第16行的指令中。
782
783该脚本也会如此解码以“Call trace”开头的部分中提到的地址,该部分显示出现问题的
784函数的路径。此外,脚本还会显示内核正在执行的代码部分的汇编输出。
785
786注意,如果你没法做到这一点,只需跳过这一步,并在报告中说明原因。如果你幸运的
787话,可能无需解码。如果需要的话,也许有人会帮你做这件事情。还要注意,这只是解
788码内核堆栈跟踪的几种方法之一。有时需要采取不同的步骤来检索相关的详细信息。
789别担心,如果您碰到的情况需要这样做,开发人员会告诉您该怎么做。
790
791
792对回归的特别关照
793-----------------
794
795 *如果您的问题是回归问题,请尽可能缩小引入问题时的范围。*
796
797Linux 首席开发者 Linus Torvalds 认为 Linux 内核永远不应恶化,这就是为什么他
798认为回归是不可接受的,并希望看到它们被迅速修复。这就是为什么引入了回归的改
799动导致的问题若无法通过其他方式快速解决,通常会被迅速撤销。因此,报告回归有
800点像“王炸”,会迅速得到修复。但要做到这一点,需要知道导致回归的变化。通常情
801况下,要由报告者来追查罪魁祸首,因为维护者往往没有时间或手头设置不便来自行
802重现它。
803
804有一个叫做“二分”的过程可以来寻找变化,这在
805“Documentation/translations/zh_CN/admin-guide/bug-bisect.rst”文档中进行了详细
806的描述,这个过程通常需要你构建十到二十个内核镜像,每次都尝试在构建下一个镜像
807之前重现问题。是的,这需要花费一些时间,但不用担心,它比大多数人想象的要快得多。
808多亏了“binary search二进制搜索”,这将引导你在源代码管理系统中找到导致回归的提交。
809一旦你找到它,就在网上搜索其主题、提交ID和缩短的提交ID(提交ID的前12个字符)。
810如果有的话,这将引导您找到关于它的现有报告。
811
812需要注意的是,二分法需要一点窍门,不是每个人都懂得诀窍,也需要相当多的努力,
813不是每个人都愿意投入。尽管如此,还是强烈建议自己进行一次二分。如果你真的
814不能或者不想走这条路,至少要找出是哪个主线内核引入的回归。比如说从 5.5.15
815切换到 5.8.4 的时候出现了一些问题,那么至少可以尝试一下相近的所有的主线版本
816(5.6、5.7 和 5.8)来检查它是什么时候出现的。除非你想在一个稳定版或长期支持
817内核中找到一个回归,否则要避免测试那些编号有三段的版本(5.6.12、5.7.8),因
818为那会使结果难以解释,可能会让你的测试变得无用。一旦你找到了引入回归的主要
819版本,就可以放心地继续报告了。但请记住:在不知道罪魁祸首的情况下,开发人员
820是否能够提供帮助取决于手头的问题。有时他们可能会从报告中确认是什么出现了问
821题,并能修复它;有时他们可能无法提供帮助,除非你进行二分。
822
823当处理回归问题时,请确保你所面临的问题真的是由内核引起的,而不是由其他东西
824引起的,如上文所述。
825
826在整个过程中,请记住:只有当旧内核和新内核的配置相似时,问题才算回归。最好
827的方法是:把配置文件(``.config``)从旧的工作内核直接复制到你尝试的每个新内
828核版本。之后运行 ``make oldnoconfig`` 来调整它以适应新版本的需要,而不启用
829任何新的功能,因为那些功能也可能导致回归。
830
831
832撰写并发送报告
833---------------
834
835 *通过详细描述问题来开始编写报告。记得包括以下条目:您为复现而安装的最新
836 内核版本、使用的Linux发行版以及关于如何复现该问题的说明。如果可能,将内
837 核构建配置(.config)和 ``dmesg`` 的输出放在网上的某个地方,并链接到它。
838 包含或上传所有其他可能相关的信息,如Oops的输出/截图或来自 ``lspci``
839 的输出。一旦你写完了这个主要部分,请在上方插入一个正常长度的段落快速概
840 述问题和影响。再在此之上添加一个简单描述问题的句子,以得到人们的阅读。
841 现在给出一个更短的描述性标题或主题。然后就可以像MAINTAINERS文件告诉你的
842 那样发送或提交报告了,除非你在处理一个“高优先级问题”:它们需要按照下面
843 “高优先级问题的特殊处理”所述特别关照。*
844
845现在你已经准备好了一切,是时候写你的报告了。上文前言中链接的三篇文档对如何
846写报告做了部分解释。这就是为什么本文将只提到一些基本的内容以及 Linux 内核特
847有的东西。
848
849有一点是符合这两类的:你的报告中最关键的部分是标题/主题、第一句话和第一段。
850开发者经常会收到许多邮件。因此,他们往往只是花几秒钟的时间浏览一下邮件,然
851后再决定继续下一封或仔细查看。因此,你报告的开头越好,有人研究并帮助你的机
852会就越大。这就是为什么你应该暂时忽略他们,先写出详细的报告。;-)
853
854每份报告都应提及的事项
855~~~~~~~~~~~~~~~~~~~~~~~~
856
857详细描述你的问题是如何发生在你安装的新纯净内核上的。试着包含你之前写的和优
858化过的分步说明,概述你和其他人如何重现这个问题;在极少数无法重现的情况下,
859尽量描述你做了什么来触发它。
860
861还应包括其他人为了解该问题及其环境而可能需要的所有相关信息。实际需要的东西
862在很大程度上取决于具体问题,但有些事项你总是应该包括在内:
863
864 * ``cat /proc/version`` 的输出,其中包含 Linux 内核版本号和构建时的编译器。
865
866 * 机器正在运行的 Linux 发行版( ``hostnamectl | grep “Operating System“`` )
867
868 * CPU 和操作系统的架构( ``uname -mi`` )
869
870 * 如果您正在处理回归,并进行了二分,请提及导致回归的变更的主题和提交ID。
871
872许多情况下,让读你报告的人多了解两件事也是明智之举:
873
874 * 用于构建 Linux 内核的配置(“.config”文件)
875
876 * 内核的信息,你从 ``dmesg`` 得到的信息写到一个文件里。确保它以像“Linux
877 version 5.8-1 (foobar@example.com) (gcc (GCC) 10.2.1, GNU ld version
878 2.34) #1 SMP Mon Aug 3 14:54:37 UTC 2020”这样的行开始,如果没有,那么第
879 一次启动阶段的重要信息已经被丢弃了。在这种情况下,可以考虑使用
880 ``journalctl -b 0 -k`` ;或者你也可以重启,重现这个问题,然后调用
881 ``dmesg`` 。
882
883这两个文件很大,所以直接把它们放到你的报告中是个坏主意。如果你是在缺陷跟踪
884器中提交问题,那么将它们附加到工单中。如果你通过邮件报告问题,不要用附件附
885上它们,因为那会使邮件变得太大,可以按下列之一做:
886
887 * 将文件上传到某个公开的地方(你的网站,公共文件粘贴服务,在
888 `bugzilla.kernel.org <https://bugzilla.kernel.org/>`_ 上创建的工单……),
889 并在你的报告中放上链接。理想情况下请使用允许这些文件保存很多年的地方,因
890 为它们可能在很多年后对别人有用;例如 5 年或 10 年后,一个开发者正在修改
891 一些代码,而这些代码正是为了修复你的问题。
892
893 * 把文件放在一边,然后说明你会在他人回复时再单独发送。只要记得报告发出去后,
894 真正做到这一点就可以了。;-)
895
896提供这些东西可能是明智的
897~~~~~~~~~~~~~~~~~~~~~~~~~~
898
899根据问题的不同,你可能需要提供更多的背景数据。这里有一些关于提供什么比较好
900的建议:
901
902 * 如果你处理的是内核的“warning”、“OOPS”或“panic”,请包含它。如果你不能复制
903 粘贴它,试着用netconsole网络终端远程跟踪或者至少拍一张屏幕的照片。
904
905 * 如果问题可能与你的电脑硬件有关,请说明你使用的是什么系统。例如,如果你的
906 显卡有问题,请提及它的制造商,显卡的型号,以及使用的芯片。如果是笔记本电
907 脑,请提及它的型号名称,但尽量确保意义明确。例如“戴尔 XPS 13”就不很明确,
908 因为它可能是 2012 年的那款,那款除了看起来和现在销售的没有什么不同之外,
909 两者没有任何共同之处。因此,在这种情况下,要加上准确的型号,例如 2019
910 年内推出的 XPS 13 型号为“9380”或“7390”。像“联想 Thinkpad T590”这样的名字
911 也有些含糊不清:这款笔记本有带独立显卡和不带的子型号,所以要尽量找到准确
912 的型号名称或注明主要部件。
913
914 * 说明正在使用的相关软件。如果你在加载模块时遇到了问题,你要说明正在使用的
915 kmod、systemd 和 udev 的版本。如果其中一个 DRM 驱动出现问题,你要说明
916 libdrm 和 Mesa 的版本;还要说明你的 Wayland 合成器或 X-Server 及其驱动。
917 如果你有文件系统问题,请注明相应的文件系统实用程序的版本(e2fsprogs,
918 btrfs-progs, xfsprogs……)。
919
920 * 从内核中收集可能有用的额外信息。例如, ``lspci -nn`` 的输出可以帮助别人
921 识别你使用的硬件。如果你的硬件有问题,你甚至可以给出 ``sudo lspci -vvv``
922 的结果,因为它提供了组件是如何配置的信息。对于一些问题,可能最好包含
923 ``/proc/cpuinfo`` , ``/proc/ioports`` , ``/proc/iomem`` ,
924 ``/proc/modules`` 或 ``/proc/scsi/scsi`` 等文件的内容。一些子系统还提
925 供了收集相关信息的工具。 ``alsa-info.sh`` `就是这样一个工具,它是音频/声
926 音子系统开发者提供的 <https://www.alsa-project.org/wiki/AlsaInfo>`_ 。
927
928这些例子应该会给你一些知识点,让你知道附上什么数据可能是明智的,但你自己也
929要想一想,哪些数据对别人会有帮助。不要太担心忘记一些东西,因为开发人员会要
930求提供他们需要的额外细节。但从一开始就把所有重要的东西都提供出来,会增加别
931人仔细查看的机会。
932
933
934重要部分:报告的开头
935~~~~~~~~~~~~~~~~~~~~~~
936
937现在你已经准备好了报告的详细部分,让我们进入最重要的部分:开头几句。现在到
938报告的最前面,在你刚才写的部分之前加上类似“The detailed description:”(详细
939描述)这样的内容,并在最前面插入两个新行。现在写一个正常长度的段落,大致概
940述这个问题。去掉所有枯燥的细节,把重点放在读者需要知道的关键部分,以让人了
941解这是怎么回事;如果你认为这个缺陷影响了很多用户,就提一下这点来吸引大家关
942注。
943
944做好这一点后,在顶部再插入两行,写一句话的摘要,快速解释报告的内容。之后你
945要更加抽象,为报告写一个更短的主题/标题。
946
947现在你已经写好了这部分,请花点时间来优化它,因为它是你的报告中最重要的部分:
948很多人会先读这部分,然后才会决定是否值得花时间阅读其他部分。
949
950现在就像 :ref:`MAINTAINERS <maintainers>` 维护者文件告诉你的那样发送或提交
951报告,除非它是前面概述的那些“高优先级问题”之一:在这种情况下,请先阅读下一
952小节,然后再发送报告。
953
954高优先级问题的特殊处理
955~~~~~~~~~~~~~~~~~~~~~~~~
956
957高优先级问题的报告需要特殊处理。
958
959**非常严重的缺陷** :确保在主题或工单标题以及第一段中明显标出 severeness
960(非常严重的)。
961
962**回归** :如果问题是一个回归,请在邮件的主题或缺陷跟踪器的标题中添加
963[REGRESSION]。如果您没有进行二分,请至少注明您测试的最新主线版本(比如 5.7)
964和出现问题的最新版本(比如 5.8)。如果您成功地进行了二分,请注明导致回归
965的提交ID和主题。也请添加该变更的作者到你的报告中;如果您需要将您的缺陷提交
966到缺陷跟踪器中,请将报告以私人邮件的形式转发给他,并注明报告提交地点。
967
968**安全问题** :对于这种问题,你将必须评估:如果细节被公开披露,是否会对其他
969用户产生短期风险。如果不会,只需按照所述继续报告问题。如果有此风险,你需要
970稍微调整一下报告流程。
971
972 * 如果 MAINTAINERS 文件指示您通过邮件报告问题,请不要抄送任何公共邮件列表。
973
974 * 如果你应该在缺陷跟踪器中提交问题,请确保将工单标记为“私有”或“安全问题”。
975 如果缺陷跟踪器没有提供保持报告私密性的方法,那就别想了,把你的报告以私人
976 邮件的形式发送给维护者吧。
977
978在这两种情况下,都一定要将报告发到 MAINTAINERS 文件中“安全联络”部分列出的
979地址。理想的情况是在发送报告的时候直接抄送他们。如果您在缺陷跟踪器中提交了
980报告,请将报告的文本转发到这些地址;但请在报告的顶部加上注释,表明您提交了
981报告,并附上工单链接。
982
983更多信息请参见“Documentation/translations/zh_CN/admin-guide/security-bugs.rst”。
984
985
986发布报告后的责任
987------------------
988
989 *等待别人的反应,继续推进事情,直到你能够接受这样或那样的结果。因此,请
990 公开和及时地回应任何询问。测试提出的修复。积极地测试:至少重新测试每个
991 新主线版本的首个候选版本(RC),并报告你的结果。如果出现拖延,就友好地
992 提醒一下。如果你没有得到任何帮助或者未能满意,请试着自己帮助自己。*
993
994如果你的报告非常优秀,而且你真的很幸运,那么某个开发者可能会立即发现导致问
995题的原因;然后他们可能会写一个补丁来修复、测试它,并直接发送给主线集成,同
996时标记它以便以后回溯到需要它的稳定版和长期支持内核。那么你需要做的就是回复
997一句“Thank you very much”(非常感谢),然后在发布后换上修复好的版本。
998
999但这种理想状况很少发生。这就是为什么你把报告拿出来之后工作才开始。你要做的
1000事情要视情况而定,但通常会是下面列出的事情。但在深入研究细节之前,这里有几
1001件重要的事情,你需要记住这部分的过程。
1002
1003
1004关于进一步互动的一般建议
1005~~~~~~~~~~~~~~~~~~~~~~~~~~
1006
1007**总是公开回复** :当你在缺陷跟踪器中提交问题时,一定要在那里回复,不要私下
1008联系任何开发者。对于邮件报告,在回复您收到的任何邮件时,总是使用“全部回复”
1009功能。这包括带有任何你可能想要添加到你的报告中的额外数据的邮件:进入邮件应
1010用程序“已发送”文件夹,并在邮件上使用“全部回复”来回复报告。这种方法可以确保
1011公共邮件列表和其他所有参与者都能及时了解情况;它还能保持邮件线程的完整性,
1012这对于邮件列表将所有相关邮件归为一类是非常重要的。
1013
1014只有两种情况不适合在缺陷跟踪器或“全部回复”中发表评论:
1015
1016 * 有人让你私下发东西。
1017
1018 * 你被告知要发送一些东西,但注意到其中包含需要保密的敏感信息。在这种情况下,
1019 可以私下发送给要求发送的开发者。但要在工单或邮件中注明你是这么做的,这
1020 样其他人就知道你尊重了这个要求。
1021
1022**在请求解释或帮助之前先研究一下** :在这部分过程中,有人可能会告诉你用尚未
1023掌握的技能做一些事情。例如你可能会被要求使用一些你从未听说过的测试工具;或
1024者你可能会被要求在 Linux 内核源代码上应用一个补丁来测试它是否有帮助。在某些
1025情况下,发个回复询问如何做就可以了。但在走这条路之前,尽量通过在互联网上搜
1026索自行找到答案;或者考虑在其他地方询问建议。比如询问朋友,或者到你平时常去
1027的聊天室或论坛发帖咨询。
1028
1029**要有耐心** :如果你真的很幸运,你可能会在几个小时内收到对你的报告的答复。
1030但大多数情况下会花费更多的时间,因为维护者分散在全球各地,因此可能在不同的
1031时区——在那里他们已经享受着远离键盘的夜晚。
1032
1033一般来说,内核开发者需要一到五个工作日来回复报告。有时会花费更长的时间,因
1034为他们可能正忙于合并窗口、其他工作、参加开发者会议,或者只是在享受一个漫长
1035的暑假。
1036
1037“高优先级的问题”(见上面的解释)例外:维护者应该尽快解决这些问题;这就是为
1038什么你应该最多等待一个星期(如果是紧急的事情,则只需两天),然后再发送友好
1039的提醒。
1040
1041有时维护者可能没有及时回复;有时候可能会出现分歧,例如一个问题是否符合回归
1042的条件。在这种情况下,在邮件列表上提出你的顾虑,并请求其他人公开或私下回复
1043如何继续推进。如果失败了,可能应该让更高级别的维护者介入。如果是 WiFi 驱动,
1044那就是无线维护者;如果没有更高级别的维护者,或者其他一切努力都失败了,那
1045这可能是一种罕见的、可以让 Linus Torvalds 参与进来的情况。
1046
1047**主动测试** :每当一个新的主线内核版本的第一个预发布版本(rc1)发布的时候,
1048去检查一下这个问题是否得到了解决,或者是否有什么重要的变化。在工单中或在
1049回复报告的邮件中提及结果(确保所有参与讨论的人都被抄送)。这将表明你的承诺
1050和你愿意帮忙。如果问题持续存在,它也会提醒开发者确保他们不会忘记它。其他一
1051些不定期的重新测试(例如用rc3、rc5 和最终版本)也是一个好主意,但只有在相关
1052的东西发生变化或者你正在写什么东西的时候才报告你的结果。
1053
1054这些些常规的事情就不说了,我们来谈谈报告后如何帮助解决问题的细节。
1055
1056查询和测试请求
1057~~~~~~~~~~~~~~~
1058
1059如果你的报告得到了回复则需履行以下责任:
1060
1061**检查与你打交道的人** :大多数情况下,会是维护者或特定代码区域的开发人员对
1062你的报告做出回应。但由于问题通常是公开报告的,所以回复的可能是任何人——包括
1063那些想要帮忙的人,但最后可能会用他们的问题或请求引导你完全偏离轨道。这很少
1064发生,但这是快速上网搜搜看你正在与谁互动是明智之举的许多原因之一。通过这样
1065做,你也可以知道你的报告是否被正确的人听到,因为如果讨论没有导致满意的问题
1066解决方案而淡出,之后可能需要提醒维护者(见下文)。
1067
1068**查询数据** :通常你会被要求测试一些东西或提供更多细节。尽快提供所要求的信
1069息,因为你已经得到了可能会帮助你的人的注意,你等待的时间越长就有越可能失去
1070关注;如果你不在数个工作日内提供信息,甚至可能出现这种结果。
1071
1072**测试请求** :当你被要求测试一个诊断补丁或可能的修复时,也要尽量及时测试。
1073但要做得恰当,一定不要急于求成:混淆事情很容易发生,这会给所有人带来许多困
1074惑。例如一个常见的错误是以为应用了一个带修复的建议补丁,但事实上并没有。即
1075使是有经验的测试人员也会偶尔发生这样的事情,但当有修复的内核和没有修复的内
1076核表现得一样时,他们大多时候会注意到。
1077
1078当没有任何实质性进展时该怎么办
1079~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1080
1081有些报告不会得到负有相关责任的 Linux 内核开发者的任何反应;或者围绕这个问题
1082的讨论有所发展,但渐渐淡出,没有任何实质内容产出。
1083
1084在这种情况下,要等两个星期(最好是三个星期)后再发出友好的提醒:也许当你的
1085报告到达时,维护者刚刚离开键盘一段时间,或者有更重要的事情要处理。在写提醒
1086信的时候,要善意地问一下,是否还需要你这边提供什么来让事情推进下去。如果报
1087告是通过邮件发出来的,那就在邮件的第一行回复你的初始邮件(见上文),其中包
1088括下方的原始报告的完整引用:这是少数几种情况下,这样的“TOFU”(Text Over,
1089Fullquote Under文字在上,完整引用在下)是正确的做法,因为这样所有的收件人都
1090会以适当的顺序立即让细节到手头上来。
1091
1092在提醒之后,再等三周的回复。如果你仍然没有得到适当的反馈,你首先应该重新考
1093虑你的方法。你是否可能尝试接触了错误的人?是不是报告也许令人反感或者太混乱,
1094以至于人们决定完全远离它?排除这些因素的最好方法是:把报告给一两个熟悉
1095FLOSS 问题报告的人看,询问他们的意见。同时征求他们关于如何继续推进的建议。
1096这可能意味着:准备一份更好的报告,让这些人在你发出去之前对它进行审查。这样
1097的方法完全可以;只需说明这是关于这个问题的第二份改进的报告,并附上第一份报
1098告的链接。
1099
1100如果报告是恰当的,你可以发送第二封提醒信;在其中询问为什么报告没有得到任何
1101回复。第二封提醒邮件的好时机是在新 Linux 内核版本的首个预发布版本('rc1')
1102发布后不久,因为无论如何你都应该在那个时候重新测试并提供状态更新(见上文)。
1103
1104如果第二次提醒的结果又在一周内没有任何反应,可以尝试联系上级维护者询问意见:
1105即使再忙的维护者在这时候也至少应该发过某种确认。
1106
1107记住要做好失望的准备:理想状况下维护者最好对每一个问题报告做出回应,但他们
1108只有义务解决之前列出的“高优先级问题”。所以,如果你得到的回复是“谢谢你的报告,
1109我目前有更重要的问题要处理,在可预见的未来没有时间去研究这个问题”,那请不
1110要太沮丧。
1111
1112也有可能在缺陷跟踪器或列表中进行了一些讨论之后,什么都没有发生,提醒也无助
1113于激励大家进行修复。这种情况可能是毁灭性的,但在 Linux 内核开发中确实会发生。
1114这些和其他得不到帮助的原因在本文结尾处的“为什么有些问题在被报告后没有得到
1115任何回应或者仍然没有修复”中进行了解释。
1116
1117如果你没有得到任何帮助或问题最终没有得到解决,不要沮丧:Linux 内核是 FLOSS,
1118因此你仍然可以自己帮助自己。例如,你可以试着找到其他受影响的人,和他们一
1119起合作来解决这个问题。这样的团队可以一起准备一份新的报告,提到团队有多少人,
1120为什么你们认为这是应该得到解决的事情。也许你们还可以一起缩小确切原因或引
1121入回归的变化,这往往会使修复更容易。而且如果运气好的话,团队中可能会有懂点
1122编程的人,也许能写出一个修复方案。
1123
1124
1125
1126“报告稳定版和长期支持内核线的回归”的参考
1127------------------------------------------
1128
1129本小节提供了在稳定版和长期支持内核线中面对回归时需要执行的步骤的详细信息。
1130
1131确保特定版本线仍然受支持
1132~~~~~~~~~~~~~~~~~~~~~~~~~
1133
1134 *检查内核开发人员是否仍然维护你关心的Linux内核版本线:去 kernel.org 的
1135 首页,确保此特定版本线的最新版没有“[EOL]”标记。*
1136
1137大多数内核版本线只支持三个月左右,因为延长维护时间会带来相当多的工作。因此,
1138每年只会选择一个版本来支持至少两年(通常是六年)。这就是为什么你需要检查
1139内核开发者是否还支持你关心的版本线。
1140
1141注意,如果 `kernel.org <https://kernel.org/>`_ 在首页上列出了两个“稳定”版本,
1142你应该考虑切换到较新的版本,而忘掉较旧的版本:对它的支持可能很快就会结束。
1143然后,它将被标记为“生命周期结束”(EOL)。达到这个程度的版本线仍然会在
1144`kernel.org <https://kernel.org/>`_ 首页上被显示一两周,但不适合用于测试和
1145报告。
1146
1147搜索稳定版邮件列表
1148~~~~~~~~~~~~~~~~~~~
1149
1150 *检查Linux稳定版邮件列表中的现有报告。*
1151
1152也许你所面临的问题已经被发现,并且已经或即将被修复。因此,请在 `Linux 稳定
1153版邮件列表的档案 <https://lore.kernel.org/stable/>`_ 中搜索类似问题的报告。
1154如果你找到任何匹配的问题,可以考虑加入讨论,除非修复工作已经完成并计划很快
1155得到应用。
1156
1157用最新版本复现问题
1158~~~~~~~~~~~~~~~~~~~
1159
1160 *从特定的版本线安装最新版本作为纯净内核。确保这个内核没有被污染,并且仍
1161 然存在问题,因为问题可能已经在那里被修复了。*
1162
1163在投入更多时间到这个过程中之前,你要检查这个问题是否在你关注的版本线的最新
1164版本中已经得到了修复。这个内核需要是纯净的,在问题发生之前不应该被污染,正
1165如上面已经在测试主线的过程中详细介绍过的一样。
1166
1167您是否是第一次注意到供应商内核的回归?供应商的更改可能会发生变化。你需要重新
1168检查排除来这个问题。当您从5.10.4-vendor.42更新到5.10.5-vendor.43时,记录损坏
1169的信息。然后在测试了前一段中所述的最新5.10版本之后,检查Linux 5.10.4的普通版本
1170是否也可以正常工作。如果问题在那里出现,那就不符合上游回归的条件,您需要切换
1171回主逐步指南来报告问题。
1172
1173报告回归
1174~~~~~~~~~~
1175
1176 *向Linux稳定版邮件列表发送一个简短的问题报告(stable@vger.kernel.org)。
1177 大致描述问题,并解释如何复现。讲清楚首个出现问题的版本和最后一个工作正常
1178 的版本。然后等待进一步的指示。*
1179
1180当报告在稳定版或长期支持内核线内发生的回归(例如在从5.10.4更新到5.10.5时),
1181一份简短的报告足以快速报告问题。因此只需要粗略的描述。
1182
1183但是请注意,如果您能够指明引入问题的确切版本,这将对开发人员有很大帮助。因此
1184如果有时间的话,请尝试使用普通内核找到该版本。让我们假设发行版发布Linux内核
11855.10.5到5.10.8的更新时发生了故障。那么按照上面的指示,去检查该版本线中的最新
1186内核,比如5.10.9。如果问题出现,请尝试普通5.10.5,以确保供应商应用的补丁不会
1187干扰。如果问题没有出现,那么尝试5.10.7,然后直到5.10.8或5.10.6(取决于结果)
1188找到第一个引入问题的版本。在报告中写明这一点,并指出5.10.9仍然存在故障。
1189
1190前一段基本粗略地概述了“二分”方法。一旦报告出来,您可能会被要求做一个正确的
1191报告,因为它允许精确地定位导致问题的确切更改(然后很容易被恢复以快速修复问题)。
1192因此如果时间允许,考虑立即进行适当的二分。有关如何详细信息,请参阅“对回归的
1193特别关照”部分和文档“Documentation/translations/zh_CN/admin-guide/bug-bisect.rst”。
1194
1195
1196“报告仅在旧内核版本线中发生的问题”的参考
1197----------------------------------------
1198
1199本节详细介绍了如果无法用主线内核重现问题,但希望在旧版本线(又称稳定版内核和
1200长期支持内核)中修复问题时需要采取的步骤。
1201
1202有些修复太复杂
1203~~~~~~~~~~~~~~~
1204
1205 *请做好准备,接下来的几个步骤可能无法在旧版本中解决问题:修复可能太大或
1206 太冒险,无法移植到那里。*
1207
1208即使是微小的、看似明显的代码变化,有时也会带来新的、完全意想不到的问题。稳
1209定版和长期支持内核的维护者非常清楚这一点,因此他们只对这些内核进行符合
1210“Documentation/translations/zh_CN/process/stable-kernel-rules.rst”中所列出的
1211规则的修改。
1212
1213复杂或有风险的修改不符合条件,因此只能应用于主线。其他的修复很容易被回溯到
1214最新的稳定版和长期支持内核,但是风险太大,无法集成到旧版内核中。所以要注意
1215你所希望的修复可能是那些不会被回溯到你所关心的版本线的修复之一。在这种情况
1216下,你将别无选择,要么忍受这个问题,要么切换到一个较新的 Linux 版本,除非你
1217想自己把修复补丁应用到你的内核中。
1218
1219通用准备
1220~~~~~~~~~~
1221
1222 *执行上面“报告仅在旧内核版本线中发生的问题”一节中的前三个步骤。*
1223
1224您需要执行本指南另一节中已经描述的几个步骤。这些步骤将让您:
1225
1226 * 检查内核开发人员是否仍然维护您关心的Linux内核版本行。
1227
1228 * 在Linux稳定邮件列表中搜索退出的报告。
1229
1230 * 检查最新版本。
1231
1232
1233检查代码历史和搜索现有的讨论
1234~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1235
1236 *在Linux内核版本控制系统中搜索修复主线问题的更改,因为它的提交消息可能
1237 会告诉你修复是否已经计划好了支持。如果你没有找到,搜索适当的邮件列表,
1238 寻找讨论此类问题或同行评议可能修复的帖子;然后检查讨论是否认为修复不适
1239 合支持。如果支持根本不被考虑,加入最新的讨论,询问是否有可能。*
1240
1241在许多情况下,你所处理的问题会发生在主线上,但已在主线上得到了解决。修正它
1242的提交也需要被回溯才能解决这个问题。这就是为什么你要搜索它或任何相关讨论。
1243
1244 * 首先尝试在存放 Linux 内核源代码的 Git 仓库中找到修复。你可以通过
1245 `kernel.org 上的网页
1246 <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/>`_
1247 或 `GitHub 上的镜像 <https://github.com/torvalds/linux>`_ 来实现;如果你
1248 有一个本地克隆,你也可以在命令行用 ``git log --grep=<pattern>`` 来搜索。
1249
1250 如果你找到了修复,请查看提交消息的尾部是否包含了类似这样的“稳定版标签”:
1251
1252 Cc: <stable@vger.kernel.org> # 5.4+
1253
1254 像上面这行,开发者标记了安全修复可以回传到 5.4 及以后的版本。大多数情况
1255 下,它会在两周内被应用到那里,但有时需要更长的时间。
1256
1257 * 如果提交没有告诉你任何东西,或者你找不到修复,请再找找关于这个问题的讨论。
1258 用你最喜欢的搜索引擎搜索网络,以及 `Linux kernel developers mailing
1259 list 内核开发者邮件列表 <https://lore.kernel.org/lkml/>`_ 的档案。也可以
1260 阅读上面的 `定位导致问题的内核区域` 一节,然后按照说明找到导致问题的子系
1261 统:它的缺陷跟踪器或邮件列表存档中可能有你要找的答案。
1262
1263 * 如果你看到了一个计划的修复,请按上所述在版本控制系统中搜索它,因为提交可
1264 能会告诉你是否可以进行回溯。
1265
1266 * 检查讨论中是否有任何迹象表明,该修复程序可能风险太大,无法回溯到你关心
1267 的版本线。如果是这样的话,你必须忍受这个问题,或者切换到应用了修复的内
1268 核版本线。
1269
1270 * 如果修复的问题未包含稳定版标签,并且没有讨论过回溯问题,请加入讨论:如
1271 果合适的话,请提及你所面对的问题的版本,以及你希望看到它被修复。
1272
1273
1274请求建议
1275~~~~~~~~~
1276
1277 *前面的步骤之一应该会给出一个解决方案。如果仍未能成功,请向可能引起问题
1278 的子系统的维护人员询问建议;抄送特定子系统的邮件列表以及稳定版邮件列表。*
1279
1280如果前面的三个步骤都没有让你更接近解决方案,那么只剩下一个选择:请求建议。
1281在你发给可能是问题根源的子系统的维护者的邮件中这样做;抄送子系统的邮件列表
1282以及稳定版邮件列表(stable@vger.kernel.org)。
1283
1284
1285为什么有些问题在报告后没有任何回应或仍未解决?
1286===============================================
1287
1288当向 Linux 开发者报告问题时,要注意只有“高优先级的问题”(回归、安全问题、严
1289重问题)才一定会得到解决。如果维护者或其他人都失败了,Linus Torvalds 他自己
1290会确保这一点。他们和其他内核开发者也会解决很多其他问题。但是要知道,有时他
1291们也会不能或不愿帮忙;有时甚至没有人发报告给他们。
1292
1293最好的解释就是那些内核开发者常常是在业余时间为 Linux 内核做出贡献。内核中的
1294不少驱动程序都是由这样的程序员编写的,往往只是因为他们想让自己的硬件可以在
1295自己喜欢的操作系统上使用。
1296
1297这些程序员大多数时候会很乐意修复别人报告的问题。但是没有人可以强迫他们这样
1298做,因为他们是自愿贡献的。
1299
1300还有一些情况下,这些开发者真的很想解决一个问题,但却不能解决:有时他们缺乏
1301硬件编程文档来解决问题。这种情况往往由于公开的文档太简陋,或者驱动程序是通
1302过逆向工程编写的。
1303
1304业余开发者迟早也会不再关心某驱动。也许他们的测试硬件坏了,被更高级的玩意取
1305代了,或者是太老了以至于只能在计算机博物馆里找到。有时开发者根本就不关心他
1306们的代码和 Linux 了,因为在他们的生活中一些不同的东西变得更重要了。在某些情
1307况下,没有人愿意接手维护者的工作——也没有人可以被强迫,因为对 Linux 内核的贡
1308献是自愿的。然而被遗弃的驱动程序仍然存在于内核中:它们对人们仍然有用,删除
1309它们可能导致回归。
1310
1311对于那些为 Linux 内核工作而获得报酬的开发者来说,情况并没有什么不同。这些人
1312现在贡献了大部分的变更。但是他们的雇主迟早也会停止关注他们的代码或者让程序
1313员专注于其他事情。例如,硬件厂商主要通过销售新硬件来赚钱;因此,他们中的不
1314少人并没有投入太多时间和精力来维护他们多年前就停止销售的东西的 Linux 内核驱
1315动。企业级 Linux 发行商往往持续维护的时间比较长,但在新版本中往往会把对老旧
1316和稀有硬件的支持放在一边,以限制范围。一旦公司抛弃了一些代码,往往由业余贡
1317献者接手,但正如上面提到的:他们迟早也会放下代码。
1318
1319优先级是一些问题没有被修复的另一个原因,因为维护者相当多的时候是被迫设置这
1320些优先级的,因为在 Linux 上工作的时间是有限的。对于业余时间或者雇主给予他们
1321的开发人员用于上游内核维护工作的时间也是如此。有时维护人员也会被报告淹没,
1322即使一个驱动程序几乎完美地工作。为了不被完全缠住,程序员可能别无选择,只能
1323对问题报告进行优先级排序而拒绝其中的一些报告。
1324
1325不过这些都不用太过担心,很多驱动都有积极的维护者,他们对尽可能多的解决问题
1326相当感兴趣。
1327
1328
1329结束语
1330=======
1331
1332与其他免费/自由&开源软件(Free/Libre & Open Source Software,FLOSS)相比,
1333向 Linux 内核开发者报告问题是很难的:这个文档的长度和复杂性以及字里行间的内
1334涵都说明了这一点。但目前就是这样了。这篇文字的主要作者希望通过记录现状来为
1335以后改善这种状况打下一些基础。
Documentation/translations/zh_CN/admin-guide/security-bugs.rst+74−0
@@ -0,0 +1,74 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../admin-guide/security-bugs`
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9安全缺陷
10=========
11
12Linux内核开发人员非常重视安全性。因此我们想知道何时发现了安全漏洞,以便尽快
13修复和披露。请向Linux内核安全团队报告安全漏洞。
14
15联络
16-----
17
18可以通过电子邮件<security@kernel.org>联系Linux内核安全团队。这是一个安全人员
19的私有列表,他们将帮助验证错误报告并开发和发布修复程序。如果您已经有了一个
20修复,请将其包含在您的报告中,这样可以大大加快进程。安全团队可能会从区域维护
21人员那里获得额外的帮助,以理解和修复安全漏洞。
22
23与任何缺陷一样,提供的信息越多,诊断和修复就越容易。如果您不清楚哪些信息有用,
24请查看“Documentation/translations/zh_CN/admin-guide/reporting-issues.rst”中
25概述的步骤。任何利用漏洞的攻击代码都非常有用,未经报告者同意不会对外发布,除
26非已经公开。
27
28请尽可能发送无附件的纯文本电子邮件。如果所有的细节都藏在附件里,那么就很难对
29一个复杂的问题进行上下文引用的讨论。把它想象成一个
30:doc:`常规的补丁提交 <../process/submitting-patches>` (即使你还没有补丁):
31描述问题和影响,列出复现步骤,然后给出一个建议的解决方案,所有这些都是纯文本的。
32
33披露和限制信息
34---------------
35
36安全列表不是公开渠道。为此,请参见下面的协作。
37
38一旦开发出了健壮的补丁,发布过程就开始了。对公开的缺陷的修复会立即发布。
39
40尽管我们倾向于在未公开缺陷的修复可用时即发布补丁,但应报告者或受影响方的请求,
41这可能会被推迟到发布过程开始后的7日内,如果根据缺陷的严重性需要更多的时间,
42则可额外延长到14天。推迟发布修复的唯一有效原因是为了适应QA的逻辑和需要发布
43协调的大规模部署。
44
45虽然可能与受信任的个人共享受限信息以开发修复,但未经报告者许可,此类信息不会
46与修复程序一起发布或发布在任何其他披露渠道上。这包括但不限于原始错误报告和
47后续讨论(如有)、漏洞、CVE信息或报告者的身份。
48
49换句话说,我们唯一感兴趣的是修复缺陷。提交给安全列表的所有其他资料以及对报告
50的任何后续讨论,即使在解除限制之后,也将永久保密。
51
52协调
53------
54
55对敏感缺陷(例如那些可能导致权限提升的缺陷)的修复可能需要与私有邮件列表
56<linux-distros@vs.openwall.org>进行协调,以便分发供应商做好准备,在公开披露
57上游补丁时发布一个已修复的内核。发行版将需要一些时间来测试建议的补丁,通常
58会要求至少几天的限制,而供应商更新发布更倾向于周二至周四。若合适,安全团队
59可以协助这种协调,或者报告者可以从一开始就包括linux发行版。在这种情况下,请
60记住在电子邮件主题行前面加上“[vs]”,如linux发行版wiki中所述:
61<http://oss-security.openwall.org/wiki/mailing-lists/distros#how-to-use-the-lists>。
62
63CVE分配
64--------
65
66安全团队通常不分配CVE,我们也不需要它们来进行报告或修复,因为这会使过程不必
67要的复杂化,并可能耽误缺陷处理。如果报告者希望在公开披露之前分配一个CVE编号,
68他们需要联系上述的私有linux-distros列表。当在提供补丁之前已有这样的CVE编号时,
69如报告者愿意,最好在提交消息中提及它。
70
71保密协议
72---------
73
74Linux内核安全团队不是一个正式的机构实体,因此无法签订任何保密协议。
Documentation/translations/zh_CN/admin-guide/tainted-kernels.rst+157−0
@@ -0,0 +1,157 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../admin-guide/tainted-kernels`
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9受污染的内核
10-------------
11
12当发生一些在稍后调查问题时可能相关的事件时,内核会将自己标记为“受污染
13(tainted)”的。不用太过担心,大多数情况下运行受污染的内核没有问题;这些信息
14主要在有人想调查某个问题时才有意义的,因为问题的真正原因可能是导致内核受污染
15的事件。这就是为什么来自受污染内核的缺陷报告常常被开发人员忽略,因此请尝试用
16未受污染的内核重现问题。
17
18请注意,即使在您消除导致污染的原因(亦即卸载专有内核模块)之后,内核仍将保持
19污染状态,以表示内核仍然不可信。这也是为什么内核在注意到内部问题(“kernel
20bug”)、可恢复错误(“kernel oops”)或不可恢复错误(“kernel panic”)时会打印
21受污染状态,并将有关此的调试信息写入日志 ``dmesg`` 输出。也可以通过
22``/proc/`` 中的文件在运行时检查受污染的状态。
23
24
25BUG、Oops或Panics消息中的污染标志
26~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
28在顶部以“CPU:”开头的一行中可以找到受污染的状态;内核是否受到污染和原因会显示
29在进程ID(“PID:”)和触发事件命令的缩写名称(“Comm:”)之后::
30
31 BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
32 Oops: 0002 [#1] SMP PTI
33 CPU: 0 PID: 4424 Comm: insmod Tainted: P W O 4.20.0-0.rc6.fc30 #1
34 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
35 RIP: 0010:my_oops_init+0x13/0x1000 [kpanic]
36 [...]
37
38如果内核在事件发生时没有被污染,您将在那里看到“Not-tainted:”;如果被污染,那
39么它将是“Tainted:”以及字母或空格。在上面的例子中,它看起来是这样的::
40
41 Tainted: P W O
42
43下表解释了这些字符的含义。在本例中,由于加载了专有模块( ``P`` ),出现了
44警告( ``W`` ),并且加载了外部构建的模块( ``O`` ),所以内核早些时候受到
45了污染。要解码其他字符,请使用下表。
46
47
48解码运行时的污染状态
49~~~~~~~~~~~~~~~~~~~~~
50
51在运行时,您可以通过读取 ``cat /proc/sys/kernel/tainted`` 来查询受污染状态。
52如果返回 ``0`` ,则内核没有受到污染;任何其他数字都表示受到污染的原因。解码
53这个数字的最简单方法是使用脚本 ``tools/debugging/kernel-chktaint`` ,您的
54发行版可能会将其作为名为 ``linux-tools`` 或 ``kernel-tools`` 的包的一部分提
55供;如果没有,您可以从
56`git.kernel.org <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/tools/debugging/kernel-chktaint>`_
57网站下载此脚本并用 ``sh kernel-chktaint`` 执行,它会在上面引用的日志中有类似
58语句的机器上打印这样的内容::
59
60 Kernel is Tainted for following reasons:
61 * Proprietary module was loaded (#0)
62 * Kernel issued warning (#9)
63 * Externally-built ('out-of-tree') module was loaded (#12)
64 See Documentation/admin-guide/tainted-kernels.rst in the Linux kernel or
65 https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html for
66 a more details explanation of the various taint flags.
67 Raw taint value as int/string: 4609/'P W O '
68
69你也可以试着自己解码这个数字。如果内核被污染的原因只有一个,那么这很简单,
70在本例中您可以通过下表找到数字。如果你需要解码有多个原因的数字,因为它是一
71个位域(bitfield),其中每个位表示一个特定类型的污染的存在或不存在,最好让
72前面提到的脚本来处理。但是如果您需要快速看一下,可以使用这个shell命令来检查
73设置了哪些位::
74
75 $ for i in $(seq 18); do echo $(($i-1)) $(($(cat /proc/sys/kernel/tainted)>>($i-1)&1));done
76
77污染状态代码表
78~~~~~~~~~~~~~~~
79
80=== ===== ====== ========================================================
81 位 日志 数字 内核被污染的原因
82=== ===== ====== ========================================================
83 0 G/P 1 已加载专用模块
84 1 _/F 2 模块被强制加载
85 2 _/S 4 内核运行在不合规范的系统上
86 3 _/R 8 模块被强制卸载
87 4 _/M 16 处理器报告了机器检测异常(MCE)
88 5 _/B 32 引用了错误的页或某些意外的页标志
89 6 _/U 64 用户空间应用程序请求的污染
90 7 _/D 128 内核最近死机了,即曾出现OOPS或BUG
91 8 _/A 256 ACPI表被用户覆盖
92 9 _/W 512 内核发出警告
93 10 _/C 1024 已加载staging驱动程序
94 11 _/I 2048 已应用平台固件缺陷的解决方案
95 12 _/O 4096 已加载外部构建(“树外”)模块
96 13 _/E 8192 已加载未签名的模块
97 14 _/L 16384 发生软锁定
98 15 _/K 32768 内核已实时打补丁
99 16 _/X 65536 备用污染,为发行版定义并使用
100 17 _/T 131072 内核是用结构随机化插件构建的
101=== ===== ====== ========================================================
102
103注:字符 ``_`` 表示空白,以便于阅读表。
104
105污染的更详细解释
106~~~~~~~~~~~~~~~~~
107
108 0) ``G`` 加载的所有模块都有GPL或兼容许可证, ``P`` 加载了任何专有模块。
109 没有MODULE_LICENSE(模块许可证)或MODULE_LICENSE未被insmod认可为GPL
110 兼容的模块被认为是专有的。
111
112
113 1) ``F`` 任何模块被 ``insmod -f`` 强制加载, ``' '`` 所有模块正常加载。
114
115 2) ``S`` 内核运行在不合规范的处理器或系统上:硬件已运行在不受支持的配置中,
116 因此无法保证正确执行。内核将被污染,例如:
117
118 - 在x86上:PAE是通过intel CPU(如Pentium M)上的forcepae强制执行的,这些
119 CPU不报告PAE,但可能有功能实现,SMP内核在非官方支持的SMP Athlon CPU上
120 运行,MSR被暴露到用户空间中。
121 - 在arm上:在某些CPU(如Keystone 2)上运行的内核,没有启用某些内核特性。
122 - 在arm64上:CPU之间存在不匹配的硬件特性,引导加载程序以不同的模式引导CPU。
123 - 某些驱动程序正在被用在不受支持的体系结构上(例如x86_64以外的其他系统
124 上的scsi/snic,非x86/x86_64/itanium上的scsi/ips,已经损坏了arm64上
125 irqchip/irq-gic的固件设置…)。
126
127 3) ``R`` 模块被 ``rmmod -f`` 强制卸载, ``' '`` 所有模块都正常卸载。
128
129 4) ``M`` 任何处理器报告了机器检测异常, ``' '`` 未发生机器检测异常。
130
131 5) ``B`` 页面释放函数发现错误的页面引用或某些意外的页面标志。这表示硬件问题
132 或内核错误;日志中应该有其他信息指示发生此污染的原因。
133
134 6) ``U`` 用户或用户应用程序特意请求设置受污染标志,否则应为 ``' '`` 。
135
136 7) ``D`` 内核最近死机了,即出现了OOPS或BUG。
137
138 8) ``A`` ACPI表被重写。
139
140 9) ``W`` 内核之前已发出过警告(尽管有些警告可能会设置更具体的污染标志)。
141
142 10) ``C`` 已加载staging驱动程序。
143
144 11) ``I`` 内核正在处理平台固件(BIOS或类似软件)中的严重错误。
145
146 12) ``O`` 已加载外部构建(“树外”)模块。
147
148 13) ``E`` 在支持模块签名的内核中加载了未签名的模块。
149
150 14) ``L`` 系统上先前发生过软锁定。
151
152 15) ``K`` 内核已经实时打了补丁。
153
154 16) ``X`` 备用污染,由Linux发行版定义和使用。
155
156 17) ``T`` 内核构建时使用了randstruct插件,它可以有意生成非常不寻常的内核结构
157 布局(甚至是性能病态的布局),这在调试时非常有用。于构建时设置。
Documentation/translations/zh_CN/admin-guide/unicode.rst+170−0
@@ -0,0 +1,170 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/admin-guide/unicode.rst
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9Unicode(统一码)支持
10======================
11
12 (英文版)上次更新:2005-01-17,版本号 1.4
13
14此文档由H. Peter Anvin <unicode@lanana.org>管理,是Linux注册名称与编号管理局
15(Linux Assigned Names And Numbers Authority,LANANA)项目的一部分。
16现行版本请见:
17
18 http://www.lanana.org/docs/unicode/admin-guide/unicode.rst
19
20简介
21-----
22
23Linux内核代码已被重写以使用Unicode来将字符映射到字体。下载一个Unicode到字体
24(Unicode-to-font)表,八位字符集与UTF-8模式都将改用此字体来显示。
25
26这微妙地改变了八位字符表的语义。现在的四个字符表是:
27
28=============== =============================== ================
29映射代号 映射名称 Escape代码 (G0)
30=============== =============================== ================
31LAT1_MAP Latin-1 (ISO 8859-1) ESC ( B
32GRAF_MAP DEC VT100 pseudographics ESC ( 0
33IBMPC_MAP IBM code page 437 ESC ( U
34USER_MAP User defined ESC ( K
35=============== =============================== ================
36
37特别是 ESC ( U 不再是“直通字体”,因为字体可能与IBM字符集完全不同。
38例如,即使加载了一个Latin-1字体,也允许使用块图形(block graphics)。
39
40请注意,尽管这些代码与ISO 2022类似,但这些代码及其用途都与ISO 2022不匹配;
41Linux有两个八位代码(G0和G1),而ISO 2022有四个七位代码(G0-G3)。
42
43根据Unicode标准/ISO 10646,U+F000到U+F8FF被保留用于操作系统范围内的分配
44(Unicode标准将其称为“团体区域(Corporate Zone)”,因为这对于Linux是不准确
45的,所以我们称之为“Linux区域”)。选择U+F000作为起点,因为它允许直接映射
46区域以2的大倍数开始(以防需要1024或2048个字符的字体)。这就留下U+E000到
47U+EFFF作为最终用户区。
48
49[v1.2]:Unicodes范围从U+F000到U+F7FF已经被硬编码为直接映射到加载的字体,
50绕过了翻译表。用户定义的映射现在默认为U+F000到U+F0FF,模拟前述行为。实际上,
51此范围可能较短;例如,vgacon只能处理256字符(U+F000..U+F0FF)或512字符
52(U+F000..U+F1FF)字体。
53
54Linux 区域中定义的实际字符
55---------------------------
56
57此外,还定义了Unicode 1.1.4中不存在的以下字符;这些字符由DEC VT图形映射使用。
58[v1.2]此用法已过时,不应再使用;请参见下文。
59
60====== ======================================
61U+F800 DEC VT GRAPHICS HORIZONTAL LINE SCAN 1
62U+F801 DEC VT GRAPHICS HORIZONTAL LINE SCAN 3
63U+F803 DEC VT GRAPHICS HORIZONTAL LINE SCAN 7
64U+F804 DEC VT GRAPHICS HORIZONTAL LINE SCAN 9
65====== ======================================
66
67DEC VT220使用6x10字符矩阵,这些字符在DEC VT图形字符集中形成一个平滑的过渡。
68我省略了扫描5行,因为它也被用作块图形字符,因此被编码为U+2500 FORMS LIGHT
69HORIZONTAL。
70
71[v1.3]:这些字符已正式添加到Unicode 3.2.0中;它们在U+23BA、U+23BB、U+23BC、
72U+23BD处添加。Linux现在使用新值。
73
74[v1.2]:添加了以下字符来表示常见的键盘符号,这些符号不太可能被添加到Unicode
75中,因为它们非常讨厌地取决于特定供应商。当然,这是糟糕设计的一个好例子。
76
77====== ======================================
78U+F810 KEYBOARD SYMBOL FLYING FLAG
79U+F811 KEYBOARD SYMBOL PULLDOWN MENU
80U+F812 KEYBOARD SYMBOL OPEN APPLE
81U+F813 KEYBOARD SYMBOL SOLID APPLE
82====== ======================================
83
84克林贡(Klingon)语支持
85------------------------
86
871996年,Linux是世界上第一个添加对人工语言克林贡支持的操作系统,克林贡是由
88Marc Okrand为《星际迷航》电视连续剧创造的。这种编码后来被征募Unicode注册表
89(ConScript Unicode Registry,CSUR)采用,并建议(但最终被拒绝)纳入Unicode
90平面一。不过,它仍然是Linux区域中的Linux/CSUR私有分配。
91
92这种编码已经得到克林贡语言研究所(Klingon Language Institute)的认可。
93有关更多信息,请联系他们:
94
95 http://www.kli.org/
96
97由于Linux CZ开头部分的字符大多是dingbats/symbols/forms类型,而且这是一种
98语言,因此根据标准Unicode惯例,我将它放置在16单元的边界上。
99
100.. note::
101
102 这个范围现在由征募Unicode注册表正式管理。规范性引用文件为:
103
104 https://www.evertype.com/standards/csur/klingon.html
105
106克林贡语有一个26个字符的字母表,一个10位数的位置数字书写系统,从左到右
107,从上到下书写。
108
109克林贡字母的几种字形已经被提出。但是由于这组符号看起来始终是一致的,只有实际
110的形状不同,因此按照标准Unicode惯例,这些差异被认为是字体变体。
111
112====== =======================================================
113U+F8D0 KLINGON LETTER A
114U+F8D1 KLINGON LETTER B
115U+F8D2 KLINGON LETTER CH
116U+F8D3 KLINGON LETTER D
117U+F8D4 KLINGON LETTER E
118U+F8D5 KLINGON LETTER GH
119U+F8D6 KLINGON LETTER H
120U+F8D7 KLINGON LETTER I
121U+F8D8 KLINGON LETTER J
122U+F8D9 KLINGON LETTER L
123U+F8DA KLINGON LETTER M
124U+F8DB KLINGON LETTER N
125U+F8DC KLINGON LETTER NG
126U+F8DD KLINGON LETTER O
127U+F8DE KLINGON LETTER P
128U+F8DF KLINGON LETTER Q
129 - Written <q> in standard Okrand Latin transliteration
130U+F8E0 KLINGON LETTER QH
131 - Written <Q> in standard Okrand Latin transliteration
132U+F8E1 KLINGON LETTER R
133U+F8E2 KLINGON LETTER S
134U+F8E3 KLINGON LETTER T
135U+F8E4 KLINGON LETTER TLH
136U+F8E5 KLINGON LETTER U
137U+F8E6 KLINGON LETTER V
138U+F8E7 KLINGON LETTER W
139U+F8E8 KLINGON LETTER Y
140U+F8E9 KLINGON LETTER GLOTTAL STOP
141
142U+F8F0 KLINGON DIGIT ZERO
143U+F8F1 KLINGON DIGIT ONE
144U+F8F2 KLINGON DIGIT TWO
145U+F8F3 KLINGON DIGIT THREE
146U+F8F4 KLINGON DIGIT FOUR
147U+F8F5 KLINGON DIGIT FIVE
148U+F8F6 KLINGON DIGIT SIX
149U+F8F7 KLINGON DIGIT SEVEN
150U+F8F8 KLINGON DIGIT EIGHT
151U+F8F9 KLINGON DIGIT NINE
152
153U+F8FD KLINGON COMMA
154U+F8FE KLINGON FULL STOP
155U+F8FF KLINGON SYMBOL FOR EMPIRE
156====== =======================================================
157
158其他虚构和人工字母
159-------------------
160
161自从分配了克林贡Linux Unicode块之后,John Cowan <jcowan@reutershealth.com>
162和 Michael Everson <everson@evertype.com> 建立了一个虚构和人工字母的注册表。
163征募Unicode注册表请访问:
164
165 https://www.evertype.com/standards/csur/
166
167所使用的范围位于最终用户区域的低端,因此无法进行规范化分配,但建议希望对虚构
168字母进行编码的人员使用这些代码,以实现互操作性。对于克林贡语,CSUR采用了Linux
169编码。CSUR的人正在推动将Tengwar和Cirth添加到Unicode平面一;将克林贡添加到
170Unicode平面一被拒绝,因此上述编码仍然是官方的。
Documentation/translations/zh_CN/core-api/index.rst+126−0
@@ -0,0 +1,126 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../core-api/irq/index`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_core-api_index.rst:
7
8
9===========
10核心API文档
11===========
12
13这是核心内核API手册的首页。 非常感谢为本手册转换(和编写!)的文档!
14
15核心实用程序
16============
17
18本节包含通用的和“核心中的核心”文档。 第一部分是 docbook 时期遗留下
19来的大量 kerneldoc 信息;有朝一日,若有人有动力的话,应当把它们拆分
20出来。
21
22Todolist:
23
24 kernel-api
25 workqueue
26 printk-basics
27 printk-formats
28 symbol-namespaces
29
30数据结构和低级实用程序
31======================
32
33在整个内核中使用的函数库。
34
35Todolist:
36
37 kobject
38 kref
39 assoc_array
40 xarray
41 idr
42 circular-buffers
43 rbtree
44 generic-radix-tree
45 packing
46 bus-virt-phys-mapping
47 this_cpu_ops
48 timekeeping
49 errseq
50
51并发原语
52========
53
54Linux如何让一切同时发生。 详情请参阅
55:doc:`/locking/index`
56
57.. toctree::
58 :maxdepth: 1
59
60 irq/index
61
62Todolist:
63
64 refcount-vs-atomic
65 local_ops
66 padata
67 ../RCU/index
68
69低级硬件管理
70============
71
72缓存管理,CPU热插拔管理等。
73
74Todolist:
75
76 cachetlb
77 cpu_hotplug
78 memory-hotplug
79 genericirq
80 protection-keys
81
82
83内存管理
84========
85
86如何在内核中分配和使用内存。请注意,在
87:doc:`/vm/index` 中有更多的内存管理文档。
88
89Todolist:
90
91 memory-allocation
92 unaligned-memory-access
93 dma-api
94 dma-api-howto
95 dma-attributes
96 dma-isa-lpc
97 mm-api
98 genalloc
99 pin_user_pages
100 boot-time-mm
101 gfp_mask-from-fs-io
102
103内核调试的接口
104==============
105
106Todolist:
107
108 debug-objects
109 tracepoint
110 debugging-via-ohci1394
111
112其它文档
113========
114
115不适合放在其它地方或尚未归类的文件;
116
117Todolist:
118
119 librs
120
121.. only:: subproject and html
122
123 Indices
124 =======
125
126 * :ref:`genindex`
Documentation/translations/zh_CN/core-api/irq/concepts.rst+24−0
@@ -0,0 +1,24 @@
1.. include:: ../../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../../core-api/irq/concepts`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_concepts.rst:
7
8
9===========
10什么是IRQ?
11===========
12
13IRQ (Interrupt ReQuest) 指来自设备的中断请求。
14目前,它们可以通过一个引脚或通过一个数据包进入。
15多个设备可以连接到同一个引脚,从而共享一个IRQ。
16
17IRQ编号是用来描述硬件中断源的内核标识符。通常它是一个到全局irq_desc数组的索引,
18但是除了在linux/interrupt.h中实现的之外,其它细节是体系结构特征相关的。
19
20IRQ编号是对机器上可能的中断源的枚举。通常枚举的是系统中所有中断控制器的输入引脚
21编号。在ISA(工业标准体系结构)的情况下所枚举的是两个i8259中断控制器的16个输入引脚。
22
23体系结构可以给IRQ号赋予额外的含义,在涉及到硬件手动配置的情况下,我们鼓励这样做。
24ISA IRQ是赋予这种额外含义的一个典型例子。
Documentation/translations/zh_CN/core-api/irq/index.rst+19−0
@@ -0,0 +1,19 @@
1.. include:: ../../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../../core-api/irq/index`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_irq_index.rst:
7
8
9====
10IRQs
11====
12
13.. toctree::
14 :maxdepth: 1
15
16 concepts
17 irq-affinity
18 irq-domain
19 irqflags-tracing
Documentation/translations/zh_CN/core-api/irq/irq-affinity.rst+76−0
@@ -0,0 +1,76 @@
1.. include:: ../../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../../core-api/irq/irq-affinity`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_irq-affinity.rst:
7
8
9==============
10SMP IRQ 亲和性
11==============
12
13变更记录:
14 - 作者:最初由Ingo Molnar <mingo@redhat.com>开始撰写
15 - 后期更新维护: Max Krasnyansky <maxk@qualcomm.com>
16
17
18/proc/irq/IRQ#/smp_affinity和/proc/irq/IRQ#/smp_affinity_list指定了哪些CPU能
19够关联到一个给定的IRQ源,这两个文件包含了这些指定cpu的cpu位掩码(smp_affinity)和cpu列
20表(smp_affinity_list)。它不允许关闭所有CPU, 同时如果IRQ控制器不支持中断请求亲和
21(IRQ affinity),那么所有cpu的默认值将保持不变(即关联到所有CPU).
22
23/proc/irq/default_smp_affinity指明了适用于所有非激活IRQ的默认亲和性掩码。一旦IRQ被
24分配/激活,它的亲和位掩码将被设置为默认掩码。然后可以如上所述改变它。默认掩码是0xffffffff。
25
26下面是一个先将IRQ44(eth1)限制在CPU0-3上,然后限制在CPU4-7上的例子(这是一个8CPU的SMP box)
27
28::
29
30 [root@moon 44]# cd /proc/irq/44
31 [root@moon 44]# cat smp_affinity
32 ffffffff
33
34 [root@moon 44]# echo 0f > smp_affinity
35 [root@moon 44]# cat smp_affinity
36 0000000f
37 [root@moon 44]# ping -f h
38 PING hell (195.4.7.3): 56 data bytes
39 ...
40 --- hell ping statistics ---
41 6029 packets transmitted, 6027 packets received, 0% packet loss
42 round-trip min/avg/max = 0.1/0.1/0.4 ms
43 [root@moon 44]# cat /proc/interrupts | grep 'CPU\|44:'
44 CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
45 44: 1068 1785 1785 1783 0 0 0 0 IO-APIC-level eth1
46
47从上面一行可以看出,IRQ44只传递给前四个处理器(0-3)。
48现在让我们把这个IRQ限制在CPU(4-7)。
49
50::
51
52 [root@moon 44]# echo f0 > smp_affinity
53 [root@moon 44]# cat smp_affinity
54 000000f0
55 [root@moon 44]# ping -f h
56 PING hell (195.4.7.3): 56 data bytes
57 ..
58 --- hell ping statistics ---
59 2779 packets transmitted, 2777 packets received, 0% packet loss
60 round-trip min/avg/max = 0.1/0.5/585.4 ms
61 [root@moon 44]# cat /proc/interrupts | 'CPU\|44:'
62 CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
63 44: 1068 1785 1785 1783 1784 1069 1070 1069 IO-APIC-level eth1
64
65这次IRQ44只传递给最后四个处理器。
66即CPU0-3的计数器没有变化。
67
68下面是一个将相同的irq(44)限制在cpus 1024到1031的例子
69
70::
71
72 [root@moon 44]# echo 1024-1031 > smp_affinity_list
73 [root@moon 44]# cat smp_affinity_list
74 1024-1031
75
76需要注意的是,如果要用位掩码来做这件事,就需要32个为0的位掩码来追踪其相关的一个。
Documentation/translations/zh_CN/core-api/irq/irq-domain.rst+227−0
@@ -0,0 +1,227 @@
1.. include:: ../../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../../core-api/irq/irq-domain`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_irq-domain.rst:
7
8
9=======================
10irq_domain 中断号映射库
11=======================
12
13目前Linux内核的设计使用了一个巨大的数字空间,每个独立的IRQ源都被分配了一个不
14同的数字。
15当只有一个中断控制器时,这很简单,但在有多个中断控制器的系统中,内核必须确保每
16个中断控制器都能得到非重复的Linux IRQ号(数字)分配。
17
18注册为唯一的irqchips的中断控制器编号呈现出上升的趋势:例如GPIO控制器等不同
19种类的子驱动程序通过将其中断处理程序建模为irqchips,即实际上是级联中断控制器,
20避免了重新实现与IRQ核心系统相同的回调机制。
21
22在这里,中断号与硬件中断号离散了所有种类的对应关系:而在过去,IRQ号可以选择,
23使它们与硬件IRQ线进入根中断控制器(即实际向CPU发射中断线的组件)相匹配,现
24在这个编号仅仅是一个数字。
25
26出于这个原因,我们需要一种机制将控制器本地中断号(即硬件irq编号)与Linux IRQ
27号分开。
28
29irq_alloc_desc*() 和 irq_free_desc*() API 提供了对irq号的分配,但它们不
30提供任何对控制器本地IRQ(hwirq)号到Linux IRQ号空间的反向映射的支持。
31
32irq_domain 库在 irq_alloc_desc*() API 的基础上增加了 hwirq 和 IRQ 号码
33之间的映射。 相比于中断控制器驱动开放编码自己的反向映射方案,我们更喜欢用
34irq_domain来管理映射。
35
36irq_domain还实现了从抽象的irq_fwspec结构体到hwirq号的转换(到目前为止是
37Device Tree和ACPI GSI),并且可以很容易地扩展以支持其它IRQ拓扑数据源。
38
39irq_domain的用法
40================
41
42中断控制器驱动程序通过以下方式创建并注册一个irq_domain。调用
43irq_domain_add_*() 或 irq_domain_create_*()函数之一(每个映射方法都有不
44同的分配器函数,后面会详细介绍)。 函数成功后会返回一个指向irq_domain的指针。
45调用者必须向分配器函数提供一个irq_domain_ops结构体。
46
47在大多数情况下,irq_domain在开始时是空的,没有任何hwirq和IRQ号之间的映射。
48通过调用irq_create_mapping()将映射添加到irq_domain中,该函数接受
49irq_domain和一个hwirq号作为参数。 如果hwirq的映射还不存在,那么它将分配
50一个新的Linux irq_desc,将其与hwirq关联起来,并调用.map()回调,这样驱动
51程序就可以执行任何必要的硬件设置。
52
53当接收到一个中断时,应该使用irq_find_mapping()函数从hwirq号中找到
54Linux IRQ号。
55
56在调用irq_find_mapping()之前,至少要调用一次irq_create_mapping()函数,
57以免描述符不能被分配。
58
59如果驱动程序有Linux的IRQ号或irq_data指针,并且需要知道相关的hwirq号(比
60如在irq_chip回调中),那么可以直接从irq_data->hwirq中获得。
61
62irq_domain映射的类型
63====================
64
65从hwirq到Linux irq的反向映射有几种机制,每种机制使用不同的分配函数。应该
66使用哪种反向映射类型取决于用例。 下面介绍每一种反向映射类型:
67
68线性映射
69--------
70
71::
72
73 irq_domain_add_linear()
74 irq_domain_create_linear()
75
76线性反向映射维护了一个固定大小的表,该表以hwirq号为索引。 当一个hwirq被映射
77时,会给hwirq分配一个irq_desc,并将irq号存储在表中。
78
79当最大的hwirq号固定且数量相对较少时,线性图是一个很好的选择(~<256)。 这种
80映射的优点是固定时间查找IRQ号,而且irq_descs只分配给在用的IRQ。 缺点是该表
81必须尽可能大的hwirq号。
82
83irq_domain_add_linear()和irq_domain_create_linear()在功能上是等价的,
84除了第一个参数不同--前者接受一个Open Firmware特定的 'struct device_node' 而
85后者接受一个更通用的抽象 'struct fwnode_handle' 。
86
87大多数驱动应该使用线性映射
88
89树状映射
90--------
91
92::
93
94 irq_domain_add_tree()
95 irq_domain_create_tree()
96
97irq_domain维护着从hwirq号到Linux IRQ的radix的树状映射。 当一个hwirq被映射时,
98一个irq_desc被分配,hwirq被用作radix树的查找键。
99
100如果hwirq号可以非常大,树状映射是一个很好的选择,因为它不需要分配一个和最大hwirq
101号一样大的表。 缺点是,hwirq到IRQ号的查找取决于表中有多少条目。
102
103irq_domain_add_tree()和irq_domain_create_tree()在功能上是等价的,除了第一
104个参数不同——前者接受一个Open Firmware特定的 'struct device_node' ,而后者接受
105一个更通用的抽象 'struct fwnode_handle' 。
106
107很少有驱动应该需要这个映射。
108
109无映射
110------
111
112::
113
114 irq_domain_add_nomap()
115
116当硬件中的hwirq号是可编程的时候,就可以采用无映射类型。 在这种情况下,最好将
117Linux IRQ号编入硬件本身,这样就不需要映射了。 调用irq_create_direct_mapping()
118会分配一个Linux IRQ号,并调用.map()回调,这样驱动就可以将Linux IRQ号编入硬件中。
119
120大多数驱动程序不能使用这个映射。
121
122传统映射类型
123------------
124
125::
126
127 irq_domain_add_simple()
128 irq_domain_add_legacy()
129 irq_domain_add_legacy_isa()
130 irq_domain_create_simple()
131 irq_domain_create_legacy()
132
133传统映射是已经为 hwirqs 分配了一系列 irq_descs 的驱动程序的特殊情况。 当驱动程
134序不能立即转换为使用线性映射时,就会使用它。 例如,许多嵌入式系统板卡支持文件使用
135一组用于IRQ号的定义(#define),这些定义被传递给struct设备注册。 在这种情况下,
136不能动态分配Linux IRQ号,应该使用传统映射。
137
138传统映射假设已经为控制器分配了一个连续的IRQ号范围,并且可以通过向hwirq号添加一
139个固定的偏移来计算IRQ号,反之亦然。 缺点是需要中断控制器管理IRQ分配,并且需要为每
140个hwirq分配一个irq_desc,即使它没有被使用。
141
142只有在必须支持固定的IRQ映射时,才应使用传统映射。 例如,ISA控制器将使用传统映射来
143映射Linux IRQ 0-15,这样现有的ISA驱动程序就能得到正确的IRQ号。
144
145大多数使用传统映射的用户应该使用irq_domain_add_simple()或
146irq_domain_create_simple(),只有在系统提供IRQ范围时才会使用传统域,否则将使用
147线性域映射。这个调用的语义是这样的:如果指定了一个IRQ范围,那么 描述符将被即时分配
148给它,如果没有范围被分配,它将不会执行 irq_domain_add_linear() 或
149irq_domain_create_linear(),这意味着 *no* irq 描述符将被分配。
150
151一个简单域的典型用例是,irqchip供应商同时支持动态和静态IRQ分配。
152
153为了避免最终出现使用线性域而没有描述符被分配的情况,确保使用简单域的驱动程序在任何
154irq_find_mapping()之前调用irq_create_mapping()是非常重要的,因为后者实际上
155将用于静态IRQ分配情况。
156
157irq_domain_add_simple()和irq_domain_create_simple()以及
158irq_domain_add_legacy()和irq_domain_create_legacy()在功能上是等价的,只
159是第一个参数不同--前者接受Open Firmware特定的 'struct device_node' ,而后者
160接受一个更通用的抽象 'struct fwnode_handle' 。
161
162IRQ域层级结构
163-------------
164
165在某些架构上,可能有多个中断控制器参与将一个中断从设备传送到目标CPU。
166让我们来看看x86平台上典型的中断传递路径吧
167::
168
169 Device --> IOAPIC -> Interrupt remapping Controller -> Local APIC -> CPU
170
171涉及到的中断控制器有三个:
172
1731) IOAPIC 控制器
1742) 中断重映射控制器
1753) Local APIC 控制器
176
177为了支持这样的硬件拓扑结构,使软件架构与硬件架构相匹配,为每个中断控制器建立一
178个irq_domain数据结构,并将这些irq_domain组织成层次结构。
179
180在建立irq_domain层次结构时,靠近设备的irq_domain为子域,靠近CPU的
181irq_domain为父域。所以在上面的例子中,将建立如下的层次结构。
182::
183
184 CPU Vector irq_domain (root irq_domain to manage CPU vectors)
185 ^
186 |
187 Interrupt Remapping irq_domain (manage irq_remapping entries)
188 ^
189 |
190 IOAPIC irq_domain (manage IOAPIC delivery entries/pins)
191
192使用irq_domain层次结构的主要接口有四个:
193
1941) irq_domain_alloc_irqs(): 分配IRQ描述符和与中断控制器相关的资源来传递这些中断。
1952) irq_domain_free_irqs(): 释放IRQ描述符和与这些中断相关的中断控制器资源。
1963) irq_domain_activate_irq(): 激活中断控制器硬件以传递中断。
1974) irq_domain_deactivate_irq(): 停用中断控制器硬件,停止传递中断。
198
199为了支持irq_domain层次结构,需要做如下修改:
200
2011) 一个新的字段 'parent' 被添加到irq_domain结构中;它用于维护irq_domain的层次信息。
2022) 一个新的字段 'parent_data' 被添加到irq_data结构中;它用于建立层次结构irq_data以
203 匹配irq_domain层次结构。irq_data用于存储irq_domain指针和硬件irq号。
2043) 新的回调被添加到irq_domain_ops结构中,以支持层次结构的irq_domain操作。
205
206在支持分层irq_domain和分层irq_data准备就绪后,为每个中断控制器建立一个irq_domain结
207构,并为每个与IRQ相关联的irq_domain分配一个irq_data结构。现在我们可以再进一步支持堆
208栈式(层次结构)的irq_chip。也就是说,一个irq_chip与层次结构中的每个irq_data相关联。
209一个子irq_chip可以自己或通过与它的父irq_chip合作来实现一个所需的操作。
210
211通过堆栈式的irq_chip,中断控制器驱动只需要处理自己管理的硬件,在需要的时候可以向其父
212irq_chip请求服务。所以我们可以实现更简洁的软件架构。
213
214为了让中断控制器驱动程序支持irq_domain层次结构,它需要做到以下几点:
215
2161) 实现 irq_domain_ops.alloc 和 irq_domain_ops.free
2172) 可选择地实现 irq_domain_ops.activate 和 irq_domain_ops.deactivate.
2183) 可选择地实现一个irq_chip来管理中断控制器硬件。
2194) 不需要实现irq_domain_ops.map和irq_domain_ops.unmap,它们在层次结构
220 irq_domain中是不用的。
221
222irq_domain层次结构绝不是x86特有的,大量用于支持其他架构,如ARM、ARM64等。
223
224调试功能
225========
226
227打开CONFIG_GENERIC_IRQ_DEBUGFS,可让IRQ子系统的大部分内部结构都在debugfs中暴露出来。
Documentation/translations/zh_CN/core-api/irq/irqflags-tracing.rst+45−0
@@ -0,0 +1,45 @@
1.. include:: ../../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../../core-api/irq/irqflags-tracing`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_irqflags-tracing.rst:
7
8
9=================
10IRQ-flags状态追踪
11=================
12
13:Author: 最初由Ingo Molnar <mingo@redhat.com>开始撰写
14
15“irq-flags tracing”(中断标志追踪)功能可以 “追踪” hardirq和softirq的状态,它让
16感兴趣的子系统有机会了解到到内核中发生的每一个
17hardirqs-off/hardirqs-on、softirqs-off/softirqs-on事件。
18
19CONFIG_TRACE_IRQFLAGS_SUPPORT是通用锁调试代码提供的CONFIG_PROVE_SPIN_LOCKING
20和CONFIG_PROVE_RW_LOCKING所需要的。否则将只有CONFIG_PROVE_MUTEX_LOCKING和
21CONFIG_PROVE_RWSEM_LOCKING在一个架构上被提供--这些都是不在IRQ上下文中使用的
22锁API。(rwsems的一个异常是可以解决的)
23
24架构对这一点的支持当然不属于“微不足道”的范畴,因为很多低级的汇编代码都要处理irq-flags
25的状态变化。但是一个架构可以以一种相当直接且无风险的方式启用irq-flags-tracing。
26
27架构如果想支持这个,需要先做一些代码组织上的改变:
28
29- 在他们的arch级Kconfig文件中添加并启用TRACE_IRQFLAGS_SUPPORT。
30
31然后还需要做一些功能上的改变来实现对irq-flags-tracing的支持:
32
33- 在低级入口代码中增加(构建条件)对trace_hardirqs_off()/trace_hardirqs_on()
34 函数的调用。锁验证器会密切关注 “real”的irq-flags是否与 “virtual”的irq-flags
35 状态相匹配,如果两者不匹配,则会发出警告(并关闭自己)。通常维护arch中
36 irq-flags-track的大部分时间都是在这种状态下度过的:看看lockdep的警告,试着
37 找出我们还没有搞定的汇编代码。修复并重复。一旦系统启动,并且在irq-flags跟踪功
38 能中没有出现lockdep警告的情况下,arch支持就完成了。
39
40- 如果该架构有不可屏蔽的中断,那么需要通过lockdep_off()/lockdep_on()将这些中
41 断从irq跟踪[和锁验证]机制中排除。
42
43 一般来说,在一个架构中,不完整的irq-flags-tracing实现是没有风险的:lockdep
44 会检测到这一点,并将自己关闭。即锁验证器仍然可靠。应该不会因为irq-tracing的错
45 误而崩溃。(除非通过修改不该修改的条件来更改汇编或寄存器而破坏其他代码)
Documentation/translations/zh_CN/cpu-freq/core.rst+105−0
@@ -0,0 +1,105 @@
1.. SPDX-License-Identifier: GPL-2.0
2.. include:: ../disclaimer-zh_CN.rst
3
4:Original: :doc:`../../../cpu-freq/core`
5:Translator: Yanteng Si <siyanteng@loongson.cn>
6
7.. _cn_core.rst:
8
9
10====================================
11CPUFreq核心和CPUFreq通知器的通用说明
12====================================
13
14作者:
15 - Dominik Brodowski <linux@brodo.de>
16 - David Kimdon <dwhedon@debian.org>
17 - Rafael J. Wysocki <rafael.j.wysocki@intel.com>
18 - Viresh Kumar <viresh.kumar@linaro.org>
19
20.. 目录:
21
22 1. CPUFreq核心和接口
23 2. CPUFreq通知器
24 3. 含有Operating Performance Point (OPP)的CPUFreq表的生成
25
261. CPUFreq核心和接口
27======================
28
29cpufreq核心代码位于drivers/cpufreq/cpufreq.c中。这些cpufreq代码为CPUFreq架构的驱
30动程序(那些操作硬件切换频率的代码)以及 "通知器 "提供了一个标准化的接口。
31这些是设备驱动程序或需要了解策略变化的其它内核部分(如 ACPI 热量管理)或所有频率更改(除
32计时代码外),甚至需要强制确定速度限制的通知器(如 ARM 架构上的 LCD 驱动程序)。
33此外, 内核 "常数" loops_per_jiffy会根据频率变化而更新。
34
35cpufreq策略的引用计数由 cpufreq_cpu_get 和 cpufreq_cpu_put 来完成,以确保 cpufreq 驱
36动程序被正确地注册到核心中,并且驱动程序在 cpufreq_put_cpu 被调用之前不会被卸载。这也保证
37了每个CPU核的cpufreq 策略在使用期间不会被释放。
38
392. CPUFreq 通知器
40====================
41
42CPUFreq通知器符合标准的内核通知器接口。
43关于通知器的细节请参阅 linux/include/linux/notifier.h。
44
45这里有两个不同的CPUfreq通知器 - 策略通知器和转换通知器。
46
47
482.1 CPUFreq策略通知器
49----------------------------
50
51当创建或移除策略时,这些都会被通知。
52
53阶段是在通知器的第二个参数中指定的。当第一次创建策略时,阶段是CPUFREQ_CREATE_POLICY,当
54策略被移除时,阶段是CPUFREQ_REMOVE_POLICY。
55
56第三个参数 ``void *pointer`` 指向一个结构体cpufreq_policy,其包括min,max(新策略的下限和
57上限(单位为kHz))这几个值。
58
59
602.2 CPUFreq转换通知器
61--------------------------------
62
63当CPUfreq驱动切换CPU核心频率时,策略中的每个在线CPU都会收到两次通知,这些变化没有任何外部干
64预。
65
66第二个参数指定阶段 - CPUFREQ_PRECHANGE or CPUFREQ_POSTCHANGE.
67
68第三个参数是一个包含如下值的结构体cpufreq_freqs:
69
70===== ====================
71cpu 受影响cpu的编号
72old 旧频率
73new 新频率
74flags cpufreq驱动的标志
75===== ====================
76
773. 含有Operating Performance Point (OPP)的CPUFreq表的生成
78==================================================================
79关于OPP的细节请参阅 Documentation/power/opp.rst
80
81dev_pm_opp_init_cpufreq_table -
82 这个功能提供了一个随时可用的转换程序,用来将OPP层关于可用频率的内部信息翻译成一种容易提供给
83 cpufreq的格式。
84
85 .. Warning::
86
87 不要在中断上下文中使用此函数。
88
89 例如::
90
91 soc_pm_init()
92 {
93 /* Do things */
94 r = dev_pm_opp_init_cpufreq_table(dev, &freq_table);
95 if (!r)
96 policy->freq_table = freq_table;
97 /* Do other things */
98 }
99
100 .. note::
101
102 该函数只有在CONFIG_PM_OPP之外还启用了CONFIG_CPU_FREQ时才可用。
103
104dev_pm_opp_free_cpufreq_table
105 释放dev_pm_opp_init_cpufreq_table分配的表。
Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst+259−0
@@ -0,0 +1,259 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :doc:`../../../cpu-freq/cpu-drivers`
6:Translator: Yanteng Si <siyanteng@loongson.cn>
7
8.. _cn_cpu-drivers.rst:
9
10
11=======================================
12如何实现一个新的CPUFreq处理器驱动程序?
13=======================================
14
15作者:
16
17
18 - Dominik Brodowski <linux@brodo.de>
19 - Rafael J. Wysocki <rafael.j.wysocki@intel.com>
20 - Viresh Kumar <viresh.kumar@linaro.org>
21
22.. Contents
23
24 1. 怎么做?
25 1.1 初始化
26 1.2 Per-CPU 初始化
27 1.3 验证
28 1.4 target/target_index 或 setpolicy?
29 1.5 target/target_index
30 1.6 setpolicy
31 1.7 get_intermediate 与 target_intermediate
32 2. 频率表助手
33
34
35
361. 怎么做?
37===========
38
39如此,你刚刚得到了一个全新的CPU/芯片组及其数据手册,并希望为这个CPU/芯片组添加cpufreq
40支持?很好,这里有一些至关重要的提示:
41
42
431.1 初始化
44----------
45
46首先,在__initcall_level_7 (module_init())或更靠后的函数中检查这个内核是否
47运行在正确的CPU和正确的芯片组上。如果是,则使用cpufreq_register_driver()向
48CPUfreq核心层注册一个cpufreq_driver结构体。
49
50结构体cpufreq_driver应该包含什么成员?
51
52 .name - 驱动的名字。
53
54 .init - 一个指向per-policy初始化函数的指针。
55
56 .verify - 一个指向"verification"函数的指针。
57
58 .setpolicy 或 .fast_switch 或 .target 或 .target_index - 差异见
59 下文。
60
61并且可选择
62
63 .flags - cpufreq核的提示。
64
65 .driver_data - cpufreq驱动程序的特定数据。
66
67 .resolve_freq - 返回最适合目标频率的频率。不过并不能改变频率。
68
69 .get_intermediate 和 target_intermediate - 用于在改变CPU频率时切换到稳定
70 的频率。
71
72 .get - 返回CPU的当前频率。
73
74 .bios_limit - 返回HW/BIOS对CPU的最大频率限制值。
75
76 .exit - 一个指向per-policy清理函数的指针,该函数在cpu热插拔过程的CPU_POST_DEAD
77 阶段被调用。
78
79 .stop_cpu - 一个指向per-policy停止函数的指针,该函数在cpu热插拔过程的CPU_DOWN_PREPARE
80 阶段被调用。
81
82 .suspend - 一个指向per-policy暂停函数的指针,该函数在关中断且在该策略的调节器停止
83 后被调用。
84
85 .resume - 一个指向per-policy恢复函数的指针,该函数在关中断且在调节器再一次开始前被
86 调用。
87
88 .ready - 一个指向per-policy准备函数的指针,该函数在策略完全初始化之后被调用。
89
90 .attr - 一个指向NULL结尾的"struct freq_attr"列表的指针,该函数允许导出值到
91 sysfs。
92
93 .boost_enabled - 如果设置,则启用提升(boost)频率。
94
95 .set_boost - 一个指向per-policy函数的指针,该函数用来开启/关闭提升(boost)频率功能。
96
97
981.2 Per-CPU 初始化
99------------------
100
101每当一个新的CPU被注册到设备模型中,或者在cpufreq驱动注册自己之后,如果此CPU的cpufreq策
102略不存在,则会调用per-policy的初始化函数cpufreq_driver.init。请注意,.init()和.exit()程序
103只对策略调用一次,而不是对策略管理的每个CPU调用一次。它需要一个 ``struct cpufreq_policy
104*policy`` 作为参数。现在该怎么做呢?
105
106如果有必要,请在你的CPU上激活CPUfreq功能支持。
107
108然后,驱动程序必须填写以下数值:
109
110+-----------------------------------+--------------------------------------+
111|policy->cpuinfo.min_freq 和 | |
112|policy->cpuinfo.max_freq | 该CPU支持的最低和最高频率(kHz) |
113| | |
114| | |
115+-----------------------------------+--------------------------------------+
116|policy->cpuinfo.transition_latency | |
117| | CPU在两个频率之间切换所需的时间,以 |
118| | 纳秒为单位(如适用,否则指定 |
119| | CPUFREQ_ETERNAL) |
120+-----------------------------------+--------------------------------------+
121|policy->cur | 该CPU当前的工作频率(如适用) |
122| | |
123+-----------------------------------+--------------------------------------+
124|policy->min, | |
125|policy->max, | |
126|policy->policy and, if necessary, | |
127|policy->governor | 必须包含该cpu的 “默认策略”。稍后 |
128| | 会用这些值调用 |
129| | cpufreq_driver.verify and either |
130| | cpufreq_driver.setpolicy or |
131| | cpufreq_driver.target/target_index |
132| | |
133+-----------------------------------+--------------------------------------+
134|policy->cpus | 用与这个CPU一起做DVFS的(在线+离线) |
135| | CPU(即与它共享时钟/电压轨)的掩码更新 |
136| | 这个 |
137| | |
138+-----------------------------------+--------------------------------------+
139
140对于设置其中的一些值(cpuinfo.min[max]_freq, policy->min[max]),频率表助手可能会有帮
141助。关于它们的更多信息,请参见第2节。
142
143
1441.3 验证
145--------
146
147当用户决定设置一个新的策略(由 “policy,governor,min,max组成”)时,必须对这个策略进行验证,
148以便纠正不兼容的值。为了验证这些值,cpufreq_verify_within_limits(``struct cpufreq_policy
149*policy``, ``unsigned int min_freq``, ``unsigned int max_freq``)函数可能会有帮助。
150关于频率表助手的详细内容请参见第2节。
151
152您需要确保至少有一个有效频率(或工作范围)在 policy->min 和 policy->max 范围内。如果有必
153要,先增加policy->max,只有在没有办法的情况下,才减少policy->min。
154
155
1561.4 target 或 target_index 或 setpolicy 或 fast_switch?
157-------------------------------------------------------
158
159大多数cpufreq驱动甚至大多数cpu频率升降算法只允许将CPU频率设置为预定义的固定值。对于这些,你
160可以使用->target(),->target_index()或->fast_switch()回调。
161
162有些cpufreq功能的处理器可以自己在某些限制之间切换频率。这些应使用->setpolicy()回调。
163
164
1651.5. target/target_index
166------------------------
167
168target_index调用有两个参数:``struct cpufreq_policy * policy``和``unsigned int``
169索引(于列出的频率表)。
170
171当调用这里时,CPUfreq驱动必须设置新的频率。实际频率必须由freq_table[index].frequency决定。
172
173它应该总是在错误的情况下恢复到之前的频率(即policy->restore_freq),即使我们之前切换到中间频率。
174
175已弃用
176----------
177目标调用有三个参数。``struct cpufreq_policy * policy``, unsigned int target_frequency,
178unsigned int relation.
179
180CPUfreq驱动在调用这里时必须设置新的频率。实际的频率必须使用以下规则来确定。
181
182- 紧跟 "目标频率"。
183- policy->min <= new_freq <= policy->max (这必须是有效的!!!)
184- 如果 relation==CPUFREQ_REL_L,尝试选择一个高于或等于 target_freq 的 new_freq。("L代表
185 最低,但不能低于")
186- 如果 relation==CPUFREQ_REL_H,尝试选择一个低于或等于 target_freq 的 new_freq。("H代表
187 最高,但不能高于")
188
189这里,频率表助手可能会帮助你--详见第2节。
190
1911.6. fast_switch
192----------------
193
194这个函数用于从调度器的上下文进行频率切换。并非所有的驱动都要实现它,因为不允许在这个回调中睡眠。这
195个回调必须经过高度优化,以尽可能快地进行切换。
196
197这个函数有两个参数: ``struct cpufreq_policy *policy`` 和 ``unsigned int target_frequency``。
198
199
2001.7 setpolicy
201-------------
202
203setpolicy调用只需要一个``struct cpufreq_policy * policy``作为参数。需要将处理器内或芯片组内动态频
204率切换的下限设置为policy->min,上限设置为policy->max,如果支持的话,当policy->policy为
205CPUFREQ_POLICY_PERFORMANCE时选择面向性能的设置,当CPUFREQ_POLICY_POWERSAVE时选择面向省电的设置。
206也可以查看drivers/cpufreq/longrun.c中的参考实现。
207
2081.8 get_intermediate 和 target_intermediate
209--------------------------------------------
210
211仅适用于 target_index() 和 CPUFREQ_ASYNC_NOTIFICATION 未设置的驱动。
212
213get_intermediate应该返回一个平台想要切换到的稳定的中间频率,target_intermediate()应该将CPU设置为
214该频率,然后再跳转到'index'对应的频率。核心会负责发送通知,驱动不必在target_intermediate()或
215target_index()中处理。
216
217在驱动程序不想因为某个目标频率切换到中间频率的情况下,它们可以从get_intermediate()中返回'0'。在这种情况
218下,核心将直接调用->target_index()。
219
220注意:->target_index()应该在失败的情况下恢复到policy->restore_freq,因为core会为此发送通知。
221
222
2232. 频率表助手
224=============
225
226由于大多数cpufreq处理器只允许被设置为几个特定的频率,因此,一个带有一些函数的 “频率表”可能会辅助处理器驱动
227程序的一些工作。这样的 "频率表" 由一个cpufreq_frequency_table条目构成的数组组成,"driver_data" 中包
228含了驱动程序的具体数值,"frequency" 中包含了相应的频率,并设置了标志。在表的最后,需要添加一个
229cpufreq_frequency_table条目,频率设置为CPUFREQ_TABLE_END。而如果想跳过表中的一个条目,则将频率设置为
230CPUFREQ_ENTRY_INVALID。这些条目不需要按照任何特定的顺序排序,但如果它们是cpufreq 核心会对它们进行快速的DVFS,
231因为搜索最佳匹配会更快。
232
233如果策略在其policy->freq_table字段中包含一个有效的指针,cpufreq表就会被核心自动验证。
234
235cpufreq_frequency_table_verify()保证至少有一个有效的频率在policy->min和policy->max范围内,并且所有其他
236标准都被满足。这对->verify调用很有帮助。
237
238cpufreq_frequency_table_target()是对应于->target阶段的频率表助手。只要把数值传递给这个函数,这个函数就会返
239回包含CPU要设置的频率的频率表条目。
240
241以下宏可以作为cpufreq_frequency_table的迭代器。
242
243cpufreq_for_each_entry(pos, table) - 遍历频率表的所有条目。
244
245cpufreq_for_each_valid_entry(pos, table) - 该函数遍历所有条目,不包括CPUFREQ_ENTRY_INVALID频率。
246使用参数 "pos"-一个``cpufreq_frequency_table * `` 作为循环变量,使用参数 "table"-作为你想迭代
247的``cpufreq_frequency_table * `` 。
248
249例如::
250
251 struct cpufreq_frequency_table *pos, *driver_freq_table;
252
253 cpufreq_for_each_entry(pos, driver_freq_table) {
254 /* Do something with pos */
255 pos->frequency = ...
256 }
257
258如果你需要在driver_freq_table中处理pos的位置,不要减去指针,因为它的代价相当高。相反,使用宏
259cpufreq_for_each_entry_idx() 和 cpufreq_for_each_valid_entry_idx() 。
Documentation/translations/zh_CN/cpu-freq/cpufreq-stats.rst+130−0
@@ -0,0 +1,130 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :doc:`../../../cpu-freq/cpufreq-stats`
6:Translator: Yanteng Si <siyanteng@loongson.cn>
7
8.. _cn_cpufreq-stats.rst:
9
10
11==========================================
12sysfs CPUFreq Stats的一般说明
13==========================================
14
15用户信息
16
17
18作者: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
19
20.. Contents
21
22 1. 简介
23 2. 提供的统计数据(举例说明)
24 3. 配置cpufreq-stats
25
26
271. 简介
28===============
29
30cpufreq-stats是一个为每个CPU提供CPU频率统计的驱动。
31这些统计数据在/sysfs中以一堆只读接口的形式提供。这个接口(在配置好后)将出现在
32/sysfs(<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/)中cpufreq下的一个单
33独的目录中,提供给每个CPU。
34各种统计数据将在此目录下形成只读文件。
35
36此驱动是独立于任何可能运行在你所用CPU上的特定cpufreq_driver而设计的。因此,它将与所有
37cpufreq_driver一起工作。
38
39
402. 提供的统计数据(举例说明)
41=====================================
42
43cpufreq stats提供了以下统计数据(在下面详细解释)。
44
45- time_in_state
46- total_trans
47- trans_table
48
49所有的统计数据将从统计驱动被载入的时间(或统计被重置的时间)开始,到某一统计数据被读取的时间为止。
50显然,统计驱动不会有任何关于统计驱动载入之前的频率转换信息。
51
52::
53
54 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
55 total 0
56 drwxr-xr-x 2 root root 0 May 14 16:06 .
57 drwxr-xr-x 3 root root 0 May 14 15:58 ..
58 --w------- 1 root root 4096 May 14 16:06 reset
59 -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state
60 -r--r--r-- 1 root root 4096 May 14 16:06 total_trans
61 -r--r--r-- 1 root root 4096 May 14 16:06 trans_table
62
63- **reset**
64
65只写属性,可用于重置统计计数器。这对于评估不同调节器下的系统行为非常有用,且无需重启。
66
67
68- **time_in_state**
69
70此项给出了这个CPU所支持的每个频率所花费的时间。cat输出的每一行都会有"<frequency>
71<time>"对,表示这个CPU在<frequency>上花费了<time>个usertime单位的时间。这里的
72usertime单位是10mS(类似于/proc中输出的其他时间)。
73
74::
75
76 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state
77 3600000 2089
78 3400000 136
79 3200000 34
80 3000000 67
81 2800000 172488
82
83
84- **total_trans**
85
86给出了这个CPU上频率转换的总次数。cat的输出将有一个单一的计数,这就是频率转换的总数。
87
88::
89
90 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans
91 20
92
93- **trans_table**
94
95这将提供所有CPU频率转换的细粒度信息。这里的cat输出是一个二维矩阵,其中一个条目<i, j>(第
96i行,第j列)代表从Freq_i到Freq_j的转换次数。Freq_i行和Freq_j列遵循驱动最初提供给cpufreq
97核的频率表的排序顺序,因此可以排序(升序或降序)或不排序。 这里的输出也包含了每行每列的实际
98频率值,以便更好地阅读。
99
100如果转换表大于PAGE_SIZE,读取时将返回一个-EFBIG错误。
101
102::
103
104 <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table
105 From : To
106 : 3600000 3400000 3200000 3000000 2800000
107 3600000: 0 5 0 0 0
108 3400000: 4 0 2 0 0
109 3200000: 0 1 0 2 0
110 3000000: 0 0 1 0 3
111 2800000: 0 0 0 2 0
112
1133. 配置cpufreq-stats
114============================
115
116要在你的内核中配置cpufreq-stats::
117
118 Config Main Menu
119 Power management options (ACPI, APM) --->
120 CPU Frequency scaling --->
121 [*] CPU Frequency scaling
122 [*] CPU frequency translation statistics
123
124
125"CPU Frequency scaling" (CONFIG_CPU_FREQ) 应该被启用以配置cpufreq-stats。
126
127"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT)提供了包括
128time_in_state、total_trans和trans_table的统计数据。
129
130一旦启用了这个选项,并且你的CPU支持cpufrequency,你就可以在/sysfs中看到CPU频率统计。
Documentation/translations/zh_CN/cpu-freq/index.rst+45−0
@@ -0,0 +1,45 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :doc:`../../../cpu-freq/index`
6:Translator: Yanteng Si <siyanteng@loongson.cn>
7
8.. _cn_index.rst:
9
10
11=======================================================
12Linux CPUFreq - Linux(TM)内核中的CPU频率和电压升降代码
13=======================================================
14
15Author: Dominik Brodowski <linux@brodo.de>
16
17 时钟升降允许你在运行中改变CPU的时钟速度。这是一个很好的节省电池电量的方法,因为时
18 钟速度越低,CPU消耗的电量越少。
19
20
21.. toctree::
22 :maxdepth: 1
23
24 core
25 cpu-drivers
26 cpufreq-stats
27
28邮件列表
29------------
30这里有一个 CPU 频率变化的 CVS 提交和通用列表,您可以在这里报告bug、问题或提交补丁。要发
31布消息,请发送电子邮件到 linux-pm@vger.kernel.org。
32
33链接
34-----
35FTP档案:
36* ftp://ftp.linux.org.uk/pub/linux/cpufreq/
37
38如何访问CVS仓库:
39* http://cvs.arm.linux.org.uk/
40
41CPUFreq邮件列表:
42* http://vger.kernel.org/vger-lists.html#linux-pm
43
44SA-1100的时钟和电压标度:
45* http://www.lartmaker.nl/projects/scaling
Documentation/translations/zh_CN/dev-tools/gcov.rst+264−0
@@ -0,0 +1,264 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/dev-tools/gcov.rst
4:Translator: 赵军奎 Bernard Zhao <bernard@vivo.com>
5
6在Linux内核里使用gcov做代码覆盖率检查
7=====================================
8
9gcov分析核心支持在Linux内核中启用GCC的覆盖率测试工具 gcov_ ,Linux内核
10运行时的代码覆盖率数据会以gcov兼容的格式导出到“gcov”debugfs目录中,可
11以通过gcov的 ``-o`` 选项(如下示例)获得指定文件的代码运行覆盖率统计数据
12(需要跳转到内核编译路径下并且要有root权限)::
13
14 # cd /tmp/linux-out
15 # gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c
16
17这将在当前目录中创建带有执行计数注释的源代码文件。
18在获得这些统计文件后,可以使用图形化的gcov前端工具(比如 lcov_ ),来实现
19自动化处理Linux内核的覆盖率运行数据,同时生成易于阅读的HTML格式文件。
20
21可能的用途:
22
23* 调试(用来判断每一行的代码是否已经运行过)
24* 测试改进(如何修改测试代码,尽可能地覆盖到没有运行过的代码)
25* 内核最小化配置(对于某一个选项配置,如果关联的代码从来没有运行过,
26 是否还需要这个配置)
27
28.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
29.. _lcov: http://ltp.sourceforge.net/coverage/lcov.php
30
31
32准备
33----
34
35内核打开如下配置::
36
37 CONFIG_DEBUG_FS=y
38 CONFIG_GCOV_KERNEL=y
39
40获取整个内核的覆盖率数据,还需要打开::
41
42 CONFIG_GCOV_PROFILE_ALL=y
43
44需要注意的是,整个内核开启覆盖率统计会造成内核镜像文件尺寸的增大,
45同时内核运行也会变慢一些。
46另外,并不是所有的架构都支持整个内核开启覆盖率统计。
47
48代码运行覆盖率数据只在debugfs挂载完成后才可以访问::
49
50 mount -t debugfs none /sys/kernel/debug
51
52
53定制化
54------
55
56如果要单独针对某一个路径或者文件进行代码覆盖率统计,可以在内核相应路
57径的Makefile中增加如下的配置:
58
59- 单独统计单个文件(例如main.o)::
60
61 GCOV_PROFILE_main.o := y
62
63- 单独统计某一个路径::
64
65 GCOV_PROFILE := y
66
67如果要在整个内核的覆盖率统计(开启CONFIG_GCOV_PROFILE_ALL)中单独排除
68某一个文件或者路径,可以使用如下的方法::
69
70 GCOV_PROFILE_main.o := n
71
72和::
73
74 GCOV_PROFILE := n
75
76此机制仅支持链接到内核镜像或编译为内核模块的文件。
77
78
79相关文件
80--------
81
82gcov功能需要在debugfs中创建如下文件:
83
84``/sys/kernel/debug/gcov``
85 gcov相关功能的根路径
86
87``/sys/kernel/debug/gcov/reset``
88 全局复位文件:向该文件写入数据后会将所有的gcov统计数据清0
89
90``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda``
91 gcov工具可以识别的覆盖率统计数据文件,向该文件写入数据后
92 会将本文件的gcov统计数据清0
93
94``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno``
95 gcov工具需要的软连接文件(指向编译时生成的信息统计文件),这个文件是
96 在gcc编译时如果配置了选项 ``-ftest-coverage`` 时生成的。
97
98
99针对模块的统计
100--------------
101
102内核中的模块会动态的加载和卸载,模块卸载时对应的数据会被清除掉。
103gcov提供了一种机制,通过保留相关数据的副本来收集这部分卸载模块的覆盖率数据。
104模块卸载后这些备份数据在debugfs中会继续存在。
105一旦这个模块重新加载,模块关联的运行统计会被初始化成debugfs中备份的数据。
106
107可以通过对内核参数gcov_persist的修改来停用gcov对模块的备份机制::
108
109 gcov_persist = 0
110
111在运行时,用户还可以通过写入模块的数据文件或者写入gcov复位文件来丢弃已卸
112载模块的数据。
113
114
115编译机和测试机分离
116------------------
117
118gcov的内核分析插桩支持内核的编译和运行是在同一台机器上,也可以编译和运
119行是在不同的机器上。
120如果内核编译和运行是不同的机器,那么需要额外的准备工作,这取决于gcov工具
121是在哪里使用的:
122
123.. _gcov-test_zh:
124
125a) 若gcov运行在测试机上
126
127 测试机上面gcov工具的版本必须要跟内核编译机器使用的gcc版本相兼容,
128 同时下面的文件要从编译机拷贝到测试机上:
129
130 从源代码中:
131 - 所有的C文件和头文件
132
133 从编译目录中:
134 - 所有的C文件和头文件
135 - 所有的.gcda文件和.gcno文件
136 - 所有目录的链接
137
138 特别需要注意,测试机器上面的目录结构跟编译机器上面的目录机构必须
139 完全一致。
140 如果文件是软链接,需要替换成真正的目录文件(这是由make的当前工作
141 目录变量CURDIR引起的)。
142
143.. _gcov-build_zh:
144
145b) 若gcov运行在编译机上
146
147 测试用例运行结束后,如下的文件需要从测试机中拷贝到编译机上:
148
149 从sysfs中的gcov目录中:
150 - 所有的.gcda文件
151 - 所有的.gcno文件软链接
152
153 这些文件可以拷贝到编译机的任意目录下,gcov使用-o选项指定拷贝的
154 目录。
155
156 比如一个是示例的目录结构如下::
157
158 /tmp/linux: 内核源码目录
159 /tmp/out: 内核编译文件路径(make O=指定)
160 /tmp/coverage: 从测试机器上面拷贝的数据文件路径
161
162 [user@build] cd /tmp/out
163 [user@build] gcov -o /tmp/coverage/tmp/out/init main.c
164
165
166关于编译器的注意事项
167--------------------
168
169GCC和LLVM gcov工具不一定兼容。
170如果编译器是GCC,使用 gcov_ 来处理.gcno和.gcda文件,如果是Clang编译器,
171则使用 llvm-cov_ 。
172
173.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
174.. _llvm-cov: https://llvm.org/docs/CommandGuide/llvm-cov.html
175
176GCC和Clang gcov之间的版本差异由Kconfig处理的。
177kconfig会根据编译工具链的检查自动选择合适的gcov格式。
178
179问题定位
180--------
181
182可能出现的问题1
183 编译到链接阶段报错终止
184
185问题原因
186 分析标志指定在了源文件但是没有链接到主内核,或者客制化了链接程序
187
188解决方法
189 通过在相应的Makefile中使用 ``GCOV_PROFILE := n``
190 或者 ``GCOV_PROFILE_basename.o := n`` 来将链接报错的文件排除掉
191
192可能出现的问题2
193 从sysfs复制的文件显示为空或不完整
194
195问题原因
196 由于seq_file的工作方式,某些工具(例如cp或tar)可能无法正确地从
197 sysfs复制文件。
198
199解决方法
200 使用 ``cat`` 读取 ``.gcda`` 文件,使用 ``cp -d`` 复制链接,或者使用附录B
201 中所示的机制。
202
203
204附录A:collect_on_build.sh
205--------------------------
206
207用于在编译机上收集覆盖率元文件的示例脚本
208(见 :ref:`编译机和测试机分离 a. <gcov-test_zh>` )
209
210.. code-block:: sh
211
212 #!/bin/bash
213
214 KSRC=$1
215 KOBJ=$2
216 DEST=$3
217
218 if [ -z "$KSRC" ] || [ -z "$KOBJ" ] || [ -z "$DEST" ]; then
219 echo "Usage: $0 <ksrc directory> <kobj directory> <output.tar.gz>" >&2
220 exit 1
221 fi
222
223 KSRC=$(cd $KSRC; printf "all:\n\t@echo \${CURDIR}\n" | make -f -)
224 KOBJ=$(cd $KOBJ; printf "all:\n\t@echo \${CURDIR}\n" | make -f -)
225
226 find $KSRC $KOBJ \( -name '*.gcno' -o -name '*.[ch]' -o -type l \) -a \
227 -perm /u+r,g+r | tar cfz $DEST -P -T -
228
229 if [ $? -eq 0 ] ; then
230 echo "$DEST successfully created, copy to test system and unpack with:"
231 echo " tar xfz $DEST -P"
232 else
233 echo "Could not create file $DEST"
234 fi
235
236
237附录B:collect_on_test.sh
238-------------------------
239
240用于在测试机上收集覆盖率数据文件的示例脚本
241(见 :ref:`编译机和测试机分离 b. <gcov-build_zh>` )
242
243.. code-block:: sh
244
245 #!/bin/bash -e
246
247 DEST=$1
248 GCDA=/sys/kernel/debug/gcov
249
250 if [ -z "$DEST" ] ; then
251 echo "Usage: $0 <output.tar.gz>" >&2
252 exit 1
253 fi
254
255 TEMPDIR=$(mktemp -d)
256 echo Collecting data..
257 find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \;
258 find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \;
259 find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \;
260 tar czf $DEST -C $TEMPDIR sys
261 rm -rf $TEMPDIR
262
263 echo "$DEST successfully created, copy to build system and unpack with:"
264 echo " tar xfz $DEST"
Documentation/translations/zh_CN/dev-tools/index.rst+35−0
@@ -0,0 +1,35 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/dev-tools/index.rst
4:Translator: 赵军奎 Bernard Zhao <bernard@vivo.com>
5
6============
7内核开发工具
8============
9
10本文档是有关内核开发工具文档的合集。
11目前这些文档已经整理在一起,不需要再花费额外的精力。
12欢迎任何补丁。
13
14.. class:: toc-title
15
16 目录
17
18.. toctree::
19 :maxdepth: 2
20
21 gcov
22
23Todolist:
24
25 - coccinelle
26 - sparse
27 - kcov
28 - kasan
29 - ubsan
30 - kmemleak
31 - kcsan
32 - gdb-kernel-debugging
33 - kgdb
34 - kselftest
35 - kunit/index
Documentation/translations/zh_CN/disclaimer-zh_CN.rst+1−1
@@ -6,4 +6,4 @@ · 5 unmodified lines
6 6
7.. note::7.. note::
8 如果您发现本文档与原始文件有任何不同或者有翻译问题,请联系该文件的译者,8 如果您发现本文档与原始文件有任何不同或者有翻译问题,请联系该文件的译者,
9 或者请求时奎亮的帮助:<alex.shi@linux.alibaba.com>。9 或者请求时奎亮的帮助:<alexs@kernel.org>。
Documentation/translations/zh_CN/doc-guide/contributing.rst+238−0
@@ -0,0 +1,238 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: Documentation/doc-guide/contributing.rst
6
7:译者: 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9如何帮助改进内核文档
10====================
11
12在任何软件开发项目中,文档都是重要组成部分。好的文档有助于引入新的开发人员,
13并帮助已有的开发人员更有效地工作。如果缺少高质量的文档,大量的时间就会浪费在
14代码的逆向工程和犯本可避免的错误上。
15
16不幸的是,内核的文档目前远远不能满足支持如此规模和重要性的项目的需要。
17
18本指南适用于希望帮助改善这种状况的贡献者。内核文档的改进可以由开发者在不同的
19技能层级上进行;这也是一条相对简单可以帮助您了解内核过程并在社区中找到一席之
20地的路径。下面的大部分内容是文档维护人员列出的最迫切需要完成的任务。
21
22文档待办事项列表
23----------------
24
25为了使我们的文档达到应有的水平,需要完成的任务数不胜数。此列表包含许多重要的
26项目,但还远远不够详尽;如果您知道改进文档的其他方法,请不要羞于启齿。
27
28消除警告(WARNING)
29~~~~~~~~~~~~~~~~~~~
30
31文档构建目前出现了数量惊人的警告。虱子多了不痒,债多了不愁;大伙儿忽略了它们,
32他们永远不会注意到他们的工作增加了新的警告。因此,消除警告是文档待办事项列表
33中优先级最高的任务之一。这项任务本身相当简单,但必须以正确的方式进行,才能取
34得成功。
35
36C代码编译器发出的警告常常会被视为误报,从而导致出现了旨在让编译器闭嘴的补丁。
37文档构建中的警告几乎总是指向真正的问题;要消除这些警告,需要理解问题并从源头上
38解决问题。因此,修复文档警告的补丁不应在标题中直接写“修复警告”;它们应该指明
39真正修复的问题。
40
41另一个重点是,文档警告常常由C代码里kernel-doc注释中的问题引起。虽然文档维护
42人员对收到这些修复补丁的副本表示感谢,但是文档树实际上通常并不适合接受这些
43补丁;它们应该被交给相关子系统的维护人员。
44
45例如,在一次文档构建中,我几乎是随意选取了一对警告::
46
47 ./drivers/devfreq/devfreq.c:1818: warning: bad line:
48 - Resource-managed devfreq_register_notifier()
49 ./drivers/devfreq/devfreq.c:1854: warning: bad line:
50 - Resource-managed devfreq_unregister_notifier()
51
52(作了断行以便于阅读)
53
54简单看一下上面给出的源文件,会发现几个kernel-doc注释,如下所示::
55
56 /**
57 * devm_devfreq_register_notifier()
58 - Resource-managed devfreq_register_notifier()
59 * @dev: The devfreq user device. (parent of devfreq)
60 * @devfreq: The devfreq object.
61 * @nb: The notifier block to be unregistered.
62 * @list: DEVFREQ_TRANSITION_NOTIFIER.
63 */
64
65问题在于缺了一个“*”,这不符合构建系统对C注释块的格式要求。此问题自2016年注释
66被添加以来一直存在——整整四年之久。修复它只需要添加丢失的星号。看一眼该文件的
67历史记录以了解主题行的常规格式是什么样,再使用 ``scripts/get_maintainer.pl``
68来搞清谁应当收到此补丁。生成的补丁如下所示::
69
70 [PATCH] PM / devfreq: Fix two malformed kerneldoc comments
71
72 Two kerneldoc comments in devfreq.c fail to adhere to the required format,
73 resulting in these doc-build warnings:
74
75 ./drivers/devfreq/devfreq.c:1818: warning: bad line:
76 - Resource-managed devfreq_register_notifier()
77 ./drivers/devfreq/devfreq.c:1854: warning: bad line:
78 - Resource-managed devfreq_unregister_notifier()
79
80 Add a couple of missing asterisks and make kerneldoc a little happier.
81
82 Signed-off-by: Jonathan Corbet <corbet@lwn.net>
83 ---
84 drivers/devfreq/devfreq.c | 4 ++--
85 1 file changed, 2 insertions(+), 2 deletions(-)
86
87 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
88 index 57f6944d65a6..00c9b80b3d33 100644
89 --- a/drivers/devfreq/devfreq.c
90 +++ b/drivers/devfreq/devfreq.c
91 @@ -1814,7 +1814,7 @@ static void devm_devfreq_notifier_release(struct device *dev, void *res)
92
93 /**
94 * devm_devfreq_register_notifier()
95 - - Resource-managed devfreq_register_notifier()
96 + * - Resource-managed devfreq_register_notifier()
97 * @dev: The devfreq user device. (parent of devfreq)
98 * @devfreq: The devfreq object.
99 * @nb: The notifier block to be unregistered.
100 @@ -1850,7 +1850,7 @@ EXPORT_SYMBOL(devm_devfreq_register_notifier);
101
102 /**
103 * devm_devfreq_unregister_notifier()
104 - - Resource-managed devfreq_unregister_notifier()
105 + * - Resource-managed devfreq_unregister_notifier()
106 * @dev: The devfreq user device. (parent of devfreq)
107 * @devfreq: The devfreq object.
108 * @nb: The notifier block to be unregistered.
109 --
110 2.24.1
111
112整个过程只花了几分钟。当然,我后来发现有人在另一个树中修复了它,这亮出了另一
113个教训:在深入研究问题之前,一定要检查linux-next树,看看问题是否已经修复。
114
115其他修复可能需要更长的时间,尤其是那些与缺少文档的结构体成员或函数参数相关的
116修复。这种情况下,需要找出这些成员或参数的作用,并正确描述它们。总之,这种
117任务有时会有点乏味,但它非常重要。如果我们真的可以从文档构建中消除警告,那么
118我们就可以开始期望开发人员开始注意避免添加新的警告了。
119
120“迷失的”kernel-doc注释
121~~~~~~~~~~~~~~~~~~~~~~
122
123开发者被鼓励去为他们的代码写kernel-doc注释,但是许多注释从未被引入文档构建。
124这使得这些信息更难找到,例如使Sphinx无法生成指向该文档的链接。将 ``kernel-doc``
125指令添加到文档中以引入这些注释可以帮助社区获得为编写注释所做工作的全部价值。
126
127``scripts/find-unused-docs.sh`` 工具可以用来找到这些被忽略的评论。
128
129请注意,将导出的函数和数据结构引入文档是最有价值的。许多子系统还具有供内部
130使用的kernel-doc注释;除非这些注释放在专门针对相关子系统开发人员的文档中,
131否则不应将其引入文档构建中。
132
133
134修正错字
135~~~~~~~~
136
137
138修复文档中的排版或格式错误是一种快速学习如何创建和发送修补程序的方法,也是
139一项有用的服务。我总是愿意接受这样的补丁。这也意味着,一旦你修复了一些这种
140错误,请考虑转移到更高级的任务,留下一些拼写错误给下一个初学者解决。
141
142请注意,有些并 **不是** 拼写错误,不应该被“修复”:
143
144 - 内核文档中用美式和英式英语拼写皆可,没有必要互相倒换。
145
146 - 在内核文档中,没必要讨论句点后面应该跟一个还是两个空格的问题。其他一些有
147 合理分歧的地方,比如“牛津逗号”,在这也是跑题的。
148
149与对任何项目的任何补丁一样,请考虑您的更改是否真的让事情变得更好。
150
151“上古”文档
152~~~~~~~~~~
153
154一些内核文档是最新的、被维护的,并且非常有用,有些文件确并非如此。尘封、陈旧
155和不准确的文档可能会误导读者,并对我们的整个文档产生怀疑。任何解决这些问题的
156事情都是非常受欢迎的。
157
158无论何时处理文档,请考虑它是否是最新的,是否需要更新,或者是否应该完全删除。
159您可以注意以下几个警告标志:
160
161 - 对2.x内核的引用
162 - 指向SourceForge存储库
163 - 历史记录除了拼写错误啥也没有持续几年
164 - 讨论Git之前时代的工作流
165
166当然,最好的办法是更新文档,添加所需的任何信息。这样的工作通常需要与熟悉相关
167子系统的开发人员合作。当有人善意地询问开发人员,并听取他们的回答然后采取
168行动时,开发人员通常更愿意与这些致力于改进文档的人员合作。
169
170有些文档已经没希望了;例如,我们偶尔会发现引用了很久以前从内核中删除的代码的
171文档。删除过时的文档会碰见令人惊讶的阻力,但我们无论如何都应该这样做。文档中
172多余的粗枝大叶对任何人都没有帮助。
173
174如果一个严重过时的文档中可能有一些有用的信息,而您又无法更新它,那么最好在
175开头添加一个警告。建议使用以下文本::
176
177 .. warning ::
178 This document is outdated and in need of attention. Please use
179 this information with caution, and please consider sending patches
180 to update it.
181
182这样的话,至少我们长期受苦的读者会得到文件可能会把他们引入歧途的警告。
183
184文档一致性
185~~~~~~~~~~
186
187这里的老前辈们会记得上世纪90年代出现在书架上的Linux书籍,它们只是从网上不同
188位置搜来的文档文件的集合。在此之后,(大部分)这些书都得到了改进,但是内核的
189文档仍然主要是建立在这种模型上。它有数千个文件,几乎每个文件都是与其他文件相
190独立编写的。我们没有一个连贯的内核文档;只有数千个独立的文档。
191
192我们一直试图通过编篡一套“书籍”来改善这种情况,以为特定读者提供成套文档。这
193包括:
194
195 - Documentation/translations/zh_CN/admin-guide/index.rst
196 - Documentation/core-api/index.rst
197 - Documentation/driver-api/index.rst
198 - Documentation/userspace-api/index.rst
199
200以及文档本身这本“书”。
201
202将文档移到适当的书中是一项重要的任务,需要继续进行。不过这项工作还是有一些
203挑战性。移动文档会给处理这些文档的人带来短期的痛苦;他们对这些更改无甚热情
204也是可以理解的。通常情况下,可以将一个文档移动一下;不过我们真的不想一直移动
205它们。
206
207即使所有文件都在正确的位置,我们也只是把一大堆文件变成一群小堆文件。试图将
208所有这些文件组合成一个整体的工作尚未开始。如果你对如何在这方面取得进展有好的
209想法,我们将很高兴了解。
210
211样式表(Stylesheet)改进
212~~~~~~~~~~~~~~~~~~~~~~~~
213
214随着Sphinx的采用,我们得到了比以前更好的HTML输出。但它仍然需要很大的改进;
215Donald Knuth和Edward Tufte可能是映像平平的。这需要调整我们的样式表,以创建
216更具排版效果、可访问性和可读性的输出。
217
218请注意:如果你承担这个任务,你将进入经典的两难领域。即使是相对明显的变化,
219也会有很多意见和讨论。唉,这就是我们生活的世界的本质。
220
221无LaTeX的PDF构建
222~~~~~~~~~~~~~~~~
223
224对于拥有大量时间和Python技能的人来说,这绝对是一项不平凡的任务。Sphinx工具链
225相对较小且包含良好;很容易添加到开发系统中。但是构建PDF或EPUB输出需要安装
226LaTeX,它绝对称不上小或包含良好的。消除Latex将是一件很好的事情。
227
228最初是希望使用 `rst2pdf <https://rst2pdf.org/>`_ 工具来生成PDF,但结果发现
229无法胜任这项任务。不过rst2pdf的开发工作最近似乎又有了起色,这是个充满希望的
230迹象。如果有开发人员愿意与该项目合作,使rst2pdf可与内核文档构建一起工作,
231大家会非常感激。
232
233编写更多文档
234~~~~~~~~~~~~
235
236当然,内核中许多部分的文档严重不足。如果您有编写一个特定内核子系统文档的相应
237知识并愿意这样做,请不要犹豫,编写并向内核贡献结果吧!数不清的内核开发人员和
238用户会感谢你。
Documentation/translations/zh_CN/doc-guide/index.rst+27−0
@@ -0,0 +1,27 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/doc-guide/index.rst
4
5:译者: 吴想成 Wu XiangCheng <bobwxc@email.cn>
6
7.. _doc_guide_zh:
8
9================
10如何编写内核文档
11================
12
13.. toctree::
14 :maxdepth: 1
15
16 sphinx
17 kernel-doc
18 parse-headers
19 contributing
20 maintainer-profile
21
22.. only:: 子项目与HTML
23
24 目录
25 ====
26
27 * :ref:`genindex`
Documentation/translations/zh_CN/doc-guide/kernel-doc.rst+499−0
@@ -0,0 +1,499 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/doc-guide/kernel-doc.rst
4
5:译者: 吴想成 Wu XiangCheng <bobwxc@email.cn>
6
7编写kernel-doc注释
8==================
9
10Linux内核源文件可以包含kernel-doc格式的结构化文档注释,用以描述代码的函数、
11类型和设计。将文档嵌入源文件更容易保持文档最新。
12
13.. note:: 内核文档格式与javadoc、gtk-doc或Doxygen看似很相似,但由于历史原因,
14 实际有着明显的不同。内核源包含成千上万个kernel-doc注释。请坚持遵循
15 此处描述的风格。
16
17.. note:: kernel-doc无法包含Rust代码:请参考 Documentation/rust/docs.rst 。
18
19从注释中提取kernel-doc结构,并从中生成适当的 `Sphinx C 域`_ 函数和带有锚点的
20类型描述。这些注释将被过滤以生成特殊kernel-doc高亮和交叉引用。详见下文。
21
22.. _Sphinx C 域: http://www.sphinx-doc.org/en/stable/domains.html
23
24使用 ``EXPORT_SYMBOL`` 或 ``EXPORT_SYMBOL_GPL`` 导出到可加载模块的每个函数都
25应该有一个kernel-doc注释。模块使用的头文件中的函数和数据结构也应该有
26kernel-doc注释。
27
28对于其他内核文件(未标记为 ``static`` )中外部可见的函数,提供kernel-doc格式
29的文档是一个很好的实践。我们也建议为私有(文件 ``static`` )程序提供kernel-doc
30格式的文档,以确保内核源代码布局的一致性。此建议优先级较低,由内核源文件的
31维护者自行决定。
32
33如何格式化kernel-doc注释
34------------------------
35
36kernel-doc注释用 ``/**`` 作为开始标记。 ``kernel-doc`` 工具将提取以这种方式
37标记的注释。注释其余部分的格式类似于一个普通的多行注释,左侧有一列星号,以
38``*/`` 行结束。
39
40函数和类型的kernel-doc注释应该放在所描述的函数或类型之前,以便最大限度地提高
41更改代码的人同时更改文档的可能性。概述kernel-doc注释可以放在最顶部的任何地方。
42
43用详细模式和不生成实际输出来运行 ``kernel-doc`` 工具,可以验证文档注释的格式
44是否正确。例如::
45
46 scripts/kernel-doc -v -none drivers/foo/bar.c
47
48当请求执行额外的gcc检查时,内核构建将验证文档格式::
49
50 make W=n
51
52函数文档
53--------
54
55函数和函数式宏的kernel-doc注释的一般格式是::
56
57 /**
58 * 函数名() - 函数简要说明.
59 * @参数1: 描述第一个参数.
60 * @参数2: 描述第二个参数.
61 * 可以为参数提供一段
62 * 多行描述.
63 *
64 * 更详细的描述,进一步讨论函数 函数名(), 这可能对使用或修改它的人有用.
65 * 以空注释行开始, 内部可以包含空注释行.
66 *
67 * 详细描述可以有多个段落.
68 *
69 * Context: 描述函数是否可以休眠, 它需要、释放或期望持有什么锁.
70 * 可以写多行.
71 * Return: 描述函数返回值.
72 *
73 * 返回值描述也可以有多个段落,
74 * 并且应该放在注释块的末尾.
75 */
76
77函数名后面的简短描述可以跨多行,并以参数描述、空注释行或注释块结尾结束。
78
79函数参数
80~~~~~~~~
81
82每个函数参数都应该按照顺序描述,紧跟在函数简要说明之后。不要在函数描述和参数
83之间,也不要在参数之间留空。
84
85每个 ``@参数:`` 描述可以跨多行。
86
87.. note::
88
89 如果 ``@参数`` 描述有多行,则说明的续行应该从上一行的同一列开始::
90
91 * @参数: 较长说明
92 * 的续行
93
94 或::
95
96 * @参数:
97 * 较长说明
98 * 的续行
99
100如果函数的参数数目可变,则需用kernel-doc格式对其进行描述::
101
102 * @...: 描述
103
104函数上下文
105~~~~~~~~~~
106
107可调用函数的上下文应该在 ``Context`` 节中描述。此节应该包括函数是休眠的还是
108可以从中断上下文调用的,以及它需要什么锁、释放什么锁和期望它的调用者持有什么
109锁。
110
111例如::
112
113 * Context: Any context.
114 * Context: Any context. Takes and releases the RCU lock.
115 * Context: Any context. Expects <lock> to be held by caller.
116 * Context: Process context. May sleep if @gfp flags permit.
117 * Context: Process context. Takes and releases <mutex>.
118 * Context: Softirq or process context. Takes and releases <lock>, BH-safe.
119 * Context: Interrupt context.
120
121返回值
122~~~~~~
123
124如有返回值,应在 ``Return`` 节中描述。
125
126.. note::
127
128 #) 您提供的多行描述文本 *不会* 识别换行符,因此如果您想将某些文本预格式化,
129 如::
130
131 * Return:
132 * 0 - OK
133 * -EINVAL - invalid argument
134 * -ENOMEM - out of memory
135
136 它们在最终文档中变成一行::
137
138 Return: 0 - OK -EINVAL - invalid argument -ENOMEM - out of memory
139
140 因此,为了在需要的地方换行,您需要使用ReST列表,例如::
141
142 * Return:
143 * * 0 - OK to runtime suspend the device
144 * * -EBUSY - Device should not be runtime suspended
145
146 #) 如果您提供的描述性文本中的行以某个后跟冒号的短语开头,则每一个这种短语
147 都将被视为新的节标题,可能会产生意料不到的效果。
148
149结构体、共用体、枚举类型文档
150----------------------------
151
152结构体(struct)、共用体(union)、枚举(enum)类型kernel-doc注释的一般格式为::
153
154 /**
155 * struct 结构体名 - 简要描述.
156 * @成员1: 成员1描述.
157 * @成员2: 成员2描述.
158 * 可以为成员提供
159 * 多行描述.
160 *
161 * 结构体的描述.
162 */
163
164可以用 ``union`` 或 ``enum`` 替换上面示例中的 ``struct`` ,以描述共用体或枚举。
165``成员`` 用于表示枚举中的元素或共用体成员。
166
167结构体名称后面的简要说明可以跨多行,并以成员说明、空白注释行或注释块结尾结束。
168
169成员
170~~~~
171
172结构体、共用体和枚举的成员应以与函数参数相同的方式记录;它们后紧跟简短的描述,
173并且为多行。
174
175在结构体或共用体描述中,可以使用 ``private:`` 和 ``public:`` 注释标签。
176``private:`` 域内的字段不会列在生成的文档中。
177
178``private:`` 和 ``public:`` 标签必须紧跟在 ``/*`` 注释标记之后。可以选择是否
179在 ``:`` 和 ``*/`` 结束标记之间包含注释。
180
181例子::
182
183 /**
184 * struct 张三 - 简短描述
185 * @a: 第一个成员
186 * @b: 第二个成员
187 * @d: 第三个成员
188 *
189 * 详细描述
190 */
191 struct 张三 {
192 int a;
193 int b;
194 /* private: 仅内部使用 */
195 int c;
196 /* public: 下一个是公有的 */
197 int d;
198 };
199
200嵌套的结构体/共用体
201~~~~~~~~~~~~~~~~~~~
202
203嵌套的结构体/共用体可像这样记录::
204
205 /**
206 * struct nested_foobar - a struct with nested unions and structs
207 * @memb1: first member of anonymous union/anonymous struct
208 * @memb2: second member of anonymous union/anonymous struct
209 * @memb3: third member of anonymous union/anonymous struct
210 * @memb4: fourth member of anonymous union/anonymous struct
211 * @bar: non-anonymous union
212 * @bar.st1: struct st1 inside @bar
213 * @bar.st2: struct st2 inside @bar
214 * @bar.st1.memb1: first member of struct st1 on union bar
215 * @bar.st1.memb2: second member of struct st1 on union bar
216 * @bar.st2.memb1: first member of struct st2 on union bar
217 * @bar.st2.memb2: second member of struct st2 on union bar
218 */
219 struct nested_foobar {
220 /* Anonymous union/struct*/
221 union {
222 struct {
223 int memb1;
224 int memb2;
225 };
226 struct {
227 void *memb3;
228 int memb4;
229 };
230 };
231 union {
232 struct {
233 int memb1;
234 int memb2;
235 } st1;
236 struct {
237 void *memb1;
238 int memb2;
239 } st2;
240 } bar;
241 };
242
243.. note::
244
245 #) 在记录嵌套结构体或共用体时,如果结构体/共用体 ``张三`` 已命名,则其中
246 的成员 ``李四`` 应记录为 ``@张三.李四:``
247
248 #) 当嵌套结构体/共用体是匿名的时,其中的成员 ``李四`` 应记录为 ``@李四:``
249
250行间注释文档
251~~~~~~~~~~~~
252
253结构成员也可在定义时以行间注释形式记录。有两种样式,一种是单行注释,其中开始
254``/**`` 和结束 ``*/`` 位于同一行;另一种是多行注释,开头结尾各自位于一行,就
255像所有其他核心文档注释一样::
256
257 /**
258 * struct 张三 - 简短描述.
259 * @张三: 成员张三.
260 */
261 struct 张三 {
262 int 张三;
263 /**
264 * @李四: 成员李四.
265 */
266 int 李四;
267 /**
268 * @王五: 成员王五.
269 *
270 * 此处,成员描述可以为好几段.
271 */
272 int 王五;
273 union {
274 /** @儿子: 单行描述. */
275 int 儿子;
276 };
277 /** @赵六: 描述@张三里面的结构体@赵六 */
278 struct {
279 /**
280 * @赵六.女儿: 描述@张三.赵六里面的@女儿
281 */
282 int 女儿;
283 } 赵六;
284 };
285
286Typedef文档
287-----------
288
289Typedef的kernel-doc文档注释的一般格式为::
290
291 /**
292 * typedef 类型名称 - 简短描述.
293 *
294 * 类型描述.
295 */
296
297还可以记录带有函数原型的typedef::
298
299 /**
300 * typedef 类型名称 - 简短描述.
301 * @参数1: 参数1的描述
302 * @参数2: 参数2的描述
303 *
304 * 类型描述.
305 *
306 * Context: 锁(Locking)上下文.
307 * Return: 返回值的意义.
308 */
309 typedef void (*类型名称)(struct v4l2_ctrl *参数1, void *参数2);
310
311高亮与交叉引用
312--------------
313
314在kernel-doc注释的描述文本中可以识别以下特殊模式,并将其转换为正确的
315reStructuredText标记和 `Sphinx C 域`_ 引用。
316
317.. attention:: 以下内容 **仅** 在kernel-doc注释中识别, **不会** 在普通的
318 reStructuredText文档中识别。
319
320``funcname()``
321 函数引用。
322
323``@parameter``
324 函数参数的名称(未交叉引用,仅格式化)。
325
326``%CONST``
327 常量的名称(未交叉引用,仅格式化)。
328
329````literal````
330 预格式化文本块。输出将使用等距字体。
331
332 若你需要使用在kernel-doc脚本或reStructuredText中有特殊含义的字符,则此功能
333 非常有用。
334
335 若你需要在函数描述中使用类似于 ``%ph`` 的东西,这特别有用。
336
337``$ENVVAR``
338 环境变量名称(未交叉引用,仅格式化)。
339
340``&struct name``
341 结构体引用。
342
343``&enum name``
344 枚举引用。
345
346``&typedef name``
347 Typedef引用。
348
349``&struct_name->member`` or ``&struct_name.member``
350 结构体或共用体成员引用。交叉引用将链接到结构体或共用体定义,而不是直接到成员。
351
352``&name``
353 泛类型引用。请首选上面描述的完整引用方式。此法主要是为了可能未描述的注释。
354
355从reStructuredText交叉引用
356~~~~~~~~~~~~~~~~~~~~~~~~~~
357
358无需额外的语法来从reStructuredText文档交叉引用kernel-do注释中定义的函数和类型。
359只需以 ``()`` 结束函数名,并在类型之前写上 ``struct`` , ``union`` , ``enum``
360或 ``typedef`` 。
361例如::
362
363 See foo().
364 See struct foo.
365 See union bar.
366 See enum baz.
367 See typedef meh.
368
369若要在交叉引用链接中使用自定义文本,可以通过以下语法进行::
370
371 See :c:func:`my custom link text for function foo <foo>`.
372 See :c:type:`my custom link text for struct bar <bar>`.
373
374有关更多详细信息,请参阅 `Sphinx C 域`_ 文档。
375
376总述性文档注释
377--------------
378
379为了促进源代码和注释紧密联合,可以将kernel-doc文档块作为自由形式的注释,而
380不是函数、结构、联合、枚举或typedef的绑定kernel-doc。例如,这可以用于解释
381驱动程序或库代码的操作理论。
382
383这是通过使用带有节标题的 ``DOC:`` 节关键字来实现的。
384
385总述或高层级文档注释的一般格式为::
386
387 /**
388 * DOC: Theory of Operation
389 *
390 * The whizbang foobar is a dilly of a gizmo. It can do whatever you
391 * want it to do, at any time. It reads your mind. Here's how it works.
392 *
393 * foo bar splat
394 *
395 * The only drawback to this gizmo is that is can sometimes damage
396 * hardware, software, or its subject(s).
397 */
398
399``DOC:`` 后面的标题用作源文件中的标题,但也用作提取文档注释的标识符。因此,
400文件中的标题必须是唯一的。
401
402包含kernel-doc注释
403==================
404
405文档注释可以被包含在任何使用专用kernel-doc Sphinx指令扩展的reStructuredText
406文档中。
407
408kernel-doc指令的格式如下::
409
410 .. kernel-doc:: source
411 :option:
412
413*source* 是相对于内核源代码树的源文件路径。
414支持以下指令选项:
415
416export: *[source-pattern ...]*
417 包括 *source* 中使用 ``EXPORT_SYMBOL`` 或 ``EXPORT_SYMBOL_GPL`` 导出的所有
418 函数的文档,无论是在 *source* 中还是在 *source-pattern* 指定的任何文件中。
419
420 当kernel-doc注释被放置在头文件中,而 ``EXPORT_SYMBOL`` 和 ``EXPORT_SYMBOL_GPL``
421 位于函数定义旁边时, *source-pattern* 非常有用。
422
423 例子::
424
425 .. kernel-doc:: lib/bitmap.c
426 :export:
427
428 .. kernel-doc:: include/net/mac80211.h
429 :export: net/mac80211/*.c
430
431internal: *[source-pattern ...]*
432 包括 *source* 中所有在 *source* 或 *source-pattern* 的任何文件中都没有使用
433 ``EXPORT_SYMBOL`` 或 ``EXPORT_SYMBOL_GPL`` 导出的函数和类型的文档。
434
435 例子::
436
437 .. kernel-doc:: drivers/gpu/drm/i915/intel_audio.c
438 :internal:
439
440identifiers: *[ function/type ...]*
441 在 *source* 中包含每个 *function* 和 *type* 的文档。如果没有指定 *function* ,
442 则 *source* 中所有函数和类型的文档都将包含在内。
443
444 例子::
445
446 .. kernel-doc:: lib/bitmap.c
447 :identifiers: bitmap_parselist bitmap_parselist_user
448
449 .. kernel-doc:: lib/idr.c
450 :identifiers:
451
452no-identifiers: *[ function/type ...]*
453 排除 *source* 中所有 *function* 和 *type* 的文档。
454
455 例子::
456
457 .. kernel-doc:: lib/bitmap.c
458 :no-identifiers: bitmap_parselist
459
460functions: *[ function/type ...]*
461 这是“identifiers”指令的别名,已弃用。
462
463doc: *title*
464 包含 *source* 中由 *title* 标题标识的 ``DOC:`` 文档段落。 *title* 中允许
465 空格;不要在 *title* 上加引号。 *title* 仅用作段落的标识符,不包含在输出中。
466 请确保在所附的reStructuredText文档中有适当的标题。
467
468 例子::
469
470 .. kernel-doc:: drivers/gpu/drm/i915/intel_audio.c
471 :doc: High Definition Audio over HDMI and Display Port
472
473如果没有选项,kernel-doc指令将包含源文件中的所有文档注释。
474
475kernel-doc扩展包含在内核源代码树中,位于 ``Documentation/sphinx/kerneldoc.py`` 。
476在内部,它使用 ``scripts/kernel-doc`` 脚本从源代码中提取文档注释。
477
478.. _kernel_doc_zh:
479
480如何使用kernel-doc生成手册(man)页
481-----------------------------------
482
483如果您只想使用kernel-doc生成手册页,可以从内核git树这样做::
484
485 $ scripts/kernel-doc -man \
486 $(git grep -l '/\*\*' -- :^Documentation :^tools) \
487 | scripts/split-man.pl /tmp/man
488
489一些旧版本的git不支持路径排除语法的某些变体。
490以下命令之一可能适用于这些版本::
491
492 $ scripts/kernel-doc -man \
493 $(git grep -l '/\*\*' -- . ':!Documentation' ':!tools') \
494 | scripts/split-man.pl /tmp/man
495
496 $ scripts/kernel-doc -man \
497 $(git grep -l '/\*\*' -- . ":(exclude)Documentation" ":(exclude)tools") \
498 | scripts/split-man.pl /tmp/man
499
Documentation/translations/zh_CN/doc-guide/maintainer-profile.rst+43−0
@@ -0,0 +1,43 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: Documentation/doc-guide/maintainer-profile.rst
6
7:译者: 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9文档子系统维护人员条目概述
10==========================
11
12文档“子系统”是内核文档和相关基础设施的中心协调点。它涵盖了 Documentation/ 下
13的文件层级(Documentation/devicetree 除外)、scripts/ 下的各种实用程序,并且
14在某些情况下的也包括 LICENSES/ 。
15
16不过值得注意的是,这个子系统的边界比通常更加模糊。许多其他子系统维护人员需要
17保持对 Documentation/ 某些部分的控制,以便于可以更自由地做更改。除此之外,
18许多内核文档都以kernel-doc注释的形式出现在源代码中;这些注释通常(但不总是)
19由相关的子系统维护人员维护。
20
21文档子系统的邮件列表是<linux-doc@vger.kernel.org>。
22补丁应尽量针对docs-next树。
23
24提交检查单补遗
25--------------
26
27在进行文档更改时,您应当构建文档以测试,并确保没有引入新的错误或警告。生成
28HTML文档并查看结果将有助于避免对文档渲染结果的不必要争执。
29
30开发周期的关键节点
31------------------
32
33补丁可以随时发送,但在合并窗口期间,响应将比通常慢。文档树往往在合并窗口打开
34之前关闭得比较晚,因为文档补丁导致回归的风险很小。
35
36审阅节奏
37--------
38
39我(译注:指Jonathan Corbet <corbet@lwn.net>)是文档子系统的唯一维护者,我在
40自己的时间里完成这项工作,所以对补丁的响应有时会很慢。当补丁被合并时(或当我
41决定拒绝合并补丁时),我都会发送通知。如果您在发送补丁后一周内没有收到回复,
42请不要犹豫,发送提醒就好。
43
Documentation/translations/zh_CN/doc-guide/parse-headers.rst+187−0
@@ -0,0 +1,187 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: Documentation/doc-guide/parse-headers.rst
6
7:译者: 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9=====================
10包含用户空间API头文件
11=====================
12
13有时,为了描述用户空间API并在代码和文档之间生成交叉引用,需要包含头文件和示例
14C代码。为用户空间API文件添加交叉引用还有一个好处:如果在文档中找不到相应符号,
15Sphinx将生成警告。这有助于保持用户空间API文档与内核更改同步。
16:ref:`parse_headers.pl <parse_headers_zh>` 提供了生成此类交叉引用的一种方法。
17在构建文档时,必须通过Makefile调用它。有关如何在内核树中使用它的示例,请参阅
18``Documentation/userspace-api/media/Makefile`` 。
19
20.. _parse_headers_zh:
21
22parse_headers.pl
23----------------
24
25脚本名称
26~~~~~~~~
27
28
29parse_headers.pl——解析一个C文件,识别函数、结构体、枚举、定义并对Sphinx文档
30创建交叉引用。
31
32
33用法概要
34~~~~~~~~
35
36
37\ **parse_headers.pl**\ [<选项>] <C文件> <输出文件> [<例外文件>]
38
39<选项> 可以是: --debug, --help 或 --usage 。
40
41
42选项
43~~~~
44
45
46
47\ **--debug**\
48
49 开启脚本详细模式,在调试时很有用。
50
51
52\ **--usage**\
53
54 打印简短的帮助信息并退出。
55
56
57
58\ **--help**\
59
60 打印更详细的帮助信息并退出。
61
62
63说明
64~~~~
65
66通过C头文件或源文件(<C文件>)中为描述API的文档编写的带交叉引用的 ..预格式化
67文本 块将文件转换成重构文本(RST)。它接受一个可选的<例外文件>,其中描述了
68哪些元素将被忽略或指向非默认引用。
69
70输出被写入到<输出文件>。
71
72它能够识别定义、函数、结构体、typedef、枚举和枚举符号,并为它们创建交叉引用。
73它还能够区分用于指定Linux ioctl的 ``#define`` 。
74
75<例外文件> 包含两种类型的语句: \ **ignore**\ 或 \ **replace**\ .
76
77ignore标记的语法为:
78
79
80ignore \ **type**\ \ **name**\
81
82The \ **ignore**\ 意味着它不会为类型为 \ **type**\ 的 \ **name**\ 符号生成
83交叉引用。
84
85
86replace标记的语法为:
87
88
89replace \ **type**\ \ **name**\ \ **new_value**\
90
91The \ **replace**\ 味着它将为 \ **type**\ 类型的 \ **name**\ 符号生成交叉引
92用,但是它将使用 \ **new_value**\ 来取代默认的替换规则。
93
94
95这两种语句中, \ **type**\ 可以是以下任一项:
96
97
98\ **ioctl**\
99
100 ignore 或 replace 语句应用于ioctl定义,如:
101
102 #define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
103
104
105
106\ **define**\
107
108 ignore 或 replace 语句应用于在<C文件>中找到的任何其他 ``#define`` 。
109
110
111
112\ **typedef**\
113
114 ignore 和 replace 语句应用于<C文件>中的typedef语句。
115
116
117
118\ **struct**\
119
120 ignore 和 replace 语句应用于<C文件>中的结构体名称语句。
121
122
123
124\ **enum**\
125
126 ignore 和 replace 语句应用于<C文件>中的枚举名称语句。
127
128
129
130\ **symbol**\
131
132 ignore 和 replace 语句应用于<C文件>中的枚举值名称语句。
133
134 replace语句中, \ **new_value**\ 会自动使用 \ **typedef**\ , \ **enum**\
135 和 \ **struct**\ 类型的 :c:type: 引用;以及 \ **ioctl**\ , \ **define**\ 和
136 \ **symbol**\ 类型的 :ref: 。引用的类型也可以在replace语句中显式定义。
137
138
139示例
140~~~~
141
142
143ignore define _VIDEODEV2_H
144
145
146忽略<C文件>中的 #define _VIDEODEV2_H 。
147
148ignore symbol PRIVATE
149
150
151如下结构体:
152
153enum foo { BAR1, BAR2, PRIVATE };
154
155不会为 \ **PRIVATE**\ 生成交叉引用。
156
157replace symbol BAR1 :c:type:\`foo\`
158replace symbol BAR2 :c:type:\`foo\`
159
160
161如下结构体:
162
163enum foo { BAR1, BAR2, PRIVATE };
164
165它会让BAR1和BAR2枚举符号交叉引用C域中的foo符号。
166
167
168
169缺陷
170~~~~
171
172
173请向Mauro Carvalho Chehab <mchehab@kernel.org>报告有关缺陷。
174
175中文翻译问题请找中文翻译维护者。
176
177
178版权
179~~~~
180
181
182版权所有 (c) 2016 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
183
184许可证 GPLv2:GNU GPL version 2 <https://gnu.org/licenses/gpl.html>
185
186这是自由软件:你可以自由地修改和重新发布它。
187在法律允许的范围内,**不提供任何保证**。
Documentation/translations/zh_CN/doc-guide/sphinx.rst+415−0
@@ -0,0 +1,415 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/doc-guide/sphinx.rst
4
5:译者: 吴想成 Wu XiangCheng <bobwxc@email.cn>
6
7.. _sphinxdoc_zh:
8
9简介
10====
11
12Linux内核使用 `Sphinx <http://www.sphinx-doc.org/>`_ 来把 ``Documentation``
13下的 `reStructuredText <http://docutils.sourceforge.net/rst.html>`_ 文件转
14换成漂亮的文档。使用 ``make htmldocs`` 或 ``make pdfdocs`` 命令即可构建HTML
15或PDF格式的文档。生成的文档放在 ``Documentation/output`` 文件夹中。
16
17reStructuredText文件可能包含包含来自源文件的结构化文档注释或kernel-doc注释。
18通常它们用于描述代码的功能、类型和设计。kernel-doc注释有一些特殊的结构和
19格式,但除此之外,它们还被作为reStructuredText处理。
20
21最后,有成千上万的纯文本文档文件散布在 ``Documentation`` 里。随着时间推移,
22其中一些可能会转换为reStructuredText,但其中大部分仍保持纯文本。
23
24.. _sphinx_install_zh:
25
26安装Sphinx
27==========
28
29Documentation/ 下的ReST文件现在使用sphinx1.3或更高版本构建。
30
31这有一个脚本可以检查Sphinx的依赖项。更多详细信息见
32:ref:`sphinx-pre-install_zh` 。
33
34大多数发行版都附带了Sphinx,但是它的工具链比较脆弱,而且在您的机器上升级它
35或其他一些Python包导致文档构建中断的情况并不少见。
36
37避免此情况的一种方法是使用与发行版附带的不同的版本。因此,建议使用
38``virtualenv-3`` 或 ``virtualenv`` 在虚拟环境中安装Sphinx,具体取决于发行版
39如何打包Python3。
40
41.. note::
42
43 #) 低于1.5版本的Sphinx无法与Python的0.13.1或更高版本docutils一起正常工作。
44 如果您想使用这些版本,那么应该运行 ``pip install 'docutils==0.12'`` 。
45
46 #) html输出建议使用RTD主题。根据Sphinx版本的不同,它应该用
47 ``pip install sphinx_rtd_theme`` 单独安装。
48
49 #) 一些ReST页面包含数学表达式。由于Sphinx的工作方式,这些表达式是使用 LaTeX
50 编写的。它需要安装amsfonts和amsmath宏包,以便显示。
51
52总之,如您要安装Sphinx 1.7.9版本,应执行::
53
54 $ virtualenv sphinx_1.7.9
55 $ . sphinx_1.7.9/bin/activate
56 (sphinx_1.7.9) $ pip install -r Documentation/sphinx/requirements.txt
57
58在运行 ``. sphinx_1.7.9/bin/activate`` 之后,提示符将变化,以指示您正在使用新
59环境。如果您打开了一个新的shell,那么在构建文档之前,您需要重新运行此命令以再
60次进入虚拟环境中。
61
62图片输出
63--------
64
65内核文档构建系统包含一个扩展,可以处理GraphViz和SVG格式的图像(参见
66:ref:`sphinx_kfigure_zh` )。
67
68为了让它工作,您需要同时安装GraphViz和ImageMagick包。如果没有安装这些软件包,
69构建系统仍将构建文档,但不会在输出中包含任何图像。
70
71PDF和LaTeX构建
72--------------
73
74目前只有Sphinx 1.4及更高版本才支持这种构建。
75
76对于PDF和LaTeX输出,还需要 ``XeLaTeX`` 3.14159265版本。(译注:此版本号真实
77存在)
78
79根据发行版的不同,您可能还需要安装一系列 ``texlive`` 软件包,这些软件包提供了
80``XeLaTeX`` 工作所需的最小功能集。
81
82.. _sphinx-pre-install_zh:
83
84检查Sphinx依赖项
85----------------
86
87这有一个脚本可以自动检查Sphinx依赖项。如果它认得您的发行版,还会提示您所用发行
88版的安装命令::
89
90 $ ./scripts/sphinx-pre-install
91 Checking if the needed tools for Fedora release 26 (Twenty Six) are available
92 Warning: better to also install "texlive-luatex85".
93 You should run:
94
95 sudo dnf install -y texlive-luatex85
96 /usr/bin/virtualenv sphinx_1.7.9
97 . sphinx_1.7.9/bin/activate
98 pip install -r Documentation/sphinx/requirements.txt
99
100 Can't build as 1 mandatory dependency is missing at ./scripts/sphinx-pre-install line 468.
101
102默认情况下,它会检查html和PDF的所有依赖项,包括图像、数学表达式和LaTeX构建的
103需求,并假设将使用虚拟Python环境。html构建所需的依赖项被认为是必需的,其他依
104赖项则是可选的。
105
106它支持两个可选参数:
107
108``--no-pdf``
109
110 禁用PDF检查;
111
112``--no-virtualenv``
113
114 使用Sphinx的系统打包,而不是Python虚拟环境。
115
116Sphinx构建
117==========
118
119生成文档的常用方法是运行 ``make htmldocs`` 或 ``make pdfdocs`` 。还有其它可用
120的格式:请参阅 ``make help`` 的文档部分。生成的文档放在 ``Documentation/output``
121下相应格式的子目录中。
122
123要生成文档,显然必须安装Sphinx( ``sphinx-build`` )。要让HTML输出更漂亮,可以
124使用Read the Docs Sphinx主题( ``sphinx_rtd_theme`` )。对于PDF输出,您还需要
125``XeLaTeX`` 和来自ImageMagick(https://www.imagemagick.org)的 ``convert(1)`` 。
126所有这些软件在大多发行版中都可用或已打包。
127
128要传递额外的选项给Sphinx,可以使用make变量 ``SPHINXOPTS`` 。例如,使用
129``make SPHINXOPTS=-v htmldocs`` 获得更详细的输出。
130
131
132要删除生成的文档,请运行 ``make cleandocs`` 。
133
134编写文档
135========
136
137添加新文档很容易,只需:
138
1391. 在 ``Documentation`` 下某处添加一个新的 ``.rst`` 文件。
1402. 从 ``Documentation/index.rst`` 中的Sphinx `主目录树`_ 链接到它。
141
142.. _主目录树: http://www.sphinx-doc.org/en/stable/markup/toctree.html
143
144对于简单的文档(比如您现在正在阅读的文档),这通常已经足够好了,但是对于较大
145的文档,最好创建一个子目录(或者使用现有的子目录)。例如,图形子系统文档位于
146``Documentation/gpu`` 下,拆分为多个 ``.rst`` 文件,并具有从主目录链接来的单
147独索引 ``index.rst`` (有自己的目录树 ``toctree`` )。
148
149请参阅 `Sphinx <http://www.sphinx-doc.org/>`_ 和 `reStructuredText
150<http://docutils.sourceforge.net/rst.html>`_ 的文档,以了解如何使用它们。
151特别是Sphinx `reStructuredText 基础`_ 这是开始学习使用reStructuredText的
152好地方。还有一些 `Sphinx 特殊标记结构`_ 。
153
154.. _reStructuredText 基础: http://www.sphinx-doc.org/en/stable/rest.html
155.. _Sphinx 特殊标记结构: http://www.sphinx-doc.org/en/stable/markup/index.html
156
157内核文档的具体指南
158------------------
159
160这是一些内核文档的具体指南:
161
162* 请不要过于痴迷转换格式到reStructuredText。保持简单。在大多数情况下,文档
163 应该是纯文本,格式应足够一致,以便可以转换为其他格式。
164
165* 将现有文档转换为reStructuredText时,请尽量减少格式更改。
166
167* 在转换文档时,还要更新内容,而不仅仅是格式。
168
169* 请遵循标题修饰符的顺序:
170
171 1. ``=`` 文档标题,要有上线::
172
173 ========
174 文档标题
175 ========
176
177 2. ``=`` 章::
178
179 章标题
180 ======
181
182 3. ``-`` 节::
183
184 节标题
185 ------
186
187 4. ``~`` 小节::
188
189 小节标题
190 ~~~~~~~~
191
192 尽管RST没有规定具体的顺序(“没有强加一个固定数量和顺序的节标题装饰风格,最终
193 按照的顺序将是实际遇到的顺序。”),但是拥有一个通用级别的文档更容易遵循。
194
195* 对于插入固定宽度的文本块(用于代码样例、用例等): ``::`` 用于语法高亮意义不
196 大的内容,尤其是短代码段; ``.. code-block:: <language>`` 用于需要语法高亮的
197 较长代码块。对于嵌入到文本中的简短代码片段,请使用 \`\` 。
198
199
200C域
201---
202
203**Sphinx C域(Domain)** (name c)适用于C API文档。例如,函数原型:
204
205.. code-block:: rst
206
207 .. c:function:: int ioctl( int fd, int request )
208
209内核文档的C域有一些附加特性。例如,您可以使用诸如 ``open`` 或 ``ioctl`` 这样的
210通用名称重命名函数的引用名称:
211
212.. code-block:: rst
213
214 .. c:function:: int ioctl( int fd, int request )
215 :name: VIDIOC_LOG_STATUS
216
217函数名称(例如ioctl)仍保留在输出中,但引用名称从 ``ioctl`` 变为
218``VIDIOC_LOG_STATUS`` 。此函数的索引项也变为 ``VIDIOC_LOG_STATUS`` 。
219
220请注意,不需要使用 ``c:func:`` 生成函数文档的交叉引用。由于一些Sphinx扩展的
221神奇力量,如果给定函数名的索引项存在,文档构建系统会自动将对 ``function()``
222的引用转换为交叉引用。如果在内核文档中看到 ``c:func:`` 的用法,请删除它。
223
224
225列表
226----
227
228我们建议使用 *列式表* 格式。 *列式表* 格式是二级列表。与ASCII艺术相比,它们对
229文本文件的读者来说可能没有那么舒适。但其优点是易于创建或修改,而且修改的差异
230(diff)更有意义,因为差异仅限于修改的内容。
231
232*平铺表* 也是一个二级列表,类似于 *列式表* ,但具有一些额外特性:
233
234* 列范围:使用 ``cspan`` 修饰,可以通过其他列扩展单元格
235
236* 行范围:使用 ``rspan`` 修饰,可以通过其他行扩展单元格
237
238* 自动将表格行最右边的单元格扩展到该行右侧空缺的单元格上。若使用
239 ``:fill-cells:`` 选项,此行为可以从 *自动合并* 更改为 *自动插入* ,自动
240 插入(空)单元格,而不是扩展合并到最后一个单元格。
241
242选项:
243
244* ``:header-rows:`` [int] 标题行计数
245* ``:stub-columns:`` [int] 标题列计数
246* ``:widths:`` [[int] [int] ... ] 列宽
247* ``:fill-cells:`` 插入缺少的单元格,而不是自动合并缺少的单元格
248
249修饰:
250
251* ``:cspan:`` [int] 扩展列
252* ``:rspan:`` [int] 扩展行
253
254下面的例子演示了如何使用这些标记。分级列表的第一级是 *表格行* 。 *表格行* 中
255只允许一个标记,即该 *表格行* 中的单元格列表。 *comments* ( ``..`` )和
256*targets* 例外(例如引用 ``:ref:`最后一行 <last row_zh>``` / :ref:`最后一行
257<last row_zh>` )。
258
259.. code-block:: rst
260
261 .. flat-table:: 表格标题
262 :widths: 2 1 1 3
263
264 * - 表头 列1
265 - 表头 列2
266 - 表头 列3
267 - 表头 列4
268
269 * - 行1
270 - 字段1.1
271 - 字段1.2(自动扩展)
272
273 * - 行2
274 - 字段2.1
275 - :rspan:`1` :cspan:`1` 字段2.2~3.3
276
277 * .. _`last row_zh`:
278
279 - 行3
280
281渲染效果:
282
283 .. flat-table:: 表格标题
284 :widths: 2 1 1 3
285
286 * - 表头 列1
287 - 表头 列2
288 - 表头 列3
289 - 表头 列4
290
291 * - 行1
292 - 字段1.1
293 - 字段1.2(自动扩展)
294
295 * - 行2
296 - 字段2.1
297 - :rspan:`1` :cspan:`1` 字段2.2~3.3
298
299 * .. _`last row_zh`:
300
301 - 行3
302
303交叉引用
304--------
305
306从一页文档到另一页文档的交叉引用可以通过简单地写出文件路径来完成,无特殊格式
307要求。路径可以是绝对路径或相对路径。绝对路径从“Documentation/”开始。例如,要
308交叉引用此页,以下写法皆可,取决于具体的文档目录(注意 ``.rst`` 扩展名是可选
309的)::
310
311 参见 Documentation/doc-guide/sphinx.rst 。此法始终可用。
312 请查看 sphinx.rst ,仅在同级目录中有效。
313 请阅读 ../sphinx.rst ,上级目录中的文件。
314
315如果要使用相对路径,则需要使用Sphinx的 ``doc`` 修饰。例如,从同一目录引用此页
316的操作如下::
317
318 参见 :doc:`sphinx文档的自定义链接文本 <sphinx>`.
319
320对于大多数用例,前者是首选,因为它更干净,更适合阅读源文件的人。如果您遇到一
321个没有任何特殊作用的 ``:doc:`` 用法,请将其转换为文档路径。
322
323有关交叉引用kernel-doc函数或类型的信息,请参阅
324Documentation/doc-guide/kernel-doc.rst 。
325
326.. _sphinx_kfigure_zh:
327
328图形图片
329========
330
331如果要添加图片,应该使用 ``kernel-figure`` 和 ``kernel-image`` 指令。例如,
332要插入具有可缩放图像格式的图形,请使用SVG(:ref:`svg_image_example_zh` )::
333
334 .. kernel-figure:: ../../../doc-guide/svg_image.svg
335 :alt: 简易 SVG 图片
336
337 SVG 图片示例
338
339.. _svg_image_example_zh:
340
341.. kernel-figure:: ../../../doc-guide/svg_image.svg
342 :alt: 简易 SVG 图片
343
344 SVG 图片示例
345
346内核figure(和image)指令支持 DOT 格式文件,请参阅
347
348* DOT:http://graphviz.org/pdf/dotguide.pdf
349* Graphviz:http://www.graphviz.org/content/dot-language
350
351一个简单的例子(:ref:`hello_dot_file_zh` )::
352
353 .. kernel-figure:: ../../../doc-guide/hello.dot
354 :alt: 你好,世界
355
356 DOT 示例
357
358.. _hello_dot_file_zh:
359
360.. kernel-figure:: ../../../doc-guide/hello.dot
361 :alt: 你好,世界
362
363 DOT 示例
364
365嵌入的渲染标记(或语言),如Graphviz的 **DOT** 由 ``kernel-render`` 指令提供::
366
367 .. kernel-render:: DOT
368 :alt: 有向图
369 :caption: 嵌入式 **DOT** (Graphviz) 代码
370
371 digraph foo {
372 "五棵松" -> "国贸";
373 }
374
375如何渲染取决于安装的工具。如果安装了Graphviz,您将看到一个矢量图像。否则,原始
376标记将作为 *文字块* 插入(:ref:`hello_dot_render_zh` )。
377
378.. _hello_dot_render_zh:
379
380.. kernel-render:: DOT
381 :alt: 有向图
382 :caption: 嵌入式 **DOT** (Graphviz) 代码
383
384 digraph foo {
385 "五棵松" -> "国贸";
386 }
387
388*render* 指令包含 *figure* 指令中已知的所有选项,以及选项 ``caption`` 。如果
389``caption`` 有值,则插入一个 *figure* 节点,若无,则插入一个 *image* 节点。
390如果您想引用它,还需要一个 ``caption`` (:ref:`hello_svg_render_zh` )。
391
392嵌入式 **SVG**::
393
394 .. kernel-render:: SVG
395 :caption: 嵌入式 **SVG** 标记
396 :alt: 右上箭头
397
398 <?xml version="1.0" encoding="UTF-8"?>
399 <svg xmlns="http://www.w3.org/2000/svg" version="1.1" ...>
400 ...
401 </svg>
402
403.. _hello_svg_render_zh:
404
405.. kernel-render:: SVG
406 :caption: 嵌入式 **SVG** 标记
407 :alt: 右上箭头
408
409 <?xml version="1.0" encoding="UTF-8"?>
410 <svg xmlns="http://www.w3.org/2000/svg"
411 version="1.1" baseProfile="full" width="70px" height="40px" viewBox="0 0 700 400">
412 <line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/>
413 <polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/>
414 </svg>
415
Documentation/translations/zh_CN/index.rst+10−0
@@ -18,8 +18,18 @@ · 17 unmodified lines
18 18
19 admin-guide/index19 admin-guide/index
20 process/index20 process/index
21 dev-tools/index
22 doc-guide/index
23 kernel-hacking/index
21 filesystems/index24 filesystems/index
22 arm64/index25 arm64/index
26 sound/index
27 cpu-freq/index
28 mips/index
29 iio/index
30 riscv/index
31 core-api/index
32 openrisc/index
23 33
24目录和表格34目录和表格
25----------35----------
Documentation/translations/zh_CN/kernel-hacking/hacking.rst+708−0
@@ -0,0 +1,708 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: Documentation/kernel-hacking/hacking.rst
4
5:译者:
6
7 吴想成 Wu XiangCheng <bobwxc@email.cn>
8
9==============
10内核骇客指北
11==============
12
13:作者: Rusty Russell
14
15引言
16=====
17
18欢迎咱优雅的读者们来阅读Rusty的非常不靠谱的Linux内核骇客(Hacking)指南。本文
19描述了内核代码的常见例程和一般要求:其目标是引导有经验的C程序员入门Linux内核
20开发。我回避了实现细节:这是代码要做的,也忽略了很多有用的例程。
21
22在你读这篇文章之前,请理解我从来没有想过要写这篇文章,因为我的资历太低了;
23但我一直想读这样的文章,自己写是唯一的方法。我希望它能成长为一个最佳实践、
24通用起点和其他信息的汇编。
25
26玩家
27=======
28
29在任何时候,系统中的每个CPU都可以:
30
31- 与任何进程无关,服务于硬件中断;
32
33- 与任何进程无关,服务于软件中断(softirq)或子任务(tasklet);
34
35- 运行于内核空间中,与进程(用户上下文)相关联;
36
37- 在用户空间中运行进程。
38
39它们之间有优先级顺序。最下面的两个可以互相抢占,但上面为严格的层次结构:
40每个层级只能被上方的抢占。例如,当一个软中断在CPU上运行时,没有其他软中断
41会抢占它,但是硬件中断可以抢占它。不过,系统中的任何其他CPU都是独立执行的。
42
43我们将会看到许多方法,用户上下文可以阻止中断,从而成为真正的不可抢占。
44
45用户上下文
46------------
47
48用户上下文是指当您从系统调用或其他陷阱进入时:就像用户空间一样,您可以被更
49重要的任务和中断抢占。您可以通过调用 :c:func:`schedule()` 进行睡眠。
50
51.. note::
52
53 在模块加载和卸载以及块设备层上的操作时,你始终处于用户上下文中。
54
55在用户上下文中,当前 ``current`` 指针(指示我们当前正在执行的任务)是有效的,
56且 :c:func:`in_interrupt()` ( ``include/linux/preempt.h`` )值为非(false)。
57
58.. warning::
59
60 请注意,如果您禁用了抢占或软中断(见下文),:c:func:`in_interrupt()` 会
61 返回假阳性。
62
63硬件中断(Hard IRQs)
64----------------------
65
66像定时器、网卡和键盘等都是可能在任意时刻产生中断的真实硬件。内核运行中断
67处理程序,为硬件提供服务。内核确保处理程序永远不会重入:如果相同的中断到达,
68它将被排队(或丢弃)。因为它会关闭中断,所以处理程序必须很快:通常它只是
69确认中断,标记一个“软件中断”以执行并退出。
70
71您可以通过 :c:func:`in_irq()` 返回真来判断您处于硬件中断状态。
72
73.. warning::
74
75 请注意,如果中断被禁用,这将返回假阳性(见下文)。
76
77软件中断上下文:软中断(Softirqs)与子任务(Tasklets)
78-------------------------------------------------------
79
80当系统调用即将返回用户空间或硬件中断处理程序退出时,任何标记为挂起(通常通
81过硬件中断)的“软件中断”将运行( ``kernel/softirq.c`` )。
82
83此处完成了许多真正的中断处理工作。在向SMP过渡的早期,只有“bottom halves下半
84部”(BHs)机制,无法利用多个CPU的优势。在从那些一团糟的就电脑切换过来后不久,
85我们放弃了这个限制,转而使用“软中断”。
86
87``include/linux/interrupt.h`` 列出了不同的软中断。定时器软中断是一个非常重要
88的软中断( ``include/linux/timer.h`` ):您可以注册它以在给定时间后为您调用
89函数。
90
91软中断通常是一个很难处理的问题,因为同一个软中断将同时在多个CPU上运行。因此,
92子任务( ``include/linux/interrupt.h`` )更常用:它们是动态可注册的(意味着
93您可以拥有任意数量),并且它们还保证任何子任务都只能在一个CPU上运行,不同的
94子任务也可以同时运行。
95
96.. warning::
97
98 “tasklet”这个名字是误导性的:它们与“任务”无关,可能更多与当时
99 阿列克谢·库兹涅佐夫享用的糟糕伏特加有关。
100
101你可以使用 :c:func:`in_softirq()` 宏( ``include/linux/preempt.h`` )来确认
102是否处于软中断(或子任务)中。
103
104.. warning::
105
106 注意,如果持有 :ref:`bottom half lock <local_bh_disable_zh>` 锁,这将返回
107 假阳性。
108
109一些基本规则
110================
111
112缺少内存保护
113 如果你损坏了内存,无论是在用户上下文还是中断上下文中,整个机器都会崩溃。
114 你确定你不能在用户空间里做你想做的事吗?
115
116缺少浮点或MMX
117 FPU上下文不会被保存;即使在用户上下文中,FPU状态也可能与当前进程不一致:
118 您会弄乱某些用户进程的FPU状态。如果真的要这样做,就必须显式地保存/恢复
119 完整的FPU状态(并避免上下文切换)。这通常不是个好主意;请优先用定点算法。
120
121严格的堆栈限制
122 对于大多数32位体系结构,根据配置选项的不同内核堆栈大约为3K到6K;对于大
123 多数64位机器,内核堆栈大约为14K,并且经常与中断共享,因此你无法使用全部。
124 应避免深度递归和栈上的巨型本地数组(用动态分配它们来代替)。
125
126Linux内核是可移植的
127 就这样吧。您的代码应该是纯64位的,并且不依赖于字节序(endian)。您还应该
128 尽量减少CPU特定的东西,例如内联汇编(inline assembly)应该被干净地封装和
129 最小化以便于移植。一般来说,它应该局限于内核树中有体系结构依赖的部分。
130
131输入输出控制(ioctls):避免编写新的系统调用
132==============================================
133
134系统调用(system call)通常看起来像这样::
135
136 asmlinkage long sys_mycall(int arg)
137 {
138 return 0;
139 }
140
141
142首先,在大多数情况下,您无需创建新的系统调用。创建一个字符设备并为其实现适当
143的输入输出控制(ioctls)。这比系统调用灵活得多,不必写进每个体系结构的
144``include/asm/unistd.h`` 和 ``arch/kernel/entry.S`` 文件里,而且更容易被Linus
145接受。
146
147如果您的程序所做的只是读取或写入一些参数,请考虑实现 :c:func:`sysfs()` 接口。
148
149在输入输出控制中,您处于进程的用户上下文。出现错误时,返回一个负的错误参数
150(errno,请参阅 ``include/uapi/asm-generic/errno-base.h`` 、
151``include/uapi/asm-generic/errno.h`` 和 ``include/linux/errno.h`` ),否则返
152回0。
153
154在睡眠之后,您应该检查是否出现了信号:Unix/Linux处理信号的方法是暂时退出系统
155调用,并返回 ``-ERESTARTSYS`` 错误。系统调用入口代码将切换回用户上下文,处理
156信号处理程序,然后系统调用将重新启动(除非用户禁用了该功能)。因此,您应该准
157备好处理重新启动,例如若您处理某些数据结构到一半。
158
159::
160
161 if (signal_pending(current))
162 return -ERESTARTSYS;
163
164
165如果你要做更长时间的计算:优先考虑用户空间。如果你真的想在内核中做这件事,你
166应该定期检查你是否需要让出CPU(请记得每个CPU都有协作多任务)。
167习惯用法::
168
169 cond_resched(); /* Will sleep */
170
171
172接口设计的小注释:UNIX系统调用的格言是“提供机制而不是策略
173Provide mechanism not policy”。
174
175死锁的“配方”
176====================
177
178您不能调用任何可能睡眠的程序,除非:
179
180- 您处于用户上下文中。
181
182- 你未拥有任何自旋锁。
183
184- 您已经启用中断(实际上,Andi Kleen说调度代码将为您启用它们,但这可能不是
185 您想要的)。
186
187注意,有些函数可能隐式地睡眠:常见的是用户空间访问函数(\*_user)和没有
188``GFP_ATOMIC`` 的内存分配函数。
189
190您应该始终打开 ``CONFIG_DEBUG_ATOMIC_SLEEP`` 项来编译内核,如果您违反这些
191规则,它将警告您。如果你 **真的** 违反了规则,你最终会锁住你的电脑。
192
193真的会这样。
194
195
196常用函数/程序
197===============
198
199:c:func:`printk()`
200------------------
201
202定义于 ``include/linux/printk.h``
203
204:c:func:`printk()` 将内核消息提供给控制台、dmesg和syslog守护进程。它对于调
205试和报告错误很有用,并且可以在中断上下文中使用,但是使用时要小心:如果机器
206的控制台中充斥着printk消息则会无法使用。它使用与ANSI C printf基本兼容的格式
207字符串,并通过C字符串串联为其提供第一个“优先”参数::
208
209 printk(KERN_INFO "i = %u\n", i);
210
211
212参见 ``include/linux/kern_levels.h`` ;了解其他 ``KERN_`` 值;syslog将这些值
213解释为级别。特殊用法:打印IP地址使用::
214
215 __be32 ipaddress;
216 printk(KERN_INFO "my ip: %pI4\n", &ipaddress);
217
218
219:c:func:`printk()` 内部使用的1K缓冲区,不捕获溢出。请确保足够使用。
220
221.. note::
222
223 当您开始在用户程序中将printf打成printk时,就知道自己是真正的内核程序员了
224 :)
225
226.. note::
227
228 另一个注释:最初的unix第六版源代码在其printf函数的顶部有一个注释:“printf
229 不应该用于叽叽喳喳”。你也应该遵循此建议。
230
231:c:func:`copy_to_user()` / :c:func:`copy_from_user()` / :c:func:`get_user()` / :c:func:`put_user()`
232---------------------------------------------------------------------------------------------------
233
234定义于 ``include/linux/uaccess.h`` / ``asm/uaccess.h``
235
236**[睡眠]**
237
238:c:func:`put_user()` 和 :c:func:`get_user()` 用于从用户空间中获取和向用户空
239间中传出单个值(如int、char或long)。指向用户空间的指针永远不应该直接取消
240引用:应该使用这些程序复制数据。两者都返回 ``-EFAULT`` 或 0。
241
242:c:func:`copy_to_user()` 和 :c:func:`copy_from_user()` 更通用:它们从/向用户
243空间复制任意数量的数据。
244
245.. warning::
246
247 与 :c:func:`put_user()` 和 :c:func:`get_user()` 不同,它们返回未复制的
248 数据量(即0仍然意味着成功)。
249
250【是的,这个愚蠢的接口真心让我尴尬。火爆的口水仗大概每年都会发生。
251—— Rusty Russell】
252
253这些函数可以隐式睡眠。它不应该在用户上下文之外调用(没有意义)、调用时禁用中断
254或获得自旋锁。
255
256:c:func:`kmalloc()`/:c:func:`kfree()`
257-------------------------------------
258
259定义于 ``include/linux/slab.h``
260
261**[可能睡眠:见下]**
262
263这些函数用于动态请求指针对齐的内存块,类似用户空间中的malloc和free,但
264:c:func:`kmalloc()` 需要额外的标志词。重要的值:
265
266``GFP_KERNEL``
267 可以睡眠和交换以释放内存。只允许在用户上下文中使用,但这是分配内存最可靠
268 的方法。
269
270``GFP_ATOMIC``
271 不会睡眠。较 ``GFP_KERNEL`` 更不可靠,但可以从中断上下文调用。你 **应该**
272 有一个很好的内存不足错误处理策略。
273
274``GFP_DMA``
275 分配低于16MB的ISA DMA。如果你不知道那是什么,那你就不需要了。非常不可靠。
276
277如果您看到一个从无效上下文警告消息调用的睡眠的函数,那么您可能在没有
278``GFP_ATOMIC`` 的情况下从中断上下文调用了一个睡眠的分配函数。你必须立即修复,
279快点!
280
281如果你要分配至少 ``PAGE_SIZE`` ( ``asm/page.h`` 或 ``asm/page_types.h`` )
282字节,请考虑使用 :c:func:`__get_free_pages()` ( ``include/linux/gfp.h`` )。
283它采用顺序参数(0表示页面大小,1表示双页,2表示四页……)和与上述相同的内存
284优先级标志字。
285
286如果分配的字节数超过一页,可以使用 :c:func:`vmalloc()` 。它将在内核映射中分
287配虚拟内存。此块在物理内存中不是连续的,但是MMU(内存管理单元)使它看起来像
288是为您准备好的连续空间(因此它只是看起来对cpu连续,对外部设备驱动程序则不然)。
289如果您真的需要为一些奇怪的设备提供大量物理上连续的内存,那么您就会遇到问题:
290Linux对此支持很差,因为正在运行的内核中的内存碎片化会使它变得很困难。最好的
291方法是在引导过程的早期通过 :c:func:`alloc_bootmem()` 函数分配。
292
293在创建自己的常用对象缓存之前,请考虑使用 ``include/linux/slab.h`` 中的slab
294缓存。
295
296:c:macro:`current`
297------------------
298
299定义于 ``include/asm/current.h``
300
301此全局变量(其实是宏)包含指向当前任务结构(task structure)的指针,因此仅在
302用户上下文中有效。例如,当进程进行系统调用时,这将指向调用进程的任务结构。
303在中断上下文中不为空(**not NULL**)。
304
305:c:func:`mdelay()`/:c:func:`udelay()`
306-------------------------------------
307
308定义于 ``include/asm/delay.h`` / ``include/linux/delay.h``
309
310:c:func:`udelay()` 和 :c:func:`ndelay()` 函数可被用于小暂停。不要对它们使用
311大的值,因为这样会导致溢出——帮助函数 :c:func:`mdelay()` 在这里很有用,或者
312考虑 :c:func:`msleep()`。
313
314:c:func:`cpu_to_be32()`/:c:func:`be32_to_cpu()`/:c:func:`cpu_to_le32()`/:c:func:`le32_to_cpu()`
315-----------------------------------------------------------------------------------------------
316
317定义于 ``include/asm/byteorder.h``
318
319:c:func:`cpu_to_be32()` 系列函数(其中“32”可以替换为64或16,“be”可以替换为
320“le”)是在内核中进行字节序转换的常用方法:它们返回转换后的值。所有的变体也
321提供反向转换函数:
322:c:func:`be32_to_cpu()` 等。
323
324这些函数有两个主要的变体:指针变体,例如 :c:func:`cpu_to_be32p()` ,它获取
325指向给定类型的指针,并返回转换后的值。另一个变体是“in-situ”系列,例如
326:c:func:`cpu_to_be32s()` ,它转换指针引用的值,并返回void。
327
328:c:func:`local_irq_save()`/:c:func:`local_irq_restore()`
329--------------------------------------------------------
330
331定义于 ``include/linux/irqflags.h``
332
333
334这些程序禁用本地CPU上的硬中断,并还原它们。它们是可重入的;在其一个
335``unsigned long flags`` 参数中保存以前的状态。如果您知道中断已启用,那么可
336直接使用 :c:func:`local_irq_disable()` 和 :c:func:`local_irq_enable()`。
337
338.. _local_bh_disable_zh:
339
340:c:func:`local_bh_disable()`/:c:func:`local_bh_enable()`
341--------------------------------------------------------
342
343定义于 ``include/linux/bottom_half.h``
344
345
346这些程序禁用本地CPU上的软中断,并还原它们。它们是可重入的;如果之前禁用了
347软中断,那么在调用这对函数之后仍然会禁用它们。它们阻止软中断和子任务在当前
348CPU上运行。
349
350:c:func:`smp_processor_id()`
351----------------------------
352
353定义于 ``include/linux/smp.h``
354
355:c:func:`get_cpu()` 禁用抢占(这样您就不会突然移动到另一个cpu)并返回当前
356处理器号,介于0和 ``NR_CPUS`` 之间。请注意,CPU编号不一定是连续的。完成后,
357使用 :c:func:`put_cpu()` 再次返回。
358
359如果您知道您不能被另一个任务抢占(即您处于中断上下文中,或已禁用抢占),您
360可以使用 :c:func:`smp_processor_id()`。
361
362``__init``/``__exit``/``__initdata``
363------------------------------------
364
365定义于 ``include/linux/init.h``
366
367引导之后,内核释放一个特殊的部分;用 ``__init`` 标记的函数和用 ``__initdata``
368标记的数据结构在引导完成后被丢弃:同样地,模块在初始化后丢弃此内存。
369``__exit`` 用于声明只在退出时需要的函数:如果此文件未编译为模块,则该函数将
370被删除。请参阅头文件以使用。请注意,使用 :c:func:`EXPORT_SYMBOL()` 或
371:c:func:`EXPORT_SYMBOL_GPL()` 将标记为 ``__init`` 的函数导出到模块是没有意义
372的——这将出问题。
373
374
375:c:func:`__initcall()`/:c:func:`module_init()`
376----------------------------------------------
377
378定义于 ``include/linux/init.h`` / ``include/linux/module.h``
379
380内核的许多部分都作为模块(内核的可动态加载部分)良好服务。使用
381:c:func:`module_init()` 和 :c:func:`module_exit()` 宏可以简化代码编写,无需
382``#ifdef`` ,即可以作为模块运行或内置在内核中。
383
384:c:func:`module_init()` 宏定义在模块插入时(如果文件编译为模块)或在引导时
385调用哪个函数:如果文件未编译为模块,:c:func:`module_init()` 宏将等效于
386:c:func:`__initcall()` ,它通过链接器的魔力确保在引导时调用该函数。
387
388该函数可以返回一个错误值,以导致模块加载失败(不幸的是,如果将模块编译到内核
389中,则此操作无效)。此函数在启用中断的用户上下文中调用,因此可以睡眠。
390
391:c:func:`module_exit()`
392-----------------------
393
394
395定义于 ``include/linux/module.h``
396
397这个宏定义了在模块删除时要调用的函数(如果是编译到内核中的文件,则无用武之地)。
398只有在模块使用计数到零时才会调用它。这个函数也可以睡眠,但不能失败:当它返回
399时,所有的东西都必须清理干净。
400
401注意,这个宏是可选的:如果它不存在,您的模块将不可移除(除非 ``rmmod -f`` )。
402
403:c:func:`try_module_get()`/:c:func:`module_put()`
404-------------------------------------------------
405
406定义于 ``include/linux/module.h``
407
408这些函数会操作模块使用计数,以防止删除(如果另一个模块使用其导出的符号之一,
409则无法删除模块,参见下文)。在调用模块代码之前,您应该在该模块上调用
410:c:func:`try_module_get()` :若失败,那么该模块将被删除,您应该将其视为不存在。
411若成功,您就可以安全地进入模块,并在完成后调用模块 :c:func:`module_put()` 。
412
413大多数可注册结构体都有所有者字段,例如在
414:c:type:`struct file_operations <file_operations>` 结构体中,此字段应设置为
415宏 ``THIS_MODULE`` 。
416
417等待队列 ``include/linux/wait.h``
418====================================
419
420**[睡眠]**
421
422等待队列用于等待某程序在条件为真时唤醒另一程序。必须小心使用,以确保没有竞争
423条件。先声明一个 :c:type:`wait_queue_head_t` ,然后对希望等待该条件的进程声明
424一个关于它们自己的 :c:type:`wait_queue_entry_t` ,并将其放入队列中。
425
426声明
427-----
428
429使用 :c:func:`DECLARE_WAIT_QUEUE_HEAD()` 宏声明一个 ``wait_queue_head_t`` ,
430或者在初始化代码中使用 :c:func:`init_waitqueue_head()` 程序。
431
432排队
433-----
434
435将自己放在等待队列中相当复杂,因为你必须在检查条件之前将自己放入队列中。有一
436个宏可以来执行此操作: :c:func:`wait_event_interruptible()`
437( ``include/linux/wait.h`` )第一个参数是等待队列头,第二个参数是计算的表达
438式;当该表达式为true时宏返回0,或者在接收到信号时返回 ``-ERESTARTSYS`` 。
439:c:func:`wait_event()` 版本会忽略信号。
440
441唤醒排队任务
442-------------
443
444调用 :c:func:`wake_up()` ( ``include/linux/wait.h`` ),它将唤醒队列中的所有
445进程。例外情况:如果有一个进程设置了 ``TASK_EXCLUSIVE`` ,队列的其余部分将不
446会被唤醒。这个基本函数的其他变体也可以在同一个头文件中使用。
447
448原子操作
449=========
450
451某些操作在所有平台上都有保证。第一类为操作 :c:type:`atomic_t`
452( ``include/asm/atomic.h`` )的函数;它包含一个有符号整数(至少32位长),
453您必须使用这些函数来操作或读取 :c:type:`atomic_t` 变量。
454:c:func:`atomic_read()` 和 :c:func:`atomic_set()` 获取并设置计数器,还有
455:c:func:`atomic_add()` ,:c:func:`atomic_sub()` ,:c:func:`atomic_inc()` ,
456:c:func:`atomic_dec()` 和 :c:func:`atomic_dec_and_test()` (如果递减为零,
457则返回true)。
458
459是的。它在原子变量为零时返回true(即!=0)。
460
461请注意,这些函数比普通的算术运算速度慢,因此不应过度使用。
462
463第二类原子操作是在 ``unsigned long`` ( ``include/linux/bitops.h`` )上的
464原子位操作。这些操作通常采用指向位模式(bit pattern)的指针,第0位是最低有效
465位。:c:func:`set_bit()`,:c:func:`clear_bit()` 和 :c:func:`change_bit()` 设置、
466清除和更改给定位。:c:func:`test_and_set_bit()` ,:c:func:`test_and_clear_bit()`
467和 :c:func:`test_and_change_bit()` 执行相同的操作,但如果之前设置了位,则返回
468true;这些对于原子设置标志特别有用。
469
470可以使用大于 ``BITS_PER_LONG`` 位的位索引调用这些操作。但结果在大端序平台上
471不太正常,所以最好不要这样做。
472
473符号
474=====
475
476在内核内部,正常的链接规则仍然适用(即除非用static关键字将符号声明为文件范围,
477否则它可以在内核中的任何位置使用)。但是对于模块,会保留一个特殊可导出符号表,
478该表将入口点限制为内核内部。模块也可以导出符号。
479
480:c:func:`EXPORT_SYMBOL()`
481-------------------------
482
483定义于 ``include/linux/export.h``
484
485这是导出符号的经典方法:动态加载的模块将能够正常使用符号。
486
487:c:func:`EXPORT_SYMBOL_GPL()`
488-----------------------------
489
490定义于 ``include/linux/export.h``
491
492
493类似于 :c:func:`EXPORT_SYMBOL()`,只是 :c:func:`EXPORT_SYMBOL_GPL()` 导出的
494符号只能由具有由 :c:func:`MODULE_LICENSE()` 指定GPL兼容许可证的模块看到。这
495意味着此函数被认为是一个内部实现问题,而不是一个真正的接口。一些维护人员和
496开发人员在添加一些新的API或功能时可能却需要导出 EXPORT_SYMBOL_GPL()。
497
498:c:func:`EXPORT_SYMBOL_NS()`
499----------------------------
500
501定义于 ``include/linux/export.h``
502
503这是 ``EXPORT_SYMBOL()`` 的变体,允许指定符号命名空间。符号名称空间记录于
504Documentation/core-api/symbol-namespaces.rst 。
505
506:c:func:`EXPORT_SYMBOL_NS_GPL()`
507--------------------------------
508
509定义于 ``include/linux/export.h``
510
511这是 ``EXPORT_SYMBOL_GPL()`` 的变体,允许指定符号命名空间。符号名称空间记录于
512Documentation/core-api/symbol-namespaces.rst 。
513
514程序与惯例
515===========
516
517双向链表 ``include/linux/list.h``
518-----------------------------------
519
520内核头文件中曾经有三组链表程序,但这一组是赢家。如果你对一个单链表没有特别迫切的
521需求,那么这是一个不错的选择。
522
523通常 :c:func:`list_for_each_entry()` 很有用。
524
525返回值惯例
526------------
527
528对于在用户上下文中调用的代码,违背C语言惯例是很常见的,即返回0表示成功,返回
529负错误值(例如 ``-EFAULT`` )表示失败。这在一开始可能是不直观的,但在内核中
530相当普遍。
531
532使用 :c:func:`ERR_PTR()` ( ``include/linux/err.h`` )将负错误值编码到指针中,
533然后使用 :c:func:`IS_ERR()` 和 :c:func:`PTR_ERR()` 将其再取出:避免为错误值
534使用单独的指针参数。挺讨厌的,但的确是个好方式。
535
536破坏编译
537----------
538
539Linus和其他开发人员有时会更改开发内核中的函数或结构体名称;这样做不仅是为了
540让每个人都保持警惕,还反映了一个重大的更改(例如,不能再在打开中断的情况下
541调用,或者执行额外的检查,或者不执行以前捕获的检查)。通常这会附带一个linux
542内核邮件列表中相当全面的注释;请搜索存档以查看。简单地对文件进行全局替换通常
543会让事情变得 **更糟** 。
544
545初始化结构体成员
546------------------
547
548初始化结构体的首选方法是使用指定的初始化器,如ISO C99所述。
549例如::
550
551 static struct block_device_operations opt_fops = {
552 .open = opt_open,
553 .release = opt_release,
554 .ioctl = opt_ioctl,
555 .check_media_change = opt_media_change,
556 };
557
558
559这使得很容易查找(grep),并且可以清楚地看到设置了哪些结构字段。你应该这样做,
560因为它看起来很酷。
561
562GNU 扩展
563----------
564
565Linux内核中明确允许GNU扩展。请注意,由于缺乏通用性,一些更复杂的版本并没有
566得到很好的支持,但以下内容被认为是标准的(有关更多详细信息,请参阅GCC info页
567的“C 扩展”部分——是的,实际上是info页,手册页只是info中内容的简短摘要)。
568
569- 内联函数
570
571- 语句表达式(Statement expressions)(即({ 和 })结构)。
572
573
574- 声明函数/变量/类型的属性(__attribute__)
575
576- typeof
577
578- 零长度数组
579
580- 宏变量
581
582- 空指针运算
583
584- 非常量(Non-Constant)初始化程序
585
586- 汇编程序指令(在 arch/ 和 include/asm/ 之内)
587
588- 字符串函数名(__func__)。
589
590- __builtin_constant_p()
591
592在内核中使用long long时要小心,gcc为其生成的代码非常糟糕:除法和乘法在i386上
593不能工作,因为内核环境中缺少用于它的gcc运行时函数。
594
595C++
596---
597
598在内核中使用C++通常是个坏主意,因为内核不提供必要的运行时环境,并且不为其
599测试包含文件。不过这仍然是可能的,但不建议。如果你真的想这么做,至少别用
600异常处理(exceptions)。
601
602#if
603---
604
605通常认为,在头文件(或.c文件顶部)中使用宏来抽象函数比在源代码中使用“if”预
606处理器语句更干净。
607
608把你的东西放进内核里
609======================
610
611为了让你的东西更正式、补丁更整洁,还有一些工作要做:
612
613- 搞清楚你在谁的地界儿上干活。查看源文件的顶部、 ``MAINTAINERS`` 文件以及
614 ``CREDITS`` 文件的最后一部分。你应该和此人协调,确保你没有重新发明轮子,
615 或者尝试一些已经被拒绝的东西。
616
617 确保你把你的名字和电子邮件地址放在你创建或修改的任何文件的顶部。当人们发
618 现一个缺陷,或者想要做出修改时,这是他们首先会看的地方。
619
620- 通常你需要一个配置选项来支持你的内核编程。在适当的目录中编辑 ``Kconfig`` 。
621 配置语言很容易通过剪切和粘贴来使用,在
622 Documentation/kbuild/kconfig-language.rst 中有完整的文档。
623
624 在您对选项的描述中,请确保同时照顾到了专家用户和对此功能一无所知的用户。
625 在此说明任何不兼容和问题。结尾一定要写上“如有疑问,就选N”(或者是“Y”);
626 这是针对那些看不懂你在说什么的人的。
627
628- 编辑 ``Makefile`` :配置变量在这里导出,因此通常你只需添加一行
629 “obj-$(CONFIG_xxx) += xxx.o”。语法记录在
630 Documentation/kbuild/makefiles.rst 。
631
632- 如果你做了一些有意义的事情,那可以把自己放进 ``CREDITS`` ,通常不止一个
633 文件(无论如何你的名字都应该在源文件的顶部)。维护人员意味着您希望在对
634 子系统进行更改时得到询问,并了解缺陷;这意味着对某部分代码做出更多承诺。
635
636- 最后,别忘记去阅读 Documentation/process/submitting-patches.rst ,
637 也许还有 Documentation/process/submitting-drivers.rst 。
638
639Kernel 仙女棒
640===============
641
642浏览源代码时的一些收藏。请随意添加到此列表。
643
644``arch/x86/include/asm/delay.h``::
645
646 #define ndelay(n) (__builtin_constant_p(n) ? \
647 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
648 __ndelay(n))
649
650
651``include/linux/fs.h``::
652
653 /*
654 * Kernel pointers have redundant information, so we can use a
655 * scheme where we can return either an error code or a dentry
656 * pointer with the same return value.
657 *
658 * This should be a per-architecture thing, to allow different
659 * error and pointer decisions.
660 */
661 #define ERR_PTR(err) ((void *)((long)(err)))
662 #define PTR_ERR(ptr) ((long)(ptr))
663 #define IS_ERR(ptr) ((unsigned long)(ptr) > (unsigned long)(-1000))
664
665``arch/x86/include/asm/uaccess_32.h:``::
666
667 #define copy_to_user(to,from,n) \
668 (__builtin_constant_p(n) ? \
669 __constant_copy_to_user((to),(from),(n)) : \
670 __generic_copy_to_user((to),(from),(n)))
671
672
673``arch/sparc/kernel/head.S:``::
674
675 /*
676 * Sun people can't spell worth damn. "compatibility" indeed.
677 * At least we *know* we can't spell, and use a spell-checker.
678 */
679
680 /* Uh, actually Linus it is I who cannot spell. Too much murky
681 * Sparc assembly will do this to ya.
682 */
683 C_LABEL(cputypvar):
684 .asciz "compatibility"
685
686 /* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
687 .align 4
688 C_LABEL(cputypvar_sun4m):
689 .asciz "compatible"
690
691
692``arch/sparc/lib/checksum.S:``::
693
694 /* Sun, you just can't beat me, you just can't. Stop trying,
695 * give up. I'm serious, I am going to kick the living shit
696 * out of you, game over, lights out.
697 */
698
699
700致谢
701=====
702
703感谢Andi Kleen提出点子,回答我的问题,纠正我的错误,充实内容等帮助。
704感谢Philipp Rumpf做了许多拼写和清晰度修复,以及一些优秀的不明显的点。
705感谢Werner Almesberger对 :c:func:`disable_irq()` 做了一个很好的总结,
706Jes Sorensen和Andrea Arcangeli补充了一些注意事项。
707感谢Michael Elizabeth Chastain检查并补充了配置部分。
708感谢Telsa Gwynne教我DocBook。
Documentation/translations/zh_CN/kernel-hacking/index.rst+22−0
@@ -0,0 +1,22 @@
1.. _kernel_hacking_zh:
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: Documentation/kernel-hacking/index.rst
6
7:译者:
8
9 吴想成 Wu XiangCheng <bobwxc@email.cn>
10
11=============
12内核骇客指南
13=============
14
15.. toctree::
16 :maxdepth: 2
17
18 hacking
19
20TODO
21
22- locking
Documentation/translations/zh_CN/openrisc/index.rst+30−0
@@ -0,0 +1,30 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :doc:`../../../openrisc/index`
6:Translator: Yanteng Si <siyanteng@loongson.cn>
7
8.. _cn_openrisc_index:
9
10
11=================
12OpenRISC 体系架构
13=================
14
15.. toctree::
16 :maxdepth: 2
17
18 openrisc_port
19 todo
20
21Todolist:
22 features
23
24
25.. only:: subproject and html
26
27 Indices
28 =======
29
30 * :ref:`genindex`
Documentation/translations/zh_CN/openrisc/openrisc_port.rst+124−0
@@ -0,0 +1,124 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../openrisc/openrisc_port`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_openrisc_port:
7
8==============
9OpenRISC Linux
10==============
11
12这是Linux对OpenRISC类微处理器的移植;具体来说,最早移植目标是32位
13OpenRISC 1000系列(或1k)。
14
15关于OpenRISC处理器和正在进行中的开发的信息:
16
17 ======= =============================
18 网站 https://openrisc.io
19 邮箱 openrisc@lists.librecores.org
20 ======= =============================
21
22---------------------------------------------------------------------
23
24OpenRISC工具链和Linux的构建指南
25===============================
26
27为了构建和运行Linux for OpenRISC,你至少需要一个基本的工具链,或许
28还需要架构模拟器。 这里概述了准备就位这些部分的步骤。
29
301) 工具链
31
32工具链二进制文件可以从openrisc.io或我们的github发布页面获得。不同
33工具链的构建指南可以在openrisc.io或Stafford的工具链构建和发布脚本
34中找到。
35
36 ====== =================================================
37 二进制 https://github.com/openrisc/or1k-gcc/releases
38 工具链 https://openrisc.io/software
39 构建 https://github.com/stffrdhrn/or1k-toolchain-build
40 ====== =================================================
41
422) 构建
43
44像往常一样构建Linux内核::
45
46 make ARCH=openrisc CROSS_COMPILE="or1k-linux-" defconfig
47 make ARCH=openrisc CROSS_COMPILE="or1k-linux-"
48
493) 在FPGA上运行(可选)
50
51OpenRISC社区通常使用FuseSoC来管理构建和编程SoC到FPGA中。 下面是用
52OpenRISC SoC对De0 Nano开发板进行编程的一个例子。 在构建过程中,
53FPGA RTL是从FuseSoC IP核库中下载的代码,并使用FPGA供应商工具构建。
54二进制文件用openocd加载到电路板上。
55
56::
57
58 git clone https://github.com/olofk/fusesoc
59 cd fusesoc
60 sudo pip install -e .
61
62 fusesoc init
63 fusesoc build de0_nano
64 fusesoc pgm de0_nano
65
66 openocd -f interface/altera-usb-blaster.cfg \
67 -f board/or1k_generic.cfg
68
69 telnet localhost 4444
70 > init
71 > halt; load_image vmlinux ; reset
72
734) 在模拟器上运行(可选)
74
75QEMU是一个处理器仿真器,我们推荐它来模拟OpenRISC平台。 请按照QEMU网
76站上的OpenRISC说明,让Linux在QEMU上运行。 你可以自己构建QEMU,但你的
77Linux发行版可能提供了支持OpenRISC的二进制包。
78
79 ============= ======================================================
80 qemu openrisc https://wiki.qemu.org/Documentation/Platforms/OpenRISC
81 ============= ======================================================
82
83---------------------------------------------------------------------
84
85术语表
86======
87
88代码中使用了以下符号约定以将范围限制在几个特定处理器实现上:
89
90========= =======================
91openrisc: OpenRISC类型处理器
92or1k: OpenRISC 1000系列处理器
93or1200: OpenRISC 1200处理器
94========= =======================
95
96---------------------------------------------------------------------
97
98历史
99====
100
1012003-11-18 Matjaz Breskvar (phoenix@bsemi.com)
102 将linux初步移植到OpenRISC或32架构。
103 所有的核心功能都实现了,并且可以使用。
104
1052003-12-08 Matjaz Breskvar (phoenix@bsemi.com)
106 彻底改变TLB失误处理。
107 重写异常处理。
108 在默认的initrd中实现了sash-3.6的所有功能。
109 大幅改进的版本。
110
1112004-04-10 Matjaz Breskvar (phoenix@bsemi.com)
112 大量的bug修复。
113 支持以太网,http和telnet服务器功能。
114 可以运行许多标准的linux应用程序。
115
1162004-06-26 Matjaz Breskvar (phoenix@bsemi.com)
117 移植到2.6.x。
118
1192004-11-30 Matjaz Breskvar (phoenix@bsemi.com)
120 大量的bug修复和增强功能。
121 增加了opencores framebuffer驱动。
122
1232010-10-09 Jonas Bonn (jonas@southpole.se)
124 重大重写,使其与上游的Linux 2.6.36看齐。
Documentation/translations/zh_CN/openrisc/todo.rst+20−0
@@ -0,0 +1,20 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../openrisc/todo`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_openrisc_todo.rst:
7
8========
9待办事项
10========
11
12OpenRISC Linux的移植已经完全投入使用,并且从 2.6.35 开始就一直在上游同步。
13然而,还有一些剩余的项目需要在未来几个月内完成。 下面是一个即将进行调查的已知
14不尽完美的项目列表,即我们的待办事项列表。
15
16- 实现其余的DMA API……dma_map_sg等。
17
18- 完成重命名清理工作……代码中提到了or32,这是架构的一个老名字。 我们
19 已经确定的名字是or1k,这个改变正在以缓慢积累的方式进行。 目前,or32相当
20 于or1k。
Documentation/translations/zh_CN/process/1.Intro.rst+102−93
@@ -1,162 +1,170 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/1.Intro.rst <development_process_intro>`3:Original: :ref:`Documentation/process/1.Intro.rst <development_process_intro>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_process_intro:13.. _cn_development_process_intro:
7 14
8介绍15引言
9====16====
10 17
11执行摘要18内容提要
12--------19--------
13 20
14本节的其余部分涵盖了内核开发过程的范围,以及开发人员及其雇主在这方面可能遇21本节的其余部分涵盖了内核开发的过程,以及开发人员及其雇主在这方面可能遇到的
15到的各种挫折。内核代码应该合并到正式的(“主线”)内核中有很多原因,包括对用22各种问题。有很多原因使内核代码应被合并到正式的(“主线”)内核中,包括对用户
16户的自动可用性、多种形式的社区支持以及影响内核开发方向的能力。提供给Linux23的自动可用性、多种形式的社区支持以及影响内核开发方向的能力。提供给Linux内核
17内核的代码必须在与GPL兼容的许可证下可用。24的代码必须在与GPL兼容的许可证下可用。
18 25
19:ref:`cn_development_process` 介绍了开发过程、内核发布周期和合并窗口的机制。26:ref:`cn_development_process` 介绍了开发过程、内核发布周期和合并窗口的机制。
20涵盖了补丁开发、审查和合并周期中的各个阶段。有一些关于工具和邮件列表的讨论。27涵盖了补丁开发、审查和合并周期中的各个阶段。还有一些关于工具和邮件列表的讨论?
21鼓励希望开始内核开发的开发人员作为初始练习跟踪并修复bug。28鼓励希望开始内核开发的开发人员跟踪并修复缺陷以作为初步练习。
22 29
23 30
24:ref:`cn_development_early_stage` 包括早期项目规划,重点是尽快让开发社区参与31:ref:`cn_development_early_stage` 包括项目的早期规划,重点是尽快让开发社区
32参与进来。
25 33
26:ref:`cn_development_coding` 是关于编码过程的;讨论了其他开发人员遇到的几个34:ref:`cn_development_coding` 是关于编程过程的;介绍了其他开发人员遇到的几个
27陷阱。对补丁的一些要求已经涵盖,并且介绍了一些工具,这些工具有助于确保内核35陷阱。也涵盖了对补丁的一些要求,并且介绍了一些工具,这些工具有助于确保内核
28补丁是正确的。36补丁是正确的。
29 37
30:ref:`cn_development_posting` 讨论发布补丁以供评审的过程。为了让开发社区38:ref:`cn_development_posting` 描述发布补丁以供评审的过程。为了让开发社区能
31认真对待,补丁必须正确格式化和描述,并且必须发送到正确的地方。遵循本节中的39认真对待,补丁必须被正确格式化和描述,并且必须发送到正确的地方。遵循本节中的
32建议有助于确保为您的工作提供最好的接纳。40建议有助于确保您的工作能被较好地接纳。
33 41
34:ref:`cn_development_followthrough` 介绍了发布补丁之后发生的事情;该工作42:ref:`cn_development_followthrough` 介绍了发布补丁之后发生的事情;工作在这时
35在这一点上还远远没有完成。与审阅者一起工作是开发过程中的一个重要部分;本节43还远远没有完成。与审阅者一起工作是开发过程中的一个重要部分;本节提供了一些
36提供了一些关于如何在这个重要阶段避免问题的提示。当补丁被合并到主线中时,44关于如何在这个重要阶段避免问题的提示。当补丁被合并到主线中时,开发人员要注意
37开发人员要注意不要假定任务已经完成。45不要假定任务已经完成。
38 46
39:ref:`cn_development_advancedtopics` 介绍了两个“高级”主题:47:ref:`cn_development_advancedtopics` 介绍了两个“高级”主题:使用Git管理补丁
40使用Git管理补丁和查看其他人发布的补丁。48和查看其他人发布的补丁。
41 49
42:ref:`cn_development_conclusion` 总结了有关内核开发的更多信息,附带有带有50:ref:`cn_development_conclusion` 总结了有关内核开发的更多信息,附带有相关资源
43指向资源的链接.51链接。
44 52
45这个文件是关于什么的53这个文档是关于什么的
46--------------------54--------------------
47 55
48Linux内核有超过800万行代码,每个版本的贡献者超过1000人,是现存最大、最活跃56Linux内核有超过800万行代码,每个版本的贡献者超过1000人,是现存最大、最活跃的
49的免费软件项目之一。从1991年开始,这个内核已经发展成为一个最好的操作系统57免费软件项目之一。从1991年开始,这个内核已经发展成为一个最好的操作系统组件,
50组件,运行在袖珍数字音乐播放器、台式PC、现存最大的超级计算机以及所有类型的58运行在袖珍数字音乐播放器、台式电脑、现存最大的超级计算机以及所有类型的系统上。
51系统上。它是一种适用于几乎任何情况的健壮、高效和可扩展的解决方案。59它是一种适用于几乎任何情况的健壮、高效和可扩展的解决方案。
52 60
53随着Linux的发展,希望参与其开发的开发人员(和公司)的数量也在增加。硬件供应商61随着Linux的发展,希望参与其开发的开发人员(和公司)的数量也在增加。硬件供应商
54希望确保Linux能够很好地支持他们的产品,使这些产品对Linux用户具有吸引力。嵌入62希望确保Linux能够很好地支持他们的产品,使这些产品对Linux用户具有吸引力。嵌入
55式系统供应商使用Linux作为集成产品的组件,希望Linux能够尽可能地胜任手头的任务。63式系统供应商使用Linux作为集成产品的组件,希望Linux能够尽可能地胜任手头的任务。
56分销商和其他基于Linux的软件供应商对Linux内核的功能、性能和可靠性有着明确的64分销商和其他基于Linux的软件供应商切实关心Linux内核的功能、性能和可靠性。最终
57兴趣。最终用户也常常希望修改Linux,使之更好地满足他们的需求。65用户也常常希望修改Linux,使之能更好地满足他们的需求。
58 66
59Linux最引人注目的特性之一是这些开发人员可以访问它;任何具备必要技能的人都可以67Linux最引人注目的特性之一是这些开发人员可以访问它;任何具备必要技能的人都可以
60改进Linux并影响其开发方向。专有产品不能提供这种开放性,这是自由软件的一个特点。68改进Linux并影响其开发方向。专有产品不能提供这种开放性,这是自由软件的一个特点。
61但是,如果有什么不同的话,内核比大多数其他自由软件项目更开放。一个典型的三个月69如果有什么不同的话,那就是内核比大多数其他自由软件项目更开放。一个典型的三个
62内核开发周期可以涉及1000多个开发人员,他们为100多个不同的公司70月内核开发周期可以涉及1000多个开发人员,他们为100多个不同的公司(或者根本不
63(或者根本没有公司)工作。71隶属公司)工作。
64 72
65与内核开发社区合作并不是特别困难。但是,尽管如此,许多潜在的贡献者在尝试做73与内核开发社区合作并不是特别困难。但尽管如此,仍有许多潜在的贡献者在尝试做
66内核工作时遇到了困难。内核社区已经发展了自己独特的操作方式,使其能够在每天74内核工作时遇到了困难。内核社区已经发展出自己独特的操作方式,使其能够在每天
67都要更改数千行代码的环境中顺利运行(并生成高质量的产品)。因此,Linux内核开发75都要更改数千行代码的环境中顺利运行(并生成高质量的产品)。因此,Linux内核开发
68过程与专有的开发方法有很大的不同也就不足为奇了。76过程与专有的开发模式有很大的不同也就不足为奇了。
69 77
70对于新开发人员来说,内核的开发过程可能会让人感到奇怪和恐惧,但这个背后有充分的78对于新开发人员来说,内核的开发过程可能会让人感到奇怪和恐惧,但这背后有充分的
71理由和坚实的经验。一个不了解内核社区的方式的开发人员(或者更糟的是,他们试图79理由和坚实的经验。一个不了解内核社区工作方式的开发人员(或者更糟的是,他们
72抛弃或规避内核社区的方式)会有一个令人沮丧的体验。开发社区, 在帮助那些试图学习80试图抛弃或规避之)会得到令人沮丧的体验。开发社区在帮助那些试图学习的人的同时,
73的人的同时,没有时间帮助那些不愿意倾听或不关心开发过程的人。81没有时间帮助那些不愿意倾听或不关心开发过程的人。
74 82
75希望阅读本文的人能够避免这种令人沮丧的经历。这里有很多材料,但阅读时所做的83希望阅读本文的人能够避免这种令人沮丧的经历。这些材料很长,但阅读它们时所做的
76努力会在短时间内得到回报。开发社区总是需要能让内核变更好的开发人员;下面的84努力会在短时间内得到回报。开发社区总是需要能让内核变更好的开发人员;下面的
77文本应该帮助您或为您工作的人员加入我们的社区。85文字应该帮助您或为您工作的人员加入我们的社区。
78 86
79致谢87致谢
80----88----
81 89
82本文件由Jonathan Corbet撰写,corbet@lwn.net。以下人员的建议使之更为完善:90本文档由Jonathan Corbet <corbet@lwn.net> 撰写。以下人员的建议使之更为完善:
83Johannes Berg, James Berry, Alex Chiang, Roland Dreier, Randy Dunlap,91Johannes Berg, James Berry, Alex Chiang, Roland Dreier, Randy Dunlap,
84Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh, Amanda McPherson,92Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh, Amanda McPherson,
85Andrew Morton, Andrew Price, Tsugikazu Shibata, 和 Jochen Voß.93Andrew Morton, Andrew Price, Tsugikazu Shibata 和 Jochen Voß 。
86 94
87这项工作得到了Linux基金会的支持,特别感谢Amanda McPherson,他看到了这项工作95这项工作得到了Linux基金会的支持,特别感谢Amanda McPherson,他看到了这项工作
88的价值并把它变成现实。96的价值并将其变成现实。
89 97
90代码进入主线的重要性98代码进入主线的重要性
91--------------------99--------------------
92 100
93有些公司和开发人员偶尔会想,为什么他们要费心学习如何与内核社区合作,并将代码101有些公司和开发人员偶尔会想,为什么他们要费心学习如何与内核社区合作,并将代码
94放入主线内核(“主线”是由Linus Torvalds维护的内核,Linux发行商将其用作基础)。102放入主线内核(“主线”是由Linus Torvalds维护的内核,Linux发行商将其用作基础)。
95在短期内,贡献代码看起来像是一种可以避免的开销;仅仅将代码分开并直接支持用户103在短期内,贡献代码看起来像是一种可以避免的开销;维护独立代码并直接支持用户
96似乎更容易。事实上,保持代码独立(“树外”)是在经济上是错误的。104似乎更容易。事实上,保持代码独立(“树外”)是在经济上是错误的。
97 105
98作为说明树外代码成本的一种方法,下面是内核开发过程的一些相关方面;本文稍后将106为了说明树外代码成本,下面给出内核开发过程的一些相关方面;本文稍后将更详细地
99更详细地讨论其中的大部分内容。考虑:107讨论其中的大部分内容。请考虑:
100 108
101- 所有Linux用户都可以使用合并到主线内核中的代码。它将自动出现在所有启用它的109- 所有Linux用户都可以使用合并到主线内核中的代码。它将自动出现在所有启用它的
102 发行版上。不需要驱动程序磁盘、下载,也不需要为多个发行版的多个版本提供支持;110 发行版上。无需驱动程序磁盘、额外下载,也不需要为多个发行版的多个版本提供
103 对于开发人员和用户来说,这一切都是可行的。并入主线解决了大量的分布和支持问题111 支持;这一切将方便所有开发人员和用户。并入主线解决了大量的分发和支持问题。
104 112
105- 当内核开发人员努力维护一个稳定的用户空间接口时,内部内核API处于不断变化之中.113- 当内核开发人员努力维护一个稳定的用户空间接口时,内核内部API处于不断变化之中。
106 缺乏一个稳定的内部接口是一个深思熟虑的设计决策;它允许在任何时候进行基本的改114 不维持稳定的内部接口是一个慎重的设计决策;它允许在任何时候进行基本的改进,
107 进,并产生更高质量的代码。但该策略的一个结果是,如果要使用新的内核,任何树外115 并产出更高质量的代码。但该策略导致结果是,若要使用新的内核,任何树外代码都
108 代码都需要持续的维护。维护树外代码需要大量的工作才能使代码保持工作状态。116 需要持续的维护。维护树外代码会需要大量的工作才能使代码保持正常运行。
109 117
110 相反,位于主线中的代码不需要这样做,因为一个简单的规则要求进行API更改的任何118 相反,位于主线中的代码不需要这样做,因为基本规则要求进行API更改的任何开发
111 开发人员也必须修复由于该更改而破坏的任何代码。因此,合并到主线中的代码大大119 人员也必须修复由于该更改而破坏的任何代码。因此,合并到主线中的代码大大降低
112 降低了维护成本。120 了维护成本。
113 121
114- 除此之外,内核中的代码通常会被其他开发人员改进。令人惊讶的结果可能来自授权122- 除此之外,内核中的代码通常会被其他开发人员改进。您授权的用户社区和客户对您
115 您的用户社区和客户改进您的产品。123 产品的改进可能会令人惊喜。
116 124
117- 内核代码在合并到主线之前和之后都要经过审查。不管原始开发人员的技能有多强,125- 内核代码在合并到主线之前和之后都要经过审查。无论原始开发人员的技能有多强,
118 这个审查过程总是能找到改进代码的方法。审查经常发现严重的错误和安全问题。126 这个审查过程总是能找到改进代码的方法。审查经常发现严重的错误和安全问题。
119 这对于在封闭环境中开发的代码尤其如此;这种代码从外部开发人员的审查中获益127 对于在封闭环境中开发的代码尤其如此;这种代码从外部开发人员的审查中获益匪浅。
120 匪浅。树外代码是低质量代码。128 树外代码是低质量代码。
121 129
122- 参与开发过程是您影响内核开发方向的方式。旁观者的抱怨会被听到,但是活跃的130- 参与开发过程是您影响内核开发方向的方式。旁观者的抱怨会被听到,但是活跃的
123 开发人员有更强的声音——并且能够实现使内核更好地满足其需求的更改。131 开发人员有更强的声音——并且能够实现使内核更好地满足其需求的更改。
124 132
125- 当单独维护代码时,总是存在第三方为类似功能提供不同实现的可能性。如果发生133- 当单独维护代码时,总是存在第三方为类似功能提供不同实现的可能性。如果发生
126 这种情况,合并代码将变得更加困难——甚至到了不可能的地步。然后,您将面临以下134 这种情况,合并代码将变得更加困难——甚至成为不可能。之后,您将面临以下令人
127 令人不快的选择:(1)无限期地维护树外的非标准特性,或(2)放弃代码并将用户135 不快的选择:(1)无限期地维护树外的非标准特性,或(2)放弃代码并将用户迁移
128 迁移到树内版本。136 到树内版本。
129 137
130- 代码的贡献是使整个过程工作的根本。通过贡献代码,您可以向内核添加新功能,并138- 代码的贡献是使整个流程工作的根本。通过贡献代码,您可以向内核添加新功能,并
131 提供其他内核开发人员使用的功能和示例。如果您已经为Linux开发了代码(或者139 提供其他内核开发人员使用的功能和示例。如果您已经为Linux开发了代码(或者正在
132 正在考虑这样做),那么您显然对这个平台的持续成功感兴趣;贡献代码是确保成功140 考虑这样做),那么您显然对这个平台的持续成功感兴趣;贡献代码是确保成功的
133 的最好方法之一。141 最好方法之一。
134 142
135上述所有理由都适用于任何树外内核代码,包括以专有的、仅二进制形式分发的代码。143上述所有理由都适用于任何树外内核代码,包括以专有的、仅二进制形式分发的代码。
136然而,在考虑任何类型的纯二进制内核代码分布之前,还需要考虑其他因素。这些包括:144然而,在考虑任何类型的纯二进制内核代码分布之前,还需要考虑其他因素。包括:
137 145
138- 围绕专有内核模块分发的法律问题充其量是模糊的;相当多的内核版权所有者认为,146- 围绕专有内核模块分发的法律问题其实较为模糊;相当多的内核版权所有者认为,
139 大多数仅限二进制的模块是内核的派生产品,因此,它们的分发违反了GNU通用公共147 大多数仅二进制的模块是内核的派生产品,因此,它们的分发违反了GNU通用公共
140 许可证(下面将详细介绍)。您的作者不是律师,本文档中的任何内容都不可能被148 许可证(下面将详细介绍)。本文作者不是律师,本文档中的任何内容都不可能被
141 视为法律建议。封闭源代码模块的真实法律地位只能由法院决定。但不管怎样,困扰149 视为法律建议。封闭源代码模块的真实法律地位只能由法院决定。但不管怎样,困扰
142 这些模块的不确定性仍然存在。150 这些模块的不确定性仍然存在。
143 151
144- 二进制模块大大增加了调试内核问题的难度,以至于大多数内核开发人员甚至都不会152- 二进制模块大大增加了调试内核问题的难度,以至于大多数内核开发人员甚至都不会
145 尝试。因此,只分发二进制模块将使您的用户更难从社区获得支持。153 尝试。因此,只分发二进制模块将使您的用户更难从社区获得支持。
146 154
147- 对于只支持二进制的模块的发行者来说,支持也更加困难,他们必须为他们希望支持155- 对于仅二进制的模块的发行者来说,支持也更加困难,他们必须为他们希望支持的
148 的每个发行版和每个内核版本提供一个版本的模块。为了提供相当全面的覆盖范围,156 每个发行版和每个内核版本提供不同版本的模块。为了提供较为全面的覆盖范围,
149 可能需要一个模块的几十个构建,并且每次升级内核时,您的用户都必须单独升级157 可能需要一个模块的几十个构建,并且每次升级内核时,您的用户都必须单独升级
150 您的模块。158 这些模块。
151 159
152- 上面提到的关于代码评审的所有问题都更加存在于封闭源代码。由于该代码根本不可160- 上面提到的关于代码评审的所有问题都更加存在于封闭源代码中。由于该代码根本
153 用,因此社区无法对其进行审查,毫无疑问,它将存在严重问题。161 不可得,因此社区无法对其进行审查,毫无疑问,它将存在严重问题。
154 162
155尤其是嵌入式系统的制造商,可能会倾向于忽视本节中所说的大部分内容,因为他们163尤其是嵌入式系统的制造商,可能会倾向于忽视本节中所说的大部分内容;因为他们
156相信自己正在商用一种使用冻结内核版本的独立产品,在发布后不需要再进行开发。164相信自己正在商用一种使用冻结内核版本的独立产品,在发布后不需要再进行开发。
157这个论点忽略了广泛的代码审查的价值以及允许用户向产品添加功能的价值。但这些165这个论点忽略了广泛的代码审查的价值以及允许用户向产品添加功能的价值。但这些
158产品也有有限的商业寿命,之后必须发布新版本的产品。在这一点上,代码在主线上166产品的商业寿命有限,之后必须发布新版本的产品。在这一点上,代码在主线上并得到
159并得到良好维护的供应商将能够更好地占位,以使新产品快速上市。167良好维护的供应商将能够更好地占位,以使新产品快速上市。
160 168
161许可169许可
162----170----
@@ -164,23 +172,24 @@ Andrew Morton, Andrew Price, Tsugikazu Shibata, 和 Jochen Voß. · 1 unmodified line
164代码是根据一些许可证提供给Linux内核的,但是所有代码都必须与GNU通用公共许可172代码是根据一些许可证提供给Linux内核的,但是所有代码都必须与GNU通用公共许可
165证(GPLV2)的版本2兼容,该版本是覆盖整个内核分发的许可证。在实践中,这意味173证(GPLV2)的版本2兼容,该版本是覆盖整个内核分发的许可证。在实践中,这意味
166着所有代码贡献都由GPLv2(可选地,语言允许在更高版本的GPL下分发)或3子句BSD174着所有代码贡献都由GPLv2(可选地,语言允许在更高版本的GPL下分发)或3子句BSD
167许可(New BSD License, 译者注)覆盖。任何不包含在兼容许可证中的贡献都不会175许可(New BSD License,译者注)覆盖。任何不包含在兼容许可证中的贡献都不会
168被接受到内核中。176被接受到内核中。
169 177
170贡献给内核的代码不需要(或请求)版权分配。合并到主线内核中的所有代码都保留178贡献给内核的代码不需要(或请求)版权分配。合并到主线内核中的所有代码都保留
171其原始所有权;因此,内核现在拥有数千个所有者。179其原始所有权;因此,内核现在拥有数千个所有者。
172 180
173这种所有权结构的一个暗示是,任何改变内核许可的尝试都注定会失败。很少有实际181这种所有权结构也暗示着,任何改变内核许可的尝试都注定会失败。很少有实际情况
174的场景可以获得所有版权所有者的同意(或者从内核中删除他们的代码)。因此,特182可以获得所有版权所有者的同意(或者从内核中删除他们的代码)。因此,尤其是在
175别是,在可预见的将来,不可能迁移到GPL的版本3。183可预见的将来,许可证不大可能迁移到GPL的版本3。
176 184
177所有贡献给内核的代码都必须是合法的免费软件。因此,不接受匿名(或匿名)贡献185所有贡献给内核的代码都必须是合法的免费软件。因此,不接受匿名(或化名)贡献
178者的代码。所有贡献者都需要在他们的代码上“sign off”,声明代码可以在GPL下与内186者的代码。所有贡献者都需要在他们的代码上“sign off(签发)”,声明代码可以
179核一起分发。无法提供未被其所有者许可为免费软件的代码,或可能为内核造成版权187在GPL下与内核一起分发。无法提供未被其所有者许可为免费软件的代码,或可能为
180相关问题的代码(例如,由缺乏适当保护的反向工程工作派生的代码)不能被接受。188内核造成版权相关问题的代码(例如,由缺乏适当保护的反向工程工作派生的代码)
189不能被接受。
181 190
182有关版权相关问题的问题在Linux开发邮件列表中很常见。这样的问题通常会得到不少191有关版权问题的提问在Linux开发邮件列表中很常见。这样的问题通常会得到不少答案,
183答案,但要记住,回答这些问题的人不是律师,不能提供法律咨询。如果您有关于192但请记住,回答这些问题的人不是律师,不能提供法律咨询。如果您有关于Linux源代码
184Linux源代码的法律问题,那么与了解该领域的律师交流是无法替代的。依靠从技术193的法律问题,没有什么可以代替咨询了解这一领域的律师。依赖从技术邮件列表中获得
185邮件列表中获得的答案是一件冒险的事情。194的答案是一件冒险的事情。
186 195
Documentation/translations/zh_CN/process/2.Process.rst+175−170
@@ -1,17 +1,24 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/2.Process.rst <development_process>`3:Original: :ref:`Documentation/process/2.Process.rst <development_process>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_process:13.. _cn_development_process:
7 14
8开发流程如何工作15开发流程如何进行
9================16================
10 17
1190年代早期的Linux内核开发是一件相当松散的事情,涉及的用户和开发人员相对较1890年代早期的Linux内核开发是一件相当松散的事情,涉及的用户和开发人员相对较少。
12少。由于拥有数以百万计的用户群,并且在一年的时间里有大约2000名开发人员参与19由于拥有数以百万计的用户群,且每年有大约2000名开发人员参与进来,内核因此必须
13进来,内核因此必须发展许多流程来保持开发的顺利进行。要成为流程的有效组成20发展出许多既定流程来保证开发的顺利进行。要参与到流程中来,需要对此流程的进行
14部分,需要对流程的工作方式有一个扎实的理解。21方式有一个扎实的理解。
15 22
16总览23总览
17----24----
@@ -20,112 +27,113 @@ · 2 unmodified lines
20内核版本。最近的发布历史记录如下:27内核版本。最近的发布历史记录如下:
21 28
22 ====== =================29 ====== =================
23 4.11 四月 30, 201730 5.0 2019年3月3日
24 4.12 七月 2, 201731 5.1 2019年5月5日
25 4.13 九月 3, 201732 5.2 2019年7月7日
26 4.14 十一月 12, 201733 5.3 2019年9月15日
27 4.15 一月 28, 201834 5.4 2019年11月24日
28 4.16 四月 1, 201835 5.5 2020年1月6日
29 ====== =================36 ====== =================
30 37
31每4.x版本都是一个主要的内核版本,具有新特性、内部API更改等等。一个典型的4.x38每个5.x版本都是一个主要的内核版本,具有新特性、内部API更改等等。一个典型的5.x
32版本包含大约13000个变更集,变更了几十万行代码。因此,4.x是Linux内核开发的前39版本包含大约13000个变更集,变更了几十万行代码。因此,5.x是Linux内核开发的前
33沿;内核使用滚动开发模型,不断集成重大变化。40沿;内核使用滚动开发模型,不断集成重大变化。
34 41
35对于每个版本的补丁合并,遵循一个相对简单的规则。在每个开发周期的开始,“合并42对于每个版本的补丁合并,遵循一个相对简单的规则。在每个开发周期的开头,“合并
36窗口”被打开。当时,被认为足够稳定(并且被开发社区接受)的代码被合并到主线内43窗口”被打开。这时,被认为足够稳定(并且被开发社区接受)的代码被合并到主线内
37核中。在这段时间内,新开发周期的大部分变更(以及所有主要变更)将以接近每天44核中。在这段时间内,新开发周期的大部分变更(以及所有主要变更)将以接近每天
381000次变更(“补丁”或“变更集”)的速度合并。451000次变更(“补丁”或“变更集”)的速度合并。
39 46
40(顺便说一句,值得注意的是,合并窗口期间集成的更改并不是凭空产生的;它们是47(顺便说一句,值得注意的是,合并窗口期间集成的更改并不是凭空产生的;它们是经
41提前收集、测试和分级的。稍后将详细描述该过程的工作方式)。48提前收集、测试和分级的。稍后将详细描述该过程的工作方式。)
42 49
43合并窗口持续大约两周。在这段时间结束时,LinusTorvalds将声明窗口已关闭,并50合并窗口持续大约两周。在这段时间结束时,LinusTorvalds将声明窗口已关闭,并
44释放第一个“rc”内核。例如,对于目标为4.14的内核,在合并窗口结束时发生的释放51释放第一个“rc”内核。例如,对于目标为5.6的内核,在合并窗口结束时发生的释放
45将被称为4.14-rc1。RC1版本是一个信号,表示合并新特性的时间已经过去,稳定下一52将被称为5.6-rc1。-rc1 版本是一个信号,表示合并新特性的时间已经过去,稳定下一
46个内核的时间已经开始。53个内核的时间已经到来。
47 54
48在接下来的6到10周内,只有修复问题的补丁才应该提交给主线。有时会允许更大的55在接下来的6到10周内,只有修复问题的补丁才应该提交给主线。有时会允许更大的
49更改,但这种情况很少发生;试图在合并窗口外合并新功能的开发人员往往会受到不56更改,但这种情况很少发生;试图在合并窗口外合并新功能的开发人员往往受不到
50友好的接待。一般来说,如果您错过了给定特性的合并窗口,最好的做法是等待下一57友好的接待。一般来说,如果您错过了给定特性的合并窗口,最好的做法是等待下一
51个开发周期。(对于以前不支持的硬件,偶尔会对驱动程序进行例外;如果它们不58个开发周期。(偶尔会对未支持硬件的驱动程序进行例外;如果它们不改变已有代码,
52改变已有代码,则不会导致回归,并且应该可以随时安全地添加)。59则不会导致回归,应该可以随时被安全地加入)。
53 60
54随着修复程序进入主线,补丁速度将随着时间的推移而变慢。Linus大约每周发布一次61随着修复程序进入主线,补丁速度将随着时间的推移而变慢。Linus大约每周发布一次
55新的-rc内核;一个正常的系列将在-rc6和-rc9之间,内核被认为足够稳定并最终发布。62新的-rc内核;在内核被认为足够稳定并最终发布前,一般会达到-rc6到-rc9之间。
56然后,整个过程又重新开始了。63然后,整个过程又重新开始了。
57 64
58例如,这里是4.16的开发周期进行情况(2018年的所有日期):65例如,这里是5.4的开发周期进行情况(2019年):
59 66
60 ============== ==============================67 ============== ==============================
61 一月 28 4.15 稳定版发布68 九月 15 5.3 稳定版发布
62 二月 11 4.16-rc1, 合并窗口关闭69 九月 30 5.4-rc1 合并窗口关闭
63 二月 18 4.16-rc270 十月 6 5.4-rc2
64 二月 25 4.16-rc371 十月 13 5.4-rc3
65 三月 4 4.16-rc472 十月 20 5.4-rc4
66 三月 11 4.16-rc573 十月 27 5.4-rc5
67 三月 18 4.16-rc674 十一月 3 5.4-rc6
68 三月 25 4.16-rc775 十一月 10 5.4-rc7
69 四月 1 4.16 稳定版发布76 十一月 17 5.4-rc8
77 十一月 24 5.4 稳定版发布
70 ============== ==============================78 ============== ==============================
71 79
72开发人员如何决定何时结束开发周期并创建稳定的版本?使用的最重要的指标是以前80开发人员如何决定何时结束开发周期并创建稳定版本?最重要的指标是以前版本的
73版本的回归列表。不欢迎出现任何错误,但是那些破坏了以前能工作的系统的错误被81回归列表。不欢迎出现任何错误,但是那些破坏了以前能工作的系统的错误被认为是
74认为是特别严重的。因此,导致回归的补丁是不受欢迎的,很可能在稳定期内删除。82特别严重的。因此,导致回归的补丁是不受欢迎的,很可能在稳定期内删除。
75 83
76开发人员的目标是在稳定发布之前修复所有已知的回归。在现实世界中,这种完美是84开发人员的目标是在稳定发布之前修复所有已知的回归。在现实世界中,这种完美是
77很难实现的;在这种规模的项目中,变量太多了。有一点,延迟最终版本只会使问题85很难实现的;在这种规模的项目中,变数太多了。需要说明的是,延迟最终版本只会
78变得更糟;等待下一个合并窗口的一堆更改将变大,从而在下次创建更多的回归错误。86使问题变得更糟;等待下一个合并窗口的更改将变多,导致下次出现更多的回归错误。
79因此,大多数4.x内核都有一些已知的回归错误,不过,希望没有一个是严重的。87因此,大多数5.x内核都有一些已知的回归错误,不过,希望没有一个是严重的。
80 88
81一旦一个稳定的版本发布,它正在进行的维护工作就被移交给“稳定团队”,目前由89一旦一个稳定的版本发布,它的持续维护工作就被移交给“稳定团队”,目前由
82Greg Kroah-Hartman组成。稳定团队将使用4.x.y编号方案不定期的发布稳定版本的更90Greg Kroah-Hartman领导。稳定团队将使用5.x.y编号方案不定期地发布稳定版本的
83新。要加入更新版本,补丁程序必须(1)修复一个重要的bug,(2)已经合并到91更新。要合入更新版本,补丁必须(1)修复一个重要的缺陷,且(2)已经合并到
84下一个开发主线中。内核通常会在超过其初始版本的一个以上的开发周期内接收稳定92下一个开发版本主线中。内核通常会在其初始版本后的一个以上的开发周期内收到
85的更新。例如,4.13内核的历史如下93稳定版更新。例如,5.2内核的历史如下(2019年):
86 94
87 ============== ===============================95 ============== ===============================
88 九月 3 4.13 稳定版发布96 七月 7 5.2 稳定版发布
89 九月 13 4.13.197 七月 13 5.2.1
90 九月 20 4.13.298 七月 21 5.2.2
91 九月 27 4.13.399 七月 26 5.2.3
92 十月 5 4.13.4100 七月 28 5.2.4
93 十月 12 4.13.5101 七月 31 5.2.5
94 ... ...102 ... ...
95 十一月 24 4.13.16103 十月 11 5.2.21
96 ============== ===============================104 ============== ===============================
97 105
984.13.16是4.13版本的最终稳定更新。1065.2.21是5.2版本的最终稳定更新。
99 107
100有些内核被指定为“长期”内核;它们将得到更长时间的支持。在本文中,当前的长期108有些内核被指定为“长期”内核;它们将得到更长时间的支持。在本文中,当前的长期
101内核及其维护者是:109内核及其维护者是:
102 110
103 ====== ====================== ==============================111 ====== ================================ ================
104 3.16 Ben Hutchings (长期稳定内核)112 3.16 Ben Hutchings (长期稳定内核)
105 4.1 Sasha Levin113 4.4 Greg Kroah-Hartman & Sasha Levin (长期稳定内核)
106 4.4 Greg Kroah-Hartman (长期稳定内核)114 4.9 Greg Kroah-Hartman & Sasha Levin
107 4.9 Greg Kroah-Hartman115 4.14 Greg Kroah-Hartman & Sasha Levin
108 4.14 Greg Kroah-Hartman116 4.19 Greg Kroah-Hartman & Sasha Levin
109 ====== ====================== ==============================117 5.4 Greg Kroah-Hartman & Sasha Levin
118 ====== ================================ ================
110 119
111为长期支持选择内核纯粹是维护人员有必要和时间来维护该版本的问题。目前还没有120长期支持内核的选择纯粹是维护人员是否有需求和时间来维护该版本的问题。
112为即将发布的任何特定版本提供长期支持的已知计划。121目前还没有为即将发布的任何特定版本提供长期支持的已知计划。
113 122
114补丁的生命周期123补丁的生命周期
115--------------124--------------
116 125
117补丁不会直接从开发人员的键盘进入主线内核。相反,有一个稍微复杂(如果有些非126补丁不会直接从开发人员的键盘进入主线内核。相反,有一个稍微复杂(如果有些非
118正式)的过程,旨在确保对每个补丁进行质量审查,并确保每个补丁实现了一个在主线127正式)的过程,旨在确保对每个补丁进行质量审查,并确保每个补丁实现了一个在主线
119中需要的更改。对于小的修复,这个过程可能会很快发生,或者,在大的和有争议的128中需要的更改。对于小的修复,这个过程可能会很快完成,,而对于较大或有争议的
120变更的情况下,会持续数年。许多开发人员的挫折来自于对这个过程缺乏理解或者129变更,可能会持续数年。许多开发人员的沮丧来自于对这个过程缺乏理解或者试图绕过它。
121试图绕过它。
122 130
123为了减少这种挫折感,本文将描述补丁如何进入内核。下面是一个介绍,它以某种131为了减少这种挫败,本文将描述补丁如何进入内核。下面的介绍以一种较为理想化的
124理想化的方式描述了这个过程。更详细的过程将在后面的章节中介绍。132方式描述了这个过程。更详细的过程将在后面的章节中介绍。
125 133
126补丁程序经历的阶段通常是:134补丁通常要经历以下阶段:
127 135
128- 设计。这就是补丁的真正需求——以及满足这些需求的方式——的所在。设计工作通常136- 设计。这就是补丁的真正需求——以及满足这些需求的方式——所在。设计工作通常
129 是在不涉及社区的情况下完成的,但是如果可能的话,最好是在公开的情况下完成137 是在不涉及社区的情况下完成的,但是如果可能的话,最好是在公开的情况下完成
130 这项工作;这样可以节省很多稍后再重新设计的时间。138 这项工作;这样可以节省很多稍后再重新设计的时间。
131 139
@@ -134,53 +142,51 @@ Greg Kroah-Hartman组成。稳定团队将使用4.x.y编号方案不定期的发 · 2 unmodified lines
134 142
135- 更广泛的评审。当补丁接近准备好纳入主线时,它应该被相关的子系统维护人员143- 更广泛的评审。当补丁接近准备好纳入主线时,它应该被相关的子系统维护人员
136 接受——尽管这种接受并不能保证补丁会一直延伸到主线。补丁将出现在维护人员的144 接受——尽管这种接受并不能保证补丁会一直延伸到主线。补丁将出现在维护人员的
137 子系统树中,并进入 -next 树(如下所述)。当流程工作时,此步骤将导致对补丁145 子系统树中,并进入 -next 树(如下所述)。当流程进行时,此步骤将会对补丁
138 进行更广泛的审查,并发现由于将此补丁与其他人所做的工作集成而导致的任何146 进行更广泛的审查,并发现由于将此补丁与其他人所做的工作合并而导致的任何
139 问题。147 问题。
140 148
141- 请注意,大多数维护人员也有日常工作,因此合并补丁可能不是他们的最高优先级。149- 请注意,大多数维护人员也有日常工作,因此合并补丁可能不是他们的最优先工作。
142 如果您的补丁程序得到了关于所需更改的反馈,那么您应该进行这些更改,或者为150 如果您的补丁得到了需要更改的反馈,那么您应该进行这些更改,或者解释为何
143 不应该进行这些更改的原因辩护。如果您的补丁没有评审意见,但没有被其相应的151 不应该进行这些更改。如果您的补丁没有评审意见,也没有被其相应的子系统或
144 子系统或驱动程序维护者接受,那么您应该坚持不懈地将补丁更新到当前内核,使152 驱动程序维护者接受,那么您应该坚持不懈地将补丁更新到当前内核使其可被正常
145 其干净地应用,并不断地将其发送以供审查和合并。153 应用,并不断地发送它以供审查和合并。
146 154
147- 合并到主线。最终,一个成功的补丁将被合并到由LinusTorvalds管理的主线存储库155- 合并到主线。最终,一个成功的补丁将被合并到由LinusTorvalds管理的主线存储库
148 中。此时可能会出现更多的评论和/或问题;开发人员应对这些问题并解决出现的156 中。此时可能会出现更多的评论和/或问题;对开发人员来说应对这些问题并解决
149 任何问题很重要。157 出现的任何问题仍很重要。
150 158
151- 稳定版发布。可能受补丁影响的用户数量现在很大,因此可能再次出现新的问题。159- 稳定版发布。大量用户可能受此补丁影响,因此可能再次出现新的问题。
152 160
153- 长期维护。虽然开发人员在合并代码后可能会忘记代码,但这种行为往往会给开发161- 长期维护。虽然开发人员在合并代码后可能会忘记代码,但这种行为往往会给开发
154 社区留下不良印象。合并代码消除了一些维护负担,因为其他代码将修复由API162 社区留下不良印象。合并代码消除了一些维护负担,因为其他人将修复由API更改
155 更改引起的问题。但是,如果代码要长期保持有用,原始开发人员应该继续为163 引起的问题。但是,如果代码要长期保持可用,原始开发人员应该继续为代码负责。
156 代码负责。
157 164
158内核开发人员(或他们的雇主)犯的最大错误之一是试图将流程简化为一个165内核开发人员(或他们的雇主)犯的最大错误之一是试图将流程简化为一个“合并到
159“合并到主线”步骤。这种方法总是会让所有相关人员感到沮丧。166主线”步骤。这种方法总是会让所有相关人员感到沮丧。
160 167
161补丁如何进入内核168补丁如何进入内核
162----------------169----------------
163 170
164只有一个人可以将补丁合并到主线内核存储库中:LinusTorvalds。但是,在进入171只有一个人可以将补丁合并到主线内核存储库中:LinusTorvalds。但是,在进入
1652.6.38内核的9500多个补丁中,只有112个(大约1.3%)是由Linus自己直接选择的。1722.6.38内核的9500多个补丁中,只有112个(大约1.3%)是由Linus自己直接选择的。
166内核项目已经发展到一个规模,没有一个开发人员可以在没有支持的情况下检查和173内核项目已经发展到一个没有一个开发人员可以在没有支持的情况下检查和选择每个
167选择每个补丁。内核开发人员处理这种增长的方式是通过使用围绕信任链构建的174补丁的规模。内核开发人员处理这种增长的方式是使用围绕信任链构建的助理系统。
168助理系统。
169 175
170内核代码库在逻辑上被分解为一组子系统:网络、特定的体系结构支持、内存管理、176内核代码库在逻辑上被分解为一组子系统:网络、特定体系结构支持、内存管理、视
171视频设备等。大多数子系统都有一个指定的维护人员,开发人员对该子系统中的代码177频设备等。大多数子系统都有一个指定的维护人员,其总体负责该子系统中的代码。
172负有全部责任。这些子系统维护者(松散地)是他们所管理的内核部分的守护者;178这些子系统维护者(松散地)是他们所管理的内核部分的“守门员”;他们(通常)
173他们(通常)会接受一个补丁以包含到主线内核中。179会接受一个补丁以包含到主线内核中。
174 180
175子系统维护人员每个人都使用git源代码管理工具管理自己版本的内核源代码树。Git181子系统维护人员每个人都管理着自己版本的内核源代码树,通常(并非总是)使用Git。
176等工具(以及Quilt或Mercurial等相关工具)允许维护人员跟踪补丁列表,包括作者182Git等工具(以及Quilt或Mercurial等相关工具)允许维护人员跟踪补丁列表,包括作者
177信息和其他元数据。在任何给定的时间,维护人员都可以确定他或她的存储库中的哪183信息和其他元数据。在任何给定的时间,维护人员都可以确定他或她的存储库中的哪
178些补丁在主线中找不到。184些补丁在主线中找不到。
179 185
180当合并窗口打开时,顶级维护人员将要求Linus从其存储库中“拉出”他们为合并选择186当合并窗口打开时,顶级维护人员将要求Linus从存储库中“拉出”他们为合并选择
181的补丁。如果Linus同意,补丁流将流向他的存储库,成为主线内核的一部分。187的补丁。如果Linus同意,补丁流将流向他的存储库,成为主线内核的一部分。
182Linus对拉操作中接收到的特定补丁的关注程度各不相同。很明显,有时他看起来很188Linus对拉取中接收到的特定补丁的关注程度各不相同。很明显,有时他看起来很
183关注。但是,作为一般规则,Linus相信子系统维护人员不会向上游发送坏补丁。189关注。但是一般来说,Linus相信子系统维护人员不会向上游发送坏补丁。
184 190
185子系统维护人员反过来也可以从其他维护人员那里获取补丁。例如,网络树是由首先191子系统维护人员反过来也可以从其他维护人员那里获取补丁。例如,网络树是由首先
186在专用于网络设备驱动程序、无线网络等的树中积累的补丁构建的。此存储链可以192在专用于网络设备驱动程序、无线网络等的树中积累的补丁构建的。此存储链可以
@@ -195,26 +201,26 @@ Next 树 · 8 unmodified lines
195 201
196子系统树链引导补丁流到内核,但它也提出了一个有趣的问题:如果有人想查看为202子系统树链引导补丁流到内核,但它也提出了一个有趣的问题:如果有人想查看为
197下一个合并窗口准备的所有补丁怎么办?开发人员将感兴趣的是,还有什么其他的203下一个合并窗口准备的所有补丁怎么办?开发人员将感兴趣的是,还有什么其他的
198更改有待解决,以查看是否存在需要担心的冲突;例如,更改核心内核函数原型的204更改有待解决,以了解是否存在需要担心的冲突;例如,更改核心内核函数原型的
199修补程序将与使用该函数旧形式的任何其他修补程序冲突。审查人员和测试人员希望205修补程序将与使用该函数旧形式的任何其他修补程序冲突。审查人员和测试人员希望
200在所有这些变更到达主线内核之前,能够访问它们的集成形式中的变更。您可以从所有206在所有这些变更到达主线内核之前,能够访问它们的集成形式的变更。您可以从所有
201有趣的子系统树中提取更改,但这将是一项大型且容易出错的工作。207相关的子系统树中提取更改,但这将是一项复杂且容易出错的工作。
202 208
203答案以-next树的形式出现,在这里子系统树被收集以供测试和审查。Andrew Morton209解决方案以-next树的形式出现,在这里子系统树被收集以供测试和审查。这些树中
204维护的这些旧树被称为“-mm”(用于内存管理,这就是它的启动名字)。-mm 树集成了210由Andrew Morton维护的较老的一个,被称为“-mm”(用于内存管理,创建时为此)。
205一长串子系统树中的补丁;它还包含一些旨在帮助调试的补丁。211-mm 树集成了一长串子系统树中的补丁;它还包含一些旨在帮助调试的补丁。
206 212
207除此之外,-mm 还包含大量由Andrew直接选择的补丁。这些补丁可能已经发布在邮件213除此之外,-mm 还包含大量由Andrew直接选择的补丁。这些补丁可能已经发布在邮件
208列表上,或者它们可能应用于内核中没有指定子系统树的部分。结果,-mm 作为一种214列表上,或者它们可能应用于内核中未指定子系统树的部分。同时,-mm 作为最后
209最后手段的子系统树运行;如果没有其他明显的路径可以让补丁进入主线,那么它很215手段的子系统树;如果没有其他明显的路径可以让补丁进入主线,那么它很可能最
210可能以-mm 结束。累积在-mm 中的各种补丁最终将被转发到适当的子系统树,或者直接216终选择-mm 树。累积在-mm 中的各种补丁最终将被转发到适当的子系统树,或者直接
211发送到Linus。在典型的开发周期中,大约5-10%的补丁通过-mm 进入主线。217发送到Linus。在典型的开发周期中,大约5-10%的补丁通过-mm 进入主线。
212 218
213当前-mm 补丁可在“mmotm”(-mm of the moment)目录中找到,地址:219当前-mm 补丁可在“mmotm”(-mm of the moment)目录中找到:
214 220
215 https://www.ozlabs.org/~akpm/mmotm/221 https://www.ozlabs.org/~akpm/mmotm/
216 222
217然而,使用mmotm树可能是一种令人沮丧的体验;它甚至可能无法编译。223然而,使用MMOTM树可能会十分令人头疼;它甚至可能无法编译。
218 224
219下一个周期补丁合并的主要树是linux-next,由Stephen Rothwell 维护。根据设计225下一个周期补丁合并的主要树是linux-next,由Stephen Rothwell 维护。根据设计
220linux-next 是下一个合并窗口关闭后主线的快照。linux-next树在Linux-kernel 和226linux-next 是下一个合并窗口关闭后主线的快照。linux-next树在Linux-kernel 和
@@ -228,49 +234,48 @@ Linux-next 已经成为内核开发过程中不可或缺的一部分;在一个 · 7 unmodified lines
228Staging 树234Staging 树
229----------235----------
230 236
231内核源代码树包含drivers/staging/directory,其中有许多驱动程序或文件系统的237内核源代码树包含drivers/staging/目录,其中有许多驱动程序或文件系统的子目录
232子目录正在被添加到内核树中。它们然需要更多的工作的时候可以保留在238正在被添加到内核树中。它们在仍然需要更多的修正的时候可以保留在driver/staging/
233driver/staging目录中;一旦完成,就可以将它们移到内核中。这是一种跟踪不符合239目录中;一旦完成,就可以将它们移到内核中。这是一种跟踪不符合Linux内核编码或
234Linux内核编码或质量标准的驱动程序的方法,但人们可能希望使用它们并跟踪开发。240质量标准的驱动程序的方法,人们可能希望使用它们并跟踪开发。
235 241
236Greg Kroah Hartman 目前负责维护staging 树。仍需要工作的驱动程序将发送给他,242Greg Kroah Hartman 目前负责维护staging 树。仍需要修正的驱动程序将发送给他,
237每个驱动程序在drivers/staging/中都有自己的子目录。除了驱动程序源文件之外,243每个驱动程序在drivers/staging/中都有自己的子目录。除了驱动程序源文件之外,
238目录中还应该有一个TODO文件。todo文件列出了驱动程序需要接受的挂起的工作,244目录中还应该有一个TODO文件。TODO文件列出了驱动程序需要接受的暂停的工作,
239以及驱动程序的任何补丁都应该抄送的人员列表。当前的规则要求,staging的驱动245以及驱动程序的任何补丁都应该抄送的人员列表。当前的规则要求,staging的驱动
240程序必须至少正确编译。246程序必须至少正确编译。
241 247
242Staging 是一种相对容易的方法,可以让新的驱动程序进入主线,幸运的是,他们会248Staging 是一种让新的驱动程序进入主线的相对容易的方法,它们会幸运地引起其他
243引起其他开发人员的注意,并迅速改进。然而,进入staging并不是故事的结尾;249开发人员的注意,并迅速改进。然而,进入staging并不是故事的结尾;staging中
244staging中没有看到常规进展的代码最终将被删除。经销商也倾向于相对不愿意使用250没有看到常规进展的代码最终将被删除。经销商也倾向于相对不愿意使用staging驱动
245staging驱动程序。因此,在成为一名合适的主线驱动的路上,staging 充其量只是251程序。因此,在成为一个合适的主线驱动的路上,staging 仅是一个中转站。
246一个停留。
247 252
248工具253工具
249----254----
250 255
251从上面的文本可以看出,内核开发过程在很大程度上依赖于在不同方向上聚集补丁的256从上面的文本可以看出,内核开发过程在很大程度上依赖于在不同方向上聚集补丁的
252能力。如果没有适当强大的工具,整个系统将无法在任何地方正常工作。关于如何使用257能力。如果没有适当强大的工具,整个系统将无法在任何地方正常工作。关于如何使用
253这些工具的教程远远超出了本文档的范围,但是还是有一些指南的空间。258这些工具的教程远远超出了本文档的范围,但还是用一点篇幅介绍一些关键点。
254 259
255到目前为止,内核社区使用的主要源代码管理系统是git。Git是在自由软件社区中开发260到目前为止,内核社区使用的主要源代码管理系统是git。Git是在自由软件社区中开发
256的许多分布式版本控制系统之一。它非常适合内核开发,因为它在处理大型存储库和261的许多分布式版本控制系统之一。它非常适合内核开发,因为它在处理大型存储库和
257大量补丁时性能非常好。它还有一个难以学习和使用的名声,尽管随着时间的推移它262大量补丁时性能非常好。它也以难以学习和使用而著称,尽管随着时间的推移它变得
258变得更好了。对于内核开发人员来说,对Git的某种熟悉几乎是一种要求;即使他们不263更好了。对于内核开发人员来说,对Git的某种熟悉几乎是一种要求;即使他们不将它
259将它用于自己的工作,他们也需要Git来跟上其他开发人员(以及主线)正在做的事情。264用于自己的工作,他们也需要Git来跟上其他开发人员(以及主线)正在做的事情。
260 265
261现在几乎所有的Linux发行版都打包了Git。主页位于:266现在几乎所有的Linux发行版都打包了Git。Git主页位于:
262 267
263 https://git-scm.com/268 https://git-scm.com/
264 269
265那个页面有指向文档和教程的指针。270此页面包含了文档和教程的链接。
266 271
267在不使用git的内核开发人员中,最流行的选择几乎肯定是mercurial:272在不使用git的内核开发人员中,最流行的选择几乎肯定是Mercurial:
268 273
269 http://www.seleric.com/mercurial/274 http://www.seleric.com/mercurial/
270 275
271Mercurial与Git共享许多特性,但它提供了一个界面,许多人觉得它更易于使用。276Mercurial与Git共享许多特性,但它提供了一个界面,许多人觉得它更易于使用。
272 277
273另一个值得了解的工具是quilt:278另一个值得了解的工具是Quilt:
274 279
275 https://savannah.nongnu.org/projects/quilt280 https://savannah.nongnu.org/projects/quilt
276 281
@@ -282,79 +287,79 @@ Quilt 是一个补丁管理系统,而不是源代码管理系统。它不会 · 5 unmodified lines
282邮件列表287邮件列表
283--------288--------
284 289
285大量的Linux内核开发工作是通过邮件列表完成的。如果不在某个地方加入至少一个列表,290大量的Linux内核开发工作是通过邮件列表完成的。如果不加入至少一个某个列表,
286就很难成为社区中一个功能完备的成员。但是,Linux邮件列表对开发人员来说也是一个291就很难成为社区中的一个“全功能”成员。但是,Linux邮件列表对开发人员来说也是
287潜在的危险,他们可能会被一堆电子邮件淹没,违反Linux列表上使用的约定,或者292一个潜在的危险,他们可能会被一堆电子邮件淹没、违反Linux列表上使用的约定,
288两者兼而有之。293或者两者兼而有之。
289 294
290大多数内核邮件列表都在vger.kernel.org上运行;主列表位于:295大多数内核邮件列表都在vger.kernel.org上运行;主列表位于:
291 296
292 http://vger.kernel.org/vger-lists.html297 http://vger.kernel.org/vger-lists.html
293 298
294不过,也有一些列表托管在别处;其中一些列表位于lists.redhat.com。299不过,也有一些列表托管在别处;其中一些列表位于
300redhat.com/mailman/listinfo。
295 301
296当然,内核开发的核心邮件列表是linux-kernel。这个名单是一个令人生畏的地方;302当然,内核开发的核心邮件列表是linux-kernel。这个列表是一个令人生畏的地方:
297每天的信息量可以达到500条,噪音很高,谈话技术性很强,参与者并不总是表现出303每天的信息量可以达到500条,噪音很高,谈话技术性很强,且参与者并不总是表现出
298高度的礼貌。但是,没有其他地方可以让内核开发社区作为一个整体聚集在一起;304高度的礼貌。但是,没有其他地方可以让内核开发社区作为一个整体聚集在一起;
299避免使用此列表的开发人员将错过重要信息。305不使用此列表的开发人员将错过重要信息。
300 306
301有一些提示可以帮助在linux-kernel生存:307以下一些提示可以帮助在linux-kernel生存:
302 308
303- 将邮件转移到单独的文件夹,而不是主邮箱。我们必须能够持续地忽略洪流。309- 将邮件转移到单独的文件夹,而不是主邮箱文件夹。我们必须能够持续地忽略洪流。
304 310
305- 不要试图跟踪每一次谈话-其他人都不会。重要的是要对感兴趣的主题(尽管请311- 不要试图跟上每一次谈话——没人会这样。重要的是要筛选感兴趣的主题(但请注意
306 注意,长时间的对话可以在不更改电子邮件主题行的情况下偏离原始主题)和参与312 长时间的对话可能会偏离原来的主题,尽管未改变电子邮件的主题)和参与的人。
307 的人进行筛选。
308 313
309- 不要挑事。如果有人试图激起愤怒的反应,忽略他们。314- 不要回复挑事的人。如果有人试图激起愤怒,请忽略他们。
310 315
311- 当响应Linux内核电子邮件(或其他列表上的电子邮件)时,请为所有相关人员保留316- 当回复Linux内核电子邮件(或其他列表上的电子邮件)时,请为所有相关人员保留
312 cc:header。如果没有强有力的理由(如明确的请求),则不应删除收件人。一定要317 Cc: 抄送头。如果没有确实的理由(如明确的请求),则不应删除收件人。一定要
313 确保你要回复的人在cc:list中。这个惯例也使你不必在回复邮件时明确要求被抄送。318 确保你要回复的人在抄送列表中。这个惯例也使你不必在回复邮件时明确要求被抄送。
314 319
315- 在提出问题之前,搜索列表档案(和整个网络)。有些开发人员可能会对那些显然320- 在提出问题之前,搜索列表存档(和整个网络)。有些开发人员可能会对那些显然
316 没有完成家庭作业的人感到不耐烦。321 没有完成家庭作业的人感到不耐烦。
317 322
318- 避免贴顶帖(把你的答案放在你要回复的引文上面的做法)。这会让你的回答更难323- 避免顶部回复(把你的答案放在你要回复的引文上面的做法)。这会让你的回答更难
319 理解,印象也很差。324 理解,印象也很差。
320 325
321- 询问正确的邮件列表。linux-kernel 可能是通用的讨论点,但它不是从所有子系统326- 在正确的邮件列表发问。linux-kernel 可能是通用的讨论场所,但它不是寻找所有
322 中寻找开发人员的最佳场所。327 子系统开发人员的最佳场所。
323 328
324最后一点——找到正确的邮件列表——是开发人员出错的常见地方。在Linux内核上提出与329最后一点——找到正确的邮件列表——是开发人员常出错的地方。在linux-kernel上
325网络相关的问题的人几乎肯定会收到一个礼貌的建议,转而在netdev列表上提出,330提出与网络相关的问题的人几乎肯定会收到一个礼貌的建议,转到netdev列表上提出,
326因为这是大多数网络开发人员经常出现的列表。还有其他列表可用于scsi、331因为这是大多数网络开发人员经常出现的列表。还有其他列表可用于scsi、video4linux、
327video4linux、ide、filesystem等子系统。查找邮件列表的最佳位置是与内核源代码332ide、filesystem等子系统。查找邮件列表的最佳位置是与内核源代码一起打包的
328一起打包的MAINTAINERS文件。333MAINTAINERS文件。
329 334
330开始内核开发335开始内核开发
331------------336------------
332 337
333关于如何开始内核开发过程的问题很常见——来自个人和公司。同样常见的是错误,这338关于如何开始内核开发过程的问题很常见——个人和公司皆然。同样常见的是失误,这
334使得关系的开始比必须的更困难。339使得关系的开始比本应的更困难。
335 340
336公司通常希望聘请知名的开发人员来启动开发团队。实际上,这是一种有效的技术。341公司通常希望聘请知名的开发人员来启动开发团队。实际上,这是一种有效的技术。
337但它也往往是昂贵的,而且没有增长经验丰富的内核开发人员储备。考虑到时间的342但它也往往是昂贵的,而且对增加有经验的内核开发人员的数量没有多大帮助。考
338投入,可以让内部开发人员加快Linux内核的开发速度。花这个时间可以让雇主拥有343虑到时间投入,可以让内部开发人员加快Linux内核的开发速度。利用这段时间可以
339一批了解内核和公司的开发人员,他们也可以帮助培训其他人。从中期来看,这往往344让雇主拥有一批既了解内核又了解公司的开发人员,还可以帮助培训其他人。从中期
340是更有利可图的方法。345来看,这通常是更有利可图的方法。
341 346
342可以理解的是,单个开发人员往往对起步感到茫然。从一个大型项目开始可能会很347可以理解的是,单个开发人员往往对起步感到茫然。从一个大型项目开始可能会很
343吓人;人们往往想先用一些较小的东西来测试水域。这是一些开发人员开始创建修补348吓人;人们往往想先用一些较小的东西来试试水。由此,一些开发人员开始创建修补
344拼写错误或轻微编码风格问题的补丁的地方。不幸的是,这样的补丁会产生一定程度349拼写错误或轻微编码风格问题的补丁。不幸的是,这样的补丁会产生一定程度的噪音,
345的噪音,这会分散整个开发社区的注意力,因此,越来越多的人看不起它们。希望向350这会分散整个开发社区的注意力,因此,它们越来越被人不看重。希望向社区介绍
346社区介绍自己的新开发人员将无法通过这些方式获得他们想要的那种接待。351自己的新开发人员将无法通过这些方式获得他们期待的反响。
347 352
348Andrew Morton 为有抱负的内核开发人员提供了这个建议353Andrew Morton 为有抱负的内核开发人员提供了如下建议
349 354
350::355::
351 356
352 所有内核初学者的No.1项目肯定是“确保内核在所有的机器上,你可以触摸357 所有内核开发者的第一个项目肯定应该是“确保内核在您可以操作的所有
353 到的,始终运行良好" 通常这样做的方法是与其他人一起解决问题(这358 机器上始终完美运行”。通常的方法是和其他人一起解决问题(这可能需
354 可能需要坚持!)但这很好——这是内核开发的一部分359 要坚持!),但就是如此——这是内核开发的一部分。
355 360
356(http://lwn.net/articles/283982/)361(http://lwn.net/articles/283982/)
357 362
358在没有明显问题需要解决的情况下,建议开发人员查看当前的回归和开放式错误列表.363在没有明显问题需要解决的情况下,通常建议开发人员查看当前的回归和开放缺陷
359解决需要修复的问题没有任何缺点;通过解决这些问题,开发人员将获得处理过程的364列表。从来都不缺少需要解决的问题;通过解决这些问题,开发人员将从该过程获得
360经验,同时与开发社区的其他人建立尊重。365经验,同时与开发社区的其他成员建立相互尊重。
Documentation/translations/zh_CN/process/3.Early-stage.rst+73−66
@@ -1,7 +1,14 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/3.Early-stage.rst <development_early_stage>`3:Original: :ref:`Documentation/process/3.Early-stage.rst <development_early_stage>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_early_stage:13.. _cn_development_early_stage:
7 14
@@ -9,45 +16,45 @@ · 1 unmodified line
9========16========
10 17
11当考虑一个Linux内核开发项目时,很可能会直接跳进去开始编码。然而,与任何重要18当考虑一个Linux内核开发项目时,很可能会直接跳进去开始编码。然而,与任何重要
12的项目一样,成功的许多基础最好是在第一行代码编写之前就做好了。在早期计划和19的项目一样,许多成功的基础最好是在第一行代码编写之前就打下。在早期计划和
13沟通中花费一些时间可以节省更多的时间。20沟通中花费一些时间可以在之后节省更多的时间。
14 21
15详述问题22搞清问题
16--------23--------
17 24
18与任何工程项目一样,成功的内核增强从要解决的问题的清晰描述开始。在某些情况25与任何工程项目一样,成功的内核改善从清晰描述要解决的问题开始。在某些情况
19下,这个步骤很容易:例如,当某个特定硬件需要驱动程序时。不过,在其他方面,26下,这个步骤很容易:例如当某个特定硬件需要驱动程序时。不过,在其他情况下,
20将实际问题与建议的解决方案混淆是很有诱惑力的,这可能会导致困难。27很容易将实际问题与建议的解决方案混在一起,这可能会导致麻烦。
21 28
22举个例子:几年前,使用Linux音频的开发人员寻求一种方法来运行应用程序,而不因29举个例子:几年前,Linux音频的开发人员寻求一种方法来运行应用程序,而不会因
23系统延迟过大而导致退出或其他工件。他们得到的解决方案是一个内核模块,旨在连30系统延迟过大而导致退出或其他问题。他们得到的解决方案是一个连接到Linux安全
24接到Linux安全模块(LSM)框架中;这个模块可以配置为允许特定的应用程序访问31模块(LSM)框架中的内核模块;这个模块可以配置为允许特定的应用程序访问实时
25实时调度程序。这个模块被实现并发送到Linux内核邮件列表,在那里它立即遇到问题。32调度程序。这个模块被实现并发到linux-kernel邮件列表,在那里它立即遇到了麻烦。
26 33
27对于音频开发人员来说,这个安全模块足以解决他们当前的问题。但是,对于更广泛的34对于音频开发人员来说,这个安全模块足以解决他们当前的问题。但是,对于更广泛的
28内核社区来说,这被视为对LSM框架的滥用(LSM框架并不打算授予他们原本不具备的35内核社区来说,这被视为对LSM框架的滥用(LSM框架并不打算授予他们原本不具备的
29进程特权),并对系统稳定性造成风险。他们首选的解决方案包括短期的通过rlimit36进程特权),并对系统稳定性造成风险。他们首选的解决方案包括短期的通过rlimit
30机制进行实时调度访问,以及长期的减少延迟的工作。37机制进行实时调度访问,以及长期的减少延迟的工作。
31 38
32然而,音频社区看不到他们实施的特定解决方案的过去;他们不愿意接受替代方案。39然而,音频社区无法超越他们实施的特定解决方案来看问题;他们不愿意接受替代方案。
33由此产生的分歧使这些开发人员对整个内核开发过程感到失望;其中一个开发人员返回40由此产生的分歧使这些开发人员对整个内核开发过程感到失望;其中一个开发人员返回
34到音频列表并发布了以下内容:41到audio列表并发布了以下内容:
35 42
36 有很多非常好的Linux内核开发人员,但他们往往会被一群傲慢的傻瓜所压倒。43 有很多非常好的Linux内核开发人员,但他们往往会被一群傲慢的傻瓜所压倒。
37 试图向这些人传达用户需求是浪费时间。他们太“聪明”了,根本听不到少数人44 试图向这些人传达用户需求是浪费时间。他们太“聪明”了,根本听不到少数
38 的话。45 人的话。
39 46
40(http://lwn.net/articles/131776/)47(http://lwn.net/articles/131776/)
41 48
42实际情况不同;与特定模块相比,内核开发人员更关心系统稳定性、长期维护以及找到49实际情况却是不同的;与特定模块相比,内核开发人员更关心系统稳定性、长期维护
43正确的问题解决方案。这个故事的寓意是把重点放在问题上——而不是具体的解决方案50以及找到问题的正确解决方案。这个故事的寓意是把重点放在问题上——而不是具体的
44上——并在投入创建代码之前与开发社区讨论这个问题。51解决方案上——并在开始编写代码之前与开发社区讨论这个问题。
45 52
46因此,在考虑一个内核开发项目时,我们应该得到一组简短问题的答案:53因此,在考虑一个内核开发项目时,我们应该得到一组简短问题的答案:
47 54
48 - 究竟需要解决的问题是什么?55 - 需要解决的问题究竟是什么?
49 56
50 - 受此问题影响的用户是谁?解决方案应该解决哪些用例?57 - 受此问题影响的用户有哪些?解决方案应该解决哪些使用案例?
51 58
52 - 内核现在为何没能解决这个问题?59 - 内核现在为何没能解决这个问题?
53 60
@@ -62,100 +69,100 @@ · 8 unmodified lines
62 69
63 - 很可能问题是由内核以您不理解的方式解决的。Linux内核很大,具有许多不明显70 - 很可能问题是由内核以您不理解的方式解决的。Linux内核很大,具有许多不明显
64 的特性和功能。并不是所有的内核功能都像人们所希望的那样有文档记录,而且很71 的特性和功能。并不是所有的内核功能都像人们所希望的那样有文档记录,而且很
65 容易遗漏一些东西。你的作者发出了一个完整的驱动程序,复制了一个新作者不72 容易遗漏一些东西。某作者发布了一个完整的驱动程序,重复了一个其不
66 知道的现有驱动程序。重新设计现有轮子的代码不仅浪费,而且不会被接受到主线73 知道的现有驱动程序。重新发明现有轮子的代码不仅浪费,而且不会被接受到主线
67 内核中。74 内核中。
68 75
69 - 建议的解决方案中可能有一些元素不适用于主线合并。在编写代码之前,最好先76 - 建议的解决方案中可能有一些要素不适合并入主线。在编写代码之前,最好先了解
70 了解这样的问题。77 这样的问题。
71 78
72 - 其他开发人员完全有可能考虑过这个问题;他们可能有更好的解决方案的想法,并且79 - 其他开发人员完全有可能考虑过这个问题;他们可能有更好的解决方案的想法,并且
73 可能愿意帮助创建这个解决方案。80 可能愿意帮助创建这个解决方案。
74 81
75在内核开发社区的多年经验给了我们一个明确的教训:闭门设计和开发的内核代码总是82在内核开发社区的多年经验给了我们一个明确的教训:闭门设计和开发的内核代码总是
76有一些问题,这些问题只有在代码发布到社区中时才会被发现。有时这些问题很严重,83有一些问题,这些问题只有在代码发布到社区中时才会被发现。有时这些问题很严重,
77需要数月或数年的努力才能使代码达到内核社区的标准。一些例子包括:84需要数月或数年的努力才能使代码达到内核社区的标准。例如:
78 85
79 - 设计并实现了单处理器系统的DeviceScape网络栈。只有使其适合于多处理器系统,86 - 设计并实现了单处理器系统的DeviceScape网络栈。只有使其适合于多处理器系统,
80 才能将其合并到主线中。在代码中改装锁等等是一项困难的任务;因此,这段代码87 才能将其合并到主线中。在代码中修改锁等等是一项困难的任务;因此,这段代码
81 (现在称为mac80211)的合并被推迟了一年多。88 (现在称为mac80211)的合并被推迟了一年多。
82 89
83 - Reiser4文件系统包含许多功能,核心内核开发人员认为这些功能应该在虚拟文件90 - Reiser4文件系统包含许多功能,核心内核开发人员认为这些功能应该在虚拟文件
84 系统层中实现。它还包括一些特性,这些特性在不将系统暴露于用户引起的死锁的91 系统层中实现。它还包括一些特性,这些特性在不将系统暴露于用户引起的死锁的
85 情况下是不容易实现的。这些问题的最新发现——以及对其中一些问题的拒绝——已经92 情况下是不容易实现的。这些问题过迟发现——以及拒绝处理其中一些问题——已经
86 导致Reiser4远离了主线内核。93 导致Reiser4置身主线内核之外。
87 94
88 - Apparmor安全模块以被认为不安全和不可靠的方式使用内部虚拟文件系统数据结构。95 - Apparmor安全模块以被认为不安全和不可靠的方式使用内部虚拟文件系统数据结构。
89 这种担心(包括其他)使Apparmor多年不在主线上。96 这种担心(包括其他)使Apparmor多年来无法进入主线。
90 97
91在每一种情况下,通过与内核开发人员的早期讨论,可以避免大量的痛苦和额外的工作。98在这些情况下,与内核开发人员的早期讨论,可以避免大量的痛苦和额外的工作。
92 99
93找谁交流100找谁交流?
94--------101----------
95 102
96当开发人员决定公开他们的计划时,下一个问题是:我们从哪里开始?答案是找到正确103当开发人员决定公开他们的计划时,下一个问题是:我们从哪里开始?答案是找到正确
97的邮件列表和正确的维护者。对于邮件列表,最好的方法是在维护者(MAINTAINERS)文件104的邮件列表和正确的维护者。对于邮件列表,最好的方法是在维护者(MAINTAINERS)文件
98中查找要发布的相关位置。如果有一个合适的子系统列表,那么发布它通常比在Linux105中查找要发布的相关位置。如果有一个合适的子系统列表,那么其上发布通常比在
99内核上发布更可取;您更有可能接触到在相关子系统中具有专业知识的开发人员,并且106linux-kernel上发布更可取;您更有可能接触到在相关子系统中具有专业知识的开发
100环境可能具支持性。107人员,并且环境可能具支持性。
101 108
102找到维护人员可能会有点困难。同样,维护者文件是开始的地方。但是,该文件往往不总109找到维护人员可能会有点困难。同样,维护者文件是开始的地方。但是,该文件往往不
103是最新的,并且并非所有子系统都在那里表示。实际上,维护者文件中列出的人员可能110是最新的,并且并非所有子系统都在那里显示。实际上,维护者文件中列出的人员可能
104不是当前实际担任该角色的人员。因此,当对联系谁有疑问时,一个有用的技巧是使用111不是当前实际担任该角色的人员。因此,当对联系谁有疑问时,一个有用的技巧是使用
105git(尤其是“git-log”)查看感兴趣的子系统中当前活动的用户。看看谁在写补丁,112git(尤其是“git-log”)查看感兴趣的子系统中当前活动的用户。看看谁在写补丁、
106如果有人的话,谁会在这些补丁上加上用线签名的。这些人将是帮助新开发项目的最佳113谁会在这些补丁上加上Signed-off-by行签名(如有)。这些人将是帮助新开发项目的
107人选。114最佳人选。
108 115
109找到合适的维护者的任务有时是非常具有挑战性的,以至于内核开发人员添加了一个116找到合适的维护者有时是非常具有挑战性的,以至于内核开发人员添加了一个脚本来
110脚本来简化过程:117简化这个过程:
111 118
112::119::
113 120
114 .../scripts/get_maintainer.pl121 .../scripts/get_maintainer.pl
115 122
116当给定“-f”选项时,此脚本将返回给定文件或目录的当前维护者。如果在命令行上传递123当给定“-f”选项时,此脚本将返回指定文件或目录的当前维护者。如果在命令行上
117了一个补丁,它将列出可能接收补丁副本的维护人员。有许多选项可以调节124给出了一个补丁,它将列出可能接收补丁副本的维护人员。有许多选项可以调节
118get_maintainer.pl搜索维护者的难易程度;请小心使用更具攻击性的选项,因为最终125get_maintainer.pl搜索维护者的严格程度;请小心使用更激进的选项,因为最终结果
119可能会包括对您正在修改的代码没有真正兴趣的开发人员。126可能会包括对您正在修改的代码没有真正兴趣的开发人员。
120 127
121如果所有其他方法都失败了,那么与Andrew Morton交谈可以成为一种有效的方法来跟踪128如果所有其他方法都失败了,那么与Andrew Morton交流是跟踪特定代码段维护人员
122特定代码段的维护人员。129的一种有效方法。
123 130
124何时邮寄?131何时邮寄?
125----------132----------
126 133
127如果可能的话,在早期阶段发布你的计划只会有帮助。描述正在解决的问题以及已经134如果可能的话,在早期阶段发布你的计划只会更有帮助。描述正在解决的问题以及已经
128制定的关于如何实施的任何计划。您可以提供的任何信息都可以帮助开发社区为项目135制定的关于如何实施的任何计划。您可以提供的任何信息都可以帮助开发社区为项目
129提供有用的输入。136提供有用的输入。
130 137
131在这个阶段可能发生的一件令人沮丧的事情不是敌对的反应,而是很少或根本没有138在这个阶段可能发生的一件令人沮丧的事情不是得到反对意见,而是很少或根本没有
132反应。可悲的事实是:(1)内核开发人员往往很忙;(2)不缺少有宏伟计划和很少139反馈。令人伤心的事实是:(1)内核开发人员往往很忙;(2)不缺少有宏伟计划但
133代码(甚至代码前景)支持他们的人;(3)没有人有义务审查或评论别人发表的140代码(甚至代码设想)很少的人去支持他们;(3)没有人有义务审查或评论别人发表
134想法。除此之外,高级设计常常隐藏一些问题,这些问题只有在有人真正尝试实现141的想法。除此之外,高层级的设计常常隐藏着一些问题,这些问题只有在有人真正尝试
135这些设计时才会被发现;因此,内核开发人员宁愿看到代码。142实现这些设计时才会被发现;因此,内核开发人员宁愿看到代码。
136 143
137如果发表评论的请求在评论的方式上没有什么效果,不要假设这意味着对项目没有144如果发布请求评论(RFC)并没得到什么有用的评论,不要以为这意味着无人对此项目
138兴趣。不幸的是,你也不能假设你的想法没有问题。在这种情况下,最好的做法是145有兴趣,同时你也不能假设你的想法没有问题。在这种情况下,最好的做法是继续进
139继续进行,把你的进展随时通知社区。146行,把你的进展随时通知社区。
140 147
141获得官方认可148获得官方认可
142-----------------------149-----------------------
143 150
144如果您的工作是在公司环境中完成的,就像大多数Linux内核工作一样,显然,在您将151如果您的工作是在公司环境中完成的,就像大多数Linux内核工作一样;显然,在您将
145公司的计划或代码发布到公共邮件列表之前,必须获得适当授权的经理的许可。发布152公司的计划或代码发布到公共邮件列表之前,必须获得有适当权利经理的许可。发布
146不确定是否兼容GPL的代码可能是有特别问题的;公司的管理层和法律人员越早能够就153不确定是否兼容GPL的代码尤其会带来问题;公司的管理层和法律人员越早能够就发布
147发布内核开发项目达成一致,对参与的每个人都越好。154内核开发项目达成一致,对参与的每个人都越好。
148 155
149一些读者可能会认为他们的核心工作是为了支持还没有正式承认存在的产品。将雇主156一些读者可能会认为他们的核心工作是为了支持还没有正式承认存在的产品。将雇主
150的计划公布在公共邮件列表上可能不是一个可行的选择。在这种情况下,有必要考虑157的计划公布在公共邮件列表上可能不是一个可行的选择。在这种情况下,有必要考虑
151保密是否真的是必要的;通常不需要把开发计划关在门内。158保密是否真的是必要的;通常不需要把开发计划关在门内。
152 159
153也就是说,有些情况下,一家公司在开发过程的早期就不能合法地披露其计划。拥有160的确,有些情况下一家公司在开发过程的早期无法合法地披露其计划。拥有经验丰富
154经验丰富的内核开发人员的公司可以选择以开环的方式进行,前提是他们以后能够避免161的内核开发人员的公司可能选择以开环的方式进行开发,前提是他们以后能够避免
155严重的集成问题。对于没有这种内部专业知识的公司,最好的选择往往是聘请外部162严重的集成问题。对于没有这种内部专业知识的公司,最好的选择往往是聘请外部
156开发商根据保密协议审查计划。Linux基金会运行了一个NDA程序,旨在帮助解决这种163开发者根据保密协议审查计划。Linux基金会运行了一个NDA程序,旨在帮助解决这种
157情况;164情况;更多信息参见:
158 165
159 http://www.linuxfoundation.org/en/NDA_program166 http://www.linuxfoundation.org/nda/
160 167
161这种审查通常足以避免以后出现严重问题,而无需公开披露项目。168这种审查通常足以避免以后出现严重问题,而无需公开披露项目。
Documentation/translations/zh_CN/process/4.Coding.rst+141−138
@@ -1,155 +1,160 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/4.Coding.rst <development_coding>`3:Original: :ref:`Documentation/process/4.Coding.rst <development_coding>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_coding:13.. _cn_development_coding:
7 14
8使代码正确15使代码正确
9======================16======================
10 17
11虽然对于一个坚实的、面向社区的设计过程有很多话要说,但是任何内核开发项目的18虽然一个坚实的、面向社区的设计过程有很多值得说道的,但是任何内核开发项目工作
12证明都在生成的代码中。它是将由其他开发人员检查并合并(或不合并)到主线树中19的证明都反映在代码中。它是将由其他开发人员检查并合并(或不合并)到主线树中
13的代码。所以这段代码的质量决定了项目的最终成功。20的代码。所以这段代码的质量决定了项目的最终成功。
14 21
15本节将检查编码过程。我们将从内核开发人员出错的几种方式开始。然后重点将转移22本节将检查编码过程。我们将从内核开发人员常犯的几种错误开始。然后重点将转移
16到正确的事情和可以帮助这个任务的工具上。23到正确的做法和相关有用的工具上。
17 24
18陷阱25陷阱
19----26----
20 27
21编码风格28代码风格
22********29********
23 30
24内核长期以来都有一种标准的编码风格,如31内核长期以来都有其标准的代码风格,如
25:ref:`Documentation/translations/zh_CN/process/coding-style.rst <cn_codingstyle>`32:ref:`Documentation/translations/zh_CN/process/coding-style.rst <cn_codingstyle>`
26中所述。在大部分时间里,该文件中描述的政策被认为至多是建议性的。因此,内核33中所述。在多数时候,该文档中描述的准则至多被认为是建议性的。因此,内核中存在
27中存在大量不符合编码风格准则的代码。代码的存在会给内核开发人员带来两个独立34大量不符合代码风格准则的代码。这种代码的存在会给内核开发人员带来两方面的危害。
28的危害。35
29 36首先,相信内核代码标准并不重要,也不强制执行。但事实上,如果没有按照标准
30首先,要相信内核编码标准并不重要,也不强制执行。事实上,如果没有按照标准对代37编写代码,那么新代码将很难加入到内核中;许多开发人员甚至会在审查代码之前要求
31码进行编码,那么向内核添加新代码是非常困难的;许多开发人员甚至会在审查代码之38对代码进行重新格式化。一个像内核这么大的代码库需要一些统一格式的代码,以使
32前要求对代码进行重新格式化。一个与内核一样大的代码库需要一些统一的代码,以使39开发人员能够快速理解其中的任何部分。所以再也经不起奇怪格式的代码的折腾了。
33开发人员能够快速理解其中的任何部分。所以已经没有空间来存放奇怪的格式化代码了。40
34 41内核的代码风格偶尔会与雇主的强制风格发生冲突。在这种情况下,必须在代码合并
35偶尔,内核的编码风格会与雇主的强制风格发生冲突。在这种情况下,内核的风格必须42之前遵从内核代码风格。将代码放入内核意味着以多种方式放弃一定程度的控制权——
36在代码合并之前获胜。将代码放入内核意味着以多种方式放弃一定程度的控制权——包括43包括控制代码样式。
37控制代码的格式化方式。44
38 45另一个危害是认为已经在内核中的代码迫切需要修复代码样式。开发者可能会开始编写
39另一个陷阱是假定已经在内核中的代码迫切需要编码样式的修复。开发人员可能会开始46重新格式化补丁,作为熟悉开发过程的一种方式,或者作为将其名字写入内核变更日志
40生成重新格式化补丁,作为熟悉过程的一种方式,或者作为将其名称写入内核变更日志47的一种方式,或者两者兼而有之。但是纯代码风格的修复被开发社区视为噪音,它们往
41的一种方式,或者两者兼而有之。但是纯编码风格的修复被开发社区视为噪音;它们往48往受到冷遇。因此,最好避免编写这种类型的补丁。在由于其他原因处理一段代码的
42往受到冷遇。因此,最好避免使用这种类型的补丁。由于其他原因,在处理一段代码的49同时顺带修复其样式是很自然的,但是不应该仅为了更改代码样式而更改之。
43同时修复它的样式是很自然的,但是编码样式的更改不应该仅为了更改而进行。50
44 51代码风格文档也不应该被视为绝对不可违反的规则。如果有一个足够的理由反对这种
45编码风格的文档也不应该被视为绝对的法律,这是永远不会被违反的。如果有一个很好52样式(例如为了80列限制拆分行会导致可读性大大降低),那么就这样做吧。
46的理由反对这种样式(例如,如果拆分为适合80列限制的行,那么它的可读性就会大大53
47降低),那么就这样做。54注意您还可以使用 ``clang-format`` 工具来帮助您处理这些规则,快速自动重新格式
48 55化部分代码,和审阅完整的文件以发现代码样式错误、拼写错误和可能的改进。它还
49请注意,您还可以使用 ``clang-format`` 工具来帮助您处理这些规则,自动重新格式56可以方便地排序 ``#includes`` 、对齐变量/宏、重排文本和其他类似任务。有关详细
50化部分代码,并查看完整的文件,以发现编码样式错误、拼写错误和可能的改进。它还57信息,请参阅文档 :ref:`Documentation/process/clang-format.rst <clangformat>`
51可以方便地进行排序,包括对齐变量/宏、回流文本和其他类似任务。有关详细信息,请
52参阅文件 :ref:`Documentation/process/clang-format.rst <clangformat>`
53 58
54抽象层59抽象层
55******60******
56 61
57计算机科学教授教学生以灵活性和信息隐藏的名义广泛使用抽象层。当然,内核广泛62计算机科学教授教学生以灵活性和信息隐藏的名义广泛使用抽象层。当然,内核广泛
58地使用了抽象;任何涉及数百万行代码的项目都不能做到这一点并存活下来。但经验63地使用了抽象;任何涉及数百万行代码的项目都必须做到这一点以存续下来。但经验
59表明,过度或过早的抽象可能和过早的优化一样有害。抽象应用于所需的级别,64表明,过度或过早的抽象可能和过早的优化一样有害。抽象应用在适当层级,
60不要过度。65不要过度。
61 66
62在一个简单的级别上,考虑一个函数的参数,该参数总是由所有调用方作为零传递。67简单点,先考虑一个调用时始终只有一个参数且总为零的函数。我们可以保留这个参数,
63我们可以保留这个论点: 以防有人最终需要使用它提供的额外灵活性。不过,到那时,68以在需要使用它时提供的额外灵活性。不过,在那时实现了这个额外参数的代码很有
64实现这个额外参数的代码很有可能以某种从未被注意到的微妙方式被破坏——因为它从69可能以某种从未被注意到的微妙方式被破坏——因为它从未被使用过。或者当需要额外
65未被使用过。或者,当需要额外的灵活性时,它不会以符合程序员早期期望的方式来70的灵活性时,它并未以符合程序员当初期望的方式来实现。内核开发人员通常会提交
66这样做。内核开发人员通常会提交补丁来删除未使用的参数;一般来说,首先不应该71补丁来删除未使用的参数;一般来说,一开始就不应该添加这些参数。
67添加这些参数。
68 72
69隐藏硬件访问的抽象层——通常允许大量的驱动程序在多个操作系统中使用——尤其不受73隐藏硬件访问的抽象层——通常为了允许大量的驱动程序兼容多个操作系统——尤其不受
70欢迎。这样的层使代码变得模糊,可能会造成性能损失;它们不属于Linux内核。74欢迎。这样的层使代码变得模糊,可能会造成性能损失;它们不属于Linux内核。
71 75
72另一方面,如果您发现自己从另一个内核子系统复制了大量的代码,那么现在是时候76另一方面,如果您发现自己从另一个内核子系统复制了大量的代码,那么是时候
73问一下,事实上,将这些代码中的一些提取到单独的库中,或者在更高的层次上实现77了解一下:是否需要将这些代码中的部分提取到单独的库中,或者在更高的层次上
74这些功能是否有意义。在整个内核中复制相同的代码没有价值。78实现这些功能。在整个内核中复制相同的代码没有价值。
75 79
76#ifdef 和预处理80#ifdef 和预处理
77***************81***************
78 82
79C预处理器似乎给一些C程序员带来了强大的诱惑,他们认为它是一种有效地将大量灵83C预处理器似乎给一些C程序员带来了强大的诱惑,他们认为它是一种将大量灵活性加入
80活性编码到源文件中的方法。但是预处理器不是C,大量使用它会导致代码对其他人来84源代码中的方法。但是预处理器不是C,大量使用它会导致代码对其他人来说更难阅读,
81说更难读取,对编译器来说更难检查正确性。大量的预处理器几乎总是代码需要一些85对编译器来说更难检查正确性。使用了大量预处理器几乎总是代码需要一些
82清理工作的标志。86清理工作的标志。
83 87
84使用ifdef的条件编译实际上是一个强大的功能,它在内核中使用。但是很少有人希望88使用#ifdef的条件编译实际上是一个强大的功能,它在内核中使用。但是很少有人希望
85看到代码被大量地撒上ifdef块。作为一般规则,ifdef的使用应尽可能限制在头文件89看到代码被铺满#ifdef块。一般规定,ifdef的使用应尽可能限制在头文件中。条件
86中。有条件编译的代码可以限制函数,如果代码不存在,这些函数就会变成空的。然后90编译代码可以限制函数,如果代码不存在,这些函数就直接变成空的。然后编译器将
87编译器将悄悄地优化对空函数的调用。结果是代码更加清晰,更容易理解。91悄悄地优化对空函数的调用。使得代码更加清晰,更容易理解。
88 92
89C预处理器宏存在许多危险,包括可能对具有副作用且没有类型安全性的表达式进行多93C预处理器宏存在许多危险性,包括可能对具有副作用且没有类型安全的表达式进行多
90重评估。如果您试图定义宏,请考虑创建一个内联函数。结果相同的代码,但是内联94重评估。如果您试图定义宏,请考虑创建一个内联函数替代。结果相同的代码,内联
91函数更容易读取,不会多次计算其参数,并且允许编译器对参数和返回值执行类型检查。95函数更容易阅读,不会多次计算其参数,并且允许编译器对参数和返回值执行类型检查。
92 96
93内联函数97内联函数
94********98********
95 99
96不过,内联函数本身也存在风险。程序员可以倾心于避免函数调用和用内联函数填充源100不过,内联函数本身也存在风险。程序员可以倾心于避免函数调用和用内联函数填充源
97文件所固有的效率。然而,这些功能实际上会降低性能。因为它们的代码在每个调用站101文件所固有的效率。然而,这些功能实际上会降低性能。因为它们的代码在每个调用站
98点都被复制,所以它们最终会增加编译内核的大小。反过来,这会对处理器的内存缓存102点都被复制一遍,所以最终会增加编译内核的大小。此外,这也对处理器的内存缓存
99造成压力,从而大大降低执行速度。通常,内联函数应该非常小,而且相对较少。毕竟,103造成压力,从而大大降低执行速度。通常内联函数应该非常小,而且相对较少。毕竟
100函数调用的成本并不高;大量内联函数的创建是过早优化的典型例子。104函数调用的成本并不高;大量创建内联函数是过早优化的典型例子。
101 105
102一般来说,内核程序员会忽略缓存效果,这会带来危险。在开始的数据结构课程中,经106一般来说,内核程序员会自冒风险忽略缓存效果。在数据结构课程开头中的经典
103典的时间/空间权衡通常不适用于当代硬件。空间就是时间,因为一个大的程序比一个107时间/空间权衡通常不适用于当代硬件。空间 *就是* 时间,因为一个大的程序比一个
104更紧凑的程序运行得慢。108更紧凑的程序运行得慢。
105 109
106最近的编译器在决定一个给定函数是否应该被内联方面扮演着越来越积极的角色。110较新的编译器越来越激进地决定一个给定函数是否应该内联。因此,随意放置使用
107因此,“inline”关键字的自由放置可能不仅仅是过度的,它也可能是无关的。111“inline”关键字可能不仅仅是过度的,也可能是无用的。
108 112
109锁113锁
110**114**
111 115
1122006年5月,“deviceescape”网络堆栈在GPL下发布,并被纳入主线内核。这是一个受1162006年5月,“deviceescape”网络堆栈在前呼后拥下以GPL发布,并被纳入主线内核。
113欢迎的消息;对Linux中无线网络的支持充其量被认为是不合格的,而deviceescape117这是一个受欢迎的消息;Linux中对无线网络的支持充其量被认为是不合格的,而
114堆栈提供了修复这种情况的承诺。然而,直到2007年6月(2.6.22),这段代码才真118Deviceescape堆栈承诺修复这种情况。然而直到2007年6月(2.6.22),这段代码才真
115正进入主线。发生了什么?119正进入主线。发生了什么?
116 120
117这段代码显示了许多闭门造车的迹象。但一个特别大的问题是,它并不是设计用于多121这段代码出现了许多闭门造车的迹象。但一个大麻烦是,它并不是为多处理器系统而
118处理器系统。在合并这个网络堆栈(现在称为mac80211)之前,需要对其进行一个锁122设计。在合并这个网络堆栈(现在称为mac80211)之前,需要对其进行一个锁方案的
119方案的改造。123改造。
120 124
121曾经,Linux内核代码可以在不考虑多处理器系统所带来的并发性问题的情况下进行125曾经,Linux内核代码可以在不考虑多处理器系统所带来的并发性问题的情况下进行
122开发。然而,现在,这个文件是写在双核笔记本电脑上的。即使在单处理器系统上,126开发。然而现在,这个文档就是在双核笔记本电脑上写的。即使在单处理器系统上,
123为提高响应能力所做的工作也会提高内核内的并发性水平。编写内核代码而不考虑锁127为提高响应能力所做的工作也会提高内核内的并发性水平。编写内核代码而不考虑锁
124的日子已经过去很长了。128的日子早已远去。
125 129
126可以由多个线程并发访问的任何资源(数据结构、硬件寄存器等)必须由锁保护。新130可以由多个线程并发访问的任何资源(数据结构、硬件寄存器等)必须由锁保护。新
127的代码应该记住这一要求;事后改装锁是一项相当困难的任务。内核开发人员应该花131的代码应该谨记这一要求;事后修改锁是一项相当困难的任务。内核开发人员应该花
128时间充分了解可用的锁原语,以便为作业选择正确的工具。显示对并发性缺乏关注的132时间充分了解可用的锁原语,以便为工作选择正确的工具。对并发性缺乏关注的代码
129代码进入主线将很困难。133很难进入主线。
130 134
131回归135回归
132****136****
133 137
134最后一个值得一提的危险是:它可能会引起改变(这可能会带来很大的改进),从而138最后一个值得一提的危险是回归:它可能会引起导致现有用户的某些东西中断的改变
135导致现有用户的某些东西中断。这种变化被称为“回归”,回归已经成为主线内核最不139(这也可能会带来很大的改进)。这种变化被称为“回归”,回归已经成为主线内核
136受欢迎的。除少数例外情况外,如果回归不能及时修正,会导致回归的变化将被取消。140最不受欢迎的问题。除了少数例外情况,如果回归不能及时修正,会导致回归的修改
137最好首先避免回归。141将被取消。最好首先避免回归发生。
138 142
139人们常常争论,如果回归让更多人可以工作,远超过产生问题,那么回归是合理的。143人们常常争论,如果回归带来的功能远超过产生的问题,那么回归是否为可接受的。
140如果它破坏的一个系统却为十个系统带来新的功能,为什么不进行更改呢?2007年7月,144如果它破坏了一个系统却为十个系统带来新的功能,为何不改改态度呢?2007年7月,
141Linus对这个问题给出了最佳答案:145Linus对这个问题给出了最佳答案:
142 146
143::147::
144 所以我们不会通过引入新问题来修复错误。那样的谎言很疯狂,没有人知道148
145 你是否真的有进展。是前进两步,后退一步,还是向前一步,向后两步?149 所以我们不会通过引入新问题来修复错误。这种方式是靠不住的,没人知道
150 是否真的有进展。是前进两步、后退一步,还是前进一步、后退两步?
146 151
147(http://lwn.net/articles/243460/)152(http://lwn.net/articles/243460/)
148 153
149一种特别不受欢迎的回归类型是用户空间ABI的任何变化。一旦接口被导出到用户空间,154特别不受欢迎的一种回归类型是用户空间ABI的任何变化。一旦接口被导出到用户空间,
150就必须无限期地支持它。这一事实使得用户空间接口的创建特别具有挑战性:因为它们155就必须无限期地支持它。这一事实使得用户空间接口的创建特别具有挑战性:因为它们
151不能以不兼容的方式进行更改,所以必须第一次正确地进行更改。因此,用户空间界面156不能以不兼容的方式进行更改,所以必须一次就对。因此,用户空间接口总是需要大量
152总是需要大量的思考、清晰的文档和广泛的审查。157的思考、清晰的文档和广泛的审查。
153 158
154 159
155代码检查工具160代码检查工具
@@ -157,13 +162,13 @@ Linus对这个问题给出了最佳答案: · 1 unmodified line
157 162
158至少目前,编写无错误代码仍然是我们中很少人能达到的理想状态。不过,我们希望做163至少目前,编写无错误代码仍然是我们中很少人能达到的理想状态。不过,我们希望做
159的是,在代码进入主线内核之前,尽可能多地捕获并修复这些错误。为此,内核开发人164的是,在代码进入主线内核之前,尽可能多地捕获并修复这些错误。为此,内核开发人
160员已经组装了一系列令人印象深刻的工具,可以自动捕获各种各样的模糊问题。计算机165员已经提供了一系列令人印象深刻的工具,可以自动捕获各种各样的隐藏问题。计算机
161发现的任何问题都是一个以后不会困扰用户的问题,因此,只要有可能,就应该使用166发现的任何问题都是一个以后不会困扰用户的问题,因此,只要有可能,就应该使用
162自动化工具。167自动化工具。
163 168
164第一步只是注意编译器产生的警告。当代版本的GCC可以检测(并警告)大量潜在错误。169第一步是注意编译器产生的警告。当前版本的GCC可以检测(并警告)大量潜在错误。
165通常,这些警告都指向真正的问题。提交以供审阅的代码通常不会产生任何编译器警告。170通常,这些警告都指向真正的问题。提交以供审阅的代码一般不会产生任何编译器警告。
166在消除警告时,注意了解真正的原因,并尽量避免“修复”,使警告消失而不解决其原因。171在消除警告时,注意了解真正的原因,并尽量避免仅“修复”使警告消失而不解决其原因。
167 172
168请注意,并非所有编译器警告都默认启用。使用“make KCFLAGS=-W”构建内核以173请注意,并非所有编译器警告都默认启用。使用“make KCFLAGS=-W”构建内核以
169获得完整集合。174获得完整集合。
@@ -172,45 +177,43 @@ Linus对这个问题给出了最佳答案: · 2 unmodified lines
172子菜单中。对于任何用于开发或测试目的的内核,都应该启用其中几个选项。特别是,177子菜单中。对于任何用于开发或测试目的的内核,都应该启用其中几个选项。特别是,
173您应该打开:178您应该打开:
174 179
175 - 启用 ENABLE_MUST_CHECK and FRAME_WARN 以获得一组额外的警告,以解决使用不180 - FRAME_WARN 获取大于给定数量的堆栈帧的警告。
176 推荐使用的接口或忽略函数的重要返回值等问题。这些警告生成的输出可能是冗长181 这些警告生成的输出可能比较冗长,但您不必担心来自内核其他部分的警告。
177 的,但您不必担心来自内核其他部分的警告。
178 182
179 - DEBUG_OBJECTS 将添加代码,以跟踪内核创建的各种对象的生存期,并在出现问题时183 - DEBUG_OBJECTS 将添加代码以跟踪内核创建的各种对象的生命周期,并在出现问题
180 发出警告。如果要添加创建(和导出)自己的复杂对象的子系统,请考虑添加对对象184 时发出警告。如果你要添加创建(和导出)关于其自己的复杂对象的子系统,请
181 调试基础结构的支持。185 考虑打开对象调试基础结构的支持。
182 186
183 - DEBUG_SLAB 可以发现各种内存分配和使用错误;它应该用于大多数开发内核。187 - DEBUG_SLAB 可以发现各种内存分配和使用错误;它应该用于大多数开发内核。
184 188
185 - DEBUG_SPINLOCK, DEBUG_ATOMIC_SLEEP and DEBUG_MUTEXES 会发现许多常见的189 - DEBUG_SPINLOCK, DEBUG_ATOMIC_SLEEP 和 DEBUG_MUTEXES 会发现许多常见的
186 锁定错误.190 锁错误。
187 191
188还有很多其他调试选项,其中一些将在下面讨论。其中一些具有显著的性能影响,不应192还有很多其他调试选项,其中一些将在下面讨论。其中一些有显著的性能影响,不应
189一直使用。但是,在学习可用选项上花费的一些时间可能会在短期内得到多次回报。193一直使用。在学习可用选项上花费一些时间,可能会在短期内得到许多回报。
190 194
191其中一个较重的调试工具是锁定检查器或“lockdep”。该工具将跟踪系统中每个锁195其中一个较重的调试工具是锁检查器或“lockdep”。该工具将跟踪系统中每个锁
192(spinlock或mutex)的获取和释放、获取锁的相对顺序、当前中断环境等等。然后,196(spinlock或mutex)的获取和释放、获取锁的相对顺序、当前中断环境等等。然后,
193它可以确保总是以相同的顺序获取锁,相同的中断假设适用于所有情况,等等。换句话197它可以确保总是以相同的顺序获取锁,相同的中断假设适用于所有情况等等。换句话
194说,lockdep可以找到许多场景,在这些场景中,系统很少会死锁。在部署的系统中,198说,lockdep可以找到许多导致系统死锁的场景。在部署的系统中,这种问题可能会
195这种问题可能会很痛苦(对于开发人员和用户而言);LockDep允许提前以自动方式199很痛苦(对于开发人员和用户而言);LockDep允许提前以自动方式发现问题。具有
196发现问题。具有任何类型的非普通锁定的代码在提交包含前应在启用lockdep的情况200任何类型的非普通锁的代码在提交合并前应在启用lockdep的情况下运行测试。
197下运行。
198 201
199作为一个勤奋的内核程序员,毫无疑问,您将检查任何可能失败的操作(如内存分配)202作为一个勤奋的内核程序员,毫无疑问,您将检查任何可能失败的操作(如内存分配)
200的返回状态。然而,事实上,最终的故障恢复路径可能完全没有经过测试。未测试的203的返回状态。然而,事实上,最终的故障复现路径可能完全没有经过测试。未测试的
201代码往往会被破坏;如果所有这些错误处理路径都被执行了几次,那么您可能对代码204代码往往会出问题;如果所有这些错误处理路径都被执行了几次,那么您可能对代码
202更有信心。205更有信心。
203 206
204内核提供了一个可以做到这一点的错误注入框架,特别是在涉及内存分配的情况下。207内核提供了一个可以做到这一点的错误注入框架,特别是在涉及内存分配的情况下。
205启用故障注入后,内存分配的可配置百分比将失败;这些失败可以限制在特定的代码208启用故障注入后,内存分配的可配置失败的百分比;这些失败可以限定在特定的代码
206范围内。在启用了故障注入的情况下运行,程序员可以看到当情况恶化时代码如何响209范围内。在启用了故障注入的情况下运行,程序员可以看到当情况恶化时代码如何响
207应。有关如何使用此工具的详细信息,请参阅210应。有关如何使用此工具的详细信息,请参阅
208Documentation/fault-injection/fault-injection.rst。211Documentation/fault-injection/fault-injection.rst。
209 212
210使用“sparse”静态分析工具可以发现其他类型的错误。对于sparse,可以警告程序员213“sparse”静态分析工具可以发现其他类型的错误。sparse可以警告程序员用户空间
211用户空间和内核空间地址之间的混淆、big endian和small endian数量的混合、在需214和内核空间地址之间的混淆、大端序与小端序的混淆、在需要一组位标志的地方传递
212要一组位标志的地方传递整数值等等。sparse必须单独安装(如果您的分发服务器没215整数值等等。sparse必须单独安装(如果您的分发服务器没有将其打包,
213有将其打包,可以在 https://sparse.wiki.kernel.org/index.php/Main_page)找到,216可以在 https://sparse.wiki.kernel.org/index.php/Main_page 找到),
214然后可以通过在make命令中添加“C=1”在代码上运行它。217然后可以通过在make命令中添加“C=1”在代码上运行它。
215 218
216“Coccinelle”工具 :ref:`http://coccinelle.lip6.fr/ <devtools_coccinelle>`219“Coccinelle”工具 :ref:`http://coccinelle.lip6.fr/ <devtools_coccinelle>`
@@ -221,8 +224,8 @@ scripts/coccinelle目录下已经打包了相当多的内核“语义补丁” · 4 unmodified lines
221 224
222 225
223其他类型的可移植性错误最好通过为其他体系结构编译代码来发现。如果没有S/390系统226其他类型的可移植性错误最好通过为其他体系结构编译代码来发现。如果没有S/390系统
224或Blackfin开发板,您仍然可以执行编译步骤。可以在以下位置找到一组用于x86系统的227或Blackfin开发板,您仍然可以执行编译步骤。可以在以下位置找到一大堆用于x86系统的
225大型交叉编译器:228交叉编译器:
226 229
227 https://www.kernel.org/pub/tools/crosstool/230 https://www.kernel.org/pub/tools/crosstool/
228 231
@@ -233,22 +236,22 @@ scripts/coccinelle目录下已经打包了相当多的内核“语义补丁” · 4 unmodified lines
233 236
234文档通常比内核开发规则更为例外。即便如此,足够的文档将有助于简化将新代码合并237文档通常比内核开发规则更为例外。即便如此,足够的文档将有助于简化将新代码合并
235到内核中的过程,使其他开发人员的生活更轻松,并对您的用户有所帮助。在许多情况238到内核中的过程,使其他开发人员的生活更轻松,并对您的用户有所帮助。在许多情况
236下,文件的添加已基本上成为强制性的。239下,添加文档已基本上是强制性的。
237 240
238任何补丁的第一个文档是其关联的变更日志。日志条目应该描述正在解决的问题、解决241任何补丁的第一个文档是其关联的变更日志。日志条目应该描述正在解决的问题、解决
239方案的形式、处理补丁的人员、对性能的任何相关影响,以及理解补丁可能需要的任何242方案的形式、处理补丁的人员、对性能的任何相关影响,以及理解补丁可能需要的任何
240其他内容。确保changelog说明了为什么补丁值得应用;大量开发人员未能提供这些信息。243其他内容。确保变更日志说明了*为什么*补丁值得应用;大量开发者未能提供这些信息。
241 244
242任何添加新用户空间界面的代码(包括新的sysfs或/proc文件)都应该包含该界面的245任何添加新用户空间接口的代码——包括新的sysfs或/proc文件——都应该包含该接口
243文档,该文档使用户空间开发人员能够知道他们在使用什么。请参阅246的文档,该文档使用户空间开发人员能够知道他们在使用什么。请参阅
244Documentation/ABI/README,了解如何格式化此文档以及需要提供哪些信息。247Documentation/ABI/README,了解如何此文档格式以及需要提供哪些信息。
245 248
246文件 :ref:`Documentation/admin-guide/kernel-parameters.rst <kernelparameters>`249文档 :ref:`Documentation/admin-guide/kernel-parameters.rst <kernelparameters>`
247描述了内核的所有引导时间参数。任何添加新参数的补丁都应该向该文件添加适当的250描述了内核的所有引导时间参数。任何添加新参数的补丁都应该向该文档添加适当的
248条目。251条目。
249 252
250任何新的配置选项都必须附有帮助文本,帮助文本清楚地解释了这些选项以及用户可能253任何新的配置选项都必须附有帮助文本,帮助文本需清楚地解释这些选项以及用户可能
251希望何时选择它们。254希望何时使用它们。
252 255
253许多子系统的内部API信息通过专门格式化的注释进行记录;这些注释可以通过256许多子系统的内部API信息通过专门格式化的注释进行记录;这些注释可以通过
254“kernel-doc”脚本以多种方式提取和格式化。如果您在具有kerneldoc注释的子系统中257“kernel-doc”脚本以多种方式提取和格式化。如果您在具有kerneldoc注释的子系统中
@@ -257,31 +260,31 @@ Documentation/ABI/README,了解如何格式化此文档以及需要提供哪 · 2 unmodified lines
257来说是一个有用的活动。这些注释的格式以及如何创建kerneldoc模板的一些信息可以在260来说是一个有用的活动。这些注释的格式以及如何创建kerneldoc模板的一些信息可以在
258:ref:`Documentation/doc-guide/ <doc_guide>` 上找到。261:ref:`Documentation/doc-guide/ <doc_guide>` 上找到。
259 262
260任何阅读大量现有内核代码的人都会注意到,注释的缺失往往是最值得注意的。再一次,263任何阅读大量现有内核代码的人都会注意到,注释的缺失往往是最值得注意的。同时,
261对新代码的期望比过去更高;合并未注释的代码将更加困难。这就是说,人们几乎不希望264对新代码的要求比过去更高;合并未注释的代码将更加困难。这就是说,人们并不期望
262用语言注释代码。代码本身应该是可读的,注释解释了更微妙的方面。265详细注释的代码。代码本身应该是自解释的,注释阐释了更微妙的方面。
263 266
264某些事情应该总是被注释。使用内存屏障时,应附上一行文字,解释为什么需要设置内存267某些事情应该总是被注释。使用内存屏障时,应附上一行文字,解释为什么需要设置内存
265屏障。数据结构的锁定规则通常需要在某个地方解释。一般来说,主要数据结构需要全面268屏障。数据结构的锁规则通常需要在某个地方解释。一般来说,主要数据结构需要全面
266的文档。应该指出单独代码位之间不明显的依赖性。任何可能诱使代码看门人进行错误的269的文档。应该指出代码中分立的位之间不明显的依赖性。任何可能诱使代码管理人进行
267“清理”的事情都需要一个注释来说明为什么要这样做。等等。270错误的“清理”的事情都需要一个注释来说明为什么要这样做。等等。
268 271
269 272
270内部API更改273内部API更改
271-----------274-----------
272 275
273内核提供给用户空间的二进制接口不能被破坏,除非在最严重的情况下。相反,内核的276内核提供给用户空间的二进制接口不能被破坏,除非逼不得已。而内核的内部编程接口
274内部编程接口是高度流动的,当需要时可以更改。如果你发现自己不得不处理一个内核277是高度流动的,当需要时可以更改。如果你发现自己不得不处理一个内核API,或者仅
275API,或者仅仅因为它不满足你的需求而不使用特定的功能,这可能是API需要改变的一278仅因为它不满足你的需求导致无法使用特定的功能,这可能是API需要改变的一个标志。
276个标志。作为内核开发人员,您有权进行此类更改。279作为内核开发人员,您有权进行此类更改。
277 280
278当然, 可以进行API更改,但它们必须是合理的。因此,任何进行内部API更改的补丁都281的确可以进行API更改,但更改必须是合理的。因此任何进行内部API更改的补丁都应该
279应该附带一个关于更改内容和必要原因的描述。这种变化也应该分解成一个单独的补丁,282附带关于更改内容和必要原因的描述。这种变化也应该拆分成一个单独的补丁,而不是
280而不是埋在一个更大的补丁中。283埋在一个更大的补丁中。
281 284
282另一个要点是,更改内部API的开发人员通常要负责修复内核树中被更改破坏的任何代码。285另一个要点是,更改内部API的开发人员通常要负责修复内核树中被更改破坏的任何代码。
283对于一个广泛使用的函数,这个职责可以导致成百上千的变化,其中许多变化可能与其他286对于一个广泛使用的函数,这个责任可以导致成百上千的变化,其中许多变化可能与其他
284开发人员正在做的工作相冲突。不用说,这可能是一项大工作,所以最好确保理由是287开发人员正在做的工作相冲突。不用说,这可能是一项大工程,所以最好确保理由是
285可靠的。请注意,coccinelle工具可以帮助进行广泛的API更改。288可靠的。请注意,coccinelle工具可以帮助进行广泛的API更改。
286 289
287在进行不兼容的API更改时,应尽可能确保编译器捕获未更新的代码。这将帮助您确保找290在进行不兼容的API更改时,应尽可能确保编译器捕获未更新的代码。这将帮助您确保找
Documentation/translations/zh_CN/process/5.Posting.rst+125−118
@@ -1,150 +1,157 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/5.Posting.rst <development_posting>`3:Original: :ref:`Documentation/process/5.Posting.rst <development_posting>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_posting:13.. _cn_development_posting:
7 14
8发布补丁15发布补丁
9========16========
10 17
11迟早,当您的工作准备好提交给社区进行审查,并最终包含到主线内核中时。不出所料,18您的工作迟早会准备好提交给社区进行审查,并最终包含到主线内核中。毫不稀奇,
12内核开发社区已经发展出一套用于发布补丁的约定和过程;遵循这些约定和过程将使19内核开发社区已经发展出一套用于发布补丁的约定和过程;遵循这些约定和过程将使
13参与其中的每个人的生活更加轻松。本文件将试图合理详细地涵盖这些期望;更多信息20参与其中的每个人的生活更加轻松。本文档试图描述这些约定的部分细节;更多信息
14也可在以下文件中找到21也可在以下文档中找到
15:ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`,22:ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`,
16:ref:`Documentation/process/submitting-drivers.rst <submittingdrivers>`23:ref:`Documentation/translations/zh_CN/process/submitting-drivers.rst <cn_submittingdrivers>`
17和 :ref:`Documentation/translations/zh_CN/process/submit-checklist.rst <cn_submitchecklist>`.24和 :ref:`Documentation/translations/zh_CN/process/submit-checklist.rst <cn_submitchecklist>`。
18 25
19何时邮寄26何时邮寄
20--------27--------
21 28
22在补丁完全“准备好”之前,有一个不断的诱惑来避免发布补丁。对于简单的补丁,29在补丁完全“准备好”之前,避免发布补丁是一种持续的诱惑。对于简单的补丁,这
23这不是问题。但是,如果正在完成的工作很复杂,那么在工作完成之前从社区获得30不是问题。但是如果正在完成的工作很复杂,那么在工作完成之前从社区获得反馈就
24反馈就可以获得很多好处。因此,您应该考虑发布正在进行的工作,甚至使Git树31可以获得很多好处。因此,您应该考虑发布正在进行的工作,甚至维护一个可用的Git
25可用,以便感兴趣的开发人员可以随时赶上您的工作。32树,以便感兴趣的开发人员可以随时赶上您的工作。
26 33
27当发布还没有准备好包含的代码时,最好在发布本身中这样说。还应提及任何有待完成34当发布中有尚未准备好被包含的代码,最好在发布中说明。还应提及任何有待完成的
28的主要工作和任何已知问题。很少有人会看到那些被认为是半生不熟的补丁,但是那些35主要工作和任何已知问题。很少有人会愿意看那些被认为是半生不熟的补丁,但是
29人会想到他们可以帮助你把工作推向正确的方向。36那些愿意的人会带着他们的点子来一起帮助你把工作推向正确的方向。
30 37
31创建补丁之前38创建补丁之前
32------------39------------
33 40
34在考虑将补丁发送到开发社区之前,有许多事情应该做。这些包括:41在考虑将补丁发送到开发社区之前,有许多事情应该做。包括:
35 42
36 - 尽可能地测试代码。利用内核的调试工具,确保内核使用所有合理的配置选项组合43 - 尽可能地测试代码。利用内核的调试工具,确保内核使用了所有可能的配置选项组合
37 进行构建,使用跨编译器为不同的体系结构进行构建等。44 进行构建,使用交叉编译器为不同的体系结构进行构建等。
38 45
39 - 确保您的代码符合内核编码风格指南。46 - 确保您的代码符合内核代码风格指南。
40 47
41 - 您的更改是否具有性能影响?如果是这样,您应该运行基准测试来显示您的变更的48 - 您的更改是否具有性能影响?如果是这样,您应该运行基准测试来显示您的变更的
42 影响(或好处);结果的摘要应该包含在补丁中。49 影响(或好处);结果的摘要应该包含在补丁中。
43 50
44 - 确保您有权发布代码。如果这项工作是为雇主完成的,雇主对这项工作具有所有权,51 - 确保您有权发布代码。如果这项工作是为雇主完成的,雇主对这项工作具有所有权,
45 并且必须同意根据GPL对其进行放行。52 并且必须同意根据GPL对其进行发布。
46 53
47一般来说,在发布代码之前进行一些额外的思考,几乎总是能在短时间内得到回报。54一般来说,在发布代码之前进行一些额外的思考,几乎总是能在短时间内得到回报。
48 55
49补丁准备56补丁准备
50--------57--------
51 58
52准备发布补丁可能是一个惊人的工作量,但再次尝试节省时间在这里通常是不明智的,59准备补丁发布的工作量可能很惊人,但在此尝试节省时间通常是不明智的,即使在短期
53即使在短期内。60内亦然。
54 61
55必须针对内核的特定版本准备补丁。作为一般规则,补丁程序应该基于Linus的Git树中62必须针对内核的特定版本准备补丁。一般来说,补丁应该基于Linus的Git树中的当前
56的当前主线。当以主线为基础时,从一个众所周知的发布点开始——一个稳定的或RC的63主线。当以主线为基础时,请从一个众所周知的发布点开始——如稳定版本或 -rc
57发布——而不是在一个主线分支任意点。64版本发布点——而不是在一个任意的主线分支点。
58 65
59但是,可能需要针对-mm、linux-next或子系统树生成版本,以便于更广泛的测试和审查。66也可能需要针对-mm、linux-next或子系统树生成版本,以便于更广泛的测试和审查。
60根据补丁的区域以及其他地方的情况,针对这些其他树建立补丁可能需要大量的工作来67根据补丁的区域以及其他地方的情况,针对其他树建立的补丁可能需要大量的工作来
61解决冲突和处理API更改。68解决冲突和处理API更改。
62 69
63只有最简单的更改才应格式化为单个补丁;其他所有更改都应作为一系列逻辑更改进行。70只有最简单的更改才应格式化为单个补丁;其他所有更改都应作为一系列逻辑更改进行。
64分割补丁是一门艺术;一些开发人员花了很长时间来弄清楚如何按照社区期望的方式来71分割补丁是一门艺术;一些开发人员花了很长时间来弄清楚如何按照社区期望的方式来
65做。然而,有一些经验法则可以大大帮助:72分割。不过,这些经验法则也许有帮助:
66 73
67 - 您发布的补丁程序系列几乎肯定不会是工作系统中的一系列更改。相反,您所做的74 - 您发布的补丁系列几乎肯定不会是开发过程中版本控制系统中的一系列更改。相反,
68 更改需要在最终形式中加以考虑,然后以有意义的方式进行拆分。开发人员对离散的、75 需要对您所做更改的最终形式加以考虑,然后以有意义的方式进行拆分。开发人员对
69 自包含的更改感兴趣,而不是您获取这些更改的路径。76 离散的、自包含的更改感兴趣,而不是您创造这些更改的原始路径。
70 77
71 - 每个逻辑上独立的变更都应该格式化为单独的补丁。这些更改可以是小的(“向此78 - 每个逻辑上独立的变更都应该格式化为单独的补丁。这些更改可以是小的(如“向
72 结构添加字段”)或大的(例如,添加一个重要的新驱动程序),但它们在概念上79 此结构体添加字段”)或大的(如添加一个重要的新驱动程序),但它们在概念上
73 应该是小的,并且可以接受一行描述。每个补丁都应该做一个特定的更改,可以单独80 应该是小的,并且可以在一行内简述。每个补丁都应该做一个特定的、可以单独
74 检查并验证它所做的事情。81 检查并验证它所做的事情的更改。
75 82
76 - 作为重申上述准则的一种方法:不要在同一补丁中混合不同类型的更改。如果一个83 - 换种方式重申上述准则,也就是说:不要在同一补丁中混合不同类型的更改。如果
77 补丁修复了一个关键的安全漏洞,重新排列了一些结构,并重新格式化了代码,那么84 一个补丁修复了一个关键的安全漏洞,又重新排列了一些结构,还重新格式化了代
78 很有可能它会被忽略,而重要的修复将丢失。85 码,那么它很有可能会被忽略,从而导致重要的修复丢失。
79 86
80 - 每个补丁都应该产生一个内核,它可以正确地构建和运行;如果补丁系列在中间被87 - 每个补丁都应该能创建一个可以正确地构建和运行的内核;如果补丁系列在中间被
81 中断,那么结果应该仍然是一个工作的内核。补丁系列的部分应用是使用88 断开,那么结果仍应是一个正常工作的内核。部分应用一系列补丁是使用
82 “git bisct”工具查找回归的一个常见场景;如果结果是一个损坏的内核,那么对于89 “git bisct”工具查找回归的一个常见场景;如果结果是一个损坏的内核,那么将使
83 那些从事追踪问题的高尚工作的开发人员和用户来说,将使他们的生活更加艰难。90 那些从事追踪问题的高尚工作的开发人员和用户的生活更加艰难。
84 91
85 - 不过,不要过分。一位开发人员曾经将一组编辑内容作为500个单独的补丁发布到一个92 - 不要过分分割。一位开发人员曾经将一组针对单个文件的编辑分成500个单独的补丁
86 文件中,这并没有使他成为内核邮件列表中最受欢迎的人。一个补丁可以相当大,93 发布,这并没有使他成为内核邮件列表中最受欢迎的人。一个补丁可以相当大,
87 只要它仍然包含一个单一的逻辑变更。94 只要它仍然包含一个单一的 *逻辑* 变更。
88 95
89 - 用一系列补丁添加一个全新的基础设施是很有诱惑力的,但是在系列中的最后一个96 - 用一系列补丁添加一个全新的基础设施,但是该设施在系列中的最后一个补丁启用
90 补丁启用整个补丁之前,该基础设施是不使用的。如果可能的话,应该避免这种97 整个变更之前不能使用,这看起来很诱人。如果可能的话,应该避免这种诱惑;
91 诱惑;如果这个系列增加了回归,那么二分法将指出最后一个补丁是导致问题的98 如果这个系列增加了回归,那么二分法将指出最后一个补丁是导致问题的补丁,
92 补丁,即使真正的bug在其他地方。只要有可能,添加新代码的补丁程序应该立即99 即使真正的bug在其他地方。只要有可能,添加新代码的补丁程序应该立即激活该
93 激活该代码。100 代码。
94 101
95创建完美补丁系列的工作可能是一个令人沮丧的过程,在完成“真正的工作”之后需要花费102创建完美补丁系列的工作可能是一个令人沮丧的过程,在完成“真正的工作”之后需要
96大量的时间和思考。但是,如果做得好,这是一段很好的时间。103花费大量的时间和思考。但是如果做得好,花费的时间就是值得的。
97 104
98补丁格式和更改日志105补丁格式和更改日志
99------------------106------------------
100 107
101所以现在你有了一系列完美的补丁可以发布,但是这项工作还没有完成。每个补丁都108所以现在你有了一系列完美的补丁可以发布,但是这项工作还没有完成。每个补丁都
102需要被格式化成一条消息,它可以快速而清晰地将其目的传达给世界其他地方。为此,109需要被格式化成一条消息,以快速而清晰地将其目的传达到世界其他地方。为此,
103每个补丁将由以下部分组成:110每个补丁将由以下部分组成:
104 111
105 - 命名补丁作者的可选“from”行。只有当你通过电子邮件传递别人的补丁时,这一行112 - 可选的“From”行,表明补丁作者。只有当你通过电子邮件发送别人的补丁时,这一行
106 才是必要的,但是如果有疑问,添加它不会有任何伤害。113 才是必须的,但是为防止疑问加上它也不会有什么坏处。
107 114
108 - 一行描述补丁的作用。对于没有其他上下文的读者来说,此消息应该足够了解补丁115 - 一行描述,说明补丁的作用。对于在没有其他上下文的情况下看到该消息的读者来说,
109 的范围;这是将在“短格式”变更日志中显示的行。此消息通常首先用相关的子系统116 该消息应足以确定修补程序的范围;此行将显示在“short form(简短格式)”变更
110 名称格式化,然后是补丁的目的。例如:117 日志中。此消息通常需要先加上子系统名称前缀,然后是补丁的目的。例如:
111 118
112 ::119 ::
113 120
114 gpio: fix build on CONFIG_GPIO_SYSFS=n121 gpio: fix build on CONFIG_GPIO_SYSFS=n
115 122
116 - 一个空白行,后面是补丁内容的详细描述。这个描述可以是必需的;它应该说明补丁123 - 一行空白,后接补丁内容的详细描述。此描述可以是任意需要的长度;它应该说明补丁
117 的作用以及为什么它应该应用于内核。124 的作用以及为什么它应该应用于内核。
118 125
119 - 一个或多个标记行,至少有一个由补丁作者的:signed-off-by 签名。签名将在下面126 - 一个或多个标记行,至少有一个由补丁作者的 Signed-off-by 签名。标记将在下面
120 更详细地描述。127 详细描述。
121 128
122上面的项目一起构成补丁的变更日志。写一篇好的变更日志是一门至关重要但常常被129上面的项目一起构成补丁的变更日志。写一则好的变更日志是一门至关重要但常常被
123忽视的艺术;值得花一点时间来讨论这个问题。当你写一个变更日志时,你应该记住130忽视的艺术;值得花一点时间来讨论这个问题。当你编写变更日志时,你应该记住有
124有很多不同的人会读你的话。其中包括子系统维护人员和审查人员,他们需要决定是否131很多不同的人会读你的话。其中包括子系统维护人员和审查人员,他们需要决定是否
125应该包括补丁,分销商和其他维护人员试图决定是否应该将补丁反向移植到其他内核,132应该合并补丁,分销商和其他维护人员试图决定是否应该将补丁反向移植到其他内核,
126bug搜寻人员想知道补丁是否负责他们正在追查的问题,想知道内核如何变化的用户。133缺陷搜寻人员想知道补丁是否导致他们正在追查的问题,以及想知道内核如何变化的
127等等。一个好的变更日志以最直接和最简洁的方式向所有这些人传达所需的信息。134用户等等。一个好的变更日志以最直接和最简洁的方式向所有这些人传达所需的信息。
128 135
129为此,总结行应该描述变更的影响和动机,以及在一行约束条件下可能发生的变化。136在结尾,总结行应该描述变更的影响和动机,以及在一行约束条件下可能发生的变化。
130然后,详细的描述可以详述这些主题,并提供任何需要的附加信息。如果补丁修复了137然后,详细的描述可以详述这些主题,并提供任何需要的附加信息。如果补丁修复了
131一个bug,请引用引入该bug的commit(如果可能,请在引用commits时同时提供commit id138一个缺陷,请引用引入该缺陷的提交(如果可能,请在引用提交时同时提供其 id 和
132和标题)。如果某个问题与特定的日志或编译器输出相关联,请包含该输出以帮助其他139标题)。如果某个问题与特定的日志或编译器输出相关联,请包含该输出以帮助其他
133人搜索同一问题的解决方案。如果更改是为了支持以后补丁中的其他更改,那么就这么140人搜索同一问题的解决方案。如果更改是为了支持以后补丁中的其他更改,那么应当
134说。如果更改了内部API,请详细说明这些更改以及其他开发人员应该如何响应。一般141说明。如果更改了内部API,请详细说明这些更改以及其他开发人员应该如何响应。
135来说,你越能把自己放在每个阅读你的changelog的人的位置上,changelog(和内核142一般来说,你越把自己放在每个阅读你变更日志的人的位置上,变更日志(和内核
136作为一个整体)就越好。143作为一个整体)就越好。
137 144
138不用说,变更日志应该是将变更提交到修订控制系统时使用的文本。接下来是:145不消说,变更日志是将变更提交到版本控制系统时使用的文本。接下来将是:
139 146
140 - 补丁本身,采用统一的(“-u”)补丁格式。将“-p”选项用于diff将使函数名与更改147 - 补丁本身,采用统一的(“-u”)补丁格式。使用“-p”选项来diff将使函数名与
141 相关联,从而使结果补丁更容易被其他人读取。148 更改相关联,从而使结果补丁更容易被其他人读取。
142 149
143您应该避免在补丁中包括对不相关文件(例如,由构建过程生成的文件或编辑器150您应该避免在补丁中包括与更改不相关文件(例如,构建过程生成的文件或编辑器
144备份文件)的更改。文档目录中的文件“dontdiff”在这方面有帮助;使用“-X”选项将151备份文件)。文档目录中的“dontdiff”文件在这方面有帮助;使用“-X”选项将
145其传递给diff。152其传递给diff。
146 153
147上面提到的标签用于描述各种开发人员如何与这个补丁的开发相关联。154上面提到的标签(tag)用于描述各种开发人员如何与这个补丁的开发相关联。
148:ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`155:ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`
149文档中对它们进行了详细描述;下面是一个简短的总结。每一行的格式如下:156文档中对它们进行了详细描述;下面是一个简短的总结。每一行的格式如下:
150 157
@@ -154,87 +161,87 @@ bug搜寻人员想知道补丁是否负责他们正在追查的问题,想知 · 3 unmodified lines
154 161
155常用的标签有:162常用的标签有:
156 163
157 - Signed-off-by: 这是一个开发人员的证明,他或她有权提交补丁以包含到内核中。164 - Signed-off-by: 这是一个开发人员的证明,证明他或她有权提交补丁以包含到内核
158 这是开发来源认证协议,其全文可在165 中。这表明同意开发者来源认证协议,其全文见
159 :ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`166 :ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`
160 中找到,如果没有适当的签字,则不能合并到主线中。167 如果没有合适的签字,则不能合并到主线中。
161 168
162 - Co-developed-by: 声明补丁是由多个开发人员共同创建的;当几个人在一个补丁上169 - Co-developed-by: 声明补丁是由多个开发人员共同创建的;当几个人在一个补丁上
163 工作时,它用于将属性赋予共同作者(除了 From: 所赋予的作者之外)。因为170 工作时,它用于给出共同作者(除了 From: 所给出的作者之外)。由于
164 Co-developed-by: 表示作者身份,所以每个共同开发人, 必须紧跟在相关合作作者171 Co-developed-by: 表示作者身份,所以每个共同开发人,必须紧跟在相关合作作者
165 的签名之后。具体内容和示例可以在以下文件中找到172 的Signed-off-by之后。具体内容和示例见以下文件
166 :ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`173 :ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`
167 174
168 - Acked-by: 表示另一个开发人员(通常是相关代码的维护人员)同意补丁适合包含175 - Acked-by: 表示另一个开发人员(通常是相关代码的维护人员)同意补丁适合包含
169 在内核中。176 在内核中。
170 177
171 - Tested-by: 声明指定的人已经测试了补丁并发现它可以工作。178 - Tested-by: 声明某人已经测试了补丁并确认它可以工作。
172 179
173 - Reviewed-by: 指定的开发人员已经审查了补丁的正确性;有关详细信息,请参阅180 - Reviewed-by: 表示某开发人员已经审查了补丁的正确性;有关详细信息,请参阅
174 :ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`181 :ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`
175 182
176 - Reported-by: 指定报告此补丁修复的问题的用户;此标记用于提供感谢。183 - Reported-by: 指定报告此补丁修复的问题的用户;此标记用于表示感谢。
177 184
178 - Cc:指定的人收到了补丁的副本,并有机会对此发表评论。185 - Cc:指定某人收到了补丁的副本,并有机会对此发表评论。
179 186
180在补丁中添加标签时要小心:只有cc:才适合在没有指定人员明确许可的情况下添加。187在补丁中添加标签时要小心:只有Cc:才适合在没有指定人员明确许可的情况下添加。
181 188
182发送补丁189发送补丁
183--------190--------
184 191
185在邮寄补丁之前,您还需要注意以下几点:192在寄出补丁之前,您还需要注意以下几点:
186 193
187 - 您确定您的邮件发送程序不会损坏补丁吗?有免费的空白更改或由邮件客户端194 - 您确定您的邮件发送程序不会损坏补丁吗?被邮件客户端更改空白或修饰了行的补丁
188 执行的行包装的补丁不会在另一端复原,并且通常不会进行任何详细检查。如果有195 无法被另一端接受,并且通常不会进行任何详细检查。如果有任何疑问,先把补丁寄
189 任何疑问,把补丁寄给你自己,让你自己相信它是完好无损的。196 给你自己,让你自己确定它是完好无损的。
190 197
191 :ref:`Documentation/translations/zh_CN/process/email-clients.rst <cn_email_clients>`198 :ref:`Documentation/translations/zh_CN/process/email-clients.rst <cn_email_clients>`
192 提供了一些有用的提示,可以让特定的邮件客户机工作以发送补丁。199 提供了一些有用的提示,可以让特定的邮件客户端正常发送补丁。
193 200
194 - 你确定你的补丁没有愚蠢的错误吗?您应该始终通过scripts/checkpatch.pl运行201 - 你确定你的补丁没有荒唐的错误吗?您应该始终通过scripts/checkpatch.pl检查
195 补丁程序,并解决它提出的投诉。请记住,checkpatch.pl虽然是大量思考内核202 补丁程序,并解决它提出的问题。请记住,checkpatch.pl,虽然体现了对内核补丁
196 补丁应该是什么样子的体现,但它并不比您聪明。如果修复checkpatch.pl投诉会203 应该是什么样的大量思考,但它并不比您聪明。如果修复checkpatch.pl给的问题会
197 使代码变得更糟,请不要这样做。204 使代码变得更糟,请不要这样做。
198 205
199补丁应始终以纯文本形式发送。请不要将它们作为附件发送;这使得审阅者在答复中更难206补丁应始终以纯文本形式发送。请不要将它们作为附件发送;这使得审阅者在答复中更难
200引用补丁的部分。相反,只需将补丁直接放到您的消息中。207引用补丁的部分。相反,只需将补丁直接放到您的消息中。
201 208
202邮寄补丁时,重要的是将副本发送给任何可能感兴趣的人。与其他一些项目不同,内核209寄出补丁时,重要的是将副本发送给任何可能感兴趣的人。与其他一些项目不同,内核
203鼓励人们错误地发送过多的副本;不要假定相关人员会看到您在邮件列表中的发布。210鼓励人们甚至错误地发送过多的副本;不要假定相关人员会看到您在邮件列表中的发布。
204尤其是,副本应发送至:211尤其是,副本应发送至:
205 212
206 - 受影响子系统的维护人员。如前所述,维护人员文件是查找这些人员的第一个地方。213 - 受影响子系统的维护人员。如前所述,维护人员文件是查找这些人员的首选地方。
207 214
208 - 其他在同一领域工作的开发人员,尤其是那些现在可能在那里工作的开发人员。使用215 - 其他在同一领域工作的开发人员,尤其是那些现在可能在那里工作的开发人员。使用
209 git查看还有谁修改了您正在处理的文件,这很有帮助。216 git查看还有谁修改了您正在处理的文件,这很有帮助。
210 217
211 - 如果您对错误报告或功能请求做出响应,也可以抄送原始发送人。218 - 如果您对某错误报告或功能请求做出响应,也可以抄送原始发送人。
212 219
213 - 将副本发送到相关邮件列表,或者,如果没有其他应用,则发送到Linux内核列表。220 - 将副本发送到相关邮件列表,或者若无相关列表,则发送到linux-kernel列表。
214 221
215 - 如果您正在修复一个bug,请考虑该修复是否应进入下一个稳定更新。如果是这样,222 - 如果您正在修复一个缺陷,请考虑该修复是否应进入下一个稳定更新。如果是这样,
216 stable@vger.kernel.org 应该得到补丁的副本。另外,在补丁本身的标签中添加223 补丁副本也应发到stable@vger.kernel.org 。另外,在补丁本身的标签中添加一个
217 一个“cc:stable@vger.kernel.org”;这将使稳定团队在修复进入主线时收到通知。224 “Cc: stable@vger.kernel.org”;这将使稳定版团队在修复进入主线时收到通知。
218 225
219当为一个补丁选择接收者时,最好知道你认为谁最终会接受这个补丁并将其合并。虽然226当为一个补丁选择接收者时,最好清楚你认为谁最终会接受这个补丁并将其合并。虽然
220可以将补丁直接发送给LinusTorvalds并让他合并,但通常情况下不会这样做。Linus227可以将补丁直接发给Linus Torvalds并让他合并,但通常情况下不会这样做。Linus很
221很忙,并且有子系统维护人员负责监视内核的特定部分。通常您会希望维护人员合并您228忙,并且有子系统维护人员负责监视内核的特定部分。通常您会希望维护人员合并您的
222的补丁。如果没有明显的维护人员,Andrew Morton通常是最后的补丁目标。229补丁。如果没有明显的维护人员,Andrew Morton通常是最后的补丁接收者。
223 230
224补丁需要好的主题行。补丁程序行的规范格式如下:231补丁需要好的主题行。补丁主题行的规范格式如下:
225 232
226::233::
227 234
228 [PATCH nn/mm] subsys: one-line description of the patch235 [PATCH nn/mm] subsys: one-line description of the patch
229 236
230其中“nn”是补丁的序号,“mm”是系列中补丁的总数,“subsys”是受影响子系统的名称。237其中“nn”是补丁的序号,“mm”是系列中补丁的总数,“subsys”是受影响子系统的
231显然,一个单独的补丁可以省略nn/mm。238名称。当然,一个单独的补丁可以省略nn/mm。
232 239
233如果您有一系列重要的补丁,那么通常将介绍性描述作为零部分发送。不过,这种约定240如果您有一系列重要的补丁,那么通常发送一个简介作为第〇部分。不过,这个约定
234并没有得到普遍遵循;如果您使用它,请记住简介中的信息不会使它进入内核变更日志。241并没有得到普遍遵循;如果您使用它,请记住简介中的信息不会进入内核变更日志。
235因此,请确保补丁本身具有完整的变更日志信息。242因此,请确保补丁本身具有完整的变更日志信息。
236 243
237一般来说,多部分补丁的第二部分和后续部分应作为对第一部分的回复发送,以便它们244一般来说,多部分补丁的第二部分和后续部分应作为对第一部分的回复发送,以便它们
238在接收端都连接在一起。像git和coilt这样的工具有命令,可以通过适当的线程发送245在接收端都连接在一起。像git和coilt这样的工具有命令,可以通过适当的线程发送
239一组补丁。但是,如果您有一个长系列,并且正在使用git,请远离–chain reply-to246一组补丁。但是,如果您有一长串补丁,并正使用git,请不要使用–-chain-reply-to
240选项,以避免创建异常深的嵌套。247选项,以避免创建过深的嵌套。
Documentation/translations/zh_CN/process/6.Followthrough.rst+86−79
@@ -1,145 +1,152 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/6.Followthrough.rst <development_followthrough>`3:Original: :ref:`Documentation/process/6.Followthrough.rst <development_followthrough>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_followthrough:13.. _cn_development_followthrough:
7 14
8跟进15跟进
9====16====
10 17
11在这一点上,您已经遵循了到目前为止给出的指导方针,并且,随着您自己的工程技能18此时,您已经遵循了到目前为止给出的指导方针,并且,随着您自己的工程技能的增加,
12的增加,已经发布了一系列完美的补丁。即使是经验丰富的内核开发人员也能犯的最大19已经发布了一系列完美的补丁。即使是经验丰富的内核开发人员也能犯的最大错误之一
13错误之一是,认为他们的工作现在已经完成了。事实上,发布补丁意味着进入流程的下20是,认为他们的工作现在已经完成了。事实上,发布补丁意味着进入流程的下一个阶段,
14一个阶段,可能还需要做很多工作。21可能还需要做很多工作。
15 22
16一个补丁在第一次发布时就非常出色,没有改进的余地,这是很罕见的。内核开发流程23一个补丁在首次发布时就非常出色、没有改进的余地,这是很罕见的。内核开发流程已
17认识到这一事实,因此,它非常注重对已发布代码的改进。作为代码的作者,您应该与24认识到这一事实,因此它非常注重对已发布代码的改进。作为代码的作者,您应该与
18内核社区合作,以确保您的代码符合内核的质量标准。如果不参与这个过程,很可能会25内核社区合作,以确保您的代码符合内核的质量标准。如果不参与这个过程,很可能会
19阻止将补丁包含到主线中。26无法将补丁合并到主线中。
20 27
21与审阅者合作28与审阅者合作
22------------29------------
23 30
24任何意义上的补丁都会导致其他开发人员在审查代码时发表大量评论。对于许多开发31任何意义上的补丁都会导致其他开发人员在审查代码时发表大量评论。对于许多开发
25人员来说,与审查人员合作可能是内核开发过程中最令人生畏的部分。但是,如果你32人员来说,与审阅人员合作可能是内核开发过程中最令人生畏的部分。但是如果你
26记住一些事情,生活会变得容易得多:33记住一些事情,生活会变得容易得多:
27 34
28 - 如果你已经很好地解释了你的补丁,评论人员会理解它的价值,以及为什么你会35 - 如果你已经很好地解释了你的补丁,审阅人员会理解它的价值,以及为什么你会
29 费尽心思去写它。但是这个并不能阻止他们提出一个基本的问题:五年或十年后36 费尽心思去写它。但是这个并不能阻止他们提出一个基本的问题:在五年或十年后
30 用这个代码维护一个内核会是什么感觉?你可能被要求做出的许多改变——从编码风格37 维护含有此代码的内核会怎么样?你可能被要求做出的许多改变——从编码风格的
31 的调整到大量的重写——都来自于对Linux的理解,即从现在起十年后,Linux仍将在38 调整到大量的重写——都来自于对Linux的理解,即从现在起十年后,Linux仍将
32 开发中。39 在开发中。
33 40
34 - 代码审查是一项艰苦的工作,这是一项相对吃力不讨好的工作;人们记得谁编写了41 - 代码审查是一项艰苦的工作,这是一项相对吃力不讨好的工作;人们记得谁编写了
35 内核代码,但对于那些审查它的人来说,几乎没有什么持久的名声。因此,评论42 内核代码,但对于那些审查它的人来说,几乎没有什么长久的名声。因此,审阅
36 人员可能会变得暴躁,尤其是当他们看到同样的错误被一遍又一遍地犯下时。如果43 人员可能会变得暴躁,尤其是当他们看到同样的错误被一遍又一遍地犯下时。如果
37 你得到了一个看起来愤怒、侮辱或完全冒犯你的评论,抵制以同样方式回应的冲动。44 你得到了一个看起来愤怒、侮辱或完全冒犯你的评论,请抑制以同样方式回应的冲动。
38 代码审查是关于代码的,而不是关于人的,代码审查人员不会亲自攻击您。45 代码审查是关于代码的,而不是关于人的,代码审阅人员不会亲自攻击您。
39 46
40 - 同样,代码审查人员也不想以牺牲你雇主的利益为代价来宣传他们雇主的议程。47 - 同样,代码审阅人员也不想以牺牲你雇主的利益为代价来宣传他们雇主的议程。
41 内核开发人员通常希望今后几年能在内核上工作,但他们明白他们的雇主可能会改48 内核开发人员通常希望今后几年能在内核上工作,但他们明白他们的雇主可能会改
42 变。他们真的,几乎毫无例外地,致力于创造他们所能做到的最好的内核;他们并49 变。他们真的,几乎毫无例外地,致力于创造他们所能做到的最好的内核;他们并
43 没有试图给雇主的竞争对手造成不适。50 没有试图给雇主的竞争对手造成不适。
44 51
45所有这些归根结底都是,当审阅者向您发送评论时,您需要注意他们正在进行的技术52所有这些归根结底就是,当审阅者向您发送评论时,您需要注意他们正在进行的技术
46观察。不要让他们的表达方式或你自己的骄傲阻止这种事情的发生。当你在一个补丁53评论。不要让他们的表达方式或你自己的骄傲阻止此事。当你在一个补丁上得到评论
47上得到评论时,花点时间去理解评论人想说什么。如果可能的话,请修复审阅者要求54时,花点时间去理解评论人想说什么。如果可能的话,请修复审阅者要求您修复的内
48您修复的内容。然后回复审稿人:谢谢他们,并描述你将如何回答他们的问题。55容。然后回复审阅者:谢谢他们,并描述你将如何回答他们的问题。
49 56
50请注意,您不必同意审阅者建议的每个更改。如果您认为审阅者误解了您的代码,请57请注意,您不必同意审阅者建议的每个更改。如果您认为审阅者误解了您的代码,请
51解释到底发生了什么。如果您对建议的更改有技术上的异议,请描述它并证明您对该58解释到底发生了什么。如果您对建议的更改有技术上的异议,请描述它并证明您对该
52问题的解决方案是正确的。如果你的解释有道理,审稿人会接受的。不过,如果你的59问题的解决方案是正确的。如果你的解释有道理,审阅者会接受的。不过,如果你的
53解释不能证明是有说服力的,尤其是当其他人开始同意审稿人的观点时,请花些时间60解释证明缺乏说服力,尤其是当其他人开始同意审稿人的观点时,请花些时间重新考虑
54重新考虑一下。你很容易对自己解决问题的方法视而不见,以至于你没有意识到某个61一下。你很容易对自己解决问题的方法视而不见,以至于你没有意识到某些东西完全
55问题根本是错误的,或者你甚至没有解决正确的问题。62是错误的,或者你甚至没有解决正确的问题。
56 63
57Andrew Morton建议,每一条不会导致代码更改的评论都应该导致额外的代码注释;64Andrew Morton建议,每一个不会导致代码更改的审阅评论都应该产生一个额外的代码
58这可以帮助未来的评论人员避免出现第一次出现的问题。65注释;这可以帮助未来的审阅人员避免第一次出现的问题。
59 66
60一个致命的错误是忽视评论,希望它们会消失。他们不会走的。如果您在没有对之前67一个致命的错误是忽视评论,希望它们会消失。它们不会走的。如果您在没有对之前
61收到的注释做出响应的情况下重新发布代码,那么很可能会发现补丁毫无用处。68收到的评论做出响应的情况下重新发布代码,那么很可能会发现补丁毫无用处。
62 69
63说到重新发布代码:请记住,审阅者不会记住您上次发布的代码的所有细节。因此,70说到重新发布代码:请记住,审阅者不会记住您上次发布的代码的所有细节。因此,
64提醒审查人员以前提出的问题以及您如何处理这些问题总是一个好主意;补丁变更71提醒审阅人员以前提出的问题以及您如何处理这些问题总是一个好主意;补丁变更
65日志是提供此类信息的好地方。审阅者不必搜索列表档案来熟悉上次所说的内容;72日志是提供此类信息的好地方。审阅者不必搜索列表档案来熟悉上次所说的内容;
66如果您帮助他们开始运行,当他们重新访问您的代码时,他们的心情会更好。73如果您帮助他们直接开始,当他们重新查看您的代码时,心情会更好。
67 74
68如果你已经试着做正确的事情,但事情仍然没有进展呢?大多数技术上的分歧都可以75如果你已经试着做正确的事情,但事情仍然没有进展呢?大多数技术上的分歧都可以
69通过讨论来解决,但有时人们只需要做出决定。如果你真的认为这个决定对你不利,76通过讨论来解决,但有时人们仍需要做出决定。如果你真的认为这个决定对你不利,
70你可以试着向更高的权力上诉。在这篇文章中,更高的权力倾向于Andrew Morton。77你可以试着向有更高权力的人上诉。对于本文,更高权力的人是 Andrew Morton 。
71Andrew在内核开发社区中受i很大的尊重;他经常为似乎被绝望地阻塞事情清障。78Andrew 在内核开发社区中非常受尊敬;他经常为似乎被绝望阻塞的事情清障。尽管
72尽管如此,对Andrew的呼吁不应轻而易举,也不应在所有其他替代方案都被探索之前79如此,不应轻易就直接找 Andrew ,也不应在所有其他替代方案都被尝试之前找他。
73使用。当然,记住,他也可能不同意你的意见。80当然,记住,他也可能不同意你的意见。
74 81
75接下来会发生什么82接下来会发生什么
76----------------83----------------
77 84
78如果一个补丁被认为是添加到内核中的一件好事,并且一旦大多数审查问题得到解决,85如果一个补丁被认为适合添加到内核中,并且大多数审查问题得到解决,下一步通常
79下一步通常是进入子系统维护人员的树中。工作方式因子系统而异;每个维护人员都86是进入子系统维护人员的树中。工作方式因子系统而异;每个维护人员都有自己的
80有自己的工作方式。特别是,可能有不止一棵树——一棵树,也许,专门用于计划下一87工作方式。特别是可能有不止一棵树——也许一棵树专门用于计划下一个合并窗口的
81个合并窗口的补丁,另一棵树用于长期工作。88补丁,另一棵树用于长期工作。
82 89
83对于应用于没有明显子系统树(例如内存管理修补程序)的区域的修补程序,默认树90对于应用到不属于明显子系统树(例如内存管理修补程序)的区域的修补程序,默认树
84通常以-mm结尾。影响多个子系统的补丁也可以最终通过-mm树。91通常上溯到-mm。影响多个子系统的补丁也可以最终进入-mm树。
85 92
86包含在子系统树中可以提高补丁的可见性。现在,使用该树的其他开发人员将默认获93包含在子系统树中可以提高补丁的可见性。现在,使用该树的其他开发人员将默认获
87得补丁。子系统树通常也为Linux提供支持,使其内容对整个开发社区可见。在这一点94得补丁。子系统树通常也为Linux提供支持,使其内容对整个开发社区可见。在这一点
88上,您很可能会从一组新的审阅者那里得到更多的评论;这些评论需要像上一轮那样95上,您很可能会从一组新的审阅者那里得到更多的评论;这些评论需要像上一轮那样
89得到回答。96得到回应。
90 97
91在这一点上也会发生什么,这取决于你的补丁的性质,是与其他人正在做的工作发生98在这时也会发生点什么,这取决于你的补丁的性质,是否与其他人正在做的工作发生
92冲突。在最坏的情况下,严重的补丁冲突可能会导致一些工作被搁置,以便剩余的补丁99冲突。在最坏的情况下,严重的补丁冲突可能会导致一些工作被搁置,以便剩余的补丁
93可以成形并合并。另一些时候,冲突解决将涉及到与其他开发人员合作,可能还会100可以成形并合并。另一些时候,冲突解决将涉及到与其他开发人员合作,可能还会
94在树之间移动一些补丁,以确保所有的应用都是干净的。这项工作可能是一件痛苦的101在树之间移动一些补丁,以确保所有的应用都是干净的。这项工作可能是一件痛苦的
95事情,但要计算您的福祉:在Linux下一棵树出现之前,这些冲突通常只在合并窗口102事情,但也需庆幸现在的幸福:在linux-next树出现之前,这些冲突通常只在合并窗口
96中出现,必须迅速解决。现在可以在合并窗口打开之前,在空闲时解决这些问题。103中出现,必须迅速解决。现在可以在合并窗口打开之前的空闲时间解决这些问题。
97 104
98有朝一日,如果一切顺利,您将登录并看到您的补丁已经合并到主线内核中。祝贺你!105有朝一日,如果一切顺利,您将登录并看到您的补丁已经合并到主线内核中。祝贺你!
99然而,一旦庆祝活动完成(并且您已经将自己添加到维护人员文件中),就值得记住106然而,一旦庆祝完了(并且您已经将自己添加到维护人员文件中),就一定要记住
100一个重要的小事实:工作仍然没有完成。并入主线带来了自身的挑战。107一个重要的小事实:工作仍然没有完成。并入主线也带来了它的挑战。
101 108
102首先,补丁的可见性再次提高。可能会有新一轮的开发者评论,他们以前不知道这109首先,补丁的可见性再次提高。可能会有以前不知道这个补丁的开发者的新一轮评论。
103个补丁。忽略它们可能很有诱惑力,因为您的代码不再存在任何被合并的问题。但是,110忽略它们可能很有诱惑力,因为您的代码不再存在任何被合并的问题。但是,要抵制
104要抵制这种诱惑,您仍然需要对有问题或建议的开发人员作出响应。111这种诱惑,您仍然需要对有问题或建议的开发人员作出响应。
105 112
106不过,更重要的是:将代码包含在主线中会将代码交给更大的一组测试人员。即使您113不过,更重要的是:将代码包含在主线中会将代码交给更多的一些测试人员。即使您
107为尚未提供的硬件提供了驱动程序,您也会惊讶于有多少人会将您的代码构建到内核114为尚未可用的硬件提供了驱动程序,您也会惊讶于有多少人会将您的代码构建到内核
108中。当然,如果有测试人员,也会有错误报告。115中。当然,如果有测试人员,也可能会有错误报告。
109 116
110最糟糕的错误报告是回归。如果你的补丁导致回归,你会发现很多不舒服的眼睛盯着117最糟糕的错误报告是回归。如果你的补丁导致回归,你会发现多到让你不舒服的眼睛盯
111你;回归需要尽快修复。如果您不愿意或无法修复回归(其他人都不会为您修复),118着你;回归需要尽快修复。如果您不愿意或无法修复回归(其他人都不会为您修复),
112那么在稳定期内,您的补丁几乎肯定会被移除。除了否定您为使补丁进入主线所做的119那么在稳定期内,您的补丁几乎肯定会被移除。除了否定您为使补丁进入主线所做的
113所有工作之外,如果由于未能修复回归而取消补丁,很可能会使将来的工作更难合并。120所有工作之外,如果由于未能修复回归而取消补丁,很可能会使将来的工作更难被合并。
114 121
115在处理完任何回归之后,可能还有其他普通的bug需要处理。稳定期是修复这些错误并122在处理完任何回归之后,可能还有其他普通缺陷需要处理。稳定期是修复这些错误并
116确保代码在主线内核版本中的首次发布尽可能可靠的最好机会。所以,请回答错误123确保代码在主线内核版本中的首次发布尽可能可靠的最好机会。所以,请回应错误
117报告,并尽可能解决问题。这就是稳定期的目的;一旦解决了旧补丁的任何问题,就124报告,并尽可能解决问题。这就是稳定期的目的;一旦解决了旧补丁的任何问题,就
118可以开始创建酷的新补丁。125可以开始尽情创建新补丁。
119 126
120别忘了,还有其他里程碑也可能会创建bug报告:下一个主线稳定版本,当著名的发行127别忘了,还有其他节点也可能会创建缺陷报告:下一个主线稳定版本,当著名的发行
121商选择包含补丁的内核版本时,等等。继续响应这些报告是您工作的基本骄傲。但是,128商选择包含您补丁的内核版本时等等。继续响应这些报告是您工作的基本素养。但是
122如果这不是足够的动机,那么也值得考虑的是,开发社区会记住那些在合并后对代码129如果这不能提供足够的动机,那么也需要考虑:开发社区会记住那些在合并后对代码
123失去兴趣的开发人员。下一次你发布补丁时,他们会以你以后不会在身边维护它为假130失去兴趣的开发人员。下一次你发布补丁时,他们会以你以后不会持续维护它为前提
124设来评估它。131来评估它。
125 132
126其他可能发生的事情133其他可能发生的事情
127------------------134------------------
128 135
129有一天,你可以打开你的邮件客户端,看到有人给你寄了一个代码补丁。毕竟,这是136某天,当你打开你的邮件客户端时,看到有人给你寄了一个代码补丁。毕竟,这是
130让您的代码公开存在的好处之一。如果您同意这个补丁,您可以将它转发给子系统137让您的代码公开存在的好处之一。如果您同意这个补丁,您可以将它转发给子系统
131维护人员(确保包含一个正确的From:行,这样属性是正确的,并添加一个您自己138维护人员(确保包含一个正确的From:行,这样属性是正确的,并添加一个您自己的
132的签准),或者回复一个Acked-by,让原始发送者向上发送它。139signoff ),或者回复一个 Acked-by: 让原始发送者向上发送它。
133 140
134如果您不同意补丁,请发送一个礼貌的回复,解释原因。如果可能的话,告诉作者需要141如果您不同意补丁,请礼貌地回复,解释原因。如果可能的话,告诉作者需要做哪些
135做哪些更改才能让您接受补丁。对于代码的编写者和维护者所反对的合并补丁,存在着142更改才能让您接受补丁。合并代码的编写者和维护者所反对的补丁的确存在着一定的
136一定的阻力,但仅此而已。如果你被认为不必要的阻碍了好的工作,那么这些补丁最143阻力,但仅此而已。如果你被认为不必要的阻碍了好的工作,那么这些补丁最终会
137终会经过你身边并进入主线。在Linux内核中,没有人对任何代码拥有绝对的否决权。144绕过你并进入主线。在Linux内核中,没有人对任何代码拥有绝对的否决权。可能除
138除了Linus。145了Linus。
139 146
140在非常罕见的情况下,您可能会看到完全不同的东西:另一个开发人员发布了针对您147在非常罕见的情况下,您可能会看到完全不同的东西:另一个开发人员发布了针对您
141的问题的不同解决方案。在这一点上,两个补丁中的一个可能不会合并,“我的在这里148的问题的不同解决方案。在这时,两个补丁之一可能不会被合并,“我的补丁首先
142是第一个”不被认为是一个令人信服的技术论据。如果有人的补丁取代了你的补丁而进149发布”不被认为是一个令人信服的技术论据。如果有别人的补丁取代了你的补丁而进
143入了主线,那么只有一种方法可以回应你:高兴你的问题得到解决,继续你的工作。150入了主线,那么只有一种方法可以回应你:很高兴你的问题解决了,请继续工作吧。
144以这种方式把一个人的工作推到一边可能会伤害和气馁,但是在他们忘记了谁的补丁151以这种方式把某人的工作推到一边可能导致伤心和气馁,但是社区会记住你的反应,
145真正被合并很久之后,社区会记住你的反应。152即使很久以后他们已经忘记了谁的补丁真正被合并。
Documentation/translations/zh_CN/process/7.AdvancedTopics.rst+75−66
@@ -1,7 +1,14 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/7.AdvancedTopics.rst <development_advancedtopics>`3:Original: :ref:`Documentation/process/7.AdvancedTopics.rst <development_advancedtopics>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4
5:Translator:
6
7 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
8
9:校译:
10
11 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 12
6.. _cn_development_advancedtopics:13.. _cn_development_advancedtopics:
7 14
@@ -15,110 +22,112 @@ · 7 unmodified lines
15---------------22---------------
16 23
17内核使用分布式版本控制始于2002年初,当时Linus首次开始使用专有的Bitkeeper应用24内核使用分布式版本控制始于2002年初,当时Linus首次开始使用专有的Bitkeeper应用
18程序。虽然bitkeeper存在争议,但它所体现的软件版本管理方法却肯定不是。分布式25程序。虽然BitKeeper存在争议,但它所体现的软件版本管理方法却肯定不是。分布式
19版本控制可以立即加速内核开发项目。在当前的时代,有几种免费的比特保持器替代品。26版本控制可以立即加速内核开发项目。现在有好几种免费的BitKeeper替代品。
20无论好坏,内核项目都将Git作为其选择的工具。27但无论好坏,内核项目都已经选择了Git作为其工具。
21 28
22使用Git管理补丁可以使开发人员的生活更加轻松,尤其是随着补丁数量的增加。Git29使用Git管理补丁可以使开发人员的生活更加轻松,尤其是随着补丁数量的增长。Git也
23也有其粗糙的边缘和一定的危险,它是一个年轻和强大的工具,仍然在其开发人员完善30有其粗糙的边角和一定的危险性,它是一个年轻和强大的工具,仍然在其开发人员完善
24中。本文档不会试图教会读者如何使用git;这会是个巨长的文档。相反,这里的重点31中。本文档不会试图教会读者如何使用git;这会是个巨长的文档。相反,这里的重点
25将是Git如何特别适合内核开发过程。想要加快Git的开发人员可以在以下网站上找到32将是Git如何特别适合内核开发过程。想要加快用Git速度的开发人员可以在以下网站上
26更多信息:33找到更多信息:
27 34
28 https://git-scm.com/35 https://git-scm.com/
29 36
30 https://www.kernel.org/pub/software/scm/git/docs/user-manual.html37 https://www.kernel.org/pub/software/scm/git/docs/user-manual.html
31 38
32在尝试使用它使补丁可供其他人使用之前,第一要务是阅读上述站点,对Git的工作39同时网上也能找到各种各样的教程。
33方式有一个扎实的了解。使用Git的开发人员应该能够获得主线存储库的副本,探索40
34修订历史,提交对树的更改,使用分支等。了解Git用于重写历史的工具(如Rebase)41在尝试使用它生成补丁供他人使用之前,第一要务是阅读上述网页,对Git的工作方式
35也很有用。Git有自己的术语和概念;Git的新用户应该了解refs、远程分支、索引、42有一个扎实的了解。使用Git的开发人员应能进行拉取主线存储库的副本,查询修订
36快进合并、推拉、分离头等。一开始可能有点吓人,但这些概念不难通过一点学习来43历史,提交对树的更改,使用分支等操作。了解Git用于重写历史的工具(如rebase)
44也很有用。Git有自己的术语和概念;Git的新用户应该了解引用、远程分支、索引、
45快进合并、推拉、游离头等。一开始可能有点吓人,但这些概念不难通过一点学习来
37理解。46理解。
38 47
39使用git生成通过电子邮件提交的补丁是提高速度的一个很好的练习。48使用git生成通过电子邮件提交的补丁是提高速度的一个很好的练习。
40 49
41当您准备好开始安装Git树供其他人查看时,您当然需要一个可以从中提取的服务器。50当您准备好开始建立Git树供其他人查看时,无疑需要一个可以从中拉取的服务器。
42如果您有一个可以访问Internet的系统,那么使用git守护进程设置这样的服务器相51如果您有一个可以访问因特网的系统,那么使用git-daemon设置这样的服务器相对
43对简单。否则,免费的公共托管网站(例如github)开始出现在网络上。成熟的开发52简单。同时,免费的公共托管网站(例如github)也开始出现在网络上。成熟的开发
44人员可以在kernel.org上获得一个帐户,但这些帐户并不容易找到;有关更多信息,53人员可以在kernel.org上获得一个帐户,但这些帐户并不容易得到;更多有关信息,
45请参阅 https://kernel.org/faq/54请参阅 https://kernel.org/faq/ 。
46 55
47正常的Git工作流程涉及到许多分支的使用。每一条开发线都可以分为单独的“主题56正常的Git工作流程涉及到许多分支的使用。每一条开发线都可以分为单独的“主题
48分支”,并独立维护。Git的分支机构很便宜,没有理由不免费使用它们。而且,在57分支”,并独立维护。Git的分支很容易使用,没有理由不使用它们。而且,在任何
49任何情况下,您都不应该在任何您打算让其他人从中受益的分支中进行开发。应该58情况下,您都不应该在任何您打算让其他人从中拉取的分支中进行开发。应该小心地
50小心地创建公开可用的分支;当它们处于完整的形式并准备好运行时(而不是之前),59创建公开可用的分支;当开发分支处于完整状态并已准备好时(而不是之前)才合并
51合并开发分支的补丁。60开发分支的补丁。
52 61
53Git提供了一些强大的工具,可以让您重写开发历史。一个不方便的补丁(比如说,62Git提供了一些强大的工具,可以让您重写开发历史。一个不方便的补丁(比如说,
54一个打破二分法的补丁,或者有其他一些明显的缺陷)可以在适当的位置修复,或者63一个打破二分法的补丁,或者有其他一些明显的缺陷)可以在适当的位置修复,或者
55完全从历史中消失。一个补丁系列可以被重写,就好像它是在今天的主线之上写的64完全从历史中消失。一个补丁系列可以被重写,就好像它是在今天的主线上写的一样,
56一样,即使你已经花了几个月的时间在写它。可以透明地将更改从一个分支转移到另65即使你已经花了几个月的时间在写它。可以透明地将更改从一个分支转移到另一个
57一个分支。等等。明智地使用git修改历史的能力可以帮助创建问题更少的干净补丁集。66分支。等等。明智地使用git修改历史的能力可以帮助创建问题更少的干净补丁集。
58 67
59然而,过度使用这种能力可能会导致其他问题,而不仅仅是对创建完美项目历史的68然而,过度使用这种功能可能会导致其他问题,而不仅仅是对创建完美项目历史的
60简单痴迷。重写历史将重写该历史中包含的更改,将经过测试(希望)的内核树变69简单痴迷。重写历史将重写该历史中包含的更改,将经过测试(希望如此)的内核树
61为未经测试的内核树。但是,除此之外,如果开发人员没有对项目历史的共享视图,70变为未经测试的内核树。除此之外,如果开发人员没有共享项目历史,他们就无法
62他们就无法轻松地协作;如果您重写了其他开发人员拉入他们存储库的历史,您将71轻松地协作;如果您重写了其他开发人员拉入他们存储库的历史,您将使这些开发
63使这些开发人员的生活更加困难。因此,这里有一个简单的经验法则:被导出到其他72人员的生活更加困难。因此,这里有一个简单的经验法则:被导出到其他地方的历史
64人的历史在此后通常被认为是不可变的。73在此后通常被认为是不可变的。
65 74
66因此,一旦将一组更改推送到公开可用的服务器上,就不应该重写这些更改。如果您75因此,一旦将一组更改推送到公开可用的服务器上,就不应该重写这些更改。如果您
67尝试强制进行不会导致快进合并(即不共享同一历史记录的更改)的更改,Git将尝76尝试强制进行无法快进合并的更改(即不共享同一历史记录的更改),Git将尝试强制
68试强制执行此规则。可以重写此检查,有时可能需要重写导出的树。在树之间移动变77执行此规则。这可能覆盖检查,有时甚至需要重写导出的树。在树之间移动变更集以
69更集以避免Linux-next中的冲突就是一个例子。但这种行为应该是罕见的。这就是为78避免linux-next中的冲突就是一个例子。但这种行为应该是罕见的。这就是为什么
70什么开发应该在私有分支中进行(必要时可以重写)并且只有在公共分支处于合理的79开发应该在私有分支中进行(必要时可以重写)并且只有在公共分支处于合理的较新
71高级状态时才转移到公共分支中的原因之一。80状态时才转移到公共分支中的原因之一。
72 81
73当主线(或其他一组变更所基于的树)前进时,很容易与该树合并以保持领先地位。82当主线(或其他一组变更所基于的树)前进时,很容易与该树合并以保持领先地位。
74对于一个私有的分支,rebasing 可能是一个很容易跟上另一棵树的方法,但是一旦83对于一个私有的分支,rebasing 可能是一个很容易跟上另一棵树的方法,但是一旦
75一棵树被导出到全世界,rebasing就不是一个选项。一旦发生这种情况,就必须进行84一棵树被导出到外界,rebasing就不可取了。一旦发生这种情况,就必须进行完全
76完全合并(merge)。合并有时是很有意义的,但是过于频繁的合并会不必要地扰乱85合并(merge)。合并有时是很有意义的,但是过于频繁的合并会不必要地扰乱历史。
77历史。在这种情况下,建议的技术是不经常合并,通常只在特定的发布点(如主线-rc86在这种情况下建议的做法是不要频繁合并,通常只在特定的发布点(如主线-rc发布)
78发布)合并。如果您对特定的更改感到紧张,则可以始终在私有分支中执行测试合并。87合并。如果您对特定的更改感到紧张,则可以始终在私有分支中执行测试合并。在
79在这种情况下,git rerere 工具很有用;它记住合并冲突是如何解决的,这样您就88这种情况下,git“rerere”工具很有用;它能记住合并冲突是如何解决的,这样您
80不必重复相同的工作。89就不必重复相同的工作。
81 90
82关于Git这样的工具的一个最大的反复抱怨是:补丁从一个存储库到另一个存储库的91关于Git这样的工具的一个最大的反复抱怨是:补丁从一个存储库到另一个存储库的
83大量移动使得很容易陷入错误建议的变更中,这些变更避开审查雷达进入主线。当内92大量移动使得很容易陷入错误建议的变更中,这些变更避开审查雷达进入主线。当内
84核开发人员看到这种情况发生时,他们往往会感到不高兴;在Git树上放置未查看或93核开发人员看到这种情况发生时,他们往往会感到不高兴;在Git树上放置未审阅或
85主题外的补丁可能会影响您将来获取树的能力。引用Linus:94主题外的补丁可能会影响您将来让树被拉取的能力。引用Linus的话:
86 95
87::96::
88 97
89 你可以给我发补丁,但要我从你哪里取一个Git补丁,我需要知道你知道98 你可以给我发补丁,但当我从你那里拉取一个Git补丁时,我需要知道你清楚
90 你在做什么,我需要能够相信事情而不去检查每个个人改变。99 自己在做什么,我需要能够相信事情而 *无需* 手动检查每个单独的更改。
91 100
92(http://lwn.net/articles/224135/)。101(http://lwn.net/articles/224135/)。
93 102
94为了避免这种情况,请确保给定分支中的所有补丁都与相关主题紧密相关;“驱动程序103为了避免这种情况,请确保给定分支中的所有补丁都与相关主题紧密相关;“驱动程序
95修复”分支不应更改核心内存管理代码。而且,最重要的是,不要使用Git树来绕过104修复”分支不应更改核心内存管理代码。而且,最重要的是,不要使用Git树来绕过
96审查过程。不时的将树的摘要发布到相关的列表中,当时间合适时,请求105审查过程。不时的将树的摘要发布到相关的列表中,在合适时候请求linux-next中
97Linux-next 中包含该树。106包含该树。
98 107
99如果其他人开始发送补丁以包含到您的树中,不要忘记查看它们。还要确保您维护正确108如果其他人开始发送补丁以包含到您的树中,不要忘记审阅它们。还要确保您维护正确
100的作者信息; ``git am`` 工具在这方面做得最好,但是如果它通过第三方转发给您,109的作者信息; git “am”工具在这方面做得最好,但是如果补丁通过第三方转发给您,
101您可能需要在补丁中添加“From:”行。110您可能需要在补丁中添加“From:”行。
102 111
103请求pull操作时,请务必提供所有相关信息:树的位置、要拉的分支以及拉操作将导致112请求拉取时,请务必提供所有相关信息:树的位置、要拉取的分支以及拉取将导致的
104的更改。在这方面,git request pull 命令非常有用;它将按照其他开发人员的预期113更改。在这方面 git request-pull 命令非常有用;它将按照其他开发人员所期望的
105格式化请求,并检查以确保您记住了将这些更改推送到公共服务器。114格式化请求,并检查以确保您已记得将这些更改推送到公共服务器。
106 115
107审查补丁116审阅补丁
108--------117--------
109 118
110一些读者当然会反对将本节与“高级主题”放在一起,因为即使是刚开始的内核开发人员119一些读者显然会反对将本节与“高级主题”放在一起,因为即使是刚开始的内核开发人员
111也应该检查补丁。当然,学习如何在内核环境中编程没有比查看其他人发布的代码更好120也应该审阅补丁。当然,没有比查看其他人发布的代码更好的方法来学习如何在内核环境
112的方法了。此外,审阅者永远供不应求;通过查看代码,您可以对整个流程做出重大贡献。121中编程了。此外,审阅者永远供不应求;通过审阅代码,您可以对整个流程做出重大贡献。
113 122
114审查代码可能是一个令人生畏的前景,特别是对于一个新的内核开发人员来说,他们123审查代码可能是一副令人生畏的图景,特别是对一个新的内核开发人员来说,他们
115可能会对公开询问代码感到紧张,而这些代码是由那些有更多经验的人发布的。不过,124可能会对公开询问代码感到紧张,而这些代码是由那些有更多经验的人发布的。不过,
116即使是最有经验的开发人员编写的代码也可以得到改进。也许对评审员(所有评审员)125即使是最有经验的开发人员编写的代码也可以得到改进。也许对(所有)审阅者最好
117最好的建议是:把评审评论当成问题而不是批评。询问“在这条路径中如何释放锁?”126的建议是:把审阅评论当成问题而不是批评。询问“在这条路径中如何释放锁?”
118总是比说“这里的锁是错误的”更好。127总是比说“这里的锁是错误的”更好。
119 128
120不同的开发人员将从不同的角度审查代码。一些主要关注的是编码样式以及代码行是129不同的开发人员将从不同的角度审查代码。部分人会主要关注代码风格以及代码行是
121否有尾随空格。其他人将主要关注补丁作为一个整体实现的变更是否对内核有好处。130否有尾随空格。其他人会主要关注补丁作为一个整体实现的变更是否对内核有好处。
122然而,其他人会检查是否存在锁定问题、堆栈使用过度、可能的安全问题、在其他131同时也有人会检查是否存在锁问题、堆栈使用过度、可能的安全问题、在其他地方
123地方发现的代码重复、足够的文档、对性能的不利影响、用户空间ABI更改等。所有132发现的代码重复、足够的文档、对性能的不利影响、用户空间ABI更改等。所有类型
124类型的检查,如果它们导致更好的代码进入内核,都是受欢迎和值得的。133的检查,只要它们能引导更好的代码进入内核,都是受欢迎和值得的。
Documentation/translations/zh_CN/process/8.Conclusion.rst+33−27
@@ -1,7 +1,13 @@
1.. include:: ../disclaimer-zh_CN.rst1.. include:: ../disclaimer-zh_CN.rst
2 2
3:Original: :ref:`Documentation/process/8.Conclusion.rst <development_conclusion>`3:Original: :ref:`Documentation/process/8.Conclusion.rst <development_conclusion>`
4:Translator: Alex Shi <alex.shi@linux.alibaba.com>4:Translator:
5
6 时奎亮 Alex Shi <alex.shi@linux.alibaba.com>
7
8:校译:
9
10 吴想成 Wu XiangCheng <bobwxc@email.cn>
5 11
6.. _cn_development_conclusion:12.. _cn_development_conclusion:
7 13
@@ -9,56 +15,56 @@ · 1 unmodified line
9========15========
10 16
11关于Linux内核开发和相关主题的信息来源很多。首先是在内核源代码分发中找到的17关于Linux内核开发和相关主题的信息来源很多。首先是在内核源代码分发中找到的
12文档目录。顶级 :ref:`Documentation/translations/zh_CN/process/howto.rst <cn_process_howto>`18文档目录。顶级
13文件是一个重要的起点19:ref:`Documentation/translations/zh_CN/process/howto.rst <cn_process_howto>`
20文件是一个重要的起点;
14:ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`21:ref:`Documentation/translations/zh_CN/process/submitting-patches.rst <cn_submittingpatches>`
15和 :ref:`process/submitting-drivers.rst <submittingdrivers>`22和 :ref:`Documentation/transaltions/zh_CN/process/submitting-drivers.rst <cn_submittingdrivers>`
16也是所有内核开发人员都应该阅读的内容。许多内部内核API都是使用kerneldoc机制23也是所有内核开发人员都应该阅读的内容。许多内部内核API都是使用kerneldoc机制
17记录的;“make htmldocs”或“make pdfdocs”可用于以HTML或PDF格式生成这些文档(24记录的;“make htmldocs”或“make pdfdocs”可用于以HTML或PDF格式生成这些文档
18尽管某些发行版提供的tex版本会遇到内部限制,无法正确处理文档)。25(尽管某些发行版提供的tex版本会遇到内部限制,无法正确处理文档)。
19 26
20不同的网站在各个细节层次上讨论内核开发。您的作者想谦虚地建议用 https://lwn.net/27不同的网站在各个细节层次上讨论内核开发。本文作者想谦虚地建议用 https://lwn.net/
21作为来源;有关许多特定内核主题的信息可以通过以下网址的lwn内核索引找到:28作为来源;有关许多特定内核主题的信息可以通过以下网址的 LWN 内核索引找到:
22 29
23 http://lwn.net/kernel/index/30 http://lwn.net/kernel/index/
24 31
25除此之外,内核开发人员的一个宝贵资源是:32除此之外,内核开发人员的一个宝贵资源是:
26 33
27 https://kernelnewbies.org/34 https://kernelnewbies.org/
28 35
29当然,我们不应该忘记 https://kernel.org/ 这是内核发布信息的最终位置。36当然,也不应该忘记 https://kernel.org/ ,这是内核发布信息的最终位置。
30 37
31关于内核开发有很多书:38关于内核开发有很多书:
32 39
33 Linux设备驱动程序,第三版(Jonathan Corbet、Alessandro Rubini和Greg Kroah Hartman)。40 《Linux设备驱动程序》第三版(Jonathan Corbet、Alessandro Rubini和Greg Kroah Hartman)
34 在线:http://lwn.net/kernel/ldd3/41 线上版本在 http://lwn.net/kernel/ldd3/
35 42
36 Linux内核开发(Robert Love)。43 《Linux内核设计与实现》(Robert Love)
37 44
38 了解Linux内核(Daniel Bovet和Marco Cesati)。45 《深入理解Linux内核》(Daniel Bovet和Marco Cesati)
39 46
40然而,所有这些书都有一个共同的缺点:当它们上架时,它们往往有些过时,而且它们47然而,所有这些书都有一个共同的缺点:它们上架时就往往有些过时,而且已经上架
41已经上架一段时间了。不过,在那里还可以找到相当多的好信息。48一段时间了。不过,在那里还是可以找到相当多的好信息。
42 49
43有关git的文档,请访问:50有关git的文档,请访问:
44 51
45 https://www.kernel.org/pub/software/scm/git/docs/52 https://www.kernel.org/pub/software/scm/git/docs/
46 53
47 https://www.kernel.org/pub/software/scm/git/docs/user-manual.html54 https://www.kernel.org/pub/software/scm/git/docs/user-manual.html
48 55
49结论56结论
50====57====
51 58
52祝贺所有通过这篇冗长的文件的人。希望它能够帮助您理解Linux内核是如何开发的,59祝贺所有通过这篇冗长的文档的人。希望它能够帮助您理解Linux内核是如何开发的,
53以及您如何参与这个过程。60以及您如何参与这个过程。
54 61
55最后,重要的是参与。任何开源软件项目都不超过其贡献者投入其中的总和。Linux内核62最后,重要的是参与。任何开源软件项目都不会超过其贡献者投入其中的总和。Linux
56的发展速度和以前一样快,因为它得到了大量开发人员的帮助,他们都在努力使它变得63内核的发展速度和以前一样快,因为它得到了大量开发人员的帮助,他们都在努力使它
57更好。内核是一个主要的例子,说明当成千上万的人为了一个共同的目标一起工作时,64变得更好。内核是一个最成功的例子,说明了当成千上万的人为了一个共同的目标一起
58可以做些什么。65工作时,可以做出什么。
59 66
60不过,内核总是可以从更大的开发人员基础中获益。总有更多的工作要做。但是,同样67不过,内核总是可以从更大的开发人员基础中获益。总有更多的工作要做。但是同样
61重要的是,Linux生态系统中的大多数其他参与者可以通过为内核做出贡献而受益。使68重要的是,Linux生态系统中的大多数其他参与者可以通过为内核做出贡献而受益。使
62代码进入主线是提高代码质量、降低维护和分发成本、提高对内核开发方向的影响程度69代码进入主线是提高代码质量、降低维护和分发成本、提高对内核开发方向的影响程度
63等的关键。这是一种人人都赢的局面。踢开你的编辑,来加入我们吧,你会非常受70等的关键。这是一种共赢的局面。启动你的编辑器,来加入我们吧;你会非常受欢迎的。
64欢迎的。
Documentation/translations/zh_CN/process/index.rst+5−5
@@ -13,11 +13,11 @@ · 12 unmodified lines
13与Linux 内核社区一起工作13与Linux 内核社区一起工作
14========================14========================
15 15
16那么你想成为Linux内核开发人员? 欢迎! 不但从技术意义上讲有很多关于内核的知识16你想成为Linux内核开发人员吗?欢迎之至!在学习许多关于内核的技术知识的同时,
17需要学,而且了解我们社区的工作方式也很重要。 阅读这些文章可以让您以更轻松地,17了解我们社区的工作方式也很重要。阅读这些文档可以让您以更轻松的、麻烦更少的
18麻烦最少的方式将更改合并到内核。18方式将更改合并到内核。
19 19
20以下是每位开发人员应阅读的基本指南。20以下是每位开发人员都应阅读的基本指南:
21 21
22.. toctree::22.. toctree::
23 :maxdepth: 123 :maxdepth: 1
@@ -47,7 +47,7 @@ · 23 unmodified lines
47 management-style47 management-style
48 embargoed-hardware-issues48 embargoed-hardware-issues
49 49
50这些是一些总体技术指南,由于缺乏更好的地方,现在已经放在这里50这些是一些总体性技术指南,由于不大好分类而放在这里:
51 51
52.. toctree::52.. toctree::
53 :maxdepth: 153 :maxdepth: 1
Documentation/translations/zh_CN/process/submit-checklist.rst+6−8
@@ -82,24 +82,22 @@ Linux内核补丁提交清单 · 81 unmodified lines
82 请参阅 ``Documentation/ABI/README`` 。更改用户空间接口的补丁应该抄送82 请参阅 ``Documentation/ABI/README`` 。更改用户空间接口的补丁应该抄送
83 linux-api@vger.kernel.org。83 linux-api@vger.kernel.org。
84 84
8520) 检查是否全部通过 ``make headers_check`` 。8520) 已通过至少注入slab和page分配失败进行检查。请参阅 ``Documentation/fault-injection/``
86
8721) 已通过至少注入slab和page分配失败进行检查。请参阅 ``Documentation/fault-injection/``
88 如果新代码是实质性的,那么添加子系统特定的故障注入可能是合适的。86 如果新代码是实质性的,那么添加子系统特定的故障注入可能是合适的。
89 87
9022) 新添加的代码已经用 ``gcc -W`` 编译(使用 ``make EXTRA-CFLAGS=-W`` )。这8821) 新添加的代码已经用 ``gcc -W`` 编译(使用 ``make EXTRA-CFLAGS=-W`` )。这
91 将产生大量噪声,但对于查找诸如“警告:有符号和无符号之间的比较”之类的错误89 将产生大量噪声,但对于查找诸如“警告:有符号和无符号之间的比较”之类的错误
92 很有用。90 很有用。
93 91
9423) 在它被合并到-mm补丁集中之后进行测试,以确保它仍然与所有其他排队的补丁以9222) 在它被合并到-mm补丁集中之后进行测试,以确保它仍然与所有其他排队的补丁以
95 及VM、VFS和其他子系统中的各种更改一起工作。93 及VM、VFS和其他子系统中的各种更改一起工作。
96 94
9724) 所有内存屏障例如 ``barrier()``, ``rmb()``, ``wmb()`` 都需要源代码中的注9523) 所有内存屏障例如 ``barrier()``, ``rmb()``, ``wmb()`` 都需要源代码中的注
98 释来解释它们正在执行的操作及其原因的逻辑。96 释来解释它们正在执行的操作及其原因的逻辑。
99 97
10025) 如果补丁添加了任何ioctl,那么也要更新 ``Documentation/userspace-api/ioctl/ioctl-number.rst``9824) 如果补丁添加了任何ioctl,那么也要更新 ``Documentation/userspace-api/ioctl/ioctl-number.rst``
101 99
10226) 如果修改后的源代码依赖或使用与以下 ``Kconfig`` 符号相关的任何内核API或10025) 如果修改后的源代码依赖或使用与以下 ``Kconfig`` 符号相关的任何内核API或
103 功能,则在禁用相关 ``Kconfig`` 符号和/或 ``=m`` (如果该选项可用)的情况101 功能,则在禁用相关 ``Kconfig`` 符号和/或 ``=m`` (如果该选项可用)的情况
104 下测试以下多个构建[并非所有这些都同时存在,只是它们的各种/随机组合]:102 下测试以下多个构建[并非所有这些都同时存在,只是它们的各种/随机组合]:
105 103
Documentation/translations/zh_CN/riscv/boot-image-header.rst+67−0
@@ -0,0 +1,67 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../riscv/boot-image-header`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_boot-image-header.rst:
7
8
9==========================
10RISC-V Linux启动镜像文件头
11==========================
12
13:Author: Atish Patra <atish.patra@wdc.com>
14:Date: 20 May 2019
15
16此文档仅描述RISC-V Linux 启动文件头的详情。
17
18TODO:
19 写一个完整的启动指南。
20
21在解压后的Linux内核镜像中存在以下64字节的文件头::
22
23 u32 code0; /* Executable code */
24 u32 code1; /* Executable code */
25 u64 text_offset; /* Image load offset, little endian */
26 u64 image_size; /* Effective Image size, little endian */
27 u64 flags; /* kernel flags, little endian */
28 u32 version; /* Version of this header */
29 u32 res1 = 0; /* Reserved */
30 u64 res2 = 0; /* Reserved */
31 u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */
32 u32 magic2 = 0x05435352; /* Magic number 2, little endian, "RSC\x05" */
33 u32 res3; /* Reserved for PE COFF offset */
34
35这种头格式与PE/COFF文件头兼容,并在很大程度上受到ARM64文件头的启发。因此,ARM64
36和RISC-V文件头可以在未来合并为一个共同的头。
37
38注意
39====
40
41- 将来也可以复用这个文件头,用来对RISC-V的EFI桩提供支持。为了使内核镜像如同一个
42 EFI应用程序一样加载,EFI规范中规定在内核镜像的开始需要PE/COFF镜像文件头。为了
43 支持EFI桩,应该用“MZ”魔术字符替换掉code0,并且res3(偏移量未0x3c)应指向PE/COFF
44 文件头的其余部分.
45
46- 表示文件头版本号的Drop-bit位域
47
48 ========== ==========
49 Bits 0:15 次要 版本
50 Bits 16:31 主要 版本
51 ========== ==========
52
53 这保持了新旧版本之间的兼容性。
54 当前版本被定义为0.2。
55
56- 从版本0.2开始,结构体成员“magic”就已经被弃用,在之后的版本中,可能会移除掉它。
57 最初,该成员应该与ARM64头的“magic”成员匹配,但遗憾的是并没有。
58 “magic2”成员代替“magic”成员与ARM64头相匹配。
59
60- 在当前的文件头,标志位域只剩下了一个位。
61
62 ===== ==============================
63 Bit 0 内核字节序。1 if BE, 0 if LE.
64 ===== ==============================
65
66- 对于引导加载程序加载内核映像来说,image_size成员对引导加载程序而言是必须的,否
67 则将引导失败。
Documentation/translations/zh_CN/riscv/index.rst+28−0
@@ -0,0 +1,28 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :doc:`../../../riscv/index`
6:Translator: Yanteng Si <siyanteng@loongson.cn>
7
8.. _cn_riscv_index:
9
10
11===============
12RISC-V 体系结构
13===============
14
15.. toctree::
16 :maxdepth: 1
17
18 boot-image-header
19 pmu
20 patch-acceptance
21
22
23.. only:: subproject and html
24
25 目录
26 ====
27
28 * :ref:`genindex`
Documentation/translations/zh_CN/riscv/patch-acceptance.rst+31−0
@@ -0,0 +1,31 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :doc:`../../../riscv/patch-acceptance`
6:Translator: Yanteng Si <siyanteng@loongson.cn>
7
8.. _cn_riscv_patch-acceptance:
9
10
11arch/riscv 开发者维护指南
12=========================
13
14概述
15----
16RISC-V指令集体系结构是公开开发的:
17正在进行的草案可供所有人查看和测试实现。新模块或者扩展草案可能会在开发过程中发
18生更改---有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给RISC-V Linux
19维护者带来挑战。Linux开发过程更喜欢经过良好检查和测试的代码,而不是试验代码。我
20们希望推广同样的规则到即将被内核合并的RISC-V相关代码。
21
22附加的提交检查单
23----------------
24我们仅接受相关标准已经被RISC-V基金会标准为“已批准”或“已冻结”的扩展或模块的补丁。
25(开发者当然可以维护自己的Linux内核树,其中包含所需代码扩展草案的代码。)
26
27此外,RISC-V规范允许爱好者创建自己的自定义扩展。这些自定义拓展不需要通过RISC-V
28基金会的任何审核或批准。为了避免将爱好者一些特别的RISC-V拓展添加进内核代码带来
29的维护复杂性和对性能的潜在影响,我们将只接受RISC-V基金会正式冻结或批准的的扩展
30补丁。(开发者当然可以维护自己的Linux内核树,其中包含他们想要的任何自定义扩展
31的代码。)
Documentation/translations/zh_CN/riscv/pmu.rst+233−0
@@ -0,0 +1,233 @@
1.. include:: ../disclaimer-zh_CN.rst
2
3:Original: :doc:`../../../riscv/pmu`
4:Translator: Yanteng Si <siyanteng@loongson.cn>
5
6.. _cn_riscv_pmu:
7
8
9========================
10RISC-V平台上对PMUs的支持
11========================
12
13Alan Kao <alankao@andestech.com>, Mar 2018
14
15简介
16------------
17
18截止本文撰写时,在The RISC-V ISA Privileged Version 1.10中提到的 perf_event
19相关特性如下:
20(详情请查阅手册)
21
22* [m|s]counteren
23* mcycle[h], cycle[h]
24* minstret[h], instret[h]
25* mhpeventx, mhpcounterx[h]
26
27仅有以上这些功能,移植perf需要做很多工作,究其原因是缺少以下通用架构的性能
28监测特性:
29
30* 启用/停用计数器
31 在我们这里,计数器一直在自由运行。
32* 计数器溢出引起的中断
33 规范中没有这种功能。
34* 中断指示器
35 不可能所有的计数器都有很多的中断端口,所以需要一个中断指示器让软件来判断
36 哪个计数器刚好溢出。
37* 写入计数器
38 由于内核不能修改计数器,所以会有一个SBI来支持这个功能[1]。 另外,一些厂商
39 考虑实现M-S-U型号机器的硬件扩展来直接写入计数器。
40
41这篇文档旨在为开发者提供一个在内核中支持PMU的简要指南。下面的章节简要解释了
42perf' 机制和待办事项。
43
44你可以在这里查看以前的讨论[1][2]。 另外,查看附录中的相关内核结构体可能会有
45帮助。
46
47
481. 初始化
49---------
50
51*riscv_pmu* 是一个类型为 *struct riscv_pmu* 的全局指针,它包含了根据perf内部
52约定的各种方法和PMU-specific参数。人们应该声明这样的实例来代表PMU。 默认情况
53下, *riscv_pmu* 指向一个常量结构体 *riscv_base_pmu* ,它对基准QEMU模型有非常
54基础的支持。
55
56
57然后他/她可以将实例的指针分配给 *riscv_pmu* ,这样就可以利用已经实现的最小逻
58辑,或者创建他/她自己的 *riscv_init_platform_pmu* 实现。
59
60换句话说,现有的 *riscv_base_pmu* 源只是提供了一个参考实现。 开发者可以灵活地
61决定多少部分可用,在最极端的情况下,他们可以根据自己的需要定制每一个函数。
62
63
642. Event Initialization
65-----------------------
66
67当用户启动perf命令来监控一些事件时,首先会被用户空间的perf工具解释为多个
68*perf_event_open* 系统调用,然后进一步调用上一步分配的 *event_init* 成员函数
69的主体。 在 *riscv_base_pmu* 的情况下,就是 *riscv_event_init* 。
70
71该功能的主要目的是将用户提供的事件翻译成映射图,从而可以直接对HW-related的控
72制寄存器或计数器进行操作。该翻译基于 *riscv_pmu* 中提供的映射和方法。
73
74注意,有些功能也可以在这个阶段完成:
75
76(1) 中断设置,这个在下一节说;
77(2) 特限级设置(仅用户空间、仅内核空间、两者都有);
78(3) 析构函数设置。 通常应用 *riscv_destroy_event* 即可;
79(4) 对非采样事件的调整,这将被函数应用,如 *perf_adjust_period* ,通常如下::
80
81 if (!is_sampling_event(event)) {
82 hwc->sample_period = x86_pmu.max_period;
83 hwc->last_period = hwc->sample_period;
84 local64_set(&hwc->period_left, hwc->sample_period);
85 }
86
87
88在 *riscv_base_pmu* 的情况下,目前只提供了(3)。
89
90
913. 中断
92-------
93
943.1. 中断初始化
95
96这种情况经常出现在 *event_init* 方案的开头。通常情况下,这应该是一个代码段,如::
97
98 int x86_reserve_hardware(void)
99 {
100 int err = 0;
101
102 if (!atomic_inc_not_zero(&pmc_refcount)) {
103 mutex_lock(&pmc_reserve_mutex);
104 if (atomic_read(&pmc_refcount) == 0) {
105 if (!reserve_pmc_hardware())
106 err = -EBUSY;
107 else
108 reserve_ds_buffers();
109 }
110 if (!err)
111 atomic_inc(&pmc_refcount);
112 mutex_unlock(&pmc_reserve_mutex);
113 }
114
115 return err;
116 }
117
118而神奇的是 *reserve_pmc_hardware* ,它通常做原子操作,使实现的IRQ可以从某个全局函
119数指针访问。 而 *release_pmc_hardware* 的作用正好相反,它用在上一节提到的事件分配
120器中。
121
122 (注:从所有架构的实现来看,*reserve/release* 对总是IRQ设置,所以 *pmc_hardware*
123 似乎有些误导。 它并不处理事件和物理计数器之间的绑定,这一点将在下一节介绍。)
124
1253.2. IRQ结构体
126
127基本上,一个IRQ运行以下伪代码::
128
129 for each hardware counter that triggered this overflow
130
131 get the event of this counter
132
133 // following two steps are defined as *read()*,
134 // check the section Reading/Writing Counters for details.
135 count the delta value since previous interrupt
136 update the event->count (# event occurs) by adding delta, and
137 event->hw.period_left by subtracting delta
138
139 if the event overflows
140 sample data
141 set the counter appropriately for the next overflow
142
143 if the event overflows again
144 too frequently, throttle this event
145 fi
146 fi
147
148 end for
149
150 然而截至目前,没有一个RISC-V的实现为perf设计了中断,所以具体的实现要在未来完成。
151
1524. Reading/Writing 计数
153-----------------------
154
155它们看似差不多,但perf对待它们的态度却截然不同。 对于读,在 *struct pmu* 中有一个
156*read* 接口,但它的作用不仅仅是读。 根据上下文,*read* 函数不仅要读取计数器的内容
157(event->count),还要更新左周期到下一个中断(event->hw.period_left)。
158
159 但 perf 的核心不需要直接写计数器。 写计数器隐藏在以下两点的抽象化之后,
160 1) *pmu->start* ,从字面上看就是开始计数,所以必须把计数器设置成一个合适的值,以
161 便下一次中断;
162 2)在IRQ里面,应该把计数器设置成同样的合理值。
163
164在RISC-V中,读操作不是问题,但写操作就需要费些力气了,因为S模式不允许写计数器。
165
166
1675. add()/del()/start()/stop()
168-----------------------------
169
170基本思想: add()/del() 向PMU添加/删除事件,start()/stop() 启动/停止PMU中某个事件
171的计数器。 所有这些函数都使用相同的参数: *struct perf_event *event* 和 *int flag* 。
172
173把 perf 看作一个状态机,那么你会发现这些函数作为这些状态之间的状态转换过程。
174定义了三种状态(event->hw.state):
175
176* PERF_HES_STOPPED: 计数停止
177* PERF_HES_UPTODATE: event->count是最新的
178* PERF_HES_ARCH: 依赖于体系结构的用法,。。。我们现在并不需要它。
179
180这些状态转换的正常流程如下:
181
182* 用户启动一个 perf 事件,导致调用 *event_init* 。
183* 当被上下文切换进来的时候,*add* 会被 perf core 调用,并带有一个标志 PERF_EF_START,
184 也就是说事件被添加后应该被启动。 在这个阶段,如果有的话,一般事件会被绑定到一个物
185 理计数器上。当状态变为PERF_HES_STOPPED和PERF_HES_UPTODATE,因为现在已经停止了,
186 (软件)事件计数不需要更新。
187
188 - 然后调用 *start* ,并启用计数器。
189 通过PERF_EF_RELOAD标志,它向计数器写入一个适当的值(详细情况请参考上一节)。
190 如果标志不包含PERF_EF_RELOAD,则不会写入任何内容。
191 现在状态被重置为none,因为它既没有停止也没有更新(计数已经开始)。
192
193*当被上下文切换出来时被调用。 然后,它检查出PMU中的所有事件,并调用 *stop* 来更新它们
194 的计数。
195
196 - *stop* 被 *del* 和perf核心调用,标志为PERF_EF_UPDATE,它经常以相同的逻辑和 *read*
197 共用同一个子程序。
198 状态又一次变为PERF_HES_STOPPED和PERF_HES_UPTODATE。
199
200 - 这两对程序的生命周期: *add* 和 *del* 在任务切换时被反复调用;*start* 和 *stop* 在
201 perf核心需要快速停止和启动时也会被调用,比如在调整中断周期时。
202
203目前的实现已经足够了,将来可以很容易地扩展到功能。
204
205A. 相关结构体
206-------------
207
208* struct pmu: include/linux/perf_event.h
209* struct riscv_pmu: arch/riscv/include/asm/perf_event.h
210
211 两个结构体都被设计为只读。
212
213 *struct pmu* 定义了一些函数指针接口,它们大多以 *struct perf_event* 作为主参数,根据
214 perf的内部状态机处理perf事件(详情请查看kernel/events/core.c)。
215
216 *struct riscv_pmu* 定义了PMU的具体参数。 命名遵循所有其它架构的惯例。
217
218* struct perf_event: include/linux/perf_event.h
219* struct hw_perf_event
220
221 表示 perf 事件的通用结构体,以及硬件相关的细节。
222
223* struct riscv_hw_events: arch/riscv/include/asm/perf_event.h
224
225 保存事件状态的结构有两个固定成员。
226 事件的数量和事件的数组。
227
228参考文献
229--------
230
231[1] https://github.com/riscv/riscv-linux/pull/124
232
233[2] https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/f19TmCNP6yA
Documentation/translations/zh_CN/sound/hd-audio/controls.rst+102−0
@@ -0,0 +1,102 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3Chinese translator: Huang Jianghui <huangjianghui@uniontech.com>
4---------------------------------------------------------------------
5.. include:: ../../disclaimer-zh_CN.rst
6以下为正文
7---------------------------------------------------------------------
8======================================
9高清音频编解码器特定混音器控件
10======================================
11
12
13此文件解释特定于编解码器的混音器控件.
14
15瑞昱编解码器
16------------
17
18声道模式
19 这是一个用于更改环绕声道设置的枚举控件,仅在环绕声道打开时显示出现。
20 它给出要使用的通道数:"2ch","4ch","6ch",和"8ch"。根据配置,这还控
21 制多I/O插孔的插孔重分配。
22
23自动静音模式
24 这是一个枚举控件,用于更改耳机和线路输出插孔的自动静音行为。如果内
25 置扬声器、耳机和/或线路输出插孔在机器上可用,则显示该控件。当只有
26 耳机或者线路输出的时候,它给出”禁用“和”启用“状态。当启用后,插孔插
27 入后扬声器会自动静音。
28
29 当耳机和线路输出插孔都存在时,它给出”禁用“、”仅扬声器“和”线路输出+扬
30 声器“。当”仅扬声器“被选择,插入耳机或者线路输出插孔可使扬声器静音,
31 但不会使线路输出静音。当线路输出+扬声器被选择,插入耳机插孔会同时使扬
32 声器和线路输出静音。
33
34
35矽玛特编解码器
36--------------
37
38模拟环回
39 此控件启用/禁用模拟环回电路。只有在编解码器提示中将”lookback“设置为真
40 时才会出现(见HD-Audio.txt)。请注意,在某些编解码器上,模拟环回和正常
41 PCM播放是独占的,即当此选项打开时,您将听不到任何PCM流。
42
43交换中置/低频
44 交换中置和低频通道顺序,通常情况下,左侧对应中置,右侧对应低频,启动此
45 项后,左边低频,右边中置。
46
47耳机作为线路输出
48 当此控制开启时,将耳机视为线路输出插孔。也就是说,耳机不会自动静音其他
49 线路输出,没有耳机放大器被设置到引脚上。
50
51麦克风插口模式、线路插孔模式等
52 这些枚举控制输入插孔引脚的方向和偏置。根据插孔类型,它可以设置为”麦克风
53 输入“和”线路输入“以确定输入偏置,或者当引脚是环绕声道的多I/O插孔时,它
54 可以设置为”线路输出“。
55
56
57威盛编解码器
58------------
59
60智能5.1
61 一个枚举控件,用于为环绕输出重新分配多个I/O插孔的任务。当它打开时,相应
62 的输入插孔(通常是线路输入和麦克风输入)被切换为环绕和中央低频输出插孔。
63
64独立耳机
65 启用此枚举控制时,耳机输出从单个流(第三个PCM,如hw:0,2)而不是主流路由。
66 如果耳机DAC与侧边或中央低频通道DAC共享,则DAC将自动切换到耳机。
67
68环回混合
69 一个用于确定是否启动了模拟环回路由的枚举控件。当它启用后,模拟环回路由到
70 前置通道。同样,耳机与扬声器输出也采用相同的路径。作为一个副作用,当设置
71 此模式后,单个音量控制将不再适用于耳机和扬声器,因为只有一个DAC连接到混
72 音器小部件。
73
74动态电源控制
75 此控件决定是否启动每个插孔的动态电源控制检测。启用时,根据插孔的插入情况
76 动态更改组件的电源状态(D0/D3)以节省电量消耗。但是,如果您的系统没有提
77 供正确的插孔检测,这将无法工作;在这种情况下,请关闭此控件。
78
79插孔检测
80 此控件仅为VT1708编解码器提供,它不会为每个插孔插拔提供适当的未请求事件。
81 当此控件打开,驱动将轮询插孔检测,以便耳机自动静音可以工作,而关闭此控
82 件将降低功耗。
83
84
85科胜讯编解码器
86--------------
87
88自动静音模式
89 见瑞昱解码器
90
91
92
93模拟编解码器
94------------
95
96通道模式
97 这是一个用于更改环绕声道设置的枚举控件,仅在环绕声道可用时显示。它提供了能
98 被使用的通道数:”2ch“、”4ch“和”6ch“。根据配置,这还控制多I/O插孔的插孔重
99 分配。
100
101独立耳机
102 启动此枚举控制后,耳机输出从单个流(第三个PCM,如hw:0,2)而不是主流路由。
Documentation/translations/zh_CN/sound/hd-audio/index.rst+14−0
@@ -0,0 +1,14 @@
1.. SPDX-License-Identifier: GPL-2.0
2.. include:: ../../disclaimer-zh_CN.rst
3
4:Original: :doc:`../../../../sound/hd-audio/index`
5:Translator: Huang Jianghui <huangjianghui@uniontech.com>
6
7
8高清音频
9========
10
11.. toctree::
12 :maxdepth: 2
13
14 controls
Documentation/translations/zh_CN/sound/index.rst+22−0
@@ -0,0 +1,22 @@
1.. SPDX-License-Identifier: GPL-2.0
2.. include:: ../disclaimer-zh_CN.rst
3
4:Original: :doc:`../../../sound/index`
5:Translator: Huang Jianghui <huangjianghui@uniontech.com>
6
7
8====================
9Linux 声音子系统文档
10====================
11
12.. toctree::
13 :maxdepth: 2
14
15 hd-audio/index
16
17.. only:: subproject and html
18
19 Indices
20 =======
21
22 * :ref:`genindex`
Documentation/userspace-api/ioctl/ioctl-number.rst+1−0
@@ -349,6 +349,7 @@ Code Seq# Include File Comments · 348 unmodified lines
3490xB5 00-0F uapi/linux/rpmsg.h <mailto:linux-remoteproc@vger.kernel.org>3490xB5 00-0F uapi/linux/rpmsg.h <mailto:linux-remoteproc@vger.kernel.org>
3500xB6 all linux/fpga-dfl.h3500xB6 all linux/fpga-dfl.h
3510xB7 all uapi/linux/remoteproc_cdev.h <mailto:linux-remoteproc@vger.kernel.org>3510xB7 all uapi/linux/remoteproc_cdev.h <mailto:linux-remoteproc@vger.kernel.org>
3520xB7 all uapi/linux/nsfs.h <mailto:Andrei Vagin <avagin@openvz.org>>
3520xC0 00-0F linux/usb/iowarrior.h3530xC0 00-0F linux/usb/iowarrior.h
3530xCA 00-0F uapi/misc/cxl.h3540xCA 00-0F uapi/misc/cxl.h
3540xCA 10-2F uapi/misc/ocxl.h3550xCA 10-2F uapi/misc/ocxl.h
Documentation/virt/kvm/api.rst+1−1
@@ -55,7 +55,7 @@ not cause harm to the host, their actual behavior is not guaranteed by · 54 unmodified lines
55the API. See "General description" for details on the ioctl usage55the API. See "General description" for details on the ioctl usage
56model that is supported by KVM.56model that is supported by KVM.
57 57
58It is important to note that althought VM ioctls may only be issued from58It is important to note that although VM ioctls may only be issued from
59the process that created the VM, a VM's lifecycle is associated with its59the process that created the VM, a VM's lifecycle is associated with its
60file descriptor, not its creator (process). In other words, the VM and60file descriptor, not its creator (process). In other words, the VM and
61its resources, *including the associated address space*, are not freed61its resources, *including the associated address space*, are not freed
Documentation/watchdog/pcwd-watchdog.rst+1−1
@@ -47,7 +47,7 @@ Documentation and Driver by Ken Hollis <kenji@bitgate.com> · 46 unmodified lines
47 WDIOC_GETSTATUS47 WDIOC_GETSTATUS
48 This returns the status of the card, with the bits of48 This returns the status of the card, with the bits of
49 WDIOF_* bitwise-anded into the value. (The comments49 WDIOF_* bitwise-anded into the value. (The comments
50 are in linux/pcwd.h)50 are in include/uapi/linux/watchdog.h)
51 51
52 WDIOC_GETBOOTSTATUS52 WDIOC_GETBOOTSTATUS
53 This returns the status of the card that was reported53 This returns the status of the card that was reported
MAINTAINERS+21−3
@@ -4235,13 +4235,20 @@ X: drivers/char/tpm/ · 4234 unmodified lines
4235CHECKPATCH4235CHECKPATCH
4236M: Andy Whitcroft <apw@canonical.com>4236M: Andy Whitcroft <apw@canonical.com>
4237M: Joe Perches <joe@perches.com>4237M: Joe Perches <joe@perches.com>
4238R: Dwaipayan Ray <dwaipayanray1@gmail.com>
4239R: Lukas Bulwahn <lukas.bulwahn@gmail.com>
4238S: Maintained4240S: Maintained
4239F: scripts/checkpatch.pl4241F: scripts/checkpatch.pl
4240 4242
4243CHECKPATCH DOCUMENTATION
4244M: Dwaipayan Ray <dwaipayanray1@gmail.com>
4245M: Lukas Bulwahn <lukas.bulwahn@gmail.com>
4246R: Joe Perches <joe@perches.com>
4247S: Maintained
4248F: Documentation/dev-tools/checkpatch.rst
4249
4241CHINESE DOCUMENTATION4250CHINESE DOCUMENTATION
4242M: Harry Wei <harryxiyou@gmail.com>4251M: Alex Shi <alexs@kernel.org>
4243M: Alex Shi <alex.shi@linux.alibaba.com>
4244L: xiyoulinuxkernelgroup@googlegroups.com (subscribers-only)
4245S: Maintained4252S: Maintained
4246F: Documentation/translations/zh_CN/4253F: Documentation/translations/zh_CN/
4247 4254
@@ -5469,6 +5476,12 @@ X: Documentation/power/ · 1221 unmodified lines
5469X: Documentation/spi/5476X: Documentation/spi/
5470X: Documentation/userspace-api/media/5477X: Documentation/userspace-api/media/
5471 5478
5479DOCUMENTATION REPORTING ISSUES
5480M: Thorsten Leemhuis <linux@leemhuis.info>
5481L: linux-doc@vger.kernel.org
5482S: Maintained
5483F: Documentation/admin-guide/reporting-issues.rst
5484
5472DOCUMENTATION SCRIPTS5485DOCUMENTATION SCRIPTS
5473M: Mauro Carvalho Chehab <mchehab@kernel.org>5486M: Mauro Carvalho Chehab <mchehab@kernel.org>
5474L: linux-doc@vger.kernel.org5487L: linux-doc@vger.kernel.org
@@ -9800,6 +9813,11 @@ F: include/uapi/linux/sunrpc/ · 4325 unmodified lines
9800F: net/sunrpc/9813F: net/sunrpc/
9801F: Documentation/filesystems/nfs/9814F: Documentation/filesystems/nfs/
9802 9815
9816KERNEL REGRESSIONS
9817M: Thorsten Leemhuis <linux@leemhuis.info>
9818L: regressions@lists.linux.dev
9819S: Supported
9820
9803KERNEL SELFTEST FRAMEWORK9821KERNEL SELFTEST FRAMEWORK
9804M: Shuah Khan <shuah@kernel.org>9822M: Shuah Khan <shuah@kernel.org>
9805M: Shuah Khan <skhan@linuxfoundation.org>9823M: Shuah Khan <skhan@linuxfoundation.org>
fs/eventpoll.c+26−26
@@ -366,8 +366,8 @@ static inline struct epitem *ep_item_from_wait(wait_queue_entry_t *p) · 365 unmodified lines
366 *366 *
367 * @ep: Pointer to the eventpoll context.367 * @ep: Pointer to the eventpoll context.
368 *368 *
369 * Returns: Returns a value different than zero if ready events are available,369 * Return: a value different than %zero if ready events are available,
370 * or zero otherwise.370 * or %zero otherwise.
371 */371 */
372static inline int ep_events_available(struct eventpoll *ep)372static inline int ep_events_available(struct eventpoll *ep)
373{373{
@@ -1023,7 +1023,7 @@ struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd, · 649 unmodified lines
1023}1023}
1024#endif /* CONFIG_KCMP */1024#endif /* CONFIG_KCMP */
1025 1025
1026/**1026/*
1027 * Adds a new entry to the tail of the list in a lockless way, i.e.1027 * Adds a new entry to the tail of the list in a lockless way, i.e.
1028 * multiple CPUs are allowed to call this function concurrently.1028 * multiple CPUs are allowed to call this function concurrently.
1029 *1029 *
@@ -1035,10 +1035,10 @@ struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd, · 5 unmodified lines
1035 * completed.1035 * completed.
1036 *1036 *
1037 * Also an element can be locklessly added to the list only in one1037 * Also an element can be locklessly added to the list only in one
1038 * direction i.e. either to the tail either to the head, otherwise1038 * direction i.e. either to the tail or to the head, otherwise
1039 * concurrent access will corrupt the list.1039 * concurrent access will corrupt the list.
1040 *1040 *
1041 * Returns %false if element has been already added to the list, %true1041 * Return: %false if element has been already added to the list, %true
1042 * otherwise.1042 * otherwise.
1043 */1043 */
1044static inline bool list_add_tail_lockless(struct list_head *new,1044static inline bool list_add_tail_lockless(struct list_head *new,
@@ -1076,11 +1076,11 @@ static inline bool list_add_tail_lockless(struct list_head *new, · 31 unmodified lines
1076 return true;1076 return true;
1077}1077}
1078 1078
1079/**1079/*
1080 * Chains a new epi entry to the tail of the ep->ovflist in a lockless way,1080 * Chains a new epi entry to the tail of the ep->ovflist in a lockless way,
1081 * i.e. multiple CPUs are allowed to call this function concurrently.1081 * i.e. multiple CPUs are allowed to call this function concurrently.
1082 *1082 *
1083 * Returns %false if epi element has been already chained, %true otherwise.1083 * Return: %false if epi element has been already chained, %true otherwise.
1084 */1084 */
1085static inline bool chain_epi_lockless(struct epitem *epi)1085static inline bool chain_epi_lockless(struct epitem *epi)
1086{1086{
@@ -1105,8 +1105,8 @@ static inline bool chain_epi_lockless(struct epitem *epi) · 18 unmodified lines
1105 * mechanism. It is called by the stored file descriptors when they1105 * mechanism. It is called by the stored file descriptors when they
1106 * have events to report.1106 * have events to report.
1107 *1107 *
1108 * This callback takes a read lock in order not to content with concurrent1108 * This callback takes a read lock in order not to contend with concurrent
1109 * events from another file descriptors, thus all modifications to ->rdllist1109 * events from another file descriptor, thus all modifications to ->rdllist
1110 * or ->ovflist are lockless. Read lock is paired with the write lock from1110 * or ->ovflist are lockless. Read lock is paired with the write lock from
1111 * ep_scan_ready_list(), which stops all list modifications and guarantees1111 * ep_scan_ready_list(), which stops all list modifications and guarantees
1112 * that lists state is seen correctly.1112 * that lists state is seen correctly.
@@ -1335,8 +1335,8 @@ static int reverse_path_check_proc(struct hlist_head *refs, int depth) · 222 unmodified lines
1335 * paths such that we will spend all our time waking up1335 * paths such that we will spend all our time waking up
1336 * eventpoll objects.1336 * eventpoll objects.
1337 *1337 *
1338 * Returns: Returns zero if the proposed links don't create too many paths,1338 * Return: %zero if the proposed links don't create too many paths,
1339 * -1 otherwise.1339 * %-1 otherwise.
1340 */1340 */
1341static int reverse_path_check(void)1341static int reverse_path_check(void)
1342{1342{
@@ -1734,7 +1734,7 @@ static struct timespec64 *ep_timeout_to_timespec(struct timespec64 *to, long ms) · 391 unmodified lines
1734}1734}
1735 1735
1736/**1736/**
1737 * ep_poll - Retrieves ready events, and delivers them to the caller supplied1737 * ep_poll - Retrieves ready events, and delivers them to the caller-supplied
1738 * event buffer.1738 * event buffer.
1739 *1739 *
1740 * @ep: Pointer to the eventpoll context.1740 * @ep: Pointer to the eventpoll context.
@@ -1747,7 +1747,7 @@ static struct timespec64 *ep_timeout_to_timespec(struct timespec64 *to, long ms) · 6 unmodified lines
1747 * until at least one event has been retrieved (or an error1747 * until at least one event has been retrieved (or an error
1748 * occurred).1748 * occurred).
1749 *1749 *
1750 * Returns: Returns the number of ready events which have been fetched, or an1750 * Return: the number of ready events which have been fetched, or an
1751 * error code, in case of error.1751 * error code, in case of error.
1752 */1752 */
1753static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,1753static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
@@ -1774,9 +1774,9 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, · 20 unmodified lines
1774 1774
1775 /*1775 /*
1776 * This call is racy: We may or may not see events that are being added1776 * This call is racy: We may or may not see events that are being added
1777 * to the ready list under the lock (e.g., in IRQ callbacks). For, cases1777 * to the ready list under the lock (e.g., in IRQ callbacks). For cases
1778 * with a non-zero timeout, this thread will check the ready list under1778 * with a non-zero timeout, this thread will check the ready list under
1779 * lock and will added to the wait queue. For, cases with a zero1779 * lock and will add to the wait queue. For cases with a zero
1780 * timeout, the user by definition should not care and will have to1780 * timeout, the user by definition should not care and will have to
1781 * recheck again.1781 * recheck again.
1782 */1782 */
@@ -1869,15 +1869,15 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, · 86 unmodified lines
1869 1869
1870/**1870/**
1871 * ep_loop_check_proc - verify that adding an epoll file inside another1871 * ep_loop_check_proc - verify that adding an epoll file inside another
1872 * epoll structure, does not violate the constraints, in1872 * epoll structure does not violate the constraints, in
1873 * terms of closed loops, or too deep chains (which can1873 * terms of closed loops, or too deep chains (which can
1874 * result in excessive stack usage).1874 * result in excessive stack usage).
1875 *1875 *
1876 * @priv: Pointer to the epoll file to be currently checked.1876 * @ep: the &struct eventpoll to be currently checked.
1877 * @depth: Current depth of the path being checked.1877 * @depth: Current depth of the path being checked.
1878 *1878 *
1879 * Returns: Returns zero if adding the epoll @file inside current epoll1879 * Return: %zero if adding the epoll @file inside current epoll
1880 * structure @ep does not violate the constraints, or -1 otherwise.1880 * structure @ep does not violate the constraints, or %-1 otherwise.
1881 */1881 */
1882static int ep_loop_check_proc(struct eventpoll *ep, int depth)1882static int ep_loop_check_proc(struct eventpoll *ep, int depth)
1883{1883{
@@ -1919,14 +1919,14 @@ static int ep_loop_check_proc(struct eventpoll *ep, int depth) · 35 unmodified lines
1919 1919
1920/**1920/**
1921 * ep_loop_check - Performs a check to verify that adding an epoll file (@to)1921 * ep_loop_check - Performs a check to verify that adding an epoll file (@to)
1922 * into another epoll file (represented by @from) does not create1922 * into another epoll file (represented by @ep) does not create
1923 * closed loops or too deep chains.1923 * closed loops or too deep chains.
1924 *1924 *
1925 * @from: Pointer to the epoll we are inserting into.1925 * @ep: Pointer to the epoll we are inserting into.
1926 * @to: Pointer to the epoll to be inserted.1926 * @to: Pointer to the epoll to be inserted.
1927 *1927 *
1928 * Returns: Returns zero if adding the epoll @to inside the epoll @from1928 * Return: %zero if adding the epoll @to inside the epoll @from
1929 * does not violate the constraints, or -1 otherwise.1929 * does not violate the constraints, or %-1 otherwise.
1930 */1930 */
1931static int ep_loop_check(struct eventpoll *ep, struct eventpoll *to)1931static int ep_loop_check(struct eventpoll *ep, struct eventpoll *to)
1932{1932{
@@ -2074,8 +2074,8 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 141 unmodified lines
2074 ep = f.file->private_data;2074 ep = f.file->private_data;
2075 2075
2076 /*2076 /*
2077 * When we insert an epoll file descriptor, inside another epoll file2077 * When we insert an epoll file descriptor inside another epoll file
2078 * descriptor, there is the change of creating closed loops, which are2078 * descriptor, there is the chance of creating closed loops, which are
2079 * better be handled here, than in more critical paths. While we are2079 * better be handled here, than in more critical paths. While we are
2080 * checking for loops we also determine the list of files reachable2080 * checking for loops we also determine the list of files reachable
2081 * and hang them on the tfile_check_list, so we can check that we2081 * and hang them on the tfile_check_list, so we can check that we
@@ -2113,7 +2113,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 31 unmodified lines
2113 }2113 }
2114 2114
2115 /*2115 /*
2116 * Try to lookup the file inside our RB tree, Since we grabbed "mtx"2116 * Try to lookup the file inside our RB tree. Since we grabbed "mtx"
2117 * above, we can be sure to be able to use the item looked up by2117 * above, we can be sure to be able to use the item looked up by
2118 * ep_find() till we release the mutex.2118 * ep_find() till we release the mutex.
2119 */2119 */
fs/namespace.c+8−6
@@ -1242,8 +1242,9 @@ struct vfsmount *mntget(struct vfsmount *mnt) · 1241 unmodified lines
1242}1242}
1243EXPORT_SYMBOL(mntget);1243EXPORT_SYMBOL(mntget);
1244 1244
1245/* path_is_mountpoint() - Check if path is a mount in the current1245/**
1246 * namespace.1246 * path_is_mountpoint() - Check if path is a mount in the current namespace.
1247 * @path: path to check
1247 *1248 *
1248 * d_mountpoint() can only be used reliably to establish if a dentry is1249 * d_mountpoint() can only be used reliably to establish if a dentry is
1249 * not mounted in any namespace and that common case is handled inline.1250 * not mounted in any namespace and that common case is handled inline.
@@ -1369,7 +1370,7 @@ void mnt_cursor_del(struct mnt_namespace *ns, struct mount *cursor) · 119 unmodified lines
1369 1370
1370/**1371/**
1371 * may_umount_tree - check if a mount tree is busy1372 * may_umount_tree - check if a mount tree is busy
1372 * @mnt: root of mount tree1373 * @m: root of mount tree
1373 *1374 *
1374 * This is called to check if a tree of mounts has any1375 * This is called to check if a tree of mounts has any
1375 * open files, pwds, chroots or sub mounts that are1376 * open files, pwds, chroots or sub mounts that are
@@ -1939,10 +1940,11 @@ void drop_collected_mounts(struct vfsmount *mnt) · 563 unmodified lines
1939 1940
1940/**1941/**
1941 * clone_private_mount - create a private clone of a path1942 * clone_private_mount - create a private clone of a path
1943 * @path: path to clone
1942 *1944 *
1943 * This creates a new vfsmount, which will be the clone of @path. The new will1945 * This creates a new vfsmount, which will be the clone of @path. The new mount
1944 * not be attached anywhere in the namespace and will be private (i.e. changes1946 * will not be attached anywhere in the namespace and will be private (i.e.
1945 * to the originating mount won't be propagated into this).1947 * changes to the originating mount won't be propagated into this).
1946 *1948 *
1947 * Release with mntput().1949 * Release with mntput().
1948 */1950 */
scripts/checkpatch.pl+113−20
@@ -23,6 +23,9 @@ my $V = '0.32'; · 22 unmodified lines
23use Getopt::Long qw(:config no_auto_abbrev);23use Getopt::Long qw(:config no_auto_abbrev);
24 24
25my $quiet = 0;25my $quiet = 0;
26my $verbose = 0;
27my %verbose_messages = ();
28my %verbose_emitted = ();
26my $tree = 1;29my $tree = 1;
27my $chk_signoff = 1;30my $chk_signoff = 1;
28my $chk_patch = 1;31my $chk_patch = 1;
@@ -61,6 +64,7 @@ my $spelling_file = "$D/spelling.txt"; · 32 unmodified lines
61my $codespell = 0;64my $codespell = 0;
62my $codespellfile = "/usr/share/codespell/dictionary.txt";65my $codespellfile = "/usr/share/codespell/dictionary.txt";
63my $conststructsfile = "$D/const_structs.checkpatch";66my $conststructsfile = "$D/const_structs.checkpatch";
67my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst";
64my $typedefsfile;68my $typedefsfile;
65my $color = "auto";69my $color = "auto";
66my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE70my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
@@ -78,6 +82,7 @@ Version: $V · 11 unmodified lines
78 82
79Options:83Options:
80 -q, --quiet quiet84 -q, --quiet quiet
85 -v, --verbose verbose mode
81 --no-tree run without a kernel tree86 --no-tree run without a kernel tree
82 --no-signoff do not check for 'Signed-off-by' line87 --no-signoff do not check for 'Signed-off-by' line
83 --patch treat FILE as patchfile (default)88 --patch treat FILE as patchfile (default)
@@ -158,15 +163,51 @@ sub list_types { · 74 unmodified lines
158 my $text = <$script>;163 my $text = <$script>;
159 close($script);164 close($script);
160 165
161 my @types = ();166 my %types = ();
162 # Also catch when type or level is passed through a variable167 # Also catch when type or level is passed through a variable
163 for ($text =~ /(?:(?:\bCHK|\bWARN|\bERROR|&\{\$msg_level})\s*\(|\$msg_type\s*=)\s*"([^"]+)"/g) {168 while ($text =~ /(?:(\bCHK|\bWARN|\bERROR|&\{\$msg_level})\s*\(|\$msg_type\s*=)\s*"([^"]+)"/g) {
164 push (@types, $_);169 if (defined($1)) {
170 if (exists($types{$2})) {
171 $types{$2} .= ",$1" if ($types{$2} ne $1);
172 } else {
173 $types{$2} = $1;
174 }
175 } else {
176 $types{$2} = "UNDETERMINED";
177 }
165 }178 }
166 @types = sort(uniq(@types));179
167 print("#\tMessage type\n\n");180 print("#\tMessage type\n\n");
168 foreach my $type (@types) {181 if ($color) {
182 print(" ( Color coding: ");
183 print(RED . "ERROR" . RESET);
184 print(" | ");
185 print(YELLOW . "WARNING" . RESET);
186 print(" | ");
187 print(GREEN . "CHECK" . RESET);
188 print(" | ");
189 print("Multiple levels / Undetermined");
190 print(" )\n\n");
191 }
192
193 foreach my $type (sort keys %types) {
194 my $orig_type = $type;
195 if ($color) {
196 my $level = $types{$type};
197 if ($level eq "ERROR") {
198 $type = RED . $type . RESET;
199 } elsif ($level eq "WARN") {
200 $type = YELLOW . $type . RESET;
201 } elsif ($level eq "CHK") {
202 $type = GREEN . $type . RESET;
203 }
204 }
169 print(++$count . "\t" . $type . "\n");205 print(++$count . "\t" . $type . "\n");
206 if ($verbose && exists($verbose_messages{$orig_type})) {
207 my $message = $verbose_messages{$orig_type};
208 $message =~ s/\n/\n\t/g;
209 print("\t" . $message . "\n\n");
210 }
170 }211 }
171 212
172 exit($exitcode);213 exit($exitcode);
@@ -198,6 +239,46 @@ if (-f $conf) { · 25 unmodified lines
198 unshift(@ARGV, @conf_args) if @conf_args;239 unshift(@ARGV, @conf_args) if @conf_args;
199}240}
200 241
242sub load_docs {
243 open(my $docs, '<', "$docsfile")
244 or warn "$P: Can't read the documentation file $docsfile $!\n";
245
246 my $type = '';
247 my $desc = '';
248 my $in_desc = 0;
249
250 while (<$docs>) {
251 chomp;
252 my $line = $_;
253 $line =~ s/\s+$//;
254
255 if ($line =~ /^\s*\*\*(.+)\*\*$/) {
256 if ($desc ne '') {
257 $verbose_messages{$type} = trim($desc);
258 }
259 $type = $1;
260 $desc = '';
261 $in_desc = 1;
262 } elsif ($in_desc) {
263 if ($line =~ /^(?:\s{4,}|$)/) {
264 $line =~ s/^\s{4}//;
265 $desc .= $line;
266 $desc .= "\n";
267 } else {
268 $verbose_messages{$type} = trim($desc);
269 $type = '';
270 $desc = '';
271 $in_desc = 0;
272 }
273 }
274 }
275
276 if ($desc ne '') {
277 $verbose_messages{$type} = trim($desc);
278 }
279 close($docs);
280}
281
201# Perl's Getopt::Long allows options to take optional arguments after a space.282# Perl's Getopt::Long allows options to take optional arguments after a space.
202# Prevent --color by itself from consuming other arguments283# Prevent --color by itself from consuming other arguments
203foreach (@ARGV) {284foreach (@ARGV) {
@@ -208,6 +289,7 @@ foreach (@ARGV) { · 4 unmodified lines
208 289
209GetOptions(290GetOptions(
210 'q|quiet+' => \$quiet,291 'q|quiet+' => \$quiet,
292 'v|verbose!' => \$verbose,
211 'tree!' => \$tree,293 'tree!' => \$tree,
212 'signoff!' => \$chk_signoff,294 'signoff!' => \$chk_signoff,
213 'patch!' => \$chk_patch,295 'patch!' => \$chk_patch,
@@ -247,13 +329,27 @@ GetOptions( · 33 unmodified lines
247 329
248help(0) if ($help);330help(0) if ($help);
249 331
332die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
333die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse);
334
335if ($color =~ /^[01]$/) {
336 $color = !$color;
337} elsif ($color =~ /^always$/i) {
338 $color = 1;
339} elsif ($color =~ /^never$/i) {
340 $color = 0;
341} elsif ($color =~ /^auto$/i) {
342 $color = (-t STDOUT);
343} else {
344 die "$P: Invalid color mode: $color\n";
345}
346
347load_docs() if ($verbose);
250list_types(0) if ($list_types);348list_types(0) if ($list_types);
251 349
252$fix = 1 if ($fix_inplace);350$fix = 1 if ($fix_inplace);
253$check_orig = $check;351$check_orig = $check;
254 352
255die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
256
257my $exit = 0;353my $exit = 0;
258 354
259my $perl_version_ok = 1;355my $perl_version_ok = 1;
@@ -268,18 +364,6 @@ if ($#ARGV < 0) { · 8 unmodified lines
268 push(@ARGV, '-');364 push(@ARGV, '-');
269}365}
270 366
271if ($color =~ /^[01]$/) {
272 $color = !$color;
273} elsif ($color =~ /^always$/i) {
274 $color = 1;
275} elsif ($color =~ /^never$/i) {
276 $color = 0;
277} elsif ($color =~ /^auto$/i) {
278 $color = (-t STDOUT);
279} else {
280 die "$P: Invalid color mode: $color\n";
281}
282
283# skip TAB size 1 to avoid additional checks on $tabsize - 1367# skip TAB size 1 to avoid additional checks on $tabsize - 1
284die "$P: Invalid TAB size: $tabsize\n" if ($tabsize < 2);368die "$P: Invalid TAB size: $tabsize\n" if ($tabsize < 2);
285 369
@@ -2209,7 +2293,16 @@ sub report { · 1923 unmodified lines
2209 splice(@lines, 1, 1);2293 splice(@lines, 1, 1);
2210 $output = join("\n", @lines);2294 $output = join("\n", @lines);
2211 }2295 }
2212 $output = (split('\n', $output))[0] . "\n" if ($terse);2296
2297 if ($terse) {
2298 $output = (split('\n', $output))[0] . "\n";
2299 }
2300
2301 if ($verbose && exists($verbose_messages{$type}) &&
2302 !exists($verbose_emitted{$type})) {
2303 $output .= $verbose_messages{$type} . "\n\n";
2304 $verbose_emitted{$type} = 1;
2305 }
2213 2306
2214 push(our @report, $output);2307 push(our @report, $output);
2215 2308
scripts/get_abi.pl+53−21
@@ -281,8 +281,12 @@ sub create_labels { · 280 unmodified lines
281# Outputs the book on ReST format281# Outputs the book on ReST format
282#282#
283 283
284# \b doesn't work well with paths. So, we need to define something else284# \b doesn't work well with paths. So, we need to define something else:
285my $bondary = qr { (?<![\w\/\`\{])(?=[\w\/\`\{])|(?<=[\w\/\`\{])(?![\w\/\`\{]) }x;285# Boundaries are punct characters, spaces and end-of-line
286my $start = qr {(^|\s|\() }x;
287my $bondary = qr { ([,.:;\)\s]|\z) }x;
288my $xref_match = qr { $start(\/(sys|config|proc|dev|kvd)\/[^,.:;\)\s]+)$bondary }x;
289my $symbols = qr { ([\x01-\x08\x0e-\x1f\x21-\x2f\x3a-\x40\x7b-\xff]) }x;
286 290
287sub output_rest {291sub output_rest {
288 create_labels();292 create_labels();
@@ -305,7 +309,6 @@ sub output_rest { · 16 unmodified lines
305 }309 }
306 310
307 my $w = $what;311 my $w = $what;
308 $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
309 312
310 if ($type ne "File") {313 if ($type ne "File") {
311 my $cur_part = $what;314 my $cur_part = $what;
@@ -329,6 +332,7 @@ sub output_rest { · 17 unmodified lines
329 my $len = 0;332 my $len = 0;
330 333
331 foreach my $name (@names) {334 foreach my $name (@names) {
335 $name =~ s/$symbols/\\$1/g;
332 $name = "**$name**";336 $name = "**$name**";
333 $len = length($name) if (length($name) > $len);337 $len = length($name) if (length($name) > $len);
334 }338 }
@@ -377,32 +381,60 @@ sub output_rest { · 42 unmodified lines
377 381
378 # Enrich text by creating cross-references382 # Enrich text by creating cross-references
379 383
380 $desc =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;384 my $new_desc = "";
385 my $init_indent = -1;
386 my $literal_indent = -1;
387
388 open(my $fh, "+<", \$desc);
389 while (my $d = <$fh>) {
390 my $indent = $d =~ m/^(\s+)/;
391 my $spaces = length($indent);
392 $init_indent = $indent if ($init_indent < 0);
393 if ($literal_indent >= 0) {
394 if ($spaces > $literal_indent) {
395 $new_desc .= $d;
396 next;
397 } else {
398 $literal_indent = -1;
399 }
400 } else {
401 if ($d =~ /()::$/ && !($d =~ /^\s*\.\./)) {
402 $literal_indent = $spaces;
403 }
404 }
381 405
382 my @matches = $desc =~ m,Documentation/ABI/([\w\/\-]+),;406 $d =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
383 foreach my $f (@matches) {
384 my $xref = $f;
385 my $path = $f;
386 $path =~ s,.*/(.*/.*),$1,;;
387 $path =~ s,[/\-],_,g;;
388 $xref .= " <abi_file_" . $path . ">";
389 $desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g;
390 }
391 407
392 @matches = $desc =~ m,$bondary(/sys/[^\s\.\,\;\:\*\s\`\'\(\)]+)$bondary,;408 my @matches = $d =~ m,Documentation/ABI/([\w\/\-]+),g;
409 foreach my $f (@matches) {
410 my $xref = $f;
411 my $path = $f;
412 $path =~ s,.*/(.*/.*),$1,;;
413 $path =~ s,[/\-],_,g;;
414 $xref .= " <abi_file_" . $path . ">";
415 $d =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g;
416 }
417
418 # Seek for cross reference symbols like /sys/...
419 @matches = $d =~ m/$xref_match/g;
393 420
394 foreach my $s (@matches) {421 foreach my $s (@matches) {
395 if (defined($data{$s}) && defined($data{$s}->{label})) {422 next if (!($s =~ m,/,));
396 my $xref = $s;423 if (defined($data{$s}) && defined($data{$s}->{label})) {
424 my $xref = $s;
397 425
398 $xref =~ s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g;426 $xref =~ s/$symbols/\\$1/g;
399 $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`";427 $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`";
400 428
401 $desc =~ s,$bondary$s$bondary,$xref,g;429 $d =~ s,$start$s$bondary,$1$xref$2,g;
430 }
402 }431 }
432 $new_desc .= $d;
403 }433 }
434 close $fh;
435
404 436
405 print "$desc\n\n";437 print "$new_desc\n\n";
406 } else {438 } else {
407 $desc =~ s/^\s+//;439 $desc =~ s/^\s+//;
408 440
scripts/kernel-doc+52−8
@@ -391,8 +391,14 @@ my $doc_com = '\s*\*\s*'; · 390 unmodified lines
391my $doc_com_body = '\s*\* ?';391my $doc_com_body = '\s*\* ?';
392my $doc_decl = $doc_com . '(\w+)';392my $doc_decl = $doc_com . '(\w+)';
393# @params and a strictly limited set of supported section names393# @params and a strictly limited set of supported section names
394# Specifically:
395# Match @word:
396# @...:
397# @{section-name}:
398# while trying to not match literal block starts like "example::"
399#
394my $doc_sect = $doc_com .400my $doc_sect = $doc_com .
395 '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)';401 '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:([^:].*)?$';
396my $doc_content = $doc_com_body . '(.*)';402my $doc_content = $doc_com_body . '(.*)';
397my $doc_block = $doc_com . 'DOC:\s*(.*)?';403my $doc_block = $doc_com . 'DOC:\s*(.*)?';
398my $doc_inline_start = '^\s*/\*\*\s*$';404my $doc_inline_start = '^\s*/\*\*\s*$';
@@ -1201,12 +1207,23 @@ sub dump_union($$) { · 802 unmodified lines
1201sub dump_struct($$) {1207sub dump_struct($$) {
1202 my $x = shift;1208 my $x = shift;
1203 my $file = shift;1209 my $file = shift;
1210 my $decl_type;
1211 my $members;
1212 my $type = qr{struct|union};
1213 # For capturing struct/union definition body, i.e. "{members*}qualifiers*"
1214 my $definition_body = qr{\{(.*)\}(?:\s*(?:__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*};
1204 1215
1205 if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {1216 if ($x =~ /($type)\s+(\w+)\s*$definition_body/) {
1206 my $decl_type = $1;1217 $decl_type = $1;
1207 $declaration_name = $2;1218 $declaration_name = $2;
1208 my $members = $3;1219 $members = $3;
1220 } elsif ($x =~ /typedef\s+($type)\s*$definition_body\s*(\w+)\s*;/) {
1221 $decl_type = $1;
1222 $declaration_name = $3;
1223 $members = $2;
1224 }
1209 1225
1226 if ($members) {
1210 if ($identifier ne $declaration_name) {1227 if ($identifier ne $declaration_name) {
1211 print STDERR "${file}:$.: warning: expecting prototype for $decl_type $identifier. Prototype was for $decl_type $declaration_name instead\n";1228 print STDERR "${file}:$.: warning: expecting prototype for $decl_type $identifier. Prototype was for $decl_type $declaration_name instead\n";
1212 return;1229 return;
@@ -1401,9 +1418,14 @@ sub dump_enum($$) { · 188 unmodified lines
1401 1418
1402 if ($members) {1419 if ($members) {
1403 if ($identifier ne $declaration_name) {1420 if ($identifier ne $declaration_name) {
1404 print STDERR "${file}:$.: warning: expecting prototype for enum $identifier. Prototype was for enum $declaration_name instead\n";1421 if ($identifier eq "") {
1422 print STDERR "${file}:$.: warning: wrong kernel-doc identifier on line:\n";
1423 } else {
1424 print STDERR "${file}:$.: warning: expecting prototype for enum $identifier. Prototype was for enum $declaration_name instead\n";
1425 }
1405 return;1426 return;
1406 }1427 }
1428 $declaration_name = "(anonymous)" if ($declaration_name eq "");
1407 1429
1408 my %_members;1430 my %_members;
1409 1431
@@ -1755,12 +1777,14 @@ sub dump_function($$) { · 345 unmodified lines
1755 $prototype =~ s/^noinline +//;1777 $prototype =~ s/^noinline +//;
1756 $prototype =~ s/__init +//;1778 $prototype =~ s/__init +//;
1757 $prototype =~ s/__init_or_module +//;1779 $prototype =~ s/__init_or_module +//;
1780 $prototype =~ s/__flatten +//;
1758 $prototype =~ s/__meminit +//;1781 $prototype =~ s/__meminit +//;
1759 $prototype =~ s/__must_check +//;1782 $prototype =~ s/__must_check +//;
1760 $prototype =~ s/__weak +//;1783 $prototype =~ s/__weak +//;
1761 $prototype =~ s/__sched +//;1784 $prototype =~ s/__sched +//;
1762 $prototype =~ s/__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +//;1785 $prototype =~ s/__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +//;
1763 my $define = $prototype =~ s/^#\s*define\s+//; #ak added1786 my $define = $prototype =~ s/^#\s*define\s+//; #ak added
1787 $prototype =~ s/__attribute_const__ +//;
1764 $prototype =~ s/__attribute__\s*\(\(1788 $prototype =~ s/__attribute__\s*\(\(
1765 (?:1789 (?:
1766 [\w\s]++ # attribute name1790 [\w\s]++ # attribute name
@@ -2085,15 +2109,28 @@ sub process_name($$) { · 318 unmodified lines
2085 }2109 }
2086 } elsif (/$doc_decl/o) {2110 } elsif (/$doc_decl/o) {
2087 $identifier = $1;2111 $identifier = $1;
2088 if (/\s*([\w\s]+?)(\(\))?\s*([-:].*)?$/) {2112 my $is_kernel_comment = 0;
2113 my $decl_start = qr{\s*\*};
2114 # test for pointer declaration type, foo * bar() - desc
2115 my $fn_type = qr{\w+\s*\*\s*};
2116 my $parenthesis = qr{\(\w*\)};
2117 my $decl_end = qr{[-:].*};
2118 if (/^$decl_start\s*([\w\s]+?)$parenthesis?\s*$decl_end?$/) {
2089 $identifier = $1;2119 $identifier = $1;
2090 }2120 }
2091 if ($identifier =~ m/^(struct|union|enum|typedef)\b\s*(\S*)/) {2121 if ($identifier =~ m/^(struct|union|enum|typedef)\b\s*(\S*)/) {
2092 $decl_type = $1;2122 $decl_type = $1;
2093 $identifier = $2;2123 $identifier = $2;
2094 } else {2124 $is_kernel_comment = 1;
2125 }
2126 # Look for foo() or static void foo() - description; or misspelt
2127 # identifier
2128 elsif (/^$decl_start\s*$fn_type?(\w+)\s*$parenthesis?\s*$decl_end?$/ ||
2129 /^$decl_start\s*$fn_type?(\w+.*)$parenthesis?\s*$decl_end$/) {
2130 $identifier = $1;
2095 $decl_type = 'function';2131 $decl_type = 'function';
2096 $identifier =~ s/^define\s+//;2132 $identifier =~ s/^define\s+//;
2133 $is_kernel_comment = 1;
2097 }2134 }
2098 $identifier =~ s/\s+$//;2135 $identifier =~ s/\s+$//;
2099 2136
@@ -2115,13 +2152,20 @@ sub process_name($$) { · 15 unmodified lines
2115 $declaration_purpose = "";2152 $declaration_purpose = "";
2116 }2153 }
2117 2154
2155 if (!$is_kernel_comment) {
2156 print STDERR "${file}:$.: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n";
2157 print STDERR $_;
2158 ++$warnings;
2159 $state = STATE_NORMAL;
2160 }
2161
2118 if (($declaration_purpose eq "") && $verbose) {2162 if (($declaration_purpose eq "") && $verbose) {
2119 print STDERR "${file}:$.: warning: missing initial short description on line:\n";2163 print STDERR "${file}:$.: warning: missing initial short description on line:\n";
2120 print STDERR $_;2164 print STDERR $_;
2121 ++$warnings;2165 ++$warnings;
2122 }2166 }
2123 2167
2124 if ($identifier eq "") {2168 if ($identifier eq "" && $decl_type ne "enum") {
2125 print STDERR "${file}:$.: warning: wrong kernel-doc identifier on line:\n";2169 print STDERR "${file}:$.: warning: wrong kernel-doc identifier on line:\n";
2126 print STDERR $_;2170 print STDERR $_;
2127 ++$warnings;2171 ++$warnings;
scripts/sphinx-pre-install+1−1
@@ -259,7 +259,7 @@ sub get_sphinx_version($) · 258 unmodified lines
259 259
260 open IN, "$cmd --version 2>&1 |";260 open IN, "$cmd --version 2>&1 |";
261 while (<IN>) {261 while (<IN>) {
262 if (m/^\s*sphinx-build\s+([\d\.]+)(\+\/[\da-f]+)?$/) {262 if (m/^\s*sphinx-build\s+([\d\.]+)((\+\/[\da-f]+)|(b\d+))?$/) {
263 $ver=$1;263 $ver=$1;
264 last;264 last;
265 }265 }
tools/debugging/kernel-chktaint+1−1
@@ -25,7 +25,7 @@ if [ "$1"x != "x" ]; then · 24 unmodified lines
25 elif [ $1 -ge 0 ] 2>/dev/null ; then25 elif [ $1 -ge 0 ] 2>/dev/null ; then
26 taint=$126 taint=$1
27 else27 else
28 echo "Error: Parameter '$1' not a positive interger. Aborting." >&228 echo "Error: Parameter '$1' not a positive integer. Aborting." >&2
29 exit 129 exit 1
30 fi30 fi
31else31else
tools/scripts/Makefile.include+2−1
@@ -86,7 +86,8 @@ endif · 85 unmodified lines
86# in newer systems.86# in newer systems.
87# Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h87# Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
88#88#
89# See https://lkml.org/lkml/2006/11/28/253 and https://gcc.gnu.org/gcc-4.8/changes.html,89# See https://lore.kernel.org/lkml/9a8748490611281710g78402fbeh8ff7fcc162dbcbca@mail.gmail.com/
90# and https://gcc.gnu.org/gcc-4.8/changes.html,
90# that takes into account Linus's comments (search for Wshadow) for the reasoning about91# that takes into account Linus's comments (search for Wshadow) for the reasoning about
91# -Wshadow not being interesting before gcc 4.8.92# -Wshadow not being interesting before gcc 4.8.
92 93