diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-12-29 14:21:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-12-29 14:21:49 -0500 |
commit | 3868772b99e3146d02cf47e739d79022eba1d77c (patch) | |
tree | d32c0283496e6955937b618981766b5f0878724f | |
parent | 6f9d71c9c759b1e7d31189a4de228983192c7dc7 (diff) | |
parent | 942104a21ce4951420ddf6c6b3179a0627301f7e (diff) |
Merge tag 'docs-5.0' of git://git.lwn.net/linux
Pull documentation update from Jonathan Corbet:
"A fairly normal cycle for documentation stuff. We have a new document
on perf security, more Italian translations, more improvements to the
memory-management docs, improvements to the pathname lookup
documentation, and the usual array of smaller fixes.
As is often the case, there are a few reaches outside of
Documentation/ to adjust kerneldoc comments"
* tag 'docs-5.0' of git://git.lwn.net/linux: (38 commits)
docs: improve pathname-lookup document structure
configfs: fix wrong name of struct in documentation
docs/mm-api: link slab_common.c to "The Slab Cache" section
slab: make kmem_cache_create{_usercopy} description proper kernel-doc
doc:process: add links where missing
docs/core-api: make mm-api.rst more structured
x86, boot: documentation whitespace fixup
Documentation: devres: note checking needs when converting
doc:it: add some process/* translations
doc:it: fixes in process/1.Intro
Documentation: convert path-lookup from markdown to resturctured text
Documentation/admin-guide: update admin-guide index.rst
Documentation/admin-guide: introduce perf-security.rst file
scripts/kernel-doc: Fix struct and struct field attribute processing
Documentation: dev-tools: Fix typos in index.rst
Correct gen_init_cpio tool's documentation
Document /proc/pid PID reuse behavior
Documentation: update path-lookup.md for parallel lookups
Documentation: Use "while" instead of "whilst"
dmaengine: Add mailing list address to the documentation
...
119 files changed, 6688 insertions, 654 deletions
diff --git a/Documentation/EDID/1024x768.S b/Documentation/EDID/1024x768.S index 6f3e4b75e49e..4aed3f9ab88a 100644 --- a/Documentation/EDID/1024x768.S +++ b/Documentation/EDID/1024x768.S | |||
@@ -31,14 +31,13 @@ | |||
31 | #define YBLANK 38 | 31 | #define YBLANK 38 |
32 | #define XOFFSET 8 | 32 | #define XOFFSET 8 |
33 | #define XPULSE 144 | 33 | #define XPULSE 144 |
34 | #define YOFFSET (63+3) | 34 | #define YOFFSET 3 |
35 | #define YPULSE (63+6) | 35 | #define YPULSE 6 |
36 | #define DPI 72 | 36 | #define DPI 72 |
37 | #define VFREQ 60 /* Hz */ | 37 | #define VFREQ 60 /* Hz */ |
38 | #define TIMING_NAME "Linux XGA" | 38 | #define TIMING_NAME "Linux XGA" |
39 | #define ESTABLISHED_TIMING2_BITS 0x08 /* Bit 3 -> 1024x768 @60 Hz */ | 39 | #define ESTABLISHED_TIMING2_BITS 0x08 /* Bit 3 -> 1024x768 @60 Hz */ |
40 | #define HSYNC_POL 0 | 40 | #define HSYNC_POL 0 |
41 | #define VSYNC_POL 0 | 41 | #define VSYNC_POL 0 |
42 | #define CRC 0x55 | ||
43 | 42 | ||
44 | #include "edid.S" | 43 | #include "edid.S" |
diff --git a/Documentation/EDID/1280x1024.S b/Documentation/EDID/1280x1024.S index bd9bef2a65af..b26dd424cad7 100644 --- a/Documentation/EDID/1280x1024.S +++ b/Documentation/EDID/1280x1024.S | |||
@@ -31,14 +31,13 @@ | |||
31 | #define YBLANK 42 | 31 | #define YBLANK 42 |
32 | #define XOFFSET 48 | 32 | #define XOFFSET 48 |
33 | #define XPULSE 112 | 33 | #define XPULSE 112 |
34 | #define YOFFSET (63+1) | 34 | #define YOFFSET 1 |
35 | #define YPULSE (63+3) | 35 | #define YPULSE 3 |
36 | #define DPI 72 | 36 | #define DPI 72 |
37 | #define VFREQ 60 /* Hz */ | 37 | #define VFREQ 60 /* Hz */ |
38 | #define TIMING_NAME "Linux SXGA" | 38 | #define TIMING_NAME "Linux SXGA" |
39 | /* No ESTABLISHED_TIMINGx_BITS */ | 39 | /* No ESTABLISHED_TIMINGx_BITS */ |
40 | #define HSYNC_POL 1 | 40 | #define HSYNC_POL 1 |
41 | #define VSYNC_POL 1 | 41 | #define VSYNC_POL 1 |
42 | #define CRC 0xa0 | ||
43 | 42 | ||
44 | #include "edid.S" | 43 | #include "edid.S" |
diff --git a/Documentation/EDID/1600x1200.S b/Documentation/EDID/1600x1200.S index a45101c6160c..0d091b282768 100644 --- a/Documentation/EDID/1600x1200.S +++ b/Documentation/EDID/1600x1200.S | |||
@@ -31,14 +31,13 @@ | |||
31 | #define YBLANK 50 | 31 | #define YBLANK 50 |
32 | #define XOFFSET 64 | 32 | #define XOFFSET 64 |
33 | #define XPULSE 192 | 33 | #define XPULSE 192 |
34 | #define YOFFSET (63+1) | 34 | #define YOFFSET 1 |
35 | #define YPULSE (63+3) | 35 | #define YPULSE 3 |
36 | #define DPI 72 | 36 | #define DPI 72 |
37 | #define VFREQ 60 /* Hz */ | 37 | #define VFREQ 60 /* Hz */ |
38 | #define TIMING_NAME "Linux UXGA" | 38 | #define TIMING_NAME "Linux UXGA" |
39 | /* No ESTABLISHED_TIMINGx_BITS */ | 39 | /* No ESTABLISHED_TIMINGx_BITS */ |
40 | #define HSYNC_POL 1 | 40 | #define HSYNC_POL 1 |
41 | #define VSYNC_POL 1 | 41 | #define VSYNC_POL 1 |
42 | #define CRC 0x9d | ||
43 | 42 | ||
44 | #include "edid.S" | 43 | #include "edid.S" |
diff --git a/Documentation/EDID/1680x1050.S b/Documentation/EDID/1680x1050.S index b0d7c69282b4..7dfed9a33eab 100644 --- a/Documentation/EDID/1680x1050.S +++ b/Documentation/EDID/1680x1050.S | |||
@@ -31,14 +31,13 @@ | |||
31 | #define YBLANK 39 | 31 | #define YBLANK 39 |
32 | #define XOFFSET 104 | 32 | #define XOFFSET 104 |
33 | #define XPULSE 176 | 33 | #define XPULSE 176 |
34 | #define YOFFSET (63+3) | 34 | #define YOFFSET 3 |
35 | #define YPULSE (63+6) | 35 | #define YPULSE 6 |
36 | #define DPI 96 | 36 | #define DPI 96 |
37 | #define VFREQ 60 /* Hz */ | 37 | #define VFREQ 60 /* Hz */ |
38 | #define TIMING_NAME "Linux WSXGA" | 38 | #define TIMING_NAME "Linux WSXGA" |
39 | /* No ESTABLISHED_TIMINGx_BITS */ | 39 | /* No ESTABLISHED_TIMINGx_BITS */ |
40 | #define HSYNC_POL 1 | 40 | #define HSYNC_POL 1 |
41 | #define VSYNC_POL 1 | 41 | #define VSYNC_POL 1 |
42 | #define CRC 0x26 | ||
43 | 42 | ||
44 | #include "edid.S" | 43 | #include "edid.S" |
diff --git a/Documentation/EDID/1920x1080.S b/Documentation/EDID/1920x1080.S index 3084355e81e7..d6ffbba28e95 100644 --- a/Documentation/EDID/1920x1080.S +++ b/Documentation/EDID/1920x1080.S | |||
@@ -31,14 +31,13 @@ | |||
31 | #define YBLANK 45 | 31 | #define YBLANK 45 |
32 | #define XOFFSET 88 | 32 | #define XOFFSET 88 |
33 | #define XPULSE 44 | 33 | #define XPULSE 44 |
34 | #define YOFFSET (63+4) | 34 | #define YOFFSET 4 |
35 | #define YPULSE (63+5) | 35 | #define YPULSE 5 |
36 | #define DPI 96 | 36 | #define DPI 96 |
37 | #define VFREQ 60 /* Hz */ | 37 | #define VFREQ 60 /* Hz */ |
38 | #define TIMING_NAME "Linux FHD" | 38 | #define TIMING_NAME "Linux FHD" |
39 | /* No ESTABLISHED_TIMINGx_BITS */ | 39 | /* No ESTABLISHED_TIMINGx_BITS */ |
40 | #define HSYNC_POL 1 | 40 | #define HSYNC_POL 1 |
41 | #define VSYNC_POL 1 | 41 | #define VSYNC_POL 1 |
42 | #define CRC 0x05 | ||
43 | 42 | ||
44 | #include "edid.S" | 43 | #include "edid.S" |
diff --git a/Documentation/EDID/800x600.S b/Documentation/EDID/800x600.S index 6644e26d5801..a5616588de08 100644 --- a/Documentation/EDID/800x600.S +++ b/Documentation/EDID/800x600.S | |||
@@ -28,14 +28,13 @@ | |||
28 | #define YBLANK 28 | 28 | #define YBLANK 28 |
29 | #define XOFFSET 40 | 29 | #define XOFFSET 40 |
30 | #define XPULSE 128 | 30 | #define XPULSE 128 |
31 | #define YOFFSET (63+1) | 31 | #define YOFFSET 1 |
32 | #define YPULSE (63+4) | 32 | #define YPULSE 4 |
33 | #define DPI 72 | 33 | #define DPI 72 |
34 | #define VFREQ 60 /* Hz */ | 34 | #define VFREQ 60 /* Hz */ |
35 | #define TIMING_NAME "Linux SVGA" | 35 | #define TIMING_NAME "Linux SVGA" |
36 | #define ESTABLISHED_TIMING1_BITS 0x01 /* Bit 0: 800x600 @ 60Hz */ | 36 | #define ESTABLISHED_TIMING1_BITS 0x01 /* Bit 0: 800x600 @ 60Hz */ |
37 | #define HSYNC_POL 1 | 37 | #define HSYNC_POL 1 |
38 | #define VSYNC_POL 1 | 38 | #define VSYNC_POL 1 |
39 | #define CRC 0xc2 | ||
40 | 39 | ||
41 | #include "edid.S" | 40 | #include "edid.S" |
diff --git a/Documentation/EDID/HOWTO.txt b/Documentation/EDID/HOWTO.txt index 835db332289b..539871c3b785 100644 --- a/Documentation/EDID/HOWTO.txt +++ b/Documentation/EDID/HOWTO.txt | |||
@@ -45,14 +45,5 @@ EDID: | |||
45 | 45 | ||
46 | #define YPIX vdisp | 46 | #define YPIX vdisp |
47 | #define YBLANK vtotal-vdisp | 47 | #define YBLANK vtotal-vdisp |
48 | #define YOFFSET (63+(vsyncstart-vdisp)) | 48 | #define YOFFSET vsyncstart-vdisp |
49 | #define YPULSE (63+(vsyncend-vsyncstart)) | 49 | #define YPULSE vsyncend-vsyncstart |
50 | |||
51 | The CRC value in the last line | ||
52 | #define CRC 0x55 | ||
53 | also is a bit tricky. After a first version of the binary data set is | ||
54 | created, it must be checked with the "edid-decode" utility which will | ||
55 | most probably complain about a wrong CRC. Fortunately, the utility also | ||
56 | displays the correct CRC which must then be inserted into the source | ||
57 | file. After the make procedure is repeated, the EDID data set is ready | ||
58 | to be used. | ||
diff --git a/Documentation/EDID/Makefile b/Documentation/EDID/Makefile index 17763ca3f12b..85a927dfab02 100644 --- a/Documentation/EDID/Makefile +++ b/Documentation/EDID/Makefile | |||
@@ -15,10 +15,21 @@ clean: | |||
15 | %.o: %.S | 15 | %.o: %.S |
16 | @cc -c $^ | 16 | @cc -c $^ |
17 | 17 | ||
18 | %.bin: %.o | 18 | %.bin.nocrc: %.o |
19 | @objcopy -Obinary $^ $@ | 19 | @objcopy -Obinary $^ $@ |
20 | 20 | ||
21 | %.bin.ihex: %.o | 21 | %.crc: %.bin.nocrc |
22 | @list=$$(for i in `seq 1 127`; do head -c$$i $^ | tail -c1 \ | ||
23 | | hexdump -v -e '/1 "%02X+"'; done); \ | ||
24 | echo "ibase=16;100-($${list%?})%100" | bc >$@ | ||
25 | |||
26 | %.p: %.crc %.S | ||
27 | @cc -c -DCRC="$$(cat $*.crc)" -o $@ $*.S | ||
28 | |||
29 | %.bin: %.p | ||
30 | @objcopy -Obinary $^ $@ | ||
31 | |||
32 | %.bin.ihex: %.p | ||
22 | @objcopy -Oihex $^ $@ | 33 | @objcopy -Oihex $^ $@ |
23 | @dos2unix $@ 2>/dev/null | 34 | @dos2unix $@ 2>/dev/null |
24 | 35 | ||
diff --git a/Documentation/EDID/edid.S b/Documentation/EDID/edid.S index ef082dcc6084..c3d13815526d 100644 --- a/Documentation/EDID/edid.S +++ b/Documentation/EDID/edid.S | |||
@@ -47,9 +47,11 @@ | |||
47 | #define mfgname2id(v1,v2,v3) \ | 47 | #define mfgname2id(v1,v2,v3) \ |
48 | ((((v1-'@')&0x1f)<<10)+(((v2-'@')&0x1f)<<5)+((v3-'@')&0x1f)) | 48 | ((((v1-'@')&0x1f)<<10)+(((v2-'@')&0x1f)<<5)+((v3-'@')&0x1f)) |
49 | #define swap16(v1) ((v1>>8)+((v1&0xff)<<8)) | 49 | #define swap16(v1) ((v1>>8)+((v1&0xff)<<8)) |
50 | #define lsbs2(v1,v2) (((v1&0x0f)<<4)+(v2&0x0f)) | ||
50 | #define msbs2(v1,v2) ((((v1>>8)&0x0f)<<4)+((v2>>8)&0x0f)) | 51 | #define msbs2(v1,v2) ((((v1>>8)&0x0f)<<4)+((v2>>8)&0x0f)) |
51 | #define msbs4(v1,v2,v3,v4) \ | 52 | #define msbs4(v1,v2,v3,v4) \ |
52 | (((v1&0x03)>>2)+((v2&0x03)>>4)+((v3&0x03)>>6)+((v4&0x03)>>8)) | 53 | ((((v1>>8)&0x03)<<6)+(((v2>>8)&0x03)<<4)+\ |
54 | (((v3>>4)&0x03)<<2)+((v4>>4)&0x03)) | ||
53 | #define pixdpi2mm(pix,dpi) ((pix*25)/dpi) | 55 | #define pixdpi2mm(pix,dpi) ((pix*25)/dpi) |
54 | #define xsize pixdpi2mm(XPIX,DPI) | 56 | #define xsize pixdpi2mm(XPIX,DPI) |
55 | #define ysize pixdpi2mm(YPIX,DPI) | 57 | #define ysize pixdpi2mm(YPIX,DPI) |
@@ -200,9 +202,9 @@ y_msbs: .byte msbs2(YPIX,YBLANK) | |||
200 | x_snc_off_lsb: .byte XOFFSET&0xff | 202 | x_snc_off_lsb: .byte XOFFSET&0xff |
201 | /* Horizontal sync pulse width pixels 8 lsbits (0-1023) */ | 203 | /* Horizontal sync pulse width pixels 8 lsbits (0-1023) */ |
202 | x_snc_pls_lsb: .byte XPULSE&0xff | 204 | x_snc_pls_lsb: .byte XPULSE&0xff |
203 | /* Bits 7-4 Vertical sync offset lines 4 lsbits -63) | 205 | /* Bits 7-4 Vertical sync offset lines 4 lsbits (0-63) |
204 | Bits 3-0 Vertical sync pulse width lines 4 lsbits -63) */ | 206 | Bits 3-0 Vertical sync pulse width lines 4 lsbits (0-63) */ |
205 | y_snc_lsb: .byte ((YOFFSET-63)<<4)+(YPULSE-63) | 207 | y_snc_lsb: .byte lsbs2(YOFFSET, YPULSE) |
206 | /* Bits 7-6 Horizontal sync offset pixels 2 msbits | 208 | /* Bits 7-6 Horizontal sync offset pixels 2 msbits |
207 | Bits 5-4 Horizontal sync pulse width pixels 2 msbits | 209 | Bits 5-4 Horizontal sync pulse width pixels 2 msbits |
208 | Bits 3-2 Vertical sync offset lines 2 msbits | 210 | Bits 3-2 Vertical sync offset lines 2 msbits |
diff --git a/Documentation/admin-guide/devices.rst b/Documentation/admin-guide/devices.rst index 7fadc05330dd..d41671aeaef0 100644 --- a/Documentation/admin-guide/devices.rst +++ b/Documentation/admin-guide/devices.rst | |||
@@ -1,3 +1,4 @@ | |||
1 | .. _admin_devices: | ||
1 | 2 | ||
2 | Linux allocated devices (4.x+ version) | 3 | Linux allocated devices (4.x+ version) |
3 | ====================================== | 4 | ====================================== |
diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index fdf72429f801..252e5ef324e5 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst | |||
@@ -110,8 +110,8 @@ If your query set is big, you can batch them too:: | |||
110 | 110 | ||
111 | ~# cat query-batch-file > <debugfs>/dynamic_debug/control | 111 | ~# cat query-batch-file > <debugfs>/dynamic_debug/control |
112 | 112 | ||
113 | A another way is to use wildcard. The match rule support ``*`` (matches | 113 | Another way is to use wildcards. The match rule supports ``*`` (matches |
114 | zero or more characters) and ``?`` (matches exactly one character).For | 114 | zero or more characters) and ``?`` (matches exactly one character). For |
115 | example, you can match all usb drivers:: | 115 | example, you can match all usb drivers:: |
116 | 116 | ||
117 | ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control | 117 | ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control |
@@ -258,7 +258,7 @@ this boot parameter for debugging purposes. | |||
258 | 258 | ||
259 | If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at | 259 | If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at |
260 | boot time, without effect, but will be reprocessed when module is | 260 | boot time, without effect, but will be reprocessed when module is |
261 | loaded later. ``dyndbg_query=`` and bare ``dyndbg=`` are only processed at | 261 | loaded later. ``ddebug_query=`` and bare ``dyndbg=`` are only processed at |
262 | boot. | 262 | boot. |
263 | 263 | ||
264 | 264 | ||
@@ -301,7 +301,7 @@ The ``dyndbg`` option is a "fake" module parameter, which means: | |||
301 | 301 | ||
302 | For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or | 302 | For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or |
303 | enabled by ``-DDEBUG`` flag during compilation) can be disabled later via | 303 | enabled by ``-DDEBUG`` flag during compilation) can be disabled later via |
304 | the sysfs interface if the debug messages are no longer needed:: | 304 | the debugfs interface if the debug messages are no longer needed:: |
305 | 305 | ||
306 | echo "module module_name -p" > <debugfs>/dynamic_debug/control | 306 | echo "module module_name -p" > <debugfs>/dynamic_debug/control |
307 | 307 | ||
diff --git a/Documentation/admin-guide/index.rst b/Documentation/admin-guide/index.rst index 965745d5fb9a..0a491676685e 100644 --- a/Documentation/admin-guide/index.rst +++ b/Documentation/admin-guide/index.rst | |||
@@ -76,6 +76,7 @@ configure specific aspects of kernel behavior to your liking. | |||
76 | thunderbolt | 76 | thunderbolt |
77 | LSM/index | 77 | LSM/index |
78 | mm/index | 78 | mm/index |
79 | perf-security | ||
79 | 80 | ||
80 | .. only:: subproject and html | 81 | .. only:: subproject and html |
81 | 82 | ||
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b7c9040f547e..37e235be1d35 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
@@ -331,7 +331,7 @@ | |||
331 | APC and your system crashes randomly. | 331 | APC and your system crashes randomly. |
332 | 332 | ||
333 | apic= [APIC,X86] Advanced Programmable Interrupt Controller | 333 | apic= [APIC,X86] Advanced Programmable Interrupt Controller |
334 | Change the output verbosity whilst booting | 334 | Change the output verbosity while booting |
335 | Format: { quiet (default) | verbose | debug } | 335 | Format: { quiet (default) | verbose | debug } |
336 | Change the amount of debugging information output | 336 | Change the amount of debugging information output |
337 | when initialising the APIC and IO-APIC components. | 337 | when initialising the APIC and IO-APIC components. |
diff --git a/Documentation/admin-guide/mm/concepts.rst b/Documentation/admin-guide/mm/concepts.rst index 291699c810d4..c2531b14bf46 100644 --- a/Documentation/admin-guide/mm/concepts.rst +++ b/Documentation/admin-guide/mm/concepts.rst | |||
@@ -4,13 +4,13 @@ | |||
4 | Concepts overview | 4 | Concepts overview |
5 | ================= | 5 | ================= |
6 | 6 | ||
7 | The memory management in Linux is complex system that evolved over the | 7 | The memory management in Linux is a complex system that evolved over the |
8 | years and included more and more functionality to support variety of | 8 | years and included more and more functionality to support a variety of |
9 | systems from MMU-less microcontrollers to supercomputers. The memory | 9 | systems from MMU-less microcontrollers to supercomputers. The memory |
10 | management for systems without MMU is called ``nommu`` and it | 10 | management for systems without an MMU is called ``nommu`` and it |
11 | definitely deserves a dedicated document, which hopefully will be | 11 | definitely deserves a dedicated document, which hopefully will be |
12 | eventually written. Yet, although some of the concepts are the same, | 12 | eventually written. Yet, although some of the concepts are the same, |
13 | here we assume that MMU is available and CPU can translate a virtual | 13 | here we assume that an MMU is available and a CPU can translate a virtual |
14 | address to a physical address. | 14 | address to a physical address. |
15 | 15 | ||
16 | .. contents:: :local: | 16 | .. contents:: :local: |
@@ -21,10 +21,10 @@ Virtual Memory Primer | |||
21 | The physical memory in a computer system is a limited resource and | 21 | The physical memory in a computer system is a limited resource and |
22 | even for systems that support memory hotplug there is a hard limit on | 22 | even for systems that support memory hotplug there is a hard limit on |
23 | the amount of memory that can be installed. The physical memory is not | 23 | the amount of memory that can be installed. The physical memory is not |
24 | necessary contiguous, it might be accessible as a set of distinct | 24 | necessarily contiguous; it might be accessible as a set of distinct |
25 | address ranges. Besides, different CPU architectures, and even | 25 | address ranges. Besides, different CPU architectures, and even |
26 | different implementations of the same architecture have different view | 26 | different implementations of the same architecture have different views |
27 | how these address ranges defined. | 27 | of how these address ranges are defined. |
28 | 28 | ||
29 | All this makes dealing directly with physical memory quite complex and | 29 | All this makes dealing directly with physical memory quite complex and |
30 | to avoid this complexity a concept of virtual memory was developed. | 30 | to avoid this complexity a concept of virtual memory was developed. |
@@ -48,8 +48,8 @@ appropriate kernel configuration option. | |||
48 | 48 | ||
49 | Each physical memory page can be mapped as one or more virtual | 49 | Each physical memory page can be mapped as one or more virtual |
50 | pages. These mappings are described by page tables that allow | 50 | pages. These mappings are described by page tables that allow |
51 | translation from virtual address used by programs to real address in | 51 | translation from a virtual address used by programs to the physical |
52 | the physical memory. The page tables organized hierarchically. | 52 | memory address. The page tables are organized hierarchically. |
53 | 53 | ||
54 | The tables at the lowest level of the hierarchy contain physical | 54 | The tables at the lowest level of the hierarchy contain physical |
55 | addresses of actual pages used by the software. The tables at higher | 55 | addresses of actual pages used by the software. The tables at higher |
@@ -121,8 +121,8 @@ Nodes | |||
121 | Many multi-processor machines are NUMA - Non-Uniform Memory Access - | 121 | Many multi-processor machines are NUMA - Non-Uniform Memory Access - |
122 | systems. In such systems the memory is arranged into banks that have | 122 | systems. In such systems the memory is arranged into banks that have |
123 | different access latency depending on the "distance" from the | 123 | different access latency depending on the "distance" from the |
124 | processor. Each bank is referred as `node` and for each node Linux | 124 | processor. Each bank is referred to as a `node` and for each node Linux |
125 | constructs an independent memory management subsystem. A node has it's | 125 | constructs an independent memory management subsystem. A node has its |
126 | own set of zones, lists of free and used pages and various statistics | 126 | own set of zones, lists of free and used pages and various statistics |
127 | counters. You can find more details about NUMA in | 127 | counters. You can find more details about NUMA in |
128 | :ref:`Documentation/vm/numa.rst <numa>` and in | 128 | :ref:`Documentation/vm/numa.rst <numa>` and in |
@@ -149,9 +149,9 @@ for program's stack and heap or by explicit calls to mmap(2) system | |||
149 | call. Usually, the anonymous mappings only define virtual memory areas | 149 | call. Usually, the anonymous mappings only define virtual memory areas |
150 | that the program is allowed to access. The read accesses will result | 150 | that the program is allowed to access. The read accesses will result |
151 | in creation of a page table entry that references a special physical | 151 | in creation of a page table entry that references a special physical |
152 | page filled with zeroes. When the program performs a write, regular | 152 | page filled with zeroes. When the program performs a write, a regular |
153 | physical page will be allocated to hold the written data. The page | 153 | physical page will be allocated to hold the written data. The page |
154 | will be marked dirty and if the kernel will decide to repurpose it, | 154 | will be marked dirty and if the kernel decides to repurpose it, |
155 | the dirty page will be swapped out. | 155 | the dirty page will be swapped out. |
156 | 156 | ||
157 | Reclaim | 157 | Reclaim |
@@ -181,8 +181,8 @@ pressure. | |||
181 | The process of freeing the reclaimable physical memory pages and | 181 | The process of freeing the reclaimable physical memory pages and |
182 | repurposing them is called (surprise!) `reclaim`. Linux can reclaim | 182 | repurposing them is called (surprise!) `reclaim`. Linux can reclaim |
183 | pages either asynchronously or synchronously, depending on the state | 183 | pages either asynchronously or synchronously, depending on the state |
184 | of the system. When system is not loaded, most of the memory is free | 184 | of the system. When the system is not loaded, most of the memory is free |
185 | and allocation request will be satisfied immediately from the free | 185 | and allocation requests will be satisfied immediately from the free |
186 | pages supply. As the load increases, the amount of the free pages goes | 186 | pages supply. As the load increases, the amount of the free pages goes |
187 | down and when it reaches a certain threshold (high watermark), an | 187 | down and when it reaches a certain threshold (high watermark), an |
188 | allocation request will awaken the ``kswapd`` daemon. It will | 188 | allocation request will awaken the ``kswapd`` daemon. It will |
@@ -190,7 +190,7 @@ asynchronously scan memory pages and either just free them if the data | |||
190 | they contain is available elsewhere, or evict to the backing storage | 190 | they contain is available elsewhere, or evict to the backing storage |
191 | device (remember those dirty pages?). As memory usage increases even | 191 | device (remember those dirty pages?). As memory usage increases even |
192 | more and reaches another threshold - min watermark - an allocation | 192 | more and reaches another threshold - min watermark - an allocation |
193 | will trigger the `direct reclaim`. In this case allocation is stalled | 193 | will trigger `direct reclaim`. In this case allocation is stalled |
194 | until enough memory pages are reclaimed to satisfy the request. | 194 | until enough memory pages are reclaimed to satisfy the request. |
195 | 195 | ||
196 | Compaction | 196 | Compaction |
@@ -200,7 +200,7 @@ As the system runs, tasks allocate and free the memory and it becomes | |||
200 | fragmented. Although with virtual memory it is possible to present | 200 | fragmented. Although with virtual memory it is possible to present |
201 | scattered physical pages as virtually contiguous range, sometimes it is | 201 | scattered physical pages as virtually contiguous range, sometimes it is |
202 | necessary to allocate large physically contiguous memory areas. Such | 202 | necessary to allocate large physically contiguous memory areas. Such |
203 | need may arise, for instance, when a device driver requires large | 203 | need may arise, for instance, when a device driver requires a large |
204 | buffer for DMA, or when THP allocates a huge page. Memory `compaction` | 204 | buffer for DMA, or when THP allocates a huge page. Memory `compaction` |
205 | addresses the fragmentation issue. This mechanism moves occupied pages | 205 | addresses the fragmentation issue. This mechanism moves occupied pages |
206 | from the lower part of a memory zone to free pages in the upper part | 206 | from the lower part of a memory zone to free pages in the upper part |
@@ -208,15 +208,16 @@ of the zone. When a compaction scan is finished free pages are grouped | |||
208 | together at the beginning of the zone and allocations of large | 208 | together at the beginning of the zone and allocations of large |
209 | physically contiguous areas become possible. | 209 | physically contiguous areas become possible. |
210 | 210 | ||
211 | Like reclaim, the compaction may happen asynchronously in ``kcompactd`` | 211 | Like reclaim, the compaction may happen asynchronously in the ``kcompactd`` |
212 | daemon or synchronously as a result of memory allocation request. | 212 | daemon or synchronously as a result of a memory allocation request. |
213 | 213 | ||
214 | OOM killer | 214 | OOM killer |
215 | ========== | 215 | ========== |
216 | 216 | ||
217 | It may happen, that on a loaded machine memory will be exhausted. When | 217 | It is possible that on a loaded machine memory will be exhausted and the |
218 | the kernel detects that the system runs out of memory (OOM) it invokes | 218 | kernel will be unable to reclaim enough memory to continue to operate. In |
219 | `OOM killer`. Its mission is simple: all it has to do is to select a | 219 | order to save the rest of the system, it invokes the `OOM killer`. |
220 | task to sacrifice for the sake of the overall system health. The | 220 | |
221 | selected task is killed in a hope that after it exits enough memory | 221 | The `OOM killer` selects a task to sacrifice for the sake of the overall |
222 | will be freed to continue normal operation. | 222 | system health. The selected task is killed in a hope that after it exits |
223 | enough memory will be freed to continue normal operation. | ||
diff --git a/Documentation/admin-guide/perf-security.rst b/Documentation/admin-guide/perf-security.rst new file mode 100644 index 000000000000..f73ebfe9bfe2 --- /dev/null +++ b/Documentation/admin-guide/perf-security.rst | |||
@@ -0,0 +1,97 @@ | |||
1 | .. _perf_security: | ||
2 | |||
3 | Perf Events and tool security | ||
4 | ============================= | ||
5 | |||
6 | Overview | ||
7 | -------- | ||
8 | |||
9 | Usage of Performance Counters for Linux (perf_events) [1]_ , [2]_ , [3]_ can | ||
10 | impose a considerable risk of leaking sensitive data accessed by monitored | ||
11 | processes. The data leakage is possible both in scenarios of direct usage of | ||
12 | perf_events system call API [2]_ and over data files generated by Perf tool user | ||
13 | mode utility (Perf) [3]_ , [4]_ . The risk depends on the nature of data that | ||
14 | perf_events performance monitoring units (PMU) [2]_ collect and expose for | ||
15 | performance analysis. Having that said perf_events/Perf performance monitoring | ||
16 | is the subject for security access control management [5]_ . | ||
17 | |||
18 | perf_events/Perf access control | ||
19 | ------------------------------- | ||
20 | |||
21 | To perform security checks, the Linux implementation splits processes into two | ||
22 | categories [6]_ : a) privileged processes (whose effective user ID is 0, referred | ||
23 | to as superuser or root), and b) unprivileged processes (whose effective UID is | ||
24 | nonzero). Privileged processes bypass all kernel security permission checks so | ||
25 | perf_events performance monitoring is fully available to privileged processes | ||
26 | without access, scope and resource restrictions. | ||
27 | |||
28 | Unprivileged processes are subject to a full security permission check based on | ||
29 | the process's credentials [5]_ (usually: effective UID, effective GID, and | ||
30 | supplementary group list). | ||
31 | |||
32 | Linux divides the privileges traditionally associated with superuser into | ||
33 | distinct units, known as capabilities [6]_ , which can be independently enabled | ||
34 | and disabled on per-thread basis for processes and files of unprivileged users. | ||
35 | |||
36 | Unprivileged processes with enabled CAP_SYS_ADMIN capability are treated as | ||
37 | privileged processes with respect to perf_events performance monitoring and | ||
38 | bypass *scope* permissions checks in the kernel. | ||
39 | |||
40 | Unprivileged processes using perf_events system call API is also subject for | ||
41 | PTRACE_MODE_READ_REALCREDS ptrace access mode check [7]_ , whose outcome | ||
42 | determines whether monitoring is permitted. So unprivileged processes provided | ||
43 | with CAP_SYS_PTRACE capability are effectively permitted to pass the check. | ||
44 | |||
45 | Other capabilities being granted to unprivileged processes can effectively | ||
46 | enable capturing of additional data required for later performance analysis of | ||
47 | monitored processes or a system. For example, CAP_SYSLOG capability permits | ||
48 | reading kernel space memory addresses from /proc/kallsyms file. | ||
49 | |||
50 | perf_events/Perf unprivileged users | ||
51 | ----------------------------------- | ||
52 | |||
53 | perf_events/Perf *scope* and *access* control for unprivileged processes is | ||
54 | governed by perf_event_paranoid [2]_ setting: | ||
55 | |||
56 | -1: | ||
57 | Impose no *scope* and *access* restrictions on using perf_events performance | ||
58 | monitoring. Per-user per-cpu perf_event_mlock_kb [2]_ locking limit is | ||
59 | ignored when allocating memory buffers for storing performance data. | ||
60 | This is the least secure mode since allowed monitored *scope* is | ||
61 | maximized and no perf_events specific limits are imposed on *resources* | ||
62 | allocated for performance monitoring. | ||
63 | |||
64 | >=0: | ||
65 | *scope* includes per-process and system wide performance monitoring | ||
66 | but excludes raw tracepoints and ftrace function tracepoints monitoring. | ||
67 | CPU and system events happened when executing either in user or | ||
68 | in kernel space can be monitored and captured for later analysis. | ||
69 | Per-user per-cpu perf_event_mlock_kb locking limit is imposed but | ||
70 | ignored for unprivileged processes with CAP_IPC_LOCK [6]_ capability. | ||
71 | |||
72 | >=1: | ||
73 | *scope* includes per-process performance monitoring only and excludes | ||
74 | system wide performance monitoring. CPU and system events happened when | ||
75 | executing either in user or in kernel space can be monitored and | ||
76 | captured for later analysis. Per-user per-cpu perf_event_mlock_kb | ||
77 | locking limit is imposed but ignored for unprivileged processes with | ||
78 | CAP_IPC_LOCK capability. | ||
79 | |||
80 | >=2: | ||
81 | *scope* includes per-process performance monitoring only. CPU and system | ||
82 | events happened when executing in user space only can be monitored and | ||
83 | captured for later analysis. Per-user per-cpu perf_event_mlock_kb | ||
84 | locking limit is imposed but ignored for unprivileged processes with | ||
85 | CAP_IPC_LOCK capability. | ||
86 | |||
87 | Bibliography | ||
88 | ------------ | ||
89 | |||
90 | .. [1] `<https://lwn.net/Articles/337493/>`_ | ||
91 | .. [2] `<http://man7.org/linux/man-pages/man2/perf_event_open.2.html>`_ | ||
92 | .. [3] `<http://web.eece.maine.edu/~vweaver/projects/perf_events/>`_ | ||
93 | .. [4] `<https://perf.wiki.kernel.org/index.php/Main_Page>`_ | ||
94 | .. [5] `<https://www.kernel.org/doc/html/latest/security/credentials.html>`_ | ||
95 | .. [6] `<http://man7.org/linux/man-pages/man7/capabilities.7.html>`_ | ||
96 | .. [7] `<http://man7.org/linux/man-pages/man2/ptrace.2.html>`_ | ||
97 | |||
diff --git a/Documentation/admin-guide/ras.rst b/Documentation/admin-guide/ras.rst index 197896718f81..c7495e42e6f4 100644 --- a/Documentation/admin-guide/ras.rst +++ b/Documentation/admin-guide/ras.rst | |||
@@ -54,7 +54,7 @@ those errors are correctable. | |||
54 | Types of errors | 54 | Types of errors |
55 | --------------- | 55 | --------------- |
56 | 56 | ||
57 | Most mechanisms used on modern systems use use technologies like Hamming | 57 | Most mechanisms used on modern systems use technologies like Hamming |
58 | Codes that allow error correction when the number of errors on a bit packet | 58 | Codes that allow error correction when the number of errors on a bit packet |
59 | is below a threshold. If the number of errors is above, those mechanisms | 59 | is below a threshold. If the number of errors is above, those mechanisms |
60 | can indicate with a high degree of confidence that an error happened, but | 60 | can indicate with a high degree of confidence that an error happened, but |
diff --git a/Documentation/admin-guide/security-bugs.rst b/Documentation/admin-guide/security-bugs.rst index 30187d49dc2c..dcd6c93c7aac 100644 --- a/Documentation/admin-guide/security-bugs.rst +++ b/Documentation/admin-guide/security-bugs.rst | |||
@@ -44,7 +44,7 @@ only valid reason for deferring the publication of a fix is to accommodate | |||
44 | the logistics of QA and large scale rollouts which require release | 44 | the logistics of QA and large scale rollouts which require release |
45 | coordination. | 45 | coordination. |
46 | 46 | ||
47 | Whilst embargoed information may be shared with trusted individuals in | 47 | While embargoed information may be shared with trusted individuals in |
48 | order to develop a fix, such information will not be published alongside | 48 | order to develop a fix, such information will not be published alongside |
49 | the fix or on any other disclosure channel without the permission of the | 49 | the fix or on any other disclosure channel without the permission of the |
50 | reporter. This includes but is not limited to the original bug report | 50 | reporter. This includes but is not limited to the original bug report |
diff --git a/Documentation/arm/Booting b/Documentation/arm/Booting index 259f00af3ab3..f1f965ce93d6 100644 --- a/Documentation/arm/Booting +++ b/Documentation/arm/Booting | |||
@@ -126,7 +126,7 @@ tagged list. | |||
126 | The boot loader must pass at a minimum the size and location of the | 126 | The boot loader must pass at a minimum the size and location of the |
127 | system memory, and the root filesystem location. The dtb must be | 127 | system memory, and the root filesystem location. The dtb must be |
128 | placed in a region of memory where the kernel decompressor will not | 128 | placed in a region of memory where the kernel decompressor will not |
129 | overwrite it, whilst remaining within the region which will be covered | 129 | overwrite it, while remaining within the region which will be covered |
130 | by the kernel's low-memory mapping. | 130 | by the kernel's low-memory mapping. |
131 | 131 | ||
132 | A safe location is just above the 128MiB boundary from start of RAM. | 132 | A safe location is just above the 128MiB boundary from start of RAM. |
diff --git a/Documentation/arm/Samsung-S3C24XX/GPIO.txt b/Documentation/arm/Samsung-S3C24XX/GPIO.txt index 0ebd7e2244d0..e8f918b96123 100644 --- a/Documentation/arm/Samsung-S3C24XX/GPIO.txt +++ b/Documentation/arm/Samsung-S3C24XX/GPIO.txt | |||
@@ -55,7 +55,7 @@ out s3c2410 API, then here are some notes on the process. | |||
55 | as they have the same arguments, and can either take the pin specific | 55 | as they have the same arguments, and can either take the pin specific |
56 | values, or the more generic special-function-number arguments. | 56 | values, or the more generic special-function-number arguments. |
57 | 57 | ||
58 | 3) s3c2410_gpio_pullup() changes have the problem that whilst the | 58 | 3) s3c2410_gpio_pullup() changes have the problem that while the |
59 | s3c2410_gpio_pullup(x, 1) can be easily translated to the | 59 | s3c2410_gpio_pullup(x, 1) can be easily translated to the |
60 | s3c_gpio_setpull(x, S3C_GPIO_PULL_NONE), the s3c2410_gpio_pullup(x, 0) | 60 | s3c_gpio_setpull(x, S3C_GPIO_PULL_NONE), the s3c2410_gpio_pullup(x, 0) |
61 | are not so easy. | 61 | are not so easy. |
diff --git a/Documentation/arm/Samsung-S3C24XX/Overview.txt b/Documentation/arm/Samsung-S3C24XX/Overview.txt index 359587b2367b..00d3c3141e21 100644 --- a/Documentation/arm/Samsung-S3C24XX/Overview.txt +++ b/Documentation/arm/Samsung-S3C24XX/Overview.txt | |||
@@ -17,7 +17,7 @@ Introduction | |||
17 | versions. | 17 | versions. |
18 | 18 | ||
19 | The S3C2416 and S3C2450 devices are very similar and S3C2450 support is | 19 | The S3C2416 and S3C2450 devices are very similar and S3C2450 support is |
20 | included under the arch/arm/mach-s3c2416 directory. Note, whilst core | 20 | included under the arch/arm/mach-s3c2416 directory. Note, while core |
21 | support for these SoCs is in, work on some of the extra peripherals | 21 | support for these SoCs is in, work on some of the extra peripherals |
22 | and extra interrupts is still ongoing. | 22 | and extra interrupts is still ongoing. |
23 | 23 | ||
diff --git a/Documentation/arm/Samsung-S3C24XX/Suspend.txt b/Documentation/arm/Samsung-S3C24XX/Suspend.txt index 1ca63b3e5635..cb4f0c0cdf9d 100644 --- a/Documentation/arm/Samsung-S3C24XX/Suspend.txt +++ b/Documentation/arm/Samsung-S3C24XX/Suspend.txt | |||
@@ -87,7 +87,7 @@ Debugging | |||
87 | suspending, which means that use of printascii() or similar direct | 87 | suspending, which means that use of printascii() or similar direct |
88 | access to the UARTs will cause the debug to stop. | 88 | access to the UARTs will cause the debug to stop. |
89 | 89 | ||
90 | 2) Whilst the pm code itself will attempt to re-enable the UART clocks, | 90 | 2) While the pm code itself will attempt to re-enable the UART clocks, |
91 | care should be taken that any external clock sources that the UARTs | 91 | care should be taken that any external clock sources that the UARTs |
92 | rely on are still enabled at that point. | 92 | rely on are still enabled at that point. |
93 | 93 | ||
diff --git a/Documentation/core-api/assoc_array.rst b/Documentation/core-api/assoc_array.rst index 8231b915c939..792bbf9939e1 100644 --- a/Documentation/core-api/assoc_array.rst +++ b/Documentation/core-api/assoc_array.rst | |||
@@ -34,7 +34,7 @@ properties: | |||
34 | 8. The array can iterated over. The objects will not necessarily come out in | 34 | 8. The array can iterated over. The objects will not necessarily come out in |
35 | key order. | 35 | key order. |
36 | 36 | ||
37 | 9. The array can be iterated over whilst it is being modified, provided the | 37 | 9. The array can be iterated over while it is being modified, provided the |
38 | RCU readlock is being held by the iterator. Note, however, under these | 38 | RCU readlock is being held by the iterator. Note, however, under these |
39 | circumstances, some objects may be seen more than once. If this is a | 39 | circumstances, some objects may be seen more than once. If this is a |
40 | problem, the iterator should lock against modification. Objects will not | 40 | problem, the iterator should lock against modification. Objects will not |
@@ -42,7 +42,7 @@ properties: | |||
42 | 42 | ||
43 | 10. Objects in the array can be looked up by means of their index key. | 43 | 10. Objects in the array can be looked up by means of their index key. |
44 | 44 | ||
45 | 11. Objects can be looked up whilst the array is being modified, provided the | 45 | 11. Objects can be looked up while the array is being modified, provided the |
46 | RCU readlock is being held by the thread doing the look up. | 46 | RCU readlock is being held by the thread doing the look up. |
47 | 47 | ||
48 | The implementation uses a tree of 16-pointer nodes internally that are indexed | 48 | The implementation uses a tree of 16-pointer nodes internally that are indexed |
@@ -273,7 +273,7 @@ The function will return ``0`` if successful and ``-ENOMEM`` if there wasn't | |||
273 | enough memory. | 273 | enough memory. |
274 | 274 | ||
275 | It is possible for other threads to iterate over or search the array under | 275 | It is possible for other threads to iterate over or search the array under |
276 | the RCU read lock whilst this function is in progress. The caller should | 276 | the RCU read lock while this function is in progress. The caller should |
277 | lock exclusively against other modifiers of the array. | 277 | lock exclusively against other modifiers of the array. |
278 | 278 | ||
279 | 279 | ||
diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst index f8bb9aa120c4..8954a88ff5b7 100644 --- a/Documentation/core-api/memory-allocation.rst +++ b/Documentation/core-api/memory-allocation.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _memory-allocation: | ||
2 | |||
1 | ======================= | 3 | ======================= |
2 | Memory Allocation Guide | 4 | Memory Allocation Guide |
3 | ======================= | 5 | ======================= |
diff --git a/Documentation/core-api/mm-api.rst b/Documentation/core-api/mm-api.rst index 5ce1ec1dd066..aa8e54b85221 100644 --- a/Documentation/core-api/mm-api.rst +++ b/Documentation/core-api/mm-api.rst | |||
@@ -46,11 +46,20 @@ The Slab Cache | |||
46 | .. kernel-doc:: mm/slab.c | 46 | .. kernel-doc:: mm/slab.c |
47 | :export: | 47 | :export: |
48 | 48 | ||
49 | .. kernel-doc:: mm/slab_common.c | ||
50 | :export: | ||
51 | |||
49 | .. kernel-doc:: mm/util.c | 52 | .. kernel-doc:: mm/util.c |
50 | :functions: kfree_const kvmalloc_node kvfree | 53 | :functions: kfree_const kvmalloc_node kvfree |
51 | 54 | ||
52 | More Memory Management Functions | 55 | Virtually Contiguous Mappings |
53 | ================================ | 56 | ============================= |
57 | |||
58 | .. kernel-doc:: mm/vmalloc.c | ||
59 | :export: | ||
60 | |||
61 | File Mapping and Page Cache | ||
62 | =========================== | ||
54 | 63 | ||
55 | .. kernel-doc:: mm/readahead.c | 64 | .. kernel-doc:: mm/readahead.c |
56 | :export: | 65 | :export: |
@@ -58,23 +67,28 @@ More Memory Management Functions | |||
58 | .. kernel-doc:: mm/filemap.c | 67 | .. kernel-doc:: mm/filemap.c |
59 | :export: | 68 | :export: |
60 | 69 | ||
61 | .. kernel-doc:: mm/memory.c | 70 | .. kernel-doc:: mm/page-writeback.c |
62 | :export: | 71 | :export: |
63 | 72 | ||
64 | .. kernel-doc:: mm/vmalloc.c | 73 | .. kernel-doc:: mm/truncate.c |
65 | :export: | 74 | :export: |
66 | 75 | ||
67 | .. kernel-doc:: mm/page_alloc.c | 76 | Memory pools |
68 | :internal: | 77 | ============ |
69 | 78 | ||
70 | .. kernel-doc:: mm/mempool.c | 79 | .. kernel-doc:: mm/mempool.c |
71 | :export: | 80 | :export: |
72 | 81 | ||
82 | DMA pools | ||
83 | ========= | ||
84 | |||
73 | .. kernel-doc:: mm/dmapool.c | 85 | .. kernel-doc:: mm/dmapool.c |
74 | :export: | 86 | :export: |
75 | 87 | ||
76 | .. kernel-doc:: mm/page-writeback.c | 88 | More Memory Management Functions |
77 | :export: | 89 | ================================ |
78 | 90 | ||
79 | .. kernel-doc:: mm/truncate.c | 91 | .. kernel-doc:: mm/memory.c |
80 | :export: | 92 | :export: |
93 | |||
94 | .. kernel-doc:: mm/page_alloc.c | ||
diff --git a/Documentation/dev-tools/coccinelle.rst b/Documentation/dev-tools/coccinelle.rst index aa14f05cabb1..00a3409b0c28 100644 --- a/Documentation/dev-tools/coccinelle.rst +++ b/Documentation/dev-tools/coccinelle.rst | |||
@@ -4,6 +4,8 @@ | |||
4 | 4 | ||
5 | .. highlight:: none | 5 | .. highlight:: none |
6 | 6 | ||
7 | .. _devtools_coccinelle: | ||
8 | |||
7 | Coccinelle | 9 | Coccinelle |
8 | ========== | 10 | ========== |
9 | 11 | ||
diff --git a/Documentation/dev-tools/index.rst b/Documentation/dev-tools/index.rst index e313925fb0fa..b0522a4dd107 100644 --- a/Documentation/dev-tools/index.rst +++ b/Documentation/dev-tools/index.rst | |||
@@ -3,8 +3,8 @@ Development tools for the kernel | |||
3 | ================================ | 3 | ================================ |
4 | 4 | ||
5 | This document is a collection of documents about development tools that can | 5 | This document is a collection of documents about development tools that can |
6 | be used to work on the kernel. For now, the documents have been pulled | 6 | be used to work on the kernel. For now, the documents have been pulled |
7 | together without any significant effot to integrate them into a coherent | 7 | together without any significant effort to integrate them into a coherent |
8 | whole; patches welcome! | 8 | whole; patches welcome! |
9 | 9 | ||
10 | .. class:: toc-title | 10 | .. class:: toc-title |
diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst index dad1bb8711e2..7756f7a7c23b 100644 --- a/Documentation/dev-tools/kselftest.rst +++ b/Documentation/dev-tools/kselftest.rst | |||
@@ -9,7 +9,7 @@ and booting a kernel. | |||
9 | 9 | ||
10 | On some systems, hot-plug tests could hang forever waiting for cpu and | 10 | On some systems, hot-plug tests could hang forever waiting for cpu and |
11 | memory to be ready to be offlined. A special hot-plug target is created | 11 | memory to be ready to be offlined. A special hot-plug target is created |
12 | to run full range of hot-plug tests. In default mode, hot-plug tests run | 12 | to run the full range of hot-plug tests. In default mode, hot-plug tests run |
13 | in safe mode with a limited scope. In limited mode, cpu-hotplug test is | 13 | in safe mode with a limited scope. In limited mode, cpu-hotplug test is |
14 | run on a single cpu as opposed to all hotplug capable cpus, and memory | 14 | run on a single cpu as opposed to all hotplug capable cpus, and memory |
15 | hotplug test is run on 2% of hotplug capable memory instead of 10%. | 15 | hotplug test is run on 2% of hotplug capable memory instead of 10%. |
@@ -89,9 +89,9 @@ Note that some tests will require root privileges. | |||
89 | Install selftests | 89 | Install selftests |
90 | ================= | 90 | ================= |
91 | 91 | ||
92 | You can use kselftest_install.sh tool installs selftests in default | 92 | You can use the kselftest_install.sh tool to install selftests in the |
93 | location which is tools/testing/selftests/kselftest or a user specified | 93 | default location, which is tools/testing/selftests/kselftest, or in a |
94 | location. | 94 | user specified location. |
95 | 95 | ||
96 | To install selftests in default location:: | 96 | To install selftests in default location:: |
97 | 97 | ||
@@ -109,7 +109,7 @@ Running installed selftests | |||
109 | Kselftest install as well as the Kselftest tarball provide a script | 109 | Kselftest install as well as the Kselftest tarball provide a script |
110 | named "run_kselftest.sh" to run the tests. | 110 | named "run_kselftest.sh" to run the tests. |
111 | 111 | ||
112 | You can simply do the following to run the installed Kselftests. Please | 112 | You can simply do the following to run the installed Kselftests. Please |
113 | note some tests will require root privileges:: | 113 | note some tests will require root privileges:: |
114 | 114 | ||
115 | $ cd kselftest | 115 | $ cd kselftest |
@@ -139,7 +139,7 @@ Contributing new tests (details) | |||
139 | default. | 139 | default. |
140 | 140 | ||
141 | TEST_CUSTOM_PROGS should be used by tests that require custom build | 141 | TEST_CUSTOM_PROGS should be used by tests that require custom build |
142 | rule and prevent common build rule use. | 142 | rules and prevent common build rule use. |
143 | 143 | ||
144 | TEST_PROGS are for test shell scripts. Please ensure shell script has | 144 | TEST_PROGS are for test shell scripts. Please ensure shell script has |
145 | its exec bit set. Otherwise, lib.mk run_tests will generate a warning. | 145 | its exec bit set. Otherwise, lib.mk run_tests will generate a warning. |
diff --git a/Documentation/device-mapper/dm-raid.txt b/Documentation/device-mapper/dm-raid.txt index 52a719b49afd..2355bef14653 100644 --- a/Documentation/device-mapper/dm-raid.txt +++ b/Documentation/device-mapper/dm-raid.txt | |||
@@ -146,7 +146,7 @@ The target is named "raid" and it accepts the following parameters: | |||
146 | [data_offset <sectors>] | 146 | [data_offset <sectors>] |
147 | This option value defines the offset into each data device | 147 | This option value defines the offset into each data device |
148 | where the data starts. This is used to provide out-of-place | 148 | where the data starts. This is used to provide out-of-place |
149 | reshaping space to avoid writing over data whilst | 149 | reshaping space to avoid writing over data while |
150 | changing the layout of stripes, hence an interruption/crash | 150 | changing the layout of stripes, hence an interruption/crash |
151 | may happen at any time without the risk of losing data. | 151 | may happen at any time without the risk of losing data. |
152 | E.g. when adding devices to an existing raid set during | 152 | E.g. when adding devices to an existing raid set during |
diff --git a/Documentation/devicetree/bindings/arm/idle-states.txt b/Documentation/devicetree/bindings/arm/idle-states.txt index 2c73847499ab..8f0937db55c5 100644 --- a/Documentation/devicetree/bindings/arm/idle-states.txt +++ b/Documentation/devicetree/bindings/arm/idle-states.txt | |||
@@ -142,7 +142,7 @@ characterised by the following graph: | |||
142 | 142 | ||
143 | The graph is split in two parts delimited by time 1ms on the X-axis. | 143 | The graph is split in two parts delimited by time 1ms on the X-axis. |
144 | The graph curve with X-axis values = { x | 0 < x < 1ms } has a steep slope | 144 | The graph curve with X-axis values = { x | 0 < x < 1ms } has a steep slope |
145 | and denotes the energy costs incurred whilst entering and leaving the idle | 145 | and denotes the energy costs incurred while entering and leaving the idle |
146 | state. | 146 | state. |
147 | The graph curve in the area delimited by X-axis values = {x | x > 1ms } has | 147 | The graph curve in the area delimited by X-axis values = {x | x > 1ms } has |
148 | shallower slope and essentially represents the energy consumption of the idle | 148 | shallower slope and essentially represents the energy consumption of the idle |
diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt index 3f1d3fca62bb..614b594f4e72 100644 --- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt +++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt | |||
@@ -56,7 +56,7 @@ For CAM, this 24-bit offset is: | |||
56 | cfg_offset(bus, device, function, register) = | 56 | cfg_offset(bus, device, function, register) = |
57 | bus << 16 | device << 11 | function << 8 | register | 57 | bus << 16 | device << 11 | function << 8 | register |
58 | 58 | ||
59 | Whilst ECAM extends this by 4 bits to accommodate 4k of function space: | 59 | While ECAM extends this by 4 bits to accommodate 4k of function space: |
60 | 60 | ||
61 | cfg_offset(bus, device, function, register) = | 61 | cfg_offset(bus, device, function, register) = |
62 | bus << 20 | device << 15 | function << 12 | register | 62 | bus << 20 | device << 15 | function << 12 | register |
diff --git a/Documentation/devicetree/bindings/serial/rs485.txt b/Documentation/devicetree/bindings/serial/rs485.txt index b7c29f74ebb2..b92592dff6dd 100644 --- a/Documentation/devicetree/bindings/serial/rs485.txt +++ b/Documentation/devicetree/bindings/serial/rs485.txt | |||
@@ -16,7 +16,7 @@ Optional properties: | |||
16 | - linux,rs485-enabled-at-boot-time: empty property telling to enable the rs485 | 16 | - linux,rs485-enabled-at-boot-time: empty property telling to enable the rs485 |
17 | feature at boot time. It can be disabled later with proper ioctl. | 17 | feature at boot time. It can be disabled later with proper ioctl. |
18 | - rs485-rx-during-tx: empty property that enables the receiving of data even | 18 | - rs485-rx-during-tx: empty property that enables the receiving of data even |
19 | whilst sending data. | 19 | while sending data. |
20 | 20 | ||
21 | RS485 example for Atmel USART: | 21 | RS485 example for Atmel USART: |
22 | usart0: serial@fff8c000 { | 22 | usart0: serial@fff8c000 { |
diff --git a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-guide/kernel-doc.rst index 8db53cdc225f..51be62aa4385 100644 --- a/Documentation/doc-guide/kernel-doc.rst +++ b/Documentation/doc-guide/kernel-doc.rst | |||
@@ -77,7 +77,7 @@ The general format of a function and function-like macro kernel-doc comment is:: | |||
77 | * Context: Describes whether the function can sleep, what locks it takes, | 77 | * Context: Describes whether the function can sleep, what locks it takes, |
78 | * releases, or expects to be held. It can extend over multiple | 78 | * releases, or expects to be held. It can extend over multiple |
79 | * lines. | 79 | * lines. |
80 | * Return: Describe the return value of foobar. | 80 | * Return: Describe the return value of function_name. |
81 | * | 81 | * |
82 | * The return value description can also have multiple paragraphs, and should | 82 | * The return value description can also have multiple paragraphs, and should |
83 | * be placed at the end of the comment block. | 83 | * be placed at the end of the comment block. |
diff --git a/Documentation/doc-guide/sphinx.rst b/Documentation/doc-guide/sphinx.rst index f0796daa95b4..02605ee1d876 100644 --- a/Documentation/doc-guide/sphinx.rst +++ b/Documentation/doc-guide/sphinx.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _sphinxdoc: | ||
2 | |||
1 | Introduction | 3 | Introduction |
2 | ============ | 4 | ============ |
3 | 5 | ||
diff --git a/Documentation/driver-api/dmaengine/dmatest.rst b/Documentation/driver-api/dmaengine/dmatest.rst index 7ce5e71c353e..49efebd2c043 100644 --- a/Documentation/driver-api/dmaengine/dmatest.rst +++ b/Documentation/driver-api/dmaengine/dmatest.rst | |||
@@ -11,6 +11,10 @@ This small document introduces how to test DMA drivers using dmatest module. | |||
11 | capability of the following: DMA_MEMCPY (memory-to-memory), DMA_MEMSET | 11 | capability of the following: DMA_MEMCPY (memory-to-memory), DMA_MEMSET |
12 | (const-to-memory or memory-to-memory, when emulated), DMA_XOR, DMA_PQ. | 12 | (const-to-memory or memory-to-memory, when emulated), DMA_XOR, DMA_PQ. |
13 | 13 | ||
14 | .. note:: | ||
15 | In case of any related questions use the official mailing list | ||
16 | dmaengine@vger.kernel.org. | ||
17 | |||
14 | Part 1 - How to build the test module | 18 | Part 1 - How to build the test module |
15 | ===================================== | 19 | ===================================== |
16 | 20 | ||
diff --git a/Documentation/driver-api/pm/devices.rst b/Documentation/driver-api/pm/devices.rst index 1128705a5731..090c151aa86b 100644 --- a/Documentation/driver-api/pm/devices.rst +++ b/Documentation/driver-api/pm/devices.rst | |||
@@ -6,6 +6,8 @@ | |||
6 | .. |struct wakeup_source| replace:: :c:type:`struct wakeup_source <wakeup_source>` | 6 | .. |struct wakeup_source| replace:: :c:type:`struct wakeup_source <wakeup_source>` |
7 | .. |struct device| replace:: :c:type:`struct device <device>` | 7 | .. |struct device| replace:: :c:type:`struct device <device>` |
8 | 8 | ||
9 | .. _driverapi_pm_devices: | ||
10 | |||
9 | ============================== | 11 | ============================== |
10 | Device Power Management Basics | 12 | Device Power Management Basics |
11 | ============================== | 13 | ============================== |
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 52a752300e94..841c99529d27 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -132,6 +132,13 @@ devres. Complexity is shifted from less maintained low level drivers | |||
132 | to better maintained higher layer. Also, as init failure path is | 132 | to better maintained higher layer. Also, as init failure path is |
133 | shared with exit path, both can get more testing. | 133 | shared with exit path, both can get more testing. |
134 | 134 | ||
135 | Note though that when converting current calls or assignments to | ||
136 | managed devm_* versions it is up to you to check if internal operations | ||
137 | like allocating memory, have failed. Managed resources pertains to the | ||
138 | freeing of these resources *only* - all other checks needed are still | ||
139 | on you. In some cases this may mean introducing checks that were not | ||
140 | necessary before moving to the managed devm_* calls. | ||
141 | |||
135 | 142 | ||
136 | 3. Devres group | 143 | 3. Devres group |
137 | --------------- | 144 | --------------- |
diff --git a/Documentation/early-userspace/README b/Documentation/early-userspace/README index 1e1057958dd3..955d667dc87e 100644 --- a/Documentation/early-userspace/README +++ b/Documentation/early-userspace/README | |||
@@ -52,7 +52,7 @@ user root (0). INITRAMFS_ROOT_GID can be set to a group ID that needs | |||
52 | to be mapped to group root (0). | 52 | to be mapped to group root (0). |
53 | 53 | ||
54 | A source file must be directives in the format required by the | 54 | A source file must be directives in the format required by the |
55 | usr/gen_init_cpio utility (run 'usr/gen_init_cpio --help' to get the | 55 | usr/gen_init_cpio utility (run 'usr/gen_init_cpio -h' to get the |
56 | file format). The directives in the file will be passed directly to | 56 | file format). The directives in the file will be passed directly to |
57 | usr/gen_init_cpio. | 57 | usr/gen_init_cpio. |
58 | 58 | ||
diff --git a/Documentation/filesystems/caching/backend-api.txt b/Documentation/filesystems/caching/backend-api.txt index c0bd5677271b..c418280c915f 100644 --- a/Documentation/filesystems/caching/backend-api.txt +++ b/Documentation/filesystems/caching/backend-api.txt | |||
@@ -704,7 +704,7 @@ FS-Cache provides some utilities that a cache backend may make use of: | |||
704 | void fscache_get_retrieval(struct fscache_retrieval *op); | 704 | void fscache_get_retrieval(struct fscache_retrieval *op); |
705 | void fscache_put_retrieval(struct fscache_retrieval *op); | 705 | void fscache_put_retrieval(struct fscache_retrieval *op); |
706 | 706 | ||
707 | These two functions are used to retain a retrieval record whilst doing | 707 | These two functions are used to retain a retrieval record while doing |
708 | asynchronous data retrieval and block allocation. | 708 | asynchronous data retrieval and block allocation. |
709 | 709 | ||
710 | 710 | ||
diff --git a/Documentation/filesystems/caching/cachefiles.txt b/Documentation/filesystems/caching/cachefiles.txt index 748a1ae49e12..28aefcbb1442 100644 --- a/Documentation/filesystems/caching/cachefiles.txt +++ b/Documentation/filesystems/caching/cachefiles.txt | |||
@@ -45,7 +45,7 @@ filesystems are very specific in nature. | |||
45 | 45 | ||
46 | CacheFiles creates a misc character device - "/dev/cachefiles" - that is used | 46 | CacheFiles creates a misc character device - "/dev/cachefiles" - that is used |
47 | to communication with the daemon. Only one thing may have this open at once, | 47 | to communication with the daemon. Only one thing may have this open at once, |
48 | and whilst it is open, a cache is at least partially in existence. The daemon | 48 | and while it is open, a cache is at least partially in existence. The daemon |
49 | opens this and sends commands down it to control the cache. | 49 | opens this and sends commands down it to control the cache. |
50 | 50 | ||
51 | CacheFiles is currently limited to a single cache. | 51 | CacheFiles is currently limited to a single cache. |
@@ -163,7 +163,7 @@ Do not mount other things within the cache as this will cause problems. The | |||
163 | kernel module contains its own very cut-down path walking facility that ignores | 163 | kernel module contains its own very cut-down path walking facility that ignores |
164 | mountpoints, but the daemon can't avoid them. | 164 | mountpoints, but the daemon can't avoid them. |
165 | 165 | ||
166 | Do not create, rename or unlink files and directories in the cache whilst the | 166 | Do not create, rename or unlink files and directories in the cache while the |
167 | cache is active, as this may cause the state to become uncertain. | 167 | cache is active, as this may cause the state to become uncertain. |
168 | 168 | ||
169 | Renaming files in the cache might make objects appear to be other objects (the | 169 | Renaming files in the cache might make objects appear to be other objects (the |
diff --git a/Documentation/filesystems/caching/netfs-api.txt b/Documentation/filesystems/caching/netfs-api.txt index 2a6f7399c1f3..ba968e8f5704 100644 --- a/Documentation/filesystems/caching/netfs-api.txt +++ b/Documentation/filesystems/caching/netfs-api.txt | |||
@@ -382,7 +382,7 @@ MISCELLANEOUS OBJECT REGISTRATION | |||
382 | An optional step is to request an object of miscellaneous type be created in | 382 | An optional step is to request an object of miscellaneous type be created in |
383 | the cache. This is almost identical to index cookie acquisition. The only | 383 | the cache. This is almost identical to index cookie acquisition. The only |
384 | difference is that the type in the object definition should be something other | 384 | difference is that the type in the object definition should be something other |
385 | than index type. Whilst the parent object could be an index, it's more likely | 385 | than index type. While the parent object could be an index, it's more likely |
386 | it would be some other type of object such as a data file. | 386 | it would be some other type of object such as a data file. |
387 | 387 | ||
388 | xattr->cache = | 388 | xattr->cache = |
diff --git a/Documentation/filesystems/caching/operations.txt b/Documentation/filesystems/caching/operations.txt index a1c052cbba35..d8976c434718 100644 --- a/Documentation/filesystems/caching/operations.txt +++ b/Documentation/filesystems/caching/operations.txt | |||
@@ -171,7 +171,7 @@ Operations are used through the following procedure: | |||
171 | (3) If the submitting thread wants to do the work itself, and has marked the | 171 | (3) If the submitting thread wants to do the work itself, and has marked the |
172 | operation with FSCACHE_OP_MYTHREAD, then it should monitor | 172 | operation with FSCACHE_OP_MYTHREAD, then it should monitor |
173 | FSCACHE_OP_WAITING as described above and check the state of the object if | 173 | FSCACHE_OP_WAITING as described above and check the state of the object if |
174 | necessary (the object might have died whilst the thread was waiting). | 174 | necessary (the object might have died while the thread was waiting). |
175 | 175 | ||
176 | When it has finished doing its processing, it should call | 176 | When it has finished doing its processing, it should call |
177 | fscache_op_complete() and fscache_put_operation() on it. | 177 | fscache_op_complete() and fscache_put_operation() on it. |
diff --git a/Documentation/filesystems/configfs/configfs.txt b/Documentation/filesystems/configfs/configfs.txt index 3828e85345ae..16e606c11f40 100644 --- a/Documentation/filesystems/configfs/configfs.txt +++ b/Documentation/filesystems/configfs/configfs.txt | |||
@@ -216,7 +216,7 @@ be called whenever userspace asks for a write(2) on the attribute. | |||
216 | 216 | ||
217 | [struct configfs_bin_attribute] | 217 | [struct configfs_bin_attribute] |
218 | 218 | ||
219 | struct configfs_attribute { | 219 | struct configfs_bin_attribute { |
220 | struct configfs_attribute cb_attr; | 220 | struct configfs_attribute cb_attr; |
221 | void *cb_private; | 221 | void *cb_private; |
222 | size_t cb_max_size; | 222 | size_t cb_max_size; |
diff --git a/Documentation/filesystems/index.rst b/Documentation/filesystems/index.rst index 46d1b1be3a51..605befab300b 100644 --- a/Documentation/filesystems/index.rst +++ b/Documentation/filesystems/index.rst | |||
@@ -359,3 +359,24 @@ encryption of files and directories. | |||
359 | :maxdepth: 2 | 359 | :maxdepth: 2 |
360 | 360 | ||
361 | fscrypt | 361 | fscrypt |
362 | |||
363 | Pathname lookup | ||
364 | =============== | ||
365 | |||
366 | |||
367 | This write-up is based on three articles published at lwn.net: | ||
368 | |||
369 | - <https://lwn.net/Articles/649115/> Pathname lookup in Linux | ||
370 | - <https://lwn.net/Articles/649729/> RCU-walk: faster pathname lookup in Linux | ||
371 | - <https://lwn.net/Articles/650786/> A walk among the symlinks | ||
372 | |||
373 | Written by Neil Brown with help from Al Viro and Jon Corbet. | ||
374 | It has subsequently been updated to reflect changes in the kernel | ||
375 | including: | ||
376 | |||
377 | - per-directory parallel name lookup. | ||
378 | |||
379 | .. toctree:: | ||
380 | :maxdepth: 2 | ||
381 | |||
382 | path-lookup.rst | ||
diff --git a/Documentation/filesystems/path-lookup.md b/Documentation/filesystems/path-lookup.rst index e2edd45c4bc0..9d6b68853f5b 100644 --- a/Documentation/filesystems/path-lookup.md +++ b/Documentation/filesystems/path-lookup.rst | |||
@@ -1,20 +1,6 @@ | |||
1 | <head> | ||
2 | <style> p { max-width:50em} ol, ul {max-width: 40em}</style> | ||
3 | </head> | ||
4 | 1 | ||
5 | Pathname lookup in Linux. | 2 | Introduction to pathname lookup |
6 | ========================= | 3 | =============================== |
7 | |||
8 | This write-up is based on three articles published at lwn.net: | ||
9 | |||
10 | - <https://lwn.net/Articles/649115/> Pathname lookup in Linux | ||
11 | - <https://lwn.net/Articles/649729/> RCU-walk: faster pathname lookup in Linux | ||
12 | - <https://lwn.net/Articles/650786/> A walk among the symlinks | ||
13 | |||
14 | Written by Neil Brown with help from Al Viro and Jon Corbet. | ||
15 | |||
16 | Introduction | ||
17 | ------------ | ||
18 | 4 | ||
19 | The most obvious aspect of pathname lookup, which very little | 5 | The most obvious aspect of pathname lookup, which very little |
20 | exploration is needed to discover, is that it is complex. There are | 6 | exploration is needed to discover, is that it is complex. There are |
@@ -32,58 +18,58 @@ distinctions we need to clarify first. | |||
32 | There are two sorts of ... | 18 | There are two sorts of ... |
33 | -------------------------- | 19 | -------------------------- |
34 | 20 | ||
35 | [`openat()`]: http://man7.org/linux/man-pages/man2/openat.2.html | 21 | .. _openat: http://man7.org/linux/man-pages/man2/openat.2.html |
36 | 22 | ||
37 | Pathnames (sometimes "file names"), used to identify objects in the | 23 | Pathnames (sometimes "file names"), used to identify objects in the |
38 | filesystem, will be familiar to most readers. They contain two sorts | 24 | filesystem, will be familiar to most readers. They contain two sorts |
39 | of elements: "slashes" that are sequences of one or more "`/`" | 25 | of elements: "slashes" that are sequences of one or more "``/``" |
40 | characters, and "components" that are sequences of one or more | 26 | characters, and "components" that are sequences of one or more |
41 | non-"`/`" characters. These form two kinds of paths. Those that | 27 | non-"``/``" characters. These form two kinds of paths. Those that |
42 | start with slashes are "absolute" and start from the filesystem root. | 28 | start with slashes are "absolute" and start from the filesystem root. |
43 | The others are "relative" and start from the current directory, or | 29 | The others are "relative" and start from the current directory, or |
44 | from some other location specified by a file descriptor given to a | 30 | from some other location specified by a file descriptor given to a |
45 | "xxx`at`" system call such as "[`openat()`]". | 31 | "``XXXat``" system call such as `openat() <openat_>`_. |
46 | 32 | ||
47 | [`execveat()`]: http://man7.org/linux/man-pages/man2/execveat.2.html | 33 | .. _execveat: http://man7.org/linux/man-pages/man2/execveat.2.html |
48 | 34 | ||
49 | It is tempting to describe the second kind as starting with a | 35 | It is tempting to describe the second kind as starting with a |
50 | component, but that isn't always accurate: a pathname can lack both | 36 | component, but that isn't always accurate: a pathname can lack both |
51 | slashes and components, it can be empty, in other words. This is | 37 | slashes and components, it can be empty, in other words. This is |
52 | generally forbidden in POSIX, but some of those "xxx`at`" system calls | 38 | generally forbidden in POSIX, but some of those "xxx``at``" system calls |
53 | in Linux permit it when the `AT_EMPTY_PATH` flag is given. For | 39 | in Linux permit it when the ``AT_EMPTY_PATH`` flag is given. For |
54 | example, if you have an open file descriptor on an executable file you | 40 | example, if you have an open file descriptor on an executable file you |
55 | can execute it by calling [`execveat()`] passing the file descriptor, | 41 | can execute it by calling `execveat() <execveat_>`_ passing |
56 | an empty path, and the `AT_EMPTY_PATH` flag. | 42 | the file descriptor, an empty path, and the ``AT_EMPTY_PATH`` flag. |
57 | 43 | ||
58 | These paths can be divided into two sections: the final component and | 44 | These paths can be divided into two sections: the final component and |
59 | everything else. The "everything else" is the easy bit. In all cases | 45 | everything else. The "everything else" is the easy bit. In all cases |
60 | it must identify a directory that already exists, otherwise an error | 46 | it must identify a directory that already exists, otherwise an error |
61 | such as `ENOENT` or `ENOTDIR` will be reported. | 47 | such as ``ENOENT`` or ``ENOTDIR`` will be reported. |
62 | 48 | ||
63 | The final component is not so simple. Not only do different system | 49 | The final component is not so simple. Not only do different system |
64 | calls interpret it quite differently (e.g. some create it, some do | 50 | calls interpret it quite differently (e.g. some create it, some do |
65 | not), but it might not even exist: neither the empty pathname nor the | 51 | not), but it might not even exist: neither the empty pathname nor the |
66 | pathname that is just slashes have a final component. If it does | 52 | pathname that is just slashes have a final component. If it does |
67 | exist, it could be "`.`" or "`..`" which are handled quite differently | 53 | exist, it could be "``.``" or "``..``" which are handled quite differently |
68 | from other components. | 54 | from other components. |
69 | 55 | ||
70 | [POSIX]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12 | 56 | .. _POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12 |
71 | 57 | ||
72 | If a pathname ends with a slash, such as "`/tmp/foo/`" it might be | 58 | If a pathname ends with a slash, such as "``/tmp/foo/``" it might be |
73 | tempting to consider that to have an empty final component. In many | 59 | tempting to consider that to have an empty final component. In many |
74 | ways that would lead to correct results, but not always. In | 60 | ways that would lead to correct results, but not always. In |
75 | particular, `mkdir()` and `rmdir()` each create or remove a directory named | 61 | particular, ``mkdir()`` and ``rmdir()`` each create or remove a directory named |
76 | by the final component, and they are required to work with pathnames | 62 | by the final component, and they are required to work with pathnames |
77 | ending in "`/`". According to [POSIX] | 63 | ending in "``/``". According to POSIX_ |
78 | 64 | ||
79 | > A pathname that contains at least one non- <slash> character and | 65 | A pathname that contains at least one non- <slash> character and |
80 | > that ends with one or more trailing <slash> characters shall not | 66 | that ends with one or more trailing <slash> characters shall not |
81 | > be resolved successfully unless the last pathname component before | 67 | be resolved successfully unless the last pathname component before |
82 | > the trailing <slash> characters names an existing directory or a | 68 | the trailing <slash> characters names an existing directory or a |
83 | > directory entry that is to be created for a directory immediately | 69 | directory entry that is to be created for a directory immediately |
84 | > after the pathname is resolved. | 70 | after the pathname is resolved. |
85 | 71 | ||
86 | The Linux pathname walking code (mostly in `fs/namei.c`) deals with | 72 | The Linux pathname walking code (mostly in ``fs/namei.c``) deals with |
87 | all of these issues: breaking the path into components, handling the | 73 | all of these issues: breaking the path into components, handling the |
88 | "everything else" quite separately from the final component, and | 74 | "everything else" quite separately from the final component, and |
89 | checking that the trailing slash is not used where it isn't | 75 | checking that the trailing slash is not used where it isn't |
@@ -100,15 +86,15 @@ of the possible races are seen most clearly in the context of the | |||
100 | "dcache" and an understanding of that is central to understanding | 86 | "dcache" and an understanding of that is central to understanding |
101 | pathname lookup. | 87 | pathname lookup. |
102 | 88 | ||
103 | More than just a cache. | 89 | More than just a cache |
104 | ----------------------- | 90 | ---------------------- |
105 | 91 | ||
106 | The "dcache" caches information about names in each filesystem to | 92 | The "dcache" caches information about names in each filesystem to |
107 | make them quickly available for lookup. Each entry (known as a | 93 | make them quickly available for lookup. Each entry (known as a |
108 | "dentry") contains three significant fields: a component name, a | 94 | "dentry") contains three significant fields: a component name, a |
109 | pointer to a parent dentry, and a pointer to the "inode" which | 95 | pointer to a parent dentry, and a pointer to the "inode" which |
110 | contains further information about the object in that parent with | 96 | contains further information about the object in that parent with |
111 | the given name. The inode pointer can be `NULL` indicating that the | 97 | the given name. The inode pointer can be ``NULL`` indicating that the |
112 | name doesn't exist in the parent. While there can be linkage in the | 98 | name doesn't exist in the parent. While there can be linkage in the |
113 | dentry of a directory to the dentries of the children, that linkage is | 99 | dentry of a directory to the dentries of the children, that linkage is |
114 | not used for pathname lookup, and so will not be considered here. | 100 | not used for pathname lookup, and so will not be considered here. |
@@ -135,7 +121,7 @@ whether remote filesystems like NFS and 9P, or cluster filesystems | |||
135 | like ocfs2 or cephfs. These filesystems allow the VFS to revalidate | 121 | like ocfs2 or cephfs. These filesystems allow the VFS to revalidate |
136 | cached information, and must provide their own protection against | 122 | cached information, and must provide their own protection against |
137 | awkward races. The VFS can detect these filesystems by the | 123 | awkward races. The VFS can detect these filesystems by the |
138 | `DCACHE_OP_REVALIDATE` flag being set in the dentry. | 124 | ``DCACHE_OP_REVALIDATE`` flag being set in the dentry. |
139 | 125 | ||
140 | REF-walk: simple concurrency management with refcounts and spinlocks | 126 | REF-walk: simple concurrency management with refcounts and spinlocks |
141 | -------------------------------------------------------------------- | 127 | -------------------------------------------------------------------- |
@@ -144,22 +130,23 @@ With all of those divisions carefully classified, we can now start | |||
144 | looking at the actual process of walking along a path. In particular | 130 | looking at the actual process of walking along a path. In particular |
145 | we will start with the handling of the "everything else" part of a | 131 | we will start with the handling of the "everything else" part of a |
146 | pathname, and focus on the "REF-walk" approach to concurrency | 132 | pathname, and focus on the "REF-walk" approach to concurrency |
147 | management. This code is found in the `link_path_walk()` function, if | 133 | management. This code is found in the ``link_path_walk()`` function, if |
148 | you ignore all the places that only run when "`LOOKUP_RCU`" | 134 | you ignore all the places that only run when "``LOOKUP_RCU``" |
149 | (indicating the use of RCU-walk) is set. | 135 | (indicating the use of RCU-walk) is set. |
150 | 136 | ||
151 | [Meet the Lockers]: https://lwn.net/Articles/453685/ | 137 | .. _Meet the Lockers: https://lwn.net/Articles/453685/ |
152 | 138 | ||
153 | REF-walk is fairly heavy-handed with locks and reference counts. Not | 139 | REF-walk is fairly heavy-handed with locks and reference counts. Not |
154 | as heavy-handed as in the old "big kernel lock" days, but certainly not | 140 | as heavy-handed as in the old "big kernel lock" days, but certainly not |
155 | afraid of taking a lock when one is needed. It uses a variety of | 141 | afraid of taking a lock when one is needed. It uses a variety of |
156 | different concurrency controls. A background understanding of the | 142 | different concurrency controls. A background understanding of the |
157 | various primitives is assumed, or can be gleaned from elsewhere such | 143 | various primitives is assumed, or can be gleaned from elsewhere such |
158 | as in [Meet the Lockers]. | 144 | as in `Meet the Lockers`_. |
159 | 145 | ||
160 | The locking mechanisms used by REF-walk include: | 146 | The locking mechanisms used by REF-walk include: |
161 | 147 | ||
162 | ### dentry->d_lockref ### | 148 | dentry->d_lockref |
149 | ~~~~~~~~~~~~~~~~~ | ||
163 | 150 | ||
164 | This uses the lockref primitive to provide both a spinlock and a | 151 | This uses the lockref primitive to provide both a spinlock and a |
165 | reference count. The special-sauce of this primitive is that the | 152 | reference count. The special-sauce of this primitive is that the |
@@ -168,49 +155,51 @@ with a single atomic memory operation. | |||
168 | 155 | ||
169 | Holding a reference on a dentry ensures that the dentry won't suddenly | 156 | Holding a reference on a dentry ensures that the dentry won't suddenly |
170 | be freed and used for something else, so the values in various fields | 157 | be freed and used for something else, so the values in various fields |
171 | will behave as expected. It also protects the `->d_inode` reference | 158 | will behave as expected. It also protects the ``->d_inode`` reference |
172 | to the inode to some extent. | 159 | to the inode to some extent. |
173 | 160 | ||
174 | The association between a dentry and its inode is fairly permanent. | 161 | The association between a dentry and its inode is fairly permanent. |
175 | For example, when a file is renamed, the dentry and inode move | 162 | For example, when a file is renamed, the dentry and inode move |
176 | together to the new location. When a file is created the dentry will | 163 | together to the new location. When a file is created the dentry will |
177 | initially be negative (i.e. `d_inode` is `NULL`), and will be assigned | 164 | initially be negative (i.e. ``d_inode`` is ``NULL``), and will be assigned |
178 | to the new inode as part of the act of creation. | 165 | to the new inode as part of the act of creation. |
179 | 166 | ||
180 | When a file is deleted, this can be reflected in the cache either by | 167 | When a file is deleted, this can be reflected in the cache either by |
181 | setting `d_inode` to `NULL`, or by removing it from the hash table | 168 | setting ``d_inode`` to ``NULL``, or by removing it from the hash table |
182 | (described shortly) used to look up the name in the parent directory. | 169 | (described shortly) used to look up the name in the parent directory. |
183 | If the dentry is still in use the second option is used as it is | 170 | If the dentry is still in use the second option is used as it is |
184 | perfectly legal to keep using an open file after it has been deleted | 171 | perfectly legal to keep using an open file after it has been deleted |
185 | and having the dentry around helps. If the dentry is not otherwise in | 172 | and having the dentry around helps. If the dentry is not otherwise in |
186 | use (i.e. if the refcount in `d_lockref` is one), only then will | 173 | use (i.e. if the refcount in ``d_lockref`` is one), only then will |
187 | `d_inode` be set to `NULL`. Doing it this way is more efficient for a | 174 | ``d_inode`` be set to ``NULL``. Doing it this way is more efficient for a |
188 | very common case. | 175 | very common case. |
189 | 176 | ||
190 | So as long as a counted reference is held to a dentry, a non-`NULL` `->d_inode` | 177 | So as long as a counted reference is held to a dentry, a non-``NULL`` ``->d_inode`` |
191 | value will never be changed. | 178 | value will never be changed. |
192 | 179 | ||
193 | ### dentry->d_lock ### | 180 | dentry->d_lock |
181 | ~~~~~~~~~~~~~~ | ||
194 | 182 | ||
195 | `d_lock` is a synonym for the spinlock that is part of `d_lockref` above. | 183 | ``d_lock`` is a synonym for the spinlock that is part of ``d_lockref`` above. |
196 | For our purposes, holding this lock protects against the dentry being | 184 | For our purposes, holding this lock protects against the dentry being |
197 | renamed or unlinked. In particular, its parent (`d_parent`), and its | 185 | renamed or unlinked. In particular, its parent (``d_parent``), and its |
198 | name (`d_name`) cannot be changed, and it cannot be removed from the | 186 | name (``d_name``) cannot be changed, and it cannot be removed from the |
199 | dentry hash table. | 187 | dentry hash table. |
200 | 188 | ||
201 | When looking for a name in a directory, REF-walk takes `d_lock` on | 189 | When looking for a name in a directory, REF-walk takes ``d_lock`` on |
202 | each candidate dentry that it finds in the hash table and then checks | 190 | each candidate dentry that it finds in the hash table and then checks |
203 | that the parent and name are correct. So it doesn't lock the parent | 191 | that the parent and name are correct. So it doesn't lock the parent |
204 | while searching in the cache; it only locks children. | 192 | while searching in the cache; it only locks children. |
205 | 193 | ||
206 | When looking for the parent for a given name (to handle "`..`"), | 194 | When looking for the parent for a given name (to handle "``..``"), |
207 | REF-walk can take `d_lock` to get a stable reference to `d_parent`, | 195 | REF-walk can take ``d_lock`` to get a stable reference to ``d_parent``, |
208 | but it first tries a more lightweight approach. As seen in | 196 | but it first tries a more lightweight approach. As seen in |
209 | `dget_parent()`, if a reference can be claimed on the parent, and if | 197 | ``dget_parent()``, if a reference can be claimed on the parent, and if |
210 | subsequently `d_parent` can be seen to have not changed, then there is | 198 | subsequently ``d_parent`` can be seen to have not changed, then there is |
211 | no need to actually take the lock on the child. | 199 | no need to actually take the lock on the child. |
212 | 200 | ||
213 | ### rename_lock ### | 201 | rename_lock |
202 | ~~~~~~~~~~~ | ||
214 | 203 | ||
215 | Looking up a given name in a given directory involves computing a hash | 204 | Looking up a given name in a given directory involves computing a hash |
216 | from the two values (the name and the dentry of the directory), | 205 | from the two values (the name and the dentry of the directory), |
@@ -224,71 +213,117 @@ happened to be looking at a dentry that was moved in this way, | |||
224 | it might end up continuing the search down the wrong chain, | 213 | it might end up continuing the search down the wrong chain, |
225 | and so miss out on part of the correct chain. | 214 | and so miss out on part of the correct chain. |
226 | 215 | ||
227 | The name-lookup process (`d_lookup()`) does _not_ try to prevent this | 216 | The name-lookup process (``d_lookup()``) does _not_ try to prevent this |
228 | from happening, but only to detect when it happens. | 217 | from happening, but only to detect when it happens. |
229 | `rename_lock` is a seqlock that is updated whenever any dentry is | 218 | ``rename_lock`` is a seqlock that is updated whenever any dentry is |
230 | renamed. If `d_lookup` finds that a rename happened while it | 219 | renamed. If ``d_lookup`` finds that a rename happened while it |
231 | unsuccessfully scanned a chain in the hash table, it simply tries | 220 | unsuccessfully scanned a chain in the hash table, it simply tries |
232 | again. | 221 | again. |
233 | 222 | ||
234 | ### inode->i_mutex ### | 223 | inode->i_rwsem |
224 | ~~~~~~~~~~~~~~ | ||
235 | 225 | ||
236 | `i_mutex` is a mutex that serializes all changes to a particular | 226 | ``i_rwsem`` is a read/write semaphore that serializes all changes to a particular |
237 | directory. This ensures that, for example, an `unlink()` and a `rename()` | 227 | directory. This ensures that, for example, an ``unlink()`` and a ``rename()`` |
238 | cannot both happen at the same time. It also keeps the directory | 228 | cannot both happen at the same time. It also keeps the directory |
239 | stable while the filesystem is asked to look up a name that is not | 229 | stable while the filesystem is asked to look up a name that is not |
240 | currently in the dcache. | 230 | currently in the dcache or, optionally, when the list of entries in a |
231 | directory is being retrieved with ``readdir()``. | ||
241 | 232 | ||
242 | This has a complementary role to that of `d_lock`: `i_mutex` on a | 233 | This has a complementary role to that of ``d_lock``: ``i_rwsem`` on a |
243 | directory protects all of the names in that directory, while `d_lock` | 234 | directory protects all of the names in that directory, while ``d_lock`` |
244 | on a name protects just one name in a directory. Most changes to the | 235 | on a name protects just one name in a directory. Most changes to the |
245 | dcache hold `i_mutex` on the relevant directory inode and briefly take | 236 | dcache hold ``i_rwsem`` on the relevant directory inode and briefly take |
246 | `d_lock` on one or more the dentries while the change happens. One | 237 | ``d_lock`` on one or more the dentries while the change happens. One |
247 | exception is when idle dentries are removed from the dcache due to | 238 | exception is when idle dentries are removed from the dcache due to |
248 | memory pressure. This uses `d_lock`, but `i_mutex` plays no role. | 239 | memory pressure. This uses ``d_lock``, but ``i_rwsem`` plays no role. |
249 | 240 | ||
250 | The mutex affects pathname lookup in two distinct ways. Firstly it | 241 | The semaphore affects pathname lookup in two distinct ways. Firstly it |
251 | serializes lookup of a name in a directory. `walk_component()` uses | 242 | prevents changes during lookup of a name in a directory. ``walk_component()`` uses |
252 | `lookup_fast()` first which, in turn, checks to see if the name is in the cache, | 243 | ``lookup_fast()`` first which, in turn, checks to see if the name is in the cache, |
253 | using only `d_lock` locking. If the name isn't found, then `walk_component()` | 244 | using only ``d_lock`` locking. If the name isn't found, then ``walk_component()`` |
254 | falls back to `lookup_slow()` which takes `i_mutex`, checks again that | 245 | falls back to ``lookup_slow()`` which takes a shared lock on ``i_rwsem``, checks again that |
255 | the name isn't in the cache, and then calls in to the filesystem to get a | 246 | the name isn't in the cache, and then calls in to the filesystem to get a |
256 | definitive answer. A new dentry will be added to the cache regardless of | 247 | definitive answer. A new dentry will be added to the cache regardless of |
257 | the result. | 248 | the result. |
258 | 249 | ||
259 | Secondly, when pathname lookup reaches the final component, it will | 250 | Secondly, when pathname lookup reaches the final component, it will |
260 | sometimes need to take `i_mutex` before performing the last lookup so | 251 | sometimes need to take an exclusive lock on ``i_rwsem`` before performing the last lookup so |
261 | that the required exclusion can be achieved. How path lookup chooses | 252 | that the required exclusion can be achieved. How path lookup chooses |
262 | to take, or not take, `i_mutex` is one of the | 253 | to take, or not take, ``i_rwsem`` is one of the |
263 | issues addressed in a subsequent section. | 254 | issues addressed in a subsequent section. |
264 | 255 | ||
265 | ### mnt->mnt_count ### | 256 | If two threads attempt to look up the same name at the same time - a |
266 | 257 | name that is not yet in the dcache - the shared lock on ``i_rwsem`` will | |
267 | `mnt_count` is a per-CPU reference counter on "`mount`" structures. | 258 | not prevent them both adding new dentries with the same name. As this |
259 | would result in confusion an extra level of interlocking is used, | ||
260 | based around a secondary hash table (``in_lookup_hashtable``) and a | ||
261 | per-dentry flag bit (``DCACHE_PAR_LOOKUP``). | ||
262 | |||
263 | To add a new dentry to the cache while only holding a shared lock on | ||
264 | ``i_rwsem``, a thread must call ``d_alloc_parallel()``. This allocates a | ||
265 | dentry, stores the required name and parent in it, checks if there | ||
266 | is already a matching dentry in the primary or secondary hash | ||
267 | tables, and if not, stores the newly allocated dentry in the secondary | ||
268 | hash table, with ``DCACHE_PAR_LOOKUP`` set. | ||
269 | |||
270 | If a matching dentry was found in the primary hash table then that is | ||
271 | returned and the caller can know that it lost a race with some other | ||
272 | thread adding the entry. If no matching dentry is found in either | ||
273 | cache, the newly allocated dentry is returned and the caller can | ||
274 | detect this from the presence of ``DCACHE_PAR_LOOKUP``. In this case it | ||
275 | knows that it has won any race and now is responsible for asking the | ||
276 | filesystem to perform the lookup and find the matching inode. When | ||
277 | the lookup is complete, it must call ``d_lookup_done()`` which clears | ||
278 | the flag and does some other house keeping, including removing the | ||
279 | dentry from the secondary hash table - it will normally have been | ||
280 | added to the primary hash table already. Note that a ``struct | ||
281 | waitqueue_head`` is passed to ``d_alloc_parallel()``, and | ||
282 | ``d_lookup_done()`` must be called while this ``waitqueue_head`` is still | ||
283 | in scope. | ||
284 | |||
285 | If a matching dentry is found in the secondary hash table, | ||
286 | ``d_alloc_parallel()`` has a little more work to do. It first waits for | ||
287 | ``DCACHE_PAR_LOOKUP`` to be cleared, using a wait_queue that was passed | ||
288 | to the instance of ``d_alloc_parallel()`` that won the race and that | ||
289 | will be woken by the call to ``d_lookup_done()``. It then checks to see | ||
290 | if the dentry has now been added to the primary hash table. If it | ||
291 | has, the dentry is returned and the caller just sees that it lost any | ||
292 | race. If it hasn't been added to the primary hash table, the most | ||
293 | likely explanation is that some other dentry was added instead using | ||
294 | ``d_splice_alias()``. In any case, ``d_alloc_parallel()`` repeats all the | ||
295 | look ups from the start and will normally return something from the | ||
296 | primary hash table. | ||
297 | |||
298 | mnt->mnt_count | ||
299 | ~~~~~~~~~~~~~~ | ||
300 | |||
301 | ``mnt_count`` is a per-CPU reference counter on "``mount``" structures. | ||
268 | Per-CPU here means that incrementing the count is cheap as it only | 302 | Per-CPU here means that incrementing the count is cheap as it only |
269 | uses CPU-local memory, but checking if the count is zero is expensive as | 303 | uses CPU-local memory, but checking if the count is zero is expensive as |
270 | it needs to check with every CPU. Taking a `mnt_count` reference | 304 | it needs to check with every CPU. Taking a ``mnt_count`` reference |
271 | prevents the mount structure from disappearing as the result of regular | 305 | prevents the mount structure from disappearing as the result of regular |
272 | unmount operations, but does not prevent a "lazy" unmount. So holding | 306 | unmount operations, but does not prevent a "lazy" unmount. So holding |
273 | `mnt_count` doesn't ensure that the mount remains in the namespace and, | 307 | ``mnt_count`` doesn't ensure that the mount remains in the namespace and, |
274 | in particular, doesn't stabilize the link to the mounted-on dentry. It | 308 | in particular, doesn't stabilize the link to the mounted-on dentry. It |
275 | does, however, ensure that the `mount` data structure remains coherent, | 309 | does, however, ensure that the ``mount`` data structure remains coherent, |
276 | and it provides a reference to the root dentry of the mounted | 310 | and it provides a reference to the root dentry of the mounted |
277 | filesystem. So a reference through `->mnt_count` provides a stable | 311 | filesystem. So a reference through ``->mnt_count`` provides a stable |
278 | reference to the mounted dentry, but not the mounted-on dentry. | 312 | reference to the mounted dentry, but not the mounted-on dentry. |
279 | 313 | ||
280 | ### mount_lock ### | 314 | mount_lock |
315 | ~~~~~~~~~~ | ||
281 | 316 | ||
282 | `mount_lock` is a global seqlock, a bit like `rename_lock`. It can be used to | 317 | ``mount_lock`` is a global seqlock, a bit like ``rename_lock``. It can be used to |
283 | check if any change has been made to any mount points. | 318 | check if any change has been made to any mount points. |
284 | 319 | ||
285 | While walking down the tree (away from the root) this lock is used when | 320 | While walking down the tree (away from the root) this lock is used when |
286 | crossing a mount point to check that the crossing was safe. That is, | 321 | crossing a mount point to check that the crossing was safe. That is, |
287 | the value in the seqlock is read, then the code finds the mount that | 322 | the value in the seqlock is read, then the code finds the mount that |
288 | is mounted on the current directory, if there is one, and increments | 323 | is mounted on the current directory, if there is one, and increments |
289 | the `mnt_count`. Finally the value in `mount_lock` is checked against | 324 | the ``mnt_count``. Finally the value in ``mount_lock`` is checked against |
290 | the old value. If there is no change, then the crossing was safe. If there | 325 | the old value. If there is no change, then the crossing was safe. If there |
291 | was a change, the `mnt_count` is decremented and the whole process is | 326 | was a change, the ``mnt_count`` is decremented and the whole process is |
292 | retried. | 327 | retried. |
293 | 328 | ||
294 | When walking up the tree (towards the root) by following a ".." link, | 329 | When walking up the tree (towards the root) by following a ".." link, |
@@ -298,7 +333,8 @@ any changes to any mount points while stepping up. This locking is | |||
298 | needed to stabilize the link to the mounted-on dentry, which the | 333 | needed to stabilize the link to the mounted-on dentry, which the |
299 | refcount on the mount itself doesn't ensure. | 334 | refcount on the mount itself doesn't ensure. |
300 | 335 | ||
301 | ### RCU ### | 336 | RCU |
337 | ~~~ | ||
302 | 338 | ||
303 | Finally the global (but extremely lightweight) RCU read lock is held | 339 | Finally the global (but extremely lightweight) RCU read lock is held |
304 | from time to time to ensure certain data structures don't get freed | 340 | from time to time to ensure certain data structures don't get freed |
@@ -307,137 +343,141 @@ unexpectedly. | |||
307 | In particular it is held while scanning chains in the dcache hash | 343 | In particular it is held while scanning chains in the dcache hash |
308 | table, and the mount point hash table. | 344 | table, and the mount point hash table. |
309 | 345 | ||
310 | Bringing it together with `struct nameidata` | 346 | Bringing it together with ``struct nameidata`` |
311 | -------------------------------------------- | 347 | -------------------------------------------- |
312 | 348 | ||
313 | [First edition Unix]: http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/u2.s | 349 | .. _First edition Unix: http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/u2.s |
314 | 350 | ||
315 | Throughout the process of walking a path, the current status is stored | 351 | Throughout the process of walking a path, the current status is stored |
316 | in a `struct nameidata`, "namei" being the traditional name - dating | 352 | in a ``struct nameidata``, "namei" being the traditional name - dating |
317 | all the way back to [First Edition Unix] - of the function that | 353 | all the way back to `First Edition Unix`_ - of the function that |
318 | converts a "name" to an "inode". `struct nameidata` contains (among | 354 | converts a "name" to an "inode". ``struct nameidata`` contains (among |
319 | other fields): | 355 | other fields): |
320 | 356 | ||
321 | ### `struct path path` ### | 357 | ``struct path path`` |
358 | ~~~~~~~~~~~~~~~~~~ | ||
322 | 359 | ||
323 | A `path` contains a `struct vfsmount` (which is | 360 | A ``path`` contains a ``struct vfsmount`` (which is |
324 | embedded in a `struct mount`) and a `struct dentry`. Together these | 361 | embedded in a ``struct mount``) and a ``struct dentry``. Together these |
325 | record the current status of the walk. They start out referring to the | 362 | record the current status of the walk. They start out referring to the |
326 | starting point (the current working directory, the root directory, or some other | 363 | starting point (the current working directory, the root directory, or some other |
327 | directory identified by a file descriptor), and are updated on each | 364 | directory identified by a file descriptor), and are updated on each |
328 | step. A reference through `d_lockref` and `mnt_count` is always | 365 | step. A reference through ``d_lockref`` and ``mnt_count`` is always |
329 | held. | 366 | held. |
330 | 367 | ||
331 | ### `struct qstr last` ### | 368 | ``struct qstr last`` |
369 | ~~~~~~~~~~~~~~~~~~ | ||
332 | 370 | ||
333 | This is a string together with a length (i.e. _not_ `nul` terminated) | 371 | This is a string together with a length (i.e. _not_ ``nul`` terminated) |
334 | that is the "next" component in the pathname. | 372 | that is the "next" component in the pathname. |
335 | 373 | ||
336 | ### `int last_type` ### | 374 | ``int last_type`` |
375 | ~~~~~~~~~~~~~~~ | ||
337 | 376 | ||
338 | This is one of `LAST_NORM`, `LAST_ROOT`, `LAST_DOT`, `LAST_DOTDOT`, or | 377 | This is one of ``LAST_NORM``, ``LAST_ROOT``, ``LAST_DOT``, ``LAST_DOTDOT``, or |
339 | `LAST_BIND`. The `last` field is only valid if the type is | 378 | ``LAST_BIND``. The ``last`` field is only valid if the type is |
340 | `LAST_NORM`. `LAST_BIND` is used when following a symlink and no | 379 | ``LAST_NORM``. ``LAST_BIND`` is used when following a symlink and no |
341 | components of the symlink have been processed yet. Others should be | 380 | components of the symlink have been processed yet. Others should be |
342 | fairly self-explanatory. | 381 | fairly self-explanatory. |
343 | 382 | ||
344 | ### `struct path root` ### | 383 | ``struct path root`` |
384 | ~~~~~~~~~~~~~~~~~~ | ||
345 | 385 | ||
346 | This is used to hold a reference to the effective root of the | 386 | This is used to hold a reference to the effective root of the |
347 | filesystem. Often that reference won't be needed, so this field is | 387 | filesystem. Often that reference won't be needed, so this field is |
348 | only assigned the first time it is used, or when a non-standard root | 388 | only assigned the first time it is used, or when a non-standard root |
349 | is requested. Keeping a reference in the `nameidata` ensures that | 389 | is requested. Keeping a reference in the ``nameidata`` ensures that |
350 | only one root is in effect for the entire path walk, even if it races | 390 | only one root is in effect for the entire path walk, even if it races |
351 | with a `chroot()` system call. | 391 | with a ``chroot()`` system call. |
352 | 392 | ||
353 | The root is needed when either of two conditions holds: (1) either the | 393 | The root is needed when either of two conditions holds: (1) either the |
354 | pathname or a symbolic link starts with a "'/'", or (2) a "`..`" | 394 | pathname or a symbolic link starts with a "'/'", or (2) a "``..``" |
355 | component is being handled, since "`..`" from the root must always stay | 395 | component is being handled, since "``..``" from the root must always stay |
356 | at the root. The value used is usually the current root directory of | 396 | at the root. The value used is usually the current root directory of |
357 | the calling process. An alternate root can be provided as when | 397 | the calling process. An alternate root can be provided as when |
358 | `sysctl()` calls `file_open_root()`, and when NFSv4 or Btrfs call | 398 | ``sysctl()`` calls ``file_open_root()``, and when NFSv4 or Btrfs call |
359 | `mount_subtree()`. In each case a pathname is being looked up in a very | 399 | ``mount_subtree()``. In each case a pathname is being looked up in a very |
360 | specific part of the filesystem, and the lookup must not be allowed to | 400 | specific part of the filesystem, and the lookup must not be allowed to |
361 | escape that subtree. It works a bit like a local `chroot()`. | 401 | escape that subtree. It works a bit like a local ``chroot()``. |
362 | 402 | ||
363 | Ignoring the handling of symbolic links, we can now describe the | 403 | Ignoring the handling of symbolic links, we can now describe the |
364 | "`link_path_walk()`" function, which handles the lookup of everything | 404 | "``link_path_walk()``" function, which handles the lookup of everything |
365 | except the final component as: | 405 | except the final component as: |
366 | 406 | ||
367 | > Given a path (`name`) and a nameidata structure (`nd`), check that the | 407 | Given a path (``name``) and a nameidata structure (``nd``), check that the |
368 | > current directory has execute permission and then advance `name` | 408 | current directory has execute permission and then advance ``name`` |
369 | > over one component while updating `last_type` and `last`. If that | 409 | over one component while updating ``last_type`` and ``last``. If that |
370 | > was the final component, then return, otherwise call | 410 | was the final component, then return, otherwise call |
371 | > `walk_component()` and repeat from the top. | 411 | ``walk_component()`` and repeat from the top. |
372 | 412 | ||
373 | `walk_component()` is even easier. If the component is `LAST_DOTS`, | 413 | ``walk_component()`` is even easier. If the component is ``LAST_DOTS``, |
374 | it calls `handle_dots()` which does the necessary locking as already | 414 | it calls ``handle_dots()`` which does the necessary locking as already |
375 | described. If it finds a `LAST_NORM` component it first calls | 415 | described. If it finds a ``LAST_NORM`` component it first calls |
376 | "`lookup_fast()`" which only looks in the dcache, but will ask the | 416 | "``lookup_fast()``" which only looks in the dcache, but will ask the |
377 | filesystem to revalidate the result if it is that sort of filesystem. | 417 | filesystem to revalidate the result if it is that sort of filesystem. |
378 | If that doesn't get a good result, it calls "`lookup_slow()`" which | 418 | If that doesn't get a good result, it calls "``lookup_slow()``" which |
379 | takes the `i_mutex`, rechecks the cache, and then asks the filesystem | 419 | takes ``i_rwsem``, rechecks the cache, and then asks the filesystem |
380 | to find a definitive answer. Each of these will call | 420 | to find a definitive answer. Each of these will call |
381 | `follow_managed()` (as described below) to handle any mount points. | 421 | ``follow_managed()`` (as described below) to handle any mount points. |
382 | 422 | ||
383 | In the absence of symbolic links, `walk_component()` creates a new | 423 | In the absence of symbolic links, ``walk_component()`` creates a new |
384 | `struct path` containing a counted reference to the new dentry and a | 424 | ``struct path`` containing a counted reference to the new dentry and a |
385 | reference to the new `vfsmount` which is only counted if it is | 425 | reference to the new ``vfsmount`` which is only counted if it is |
386 | different from the previous `vfsmount`. It then calls | 426 | different from the previous ``vfsmount``. It then calls |
387 | `path_to_nameidata()` to install the new `struct path` in the | 427 | ``path_to_nameidata()`` to install the new ``struct path`` in the |
388 | `struct nameidata` and drop the unneeded references. | 428 | ``struct nameidata`` and drop the unneeded references. |
389 | 429 | ||
390 | This "hand-over-hand" sequencing of getting a reference to the new | 430 | This "hand-over-hand" sequencing of getting a reference to the new |
391 | dentry before dropping the reference to the previous dentry may | 431 | dentry before dropping the reference to the previous dentry may |
392 | seem obvious, but is worth pointing out so that we will recognize its | 432 | seem obvious, but is worth pointing out so that we will recognize its |
393 | analogue in the "RCU-walk" version. | 433 | analogue in the "RCU-walk" version. |
394 | 434 | ||
395 | Handling the final component. | 435 | Handling the final component |
396 | ----------------------------- | 436 | ---------------------------- |
397 | 437 | ||
398 | `link_path_walk()` only walks as far as setting `nd->last` and | 438 | ``link_path_walk()`` only walks as far as setting ``nd->last`` and |
399 | `nd->last_type` to refer to the final component of the path. It does | 439 | ``nd->last_type`` to refer to the final component of the path. It does |
400 | not call `walk_component()` that last time. Handling that final | 440 | not call ``walk_component()`` that last time. Handling that final |
401 | component remains for the caller to sort out. Those callers are | 441 | component remains for the caller to sort out. Those callers are |
402 | `path_lookupat()`, `path_parentat()`, `path_mountpoint()` and | 442 | ``path_lookupat()``, ``path_parentat()``, ``path_mountpoint()`` and |
403 | `path_openat()` each of which handles the differing requirements of | 443 | ``path_openat()`` each of which handles the differing requirements of |
404 | different system calls. | 444 | different system calls. |
405 | 445 | ||
406 | `path_parentat()` is clearly the simplest - it just wraps a little bit | 446 | ``path_parentat()`` is clearly the simplest - it just wraps a little bit |
407 | of housekeeping around `link_path_walk()` and returns the parent | 447 | of housekeeping around ``link_path_walk()`` and returns the parent |
408 | directory and final component to the caller. The caller will be either | 448 | directory and final component to the caller. The caller will be either |
409 | aiming to create a name (via `filename_create()`) or remove or rename | 449 | aiming to create a name (via ``filename_create()``) or remove or rename |
410 | a name (in which case `user_path_parent()` is used). They will use | 450 | a name (in which case ``user_path_parent()`` is used). They will use |
411 | `i_mutex` to exclude other changes while they validate and then | 451 | ``i_rwsem`` to exclude other changes while they validate and then |
412 | perform their operation. | 452 | perform their operation. |
413 | 453 | ||
414 | `path_lookupat()` is nearly as simple - it is used when an existing | 454 | ``path_lookupat()`` is nearly as simple - it is used when an existing |
415 | object is wanted such as by `stat()` or `chmod()`. It essentially just | 455 | object is wanted such as by ``stat()`` or ``chmod()``. It essentially just |
416 | calls `walk_component()` on the final component through a call to | 456 | calls ``walk_component()`` on the final component through a call to |
417 | `lookup_last()`. `path_lookupat()` returns just the final dentry. | 457 | ``lookup_last()``. ``path_lookupat()`` returns just the final dentry. |
418 | 458 | ||
419 | `path_mountpoint()` handles the special case of unmounting which must | 459 | ``path_mountpoint()`` handles the special case of unmounting which must |
420 | not try to revalidate the mounted filesystem. It effectively | 460 | not try to revalidate the mounted filesystem. It effectively |
421 | contains, through a call to `mountpoint_last()`, an alternate | 461 | contains, through a call to ``mountpoint_last()``, an alternate |
422 | implementation of `lookup_slow()` which skips that step. This is | 462 | implementation of ``lookup_slow()`` which skips that step. This is |
423 | important when unmounting a filesystem that is inaccessible, such as | 463 | important when unmounting a filesystem that is inaccessible, such as |
424 | one provided by a dead NFS server. | 464 | one provided by a dead NFS server. |
425 | 465 | ||
426 | Finally `path_openat()` is used for the `open()` system call; it | 466 | Finally ``path_openat()`` is used for the ``open()`` system call; it |
427 | contains, in support functions starting with "`do_last()`", all the | 467 | contains, in support functions starting with "``do_last()``", all the |
428 | complexity needed to handle the different subtleties of O_CREAT (with | 468 | complexity needed to handle the different subtleties of O_CREAT (with |
429 | or without O_EXCL), final "`/`" characters, and trailing symbolic | 469 | or without O_EXCL), final "``/``" characters, and trailing symbolic |
430 | links. We will revisit this in the final part of this series, which | 470 | links. We will revisit this in the final part of this series, which |
431 | focuses on those symbolic links. "`do_last()`" will sometimes, but | 471 | focuses on those symbolic links. "``do_last()``" will sometimes, but |
432 | not always, take `i_mutex`, depending on what it finds. | 472 | not always, take ``i_rwsem``, depending on what it finds. |
433 | 473 | ||
434 | Each of these, or the functions which call them, need to be alert to | 474 | Each of these, or the functions which call them, need to be alert to |
435 | the possibility that the final component is not `LAST_NORM`. If the | 475 | the possibility that the final component is not ``LAST_NORM``. If the |
436 | goal of the lookup is to create something, then any value for | 476 | goal of the lookup is to create something, then any value for |
437 | `last_type` other than `LAST_NORM` will result in an error. For | 477 | ``last_type`` other than ``LAST_NORM`` will result in an error. For |
438 | example if `path_parentat()` reports `LAST_DOTDOT`, then the caller | 478 | example if ``path_parentat()`` reports ``LAST_DOTDOT``, then the caller |
439 | won't try to create that name. They also check for trailing slashes | 479 | won't try to create that name. They also check for trailing slashes |
440 | by testing `last.name[last.len]`. If there is any character beyond | 480 | by testing ``last.name[last.len]``. If there is any character beyond |
441 | the final component, it must be a trailing slash. | 481 | the final component, it must be a trailing slash. |
442 | 482 | ||
443 | Revalidation and automounts | 483 | Revalidation and automounts |
@@ -448,12 +488,12 @@ process not yet covered. One is the handling of stale cache entries | |||
448 | and the other is automounts. | 488 | and the other is automounts. |
449 | 489 | ||
450 | On filesystems that require it, the lookup routines will call the | 490 | On filesystems that require it, the lookup routines will call the |
451 | `->d_revalidate()` dentry method to ensure that the cached information | 491 | ``->d_revalidate()`` dentry method to ensure that the cached information |
452 | is current. This will often confirm validity or update a few details | 492 | is current. This will often confirm validity or update a few details |
453 | from a server. In some cases it may find that there has been change | 493 | from a server. In some cases it may find that there has been change |
454 | further up the path and that something that was thought to be valid | 494 | further up the path and that something that was thought to be valid |
455 | previously isn't really. When this happens the lookup of the whole | 495 | previously isn't really. When this happens the lookup of the whole |
456 | path is aborted and retried with the "`LOOKUP_REVAL`" flag set. This | 496 | path is aborted and retried with the "``LOOKUP_REVAL``" flag set. This |
457 | forces revalidation to be more thorough. We will see more details of | 497 | forces revalidation to be more thorough. We will see more details of |
458 | this retry process in the next article. | 498 | this retry process in the next article. |
459 | 499 | ||
@@ -465,52 +505,55 @@ tree, but a few notes specifically related to path lookup are in order | |||
465 | here. | 505 | here. |
466 | 506 | ||
467 | The Linux VFS has a concept of "managed" dentries which is reflected | 507 | The Linux VFS has a concept of "managed" dentries which is reflected |
468 | in function names such as "`follow_managed()`". There are three | 508 | in function names such as "``follow_managed()``". There are three |
469 | potentially interesting things about these dentries corresponding | 509 | potentially interesting things about these dentries corresponding |
470 | to three different flags that might be set in `dentry->d_flags`: | 510 | to three different flags that might be set in ``dentry->d_flags``: |
471 | 511 | ||
472 | ### `DCACHE_MANAGE_TRANSIT` ### | 512 | ``DCACHE_MANAGE_TRANSIT`` |
513 | ~~~~~~~~~~~~~~~~~~~~~~~ | ||
473 | 514 | ||
474 | If this flag has been set, then the filesystem has requested that the | 515 | If this flag has been set, then the filesystem has requested that the |
475 | `d_manage()` dentry operation be called before handling any possible | 516 | ``d_manage()`` dentry operation be called before handling any possible |
476 | mount point. This can perform two particular services: | 517 | mount point. This can perform two particular services: |
477 | 518 | ||
478 | It can block to avoid races. If an automount point is being | 519 | It can block to avoid races. If an automount point is being |
479 | unmounted, the `d_manage()` function will usually wait for that | 520 | unmounted, the ``d_manage()`` function will usually wait for that |
480 | process to complete before letting the new lookup proceed and possibly | 521 | process to complete before letting the new lookup proceed and possibly |
481 | trigger a new automount. | 522 | trigger a new automount. |
482 | 523 | ||
483 | It can selectively allow only some processes to transit through a | 524 | It can selectively allow only some processes to transit through a |
484 | mount point. When a server process is managing automounts, it may | 525 | mount point. When a server process is managing automounts, it may |
485 | need to access a directory without triggering normal automount | 526 | need to access a directory without triggering normal automount |
486 | processing. That server process can identify itself to the `autofs` | 527 | processing. That server process can identify itself to the ``autofs`` |
487 | filesystem, which will then give it a special pass through | 528 | filesystem, which will then give it a special pass through |
488 | `d_manage()` by returning `-EISDIR`. | 529 | ``d_manage()`` by returning ``-EISDIR``. |
489 | 530 | ||
490 | ### `DCACHE_MOUNTED` ### | 531 | ``DCACHE_MOUNTED`` |
532 | ~~~~~~~~~~~~~~~~ | ||
491 | 533 | ||
492 | This flag is set on every dentry that is mounted on. As Linux | 534 | This flag is set on every dentry that is mounted on. As Linux |
493 | supports multiple filesystem namespaces, it is possible that the | 535 | supports multiple filesystem namespaces, it is possible that the |
494 | dentry may not be mounted on in *this* namespace, just in some | 536 | dentry may not be mounted on in *this* namespace, just in some |
495 | other. So this flag is seen as a hint, not a promise. | 537 | other. So this flag is seen as a hint, not a promise. |
496 | 538 | ||
497 | If this flag is set, and `d_manage()` didn't return `-EISDIR`, | 539 | If this flag is set, and ``d_manage()`` didn't return ``-EISDIR``, |
498 | `lookup_mnt()` is called to examine the mount hash table (honoring the | 540 | ``lookup_mnt()`` is called to examine the mount hash table (honoring the |
499 | `mount_lock` described earlier) and possibly return a new `vfsmount` | 541 | ``mount_lock`` described earlier) and possibly return a new ``vfsmount`` |
500 | and a new `dentry` (both with counted references). | 542 | and a new ``dentry`` (both with counted references). |
501 | 543 | ||
502 | ### `DCACHE_NEED_AUTOMOUNT` ### | 544 | ``DCACHE_NEED_AUTOMOUNT`` |
545 | ~~~~~~~~~~~~~~~~~~~~~~~ | ||
503 | 546 | ||
504 | If `d_manage()` allowed us to get this far, and `lookup_mnt()` didn't | 547 | If ``d_manage()`` allowed us to get this far, and ``lookup_mnt()`` didn't |
505 | find a mount point, then this flag causes the `d_automount()` dentry | 548 | find a mount point, then this flag causes the ``d_automount()`` dentry |
506 | operation to be called. | 549 | operation to be called. |
507 | 550 | ||
508 | The `d_automount()` operation can be arbitrarily complex and may | 551 | The ``d_automount()`` operation can be arbitrarily complex and may |
509 | communicate with server processes etc. but it should ultimately either | 552 | communicate with server processes etc. but it should ultimately either |
510 | report that there was an error, that there was nothing to mount, or | 553 | report that there was an error, that there was nothing to mount, or |
511 | should provide an updated `struct path` with new `dentry` and `vfsmount`. | 554 | should provide an updated ``struct path`` with new ``dentry`` and ``vfsmount``. |
512 | 555 | ||
513 | In the latter case, `finish_automount()` will be called to safely | 556 | In the latter case, ``finish_automount()`` will be called to safely |
514 | install the new mount point into the mount table. | 557 | install the new mount point into the mount table. |
515 | 558 | ||
516 | There is no new locking of import here and it is important that no | 559 | There is no new locking of import here and it is important that no |
@@ -567,7 +610,7 @@ isn't in the cache, then it tries to stop gracefully and switch to | |||
567 | REF-walk. | 610 | REF-walk. |
568 | 611 | ||
569 | This stopping requires getting a counted reference on the current | 612 | This stopping requires getting a counted reference on the current |
570 | `vfsmount` and `dentry`, and ensuring that these are still valid - | 613 | ``vfsmount`` and ``dentry``, and ensuring that these are still valid - |
571 | that a path walk with REF-walk would have found the same entries. | 614 | that a path walk with REF-walk would have found the same entries. |
572 | This is an invariant that RCU-walk must guarantee. It can only make | 615 | This is an invariant that RCU-walk must guarantee. It can only make |
573 | decisions, such as selecting the next step, that are decisions which | 616 | decisions, such as selecting the next step, that are decisions which |
@@ -578,21 +621,21 @@ RCU-walk finds it cannot stop gracefully, it simply gives up and | |||
578 | restarts from the top with REF-walk. | 621 | restarts from the top with REF-walk. |
579 | 622 | ||
580 | This pattern of "try RCU-walk, if that fails try REF-walk" can be | 623 | This pattern of "try RCU-walk, if that fails try REF-walk" can be |
581 | clearly seen in functions like `filename_lookup()`, | 624 | clearly seen in functions like ``filename_lookup()``, |
582 | `filename_parentat()`, `filename_mountpoint()`, | 625 | ``filename_parentat()``, ``filename_mountpoint()``, |
583 | `do_filp_open()`, and `do_file_open_root()`. These five | 626 | ``do_filp_open()``, and ``do_file_open_root()``. These five |
584 | correspond roughly to the four `path_`* functions we met earlier, | 627 | correspond roughly to the four ``path_``* functions we met earlier, |
585 | each of which calls `link_path_walk()`. The `path_*` functions are | 628 | each of which calls ``link_path_walk()``. The ``path_*`` functions are |
586 | called using different mode flags until a mode is found which works. | 629 | called using different mode flags until a mode is found which works. |
587 | They are first called with `LOOKUP_RCU` set to request "RCU-walk". If | 630 | They are first called with ``LOOKUP_RCU`` set to request "RCU-walk". If |
588 | that fails with the error `ECHILD` they are called again with no | 631 | that fails with the error ``ECHILD`` they are called again with no |
589 | special flag to request "REF-walk". If either of those report the | 632 | special flag to request "REF-walk". If either of those report the |
590 | error `ESTALE` a final attempt is made with `LOOKUP_REVAL` set (and no | 633 | error ``ESTALE`` a final attempt is made with ``LOOKUP_REVAL`` set (and no |
591 | `LOOKUP_RCU`) to ensure that entries found in the cache are forcibly | 634 | ``LOOKUP_RCU``) to ensure that entries found in the cache are forcibly |
592 | revalidated - normally entries are only revalidated if the filesystem | 635 | revalidated - normally entries are only revalidated if the filesystem |
593 | determines that they are too old to trust. | 636 | determines that they are too old to trust. |
594 | 637 | ||
595 | The `LOOKUP_RCU` attempt may drop that flag internally and switch to | 638 | The ``LOOKUP_RCU`` attempt may drop that flag internally and switch to |
596 | REF-walk, but will never then try to switch back to RCU-walk. Places | 639 | REF-walk, but will never then try to switch back to RCU-walk. Places |
597 | that trip up RCU-walk are much more likely to be near the leaves and | 640 | that trip up RCU-walk are much more likely to be near the leaves and |
598 | so it is very unlikely that there will be much, if any, benefit from | 641 | so it is very unlikely that there will be much, if any, benefit from |
@@ -602,7 +645,7 @@ RCU and seqlocks: fast and light | |||
602 | -------------------------------- | 645 | -------------------------------- |
603 | 646 | ||
604 | RCU is, unsurprisingly, critical to RCU-walk mode. The | 647 | RCU is, unsurprisingly, critical to RCU-walk mode. The |
605 | `rcu_read_lock()` is held for the entire time that RCU-walk is walking | 648 | ``rcu_read_lock()`` is held for the entire time that RCU-walk is walking |
606 | down a path. The particular guarantee it provides is that the key | 649 | down a path. The particular guarantee it provides is that the key |
607 | data structures - dentries, inodes, super_blocks, and mounts - will | 650 | data structures - dentries, inodes, super_blocks, and mounts - will |
608 | not be freed while the lock is held. They might be unlinked or | 651 | not be freed while the lock is held. They might be unlinked or |
@@ -614,7 +657,7 @@ seqlocks. | |||
614 | As we saw above, REF-walk holds a counted reference to the current | 657 | As we saw above, REF-walk holds a counted reference to the current |
615 | dentry and the current vfsmount, and does not release those references | 658 | dentry and the current vfsmount, and does not release those references |
616 | before taking references to the "next" dentry or vfsmount. It also | 659 | before taking references to the "next" dentry or vfsmount. It also |
617 | sometimes takes the `d_lock` spinlock. These references and locks are | 660 | sometimes takes the ``d_lock`` spinlock. These references and locks are |
618 | taken to prevent certain changes from happening. RCU-walk must not | 661 | taken to prevent certain changes from happening. RCU-walk must not |
619 | take those references or locks and so cannot prevent such changes. | 662 | take those references or locks and so cannot prevent such changes. |
620 | Instead, it checks to see if a change has been made, and aborts or | 663 | Instead, it checks to see if a change has been made, and aborts or |
@@ -624,123 +667,126 @@ To preserve the invariant mentioned above (that RCU-walk may only make | |||
624 | decisions that REF-walk could have made), it must make the checks at | 667 | decisions that REF-walk could have made), it must make the checks at |
625 | or near the same places that REF-walk holds the references. So, when | 668 | or near the same places that REF-walk holds the references. So, when |
626 | REF-walk increments a reference count or takes a spinlock, RCU-walk | 669 | REF-walk increments a reference count or takes a spinlock, RCU-walk |
627 | samples the status of a seqlock using `read_seqcount_begin()` or a | 670 | samples the status of a seqlock using ``read_seqcount_begin()`` or a |
628 | similar function. When REF-walk decrements the count or drops the | 671 | similar function. When REF-walk decrements the count or drops the |
629 | lock, RCU-walk checks if the sampled status is still valid using | 672 | lock, RCU-walk checks if the sampled status is still valid using |
630 | `read_seqcount_retry()` or similar. | 673 | ``read_seqcount_retry()`` or similar. |
631 | 674 | ||
632 | However, there is a little bit more to seqlocks than that. If | 675 | However, there is a little bit more to seqlocks than that. If |
633 | RCU-walk accesses two different fields in a seqlock-protected | 676 | RCU-walk accesses two different fields in a seqlock-protected |
634 | structure, or accesses the same field twice, there is no a priori | 677 | structure, or accesses the same field twice, there is no a priori |
635 | guarantee of any consistency between those accesses. When consistency | 678 | guarantee of any consistency between those accesses. When consistency |
636 | is needed - which it usually is - RCU-walk must take a copy and then | 679 | is needed - which it usually is - RCU-walk must take a copy and then |
637 | use `read_seqcount_retry()` to validate that copy. | 680 | use ``read_seqcount_retry()`` to validate that copy. |
638 | 681 | ||
639 | `read_seqcount_retry()` not only checks the sequence number, but also | 682 | ``read_seqcount_retry()`` not only checks the sequence number, but also |
640 | imposes a memory barrier so that no memory-read instruction from | 683 | imposes a memory barrier so that no memory-read instruction from |
641 | *before* the call can be delayed until *after* the call, either by the | 684 | *before* the call can be delayed until *after* the call, either by the |
642 | CPU or by the compiler. A simple example of this can be seen in | 685 | CPU or by the compiler. A simple example of this can be seen in |
643 | `slow_dentry_cmp()` which, for filesystems which do not use simple | 686 | ``slow_dentry_cmp()`` which, for filesystems which do not use simple |
644 | byte-wise name equality, calls into the filesystem to compare a name | 687 | byte-wise name equality, calls into the filesystem to compare a name |
645 | against a dentry. The length and name pointer are copied into local | 688 | against a dentry. The length and name pointer are copied into local |
646 | variables, then `read_seqcount_retry()` is called to confirm the two | 689 | variables, then ``read_seqcount_retry()`` is called to confirm the two |
647 | are consistent, and only then is `->d_compare()` called. When | 690 | are consistent, and only then is ``->d_compare()`` called. When |
648 | standard filename comparison is used, `dentry_cmp()` is called | 691 | standard filename comparison is used, ``dentry_cmp()`` is called |
649 | instead. Notably it does _not_ use `read_seqcount_retry()`, but | 692 | instead. Notably it does _not_ use ``read_seqcount_retry()``, but |
650 | instead has a large comment explaining why the consistency guarantee | 693 | instead has a large comment explaining why the consistency guarantee |
651 | isn't necessary. A subsequent `read_seqcount_retry()` will be | 694 | isn't necessary. A subsequent ``read_seqcount_retry()`` will be |
652 | sufficient to catch any problem that could occur at this point. | 695 | sufficient to catch any problem that could occur at this point. |
653 | 696 | ||
654 | With that little refresher on seqlocks out of the way we can look at | 697 | With that little refresher on seqlocks out of the way we can look at |
655 | the bigger picture of how RCU-walk uses seqlocks. | 698 | the bigger picture of how RCU-walk uses seqlocks. |
656 | 699 | ||
657 | ### `mount_lock` and `nd->m_seq` ### | 700 | ``mount_lock`` and ``nd->m_seq`` |
701 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
658 | 702 | ||
659 | We already met the `mount_lock` seqlock when REF-walk used it to | 703 | We already met the ``mount_lock`` seqlock when REF-walk used it to |
660 | ensure that crossing a mount point is performed safely. RCU-walk uses | 704 | ensure that crossing a mount point is performed safely. RCU-walk uses |
661 | it for that too, but for quite a bit more. | 705 | it for that too, but for quite a bit more. |
662 | 706 | ||
663 | Instead of taking a counted reference to each `vfsmount` as it | 707 | Instead of taking a counted reference to each ``vfsmount`` as it |
664 | descends the tree, RCU-walk samples the state of `mount_lock` at the | 708 | descends the tree, RCU-walk samples the state of ``mount_lock`` at the |
665 | start of the walk and stores this initial sequence number in the | 709 | start of the walk and stores this initial sequence number in the |
666 | `struct nameidata` in the `m_seq` field. This one lock and one | 710 | ``struct nameidata`` in the ``m_seq`` field. This one lock and one |
667 | sequence number are used to validate all accesses to all `vfsmounts`, | 711 | sequence number are used to validate all accesses to all ``vfsmounts``, |
668 | and all mount point crossings. As changes to the mount table are | 712 | and all mount point crossings. As changes to the mount table are |
669 | relatively rare, it is reasonable to fall back on REF-walk any time | 713 | relatively rare, it is reasonable to fall back on REF-walk any time |
670 | that any "mount" or "unmount" happens. | 714 | that any "mount" or "unmount" happens. |
671 | 715 | ||
672 | `m_seq` is checked (using `read_seqretry()`) at the end of an RCU-walk | 716 | ``m_seq`` is checked (using ``read_seqretry()``) at the end of an RCU-walk |
673 | sequence, whether switching to REF-walk for the rest of the path or | 717 | sequence, whether switching to REF-walk for the rest of the path or |
674 | when the end of the path is reached. It is also checked when stepping | 718 | when the end of the path is reached. It is also checked when stepping |
675 | down over a mount point (in `__follow_mount_rcu()`) or up (in | 719 | down over a mount point (in ``__follow_mount_rcu()``) or up (in |
676 | `follow_dotdot_rcu()`). If it is ever found to have changed, the | 720 | ``follow_dotdot_rcu()``). If it is ever found to have changed, the |
677 | whole RCU-walk sequence is aborted and the path is processed again by | 721 | whole RCU-walk sequence is aborted and the path is processed again by |
678 | REF-walk. | 722 | REF-walk. |
679 | 723 | ||
680 | If RCU-walk finds that `mount_lock` hasn't changed then it can be sure | 724 | If RCU-walk finds that ``mount_lock`` hasn't changed then it can be sure |
681 | that, had REF-walk taken counted references on each vfsmount, the | 725 | that, had REF-walk taken counted references on each vfsmount, the |
682 | results would have been the same. This ensures the invariant holds, | 726 | results would have been the same. This ensures the invariant holds, |
683 | at least for vfsmount structures. | 727 | at least for vfsmount structures. |
684 | 728 | ||
685 | ### `dentry->d_seq` and `nd->seq`. ### | 729 | ``dentry->d_seq`` and ``nd->seq`` |
730 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
686 | 731 | ||
687 | In place of taking a count or lock on `d_reflock`, RCU-walk samples | 732 | In place of taking a count or lock on ``d_reflock``, RCU-walk samples |
688 | the per-dentry `d_seq` seqlock, and stores the sequence number in the | 733 | the per-dentry ``d_seq`` seqlock, and stores the sequence number in the |
689 | `seq` field of the nameidata structure, so `nd->seq` should always be | 734 | ``seq`` field of the nameidata structure, so ``nd->seq`` should always be |
690 | the current sequence number of `nd->dentry`. This number needs to be | 735 | the current sequence number of ``nd->dentry``. This number needs to be |
691 | revalidated after copying, and before using, the name, parent, or | 736 | revalidated after copying, and before using, the name, parent, or |
692 | inode of the dentry. | 737 | inode of the dentry. |
693 | 738 | ||
694 | The handling of the name we have already looked at, and the parent is | 739 | The handling of the name we have already looked at, and the parent is |
695 | only accessed in `follow_dotdot_rcu()` which fairly trivially follows | 740 | only accessed in ``follow_dotdot_rcu()`` which fairly trivially follows |
696 | the required pattern, though it does so for three different cases. | 741 | the required pattern, though it does so for three different cases. |
697 | 742 | ||
698 | When not at a mount point, `d_parent` is followed and its `d_seq` is | 743 | When not at a mount point, ``d_parent`` is followed and its ``d_seq`` is |
699 | collected. When we are at a mount point, we instead follow the | 744 | collected. When we are at a mount point, we instead follow the |
700 | `mnt->mnt_mountpoint` link to get a new dentry and collect its | 745 | ``mnt->mnt_mountpoint`` link to get a new dentry and collect its |
701 | `d_seq`. Then, after finally finding a `d_parent` to follow, we must | 746 | ``d_seq``. Then, after finally finding a ``d_parent`` to follow, we must |
702 | check if we have landed on a mount point and, if so, must find that | 747 | check if we have landed on a mount point and, if so, must find that |
703 | mount point and follow the `mnt->mnt_root` link. This would imply a | 748 | mount point and follow the ``mnt->mnt_root`` link. This would imply a |
704 | somewhat unusual, but certainly possible, circumstance where the | 749 | somewhat unusual, but certainly possible, circumstance where the |
705 | starting point of the path lookup was in part of the filesystem that | 750 | starting point of the path lookup was in part of the filesystem that |
706 | was mounted on, and so not visible from the root. | 751 | was mounted on, and so not visible from the root. |
707 | 752 | ||
708 | The inode pointer, stored in `->d_inode`, is a little more | 753 | The inode pointer, stored in ``->d_inode``, is a little more |
709 | interesting. The inode will always need to be accessed at least | 754 | interesting. The inode will always need to be accessed at least |
710 | twice, once to determine if it is NULL and once to verify access | 755 | twice, once to determine if it is NULL and once to verify access |
711 | permissions. Symlink handling requires a validated inode pointer too. | 756 | permissions. Symlink handling requires a validated inode pointer too. |
712 | Rather than revalidating on each access, a copy is made on the first | 757 | Rather than revalidating on each access, a copy is made on the first |
713 | access and it is stored in the `inode` field of `nameidata` from where | 758 | access and it is stored in the ``inode`` field of ``nameidata`` from where |
714 | it can be safely accessed without further validation. | 759 | it can be safely accessed without further validation. |
715 | 760 | ||
716 | `lookup_fast()` is the only lookup routine that is used in RCU-mode, | 761 | ``lookup_fast()`` is the only lookup routine that is used in RCU-mode, |
717 | `lookup_slow()` being too slow and requiring locks. It is in | 762 | ``lookup_slow()`` being too slow and requiring locks. It is in |
718 | `lookup_fast()` that we find the important "hand over hand" tracking | 763 | ``lookup_fast()`` that we find the important "hand over hand" tracking |
719 | of the current dentry. | 764 | of the current dentry. |
720 | 765 | ||
721 | The current `dentry` and current `seq` number are passed to | 766 | The current ``dentry`` and current ``seq`` number are passed to |
722 | `__d_lookup_rcu()` which, on success, returns a new `dentry` and a | 767 | ``__d_lookup_rcu()`` which, on success, returns a new ``dentry`` and a |
723 | new `seq` number. `lookup_fast()` then copies the inode pointer and | 768 | new ``seq`` number. ``lookup_fast()`` then copies the inode pointer and |
724 | revalidates the new `seq` number. It then validates the old `dentry` | 769 | revalidates the new ``seq`` number. It then validates the old ``dentry`` |
725 | with the old `seq` number one last time and only then continues. This | 770 | with the old ``seq`` number one last time and only then continues. This |
726 | process of getting the `seq` number of the new dentry and then | 771 | process of getting the ``seq`` number of the new dentry and then |
727 | checking the `seq` number of the old exactly mirrors the process of | 772 | checking the ``seq`` number of the old exactly mirrors the process of |
728 | getting a counted reference to the new dentry before dropping that for | 773 | getting a counted reference to the new dentry before dropping that for |
729 | the old dentry which we saw in REF-walk. | 774 | the old dentry which we saw in REF-walk. |
730 | 775 | ||
731 | ### No `inode->i_mutex` or even `rename_lock` ### | 776 | No ``inode->i_rwsem`` or even ``rename_lock`` |
777 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
732 | 778 | ||
733 | A mutex is a fairly heavyweight lock that can only be taken when it is | 779 | A semaphore is a fairly heavyweight lock that can only be taken when it is |
734 | permissible to sleep. As `rcu_read_lock()` forbids sleeping, | 780 | permissible to sleep. As ``rcu_read_lock()`` forbids sleeping, |
735 | `inode->i_mutex` plays no role in RCU-walk. If some other thread does | 781 | ``inode->i_rwsem`` plays no role in RCU-walk. If some other thread does |
736 | take `i_mutex` and modifies the directory in a way that RCU-walk needs | 782 | take ``i_rwsem`` and modifies the directory in a way that RCU-walk needs |
737 | to notice, the result will be either that RCU-walk fails to find the | 783 | to notice, the result will be either that RCU-walk fails to find the |
738 | dentry that it is looking for, or it will find a dentry which | 784 | dentry that it is looking for, or it will find a dentry which |
739 | `read_seqretry()` won't validate. In either case it will drop down to | 785 | ``read_seqretry()`` won't validate. In either case it will drop down to |
740 | REF-walk mode which can take whatever locks are needed. | 786 | REF-walk mode which can take whatever locks are needed. |
741 | 787 | ||
742 | Though `rename_lock` could be used by RCU-walk as it doesn't require | 788 | Though ``rename_lock`` could be used by RCU-walk as it doesn't require |
743 | any sleeping, RCU-walk doesn't bother. REF-walk uses `rename_lock` to | 789 | any sleeping, RCU-walk doesn't bother. REF-walk uses ``rename_lock`` to |
744 | protect against the possibility of hash chains in the dcache changing | 790 | protect against the possibility of hash chains in the dcache changing |
745 | while they are being searched. This can result in failing to find | 791 | while they are being searched. This can result in failing to find |
746 | something that actually is there. When RCU-walk fails to find | 792 | something that actually is there. When RCU-walk fails to find |
@@ -749,57 +795,57 @@ already drops down to REF-walk and tries again with appropriate | |||
749 | locking. This neatly handles all cases, so adding extra checks on | 795 | locking. This neatly handles all cases, so adding extra checks on |
750 | rename_lock would bring no significant value. | 796 | rename_lock would bring no significant value. |
751 | 797 | ||
752 | `unlazy walk()` and `complete_walk()` | 798 | ``unlazy walk()`` and ``complete_walk()`` |
753 | ------------------------------------- | 799 | ------------------------------------- |
754 | 800 | ||
755 | That "dropping down to REF-walk" typically involves a call to | 801 | That "dropping down to REF-walk" typically involves a call to |
756 | `unlazy_walk()`, so named because "RCU-walk" is also sometimes | 802 | ``unlazy_walk()``, so named because "RCU-walk" is also sometimes |
757 | referred to as "lazy walk". `unlazy_walk()` is called when | 803 | referred to as "lazy walk". ``unlazy_walk()`` is called when |
758 | following the path down to the current vfsmount/dentry pair seems to | 804 | following the path down to the current vfsmount/dentry pair seems to |
759 | have proceeded successfully, but the next step is problematic. This | 805 | have proceeded successfully, but the next step is problematic. This |
760 | can happen if the next name cannot be found in the dcache, if | 806 | can happen if the next name cannot be found in the dcache, if |
761 | permission checking or name revalidation couldn't be achieved while | 807 | permission checking or name revalidation couldn't be achieved while |
762 | the `rcu_read_lock()` is held (which forbids sleeping), if an | 808 | the ``rcu_read_lock()`` is held (which forbids sleeping), if an |
763 | automount point is found, or in a couple of cases involving symlinks. | 809 | automount point is found, or in a couple of cases involving symlinks. |
764 | It is also called from `complete_walk()` when the lookup has reached | 810 | It is also called from ``complete_walk()`` when the lookup has reached |
765 | the final component, or the very end of the path, depending on which | 811 | the final component, or the very end of the path, depending on which |
766 | particular flavor of lookup is used. | 812 | particular flavor of lookup is used. |
767 | 813 | ||
768 | Other reasons for dropping out of RCU-walk that do not trigger a call | 814 | Other reasons for dropping out of RCU-walk that do not trigger a call |
769 | to `unlazy_walk()` are when some inconsistency is found that cannot be | 815 | to ``unlazy_walk()`` are when some inconsistency is found that cannot be |
770 | handled immediately, such as `mount_lock` or one of the `d_seq` | 816 | handled immediately, such as ``mount_lock`` or one of the ``d_seq`` |
771 | seqlocks reporting a change. In these cases the relevant function | 817 | seqlocks reporting a change. In these cases the relevant function |
772 | will return `-ECHILD` which will percolate up until it triggers a new | 818 | will return ``-ECHILD`` which will percolate up until it triggers a new |
773 | attempt from the top using REF-walk. | 819 | attempt from the top using REF-walk. |
774 | 820 | ||
775 | For those cases where `unlazy_walk()` is an option, it essentially | 821 | For those cases where ``unlazy_walk()`` is an option, it essentially |
776 | takes a reference on each of the pointers that it holds (vfsmount, | 822 | takes a reference on each of the pointers that it holds (vfsmount, |
777 | dentry, and possibly some symbolic links) and then verifies that the | 823 | dentry, and possibly some symbolic links) and then verifies that the |
778 | relevant seqlocks have not been changed. If there have been changes, | 824 | relevant seqlocks have not been changed. If there have been changes, |
779 | it, too, aborts with `-ECHILD`, otherwise the transition to REF-walk | 825 | it, too, aborts with ``-ECHILD``, otherwise the transition to REF-walk |
780 | has been a success and the lookup process continues. | 826 | has been a success and the lookup process continues. |
781 | 827 | ||
782 | Taking a reference on those pointers is not quite as simple as just | 828 | Taking a reference on those pointers is not quite as simple as just |
783 | incrementing a counter. That works to take a second reference if you | 829 | incrementing a counter. That works to take a second reference if you |
784 | already have one (often indirectly through another object), but it | 830 | already have one (often indirectly through another object), but it |
785 | isn't sufficient if you don't actually have a counted reference at | 831 | isn't sufficient if you don't actually have a counted reference at |
786 | all. For `dentry->d_lockref`, it is safe to increment the reference | 832 | all. For ``dentry->d_lockref``, it is safe to increment the reference |
787 | counter to get a reference unless it has been explicitly marked as | 833 | counter to get a reference unless it has been explicitly marked as |
788 | "dead" which involves setting the counter to `-128`. | 834 | "dead" which involves setting the counter to ``-128``. |
789 | `lockref_get_not_dead()` achieves this. | 835 | ``lockref_get_not_dead()`` achieves this. |
790 | 836 | ||
791 | For `mnt->mnt_count` it is safe to take a reference as long as | 837 | For ``mnt->mnt_count`` it is safe to take a reference as long as |
792 | `mount_lock` is then used to validate the reference. If that | 838 | ``mount_lock`` is then used to validate the reference. If that |
793 | validation fails, it may *not* be safe to just drop that reference in | 839 | validation fails, it may *not* be safe to just drop that reference in |
794 | the standard way of calling `mnt_put()` - an unmount may have | 840 | the standard way of calling ``mnt_put()`` - an unmount may have |
795 | progressed too far. So the code in `legitimize_mnt()`, when it | 841 | progressed too far. So the code in ``legitimize_mnt()``, when it |
796 | finds that the reference it got might not be safe, checks the | 842 | finds that the reference it got might not be safe, checks the |
797 | `MNT_SYNC_UMOUNT` flag to determine if a simple `mnt_put()` is | 843 | ``MNT_SYNC_UMOUNT`` flag to determine if a simple ``mnt_put()`` is |
798 | correct, or if it should just decrement the count and pretend none of | 844 | correct, or if it should just decrement the count and pretend none of |
799 | this ever happened. | 845 | this ever happened. |
800 | 846 | ||
801 | Taking care in filesystems | 847 | Taking care in filesystems |
802 | --------------------------- | 848 | -------------------------- |
803 | 849 | ||
804 | RCU-walk depends almost entirely on cached information and often will | 850 | RCU-walk depends almost entirely on cached information and often will |
805 | not call into the filesystem at all. However there are two places, | 851 | not call into the filesystem at all. However there are two places, |
@@ -809,26 +855,26 @@ careful. | |||
809 | 855 | ||
810 | If the filesystem has non-standard permission-checking requirements - | 856 | If the filesystem has non-standard permission-checking requirements - |
811 | such as a networked filesystem which may need to check with the server | 857 | such as a networked filesystem which may need to check with the server |
812 | - the `i_op->permission` interface might be called during RCU-walk. | 858 | - the ``i_op->permission`` interface might be called during RCU-walk. |
813 | In this case an extra "`MAY_NOT_BLOCK`" flag is passed so that it | 859 | In this case an extra "``MAY_NOT_BLOCK``" flag is passed so that it |
814 | knows not to sleep, but to return `-ECHILD` if it cannot complete | 860 | knows not to sleep, but to return ``-ECHILD`` if it cannot complete |
815 | promptly. `i_op->permission` is given the inode pointer, not the | 861 | promptly. ``i_op->permission`` is given the inode pointer, not the |
816 | dentry, so it doesn't need to worry about further consistency checks. | 862 | dentry, so it doesn't need to worry about further consistency checks. |
817 | However if it accesses any other filesystem data structures, it must | 863 | However if it accesses any other filesystem data structures, it must |
818 | ensure they are safe to be accessed with only the `rcu_read_lock()` | 864 | ensure they are safe to be accessed with only the ``rcu_read_lock()`` |
819 | held. This typically means they must be freed using `kfree_rcu()` or | 865 | held. This typically means they must be freed using ``kfree_rcu()`` or |
820 | similar. | 866 | similar. |
821 | 867 | ||
822 | [`READ_ONCE()`]: https://lwn.net/Articles/624126/ | 868 | .. _READ_ONCE: https://lwn.net/Articles/624126/ |
823 | 869 | ||
824 | If the filesystem may need to revalidate dcache entries, then | 870 | If the filesystem may need to revalidate dcache entries, then |
825 | `d_op->d_revalidate` may be called in RCU-walk too. This interface | 871 | ``d_op->d_revalidate`` may be called in RCU-walk too. This interface |
826 | *is* passed the dentry but does not have access to the `inode` or the | 872 | *is* passed the dentry but does not have access to the ``inode`` or the |
827 | `seq` number from the `nameidata`, so it needs to be extra careful | 873 | ``seq`` number from the ``nameidata``, so it needs to be extra careful |
828 | when accessing fields in the dentry. This "extra care" typically | 874 | when accessing fields in the dentry. This "extra care" typically |
829 | involves using [`READ_ONCE()`] to access fields, and verifying the | 875 | involves using `READ_ONCE() <READ_ONCE_>`_ to access fields, and verifying the |
830 | result is not NULL before using it. This pattern can be seen in | 876 | result is not NULL before using it. This pattern can be seen in |
831 | `nfs_lookup_revalidate()`. | 877 | ``nfs_lookup_revalidate()``. |
832 | 878 | ||
833 | A pair of patterns | 879 | A pair of patterns |
834 | ------------------ | 880 | ------------------ |
@@ -839,14 +885,14 @@ being aware of. | |||
839 | 885 | ||
840 | The first is "try quickly and check, if that fails try slowly". We | 886 | The first is "try quickly and check, if that fails try slowly". We |
841 | can see that in the high-level approach of first trying RCU-walk and | 887 | can see that in the high-level approach of first trying RCU-walk and |
842 | then trying REF-walk, and in places where `unlazy_walk()` is used to | 888 | then trying REF-walk, and in places where ``unlazy_walk()`` is used to |
843 | switch to REF-walk for the rest of the path. We also saw it earlier | 889 | switch to REF-walk for the rest of the path. We also saw it earlier |
844 | in `dget_parent()` when following a "`..`" link. It tries a quick way | 890 | in ``dget_parent()`` when following a "``..``" link. It tries a quick way |
845 | to get a reference, then falls back to taking locks if needed. | 891 | to get a reference, then falls back to taking locks if needed. |
846 | 892 | ||
847 | The second pattern is "try quickly and check, if that fails try | 893 | The second pattern is "try quickly and check, if that fails try |
848 | again - repeatedly". This is seen with the use of `rename_lock` and | 894 | again - repeatedly". This is seen with the use of ``rename_lock`` and |
849 | `mount_lock` in REF-walk. RCU-walk doesn't make use of this pattern - | 895 | ``mount_lock`` in REF-walk. RCU-walk doesn't make use of this pattern - |
850 | if anything goes wrong it is much safer to just abort and try a more | 896 | if anything goes wrong it is much safer to just abort and try a more |
851 | sedate approach. | 897 | sedate approach. |
852 | 898 | ||
@@ -882,8 +928,8 @@ Conceptually, symbolic links could be handled by editing the path. If | |||
882 | a component name refers to a symbolic link, then that component is | 928 | a component name refers to a symbolic link, then that component is |
883 | replaced by the body of the link and, if that body starts with a '/', | 929 | replaced by the body of the link and, if that body starts with a '/', |
884 | then all preceding parts of the path are discarded. This is what the | 930 | then all preceding parts of the path are discarded. This is what the |
885 | "`readlink -f`" command does, though it also edits out "`.`" and | 931 | "``readlink -f``" command does, though it also edits out "``.``" and |
886 | "`..`" components. | 932 | "``..``" components. |
887 | 933 | ||
888 | Directly editing the path string is not really necessary when looking | 934 | Directly editing the path string is not really necessary when looking |
889 | up a path, and discarding early components is pointless as they aren't | 935 | up a path, and discarding early components is pointless as they aren't |
@@ -899,19 +945,19 @@ There are two reasons for placing limits on how many symlinks can | |||
899 | occur in a single path lookup. The most obvious is to avoid loops. | 945 | occur in a single path lookup. The most obvious is to avoid loops. |
900 | If a symlink referred to itself either directly or through | 946 | If a symlink referred to itself either directly or through |
901 | intermediaries, then following the symlink can never complete | 947 | intermediaries, then following the symlink can never complete |
902 | successfully - the error `ELOOP` must be returned. Loops can be | 948 | successfully - the error ``ELOOP`` must be returned. Loops can be |
903 | detected without imposing limits, but limits are the simplest solution | 949 | detected without imposing limits, but limits are the simplest solution |
904 | and, given the second reason for restriction, quite sufficient. | 950 | and, given the second reason for restriction, quite sufficient. |
905 | 951 | ||
906 | [outlined recently]: http://thread.gmane.org/gmane.linux.kernel/1934390/focus=1934550 | 952 | .. _outlined recently: http://thread.gmane.org/gmane.linux.kernel/1934390/focus=1934550 |
907 | 953 | ||
908 | The second reason was [outlined recently] by Linus: | 954 | The second reason was `outlined recently`_ by Linus: |
909 | 955 | ||
910 | > Because it's a latency and DoS issue too. We need to react well to | 956 | Because it's a latency and DoS issue too. We need to react well to |
911 | > true loops, but also to "very deep" non-loops. It's not about memory | 957 | true loops, but also to "very deep" non-loops. It's not about memory |
912 | > use, it's about users triggering unreasonable CPU resources. | 958 | use, it's about users triggering unreasonable CPU resources. |
913 | 959 | ||
914 | Linux imposes a limit on the length of any pathname: `PATH_MAX`, which | 960 | Linux imposes a limit on the length of any pathname: ``PATH_MAX``, which |
915 | is 4096. There are a number of reasons for this limit; not letting the | 961 | is 4096. There are a number of reasons for this limit; not letting the |
916 | kernel spend too much time on just one path is one of them. With | 962 | kernel spend too much time on just one path is one of them. With |
917 | symbolic links you can effectively generate much longer paths so some | 963 | symbolic links you can effectively generate much longer paths so some |
@@ -921,7 +967,7 @@ further limit of eight on the maximum depth of recursion, but that was | |||
921 | raised to 40 when a separate stack was implemented, so there is now | 967 | raised to 40 when a separate stack was implemented, so there is now |
922 | just the one limit. | 968 | just the one limit. |
923 | 969 | ||
924 | The `nameidata` structure that we met in an earlier article contains a | 970 | The ``nameidata`` structure that we met in an earlier article contains a |
925 | small stack that can be used to store the remaining part of up to two | 971 | small stack that can be used to store the remaining part of up to two |
926 | symlinks. In many cases this will be sufficient. If it isn't, a | 972 | symlinks. In many cases this will be sufficient. If it isn't, a |
927 | separate stack is allocated with room for 40 symlinks. Pathname | 973 | separate stack is allocated with room for 40 symlinks. Pathname |
@@ -941,13 +987,13 @@ to external storage. It is particularly important for RCU-walk to be | |||
941 | able to find and temporarily hold onto these cached entries, so that | 987 | able to find and temporarily hold onto these cached entries, so that |
942 | it doesn't need to drop down into REF-walk. | 988 | it doesn't need to drop down into REF-walk. |
943 | 989 | ||
944 | [object-oriented design pattern]: https://lwn.net/Articles/446317/ | 990 | .. _object-oriented design pattern: https://lwn.net/Articles/446317/ |
945 | 991 | ||
946 | While each filesystem is free to make its own choice, symlinks are | 992 | While each filesystem is free to make its own choice, symlinks are |
947 | typically stored in one of two places. Short symlinks are often | 993 | typically stored in one of two places. Short symlinks are often |
948 | stored directly in the inode. When a filesystem allocates a `struct | 994 | stored directly in the inode. When a filesystem allocates a ``struct |
949 | inode` it typically allocates extra space to store private data (a | 995 | inode`` it typically allocates extra space to store private data (a |
950 | common [object-oriented design pattern] in the kernel). This will | 996 | common `object-oriented design pattern`_ in the kernel). This will |
951 | sometimes include space for a symlink. The other common location is | 997 | sometimes include space for a symlink. The other common location is |
952 | in the page cache, which normally stores the content of files. The | 998 | in the page cache, which normally stores the content of files. The |
953 | pathname in a symlink can be seen as the content of that symlink and | 999 | pathname in a symlink can be seen as the content of that symlink and |
@@ -962,13 +1008,13 @@ the inode which, itself, is protected by RCU or by a counted reference | |||
962 | on the dentry. This means that the mechanisms that pathname lookup | 1008 | on the dentry. This means that the mechanisms that pathname lookup |
963 | uses to access the dcache and icache (inode cache) safely are quite | 1009 | uses to access the dcache and icache (inode cache) safely are quite |
964 | sufficient for accessing some cached symlinks safely. In these cases, | 1010 | sufficient for accessing some cached symlinks safely. In these cases, |
965 | the `i_link` pointer in the inode is set to point to wherever the | 1011 | the ``i_link`` pointer in the inode is set to point to wherever the |
966 | symlink is stored and it can be accessed directly whenever needed. | 1012 | symlink is stored and it can be accessed directly whenever needed. |
967 | 1013 | ||
968 | When the symlink is stored in the page cache or elsewhere, the | 1014 | When the symlink is stored in the page cache or elsewhere, the |
969 | situation is not so straightforward. A reference on a dentry or even | 1015 | situation is not so straightforward. A reference on a dentry or even |
970 | on an inode does not imply any reference on cached pages of that | 1016 | on an inode does not imply any reference on cached pages of that |
971 | inode, and even an `rcu_read_lock()` is not sufficient to ensure that | 1017 | inode, and even an ``rcu_read_lock()`` is not sufficient to ensure that |
972 | a page will not disappear. So for these symlinks the pathname lookup | 1018 | a page will not disappear. So for these symlinks the pathname lookup |
973 | code needs to ask the filesystem to provide a stable reference and, | 1019 | code needs to ask the filesystem to provide a stable reference and, |
974 | significantly, needs to release that reference when it is finished | 1020 | significantly, needs to release that reference when it is finished |
@@ -978,48 +1024,48 @@ Taking a reference to a cache page is often possible even in RCU-walk | |||
978 | mode. It does require making changes to memory, which is best avoided, | 1024 | mode. It does require making changes to memory, which is best avoided, |
979 | but that isn't necessarily a big cost and it is better than dropping | 1025 | but that isn't necessarily a big cost and it is better than dropping |
980 | out of RCU-walk mode completely. Even filesystems that allocate | 1026 | out of RCU-walk mode completely. Even filesystems that allocate |
981 | space to copy the symlink into can use `GFP_ATOMIC` to often successfully | 1027 | space to copy the symlink into can use ``GFP_ATOMIC`` to often successfully |
982 | allocate memory without the need to drop out of RCU-walk. If a | 1028 | allocate memory without the need to drop out of RCU-walk. If a |
983 | filesystem cannot successfully get a reference in RCU-walk mode, it | 1029 | filesystem cannot successfully get a reference in RCU-walk mode, it |
984 | must return `-ECHILD` and `unlazy_walk()` will be called to return to | 1030 | must return ``-ECHILD`` and ``unlazy_walk()`` will be called to return to |
985 | REF-walk mode in which the filesystem is allowed to sleep. | 1031 | REF-walk mode in which the filesystem is allowed to sleep. |
986 | 1032 | ||
987 | The place for all this to happen is the `i_op->follow_link()` inode | 1033 | The place for all this to happen is the ``i_op->follow_link()`` inode |
988 | method. In the present mainline code this is never actually called in | 1034 | method. In the present mainline code this is never actually called in |
989 | RCU-walk mode as the rewrite is not quite complete. It is likely that | 1035 | RCU-walk mode as the rewrite is not quite complete. It is likely that |
990 | in a future release this method will be passed an `inode` pointer when | 1036 | in a future release this method will be passed an ``inode`` pointer when |
991 | called in RCU-walk mode so it both (1) knows to be careful, and (2) has the | 1037 | called in RCU-walk mode so it both (1) knows to be careful, and (2) has the |
992 | validated pointer. Much like the `i_op->permission()` method we | 1038 | validated pointer. Much like the ``i_op->permission()`` method we |
993 | looked at previously, `->follow_link()` would need to be careful that | 1039 | looked at previously, ``->follow_link()`` would need to be careful that |
994 | all the data structures it references are safe to be accessed while | 1040 | all the data structures it references are safe to be accessed while |
995 | holding no counted reference, only the RCU lock. Though getting a | 1041 | holding no counted reference, only the RCU lock. Though getting a |
996 | reference with `->follow_link()` is not yet done in RCU-walk mode, the | 1042 | reference with ``->follow_link()`` is not yet done in RCU-walk mode, the |
997 | code is ready to release the reference when that does happen. | 1043 | code is ready to release the reference when that does happen. |
998 | 1044 | ||
999 | This need to drop the reference to a symlink adds significant | 1045 | This need to drop the reference to a symlink adds significant |
1000 | complexity. It requires a reference to the inode so that the | 1046 | complexity. It requires a reference to the inode so that the |
1001 | `i_op->put_link()` inode operation can be called. In REF-walk, that | 1047 | ``i_op->put_link()`` inode operation can be called. In REF-walk, that |
1002 | reference is kept implicitly through a reference to the dentry, so | 1048 | reference is kept implicitly through a reference to the dentry, so |
1003 | keeping the `struct path` of the symlink is easiest. For RCU-walk, | 1049 | keeping the ``struct path`` of the symlink is easiest. For RCU-walk, |
1004 | the pointer to the inode is kept separately. To allow switching from | 1050 | the pointer to the inode is kept separately. To allow switching from |
1005 | RCU-walk back to REF-walk in the middle of processing nested symlinks | 1051 | RCU-walk back to REF-walk in the middle of processing nested symlinks |
1006 | we also need the seq number for the dentry so we can confirm that | 1052 | we also need the seq number for the dentry so we can confirm that |
1007 | switching back was safe. | 1053 | switching back was safe. |
1008 | 1054 | ||
1009 | Finally, when providing a reference to a symlink, the filesystem also | 1055 | Finally, when providing a reference to a symlink, the filesystem also |
1010 | provides an opaque "cookie" that must be passed to `->put_link()` so that it | 1056 | provides an opaque "cookie" that must be passed to ``->put_link()`` so that it |
1011 | knows what to free. This might be the allocated memory area, or a | 1057 | knows what to free. This might be the allocated memory area, or a |
1012 | pointer to the `struct page` in the page cache, or something else | 1058 | pointer to the ``struct page`` in the page cache, or something else |
1013 | completely. Only the filesystem knows what it is. | 1059 | completely. Only the filesystem knows what it is. |
1014 | 1060 | ||
1015 | In order for the reference to each symlink to be dropped when the walk completes, | 1061 | In order for the reference to each symlink to be dropped when the walk completes, |
1016 | whether in RCU-walk or REF-walk, the symlink stack needs to contain, | 1062 | whether in RCU-walk or REF-walk, the symlink stack needs to contain, |
1017 | along with the path remnants: | 1063 | along with the path remnants: |
1018 | 1064 | ||
1019 | - the `struct path` to provide a reference to the inode in REF-walk | 1065 | - the ``struct path`` to provide a reference to the inode in REF-walk |
1020 | - the `struct inode *` to provide a reference to the inode in RCU-walk | 1066 | - the ``struct inode *`` to provide a reference to the inode in RCU-walk |
1021 | - the `seq` to allow the path to be safely switched from RCU-walk to REF-walk | 1067 | - the ``seq`` to allow the path to be safely switched from RCU-walk to REF-walk |
1022 | - the `cookie` that tells `->put_path()` what to put. | 1068 | - the ``cookie`` that tells ``->put_path()`` what to put. |
1023 | 1069 | ||
1024 | This means that each entry in the symlink stack needs to hold five | 1070 | This means that each entry in the symlink stack needs to hold five |
1025 | pointers and an integer instead of just one pointer (the path | 1071 | pointers and an integer instead of just one pointer (the path |
@@ -1028,28 +1074,28 @@ with 40 entries it adds up to 1600 bytes total, which is less than | |||
1028 | half a page. So it might seem like a lot, but is by no means | 1074 | half a page. So it might seem like a lot, but is by no means |
1029 | excessive. | 1075 | excessive. |
1030 | 1076 | ||
1031 | Note that, in a given stack frame, the path remnant (`name`) is not | 1077 | Note that, in a given stack frame, the path remnant (``name``) is not |
1032 | part of the symlink that the other fields refer to. It is the remnant | 1078 | part of the symlink that the other fields refer to. It is the remnant |
1033 | to be followed once that symlink has been fully parsed. | 1079 | to be followed once that symlink has been fully parsed. |
1034 | 1080 | ||
1035 | Following the symlink | 1081 | Following the symlink |
1036 | --------------------- | 1082 | --------------------- |
1037 | 1083 | ||
1038 | The main loop in `link_path_walk()` iterates seamlessly over all | 1084 | The main loop in ``link_path_walk()`` iterates seamlessly over all |
1039 | components in the path and all of the non-final symlinks. As symlinks | 1085 | components in the path and all of the non-final symlinks. As symlinks |
1040 | are processed, the `name` pointer is adjusted to point to a new | 1086 | are processed, the ``name`` pointer is adjusted to point to a new |
1041 | symlink, or is restored from the stack, so that much of the loop | 1087 | symlink, or is restored from the stack, so that much of the loop |
1042 | doesn't need to notice. Getting this `name` variable on and off the | 1088 | doesn't need to notice. Getting this ``name`` variable on and off the |
1043 | stack is very straightforward; pushing and popping the references is | 1089 | stack is very straightforward; pushing and popping the references is |
1044 | a little more complex. | 1090 | a little more complex. |
1045 | 1091 | ||
1046 | When a symlink is found, `walk_component()` returns the value `1` | 1092 | When a symlink is found, ``walk_component()`` returns the value ``1`` |
1047 | (`0` is returned for any other sort of success, and a negative number | 1093 | (``0`` is returned for any other sort of success, and a negative number |
1048 | is, as usual, an error indicator). This causes `get_link()` to be | 1094 | is, as usual, an error indicator). This causes ``get_link()`` to be |
1049 | called; it then gets the link from the filesystem. Providing that | 1095 | called; it then gets the link from the filesystem. Providing that |
1050 | operation is successful, the old path `name` is placed on the stack, | 1096 | operation is successful, the old path ``name`` is placed on the stack, |
1051 | and the new value is used as the `name` for a while. When the end of | 1097 | and the new value is used as the ``name`` for a while. When the end of |
1052 | the path is found (i.e. `*name` is `'\0'`) the old `name` is restored | 1098 | the path is found (i.e. ``*name`` is ``'\0'``) the old ``name`` is restored |
1053 | off the stack and path walking continues. | 1099 | off the stack and path walking continues. |
1054 | 1100 | ||
1055 | Pushing and popping the reference pointers (inode, cookie, etc.) is more | 1101 | Pushing and popping the reference pointers (inode, cookie, etc.) is more |
@@ -1060,113 +1106,114 @@ the symlink-just-found to avoid leaving empty path remnants that would | |||
1060 | just get in the way. | 1106 | just get in the way. |
1061 | 1107 | ||
1062 | It is most convenient to push the new symlink references onto the | 1108 | It is most convenient to push the new symlink references onto the |
1063 | stack in `walk_component()` immediately when the symlink is found; | 1109 | stack in ``walk_component()`` immediately when the symlink is found; |
1064 | `walk_component()` is also the last piece of code that needs to look at the | 1110 | ``walk_component()`` is also the last piece of code that needs to look at the |
1065 | old symlink as it walks that last component. So it is quite | 1111 | old symlink as it walks that last component. So it is quite |
1066 | convenient for `walk_component()` to release the old symlink and pop | 1112 | convenient for ``walk_component()`` to release the old symlink and pop |
1067 | the references just before pushing the reference information for the | 1113 | the references just before pushing the reference information for the |
1068 | new symlink. It is guided in this by two flags; `WALK_GET`, which | 1114 | new symlink. It is guided in this by two flags; ``WALK_GET``, which |
1069 | gives it permission to follow a symlink if it finds one, and | 1115 | gives it permission to follow a symlink if it finds one, and |
1070 | `WALK_PUT`, which tells it to release the current symlink after it has been | 1116 | ``WALK_PUT``, which tells it to release the current symlink after it has been |
1071 | followed. `WALK_PUT` is tested first, leading to a call to | 1117 | followed. ``WALK_PUT`` is tested first, leading to a call to |
1072 | `put_link()`. `WALK_GET` is tested subsequently (by | 1118 | ``put_link()``. ``WALK_GET`` is tested subsequently (by |
1073 | `should_follow_link()`) leading to a call to `pick_link()` which sets | 1119 | ``should_follow_link()``) leading to a call to ``pick_link()`` which sets |
1074 | up the stack frame. | 1120 | up the stack frame. |
1075 | 1121 | ||
1076 | ### Symlinks with no final component ### | 1122 | Symlinks with no final component |
1123 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
1077 | 1124 | ||
1078 | A pair of special-case symlinks deserve a little further explanation. | 1125 | A pair of special-case symlinks deserve a little further explanation. |
1079 | Both result in a new `struct path` (with mount and dentry) being set | 1126 | Both result in a new ``struct path`` (with mount and dentry) being set |
1080 | up in the `nameidata`, and result in `get_link()` returning `NULL`. | 1127 | up in the ``nameidata``, and result in ``get_link()`` returning ``NULL``. |
1081 | 1128 | ||
1082 | The more obvious case is a symlink to "`/`". All symlinks starting | 1129 | The more obvious case is a symlink to "``/``". All symlinks starting |
1083 | with "`/`" are detected in `get_link()` which resets the `nameidata` | 1130 | with "``/``" are detected in ``get_link()`` which resets the ``nameidata`` |
1084 | to point to the effective filesystem root. If the symlink only | 1131 | to point to the effective filesystem root. If the symlink only |
1085 | contains "`/`" then there is nothing more to do, no components at all, | 1132 | contains "``/``" then there is nothing more to do, no components at all, |
1086 | so `NULL` is returned to indicate that the symlink can be released and | 1133 | so ``NULL`` is returned to indicate that the symlink can be released and |
1087 | the stack frame discarded. | 1134 | the stack frame discarded. |
1088 | 1135 | ||
1089 | The other case involves things in `/proc` that look like symlinks but | 1136 | The other case involves things in ``/proc`` that look like symlinks but |
1090 | aren't really. | 1137 | aren't really:: |
1091 | 1138 | ||
1092 | > $ ls -l /proc/self/fd/1 | 1139 | $ ls -l /proc/self/fd/1 |
1093 | > lrwx------ 1 neilb neilb 64 Jun 13 10:19 /proc/self/fd/1 -> /dev/pts/4 | 1140 | lrwx------ 1 neilb neilb 64 Jun 13 10:19 /proc/self/fd/1 -> /dev/pts/4 |
1094 | 1141 | ||
1095 | Every open file descriptor in any process is represented in `/proc` by | 1142 | Every open file descriptor in any process is represented in ``/proc`` by |
1096 | something that looks like a symlink. It is really a reference to the | 1143 | something that looks like a symlink. It is really a reference to the |
1097 | target file, not just the name of it. When you `readlink` these | 1144 | target file, not just the name of it. When you ``readlink`` these |
1098 | objects you get a name that might refer to the same file - unless it | 1145 | objects you get a name that might refer to the same file - unless it |
1099 | has been unlinked or mounted over. When `walk_component()` follows | 1146 | has been unlinked or mounted over. When ``walk_component()`` follows |
1100 | one of these, the `->follow_link()` method in "procfs" doesn't return | 1147 | one of these, the ``->follow_link()`` method in "procfs" doesn't return |
1101 | a string name, but instead calls `nd_jump_link()` which updates the | 1148 | a string name, but instead calls ``nd_jump_link()`` which updates the |
1102 | `nameidata` in place to point to that target. `->follow_link()` then | 1149 | ``nameidata`` in place to point to that target. ``->follow_link()`` then |
1103 | returns `NULL`. Again there is no final component and `get_link()` | 1150 | returns ``NULL``. Again there is no final component and ``get_link()`` |
1104 | reports this by leaving the `last_type` field of `nameidata` as | 1151 | reports this by leaving the ``last_type`` field of ``nameidata`` as |
1105 | `LAST_BIND`. | 1152 | ``LAST_BIND``. |
1106 | 1153 | ||
1107 | Following the symlink in the final component | 1154 | Following the symlink in the final component |
1108 | -------------------------------------------- | 1155 | -------------------------------------------- |
1109 | 1156 | ||
1110 | All this leads to `link_path_walk()` walking down every component, and | 1157 | All this leads to ``link_path_walk()`` walking down every component, and |
1111 | following all symbolic links it finds, until it reaches the final | 1158 | following all symbolic links it finds, until it reaches the final |
1112 | component. This is just returned in the `last` field of `nameidata`. | 1159 | component. This is just returned in the ``last`` field of ``nameidata``. |
1113 | For some callers, this is all they need; they want to create that | 1160 | For some callers, this is all they need; they want to create that |
1114 | `last` name if it doesn't exist or give an error if it does. Other | 1161 | ``last`` name if it doesn't exist or give an error if it does. Other |
1115 | callers will want to follow a symlink if one is found, and possibly | 1162 | callers will want to follow a symlink if one is found, and possibly |
1116 | apply special handling to the last component of that symlink, rather | 1163 | apply special handling to the last component of that symlink, rather |
1117 | than just the last component of the original file name. These callers | 1164 | than just the last component of the original file name. These callers |
1118 | potentially need to call `link_path_walk()` again and again on | 1165 | potentially need to call ``link_path_walk()`` again and again on |
1119 | successive symlinks until one is found that doesn't point to another | 1166 | successive symlinks until one is found that doesn't point to another |
1120 | symlink. | 1167 | symlink. |
1121 | 1168 | ||
1122 | This case is handled by the relevant caller of `link_path_walk()`, such as | 1169 | This case is handled by the relevant caller of ``link_path_walk()``, such as |
1123 | `path_lookupat()` using a loop that calls `link_path_walk()`, and then | 1170 | ``path_lookupat()`` using a loop that calls ``link_path_walk()``, and then |
1124 | handles the final component. If the final component is a symlink | 1171 | handles the final component. If the final component is a symlink |
1125 | that needs to be followed, then `trailing_symlink()` is called to set | 1172 | that needs to be followed, then ``trailing_symlink()`` is called to set |
1126 | things up properly and the loop repeats, calling `link_path_walk()` | 1173 | things up properly and the loop repeats, calling ``link_path_walk()`` |
1127 | again. This could loop as many as 40 times if the last component of | 1174 | again. This could loop as many as 40 times if the last component of |
1128 | each symlink is another symlink. | 1175 | each symlink is another symlink. |
1129 | 1176 | ||
1130 | The various functions that examine the final component and possibly | 1177 | The various functions that examine the final component and possibly |
1131 | report that it is a symlink are `lookup_last()`, `mountpoint_last()` | 1178 | report that it is a symlink are ``lookup_last()``, ``mountpoint_last()`` |
1132 | and `do_last()`, each of which use the same convention as | 1179 | and ``do_last()``, each of which use the same convention as |
1133 | `walk_component()` of returning `1` if a symlink was found that needs | 1180 | ``walk_component()`` of returning ``1`` if a symlink was found that needs |
1134 | to be followed. | 1181 | to be followed. |
1135 | 1182 | ||
1136 | Of these, `do_last()` is the most interesting as it is used for | 1183 | Of these, ``do_last()`` is the most interesting as it is used for |
1137 | opening a file. Part of `do_last()` runs with `i_mutex` held and this | 1184 | opening a file. Part of ``do_last()`` runs with ``i_rwsem`` held and this |
1138 | part is in a separate function: `lookup_open()`. | 1185 | part is in a separate function: ``lookup_open()``. |
1139 | 1186 | ||
1140 | Explaining `do_last()` completely is beyond the scope of this article, | 1187 | Explaining ``do_last()`` completely is beyond the scope of this article, |
1141 | but a few highlights should help those interested in exploring the | 1188 | but a few highlights should help those interested in exploring the |
1142 | code. | 1189 | code. |
1143 | 1190 | ||
1144 | 1. Rather than just finding the target file, `do_last()` needs to open | 1191 | 1. Rather than just finding the target file, ``do_last()`` needs to open |
1145 | it. If the file was found in the dcache, then `vfs_open()` is used for | 1192 | it. If the file was found in the dcache, then ``vfs_open()`` is used for |
1146 | this. If not, then `lookup_open()` will either call `atomic_open()` (if | 1193 | this. If not, then ``lookup_open()`` will either call ``atomic_open()`` (if |
1147 | the filesystem provides it) to combine the final lookup with the open, or | 1194 | the filesystem provides it) to combine the final lookup with the open, or |
1148 | will perform the separate `lookup_real()` and `vfs_create()` steps | 1195 | will perform the separate ``lookup_real()`` and ``vfs_create()`` steps |
1149 | directly. In the later case the actual "open" of this newly found or | 1196 | directly. In the later case the actual "open" of this newly found or |
1150 | created file will be performed by `vfs_open()`, just as if the name | 1197 | created file will be performed by ``vfs_open()``, just as if the name |
1151 | were found in the dcache. | 1198 | were found in the dcache. |
1152 | 1199 | ||
1153 | 2. `vfs_open()` can fail with `-EOPENSTALE` if the cached information | 1200 | 2. ``vfs_open()`` can fail with ``-EOPENSTALE`` if the cached information |
1154 | wasn't quite current enough. Rather than restarting the lookup from | 1201 | wasn't quite current enough. Rather than restarting the lookup from |
1155 | the top with `LOOKUP_REVAL` set, `lookup_open()` is called instead, | 1202 | the top with ``LOOKUP_REVAL`` set, ``lookup_open()`` is called instead, |
1156 | giving the filesystem a chance to resolve small inconsistencies. | 1203 | giving the filesystem a chance to resolve small inconsistencies. |
1157 | If that doesn't work, only then is the lookup restarted from the top. | 1204 | If that doesn't work, only then is the lookup restarted from the top. |
1158 | 1205 | ||
1159 | 3. An open with O_CREAT **does** follow a symlink in the final component, | 1206 | 3. An open with O_CREAT **does** follow a symlink in the final component, |
1160 | unlike other creation system calls (like `mkdir`). So the sequence: | 1207 | unlike other creation system calls (like ``mkdir``). So the sequence:: |
1161 | 1208 | ||
1162 | > ln -s bar /tmp/foo | 1209 | ln -s bar /tmp/foo |
1163 | > echo hello > /tmp/foo | 1210 | echo hello > /tmp/foo |
1164 | 1211 | ||
1165 | will create a file called `/tmp/bar`. This is not permitted if | 1212 | will create a file called ``/tmp/bar``. This is not permitted if |
1166 | `O_EXCL` is set but otherwise is handled for an O_CREAT open much | 1213 | ``O_EXCL`` is set but otherwise is handled for an O_CREAT open much |
1167 | like for a non-creating open: `should_follow_link()` returns `1`, and | 1214 | like for a non-creating open: ``should_follow_link()`` returns ``1``, and |
1168 | so does `do_last()` so that `trailing_symlink()` gets called and the | 1215 | so does ``do_last()`` so that ``trailing_symlink()`` gets called and the |
1169 | open process continues on the symlink that was found. | 1216 | open process continues on the symlink that was found. |
1170 | 1217 | ||
1171 | Updating the access time | 1218 | Updating the access time |
1172 | ------------------------ | 1219 | ------------------------ |
@@ -1180,110 +1227,112 @@ footprints are best kept to a minimum. | |||
1180 | One other place where walking down a symlink can involve leaving | 1227 | One other place where walking down a symlink can involve leaving |
1181 | footprints in a way that doesn't affect directories is in updating access times. | 1228 | footprints in a way that doesn't affect directories is in updating access times. |
1182 | In Unix (and Linux) every filesystem object has a "last accessed | 1229 | In Unix (and Linux) every filesystem object has a "last accessed |
1183 | time", or "`atime`". Passing through a directory to access a file | 1230 | time", or "``atime``". Passing through a directory to access a file |
1184 | within is not considered to be an access for the purposes of | 1231 | within is not considered to be an access for the purposes of |
1185 | `atime`; only listing the contents of a directory can update its `atime`. | 1232 | ``atime``; only listing the contents of a directory can update its ``atime``. |
1186 | Symlinks are different it seems. Both reading a symlink (with `readlink()`) | 1233 | Symlinks are different it seems. Both reading a symlink (with ``readlink()``) |
1187 | and looking up a symlink on the way to some other destination can | 1234 | and looking up a symlink on the way to some other destination can |
1188 | update the atime on that symlink. | 1235 | update the atime on that symlink. |
1189 | 1236 | ||
1190 | [clearest statement]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_08 | 1237 | .. _clearest statement: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_08 |
1191 | 1238 | ||
1192 | It is not clear why this is the case; POSIX has little to say on the | 1239 | It is not clear why this is the case; POSIX has little to say on the |
1193 | subject. The [clearest statement] is that, if a particular implementation | 1240 | subject. The `clearest statement`_ is that, if a particular implementation |
1194 | updates a timestamp in a place not specified by POSIX, this must be | 1241 | updates a timestamp in a place not specified by POSIX, this must be |
1195 | documented "except that any changes caused by pathname resolution need | 1242 | documented "except that any changes caused by pathname resolution need |
1196 | not be documented". This seems to imply that POSIX doesn't really | 1243 | not be documented". This seems to imply that POSIX doesn't really |
1197 | care about access-time updates during pathname lookup. | 1244 | care about access-time updates during pathname lookup. |
1198 | 1245 | ||
1199 | [Linux 1.3.87]: https://git.kernel.org/cgit/linux/kernel/git/history/history.git/diff/fs/ext2/symlink.c?id=f806c6db77b8eaa6e00dcfb6b567706feae8dbb8 | 1246 | .. _Linux 1.3.87: https://git.kernel.org/cgit/linux/kernel/git/history/history.git/diff/fs/ext2/symlink.c?id=f806c6db77b8eaa6e00dcfb6b567706feae8dbb8 |
1200 | 1247 | ||
1201 | An examination of history shows that prior to [Linux 1.3.87], the ext2 | 1248 | An examination of history shows that prior to `Linux 1.3.87`_, the ext2 |
1202 | filesystem, at least, didn't update atime when following a link. | 1249 | filesystem, at least, didn't update atime when following a link. |
1203 | Unfortunately we have no record of why that behavior was changed. | 1250 | Unfortunately we have no record of why that behavior was changed. |
1204 | 1251 | ||
1205 | In any case, access time must now be updated and that operation can be | 1252 | In any case, access time must now be updated and that operation can be |
1206 | quite complex. Trying to stay in RCU-walk while doing it is best | 1253 | quite complex. Trying to stay in RCU-walk while doing it is best |
1207 | avoided. Fortunately it is often permitted to skip the `atime` | 1254 | avoided. Fortunately it is often permitted to skip the ``atime`` |
1208 | update. Because `atime` updates cause performance problems in various | 1255 | update. Because ``atime`` updates cause performance problems in various |
1209 | areas, Linux supports the `relatime` mount option, which generally | 1256 | areas, Linux supports the ``relatime`` mount option, which generally |
1210 | limits the updates of `atime` to once per day on files that aren't | 1257 | limits the updates of ``atime`` to once per day on files that aren't |
1211 | being changed (and symlinks never change once created). Even without | 1258 | being changed (and symlinks never change once created). Even without |
1212 | `relatime`, many filesystems record `atime` with a one-second | 1259 | ``relatime``, many filesystems record ``atime`` with a one-second |
1213 | granularity, so only one update per second is required. | 1260 | granularity, so only one update per second is required. |
1214 | 1261 | ||
1215 | It is easy to test if an `atime` update is needed while in RCU-walk | 1262 | It is easy to test if an ``atime`` update is needed while in RCU-walk |
1216 | mode and, if it isn't, the update can be skipped and RCU-walk mode | 1263 | mode and, if it isn't, the update can be skipped and RCU-walk mode |
1217 | continues. Only when an `atime` update is actually required does the | 1264 | continues. Only when an ``atime`` update is actually required does the |
1218 | path walk drop down to REF-walk. All of this is handled in the | 1265 | path walk drop down to REF-walk. All of this is handled in the |
1219 | `get_link()` function. | 1266 | ``get_link()`` function. |
1220 | 1267 | ||
1221 | A few flags | 1268 | A few flags |
1222 | ----------- | 1269 | ----------- |
1223 | 1270 | ||
1224 | A suitable way to wrap up this tour of pathname walking is to list | 1271 | A suitable way to wrap up this tour of pathname walking is to list |
1225 | the various flags that can be stored in the `nameidata` to guide the | 1272 | the various flags that can be stored in the ``nameidata`` to guide the |
1226 | lookup process. Many of these are only meaningful on the final | 1273 | lookup process. Many of these are only meaningful on the final |
1227 | component, others reflect the current state of the pathname lookup. | 1274 | component, others reflect the current state of the pathname lookup. |
1228 | And then there is `LOOKUP_EMPTY`, which doesn't fit conceptually with | 1275 | And then there is ``LOOKUP_EMPTY``, which doesn't fit conceptually with |
1229 | the others. If this is not set, an empty pathname causes an error | 1276 | the others. If this is not set, an empty pathname causes an error |
1230 | very early on. If it is set, empty pathnames are not considered to be | 1277 | very early on. If it is set, empty pathnames are not considered to be |
1231 | an error. | 1278 | an error. |
1232 | 1279 | ||
1233 | ### Global state flags ### | 1280 | Global state flags |
1281 | ~~~~~~~~~~~~~~~~~~ | ||
1234 | 1282 | ||
1235 | We have already met two global state flags: `LOOKUP_RCU` and | 1283 | We have already met two global state flags: ``LOOKUP_RCU`` and |
1236 | `LOOKUP_REVAL`. These select between one of three overall approaches | 1284 | ``LOOKUP_REVAL``. These select between one of three overall approaches |
1237 | to lookup: RCU-walk, REF-walk, and REF-walk with forced revalidation. | 1285 | to lookup: RCU-walk, REF-walk, and REF-walk with forced revalidation. |
1238 | 1286 | ||
1239 | `LOOKUP_PARENT` indicates that the final component hasn't been reached | 1287 | ``LOOKUP_PARENT`` indicates that the final component hasn't been reached |
1240 | yet. This is primarily used to tell the audit subsystem the full | 1288 | yet. This is primarily used to tell the audit subsystem the full |
1241 | context of a particular access being audited. | 1289 | context of a particular access being audited. |
1242 | 1290 | ||
1243 | `LOOKUP_ROOT` indicates that the `root` field in the `nameidata` was | 1291 | ``LOOKUP_ROOT`` indicates that the ``root`` field in the ``nameidata`` was |
1244 | provided by the caller, so it shouldn't be released when it is no | 1292 | provided by the caller, so it shouldn't be released when it is no |
1245 | longer needed. | 1293 | longer needed. |
1246 | 1294 | ||
1247 | `LOOKUP_JUMPED` means that the current dentry was chosen not because | 1295 | ``LOOKUP_JUMPED`` means that the current dentry was chosen not because |
1248 | it had the right name but for some other reason. This happens when | 1296 | it had the right name but for some other reason. This happens when |
1249 | following "`..`", following a symlink to `/`, crossing a mount point | 1297 | following "``..``", following a symlink to ``/``, crossing a mount point |
1250 | or accessing a "`/proc/$PID/fd/$FD`" symlink. In this case the | 1298 | or accessing a "``/proc/$PID/fd/$FD``" symlink. In this case the |
1251 | filesystem has not been asked to revalidate the name (with | 1299 | filesystem has not been asked to revalidate the name (with |
1252 | `d_revalidate()`). In such cases the inode may still need to be | 1300 | ``d_revalidate()``). In such cases the inode may still need to be |
1253 | revalidated, so `d_op->d_weak_revalidate()` is called if | 1301 | revalidated, so ``d_op->d_weak_revalidate()`` is called if |
1254 | `LOOKUP_JUMPED` is set when the look completes - which may be at the | 1302 | ``LOOKUP_JUMPED`` is set when the look completes - which may be at the |
1255 | final component or, when creating, unlinking, or renaming, at the penultimate component. | 1303 | final component or, when creating, unlinking, or renaming, at the penultimate component. |
1256 | 1304 | ||
1257 | ### Final-component flags ### | 1305 | Final-component flags |
1306 | ~~~~~~~~~~~~~~~~~~~~~ | ||
1258 | 1307 | ||
1259 | Some of these flags are only set when the final component is being | 1308 | Some of these flags are only set when the final component is being |
1260 | considered. Others are only checked for when considering that final | 1309 | considered. Others are only checked for when considering that final |
1261 | component. | 1310 | component. |
1262 | 1311 | ||
1263 | `LOOKUP_AUTOMOUNT` ensures that, if the final component is an automount | 1312 | ``LOOKUP_AUTOMOUNT`` ensures that, if the final component is an automount |
1264 | point, then the mount is triggered. Some operations would trigger it | 1313 | point, then the mount is triggered. Some operations would trigger it |
1265 | anyway, but operations like `stat()` deliberately don't. `statfs()` | 1314 | anyway, but operations like ``stat()`` deliberately don't. ``statfs()`` |
1266 | needs to trigger the mount but otherwise behaves a lot like `stat()`, so | 1315 | needs to trigger the mount but otherwise behaves a lot like ``stat()``, so |
1267 | it sets `LOOKUP_AUTOMOUNT`, as does "`quotactl()`" and the handling of | 1316 | it sets ``LOOKUP_AUTOMOUNT``, as does "``quotactl()``" and the handling of |
1268 | "`mount --bind`". | 1317 | "``mount --bind``". |
1269 | 1318 | ||
1270 | `LOOKUP_FOLLOW` has a similar function to `LOOKUP_AUTOMOUNT` but for | 1319 | ``LOOKUP_FOLLOW`` has a similar function to ``LOOKUP_AUTOMOUNT`` but for |
1271 | symlinks. Some system calls set or clear it implicitly, while | 1320 | symlinks. Some system calls set or clear it implicitly, while |
1272 | others have API flags such as `AT_SYMLINK_FOLLOW` and | 1321 | others have API flags such as ``AT_SYMLINK_FOLLOW`` and |
1273 | `UMOUNT_NOFOLLOW` to control it. Its effect is similar to | 1322 | ``UMOUNT_NOFOLLOW`` to control it. Its effect is similar to |
1274 | `WALK_GET` that we already met, but it is used in a different way. | 1323 | ``WALK_GET`` that we already met, but it is used in a different way. |
1275 | 1324 | ||
1276 | `LOOKUP_DIRECTORY` insists that the final component is a directory. | 1325 | ``LOOKUP_DIRECTORY`` insists that the final component is a directory. |
1277 | Various callers set this and it is also set when the final component | 1326 | Various callers set this and it is also set when the final component |
1278 | is found to be followed by a slash. | 1327 | is found to be followed by a slash. |
1279 | 1328 | ||
1280 | Finally `LOOKUP_OPEN`, `LOOKUP_CREATE`, `LOOKUP_EXCL`, and | 1329 | Finally ``LOOKUP_OPEN``, ``LOOKUP_CREATE``, ``LOOKUP_EXCL``, and |
1281 | `LOOKUP_RENAME_TARGET` are not used directly by the VFS but are made | 1330 | ``LOOKUP_RENAME_TARGET`` are not used directly by the VFS but are made |
1282 | available to the filesystem and particularly the `->d_revalidate()` | 1331 | available to the filesystem and particularly the ``->d_revalidate()`` |
1283 | method. A filesystem can choose not to bother revalidating too hard | 1332 | method. A filesystem can choose not to bother revalidating too hard |
1284 | if it knows that it will be asked to open or create the file soon. | 1333 | if it knows that it will be asked to open or create the file soon. |
1285 | These flags were previously useful for `->lookup()` too but with the | 1334 | These flags were previously useful for ``->lookup()`` too but with the |
1286 | introduction of `->atomic_open()` they are less relevant there. | 1335 | introduction of ``->atomic_open()`` they are less relevant there. |
1287 | 1336 | ||
1288 | End of the road | 1337 | End of the road |
1289 | --------------- | 1338 | --------------- |
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index b24fd9bccc99..66cad5c86171 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -125,6 +125,13 @@ process running on the system, which is named after the process ID (PID). | |||
125 | The link self points to the process reading the file system. Each process | 125 | The link self points to the process reading the file system. Each process |
126 | subdirectory has the entries listed in Table 1-1. | 126 | subdirectory has the entries listed in Table 1-1. |
127 | 127 | ||
128 | Note that an open a file descriptor to /proc/<pid> or to any of its | ||
129 | contained files or subdirectories does not prevent <pid> being reused | ||
130 | for some other process in the event that <pid> exits. Operations on | ||
131 | open /proc/<pid> file descriptors corresponding to dead processes | ||
132 | never act on any new process that the kernel may, through chance, have | ||
133 | also assigned the process ID <pid>. Instead, operations on these FDs | ||
134 | usually fail with ESRCH. | ||
128 | 135 | ||
129 | Table 1-1: Process specific entries in /proc | 136 | Table 1-1: Process specific entries in /proc |
130 | .............................................................................. | 137 | .............................................................................. |
@@ -194,8 +201,10 @@ read the file /proc/PID/status: | |||
194 | CapPrm: 0000000000000000 | 201 | CapPrm: 0000000000000000 |
195 | CapEff: 0000000000000000 | 202 | CapEff: 0000000000000000 |
196 | CapBnd: ffffffffffffffff | 203 | CapBnd: ffffffffffffffff |
204 | CapAmb: 0000000000000000 | ||
197 | NoNewPrivs: 0 | 205 | NoNewPrivs: 0 |
198 | Seccomp: 0 | 206 | Seccomp: 0 |
207 | Speculation_Store_Bypass: thread vulnerable | ||
199 | voluntary_ctxt_switches: 0 | 208 | voluntary_ctxt_switches: 0 |
200 | nonvoluntary_ctxt_switches: 1 | 209 | nonvoluntary_ctxt_switches: 1 |
201 | 210 | ||
@@ -215,7 +224,7 @@ asynchronous manner and the value may not be very precise. To see a precise | |||
215 | snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table. | 224 | snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table. |
216 | It's slow but very precise. | 225 | It's slow but very precise. |
217 | 226 | ||
218 | Table 1-2: Contents of the status files (as of 4.8) | 227 | Table 1-2: Contents of the status files (as of 4.19) |
219 | .............................................................................. | 228 | .............................................................................. |
220 | Field Content | 229 | Field Content |
221 | Name filename of the executable | 230 | Name filename of the executable |
@@ -270,8 +279,10 @@ Table 1-2: Contents of the status files (as of 4.8) | |||
270 | CapPrm bitmap of permitted capabilities | 279 | CapPrm bitmap of permitted capabilities |
271 | CapEff bitmap of effective capabilities | 280 | CapEff bitmap of effective capabilities |
272 | CapBnd bitmap of capabilities bounding set | 281 | CapBnd bitmap of capabilities bounding set |
282 | CapAmb bitmap of ambient capabilities | ||
273 | NoNewPrivs no_new_privs, like prctl(PR_GET_NO_NEW_PRIV, ...) | 283 | NoNewPrivs no_new_privs, like prctl(PR_GET_NO_NEW_PRIV, ...) |
274 | Seccomp seccomp mode, like prctl(PR_GET_SECCOMP, ...) | 284 | Seccomp seccomp mode, like prctl(PR_GET_SECCOMP, ...) |
285 | Speculation_Store_Bypass speculative store bypass mitigation status | ||
275 | Cpus_allowed mask of CPUs on which this process may run | 286 | Cpus_allowed mask of CPUs on which this process may run |
276 | Cpus_allowed_list Same as previous, but in "list format" | 287 | Cpus_allowed_list Same as previous, but in "list format" |
277 | Mems_allowed mask of memory nodes allowed to this process | 288 | Mems_allowed mask of memory nodes allowed to this process |
diff --git a/Documentation/filesystems/qnx6.txt b/Documentation/filesystems/qnx6.txt index 4f3d6a882bdc..48ea68f15845 100644 --- a/Documentation/filesystems/qnx6.txt +++ b/Documentation/filesystems/qnx6.txt | |||
@@ -87,7 +87,7 @@ addressed with 16 direct blocks. | |||
87 | For more than 16 blocks an indirect addressing in form of another tree is | 87 | For more than 16 blocks an indirect addressing in form of another tree is |
88 | used. (scheme is the same as the one used for the superblock root nodes) | 88 | used. (scheme is the same as the one used for the superblock root nodes) |
89 | 89 | ||
90 | The filesize is stored 64bit. Inode counting starts with 1. (whilst long | 90 | The filesize is stored 64bit. Inode counting starts with 1. (while long |
91 | filename inodes start with 0) | 91 | filename inodes start with 0) |
92 | 92 | ||
93 | Directories | 93 | Directories |
@@ -155,7 +155,7 @@ Then userspace. | |||
155 | The requirement for a static, fixed preallocated system area comes from how | 155 | The requirement for a static, fixed preallocated system area comes from how |
156 | qnx6fs deals with writes. | 156 | qnx6fs deals with writes. |
157 | Each superblock got it's own half of the system area. So superblock #1 | 157 | Each superblock got it's own half of the system area. So superblock #1 |
158 | always uses blocks from the lower half whilst superblock #2 just writes to | 158 | always uses blocks from the lower half while superblock #2 just writes to |
159 | blocks represented by the upper half bitmap system area bits. | 159 | blocks represented by the upper half bitmap system area bits. |
160 | 160 | ||
161 | Bitmap blocks, Inode blocks and indirect addressing blocks for those two | 161 | Bitmap blocks, Inode blocks and indirect addressing blocks for those two |
diff --git a/Documentation/filesystems/spufs.txt b/Documentation/filesystems/spufs.txt index 1343d118a9b2..eb9e3aa63026 100644 --- a/Documentation/filesystems/spufs.txt +++ b/Documentation/filesystems/spufs.txt | |||
@@ -452,7 +452,7 @@ RETURN VALUE | |||
452 | 452 | ||
453 | 453 | ||
454 | ERRORS | 454 | ERRORS |
455 | EACCESS | 455 | EACCES |
456 | The current user does not have write access on the spufs mount | 456 | The current user does not have write access on the spufs mount |
457 | point. | 457 | point. |
458 | 458 | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 5f71a252e2e0..8dc8e9c2913f 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
@@ -1131,7 +1131,7 @@ struct dentry_operations { | |||
1131 | 1131 | ||
1132 | d_manage: called to allow the filesystem to manage the transition from a | 1132 | d_manage: called to allow the filesystem to manage the transition from a |
1133 | dentry (optional). This allows autofs, for example, to hold up clients | 1133 | dentry (optional). This allows autofs, for example, to hold up clients |
1134 | waiting to explore behind a 'mountpoint' whilst letting the daemon go | 1134 | waiting to explore behind a 'mountpoint' while letting the daemon go |
1135 | past and construct the subtree there. 0 should be returned to let the | 1135 | past and construct the subtree there. 0 should be returned to let the |
1136 | calling process continue. -EISDIR can be returned to tell pathwalk to | 1136 | calling process continue. -EISDIR can be returned to tell pathwalk to |
1137 | use this directory as an ordinary directory and to ignore anything | 1137 | use this directory as an ordinary directory and to ignore anything |
diff --git a/Documentation/filesystems/xfs-self-describing-metadata.txt b/Documentation/filesystems/xfs-self-describing-metadata.txt index 05aa455163e3..68604e67a495 100644 --- a/Documentation/filesystems/xfs-self-describing-metadata.txt +++ b/Documentation/filesystems/xfs-self-describing-metadata.txt | |||
@@ -110,7 +110,7 @@ owner field in the metadata object, we can immediately do top down validation to | |||
110 | determine the scope of the problem. | 110 | determine the scope of the problem. |
111 | 111 | ||
112 | Different types of metadata have different owner identifiers. For example, | 112 | Different types of metadata have different owner identifiers. For example, |
113 | directory, attribute and extent tree blocks are all owned by an inode, whilst | 113 | directory, attribute and extent tree blocks are all owned by an inode, while |
114 | freespace btree blocks are owned by an allocation group. Hence the size and | 114 | freespace btree blocks are owned by an allocation group. Hence the size and |
115 | contents of the owner field are determined by the type of metadata object we are | 115 | contents of the owner field are determined by the type of metadata object we are |
116 | looking at. The owner information can also identify misplaced writes (e.g. | 116 | looking at. The owner information can also identify misplaced writes (e.g. |
diff --git a/Documentation/filesystems/xfs.txt b/Documentation/filesystems/xfs.txt index a9ae82fb9d13..9ccfd1bc6201 100644 --- a/Documentation/filesystems/xfs.txt +++ b/Documentation/filesystems/xfs.txt | |||
@@ -417,7 +417,7 @@ level directory: | |||
417 | filesystem from ever unmounting fully in the case of "retry forever" | 417 | filesystem from ever unmounting fully in the case of "retry forever" |
418 | handler configurations. | 418 | handler configurations. |
419 | 419 | ||
420 | Note: there is no guarantee that fail_at_unmount can be set whilst an | 420 | Note: there is no guarantee that fail_at_unmount can be set while an |
421 | unmount is in progress. It is possible that the sysfs entries are | 421 | unmount is in progress. It is possible that the sysfs entries are |
422 | removed by the unmounting filesystem before a "retry forever" error | 422 | removed by the unmounting filesystem before a "retry forever" error |
423 | handler configuration causes unmount to hang, and hence the filesystem | 423 | handler configuration causes unmount to hang, and hence the filesystem |
diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 4b4bf2c5eac5..a752aa561ea4 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst | |||
@@ -190,11 +190,11 @@ ENOSPC: | |||
190 | 190 | ||
191 | Simply running out of kernel/system memory is signalled through ENOMEM. | 191 | Simply running out of kernel/system memory is signalled through ENOMEM. |
192 | 192 | ||
193 | EPERM/EACCESS: | 193 | EPERM/EACCES: |
194 | Returned for an operation that is valid, but needs more privileges. | 194 | Returned for an operation that is valid, but needs more privileges. |
195 | E.g. root-only or much more common, DRM master-only operations return | 195 | E.g. root-only or much more common, DRM master-only operations return |
196 | this when when called by unpriviledged clients. There's no clear | 196 | this when when called by unpriviledged clients. There's no clear |
197 | difference between EACCESS and EPERM. | 197 | difference between EACCES and EPERM. |
198 | 198 | ||
199 | ENODEV: | 199 | ENODEV: |
200 | The device is not (yet) present or fully initialized. | 200 | The device is not (yet) present or fully initialized. |
diff --git a/Documentation/leds/leds-class.txt b/Documentation/leds/leds-class.txt index 836cb16d6f09..8b39cc6b03ee 100644 --- a/Documentation/leds/leds-class.txt +++ b/Documentation/leds/leds-class.txt | |||
@@ -15,7 +15,7 @@ existing subsystems with minimal additional code. Examples are the disk-activity | |||
15 | nand-disk and sharpsl-charge triggers. With led triggers disabled, the code | 15 | nand-disk and sharpsl-charge triggers. With led triggers disabled, the code |
16 | optimises away. | 16 | optimises away. |
17 | 17 | ||
18 | Complex triggers whilst available to all LEDs have LED specific | 18 | Complex triggers while available to all LEDs have LED specific |
19 | parameters and work on a per LED basis. The timer trigger is an example. | 19 | parameters and work on a per LED basis. The timer trigger is an example. |
20 | The timer trigger will periodically change the LED brightness between | 20 | The timer trigger will periodically change the LED brightness between |
21 | LED_OFF and the current brightness setting. The "on" and "off" time can | 21 | LED_OFF and the current brightness setting. The "on" and "off" time can |
diff --git a/Documentation/media/uapi/v4l/extended-controls.rst b/Documentation/media/uapi/v4l/extended-controls.rst index c471408d9bf9..286a2dd7ec36 100644 --- a/Documentation/media/uapi/v4l/extended-controls.rst +++ b/Documentation/media/uapi/v4l/extended-controls.rst | |||
@@ -4003,7 +4003,7 @@ demodulator. It receives radio frequency (RF) from the antenna and | |||
4003 | converts that received signal to lower intermediate frequency (IF) or | 4003 | converts that received signal to lower intermediate frequency (IF) or |
4004 | baseband frequency (BB). Tuners that could do baseband output are often | 4004 | baseband frequency (BB). Tuners that could do baseband output are often |
4005 | called Zero-IF tuners. Older tuners were typically simple PLL tuners | 4005 | called Zero-IF tuners. Older tuners were typically simple PLL tuners |
4006 | inside a metal box, whilst newer ones are highly integrated chips | 4006 | inside a metal box, while newer ones are highly integrated chips |
4007 | without a metal box "silicon tuners". These controls are mostly | 4007 | without a metal box "silicon tuners". These controls are mostly |
4008 | applicable for new feature rich silicon tuners, just because older | 4008 | applicable for new feature rich silicon tuners, just because older |
4009 | tuners does not have much adjustable features. | 4009 | tuners does not have much adjustable features. |
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index c1d913944ad8..1c22b21ae922 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
@@ -587,7 +587,7 @@ leading to the following situation: | |||
587 | 587 | ||
588 | (Q == &B) and (D == 2) ???? | 588 | (Q == &B) and (D == 2) ???? |
589 | 589 | ||
590 | Whilst this may seem like a failure of coherency or causality maintenance, it | 590 | While this may seem like a failure of coherency or causality maintenance, it |
591 | isn't, and this behaviour can be observed on certain real CPUs (such as the DEC | 591 | isn't, and this behaviour can be observed on certain real CPUs (such as the DEC |
592 | Alpha). | 592 | Alpha). |
593 | 593 | ||
@@ -2008,7 +2008,7 @@ for each construct. These operations all imply certain barriers: | |||
2008 | 2008 | ||
2009 | Certain locking variants of the ACQUIRE operation may fail, either due to | 2009 | Certain locking variants of the ACQUIRE operation may fail, either due to |
2010 | being unable to get the lock immediately, or due to receiving an unblocked | 2010 | being unable to get the lock immediately, or due to receiving an unblocked |
2011 | signal whilst asleep waiting for the lock to become available. Failed | 2011 | signal while asleep waiting for the lock to become available. Failed |
2012 | locks do not imply any sort of barrier. | 2012 | locks do not imply any sort of barrier. |
2013 | 2013 | ||
2014 | [!] Note: one of the consequences of lock ACQUIREs and RELEASEs being only | 2014 | [!] Note: one of the consequences of lock ACQUIREs and RELEASEs being only |
@@ -2508,7 +2508,7 @@ CPU, that CPU's dependency ordering logic will take care of everything else. | |||
2508 | ATOMIC OPERATIONS | 2508 | ATOMIC OPERATIONS |
2509 | ----------------- | 2509 | ----------------- |
2510 | 2510 | ||
2511 | Whilst they are technically interprocessor interaction considerations, atomic | 2511 | While they are technically interprocessor interaction considerations, atomic |
2512 | operations are noted specially as some of them imply full memory barriers and | 2512 | operations are noted specially as some of them imply full memory barriers and |
2513 | some don't, but they're very heavily relied on as a group throughout the | 2513 | some don't, but they're very heavily relied on as a group throughout the |
2514 | kernel. | 2514 | kernel. |
@@ -2531,7 +2531,7 @@ the device to malfunction. | |||
2531 | 2531 | ||
2532 | Inside of the Linux kernel, I/O should be done through the appropriate accessor | 2532 | Inside of the Linux kernel, I/O should be done through the appropriate accessor |
2533 | routines - such as inb() or writel() - which know how to make such accesses | 2533 | routines - such as inb() or writel() - which know how to make such accesses |
2534 | appropriately sequential. Whilst this, for the most part, renders the explicit | 2534 | appropriately sequential. While this, for the most part, renders the explicit |
2535 | use of memory barriers unnecessary, there are a couple of situations where they | 2535 | use of memory barriers unnecessary, there are a couple of situations where they |
2536 | might be needed: | 2536 | might be needed: |
2537 | 2537 | ||
@@ -2555,7 +2555,7 @@ access the device. | |||
2555 | 2555 | ||
2556 | This may be alleviated - at least in part - by disabling local interrupts (a | 2556 | This may be alleviated - at least in part - by disabling local interrupts (a |
2557 | form of locking), such that the critical operations are all contained within | 2557 | form of locking), such that the critical operations are all contained within |
2558 | the interrupt-disabled section in the driver. Whilst the driver's interrupt | 2558 | the interrupt-disabled section in the driver. While the driver's interrupt |
2559 | routine is executing, the driver's core may not run on the same CPU, and its | 2559 | routine is executing, the driver's core may not run on the same CPU, and its |
2560 | interrupt is not permitted to happen again until the current interrupt has been | 2560 | interrupt is not permitted to happen again until the current interrupt has been |
2561 | handled, thus the interrupt handler does not need to lock against that. | 2561 | handled, thus the interrupt handler does not need to lock against that. |
@@ -2763,7 +2763,7 @@ CACHE COHERENCY | |||
2763 | 2763 | ||
2764 | Life isn't quite as simple as it may appear above, however: for while the | 2764 | Life isn't quite as simple as it may appear above, however: for while the |
2765 | caches are expected to be coherent, there's no guarantee that that coherency | 2765 | caches are expected to be coherent, there's no guarantee that that coherency |
2766 | will be ordered. This means that whilst changes made on one CPU will | 2766 | will be ordered. This means that while changes made on one CPU will |
2767 | eventually become visible on all CPUs, there's no guarantee that they will | 2767 | eventually become visible on all CPUs, there's no guarantee that they will |
2768 | become apparent in the same order on those other CPUs. | 2768 | become apparent in the same order on those other CPUs. |
2769 | 2769 | ||
@@ -2799,7 +2799,7 @@ Imagine the system has the following properties: | |||
2799 | (*) an even-numbered cache line may be in cache B, cache D or it may still be | 2799 | (*) an even-numbered cache line may be in cache B, cache D or it may still be |
2800 | resident in memory; | 2800 | resident in memory; |
2801 | 2801 | ||
2802 | (*) whilst the CPU core is interrogating one cache, the other cache may be | 2802 | (*) while the CPU core is interrogating one cache, the other cache may be |
2803 | making use of the bus to access the rest of the system - perhaps to | 2803 | making use of the bus to access the rest of the system - perhaps to |
2804 | displace a dirty cacheline or to do a speculative load; | 2804 | displace a dirty cacheline or to do a speculative load; |
2805 | 2805 | ||
@@ -2835,7 +2835,7 @@ now imagine that the second CPU wants to read those values: | |||
2835 | x = *q; | 2835 | x = *q; |
2836 | 2836 | ||
2837 | The above pair of reads may then fail to happen in the expected order, as the | 2837 | The above pair of reads may then fail to happen in the expected order, as the |
2838 | cacheline holding p may get updated in one of the second CPU's caches whilst | 2838 | cacheline holding p may get updated in one of the second CPU's caches while |
2839 | the update to the cacheline holding v is delayed in the other of the second | 2839 | the update to the cacheline holding v is delayed in the other of the second |
2840 | CPU's caches by some other cache event: | 2840 | CPU's caches by some other cache event: |
2841 | 2841 | ||
@@ -2855,7 +2855,7 @@ CPU's caches by some other cache event: | |||
2855 | <C:unbusy> | 2855 | <C:unbusy> |
2856 | <C:commit v=2> | 2856 | <C:commit v=2> |
2857 | 2857 | ||
2858 | Basically, whilst both cachelines will be updated on CPU 2 eventually, there's | 2858 | Basically, while both cachelines will be updated on CPU 2 eventually, there's |
2859 | no guarantee that, without intervention, the order of update will be the same | 2859 | no guarantee that, without intervention, the order of update will be the same |
2860 | as that committed on CPU 1. | 2860 | as that committed on CPU 1. |
2861 | 2861 | ||
@@ -2885,7 +2885,7 @@ coherency queue before processing any further requests: | |||
2885 | 2885 | ||
2886 | This sort of problem can be encountered on DEC Alpha processors as they have a | 2886 | This sort of problem can be encountered on DEC Alpha processors as they have a |
2887 | split cache that improves performance by making better use of the data bus. | 2887 | split cache that improves performance by making better use of the data bus. |
2888 | Whilst most CPUs do imply a data dependency barrier on the read when a memory | 2888 | While most CPUs do imply a data dependency barrier on the read when a memory |
2889 | access depends on a read, not all do, so it may not be relied on. | 2889 | access depends on a read, not all do, so it may not be relied on. |
2890 | 2890 | ||
2891 | Other CPUs may also have split caches, but must coordinate between the various | 2891 | Other CPUs may also have split caches, but must coordinate between the various |
@@ -2974,7 +2974,7 @@ assumption doesn't hold because: | |||
2974 | thus cutting down on transaction setup costs (memory and PCI devices may | 2974 | thus cutting down on transaction setup costs (memory and PCI devices may |
2975 | both be able to do this); and | 2975 | both be able to do this); and |
2976 | 2976 | ||
2977 | (*) the CPU's data cache may affect the ordering, and whilst cache-coherency | 2977 | (*) the CPU's data cache may affect the ordering, and while cache-coherency |
2978 | mechanisms may alleviate this - once the store has actually hit the cache | 2978 | mechanisms may alleviate this - once the store has actually hit the cache |
2979 | - there's no guarantee that the coherency management will be propagated in | 2979 | - there's no guarantee that the coherency management will be propagated in |
2980 | order to other CPUs. | 2980 | order to other CPUs. |
diff --git a/Documentation/networking/device_drivers/dec/de4x5.txt b/Documentation/networking/device_drivers/dec/de4x5.txt index c8e4ca9b2c3e..452aac58341d 100644 --- a/Documentation/networking/device_drivers/dec/de4x5.txt +++ b/Documentation/networking/device_drivers/dec/de4x5.txt | |||
@@ -84,7 +84,7 @@ | |||
84 | 84 | ||
85 | Automedia detection is included so that in principle you can disconnect | 85 | Automedia detection is included so that in principle you can disconnect |
86 | from, e.g. TP, reconnect to BNC and things will still work (after a | 86 | from, e.g. TP, reconnect to BNC and things will still work (after a |
87 | pause whilst the driver figures out where its media went). My tests | 87 | pause while the driver figures out where its media went). My tests |
88 | using ping showed that it appears to work.... | 88 | using ping showed that it appears to work.... |
89 | 89 | ||
90 | By default, the driver will now autodetect any DECchip based card. | 90 | By default, the driver will now autodetect any DECchip based card. |
diff --git a/Documentation/networking/rxrpc.txt b/Documentation/networking/rxrpc.txt index 89f1302d593a..c9d052e0cf51 100644 --- a/Documentation/networking/rxrpc.txt +++ b/Documentation/networking/rxrpc.txt | |||
@@ -661,7 +661,7 @@ A server would be set up to accept operations in the following manner: | |||
661 | setsockopt(server, SOL_RXRPC, RXRPC_SECURITY_KEYRING, "AFSkeys", 7); | 661 | setsockopt(server, SOL_RXRPC, RXRPC_SECURITY_KEYRING, "AFSkeys", 7); |
662 | 662 | ||
663 | The keyring can be manipulated after it has been given to the socket. This | 663 | The keyring can be manipulated after it has been given to the socket. This |
664 | permits the server to add more keys, replace keys, etc. whilst it is live. | 664 | permits the server to add more keys, replace keys, etc. while it is live. |
665 | 665 | ||
666 | (3) A local address must then be bound: | 666 | (3) A local address must then be bound: |
667 | 667 | ||
@@ -1032,7 +1032,7 @@ The kernel interface functions are as follows: | |||
1032 | struct sockaddr_rxrpc *srx, | 1032 | struct sockaddr_rxrpc *srx, |
1033 | struct key *key); | 1033 | struct key *key); |
1034 | 1034 | ||
1035 | This attempts to partially reinitialise a call and submit it again whilst | 1035 | This attempts to partially reinitialise a call and submit it again while |
1036 | reusing the original call's Tx queue to avoid the need to repackage and | 1036 | reusing the original call's Tx queue to avoid the need to repackage and |
1037 | re-encrypt the data to be sent. call indicates the call to retry, srx the | 1037 | re-encrypt the data to be sent. call indicates the call to retry, srx the |
1038 | new address to send it to and key the encryption key to use for signing or | 1038 | new address to send it to and key the encryption key to use for signing or |
@@ -1066,7 +1066,7 @@ The kernel interface functions are as follows: | |||
1066 | alive after waiting for a suitable interval. | 1066 | alive after waiting for a suitable interval. |
1067 | 1067 | ||
1068 | This allows the caller to work out if the server is still contactable and | 1068 | This allows the caller to work out if the server is still contactable and |
1069 | if the call is still alive on the server whilst waiting for the server to | 1069 | if the call is still alive on the server while waiting for the server to |
1070 | process a client operation. | 1070 | process a client operation. |
1071 | 1071 | ||
1072 | The second function causes a ping ACK to be transmitted to try to provoke | 1072 | The second function causes a ping ACK to be transmitted to try to provoke |
@@ -1149,14 +1149,14 @@ adjusted through sysctls in /proc/net/rxrpc/: | |||
1149 | (*) connection_expiry | 1149 | (*) connection_expiry |
1150 | 1150 | ||
1151 | The amount of time in seconds after a connection was last used before we | 1151 | The amount of time in seconds after a connection was last used before we |
1152 | remove it from the connection list. Whilst a connection is in existence, | 1152 | remove it from the connection list. While a connection is in existence, |
1153 | it serves as a placeholder for negotiated security; when it is deleted, | 1153 | it serves as a placeholder for negotiated security; when it is deleted, |
1154 | the security must be renegotiated. | 1154 | the security must be renegotiated. |
1155 | 1155 | ||
1156 | (*) transport_expiry | 1156 | (*) transport_expiry |
1157 | 1157 | ||
1158 | The amount of time in seconds after a transport was last used before we | 1158 | The amount of time in seconds after a transport was last used before we |
1159 | remove it from the transport list. Whilst a transport is in existence, it | 1159 | remove it from the transport list. While a transport is in existence, it |
1160 | serves to anchor the peer data and keeps the connection ID counter. | 1160 | serves to anchor the peer data and keeps the connection ID counter. |
1161 | 1161 | ||
1162 | (*) rxrpc_rx_window_size | 1162 | (*) rxrpc_rx_window_size |
diff --git a/Documentation/power/regulator/overview.txt b/Documentation/power/regulator/overview.txt index 40ca2d6e2742..721b4739ec32 100644 --- a/Documentation/power/regulator/overview.txt +++ b/Documentation/power/regulator/overview.txt | |||
@@ -22,7 +22,7 @@ Nomenclature | |||
22 | Some terms used in this document:- | 22 | Some terms used in this document:- |
23 | 23 | ||
24 | o Regulator - Electronic device that supplies power to other devices. | 24 | o Regulator - Electronic device that supplies power to other devices. |
25 | Most regulators can enable and disable their output whilst | 25 | Most regulators can enable and disable their output while |
26 | some can control their output voltage and or current. | 26 | some can control their output voltage and or current. |
27 | 27 | ||
28 | Input Voltage -> Regulator -> Output Voltage | 28 | Input Voltage -> Regulator -> Output Voltage |
diff --git a/Documentation/process/1.Intro.rst b/Documentation/process/1.Intro.rst index e782ae2eef58..c3d0270bbfb3 100644 --- a/Documentation/process/1.Intro.rst +++ b/Documentation/process/1.Intro.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _development_process_intro: | ||
2 | |||
1 | Introduction | 3 | Introduction |
2 | ============ | 4 | ============ |
3 | 5 | ||
diff --git a/Documentation/process/4.Coding.rst b/Documentation/process/4.Coding.rst index eb4b185d168c..cfe264889447 100644 --- a/Documentation/process/4.Coding.rst +++ b/Documentation/process/4.Coding.rst | |||
@@ -315,7 +315,8 @@ variety of potential coding problems; it can also propose fixes for those | |||
315 | problems. Quite a few "semantic patches" for the kernel have been packaged | 315 | problems. Quite a few "semantic patches" for the kernel have been packaged |
316 | under the scripts/coccinelle directory; running "make coccicheck" will run | 316 | under the scripts/coccinelle directory; running "make coccicheck" will run |
317 | through those semantic patches and report on any problems found. See | 317 | through those semantic patches and report on any problems found. See |
318 | Documentation/dev-tools/coccinelle.rst for more information. | 318 | :ref:`Documentation/dev-tools/coccinelle.rst <devtools_coccinelle>` |
319 | for more information. | ||
319 | 320 | ||
320 | Other kinds of portability errors are best found by compiling your code for | 321 | Other kinds of portability errors are best found by compiling your code for |
321 | other architectures. If you do not happen to have an S/390 system or a | 322 | other architectures. If you do not happen to have an S/390 system or a |
diff --git a/Documentation/process/5.Posting.rst b/Documentation/process/5.Posting.rst index c418c5d6cae4..4213e580f273 100644 --- a/Documentation/process/5.Posting.rst +++ b/Documentation/process/5.Posting.rst | |||
@@ -9,9 +9,10 @@ kernel. Unsurprisingly, the kernel development community has evolved a set | |||
9 | of conventions and procedures which are used in the posting of patches; | 9 | of conventions and procedures which are used in the posting of patches; |
10 | following them will make life much easier for everybody involved. This | 10 | following them will make life much easier for everybody involved. This |
11 | document will attempt to cover these expectations in reasonable detail; | 11 | document will attempt to cover these expectations in reasonable detail; |
12 | more information can also be found in the files process/submitting-patches.rst, | 12 | more information can also be found in the files |
13 | process/submitting-drivers.rst, and process/submit-checklist.rst in the kernel | 13 | :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`, |
14 | documentation directory. | 14 | :ref:`Documentation/process/submitting-drivers.rst <submittingdrivers>` |
15 | and :ref:`Documentation/process/submit-checklist.rst <submitchecklist>`. | ||
15 | 16 | ||
16 | 17 | ||
17 | When to post | 18 | When to post |
@@ -198,8 +199,10 @@ pass it to diff with the "-X" option. | |||
198 | 199 | ||
199 | The tags mentioned above are used to describe how various developers have | 200 | The tags mentioned above are used to describe how various developers have |
200 | been associated with the development of this patch. They are described in | 201 | been associated with the development of this patch. They are described in |
201 | detail in the process/submitting-patches.rst document; what follows here is a | 202 | detail in |
202 | brief summary. Each of these lines has the format: | 203 | the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` |
204 | document; what follows here is a brief summary. Each of these lines has | ||
205 | the format: | ||
203 | 206 | ||
204 | :: | 207 | :: |
205 | 208 | ||
@@ -210,8 +213,8 @@ The tags in common use are: | |||
210 | - Signed-off-by: this is a developer's certification that he or she has | 213 | - Signed-off-by: this is a developer's certification that he or she has |
211 | the right to submit the patch for inclusion into the kernel. It is an | 214 | the right to submit the patch for inclusion into the kernel. It is an |
212 | agreement to the Developer's Certificate of Origin, the full text of | 215 | agreement to the Developer's Certificate of Origin, the full text of |
213 | which can be found in Documentation/process/submitting-patches.rst. Code | 216 | which can be found in :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` |
214 | without a proper signoff cannot be merged into the mainline. | 217 | Code without a proper signoff cannot be merged into the mainline. |
215 | 218 | ||
216 | - Co-developed-by: states that the patch was also created by another developer | 219 | - Co-developed-by: states that the patch was also created by another developer |
217 | along with the original author. This is useful at times when multiple | 220 | along with the original author. This is useful at times when multiple |
@@ -226,7 +229,7 @@ The tags in common use are: | |||
226 | it to work. | 229 | it to work. |
227 | 230 | ||
228 | - Reviewed-by: the named developer has reviewed the patch for correctness; | 231 | - Reviewed-by: the named developer has reviewed the patch for correctness; |
229 | see the reviewer's statement in Documentation/process/submitting-patches.rst | 232 | see the reviewer's statement in :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` |
230 | for more detail. | 233 | for more detail. |
231 | 234 | ||
232 | - Reported-by: names a user who reported a problem which is fixed by this | 235 | - Reported-by: names a user who reported a problem which is fixed by this |
@@ -253,8 +256,8 @@ take care of: | |||
253 | be examined in any detail. If there is any doubt at all, mail the patch | 256 | be examined in any detail. If there is any doubt at all, mail the patch |
254 | to yourself and convince yourself that it shows up intact. | 257 | to yourself and convince yourself that it shows up intact. |
255 | 258 | ||
256 | Documentation/process/email-clients.rst has some helpful hints on making | 259 | :ref:`Documentation/process/email-clients.rst <email_clients>` has some |
257 | specific mail clients work for sending patches. | 260 | helpful hints on making specific mail clients work for sending patches. |
258 | 261 | ||
259 | - Are you sure your patch is free of silly mistakes? You should always | 262 | - Are you sure your patch is free of silly mistakes? You should always |
260 | run patches through scripts/checkpatch.pl and address the complaints it | 263 | run patches through scripts/checkpatch.pl and address the complaints it |
diff --git a/Documentation/process/8.Conclusion.rst b/Documentation/process/8.Conclusion.rst index 1c7f54cd0261..8395aa2c1f3a 100644 --- a/Documentation/process/8.Conclusion.rst +++ b/Documentation/process/8.Conclusion.rst | |||
@@ -5,9 +5,10 @@ For more information | |||
5 | 5 | ||
6 | There are numerous sources of information on Linux kernel development and | 6 | There are numerous sources of information on Linux kernel development and |
7 | related topics. First among those will always be the Documentation | 7 | related topics. First among those will always be the Documentation |
8 | directory found in the kernel source distribution. The top-level process/howto.rst | 8 | directory found in the kernel source distribution. The top-level :ref:`process/howto.rst <process_howto>` |
9 | file is an important starting point; process/submitting-patches.rst and | 9 | file is an important starting point; :ref:`process/submitting-patches.rst <submittingpatches>` |
10 | process/submitting-drivers.rst are also something which all kernel developers should | 10 | and :ref:`process/submitting-drivers.rst <submittingdrivers>` |
11 | are also something which all kernel developers should | ||
11 | read. Many internal kernel APIs are documented using the kerneldoc | 12 | read. Many internal kernel APIs are documented using the kerneldoc |
12 | mechanism; "make htmldocs" or "make pdfdocs" can be used to generate those | 13 | mechanism; "make htmldocs" or "make pdfdocs" can be used to generate those |
13 | documents in HTML or PDF format (though the version of TeX shipped by some | 14 | documents in HTML or PDF format (though the version of TeX shipped by some |
diff --git a/Documentation/process/adding-syscalls.rst b/Documentation/process/adding-syscalls.rst index 88a7d5c8bb2f..1c3a840d06b9 100644 --- a/Documentation/process/adding-syscalls.rst +++ b/Documentation/process/adding-syscalls.rst | |||
@@ -1,3 +1,6 @@ | |||
1 | |||
2 | .. _addsyscalls: | ||
3 | |||
1 | Adding a New System Call | 4 | Adding a New System Call |
2 | ======================== | 5 | ======================== |
3 | 6 | ||
diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index d1bf143b446f..18735dc460a0 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst | |||
@@ -326,7 +326,7 @@ Kernel documentation | |||
326 | Sphinx | 326 | Sphinx |
327 | ------ | 327 | ------ |
328 | 328 | ||
329 | Please see :ref:`sphinx_install` in ``Documentation/doc-guide/sphinx.rst`` | 329 | Please see :ref:`sphinx_install` in :ref:`Documentation/doc-guide/sphinx.rst <sphinxdoc>` |
330 | for details about Sphinx requirements. | 330 | for details about Sphinx requirements. |
331 | 331 | ||
332 | Getting updated software | 332 | Getting updated software |
diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst index 4e7c0a1c427a..277c113376a6 100644 --- a/Documentation/process/coding-style.rst +++ b/Documentation/process/coding-style.rst | |||
@@ -1075,5 +1075,5 @@ gcc internals and indent, all available from http://www.gnu.org/manual/ | |||
1075 | WG14 is the international standardization working group for the programming | 1075 | WG14 is the international standardization working group for the programming |
1076 | language C, URL: http://www.open-std.org/JTC1/SC22/WG14/ | 1076 | language C, URL: http://www.open-std.org/JTC1/SC22/WG14/ |
1077 | 1077 | ||
1078 | Kernel process/coding-style.rst, by greg@kroah.com at OLS 2002: | 1078 | Kernel :ref:`process/coding-style.rst <codingstyle>`, by greg@kroah.com at OLS 2002: |
1079 | http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ | 1079 | http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ |
diff --git a/Documentation/process/howto.rst b/Documentation/process/howto.rst index dcb25f94188e..58b2f46c4f98 100644 --- a/Documentation/process/howto.rst +++ b/Documentation/process/howto.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _process_howto: | ||
2 | |||
1 | HOWTO do Linux kernel development | 3 | HOWTO do Linux kernel development |
2 | ================================= | 4 | ================================= |
3 | 5 | ||
@@ -296,9 +298,9 @@ two weeks, but it can be longer if there are no pressing problems. A | |||
296 | security-related problem, instead, can cause a release to happen almost | 298 | security-related problem, instead, can cause a release to happen almost |
297 | instantly. | 299 | instantly. |
298 | 300 | ||
299 | The file Documentation/process/stable-kernel-rules.rst in the kernel tree | 301 | The file :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` |
300 | documents what kinds of changes are acceptable for the -stable tree, and | 302 | in the kernel tree documents what kinds of changes are acceptable for |
301 | how the release process works. | 303 | the -stable tree, and how the release process works. |
302 | 304 | ||
303 | 4.x -git patches | 305 | 4.x -git patches |
304 | ~~~~~~~~~~~~~~~~ | 306 | ~~~~~~~~~~~~~~~~ |
@@ -358,7 +360,8 @@ tool. For details on how to use the kernel bugzilla, please see: | |||
358 | 360 | ||
359 | https://bugzilla.kernel.org/page.cgi?id=faq.html | 361 | https://bugzilla.kernel.org/page.cgi?id=faq.html |
360 | 362 | ||
361 | The file admin-guide/reporting-bugs.rst in the main kernel source directory has a good | 363 | The file :ref:`admin-guide/reporting-bugs.rst <reportingbugs>` |
364 | in the main kernel source directory has a good | ||
362 | template for how to report a possible kernel bug, and details what kind | 365 | template for how to report a possible kernel bug, and details what kind |
363 | of information is needed by the kernel developers to help track down the | 366 | of information is needed by the kernel developers to help track down the |
364 | problem. | 367 | problem. |
@@ -424,7 +427,7 @@ add your statements between the individual quoted sections instead of | |||
424 | writing at the top of the mail. | 427 | writing at the top of the mail. |
425 | 428 | ||
426 | If you add patches to your mail, make sure they are plain readable text | 429 | If you add patches to your mail, make sure they are plain readable text |
427 | as stated in Documentation/process/submitting-patches.rst. | 430 | as stated in :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`. |
428 | Kernel developers don't want to deal with | 431 | Kernel developers don't want to deal with |
429 | attachments or compressed patches; they may want to comment on | 432 | attachments or compressed patches; they may want to comment on |
430 | individual lines of your patch, which works only that way. Make sure you | 433 | individual lines of your patch, which works only that way. Make sure you |
diff --git a/Documentation/process/kernel-driver-statement.rst b/Documentation/process/kernel-driver-statement.rst index e78452c2164c..a849790a68bc 100644 --- a/Documentation/process/kernel-driver-statement.rst +++ b/Documentation/process/kernel-driver-statement.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _process_statement_driver: | ||
2 | |||
1 | Kernel Driver Statement | 3 | Kernel Driver Statement |
2 | ----------------------- | 4 | ----------------------- |
3 | 5 | ||
diff --git a/Documentation/process/kernel-enforcement-statement.rst b/Documentation/process/kernel-enforcement-statement.rst index 6816c12d6956..e5a1be476047 100644 --- a/Documentation/process/kernel-enforcement-statement.rst +++ b/Documentation/process/kernel-enforcement-statement.rst | |||
@@ -1,4 +1,6 @@ | |||
1 | Linux Kernel Enforcement Statement | 1 | .. _process_statement_kernel: |
2 | |||
3 | Linux Kernel Enforcement Statement | ||
2 | ---------------------------------- | 4 | ---------------------------------- |
3 | 5 | ||
4 | As developers of the Linux kernel, we have a keen interest in how our software | 6 | As developers of the Linux kernel, we have a keen interest in how our software |
diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst index 633be1043690..547bbf28e615 100644 --- a/Documentation/process/magic-number.rst +++ b/Documentation/process/magic-number.rst | |||
@@ -1,3 +1,5 @@ | |||
1 | .. _magicnumbers: | ||
2 | |||
1 | Linux magic numbers | 3 | Linux magic numbers |
2 | =================== | 4 | =================== |
3 | 5 | ||
diff --git a/Documentation/process/management-style.rst b/Documentation/process/management-style.rst index 85ef8ca8f639..186753ff3d2d 100644 --- a/Documentation/process/management-style.rst +++ b/Documentation/process/management-style.rst | |||
@@ -5,8 +5,9 @@ Linux kernel management style | |||
5 | 5 | ||
6 | This is a short document describing the preferred (or made up, depending | 6 | This is a short document describing the preferred (or made up, depending |
7 | on who you ask) management style for the linux kernel. It's meant to | 7 | on who you ask) management style for the linux kernel. It's meant to |
8 | mirror the process/coding-style.rst document to some degree, and mainly written to | 8 | mirror the :ref:`process/coding-style.rst <codingstyle>` document to some |
9 | avoid answering [#f1]_ the same (or similar) questions over and over again. | 9 | degree, and mainly written to avoid answering [#f1]_ the same (or similar) |
10 | questions over and over again. | ||
10 | 11 | ||
11 | Management style is very personal and much harder to quantify than | 12 | Management style is very personal and much harder to quantify than |
12 | simple coding style rules, so this document may or may not have anything | 13 | simple coding style rules, so this document may or may not have anything |
diff --git a/Documentation/process/submitting-drivers.rst b/Documentation/process/submitting-drivers.rst index b38bf2054ce3..58bc047e7b95 100644 --- a/Documentation/process/submitting-drivers.rst +++ b/Documentation/process/submitting-drivers.rst | |||
@@ -16,7 +16,8 @@ you should probably talk to XFree86 (http://www.xfree86.org/) and/or X.Org | |||
16 | 16 | ||
17 | Oh, and we don't really recommend submitting changes to XFree86 :) | 17 | Oh, and we don't really recommend submitting changes to XFree86 :) |
18 | 18 | ||
19 | Also read the Documentation/process/submitting-patches.rst document. | 19 | Also read the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` |
20 | document. | ||
20 | 21 | ||
21 | 22 | ||
22 | Allocating Device Numbers | 23 | Allocating Device Numbers |
@@ -27,7 +28,8 @@ by the Linux assigned name and number authority (currently this is | |||
27 | Torben Mathiasen). The site is http://www.lanana.org/. This | 28 | Torben Mathiasen). The site is http://www.lanana.org/. This |
28 | also deals with allocating numbers for devices that are not going to | 29 | also deals with allocating numbers for devices that are not going to |
29 | be submitted to the mainstream kernel. | 30 | be submitted to the mainstream kernel. |
30 | See Documentation/admin-guide/devices.rst for more information on this. | 31 | See :ref:`Documentation/admin-guide/devices.rst <admin_devices>` |
32 | for more information on this. | ||
31 | 33 | ||
32 | If you don't use assigned numbers then when your device is submitted it will | 34 | If you don't use assigned numbers then when your device is submitted it will |
33 | be given an assigned number even if that is different from values you may | 35 | be given an assigned number even if that is different from values you may |
@@ -117,7 +119,7 @@ PM support: | |||
117 | anything. For the driver testing instructions see | 119 | anything. For the driver testing instructions see |
118 | Documentation/power/drivers-testing.txt and for a relatively | 120 | Documentation/power/drivers-testing.txt and for a relatively |
119 | complete overview of the power management issues related to | 121 | complete overview of the power management issues related to |
120 | drivers see Documentation/driver-api/pm/devices.rst. | 122 | drivers see :ref:`Documentation/driver-api/pm/devices.rst <driverapi_pm_devices>`. |
121 | 123 | ||
122 | Control: | 124 | Control: |
123 | In general if there is active maintenance of a driver by | 125 | In general if there is active maintenance of a driver by |
diff --git a/Documentation/s390/3270.ChangeLog b/Documentation/s390/3270.ChangeLog index 031c36081946..ecaf60b6c381 100644 --- a/Documentation/s390/3270.ChangeLog +++ b/Documentation/s390/3270.ChangeLog | |||
@@ -16,7 +16,7 @@ Sep 2002: Dynamically get 3270 input buffer | |||
16 | 16 | ||
17 | Sep 2002: Fix tubfs kmalloc()s | 17 | Sep 2002: Fix tubfs kmalloc()s |
18 | * Do read and write lengths correctly in fs3270_read() | 18 | * Do read and write lengths correctly in fs3270_read() |
19 | and fs3270_write(), whilst never asking kmalloc() | 19 | and fs3270_write(), while never asking kmalloc() |
20 | for more than 0x800 bytes. Affects tubfs.c and tubio.h. | 20 | for more than 0x800 bytes. Affects tubfs.c and tubio.h. |
21 | 21 | ||
22 | Sep 2002: Recognize 3270 control unit type 3174 | 22 | Sep 2002: Recognize 3270 control unit type 3174 |
diff --git a/Documentation/security/credentials.rst b/Documentation/security/credentials.rst index 5bb7125faeee..282e79feee6a 100644 --- a/Documentation/security/credentials.rst +++ b/Documentation/security/credentials.rst | |||
@@ -291,7 +291,7 @@ for example), it must be considered immutable, barring two exceptions: | |||
291 | 291 | ||
292 | 1. The reference count may be altered. | 292 | 1. The reference count may be altered. |
293 | 293 | ||
294 | 2. Whilst the keyring subscriptions of a set of credentials may not be | 294 | 2. While the keyring subscriptions of a set of credentials may not be |
295 | changed, the keyrings subscribed to may have their contents altered. | 295 | changed, the keyrings subscribed to may have their contents altered. |
296 | 296 | ||
297 | To catch accidental credential alteration at compile time, struct task_struct | 297 | To catch accidental credential alteration at compile time, struct task_struct |
@@ -358,7 +358,7 @@ Once a reference has been obtained, it must be released with ``put_cred()``, | |||
358 | Accessing Another Task's Credentials | 358 | Accessing Another Task's Credentials |
359 | ------------------------------------ | 359 | ------------------------------------ |
360 | 360 | ||
361 | Whilst a task may access its own credentials without the need for locking, the | 361 | While a task may access its own credentials without the need for locking, the |
362 | same is not true of a task wanting to access another task's credentials. It | 362 | same is not true of a task wanting to access another task's credentials. It |
363 | must use the RCU read lock and ``rcu_dereference()``. | 363 | must use the RCU read lock and ``rcu_dereference()``. |
364 | 364 | ||
@@ -382,7 +382,7 @@ This should be used inside the RCU read lock, as in the following example:: | |||
382 | } | 382 | } |
383 | 383 | ||
384 | Should it be necessary to hold another task's credentials for a long period of | 384 | Should it be necessary to hold another task's credentials for a long period of |
385 | time, and possibly to sleep whilst doing so, then the caller should get a | 385 | time, and possibly to sleep while doing so, then the caller should get a |
386 | reference on them using:: | 386 | reference on them using:: |
387 | 387 | ||
388 | const struct cred *get_task_cred(struct task_struct *task); | 388 | const struct cred *get_task_cred(struct task_struct *task); |
@@ -442,7 +442,7 @@ duplicate of the current process's credentials, returning with the mutex still | |||
442 | held if successful. It returns NULL if not successful (out of memory). | 442 | held if successful. It returns NULL if not successful (out of memory). |
443 | 443 | ||
444 | The mutex prevents ``ptrace()`` from altering the ptrace state of a process | 444 | The mutex prevents ``ptrace()`` from altering the ptrace state of a process |
445 | whilst security checks on credentials construction and changing is taking place | 445 | while security checks on credentials construction and changing is taking place |
446 | as the ptrace state may alter the outcome, particularly in the case of | 446 | as the ptrace state may alter the outcome, particularly in the case of |
447 | ``execve()``. | 447 | ``execve()``. |
448 | 448 | ||
diff --git a/Documentation/security/keys/request-key.rst b/Documentation/security/keys/request-key.rst index 21e27238cec6..600ad67d1707 100644 --- a/Documentation/security/keys/request-key.rst +++ b/Documentation/security/keys/request-key.rst | |||
@@ -132,7 +132,7 @@ Negative Instantiation And Rejection | |||
132 | Rather than instantiating a key, it is possible for the possessor of an | 132 | Rather than instantiating a key, it is possible for the possessor of an |
133 | authorisation key to negatively instantiate a key that's under construction. | 133 | authorisation key to negatively instantiate a key that's under construction. |
134 | This is a short duration placeholder that causes any attempt at re-requesting | 134 | This is a short duration placeholder that causes any attempt at re-requesting |
135 | the key whilst it exists to fail with error ENOKEY if negated or the specified | 135 | the key while it exists to fail with error ENOKEY if negated or the specified |
136 | error if rejected. | 136 | error if rejected. |
137 | 137 | ||
138 | This is provided to prevent excessive repeated spawning of /sbin/request-key | 138 | This is provided to prevent excessive repeated spawning of /sbin/request-key |
diff --git a/Documentation/serial/serial-rs485.txt b/Documentation/serial/serial-rs485.txt index 389fcd4759e9..ce0c1a9b8aab 100644 --- a/Documentation/serial/serial-rs485.txt +++ b/Documentation/serial/serial-rs485.txt | |||
@@ -75,7 +75,7 @@ | |||
75 | /* Set rts delay after send, if needed: */ | 75 | /* Set rts delay after send, if needed: */ |
76 | rs485conf.delay_rts_after_send = ...; | 76 | rs485conf.delay_rts_after_send = ...; |
77 | 77 | ||
78 | /* Set this flag if you want to receive data even whilst sending data */ | 78 | /* Set this flag if you want to receive data even while sending data */ |
79 | rs485conf.flags |= SER_RS485_RX_DURING_TX; | 79 | rs485conf.flags |= SER_RS485_RX_DURING_TX; |
80 | 80 | ||
81 | if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) { | 81 | if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) { |
diff --git a/Documentation/sound/soc/dai.rst b/Documentation/sound/soc/dai.rst index 55820e51708f..2e99183a7a47 100644 --- a/Documentation/sound/soc/dai.rst +++ b/Documentation/sound/soc/dai.rst | |||
@@ -24,7 +24,7 @@ I2S | |||
24 | === | 24 | === |
25 | 25 | ||
26 | I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and | 26 | I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and |
27 | Rx lines are used for audio transmission, whilst the bit clock (BCLK) and | 27 | Rx lines are used for audio transmission, while the bit clock (BCLK) and |
28 | left/right clock (LRC) synchronise the link. I2S is flexible in that either the | 28 | left/right clock (LRC) synchronise the link. I2S is flexible in that either the |
29 | controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock | 29 | controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock |
30 | usually varies depending on the sample rate and the master system clock | 30 | usually varies depending on the sample rate and the master system clock |
@@ -49,9 +49,9 @@ PCM | |||
49 | 49 | ||
50 | PCM is another 4 wire interface, very similar to I2S, which can support a more | 50 | PCM is another 4 wire interface, very similar to I2S, which can support a more |
51 | flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used | 51 | flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used |
52 | to synchronise the link whilst the Tx and Rx lines are used to transmit and | 52 | to synchronise the link while the Tx and Rx lines are used to transmit and |
53 | receive the audio data. Bit clock usually varies depending on sample rate | 53 | receive the audio data. Bit clock usually varies depending on sample rate |
54 | whilst sync runs at the sample rate. PCM also supports Time Division | 54 | while sync runs at the sample rate. PCM also supports Time Division |
55 | Multiplexing (TDM) in that several devices can use the bus simultaneously (this | 55 | Multiplexing (TDM) in that several devices can use the bus simultaneously (this |
56 | is sometimes referred to as network mode). | 56 | is sometimes referred to as network mode). |
57 | 57 | ||
diff --git a/Documentation/sound/soc/dpcm.rst b/Documentation/sound/soc/dpcm.rst index fe61e02277f8..f6845b2278ea 100644 --- a/Documentation/sound/soc/dpcm.rst +++ b/Documentation/sound/soc/dpcm.rst | |||
@@ -218,7 +218,7 @@ like a BT phone call :- | |||
218 | * * <----DAI5-----> FM | 218 | * * <----DAI5-----> FM |
219 | ************* | 219 | ************* |
220 | 220 | ||
221 | This allows the host CPU to sleep whilst the DSP, MODEM DAI and the BT DAI are | 221 | This allows the host CPU to sleep while the DSP, MODEM DAI and the BT DAI are |
222 | still in operation. | 222 | still in operation. |
223 | 223 | ||
224 | A BE DAI link can also set the codec to a dummy device if the code is a device | 224 | A BE DAI link can also set the codec to a dummy device if the code is a device |
diff --git a/Documentation/static-keys.txt b/Documentation/static-keys.txt index ab16efe0c79d..d68135560895 100644 --- a/Documentation/static-keys.txt +++ b/Documentation/static-keys.txt | |||
@@ -156,7 +156,7 @@ or increment/decrement function. | |||
156 | 156 | ||
157 | Note that switching branches results in some locks being taken, | 157 | Note that switching branches results in some locks being taken, |
158 | particularly the CPU hotplug lock (in order to avoid races against | 158 | particularly the CPU hotplug lock (in order to avoid races against |
159 | CPUs being brought in the kernel whilst the kernel is getting | 159 | CPUs being brought in the kernel while the kernel is getting |
160 | patched). Calling the static key API from within a hotplug notifier is | 160 | patched). Calling the static key API from within a hotplug notifier is |
161 | thus a sure deadlock recipe. In order to still allow use of the | 161 | thus a sure deadlock recipe. In order to still allow use of the |
162 | functionnality, the following functions are provided: | 162 | functionnality, the following functions are provided: |
diff --git a/Documentation/thermal/power_allocator.txt b/Documentation/thermal/power_allocator.txt index a1ce2235f121..9fb0ff06dca9 100644 --- a/Documentation/thermal/power_allocator.txt +++ b/Documentation/thermal/power_allocator.txt | |||
@@ -110,7 +110,7 @@ the permitted thermal "ramp" of the system. For instance, a lower | |||
110 | `k_pu` value will provide a slower ramp, at the cost of capping | 110 | `k_pu` value will provide a slower ramp, at the cost of capping |
111 | available capacity at a low temperature. On the other hand, a high | 111 | available capacity at a low temperature. On the other hand, a high |
112 | value of `k_pu` will result in the governor granting very high power | 112 | value of `k_pu` will result in the governor granting very high power |
113 | whilst temperature is low, and may lead to temperature overshooting. | 113 | while temperature is low, and may lead to temperature overshooting. |
114 | 114 | ||
115 | The default value for `k_pu` is: | 115 | The default value for `k_pu` is: |
116 | 116 | ||
diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst index f82434f2795e..0131df7f5968 100644 --- a/Documentation/trace/ftrace.rst +++ b/Documentation/trace/ftrace.rst | |||
@@ -24,13 +24,13 @@ It can be used for debugging or analyzing latencies and | |||
24 | performance issues that take place outside of user-space. | 24 | performance issues that take place outside of user-space. |
25 | 25 | ||
26 | Although ftrace is typically considered the function tracer, it | 26 | Although ftrace is typically considered the function tracer, it |
27 | is really a frame work of several assorted tracing utilities. | 27 | is really a framework of several assorted tracing utilities. |
28 | There's latency tracing to examine what occurs between interrupts | 28 | There's latency tracing to examine what occurs between interrupts |
29 | disabled and enabled, as well as for preemption and from a time | 29 | disabled and enabled, as well as for preemption and from a time |
30 | a task is woken to the task is actually scheduled in. | 30 | a task is woken to the task is actually scheduled in. |
31 | 31 | ||
32 | One of the most common uses of ftrace is the event tracing. | 32 | One of the most common uses of ftrace is the event tracing. |
33 | Through out the kernel is hundreds of static event points that | 33 | Throughout the kernel is hundreds of static event points that |
34 | can be enabled via the tracefs file system to see what is | 34 | can be enabled via the tracefs file system to see what is |
35 | going on in certain parts of the kernel. | 35 | going on in certain parts of the kernel. |
36 | 36 | ||
@@ -462,7 +462,7 @@ of ftrace. Here is a list of some of the key files: | |||
462 | 462 | ||
463 | mono_raw: | 463 | mono_raw: |
464 | This is the raw monotonic clock (CLOCK_MONOTONIC_RAW) | 464 | This is the raw monotonic clock (CLOCK_MONOTONIC_RAW) |
465 | which is montonic but is not subject to any rate adjustments | 465 | which is monotonic but is not subject to any rate adjustments |
466 | and ticks at the same rate as the hardware clocksource. | 466 | and ticks at the same rate as the hardware clocksource. |
467 | 467 | ||
468 | boot: | 468 | boot: |
@@ -914,8 +914,8 @@ The above is mostly meaningful for kernel developers. | |||
914 | current trace and the next trace. | 914 | current trace and the next trace. |
915 | 915 | ||
916 | - '$' - greater than 1 second | 916 | - '$' - greater than 1 second |
917 | - '@' - greater than 100 milisecond | 917 | - '@' - greater than 100 millisecond |
918 | - '*' - greater than 10 milisecond | 918 | - '*' - greater than 10 millisecond |
919 | - '#' - greater than 1000 microsecond | 919 | - '#' - greater than 1000 microsecond |
920 | - '!' - greater than 100 microsecond | 920 | - '!' - greater than 100 microsecond |
921 | - '+' - greater than 10 microsecond | 921 | - '+' - greater than 10 microsecond |
@@ -2541,7 +2541,7 @@ At compile time every C file object is run through the | |||
2541 | recordmcount program (located in the scripts directory). This | 2541 | recordmcount program (located in the scripts directory). This |
2542 | program will parse the ELF headers in the C object to find all | 2542 | program will parse the ELF headers in the C object to find all |
2543 | the locations in the .text section that call mcount. Starting | 2543 | the locations in the .text section that call mcount. Starting |
2544 | with gcc verson 4.6, the -mfentry has been added for x86, which | 2544 | with gcc version 4.6, the -mfentry has been added for x86, which |
2545 | calls "__fentry__" instead of "mcount". Which is called before | 2545 | calls "__fentry__" instead of "mcount". Which is called before |
2546 | the creation of the stack frame. | 2546 | the creation of the stack frame. |
2547 | 2547 | ||
@@ -2978,7 +2978,7 @@ The following commands are supported: | |||
2978 | When the function is hit, it will dump the contents of the ftrace | 2978 | When the function is hit, it will dump the contents of the ftrace |
2979 | ring buffer to the console. This is useful if you need to debug | 2979 | ring buffer to the console. This is useful if you need to debug |
2980 | something, and want to dump the trace when a certain function | 2980 | something, and want to dump the trace when a certain function |
2981 | is hit. Perhaps its a function that is called before a tripple | 2981 | is hit. Perhaps it's a function that is called before a triple |
2982 | fault happens and does not allow you to get a regular dump. | 2982 | fault happens and does not allow you to get a regular dump. |
2983 | 2983 | ||
2984 | - cpudump: | 2984 | - cpudump: |
diff --git a/Documentation/translations/it_IT/admin-guide/README.rst b/Documentation/translations/it_IT/admin-guide/README.rst new file mode 100644 index 000000000000..80f5ffc94a9e --- /dev/null +++ b/Documentation/translations/it_IT/admin-guide/README.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/admin-guide/README.rst <readme>` | ||
4 | |||
5 | .. _it_readme: | ||
6 | |||
7 | Rilascio del kernel Linux 4.x <http://kernel.org/> | ||
8 | =================================================== | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/admin-guide/security-bugs.rst b/Documentation/translations/it_IT/admin-guide/security-bugs.rst new file mode 100644 index 000000000000..18a5822c7d9a --- /dev/null +++ b/Documentation/translations/it_IT/admin-guide/security-bugs.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/admin-guide/security-bugs.rst <securitybugs>` | ||
4 | |||
5 | .. _it_securitybugs: | ||
6 | |||
7 | Bachi di sicurezza | ||
8 | ================== | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/doc-guide/kernel-doc.rst b/Documentation/translations/it_IT/doc-guide/kernel-doc.rst index 2bf1c1e2f394..a4ecd8f27631 100644 --- a/Documentation/translations/it_IT/doc-guide/kernel-doc.rst +++ b/Documentation/translations/it_IT/doc-guide/kernel-doc.rst | |||
@@ -107,7 +107,7 @@ macro simil-funzioni è il seguente:: | |||
107 | * Context: Describes whether the function can sleep, what locks it takes, | 107 | * Context: Describes whether the function can sleep, what locks it takes, |
108 | * releases, or expects to be held. It can extend over multiple | 108 | * releases, or expects to be held. It can extend over multiple |
109 | * lines. | 109 | * lines. |
110 | * Return: Describe the return value of foobar. | 110 | * Return: Describe the return value of function_name. |
111 | * | 111 | * |
112 | * The return value description can also have multiple paragraphs, and should | 112 | * The return value description can also have multiple paragraphs, and should |
113 | * be placed at the end of the comment block. | 113 | * be placed at the end of the comment block. |
diff --git a/Documentation/translations/it_IT/index.rst b/Documentation/translations/it_IT/index.rst index 898a7823a6f4..ea9b2916b3e4 100644 --- a/Documentation/translations/it_IT/index.rst +++ b/Documentation/translations/it_IT/index.rst | |||
@@ -86,6 +86,7 @@ vostre modifiche molto più semplice | |||
86 | .. toctree:: | 86 | .. toctree:: |
87 | :maxdepth: 2 | 87 | :maxdepth: 2 |
88 | 88 | ||
89 | process/index | ||
89 | doc-guide/index | 90 | doc-guide/index |
90 | kernel-hacking/index | 91 | kernel-hacking/index |
91 | 92 | ||
diff --git a/Documentation/translations/it_IT/kernel-hacking/locking.rst b/Documentation/translations/it_IT/kernel-hacking/locking.rst index 753643622c23..0ef31666663b 100644 --- a/Documentation/translations/it_IT/kernel-hacking/locking.rst +++ b/Documentation/translations/it_IT/kernel-hacking/locking.rst | |||
@@ -593,8 +593,8 @@ l'opzione ``GFP_KERNEL`` che è permessa solo in contesto utente. Ho supposto | |||
593 | che :c:func:`cache_add()` venga chiamata dal contesto utente, altrimenti | 593 | che :c:func:`cache_add()` venga chiamata dal contesto utente, altrimenti |
594 | questa opzione deve diventare un parametro di :c:func:`cache_add()`. | 594 | questa opzione deve diventare un parametro di :c:func:`cache_add()`. |
595 | 595 | ||
596 | Exposing Objects Outside This File | 596 | Esporre gli oggetti al di fuori del file |
597 | ---------------------------------- | 597 | ---------------------------------------- |
598 | 598 | ||
599 | Se i vostri oggetti contengono più informazioni, potrebbe non essere | 599 | Se i vostri oggetti contengono più informazioni, potrebbe non essere |
600 | sufficiente copiare i dati avanti e indietro: per esempio, altre parti del | 600 | sufficiente copiare i dati avanti e indietro: per esempio, altre parti del |
diff --git a/Documentation/translations/it_IT/process/1.Intro.rst b/Documentation/translations/it_IT/process/1.Intro.rst new file mode 100644 index 000000000000..c1be6dc398a7 --- /dev/null +++ b/Documentation/translations/it_IT/process/1.Intro.rst | |||
@@ -0,0 +1,297 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/1.Intro.rst <development_process_intro>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_intro: | ||
7 | |||
8 | Introduzione | ||
9 | ============ | ||
10 | |||
11 | Riepilogo generale | ||
12 | ------------------ | ||
13 | |||
14 | Il resto di questa sezione riguarda il processo di sviluppo del kernel e | ||
15 | quella sorta di frustrazione che gli sviluppatori e i loro datori di lavoro | ||
16 | potrebbero dover affrontare. Ci sono molte ragioni per le quali del codice | ||
17 | per il kernel debba essere incorporato nel kernel ufficiale, fra le quali: | ||
18 | disponibilità immediata agli utilizzatori, supporto della comunità in | ||
19 | differenti modalità, e la capacità di influenzare la direzione dello sviluppo | ||
20 | del kernel. | ||
21 | Il codice che contribuisce al kernel Linux deve essere reso disponibile sotto | ||
22 | una licenza GPL-compatibile. | ||
23 | |||
24 | La sezione :ref:`it_development_process` introduce il processo di sviluppo, | ||
25 | il ciclo di rilascio del kernel, ed i meccanismi della finestra | ||
26 | d'incorporazione. Il capitolo copre le varie fasi di una modifica: sviluppo, | ||
27 | revisione e ciclo d'incorporazione. Ci sono alcuni dibattiti su strumenti e | ||
28 | liste di discussione. Gli sviluppatori che sono in attesa di poter sviluppare | ||
29 | qualcosa per il kernel sono invitati ad individuare e sistemare bachi come | ||
30 | esercizio iniziale. | ||
31 | |||
32 | La sezione :ref:`it_development_early_stage` copre i primi stadi della | ||
33 | pianificazione di un progetto di sviluppo, con particolare enfasi sul | ||
34 | coinvolgimento della comunità, il prima possibile. | ||
35 | |||
36 | La sezione :ref:`it_development_coding` riguarda il processo di scrittura | ||
37 | del codice. Qui, sono esposte le diverse insidie che sono state già affrontate | ||
38 | da altri sviluppatori. Il capitolo copre anche alcuni dei requisiti per le | ||
39 | modifiche, ed esiste un'introduzione ad alcuni strumenti che possono aiutarvi | ||
40 | nell'assicurarvi che le modifiche per il kernel siano corrette. | ||
41 | |||
42 | La sezione :ref:`it_development_posting` parla del processo di pubblicazione | ||
43 | delle modifiche per la revisione. Per essere prese in considerazione dalla | ||
44 | comunità di sviluppo, le modifiche devono essere propriamente formattate ed | ||
45 | esposte, e devono essere inviate nel posto giusto. Seguire i consigli presenti | ||
46 | in questa sezione dovrebbe essere d'aiuto nell'assicurare la migliore | ||
47 | accoglienza possibile del vostro lavoro. | ||
48 | |||
49 | La sezione :ref:`it_development_followthrough` copre ciò che accade dopo | ||
50 | la pubblicazione delle modifiche; a questo punto il lavoro è lontano | ||
51 | dall'essere concluso. Lavorare con i revisori è una parte cruciale del | ||
52 | processo di sviluppo; questa sezione offre una serie di consigli su come | ||
53 | evitare problemi in questa importante fase. Gli sviluppatori sono diffidenti | ||
54 | nell'affermare che il lavoro è concluso quando una modifica è incorporata nei | ||
55 | sorgenti principali. | ||
56 | |||
57 | La sezione :ref:`it_development_advancedtopics` introduce un paio di argomenti | ||
58 | "avanzati": gestire le modifiche con git e controllare le modifiche pubblicate | ||
59 | da altri. | ||
60 | |||
61 | La sezione :ref:`it_development_conclusion` chiude il documento con dei | ||
62 | riferimenti ad altre fonti che forniscono ulteriori informazioni sullo sviluppo | ||
63 | del kernel. | ||
64 | |||
65 | Di cosa parla questo documento | ||
66 | ------------------------------ | ||
67 | |||
68 | Il kernel Linux, ha oltre 8 milioni di linee di codice e ben oltre 1000 | ||
69 | contributori ad ogni rilascio; è uno dei più vasti e più attivi software | ||
70 | liberi progettati mai esistiti. Sin dal sul modesto inizio nel 1991, | ||
71 | questo kernel si è evoluto nel miglior componente per sistemi operativi | ||
72 | che fanno funzionare piccoli riproduttori musicali, PC, grandi super computer | ||
73 | e tutte le altre tipologie di sistemi fra questi estremi. È una soluzione | ||
74 | robusta, efficiente ed adattabile a praticamente qualsiasi situazione. | ||
75 | |||
76 | Con la crescita di Linux è arrivato anche un aumento di sviluppatori | ||
77 | (ed aziende) desiderosi di partecipare a questo sviluppo. I produttori di | ||
78 | hardware vogliono assicurarsi che il loro prodotti siano supportati da Linux, | ||
79 | rendendo questi prodotti attrattivi agli utenti Linux. I produttori di | ||
80 | sistemi integrati, che usano Linux come componente di un prodotto integrato, | ||
81 | vogliono che Linux sia capace ed adeguato agli obiettivi ed il più possibile | ||
82 | alla mano. Fornitori ed altri produttori di software che basano i propri | ||
83 | prodotti su Linux hanno un chiaro interesse verso capacità, prestazioni ed | ||
84 | affidabilità del kernel Linux. E gli utenti finali, anche, spesso vorrebbero | ||
85 | cambiare Linux per renderlo più aderente alle proprie necessità. | ||
86 | |||
87 | Una delle caratteristiche più coinvolgenti di Linux è quella dell'accessibilità | ||
88 | per gli sviluppatori; chiunque con le capacità richieste può migliorare | ||
89 | Linux ed influenzarne la direzione di sviluppo. Prodotti non open-source non | ||
90 | possono offrire questo tipo di apertura, che è una caratteristica del software | ||
91 | libero. Ma, anzi, il kernel è persino più aperto rispetto a molti altri | ||
92 | progetti di software libero. Un classico ciclo di sviluppo trimestrale può | ||
93 | coinvolgere 1000 sviluppatori che lavorano per più di 100 differenti aziende | ||
94 | (o per nessuna azienda). | ||
95 | |||
96 | Lavorare con la comunità di sviluppo del kernel non è particolarmente | ||
97 | difficile. Ma, ciononostante, diversi potenziali contributori hanno trovato | ||
98 | delle difficoltà quando hanno cercato di lavorare sul kernel. La comunità del | ||
99 | kernel utilizza un proprio modo di operare che gli permette di funzionare | ||
100 | agevolmente (e genera un prodotto di alta qualità) in un ambiente dove migliaia | ||
101 | di stringhe di codice sono modificate ogni giorni. Quindi non deve sorprendere | ||
102 | che il processo di sviluppo del kernel differisca notevolmente dai metodi di | ||
103 | sviluppo privati. | ||
104 | |||
105 | Il processo di sviluppo del Kernel può, dall'altro lato, risultare | ||
106 | intimidatorio e strano ai nuovi sviluppatori, ma ha dietro di se buone ragioni | ||
107 | e solide esperienze. Uno sviluppatore che non comprende i modi della comunità | ||
108 | del kernel (o, peggio, che cerchi di aggirarli o violarli) avrà un'esperienza | ||
109 | deludente nel proprio bagaglio. La comunità di sviluppo, sebbene sia utile | ||
110 | a coloro che cercano di imparare, ha poco tempo da dedicare a coloro che non | ||
111 | ascoltano o coloro che non sono interessati al processo di sviluppo. | ||
112 | |||
113 | Si spera che coloro che leggono questo documento saranno in grado di evitare | ||
114 | queste esperienze spiacevoli. C'è molto materiale qui, ma lo sforzo della | ||
115 | lettura sarà ripagato in breve tempo. La comunità di sviluppo ha sempre | ||
116 | bisogno di sviluppatori che vogliano aiutare a rendere il kernel migliore; | ||
117 | il testo seguente potrebbe esservi d'aiuto - o essere d'aiuto ai vostri | ||
118 | collaboratori- per entrare a far parte della nostra comunità. | ||
119 | |||
120 | Crediti | ||
121 | ------- | ||
122 | |||
123 | Questo documento è stato scritto da Jonathan Corbet, corbet@lwn.net. | ||
124 | È stato migliorato da Johannes Berg, James Berry, Alex Chiang, Roland | ||
125 | Dreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh, | ||
126 | Amanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata e Jochen Voß. | ||
127 | |||
128 | Questo lavoro è stato supportato dalla Linux Foundation; un ringraziamento | ||
129 | speciale ad Amanda McPherson, che ha visto il valore di questo lavoro e lo ha | ||
130 | reso possibile. | ||
131 | |||
132 | L'importanza d'avere il codice nei sorgenti principali | ||
133 | ------------------------------------------------------ | ||
134 | |||
135 | Alcune aziende e sviluppatori ogni tanto si domandano perché dovrebbero | ||
136 | preoccuparsi di apprendere come lavorare con la comunità del kernel e di | ||
137 | inserire il loro codice nel ramo di sviluppo principale (per ramo principale | ||
138 | s'intende quello mantenuto da Linus Torvalds e usato come base dai | ||
139 | distributori Linux). Nel breve termine, contribuire al codice può sembrare | ||
140 | un costo inutile; può sembra più facile tenere separato il proprio codice e | ||
141 | supportare direttamente i suoi utilizzatori. La verità è che il tenere il | ||
142 | codice separato ("fuori dai sorgenti", *"out-of-tree"*) è un falso risparmio. | ||
143 | |||
144 | Per dimostrare i costi di un codice "fuori dai sorgenti", eccovi | ||
145 | alcuni aspetti rilevanti del processo di sviluppo kernel; la maggior parte | ||
146 | di essi saranno approfonditi dettagliatamente più avanti in questo documento. | ||
147 | Considerate: | ||
148 | |||
149 | - Il codice che è stato inserito nel ramo principale del kernel è disponibile | ||
150 | a tutti gli utilizzatori Linux. Sarà automaticamente presente in tutte le | ||
151 | distribuzioni che lo consentono. Non c'è bisogno di: driver per dischi, | ||
152 | scaricare file, o della scocciatura del dover supportare diverse versioni di | ||
153 | diverse distribuzioni; funziona già tutto, per gli sviluppatori e per gli | ||
154 | utilizzatori. L'inserimento nel ramo principale risolve un gran numero di | ||
155 | problemi di distribuzione e di supporto. | ||
156 | |||
157 | - Nonostante gli sviluppatori kernel si sforzino di tenere stabile | ||
158 | l'interfaccia dello spazio utente, quella interna al kernel è in continuo | ||
159 | cambiamento. La mancanza di un'interfaccia interna è deliberatamente una | ||
160 | decisione di progettazione; ciò permette che i miglioramenti fondamentali | ||
161 | vengano fatti in un qualsiasi momento e che risultino fatti con un codice di | ||
162 | alta qualità. Ma una delle conseguenze di questa politica è che qualsiasi | ||
163 | codice "fuori dai sorgenti" richiede costante manutenzione per renderlo | ||
164 | funzionante coi kernel più recenti. Tenere un codice "fuori dai sorgenti" | ||
165 | richiede una mole di lavoro significativa solo per farlo funzionare. | ||
166 | |||
167 | Invece, il codice che si trova nel ramo principale non necessita di questo | ||
168 | tipo di lavoro poiché ad ogni sviluppatore che faccia una modifica alle | ||
169 | interfacce viene richiesto di sistemare anche il codice che utilizza | ||
170 | quell'interfaccia. Quindi, il codice che è stato inserito nel ramo principale | ||
171 | ha dei costi di mantenimento significativamente più bassi. | ||
172 | |||
173 | - Oltre a ciò, spesso il codice che è all'interno del kernel sarà migliorato da | ||
174 | altri sviluppatori. Dare pieni poteri alla vostra comunità di utenti e ai | ||
175 | clienti può portare a sorprendenti risultati che migliorano i vostri | ||
176 | prodotti. | ||
177 | |||
178 | - Il codice kernel è soggetto a revisioni, sia prima che dopo l'inserimento | ||
179 | nel ramo principale. Non importa quanto forti fossero le abilità dello | ||
180 | sviluppatore originale, il processo di revisione troverà il modo di migliore | ||
181 | il codice. Spesso la revisione trova bachi importanti e problemi di | ||
182 | sicurezza. Questo è particolarmente vero per il codice che è stato | ||
183 | sviluppato in un ambiente chiuso; tale codice ottiene un forte beneficio | ||
184 | dalle revisioni provenienti da sviluppatori esteri. Il codice | ||
185 | "fuori dai sorgenti", invece, è un codice di bassa qualità. | ||
186 | |||
187 | - La partecipazione al processo di sviluppo costituisce la vostra via per | ||
188 | influenzare la direzione di sviluppo del kernel. Gli utilizzatori che | ||
189 | "reclamano da bordo campo" sono ascoltati, ma gli sviluppatori attivi | ||
190 | hanno una voce più forte - e la capacità di implementare modifiche che | ||
191 | renderanno il kernel più funzionale alle loro necessità. | ||
192 | |||
193 | - Quando il codice è gestito separatamente, esiste sempre la possibilità che | ||
194 | terze parti contribuiscano con una differente implementazione che fornisce | ||
195 | le stesse funzionalità. Se dovesse accadere, l'inserimento del codice | ||
196 | diventerà molto più difficile - fino all'impossibilità. Poi, dovrete far | ||
197 | fronte a delle alternative poco piacevoli, come: (1) mantenere un elemento | ||
198 | non standard "fuori dai sorgenti" per un tempo indefinito, o (2) abbandonare | ||
199 | il codice e far migrare i vostri utenti alla versione "nei sorgenti". | ||
200 | |||
201 | - Contribuire al codice è l'azione fondamentale che fa funzionare tutto il | ||
202 | processo. Contribuendo attraverso il vostro codice potete aggiungere nuove | ||
203 | funzioni al kernel e fornire competenze ed esempi che saranno utili ad | ||
204 | altri sviluppatori. Se avete sviluppato del codice Linux (o state pensando | ||
205 | di farlo), avete chiaramente interesse nel far proseguire il successo di | ||
206 | questa piattaforma. Contribuire al codice è une delle migliori vie per | ||
207 | aiutarne il successo. | ||
208 | |||
209 | Il ragionamento sopra citato si applica ad ogni codice "fuori dai sorgenti" | ||
210 | dal kernel, incluso il codice proprietario distribuito solamente in formato | ||
211 | binario. Ci sono, comunque, dei fattori aggiuntivi che dovrebbero essere | ||
212 | tenuti in conto prima di prendere in considerazione qualsiasi tipo di | ||
213 | distribuzione binaria di codice kernel. Questo include che: | ||
214 | |||
215 | - Le questioni legali legate alla distribuzione di moduli kernel proprietari | ||
216 | sono molto nebbiose; parecchi detentori di copyright sul kernel credono che | ||
217 | molti moduli binari siano prodotti derivati del kernel e che, come risultato, | ||
218 | la loro diffusione sia una violazione della licenza generale di GNU (della | ||
219 | quale si parlerà più avanti). L'autore qui non è un avvocato, e | ||
220 | niente in questo documento può essere considerato come un consiglio legale. | ||
221 | Il vero stato legale dei moduli proprietari può essere determinato | ||
222 | esclusivamente da un giudice. Ma l'incertezza che perseguita quei moduli | ||
223 | è lì comunque. | ||
224 | |||
225 | - I moduli binari aumentano di molto la difficoltà di fare debugging del | ||
226 | kernel, al punto che la maggior parte degli sviluppatori del kernel non | ||
227 | vorranno nemmeno tentare. Quindi la diffusione di moduli esclusivamente | ||
228 | binari renderà difficile ai vostri utilizzatori trovare un supporto dalla | ||
229 | comunità. | ||
230 | |||
231 | - Il supporto è anche difficile per i distributori di moduli binari che devono | ||
232 | fornire una versione del modulo per ogni distribuzione e per ogni versione | ||
233 | del kernel che vogliono supportate. Per fornire una copertura ragionevole e | ||
234 | comprensiva, può essere richiesto di produrre dozzine di singoli moduli. | ||
235 | E inoltre i vostri utilizzatori dovranno aggiornare il vostro modulo | ||
236 | separatamente ogni volta che aggiornano il loro kernel. | ||
237 | |||
238 | - Tutto ciò che è stato detto prima riguardo alla revisione del codice si | ||
239 | applica doppiamente al codice proprietario. Dato che questo codice non è | ||
240 | del tutto disponibile, non può essere revisionato dalla comunità e avrà, | ||
241 | senza dubbio, seri problemi. | ||
242 | |||
243 | I produttori di sistemi integrati, in particolare, potrebbero esser tentati | ||
244 | dall'evitare molto di ciò che è stato detto in questa sezione, credendo che | ||
245 | stiano distribuendo un prodotto finito che utilizza una versione del kernel | ||
246 | immutabile e che non richiede un ulteriore sviluppo dopo il rilascio. Questa | ||
247 | idea non comprende il valore di una vasta revisione del codice e il valore | ||
248 | del permettere ai propri utenti di aggiungere funzionalità al vostro prodotto. | ||
249 | Ma anche questi prodotti, hanno una vita commerciale limitata, dopo la quale | ||
250 | deve essere rilasciata una nuova versione. A quel punto, i produttori il cui | ||
251 | codice è nel ramo principale di sviluppo avranno un codice ben mantenuto e | ||
252 | saranno in una posizione migliore per ottenere velocemente un nuovo prodotto | ||
253 | pronto per essere distribuito. | ||
254 | |||
255 | |||
256 | Licenza | ||
257 | ------- | ||
258 | |||
259 | IL codice Linux utilizza diverse licenze, ma il codice completo deve essere | ||
260 | compatibile con la seconda versione della licenza GNU General Public License | ||
261 | (GPLv2), che è la licenza che copre la distribuzione del kernel. | ||
262 | Nella pratica, ciò significa che tutti i contributi al codice sono coperti | ||
263 | anche'essi dalla GPLv2 (con, opzionalmente, una dicitura che permette la | ||
264 | possibilità di distribuirlo con licenze più recenti di GPL) o dalla licenza | ||
265 | three-clause BSD. Qualsiasi contributo che non è coperto da una licenza | ||
266 | compatibile non verrà accettata nel kernel. | ||
267 | |||
268 | Per il codice sottomesso al kernel non è necessario (o richiesto) la | ||
269 | concessione del Copyright. Tutto il codice inserito nel ramo principale del | ||
270 | kernel conserva la sua proprietà originale; ne risulta che ora il kernel abbia | ||
271 | migliaia di proprietari. | ||
272 | |||
273 | Una conseguenza di questa organizzazione della proprietà è che qualsiasi | ||
274 | tentativo di modifica della licenza del kernel è destinata ad un quasi sicuro | ||
275 | fallimento. Esistono alcuni scenari pratici nei quali il consenso di tutti | ||
276 | i detentori di copyright può essere ottenuto (o il loro codice verrà rimosso | ||
277 | dal kernel). Quindi, in sostanza, non esiste la possibilità che si giunga ad | ||
278 | una versione 3 della licenza GPL nel prossimo futuro. | ||
279 | |||
280 | È imperativo che tutto il codice che contribuisce al kernel sia legittimamente | ||
281 | software libero. Per questa ragione, un codice proveniente da un contributore | ||
282 | anonimo (o sotto pseudonimo) non verrà accettato. È richiesto a tutti i | ||
283 | contributori di firmare il proprio codice, attestando così che quest'ultimo | ||
284 | può essere distribuito insieme al kernel sotto la licenza GPL. Il codice che | ||
285 | non è stato licenziato come software libero dal proprio creatore, o che | ||
286 | potrebbe creare problemi di copyright per il kernel (come il codice derivante | ||
287 | da processi di ingegneria inversa senza le opportune tutele), non può essere | ||
288 | diffuso. | ||
289 | |||
290 | Domande relative a questioni legate al copyright sono frequenti nelle liste | ||
291 | di discussione dedicate allo sviluppo di Linux. Tali quesiti, normalmente, | ||
292 | non riceveranno alcuna risposta, ma una cosa deve essere tenuta presente: | ||
293 | le persone che risponderanno a quelle domande non sono avvocati e non possono | ||
294 | fornire supporti legali. Se avete questioni legali relative ai sorgenti | ||
295 | del codice Linux, non esiste alternativa che quella di parlare con un | ||
296 | avvocato esperto nel settore. Fare affidamento sulle risposte ottenute da | ||
297 | una lista di discussione tecnica è rischioso. | ||
diff --git a/Documentation/translations/it_IT/process/2.Process.rst b/Documentation/translations/it_IT/process/2.Process.rst new file mode 100644 index 000000000000..9af4d01617c4 --- /dev/null +++ b/Documentation/translations/it_IT/process/2.Process.rst | |||
@@ -0,0 +1,531 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/2.Process.rst <development_process>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_process: | ||
7 | |||
8 | Come funziona il processo di sviluppo | ||
9 | ===================================== | ||
10 | |||
11 | Lo sviluppo del Kernel agli inizi degli anno '90 era abbastanza libero, con | ||
12 | un numero di utenti e sviluppatori relativamente basso. Con una base | ||
13 | di milioni di utenti e con 2000 sviluppatori coinvolti nel giro di un anno, | ||
14 | il kernel da allora ha messo in atto un certo numero di procedure per rendere | ||
15 | lo sviluppo più agevole. È richiesta una solida conoscenza di come tale | ||
16 | processo si svolge per poter esserne parte attiva. | ||
17 | |||
18 | Il quadro d'insieme | ||
19 | ------------------- | ||
20 | |||
21 | Gli sviluppatori kernel utilizzano un calendario di rilascio generico, dove | ||
22 | ogni due o tre mesi viene effettuata un rilascio importante del kernel. | ||
23 | I rilasci più recenti sono stati: | ||
24 | |||
25 | ====== ================= | ||
26 | 4.11 Aprile 30, 2017 | ||
27 | 4.12 Luglio 2, 2017 | ||
28 | 4.13 Settembre 3, 2017 | ||
29 | 4.14 Novembre 12, 2017 | ||
30 | 4.15 Gennaio 28, 2018 | ||
31 | 4.16 Aprile 1, 2018 | ||
32 | ====== ================= | ||
33 | |||
34 | Ciascun rilascio 4.x è un importante rilascio del kernel con nuove | ||
35 | funzionalità, modifiche interne dell'API, e molto altro. Un tipico | ||
36 | rilascio 4.x contiene quasi 13,000 gruppi di modifiche con ulteriori | ||
37 | modifiche a parecchie migliaia di linee di codice. La 4.x. è pertanto la | ||
38 | linea di confine nello sviluppo del kernel Linux; il kernel utilizza un sistema | ||
39 | di sviluppo continuo che integra costantemente nuove importanti modifiche. | ||
40 | |||
41 | Viene seguita una disciplina abbastanza lineare per l'inclusione delle | ||
42 | patch di ogni rilascio. All'inizio di ogni ciclo di sviluppo, la | ||
43 | "finestra di inclusione" viene dichiarata aperta. In quel momento il codice | ||
44 | ritenuto sufficientemente stabile(e che è accettato dalla comunità di sviluppo) | ||
45 | viene incluso nel ramo principale del kernel. La maggior parte delle | ||
46 | patch per un nuovo ciclo di sviluppo (e tutte le più importanti modifiche) | ||
47 | saranno inserite durante questo periodo, ad un ritmo che si attesta sulle | ||
48 | 1000 modifiche ("patch" o "gruppo di modifiche") al giorno. | ||
49 | |||
50 | (per inciso, vale la pena notare che i cambiamenti integrati durante la | ||
51 | "finestra di inclusione" non escono dal nulla; questi infatti, sono stati | ||
52 | raccolti e, verificati in anticipo. Il funzionamento di tale procedimento | ||
53 | verrà descritto dettagliatamente più avanti). | ||
54 | |||
55 | La finestra di inclusione resta attiva approssimativamente per due settimane. | ||
56 | Al termine di questo periodo, Linus Torvald dichiarerà che la finestra è | ||
57 | chiusa e rilascerà il primo degli "rc" del kernel. | ||
58 | Per il kernel che è destinato ad essere 2.6.40, per esempio, il rilascio | ||
59 | che emerge al termine della finestra d'inclusione si chiamerà 2.6.40-rc1. | ||
60 | Questo rilascio indica che il momento di aggiungere nuovi componenti è | ||
61 | passato, e che è iniziato il periodo di stabilizzazione del prossimo kernel. | ||
62 | |||
63 | Nelle successive sei/dieci settimane, potranno essere sottoposte solo modifiche | ||
64 | che vanno a risolvere delle problematiche. Occasionalmente potrà essere | ||
65 | consentita una modifica più consistente, ma tali occasioni sono rare. | ||
66 | Gli sviluppatori che tenteranno di aggiungere nuovi elementi al di fuori della | ||
67 | finestra di inclusione, tendenzialmente, riceveranno un accoglienza poco | ||
68 | amichevole. Come regola generale: se vi perdete la finestra di inclusione per | ||
69 | un dato componente, la cosa migliore da fare è aspettare il ciclo di sviluppo | ||
70 | successivo (un'eccezione può essere fatta per i driver per hardware non | ||
71 | supportati in precedenza; se toccano codice non facente parte di quello | ||
72 | attuale, che non causino regressioni e che potrebbero essere aggiunti in | ||
73 | sicurezza in un qualsiasi momento) | ||
74 | |||
75 | Mentre le correzioni si aprono la loro strada all'interno del ramo principale, | ||
76 | il ritmo delle modifiche rallenta col tempo. Linus rilascia un nuovo | ||
77 | kernel -rc circa una volta alla settimana; e ne usciranno circa 6 o 9 prima | ||
78 | che il kernel venga considerato sufficientemente stabile e che il rilascio | ||
79 | finale 2.6.x venga fatto. A quel punto tutto il processo ricomincerà. | ||
80 | |||
81 | Esempio: ecco com'è andato il ciclo di sviluppo della versione 4.16 | ||
82 | (tutte le date si collocano nel 2018) | ||
83 | |||
84 | |||
85 | ============== ======================================= | ||
86 | Gennaio 28 4.15 rilascio stabile | ||
87 | Febbraio 11 4.16-rc1, finestra di inclusione chiusa | ||
88 | Febbraio 18 4.16-rc2 | ||
89 | Febbraio 25 4.16-rc3 | ||
90 | Marzo 4 4.16-rc4 | ||
91 | Marzo 11 4.16-rc5 | ||
92 | Marzo 18 4.16-rc6 | ||
93 | Marzo 25 4.16-rc7 | ||
94 | Aprile 1 4.17 rilascio stabile | ||
95 | ============== ======================================= | ||
96 | |||
97 | In che modo gli sviluppatori decidono quando chiudere il ciclo di sviluppo e | ||
98 | creare quindi una rilascio stabile? Un metro valido è il numero di regressioni | ||
99 | rilevate nel precedente rilascio. Nessun baco è il benvenuto, ma quelli che | ||
100 | procurano problemi su sistemi che hanno funzionato in passato sono considerati | ||
101 | particolarmente seri. Per questa ragione, le modifiche che portano ad una | ||
102 | regressione sono viste sfavorevolmente e verranno quasi sicuramente annullate | ||
103 | durante il periodo di stabilizzazione. | ||
104 | |||
105 | L'obiettivo degli sviluppatori è quello di aggiustare tutte le regressioni | ||
106 | conosciute prima che avvenga il rilascio stabile. Nel mondo reale, questo | ||
107 | tipo di perfezione difficilmente viene raggiunta; esistono troppe variabili | ||
108 | in un progetto di questa portata. Arriva un punto dove ritardare il rilascio | ||
109 | finale peggiora la situazione; la quantità di modifiche in attesa della | ||
110 | prossima finestra di inclusione crescerà enormemente, creando ancor più | ||
111 | regressioni al giro successivo. Quindi molti kernel 4.x escono con una | ||
112 | manciata di regressioni delle quali, si spera, nessuna è grave. | ||
113 | |||
114 | Una volta che un rilascio stabile è fatto, il suo costante mantenimento è | ||
115 | affidato al "squadra stabilità", attualmente composta da Greg Kroah-Hartman. | ||
116 | Questa squadra rilascia occasionalmente degli aggiornamenti relativi al | ||
117 | rilascio stabile usando la numerazione 4.x.y. Per essere presa in | ||
118 | considerazione per un rilascio d'aggiornamento, una modifica deve: | ||
119 | (1) correggere un baco importante (2) essere già inserita nel ramo principale | ||
120 | per il prossimo sviluppo del kernel. Solitamente, passato il loro rilascio | ||
121 | iniziale, i kernel ricevono aggiornamenti per più di un ciclo di sviluppo. | ||
122 | Quindi, per esempio, la storia del kernel 4.13 appare così: | ||
123 | |||
124 | ============== =============================== | ||
125 | Settembre 3 4.13 rilascio stabile | ||
126 | Settembre 13 4.13.1 | ||
127 | Settembre 20 4.13.2 | ||
128 | Settembre 27 4.13.3 | ||
129 | Ottobre 5 4.13.4 | ||
130 | Ottobre 12 4.13.5 | ||
131 | ... ... | ||
132 | Novembre 24 4.13.16 | ||
133 | ============== =============================== | ||
134 | |||
135 | La 4.13.16 fu l'aggiornamento finale per la versione 4.13. | ||
136 | |||
137 | Alcuni kernel sono destinati ad essere kernel a "lungo termine"; questi | ||
138 | riceveranno assistenza per un lungo periodo di tempo. Al momento in cui | ||
139 | scriviamo, i manutentori dei kernel stabili a lungo termine sono: | ||
140 | |||
141 | ====== ====================== ========================================== | ||
142 | 3.16 Ben Hutchings (kernel stabile molto più a lungo termine) | ||
143 | 4.1 Sasha Levin | ||
144 | 4.4 Greg Kroah-Hartman (kernel stabile molto più a lungo termine) | ||
145 | 4.9 Greg Kroah-Hartman | ||
146 | 4.14 Greg Kroah-Hartman | ||
147 | ====== ====================== ========================================== | ||
148 | |||
149 | |||
150 | Questa selezione di kernel di lungo periodo sono puramente dovuti ai loro | ||
151 | manutentori, alla loro necessità e al tempo per tenere aggiornate proprio | ||
152 | quelle versioni. Non ci sono altri kernel a lungo termine in programma per | ||
153 | alcun rilascio in arrivo. | ||
154 | |||
155 | Il ciclo di vita di una patch | ||
156 | ----------------------------- | ||
157 | |||
158 | Le patch non passano direttamente dalla tastiera dello sviluppatori | ||
159 | al ramo principale del kernel. Esiste, invece, una procedura disegnata | ||
160 | per assicurare che ogni patch sia di buona qualità e desiderata nel | ||
161 | ramo principale. Questo processo avviene velocemente per le correzioni | ||
162 | meno importanti, o, nel caso di patch ampie e controverse, va avanti per anni. | ||
163 | Per uno sviluppatore la maggior frustrazione viene dalla mancanza di | ||
164 | comprensione di questo processo o dai tentativi di aggirarlo. | ||
165 | |||
166 | Nella speranza di ridurre questa frustrazione, questo documento spiegherà | ||
167 | come una patch viene inserita nel kernel. Ciò che segue è un'introduzione | ||
168 | che descrive il processo ideale. Approfondimenti verranno invece trattati | ||
169 | più avanti. | ||
170 | |||
171 | Una patch attraversa, generalmente, le seguenti fasi: | ||
172 | |||
173 | - Progetto. In questa fase sono stabilite quelli che sono i requisiti | ||
174 | della modifica - e come verranno soddisfatti. Il lavoro di progettazione | ||
175 | viene spesso svolto senza coinvolgere la comunità, ma è meglio renderlo | ||
176 | il più aperto possibile; questo può far risparmiare molto tempo evitando | ||
177 | eventuali riprogettazioni successive. | ||
178 | |||
179 | - Prima revisione. Le patch vengono pubblicate sulle liste di discussione | ||
180 | interessate, e gli sviluppatori in quella lista risponderanno coi loro | ||
181 | commenti. Se si svolge correttamente, questo procedimento potrebbe far | ||
182 | emergere problemi rilevanti in una patch. | ||
183 | |||
184 | - Revisione più ampia. Quando la patch è quasi pronta per essere inserita | ||
185 | nel ramo principale, un manutentore importante del sottosistema dovrebbe | ||
186 | accettarla - anche se, questa accettazione non è una garanzia che la | ||
187 | patch arriverà nel ramo principale. La patch sarà visibile nei sorgenti | ||
188 | del sottosistema in questione e nei sorgenti -next (descritti sotto). | ||
189 | Quando il processo va a buon fine, questo passo porta ad una revisione | ||
190 | più estesa della patch e alla scoperta di problemi d'integrazione | ||
191 | con il lavoro altrui. | ||
192 | |||
193 | - Per favore, tenete da conto che la maggior parte dei manutentori ha | ||
194 | anche un lavoro quotidiano, quindi integrare le vostre patch potrebbe | ||
195 | non essere la loro priorità più alta. Se una vostra patch riceve | ||
196 | dei suggerimenti su dei cambiamenti necessari, dovreste applicare | ||
197 | quei cambiamenti o giustificare perché non sono necessari. Se la vostra | ||
198 | patch non riceve alcuna critica ma non è stata integrata dal | ||
199 | manutentore del driver o sottosistema, allora dovreste continuare con | ||
200 | i necessari aggiornamenti per mantenere la patch aggiornata al kernel | ||
201 | più recente cosicché questa possa integrarsi senza problemi; continuate | ||
202 | ad inviare gli aggiornamenti per essere revisionati e integrati. | ||
203 | |||
204 | - Inclusione nel ramo principale. Eventualmente, una buona patch verrà | ||
205 | inserita all'interno nel repositorio principale, gestito da | ||
206 | Linus Torvalds. In questa fase potrebbero emergere nuovi problemi e/o | ||
207 | commenti; è importante che lo sviluppatore sia collaborativo e che sistemi | ||
208 | ogni questione che possa emergere. | ||
209 | |||
210 | - Rilascio stabile. Ora, il numero di utilizzatori che sono potenzialmente | ||
211 | toccati dalla patch è aumentato, quindi, ancora una volta, potrebbero | ||
212 | emergere nuovi problemi. | ||
213 | |||
214 | - Manutenzione di lungo periodo. Nonostante sia possibile che uno sviluppatore | ||
215 | si dimentichi del codice dopo la sua integrazione, questo comportamento | ||
216 | lascia una brutta impressione nella comunità di sviluppo. Integrare il | ||
217 | codice elimina alcuni degli oneri facenti parte della manutenzione, in | ||
218 | particolare, sistemerà le problematiche causate dalle modifiche all'API. | ||
219 | Ma lo sviluppatore originario dovrebbe continuare ad assumersi la | ||
220 | responsabilità per il codice se quest'ultimo continua ad essere utile | ||
221 | nel lungo periodo. | ||
222 | |||
223 | Uno dei più grandi errori fatti dagli sviluppatori kernel (o dai loro datori | ||
224 | di lavoro) è quello di cercare di ridurre tutta la procedura ad una singola | ||
225 | "integrazione nel remo principale". Questo approccio inevitabilmente conduce | ||
226 | a una condizione di frustrazione per tutti coloro che sono coinvolti. | ||
227 | |||
228 | Come le modifiche finiscono nel Kernel | ||
229 | -------------------------------------- | ||
230 | |||
231 | Esiste una sola persona che può inserire le patch nel repositorio principale | ||
232 | del kernel: Linus Torvalds. Ma, di tutte le 9500 patch che entrarono nella | ||
233 | versione 2.6.38 del kernel, solo 112 (circa l'1,3%) furono scelte direttamente | ||
234 | da Linus in persona. Il progetto del kernel è cresciuto fino a raggiungere | ||
235 | una dimensione tale per cui un singolo sviluppatore non può controllare e | ||
236 | selezionare indipendentemente ogni modifica senza essere supportato. | ||
237 | La via scelta dagli sviluppatori per indirizzare tale crescita è stata quella | ||
238 | di utilizzare un sistema di "sottotenenti" basato sulla fiducia. | ||
239 | |||
240 | Il codice base del kernel è spezzato in una serie si sottosistemi: rete, | ||
241 | supporto per specifiche architetture, gestione della memoria, video e | ||
242 | strumenti, etc. Molti sottosistemi hanno un manutentore designato: ovvero uno | ||
243 | sviluppatore che ha piena responsabilità di tutto il codice presente in quel | ||
244 | sottosistema. Tali manutentori di sottosistema sono i guardiani | ||
245 | (in un certo senso) della parte di kernel che gestiscono; sono coloro che | ||
246 | (solitamente) accetteranno una patch per l'inclusione nel ramo principale | ||
247 | del kernel. | ||
248 | |||
249 | I manutentori di sottosistema gestiscono ciascuno la propria parte dei sorgenti | ||
250 | del kernel, utilizzando abitualmente (ma certamente non sempre) git. | ||
251 | Strumenti come git (e affini come quilt o mercurial) permettono ai manutentori | ||
252 | di stilare una lista delle patch, includendo informazioni sull'autore ed | ||
253 | altri metadati. In ogni momento, il manutentore può individuare quale patch | ||
254 | nel sua repositorio non si trova nel ramo principale. | ||
255 | |||
256 | Quando la "finestra di integrazione" si apre, i manutentori di alto livello | ||
257 | chiederanno a Linus di "prendere" dai loro repositori le modifiche che hanno | ||
258 | selezionato per l'inclusione. Se Linus acconsente, il flusso di patch si | ||
259 | convoglierà nel repositorio di quest ultimo, divenendo così parte del ramo | ||
260 | principale del kernel. La quantità d'attenzione che Linus presta alle | ||
261 | singole patch ricevute durante l'operazione di integrazione varia. | ||
262 | È chiaro che, qualche volta, guardi più attentamente. Ma, come regola | ||
263 | generale, Linus confida nel fatto che i manutentori di sottosistema non | ||
264 | selezionino pessime patch. | ||
265 | |||
266 | I manutentori di sottosistemi, a turno, possono "prendere" patch | ||
267 | provenienti da altri manutentori. Per esempio, i sorgenti per la rete rete | ||
268 | sono costruiti da modifiche che si sono accumulate inizialmente nei sorgenti | ||
269 | dedicati ai driver per dispositivi di rete, rete senza fili, ecc. Tale | ||
270 | catena di repositori può essere più o meno lunga, benché raramente ecceda | ||
271 | i due o tre collegamenti. Questo processo è conosciuto come | ||
272 | "la catena della fiducia", perché ogni manutentore all'interno della | ||
273 | catena si fida di coloro che gestiscono i livelli più bassi. | ||
274 | |||
275 | Chiaramente, in un sistema come questo, l'inserimento delle patch all'interno | ||
276 | del kernel si basa sul trovare il manutentore giusto. Di norma, inviare | ||
277 | patch direttamente a Linus non è la via giusta. | ||
278 | |||
279 | |||
280 | Sorgenti -next | ||
281 | -------------- | ||
282 | |||
283 | La catena di sottosistemi guida il flusso di patch all'interno del kernel, | ||
284 | ma solleva anche un interessante quesito: se qualcuno volesse vedere tutte le | ||
285 | patch pronte per la prossima finestra di integrazione? | ||
286 | Gli sviluppatori si interesseranno alle patch in sospeso per verificare | ||
287 | che non ci siano altri conflitti di cui preoccuparsi; una modifica che, per | ||
288 | esempio, cambia il prototipo di una funzione fondamentale del kernel andrà in | ||
289 | conflitto con qualsiasi altra modifica che utilizzi la vecchia versione di | ||
290 | quella funzione. Revisori e tester vogliono invece avere accesso alle | ||
291 | modifiche nella loro totalità prima che approdino nel ramo principale del | ||
292 | kernel. Uno potrebbe prendere le patch provenienti da tutti i sottosistemi | ||
293 | d'interesse, ma questo sarebbe un lavoro enorme e fallace. | ||
294 | |||
295 | La risposta ci viene sotto forma di sorgenti -next, dove i sottosistemi sono | ||
296 | raccolti per essere testati e controllati. Il più vecchio di questi sorgenti, | ||
297 | gestito da Andrew Morton, è chiamato "-mm" (memory management, che è l'inizio | ||
298 | di tutto). L'-mm integra patch proveniente da una lunga lista di sottosistemi; | ||
299 | e ha, inoltre, alcune patch destinate al supporto del debugging. | ||
300 | |||
301 | Oltre a questo, -mm contiene una raccolta significativa di patch che sono | ||
302 | state selezionate da Andrew direttamente. Queste patch potrebbero essere | ||
303 | state inviate in una lista di discussione, o possono essere applicate ad una | ||
304 | parte del kernel per la quale non esiste un sottosistema dedicato. | ||
305 | Di conseguenza, -mm opera come una specie di sottosistema "ultima spiaggia"; | ||
306 | se per una patch non esiste una via chiara per entrare nel ramo principale, | ||
307 | allora è probabile che finirà in -mm. Le patch passate per -mm | ||
308 | eventualmente finiranno nel sottosistema più appropriato o saranno inviate | ||
309 | direttamente a Linus. In un tipico ciclo di sviluppo, circa il 5-10% delle | ||
310 | patch andrà nel ramo principale attraverso -mm. | ||
311 | |||
312 | La patch -mm correnti sono disponibili nella cartella "mmotm" (-mm of | ||
313 | the moment) all'indirizzo: | ||
314 | |||
315 | http://www.ozlabs.org/~akpm/mmotm/ | ||
316 | |||
317 | È molto probabile che l'uso dei sorgenti MMOTM diventi un'esperienza | ||
318 | frustrante; ci sono buone probabilità che non compili nemmeno. | ||
319 | |||
320 | I sorgenti principali per il prossimo ciclo d'integrazione delle patch | ||
321 | è linux-next, gestito da Stephen Rothwell. I sorgenti linux-next sono, per | ||
322 | definizione, un'istantanea di come dovrà apparire il ramo principale dopo che | ||
323 | la prossima finestra di inclusione si chiuderà. I linux-next sono annunciati | ||
324 | sulla lista di discussione linux-kernel e linux-next nel momento in cui | ||
325 | vengono assemblati; e possono essere scaricate da: | ||
326 | |||
327 | http://www.kernel.org/pub/linux/kernel/next/ | ||
328 | |||
329 | Linux-next è divenuto parte integrante del processo di sviluppo del kernel; | ||
330 | tutte le patch incorporate durante una finestra di integrazione dovrebbero | ||
331 | aver trovato la propria strada in linux-next, a volte anche prima dell'apertura | ||
332 | della finestra di integrazione. | ||
333 | |||
334 | |||
335 | Sorgenti in preparazione | ||
336 | ------------------------ | ||
337 | |||
338 | Nei sorgenti del kernel esiste la cartella drivers/staging/, dove risiedono | ||
339 | molte sotto-cartelle per i driver o i filesystem che stanno per essere aggiunti | ||
340 | al kernel. Questi restano nella cartella drivers/staging fintanto che avranno | ||
341 | bisogno di maggior lavoro; una volta completato, possono essere spostate | ||
342 | all'interno del kernel nel posto più appropriato. Questo è il modo di tener | ||
343 | traccia dei driver che non sono ancora in linea con gli standard di codifica | ||
344 | o qualità, ma che le persone potrebbero voler usare ugualmente e tracciarne | ||
345 | lo sviluppo. | ||
346 | |||
347 | Greg Kroah-Hartman attualmente gestisce i sorgenti in preparazione. I driver | ||
348 | che non sono completamente pronti vengono inviati a lui, e ciascun driver avrà | ||
349 | la propria sotto-cartella in drivers/staging/. Assieme ai file sorgenti | ||
350 | dei driver, dovrebbe essere presente nella stessa cartella anche un file TODO. | ||
351 | Il file TODO elenca il lavoro ancora da fare su questi driver per poter essere | ||
352 | accettati nel kernel, e indica anche la lista di persone da inserire in copia | ||
353 | conoscenza per ogni modifica fatta. Le regole attuali richiedono che i | ||
354 | driver debbano, come minimo, compilare adeguatamente. | ||
355 | |||
356 | La *preparazione* può essere una via relativamente facile per inserire nuovi | ||
357 | driver all'interno del ramo principale, dove, con un po' di fortuna, saranno | ||
358 | notati da altri sviluppatori e migliorati velocemente. Entrare nella fase | ||
359 | di preparazione non è però la fine della storia, infatti, il codice che si | ||
360 | trova nella cartella staging che non mostra regolari progressi potrebbe | ||
361 | essere rimosso. Le distribuzioni, inoltre, tendono a dimostrarsi relativamente | ||
362 | riluttanti nell'attivare driver in preparazione. Quindi lo preparazione è, | ||
363 | nel migliore dei casi, una tappa sulla strada verso il divenire un driver | ||
364 | del ramo principale. | ||
365 | |||
366 | |||
367 | Strumenti | ||
368 | --------- | ||
369 | |||
370 | Come è possibile notare dal testo sopra, il processo di sviluppo del kernel | ||
371 | dipende pesantemente dalla capacità di guidare la raccolta di patch in | ||
372 | diverse direzioni. L'intera cosa non funzionerebbe se non venisse svolta | ||
373 | con l'uso di strumenti appropriati e potenti. Spiegare l'uso di tali | ||
374 | strumenti non è lo scopo di questo documento, ma c'è spazio per alcuni | ||
375 | consigli. | ||
376 | |||
377 | In assoluto, nella comunità del kernel, predomina l'uso di git come sistema | ||
378 | di gestione dei sorgenti. Git è una delle diverse tipologie di sistemi | ||
379 | distribuiti di controllo versione che sono stati sviluppati nella comunità | ||
380 | del software libero. Esso è calibrato per lo sviluppo del kernel, e si | ||
381 | comporta abbastanza bene quando ha a che fare con repositori grandi e con un | ||
382 | vasto numero di patch. Git ha inoltre la reputazione di essere difficile | ||
383 | da imparare e utilizzare, benché stia migliorando. Agli sviluppatori | ||
384 | del kernel viene richiesta un po' di familiarità con git; anche se non lo | ||
385 | utilizzano per il proprio lavoro, hanno bisogno di git per tenersi al passo | ||
386 | con il lavoro degli altri sviluppatori (e con il ramo principale). | ||
387 | |||
388 | Git è ora compreso in quasi tutte le distribuzioni Linux. Esiste una sito che | ||
389 | potete consultare: | ||
390 | |||
391 | http://git-scm.com/ | ||
392 | |||
393 | Qui troverete i riferimenti alla documentazione e alle guide passo-passo. | ||
394 | |||
395 | Tra gli sviluppatori Kernel che non usano git, la scelta alternativa più | ||
396 | popolare è quasi sicuramente Mercurial: | ||
397 | |||
398 | http://www.selenic.com/mercurial/ | ||
399 | |||
400 | Mercurial condivide diverse caratteristiche con git, ma fornisce | ||
401 | un'interfaccia che potrebbe risultare più semplice da utilizzare. | ||
402 | |||
403 | L'altro strumento che vale la pena conoscere è Quilt: | ||
404 | |||
405 | http://savannah.nongnu.org/projects/quilt/ | ||
406 | |||
407 | |||
408 | Quilt è un sistema di gestione delle patch, piuttosto che un sistema | ||
409 | di gestione dei sorgenti. Non mantiene uno storico degli eventi; ma piuttosto | ||
410 | è orientato verso il tracciamento di uno specifico insieme di modifiche | ||
411 | rispetto ad un codice in evoluzione. Molti dei più grandi manutentori di | ||
412 | sottosistema utilizzano quilt per gestire le patch che dovrebbero essere | ||
413 | integrate. Per la gestione di certe tipologie di sorgenti (-mm, per esempio), | ||
414 | quilt è il miglior strumento per svolgere il lavoro. | ||
415 | |||
416 | |||
417 | Liste di discussione | ||
418 | -------------------- | ||
419 | |||
420 | Una grossa parte del lavoro di sviluppo del Kernel Linux viene svolto tramite | ||
421 | le liste di discussione. È difficile essere un membro della comunità | ||
422 | pienamente coinvolto se non si partecipa almeno ad una lista da qualche | ||
423 | parte. Ma, le liste di discussione di Linux rappresentano un potenziale | ||
424 | problema per gli sviluppatori, che rischiano di venir sepolti da un mare di | ||
425 | email, restare incagliati nelle convenzioni in vigore nelle liste Linux, | ||
426 | o entrambi. | ||
427 | |||
428 | Molte delle liste di discussione del Kernel girano su vger.kernel.org; | ||
429 | l'elenco principale lo si trova sul sito: | ||
430 | |||
431 | http://vger.kernel.org/vger-lists.html | ||
432 | |||
433 | Esistono liste gestite altrove; un certo numero di queste sono in | ||
434 | lists.redhat.com. | ||
435 | |||
436 | La lista di discussione principale per lo sviluppo del kernel è, ovviamente, | ||
437 | linux-kernel. Questa lista è un luogo ostile dove trovarsi; i volumi possono | ||
438 | raggiungere i 500 messaggi al giorno, la quantità di "rumore" è elevata, | ||
439 | la conversazione può essere strettamente tecnica e i partecipanti non sono | ||
440 | sempre preoccupati di mostrare un alto livello di educazione. Ma non esiste | ||
441 | altro luogo dove la comunità di sviluppo del kernel si unisce per intero; | ||
442 | gli sviluppatori che evitano tale lista si perderanno informazioni importanti. | ||
443 | |||
444 | Ci sono alcuni consigli che possono essere utili per sopravvivere a | ||
445 | linux-kernel: | ||
446 | |||
447 | - Tenete la lista in una cartella separata, piuttosto che inserirla nella | ||
448 | casella di posta principale. Così da essere in grado di ignorare il flusso | ||
449 | di mail per un certo periodo di tempo. | ||
450 | |||
451 | - Non cercate di seguire ogni conversazione - nessuno lo fa. È importante | ||
452 | filtrare solo gli argomenti d'interesse (sebbene va notato che le | ||
453 | conversazioni di lungo periodo possono deviare dall'argomento originario | ||
454 | senza cambiare il titolo della mail) e le persone che stanno partecipando. | ||
455 | |||
456 | - Non alimentate i troll. Se qualcuno cerca di creare nervosismo, ignoratelo. | ||
457 | |||
458 | - Quando rispondete ad una mail linux-kernel (o ad altre liste) mantenete | ||
459 | tutti i Cc:. In assenza di importanti motivazioni (come una richiesta | ||
460 | esplicita), non dovreste mai togliere destinatari. Assicuratevi sempre che | ||
461 | la persona alla quale state rispondendo sia presente nella lista Cc. Questa | ||
462 | usanza fa si che divenga inutile chiedere esplicitamente di essere inseriti | ||
463 | in copia nel rispondere al vostro messaggio. | ||
464 | |||
465 | - Cercate nell'archivio della lista (e nella rete nella sua totalità) prima | ||
466 | di far domande. Molti sviluppatori possono divenire impazienti con le | ||
467 | persone che chiaramente non hanno svolto i propri compiti a casa. | ||
468 | |||
469 | - Evitate il *top-posting* (cioè la pratica di mettere la vostra risposta sopra | ||
470 | alla frase alla quale state rispondendo). Ciò renderebbe la vostra risposta | ||
471 | difficile da leggere e genera scarsa impressione. | ||
472 | |||
473 | - Chiedete nella lista di discussione corretta. Linux-kernel può essere un | ||
474 | punto di incontro generale, ma non è il miglior posto dove trovare | ||
475 | sviluppatori da tutti i sottosistemi. | ||
476 | |||
477 | Infine, la ricerca della corretta lista di discussione è uno degli errori più | ||
478 | comuni per gli sviluppatori principianti. Qualcuno che pone una domanda | ||
479 | relativa alla rete su linux-kernel riceverà quasi certamente il suggerimento | ||
480 | di chiedere sulla lista netdev, che è la lista frequentata dagli sviluppatori | ||
481 | di rete. Ci sono poi altre liste per i sottosistemi SCSI, video4linux, IDE, | ||
482 | filesystem, etc. Il miglior posto dove cercare una lista di discussione è il | ||
483 | file MAINTAINERS che si trova nei sorgenti del kernel. | ||
484 | |||
485 | Iniziare con lo sviluppo del Kernel | ||
486 | ----------------------------------- | ||
487 | |||
488 | Sono comuni le domande sul come iniziare con lo sviluppo del kernel - sia da | ||
489 | singole persone che da aziende. Altrettanto comuni sono i passi falsi che | ||
490 | rendono l'inizio di tale relazione più difficile di quello che dovrebbe essere. | ||
491 | |||
492 | Le aziende spesso cercano di assumere sviluppatori noti per creare un gruppo | ||
493 | di sviluppo iniziale. Questo, in effetti, può essere una tecnica efficace. | ||
494 | Ma risulta anche essere dispendiosa e non va ad accrescere il bacino di | ||
495 | sviluppatori kernel con esperienza. È possibile anche "portare a casa" | ||
496 | sviluppatori per accelerare lo sviluppo del kernel, dando comunque | ||
497 | all'investimento un po' di tempo. Prendersi questo tempo può fornire | ||
498 | al datore di lavoro un gruppo di sviluppatori che comprendono sia il kernel | ||
499 | che l'azienda stessa, e che possono supportare la formazione di altre persone. | ||
500 | Nel medio periodo, questa è spesso uno delle soluzioni più proficue. | ||
501 | |||
502 | I singoli sviluppatori sono spesso, comprensibilmente, una perdita come punto | ||
503 | di partenza. Iniziare con un grande progetto può rivelarsi intimidatorio; | ||
504 | spesso all'inizio si vuole solo verificare il terreno con qualcosa di piccolo. | ||
505 | Questa è una delle motivazioni per le quali molti sviluppatori saltano alla | ||
506 | creazione di patch che vanno a sistemare errori di battitura o | ||
507 | problematiche minori legate allo stile del codice. Sfortunatamente, tali | ||
508 | patch creano un certo livello di rumore che distrae l'intera comunità di | ||
509 | sviluppo, quindi, sempre di più, esse vengono degradate. I nuovi sviluppatori | ||
510 | che desiderano presentarsi alla comunità non riceveranno l'accoglienza | ||
511 | che vorrebbero con questi mezzi. | ||
512 | |||
513 | Andrew Morton da questo consiglio agli aspiranti sviluppatori kernel | ||
514 | |||
515 | :: | ||
516 | |||
517 | Il primo progetto per un neofita del kernel dovrebbe essere | ||
518 | sicuramente quello di "assicurarsi che il kernel funzioni alla | ||
519 | perfezione sempre e su tutte le macchine sulle quali potete stendere | ||
520 | la vostra mano". Solitamente il modo per fare ciò è quello di | ||
521 | collaborare con gli altri nel sistemare le cose (questo richiede | ||
522 | persistenza!) ma va bene - è parte dello sviluppo kernel. | ||
523 | |||
524 | (http://lwn.net/Articles/283982/). | ||
525 | |||
526 | In assenza di problemi ovvi da risolvere, si consiglia agli sviluppatori | ||
527 | di consultare, in generale, la lista di regressioni e di bachi aperti. | ||
528 | Non c'è mai carenza di problematiche bisognose di essere sistemate; | ||
529 | accollandosi tali questioni gli sviluppatori accumuleranno esperienza con | ||
530 | la procedura, ed allo stesso tempo, aumenteranno la loro rispettabilità | ||
531 | all'interno della comunità di sviluppo. | ||
diff --git a/Documentation/translations/it_IT/process/3.Early-stage.rst b/Documentation/translations/it_IT/process/3.Early-stage.rst new file mode 100644 index 000000000000..443ac1e5558f --- /dev/null +++ b/Documentation/translations/it_IT/process/3.Early-stage.rst | |||
@@ -0,0 +1,241 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/3.Early-stage.rst <development_early_stage>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_early_stage: | ||
7 | |||
8 | I primi passi della pianificazione | ||
9 | ================================== | ||
10 | |||
11 | Osservando un progetto di sviluppo per il kernel Linux, si potrebbe essere | ||
12 | tentati dal saltare tutto e iniziare a codificare. Tuttavia, come ogni | ||
13 | progetto significativo, molta della preparazione per giungere al successo | ||
14 | viene fatta prima che una sola linea di codice venga scritta. Il tempo speso | ||
15 | nella pianificazione e la comunicazione può far risparmiare molto | ||
16 | tempo in futuro. | ||
17 | |||
18 | Specificare il problema | ||
19 | ----------------------- | ||
20 | |||
21 | Come qualsiasi progetto ingegneristico, un miglioramento del kernel di | ||
22 | successo parte con una chiara descrizione del problema da risolvere. | ||
23 | In alcuni casi, questo passaggio è facile: ad esempio quando un driver è | ||
24 | richiesto per un particolare dispositivo. In altri casi invece, si | ||
25 | tende a confondere il problema reale con le soluzioni proposte e questo | ||
26 | può portare all'emergere di problemi. | ||
27 | |||
28 | Facciamo un esempio: qualche anno fa, gli sviluppatori che lavoravano con | ||
29 | linux audio cercarono un modo per far girare le applicazioni senza dropouts | ||
30 | o altri artefatti dovuti all'eccessivo ritardo nel sistema. La soluzione | ||
31 | alla quale giunsero fu un modulo del kernel destinato ad agganciarsi al | ||
32 | framework Linux Security Module (LSM); questo modulo poteva essere | ||
33 | configurato per dare ad una specifica applicazione accesso allo | ||
34 | schedulatore *realtime*. Tale modulo fu implementato e inviato nella | ||
35 | lista di discussione linux-kernel, dove incontrò subito dei problemi. | ||
36 | |||
37 | Per gli sviluppatori audio, questo modulo di sicurezza era sufficiente a | ||
38 | risolvere il loro problema nell'immediato. Per l'intera comunità kernel, | ||
39 | invece, era un uso improprio del framework LSM (che non è progettato per | ||
40 | conferire privilegi a processi che altrimenti non avrebbero potuto ottenerli) | ||
41 | e un rischio per la stabilità del sistema. Le loro soluzioni di punta nel | ||
42 | breve periodo, comportavano un accesso alla schedulazione realtime attraverso | ||
43 | il meccanismo rlimit, e nel lungo periodo un costante lavoro nella riduzione | ||
44 | dei ritardi. | ||
45 | |||
46 | La comunità audio, comunque, non poteva vedere al di là della singola | ||
47 | soluzione che avevano implementato; erano riluttanti ad accettare alternative. | ||
48 | Il conseguente dissenso lasciò in quegli sviluppatori un senso di | ||
49 | disillusione nei confronti dell'intero processo di sviluppo; uno di loro | ||
50 | scrisse questo messaggio: | ||
51 | |||
52 | Ci sono numerosi sviluppatori del kernel Linux davvero bravi, ma | ||
53 | rischiano di restare sovrastati da una vasta massa di stolti arroganti. | ||
54 | Cercare di comunicare le richieste degli utenti a queste persone è | ||
55 | una perdita di tempo. Loro sono troppo "intelligenti" per stare ad | ||
56 | ascoltare dei poveri mortali. | ||
57 | |||
58 | (http://lwn.net/Articles/131776/). | ||
59 | |||
60 | La realtà delle cose fu differente; gli sviluppatori del kernel erano molto | ||
61 | più preoccupati per la stabilità del sistema, per la manutenzione di lungo | ||
62 | periodo e cercavano la giusta soluzione alla problematica esistente con uno | ||
63 | specifico modulo. La morale della storia è quella di concentrarsi sul | ||
64 | problema - non su di una specifica soluzione- e di discuterne con la comunità | ||
65 | di sviluppo prima di investire tempo nella scrittura del codice. | ||
66 | |||
67 | Quindi, osservando un progetto di sviluppo del kernel, si dovrebbe | ||
68 | rispondere a questa lista di domande: | ||
69 | |||
70 | - Qual'è, precisamente, il problema che dev'essere risolto? | ||
71 | |||
72 | - Chi sono gli utenti coinvolti da tal problema? A quale caso dovrebbe | ||
73 | essere indirizzata la soluzione? | ||
74 | |||
75 | - In che modo il kernel risulta manchevole nell'indirizzare il problema | ||
76 | in questione? | ||
77 | |||
78 | Solo dopo ha senso iniziare a considerare le possibili soluzioni. | ||
79 | |||
80 | Prime discussioni | ||
81 | ----------------- | ||
82 | |||
83 | Quando si pianifica un progetto di sviluppo per il kernel, sarebbe quanto meno | ||
84 | opportuno discuterne inizialmente con la comunità prima di lanciarsi | ||
85 | nell'implementazione. Una discussione preliminare può far risparmiare sia | ||
86 | tempo che problemi in svariati modi: | ||
87 | |||
88 | - Potrebbe essere che il problema sia già stato risolto nel kernel in | ||
89 | una maniera che non avete ancora compreso. Il kernel Linux è grande e ha | ||
90 | una serie di funzionalità e capacità che non sono scontate nell'immediato. | ||
91 | Non tutte le capacità del kernel sono documentate così bene come ci | ||
92 | piacerebbe, ed è facile perdersi qualcosa. Il vostro autore ha assistito | ||
93 | alla pubblicazione di un driver intero che duplica un altro driver | ||
94 | esistente di cui il nuovo autore era ignaro. Il codice che rinnova | ||
95 | ingranaggi già esistenti non è soltanto dispendioso; non verrà nemmeno | ||
96 | accettato nel ramo principale del kernel. | ||
97 | |||
98 | - Potrebbero esserci proposte che non sono considerate accettabili per | ||
99 | l'integrazione all'interno del ramo principale. È meglio affrontarle | ||
100 | prima di scrivere il codice. | ||
101 | |||
102 | - È possibile che altri sviluppatori abbiano pensato al problema; potrebbero | ||
103 | avere delle idee per soluzioni migliori, e potrebbero voler contribuire | ||
104 | alla loro creazione. | ||
105 | |||
106 | Anni di esperienza con la comunità di sviluppo del kernel hanno impartito una | ||
107 | chiara lezione: il codice per il kernel che è pensato e sviluppato a porte | ||
108 | chiuse, inevitabilmente, ha problematiche che si rivelano solo quando il | ||
109 | codice viene rilasciato pubblicamente. Qualche volta tali problemi sono | ||
110 | importanti e richiedono mesi o anni di sforzi prima che il codice possa | ||
111 | raggiungere gli standard richiesti della comunità. | ||
112 | Alcuni esempi possono essere: | ||
113 | |||
114 | - La rete Devicescape è stata creata e implementata per sistemi | ||
115 | mono-processore. Non avrebbe potuto essere inserita nel ramo principale | ||
116 | fino a che non avesse supportato anche i sistemi multi-processore. | ||
117 | Riadattare i meccanismi di sincronizzazione e simili è un compito difficile; | ||
118 | come risultato, l'inserimento di questo codice (ora chiamato mac80211) | ||
119 | fu rimandato per più di un anno. | ||
120 | |||
121 | - Il filesystem Reiser4 include una seria di funzionalità che, secondo | ||
122 | l'opinione degli sviluppatori principali del kernel, avrebbero dovuto | ||
123 | essere implementate a livello di filesystem virtuale. Comprende | ||
124 | anche funzionalità che non sono facilmente implementabili senza esporre | ||
125 | il sistema al rischio di uno stallo. La scoperta tardiva di questi | ||
126 | problemi - e il diniego a risolverne alcuni - ha avuto come conseguenza | ||
127 | il fatto che Raiser4 resta fuori dal ramo principale del kernel. | ||
128 | |||
129 | - Il modulo di sicurezza AppArmor utilizzava strutture dati del | ||
130 | filesystem virtuale interno in modi che sono stati considerati rischiosi e | ||
131 | inattendibili. Questi problemi (tra le altre cose) hanno tenuto AppArmor | ||
132 | fuori dal ramo principale per anni. | ||
133 | |||
134 | Ciascuno di questi casi è stato un travaglio e ha richiesto del lavoro | ||
135 | straordinario, cose che avrebbero potuto essere evitate con alcune | ||
136 | "chiacchierate" preliminari con gli sviluppatori kernel. | ||
137 | |||
138 | Con chi parlare? | ||
139 | ---------------- | ||
140 | |||
141 | Quando gli sviluppatori hanno deciso di rendere pubblici i propri progetti, la | ||
142 | domanda successiva sarà: da dove partiamo? La risposta è quella di trovare | ||
143 | la giusta lista di discussione e il giusto manutentore. Per le liste di | ||
144 | discussione, il miglior approccio è quello di cercare la lista più adatta | ||
145 | nel file MAINTAINERS. Se esiste una lista di discussione di sottosistema, | ||
146 | è preferibile pubblicare lì piuttosto che sulla lista di discussione generale | ||
147 | del kernel Linux; avrete maggiori probabilità di trovare sviluppatori con | ||
148 | esperienza sul tema, e l'ambiente che troverete potrebbe essere più | ||
149 | incoraggiante. | ||
150 | |||
151 | Trovare manutentori può rivelarsi un po' difficoltoso. Ancora, il file | ||
152 | MAINTAINERS è il posto giusto da dove iniziare. Il file potrebbe non essere | ||
153 | sempre aggiornato, inoltre, non tutti i sottosistemi sono rappresentati qui. | ||
154 | Coloro che sono elencati nel file MAINTAINERS potrebbero, in effetti, non | ||
155 | essere le persone che attualmente svolgono quel determinato ruolo. Quindi, | ||
156 | quando c'è un dubbio su chi contattare, un trucco utile è quello di usare | ||
157 | git (git log in particolare) per vedere chi attualmente è attivo all'interno | ||
158 | del sottosistema interessato. Controllate chi sta scrivendo le patch, | ||
159 | e chi, se non ci fosse nessuno, sta aggiungendo la propria firma | ||
160 | (Signed-off-by) a quelle patch. Quelle sono le persone maggiormente | ||
161 | qualificate per aiutarvi con lo sviluppo di nuovo progetto. | ||
162 | |||
163 | Il compito di trovare il giusto manutentore, a volte, è una tale sfida che | ||
164 | ha spinto gli sviluppatori del kernel a scrivere uno script che li aiutasse | ||
165 | in questa ricerca: | ||
166 | |||
167 | :: | ||
168 | |||
169 | .../scripts/get_maintainer.pl | ||
170 | |||
171 | Se questo script viene eseguito con l'opzione "-f" ritornerà il | ||
172 | manutentore(i) attuale per un dato file o cartella. Se viene passata una | ||
173 | patch sulla linea di comando, lo script elencherà i manutentori che | ||
174 | dovrebbero riceverne una copia. Ci sono svariate opzioni che regolano | ||
175 | quanto a fondo get_maintainer.pl debba cercare i manutentori; | ||
176 | siate quindi prudenti nell'utilizzare le opzioni più aggressive poiché | ||
177 | potreste finire per includere sviluppatori che non hanno un vero interesse | ||
178 | per il codice che state modificando. | ||
179 | |||
180 | Se tutto ciò dovesse fallire, parlare con Andrew Morton potrebbe essere | ||
181 | un modo efficace per capire chi è il manutentore di un dato pezzo di codice. | ||
182 | |||
183 | Quando pubblicare | ||
184 | ----------------- | ||
185 | |||
186 | Se potete, pubblicate i vostri intenti durante le fasi preliminari, sarà | ||
187 | molto utile. Descrivete il problema da risolvere e ogni piano che è stato | ||
188 | elaborato per l'implementazione. Ogni informazione fornita può aiutare | ||
189 | la comunità di sviluppo a fornire spunti utili per il progetto. | ||
190 | |||
191 | Un evento che potrebbe risultare scoraggiate e che potrebbe accadere in | ||
192 | questa fase non è il ricevere una risposta ostile, ma, invece, ottenere | ||
193 | una misera o inesistente reazione. La triste verità è che: (1) gli | ||
194 | sviluppatori del kernel tendono ad essere occupati, (2) ci sono tante persone | ||
195 | con grandi progetti e poco codice (o anche solo la prospettiva di | ||
196 | avere un codice) a cui riferirsi e (3) nessuno è obbligato a revisionare | ||
197 | o a fare osservazioni in merito ad idee pubblicate da altri. Oltre a | ||
198 | questo, progetti di alto livello spesso nascondono problematiche che si | ||
199 | rivelano solo quando qualcuno cerca di implementarle; per questa ragione | ||
200 | gli sviluppatori kernel preferirebbero vedere il codice. | ||
201 | |||
202 | Quindi, se una richiesta pubblica di commenti riscuote poco successo, non | ||
203 | pensate che ciò significhi che non ci sia interesse nel progetto. | ||
204 | Sfortunatamente, non potete nemmeno assumere che non ci siano problemi con | ||
205 | la vostra idea. La cosa migliore da fare in questa situazione è quella di | ||
206 | andare avanti e tenere la comunità informata mentre procedete. | ||
207 | |||
208 | Ottenere riscontri ufficiali | ||
209 | ---------------------------- | ||
210 | |||
211 | Se il vostro lavoro è stato svolto in un ambiente aziendale - come molto | ||
212 | del lavoro fatto su Linux - dovete, ovviamente, avere il permesso dei | ||
213 | dirigenti prima che possiate pubblicare i progetti, o il codice aziendale, | ||
214 | su una lista di discussione pubblica. La pubblicazione di codice che non | ||
215 | è stato rilascio espressamente con licenza GPL-compatibile può rivelarsi | ||
216 | problematico; prima la dirigenza, e il personale legale, troverà una decisione | ||
217 | sulla pubblicazione di un progetto, meglio sarà per tutte le persone coinvolte. | ||
218 | |||
219 | A questo punto, alcuni lettori potrebbero pensare che il loro lavoro sul | ||
220 | kernel è preposto a supportare un prodotto che non è ancora ufficialmente | ||
221 | riconosciuto. Rivelare le intenzioni dei propri datori di lavori in una | ||
222 | lista di discussione pubblica potrebbe non essere una soluzione valida. | ||
223 | In questi casi, vale la pena considerare se la segretezza sia necessaria | ||
224 | o meno; spesso non c'è una reale necessità di mantenere chiusi i progetti di | ||
225 | sviluppo. | ||
226 | |||
227 | Detto ciò, ci sono anche casi dove l'azienda legittimamente non può rivelare | ||
228 | le proprie intenzioni in anticipo durante il processo di sviluppo. Le aziende | ||
229 | che hanno sviluppatori kernel esperti possono scegliere di procedere a | ||
230 | carte coperte partendo dall'assunto che saranno in grado di evitare, o gestire, | ||
231 | in futuro, eventuali problemi d'integrazione. Per le aziende senza questo tipo | ||
232 | di esperti, la migliore opzione è spesso quella di assumere uno sviluppatore | ||
233 | esterno che revisioni i progetti con un accordo di segretezza. | ||
234 | La Linux Foundation applica un programma di NDA creato appositamente per | ||
235 | aiutare le aziende in questa particolare situazione; potrete trovare più | ||
236 | informazioni sul sito: | ||
237 | |||
238 | http://www.linuxfoundation.org/en/NDA_program | ||
239 | |||
240 | Questa tipologia di revisione è spesso sufficiente per evitare gravi problemi | ||
241 | senza che sia richiesta l'esposizione pubblica del progetto. | ||
diff --git a/Documentation/translations/it_IT/process/4.Coding.rst b/Documentation/translations/it_IT/process/4.Coding.rst new file mode 100644 index 000000000000..c61059015e52 --- /dev/null +++ b/Documentation/translations/it_IT/process/4.Coding.rst | |||
@@ -0,0 +1,447 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/4.Coding.rst <development_coding>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_coding: | ||
7 | |||
8 | Scrivere codice corretto | ||
9 | ======================== | ||
10 | |||
11 | Nonostante ci sia molto da dire sul processo di creazione, sulla sua solidità | ||
12 | e sul suo orientamento alla comunità, la prova di ogni progetto di sviluppo | ||
13 | del kernel si trova nel codice stesso. È il codice che sarà esaminato dagli | ||
14 | altri sviluppatori ed inserito (o no) nel ramo principale. Quindi è la | ||
15 | qualità di questo codice che determinerà il successo finale del progetto. | ||
16 | |||
17 | Questa sezione esaminerà il processo di codifica. Inizieremo con uno sguardo | ||
18 | sulle diverse casistiche nelle quali gli sviluppatori kernel possono | ||
19 | sbagliare. Poi, l'attenzione si sposterà verso "il fare le cose | ||
20 | correttamente" e sugli strumenti che possono essere utili in questa missione. | ||
21 | |||
22 | Trappole | ||
23 | -------- | ||
24 | |||
25 | Lo stile del codice | ||
26 | ******************* | ||
27 | |||
28 | Il kernel ha da tempo delle norme sullo stile di codifica che sono descritte in | ||
29 | :ref:`Documentation/translations/it_IT/process/coding-style.rst <codingstyle>`. | ||
30 | Per la maggior parte del tempo, la politica descritta in quel file è stata | ||
31 | praticamente informativa. Ne risulta che ci sia una quantità sostanziale di | ||
32 | codice nel kernel che non rispetta le linee guida relative allo stile. | ||
33 | La presenza di quel codice conduce a due distinti pericoli per gli | ||
34 | sviluppatori kernel. | ||
35 | |||
36 | Il primo di questi è credere che gli standard di codifica del kernel | ||
37 | non sono importanti e possono non essere applicati. La verità è che | ||
38 | aggiungere nuovo codice al kernel è davvero difficile se questo non | ||
39 | rispetta le norme; molti sviluppatori richiederanno che il codice sia | ||
40 | riformulato prima che anche solo lo revisionino. Una base di codice larga | ||
41 | quanto il kernel richiede una certa uniformità, in modo da rendere possibile | ||
42 | per gli sviluppatori una comprensione veloce di ogni sua parte. Non ci sono, | ||
43 | quindi, più spazi per un codice formattato alla carlona. | ||
44 | |||
45 | Occasionalmente, lo stile di codifica del kernel andrà in conflitto con lo | ||
46 | stile richiesto da un datore di lavoro. In alcuni casi, lo stile del kernel | ||
47 | dovrà prevalere prima che il codice venga inserito. Mettere il codice | ||
48 | all'interno del kernel significa rinunciare a un certo grado di controllo | ||
49 | in differenti modi - incluso il controllo sul come formattare il codice. | ||
50 | |||
51 | L’altra trappola è quella di pensare che il codice già presente nel kernel | ||
52 | abbia urgentemente bisogno di essere sistemato. Gli sviluppatori potrebbero | ||
53 | iniziare a generare patch che correggono lo stile come modo per prendere | ||
54 | famigliarità con il processo, o come modo per inserire i propri nomi nei | ||
55 | changelog del kernel – o entrambe. La comunità di sviluppo vede un attività | ||
56 | di codifica puramente correttiva come "rumore"; queste attività riceveranno | ||
57 | una fredda accoglienza. Di conseguenza è meglio evitare questo tipo di patch. | ||
58 | Mentre si lavora su un pezzo di codice è normale correggerne anche lo stile, | ||
59 | ma le modifiche di stile non dovrebbero essere fatte fini a se stesse. | ||
60 | |||
61 | Il documento sullo stile del codice non dovrebbe essere letto come una legge | ||
62 | assoluta che non può mai essere trasgredita. Se c’è un a buona ragione | ||
63 | (per esempio, una linea che diviene poco leggibile se divisa per rientrare | ||
64 | nel limite di 80 colonne), fatelo e basta. | ||
65 | |||
66 | Notate che potete utilizzare lo strumento “clang-format” per aiutarvi con | ||
67 | le regole, per una riformattazione automatica e veloce del vostro codice | ||
68 | e per revisionare interi file per individuare errori nello stile di codifica, | ||
69 | refusi e possibili miglioramenti. Inoltre è utile anche per classificare gli | ||
70 | ``#includes``, per allineare variabili/macro, per testi derivati ed altri | ||
71 | compiti del genere. Consultate il file | ||
72 | :ref:`Documentation/translations/it_IT/process/clang-format.rst <clangformat>` | ||
73 | per maggiori dettagli | ||
74 | |||
75 | |||
76 | Livelli di astrazione | ||
77 | ********************* | ||
78 | |||
79 | |||
80 | I professori di Informatica insegnano ai propri studenti a fare ampio uso dei | ||
81 | livelli di astrazione nel nome della flessibilità e del nascondere informazioni. | ||
82 | Certo il kernel fa un grande uso dell'astrazione; nessun progetto con milioni | ||
83 | di righe di codice potrebbe fare altrimenti e sopravvivere. Ma l'esperienza | ||
84 | ha dimostrato che un'eccessiva o prematura astrazione può rivelarsi dannosa | ||
85 | al pari di una prematura ottimizzazione. L'astrazione dovrebbe essere usata | ||
86 | fino al livello necessario e non oltre. | ||
87 | |||
88 | Ad un livello base, considerate una funzione che ha un argomento che viene | ||
89 | sempre impostato a zero da tutti i chiamanti. Uno potrebbe mantenere | ||
90 | quell'argomento nell'eventualità qualcuno volesse sfruttare la flessibilità | ||
91 | offerta. In ogni caso, tuttavia, ci sono buone possibilità che il codice | ||
92 | che va ad implementare questo argomento aggiuntivo, sia stato rotto in maniera | ||
93 | sottile, in un modo che non è mai stato notato - perché non è mai stato usato. | ||
94 | Oppure, quando sorge la necessità di avere più flessibilità, questo argomento | ||
95 | non la fornisce in maniera soddisfacente. Gli sviluppatori di Kernel, | ||
96 | sottopongono costantemente patch che vanno a rimuovere gli argomenti | ||
97 | inutilizzate; anche se, in generale, non avrebbero dovuto essere aggiunti. | ||
98 | |||
99 | I livelli di astrazione che nascondono l'accesso all'hardware - | ||
100 | spesso per poter usare dei driver su diversi sistemi operativi - vengono | ||
101 | particolarmente disapprovati. Tali livelli oscurano il codice e possono | ||
102 | peggiorare le prestazioni; essi non appartengono al kernel Linux. | ||
103 | |||
104 | D'altro canto, se vi ritrovate a dover copiare una quantità significativa di | ||
105 | codice proveniente da un altro sottosistema del kernel, è tempo di chiedersi | ||
106 | se, in effetti, non avrebbe più senso togliere parte di quel codice e metterlo | ||
107 | in una libreria separata o di implementare quella funzionalità ad un livello | ||
108 | più elevato. Non c'è utilità nel replicare lo stesso codice per tutto | ||
109 | il kernel. | ||
110 | |||
111 | |||
112 | #ifdef e l'uso del preprocessore in generale | ||
113 | ******************************************** | ||
114 | |||
115 | Il preprocessore C sembra essere una fonte di attrazione per qualche | ||
116 | programmatore C, che ci vede una via per ottenere una grande flessibilità | ||
117 | all'interno di un file sorgente. Ma il preprocessore non è scritto in C, | ||
118 | e un suo massiccio impiego conduce a un codice che è molto più difficile | ||
119 | da leggere per gli altri e che rende più difficile il lavoro di verifica del | ||
120 | compilatore. L'uso eccessivo del preprocessore è praticamente sempre il segno | ||
121 | di un codice che necessita di un certo lavoro di pulizia. | ||
122 | |||
123 | La compilazione condizionata con #ifdef è, in effetti, un potente strumento, | ||
124 | ed esso viene usato all'interno del kernel. Ma esiste un piccolo desiderio: | ||
125 | quello di vedere il codice coperto solo da una leggera spolverata di | ||
126 | blocchi #ifdef. Come regola generale, quando possibile, l'uso di #ifdef | ||
127 | dovrebbe essere confinato nei file d'intestazione. Il codice compilato | ||
128 | condizionatamente può essere confinato a funzioni tali che, nel caso in cui | ||
129 | il codice non deve essere presente, diventano vuote. Il compilatore poi | ||
130 | ottimizzerà la chiamata alla funzione vuota rimuovendola. Il risultato è | ||
131 | un codice molto più pulito, più facile da seguire. | ||
132 | |||
133 | Le macro del preprocessore C presentano una serie di pericoli, inclusi | ||
134 | valutazioni multiple di espressioni che hanno effetti collaterali e non | ||
135 | garantiscono una sicurezza rispetto ai tipi. Se siete tentati dal definire | ||
136 | una macro, considerate l'idea di creare invece una funzione inline. Il codice | ||
137 | che ne risulterà sarà lo stesso, ma le funzioni inline sono più leggibili, | ||
138 | non considerano i propri argomenti più volte, e permettono al compilatore di | ||
139 | effettuare controlli sul tipo degli argomenti e del valore di ritorno. | ||
140 | |||
141 | |||
142 | Funzioni inline | ||
143 | *************** | ||
144 | |||
145 | Comunque, anche le funzioni inline hanno i loro pericoli. I programmatori | ||
146 | potrebbero innamorarsi dell'efficienza percepita derivata dalla rimozione | ||
147 | di una chiamata a funzione. Queste funzioni, tuttavia, possono ridurre le | ||
148 | prestazioni. Dato che il loro codice viene replicato ovunque vi sia una | ||
149 | chiamata ad esse, si finisce per gonfiare le dimensioni del kernel compilato. | ||
150 | Questi, a turno, creano pressione sulla memoria cache del processore, e questo | ||
151 | può causare rallentamenti importanti. Le funzioni inline, di norma, dovrebbero | ||
152 | essere piccole e usate raramente. Il costo di una chiamata a funzione, dopo | ||
153 | tutto, non è così alto; la creazione di molte funzioni inline è il classico | ||
154 | esempio di un'ottimizzazione prematura. | ||
155 | |||
156 | In generale, i programmatori del kernel ignorano gli effetti della cache a | ||
157 | loro rischio e pericolo. Il classico compromesso tempo/spazio teorizzato | ||
158 | all'inizio delle lezioni sulle strutture dati spesso non si applica | ||
159 | all'hardware moderno. Lo spazio *è* tempo, in questo senso un programma | ||
160 | più grande sarà più lento rispetto ad uno più compatto. | ||
161 | |||
162 | I compilatori più recenti hanno preso un ruolo attivo nel decidere se | ||
163 | una data funzione deve essere resa inline oppure no. Quindi l'uso | ||
164 | indiscriminato della parola chiave "inline" potrebbe non essere non solo | ||
165 | eccessivo, ma anche irrilevante. | ||
166 | |||
167 | Sincronizzazione | ||
168 | **************** | ||
169 | |||
170 | Nel maggio 2006, il sistema di rete "Devicescape" fu rilasciato in pompa magna | ||
171 | sotto la licenza GPL e reso disponibile per la sua inclusione nella ramo | ||
172 | principale del kernel. Questa donazione fu una notizia bene accolta; | ||
173 | il supporto per le reti senza fili era considerata, nel migliore dei casi, | ||
174 | al di sotto degli standard; il sistema Deviscape offrì la promessa di una | ||
175 | risoluzione a tale situazione. Tuttavia, questo codice non fu inserito nel | ||
176 | ramo principale fino al giugno del 2007 (2.6.22). Cosa accadde? | ||
177 | |||
178 | Quel codice mostrava numerosi segnali di uno sviluppo in azienda avvenuto | ||
179 | a porte chiuse. Ma in particolare, un grosso problema fu che non fu | ||
180 | progettato per girare in un sistema multiprocessore. Prima che questo | ||
181 | sistema di rete (ora chiamato mac80211) potesse essere inserito, fu necessario | ||
182 | un lavoro sugli schemi di sincronizzazione. | ||
183 | |||
184 | Una volta, il codice del kernel Linux poteva essere sviluppato senza pensare | ||
185 | ai problemi di concorrenza presenti nei sistemi multiprocessore. Ora, | ||
186 | comunque, questo documento è stato scritto su di un portatile dual-core. | ||
187 | Persino su sistemi a singolo processore, il lavoro svolto per incrementare | ||
188 | la capacità di risposta aumenterà il livello di concorrenza interno al kernel. | ||
189 | I giorni nei quali il codice poteva essere scritto senza pensare alla | ||
190 | sincronizzazione sono da passati tempo. | ||
191 | |||
192 | Ogni risorsa (strutture dati, registri hardware, etc.) ai quali si potrebbe | ||
193 | avere accesso simultaneo da più di un thread deve essere sincronizzato. Il | ||
194 | nuovo codice dovrebbe essere scritto avendo tale accortezza in testa; | ||
195 | riadattare la sincronizzazione a posteriori è un compito molto più difficile. | ||
196 | Gli sviluppatori del kernel dovrebbero prendersi il tempo di comprendere bene | ||
197 | le primitive di sincronizzazione, in modo da sceglier lo strumento corretto | ||
198 | per eseguire un compito. Il codice che presenta una mancanza di attenzione | ||
199 | alla concorrenza avrà un percorso difficile all'interno del ramo principale. | ||
200 | |||
201 | Regressioni | ||
202 | *********** | ||
203 | |||
204 | Vale la pena menzionare un ultimo pericolo: potrebbe rivelarsi accattivante | ||
205 | l'idea di eseguire un cambiamento (che potrebbe portare a grandi | ||
206 | miglioramenti) che porterà ad alcune rotture per gli utenti esistenti. | ||
207 | Questa tipologia di cambiamento è chiamata "regressione", e le regressioni son | ||
208 | diventate mal viste nel ramo principale del kernel. Con alcune eccezioni, | ||
209 | i cambiamenti che causano regressioni saranno fermati se quest'ultime non | ||
210 | potranno essere corrette in tempo utile. È molto meglio quindi evitare | ||
211 | la regressione fin dall'inizio. | ||
212 | |||
213 | Spesso si è argomentato che una regressione può essere giustificata se essa | ||
214 | porta risolve più problemi di quanti non ne crei. Perché, dunque, non fare | ||
215 | un cambiamento se questo porta a nuove funzionalità a dieci sistemi per | ||
216 | ognuno dei quali esso determina una rottura? La migliore risposta a questa | ||
217 | domanda ci è stata fornita da Linus nel luglio 2007: | ||
218 | |||
219 | :: | ||
220 | Dunque, noi non sistemiamo bachi introducendo nuovi problemi. Quella | ||
221 | via nasconde insidie, e nessuno può sapere del tutto se state facendo | ||
222 | dei progressi reali. Sono due passi avanti e uno indietro, oppure | ||
223 | un passo avanti e due indietro? | ||
224 | |||
225 | (http://lwn.net/Articles/243460/). | ||
226 | |||
227 | Una particolare tipologia di regressione mal vista consiste in una qualsiasi | ||
228 | sorta di modifica all'ABI dello spazio utente. Una volta che un'interfaccia | ||
229 | viene esportata verso lo spazio utente, dev'essere supportata all'infinito. | ||
230 | Questo fatto rende la creazione di interfacce per lo spazio utente | ||
231 | particolarmente complicato: dato che non possono venir cambiate introducendo | ||
232 | incompatibilità, esse devono essere fatte bene al primo colpo. Per questa | ||
233 | ragione sono sempre richieste: ampie riflessioni, documentazione chiara e | ||
234 | ampie revisioni dell'interfaccia verso lo spazio utente. | ||
235 | |||
236 | |||
237 | Strumenti di verifica del codice | ||
238 | -------------------------------- | ||
239 | Almeno per ora la scrittura di codice priva di errori resta un ideale | ||
240 | irraggiungibile ai più. Quello che speriamo di poter fare, tuttavia, è | ||
241 | trovare e correggere molti di questi errori prima che il codice entri nel | ||
242 | ramo principale del kernel. A tal scopo gli sviluppatori del kernel devono | ||
243 | mettere insieme una schiera impressionante di strumenti che possano | ||
244 | localizzare automaticamente un'ampia varietà di problemi. Qualsiasi problema | ||
245 | trovato dal computer è un problema che non affliggerà l'utente in seguito, | ||
246 | ne consegue che gli strumenti automatici dovrebbero essere impiegati ovunque | ||
247 | possibile. | ||
248 | |||
249 | Il primo passo consiste semplicemente nel fare attenzione agli avvertimenti | ||
250 | proveniente dal compilatore. Versioni moderne di gcc possono individuare | ||
251 | (e segnalare) un gran numero di potenziali errori. Molto spesso, questi | ||
252 | avvertimenti indicano problemi reali. Di regola, il codice inviato per la | ||
253 | revisione non dovrebbe produrre nessun avvertimento da parte del compilatore. | ||
254 | Per mettere a tacere gli avvertimenti, cercate di comprenderne le cause reali | ||
255 | e cercate di evitare le "riparazioni" che fan sparire l'avvertimento senza | ||
256 | però averne trovato la causa. | ||
257 | |||
258 | Tenete a mente che non tutti gli avvertimenti sono disabilitati di default. | ||
259 | Costruite il kernel con "make EXTRA_CFLAGS=-W" per ottenerli tutti. | ||
260 | |||
261 | Il kernel fornisce differenti opzioni che abilitano funzionalità di debugging; | ||
262 | molti di queste sono trovano all'interno del sotto menu "kernel hacking". | ||
263 | La maggior parte di queste opzioni possono essere attivate per qualsiasi | ||
264 | kernel utilizzato per lo sviluppo o a scopo di test. In particolare dovreste | ||
265 | attivare: | ||
266 | |||
267 | - ENABLE_WARN_DEPRECATED, ENABLE_MUST_CHECK, e FRAME_WARN per ottenere degli | ||
268 | avvertimenti dedicati a problemi come l'uso di interfacce deprecate o | ||
269 | l'ignorare un importante valore di ritorno di una funzione. Il risultato | ||
270 | generato da questi avvertimenti può risultare verboso, ma non bisogna | ||
271 | preoccuparsi per gli avvertimenti provenienti da altre parti del kernel. | ||
272 | |||
273 | - DEBUG_OBJECTS aggiungerà un codice per tracciare il ciclo di vita di | ||
274 | diversi oggetti creati dal kernel e avvisa quando qualcosa viene eseguito | ||
275 | fuori controllo. Se state aggiungendo un sottosistema che crea (ed | ||
276 | esporta) oggetti complessi propri, considerate l'aggiunta di un supporto | ||
277 | al debugging dell'oggetto. | ||
278 | |||
279 | - DEBUG_SLAB può trovare svariati errori di uso e di allocazione di memoria; | ||
280 | esso dovrebbe esser usato dalla maggior parte dei kernel di sviluppo. | ||
281 | |||
282 | - DEBUG_SPINLOCK, DEBUG_ATOMIC_SLEEP, e DEBUG_MUTEXES troveranno un certo | ||
283 | numero di errori comuni di sincronizzazione. | ||
284 | |||
285 | Esistono ancora delle altre opzioni di debugging, di alcune di esse | ||
286 | discuteremo qui sotto. Alcune di esse hanno un forte impatto e non dovrebbero | ||
287 | essere usate tutte le volte. Ma qualche volta il tempo speso nell'capire | ||
288 | le opzioni disponibili porterà ad un risparmio di tempo nel breve termine. | ||
289 | |||
290 | Uno degli strumenti di debugging più tosti è il *locking checker*, o | ||
291 | "lockdep". Questo strumento traccerà qualsiasi acquisizione e rilascio di | ||
292 | ogni *lock* (spinlock o mutex) nel sistema, l'ordine con il quale i *lock* | ||
293 | sono acquisiti in relazione l'uno con l'altro, l'ambiente corrente di | ||
294 | interruzione, eccetera. Inoltre esso può assicurare che i *lock* vengano | ||
295 | acquisiti sempre nello stesso ordine, che le stesse assunzioni sulle | ||
296 | interruzioni si applichino in tutte le occasioni, e così via. In altre parole, | ||
297 | lockdep può scovare diversi scenari nei quali il sistema potrebbe, in rari | ||
298 | casi, trovarsi in stallo. Questa tipologia di problema può essere grave | ||
299 | (sia per gli sviluppatori che per gli utenti) in un sistema in uso; lockdep | ||
300 | permette di trovare tali problemi automaticamente e in anticipo. | ||
301 | |||
302 | In qualità di programmatore kernel diligente, senza dubbio, dovrete controllare | ||
303 | il valore di ritorno di ogni operazione (come l'allocazione della memoria) | ||
304 | poiché esso potrebbe fallire. Il nocciolo della questione è che i percorsi | ||
305 | di gestione degli errori, con grande probabilità, non sono mai stati | ||
306 | collaudati del tutto. Il codice collaudato tende ad essere codice bacato; | ||
307 | potrete quindi essere più a vostro agio con il vostro codice se tutti questi | ||
308 | percorsi fossero stati verificati un po' di volte. | ||
309 | |||
310 | Il kernel fornisce un framework per l'inserimento di fallimenti che fa | ||
311 | esattamente al caso, specialmente dove sono coinvolte allocazioni di memoria. | ||
312 | Con l'opzione per l'inserimento dei fallimenti abilitata, una certa percentuale | ||
313 | di allocazione di memoria sarà destinata al fallimento; questi fallimenti | ||
314 | possono essere ridotti ad uno specifico pezzo di codice. Procedere con | ||
315 | l'inserimento dei fallimenti attivo permette al programmatore di verificare | ||
316 | come il codice risponde quando le cose vanno male. Consultate: | ||
317 | Documentation/fault-injection/fault-injection.txt per avere maggiori | ||
318 | informazioni su come utilizzare questo strumento. | ||
319 | |||
320 | Altre tipologie di errori possono essere riscontrati con lo strumento di | ||
321 | analisi statica "sparse". Con Sparse, il programmatore può essere avvisato | ||
322 | circa la confusione tra gli indirizzi dello spazio utente e dello spazio | ||
323 | kernel, un miscuglio fra quantità big-endian e little-endian, il passaggio | ||
324 | di un valore intero dove ci sia aspetta un gruppo di flag, e così via. | ||
325 | Sparse deve essere installato separatamente (se il vostra distribuzione non | ||
326 | lo prevede, potete trovarlo su https://sparse.wiki.kernel.org/index.php/Main_Page); | ||
327 | può essere attivato sul codice aggiungendo "C=1" al comando make. | ||
328 | |||
329 | Lo strumento "Coccinelle" (http://coccinelle.lip6.fr/) è in grado di trovare | ||
330 | una vasta varietà di potenziali problemi di codifica; e può inoltre proporre | ||
331 | soluzioni per risolverli. Un buon numero di "patch semantiche" per il kernel | ||
332 | sono state preparate nella cartella scripts/coccinelle; utilizzando | ||
333 | "make coccicheck" esso percorrerà tali patch semantiche e farà rapporto su | ||
334 | qualsiasi problema trovato. Per maggiori informazioni, consultate | ||
335 | :ref:`Documentation/dev-tools/coccinelle.rst <devtools_coccinelle>`. | ||
336 | |||
337 | Altri errori di portabilità sono meglio scovati compilando il vostro codice | ||
338 | per altre architetture. Se non vi accade di avere un sistema S/390 o una | ||
339 | scheda di sviluppo Blackfin sotto mano, potete comunque continuare la fase | ||
340 | di compilazione. Un vasto numero di cross-compilatori per x86 possono | ||
341 | essere trovati al sito: | ||
342 | |||
343 | http://www.kernel.org/pub/tools/crosstool/ | ||
344 | |||
345 | Il tempo impiegato nell'installare e usare questi compilatori sarà d'aiuto | ||
346 | nell'evitare situazioni imbarazzanti nel futuro. | ||
347 | |||
348 | |||
349 | Documentazione | ||
350 | -------------- | ||
351 | |||
352 | La documentazione è spesso stata più un'eccezione che una regola nello | ||
353 | sviluppo del kernel. Nonostante questo, un'adeguata documentazione aiuterà | ||
354 | a facilitare l'inserimento di nuovo codice nel kernel, rende la vita più | ||
355 | facile per gli altri sviluppatori e sarà utile per i vostri utenti. In molti | ||
356 | casi, la documentazione è divenuta sostanzialmente obbligatoria. | ||
357 | |||
358 | La prima parte di documentazione per qualsiasi patch è il suo changelog. | ||
359 | Questi dovrebbero descrivere le problematiche risolte, la tipologia di | ||
360 | soluzione, le persone che lavorano alla patch, ogni effetto rilevante | ||
361 | sulle prestazioni e tutto ciò che può servire per la comprensione della | ||
362 | patch. Assicuratevi che il changelog dica *perché*, vale la pena aggiungere | ||
363 | la patch; un numero sorprendente di sviluppatori sbaglia nel fornire tale | ||
364 | informazione. | ||
365 | |||
366 | Qualsiasi codice che aggiunge una nuova interfaccia in spazio utente - inclusi | ||
367 | nuovi file in sysfs o /proc - dovrebbe includere la documentazione di tale | ||
368 | interfaccia così da permette agli sviluppatori dello spazio utente di sapere | ||
369 | con cosa stanno lavorando. Consultate: Documentation/ABI/README per avere una | ||
370 | descrizione di come questi documenti devono essere impostati e quali | ||
371 | informazioni devono essere fornite. | ||
372 | |||
373 | Il file :ref:`Documentation/translations/it_IT/admin-guide/kernel-parameters.rst <kernelparameters>` | ||
374 | descrive tutti i parametri di avvio del kernel. Ogni patch che aggiunga | ||
375 | nuovi parametri dovrebbe aggiungere nuove voci a questo file. | ||
376 | |||
377 | Ogni nuova configurazione deve essere accompagnata da un testo di supporto | ||
378 | che spieghi chiaramente le opzioni e spieghi quando l'utente potrebbe volerle | ||
379 | selezionare. | ||
380 | |||
381 | Per molti sottosistemi le informazioni sull'API interna sono documentate sotto | ||
382 | forma di commenti formattati in maniera particolare; questi commenti possono | ||
383 | essere estratti e formattati in differenti modi attraverso lo script | ||
384 | "kernel-doc". Se state lavorando all'interno di un sottosistema che ha | ||
385 | commenti kerneldoc dovreste mantenerli e aggiungerli, in maniera appropriata, | ||
386 | per le funzioni disponibili esternamente. Anche in aree che non sono molto | ||
387 | documentate, non c'è motivo per non aggiungere commenti kerneldoc per il | ||
388 | futuro; infatti, questa può essere un'attività utile per sviluppatori novizi | ||
389 | del kernel. Il formato di questi commenti, assieme alle informazione su come | ||
390 | creare modelli per kerneldoc, possono essere trovati in | ||
391 | :ref:`Documentation/translations/it_IT/doc-guide/ <doc_guide>`. | ||
392 | |||
393 | Chiunque legga un ammontare significativo di codice kernel noterà che, spesso, | ||
394 | i commenti si fanno maggiormente notare per la loro assenza. Ancora una volta, | ||
395 | le aspettative verso il nuovo codice sono più alte rispetto al passato; | ||
396 | inserire codice privo di commenti sarà più difficile. Detto ciò, va aggiunto | ||
397 | che non si desiderano commenti prolissi per il codice. Il codice dovrebbe | ||
398 | essere, di per sé, leggibile, con dei commenti che spieghino gli aspetti più | ||
399 | sottili. | ||
400 | |||
401 | Determinate cose dovrebbero essere sempre commentate. L'uso di barriere | ||
402 | di memoria dovrebbero essere accompagnate da una riga che spieghi perché sia | ||
403 | necessaria. Le regole di sincronizzazione per le strutture dati, generalmente, | ||
404 | necessitano di una spiegazioni da qualche parte. Le strutture dati più | ||
405 | importanti, in generale, hanno bisogno di una documentazione onnicomprensiva. | ||
406 | Le dipendenze che non sono ovvie tra bit separati di codice dovrebbero essere | ||
407 | indicate. Tutto ciò che potrebbe indurre un inserviente del codice a fare | ||
408 | una "pulizia" incorretta, ha bisogno di un commento che dica perché è stato | ||
409 | fatto in quel modo. E così via. | ||
410 | |||
411 | Cambiamenti interni dell'API | ||
412 | ---------------------------- | ||
413 | |||
414 | L'interfaccia binaria fornita dal kernel allo spazio utente non può essere | ||
415 | rotta tranne che in circostanze eccezionali. L'interfaccia di programmazione | ||
416 | interna al kernel, invece, è estremamente fluida e può essere modificata al | ||
417 | bisogno. Se vi trovate a dover lavorare attorno ad un'API del kernel o | ||
418 | semplicemente non state utilizzando una funzionalità offerta perché questa | ||
419 | non rispecchia i vostri bisogni, allora questo potrebbe essere un segno che | ||
420 | l'API ha bisogno di essere cambiata. In qualità di sviluppatore del kernel, | ||
421 | hai il potere di fare questo tipo di modifica. | ||
422 | |||
423 | Ci sono ovviamente alcuni punti da cogliere. I cambiamenti API possono essere | ||
424 | fatti, ma devono essere giustificati. Quindi ogni patch che porta ad una | ||
425 | modifica dell'API interna dovrebbe essere accompagnata da una descrizione | ||
426 | della modifica in sé e del perché essa è necessaria. Questo tipo di | ||
427 | cambiamenti dovrebbero, inoltre, essere fatti in una patch separata, invece di | ||
428 | essere sepolti all'interno di una patch più grande. | ||
429 | |||
430 | L'altro punto da cogliere consiste nel fatto che uno sviluppatore che | ||
431 | modifica l'API deve, in generale, essere responsabile della correzione | ||
432 | di tutto il codice del kernel che viene rotto per via della sua modifica. | ||
433 | Per una funzione ampiamente usata, questo compito può condurre letteralmente | ||
434 | a centinaia o migliaia di modifiche, molte delle quali sono in conflitto con | ||
435 | il lavoro svolto da altri sviluppatori. Non c'è bisogno di dire che questo | ||
436 | può essere un lavoro molto grosso, quindi è meglio essere sicuri che la | ||
437 | motivazione sia ben solida. Notate che lo strumento Coccinelle può fornire | ||
438 | un aiuto con modifiche estese dell'API. | ||
439 | |||
440 | Quando viene fatta una modifica API incompatibile, una persona dovrebbe, | ||
441 | quando possibile, assicurarsi che quel codice non aggiornato sia trovato | ||
442 | dal compilatore. Questo vi aiuterà ad essere sicuri d'avere trovato, | ||
443 | tutti gli usi di quell'interfaccia. Inoltre questo avviserà gli sviluppatori | ||
444 | di codice fuori dal kernel che c'è un cambiamento per il quale è necessario del | ||
445 | lavoro. Il supporto al codice fuori dal kernel non è qualcosa di cui gli | ||
446 | sviluppatori del kernel devono preoccuparsi, ma non dobbiamo nemmeno rendere | ||
447 | più difficile del necessario la vita agli sviluppatori di questo codice. | ||
diff --git a/Documentation/translations/it_IT/process/5.Posting.rst b/Documentation/translations/it_IT/process/5.Posting.rst new file mode 100644 index 000000000000..b979266aa884 --- /dev/null +++ b/Documentation/translations/it_IT/process/5.Posting.rst | |||
@@ -0,0 +1,348 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/5.Posting.rst <development_posting>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_posting: | ||
7 | |||
8 | Pubblicare modifiche | ||
9 | ==================== | ||
10 | |||
11 | Prima o poi arriva il momento in cui il vostro lavoro è pronto per essere | ||
12 | presentato alla comunità per una revisione ed eventualmente per la sua | ||
13 | inclusione nel ramo principale del kernel. Com'era prevedibile, | ||
14 | la comunità di sviluppo del kernel ha elaborato un insieme di convenzioni | ||
15 | e di procedure per la pubblicazione delle patch; seguirle renderà la vita | ||
16 | più facile a tutti quanti. Questo documento cercherà di coprire questi | ||
17 | argomenti con un ragionevole livello di dettaglio; più informazioni possono | ||
18 | essere trovare nella cartella 'Documentation', nei file | ||
19 | :ref:`translations/it_IT/process/submitting-patches.rst <it_submittingpatches>`, | ||
20 | :ref:`translations/it_IT/process/submitting-drivers.rst <it_submittingdrivers>`, e | ||
21 | :ref:`translations/it_IT/process/submit-checklist.rst <it_submitchecklist>`. | ||
22 | |||
23 | |||
24 | Quando pubblicarle | ||
25 | ------------------ | ||
26 | |||
27 | C'è sempre una certa resistenza nel pubblicare patch finché non sono | ||
28 | veramente "pronte". Per semplici patch questo non è un problema. | ||
29 | Ma quando il lavoro è di una certa complessità, c'è molto da guadagnare | ||
30 | dai riscontri che la comunità può darvi prima che completiate il lavoro. | ||
31 | Dovreste considerare l'idea di pubblicare un lavoro incompleto, o anche | ||
32 | preparare un ramo git disponibile agli sviluppatori interessati, cosicché | ||
33 | possano stare al passo col vostro lavoro in qualunque momento. | ||
34 | |||
35 | Quando pubblicate del codice che non è considerato pronto per l'inclusione, | ||
36 | è bene che lo diciate al momento della pubblicazione. Inoltre, aggiungete | ||
37 | informazioni sulle cose ancora da sviluppare e sui problemi conosciuti. | ||
38 | Poche persone guarderanno delle patch che si sa essere fatte a metà, | ||
39 | ma quelli che lo faranno penseranno di potervi aiutare a condurre il vostro | ||
40 | sviluppo nella giusta direzione. | ||
41 | |||
42 | |||
43 | Prima di creare patch | ||
44 | --------------------- | ||
45 | |||
46 | Ci sono un certo numero di cose che dovreste fare prima di considerare | ||
47 | l'invio delle patch alla comunità di sviluppo. Queste cose includono: | ||
48 | |||
49 | - Verificare il codice fino al massimo che vi è consentito. Usate gli | ||
50 | strumenti di debug del kernel, assicuratevi che il kernel compili con | ||
51 | tutte le più ragionevoli combinazioni d'opzioni, usate cross-compilatori | ||
52 | per compilare il codice per differenti architetture, eccetera. | ||
53 | |||
54 | - Assicuratevi che il vostro codice sia conforme alla linee guida del | ||
55 | kernel sullo stile del codice. | ||
56 | |||
57 | - La vostra patch ha delle conseguenze in termini di prestazioni? | ||
58 | Se è così, dovreste eseguire dei *benchmark* che mostrino il loro | ||
59 | impatto (anche positivo); un riassunto dei risultati dovrebbe essere | ||
60 | incluso nella patch. | ||
61 | |||
62 | - Siate certi d'avere i diritti per pubblicare il codice. Se questo | ||
63 | lavoro è stato fatto per un datore di lavoro, egli avrà dei diritti su | ||
64 | questo lavoro e dovrà quindi essere d'accordo alla sua pubblicazione | ||
65 | con una licenza GPL | ||
66 | |||
67 | Come regola generale, pensarci un po' di più prima di inviare il codice | ||
68 | ripaga quasi sempre lo sforzo. | ||
69 | |||
70 | |||
71 | Preparazione di una patch | ||
72 | ------------------------- | ||
73 | |||
74 | La preparazione delle patch per la pubblicazione può richiedere una quantità | ||
75 | di lavoro significativa, ma, ripetiamolo ancora, generalmente sconsigliamo | ||
76 | di risparmiare tempo in questa fase, anche sul breve periodo. | ||
77 | |||
78 | Le patch devono essere preparate per una specifica versione del kernel. | ||
79 | Come regola generale, una patch dovrebbe basarsi sul ramo principale attuale | ||
80 | così come lo si trova nei sorgenti git di Linus. Quando vi basate sul ramo | ||
81 | principale, cominciate da un punto di rilascio ben noto - uno stabile o | ||
82 | un -rc - piuttosto che creare il vostro ramo da quello principale in un punto | ||
83 | a caso. | ||
84 | |||
85 | Per facilitare una revisione e una verifica più estesa, potrebbe diventare | ||
86 | necessaria la produzione di versioni per -mm, linux-next o i sorgenti di un | ||
87 | sottosistema. Basare questa patch sui suddetti sorgenti potrebbe richiedere | ||
88 | un lavoro significativo nella risoluzione dei conflitti e nella correzione dei | ||
89 | cambiamenti di API; questo potrebbe variare a seconda dell'area d'interesse | ||
90 | della vostra patch e da quello che succede altrove nel kernel. | ||
91 | |||
92 | Solo le modifiche più semplici dovrebbero essere preparate come una singola | ||
93 | patch; tutto il resto dovrebbe essere preparato come una serie logica di | ||
94 | modifiche. Spezzettare le patch è un po' un'arte; alcuni sviluppatori | ||
95 | passano molto tempo nel capire come farlo in modo che piaccia alla comunità. | ||
96 | Ci sono alcune regole spannometriche, che comunque possono aiutare | ||
97 | considerevolmente: | ||
98 | |||
99 | - La serie di patch che pubblicherete, quasi sicuramente, non sarà | ||
100 | come quella che trovate nel vostro sistema di controllo di versione. | ||
101 | Invece, le vostre modifiche dovranno essere considerate nella loro forma | ||
102 | finale, e quindi separate in parti che abbiano un senso. Gli sviluppatori | ||
103 | sono interessati in modifiche che siano discrete e indipendenti, non | ||
104 | alla strada che avete percorso per ottenerle. | ||
105 | |||
106 | - Ogni modifica logicamente indipendente dovrebbe essere preparata come una | ||
107 | patch separata. Queste modifiche possono essere piccole ("aggiunto un | ||
108 | campo in questa struttura") o grandi (l'aggiunta di un driver nuovo, | ||
109 | per esempio), ma dovrebbero essere concettualmente piccole da permettere | ||
110 | una descrizione in una sola riga. Ogni patch dovrebbe fare modifiche | ||
111 | specifiche che si possano revisionare indipendentemente e di cui si possa | ||
112 | verificare la veridicità. | ||
113 | |||
114 | - Giusto per riaffermare quando detto sopra: non mischiate diversi tipi di | ||
115 | modifiche nella stessa patch. Se una modifica corregge un baco critico | ||
116 | per la sicurezza, riorganizza alcune strutture, e riformatta il codice, | ||
117 | ci sono buone probabilità che venga ignorata e che la correzione importante | ||
118 | venga persa. | ||
119 | |||
120 | - Ogni modifica dovrebbe portare ad un kernel che compila e funziona | ||
121 | correttamente; se la vostra serie di patch si interrompe a metà il | ||
122 | risultato dovrebbe essere comunque un kernel funzionante. L'applicazione | ||
123 | parziale di una serie di patch è uno scenario comune nel quale il | ||
124 | comando "git bisect" viene usato per trovare delle regressioni; se il | ||
125 | risultato è un kernel guasto, renderete la vita degli sviluppatori più | ||
126 | difficile così come quella di chi s'impegna nel nobile lavoro di | ||
127 | scovare i problemi. | ||
128 | |||
129 | - Però, non strafate. Una volta uno sviluppatore pubblicò una serie di 500 | ||
130 | patch che modificavano un unico file - un atto che non lo rese la persona | ||
131 | più popolare sulla lista di discussione del kernel. Una singola patch | ||
132 | può essere ragionevolmente grande fintanto che contenga un singolo | ||
133 | cambiamento *logico*. | ||
134 | |||
135 | - Potrebbe essere allettante l'idea di aggiungere una nuova infrastruttura | ||
136 | come una serie di patch, ma di lasciare questa infrastruttura inutilizzata | ||
137 | finché l'ultima patch della serie non abilita tutto quanto. Quando è | ||
138 | possibile, questo dovrebbe essere evitato; se questa serie aggiunge delle | ||
139 | regressioni, "bisect" indicherà quest'ultima patch come causa del | ||
140 | problema anche se il baco si trova altrove. Possibilmente, quando una | ||
141 | patch aggiunge del nuovo codice dovrebbe renderlo attivo immediatamente. | ||
142 | |||
143 | Lavorare per creare la serie di patch perfetta potrebbe essere frustrante | ||
144 | perché richiede un certo tempo e soprattutto dopo che il "vero lavoro" è | ||
145 | già stato fatto. Quando ben fatto, comunque, è tempo ben speso. | ||
146 | |||
147 | |||
148 | Formattazione delle patch e i changelog | ||
149 | --------------------------------------- | ||
150 | |||
151 | Quindi adesso avete una serie perfetta di patch pronte per la pubblicazione, | ||
152 | ma il lavoro non è davvero finito. Ogni patch deve essere preparata con | ||
153 | un messaggio che spieghi al resto del mondo, in modo chiaro e veloce, | ||
154 | il suo scopo. Per ottenerlo, ogni patch sarà composta dai seguenti elementi: | ||
155 | |||
156 | - Un campo opzionale "From" col nome dell'autore della patch. Questa riga | ||
157 | è necessaria solo se state passando la patch di qualcun altro via email, | ||
158 | ma nel dubbio non fa di certo male aggiungerlo. | ||
159 | |||
160 | - Una descrizione di una riga che spieghi cosa fa la patch. Questo | ||
161 | messaggio dovrebbe essere sufficiente per far comprendere al lettore lo | ||
162 | scopo della patch senza altre informazioni. Questo messaggio, | ||
163 | solitamente, presenta in testa il nome del sottosistema a cui si riferisce, | ||
164 | seguito dallo scopo della patch. Per esempio: | ||
165 | |||
166 | :: | ||
167 | |||
168 | gpio: fix build on CONFIG_GPIO_SYSFS=n | ||
169 | |||
170 | - Una riga bianca seguita da una descrizione dettagliata della patch. | ||
171 | Questa descrizione può essere lunga tanto quanto serve; dovrebbe spiegare | ||
172 | cosa fa e perché dovrebbe essere aggiunta al kernel. | ||
173 | |||
174 | - Una o più righe etichette, con, minimo, una riga *Signed-off-by:* | ||
175 | col nome dall'autore della patch. Queste etichette verranno descritte | ||
176 | meglio più avanti. | ||
177 | |||
178 | Gli elementi qui sopra, assieme, formano il changelog di una patch. | ||
179 | Scrivere un buon changelog è cruciale ma è spesso un'arte trascurata; | ||
180 | vale la pena spendere qualche parola in più al riguardo. Quando scrivete | ||
181 | un changelog dovreste tenere ben presente che molte persone leggeranno | ||
182 | le vostre parole. Queste includono i manutentori di un sotto-sistema, e i | ||
183 | revisori che devono decidere se la patch debba essere inclusa o no, | ||
184 | le distribuzioni e altri manutentori che cercano di valutare se la patch | ||
185 | debba essere applicata su kernel più vecchi, i cacciatori di bachi che si | ||
186 | chiederanno se la patch è la causa di un problema che stanno cercando, | ||
187 | gli utenti che vogliono sapere com'è cambiato il kernel, e molti altri. | ||
188 | Un buon changelog fornisce le informazioni necessarie a tutte queste | ||
189 | persone nel modo più diretto e conciso possibile. | ||
190 | |||
191 | A questo scopo, la riga riassuntiva dovrebbe descrivere gli effetti della | ||
192 | modifica e la motivazione della patch nel modo migliore possibile nonostante | ||
193 | il limite di una sola riga. La descrizione dettagliata può spiegare meglio | ||
194 | i temi e fornire maggiori informazioni. Se una patch corregge un baco, | ||
195 | citate, se possibile, il commit che lo introdusse (e per favore, quando | ||
196 | citate un commit aggiungete sia il suo identificativo che il titolo), | ||
197 | Se il problema è associabile ad un file di log o all' output del compilatore, | ||
198 | includeteli al fine d'aiutare gli altri a trovare soluzioni per lo stesso | ||
199 | problema. Se la modifica ha lo scopo di essere di supporto a sviluppi | ||
200 | successivi, ditelo. Se le API interne vengono cambiate, dettagliate queste | ||
201 | modifiche e come gli altri dovrebbero agire per applicarle. In generale, | ||
202 | più riuscirete ad entrare nei panni di tutti quelli che leggeranno il | ||
203 | vostro changelog, meglio sarà il changelog (e il kernel nel suo insieme). | ||
204 | |||
205 | Non serve dirlo, un changelog dovrebbe essere il testo usato nel messaggio | ||
206 | di commit in un sistema di controllo di versione. Sarà seguito da: | ||
207 | |||
208 | - La patch stessa, nel formato unificato per patch ("-u"). Usare | ||
209 | l'opzione "-p" assocerà alla modifica il nome della funzione alla quale | ||
210 | si riferisce, rendendo il risultato più facile da leggere per gli altri. | ||
211 | |||
212 | Dovreste evitare di includere nelle patch delle modifiche per file | ||
213 | irrilevanti (quelli generati dal processo di generazione, per esempio, o i file | ||
214 | di backup del vostro editor). Il file "dontdiff" nella cartella Documentation | ||
215 | potrà esservi d'aiuto su questo punto; passatelo a diff con l'opzione "-X". | ||
216 | |||
217 | Le etichette sopra menzionante sono usate per descrivere come i vari | ||
218 | sviluppatori sono stati associati allo sviluppo di una patch. Sono descritte | ||
219 | in dettaglio nel documento :ref:`translations/it_IT/process/submitting-patches.rst <it_submittingpatches>`; | ||
220 | quello che segue è un breve riassunto. Ognuna di queste righe ha il seguente | ||
221 | formato: | ||
222 | |||
223 | :: | ||
224 | |||
225 | tag: Full Name <email address> optional-other-stuff | ||
226 | |||
227 | Le etichette in uso più comuni sono: | ||
228 | |||
229 | - Signed-off-by: questa è la certificazione che lo sviluppatore ha il diritto | ||
230 | di sottomettere la patch per l'integrazione nel kernel. Questo rappresenta | ||
231 | il consenso verso il certificato d'origine degli sviluppatori, il testo | ||
232 | completo potrà essere trovato in | ||
233 | :ref:`Documentation/translations/it_IT/process/submitting-patches.rst <it_submittingpatches>`. | ||
234 | Codice che non presenta una firma appropriata non potrà essere integrato. | ||
235 | |||
236 | - Co-developed-by: indica che la patch è stata sviluppata anche da un altro | ||
237 | sviluppatore assieme all'autore originale. Questo è utile quando più | ||
238 | persone lavorano sulla stessa patch. Da notare che questa persona deve | ||
239 | avere anche una riga "Signed-off-by:" nella patch. | ||
240 | |||
241 | - Acked-by: indica il consenso di un altro sviluppatore (spesso il manutentore | ||
242 | del codice in oggetto) all'integrazione della patch nel kernel. | ||
243 | |||
244 | - Tested-by: menziona la persona che ha verificato la patch e l'ha trovata | ||
245 | funzionante. | ||
246 | |||
247 | - Reviwed-by: menziona lo sviluppatore che ha revisionato la patch; per | ||
248 | maggiori dettagli leggete la dichiarazione dei revisori in | ||
249 | :ref:`Documentation/translations/it_IT/process/submitting-patches.rst <it_submittingpatches>` | ||
250 | |||
251 | - Reported-by: menziona l'utente che ha riportato il problema corretto da | ||
252 | questa patch; quest'etichetta viene usata per dare credito alle persone | ||
253 | che hanno verificato il codice e ci hanno fatto sapere quando le cose non | ||
254 | funzionavano correttamente. | ||
255 | |||
256 | - Cc: la persona menzionata ha ricevuto una copia della patch ed ha avuto | ||
257 | l'opportunità di commentarla. | ||
258 | |||
259 | State attenti ad aggiungere queste etichette alla vostra patch: solo | ||
260 | "Cc:" può essere aggiunta senza il permesso esplicito della persona menzionata. | ||
261 | |||
262 | Inviare la modifica | ||
263 | ------------------- | ||
264 | |||
265 | Prima di inviare la vostra patch, ci sarebbero ancora un paio di cose di cui | ||
266 | dovreste aver cura: | ||
267 | |||
268 | - Siete sicuri che il vostro programma di posta non corromperà le patch? | ||
269 | Le patch che hanno spazi bianchi in libertà o andate a capo aggiunti | ||
270 | dai programmi di posta non funzioneranno per chi le riceve, e spesso | ||
271 | non verranno nemmeno esaminate in dettaglio. Se avete un qualsiasi dubbio, | ||
272 | inviate la patch a voi stessi e verificate che sia integra. | ||
273 | |||
274 | :ref:`Documentation/translations/it_IT/process/email-clients.rst <it_email_clients>` | ||
275 | contiene alcuni suggerimenti utili sulla configurazione dei programmi | ||
276 | di posta al fine di inviare patch. | ||
277 | |||
278 | - Siete sicuri che la vostra patch non contenga sciocchi errori? Dovreste | ||
279 | sempre processare le patch con scripts/checkpatch.pl e correggere eventuali | ||
280 | problemi riportati. Per favore tenete ben presente che checkpatch.pl non è | ||
281 | più intelligente di voi, nonostante sia il risultato di un certa quantità di | ||
282 | ragionamenti su come debba essere una patch per il kernel. Se seguire | ||
283 | i suggerimenti di checkpatch.pl rende il codice peggiore, allora non fatelo. | ||
284 | |||
285 | Le patch dovrebbero essere sempre inviate come testo puro. Per favore non | ||
286 | inviatele come allegati; questo rende molto più difficile, per i revisori, | ||
287 | citare parti della patch che si vogliono commentare. Invece, mettete la vostra | ||
288 | patch direttamente nel messaggio. | ||
289 | |||
290 | Quando inviate le patch, è importante inviarne una copia a tutte le persone che | ||
291 | potrebbero esserne interessate. Al contrario di altri progetti, il kernel | ||
292 | incoraggia le persone a peccare nell'invio di tante copie; non presumente che | ||
293 | le persone interessate vedano i vostri messaggi sulla lista di discussione. | ||
294 | In particolare le copie dovrebbero essere inviate a: | ||
295 | |||
296 | - I manutentori dei sottosistemi affetti della modifica. Come descritto | ||
297 | in precedenza, il file MAINTAINERS è il primo luogo dove cercare i nomi | ||
298 | di queste persone. | ||
299 | |||
300 | - Altri sviluppatori che hanno lavorato nello stesso ambiente - specialmente | ||
301 | quelli che potrebbero lavorarci proprio ora. Usate git potrebbe essere | ||
302 | utile per vedere chi altri ha modificato i file su cui state lavorando. | ||
303 | |||
304 | - Se state rispondendo a un rapporto su un baco, o a una richiesta di | ||
305 | funzionalità, includete anche gli autori di quei rapporti/richieste. | ||
306 | |||
307 | - Inviate una copia alle liste di discussione interessate, o, se nient'altro | ||
308 | è adatto, alla lista linux-kernel | ||
309 | |||
310 | - Se state correggendo un baco, pensate se la patch dovrebbe essere inclusa | ||
311 | nel prossimo rilascio stabile. Se è così, la lista di discussione | ||
312 | stable@vger.kernel.org dovrebbe riceverne una copia. Aggiungete anche | ||
313 | l'etichetta "Cc: stable@vger.kernel.org" nella patch stessa; questo | ||
314 | permetterà alla squadra *stable* di ricevere una notifica quando questa | ||
315 | correzione viene integrata nel ramo principale. | ||
316 | |||
317 | Quando scegliete i destinatari della patch, è bene avere un'idea di chi | ||
318 | pensiate che sia colui che, eventualmente, accetterà la vostra patch e | ||
319 | la integrerà. Nonostante sia possibile inviare patch direttamente a | ||
320 | Linus Torvalds, e lasciare che sia lui ad integrarle,solitamente non è la | ||
321 | strada migliore da seguire. Linus è occupato, e ci sono dei manutentori di | ||
322 | sotto-sistema che controllano una parte specifica del kernel. Solitamente, | ||
323 | vorreste che siano questi manutentori ad integrare le vostre patch. Se non | ||
324 | c'è un chiaro manutentore, l'ultima spiaggia è spesso Andrew Morton. | ||
325 | |||
326 | Le patch devono avere anche un buon oggetto. Il tipico formato per l'oggetto | ||
327 | di una patch assomiglia a questo: | ||
328 | |||
329 | :: | ||
330 | |||
331 | [PATCH nn/mm] subsys: one-line description of the patch | ||
332 | |||
333 | dove "nn" è il numero ordinale della patch, "mm" è il numero totale delle patch | ||
334 | nella serie, e "subsys" è il nome del sottosistema interessato. Chiaramente, | ||
335 | nn/mm può essere omesso per una serie composta da una singola patch. | ||
336 | |||
337 | Se avete una significative serie di patch, è prassi inviare una descrizione | ||
338 | introduttiva come parte zero. Tuttavia questa convenzione non è universalmente | ||
339 | seguita; se la usate, ricordate che le informazioni nell'introduzione non | ||
340 | faranno parte del changelog del kernel. Quindi per favore, assicuratevi che | ||
341 | ogni patch abbia un changelog completo. | ||
342 | |||
343 | In generale, la seconda parte e quelle successive di una patch "composta" | ||
344 | dovrebbero essere inviate come risposta alla prima, cosicché vengano viste | ||
345 | come un unico *thread*. Strumenti come git e quilt hanno comandi per inviare | ||
346 | gruppi di patch con la struttura appropriata. Se avete una serie lunga | ||
347 | e state usando git, per favore state alla larga dall'opzione --chain-reply-to | ||
348 | per evitare di creare un annidamento eccessivo. | ||
diff --git a/Documentation/translations/it_IT/process/6.Followthrough.rst b/Documentation/translations/it_IT/process/6.Followthrough.rst new file mode 100644 index 000000000000..df7d5fb28832 --- /dev/null +++ b/Documentation/translations/it_IT/process/6.Followthrough.rst | |||
@@ -0,0 +1,240 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/6.Followthrough.rst <development_followthrough>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_followthrough: | ||
7 | |||
8 | ============= | ||
9 | Completamento | ||
10 | ============= | ||
11 | |||
12 | A questo punto, avete seguito le linee guida fino a questo punto e, con | ||
13 | l'aggiunta delle vostre capacità ingegneristiche, avete pubblicato una serie | ||
14 | perfetta di patch. Uno dei più grandi errori che possono essere commessi | ||
15 | persino da sviluppatori kernel esperti è quello di concludere che il | ||
16 | lavoro sia ormai finito. In verità, la pubblicazione delle patch | ||
17 | simboleggia una transizione alla fase successiva del processo, con, | ||
18 | probabilmente, ancora un po' di lavoro da fare. | ||
19 | |||
20 | È raro che una modifica sia così bella alla sua prima pubblicazione che non | ||
21 | ci sia alcuno spazio di miglioramento. Il programma di sviluppo del kernel | ||
22 | riconosce questo fatto e quindi, è fortemente orientato al miglioramento | ||
23 | del codice pubblicato. Voi, in qualità di autori del codice, dovrete | ||
24 | lavorare con la comunità del kernel per assicurare che il vostro codice | ||
25 | mantenga gli standard qualitativi richiesti. Un fallimento in questo | ||
26 | processo è quasi come impedire l'inclusione delle vostre patch nel | ||
27 | ramo principale. | ||
28 | |||
29 | Lavorare con i revisori | ||
30 | ======================= | ||
31 | |||
32 | Una patch che abbia una certa rilevanza avrà ricevuto numerosi commenti | ||
33 | da parte di altri sviluppatori dato che avranno revisionato il codice. | ||
34 | Lavorare con i revisori può rivelarsi, per molti sviluppatori, la parte | ||
35 | più intimidatoria del processo di sviluppo del kernel. La vita può esservi | ||
36 | resa molto più facile se tenete presente alcuni dettagli: | ||
37 | |||
38 | - Se avete descritto la vostra modifica correttamente, i revisori ne | ||
39 | comprenderanno il valore e il perché vi siete presi il disturbo di | ||
40 | scriverla. Ma tale valore non li tratterrà dal porvi una domanda | ||
41 | fondamentale: come verrà mantenuto questo codice nel kernel nei prossimi | ||
42 | cinque o dieci anni? Molti dei cambiamenti che potrebbero esservi | ||
43 | richiesti - da piccoli problemi di stile a sostanziali ristesure - | ||
44 | vengono dalla consapevolezza che Linux resterà in circolazione e in | ||
45 | continuo sviluppo ancora per diverse decadi. | ||
46 | |||
47 | - La revisione del codice è un duro lavoro, ed è un mestiere poco | ||
48 | riconosciuto; le persone ricordano chi ha scritto il codice, ma meno | ||
49 | fama è attribuita a chi lo ha revisionato. Quindi i revisori potrebbero | ||
50 | divenire burberi, specialmente quando vendono i medesimi errori venire | ||
51 | fatti ancora e ancora. Se ricevete una revisione che vi sembra abbia | ||
52 | un tono arrabbiato, insultante o addirittura offensivo, resistente alla | ||
53 | tentazione di rispondere a tono. La revisione riguarda il codice e non | ||
54 | la persona, e i revisori non vi stanno attaccando personalmente. | ||
55 | |||
56 | - Similarmente, i revisori del codice non stanno cercando di promuovere | ||
57 | i loro interessi a vostre spese. Gli sviluppatori del kernel spesso si | ||
58 | aspettano di lavorare sul kernel per anni, ma sanno che il loro datore | ||
59 | di lavoro può cambiare. Davvero, senza praticamente eccezioni, loro | ||
60 | stanno lavorando per la creazione del miglior kernel possibile; non | ||
61 | stanno cercando di creare un disagio ad aziende concorrenti. | ||
62 | |||
63 | Quello che si sta cercando di dire è che, quando i revisori vi inviano degli | ||
64 | appunti dovete fare attenzione alle osservazioni tecniche che vi stanno | ||
65 | facendo. Non lasciate che il loro modo di esprimersi o il vostro orgoglio | ||
66 | impediscano che ciò accada. Quando avete dei suggerimenti sulla revisione, | ||
67 | prendetevi il tempo per comprendere cosa il revisore stia cercando di | ||
68 | comunicarvi. Se possibile, sistemate le cose che il revisore vi chiede di | ||
69 | modificare. E rispondete al revisore ringraziandolo e spiegando come | ||
70 | intendete fare. | ||
71 | |||
72 | Notate che non dovete per forza essere d'accordo con ogni singola modifica | ||
73 | suggerita dai revisori. Se credete che il revisore non abbia compreso | ||
74 | il vostro codice, spiegateglielo. Se avete un'obiezione tecnica da fargli | ||
75 | su di una modifica suggerita, spiegatela inserendo anche la vostra soluzione | ||
76 | al problema. Se la vostra spiegazione ha senso, il revisore la accetterà. | ||
77 | Tuttavia, la vostra motivazione potrebbe non essere del tutto persuasiva, | ||
78 | specialmente se altri iniziano ad essere d'accordo con il revisore. | ||
79 | Prendetevi quindi un po' di tempo per pensare ancora alla cosa. Può risultare | ||
80 | facile essere accecati dalla propria soluzione al punto che non realizzate che | ||
81 | c'è qualcosa di fondamentalmente sbagliato o, magari, non state nemmeno | ||
82 | risolvendo il problema giusto. | ||
83 | |||
84 | Andrew Morton suggerisce che ogni suggerimento di revisione che non è | ||
85 | presente nella modifica del codice dovrebbe essere inserito in un commento | ||
86 | aggiuntivo; ciò può essere d'aiuto ai futuri revisori nell'evitare domande | ||
87 | che sorgono al primo sguardo. | ||
88 | |||
89 | Un errore fatale è quello di ignorare i commenti di revisione nella speranza | ||
90 | che se ne andranno. Non andranno via. Se pubblicherete nuovamente il | ||
91 | codice senza aver risposto ai commenti ricevuti, probabilmente le vostre | ||
92 | modifiche non andranno da nessuna parte. | ||
93 | |||
94 | Parlando di ripubblicazione del codice: per favore tenete a mente che i | ||
95 | revisori non ricorderanno tutti i dettagli del codice che avete pubblicato | ||
96 | l'ultima volta. Quindi è sempre una buona idea quella di ricordare ai | ||
97 | revisori le questioni sollevate precedetemene e come le avete risolte. | ||
98 | I revisori non dovrebbero star lì a cercare all'interno degli archivi per | ||
99 | famigliarizzare con ciò che è stato detto l'ultima volta; se li aiutate | ||
100 | in questo senso, saranno di umore migliore quando riguarderanno il vostro | ||
101 | codice. | ||
102 | |||
103 | Se invece avete cercato di far tutto correttamente ma le cose continuano | ||
104 | a non andar bene? Molti disaccordi di natura tecnica possono essere risolti | ||
105 | attraverso la discussione, ma ci sono volte dove qualcuno deve prendere | ||
106 | una decisione. Se credete veramente che tale decisione andrà contro di voi | ||
107 | ingiustamente, potete sempre tentare di rivolgervi a qualcuno più | ||
108 | in alto di voi. Per cose di questo genere la persona con più potere è | ||
109 | Andrew Morton. Andrew è una figura molto rispettata all'interno della | ||
110 | comunità di sviluppo del kernel; lui può spesso sbrogliare situazioni che | ||
111 | sembrano irrimediabilmente bloccate. Rivolgersi ad Andrew non deve essere | ||
112 | fatto alla leggera, e non deve essere fatto prima di aver esplorato tutte | ||
113 | le altre alternative. E tenete a mente, ovviamente, che nemmeno lui | ||
114 | potrebbe non essere d'accordo con voi. | ||
115 | |||
116 | Cosa accade poi | ||
117 | =============== | ||
118 | |||
119 | Se la modifica è ritenuta un elemento valido da essere aggiunta al kernel, | ||
120 | e una volta che la maggior parte degli appunti dei revisori sono stati | ||
121 | sistemati, il passo successivo solitamente è quello di entrare in un | ||
122 | sottosistema gestito da un manutentore. Come ciò avviene dipende dal | ||
123 | sottosistema medesimo; ogni manutentore ha il proprio modo di fare le cose. | ||
124 | In particolare, ci potrebbero essere diversi sorgenti - uno, magari, dedicato | ||
125 | alle modifiche pianificate per la finestra di fusione successiva, e un altro | ||
126 | per il lavoro di lungo periodo. | ||
127 | |||
128 | Per le modifiche proposte in aree per le quali non esiste un sottosistema | ||
129 | preciso (modifiche di gestione della memoria, per esempio), i sorgenti di | ||
130 | ripiego finiscono per essere -mm. Ed anche le modifiche che riguardano | ||
131 | più sottosistemi possono finire in quest'ultimo. | ||
132 | |||
133 | L'inclusione nei sorgenti di un sottosistema può comportare per una patch, | ||
134 | un alto livello di visibilità. Ora altri sviluppatori che stanno lavorando | ||
135 | in quei medesimi sorgenti avranno le vostre modifiche. I sottosistemi | ||
136 | solitamente riforniscono anche Linux-next, rendendo i propri contenuti | ||
137 | visibili all'intera comunità di sviluppo. A questo punto, ci sono buone | ||
138 | possibilità per voi di ricevere ulteriori commenti da un nuovo gruppo di | ||
139 | revisori; anche a questi commenti dovrete rispondere come avete già fatto per | ||
140 | gli altri. | ||
141 | |||
142 | Ciò che potrebbe accadere a questo punto, in base alla natura della vostra | ||
143 | modifica, riguarda eventuali conflitti con il lavoro svolto da altri. | ||
144 | Nella peggiore delle situazioni, i conflitti più pesanti tra modifiche possono | ||
145 | concludersi con la messa a lato di alcuni dei lavori svolti cosicché le | ||
146 | modifiche restanti possano funzionare ed essere integrate. Altre volte, la | ||
147 | risoluzione dei conflitti richiederà del lavoro con altri sviluppatori e, | ||
148 | possibilmente, lo spostamento di alcune patch da dei sorgenti a degli altri | ||
149 | in modo da assicurare che tutto sia applicato in modo pulito. Questo lavoro | ||
150 | può rivelarsi una spina nel fianco, ma consideratevi fortunati: prima | ||
151 | dell'avvento dei sorgenti linux-next, questi conflitti spesso emergevano solo | ||
152 | durante l'apertura della finestra di integrazione e dovevano essere smaltiti | ||
153 | in fretta. Ora essi possono essere risolti comodamente, prima dell'apertura | ||
154 | della finestra. | ||
155 | |||
156 | Un giorno, se tutto va bene, vi collegherete e vedrete che la vostra patch | ||
157 | è stata inserita nel ramo principale de kernel. Congratulazioni! Terminati | ||
158 | i festeggiamenti (nel frattempo avrete inserito il vostro nome nel file | ||
159 | MAINTAINERS) vale la pena ricordare una piccola cosa, ma importante: il | ||
160 | lavoro non è ancora finito. L'inserimento nel ramo principale porta con se | ||
161 | nuove sfide. | ||
162 | |||
163 | Cominciamo con il dire che ora la visibilità della vostra modifica è | ||
164 | ulteriormente cresciuta. Ci potrebbe portare ad una nuova fase di | ||
165 | commenti dagli sviluppatori che non erano ancora a conoscenza della vostra | ||
166 | patch. Ignorarli potrebbe essere allettante dato che non ci sono più | ||
167 | dubbi sull'integrazione della modifica. Resistete a tale tentazione, dovete | ||
168 | mantenervi disponibili agli sviluppatori che hanno domande o suggerimenti | ||
169 | per voi. | ||
170 | |||
171 | Ancora più importante: l'inclusione nel ramo principale mette il vostro | ||
172 | codice nelle mani di un gruppo di *tester* molto più esteso. Anche se avete | ||
173 | contribuito ad un driver per un hardware che non è ancora disponibile, sarete | ||
174 | sorpresi da quante persone inseriranno il vostro codice nei loro kernel. | ||
175 | E, ovviamente, dove ci sono *tester*, ci saranno anche dei rapporti su | ||
176 | eventuali bachi. | ||
177 | |||
178 | La peggior specie di rapporti sono quelli che indicano delle regressioni. | ||
179 | Se la vostra modifica causa una regressione, avrete un gran numero di | ||
180 | occhi puntati su di voi; la regressione deve essere sistemata il prima | ||
181 | possibile. Se non vorrete o non sarete capaci di sistemarla (e nessuno | ||
182 | lo farà per voi), la vostra modifica sarà quasi certamente rimossa durante | ||
183 | la fase di stabilizzazione. Oltre alla perdita di tutto il lavoro svolto | ||
184 | per far si che la vostra modifica fosse inserita nel ramo principale, | ||
185 | l'avere una modifica rimossa a causa del fallimento nel sistemare una | ||
186 | regressione, potrebbe rendere più difficile per voi far accettare | ||
187 | il vostro lavoro in futuro. | ||
188 | |||
189 | Dopo che ogni regressione è stata affrontata, ci potrebbero essere altri | ||
190 | bachi ordinari da "sconfiggere". Il periodo di stabilizzazione è la | ||
191 | vostra migliore opportunità per sistemare questi bachi e assicurarvi che | ||
192 | il debutto del vostro codice nel ramo principale del kernel sia il più solido | ||
193 | possibile. Quindi, per favore, rispondete ai rapporti sui bachi e ponete | ||
194 | rimedio, se possibile, a tutti i problemi. È a questo che serve il periodo | ||
195 | di stabilizzazione; potete iniziare creando nuove fantastiche modifiche | ||
196 | una volta che ogni problema con le vecchie sia stato risolto. | ||
197 | |||
198 | Non dimenticate che esistono altre pietre miliari che possono generare | ||
199 | rapporti sui bachi: il successivo rilascio stabile, quando una distribuzione | ||
200 | importante usa una versione del kernel nel quale è presente la vostra | ||
201 | modifica, eccetera. Il continuare a rispondere a questi rapporti è fonte di | ||
202 | orgoglio per il vostro lavoro. Se questa non è una sufficiente motivazione, | ||
203 | allora, è anche consigliabile considera che la comunità di sviluppo ricorda | ||
204 | gli sviluppatori che hanno perso interesse per il loro codice una volta | ||
205 | integrato. La prossima volta che pubblicherete una patch, la comunità | ||
206 | la valuterà anche sulla base del fatto che non sarete disponibili a | ||
207 | prendervene cura anche nel futuro. | ||
208 | |||
209 | |||
210 | Altre cose che posso accadere | ||
211 | ============================= | ||
212 | |||
213 | Un giorno, potreste aprire la vostra email e vedere che qualcuno vi ha | ||
214 | inviato una patch per il vostro codice. Questo, dopo tutto, è uno dei | ||
215 | vantaggi di avere il vostro codice "là fuori". Se siete d'accordo con | ||
216 | la modifica, potrete anche inoltrarla ad un manutentore di sottosistema | ||
217 | (assicuratevi di includere la riga "From:" cosicché l'attribuzione sia | ||
218 | corretta, e aggiungete una vostra firma "Signed-off-by"), oppure inviate | ||
219 | un "Acked-by:" e lasciate che l'autore originale la invii. | ||
220 | |||
221 | Se non siete d'accordo con la patch, inviate una risposta educata | ||
222 | spiegando il perché. Se possibile, dite all'autore quali cambiamenti | ||
223 | servirebbero per rendere la patch accettabile da voi. C'è una certa | ||
224 | riluttanza nell'inserire modifiche con un conflitto fra autore | ||
225 | e manutentore del codice, ma solo fino ad un certo punto. Se siete visti | ||
226 | come qualcuno che blocca un buon lavoro senza motivo, quelle patch vi | ||
227 | passeranno oltre e andranno nel ramo principale in ogni caso. Nel kernel | ||
228 | Linux, nessuno ha potere di veto assoluto su alcun codice. Eccezione | ||
229 | fatta per Linus, forse. | ||
230 | |||
231 | In rarissime occasioni, potreste vedere qualcosa di completamente diverso: | ||
232 | un altro sviluppatore che pubblica una soluzione differente al vostro | ||
233 | problema. A questo punto, c'è una buona probabilità che una delle due | ||
234 | modifiche non verrà integrata, e il "c'ero prima io" non è considerato | ||
235 | un argomento tecnico rilevante. Se la modifica di qualcun'altro rimpiazza | ||
236 | la vostra ed entra nel ramo principale, esiste un unico modo di reagire: | ||
237 | siate contenti che il vostro problema sia stato risolto e andate avanti con | ||
238 | il vostro lavoro. L'avere un vostro lavoro spintonato da parte in questo | ||
239 | modo può essere avvilente e scoraggiante, ma la comunità ricorderà come | ||
240 | avrete reagito anche dopo che avrà dimenticato quale fu la modifica accettata. | ||
diff --git a/Documentation/translations/it_IT/process/7.AdvancedTopics.rst b/Documentation/translations/it_IT/process/7.AdvancedTopics.rst new file mode 100644 index 000000000000..cc1cff5d23ae --- /dev/null +++ b/Documentation/translations/it_IT/process/7.AdvancedTopics.rst | |||
@@ -0,0 +1,191 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/7.AdvancedTopics.rst <development_advancedtopics>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_advancedtopics: | ||
7 | |||
8 | Argomenti avanzati | ||
9 | ================== | ||
10 | |||
11 | A questo punto, si spera, dovreste avere un'idea su come funziona il processo | ||
12 | di sviluppo. Ma rimane comunque molto da imparare! Questo capitolo copre | ||
13 | alcuni argomenti che potrebbero essere utili per gli sviluppatori che stanno | ||
14 | per diventare parte integrante del processo di sviluppo del kernel. | ||
15 | |||
16 | Gestire le modifiche con git | ||
17 | ----------------------------- | ||
18 | |||
19 | L'uso di un sistema distribuito per il controllo delle versioni del kernel | ||
20 | ebbe iniziò nel 2002 quando Linux iniziò a provare il programma proprietario | ||
21 | BitKeeper. Nonostante l'uso di BitKeeper fosse opinabile, di certo il suo | ||
22 | approccio alla gestione dei sorgenti non lo era. Un sistema distribuito per | ||
23 | il controllo delle versioni accelerò immediatamente lo sviluppo del kernel. | ||
24 | Oggigiorno, ci sono diverse alternative libere a BitKeeper. Per il meglio o il | ||
25 | peggio, il progetto del kernel ha deciso di usare git per gestire i sorgenti. | ||
26 | |||
27 | Gestire le modifiche con git può rendere la vita dello sviluppatore molto | ||
28 | più facile, specialmente quando il volume delle modifiche cresce. | ||
29 | Git ha anche i suoi lati taglienti che possono essere pericolosi; è uno | ||
30 | strumento giovane e potente che è ancora in fase di civilizzazione da parte | ||
31 | dei suoi sviluppatori. Questo documento non ha lo scopo di insegnare l'uso | ||
32 | di git ai suoi lettori; ci sarebbe materiale a sufficienza per un lungo | ||
33 | documento al riguardo. Invece, qui ci concentriamo in particolare su come | ||
34 | git è parte del processo di sviluppo del kernel. Gli sviluppatori che | ||
35 | desiderassero diventare agili con git troveranno più informazioni ai | ||
36 | seguenti indirizzi: | ||
37 | |||
38 | http://git-scm.com/ | ||
39 | |||
40 | http://www.kernel.org/pub/software/scm/git/docs/user-manual.html | ||
41 | |||
42 | e su varie guide che potrete trovare su internet. | ||
43 | |||
44 | La prima cosa da fare prima di usarlo per produrre patch che saranno | ||
45 | disponibili ad altri, è quella di leggere i siti qui sopra e di acquisire una | ||
46 | base solida su come funziona git. Uno sviluppatore che sappia usare git | ||
47 | dovrebbe essere capace di ottenere una copia del repositorio principale, | ||
48 | esplorare la storia della revisione, registrare le modifiche, usare i rami, | ||
49 | eccetera. Una certa comprensione degli strumenti git per riscrivere la storia | ||
50 | (come ``rebase``) è altrettanto utile. Git ha i propri concetti e la propria | ||
51 | terminologia; un nuovo utente dovrebbe conoscere *refs*, *remote branch*, | ||
52 | *index*, *fast-forward merge*, *push* e *pull*, *detached head*, eccetera. | ||
53 | Il tutto potrebbe essere un po' intimidatorio visto da fuori, ma con un po' | ||
54 | di studio i concetti non saranno così difficili da capire. | ||
55 | |||
56 | Utilizzare git per produrre patch da sottomettere via email può essere | ||
57 | un buon esercizio da fare mentre si sta prendendo confidenza con lo strumento. | ||
58 | |||
59 | Quando sarete in grado di creare rami git che siano guardabili da altri, | ||
60 | vi servirà, ovviamente, un server dal quale sia possibile attingere le vostre | ||
61 | modifiche. Se avete un server accessibile da Internet, configurarlo per | ||
62 | eseguire git-daemon è relativamente semplice . Altrimenti, iniziano a | ||
63 | svilupparsi piattaforme che offrono spazi pubblici, e gratuiti (Github, | ||
64 | per esempio). Gli sviluppatori permanenti possono ottenere un account | ||
65 | su kernel.org, ma non è proprio facile da ottenere; per maggiori informazioni | ||
66 | consultate la pagina web http://kernel.org/faq/. | ||
67 | |||
68 | In git è normale avere a che fare con tanti rami. Ogni linea di sviluppo | ||
69 | può essere separata in "rami per argomenti" e gestiti indipendentemente. | ||
70 | In git i rami sono facilissimi, per cui non c'è motivo per non usarli | ||
71 | in libertà. In ogni caso, non dovreste sviluppare su alcun ramo dal | ||
72 | quale altri potrebbero attingere. I rami disponibili pubblicamente dovrebbero | ||
73 | essere creati con attenzione; integrate patch dai rami di sviluppo | ||
74 | solo quando sono complete e pronte ad essere consegnate - non prima. | ||
75 | |||
76 | Git offre alcuni strumenti che vi permettono di riscrivere la storia del | ||
77 | vostro sviluppo. Una modifica errata (diciamo, una che rompe la bisezione, | ||
78 | oppure che ha un qualche tipo di baco evidente) può essere corretta sul posto | ||
79 | o fatta sparire completamente dalla storia. Una serie di patch può essere | ||
80 | riscritta come se fosse stata scritta in cima al ramo principale di oggi, | ||
81 | anche se ci avete lavorato per mesi. Le modifiche possono essere spostate | ||
82 | in modo trasparente da un ramo ad un altro. E così via. Un uso giudizioso | ||
83 | di git per revisionare la storia può aiutare nella creazione di una serie | ||
84 | di patch pulite e con meno problemi. | ||
85 | |||
86 | Un uso eccessivo può portare ad altri tipi di problemi, tuttavia, oltre | ||
87 | alla semplice ossessione per la creazione di una storia del progetto che sia | ||
88 | perfetta. Riscrivere la storia riscriverà le patch contenute in quella | ||
89 | storia, trasformando un kernel verificato (si spera) in uno da verificare. | ||
90 | Ma, oltre a questo, gli sviluppatori non possono collaborare se non condividono | ||
91 | la stessa vista sulla storia del progetto; se riscrivete la storia dalla quale | ||
92 | altri sviluppatori hanno attinto per i loro repositori, renderete la loro vita | ||
93 | molto più difficile. Quindi tenete conto di questa semplice regola generale: | ||
94 | la storia che avete esposto ad altri, generalmente, dovrebbe essere vista come | ||
95 | immutabile. | ||
96 | |||
97 | Dunque, una volta che il vostro insieme di patch è stato reso disponibile | ||
98 | pubblicamente non dovrebbe essere più sovrascritto. Git tenterà di imporre | ||
99 | questa regola, e si rifiuterà di pubblicare nuove patch che non risultino | ||
100 | essere dirette discendenti di quelle pubblicate in precedenza (in altre parole, | ||
101 | patch che non condividono la stessa storia). È possibile ignorare questo | ||
102 | controllo, e ci saranno momenti in cui sarà davvero necessario riscrivere | ||
103 | un ramo già pubblicato. Un esempio è linux-next dove le patch vengono | ||
104 | spostate da un ramo all'altro al fine di evitare conflitti. Ma questo tipo | ||
105 | d'azione dovrebbe essere un'eccezione. Questo è uno dei motivi per cui lo | ||
106 | sviluppo dovrebbe avvenire in rami privati (che possono essere sovrascritti | ||
107 | quando lo si ritiene necessario) e reso pubblico solo quando è in uno stato | ||
108 | avanzato. | ||
109 | |||
110 | Man mano che il ramo principale (o altri rami su cui avete basato le | ||
111 | modifiche) avanza, diventa allettante l'idea di integrare tutte le patch | ||
112 | per rimanere sempre aggiornati. Per un ramo privato, il *rebase* può essere | ||
113 | un modo semplice per rimanere aggiornati, ma questa non è un'opzione nel | ||
114 | momento in cui il vostro ramo è stato esposto al mondo intero. | ||
115 | *Merge* occasionali possono essere considerati di buon senso, ma quando | ||
116 | diventano troppo frequenti confondono inutilmente la storia. La tecnica | ||
117 | suggerita in questi casi è quella di fare *merge* raramente, e più in generale | ||
118 | solo nei momenti di rilascio (per esempio gli -rc del ramo principale). | ||
119 | Se siete nervosi circa alcune patch in particolare, potete sempre fare | ||
120 | dei *merge* di test in un ramo privato. In queste situazioni git "rerere" | ||
121 | può essere utile; questo strumento si ricorda come i conflitti di *merge* | ||
122 | furono risolti in passato cosicché non dovrete fare lo stesso lavoro due volte. | ||
123 | |||
124 | Una delle lamentele più grosse e ricorrenti sull'uso di strumenti come git | ||
125 | è il grande movimento di patch da un repositorio all'altro che rende | ||
126 | facile l'integrazione nel ramo principale di modifiche mediocri, il tutto | ||
127 | sotto il naso dei revisori. Gli sviluppatori del kernel tendono ad essere | ||
128 | scontenti quando vedono succedere queste cose; preparare un ramo git con | ||
129 | patch che non hanno ricevuto alcuna revisione o completamente avulse, potrebbe | ||
130 | influire sulla vostra capacita di proporre, in futuro, l'integrazione dei | ||
131 | vostri rami. Citando Linus | ||
132 | |||
133 | :: | ||
134 | |||
135 | Potete inviarmi le vostre patch, ma per far si che io integri una | ||
136 | vostra modifica da git, devo sapere che voi sappiate cosa state | ||
137 | facendo, e ho bisogno di fidarmi *senza* dover passare tutte | ||
138 | le modifiche manualmente una per una. | ||
139 | |||
140 | (http://lwn.net/Articles/224135/). | ||
141 | |||
142 | Per evitare queste situazioni, assicuratevi che tutte le patch in un ramo | ||
143 | siano strettamente correlate al tema delle modifiche; un ramo "driver fixes" | ||
144 | non dovrebbe fare modifiche al codice principale per la gestione della memoria. | ||
145 | E, più importante ancora, non usate un repositorio git per tentare di | ||
146 | evitare il processo di revisione. Pubblicate un sommario di quello che il | ||
147 | vostro ramo contiene sulle liste di discussione più opportune, e , quando | ||
148 | sarà il momento, richiedete che il vostro ramo venga integrato in linux-next. | ||
149 | |||
150 | Se e quando altri inizieranno ad inviarvi patch per essere incluse nel | ||
151 | vostro repositorio, non dovete dimenticare di revisionarle. Inoltre | ||
152 | assicuratevi di mantenerne le informazioni di paternità; al riguardo git "am" | ||
153 | fa del suo meglio, ma potreste dover aggiungere una riga "From:" alla patch | ||
154 | nel caso in cui sia arrivata per vie traverse. | ||
155 | |||
156 | Quando richiedete l'integrazione, siate certi di fornire tutte le informazioni: | ||
157 | dov'è il vostro repositorio, quale ramo integrare, e quali cambiamenti si | ||
158 | otterranno dall'integrazione. Il comando git request-pull può essere d'aiuto; | ||
159 | preparerà una richiesta nel modo in cui gli altri sviluppatori se l'aspettano, | ||
160 | e verificherà che vi siate ricordati di pubblicare quelle patch su un | ||
161 | server pubblico. | ||
162 | |||
163 | Revisionare le patch | ||
164 | -------------------- | ||
165 | |||
166 | Alcuni lettori potrebbero avere obiezioni sulla presenza di questa sezione | ||
167 | negli "argomenti avanzati" sulla base che anche gli sviluppatori principianti | ||
168 | dovrebbero revisionare le patch. É certamente vero che non c'è modo | ||
169 | migliore di imparare come programmare per il kernel che guardare il codice | ||
170 | pubblicato dagli altri. In aggiunta, i revisori sono sempre troppo pochi; | ||
171 | guardando il codice potete apportare un significativo contributo all'intero | ||
172 | processo. | ||
173 | |||
174 | Revisionare il codice potrebbe risultare intimidatorio, specialmente per i | ||
175 | nuovi arrivati che potrebbero sentirsi un po' nervosi nel questionare | ||
176 | il codice - in pubblico - pubblicato da sviluppatori più esperti. Perfino | ||
177 | il codice scritto dagli sviluppatori più esperti può essere migliorato. | ||
178 | Forse il suggerimento migliore per i revisori (tutti) è questo: formulate | ||
179 | i commenti come domande e non come critiche. Chiedere "Come viene rilasciato | ||
180 | il *lock* in questo percorso?" funziona sempre molto meglio che | ||
181 | "qui la sincronizzazione è sbagliata". | ||
182 | |||
183 | Diversi sviluppatori revisioneranno il codice con diversi punti di vista. | ||
184 | Alcuni potrebbero concentrarsi principalmente sullo stile del codice e se | ||
185 | alcune linee hanno degli spazio bianchi di troppo. Altri si chiederanno | ||
186 | se accettare una modifica interamente è una cosa positiva per il kernel | ||
187 | o no. E altri ancora si focalizzeranno sui problemi di sincronizzazione, | ||
188 | l'uso eccessivo di *stack*, problemi di sicurezza, duplicazione del codice | ||
189 | in altri contesti, documentazione, effetti negativi sulle prestazioni, cambi | ||
190 | all'ABI dello spazio utente, eccetera. Qualunque tipo di revisione è ben | ||
191 | accetta e di valore, se porta ad avere un codice migliore nel kernel. | ||
diff --git a/Documentation/translations/it_IT/process/8.Conclusion.rst b/Documentation/translations/it_IT/process/8.Conclusion.rst new file mode 100644 index 000000000000..039bfc5a4108 --- /dev/null +++ b/Documentation/translations/it_IT/process/8.Conclusion.rst | |||
@@ -0,0 +1,85 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/8.Conclusion.rst <development_conclusion>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_conclusion: | ||
7 | |||
8 | Per maggiori informazioni | ||
9 | ========================= | ||
10 | |||
11 | Esistono numerose fonti di informazioni sullo sviluppo del kernel Linux | ||
12 | e argomenti correlati. Primo tra questi sarà sempre la cartella Documentation | ||
13 | che si trova nei sorgenti kernel. | ||
14 | |||
15 | Il file :ref:`process/howto.rst <it_process_howto>` è un punto di partenza | ||
16 | importante; :ref:`process/submitting-patches.rst <it_submittingpatches>` e | ||
17 | :ref:`process/submitting-drivers.rst <it_submittingdrivers>` sono | ||
18 | anch'essi qualcosa che tutti gli sviluppatori del kernel dovrebbero leggere. | ||
19 | Molte API interne al kernel sono documentate utilizzando il meccanismo | ||
20 | kerneldoc; "make htmldocs" o "make pdfdocs" possono essere usati per generare | ||
21 | quei documenti in HTML o PDF (sebbene le versioni di TeX di alcune | ||
22 | distribuzioni hanno dei limiti interni e fallisce nel processare | ||
23 | appropriatamente i documenti). | ||
24 | |||
25 | Diversi siti web approfondiscono lo sviluppo del kernel ad ogni livello | ||
26 | di dettaglio. Il vostro autore vorrebbe umilmente suggerirvi | ||
27 | http://lwn.net/ come fonte; usando l'indice 'kernel' su LWN troverete | ||
28 | molti argomenti specifici sul kernel: | ||
29 | |||
30 | http://lwn.net/Kernel/Index/ | ||
31 | |||
32 | Oltre a ciò, una risorsa valida per gli sviluppatori kernel è: | ||
33 | |||
34 | http://kernelnewbies.org/ | ||
35 | |||
36 | E, ovviamente, una fonte da non dimenticare è http://kernel.org/, il luogo | ||
37 | definitivo per le informazioni sui rilasci del kernel. | ||
38 | |||
39 | Ci sono numerosi libri sullo sviluppo del kernel: | ||
40 | |||
41 | Linux Device Drivers, 3rd Edition (Jonathan Corbet, Alessandro | ||
42 | Rubini, and Greg Kroah-Hartman). In linea all'indirizzo | ||
43 | http://lwn.net/Kernel/LDD3/. | ||
44 | |||
45 | Linux Kernel Development (Robert Love). | ||
46 | |||
47 | Understanding the Linux Kernel (Daniel Bovet and Marco Cesati). | ||
48 | |||
49 | Tutti questi libri soffrono di un errore comune: tendono a risultare in un | ||
50 | certo senso obsoleti dal momento che si trovano in libreria da diverso | ||
51 | tempo. Comunque contengono informazioni abbastanza buone. | ||
52 | |||
53 | La documentazione per git la troverete su: | ||
54 | |||
55 | http://www.kernel.org/pub/software/scm/git/docs/ | ||
56 | |||
57 | http://www.kernel.org/pub/software/scm/git/docs/user-manual.html | ||
58 | |||
59 | |||
60 | |||
61 | Conclusioni | ||
62 | =========== | ||
63 | |||
64 | Congratulazioni a chiunque ce l'abbia fatta a terminare questo documento di | ||
65 | lungo-respiro. Si spera che abbia fornito un'utile comprensione d'insieme | ||
66 | di come il kernel Linux viene sviluppato e di come potete partecipare a | ||
67 | tale processo. | ||
68 | |||
69 | Infine, quello che conta è partecipare. Qualsiasi progetto software | ||
70 | open-source non è altro che la somma di quello che i suoi contributori | ||
71 | mettono al suo interno. Il kernel Linux è cresciuto velocemente e bene | ||
72 | perché ha ricevuto il supporto di un impressionante gruppo di sviluppatori, | ||
73 | ognuno dei quali sta lavorando per renderlo migliore. Il kernel è un esempio | ||
74 | importante di cosa può essere fatto quando migliaia di persone lavorano | ||
75 | insieme verso un obiettivo comune. | ||
76 | |||
77 | Il kernel può sempre beneficiare di una larga base di sviluppatori, tuttavia, | ||
78 | c'è sempre molto lavoro da fare. Ma, cosa non meno importante, molti degli | ||
79 | altri partecipanti all'ecosistema Linux possono trarre beneficio attraverso | ||
80 | il contributo al kernel. Inserire codice nel ramo principale è la chiave | ||
81 | per arrivare ad una qualità del codice più alta, bassa manutenzione e | ||
82 | bassi prezzi di distribuzione, alti livelli d'influenza sulla direzione | ||
83 | dello sviluppo del kernel, e molto altro. È una situazione nella quale | ||
84 | tutti coloro che sono coinvolti vincono. Mollate il vostro editor e | ||
85 | raggiungeteci; sarete più che benvenuti. | ||
diff --git a/Documentation/translations/it_IT/process/adding-syscalls.rst b/Documentation/translations/it_IT/process/adding-syscalls.rst new file mode 100644 index 000000000000..e0a64b0688a7 --- /dev/null +++ b/Documentation/translations/it_IT/process/adding-syscalls.rst | |||
@@ -0,0 +1,643 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/adding-syscalls.rst <addsyscalls>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_addsyscalls: | ||
7 | |||
8 | Aggiungere una nuova chiamata di sistema | ||
9 | ======================================== | ||
10 | |||
11 | Questo documento descrive quello che è necessario sapere per aggiungere | ||
12 | nuove chiamate di sistema al kernel Linux; questo è da considerarsi come | ||
13 | un'aggiunta ai soliti consigli su come proporre nuove modifiche | ||
14 | :ref:`Documentation/translations/it_IT/process/submitting-patches.rst <it_submittingpatches>`. | ||
15 | |||
16 | |||
17 | Alternative alle chiamate di sistema | ||
18 | ------------------------------------ | ||
19 | |||
20 | La prima considerazione da fare quando si aggiunge una nuova chiamata di | ||
21 | sistema è quella di valutare le alternative. Nonostante le chiamate di sistema | ||
22 | siano il punto di interazione fra spazio utente e kernel più tradizionale ed | ||
23 | ovvio, esistono altre possibilità - scegliete quella che meglio si adatta alle | ||
24 | vostra interfaccia. | ||
25 | |||
26 | - Se le operazioni coinvolte possono rassomigliare a quelle di un filesystem, | ||
27 | allora potrebbe avere molto più senso la creazione di un nuovo filesystem o | ||
28 | dispositivo. Inoltre, questo rende più facile incapsulare la nuova | ||
29 | funzionalità in un modulo kernel piuttosto che essere sviluppata nel cuore | ||
30 | del kernel. | ||
31 | |||
32 | - Se la nuova funzionalità prevede operazioni dove il kernel notifica | ||
33 | lo spazio utente su un avvenimento, allora restituire un descrittore | ||
34 | di file all'oggetto corrispondente permette allo spazio utente di | ||
35 | utilizzare ``poll``/``select``/``epoll`` per ricevere quelle notifiche. | ||
36 | - Tuttavia, le operazioni che non si sposano bene con operazioni tipo | ||
37 | :manpage:`read(2)`/:manpage:`write(2)` dovrebbero essere implementate | ||
38 | come chiamate :manpage:`ioctl(2)`, il che potrebbe portare ad un'API in | ||
39 | un qualche modo opaca. | ||
40 | |||
41 | - Se dovete esporre solo delle informazioni sul sistema, un nuovo nodo in | ||
42 | sysfs (vedere ``Documentation/translations/it_IT/filesystems/sysfs.txt``) o | ||
43 | in procfs potrebbe essere sufficiente. Tuttavia, l'accesso a questi | ||
44 | meccanismi richiede che il filesystem sia montato, il che potrebbe non | ||
45 | essere sempre vero (per esempio, in ambienti come namespace/sandbox/chroot). | ||
46 | Evitate d'aggiungere nuove API in debugfs perché questo non viene | ||
47 | considerata un'interfaccia di 'produzione' verso lo spazio utente. | ||
48 | - Se l'operazione è specifica ad un particolare file o descrittore, allora | ||
49 | potrebbe essere appropriata l'aggiunta di un comando :manpage:`fcntl(2)`. | ||
50 | Tuttavia, :manpage:`fcntl(2)` è una chiamata di sistema multiplatrice che | ||
51 | nasconde una notevole complessità, quindi è ottima solo quando la nuova | ||
52 | funzione assomiglia a quelle già esistenti in :manpage:`fcntl(2)`, oppure | ||
53 | la nuova funzionalità è veramente semplice (per esempio, leggere/scrivere | ||
54 | un semplice flag associato ad un descrittore di file). | ||
55 | - Se l'operazione è specifica ad un particolare processo, allora | ||
56 | potrebbe essere appropriata l'aggiunta di un comando :manpage:`prctl(2)`. | ||
57 | Come per :manpage:`fcntl(2)`, questa chiamata di sistema è un complesso | ||
58 | multiplatore quindi è meglio usarlo per cose molto simili a quelle esistenti | ||
59 | nel comando ``prctl`` oppure per leggere/scrivere un semplice flag relativo | ||
60 | al processo. | ||
61 | |||
62 | |||
63 | Progettare l'API: pianificare le estensioni | ||
64 | ------------------------------------------- | ||
65 | |||
66 | Una nuova chiamata di sistema diventerà parte dell'API del kernel, e | ||
67 | dev'essere supportata per un periodo indefinito. Per questo, è davvero | ||
68 | un'ottima idea quella di discutere apertamente l'interfaccia sulla lista | ||
69 | di discussione del kernel, ed è altrettanto importante pianificarne eventuali | ||
70 | estensioni future. | ||
71 | |||
72 | (Nella tabella delle chiamate di sistema sono disseminati esempi dove questo | ||
73 | non fu fatto, assieme ai corrispondenti aggiornamenti - | ||
74 | ``eventfd``/``eventfd2``, ``dup2``/``dup3``, ``inotify_init``/``inotify_init1``, | ||
75 | ``pipe``/``pipe2``, ``renameat``/``renameat2`` --quindi imparate dalla storia | ||
76 | del kernel e pianificate le estensioni fin dall'inizio) | ||
77 | |||
78 | Per semplici chiamate di sistema che accettano solo un paio di argomenti, | ||
79 | il modo migliore di permettere l'estensibilità è quello di includere un | ||
80 | argomento *flags* alla chiamata di sistema. Per assicurarsi che i programmi | ||
81 | dello spazio utente possano usare in sicurezza *flags* con diverse versioni | ||
82 | del kernel, verificate se *flags* contiene un qualsiasi valore sconosciuto, | ||
83 | in qual caso rifiutate la chiamata di sistema (con ``EINVAL``):: | ||
84 | |||
85 | if (flags & ~(THING_FLAG1 | THING_FLAG2 | THING_FLAG3)) | ||
86 | return -EINVAL; | ||
87 | |||
88 | (Se *flags* non viene ancora utilizzato, verificate che l'argomento sia zero) | ||
89 | |||
90 | Per chiamate di sistema più sofisticate che coinvolgono un numero più grande di | ||
91 | argomenti, il modo migliore è quello di incapsularne la maggior parte in una | ||
92 | struttura dati che verrà passata per puntatore. Questa struttura potrà | ||
93 | funzionare con future estensioni includendo un campo *size*:: | ||
94 | |||
95 | struct xyzzy_params { | ||
96 | u32 size; /* userspace sets p->size = sizeof(struct xyzzy_params) */ | ||
97 | u32 param_1; | ||
98 | u64 param_2; | ||
99 | u64 param_3; | ||
100 | }; | ||
101 | |||
102 | Fintanto che un qualsiasi campo nuovo, diciamo ``param_4``, è progettato per | ||
103 | offrire il comportamento precedente quando vale zero, allora questo permetterà | ||
104 | di gestire un conflitto di versione in entrambe le direzioni: | ||
105 | |||
106 | - un vecchio kernel può gestire l'accesso di una versione moderna di un | ||
107 | programma in spazio utente verificando che la memoria oltre la dimensione | ||
108 | della struttura dati attesa sia zero (in pratica verificare che | ||
109 | ``param_4 == 0``). | ||
110 | - un nuovo kernel può gestire l'accesso di una versione vecchia di un | ||
111 | programma in spazio utente estendendo la struttura dati con zeri (in pratica | ||
112 | ``param_4 = 0``). | ||
113 | |||
114 | Vedere :manpage:`perf_event_open(2)` e la funzione ``perf_copy_attr()`` (in | ||
115 | ``kernel/events/core.c``) per un esempio pratico di questo approccio. | ||
116 | |||
117 | |||
118 | Progettare l'API: altre considerazioni | ||
119 | -------------------------------------- | ||
120 | |||
121 | Se la vostra nuova chiamata di sistema permette allo spazio utente di fare | ||
122 | riferimento ad un oggetto del kernel, allora questa dovrebbe usare un | ||
123 | descrittore di file per accesso all'oggetto - non inventatevi nuovi tipi di | ||
124 | accesso da spazio utente quando il kernel ha già dei meccanismi e una semantica | ||
125 | ben definita per utilizzare i descrittori di file. | ||
126 | |||
127 | Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` ritorna un nuovo | ||
128 | descrittore di file, allora l'argomento *flags* dovrebbe includere un valore | ||
129 | equivalente a ``O_CLOEXEC`` per i nuovi descrittori. Questo rende possibile, | ||
130 | nello spazio utente, la chiusura della finestra temporale fra le chiamate a | ||
131 | ``xyzzy()`` e ``fcntl(fd, F_SETFD, FD_CLOEXEC)``, dove un inaspettato | ||
132 | ``fork()`` o ``execve()`` potrebbe trasferire il descrittore al programma | ||
133 | eseguito (Comunque, resistete alla tentazione di riutilizzare il valore di | ||
134 | ``O_CLOEXEC`` dato che è specifico dell'architettura e fa parte di una | ||
135 | enumerazione di flag ``O_*`` che è abbastanza ricca). | ||
136 | |||
137 | Se la vostra nuova chiamata di sistema ritorna un nuovo descrittore di file, | ||
138 | dovreste considerare che significato avrà l'uso delle chiamate di sistema | ||
139 | della famiglia di :manpage:`poll(2)`. Rendere un descrittore di file pronto | ||
140 | per la lettura o la scrittura è il tipico modo del kernel per notificare lo | ||
141 | spazio utente circa un evento associato all'oggetto del kernel. | ||
142 | |||
143 | Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` ha un argomento | ||
144 | che è il percorso ad un file:: | ||
145 | |||
146 | int sys_xyzzy(const char __user *path, ..., unsigned int flags); | ||
147 | |||
148 | dovreste anche considerare se non sia più appropriata una versione | ||
149 | :manpage:`xyzzyat(2)`:: | ||
150 | |||
151 | int sys_xyzzyat(int dfd, const char __user *path, ..., unsigned int flags); | ||
152 | |||
153 | Questo permette più flessibilità su come lo spazio utente specificherà il file | ||
154 | in questione; in particolare, permette allo spazio utente di richiedere la | ||
155 | funzionalità su un descrittore di file già aperto utilizzando il *flag* | ||
156 | ``AT_EMPTY_PATH``, in pratica otterremmo gratuitamente l'operazione | ||
157 | :manpage:`fxyzzy(3)`:: | ||
158 | |||
159 | - xyzzyat(AT_FDCWD, path, ..., 0) is equivalent to xyzzy(path,...) | ||
160 | - xyzzyat(fd, "", ..., AT_EMPTY_PATH) is equivalent to fxyzzy(fd, ...) | ||
161 | |||
162 | (Per maggiori dettagli sulla logica delle chiamate \*at(), leggete la pagina | ||
163 | man :manpage:`openat(2)`; per un esempio di AT_EMPTY_PATH, leggere la pagina | ||
164 | man :manpage:`fstatat(2)`). | ||
165 | |||
166 | Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` prevede un parametro | ||
167 | per descrivere uno scostamento all'interno di un file, usate ``loff_t`` come | ||
168 | tipo cosicché scostamenti a 64-bit potranno essere supportati anche su | ||
169 | architetture a 32-bit. | ||
170 | |||
171 | Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` prevede l'uso di | ||
172 | funzioni riservate, allora dev'essere gestita da un opportuno bit di privilegio | ||
173 | (verificato con una chiamata a ``capable()``), come descritto nella pagina man | ||
174 | :manpage:`capabilities(7)`. Scegliete un bit di privilegio già esistente per | ||
175 | gestire la funzionalità associata, ma evitate la combinazione di diverse | ||
176 | funzionalità vagamente collegate dietro lo stesso bit, in quanto va contro il | ||
177 | principio di *capabilities* di separare i poteri di root. In particolare, | ||
178 | evitate di aggiungere nuovi usi al fin-troppo-generico privilegio | ||
179 | ``CAP_SYS_ADMIN``. | ||
180 | |||
181 | Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` manipola altri | ||
182 | processi oltre a quello chiamato, allora dovrebbe essere limitata (usando | ||
183 | la chiamata ``ptrace_may_access()``) di modo che solo un processo chiamante | ||
184 | con gli stessi permessi del processo in oggetto, o con i necessari privilegi, | ||
185 | possa manipolarlo. | ||
186 | |||
187 | Infine, state attenti che in alcune architetture non-x86 la vita delle chiamate | ||
188 | di sistema con argomenti a 64-bit viene semplificata se questi argomenti | ||
189 | ricadono in posizioni dispari (pratica, i parametri 1, 3, 5); questo permette | ||
190 | l'uso di coppie contigue di registri a 32-bit. (Questo non conta se gli | ||
191 | argomenti sono parte di una struttura dati che viene passata per puntatore). | ||
192 | |||
193 | |||
194 | Proporre l'API | ||
195 | -------------- | ||
196 | |||
197 | Al fine di rendere le nuove chiamate di sistema di facile revisione, è meglio | ||
198 | che dividiate le modifiche i pezzi separati. Questi dovrebbero includere | ||
199 | almeno le seguenti voci in *commit* distinti (ognuno dei quali sarà descritto | ||
200 | più avanti): | ||
201 | |||
202 | - l'essenza dell'implementazione della chiamata di sistema, con i prototipi, | ||
203 | i numeri generici, le modifiche al Kconfig e l'implementazione *stub* di | ||
204 | ripiego. | ||
205 | - preparare la nuova chiamata di sistema per un'architettura specifica, | ||
206 | solitamente x86 (ovvero tutti: x86_64, x86_32 e x32). | ||
207 | - un programma di auto-verifica da mettere in ``tools/testing/selftests/`` | ||
208 | che mostri l'uso della chiamata di sistema. | ||
209 | - una bozza di pagina man per la nuova chiamata di sistema. Può essere | ||
210 | scritta nell'email di presentazione, oppure come modifica vera e propria | ||
211 | al repositorio delle pagine man. | ||
212 | |||
213 | Le proposte di nuove chiamate di sistema, come ogni altro modifica all'API del | ||
214 | kernel, deve essere sottomessa alla lista di discussione | ||
215 | linux-api@vger.kernel.org. | ||
216 | |||
217 | |||
218 | Implementazione di chiamate di sistema generiche | ||
219 | ------------------------------------------------ | ||
220 | |||
221 | Il principale punto d'accesso alla vostra nuova chiamata di sistema | ||
222 | :manpage:`xyzzy(2)` verrà chiamato ``sys_xyzzy()``; ma, piuttosto che in modo | ||
223 | esplicito, lo aggiungerete tramite la macro ``SYSCALL_DEFINEn``. La 'n' | ||
224 | indica il numero di argomenti della chiamata di sistema; la macro ha come | ||
225 | argomento il nome della chiamata di sistema, seguito dalle coppie (tipo, nome) | ||
226 | per definire i suoi parametri. L'uso di questa macro permette di avere | ||
227 | i metadati della nuova chiamata di sistema disponibili anche per altri | ||
228 | strumenti. | ||
229 | |||
230 | Il nuovo punto d'accesso necessita anche del suo prototipo di funzione in | ||
231 | ``include/linux/syscalls.h``, marcato come asmlinkage di modo da abbinargli | ||
232 | il modo in cui quelle chiamate di sistema verranno invocate:: | ||
233 | |||
234 | asmlinkage long sys_xyzzy(...); | ||
235 | |||
236 | Alcune architetture (per esempio x86) hanno le loro specifiche tabelle di | ||
237 | chiamate di sistema (syscall), ma molte altre architetture condividono una | ||
238 | tabella comune di syscall. Aggiungete alla lista generica la vostra nuova | ||
239 | chiamata di sistema aggiungendo un nuovo elemento alla lista in | ||
240 | ``include/uapi/asm-generic/unistd.h``:: | ||
241 | |||
242 | #define __NR_xyzzy 292 | ||
243 | __SYSCALL(__NR_xyzzy, sys_xyzzy) | ||
244 | |||
245 | Aggiornate anche il contatore __NR_syscalls di modo che sia coerente con | ||
246 | l'aggiunta della nuove chiamate di sistema; va notato che se più di una nuova | ||
247 | chiamata di sistema viene aggiunga nella stessa finestra di sviluppo, il numero | ||
248 | della vostra nuova syscall potrebbe essere aggiustato al fine di risolvere i | ||
249 | conflitti. | ||
250 | |||
251 | Il file ``kernel/sys_ni.c`` fornisce le implementazioni *stub* di ripiego che | ||
252 | ritornano ``-ENOSYS``. Aggiungete la vostra nuova chiamata di sistema anche | ||
253 | qui:: | ||
254 | |||
255 | COND_SYSCALL(xyzzy); | ||
256 | |||
257 | La vostra nuova funzionalità del kernel, e la chiamata di sistema che la | ||
258 | controlla, dovrebbero essere opzionali. Quindi, aggiungete un'opzione | ||
259 | ``CONFIG`` (solitamente in ``init/Kconfig``). Come al solito per le nuove | ||
260 | opzioni ``CONFIG``: | ||
261 | |||
262 | - Includete una descrizione della nuova funzionalità e della chiamata di | ||
263 | sistema che la controlla. | ||
264 | - Rendete l'opzione dipendente da EXPERT se dev'essere nascosta agli utenti | ||
265 | normali. | ||
266 | - Nel Makefile, rendere tutti i nuovi file sorgenti, che implementano la | ||
267 | nuova funzionalità, dipendenti dall'opzione CONFIG (per esempio | ||
268 | ``obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.o``). | ||
269 | - Controllate due volte che sia possibile generare il kernel con la nuova | ||
270 | opzione CONFIG disabilitata. | ||
271 | |||
272 | Per riassumere, vi serve un *commit* che includa: | ||
273 | |||
274 | - un'opzione ``CONFIG``per la nuova funzione, normalmente in ``init/Kconfig`` | ||
275 | - ``SYSCALL_DEFINEn(xyzzy, ...)`` per il punto d'accesso | ||
276 | - il corrispondente prototipo in ``include/linux/syscalls.h`` | ||
277 | - un elemento nella tabella generica in ``include/uapi/asm-generic/unistd.h`` | ||
278 | - *stub* di ripiego in ``kernel/sys_ni.c`` | ||
279 | |||
280 | |||
281 | Implementazione delle chiamate di sistema x86 | ||
282 | --------------------------------------------- | ||
283 | |||
284 | Per collegare la vostra nuova chiamate di sistema alle piattaforme x86, | ||
285 | dovete aggiornate la tabella principale di syscall. Assumendo che la vostra | ||
286 | nuova chiamata di sistema non sia particolarmente speciale (vedere sotto), | ||
287 | dovete aggiungere un elemento *common* (per x86_64 e x32) in | ||
288 | arch/x86/entry/syscalls/syscall_64.tbl:: | ||
289 | |||
290 | 333 common xyzzy sys_xyzzy | ||
291 | |||
292 | e un elemento per *i386* ``arch/x86/entry/syscalls/syscall_32.tbl``:: | ||
293 | |||
294 | 380 i386 xyzzy sys_xyzzy | ||
295 | |||
296 | Ancora una volta, questi numeri potrebbero essere cambiati se generano | ||
297 | conflitti durante la finestra di integrazione. | ||
298 | |||
299 | |||
300 | Chiamate di sistema compatibili (generico) | ||
301 | ------------------------------------------ | ||
302 | |||
303 | Per molte chiamate di sistema, la stessa implementazione a 64-bit può essere | ||
304 | invocata anche quando il programma in spazio utente è a 32-bit; anche se la | ||
305 | chiamata di sistema include esplicitamente un puntatore, questo viene gestito | ||
306 | in modo trasparente. | ||
307 | |||
308 | Tuttavia, ci sono un paio di situazione dove diventa necessario avere un | ||
309 | livello di gestione della compatibilità per risolvere le differenze di | ||
310 | dimensioni fra 32-bit e 64-bit. | ||
311 | |||
312 | Il primo caso è quando un kernel a 64-bit supporta anche programmi in spazio | ||
313 | utente a 32-bit, perciò dovrà ispezionare aree della memoria (``__user``) che | ||
314 | potrebbero contenere valori a 32-bit o a 64-bit. In particolar modo, questo | ||
315 | è necessario quando un argomento di una chiamata di sistema è: | ||
316 | |||
317 | - un puntatore ad un puntatore | ||
318 | - un puntatore ad una struttura dati contenente a sua volta un puntatore | ||
319 | ( ad esempio ``struct iovec __user *``) | ||
320 | - un puntatore ad un tipo intero di dimensione variabile (``time_t``, | ||
321 | ``off_t``, ``long``, ...) | ||
322 | - un puntatore ad una struttura dati contenente un tipo intero di dimensione | ||
323 | variabile. | ||
324 | |||
325 | Il secondo caso che richiede un livello di gestione della compatibilità è | ||
326 | quando uno degli argomenti di una chiamata a sistema è esplicitamente un tipo | ||
327 | a 64-bit anche su architetture a 32-bit, per esempio ``loff_t`` o ``__u64``. | ||
328 | In questo caso, un valore che arriva ad un kernel a 64-bit da un'applicazione | ||
329 | a 32-bit verrà diviso in due valori a 32-bit che dovranno essere riassemblati | ||
330 | in questo livello di compatibilità. | ||
331 | |||
332 | (Da notare che non serve questo livello di compatibilità per argomenti che | ||
333 | sono puntatori ad un tipo esplicitamente a 64-bit; per esempio, in | ||
334 | :manpage:`splice(2)` l'argomento di tipo ``loff_t __user *`` non necessita | ||
335 | di una chiamata di sistema ``compat_``) | ||
336 | |||
337 | La versione compatibile della nostra chiamata di sistema si chiamerà | ||
338 | ``compat_sys_xyzzy()``, e viene aggiunta utilizzando la macro | ||
339 | ``COMPAT_SYSCALL_DEFINEn()`` (simile a SYSCALL_DEFINEn). Questa versione | ||
340 | dell'implementazione è parte del kernel a 64-bit ma accetta parametri a 32-bit | ||
341 | che trasformerà secondo le necessità (tipicamente, la versione | ||
342 | ``compat_sys_`` converte questi valori nello loro corrispondente a 64-bit e | ||
343 | può chiamare la versione ``sys_`` oppure invocare una funzione che implementa | ||
344 | le parti comuni). | ||
345 | |||
346 | Il punto d'accesso *compat* deve avere il corrispondente prototipo di funzione | ||
347 | in ``include/linux/compat.h``, marcato come asmlinkage di modo da abbinargli | ||
348 | il modo in cui quelle chiamate di sistema verranno invocate:: | ||
349 | |||
350 | asmlinkage long compat_sys_xyzzy(...); | ||
351 | |||
352 | Se la chiamata di sistema prevede una struttura dati organizzata in modo | ||
353 | diverso per sistemi a 32-bit e per quelli a 64-bit, diciamo | ||
354 | ``struct xyzzy_args``, allora il file d'intestazione | ||
355 | ``then the include/linux/compat.h`` deve includere la sua versione | ||
356 | *compatibile* (``struct compat_xyzzy_args``); ogni variabile con | ||
357 | dimensione variabile deve avere il proprio tipo ``compat_`` corrispondente | ||
358 | a quello in ``struct xyzzy_args``. La funzione ``compat_sys_xyzzy()`` | ||
359 | può usare la struttura ``compat_`` per analizzare gli argomenti ricevuti | ||
360 | da una chiamata a 32-bit. | ||
361 | |||
362 | Per esempio, se avete i seguenti campi:: | ||
363 | |||
364 | struct xyzzy_args { | ||
365 | const char __user *ptr; | ||
366 | __kernel_long_t varying_val; | ||
367 | u64 fixed_val; | ||
368 | /* ... */ | ||
369 | }; | ||
370 | |||
371 | nella struttura ``struct xyzzy_args``, allora la struttura | ||
372 | ``struct compat_xyzzy_args`` dovrebbe avere:: | ||
373 | |||
374 | struct compat_xyzzy_args { | ||
375 | compat_uptr_t ptr; | ||
376 | compat_long_t varying_val; | ||
377 | u64 fixed_val; | ||
378 | /* ... */ | ||
379 | }; | ||
380 | |||
381 | La lista generica delle chiamate di sistema ha bisogno di essere | ||
382 | aggiustata al fine di permettere l'uso della versione *compatibile*; | ||
383 | la voce in ``include/uapi/asm-generic/unistd.h`` dovrebbero usare | ||
384 | ``__SC_COMP`` piuttosto di ``__SYSCALL``:: | ||
385 | |||
386 | #define __NR_xyzzy 292 | ||
387 | __SC_COMP(__NR_xyzzy, sys_xyzzy, compat_sys_xyzzy) | ||
388 | |||
389 | Riassumendo, vi serve: | ||
390 | |||
391 | - un ``COMPAT_SYSCALL_DEFINEn(xyzzy, ...)`` per il punto d'accesso | ||
392 | *compatibile* | ||
393 | - un prototipo in ``include/linux/compat.h`` | ||
394 | - (se necessario) una struttura di compatibilità a 32-bit in | ||
395 | ``include/linux/compat.h`` | ||
396 | - una voce ``__SC_COMP``, e non ``__SYSCALL``, in | ||
397 | ``include/uapi/asm-generic/unistd.h`` | ||
398 | |||
399 | Compatibilità delle chiamate di sistema (x86) | ||
400 | --------------------------------------------- | ||
401 | |||
402 | Per collegare una chiamata di sistema, su un'architettura x86, con la sua | ||
403 | versione *compatibile*, è necessario aggiustare la voce nella tabella | ||
404 | delle syscall. | ||
405 | |||
406 | Per prima cosa, la voce in ``arch/x86/entry/syscalls/syscall_32.tbl`` prende | ||
407 | un argomento aggiuntivo per indicare che un programma in spazio utente | ||
408 | a 32-bit, eseguito su un kernel a 64-bit, dovrebbe accedere tramite il punto | ||
409 | d'accesso compatibile:: | ||
410 | |||
411 | 380 i386 xyzzy sys_xyzzy __ia32_compat_sys_xyzzy | ||
412 | |||
413 | Secondo, dovete capire cosa dovrebbe succedere alla nuova chiamata di sistema | ||
414 | per la versione dell'ABI x32. Qui C'è una scelta da fare: gli argomenti | ||
415 | possono corrisponde alla versione a 64-bit o a quella a 32-bit. | ||
416 | |||
417 | Se c'è un puntatore ad un puntatore, la decisione è semplice: x32 è ILP32, | ||
418 | quindi gli argomenti dovrebbero corrispondere a quelli a 32-bit, e la voce in | ||
419 | ``arch/x86/entry/syscalls/syscall_64.tbl`` sarà divisa cosicché i programmi | ||
420 | x32 eseguano la chiamata *compatibile*:: | ||
421 | |||
422 | 333 64 xyzzy sys_xyzzy | ||
423 | ... | ||
424 | 555 x32 xyzzy __x32_compat_sys_xyzzy | ||
425 | |||
426 | Se non ci sono puntatori, allora è preferibile riutilizzare la chiamata di | ||
427 | sistema a 64-bit per l'ABI x32 (e di conseguenza la voce in | ||
428 | arch/x86/entry/syscalls/syscall_64.tbl rimane immutata). | ||
429 | |||
430 | In ambo i casi, dovreste verificare che i tipi usati dagli argomenti | ||
431 | abbiano un'esatta corrispondenza da x32 (-mx32) al loro equivalente a | ||
432 | 32-bit (-m32) o 64-bit (-m64). | ||
433 | |||
434 | |||
435 | Chiamate di sistema che ritornano altrove | ||
436 | ----------------------------------------- | ||
437 | |||
438 | Nella maggior parte delle chiamate di sistema, al termine della loro | ||
439 | esecuzione, i programmi in spazio utente riprendono esattamente dal punto | ||
440 | in cui si erano interrotti -- quindi dall'istruzione successiva, con lo | ||
441 | stesso *stack* e con la maggior parte del registri com'erano stati | ||
442 | lasciati prima della chiamata di sistema, e anche con la stessa memoria | ||
443 | virtuale. | ||
444 | |||
445 | Tuttavia, alcune chiamata di sistema fanno le cose in modo differente. | ||
446 | Potrebbero ritornare ad un punto diverso (``rt_sigreturn``) o cambiare | ||
447 | la memoria in spazio utente (``fork``/``vfork``/``clone``) o perfino | ||
448 | l'architettura del programma (``execve``/``execveat``). | ||
449 | |||
450 | Per permettere tutto ciò, l'implementazione nel kernel di questo tipo di | ||
451 | chiamate di sistema potrebbero dover salvare e ripristinare registri | ||
452 | aggiuntivi nello *stack* del kernel, permettendo così un controllo completo | ||
453 | su dove e come l'esecuzione dovrà continuare dopo l'esecuzione della | ||
454 | chiamata di sistema. | ||
455 | |||
456 | Queste saranno specifiche per ogni architettura, ma tipicamente si definiscono | ||
457 | dei punti d'accesso in *assembly* per salvare/ripristinare i registri | ||
458 | aggiuntivi e quindi chiamare il vero punto d'accesso per la chiamata di | ||
459 | sistema. | ||
460 | |||
461 | Per l'architettura x86_64, questo è implementato come un punto d'accesso | ||
462 | ``stub_xyzzy`` in ``arch/x86/entry/entry_64.S``, e la voce nella tabella | ||
463 | di syscall (``arch/x86/entry/syscalls/syscall_64.tbl``) verrà corretta di | ||
464 | conseguenza:: | ||
465 | |||
466 | 333 common xyzzy stub_xyzzy | ||
467 | |||
468 | L'equivalente per programmi a 32-bit eseguiti su un kernel a 64-bit viene | ||
469 | normalmente chiamato ``stub32_xyzzy`` e implementato in | ||
470 | ``arch/x86/entry/entry_64_compat.S`` con la corrispondente voce nella tabella | ||
471 | di syscall ``arch/x86/entry/syscalls/syscall_32.tbl`` corretta nel | ||
472 | seguente modo:: | ||
473 | |||
474 | 380 i386 xyzzy sys_xyzzy stub32_xyzzy | ||
475 | |||
476 | Se una chiamata di sistema necessita di un livello di compatibilità (come | ||
477 | nella sezione precedente), allora la versione ``stub32_`` deve invocare | ||
478 | la versione ``compat_sys_`` piuttosto che quella nativa a 64-bit. In aggiunta, | ||
479 | se l'implementazione dell'ABI x32 è diversa da quella x86_64, allora la sua | ||
480 | voce nella tabella di syscall dovrà chiamare uno *stub* che invoca la versione | ||
481 | ``compat_sys_``, | ||
482 | |||
483 | Per completezza, sarebbe carino impostare una mappatura cosicché | ||
484 | *user-mode* Linux (UML) continui a funzionare -- la sua tabella di syscall | ||
485 | farà riferimento a stub_xyzzy, ma UML non include l'implementazione | ||
486 | in ``arch/x86/entry/entry_64.S`` (perché UML simula i registri eccetera). | ||
487 | Correggerlo è semplice, basta aggiungere una #define in | ||
488 | ``arch/x86/um/sys_call_table_64.c``:: | ||
489 | |||
490 | #define stub_xyzzy sys_xyzzy | ||
491 | |||
492 | |||
493 | Altri dettagli | ||
494 | -------------- | ||
495 | |||
496 | La maggior parte dei kernel tratta le chiamate di sistema allo stesso modo, | ||
497 | ma possono esserci rare eccezioni per le quali potrebbe essere necessario | ||
498 | l'aggiornamento della vostra chiamata di sistema. | ||
499 | |||
500 | Il sotto-sistema di controllo (*audit subsystem*) è uno di questi casi | ||
501 | speciali; esso include (per architettura) funzioni che classificano alcuni | ||
502 | tipi di chiamate di sistema -- in particolare apertura dei file | ||
503 | (``open``/``openat``), esecuzione dei programmi (``execve``/``exeveat``) | ||
504 | oppure multiplatori di socket (``socketcall``). Se la vostra nuova chiamata | ||
505 | di sistema è simile ad una di queste, allora il sistema di controllo dovrebbe | ||
506 | essere aggiornato. | ||
507 | |||
508 | Più in generale, se esiste una chiamata di sistema che è simile alla vostra, | ||
509 | vale la pena fare una ricerca con ``grep`` su tutto il kernel per la chiamata | ||
510 | di sistema esistente per verificare che non ci siano altri casi speciali. | ||
511 | |||
512 | |||
513 | Verifica | ||
514 | -------- | ||
515 | |||
516 | Una nuova chiamata di sistema dev'essere, ovviamente, provata; è utile fornire | ||
517 | ai revisori un programma in spazio utente che mostri l'uso della chiamata di | ||
518 | sistema. Un buon modo per combinare queste cose è quello di aggiungere un | ||
519 | semplice programma di auto-verifica in una nuova cartella in | ||
520 | ``tools/testing/selftests/``. | ||
521 | |||
522 | Per una nuova chiamata di sistema, ovviamente, non ci sarà alcuna funzione | ||
523 | in libc e quindi il programma di verifica dovrà invocarla usando ``syscall()``; | ||
524 | inoltre, se la nuova chiamata di sistema prevede un nuova struttura dati | ||
525 | visibile in spazio utente, il file d'intestazione necessario dev'essere | ||
526 | installato al fine di compilare il programma. | ||
527 | |||
528 | Assicuratevi che il programma di auto-verifica possa essere eseguito | ||
529 | correttamente su tutte le architetture supportate. Per esempio, verificate che | ||
530 | funzioni quando viene compilato per x86_64 (-m64), x86_32 (-m32) e x32 (-mx32). | ||
531 | |||
532 | Al fine di una più meticolosa ed estesa verifica della nuova funzionalità, | ||
533 | dovreste considerare l'aggiunta di nuove verifica al progetto 'Linux Test', | ||
534 | oppure al progetto xfstests per cambiamenti relativi al filesystem. | ||
535 | |||
536 | - https://linux-test-project.github.io/ | ||
537 | - git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git | ||
538 | |||
539 | |||
540 | Pagine man | ||
541 | ---------- | ||
542 | |||
543 | Tutte le nuove chiamate di sistema dovrebbero avere una pagina man completa, | ||
544 | idealmente usando i marcatori groff, ma anche il puro testo può andare. Se | ||
545 | state usando groff, è utile che includiate nella email di presentazione una | ||
546 | versione già convertita in formato ASCII: semplificherà la vita dei revisori. | ||
547 | |||
548 | Le pagine man dovrebbero essere in copia-conoscenza verso | ||
549 | linux-man@vger.kernel.org | ||
550 | Per maggiori dettagli, leggere | ||
551 | https://www.kernel.org/doc/man-pages/patches.html | ||
552 | |||
553 | |||
554 | Non invocate chiamate di sistema dal kernel | ||
555 | ------------------------------------------- | ||
556 | |||
557 | Le chiamate di sistema sono, come già detto prima, punti di interazione fra | ||
558 | lo spazio utente e il kernel. Perciò, le chiamate di sistema come | ||
559 | ``sys_xyzzy()`` o ``compat_sys_xyzzy()`` dovrebbero essere chiamate solo dallo | ||
560 | spazio utente attraverso la tabella syscall, ma non da nessun altro punto nel | ||
561 | kernel. Se la nuova funzionalità è utile all'interno del kernel, per esempio | ||
562 | dev'essere condivisa fra una vecchia e una nuova chiamata di sistema o | ||
563 | dev'essere utilizzata da una chiamata di sistema e la sua variante compatibile, | ||
564 | allora dev'essere implementata come una funzione di supporto | ||
565 | (*helper function*) (per esempio ``kern_xyzzy()``). Questa funzione potrà | ||
566 | essere chiamata dallo *stub* (``sys_xyzzy()``), dalla variante compatibile | ||
567 | (``compat_sys_xyzzy()``), e/o da altri parti del kernel. | ||
568 | |||
569 | Sui sistemi x86 a 64-bit, a partire dalla versione v4.17 è un requisito | ||
570 | fondamentale quello di non invocare chiamate di sistema all'interno del kernel. | ||
571 | Esso usa una diversa convenzione per l'invocazione di chiamate di sistema dove | ||
572 | ``struct pt_regs`` viene decodificata al volo in una funzione che racchiude | ||
573 | la chiamata di sistema la quale verrà eseguita successivamente. | ||
574 | Questo significa che verranno passati solo i parametri che sono davvero | ||
575 | necessari ad una specifica chiamata di sistema, invece che riempire ogni volta | ||
576 | 6 registri del processore con contenuti presi dallo spazio utente (potrebbe | ||
577 | causare seri problemi nella sequenza di chiamate). | ||
578 | |||
579 | Inoltre, le regole su come i dati possano essere usati potrebbero differire | ||
580 | fra il kernel e l'utente. Questo è un altro motivo per cui invocare | ||
581 | ``sys_xyzzy()`` è generalmente una brutta idea. | ||
582 | |||
583 | Eccezioni a questa regola vengono accettate solo per funzioni d'architetture | ||
584 | che surclassano quelle generiche, per funzioni d'architettura di compatibilità, | ||
585 | o per altro codice in arch/ | ||
586 | |||
587 | |||
588 | Riferimenti e fonti | ||
589 | ------------------- | ||
590 | |||
591 | - Articolo di Michael Kerris su LWN sull'uso dell'argomento flags nelle | ||
592 | chiamate di sistema: https://lwn.net/Articles/585415/ | ||
593 | - Articolo di Michael Kerris su LWN su come gestire flag sconosciuti in | ||
594 | una chiamata di sistema: https://lwn.net/Articles/588444/ | ||
595 | - Articolo di Jake Edge su LWN che descrive i limiti degli argomenti a 64-bit | ||
596 | delle chiamate di sistema: https://lwn.net/Articles/311630/ | ||
597 | - Una coppia di articoli di David Drysdale che descrivono i dettagli del | ||
598 | percorso implementativo di una chiamata di sistema per la versione v3.14: | ||
599 | |||
600 | - https://lwn.net/Articles/604287/ | ||
601 | - https://lwn.net/Articles/604515/ | ||
602 | |||
603 | - Requisiti specifici alle architetture sono discussi nella pagina man | ||
604 | :manpage:`syscall(2)` : | ||
605 | http://man7.org/linux/man-pages/man2/syscall.2.html#NOTES | ||
606 | - Collezione di email di Linux Torvalds sui problemi relativi a ``ioctl()``: | ||
607 | http://yarchive.net/comp/linux/ioctl.html | ||
608 | - "Come non inventare interfacce del kernel", Arnd Bergmann, | ||
609 | http://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdf | ||
610 | - Articolo di Michael Kerris su LWN sull'evitare nuovi usi di CAP_SYS_ADMIN: | ||
611 | https://lwn.net/Articles/486306/ | ||
612 | - Raccomandazioni da Andrew Morton circa il fatto che tutte le informazioni | ||
613 | su una nuova chiamata di sistema dovrebbero essere contenute nello stesso | ||
614 | filone di discussione di email: https://lkml.org/lkml/2014/7/24/641 | ||
615 | - Raccomandazioni da Michael Kerrisk circa il fatto che le nuove chiamate di | ||
616 | sistema dovrebbero avere una pagina man: https://lkml.org/lkml/2014/6/13/309 | ||
617 | - Consigli da Thomas Gleixner sul fatto che il collegamento all'architettura | ||
618 | x86 dovrebbe avvenire in un *commit* differente: | ||
619 | https://lkml.org/lkml/2014/11/19/254 | ||
620 | - Consigli da Greg Kroah-Hartman circa la bontà d'avere una pagina man e un | ||
621 | programma di auto-verifica per le nuove chiamate di sistema: | ||
622 | https://lkml.org/lkml/2014/3/19/710 | ||
623 | - Discussione di Michael Kerrisk sulle nuove chiamate di sistema contro | ||
624 | le estensioni :manpage:`prctl(2)`: https://lkml.org/lkml/2014/6/3/411 | ||
625 | - Consigli da Ingo Molnar che le chiamate di sistema con più argomenti | ||
626 | dovrebbero incapsularli in una struttura che includa un argomento | ||
627 | *size* per garantire l'estensibilità futura: | ||
628 | https://lkml.org/lkml/2015/7/30/117 | ||
629 | - Un certo numero di casi strani emersi dall'uso (riuso) dei flag O_*: | ||
630 | |||
631 | - commit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness | ||
632 | check") | ||
633 | - commit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc | ||
634 | conflict") | ||
635 | - commit bb458c644a59 ("Safer ABI for O_TMPFILE") | ||
636 | |||
637 | - Discussion from Matthew Wilcox about restrictions on 64-bit arguments: | ||
638 | https://lkml.org/lkml/2008/12/12/187 | ||
639 | - Raccomandazioni da Greg Kroah-Hartman sul fatto che i flag sconosciuti dovrebbero | ||
640 | essere controllati: https://lkml.org/lkml/2014/7/17/577 | ||
641 | - Raccomandazioni da Linus Torvalds che le chiamate di sistema x32 dovrebbero | ||
642 | favorire la compatibilità con le versioni a 64-bit piuttosto che quelle a 32-bit: | ||
643 | https://lkml.org/lkml/2011/8/31/244 | ||
diff --git a/Documentation/translations/it_IT/process/applying-patches.rst b/Documentation/translations/it_IT/process/applying-patches.rst new file mode 100644 index 000000000000..f5e9c7d0b16d --- /dev/null +++ b/Documentation/translations/it_IT/process/applying-patches.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/applying-patches.rst <applying_patches>` | ||
4 | |||
5 | |||
6 | .. _it_applying_patches: | ||
7 | |||
8 | Applicare modifiche al kernel Linux | ||
9 | =================================== | ||
10 | |||
11 | .. warning:: | ||
12 | |||
13 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/changes.rst b/Documentation/translations/it_IT/process/changes.rst new file mode 100644 index 000000000000..956cf95a1214 --- /dev/null +++ b/Documentation/translations/it_IT/process/changes.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/changes.rst <changes>` | ||
4 | |||
5 | .. _it_changes: | ||
6 | |||
7 | Requisiti minimi per compilare il kernel | ||
8 | ++++++++++++++++++++++++++++++++++++++++ | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/clang-format.rst b/Documentation/translations/it_IT/process/clang-format.rst new file mode 100644 index 000000000000..77eac809a639 --- /dev/null +++ b/Documentation/translations/it_IT/process/clang-format.rst | |||
@@ -0,0 +1,197 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/clang-format.rst <clangformat>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_clangformat: | ||
7 | |||
8 | clang-format | ||
9 | ============ | ||
10 | ``clang-format`` è uno strumento per formattare codice C/C++/... secondo | ||
11 | un gruppo di regole ed euristiche. Come tutti gli strumenti, non è perfetto | ||
12 | e non copre tutti i singoli casi, ma è abbastanza buono per essere utile. | ||
13 | |||
14 | ``clang-format`` può essere usato per diversi fini: | ||
15 | |||
16 | - Per riformattare rapidamente un blocco di codice secondo lo stile del | ||
17 | kernel. Particolarmente utile quando si sposta del codice e lo si | ||
18 | allinea/ordina. Vedere it_clangformatreformat_. | ||
19 | |||
20 | - Identificare errori di stile, refusi e possibili miglioramenti nei | ||
21 | file che mantieni, le modifiche che revisioni, le differenze, | ||
22 | eccetera. Vedere it_clangformatreview_. | ||
23 | |||
24 | - Ti aiuta a seguire lo stile del codice, particolarmente utile per i | ||
25 | nuovi arrivati o per coloro che lavorano allo stesso tempo su diversi | ||
26 | progetti con stili di codifica differenti. | ||
27 | |||
28 | Il suo file di configurazione è ``.clang-format`` e si trova nella cartella | ||
29 | principale dei sorgenti del kernel. Le regole scritte in quel file tentano | ||
30 | di approssimare le lo stile di codifica del kernel. Si tenta anche di seguire | ||
31 | il più possibile | ||
32 | :ref:`Documentation/translations/it_IT/process/coding-style.rst <it_codingstyle>`. | ||
33 | Dato che non tutto il kernel segue lo stesso stile, potreste voler aggiustare | ||
34 | le regole di base per un particolare sottosistema o cartella. Per farlo, | ||
35 | potete sovrascriverle scrivendole in un altro file ``.clang-format`` in | ||
36 | una sottocartella. | ||
37 | |||
38 | Questo strumento è già stato incluso da molto tempo nelle distribuzioni | ||
39 | Linux più popolari. Cercate ``clang-format`` nel vostro repositorio. | ||
40 | Altrimenti, potete scaricare una versione pre-generata dei binari di LLVM/clang | ||
41 | oppure generarlo dai codici sorgenti: | ||
42 | |||
43 | http://releases.llvm.org/download.html | ||
44 | |||
45 | Troverete più informazioni ai seguenti indirizzi: | ||
46 | |||
47 | https://clang.llvm.org/docs/ClangFormat.html | ||
48 | |||
49 | https://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
50 | |||
51 | |||
52 | .. _it_clangformatreview: | ||
53 | |||
54 | Revisionare lo stile di codifica per file e modifiche | ||
55 | ----------------------------------------------------- | ||
56 | |||
57 | Eseguendo questo programma, potrete revisionare un intero sottosistema, | ||
58 | cartella o singoli file alla ricerca di errori di stile, refusi o | ||
59 | miglioramenti. | ||
60 | |||
61 | Per farlo, potete eseguire qualcosa del genere:: | ||
62 | |||
63 | # Make sure your working directory is clean! | ||
64 | clang-format -i kernel/*.[ch] | ||
65 | |||
66 | E poi date un'occhiata a *git diff*. | ||
67 | |||
68 | Osservare le righe di questo diff è utile a migliorare/aggiustare | ||
69 | le opzioni di stile nel file di configurazione; così come per verificare | ||
70 | le nuove funzionalità/versioni di ``clang-format``. | ||
71 | |||
72 | ``clang-format`` è in grado di leggere diversi diff unificati, quindi | ||
73 | potrete revisionare facilmente delle modifiche e *git diff*. | ||
74 | La documentazione si trova al seguente indirizzo: | ||
75 | |||
76 | https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting | ||
77 | |||
78 | Per evitare che ``clang-format`` formatti alcune parti di un file, potete | ||
79 | scrivere nel codice:: | ||
80 | |||
81 | int formatted_code; | ||
82 | // clang-format off | ||
83 | void unformatted_code ; | ||
84 | // clang-format on | ||
85 | void formatted_code_again; | ||
86 | |||
87 | Nonostante si attraente l'idea di utilizzarlo per mantenere un file | ||
88 | sempre in sintonia con ``clang-format``, specialmente per file nuovi o | ||
89 | se siete un manutentore, ricordatevi che altre persone potrebbero usare | ||
90 | una versione diversa di ``clang-format`` oppure non utilizzarlo del tutto. | ||
91 | Quindi, dovreste trattenervi dall'usare questi marcatori nel codice del | ||
92 | kernel; almeno finché non vediamo che ``clang-format`` è diventato largamente | ||
93 | utilizzato. | ||
94 | |||
95 | |||
96 | .. _it_clangformatreformat: | ||
97 | |||
98 | Riformattare blocchi di codice | ||
99 | ------------------------------ | ||
100 | |||
101 | Utilizzando dei plugin per il vostro editor, potete riformattare una | ||
102 | blocco (selezione) di codice con una singola combinazione di tasti. | ||
103 | Questo è particolarmente utile: quando si riorganizza il codice, per codice | ||
104 | complesso, macro multi-riga (e allineare le loro "barre"), eccetera. | ||
105 | |||
106 | Ricordatevi che potete sempre aggiustare le modifiche in quei casi dove | ||
107 | questo strumento non ha fatto un buon lavoro. Ma come prima approssimazione, | ||
108 | può essere davvero molto utile. | ||
109 | |||
110 | Questo programma si integra con molti dei più popolari editor. Alcuni di | ||
111 | essi come vim, emacs, BBEdit, Visaul Studio, lo supportano direttamente. | ||
112 | Al seguente indirizzo troverete le istruzioni: | ||
113 | |||
114 | https://clang.llvm.org/docs/ClangFormat.html | ||
115 | |||
116 | Per Atom, Eclipse, Sublime Text, Visual Studio Code, XCode e altri editor | ||
117 | e IDEs dovreste essere in grado di trovare dei plugin pronti all'uso. | ||
118 | |||
119 | Per questo caso d'uso, considerate l'uso di un secondo ``.clang-format`` | ||
120 | che potete personalizzare con le vostre opzioni. | ||
121 | Consultare it_clangformatextra_. | ||
122 | |||
123 | |||
124 | .. _it_clangformatmissing: | ||
125 | |||
126 | Cose non supportate | ||
127 | ------------------- | ||
128 | |||
129 | ``clang-format`` non ha il supporto per alcune cose che sono comuni nel | ||
130 | codice del kernel. Sono facili da ricordare; quindi, se lo usate | ||
131 | regolarmente, imparerete rapidamente a evitare/ignorare certi problemi. | ||
132 | |||
133 | In particolare, quelli più comuni che noterete sono: | ||
134 | |||
135 | - Allineamento di ``#define`` su una singola riga, per esempio:: | ||
136 | |||
137 | #define TRACING_MAP_BITS_DEFAULT 11 | ||
138 | #define TRACING_MAP_BITS_MAX 17 | ||
139 | #define TRACING_MAP_BITS_MIN 7 | ||
140 | |||
141 | contro:: | ||
142 | |||
143 | #define TRACING_MAP_BITS_DEFAULT 11 | ||
144 | #define TRACING_MAP_BITS_MAX 17 | ||
145 | #define TRACING_MAP_BITS_MIN 7 | ||
146 | |||
147 | - Allineamento dei valori iniziali, per esempio:: | ||
148 | |||
149 | static const struct file_operations uprobe_events_ops = { | ||
150 | .owner = THIS_MODULE, | ||
151 | .open = probes_open, | ||
152 | .read = seq_read, | ||
153 | .llseek = seq_lseek, | ||
154 | .release = seq_release, | ||
155 | .write = probes_write, | ||
156 | }; | ||
157 | |||
158 | contro:: | ||
159 | |||
160 | static const struct file_operations uprobe_events_ops = { | ||
161 | .owner = THIS_MODULE, | ||
162 | .open = probes_open, | ||
163 | .read = seq_read, | ||
164 | .llseek = seq_lseek, | ||
165 | .release = seq_release, | ||
166 | .write = probes_write, | ||
167 | }; | ||
168 | |||
169 | |||
170 | .. _it_clangformatextra: | ||
171 | |||
172 | Funzionalità e opzioni aggiuntive | ||
173 | --------------------------------- | ||
174 | |||
175 | Al fine di minimizzare le differenze fra il codice attuale e l'output | ||
176 | del programma, alcune opzioni di stile e funzionalità non sono abilitate | ||
177 | nella configurazione base. In altre parole, lo scopo è di rendere le | ||
178 | differenze le più piccole possibili, permettendo la semplificazione | ||
179 | della revisione di file, differenze e modifiche. | ||
180 | |||
181 | In altri casi (per esempio un particolare sottosistema/cartella/file), lo | ||
182 | stile del kernel potrebbe essere diverso e abilitare alcune di queste | ||
183 | opzioni potrebbe dare risultati migliori. | ||
184 | |||
185 | Per esempio: | ||
186 | |||
187 | - Allineare assegnamenti (``AlignConsecutiveAssignments``). | ||
188 | |||
189 | - Allineare dichiarazioni (``AlignConsecutiveDeclarations``). | ||
190 | |||
191 | - Riorganizzare il testo nei commenti (``ReflowComments``). | ||
192 | |||
193 | - Ordinare gli ``#include`` (``SortIncludes``). | ||
194 | |||
195 | Piuttosto che per interi file, solitamente sono utili per la riformattazione | ||
196 | di singoli blocchi. In alternativa, potete creare un altro file | ||
197 | ``.clang-format`` da utilizzare con il vostro editor/IDE. | ||
diff --git a/Documentation/translations/it_IT/process/code-of-conduct.rst b/Documentation/translations/it_IT/process/code-of-conduct.rst new file mode 100644 index 000000000000..7dbd7f55f37c --- /dev/null +++ b/Documentation/translations/it_IT/process/code-of-conduct.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/code-of-conduct.rst <code_of_conduct>` | ||
4 | |||
5 | .. _it_code_of_conduct: | ||
6 | |||
7 | Accordo dei contributori sul codice di condotta | ||
8 | +++++++++++++++++++++++++++++++++++++++++++++++ | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/coding-style.rst b/Documentation/translations/it_IT/process/coding-style.rst new file mode 100644 index 000000000000..b707bdbe178c --- /dev/null +++ b/Documentation/translations/it_IT/process/coding-style.rst | |||
@@ -0,0 +1,1094 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/coding-style.rst <codingstyle>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_codingstyle: | ||
7 | |||
8 | Stile del codice per il kernel Linux | ||
9 | ==================================== | ||
10 | |||
11 | Questo è un breve documento che descrive lo stile di codice preferito per | ||
12 | il kernel Linux. Lo stile di codifica è molto personale e non voglio | ||
13 | **forzare** nessuno ad accettare il mio, ma questo stile è quello che | ||
14 | dev'essere usato per qualsiasi cosa che io sia in grado di mantenere, e l'ho | ||
15 | preferito anche per molte altre cose. Per favore, almeno tenete in | ||
16 | considerazione le osservazioni espresse qui. | ||
17 | |||
18 | La prima cosa che suggerisco è quella di stamparsi una copia degli standard | ||
19 | di codifica GNU e di NON leggerla. Bruciatela, è un grande gesto simbolico. | ||
20 | |||
21 | Comunque, ecco i punti: | ||
22 | |||
23 | 1) Indentazione | ||
24 | --------------- | ||
25 | |||
26 | La tabulazione (tab) è di 8 caratteri e così anche le indentazioni. Ci sono | ||
27 | alcuni movimenti di eretici che vorrebbero l'indentazione a 4 (o perfino 2!) | ||
28 | caratteri di profondità, che è simile al tentativo di definire il valore del | ||
29 | pi-greco a 3. | ||
30 | |||
31 | Motivazione: l'idea dell'indentazione è di definire chiaramente dove un blocco | ||
32 | di controllo inizia e finisce. Specialmente quando siete rimasti a guardare lo | ||
33 | schermo per 20 ore a file, troverete molto più facile capire i livelli di | ||
34 | indentazione se questi sono larghi. | ||
35 | |||
36 | Ora, alcuni rivendicano che un'indentazione da 8 caratteri sposta il codice | ||
37 | troppo a destra e che quindi rende difficile la lettura su schermi a 80 | ||
38 | caratteri. La risposta a questa affermazione è che se vi servono più di 3 | ||
39 | livelli di indentazione, siete comunque fregati e dovreste correggere il vostro | ||
40 | programma. | ||
41 | |||
42 | In breve, l'indentazione ad 8 caratteri rende più facile la lettura, e in | ||
43 | aggiunta vi avvisa quando state annidando troppo le vostre funzioni. | ||
44 | Tenete ben a mente questo avviso. | ||
45 | |||
46 | Al fine di facilitare l'indentazione del costrutto switch, si preferisce | ||
47 | allineare sulla stessa colonna la parola chiave ``switch`` e i suoi | ||
48 | subordinati ``case``. In questo modo si evita una doppia indentazione per | ||
49 | i ``case``. Un esempio.: | ||
50 | |||
51 | .. code-block:: c | ||
52 | |||
53 | switch (suffix) { | ||
54 | case 'G': | ||
55 | case 'g': | ||
56 | mem <<= 30; | ||
57 | break; | ||
58 | case 'M': | ||
59 | case 'm': | ||
60 | mem <<= 20; | ||
61 | break; | ||
62 | case 'K': | ||
63 | case 'k': | ||
64 | mem <<= 10; | ||
65 | /* fall through */ | ||
66 | default: | ||
67 | break; | ||
68 | } | ||
69 | |||
70 | A meno che non vogliate nascondere qualcosa, non mettete più istruzioni sulla | ||
71 | stessa riga: | ||
72 | |||
73 | .. code-block:: c | ||
74 | |||
75 | if (condition) do_this; | ||
76 | do_something_everytime; | ||
77 | |||
78 | né mettete più assegnamenti sulla stessa riga. Lo stile del kernel | ||
79 | è ultrasemplice. Evitate espressioni intricate. | ||
80 | |||
81 | Al di fuori dei commenti, della documentazione ed escludendo i Kconfig, gli | ||
82 | spazi non vengono mai usati per l'indentazione, e l'esempio qui sopra è | ||
83 | volutamente errato. | ||
84 | |||
85 | Procuratevi un buon editor di testo e non lasciate spazi bianchi alla fine | ||
86 | delle righe. | ||
87 | |||
88 | |||
89 | 2) Spezzare righe lunghe e stringhe | ||
90 | ----------------------------------- | ||
91 | |||
92 | Lo stile del codice riguarda la leggibilità e la manutenibilità utilizzando | ||
93 | strumenti comuni. | ||
94 | |||
95 | Il limite delle righe è di 80 colonne e questo e un limite fortemente | ||
96 | desiderato. | ||
97 | |||
98 | Espressioni più lunghe di 80 colonne saranno spezzettate in pezzi più piccoli, | ||
99 | a meno che eccedere le 80 colonne non aiuti ad aumentare la leggibilità senza | ||
100 | nascondere informazioni. I pezzi derivati sono sostanzialmente più corti degli | ||
101 | originali e vengono posizionati più a destra. Lo stesso si applica, nei file | ||
102 | d'intestazione, alle funzioni con una lista di argomenti molto lunga. Tuttavia, | ||
103 | non spezzettate mai le stringhe visibili agli utenti come i messaggi di | ||
104 | printk, questo perché inibireste la possibilità d'utilizzare grep per cercarle. | ||
105 | |||
106 | 3) Posizionamento di parentesi graffe e spazi | ||
107 | --------------------------------------------- | ||
108 | |||
109 | Un altro problema che s'affronta sempre quando si parla di stile in C è | ||
110 | il posizionamento delle parentesi graffe. Al contrario della dimensione | ||
111 | dell'indentazione, non ci sono motivi tecnici sulla base dei quali scegliere | ||
112 | una strategia di posizionamento o un'altra; ma il modo qui preferito, | ||
113 | come mostratoci dai profeti Kernighan e Ritchie, è quello di | ||
114 | posizionare la parentesi graffa di apertura per ultima sulla riga, e quella | ||
115 | di chiusura per prima su una nuova riga, così: | ||
116 | |||
117 | .. code-block:: c | ||
118 | |||
119 | if (x is true) { | ||
120 | we do y | ||
121 | } | ||
122 | |||
123 | Questo è valido per tutte le espressioni che non siano funzioni (if, switch, | ||
124 | for, while, do). Per esempio: | ||
125 | |||
126 | .. code-block:: c | ||
127 | |||
128 | switch (action) { | ||
129 | case KOBJ_ADD: | ||
130 | return "add"; | ||
131 | case KOBJ_REMOVE: | ||
132 | return "remove"; | ||
133 | case KOBJ_CHANGE: | ||
134 | return "change"; | ||
135 | default: | ||
136 | return NULL; | ||
137 | } | ||
138 | |||
139 | Tuttavia, c'è il caso speciale, le funzioni: queste hanno la parentesi graffa | ||
140 | di apertura all'inizio della riga successiva, quindi: | ||
141 | |||
142 | .. code-block:: c | ||
143 | |||
144 | int function(int x) | ||
145 | { | ||
146 | body of function | ||
147 | } | ||
148 | |||
149 | Eretici da tutto il mondo affermano che questa incoerenza è ... | ||
150 | insomma ... incoerente, ma tutte le persone ragionevoli sanno che (a) | ||
151 | K&R hanno **ragione** e (b) K&R hanno ragione. A parte questo, le funzioni | ||
152 | sono comunque speciali (non potete annidarle in C). | ||
153 | |||
154 | Notate che la graffa di chiusura è da sola su una riga propria, ad | ||
155 | **eccezione** di quei casi dove è seguita dalla continuazione della stessa | ||
156 | espressione, in pratica ``while`` nell'espressione do-while, oppure ``else`` | ||
157 | nell'espressione if-else, come questo: | ||
158 | |||
159 | .. code-block:: c | ||
160 | |||
161 | do { | ||
162 | body of do-loop | ||
163 | } while (condition); | ||
164 | |||
165 | e | ||
166 | |||
167 | .. code-block:: c | ||
168 | |||
169 | if (x == y) { | ||
170 | .. | ||
171 | } else if (x > y) { | ||
172 | ... | ||
173 | } else { | ||
174 | .... | ||
175 | } | ||
176 | |||
177 | Motivazione: K&R. | ||
178 | |||
179 | Inoltre, notate che questo posizionamento delle graffe minimizza il numero | ||
180 | di righe vuote senza perdere di leggibilità. In questo modo, dato che le | ||
181 | righe sul vostro schermo non sono una risorsa illimitata (pensate ad uno | ||
182 | terminale con 25 righe), avrete delle righe vuote da riempire con dei | ||
183 | commenti. | ||
184 | |||
185 | Non usate inutilmente le graffe dove una singola espressione è sufficiente. | ||
186 | |||
187 | .. code-block:: c | ||
188 | |||
189 | if (condition) | ||
190 | action(); | ||
191 | |||
192 | e | ||
193 | |||
194 | .. code-block:: none | ||
195 | |||
196 | if (condition) | ||
197 | do_this(); | ||
198 | else | ||
199 | do_that(); | ||
200 | |||
201 | Questo non vale nel caso in cui solo un ramo dell'espressione if-else | ||
202 | contiene una sola espressione; in quest'ultimo caso usate le graffe per | ||
203 | entrambe i rami: | ||
204 | |||
205 | .. code-block:: c | ||
206 | |||
207 | if (condition) { | ||
208 | do_this(); | ||
209 | do_that(); | ||
210 | } else { | ||
211 | otherwise(); | ||
212 | } | ||
213 | |||
214 | Inoltre, usate le graffe se un ciclo contiene più di una semplice istruzione: | ||
215 | |||
216 | .. code-block:: c | ||
217 | |||
218 | while (condition) { | ||
219 | if (test) | ||
220 | do_something(); | ||
221 | } | ||
222 | |||
223 | 3.1) Spazi | ||
224 | ********** | ||
225 | |||
226 | Lo stile del kernel Linux per quanto riguarda gli spazi, dipende | ||
227 | (principalmente) dalle funzioni e dalle parole chiave. Usate una spazio dopo | ||
228 | (quasi tutte) le parole chiave. L'eccezioni più evidenti sono sizeof, typeof, | ||
229 | alignof, e __attribute__, il cui aspetto è molto simile a quello delle | ||
230 | funzioni (e in Linux, solitamente, sono usate con le parentesi, anche se il | ||
231 | linguaggio non lo richiede; come ``sizeof info`` dopo aver dichiarato | ||
232 | ``struct fileinfo info``). | ||
233 | |||
234 | Quindi utilizzate uno spazio dopo le seguenti parole chiave:: | ||
235 | |||
236 | if, switch, case, for, do, while | ||
237 | |||
238 | ma non con sizeof, typeof, alignof, o __attribute__. Ad esempio, | ||
239 | |||
240 | .. code-block:: c | ||
241 | |||
242 | |||
243 | s = sizeof(struct file); | ||
244 | |||
245 | Non aggiungete spazi attorno (dentro) ad un'espressione fra parentesi. Questo | ||
246 | esempio è **brutto**: | ||
247 | |||
248 | .. code-block:: c | ||
249 | |||
250 | |||
251 | s = sizeof( struct file ); | ||
252 | |||
253 | Quando dichiarate un puntatore ad una variabile o una funzione che ritorna un | ||
254 | puntatore, il posto suggerito per l'asterisco ``*`` è adiacente al nome della | ||
255 | variabile o della funzione, e non adiacente al nome del tipo. Esempi: | ||
256 | |||
257 | .. code-block:: c | ||
258 | |||
259 | |||
260 | char *linux_banner; | ||
261 | unsigned long long memparse(char *ptr, char **retptr); | ||
262 | char *match_strdup(substring_t *s); | ||
263 | |||
264 | Usate uno spazio attorno (da ogni parte) alla maggior parte degli operatori | ||
265 | binari o ternari, come i seguenti:: | ||
266 | |||
267 | = + - < > * / % | & ^ <= >= == != ? : | ||
268 | |||
269 | ma non mettete spazi dopo gli operatori unari:: | ||
270 | |||
271 | & * + - ~ ! sizeof typeof alignof __attribute__ defined | ||
272 | |||
273 | nessuno spazio dopo l'operatore unario suffisso di incremento o decremento:: | ||
274 | |||
275 | ++ -- | ||
276 | |||
277 | nessuno spazio dopo l'operatore unario prefisso di incremento o decremento:: | ||
278 | |||
279 | ++ -- | ||
280 | |||
281 | e nessuno spazio attorno agli operatori dei membri di una struttura ``.`` e | ||
282 | ``->``. | ||
283 | |||
284 | Non lasciate spazi bianchi alla fine delle righe. Alcuni editor con | ||
285 | l'indentazione ``furba`` inseriranno gli spazi bianchi all'inizio di una nuova | ||
286 | riga in modo appropriato, quindi potrete scrivere la riga di codice successiva | ||
287 | immediatamente. Tuttavia, alcuni di questi stessi editor non rimuovono | ||
288 | questi spazi bianchi quando non scrivete nulla sulla nuova riga, ad esempio | ||
289 | perché volete lasciare una riga vuota. Il risultato è che finirete per avere | ||
290 | delle righe che contengono spazi bianchi in coda. | ||
291 | |||
292 | Git vi avviserà delle modifiche che aggiungono questi spazi vuoti di fine riga, | ||
293 | e può opzionalmente rimuoverli per conto vostro; tuttavia, se state applicando | ||
294 | una serie di modifiche, questo potrebbe far fallire delle modifiche successive | ||
295 | perché il contesto delle righe verrà cambiato. | ||
296 | |||
297 | 4) Assegnare nomi | ||
298 | ----------------- | ||
299 | |||
300 | C è un linguaggio spartano, e così dovrebbero esserlo i vostri nomi. Al | ||
301 | contrario dei programmatori Modula-2 o Pascal, i programmatori C non usano | ||
302 | nomi graziosi come ThisVariableIsATemporaryCounter. Un programmatore C | ||
303 | chiamerebbe questa variabile ``tmp``, che è molto più facile da scrivere e | ||
304 | non è una delle più difficili da capire. | ||
305 | |||
306 | TUTTAVIA, nonostante i nomi con notazione mista siano da condannare, i nomi | ||
307 | descrittivi per variabili globali sono un dovere. Chiamare una funzione | ||
308 | globale ``pippo`` è un insulto. | ||
309 | |||
310 | Le variabili GLOBALI (da usare solo se vi servono **davvero**) devono avere | ||
311 | dei nomi descrittivi, così come le funzioni globali. Se avete una funzione | ||
312 | che conta gli utenti attivi, dovreste chiamarla ``count_active_users()`` o | ||
313 | qualcosa di simile, **non** dovreste chiamarla ``cntusr()``. | ||
314 | |||
315 | Codificare il tipo di funzione nel suo nome (quella cosa chiamata notazione | ||
316 | ungherese) fa male al cervello - il compilatore conosce comunque il tipo e | ||
317 | può verificarli, e inoltre confonde i programmatori. Non c'è da | ||
318 | sorprendersi che MicroSoft faccia programmi bacati. | ||
319 | |||
320 | Le variabili LOCALI dovrebbero avere nomi corti, e significativi. Se avete | ||
321 | un qualsiasi contatore di ciclo, probabilmente sarà chiamato ``i``. | ||
322 | Chiamarlo ``loop_counter`` non è produttivo, non ci sono possibilità che | ||
323 | ``i`` possa non essere capito. Analogamente, ``tmp`` può essere una qualsiasi | ||
324 | variabile che viene usata per salvare temporaneamente un valore. | ||
325 | |||
326 | Se avete paura di fare casino coi nomi delle vostre variabili locali, allora | ||
327 | avete un altro problema che è chiamato sindrome dello squilibrio dell'ormone | ||
328 | della crescita delle funzioni. Vedere il capitolo 6 (funzioni). | ||
329 | |||
330 | 5) Definizione di tipi (typedef) | ||
331 | -------------------------------- | ||
332 | |||
333 | Per favore non usate cose come ``vps_t``. | ||
334 | Usare il typedef per strutture e puntatori è uno **sbaglio**. Quando vedete: | ||
335 | |||
336 | .. code-block:: c | ||
337 | |||
338 | vps_t a; | ||
339 | |||
340 | nei sorgenti, cosa significa? | ||
341 | Se, invece, dicesse: | ||
342 | |||
343 | .. code-block:: c | ||
344 | |||
345 | struct virtual_container *a; | ||
346 | |||
347 | potreste dire cos'è effettivamente ``a``. | ||
348 | |||
349 | Molte persone pensano che la definizione dei tipi ``migliori la leggibilità``. | ||
350 | Non molto. Sono utili per: | ||
351 | |||
352 | (a) gli oggetti completamente opachi (dove typedef viene proprio usato allo | ||
353 | scopo di **nascondere** cosa sia davvero l'oggetto). | ||
354 | |||
355 | Esempio: ``pte_t`` eccetera sono oggetti opachi che potete usare solamente | ||
356 | con le loro funzioni accessorie. | ||
357 | |||
358 | .. note:: | ||
359 | Gli oggetti opachi e le ``funzioni accessorie`` non sono, di per se, | ||
360 | una bella cosa. Il motivo per cui abbiamo cose come pte_t eccetera è | ||
361 | che davvero non c'è alcuna informazione portabile. | ||
362 | |||
363 | (b) i tipi chiaramente interi, dove l'astrazione **aiuta** ad evitare | ||
364 | confusione sul fatto che siano ``int`` oppure ``long``. | ||
365 | |||
366 | u8/u16/u32 sono typedef perfettamente accettabili, anche se ricadono | ||
367 | nella categoria (d) piuttosto che in questa. | ||
368 | |||
369 | .. note:: | ||
370 | |||
371 | Ancora - dev'esserci una **ragione** per farlo. Se qualcosa è | ||
372 | ``unsigned long``, non c'è alcun bisogno di avere: | ||
373 | |||
374 | typedef unsigned long myfalgs_t; | ||
375 | |||
376 | ma se ci sono chiare circostanze in cui potrebbe essere ``unsigned int`` | ||
377 | e in altre configurazioni ``unsigned long``, allora certamente typedef | ||
378 | è una buona scelta. | ||
379 | |||
380 | (c) quando di rado create letteralmente dei **nuovi** tipi su cui effettuare | ||
381 | verifiche. | ||
382 | |||
383 | (d) circostanze eccezionali, in cui si definiscono nuovi tipi identici a | ||
384 | quelli definiti dallo standard C99. | ||
385 | |||
386 | Nonostante ci voglia poco tempo per abituare occhi e cervello all'uso dei | ||
387 | tipi standard come ``uint32_t``, alcune persone ne obiettano l'uso. | ||
388 | |||
389 | Perciò, i tipi specifici di Linux ``u8/u16/u32/u64`` e i loro equivalenti | ||
390 | con segno, identici ai tipi standard, sono permessi- tuttavia, non sono | ||
391 | obbligatori per il nuovo codice. | ||
392 | |||
393 | (e) i tipi sicuri nella spazio utente. | ||
394 | |||
395 | In alcune strutture dati visibili dallo spazio utente non possiamo | ||
396 | richiedere l'uso dei tipi C99 e nemmeno i vari ``u32`` descritti prima. | ||
397 | Perciò, utilizziamo __u32 e tipi simili in tutte le strutture dati | ||
398 | condivise con lo spazio utente. | ||
399 | |||
400 | Magari ci sono altri casi validi, ma la regola di base dovrebbe essere di | ||
401 | non usare MAI MAI un typedef a meno che non rientri in una delle regole | ||
402 | descritte qui. | ||
403 | |||
404 | In generale, un puntatore, o una struttura a cui si ha accesso diretto in | ||
405 | modo ragionevole, non dovrebbero **mai** essere definite con un typedef. | ||
406 | |||
407 | 6) Funzioni | ||
408 | ----------- | ||
409 | |||
410 | Le funzioni dovrebbero essere brevi e carine, e fare una cosa sola. Dovrebbero | ||
411 | occupare uno o due schermi di testo (come tutti sappiamo, la dimensione | ||
412 | di uno schermo secondo ISO/ANSI è di 80x24), e fare una cosa sola e bene. | ||
413 | |||
414 | La massima lunghezza di una funziona è inversamente proporzionale alla sua | ||
415 | complessità e al livello di indentazione di quella funzione. Quindi, se avete | ||
416 | una funzione che è concettualmente semplice ma che è implementata come un | ||
417 | lunga (ma semplice) sequenza di caso-istruzione, dove avete molte piccole cose | ||
418 | per molti casi differenti, allora va bene avere funzioni più lunghe. | ||
419 | |||
420 | Comunque, se avete una funzione complessa e sospettate che uno studente | ||
421 | non particolarmente dotato del primo anno delle scuole superiori potrebbe | ||
422 | non capire cosa faccia la funzione, allora dovreste attenervi strettamente ai | ||
423 | limiti. Usate funzioni di supporto con nomi descrittivi (potete chiedere al | ||
424 | compilatore di renderle inline se credete che sia necessario per le | ||
425 | prestazioni, e probabilmente farà un lavoro migliore di quanto avreste potuto | ||
426 | fare voi). | ||
427 | |||
428 | Un'altra misura delle funzioni sono il numero di variabili locali. Non | ||
429 | dovrebbero eccedere le 5-10, oppure state sbagliando qualcosa. Ripensate la | ||
430 | funzione, e dividetela in pezzettini. Generalmente, un cervello umano può | ||
431 | seguire facilmente circa 7 cose diverse, di più lo confonderebbe. Lo sai | ||
432 | d'essere brillante, ma magari vorresti riuscire a capire cos'avevi fatto due | ||
433 | settimane prima. | ||
434 | |||
435 | Nei file sorgenti, separate le funzioni con una riga vuota. Se la funzione è | ||
436 | esportata, la macro **EXPORT** per questa funzione deve seguire immediatamente | ||
437 | la riga della parentesi graffa di chiusura. Ad esempio: | ||
438 | |||
439 | .. code-block:: c | ||
440 | |||
441 | int system_is_up(void) | ||
442 | { | ||
443 | return system_state == SYSTEM_RUNNING; | ||
444 | } | ||
445 | EXPORT_SYMBOL(system_is_up); | ||
446 | |||
447 | Nei prototipi di funzione, includete i nomi dei parametri e i loro tipi. | ||
448 | Nonostante questo non sia richiesto dal linguaggio C, in Linux viene preferito | ||
449 | perché è un modo semplice per aggiungere informazioni importanti per il | ||
450 | lettore. | ||
451 | |||
452 | 7) Centralizzare il ritorno delle funzioni | ||
453 | ------------------------------------------ | ||
454 | |||
455 | Sebbene sia deprecata da molte persone, l'istruzione goto è impiegata di | ||
456 | frequente dai compilatori sotto forma di salto incondizionato. | ||
457 | |||
458 | L'istruzione goto diventa utile quando una funzione ha punti d'uscita multipli | ||
459 | e vanno eseguite alcune procedure di pulizia in comune. Se non è necessario | ||
460 | pulire alcunché, allora ritornate direttamente. | ||
461 | |||
462 | Assegnate un nome all'etichetta di modo che suggerisca cosa fa la goto o | ||
463 | perché esiste. Un esempio di un buon nome potrebbe essere ``out_free_buffer:`` | ||
464 | se la goto libera (free) un ``buffer``. Evitate l'uso di nomi GW-BASIC come | ||
465 | ``err1:`` ed ``err2:``, potreste doverli riordinare se aggiungete o rimuovete | ||
466 | punti d'uscita, e inoltre rende difficile verificarne la correttezza. | ||
467 | |||
468 | I motivo per usare le goto sono: | ||
469 | |||
470 | - i salti incondizionati sono più facili da capire e seguire | ||
471 | - l'annidamento si riduce | ||
472 | - si evita di dimenticare, per errore, di aggiornare un singolo punto d'uscita | ||
473 | - aiuta il compilatore ad ottimizzare il codice ridondante ;) | ||
474 | |||
475 | .. code-block:: c | ||
476 | |||
477 | int fun(int a) | ||
478 | { | ||
479 | int result = 0; | ||
480 | char *buffer; | ||
481 | |||
482 | buffer = kmalloc(SIZE, GFP_KERNEL); | ||
483 | if (!buffer) | ||
484 | return -ENOMEM; | ||
485 | |||
486 | if (condition1) { | ||
487 | while (loop1) { | ||
488 | ... | ||
489 | } | ||
490 | result = 1; | ||
491 | goto out_free_buffer; | ||
492 | } | ||
493 | ... | ||
494 | out_free_buffer: | ||
495 | kfree(buffer); | ||
496 | return result; | ||
497 | } | ||
498 | |||
499 | Un baco abbastanza comune di cui bisogna prendere nota è il ``one err bugs`` | ||
500 | che assomiglia a questo: | ||
501 | |||
502 | .. code-block:: c | ||
503 | |||
504 | err: | ||
505 | kfree(foo->bar); | ||
506 | kfree(foo); | ||
507 | return ret; | ||
508 | |||
509 | Il baco in questo codice è che in alcuni punti d'uscita la variabile ``foo`` è | ||
510 | NULL. Normalmente si corregge questo baco dividendo la gestione dell'errore in | ||
511 | due parti ``err_free_bar:`` e ``err_free_foo:``: | ||
512 | |||
513 | .. code-block:: c | ||
514 | |||
515 | err_free_bar: | ||
516 | kfree(foo->bar); | ||
517 | err_free_foo: | ||
518 | kfree(foo); | ||
519 | return ret; | ||
520 | |||
521 | Idealmente, dovreste simulare condizioni d'errore per verificare i vostri | ||
522 | percorsi d'uscita. | ||
523 | |||
524 | |||
525 | 8) Commenti | ||
526 | ----------- | ||
527 | |||
528 | I commenti sono una buona cosa, ma c'è anche il rischio di esagerare. MAI | ||
529 | spiegare COME funziona il vostro codice in un commento: è molto meglio | ||
530 | scrivere il codice di modo che il suo funzionamento sia ovvio, inoltre | ||
531 | spiegare codice scritto male è una perdita di tempo. | ||
532 | |||
533 | Solitamente, i commenti devono dire COSA fa il codice, e non COME lo fa. | ||
534 | Inoltre, cercate di evitare i commenti nel corpo della funzione: se la | ||
535 | funzione è così complessa che dovete commentarla a pezzi, allora dovreste | ||
536 | tornare al punto 6 per un momento. Potete mettere dei piccoli commenti per | ||
537 | annotare o avvisare il lettore circa un qualcosa di particolarmente arguto | ||
538 | (o brutto), ma cercate di non esagerare. Invece, mettete i commenti in | ||
539 | testa alla funzione spiegando alle persone cosa fa, e possibilmente anche | ||
540 | il PERCHÉ. | ||
541 | |||
542 | Per favore, quando commentate una funzione dell'API del kernel usate il | ||
543 | formato kernel-doc. Per maggiori dettagli, leggete i file in | ||
544 | :ref::ref:`Documentation/translations/it_IT/doc-guide/ <it_doc_guide>` e in | ||
545 | ``script/kernel-doc``. | ||
546 | |||
547 | Lo stile preferito per i commenti più lunghi (multi-riga) è: | ||
548 | |||
549 | .. code-block:: c | ||
550 | |||
551 | /* | ||
552 | * This is the preferred style for multi-line | ||
553 | * comments in the Linux kernel source code. | ||
554 | * Please use it consistently. | ||
555 | * | ||
556 | * Description: A column of asterisks on the left side, | ||
557 | * with beginning and ending almost-blank lines. | ||
558 | */ | ||
559 | |||
560 | Per i file in net/ e in drivers/net/ lo stile preferito per i commenti | ||
561 | più lunghi (multi-riga) è leggermente diverso. | ||
562 | |||
563 | .. code-block:: c | ||
564 | |||
565 | /* The preferred comment style for files in net/ and drivers/net | ||
566 | * looks like this. | ||
567 | * | ||
568 | * It is nearly the same as the generally preferred comment style, | ||
569 | * but there is no initial almost-blank line. | ||
570 | */ | ||
571 | |||
572 | È anche importante commentare i dati, sia per i tipi base che per tipi | ||
573 | derivati. A questo scopo, dichiarate un dato per riga (niente virgole | ||
574 | per una dichiarazione multipla). Questo vi lascerà spazio per un piccolo | ||
575 | commento per spiegarne l'uso. | ||
576 | |||
577 | |||
578 | 9) Avete fatto un pasticcio | ||
579 | --------------------------- | ||
580 | |||
581 | Va bene, li facciamo tutti. Probabilmente vi è stato detto dal vostro | ||
582 | aiutante Unix di fiducia che ``GNU emacs`` formatta automaticamente il | ||
583 | codice C per conto vostro, e avete notato che sì, in effetti lo fa, ma che | ||
584 | i modi predefiniti non sono proprio allettanti (infatti, sono peggio che | ||
585 | premere tasti a caso - un numero infinito di scimmie che scrivono in | ||
586 | GNU emacs non faranno mai un buon programma). | ||
587 | |||
588 | Quindi, potete sbarazzarvi di GNU emacs, o riconfigurarlo con valori più | ||
589 | sensati. Per fare quest'ultima cosa, potete appiccicare il codice che | ||
590 | segue nel vostro file .emacs: | ||
591 | |||
592 | .. code-block:: none | ||
593 | |||
594 | (defun c-lineup-arglist-tabs-only (ignored) | ||
595 | "Line up argument lists by tabs, not spaces" | ||
596 | (let* ((anchor (c-langelem-pos c-syntactic-element)) | ||
597 | (column (c-langelem-2nd-pos c-syntactic-element)) | ||
598 | (offset (- (1+ column) anchor)) | ||
599 | (steps (floor offset c-basic-offset))) | ||
600 | (* (max steps 1) | ||
601 | c-basic-offset))) | ||
602 | |||
603 | (add-hook 'c-mode-common-hook | ||
604 | (lambda () | ||
605 | ;; Add kernel style | ||
606 | (c-add-style | ||
607 | "linux-tabs-only" | ||
608 | '("linux" (c-offsets-alist | ||
609 | (arglist-cont-nonempty | ||
610 | c-lineup-gcc-asm-reg | ||
611 | c-lineup-arglist-tabs-only)))))) | ||
612 | |||
613 | (add-hook 'c-mode-hook | ||
614 | (lambda () | ||
615 | (let ((filename (buffer-file-name))) | ||
616 | ;; Enable kernel mode for the appropriate files | ||
617 | (when (and filename | ||
618 | (string-match (expand-file-name "~/src/linux-trees") | ||
619 | filename)) | ||
620 | (setq indent-tabs-mode t) | ||
621 | (setq show-trailing-whitespace t) | ||
622 | (c-set-style "linux-tabs-only"))))) | ||
623 | |||
624 | Questo farà funzionare meglio emacs con lo stile del kernel per i file che | ||
625 | si trovano nella cartella ``~/src/linux-trees``. | ||
626 | |||
627 | Ma anche se doveste fallire nell'ottenere una formattazione sensata in emacs | ||
628 | non tutto è perduto: usate ``indent``. | ||
629 | |||
630 | Ora, ancora, GNU indent ha la stessa configurazione decerebrata di GNU emacs, | ||
631 | ed è per questo che dovete passargli alcune opzioni da riga di comando. | ||
632 | Tuttavia, non è così terribile, perché perfino i creatori di GNU indent | ||
633 | riconoscono l'autorità di K&R (le persone del progetto GNU non sono cattive, | ||
634 | sono solo mal indirizzate sull'argomento), quindi date ad indent le opzioni | ||
635 | ``-kr -i8`` (che significa ``K&R, 8 caratteri di indentazione``), o utilizzate | ||
636 | ``scripts/Lindent`` che indenterà usando l'ultimo stile. | ||
637 | |||
638 | ``indent`` ha un sacco di opzioni, e specialmente quando si tratta di | ||
639 | riformattare i commenti dovreste dare un'occhiata alle pagine man. | ||
640 | Ma ricordatevi: ``indent`` non è un correttore per una cattiva programmazione. | ||
641 | |||
642 | Da notare che potete utilizzare anche ``clang-format`` per aiutarvi con queste | ||
643 | regole, per riformattare rapidamente ad automaticamente alcune parti del | ||
644 | vostro codice, e per revisionare interi file al fine di identificare errori | ||
645 | di stile, refusi e possibilmente anche delle migliorie. È anche utile per | ||
646 | ordinare gli ``#include``, per allineare variabili/macro, per ridistribuire | ||
647 | il testo e altre cose simili. | ||
648 | Per maggiori dettagli, consultate il file | ||
649 | :ref:`Documentation/translations/it_IT/process/clang-format.rst <it_clangformat>`. | ||
650 | |||
651 | |||
652 | 10) File di configurazione Kconfig | ||
653 | ---------------------------------- | ||
654 | |||
655 | Per tutti i file di configurazione Kconfig* che si possono trovare nei | ||
656 | sorgenti, l'indentazione è un po' differente. Le linee dopo un ``config`` | ||
657 | sono indentate con un tab, mentre il testo descrittivo è indentato di | ||
658 | ulteriori due spazi. Esempio:: | ||
659 | |||
660 | config AUDIT | ||
661 | bool "Auditing support" | ||
662 | depends on NET | ||
663 | help | ||
664 | Enable auditing infrastructure that can be used with another | ||
665 | kernel subsystem, such as SELinux (which requires this for | ||
666 | logging of avc messages output). Does not do system-call | ||
667 | auditing without CONFIG_AUDITSYSCALL. | ||
668 | |||
669 | Le funzionalità davvero pericolose (per esempio il supporto alla scrittura | ||
670 | per certi filesystem) dovrebbero essere dichiarate chiaramente come tali | ||
671 | nella stringa di titolo:: | ||
672 | |||
673 | config ADFS_FS_RW | ||
674 | bool "ADFS write support (DANGEROUS)" | ||
675 | depends on ADFS_FS | ||
676 | ... | ||
677 | |||
678 | Per la documentazione completa sui file di configurazione, consultate | ||
679 | il documento Documentation/translations/it_IT/kbuild/kconfig-language.txt | ||
680 | |||
681 | |||
682 | 11) Strutture dati | ||
683 | ------------------ | ||
684 | |||
685 | Le strutture dati che hanno una visibilità superiore al contesto del | ||
686 | singolo thread in cui vengono create e distrutte, dovrebbero sempre | ||
687 | avere un contatore di riferimenti. Nel kernel non esiste un | ||
688 | *garbage collector* (e fuori dal kernel i *garbage collector* sono lenti | ||
689 | e inefficienti), questo significa che **dovete** assolutamente avere un | ||
690 | contatore di riferimenti per ogni cosa che usate. | ||
691 | |||
692 | Avere un contatore di riferimenti significa che potete evitare la | ||
693 | sincronizzazione e permette a più utenti di accedere alla struttura dati | ||
694 | in parallelo - e non doversi preoccupare di una struttura dati che | ||
695 | improvvisamente sparisce dalla loro vista perché il loro processo dormiva | ||
696 | o stava facendo altro per un attimo. | ||
697 | |||
698 | Da notare che la sincronizzazione **non** si sostituisce al conteggio dei | ||
699 | riferimenti. La sincronizzazione ha lo scopo di mantenere le strutture | ||
700 | dati coerenti, mentre il conteggio dei riferimenti è una tecnica di gestione | ||
701 | della memoria. Solitamente servono entrambe le cose, e non vanno confuse fra | ||
702 | di loro. | ||
703 | |||
704 | Quando si hanno diverse classi di utenti, le strutture dati possono avere | ||
705 | due livelli di contatori di riferimenti. Il contatore di classe conta | ||
706 | il numero dei suoi utenti, e il contatore globale viene decrementato una | ||
707 | sola volta quando il contatore di classe va a zero. | ||
708 | |||
709 | Un esempio di questo tipo di conteggio dei riferimenti multi-livello può | ||
710 | essere trovato nella gestore della memoria (``struct mm_sturct``: mm_user e | ||
711 | mm_count), e nel codice dei filesystem (``struct super_block``: s_count e | ||
712 | s_active). | ||
713 | |||
714 | Ricordatevi: se un altro thread può trovare la vostra struttura dati, e non | ||
715 | avete un contatore di riferimenti per essa, quasi certamente avete un baco. | ||
716 | |||
717 | 12) Macro, enumerati e RTL | ||
718 | --------------------------- | ||
719 | |||
720 | I nomi delle macro che definiscono delle costanti e le etichette degli | ||
721 | enumerati sono scritte in maiuscolo. | ||
722 | |||
723 | .. code-block:: c | ||
724 | |||
725 | #define CONSTANT 0x12345 | ||
726 | |||
727 | Gli enumerati sono da preferire quando si definiscono molte costanti correlate. | ||
728 | |||
729 | I nomi delle macro in MAIUSCOLO sono preferibili ma le macro che assomigliano | ||
730 | a delle funzioni possono essere scritte in minuscolo. | ||
731 | |||
732 | Generalmente, le funzioni inline sono preferibili rispetto alle macro che | ||
733 | sembrano funzioni. | ||
734 | |||
735 | Le macro che contengono più istruzioni dovrebbero essere sempre chiuse in un | ||
736 | blocco do - while: | ||
737 | |||
738 | .. code-block:: c | ||
739 | |||
740 | #define macrofun(a, b, c) \ | ||
741 | do { \ | ||
742 | if (a == 5) \ | ||
743 | do_this(b, c); \ | ||
744 | } while (0) | ||
745 | |||
746 | Cose da evitare quando si usano le macro: | ||
747 | |||
748 | 1) le macro che hanno effetti sul flusso del codice: | ||
749 | |||
750 | .. code-block:: c | ||
751 | |||
752 | #define FOO(x) \ | ||
753 | do { \ | ||
754 | if (blah(x) < 0) \ | ||
755 | return -EBUGGERED; \ | ||
756 | } while (0) | ||
757 | |||
758 | sono **proprio** una pessima idea. Sembra una chiamata a funzione ma termina | ||
759 | la funzione chiamante; non cercate di rompere il decodificatore interno di | ||
760 | chi legge il codice. | ||
761 | |||
762 | 2) le macro che dipendono dall'uso di una variabile locale con un nome magico: | ||
763 | |||
764 | .. code-block:: c | ||
765 | |||
766 | #define FOO(val) bar(index, val) | ||
767 | |||
768 | potrebbe sembrare una bella cosa, ma è dannatamente confusionario quando uno | ||
769 | legge il codice e potrebbe romperlo con una cambiamento che sembra innocente. | ||
770 | |||
771 | 3) le macro con argomenti che sono utilizzati come l-values; questo potrebbe | ||
772 | ritorcervisi contro se qualcuno, per esempio, trasforma FOO in una funzione | ||
773 | inline. | ||
774 | |||
775 | 4) dimenticatevi delle precedenze: le macro che definiscono espressioni devono | ||
776 | essere racchiuse fra parentesi. State attenti a problemi simili con le macro | ||
777 | parametrizzate. | ||
778 | |||
779 | .. code-block:: c | ||
780 | |||
781 | #define CONSTANT 0x4000 | ||
782 | #define CONSTEXP (CONSTANT | 3) | ||
783 | |||
784 | 5) collisione nello spazio dei nomi quando si definisce una variabile locale in | ||
785 | una macro che sembra una funzione: | ||
786 | |||
787 | .. code-block:: c | ||
788 | |||
789 | #define FOO(x) \ | ||
790 | ({ \ | ||
791 | typeof(x) ret; \ | ||
792 | ret = calc_ret(x); \ | ||
793 | (ret); \ | ||
794 | }) | ||
795 | |||
796 | ret è un nome comune per una variabile locale - __foo_ret difficilmente | ||
797 | andrà in conflitto con una variabile già esistente. | ||
798 | |||
799 | Il manuale di cpp si occupa esaustivamente delle macro. Il manuale di sviluppo | ||
800 | di gcc copre anche l'RTL che viene usato frequentemente nel kernel per il | ||
801 | linguaggio assembler. | ||
802 | |||
803 | 13) Visualizzare i messaggi del kernel | ||
804 | -------------------------------------- | ||
805 | |||
806 | Agli sviluppatori del kernel piace essere visti come dotti. Tenete un occhio | ||
807 | di riguardo per l'ortografia e farete una belle figura. In inglese, evitate | ||
808 | l'uso di parole mozzate come ``dont``: usate ``do not`` oppure ``don't``. | ||
809 | Scrivete messaggi concisi, chiari, e inequivocabili. | ||
810 | |||
811 | I messaggi del kernel non devono terminare con un punto fermo. | ||
812 | |||
813 | Scrivere i numeri fra parentesi (%d) non migliora alcunché e per questo | ||
814 | dovrebbero essere evitati. | ||
815 | |||
816 | Ci sono alcune macro per la diagnostica in <linux/device.h> che dovreste | ||
817 | usare per assicurarvi che i messaggi vengano associati correttamente ai | ||
818 | dispositivi e ai driver, e che siano etichettati correttamente: dev_err(), | ||
819 | dev_warn(), dev_info(), e così via. Per messaggi che non sono associati ad | ||
820 | alcun dispositivo, <linux/printk.h> definisce pr_info(), pr_warn(), pr_err(), | ||
821 | eccetera. | ||
822 | |||
823 | Tirar fuori un buon messaggio di debug può essere una vera sfida; e quando | ||
824 | l'avete può essere d'enorme aiuto per risolvere problemi da remoto. | ||
825 | Tuttavia, i messaggi di debug sono gestiti differentemente rispetto agli | ||
826 | altri. Le funzioni pr_XXX() stampano incondizionatamente ma pr_debug() no; | ||
827 | essa non viene compilata nella configurazione predefinita, a meno che | ||
828 | DEBUG o CONFIG_DYNAMIC_DEBUG non vengono impostati. Questo vale anche per | ||
829 | dev_dbg() e in aggiunta VERBOSE_DEBUG per aggiungere i messaggi dev_vdbg(). | ||
830 | |||
831 | Molti sottosistemi hanno delle opzioni di debug in Kconfig che aggiungono | ||
832 | -DDEBUG nei corrispettivi Makefile, e in altri casi aggiungono #define DEBUG | ||
833 | in specifici file. Infine, quando un messaggio di debug dev'essere stampato | ||
834 | incondizionatamente, per esempio perché siete già in una sezione di debug | ||
835 | racchiusa in #ifdef, potete usare printk(KERN_DEBUG ...). | ||
836 | |||
837 | 14) Assegnare memoria | ||
838 | --------------------- | ||
839 | |||
840 | Il kernel fornisce i seguenti assegnatori ad uso generico: | ||
841 | kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), e vzalloc(). | ||
842 | Per maggiori informazioni, consultate la documentazione dell'API. | ||
843 | |||
844 | Il modo preferito per passare la dimensione di una struttura è il seguente: | ||
845 | |||
846 | .. code-block:: c | ||
847 | |||
848 | p = kmalloc(sizeof(*p), ...); | ||
849 | |||
850 | La forma alternativa, dove il nome della struttura viene scritto interamente, | ||
851 | peggiora la leggibilità e introduce possibili bachi quando il tipo di | ||
852 | puntatore cambia tipo ma il corrispondente sizeof non viene aggiornato. | ||
853 | |||
854 | Il valore di ritorno è un puntatore void, effettuare un cast su di esso è | ||
855 | ridondante. La conversione fra un puntatore void e un qualsiasi altro tipo | ||
856 | di puntatore è garantito dal linguaggio di programmazione C. | ||
857 | |||
858 | Il modo preferito per assegnare un vettore è il seguente: | ||
859 | |||
860 | .. code-block:: c | ||
861 | |||
862 | p = kmalloc_array(n, sizeof(...), ...); | ||
863 | |||
864 | Il modo preferito per assegnare un vettore a zero è il seguente: | ||
865 | |||
866 | .. code-block:: c | ||
867 | |||
868 | p = kcalloc(n, sizeof(...), ...); | ||
869 | |||
870 | Entrambe verificano la condizione di overflow per la dimensione | ||
871 | d'assegnamento n * sizeof(...), se accade ritorneranno NULL. | ||
872 | |||
873 | 15) Il morbo inline | ||
874 | ------------------- | ||
875 | |||
876 | Sembra che ci sia la percezione errata che gcc abbia una qualche magica | ||
877 | opzione "rendimi più veloce" chiamata ``inline``. In alcuni casi l'uso di | ||
878 | inline è appropriato (per esempio in sostituzione delle macro, vedi | ||
879 | capitolo 12), ma molto spesso non lo è. L'uso abbondante della parola chiave | ||
880 | inline porta ad avere un kernel più grande, che si traduce in un sistema nel | ||
881 | suo complesso più lento per via di una cache per le istruzioni della CPU più | ||
882 | grande e poi semplicemente perché ci sarà meno spazio disponibile per una | ||
883 | pagina di cache. Pensateci un attimo; una fallimento nella cache causa una | ||
884 | ricerca su disco che può tranquillamente richiedere 5 millisecondi. Ci sono | ||
885 | TANTI cicli di CPU che potrebbero essere usati in questi 5 millisecondi. | ||
886 | |||
887 | Spesso le persone dicono che aggiungere inline a delle funzioni dichiarate | ||
888 | static e utilizzare una sola volta è sempre una scelta vincente perché non | ||
889 | ci sono altri compromessi. Questo è tecnicamente vero ma gcc è in grado di | ||
890 | trasformare automaticamente queste funzioni in inline; i problemi di | ||
891 | manutenzione del codice per rimuovere gli inline quando compare un secondo | ||
892 | utente surclassano il potenziale vantaggio nel suggerire a gcc di fare una | ||
893 | cosa che avrebbe fatto comunque. | ||
894 | |||
895 | 16) Nomi e valori di ritorno delle funzioni | ||
896 | ------------------------------------------- | ||
897 | |||
898 | Le funzioni possono ritornare diversi tipi di valori, e uno dei più comuni | ||
899 | è quel valore che indica se una funzione ha completato con successo o meno. | ||
900 | Questo valore può essere rappresentato come un codice di errore intero | ||
901 | (-Exxx = fallimento, 0 = successo) oppure un booleano di successo | ||
902 | (0 = fallimento, non-zero = successo). | ||
903 | |||
904 | Mischiare questi due tipi di rappresentazioni è un terreno fertile per | ||
905 | i bachi più insidiosi. Se il linguaggio C includesse una forte distinzione | ||
906 | fra gli interi e i booleani, allora il compilatore potrebbe trovare questi | ||
907 | errori per conto nostro ... ma questo non c'è. Per evitare di imbattersi | ||
908 | in questo tipo di baco, seguite sempre la seguente convenzione:: | ||
909 | |||
910 | Se il nome di una funzione è un'azione o un comando imperativo, | ||
911 | essa dovrebbe ritornare un codice di errore intero. Se il nome | ||
912 | è un predicato, la funzione dovrebbe ritornare un booleano di | ||
913 | "successo" | ||
914 | |||
915 | Per esempio, ``add work`` è un comando, e la funzione add_work() ritorna 0 | ||
916 | in caso di successo o -EBUSY in caso di fallimento. Allo stesso modo, | ||
917 | ``PCI device present`` è un predicato, e la funzione pci_dev_present() ritorna | ||
918 | 1 se trova il dispositivo corrispondente con successo, altrimenti 0. | ||
919 | |||
920 | Tutte le funzioni esportate (EXPORT) devono rispettare questa convenzione, e | ||
921 | così dovrebbero anche tutte le funzioni pubbliche. Le funzioni private | ||
922 | (static) possono non seguire questa convenzione, ma è comunque raccomandato | ||
923 | che lo facciano. | ||
924 | |||
925 | Le funzioni il cui valore di ritorno è il risultato di una computazione, | ||
926 | piuttosto che l'indicazione sul successo di tale computazione, non sono | ||
927 | soggette a questa regola. Solitamente si indicano gli errori ritornando un | ||
928 | qualche valore fuori dai limiti. Un tipico esempio è quello delle funzioni | ||
929 | che ritornano un puntatore; queste utilizzano NULL o ERR_PTR come meccanismo | ||
930 | di notifica degli errori. | ||
931 | |||
932 | 17) Non reinventate le macro del kernel | ||
933 | --------------------------------------- | ||
934 | |||
935 | Il file di intestazione include/linux/kernel.h contiene un certo numero | ||
936 | di macro che dovreste usare piuttosto che implementarne una qualche variante. | ||
937 | Per esempio, se dovete calcolare la lunghezza di un vettore, sfruttate la | ||
938 | macro: | ||
939 | |||
940 | .. code-block:: c | ||
941 | |||
942 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
943 | |||
944 | Analogamente, se dovete calcolare la dimensione di un qualche campo di una | ||
945 | struttura, usate | ||
946 | |||
947 | .. code-block:: c | ||
948 | |||
949 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) | ||
950 | |||
951 | Ci sono anche le macro min() e max() che, se vi serve, effettuano un controllo | ||
952 | rigido sui tipi. Sentitevi liberi di leggere attentamente questo file | ||
953 | d'intestazione per scoprire cos'altro è stato definito che non dovreste | ||
954 | reinventare nel vostro codice. | ||
955 | |||
956 | 18) Linee di configurazione degli editor e altre schifezze | ||
957 | ----------------------------------------------------------- | ||
958 | |||
959 | Alcuni editor possono interpretare dei parametri di configurazione integrati | ||
960 | nei file sorgenti e indicati con dai marcatori speciali. Per esempio, emacs | ||
961 | interpreta le linee marcate nel seguente modo: | ||
962 | |||
963 | .. code-block:: c | ||
964 | |||
965 | -*- mode: c -*- | ||
966 | |||
967 | O come queste: | ||
968 | |||
969 | .. code-block:: c | ||
970 | |||
971 | /* | ||
972 | Local Variables: | ||
973 | compile-command: "gcc -DMAGIC_DEBUG_FLAG foo.c" | ||
974 | End: | ||
975 | */ | ||
976 | |||
977 | Vim interpreta i marcatori come questi: | ||
978 | |||
979 | .. code-block:: c | ||
980 | |||
981 | /* vim:set sw=8 noet */ | ||
982 | |||
983 | Non includete nessuna di queste cose nei file sorgenti. Le persone hanno le | ||
984 | proprie configurazioni personali per l'editor, e i vostri sorgenti non | ||
985 | dovrebbero sovrascrivergliele. Questo vale anche per i marcatori | ||
986 | d'indentazione e di modalità d'uso. Le persone potrebbero aver configurato una | ||
987 | modalità su misura, oppure potrebbero avere qualche altra magia per far | ||
988 | funzionare bene l'indentazione. | ||
989 | |||
990 | 19) Inline assembly | ||
991 | --------------------- | ||
992 | |||
993 | Nel codice specifico per un'architettura, potreste aver bisogno di codice | ||
994 | *inline assembly* per interfacciarvi col processore o con una funzionalità | ||
995 | specifica della piattaforma. Non esitate a farlo quando è necessario. | ||
996 | Comunque, non usatele gratuitamente quando il C può fare la stessa cosa. | ||
997 | Potete e dovreste punzecchiare l'hardware in C quando è possibile. | ||
998 | |||
999 | Considerate la scrittura di una semplice funzione che racchiude pezzi comuni | ||
1000 | di codice assembler piuttosto che continuare a riscrivere delle piccole | ||
1001 | varianti. Ricordatevi che l' *inline assembly* può utilizzare i parametri C. | ||
1002 | |||
1003 | Il codice assembler più corposo e non banale dovrebbe andare nei file .S, | ||
1004 | coi rispettivi prototipi C definiti nei file d'intestazione. I prototipi C | ||
1005 | per le funzioni assembler dovrebbero usare ``asmlinkage``. | ||
1006 | |||
1007 | Potreste aver bisogno di marcare il vostro codice asm come volatile al fine | ||
1008 | d'evitare che GCC lo rimuova quando pensa che non ci siano effetti collaterali. | ||
1009 | Non c'è sempre bisogno di farlo, e farlo quando non serve limita le | ||
1010 | ottimizzazioni. | ||
1011 | |||
1012 | Quando scrivete una singola espressione *inline assembly* contenente più | ||
1013 | istruzioni, mettete ognuna di queste istruzioni in una stringa e riga diversa; | ||
1014 | ad eccezione dell'ultima stringa/istruzione, ognuna deve terminare con ``\n\t`` | ||
1015 | al fine di allineare correttamente l'assembler che verrà generato: | ||
1016 | |||
1017 | .. code-block:: c | ||
1018 | |||
1019 | asm ("magic %reg1, #42\n\t" | ||
1020 | "more_magic %reg2, %reg3" | ||
1021 | : /* outputs */ : /* inputs */ : /* clobbers */); | ||
1022 | |||
1023 | 20) Compilazione sotto condizione | ||
1024 | --------------------------------- | ||
1025 | |||
1026 | Ovunque sia possibile, non usate le direttive condizionali del preprocessore | ||
1027 | (#if, #ifdef) nei file .c; farlo rende il codice difficile da leggere e da | ||
1028 | seguire. Invece, usate queste direttive nei file d'intestazione per definire | ||
1029 | le funzioni usate nei file .c, fornendo i relativi stub nel caso #else, | ||
1030 | e quindi chiamate queste funzioni senza condizioni di preprocessore. Il | ||
1031 | compilatore non produrrà alcun codice per le funzioni stub, produrrà gli | ||
1032 | stessi risultati, e la logica rimarrà semplice da seguire. | ||
1033 | |||
1034 | È preferibile non compilare intere funzioni piuttosto che porzioni d'esse o | ||
1035 | porzioni d'espressioni. Piuttosto che mettere una ifdef in un'espressione, | ||
1036 | fattorizzate parte dell'espressione, o interamente, in funzioni e applicate | ||
1037 | la direttiva condizionale su di esse. | ||
1038 | |||
1039 | Se avete una variabile o funzione che potrebbe non essere usata in alcune | ||
1040 | configurazioni, e quindi il compilatore potrebbe avvisarvi circa la definizione | ||
1041 | inutilizzata, marcate questa definizione come __maybe_used piuttosto che | ||
1042 | racchiuderla in una direttiva condizionale del preprocessore. (Comunque, | ||
1043 | se una variabile o funzione è *sempre* inutilizzata, rimuovetela). | ||
1044 | |||
1045 | Nel codice, dov'è possibile, usate la macro IS_ENABLED per convertire i | ||
1046 | simboli Kconfig in espressioni booleane C, e quindi usatela nelle classiche | ||
1047 | condizioni C: | ||
1048 | |||
1049 | .. code-block:: c | ||
1050 | |||
1051 | if (IS_ENABLED(CONFIG_SOMETHING)) { | ||
1052 | ... | ||
1053 | } | ||
1054 | |||
1055 | Il compilatore valuterà la condizione come costante (constant-fold), e quindi | ||
1056 | includerà o escluderà il blocco di codice come se fosse in un #ifdef, quindi | ||
1057 | non ne aumenterà il tempo di esecuzione. Tuttavia, questo permette al | ||
1058 | compilatore C di vedere il codice nel blocco condizionale e verificarne la | ||
1059 | correttezza (sintassi, tipi, riferimenti ai simboli, eccetera). Quindi | ||
1060 | dovete comunque utilizzare #ifdef se il codice nel blocco condizionale esiste | ||
1061 | solo quando la condizione è soddisfatta. | ||
1062 | |||
1063 | Alla fine di un blocco corposo di #if o #ifdef (più di alcune linee), | ||
1064 | mettete un commento sulla stessa riga di #endif, annotando la condizione | ||
1065 | che termina. Per esempio: | ||
1066 | |||
1067 | .. code-block:: c | ||
1068 | |||
1069 | #ifdef CONFIG_SOMETHING | ||
1070 | ... | ||
1071 | #endif /* CONFIG_SOMETHING */ | ||
1072 | |||
1073 | Appendice I) riferimenti | ||
1074 | ------------------------ | ||
1075 | |||
1076 | The C Programming Language, Second Edition | ||
1077 | by Brian W. Kernighan and Dennis M. Ritchie. | ||
1078 | Prentice Hall, Inc., 1988. | ||
1079 | ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback). | ||
1080 | |||
1081 | The Practice of Programming | ||
1082 | by Brian W. Kernighan and Rob Pike. | ||
1083 | Addison-Wesley, Inc., 1999. | ||
1084 | ISBN 0-201-61586-X. | ||
1085 | |||
1086 | Manuali GNU - nei casi in cui sono compatibili con K&R e questo documento - | ||
1087 | per indent, cpp, gcc e i suoi dettagli interni, tutto disponibile qui | ||
1088 | http://www.gnu.org/manual/ | ||
1089 | |||
1090 | WG14 è il gruppo internazionale di standardizzazione per il linguaggio C, | ||
1091 | URL: http://www.open-std.org/JTC1/SC22/WG14/ | ||
1092 | |||
1093 | Kernel process/coding-style.rst, by greg@kroah.com at OLS 2002: | ||
1094 | http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ | ||
diff --git a/Documentation/translations/it_IT/process/development-process.rst b/Documentation/translations/it_IT/process/development-process.rst new file mode 100644 index 000000000000..f1a6eca30824 --- /dev/null +++ b/Documentation/translations/it_IT/process/development-process.rst | |||
@@ -0,0 +1,33 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/development-process.rst <development_process_main>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_development_process_main: | ||
7 | |||
8 | Una guida al processo di sviluppo del Kernel | ||
9 | ============================================ | ||
10 | |||
11 | Contenuti: | ||
12 | |||
13 | .. toctree:: | ||
14 | :numbered: | ||
15 | :maxdepth: 2 | ||
16 | |||
17 | 1.Intro | ||
18 | 2.Process | ||
19 | 3.Early-stage | ||
20 | 4.Coding | ||
21 | 5.Posting | ||
22 | 6.Followthrough | ||
23 | 7.AdvancedTopics | ||
24 | 8.Conclusion | ||
25 | |||
26 | Lo scopo di questo documento è quello di aiutare gli sviluppatori (ed i loro | ||
27 | supervisori) a lavorare con la communità di sviluppo con il minimo sforzo. È | ||
28 | un tentativo di documentare il funzionamento di questa communità in modo che | ||
29 | sia accessibile anche a coloro che non hanno famigliarità con lo sviluppo del | ||
30 | Kernel Linux (o, anzi, con lo sviluppo di software libero in generale). Benchè | ||
31 | qui sia presente del materiale tecnico, questa è una discussione rivolta in | ||
32 | particolare al procedimento, e quindi per essere compreso non richiede una | ||
33 | conoscenza approfondità sullo sviluppo del kernel. | ||
diff --git a/Documentation/translations/it_IT/process/email-clients.rst b/Documentation/translations/it_IT/process/email-clients.rst new file mode 100644 index 000000000000..224ab031ffd3 --- /dev/null +++ b/Documentation/translations/it_IT/process/email-clients.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/email-clients.rst <email_clients>` | ||
4 | |||
5 | .. _it_email_clients: | ||
6 | |||
7 | Informazioni sui programmi di posta elettronica per Linux | ||
8 | ========================================================= | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/howto.rst b/Documentation/translations/it_IT/process/howto.rst new file mode 100644 index 000000000000..909e6a55bc43 --- /dev/null +++ b/Documentation/translations/it_IT/process/howto.rst | |||
@@ -0,0 +1,655 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/howto.rst <process_howto>` | ||
4 | :Translator: Alessia Mantegazza <amantegazza@vaga.pv.it> | ||
5 | |||
6 | .. _it_process_howto: | ||
7 | |||
8 | Come partecipare allo sviluppo del kernel Linux | ||
9 | =============================================== | ||
10 | |||
11 | Questo è il documento fulcro di quanto trattato sull'argomento. | ||
12 | Esso contiene le istruzioni su come diventare uno sviluppatore | ||
13 | del kernel Linux e spiega come lavorare con la comunità di | ||
14 | sviluppo kernel Linux. Il documento non tratterà alcun aspetto | ||
15 | tecnico relativo alla programmazione del kernel, ma vi aiuterà | ||
16 | indirizzandovi sulla corretta strada. | ||
17 | |||
18 | Se qualsiasi cosa presente in questo documento diventasse obsoleta, | ||
19 | vi preghiamo di inviare le correzioni agli amministratori di questo | ||
20 | file, indicati in fondo al presente documento. | ||
21 | |||
22 | Introduzione | ||
23 | ------------ | ||
24 | Dunque, volete imparare come diventare sviluppatori del kernel Linux? | ||
25 | O vi è stato detto dal vostro capo, "Vai, scrivi un driver Linux per | ||
26 | questo dispositivo". Bene, l'obbiettivo di questo documento è quello | ||
27 | di insegnarvi tutto ciò che dovete sapere per raggiungere il vostro | ||
28 | scopo descrivendo il procedimento da seguire e consigliandovi | ||
29 | su come lavorare con la comunità. Il documento cercherà, inoltre, | ||
30 | di spiegare alcune delle ragioni per le quali la comunità lavora in un | ||
31 | modo suo particolare. | ||
32 | |||
33 | Il kernel è scritto prevalentemente nel linguaggio C con alcune parti | ||
34 | specifiche dell'architettura scritte in linguaggio assembly. | ||
35 | Per lo sviluppo kernel è richiesta una buona conoscenza del linguaggio C. | ||
36 | L'assembly (di qualsiasi architettura) non è richiesto, a meno che non | ||
37 | pensiate di fare dello sviluppo di basso livello per un'architettura. | ||
38 | Sebbene essi non siano un buon sostituto ad un solido studio del | ||
39 | linguaggio C o ad anni di esperienza, i seguenti libri sono, se non | ||
40 | altro, utili riferimenti: | ||
41 | |||
42 | - "The C Programming Language" di Kernighan e Ritchie [Prentice Hall] | ||
43 | - "Practical C Programming" di Steve Oualline [O'Reilly] | ||
44 | - "C: A Reference Manual" di Harbison and Steele [Prentice Hall] | ||
45 | |||
46 | Il kernel è stato scritto usando GNU C e la toolchain GNU. | ||
47 | Sebbene si attenga allo standard ISO C89, esso utilizza una serie di | ||
48 | estensioni che non sono previste in questo standard. Il kernel è un | ||
49 | ambiente C indipendente, che non ha alcuna dipendenza dalle librerie | ||
50 | C standard, così alcune parti del C standard non sono supportate. | ||
51 | Le divisioni ``long long`` e numeri in virgola mobile non sono permessi. | ||
52 | Qualche volta è difficile comprendere gli assunti che il kernel ha | ||
53 | riguardo gli strumenti e le estensioni in uso, e sfortunatamente non | ||
54 | esiste alcuna indicazione definitiva. Per maggiori informazioni, controllate, | ||
55 | la pagina `info gcc`. | ||
56 | |||
57 | Tenete a mente che state cercando di apprendere come lavorare con la comunità | ||
58 | di sviluppo già esistente. Questo è un gruppo eterogeneo di persone, con alti | ||
59 | standard di codifica, di stile e di procedura. Questi standard sono stati | ||
60 | creati nel corso del tempo basandosi su quanto hanno riscontrato funzionare al | ||
61 | meglio per un squadra così grande e geograficamente sparsa. Cercate di | ||
62 | imparare, in anticipo, il più possibile circa questi standard, poichè ben | ||
63 | spiegati; non aspettatevi che gli altri si adattino al vostro modo di fare | ||
64 | o a quello della vostra azienda. | ||
65 | |||
66 | Note legali | ||
67 | ------------ | ||
68 | Il codice sorgente del kernel Linux è rilasciato sotto GPL. Siete pregati | ||
69 | di visionare il file, COPYING, presente nella cartella principale dei | ||
70 | sorgente, per eventuali dettagli sulla licenza. Se avete ulteriori domande | ||
71 | sulla licenza, contattate un avvocato, non chiedete sulle liste di discussione | ||
72 | del kernel Linux. Le persone presenti in queste liste non sono avvocati, | ||
73 | e non dovreste basarvi sulle loro dichiarazioni in materia giuridica. | ||
74 | |||
75 | Per domande più frequenti e risposte sulla licenza GPL, guardare: | ||
76 | |||
77 | https://www.gnu.org/licenses/gpl-faq.html | ||
78 | |||
79 | Documentazione | ||
80 | -------------- | ||
81 | I sorgenti del kernel Linux hanno una vasta base di documenti che vi | ||
82 | insegneranno come interagire con la comunità del kernel. Quando nuove | ||
83 | funzionalità vengono aggiunte al kernel, si raccomanda di aggiungere anche i | ||
84 | relativi file di documentatione che spiegano come usarele. | ||
85 | Quando un cambiamento del kernel genera anche un cambiamento nell'interfaccia | ||
86 | con lo spazio utente, è raccomandabile che inviate una notifica o una | ||
87 | correzione alle pagine *man* spiegando tale modifica agli amministratori di | ||
88 | queste pagine all'indirizzo mtk.manpages@gmail.com, aggiungendo | ||
89 | in CC la lista linux-api@vger.kernel.org. | ||
90 | |||
91 | Di seguito una lista di file che sono presenti nei sorgente del kernel e che | ||
92 | è richiesto che voi leggiate: | ||
93 | |||
94 | :ref:`Documentation/translations/it_IT/admin-guide/README.rst <it_readme>` | ||
95 | Questo file da una piccola anteprima del kernel Linux e descrive il | ||
96 | minimo necessario per configurare e generare il kernel. I novizi | ||
97 | del kernel dovrebbero iniziare da qui. | ||
98 | |||
99 | :ref:`Documentation/translations/it_IT/process/changes.rst <it_changes>` | ||
100 | |||
101 | Questo file fornisce una lista dei pacchetti software necessari | ||
102 | a compilare e far funzionare il kernel con successo. | ||
103 | |||
104 | :ref:`Documentation/translations/it_IT/process/coding-style.rst <it_codingstyle>` | ||
105 | |||
106 | Questo file descrive lo stile della codifica per il kernel Linux, | ||
107 | e parte delle motivazioni che ne sono alla base. Tutto il nuovo codice deve | ||
108 | seguire le linee guida in questo documento. Molti amministratori | ||
109 | accetteranno patch solo se queste osserveranno tali regole, e molte | ||
110 | persone revisioneranno il codice solo se scritto nello stile appropriato. | ||
111 | |||
112 | :ref:`Documentation/translations/it_IT/process/submitting-patches.rst <it_submittingpatches>` e | ||
113 | :ref:`Documentation/translations/it_IT/process/submitting-drivers.rst <it_submittingdrivers>` | ||
114 | |||
115 | Questo file descrive dettagliatamente come creare ed inviare una patch | ||
116 | con successo, includendo (ma non solo questo): | ||
117 | |||
118 | - Contenuto delle email | ||
119 | - Formato delle email | ||
120 | - I destinatari delle email | ||
121 | |||
122 | Seguire tali regole non garantirà il successo (tutte le patch sono soggette | ||
123 | a controlli realitivi a contenuto e stile), ma non seguirle lo precluderà | ||
124 | sempre. | ||
125 | |||
126 | Altre ottime descrizioni di come creare buone patch sono: | ||
127 | |||
128 | "The Perfect Patch" | ||
129 | https://www.ozlabs.org/~akpm/stuff/tpp.txt | ||
130 | |||
131 | "Linux kernel patch submission format" | ||
132 | http://linux.yyz.us/patch-format.html | ||
133 | |||
134 | :ref:`Documentation/process/translations/it_IT/stable-api-nonsense.rst <it_stable_api_nonsense>` | ||
135 | |||
136 | Questo file descrive la motivazioni sottostanti la conscia decisione di | ||
137 | non avere un API stabile all'interno del kernel, incluso cose come: | ||
138 | |||
139 | - Sottosistemi shim-layers (per compatibilità?) | ||
140 | - Portabilità fra Sistemi Operativi dei driver. | ||
141 | - Attenuare i rapidi cambiamenti all'interno dei sorgenti del kernel | ||
142 | (o prevenirli) | ||
143 | |||
144 | Questo documento è vitale per la comprensione della filosifia alla base | ||
145 | dello sviluppo di Linux ed è molto importante per le persone che arrivano | ||
146 | da esperienze con altri Sistemi Operativi. | ||
147 | |||
148 | :ref:`Documentation/translations/it_IT/admin-guide/security-bugs.rst <it_securitybugs>` | ||
149 | Se ritenete di aver trovato un problema di sicurezza nel kernel Linux, | ||
150 | seguite i passaggi scritti in questo documento per notificarlo agli | ||
151 | sviluppatori del kernel, ed aiutare la risoluzione del problema. | ||
152 | |||
153 | :ref:`Documentation/translations/it_IT/process/management-style.rst <it_managementstyle>` | ||
154 | Questo documento descrive come i manutentori del kernel Linux operano | ||
155 | e la filosofia comune alla base del loro metodo. Questa è un'importante | ||
156 | lettura per tutti coloro che sono nuovi allo sviluppo del kernel (o per | ||
157 | chi è semplicemente curioso), poiché risolve molti dei più comuni | ||
158 | fraintendimenti e confusioni dovuti al particolare comportamento dei | ||
159 | manutentori del kernel. | ||
160 | |||
161 | :ref:`Documentation/translations/it_IT/process/stable-kernel-rules.rst <it_stable_kernel_rules>` | ||
162 | Questo file descrive le regole sulle quali vengono basati i rilasci del | ||
163 | kernel, e spiega cosa fare se si vuole che una modifica venga inserita | ||
164 | in uno di questi rilasci. | ||
165 | |||
166 | :ref:`Documentation/translations/it_IT/process/kernel-docs.rst <it_kernel_docs>` | ||
167 | Una lista di documenti pertinenti allo sviluppo del kernel. | ||
168 | Per favore consultate questa lista se non trovate ciò che cercate nella | ||
169 | documentazione interna del kernel. | ||
170 | |||
171 | :ref:`Documentation/translations/it_IT/process/applying-patches.rst <it_applying_patches>` | ||
172 | Una buona introduzione che descrivere esattamente cos'è una patch e come | ||
173 | applicarla ai differenti rami di sviluppo del kernel. | ||
174 | |||
175 | Il kernel inoltre ha un vasto numero di documenti che possono essere | ||
176 | automaticamente generati dal codice sorgente stesso o da file | ||
177 | ReStructuredText (ReST), come questo. Esso include una completa | ||
178 | descrizione dell'API interna del kernel, e le regole su come gestire la | ||
179 | sincronizzazione (locking) correttamente | ||
180 | |||
181 | Tutte queste tipologie di documenti possono essere generati in PDF o in | ||
182 | HTML utilizzando:: | ||
183 | |||
184 | make pdfdocs | ||
185 | make htmldocs | ||
186 | |||
187 | rispettivamente dalla cartella principale dei sorgenti del kernel. | ||
188 | |||
189 | I documenti che impiegano ReST saranno generati nella cartella | ||
190 | Documentation/output. | ||
191 | Questi posso essere generati anche in formato LaTex e ePub con:: | ||
192 | |||
193 | make latexdocs | ||
194 | make epubdocs | ||
195 | |||
196 | Diventare uno sviluppatore del kernel | ||
197 | ------------------------------------- | ||
198 | Se non sapete nulla sullo sviluppo del kernel Linux, dovreste dare uno | ||
199 | sguardo al progetto *Linux KernelNewbies*: | ||
200 | |||
201 | https://kernelnewbies.org | ||
202 | |||
203 | Esso prevede un'utile lista di discussione dove potete porre più o meno ogni | ||
204 | tipo di quesito relativo ai concetti fondamentali sullo sviluppo del kernel | ||
205 | (assicuratevi di cercare negli archivi, prima di chiedere qualcosa alla | ||
206 | quale è già stata fornita risposta in passato). Esistono inoltre, un canale IRC | ||
207 | che potete usare per formulare domande in tempo reale, e molti documenti utili | ||
208 | che vi faciliteranno nell'apprendimento dello sviluppo del kernel Linux. | ||
209 | |||
210 | Il sito internet contiene informazioni di base circa l'organizzazione del | ||
211 | codice, sottosistemi e progetti attuali (sia interni che esterni a Linux). | ||
212 | Esso descrive, inoltre, informazioni logistiche di base, riguardanti ad esempio | ||
213 | la compilazione del kernel e l'applicazione di una modifica. | ||
214 | |||
215 | Se non sapete dove cominciare, ma volete cercare delle attività dalle quali | ||
216 | partire per partecipare alla comunità di sviluppo, andate al progetto Linux | ||
217 | Kernel Janitor's. | ||
218 | |||
219 | https://kernelnewbies.org/KernelJanitors | ||
220 | |||
221 | È un buon posto da cui iniziare. Esso presenta una lista di problematiche | ||
222 | relativamente semplici da sistemare e pulire all'interno della sorgente del | ||
223 | kernel Linux. Lavorando con gli sviluppatori incaricati di questo progetto, | ||
224 | imparerete le basi per l'inserimento delle vostre modifiche all'interno dei | ||
225 | sorgenti del kernel Linux, e possibilmente, sarete indirizzati al lavoro | ||
226 | successivo da svolgere, se non ne avrete ancora idea. | ||
227 | |||
228 | Prima di apportare una qualsiasi modifica al codice del kernel Linux, | ||
229 | è imperativo comprendere come tale codice funziona. A questo scopo, non c'è | ||
230 | nulla di meglio che leggerlo direttamente (la maggior parte dei bit più | ||
231 | complessi sono ben commentati), eventualmente anche con l'aiuto di strumenti | ||
232 | specializzati. Uno degli strumenti che è particolarmente raccomandato è | ||
233 | il progetto Linux Cross-Reference, che è in grado di presentare codice | ||
234 | sorgente in un formato autoreferenziale ed indicizzato. Un eccellente ed | ||
235 | aggiornata fonte di consultazione del codice del kernel la potete trovare qui: | ||
236 | |||
237 | http://lxr.free-electrons.com/ | ||
238 | |||
239 | |||
240 | Il processo di sviluppo | ||
241 | ----------------------- | ||
242 | Il processo di sviluppo del kernel Linux si compone di pochi "rami" principali | ||
243 | e di molti altri rami per specifici sottosistemi. Questi rami sono: | ||
244 | |||
245 | - I sorgenti kernel 4.x | ||
246 | - I sorgenti stabili del kernel 4.x.y -stable | ||
247 | - Le modifiche in 4.x -git | ||
248 | - Sorgenti dei sottosistemi del kernel e le loro modifiche | ||
249 | - Il kernel 4.x -next per test d'integrazione | ||
250 | |||
251 | I sorgenti kernel 4.x | ||
252 | ~~~~~~~~~~~~~~~~~~~~~ | ||
253 | |||
254 | I kernel 4.x sono amministrati da Linus Torvald, e possono essere trovati | ||
255 | su https://kernel.org nella cartella pub/linux/kernel/v4.x/. Il processo | ||
256 | di sviluppo è il seguente: | ||
257 | |||
258 | - Non appena un nuovo kernel viene rilasciato si apre una finestra di due | ||
259 | settimane. Durante questo periodo i manutentori possono proporre a Linus | ||
260 | dei grossi cambiamenti; solitamente i cambiamenti che sono già stati | ||
261 | inseriti nel ramo -next del kernel per alcune settimane. Il modo migliore | ||
262 | per sottoporre dei cambiamenti è attraverso git (lo strumento usato per | ||
263 | gestire i sorgenti del kernel, più informazioni sul sito | ||
264 | https://git-scm.com/) ma anche delle patch vanno bene. | ||
265 | |||
266 | - Al termine delle due settimane un kernel -rc1 viene rilasciato e | ||
267 | l'obbiettivo ora è quello di renderlo il più solido possibile. A questo | ||
268 | punto la maggior parte delle patch dovrebbero correggere un'eventuale | ||
269 | regressione. I bachi che sono sempre esistiti non sono considerabili come | ||
270 | regressioni, quindi inviate questo tipo di cambiamenti solo se sono | ||
271 | importanti. Notate che un intero driver (o filesystem) potrebbe essere | ||
272 | accettato dopo la -rc1 poiché non esistono rischi di una possibile | ||
273 | regressione con tale cambiamento, fintanto che quest'ultimo è | ||
274 | auto-contenuto e non influisce su aree esterne al codice che è stato | ||
275 | aggiunto. git può essere utilizzato per inviare le patch a Linus dopo che | ||
276 | la -rc1 è stata rilasciata, ma è anche necessario inviare le patch ad | ||
277 | una lista di discussione pubblica per un'ulteriore revisione. | ||
278 | |||
279 | - Una nuova -rc viene rilasciata ogni volta che Linus reputa che gli attuali | ||
280 | sorgenti siano in uno stato di salute ragionevolmente adeguato ai test. | ||
281 | L'obiettivo è quello di rilasciare una nuova -rc ogni settimana. | ||
282 | |||
283 | - Il processo continua fino a che il kernel è considerato "pronto"; tale | ||
284 | processo dovrebbe durare circa in 6 settimane. | ||
285 | |||
286 | È utile menzionare quanto scritto da Andrew Morton sulla lista di discussione | ||
287 | kernel-linux in merito ai rilasci del kernel: | ||
288 | |||
289 | *"Nessuno sa quando un kernel verrà rilasciato, poichè questo è | ||
290 | legato allo stato dei bachi e non ad una cronologia preventiva."* | ||
291 | |||
292 | I sorgenti stabili del kernel 4.x.y -stable | ||
293 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
294 | |||
295 | I kernel con versioni in 3-parti sono "kernel stabili". Essi contengono | ||
296 | correzioni critiche relativamente piccole nell'ambito della sicurezza | ||
297 | oppure significative regressioni scoperte in un dato 4.x kernel. | ||
298 | |||
299 | Questo è il ramo raccomandato per gli utenti che vogliono un kernel recente | ||
300 | e stabile e non sono interessati a dare il proprio contributo alla verifica | ||
301 | delle versioni di sviluppo o sperimentali. | ||
302 | |||
303 | Se non è disponibile alcun kernel 4.x.y., quello più aggiornato e stabile | ||
304 | sarà il kernel 4.x con la numerazione più alta. | ||
305 | |||
306 | 4.x.y sono amministrati dal gruppo "stable" <stable@vger.kernel.org>, e sono | ||
307 | rilasciati a seconda delle esigenze. Il normale periodo di rilascio è | ||
308 | approssimativamente di due settimane, ma può essere più lungo se non si | ||
309 | verificano problematiche urgenti. Un problema relativo alla sicurezza, invece, | ||
310 | può determinare un rilascio immediato. | ||
311 | |||
312 | Il file Documentation/process/stable-kernel-rules.rst (nei sorgenti) documenta | ||
313 | quali tipologie di modifiche sono accettate per i sorgenti -stable, e come | ||
314 | avviene il processo di rilascio. | ||
315 | |||
316 | Le modifiche in 4.x -git | ||
317 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
318 | |||
319 | Queste sono istantanee quotidiane del kernel di Linus e sono gestite in | ||
320 | una repositorio git (da qui il nome). Queste modifiche sono solitamente | ||
321 | rilasciate giornalmente e rappresentano l'attuale stato dei sorgenti di | ||
322 | Linus. Queste sono da considerarsi più sperimentali di un -rc in quanto | ||
323 | generate automaticamente senza nemmeno aver dato una rapida occhiata | ||
324 | per verificarne lo stato. | ||
325 | |||
326 | |||
327 | Sorgenti dei sottosistemi del kernel e le loro patch | ||
328 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
329 | |||
330 | I manutentori dei diversi sottosistemi del kernel --- ed anche molti | ||
331 | sviluppatori di sottosistemi --- mostrano il loro attuale stato di sviluppo | ||
332 | nei loro repositori. In questo modo, altri possono vedere cosa succede nelle | ||
333 | diverse parti del kernel. In aree dove lo sviluppo è rapido, potrebbe essere | ||
334 | chiesto ad uno sviluppatore di basare le proprie modifiche su questi repositori | ||
335 | in modo da evitare i conflitti fra le sottomissioni ed altri lavori in corso | ||
336 | |||
337 | La maggior parte di questi repositori sono git, ma esistono anche altri SCM | ||
338 | in uso, o file di patch pubblicate come una serie quilt. | ||
339 | Gli indirizzi dei repositori di sottosistema sono indicati nel file | ||
340 | MAINTAINERS. Molti di questi posso essere trovati su https://git.kernel.org/. | ||
341 | |||
342 | Prima che una modifica venga inclusa in questi sottosistemi, sarà soggetta ad | ||
343 | una revisione che inizialmente avviene tramite liste di discussione (vedere la | ||
344 | sezione dedicata qui sotto). Per molti sottosistemi del kernel, tale processo | ||
345 | di revisione è monitorato con lo strumento patchwork. | ||
346 | Patchwork offre un'interfaccia web che mostra le patch pubblicate, inclusi i | ||
347 | commenti o le revisioni fatte, e gli amministratori possono indicare le patch | ||
348 | come "in revisione", "accettate", o "rifiutate". Diversi siti Patchwork sono | ||
349 | elencati al sito https://patchwork.kernel.org/. | ||
350 | |||
351 | Il kernel 4.x -next per test d'integrazione | ||
352 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
353 | |||
354 | Prima che gli aggiornamenti dei sottosistemi siano accorpati nel ramo | ||
355 | principale 4.x, sarà necessario un test d'integrazione. | ||
356 | A tale scopo, esiste un repositorio speciale di test nel quale virtualmente | ||
357 | tutti i rami dei sottosistemi vengono inclusi su base quotidiana: | ||
358 | |||
359 | https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git | ||
360 | |||
361 | In questo modo, i kernel -next offrono uno sguardo riassuntivo su quello che | ||
362 | ci si aspetterà essere nel kernel principale nel successivo periodo | ||
363 | d'incorporazione. | ||
364 | Coloro che vorranno fare dei test d'esecuzione del kernel -next sono più che | ||
365 | benvenuti. | ||
366 | |||
367 | |||
368 | Riportare Bug | ||
369 | ------------- | ||
370 | |||
371 | https://bugzilla.kernel.org è dove gli sviluppatori del kernel Linux tracciano | ||
372 | i bachi del kernel. Gli utenti sono incoraggiati nel riportare tutti i bachi | ||
373 | che trovano utilizzando questo strumento. | ||
374 | Per maggiori dettagli su come usare il bugzilla del kernel, guardare: | ||
375 | |||
376 | https://bugzilla.kernel.org/page.cgi?id=faq.html | ||
377 | |||
378 | Il file admin-guide/reporting-bugs.rst nella cartella principale del kernel | ||
379 | fornisce un buon modello sul come segnalare un baco nel kernel, e spiega quali | ||
380 | informazioni sono necessarie agli sviluppatori per poter aiutare il | ||
381 | rintracciamento del problema. | ||
382 | |||
383 | Gestire i rapporti sui bug | ||
384 | -------------------------- | ||
385 | |||
386 | Uno dei modi migliori per mettere in pratica le vostre capacità di hacking è | ||
387 | quello di riparare bachi riportati da altre persone. Non solo aiuterete a far | ||
388 | diventare il kernel più stabile, ma imparerete a riparare problemi veri dal | ||
389 | mondo ed accrescerete le vostre competenze, e gli altri sviluppatori saranno | ||
390 | al corrente della vostra presenza. Riparare bachi è una delle migliori vie per | ||
391 | acquisire meriti tra gli altri sviluppatori, perchè non a molte persone piace | ||
392 | perdere tempo a sistemare i bachi di altri. | ||
393 | |||
394 | Per lavorare sui rapporti di bachi già riportati, andate su | ||
395 | https://bugzilla.kernel.org. | ||
396 | |||
397 | Liste di discussione | ||
398 | -------------------- | ||
399 | |||
400 | Come descritto in molti dei documenti qui sopra, la maggior parte degli | ||
401 | sviluppatori del kernel partecipano alla lista di discussione Linux Kernel. | ||
402 | I dettagli su come iscriversi e disiscriversi dalla lista possono essere | ||
403 | trovati al sito: | ||
404 | |||
405 | http://vger.kernel.org/vger-lists.html#linux-kernel | ||
406 | |||
407 | Ci sono diversi archivi della lista di discussione. Usate un qualsiasi motore | ||
408 | di ricerca per trovarli. Per esempio: | ||
409 | |||
410 | http://dir.gmane.org/gmane.linux.kernel | ||
411 | |||
412 | É caldamente consigliata una ricerca in questi archivi sul tema che volete | ||
413 | sollevare, prima di pubblicarlo sulla lista. Molte cose sono già state | ||
414 | discusse in dettaglio e registrate negli archivi della lista di discussione. | ||
415 | |||
416 | Molti dei sottosistemi del kernel hanno anche una loro lista di discussione | ||
417 | dedicata. Guardate nel file MAINTAINERS per avere una lista delle liste di | ||
418 | discussione e il loro uso. | ||
419 | |||
420 | Molte di queste liste sono gestite su kernel.org. Per informazioni consultate | ||
421 | la seguente pagina: | ||
422 | |||
423 | http://vger.kernel.org/vger-lists.html | ||
424 | |||
425 | Per favore ricordatevi della buona educazione quando utilizzate queste liste. | ||
426 | Sebbene sia un pò dozzinale, il seguente URL contiene alcune semplici linee | ||
427 | guida per interagire con la lista (o con qualsiasi altra lista): | ||
428 | |||
429 | http://www.albion.com/netiquette/ | ||
430 | |||
431 | Se diverse persone rispondo alla vostra mail, la lista dei riceventi (copia | ||
432 | conoscenza) potrebbe diventare abbastanza lunga. Non cancellate nessuno dalla | ||
433 | lista di CC: senza un buon motivo, e non rispondete solo all'indirizzo | ||
434 | della lista di discussione. Fateci l'abitudine perché capita spesso di | ||
435 | ricevere la stessa email due volte: una dal mittente ed una dalla lista; e non | ||
436 | cercate di modificarla aggiungendo intestazioni stravaganti, agli altri non | ||
437 | piacerà. | ||
438 | |||
439 | Ricordate di rimanere sempre in argomento e di mantenere le attribuzioni | ||
440 | delle vostre risposte invariate; mantenete il "John Kernelhacker wrote ...:" | ||
441 | in cima alla vostra replica e aggiungete le vostre risposte fra i singoli | ||
442 | blocchi citati, non scrivete all'inizio dell'email. | ||
443 | |||
444 | Se aggiungete patch alla vostra mail, assicuratevi che siano del tutto | ||
445 | leggibili come indicato in Documentation/process/submitting-patches.rst. | ||
446 | Gli sviluppatori kernel non vogliono avere a che fare con allegati o patch | ||
447 | compresse; vogliono invece poter commentare le righe dei vostri cambiamenti, | ||
448 | il che può funzionare solo in questo modo. | ||
449 | Assicuratevi di utilizzare un gestore di mail che non alterì gli spazi ed i | ||
450 | caratteri. Un ottimo primo test è quello di inviare a voi stessi una mail e | ||
451 | cercare di sottoporre la vostra stessa patch. Se non funziona, sistemate il | ||
452 | vostro programma di posta, o cambiatelo, finché non funziona. | ||
453 | |||
454 | Ed infine, per favore ricordatevi di mostrare rispetto per gli altri | ||
455 | sottoscriventi. | ||
456 | |||
457 | Lavorare con la comunità | ||
458 | ------------------------ | ||
459 | |||
460 | L'obiettivo di questa comunità è quello di fornire il miglior kernel possibile. | ||
461 | Quando inviate una modifica che volete integrare, sarà valutata esclusivamente | ||
462 | dal punto di vista tecnico. Quindi, cosa dovreste aspettarvi? | ||
463 | |||
464 | - critiche | ||
465 | - commenti | ||
466 | - richieste di cambiamento | ||
467 | - richieste di spiegazioni | ||
468 | - nulla | ||
469 | |||
470 | Ricordatevi che questo fa parte dell'integrazione della vostra modifica | ||
471 | all'interno del kernel. Dovete essere in grado di accettare le critiche, | ||
472 | valutarle a livello tecnico ed eventualmente rielaborare nuovamente le vostre | ||
473 | modifiche o fornire delle chiare e concise motivazioni per le quali le | ||
474 | modifiche suggerite non dovrebbero essere fatte. | ||
475 | Se non riceverete risposte, aspettate qualche giorno e riprovate ancora, | ||
476 | qualche volta le cose si perdono nell'enorme mucchio di email. | ||
477 | |||
478 | Cosa non dovreste fare? | ||
479 | |||
480 | - aspettarvi che la vostra modifica venga accettata senza problemi | ||
481 | - mettervi sulla difensiva | ||
482 | - ignorare i commenti | ||
483 | - sottomettere nuovamente la modifica senza fare nessuno dei cambiamenti | ||
484 | richiesti | ||
485 | |||
486 | In una comunità che è alla ricerca delle migliori soluzioni tecniche possibili, | ||
487 | ci saranno sempre opinioni differenti sull'utilità di una modifica. | ||
488 | Siate cooperativi e vogliate adattare la vostra idea in modo che sia inserita | ||
489 | nel kernel. O almeno vogliate dimostrare che la vostra idea vale. | ||
490 | Ricordatevi, sbagliare è accettato fintanto che siate disposti a lavorare verso | ||
491 | una soluzione che è corretta. | ||
492 | |||
493 | È normale che le risposte alla vostra prima modifica possa essere | ||
494 | semplicemente una lista con dozzine di cose che dovreste correggere. | ||
495 | Questo **non** implica che la vostra patch non sarà accettata, e questo | ||
496 | **non** è contro di voi personalmente. | ||
497 | Semplicemente correggete tutte le questioni sollevate contro la vostra modifica | ||
498 | ed inviatela nuovamente. | ||
499 | |||
500 | Differenze tra la comunità del kernel e le strutture aziendali | ||
501 | -------------------------------------------------------------- | ||
502 | |||
503 | La comunità del kernel funziona diversamente rispetto a molti ambienti di | ||
504 | sviluppo aziendali. Qui di seguito una lista di cose che potete provare a | ||
505 | fare per evitare problemi: | ||
506 | |||
507 | Cose da dire riguardanti le modifiche da voi proposte: | ||
508 | |||
509 | - "Questo risolve più problematiche." | ||
510 | - "Questo elimina 2000 stringhe di codice." | ||
511 | - "Qui una modifica che spiega cosa sto cercando di fare." | ||
512 | - "L'ho testato su 5 diverse architetture.." | ||
513 | - "Qui una serie di piccole modifiche che.." | ||
514 | - "Questo aumenta le prestazioni di macchine standard..." | ||
515 | |||
516 | Cose che dovreste evitare di dire: | ||
517 | |||
518 | - "Lo abbiamo fatto in questo modo in AIX/ptx/Solaris, di conseguenza | ||
519 | deve per forza essere giusto..." | ||
520 | - "Ho fatto questo per 20 anni, quindi.." | ||
521 | - "Questo è richiesto dalla mia Azienda per far soldi" | ||
522 | - "Questo è per la linea di prodotti della nostra Azienda" | ||
523 | - "Ecco il mio documento di design di 1000 pagine che descrive ciò che ho | ||
524 | in mente" | ||
525 | - "Ci ho lavorato per 6 mesi..." | ||
526 | - "Ecco una patch da 5000 righe che.." | ||
527 | - "Ho riscritto il pasticcio attuale, ed ecco qua.." | ||
528 | - "Ho una scadenza, e questa modifica ha bisogno di essere approvata ora" | ||
529 | |||
530 | Un'altra cosa nella quale la comunità del kernel si differenzia dai più | ||
531 | classici ambienti di ingegneria del software è la natura "senza volto" delle | ||
532 | interazioni umane. Uno dei benefici dell'uso delle email e di irc come forma | ||
533 | primordiale di comunicazione è l'assenza di discriminazione basata su genere e | ||
534 | razza. L'ambienti di lavoro Linux accetta donne e minoranze perchè tutto quello | ||
535 | che sei è un indirizzo email. Aiuta anche l'aspetto internazionale nel | ||
536 | livellare il terreno di gioco perchè non è possibile indovinare il genere | ||
537 | basandosi sul nome di una persona. Un uomo può chiamarsi Andrea ed una donna | ||
538 | potrebbe chiamarsi Pat. Gran parte delle donne che hanno lavorato al kernel | ||
539 | Linux e che hanno espresso una personale opinione hanno avuto esperienze | ||
540 | positive. | ||
541 | |||
542 | La lingua potrebbe essere un ostacolo per quelle persone che non si trovano | ||
543 | a loro agio con l'inglese. Una buona padronanza del linguaggio può essere | ||
544 | necessaria per esporre le proprie idee in maniera appropiata all'interno | ||
545 | delle liste di discussione, quindi è consigliabile che rileggiate le vostre | ||
546 | email prima di inviarle in modo da essere certi che abbiano senso in inglese. | ||
547 | |||
548 | |||
549 | Spezzare le vostre modifiche | ||
550 | ---------------------------- | ||
551 | |||
552 | La comunità del kernel Linux non accetta con piacere grossi pezzi di codice | ||
553 | buttati lì tutti in una volta. Le modifiche necessitano di essere | ||
554 | adeguatamente presentate, discusse, e suddivise in parti più piccole ed | ||
555 | indipendenti. Questo è praticamente l'esatto opposto di quello che le | ||
556 | aziende fanno solitamente. La vostra proposta dovrebbe, inoltre, essere | ||
557 | presentata prestissimo nel processo di sviluppo, così che possiate ricevere | ||
558 | un riscontro su quello che state facendo. Lasciate che la comunità | ||
559 | senta che state lavorando con loro, e che non li stiate sfruttando come | ||
560 | discarica per le vostre aggiunte. In ogni caso, non inviate 50 email nello | ||
561 | stesso momento in una lista di discussione, il più delle volte la vostra serie | ||
562 | di modifiche dovrebbe essere più piccola. | ||
563 | |||
564 | I motivi per i quali dovreste frammentare le cose sono i seguenti: | ||
565 | |||
566 | 1) Piccole modifiche aumentano le probabilità che vengano accettate, | ||
567 | altrimenti richiederebbe troppo tempo o sforzo nel verificarne | ||
568 | la correttezza. Una modifica di 5 righe può essere accettata da un | ||
569 | manutentore con a mala pena una seconda occhiata. Invece, una modifica da | ||
570 | 500 linee può richiedere ore di rilettura per verificarne la correttezza | ||
571 | (il tempo necessario è esponenzialmente proporzionale alla dimensione della | ||
572 | modifica, o giù di lì) | ||
573 | |||
574 | Piccole modifiche sono inoltre molto facili da debuggare quando qualcosa | ||
575 | non va. È molto più facile annullare le modifiche una per una che | ||
576 | dissezionare una patch molto grande dopo la sua sottomissione (e rompere | ||
577 | qualcosa). | ||
578 | |||
579 | 2) È importante non solo inviare piccole modifiche, ma anche riscriverle e | ||
580 | semplificarle (o più semplicemente ordinarle) prima di sottoporle. | ||
581 | |||
582 | Qui un'analogia dello sviluppatore kernel Al Viro: | ||
583 | |||
584 | *"Pensate ad un insegnante di matematica che corregge il compito | ||
585 | di uno studente (di matematica). L'insegnante non vuole vedere le | ||
586 | prove e gli errori commessi dallo studente prima che arrivi alla | ||
587 | soluzione. Vuole vedere la risposta più pulita ed elegante | ||
588 | possibile. Un buono studente lo sa, e non presenterebbe mai le | ||
589 | proprie bozze prima prima della soluzione finale"* | ||
590 | |||
591 | *"Lo stesso vale per lo sviluppo del kernel. I manutentori ed i | ||
592 | revisori non vogliono vedere il procedimento che sta dietro al | ||
593 | problema che uno sta risolvendo. Vogliono vedere una soluzione | ||
594 | semplice ed elegante."* | ||
595 | |||
596 | Può essere una vera sfida il saper mantenere l'equilibrio fra una presentazione | ||
597 | elegante della vostra soluzione, lavorare insieme ad una comunità e dibattere | ||
598 | su un lavoro incompleto. Pertanto è bene entrare presto nel processo di | ||
599 | revisione per migliorare il vostro lavoro, ma anche per riuscire a tenere le | ||
600 | vostre modifiche in pezzettini che potrebbero essere già accettate, nonostante | ||
601 | la vostra intera attività non lo sia ancora. | ||
602 | |||
603 | In fine, rendetevi conto che non è accettabile inviare delle modifiche | ||
604 | incomplete con la promessa che saranno "sistemate dopo". | ||
605 | |||
606 | |||
607 | Giustificare le vostre modifiche | ||
608 | -------------------------------- | ||
609 | |||
610 | Insieme alla frammentazione delle vostre modifiche, è altrettanto importante | ||
611 | permettere alla comunità Linux di capire perché dovrebbero accettarle. | ||
612 | Nuove funzionalità devono essere motivate come necessarie ed utili. | ||
613 | |||
614 | |||
615 | Documentare le vostre modifiche | ||
616 | ------------------------------- | ||
617 | |||
618 | Quando inviate le vostre modifiche, fate particolare attenzione a quello che | ||
619 | scrivete nella vostra email. Questa diventerà il *ChangeLog* per la modifica, | ||
620 | e sarà visibile a tutti per sempre. Dovrebbe descrivere la modifica nella sua | ||
621 | interezza, contenendo: | ||
622 | |||
623 | - perchè la modifica è necessaria | ||
624 | - l'approccio d'insieme alla patch | ||
625 | - dettagli supplementari | ||
626 | - risultati dei test | ||
627 | |||
628 | Per maggiori dettagli su come tutto ciò dovrebbe apparire, riferitevi alla | ||
629 | sezione ChangeLog del documento: | ||
630 | |||
631 | "The Perfect Patch" | ||
632 | http://www.ozlabs.org/~akpm/stuff/tpp.txt | ||
633 | |||
634 | A volte tutto questo è difficile da realizzare. Il perfezionamento di queste | ||
635 | pratiche può richiedere anni (eventualmente). È un processo continuo di | ||
636 | miglioramento che richiede molta pazienza e determinazione. Ma non mollate, | ||
637 | si può fare. Molti lo hanno fatto prima, ed ognuno ha dovuto iniziare dove | ||
638 | siete voi ora. | ||
639 | |||
640 | |||
641 | |||
642 | |||
643 | ---------- | ||
644 | |||
645 | Grazie a Paolo Ciarrocchi che ha permesso che la sezione "Development Process" | ||
646 | (https://lwn.net/Articles/94386/) fosse basata sui testi da lui scritti, ed a | ||
647 | Randy Dunlap e Gerrit Huizenga per la lista di cose che dovreste e non | ||
648 | dovreste dire. Grazie anche a Pat Mochel, Hanna Linder, Randy Dunlap, | ||
649 | Kay Sievers, Vojtech Pavlik, Jan Kara, Josh Boyer, Kees Cook, Andrew Morton, | ||
650 | Andi Kleen, Vadim Lobanov, Jesper Juhl, Adrian Bunk, Keri Harris, Frans Pop, | ||
651 | David A. Wheeler, Junio Hamano, Michael Kerrisk, e Alex Shepard per le | ||
652 | loro revisioni, commenti e contributi. Senza il loro aiuto, questo documento | ||
653 | non sarebbe stato possibile. | ||
654 | |||
655 | Manutentore: Greg Kroah-Hartman <greg@kroah.com> | ||
diff --git a/Documentation/translations/it_IT/process/index.rst b/Documentation/translations/it_IT/process/index.rst new file mode 100644 index 000000000000..2eda85d5cd1e --- /dev/null +++ b/Documentation/translations/it_IT/process/index.rst | |||
@@ -0,0 +1,67 @@ | |||
1 | .. raw:: latex | ||
2 | |||
3 | \renewcommand\thesection* | ||
4 | \renewcommand\thesubsection* | ||
5 | |||
6 | .. include:: ../disclaimer-ita.rst | ||
7 | |||
8 | :Original: :ref:`Documentation/process/index.rst <process_index>` | ||
9 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
10 | |||
11 | .. _it_process_index: | ||
12 | |||
13 | Lavorare con la comunità di sviluppo del kernel | ||
14 | =============================================== | ||
15 | |||
16 | Quindi volete diventare sviluppatori del kernel? Benvenuti! C'è molto da | ||
17 | imparare sul lato tecnico del kernel, ma è anche importante capire come | ||
18 | funziona la nostra comunità. Leggere questi documenti renderà più facile | ||
19 | l'accettazione delle vostre modifiche con il minimo sforzo. | ||
20 | |||
21 | Di seguito le guide che ogni sviluppatore dovrebbe leggere. | ||
22 | |||
23 | .. toctree:: | ||
24 | :maxdepth: 1 | ||
25 | |||
26 | howto | ||
27 | code-of-conduct | ||
28 | development-process | ||
29 | submitting-patches | ||
30 | coding-style | ||
31 | maintainer-pgp-guide | ||
32 | email-clients | ||
33 | kernel-enforcement-statement | ||
34 | kernel-driver-statement | ||
35 | |||
36 | Poi ci sono altre guide sulla comunità che sono di interesse per molti | ||
37 | degli sviluppatori: | ||
38 | |||
39 | .. toctree:: | ||
40 | :maxdepth: 1 | ||
41 | |||
42 | changes | ||
43 | submitting-drivers | ||
44 | stable-api-nonsense | ||
45 | management-style | ||
46 | stable-kernel-rules | ||
47 | submit-checklist | ||
48 | kernel-docs | ||
49 | |||
50 | Ed infine, qui ci sono alcune guide più tecniche che son state messe qua solo | ||
51 | perché non si è trovato un posto migliore. | ||
52 | |||
53 | .. toctree:: | ||
54 | :maxdepth: 1 | ||
55 | |||
56 | applying-patches | ||
57 | adding-syscalls | ||
58 | magic-number | ||
59 | volatile-considered-harmful | ||
60 | clang-format | ||
61 | |||
62 | .. only:: subproject and html | ||
63 | |||
64 | Indices | ||
65 | ======= | ||
66 | |||
67 | * :ref:`genindex` | ||
diff --git a/Documentation/translations/it_IT/process/kernel-docs.rst b/Documentation/translations/it_IT/process/kernel-docs.rst new file mode 100644 index 000000000000..7bd70d661737 --- /dev/null +++ b/Documentation/translations/it_IT/process/kernel-docs.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/kernel-docs.rst <kernel_docs>` | ||
4 | |||
5 | |||
6 | .. _it_kernel_docs: | ||
7 | |||
8 | Indice di documenti per le persone interessate a capire e/o scrivere per il kernel Linux | ||
9 | ======================================================================================== | ||
10 | |||
11 | .. warning:: | ||
12 | |||
13 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/kernel-driver-statement.rst b/Documentation/translations/it_IT/process/kernel-driver-statement.rst new file mode 100644 index 000000000000..f016a75a9d6e --- /dev/null +++ b/Documentation/translations/it_IT/process/kernel-driver-statement.rst | |||
@@ -0,0 +1,211 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/kernel-driver-statement.rst <process_statement_driver>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_process_statement_driver: | ||
7 | |||
8 | Dichiarazioni sui driver per il kernel | ||
9 | ====================================== | ||
10 | |||
11 | Presa di posizione sui moduli per il kernel Linux | ||
12 | ------------------------------------------------- | ||
13 | |||
14 | Noi, i sottoscritti sviluppatori del kernel, consideriamo pericoloso | ||
15 | o indesiderato qualsiasi modulo o driver per il kernel Linux di tipo | ||
16 | *a sorgenti chiusi* (*closed-source*). Ripetutamente, li abbiamo | ||
17 | trovati deleteri per gli utenti Linux, le aziende, ed in generale | ||
18 | l'ecosistema Linux. Questi moduli impediscono l'apertura, la stabilità, | ||
19 | la flessibilità, e la manutenibilità del modello di sviluppo di Linux | ||
20 | e impediscono ai loro utenti di beneficiare dell'esperienza dalla | ||
21 | comunità Linux. I fornitori che distribuiscono codice a sorgenti chiusi | ||
22 | obbligano i propri utenti a rinunciare ai principali vantaggi di Linux | ||
23 | o a cercarsi nuovi fornitori. | ||
24 | Perciò, al fine di sfruttare i vantaggi che codice aperto ha da offrire, | ||
25 | come l'abbattimento dei costi e un supporto condiviso, spingiamo i | ||
26 | fornitori ad adottare una politica di supporto ai loro clienti Linux | ||
27 | che preveda il rilascio dei sorgenti per il kernel. | ||
28 | |||
29 | Parliamo solo per noi stessi, e non per una qualsiasi azienda per la | ||
30 | quale lavoriamo oggi, o abbiamo lavorato in passato, o lavoreremo in | ||
31 | futuro. | ||
32 | |||
33 | |||
34 | - Dave Airlie | ||
35 | - Nick Andrew | ||
36 | - Jens Axboe | ||
37 | - Ralf Baechle | ||
38 | - Felipe Balbi | ||
39 | - Ohad Ben-Cohen | ||
40 | - Muli Ben-Yehuda | ||
41 | - Jiri Benc | ||
42 | - Arnd Bergmann | ||
43 | - Thomas Bogendoerfer | ||
44 | - Vitaly Bordug | ||
45 | - James Bottomley | ||
46 | - Josh Boyer | ||
47 | - Neil Brown | ||
48 | - Mark Brown | ||
49 | - David Brownell | ||
50 | - Michael Buesch | ||
51 | - Franck Bui-Huu | ||
52 | - Adrian Bunk | ||
53 | - François Cami | ||
54 | - Ralph Campbell | ||
55 | - Luiz Fernando N. Capitulino | ||
56 | - Mauro Carvalho Chehab | ||
57 | - Denis Cheng | ||
58 | - Jonathan Corbet | ||
59 | - Glauber Costa | ||
60 | - Alan Cox | ||
61 | - Magnus Damm | ||
62 | - Ahmed S. Darwish | ||
63 | - Robert P. J. Day | ||
64 | - Hans de Goede | ||
65 | - Arnaldo Carvalho de Melo | ||
66 | - Helge Deller | ||
67 | - Jean Delvare | ||
68 | - Mathieu Desnoyers | ||
69 | - Sven-Thorsten Dietrich | ||
70 | - Alexey Dobriyan | ||
71 | - Daniel Drake | ||
72 | - Alex Dubov | ||
73 | - Randy Dunlap | ||
74 | - Michael Ellerman | ||
75 | - Pekka Enberg | ||
76 | - Jan Engelhardt | ||
77 | - Mark Fasheh | ||
78 | - J. Bruce Fields | ||
79 | - Larry Finger | ||
80 | - Jeremy Fitzhardinge | ||
81 | - Mike Frysinger | ||
82 | - Kumar Gala | ||
83 | - Robin Getz | ||
84 | - Liam Girdwood | ||
85 | - Jan-Benedict Glaw | ||
86 | - Thomas Gleixner | ||
87 | - Brice Goglin | ||
88 | - Cyrill Gorcunov | ||
89 | - Andy Gospodarek | ||
90 | - Thomas Graf | ||
91 | - Krzysztof Halasa | ||
92 | - Harvey Harrison | ||
93 | - Stephen Hemminger | ||
94 | - Michael Hennerich | ||
95 | - Tejun Heo | ||
96 | - Benjamin Herrenschmidt | ||
97 | - Kristian Høgsberg | ||
98 | - Henrique de Moraes Holschuh | ||
99 | - Marcel Holtmann | ||
100 | - Mike Isely | ||
101 | - Takashi Iwai | ||
102 | - Olof Johansson | ||
103 | - Dave Jones | ||
104 | - Jesper Juhl | ||
105 | - Matthias Kaehlcke | ||
106 | - Kenji Kaneshige | ||
107 | - Jan Kara | ||
108 | - Jeremy Kerr | ||
109 | - Russell King | ||
110 | - Olaf Kirch | ||
111 | - Roel Kluin | ||
112 | - Hans-Jürgen Koch | ||
113 | - Auke Kok | ||
114 | - Peter Korsgaard | ||
115 | - Jiri Kosina | ||
116 | - Aaro Koskinen | ||
117 | - Mariusz Kozlowski | ||
118 | - Greg Kroah-Hartman | ||
119 | - Michael Krufky | ||
120 | - Aneesh Kumar | ||
121 | - Clemens Ladisch | ||
122 | - Christoph Lameter | ||
123 | - Gunnar Larisch | ||
124 | - Anders Larsen | ||
125 | - Grant Likely | ||
126 | - John W. Linville | ||
127 | - Yinghai Lu | ||
128 | - Tony Luck | ||
129 | - Pavel Machek | ||
130 | - Matt Mackall | ||
131 | - Paul Mackerras | ||
132 | - Roland McGrath | ||
133 | - Patrick McHardy | ||
134 | - Kyle McMartin | ||
135 | - Paul Menage | ||
136 | - Thierry Merle | ||
137 | - Eric Miao | ||
138 | - Akinobu Mita | ||
139 | - Ingo Molnar | ||
140 | - James Morris | ||
141 | - Andrew Morton | ||
142 | - Paul Mundt | ||
143 | - Oleg Nesterov | ||
144 | - Luca Olivetti | ||
145 | - S.Çağlar Onur | ||
146 | - Pierre Ossman | ||
147 | - Keith Owens | ||
148 | - Venkatesh Pallipadi | ||
149 | - Nick Piggin | ||
150 | - Nicolas Pitre | ||
151 | - Evgeniy Polyakov | ||
152 | - Richard Purdie | ||
153 | - Mike Rapoport | ||
154 | - Sam Ravnborg | ||
155 | - Gerrit Renker | ||
156 | - Stefan Richter | ||
157 | - David Rientjes | ||
158 | - Luis R. Rodriguez | ||
159 | - Stefan Roese | ||
160 | - Francois Romieu | ||
161 | - Rami Rosen | ||
162 | - Stephen Rothwell | ||
163 | - Maciej W. Rozycki | ||
164 | - Mark Salyzyn | ||
165 | - Yoshinori Sato | ||
166 | - Deepak Saxena | ||
167 | - Holger Schurig | ||
168 | - Amit Shah | ||
169 | - Yoshihiro Shimoda | ||
170 | - Sergei Shtylyov | ||
171 | - Kay Sievers | ||
172 | - Sebastian Siewior | ||
173 | - Rik Snel | ||
174 | - Jes Sorensen | ||
175 | - Alexey Starikovskiy | ||
176 | - Alan Stern | ||
177 | - Timur Tabi | ||
178 | - Hirokazu Takata | ||
179 | - Eliezer Tamir | ||
180 | - Eugene Teo | ||
181 | - Doug Thompson | ||
182 | - FUJITA Tomonori | ||
183 | - Dmitry Torokhov | ||
184 | - Marcelo Tosatti | ||
185 | - Steven Toth | ||
186 | - Theodore Tso | ||
187 | - Matthias Urlichs | ||
188 | - Geert Uytterhoeven | ||
189 | - Arjan van de Ven | ||
190 | - Ivo van Doorn | ||
191 | - Rik van Riel | ||
192 | - Wim Van Sebroeck | ||
193 | - Hans Verkuil | ||
194 | - Horst H. von Brand | ||
195 | - Dmitri Vorobiev | ||
196 | - Anton Vorontsov | ||
197 | - Daniel Walker | ||
198 | - Johannes Weiner | ||
199 | - Harald Welte | ||
200 | - Matthew Wilcox | ||
201 | - Dan J. Williams | ||
202 | - Darrick J. Wong | ||
203 | - David Woodhouse | ||
204 | - Chris Wright | ||
205 | - Bryan Wu | ||
206 | - Rafael J. Wysocki | ||
207 | - Herbert Xu | ||
208 | - Vlad Yasevich | ||
209 | - Peter Zijlstra | ||
210 | - Bartlomiej Zolnierkiewicz | ||
211 | |||
diff --git a/Documentation/translations/it_IT/process/kernel-enforcement-statement.rst b/Documentation/translations/it_IT/process/kernel-enforcement-statement.rst new file mode 100644 index 000000000000..4ddf5a35b270 --- /dev/null +++ b/Documentation/translations/it_IT/process/kernel-enforcement-statement.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/kernel-enforcement-statement.rst <process_statement_kernel>` | ||
4 | |||
5 | |||
6 | .. _it_process_statement_kernel: | ||
7 | |||
8 | Applicazione della licenza sul kernel Linux | ||
9 | =========================================== | ||
10 | |||
11 | .. warning:: | ||
12 | |||
13 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst new file mode 100644 index 000000000000..5281d53e57ee --- /dev/null +++ b/Documentation/translations/it_IT/process/magic-number.rst | |||
@@ -0,0 +1,170 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/magic-numbers.rst <magicnumbers>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_magicnumbers: | ||
7 | |||
8 | I numeri magici di Linux | ||
9 | ======================== | ||
10 | |||
11 | Questo documento è un registro dei numeri magici in uso. Quando | ||
12 | aggiungete un numero magico ad una struttura, dovreste aggiungerlo anche | ||
13 | a questo documento; la cosa migliore è che tutti i numeri magici usati | ||
14 | dalle varie strutture siano unici. | ||
15 | |||
16 | È **davvero** un'ottima idea proteggere le strutture dati del kernel con | ||
17 | dei numeri magici. Questo vi permette in fase d'esecuzione di (a) verificare | ||
18 | se una struttura è stata malmenata, o (b) avete passato a una procedura la | ||
19 | struttura errata. Quest'ultimo è molto utile - particolarmente quando si passa | ||
20 | una struttura dati tramite un puntatore void \*. Il codice tty, per esempio, | ||
21 | effettua questa operazione con regolarità passando avanti e indietro le | ||
22 | strutture specifiche per driver e discipline. | ||
23 | |||
24 | Per utilizzare un numero magico, dovete dichiararlo all'inizio della struttura | ||
25 | dati, come di seguito:: | ||
26 | |||
27 | struct tty_ldisc { | ||
28 | int magic; | ||
29 | ... | ||
30 | }; | ||
31 | |||
32 | Per favore, seguite questa direttiva quando aggiungerete migliorie al kernel! | ||
33 | Mi ha risparmiato un numero illimitato di ore di debug, specialmente nei casi | ||
34 | più ostici dove si è andati oltre la dimensione di un vettore e la struttura | ||
35 | dati che lo seguiva in memoria è stata sovrascritta. Seguendo questa | ||
36 | direttiva, questi casi vengono identificati velocemente e in sicurezza. | ||
37 | |||
38 | Registro dei cambiamenti:: | ||
39 | |||
40 | Theodore Ts'o | ||
41 | 31 Mar 94 | ||
42 | |||
43 | La tabella magica è aggiornata a Linux 2.1.55. | ||
44 | |||
45 | Michael Chastain | ||
46 | <mailto:mec@shout.net> | ||
47 | 22 Sep 1997 | ||
48 | |||
49 | Ora dovrebbe essere aggiornata a Linux 2.1.112. Dato che | ||
50 | siamo in un momento di congelamento delle funzionalità | ||
51 | (*feature freeze*) è improbabile che qualcosa cambi prima | ||
52 | della versione 2.2.x. Le righe sono ordinate secondo il | ||
53 | campo numero. | ||
54 | |||
55 | Krzysztof G. Baranowski | ||
56 | <mailto: kgb@knm.org.pl> | ||
57 | 29 Jul 1998 | ||
58 | |||
59 | Aggiornamento della tabella a Linux 2.5.45. Giusti nel congelamento | ||
60 | delle funzionalità ma è comunque possibile che qualche nuovo | ||
61 | numero magico s'intrufoli prima del kernel 2.6.x. | ||
62 | |||
63 | Petr Baudis | ||
64 | <pasky@ucw.cz> | ||
65 | 03 Nov 2002 | ||
66 | |||
67 | Aggiornamento della tabella magica a Linux 2.5.74. | ||
68 | |||
69 | Fabian Frederick | ||
70 | <ffrederick@users.sourceforge.net> | ||
71 | 09 Jul 2003 | ||
72 | |||
73 | |||
74 | ===================== ================ ======================== ========================================== | ||
75 | Nome magico Numero Struttura File | ||
76 | ===================== ================ ======================== ========================================== | ||
77 | PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` | ||
78 | CMAGIC 0x0111 user ``include/linux/a.out.h`` | ||
79 | MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` | ||
80 | HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c`` | ||
81 | APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` | ||
82 | CYCLADES_MAGIC 0x4359 cyclades_port ``include/linux/cyclades.h`` | ||
83 | DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` | ||
84 | DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` | ||
85 | FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` | ||
86 | FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` | ||
87 | ISICOM_MAGIC 0x4d54 isi_port ``include/linux/isicom.h`` | ||
88 | PTY_MAGIC 0x5001 ``drivers/char/pty.c`` | ||
89 | PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` | ||
90 | SERIAL_MAGIC 0x5301 async_struct ``include/linux/serial.h`` | ||
91 | SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` | ||
92 | SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` | ||
93 | STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` | ||
94 | X25_ASY_MAGIC 0x5303 x25_asy ``drivers/net/x25_asy.h`` | ||
95 | SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` | ||
96 | AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` | ||
97 | TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` | ||
98 | MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` | ||
99 | TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` | ||
100 | MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` | ||
101 | TTY_LDISC_MAGIC 0x5403 tty_ldisc ``include/linux/tty_ldisc.h`` | ||
102 | USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` | ||
103 | FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` | ||
104 | USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` | ||
105 | RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/rfcomm/tty.c`` | ||
106 | USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h`` | ||
107 | CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h`` | ||
108 | RPORT_MAGIC 0x00525001 r_port ``drivers/char/rocket_int.h`` | ||
109 | LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c`` | ||
110 | GDTIOCTL_MAGIC 0x06030f07 gdth_iowr_str ``drivers/scsi/gdth_ioctl.h`` | ||
111 | RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c`` | ||
112 | NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h`` | ||
113 | RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c`` | ||
114 | BAYCOM_MAGIC 0x19730510 baycom_state ``drivers/net/baycom_epp.c`` | ||
115 | ISDN_X25IFACE_MAGIC 0x1e75a2b9 isdn_x25iface_proto_data ``drivers/isdn/isdn_x25iface.h`` | ||
116 | ECP_MAGIC 0x21504345 cdkecpsig ``include/linux/cdk.h`` | ||
117 | LSOMAGIC 0x27091997 lso ``drivers/fc4/fc.c`` | ||
118 | LSMAGIC 0x2a3b4d2a ls ``drivers/fc4/fc.c`` | ||
119 | WANPIPE_MAGIC 0x414C4453 sdla_{dump,exec} ``include/linux/wanpipe.h`` | ||
120 | CS_CARD_MAGIC 0x43525553 cs_card ``sound/oss/cs46xx.c`` | ||
121 | LABELCL_MAGIC 0x4857434c labelcl_info_s ``include/asm/ia64/sn/labelcl.h`` | ||
122 | ISDN_ASYNC_MAGIC 0x49344C01 modem_info ``include/linux/isdn.h`` | ||
123 | CTC_ASYNC_MAGIC 0x49344C01 ctc_tty_info ``drivers/s390/net/ctctty.c`` | ||
124 | ISDN_NET_MAGIC 0x49344C02 isdn_net_local_s ``drivers/isdn/i4l/isdn_net_lib.h`` | ||
125 | SAVEKMSG_MAGIC2 0x4B4D5347 savekmsg ``arch/*/amiga/config.c`` | ||
126 | CS_STATE_MAGIC 0x4c4f4749 cs_state ``sound/oss/cs46xx.c`` | ||
127 | SLAB_C_MAGIC 0x4f17a36d kmem_cache ``mm/slab.c`` | ||
128 | COW_MAGIC 0x4f4f4f4d cow_header_v1 ``arch/um/drivers/ubd_user.c`` | ||
129 | I810_CARD_MAGIC 0x5072696E i810_card ``sound/oss/i810_audio.c`` | ||
130 | TRIDENT_CARD_MAGIC 0x5072696E trident_card ``sound/oss/trident.c`` | ||
131 | ROUTER_MAGIC 0x524d4157 wan_device [in ``wanrouter.h`` pre 3.9] | ||
132 | SAVEKMSG_MAGIC1 0x53415645 savekmsg ``arch/*/amiga/config.c`` | ||
133 | GDA_MAGIC 0x58464552 gda ``arch/mips/include/asm/sn/gda.h`` | ||
134 | RED_MAGIC1 0x5a2cf071 (any) ``mm/slab.c`` | ||
135 | EEPROM_MAGIC_VALUE 0x5ab478d2 lanai_dev ``drivers/atm/lanai.c`` | ||
136 | HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` | ||
137 | PCXX_MAGIC 0x5c6df104 channel ``drivers/char/pcxx.h`` | ||
138 | KV_MAGIC 0x5f4b565f kernel_vars_s ``arch/mips/include/asm/sn/klkernvars.h`` | ||
139 | I810_STATE_MAGIC 0x63657373 i810_state ``sound/oss/i810_audio.c`` | ||
140 | TRIDENT_STATE_MAGIC 0x63657373 trient_state ``sound/oss/trident.c`` | ||
141 | M3_CARD_MAGIC 0x646e6f50 m3_card ``sound/oss/maestro3.c`` | ||
142 | FW_HEADER_MAGIC 0x65726F66 fw_header ``drivers/atm/fore200e.h`` | ||
143 | SLOT_MAGIC 0x67267321 slot ``drivers/hotplug/cpqphp.h`` | ||
144 | SLOT_MAGIC 0x67267322 slot ``drivers/hotplug/acpiphp.h`` | ||
145 | LO_MAGIC 0x68797548 nbd_device ``include/linux/nbd.h`` | ||
146 | OPROFILE_MAGIC 0x6f70726f super_block ``drivers/oprofile/oprofilefs.h`` | ||
147 | M3_STATE_MAGIC 0x734d724d m3_state ``sound/oss/maestro3.c`` | ||
148 | VMALLOC_MAGIC 0x87654320 snd_alloc_track ``sound/core/memory.c`` | ||
149 | KMALLOC_MAGIC 0x87654321 snd_alloc_track ``sound/core/memory.c`` | ||
150 | PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/media/pwc.h`` | ||
151 | NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h`` | ||
152 | ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h`` | ||
153 | CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h`` | ||
154 | DPMEM_MAGIC 0xc0ffee11 gdt_pci_sram ``drivers/scsi/gdth.h`` | ||
155 | YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c`` | ||
156 | CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` | ||
157 | QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c`` | ||
158 | QUEUE_MAGIC_USED 0xf7e1cc33 queue_entry ``drivers/scsi/arm/queue.c`` | ||
159 | HTB_CMAGIC 0xFEFAFEF1 htb_class ``net/sched/sch_htb.c`` | ||
160 | NMI_MAGIC 0x48414d4d455201 nmi_s ``arch/mips/include/asm/sn/nmi.h`` | ||
161 | ===================== ================ ======================== ========================================== | ||
162 | |||
163 | Da notare che ci sono anche dei numeri magici specifici per driver nel | ||
164 | *sound memory management*. Consultate ``include/sound/sndmagic.h`` per una | ||
165 | lista completa. Molti driver audio OSS hanno i loro numeri magici costruiti a | ||
166 | partire dall'identificativo PCI della scheda audio - nemmeno questi sono | ||
167 | elencati in questo file. | ||
168 | |||
169 | Il file-system HFS è un altro grande utilizzatore di numeri magici - potete | ||
170 | trovarli qui ``fs/hfs/hfs.h``. | ||
diff --git a/Documentation/translations/it_IT/process/maintainer-pgp-guide.rst b/Documentation/translations/it_IT/process/maintainer-pgp-guide.rst new file mode 100644 index 000000000000..24a133f0a51d --- /dev/null +++ b/Documentation/translations/it_IT/process/maintainer-pgp-guide.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/maintainer-pgp-guide.rst <pgpguide>` | ||
4 | |||
5 | .. _it_pgpguide: | ||
6 | |||
7 | ======================================== | ||
8 | Guida a PGP per i manutentori del kernel | ||
9 | ======================================== | ||
10 | |||
11 | .. warning:: | ||
12 | |||
13 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/management-style.rst b/Documentation/translations/it_IT/process/management-style.rst new file mode 100644 index 000000000000..07e68bfb8402 --- /dev/null +++ b/Documentation/translations/it_IT/process/management-style.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/management-style.rst <managementstyle>` | ||
4 | |||
5 | .. _it_managementstyle: | ||
6 | |||
7 | Tipo di gestione del kernel Linux | ||
8 | ================================= | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/stable-api-nonsense.rst b/Documentation/translations/it_IT/process/stable-api-nonsense.rst new file mode 100644 index 000000000000..d4fa4abf8dd3 --- /dev/null +++ b/Documentation/translations/it_IT/process/stable-api-nonsense.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/stable-api-nonsense.rst <stable_api_nonsense>` | ||
4 | |||
5 | |||
6 | .. _it_stable_api_nonsense: | ||
7 | |||
8 | L'interfaccia dei driver per il kernel Linux | ||
9 | ============================================ | ||
10 | |||
11 | .. warning:: | ||
12 | |||
13 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/stable-kernel-rules.rst b/Documentation/translations/it_IT/process/stable-kernel-rules.rst new file mode 100644 index 000000000000..6fa5ce9c3572 --- /dev/null +++ b/Documentation/translations/it_IT/process/stable-kernel-rules.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` | ||
4 | |||
5 | .. _it_stable_kernel_rules: | ||
6 | |||
7 | Tutto quello che volevate sapere sui rilasci -stable di Linux | ||
8 | ============================================================== | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/submit-checklist.rst b/Documentation/translations/it_IT/process/submit-checklist.rst new file mode 100644 index 000000000000..b6b4dd94a660 --- /dev/null +++ b/Documentation/translations/it_IT/process/submit-checklist.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/submit-checklist.rst <submitchecklist>` | ||
4 | |||
5 | .. _it_submitchecklist: | ||
6 | |||
7 | Lista delle cose da fare per inviare una modifica al kernel Linux | ||
8 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/submitting-drivers.rst b/Documentation/translations/it_IT/process/submitting-drivers.rst new file mode 100644 index 000000000000..16df950ef808 --- /dev/null +++ b/Documentation/translations/it_IT/process/submitting-drivers.rst | |||
@@ -0,0 +1,12 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/submitting-drivers.rst <submittingdrivers>` | ||
4 | |||
5 | .. _it_submittingdrivers: | ||
6 | |||
7 | Sottomettere driver per il kernel Linux | ||
8 | ======================================= | ||
9 | |||
10 | .. warning:: | ||
11 | |||
12 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/submitting-patches.rst b/Documentation/translations/it_IT/process/submitting-patches.rst new file mode 100644 index 000000000000..d633775ed556 --- /dev/null +++ b/Documentation/translations/it_IT/process/submitting-patches.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` | ||
4 | |||
5 | |||
6 | .. _it_submittingpatches: | ||
7 | |||
8 | Sottomettere modifiche: la guida essenziale per vedere il vostro codice nel kernel | ||
9 | ================================================================================== | ||
10 | |||
11 | .. warning:: | ||
12 | |||
13 | TODO ancora da tradurre | ||
diff --git a/Documentation/translations/it_IT/process/volatile-considered-harmful.rst b/Documentation/translations/it_IT/process/volatile-considered-harmful.rst new file mode 100644 index 000000000000..efc640cac596 --- /dev/null +++ b/Documentation/translations/it_IT/process/volatile-considered-harmful.rst | |||
@@ -0,0 +1,134 @@ | |||
1 | .. include:: ../disclaimer-ita.rst | ||
2 | |||
3 | :Original: :ref:`Documentation/process/volatile-considered-harmful.rst <volatile_considered_harmful>` | ||
4 | :Translator: Federico Vaga <federico.vaga@vaga.pv.it> | ||
5 | |||
6 | .. _it_volatile_considered_harmful: | ||
7 | |||
8 | Perché la parola chiave "volatile" non dovrebbe essere usata | ||
9 | ------------------------------------------------------------ | ||
10 | |||
11 | Spesso i programmatori C considerano volatili quelle variabili che potrebbero | ||
12 | essere cambiate al di fuori dal thread di esecuzione corrente; come risultato, | ||
13 | a volte saranno tentati dall'utilizzare *volatile* nel kernel per le | ||
14 | strutture dati condivise. In altre parole, gli è stato insegnato ad usare | ||
15 | *volatile* come una variabile atomica di facile utilizzo, ma non è così. | ||
16 | L'uso di *volatile* nel kernel non è quasi mai corretto; questo documento ne | ||
17 | descrive le ragioni. | ||
18 | |||
19 | Il punto chiave da capire su *volatile* è che il suo scopo è quello di | ||
20 | sopprimere le ottimizzazioni, che non è quasi mai quello che si vuole. | ||
21 | Nel kernel si devono proteggere le strutture dati condivise contro accessi | ||
22 | concorrenti e indesiderati: questa è un'attività completamente diversa. | ||
23 | Il processo di protezione contro gli accessi concorrenti indesiderati eviterà | ||
24 | anche la maggior parte dei problemi relativi all'ottimizzazione in modo più | ||
25 | efficiente. | ||
26 | |||
27 | Come *volatile*, le primitive del kernel che rendono sicuro l'accesso ai dati | ||
28 | (spinlock, mutex, barriere di sincronizzazione, ecc) sono progettate per | ||
29 | prevenire le ottimizzazioni indesiderate. Se vengono usate opportunamente, | ||
30 | non ci sarà bisogno di utilizzare *volatile*. Se vi sembra che *volatile* sia | ||
31 | comunque necessario, ci dev'essere quasi sicuramente un baco da qualche parte. | ||
32 | In un pezzo di codice kernel scritto a dovere, *volatile* può solo servire a | ||
33 | rallentare le cose. | ||
34 | |||
35 | Considerate questo tipico blocco di codice kernel:: | ||
36 | |||
37 | spin_lock(&the_lock); | ||
38 | do_something_on(&shared_data); | ||
39 | do_something_else_with(&shared_data); | ||
40 | spin_unlock(&the_lock); | ||
41 | |||
42 | Se tutto il codice seguisse le regole di sincronizzazione, il valore di un | ||
43 | dato condiviso non potrebbe cambiare inaspettatamente mentre si trattiene un | ||
44 | lock. Un qualsiasi altro blocco di codice che vorrà usare quel dato rimarrà | ||
45 | in attesa del lock. Gli spinlock agiscono come barriere di sincronizzazione | ||
46 | - sono stati esplicitamente scritti per agire così - il che significa che gli | ||
47 | accessi al dato condiviso non saranno ottimizzati. Quindi il compilatore | ||
48 | potrebbe pensare di sapere cosa ci sarà nel dato condiviso ma la chiamata | ||
49 | spin_lock(), che agisce come una barriera di sincronizzazione, gli imporrà di | ||
50 | dimenticarsi tutto ciò che sapeva su di esso. | ||
51 | |||
52 | Se il dato condiviso fosse stato dichiarato come *volatile*, la | ||
53 | sincronizzazione rimarrebbe comunque necessaria. Ma verrà impedito al | ||
54 | compilatore di ottimizzare gli accessi al dato anche _dentro_ alla sezione | ||
55 | critica, dove sappiamo che in realtà nessun altro può accedervi. Mentre si | ||
56 | trattiene un lock, il dato condiviso non è *volatile*. Quando si ha a che | ||
57 | fare con dei dati condivisi, un'opportuna sincronizzazione rende inutile | ||
58 | l'uso di *volatile* - anzi potenzialmente dannoso. | ||
59 | |||
60 | L'uso di *volatile* fu originalmente pensato per l'accesso ai registri di I/O | ||
61 | mappati in memoria. All'interno del kernel, l'accesso ai registri, dovrebbe | ||
62 | essere protetto dai lock, ma si potrebbe anche desiderare che il compilatore | ||
63 | non "ottimizzi" l'accesso ai registri all'interno di una sezione critica. | ||
64 | Ma, all'interno del kernel, l'accesso alla memoria di I/O viene sempre fatto | ||
65 | attraverso funzioni d'accesso; accedere alla memoria di I/O direttamente | ||
66 | con i puntatori è sconsigliato e non funziona su tutte le architetture. | ||
67 | Queste funzioni d'accesso sono scritte per evitare ottimizzazioni indesiderate, | ||
68 | quindi, di nuovo, *volatile* è inutile. | ||
69 | |||
70 | Un'altra situazione dove qualcuno potrebbe essere tentato dall'uso di | ||
71 | *volatile*, è nel caso in cui il processore è in un'attesa attiva sul valore | ||
72 | di una variabile. Il modo giusto di fare questo tipo di attesa è il seguente:: | ||
73 | |||
74 | while (my_variable != what_i_want) | ||
75 | cpu_relax(); | ||
76 | |||
77 | La chiamata cpu_relax() può ridurre il consumo di energia del processore | ||
78 | o cedere il passo ad un processore hyperthreaded gemello; funziona anche come | ||
79 | una barriera per il compilatore, quindi, ancora una volta, *volatile* non è | ||
80 | necessario. Ovviamente, tanto per puntualizzare, le attese attive sono | ||
81 | generalmente un atto antisociale. | ||
82 | |||
83 | Ci sono comunque alcune rare situazioni dove l'uso di *volatile* nel kernel | ||
84 | ha senso: | ||
85 | |||
86 | - Le funzioni d'accesso sopracitate potrebbero usare *volatile* su quelle | ||
87 | architetture che supportano l'accesso diretto alla memoria di I/O. | ||
88 | In pratica, ogni chiamata ad una funzione d'accesso diventa una piccola | ||
89 | sezione critica a se stante, e garantisce che l'accesso avvenga secondo | ||
90 | le aspettative del programmatore. | ||
91 | |||
92 | - I codice *inline assembly* che fa cambiamenti nella memoria, ma che non | ||
93 | ha altri effetti espliciti, rischia di essere rimosso da GCC. Aggiungere | ||
94 | la parola chiave *volatile* a questo codice ne previene la rimozione. | ||
95 | |||
96 | - La variabile jiffies è speciale in quanto assume un valore diverso ogni | ||
97 | volta che viene letta ma può essere lette senza alcuna sincronizzazione. | ||
98 | Quindi jiffies può essere *volatile*, ma l'aggiunta ad altre variabili di | ||
99 | questo è sconsigliata. Jiffies è considerata uno "stupido retaggio" | ||
100 | (parole di Linus) in questo contesto; correggerla non ne varrebbe la pena e | ||
101 | causerebbe più problemi. | ||
102 | |||
103 | - I puntatori a delle strutture dati in una memoria coerente che potrebbe | ||
104 | essere modificata da dispositivi di I/O può, a volte, essere legittimamente | ||
105 | *volatile*. Un esempio pratico può essere quello di un adattatore di rete | ||
106 | che utilizza un puntatore ad un buffer circolare, questo viene cambiato | ||
107 | dall'adattatore per indicare quali descrittori sono stati processati. | ||
108 | |||
109 | Per la maggior parte del codice, nessuna delle giustificazioni sopracitate può | ||
110 | essere considerata. Di conseguenza, l'uso di *volatile* è probabile che venga | ||
111 | visto come un baco e porterà a verifiche aggiuntive. Gli sviluppatori tentati | ||
112 | dall'uso di *volatile* dovrebbero fermarsi e pensare a cosa vogliono davvero | ||
113 | ottenere. | ||
114 | |||
115 | Le modifiche che rimuovono variabili *volatile* sono generalmente ben accette | ||
116 | - purché accompagnate da una giustificazione che dimostri che i problemi di | ||
117 | concorrenza siano stati opportunamente considerati. | ||
118 | |||
119 | Riferimenti | ||
120 | =========== | ||
121 | |||
122 | [1] http://lwn.net/Articles/233481/ | ||
123 | |||
124 | [2] http://lwn.net/Articles/233482/ | ||
125 | |||
126 | Crediti | ||
127 | ======= | ||
128 | |||
129 | Impulso e ricerca originale di Randy Dunlap | ||
130 | |||
131 | Scritto da Jonathan Corbet | ||
132 | |||
133 | Migliorato dai commenti di Satyam Sharma, Johannes Stezenbach, Jesper | ||
134 | Juhl, Heikki Orsila, H. Peter Anvin, Philipp Hahn, e Stefan Richter. | ||
diff --git a/Documentation/vm/index.rst b/Documentation/vm/index.rst index c4ded22197ca..2b3ab3a1ccf3 100644 --- a/Documentation/vm/index.rst +++ b/Documentation/vm/index.rst | |||
@@ -2,7 +2,9 @@ | |||
2 | Linux Memory Management Documentation | 2 | Linux Memory Management Documentation |
3 | ===================================== | 3 | ===================================== |
4 | 4 | ||
5 | This is a collection of documents about Linux memory management (mm) subsystem. | 5 | This is a collection of documents about the Linux memory management (mm) |
6 | subsystem. If you are looking for advice on simply allocating memory, | ||
7 | see the :ref:`memory-allocation`. | ||
6 | 8 | ||
7 | User guides for MM features | 9 | User guides for MM features |
8 | =========================== | 10 | =========================== |
diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt index 5e9b826b5f62..f4c2a97bfdbd 100644 --- a/Documentation/x86/boot.txt +++ b/Documentation/x86/boot.txt | |||
@@ -58,7 +58,7 @@ Protocol 2.11: (Kernel 3.6) Added a field for offset of EFI handover | |||
58 | protocol entry point. | 58 | protocol entry point. |
59 | 59 | ||
60 | Protocol 2.12: (Kernel 3.8) Added the xloadflags field and extension fields | 60 | Protocol 2.12: (Kernel 3.8) Added the xloadflags field and extension fields |
61 | to struct boot_params for loading bzImage and ramdisk | 61 | to struct boot_params for loading bzImage and ramdisk |
62 | above 4G in 64bit. | 62 | above 4G in 64bit. |
63 | 63 | ||
64 | **** MEMORY LAYOUT | 64 | **** MEMORY LAYOUT |
diff --git a/include/linux/slab.h b/include/linux/slab.h index 6d9bd6fc0c57..11b45f7ae405 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -486,48 +486,47 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags) | |||
486 | * kmalloc is the normal method of allocating memory | 486 | * kmalloc is the normal method of allocating memory |
487 | * for objects smaller than page size in the kernel. | 487 | * for objects smaller than page size in the kernel. |
488 | * | 488 | * |
489 | * The @flags argument may be one of: | 489 | * The @flags argument may be one of the GFP flags defined at |
490 | * include/linux/gfp.h and described at | ||
491 | * :ref:`Documentation/core-api/mm-api.rst <mm-api-gfp-flags>` | ||
490 | * | 492 | * |
491 | * %GFP_USER - Allocate memory on behalf of user. May sleep. | 493 | * The recommended usage of the @flags is described at |
494 | * :ref:`Documentation/core-api/memory-allocation.rst <memory-allocation>` | ||
492 | * | 495 | * |
493 | * %GFP_KERNEL - Allocate normal kernel ram. May sleep. | 496 | * Below is a brief outline of the most useful GFP flags |
494 | * | 497 | * |
495 | * %GFP_ATOMIC - Allocation will not sleep. May use emergency pools. | 498 | * %GFP_KERNEL |
496 | * For example, use this inside interrupt handlers. | 499 | * Allocate normal kernel ram. May sleep. |
497 | * | 500 | * |
498 | * %GFP_HIGHUSER - Allocate pages from high memory. | 501 | * %GFP_NOWAIT |
502 | * Allocation will not sleep. | ||
499 | * | 503 | * |
500 | * %GFP_NOIO - Do not do any I/O at all while trying to get memory. | 504 | * %GFP_ATOMIC |
505 | * Allocation will not sleep. May use emergency pools. | ||
501 | * | 506 | * |
502 | * %GFP_NOFS - Do not make any fs calls while trying to get memory. | 507 | * %GFP_HIGHUSER |
503 | * | 508 | * Allocate memory from high memory on behalf of user. |
504 | * %GFP_NOWAIT - Allocation will not sleep. | ||
505 | * | ||
506 | * %__GFP_THISNODE - Allocate node-local memory only. | ||
507 | * | ||
508 | * %GFP_DMA - Allocation suitable for DMA. | ||
509 | * Should only be used for kmalloc() caches. Otherwise, use a | ||
510 | * slab created with SLAB_DMA. | ||
511 | * | 509 | * |
512 | * Also it is possible to set different flags by OR'ing | 510 | * Also it is possible to set different flags by OR'ing |
513 | * in one or more of the following additional @flags: | 511 | * in one or more of the following additional @flags: |
514 | * | 512 | * |
515 | * %__GFP_HIGH - This allocation has high priority and may use emergency pools. | 513 | * %__GFP_HIGH |
516 | * | 514 | * This allocation has high priority and may use emergency pools. |
517 | * %__GFP_NOFAIL - Indicate that this allocation is in no way allowed to fail | ||
518 | * (think twice before using). | ||
519 | * | 515 | * |
520 | * %__GFP_NORETRY - If memory is not immediately available, | 516 | * %__GFP_NOFAIL |
521 | * then give up at once. | 517 | * Indicate that this allocation is in no way allowed to fail |
518 | * (think twice before using). | ||
522 | * | 519 | * |
523 | * %__GFP_NOWARN - If allocation fails, don't issue any warnings. | 520 | * %__GFP_NORETRY |
521 | * If memory is not immediately available, | ||
522 | * then give up at once. | ||
524 | * | 523 | * |
525 | * %__GFP_RETRY_MAYFAIL - Try really hard to succeed the allocation but fail | 524 | * %__GFP_NOWARN |
526 | * eventually. | 525 | * If allocation fails, don't issue any warnings. |
527 | * | 526 | * |
528 | * There are other flags available as well, but these are not intended | 527 | * %__GFP_RETRY_MAYFAIL |
529 | * for general use, and so are not documented here. For a full list of | 528 | * Try really hard to succeed the allocation but fail |
530 | * potential flags, always refer to linux/gfp.h. | 529 | * eventually. |
531 | */ | 530 | */ |
532 | static __always_inline void *kmalloc(size_t size, gfp_t flags) | 531 | static __always_inline void *kmalloc(size_t size, gfp_t flags) |
533 | { | 532 | { |
diff --git a/mm/slab_common.c b/mm/slab_common.c index 70b0cc85db67..81732d05e74a 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -406,8 +406,9 @@ out_free_cache: | |||
406 | goto out; | 406 | goto out; |
407 | } | 407 | } |
408 | 408 | ||
409 | /* | 409 | /** |
410 | * kmem_cache_create_usercopy - Create a cache. | 410 | * kmem_cache_create_usercopy - Create a cache with a region suitable |
411 | * for copying to userspace | ||
411 | * @name: A string which is used in /proc/slabinfo to identify this cache. | 412 | * @name: A string which is used in /proc/slabinfo to identify this cache. |
412 | * @size: The size of objects to be created in this cache. | 413 | * @size: The size of objects to be created in this cache. |
413 | * @align: The required alignment for the objects. | 414 | * @align: The required alignment for the objects. |
@@ -416,7 +417,6 @@ out_free_cache: | |||
416 | * @usersize: Usercopy region size | 417 | * @usersize: Usercopy region size |
417 | * @ctor: A constructor for the objects. | 418 | * @ctor: A constructor for the objects. |
418 | * | 419 | * |
419 | * Returns a ptr to the cache on success, NULL on failure. | ||
420 | * Cannot be called within a interrupt, but can be interrupted. | 420 | * Cannot be called within a interrupt, but can be interrupted. |
421 | * The @ctor is run when new pages are allocated by the cache. | 421 | * The @ctor is run when new pages are allocated by the cache. |
422 | * | 422 | * |
@@ -425,12 +425,14 @@ out_free_cache: | |||
425 | * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) | 425 | * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) |
426 | * to catch references to uninitialised memory. | 426 | * to catch references to uninitialised memory. |
427 | * | 427 | * |
428 | * %SLAB_RED_ZONE - Insert `Red' zones around the allocated memory to check | 428 | * %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check |
429 | * for buffer overruns. | 429 | * for buffer overruns. |
430 | * | 430 | * |
431 | * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware | 431 | * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware |
432 | * cacheline. This can be beneficial if you're counting cycles as closely | 432 | * cacheline. This can be beneficial if you're counting cycles as closely |
433 | * as davem. | 433 | * as davem. |
434 | * | ||
435 | * Return: a pointer to the cache on success, NULL on failure. | ||
434 | */ | 436 | */ |
435 | struct kmem_cache * | 437 | struct kmem_cache * |
436 | kmem_cache_create_usercopy(const char *name, | 438 | kmem_cache_create_usercopy(const char *name, |
@@ -514,6 +516,31 @@ out_unlock: | |||
514 | } | 516 | } |
515 | EXPORT_SYMBOL(kmem_cache_create_usercopy); | 517 | EXPORT_SYMBOL(kmem_cache_create_usercopy); |
516 | 518 | ||
519 | /** | ||
520 | * kmem_cache_create - Create a cache. | ||
521 | * @name: A string which is used in /proc/slabinfo to identify this cache. | ||
522 | * @size: The size of objects to be created in this cache. | ||
523 | * @align: The required alignment for the objects. | ||
524 | * @flags: SLAB flags | ||
525 | * @ctor: A constructor for the objects. | ||
526 | * | ||
527 | * Cannot be called within a interrupt, but can be interrupted. | ||
528 | * The @ctor is run when new pages are allocated by the cache. | ||
529 | * | ||
530 | * The flags are | ||
531 | * | ||
532 | * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) | ||
533 | * to catch references to uninitialised memory. | ||
534 | * | ||
535 | * %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check | ||
536 | * for buffer overruns. | ||
537 | * | ||
538 | * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware | ||
539 | * cacheline. This can be beneficial if you're counting cycles as closely | ||
540 | * as davem. | ||
541 | * | ||
542 | * Return: a pointer to the cache on success, NULL on failure. | ||
543 | */ | ||
517 | struct kmem_cache * | 544 | struct kmem_cache * |
518 | kmem_cache_create(const char *name, unsigned int size, unsigned int align, | 545 | kmem_cache_create(const char *name, unsigned int size, unsigned int align, |
519 | slab_flags_t flags, void (*ctor)(void *)) | 546 | slab_flags_t flags, void (*ctor)(void *)) |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index ffbe901a37b5..c5333d251985 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -212,7 +212,7 @@ my $anon_struct_union = 0; | |||
212 | my $type_constant = '\b``([^\`]+)``\b'; | 212 | my $type_constant = '\b``([^\`]+)``\b'; |
213 | my $type_constant2 = '\%([-_\w]+)'; | 213 | my $type_constant2 = '\%([-_\w]+)'; |
214 | my $type_func = '(\w+)\(\)'; | 214 | my $type_func = '(\w+)\(\)'; |
215 | my $type_param = '\@(\w*(\.\w+)*(\.\.\.)?)'; | 215 | my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)'; |
216 | my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params | 216 | my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params |
217 | my $type_env = '(\$\w+)'; | 217 | my $type_env = '(\$\w+)'; |
218 | my $type_enum = '\&(enum\s*([_\w]+))'; | 218 | my $type_enum = '\&(enum\s*([_\w]+))'; |
@@ -361,7 +361,7 @@ my $doc_com = '\s*\*\s*'; | |||
361 | my $doc_com_body = '\s*\* ?'; | 361 | my $doc_com_body = '\s*\* ?'; |
362 | my $doc_decl = $doc_com . '(\w+)'; | 362 | my $doc_decl = $doc_com . '(\w+)'; |
363 | # @params and a strictly limited set of supported section names | 363 | # @params and a strictly limited set of supported section names |
364 | my $doc_sect = $doc_com . | 364 | my $doc_sect = $doc_com . |
365 | '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)'; | 365 | '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)'; |
366 | my $doc_content = $doc_com_body . '(.*)'; | 366 | my $doc_content = $doc_com_body . '(.*)'; |
367 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; | 367 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; |
@@ -751,7 +751,7 @@ sub output_blockhead_rst(%) { | |||
751 | 751 | ||
752 | # | 752 | # |
753 | # Apply the RST highlights to a sub-block of text. | 753 | # Apply the RST highlights to a sub-block of text. |
754 | # | 754 | # |
755 | sub highlight_block($) { | 755 | sub highlight_block($) { |
756 | # The dohighlight kludge requires the text be called $contents | 756 | # The dohighlight kludge requires the text be called $contents |
757 | my $contents = shift; | 757 | my $contents = shift; |
@@ -1062,7 +1062,7 @@ sub dump_struct($$) { | |||
1062 | my $x = shift; | 1062 | my $x = shift; |
1063 | my $file = shift; | 1063 | my $file = shift; |
1064 | 1064 | ||
1065 | if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) { | 1065 | if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) { |
1066 | my $decl_type = $1; | 1066 | my $decl_type = $1; |
1067 | $declaration_name = $2; | 1067 | $declaration_name = $2; |
1068 | my $members = $3; | 1068 | my $members = $3; |
@@ -1073,8 +1073,9 @@ sub dump_struct($$) { | |||
1073 | # strip comments: | 1073 | # strip comments: |
1074 | $members =~ s/\/\*.*?\*\///gos; | 1074 | $members =~ s/\/\*.*?\*\///gos; |
1075 | # strip attributes | 1075 | # strip attributes |
1076 | $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i; | 1076 | $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)//gi; |
1077 | $members =~ s/__aligned\s*\([^;]*\)//gos; | 1077 | $members =~ s/\s*__aligned\s*\([^;]*\)//gos; |
1078 | $members =~ s/\s*__packed\s*//gos; | ||
1078 | $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos; | 1079 | $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos; |
1079 | # replace DECLARE_BITMAP | 1080 | # replace DECLARE_BITMAP |
1080 | $members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos; | 1081 | $members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos; |