summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-29 14:21:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-29 14:21:49 -0500
commit3868772b99e3146d02cf47e739d79022eba1d77c (patch)
treed32c0283496e6955937b618981766b5f0878724f
parent6f9d71c9c759b1e7d31189a4de228983192c7dc7 (diff)
parent942104a21ce4951420ddf6c6b3179a0627301f7e (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 ...
-rw-r--r--Documentation/EDID/1024x768.S5
-rw-r--r--Documentation/EDID/1280x1024.S5
-rw-r--r--Documentation/EDID/1600x1200.S5
-rw-r--r--Documentation/EDID/1680x1050.S5
-rw-r--r--Documentation/EDID/1920x1080.S5
-rw-r--r--Documentation/EDID/800x600.S5
-rw-r--r--Documentation/EDID/HOWTO.txt13
-rw-r--r--Documentation/EDID/Makefile15
-rw-r--r--Documentation/EDID/edid.S10
-rw-r--r--Documentation/admin-guide/devices.rst1
-rw-r--r--Documentation/admin-guide/dynamic-debug-howto.rst8
-rw-r--r--Documentation/admin-guide/index.rst1
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt2
-rw-r--r--Documentation/admin-guide/mm/concepts.rst51
-rw-r--r--Documentation/admin-guide/perf-security.rst97
-rw-r--r--Documentation/admin-guide/ras.rst2
-rw-r--r--Documentation/admin-guide/security-bugs.rst2
-rw-r--r--Documentation/arm/Booting2
-rw-r--r--Documentation/arm/Samsung-S3C24XX/GPIO.txt2
-rw-r--r--Documentation/arm/Samsung-S3C24XX/Overview.txt2
-rw-r--r--Documentation/arm/Samsung-S3C24XX/Suspend.txt2
-rw-r--r--Documentation/core-api/assoc_array.rst6
-rw-r--r--Documentation/core-api/memory-allocation.rst2
-rw-r--r--Documentation/core-api/mm-api.rst32
-rw-r--r--Documentation/dev-tools/coccinelle.rst2
-rw-r--r--Documentation/dev-tools/index.rst4
-rw-r--r--Documentation/dev-tools/kselftest.rst12
-rw-r--r--Documentation/device-mapper/dm-raid.txt2
-rw-r--r--Documentation/devicetree/bindings/arm/idle-states.txt2
-rw-r--r--Documentation/devicetree/bindings/pci/host-generic-pci.txt2
-rw-r--r--Documentation/devicetree/bindings/serial/rs485.txt2
-rw-r--r--Documentation/doc-guide/kernel-doc.rst2
-rw-r--r--Documentation/doc-guide/sphinx.rst2
-rw-r--r--Documentation/driver-api/dmaengine/dmatest.rst4
-rw-r--r--Documentation/driver-api/pm/devices.rst2
-rw-r--r--Documentation/driver-model/devres.txt7
-rw-r--r--Documentation/early-userspace/README2
-rw-r--r--Documentation/filesystems/caching/backend-api.txt2
-rw-r--r--Documentation/filesystems/caching/cachefiles.txt4
-rw-r--r--Documentation/filesystems/caching/netfs-api.txt2
-rw-r--r--Documentation/filesystems/caching/operations.txt2
-rw-r--r--Documentation/filesystems/configfs/configfs.txt2
-rw-r--r--Documentation/filesystems/index.rst21
-rw-r--r--Documentation/filesystems/path-lookup.rst (renamed from Documentation/filesystems/path-lookup.md)913
-rw-r--r--Documentation/filesystems/proc.txt13
-rw-r--r--Documentation/filesystems/qnx6.txt4
-rw-r--r--Documentation/filesystems/spufs.txt2
-rw-r--r--Documentation/filesystems/vfs.txt2
-rw-r--r--Documentation/filesystems/xfs-self-describing-metadata.txt2
-rw-r--r--Documentation/filesystems/xfs.txt2
-rw-r--r--Documentation/gpu/drm-uapi.rst4
-rw-r--r--Documentation/leds/leds-class.txt2
-rw-r--r--Documentation/media/uapi/v4l/extended-controls.rst2
-rw-r--r--Documentation/memory-barriers.txt22
-rw-r--r--Documentation/networking/device_drivers/dec/de4x5.txt2
-rw-r--r--Documentation/networking/rxrpc.txt10
-rw-r--r--Documentation/power/regulator/overview.txt2
-rw-r--r--Documentation/process/1.Intro.rst2
-rw-r--r--Documentation/process/4.Coding.rst3
-rw-r--r--Documentation/process/5.Posting.rst23
-rw-r--r--Documentation/process/8.Conclusion.rst7
-rw-r--r--Documentation/process/adding-syscalls.rst3
-rw-r--r--Documentation/process/changes.rst2
-rw-r--r--Documentation/process/coding-style.rst2
-rw-r--r--Documentation/process/howto.rst13
-rw-r--r--Documentation/process/kernel-driver-statement.rst2
-rw-r--r--Documentation/process/kernel-enforcement-statement.rst4
-rw-r--r--Documentation/process/magic-number.rst2
-rw-r--r--Documentation/process/management-style.rst5
-rw-r--r--Documentation/process/submitting-drivers.rst8
-rw-r--r--Documentation/s390/3270.ChangeLog2
-rw-r--r--Documentation/security/credentials.rst8
-rw-r--r--Documentation/security/keys/request-key.rst2
-rw-r--r--Documentation/serial/serial-rs485.txt2
-rw-r--r--Documentation/sound/soc/dai.rst6
-rw-r--r--Documentation/sound/soc/dpcm.rst2
-rw-r--r--Documentation/static-keys.txt2
-rw-r--r--Documentation/thermal/power_allocator.txt2
-rw-r--r--Documentation/trace/ftrace.rst14
-rw-r--r--Documentation/translations/it_IT/admin-guide/README.rst12
-rw-r--r--Documentation/translations/it_IT/admin-guide/security-bugs.rst12
-rw-r--r--Documentation/translations/it_IT/doc-guide/kernel-doc.rst2
-rw-r--r--Documentation/translations/it_IT/index.rst1
-rw-r--r--Documentation/translations/it_IT/kernel-hacking/locking.rst4
-rw-r--r--Documentation/translations/it_IT/process/1.Intro.rst297
-rw-r--r--Documentation/translations/it_IT/process/2.Process.rst531
-rw-r--r--Documentation/translations/it_IT/process/3.Early-stage.rst241
-rw-r--r--Documentation/translations/it_IT/process/4.Coding.rst447
-rw-r--r--Documentation/translations/it_IT/process/5.Posting.rst348
-rw-r--r--Documentation/translations/it_IT/process/6.Followthrough.rst240
-rw-r--r--Documentation/translations/it_IT/process/7.AdvancedTopics.rst191
-rw-r--r--Documentation/translations/it_IT/process/8.Conclusion.rst85
-rw-r--r--Documentation/translations/it_IT/process/adding-syscalls.rst643
-rw-r--r--Documentation/translations/it_IT/process/applying-patches.rst13
-rw-r--r--Documentation/translations/it_IT/process/changes.rst12
-rw-r--r--Documentation/translations/it_IT/process/clang-format.rst197
-rw-r--r--Documentation/translations/it_IT/process/code-of-conduct.rst12
-rw-r--r--Documentation/translations/it_IT/process/coding-style.rst1094
-rw-r--r--Documentation/translations/it_IT/process/development-process.rst33
-rw-r--r--Documentation/translations/it_IT/process/email-clients.rst12
-rw-r--r--Documentation/translations/it_IT/process/howto.rst655
-rw-r--r--Documentation/translations/it_IT/process/index.rst67
-rw-r--r--Documentation/translations/it_IT/process/kernel-docs.rst13
-rw-r--r--Documentation/translations/it_IT/process/kernel-driver-statement.rst211
-rw-r--r--Documentation/translations/it_IT/process/kernel-enforcement-statement.rst13
-rw-r--r--Documentation/translations/it_IT/process/magic-number.rst170
-rw-r--r--Documentation/translations/it_IT/process/maintainer-pgp-guide.rst13
-rw-r--r--Documentation/translations/it_IT/process/management-style.rst12
-rw-r--r--Documentation/translations/it_IT/process/stable-api-nonsense.rst13
-rw-r--r--Documentation/translations/it_IT/process/stable-kernel-rules.rst12
-rw-r--r--Documentation/translations/it_IT/process/submit-checklist.rst12
-rw-r--r--Documentation/translations/it_IT/process/submitting-drivers.rst12
-rw-r--r--Documentation/translations/it_IT/process/submitting-patches.rst13
-rw-r--r--Documentation/translations/it_IT/process/volatile-considered-harmful.rst134
-rw-r--r--Documentation/vm/index.rst4
-rw-r--r--Documentation/x86/boot.txt2
-rw-r--r--include/linux/slab.h55
-rw-r--r--mm/slab_common.c35
-rwxr-xr-xscripts/kernel-doc13
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
51The CRC value in the last line
52 #define CRC 0x55
53also is a bit tricky. After a first version of the binary data set is
54created, it must be checked with the "edid-decode" utility which will
55most probably complain about a wrong CRC. Fortunately, the utility also
56displays the correct CRC which must then be inserted into the source
57file. After the make procedure is repeated, the EDID data set is ready
58to 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)
200x_snc_off_lsb: .byte XOFFSET&0xff 202x_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) */
202x_snc_pls_lsb: .byte XPULSE&0xff 204x_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) */
205y_snc_lsb: .byte ((YOFFSET-63)<<4)+(YPULSE-63) 207y_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
2Linux allocated devices (4.x+ version) 3Linux 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
113A another way is to use wildcard. The match rule support ``*`` (matches 113Another way is to use wildcards. The match rule supports ``*`` (matches
114zero or more characters) and ``?`` (matches exactly one character).For 114zero or more characters) and ``?`` (matches exactly one character). For
115example, you can match all usb drivers:: 115example, 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
259If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at 259If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at
260boot time, without effect, but will be reprocessed when module is 260boot time, without effect, but will be reprocessed when module is
261loaded later. ``dyndbg_query=`` and bare ``dyndbg=`` are only processed at 261loaded later. ``ddebug_query=`` and bare ``dyndbg=`` are only processed at
262boot. 262boot.
263 263
264 264
@@ -301,7 +301,7 @@ The ``dyndbg`` option is a "fake" module parameter, which means:
301 301
302For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or 302For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or
303enabled by ``-DDEBUG`` flag during compilation) can be disabled later via 303enabled by ``-DDEBUG`` flag during compilation) can be disabled later via
304the sysfs interface if the debug messages are no longer needed:: 304the 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 @@
4Concepts overview 4Concepts overview
5================= 5=================
6 6
7The memory management in Linux is complex system that evolved over the 7The memory management in Linux is a complex system that evolved over the
8years and included more and more functionality to support variety of 8years and included more and more functionality to support a variety of
9systems from MMU-less microcontrollers to supercomputers. The memory 9systems from MMU-less microcontrollers to supercomputers. The memory
10management for systems without MMU is called ``nommu`` and it 10management for systems without an MMU is called ``nommu`` and it
11definitely deserves a dedicated document, which hopefully will be 11definitely deserves a dedicated document, which hopefully will be
12eventually written. Yet, although some of the concepts are the same, 12eventually written. Yet, although some of the concepts are the same,
13here we assume that MMU is available and CPU can translate a virtual 13here we assume that an MMU is available and a CPU can translate a virtual
14address to a physical address. 14address to a physical address.
15 15
16.. contents:: :local: 16.. contents:: :local:
@@ -21,10 +21,10 @@ Virtual Memory Primer
21The physical memory in a computer system is a limited resource and 21The physical memory in a computer system is a limited resource and
22even for systems that support memory hotplug there is a hard limit on 22even for systems that support memory hotplug there is a hard limit on
23the amount of memory that can be installed. The physical memory is not 23the amount of memory that can be installed. The physical memory is not
24necessary contiguous, it might be accessible as a set of distinct 24necessarily contiguous; it might be accessible as a set of distinct
25address ranges. Besides, different CPU architectures, and even 25address ranges. Besides, different CPU architectures, and even
26different implementations of the same architecture have different view 26different implementations of the same architecture have different views
27how these address ranges defined. 27of how these address ranges are defined.
28 28
29All this makes dealing directly with physical memory quite complex and 29All this makes dealing directly with physical memory quite complex and
30to avoid this complexity a concept of virtual memory was developed. 30to avoid this complexity a concept of virtual memory was developed.
@@ -48,8 +48,8 @@ appropriate kernel configuration option.
48 48
49Each physical memory page can be mapped as one or more virtual 49Each physical memory page can be mapped as one or more virtual
50pages. These mappings are described by page tables that allow 50pages. These mappings are described by page tables that allow
51translation from virtual address used by programs to real address in 51translation from a virtual address used by programs to the physical
52the physical memory. The page tables organized hierarchically. 52memory address. The page tables are organized hierarchically.
53 53
54The tables at the lowest level of the hierarchy contain physical 54The tables at the lowest level of the hierarchy contain physical
55addresses of actual pages used by the software. The tables at higher 55addresses of actual pages used by the software. The tables at higher
@@ -121,8 +121,8 @@ Nodes
121Many multi-processor machines are NUMA - Non-Uniform Memory Access - 121Many multi-processor machines are NUMA - Non-Uniform Memory Access -
122systems. In such systems the memory is arranged into banks that have 122systems. In such systems the memory is arranged into banks that have
123different access latency depending on the "distance" from the 123different access latency depending on the "distance" from the
124processor. Each bank is referred as `node` and for each node Linux 124processor. Each bank is referred to as a `node` and for each node Linux
125constructs an independent memory management subsystem. A node has it's 125constructs an independent memory management subsystem. A node has its
126own set of zones, lists of free and used pages and various statistics 126own set of zones, lists of free and used pages and various statistics
127counters. You can find more details about NUMA in 127counters. 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
149call. Usually, the anonymous mappings only define virtual memory areas 149call. Usually, the anonymous mappings only define virtual memory areas
150that the program is allowed to access. The read accesses will result 150that the program is allowed to access. The read accesses will result
151in creation of a page table entry that references a special physical 151in creation of a page table entry that references a special physical
152page filled with zeroes. When the program performs a write, regular 152page filled with zeroes. When the program performs a write, a regular
153physical page will be allocated to hold the written data. The page 153physical page will be allocated to hold the written data. The page
154will be marked dirty and if the kernel will decide to repurpose it, 154will be marked dirty and if the kernel decides to repurpose it,
155the dirty page will be swapped out. 155the dirty page will be swapped out.
156 156
157Reclaim 157Reclaim
@@ -181,8 +181,8 @@ pressure.
181The process of freeing the reclaimable physical memory pages and 181The process of freeing the reclaimable physical memory pages and
182repurposing them is called (surprise!) `reclaim`. Linux can reclaim 182repurposing them is called (surprise!) `reclaim`. Linux can reclaim
183pages either asynchronously or synchronously, depending on the state 183pages either asynchronously or synchronously, depending on the state
184of the system. When system is not loaded, most of the memory is free 184of the system. When the system is not loaded, most of the memory is free
185and allocation request will be satisfied immediately from the free 185and allocation requests will be satisfied immediately from the free
186pages supply. As the load increases, the amount of the free pages goes 186pages supply. As the load increases, the amount of the free pages goes
187down and when it reaches a certain threshold (high watermark), an 187down and when it reaches a certain threshold (high watermark), an
188allocation request will awaken the ``kswapd`` daemon. It will 188allocation request will awaken the ``kswapd`` daemon. It will
@@ -190,7 +190,7 @@ asynchronously scan memory pages and either just free them if the data
190they contain is available elsewhere, or evict to the backing storage 190they contain is available elsewhere, or evict to the backing storage
191device (remember those dirty pages?). As memory usage increases even 191device (remember those dirty pages?). As memory usage increases even
192more and reaches another threshold - min watermark - an allocation 192more and reaches another threshold - min watermark - an allocation
193will trigger the `direct reclaim`. In this case allocation is stalled 193will trigger `direct reclaim`. In this case allocation is stalled
194until enough memory pages are reclaimed to satisfy the request. 194until enough memory pages are reclaimed to satisfy the request.
195 195
196Compaction 196Compaction
@@ -200,7 +200,7 @@ As the system runs, tasks allocate and free the memory and it becomes
200fragmented. Although with virtual memory it is possible to present 200fragmented. Although with virtual memory it is possible to present
201scattered physical pages as virtually contiguous range, sometimes it is 201scattered physical pages as virtually contiguous range, sometimes it is
202necessary to allocate large physically contiguous memory areas. Such 202necessary to allocate large physically contiguous memory areas. Such
203need may arise, for instance, when a device driver requires large 203need may arise, for instance, when a device driver requires a large
204buffer for DMA, or when THP allocates a huge page. Memory `compaction` 204buffer for DMA, or when THP allocates a huge page. Memory `compaction`
205addresses the fragmentation issue. This mechanism moves occupied pages 205addresses the fragmentation issue. This mechanism moves occupied pages
206from the lower part of a memory zone to free pages in the upper part 206from 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
208together at the beginning of the zone and allocations of large 208together at the beginning of the zone and allocations of large
209physically contiguous areas become possible. 209physically contiguous areas become possible.
210 210
211Like reclaim, the compaction may happen asynchronously in ``kcompactd`` 211Like reclaim, the compaction may happen asynchronously in the ``kcompactd``
212daemon or synchronously as a result of memory allocation request. 212daemon or synchronously as a result of a memory allocation request.
213 213
214OOM killer 214OOM killer
215========== 215==========
216 216
217It may happen, that on a loaded machine memory will be exhausted. When 217It is possible that on a loaded machine memory will be exhausted and the
218the kernel detects that the system runs out of memory (OOM) it invokes 218kernel 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 219order to save the rest of the system, it invokes the `OOM killer`.
220task to sacrifice for the sake of the overall system health. The 220
221selected task is killed in a hope that after it exits enough memory 221The `OOM killer` selects a task to sacrifice for the sake of the overall
222will be freed to continue normal operation. 222system health. The selected task is killed in a hope that after it exits
223enough 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
3Perf Events and tool security
4=============================
5
6Overview
7--------
8
9Usage of Performance Counters for Linux (perf_events) [1]_ , [2]_ , [3]_ can
10impose a considerable risk of leaking sensitive data accessed by monitored
11processes. The data leakage is possible both in scenarios of direct usage of
12perf_events system call API [2]_ and over data files generated by Perf tool user
13mode utility (Perf) [3]_ , [4]_ . The risk depends on the nature of data that
14perf_events performance monitoring units (PMU) [2]_ collect and expose for
15performance analysis. Having that said perf_events/Perf performance monitoring
16is the subject for security access control management [5]_ .
17
18perf_events/Perf access control
19-------------------------------
20
21To perform security checks, the Linux implementation splits processes into two
22categories [6]_ : a) privileged processes (whose effective user ID is 0, referred
23to as superuser or root), and b) unprivileged processes (whose effective UID is
24nonzero). Privileged processes bypass all kernel security permission checks so
25perf_events performance monitoring is fully available to privileged processes
26without access, scope and resource restrictions.
27
28Unprivileged processes are subject to a full security permission check based on
29the process's credentials [5]_ (usually: effective UID, effective GID, and
30supplementary group list).
31
32Linux divides the privileges traditionally associated with superuser into
33distinct units, known as capabilities [6]_ , which can be independently enabled
34and disabled on per-thread basis for processes and files of unprivileged users.
35
36Unprivileged processes with enabled CAP_SYS_ADMIN capability are treated as
37privileged processes with respect to perf_events performance monitoring and
38bypass *scope* permissions checks in the kernel.
39
40Unprivileged processes using perf_events system call API is also subject for
41PTRACE_MODE_READ_REALCREDS ptrace access mode check [7]_ , whose outcome
42determines whether monitoring is permitted. So unprivileged processes provided
43with CAP_SYS_PTRACE capability are effectively permitted to pass the check.
44
45Other capabilities being granted to unprivileged processes can effectively
46enable capturing of additional data required for later performance analysis of
47monitored processes or a system. For example, CAP_SYSLOG capability permits
48reading kernel space memory addresses from /proc/kallsyms file.
49
50perf_events/Perf unprivileged users
51-----------------------------------
52
53perf_events/Perf *scope* and *access* control for unprivileged processes is
54governed 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
87Bibliography
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.
54Types of errors 54Types of errors
55--------------- 55---------------
56 56
57Most mechanisms used on modern systems use use technologies like Hamming 57Most mechanisms used on modern systems use technologies like Hamming
58Codes that allow error correction when the number of errors on a bit packet 58Codes that allow error correction when the number of errors on a bit packet
59is below a threshold. If the number of errors is above, those mechanisms 59is below a threshold. If the number of errors is above, those mechanisms
60can indicate with a high degree of confidence that an error happened, but 60can 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
44the logistics of QA and large scale rollouts which require release 44the logistics of QA and large scale rollouts which require release
45coordination. 45coordination.
46 46
47Whilst embargoed information may be shared with trusted individuals in 47While embargoed information may be shared with trusted individuals in
48order to develop a fix, such information will not be published alongside 48order to develop a fix, such information will not be published alongside
49the fix or on any other disclosure channel without the permission of the 49the fix or on any other disclosure channel without the permission of the
50reporter. This includes but is not limited to the original bug report 50reporter. 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.
126The boot loader must pass at a minimum the size and location of the 126The boot loader must pass at a minimum the size and location of the
127system memory, and the root filesystem location. The dtb must be 127system memory, and the root filesystem location. The dtb must be
128placed in a region of memory where the kernel decompressor will not 128placed in a region of memory where the kernel decompressor will not
129overwrite it, whilst remaining within the region which will be covered 129overwrite it, while remaining within the region which will be covered
130by the kernel's low-memory mapping. 130by the kernel's low-memory mapping.
131 131
132A safe location is just above the 128MiB boundary from start of RAM. 132A 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
583) s3c2410_gpio_pullup() changes have the problem that whilst the 583) 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:
348. The array can iterated over. The objects will not necessarily come out in 348. The array can iterated over. The objects will not necessarily come out in
35 key order. 35 key order.
36 36
379. The array can be iterated over whilst it is being modified, provided the 379. 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
4310. Objects in the array can be looked up by means of their index key. 4310. Objects in the array can be looked up by means of their index key.
44 44
4511. Objects can be looked up whilst the array is being modified, provided the 4511. 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
48The implementation uses a tree of 16-pointer nodes internally that are indexed 48The 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
273enough memory. 273enough memory.
274 274
275It is possible for other threads to iterate over or search the array under 275It is possible for other threads to iterate over or search the array under
276the RCU read lock whilst this function is in progress. The caller should 276the RCU read lock while this function is in progress. The caller should
277lock exclusively against other modifiers of the array. 277lock 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=======================
2Memory Allocation Guide 4Memory 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
52More Memory Management Functions 55Virtually Contiguous Mappings
53================================ 56=============================
57
58.. kernel-doc:: mm/vmalloc.c
59 :export:
60
61File 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 76Memory pools
68 :internal: 77============
69 78
70.. kernel-doc:: mm/mempool.c 79.. kernel-doc:: mm/mempool.c
71 :export: 80 :export:
72 81
82DMA 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 88More 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
7Coccinelle 9Coccinelle
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
5This document is a collection of documents about development tools that can 5This document is a collection of documents about development tools that can
6be used to work on the kernel. For now, the documents have been pulled 6be used to work on the kernel. For now, the documents have been pulled
7together without any significant effot to integrate them into a coherent 7together without any significant effort to integrate them into a coherent
8whole; patches welcome! 8whole; 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
10On some systems, hot-plug tests could hang forever waiting for cpu and 10On some systems, hot-plug tests could hang forever waiting for cpu and
11memory to be ready to be offlined. A special hot-plug target is created 11memory to be ready to be offlined. A special hot-plug target is created
12to run full range of hot-plug tests. In default mode, hot-plug tests run 12to run the full range of hot-plug tests. In default mode, hot-plug tests run
13in safe mode with a limited scope. In limited mode, cpu-hotplug test is 13in safe mode with a limited scope. In limited mode, cpu-hotplug test is
14run on a single cpu as opposed to all hotplug capable cpus, and memory 14run on a single cpu as opposed to all hotplug capable cpus, and memory
15hotplug test is run on 2% of hotplug capable memory instead of 10%. 15hotplug test is run on 2% of hotplug capable memory instead of 10%.
@@ -89,9 +89,9 @@ Note that some tests will require root privileges.
89Install selftests 89Install selftests
90================= 90=================
91 91
92You can use kselftest_install.sh tool installs selftests in default 92You can use the kselftest_install.sh tool to install selftests in the
93location which is tools/testing/selftests/kselftest or a user specified 93default location, which is tools/testing/selftests/kselftest, or in a
94location. 94user specified location.
95 95
96To install selftests in default location:: 96To install selftests in default location::
97 97
@@ -109,7 +109,7 @@ Running installed selftests
109Kselftest install as well as the Kselftest tarball provide a script 109Kselftest install as well as the Kselftest tarball provide a script
110named "run_kselftest.sh" to run the tests. 110named "run_kselftest.sh" to run the tests.
111 111
112You can simply do the following to run the installed Kselftests. Please 112You can simply do the following to run the installed Kselftests. Please
113note some tests will require root privileges:: 113note 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
143The graph is split in two parts delimited by time 1ms on the X-axis. 143The graph is split in two parts delimited by time 1ms on the X-axis.
144The graph curve with X-axis values = { x | 0 < x < 1ms } has a steep slope 144The graph curve with X-axis values = { x | 0 < x < 1ms } has a steep slope
145and denotes the energy costs incurred whilst entering and leaving the idle 145and denotes the energy costs incurred while entering and leaving the idle
146state. 146state.
147The graph curve in the area delimited by X-axis values = {x | x > 1ms } has 147The graph curve in the area delimited by X-axis values = {x | x > 1ms } has
148shallower slope and essentially represents the energy consumption of the idle 148shallower 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
59Whilst ECAM extends this by 4 bits to accommodate 4k of function space: 59While 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
21RS485 example for Atmel USART: 21RS485 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
1Introduction 3Introduction
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
14Part 1 - How to build the test module 18Part 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==============================
10Device Power Management Basics 12Device 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
132to better maintained higher layer. Also, as init failure path is 132to better maintained higher layer. Also, as init failure path is
133shared with exit path, both can get more testing. 133shared with exit path, both can get more testing.
134 134
135Note though that when converting current calls or assignments to
136managed devm_* versions it is up to you to check if internal operations
137like allocating memory, have failed. Managed resources pertains to the
138freeing of these resources *only* - all other checks needed are still
139on you. In some cases this may mean introducing checks that were not
140necessary 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
52to be mapped to group root (0). 52to be mapped to group root (0).
53 53
54A source file must be directives in the format required by the 54A source file must be directives in the format required by the
55usr/gen_init_cpio utility (run 'usr/gen_init_cpio --help' to get the 55usr/gen_init_cpio utility (run 'usr/gen_init_cpio -h' to get the
56file format). The directives in the file will be passed directly to 56file format). The directives in the file will be passed directly to
57usr/gen_init_cpio. 57usr/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
46CacheFiles creates a misc character device - "/dev/cachefiles" - that is used 46CacheFiles creates a misc character device - "/dev/cachefiles" - that is used
47to communication with the daemon. Only one thing may have this open at once, 47to communication with the daemon. Only one thing may have this open at once,
48and whilst it is open, a cache is at least partially in existence. The daemon 48and while it is open, a cache is at least partially in existence. The daemon
49opens this and sends commands down it to control the cache. 49opens this and sends commands down it to control the cache.
50 50
51CacheFiles is currently limited to a single cache. 51CacheFiles 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
163kernel module contains its own very cut-down path walking facility that ignores 163kernel module contains its own very cut-down path walking facility that ignores
164mountpoints, but the daemon can't avoid them. 164mountpoints, but the daemon can't avoid them.
165 165
166Do not create, rename or unlink files and directories in the cache whilst the 166Do not create, rename or unlink files and directories in the cache while the
167cache is active, as this may cause the state to become uncertain. 167cache is active, as this may cause the state to become uncertain.
168 168
169Renaming files in the cache might make objects appear to be other objects (the 169Renaming 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
382An optional step is to request an object of miscellaneous type be created in 382An optional step is to request an object of miscellaneous type be created in
383the cache. This is almost identical to index cookie acquisition. The only 383the cache. This is almost identical to index cookie acquisition. The only
384difference is that the type in the object definition should be something other 384difference is that the type in the object definition should be something other
385than index type. Whilst the parent object could be an index, it's more likely 385than index type. While the parent object could be an index, it's more likely
386it would be some other type of object such as a data file. 386it 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
363Pathname lookup
364===============
365
366
367This 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
373Written by Neil Brown with help from Al Viro and Jon Corbet.
374It has subsequently been updated to reflect changes in the kernel
375including:
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
5Pathname lookup in Linux. 2Introduction to pathname lookup
6========================= 3===============================
7
8This 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
14Written by Neil Brown with help from Al Viro and Jon Corbet.
15
16Introduction
17------------
18 4
19The most obvious aspect of pathname lookup, which very little 5The most obvious aspect of pathname lookup, which very little
20exploration is needed to discover, is that it is complex. There are 6exploration is needed to discover, is that it is complex. There are
@@ -32,58 +18,58 @@ distinctions we need to clarify first.
32There are two sorts of ... 18There 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
37Pathnames (sometimes "file names"), used to identify objects in the 23Pathnames (sometimes "file names"), used to identify objects in the
38filesystem, will be familiar to most readers. They contain two sorts 24filesystem, will be familiar to most readers. They contain two sorts
39of elements: "slashes" that are sequences of one or more "`/`" 25of elements: "slashes" that are sequences of one or more "``/``"
40characters, and "components" that are sequences of one or more 26characters, and "components" that are sequences of one or more
41non-"`/`" characters. These form two kinds of paths. Those that 27non-"``/``" characters. These form two kinds of paths. Those that
42start with slashes are "absolute" and start from the filesystem root. 28start with slashes are "absolute" and start from the filesystem root.
43The others are "relative" and start from the current directory, or 29The others are "relative" and start from the current directory, or
44from some other location specified by a file descriptor given to a 30from 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
49It is tempting to describe the second kind as starting with a 35It is tempting to describe the second kind as starting with a
50component, but that isn't always accurate: a pathname can lack both 36component, but that isn't always accurate: a pathname can lack both
51slashes and components, it can be empty, in other words. This is 37slashes and components, it can be empty, in other words. This is
52generally forbidden in POSIX, but some of those "xxx`at`" system calls 38generally forbidden in POSIX, but some of those "xxx``at``" system calls
53in Linux permit it when the `AT_EMPTY_PATH` flag is given. For 39in Linux permit it when the ``AT_EMPTY_PATH`` flag is given. For
54example, if you have an open file descriptor on an executable file you 40example, if you have an open file descriptor on an executable file you
55can execute it by calling [`execveat()`] passing the file descriptor, 41can execute it by calling `execveat() <execveat_>`_ passing
56an empty path, and the `AT_EMPTY_PATH` flag. 42the file descriptor, an empty path, and the ``AT_EMPTY_PATH`` flag.
57 43
58These paths can be divided into two sections: the final component and 44These paths can be divided into two sections: the final component and
59everything else. The "everything else" is the easy bit. In all cases 45everything else. The "everything else" is the easy bit. In all cases
60it must identify a directory that already exists, otherwise an error 46it must identify a directory that already exists, otherwise an error
61such as `ENOENT` or `ENOTDIR` will be reported. 47such as ``ENOENT`` or ``ENOTDIR`` will be reported.
62 48
63The final component is not so simple. Not only do different system 49The final component is not so simple. Not only do different system
64calls interpret it quite differently (e.g. some create it, some do 50calls interpret it quite differently (e.g. some create it, some do
65not), but it might not even exist: neither the empty pathname nor the 51not), but it might not even exist: neither the empty pathname nor the
66pathname that is just slashes have a final component. If it does 52pathname that is just slashes have a final component. If it does
67exist, it could be "`.`" or "`..`" which are handled quite differently 53exist, it could be "``.``" or "``..``" which are handled quite differently
68from other components. 54from 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
72If a pathname ends with a slash, such as "`/tmp/foo/`" it might be 58If a pathname ends with a slash, such as "``/tmp/foo/``" it might be
73tempting to consider that to have an empty final component. In many 59tempting to consider that to have an empty final component. In many
74ways that would lead to correct results, but not always. In 60ways that would lead to correct results, but not always. In
75particular, `mkdir()` and `rmdir()` each create or remove a directory named 61particular, ``mkdir()`` and ``rmdir()`` each create or remove a directory named
76by the final component, and they are required to work with pathnames 62by the final component, and they are required to work with pathnames
77ending in "`/`". According to [POSIX] 63ending in "``/``". According to POSIX_
78 64
79> A pathname that contains at least one non- &lt;slash> character and 65 A pathname that contains at least one non- &lt;slash> character and
80> that ends with one or more trailing &lt;slash> characters shall not 66 that ends with one or more trailing &lt;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
86The Linux pathname walking code (mostly in `fs/namei.c`) deals with 72The Linux pathname walking code (mostly in ``fs/namei.c``) deals with
87all of these issues: breaking the path into components, handling the 73all 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
89checking that the trailing slash is not used where it isn't 75checking 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
101pathname lookup. 87pathname lookup.
102 88
103More than just a cache. 89More than just a cache
104----------------------- 90----------------------
105 91
106The "dcache" caches information about names in each filesystem to 92The "dcache" caches information about names in each filesystem to
107make them quickly available for lookup. Each entry (known as a 93make 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
109pointer to a parent dentry, and a pointer to the "inode" which 95pointer to a parent dentry, and a pointer to the "inode" which
110contains further information about the object in that parent with 96contains further information about the object in that parent with
111the given name. The inode pointer can be `NULL` indicating that the 97the given name. The inode pointer can be ``NULL`` indicating that the
112name doesn't exist in the parent. While there can be linkage in the 98name doesn't exist in the parent. While there can be linkage in the
113dentry of a directory to the dentries of the children, that linkage is 99dentry of a directory to the dentries of the children, that linkage is
114not used for pathname lookup, and so will not be considered here. 100not 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
135like ocfs2 or cephfs. These filesystems allow the VFS to revalidate 121like ocfs2 or cephfs. These filesystems allow the VFS to revalidate
136cached information, and must provide their own protection against 122cached information, and must provide their own protection against
137awkward races. The VFS can detect these filesystems by the 123awkward 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
140REF-walk: simple concurrency management with refcounts and spinlocks 126REF-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
144looking at the actual process of walking along a path. In particular 130looking at the actual process of walking along a path. In particular
145we will start with the handling of the "everything else" part of a 131we will start with the handling of the "everything else" part of a
146pathname, and focus on the "REF-walk" approach to concurrency 132pathname, and focus on the "REF-walk" approach to concurrency
147management. This code is found in the `link_path_walk()` function, if 133management. This code is found in the ``link_path_walk()`` function, if
148you ignore all the places that only run when "`LOOKUP_RCU`" 134you 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
153REF-walk is fairly heavy-handed with locks and reference counts. Not 139REF-walk is fairly heavy-handed with locks and reference counts. Not
154as heavy-handed as in the old "big kernel lock" days, but certainly not 140as heavy-handed as in the old "big kernel lock" days, but certainly not
155afraid of taking a lock when one is needed. It uses a variety of 141afraid of taking a lock when one is needed. It uses a variety of
156different concurrency controls. A background understanding of the 142different concurrency controls. A background understanding of the
157various primitives is assumed, or can be gleaned from elsewhere such 143various primitives is assumed, or can be gleaned from elsewhere such
158as in [Meet the Lockers]. 144as in `Meet the Lockers`_.
159 145
160The locking mechanisms used by REF-walk include: 146The locking mechanisms used by REF-walk include:
161 147
162### dentry->d_lockref ### 148dentry->d_lockref
149~~~~~~~~~~~~~~~~~
163 150
164This uses the lockref primitive to provide both a spinlock and a 151This uses the lockref primitive to provide both a spinlock and a
165reference count. The special-sauce of this primitive is that the 152reference count. The special-sauce of this primitive is that the
@@ -168,49 +155,51 @@ with a single atomic memory operation.
168 155
169Holding a reference on a dentry ensures that the dentry won't suddenly 156Holding a reference on a dentry ensures that the dentry won't suddenly
170be freed and used for something else, so the values in various fields 157be freed and used for something else, so the values in various fields
171will behave as expected. It also protects the `->d_inode` reference 158will behave as expected. It also protects the ``->d_inode`` reference
172to the inode to some extent. 159to the inode to some extent.
173 160
174The association between a dentry and its inode is fairly permanent. 161The association between a dentry and its inode is fairly permanent.
175For example, when a file is renamed, the dentry and inode move 162For example, when a file is renamed, the dentry and inode move
176together to the new location. When a file is created the dentry will 163together to the new location. When a file is created the dentry will
177initially be negative (i.e. `d_inode` is `NULL`), and will be assigned 164initially be negative (i.e. ``d_inode`` is ``NULL``), and will be assigned
178to the new inode as part of the act of creation. 165to the new inode as part of the act of creation.
179 166
180When a file is deleted, this can be reflected in the cache either by 167When a file is deleted, this can be reflected in the cache either by
181setting `d_inode` to `NULL`, or by removing it from the hash table 168setting ``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.
183If the dentry is still in use the second option is used as it is 170If the dentry is still in use the second option is used as it is
184perfectly legal to keep using an open file after it has been deleted 171perfectly legal to keep using an open file after it has been deleted
185and having the dentry around helps. If the dentry is not otherwise in 172and having the dentry around helps. If the dentry is not otherwise in
186use (i.e. if the refcount in `d_lockref` is one), only then will 173use (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
188very common case. 175very common case.
189 176
190So as long as a counted reference is held to a dentry, a non-`NULL` `->d_inode` 177So as long as a counted reference is held to a dentry, a non-``NULL`` ``->d_inode``
191value will never be changed. 178value will never be changed.
192 179
193### dentry->d_lock ### 180dentry->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.
196For our purposes, holding this lock protects against the dentry being 184For our purposes, holding this lock protects against the dentry being
197renamed or unlinked. In particular, its parent (`d_parent`), and its 185renamed or unlinked. In particular, its parent (``d_parent``), and its
198name (`d_name`) cannot be changed, and it cannot be removed from the 186name (``d_name``) cannot be changed, and it cannot be removed from the
199dentry hash table. 187dentry hash table.
200 188
201When looking for a name in a directory, REF-walk takes `d_lock` on 189When looking for a name in a directory, REF-walk takes ``d_lock`` on
202each candidate dentry that it finds in the hash table and then checks 190each candidate dentry that it finds in the hash table and then checks
203that the parent and name are correct. So it doesn't lock the parent 191that the parent and name are correct. So it doesn't lock the parent
204while searching in the cache; it only locks children. 192while searching in the cache; it only locks children.
205 193
206When looking for the parent for a given name (to handle "`..`"), 194When looking for the parent for a given name (to handle "``..``"),
207REF-walk can take `d_lock` to get a stable reference to `d_parent`, 195REF-walk can take ``d_lock`` to get a stable reference to ``d_parent``,
208but it first tries a more lightweight approach. As seen in 196but 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
210subsequently `d_parent` can be seen to have not changed, then there is 198subsequently ``d_parent`` can be seen to have not changed, then there is
211no need to actually take the lock on the child. 199no need to actually take the lock on the child.
212 200
213### rename_lock ### 201rename_lock
202~~~~~~~~~~~
214 203
215Looking up a given name in a given directory involves computing a hash 204Looking up a given name in a given directory involves computing a hash
216from the two values (the name and the dentry of the directory), 205from 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,
224it might end up continuing the search down the wrong chain, 213it might end up continuing the search down the wrong chain,
225and so miss out on part of the correct chain. 214and so miss out on part of the correct chain.
226 215
227The name-lookup process (`d_lookup()`) does _not_ try to prevent this 216The name-lookup process (``d_lookup()``) does _not_ try to prevent this
228from happening, but only to detect when it happens. 217from 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
230renamed. If `d_lookup` finds that a rename happened while it 219renamed. If ``d_lookup`` finds that a rename happened while it
231unsuccessfully scanned a chain in the hash table, it simply tries 220unsuccessfully scanned a chain in the hash table, it simply tries
232again. 221again.
233 222
234### inode->i_mutex ### 223inode->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
237directory. This ensures that, for example, an `unlink()` and a `rename()` 227directory. This ensures that, for example, an ``unlink()`` and a ``rename()``
238cannot both happen at the same time. It also keeps the directory 228cannot both happen at the same time. It also keeps the directory
239stable while the filesystem is asked to look up a name that is not 229stable while the filesystem is asked to look up a name that is not
240currently in the dcache. 230currently in the dcache or, optionally, when the list of entries in a
231directory is being retrieved with ``readdir()``.
241 232
242This has a complementary role to that of `d_lock`: `i_mutex` on a 233This has a complementary role to that of ``d_lock``: ``i_rwsem`` on a
243directory protects all of the names in that directory, while `d_lock` 234directory protects all of the names in that directory, while ``d_lock``
244on a name protects just one name in a directory. Most changes to the 235on a name protects just one name in a directory. Most changes to the
245dcache hold `i_mutex` on the relevant directory inode and briefly take 236dcache 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
247exception is when idle dentries are removed from the dcache due to 238exception is when idle dentries are removed from the dcache due to
248memory pressure. This uses `d_lock`, but `i_mutex` plays no role. 239memory pressure. This uses ``d_lock``, but ``i_rwsem`` plays no role.
249 240
250The mutex affects pathname lookup in two distinct ways. Firstly it 241The semaphore affects pathname lookup in two distinct ways. Firstly it
251serializes lookup of a name in a directory. `walk_component()` uses 242prevents 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,
253using only `d_lock` locking. If the name isn't found, then `walk_component()` 244using only ``d_lock`` locking. If the name isn't found, then ``walk_component()``
254falls back to `lookup_slow()` which takes `i_mutex`, checks again that 245falls back to ``lookup_slow()`` which takes a shared lock on ``i_rwsem``, checks again that
255the name isn't in the cache, and then calls in to the filesystem to get a 246the name isn't in the cache, and then calls in to the filesystem to get a
256definitive answer. A new dentry will be added to the cache regardless of 247definitive answer. A new dentry will be added to the cache regardless of
257the result. 248the result.
258 249
259Secondly, when pathname lookup reaches the final component, it will 250Secondly, when pathname lookup reaches the final component, it will
260sometimes need to take `i_mutex` before performing the last lookup so 251sometimes need to take an exclusive lock on ``i_rwsem`` before performing the last lookup so
261that the required exclusion can be achieved. How path lookup chooses 252that the required exclusion can be achieved. How path lookup chooses
262to take, or not take, `i_mutex` is one of the 253to take, or not take, ``i_rwsem`` is one of the
263issues addressed in a subsequent section. 254issues addressed in a subsequent section.
264 255
265### mnt->mnt_count ### 256If two threads attempt to look up the same name at the same time - a
266 257name 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. 258not prevent them both adding new dentries with the same name. As this
259would result in confusion an extra level of interlocking is used,
260based around a secondary hash table (``in_lookup_hashtable``) and a
261per-dentry flag bit (``DCACHE_PAR_LOOKUP``).
262
263To 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
265dentry, stores the required name and parent in it, checks if there
266is already a matching dentry in the primary or secondary hash
267tables, and if not, stores the newly allocated dentry in the secondary
268hash table, with ``DCACHE_PAR_LOOKUP`` set.
269
270If a matching dentry was found in the primary hash table then that is
271returned and the caller can know that it lost a race with some other
272thread adding the entry. If no matching dentry is found in either
273cache, the newly allocated dentry is returned and the caller can
274detect this from the presence of ``DCACHE_PAR_LOOKUP``. In this case it
275knows that it has won any race and now is responsible for asking the
276filesystem to perform the lookup and find the matching inode. When
277the lookup is complete, it must call ``d_lookup_done()`` which clears
278the flag and does some other house keeping, including removing the
279dentry from the secondary hash table - it will normally have been
280added to the primary hash table already. Note that a ``struct
281waitqueue_head`` is passed to ``d_alloc_parallel()``, and
282``d_lookup_done()`` must be called while this ``waitqueue_head`` is still
283in scope.
284
285If 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
288to the instance of ``d_alloc_parallel()`` that won the race and that
289will be woken by the call to ``d_lookup_done()``. It then checks to see
290if the dentry has now been added to the primary hash table. If it
291has, the dentry is returned and the caller just sees that it lost any
292race. If it hasn't been added to the primary hash table, the most
293likely explanation is that some other dentry was added instead using
294``d_splice_alias()``. In any case, ``d_alloc_parallel()`` repeats all the
295look ups from the start and will normally return something from the
296primary hash table.
297
298mnt->mnt_count
299~~~~~~~~~~~~~~
300
301``mnt_count`` is a per-CPU reference counter on "``mount``" structures.
268Per-CPU here means that incrementing the count is cheap as it only 302Per-CPU here means that incrementing the count is cheap as it only
269uses CPU-local memory, but checking if the count is zero is expensive as 303uses CPU-local memory, but checking if the count is zero is expensive as
270it needs to check with every CPU. Taking a `mnt_count` reference 304it needs to check with every CPU. Taking a ``mnt_count`` reference
271prevents the mount structure from disappearing as the result of regular 305prevents the mount structure from disappearing as the result of regular
272unmount operations, but does not prevent a "lazy" unmount. So holding 306unmount 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,
274in particular, doesn't stabilize the link to the mounted-on dentry. It 308in particular, doesn't stabilize the link to the mounted-on dentry. It
275does, however, ensure that the `mount` data structure remains coherent, 309does, however, ensure that the ``mount`` data structure remains coherent,
276and it provides a reference to the root dentry of the mounted 310and it provides a reference to the root dentry of the mounted
277filesystem. So a reference through `->mnt_count` provides a stable 311filesystem. So a reference through ``->mnt_count`` provides a stable
278reference to the mounted dentry, but not the mounted-on dentry. 312reference to the mounted dentry, but not the mounted-on dentry.
279 313
280### mount_lock ### 314mount_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
283check if any change has been made to any mount points. 318check if any change has been made to any mount points.
284 319
285While walking down the tree (away from the root) this lock is used when 320While walking down the tree (away from the root) this lock is used when
286crossing a mount point to check that the crossing was safe. That is, 321crossing a mount point to check that the crossing was safe. That is,
287the value in the seqlock is read, then the code finds the mount that 322the value in the seqlock is read, then the code finds the mount that
288is mounted on the current directory, if there is one, and increments 323is mounted on the current directory, if there is one, and increments
289the `mnt_count`. Finally the value in `mount_lock` is checked against 324the ``mnt_count``. Finally the value in ``mount_lock`` is checked against
290the old value. If there is no change, then the crossing was safe. If there 325the old value. If there is no change, then the crossing was safe. If there
291was a change, the `mnt_count` is decremented and the whole process is 326was a change, the ``mnt_count`` is decremented and the whole process is
292retried. 327retried.
293 328
294When walking up the tree (towards the root) by following a ".." link, 329When 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
298needed to stabilize the link to the mounted-on dentry, which the 333needed to stabilize the link to the mounted-on dentry, which the
299refcount on the mount itself doesn't ensure. 334refcount on the mount itself doesn't ensure.
300 335
301### RCU ### 336RCU
337~~~
302 338
303Finally the global (but extremely lightweight) RCU read lock is held 339Finally the global (but extremely lightweight) RCU read lock is held
304from time to time to ensure certain data structures don't get freed 340from time to time to ensure certain data structures don't get freed
@@ -307,137 +343,141 @@ unexpectedly.
307In particular it is held while scanning chains in the dcache hash 343In particular it is held while scanning chains in the dcache hash
308table, and the mount point hash table. 344table, and the mount point hash table.
309 345
310Bringing it together with `struct nameidata` 346Bringing 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
315Throughout the process of walking a path, the current status is stored 351Throughout the process of walking a path, the current status is stored
316in a `struct nameidata`, "namei" being the traditional name - dating 352in a ``struct nameidata``, "namei" being the traditional name - dating
317all the way back to [First Edition Unix] - of the function that 353all the way back to `First Edition Unix`_ - of the function that
318converts a "name" to an "inode". `struct nameidata` contains (among 354converts a "name" to an "inode". ``struct nameidata`` contains (among
319other fields): 355other fields):
320 356
321### `struct path path` ### 357``struct path path``
358~~~~~~~~~~~~~~~~~~
322 359
323A `path` contains a `struct vfsmount` (which is 360A ``path`` contains a ``struct vfsmount`` (which is
324embedded in a `struct mount`) and a `struct dentry`. Together these 361embedded in a ``struct mount``) and a ``struct dentry``. Together these
325record the current status of the walk. They start out referring to the 362record the current status of the walk. They start out referring to the
326starting point (the current working directory, the root directory, or some other 363starting point (the current working directory, the root directory, or some other
327directory identified by a file descriptor), and are updated on each 364directory identified by a file descriptor), and are updated on each
328step. A reference through `d_lockref` and `mnt_count` is always 365step. A reference through ``d_lockref`` and ``mnt_count`` is always
329held. 366held.
330 367
331### `struct qstr last` ### 368``struct qstr last``
369~~~~~~~~~~~~~~~~~~
332 370
333This is a string together with a length (i.e. _not_ `nul` terminated) 371This is a string together with a length (i.e. _not_ ``nul`` terminated)
334that is the "next" component in the pathname. 372that is the "next" component in the pathname.
335 373
336### `int last_type` ### 374``int last_type``
375~~~~~~~~~~~~~~~
337 376
338This is one of `LAST_NORM`, `LAST_ROOT`, `LAST_DOT`, `LAST_DOTDOT`, or 377This 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
341components of the symlink have been processed yet. Others should be 380components of the symlink have been processed yet. Others should be
342fairly self-explanatory. 381fairly self-explanatory.
343 382
344### `struct path root` ### 383``struct path root``
384~~~~~~~~~~~~~~~~~~
345 385
346This is used to hold a reference to the effective root of the 386This is used to hold a reference to the effective root of the
347filesystem. Often that reference won't be needed, so this field is 387filesystem. Often that reference won't be needed, so this field is
348only assigned the first time it is used, or when a non-standard root 388only assigned the first time it is used, or when a non-standard root
349is requested. Keeping a reference in the `nameidata` ensures that 389is requested. Keeping a reference in the ``nameidata`` ensures that
350only one root is in effect for the entire path walk, even if it races 390only one root is in effect for the entire path walk, even if it races
351with a `chroot()` system call. 391with a ``chroot()`` system call.
352 392
353The root is needed when either of two conditions holds: (1) either the 393The root is needed when either of two conditions holds: (1) either the
354pathname or a symbolic link starts with a "'/'", or (2) a "`..`" 394pathname or a symbolic link starts with a "'/'", or (2) a "``..``"
355component is being handled, since "`..`" from the root must always stay 395component is being handled, since "``..``" from the root must always stay
356at the root. The value used is usually the current root directory of 396at the root. The value used is usually the current root directory of
357the calling process. An alternate root can be provided as when 397the 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
360specific part of the filesystem, and the lookup must not be allowed to 400specific part of the filesystem, and the lookup must not be allowed to
361escape that subtree. It works a bit like a local `chroot()`. 401escape that subtree. It works a bit like a local ``chroot()``.
362 402
363Ignoring the handling of symbolic links, we can now describe the 403Ignoring 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
365except the final component as: 405except 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``,
374it calls `handle_dots()` which does the necessary locking as already 414it calls ``handle_dots()`` which does the necessary locking as already
375described. If it finds a `LAST_NORM` component it first calls 415described. 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
377filesystem to revalidate the result if it is that sort of filesystem. 417filesystem to revalidate the result if it is that sort of filesystem.
378If that doesn't get a good result, it calls "`lookup_slow()`" which 418If that doesn't get a good result, it calls "``lookup_slow()``" which
379takes the `i_mutex`, rechecks the cache, and then asks the filesystem 419takes ``i_rwsem``, rechecks the cache, and then asks the filesystem
380to find a definitive answer. Each of these will call 420to 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
383In the absence of symbolic links, `walk_component()` creates a new 423In 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
385reference to the new `vfsmount` which is only counted if it is 425reference to the new ``vfsmount`` which is only counted if it is
386different from the previous `vfsmount`. It then calls 426different 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
390This "hand-over-hand" sequencing of getting a reference to the new 430This "hand-over-hand" sequencing of getting a reference to the new
391dentry before dropping the reference to the previous dentry may 431dentry before dropping the reference to the previous dentry may
392seem obvious, but is worth pointing out so that we will recognize its 432seem obvious, but is worth pointing out so that we will recognize its
393analogue in the "RCU-walk" version. 433analogue in the "RCU-walk" version.
394 434
395Handling the final component. 435Handling 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
400not call `walk_component()` that last time. Handling that final 440not call ``walk_component()`` that last time. Handling that final
401component remains for the caller to sort out. Those callers are 441component 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
404different system calls. 444different 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
407of housekeeping around `link_path_walk()` and returns the parent 447of housekeeping around ``link_path_walk()`` and returns the parent
408directory and final component to the caller. The caller will be either 448directory and final component to the caller. The caller will be either
409aiming to create a name (via `filename_create()`) or remove or rename 449aiming to create a name (via ``filename_create()``) or remove or rename
410a name (in which case `user_path_parent()` is used). They will use 450a 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
412perform their operation. 452perform 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
415object is wanted such as by `stat()` or `chmod()`. It essentially just 455object is wanted such as by ``stat()`` or ``chmod()``. It essentially just
416calls `walk_component()` on the final component through a call to 456calls ``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
420not try to revalidate the mounted filesystem. It effectively 460not try to revalidate the mounted filesystem. It effectively
421contains, through a call to `mountpoint_last()`, an alternate 461contains, through a call to ``mountpoint_last()``, an alternate
422implementation of `lookup_slow()` which skips that step. This is 462implementation of ``lookup_slow()`` which skips that step. This is
423important when unmounting a filesystem that is inaccessible, such as 463important when unmounting a filesystem that is inaccessible, such as
424one provided by a dead NFS server. 464one provided by a dead NFS server.
425 465
426Finally `path_openat()` is used for the `open()` system call; it 466Finally ``path_openat()`` is used for the ``open()`` system call; it
427contains, in support functions starting with "`do_last()`", all the 467contains, in support functions starting with "``do_last()``", all the
428complexity needed to handle the different subtleties of O_CREAT (with 468complexity needed to handle the different subtleties of O_CREAT (with
429or without O_EXCL), final "`/`" characters, and trailing symbolic 469or without O_EXCL), final "``/``" characters, and trailing symbolic
430links. We will revisit this in the final part of this series, which 470links. We will revisit this in the final part of this series, which
431focuses on those symbolic links. "`do_last()`" will sometimes, but 471focuses on those symbolic links. "``do_last()``" will sometimes, but
432not always, take `i_mutex`, depending on what it finds. 472not always, take ``i_rwsem``, depending on what it finds.
433 473
434Each of these, or the functions which call them, need to be alert to 474Each of these, or the functions which call them, need to be alert to
435the possibility that the final component is not `LAST_NORM`. If the 475the possibility that the final component is not ``LAST_NORM``. If the
436goal of the lookup is to create something, then any value for 476goal 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
438example if `path_parentat()` reports `LAST_DOTDOT`, then the caller 478example if ``path_parentat()`` reports ``LAST_DOTDOT``, then the caller
439won't try to create that name. They also check for trailing slashes 479won't try to create that name. They also check for trailing slashes
440by testing `last.name[last.len]`. If there is any character beyond 480by testing ``last.name[last.len]``. If there is any character beyond
441the final component, it must be a trailing slash. 481the final component, it must be a trailing slash.
442 482
443Revalidation and automounts 483Revalidation and automounts
@@ -448,12 +488,12 @@ process not yet covered. One is the handling of stale cache entries
448and the other is automounts. 488and the other is automounts.
449 489
450On filesystems that require it, the lookup routines will call the 490On 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
452is current. This will often confirm validity or update a few details 492is current. This will often confirm validity or update a few details
453from a server. In some cases it may find that there has been change 493from a server. In some cases it may find that there has been change
454further up the path and that something that was thought to be valid 494further up the path and that something that was thought to be valid
455previously isn't really. When this happens the lookup of the whole 495previously isn't really. When this happens the lookup of the whole
456path is aborted and retried with the "`LOOKUP_REVAL`" flag set. This 496path is aborted and retried with the "``LOOKUP_REVAL``" flag set. This
457forces revalidation to be more thorough. We will see more details of 497forces revalidation to be more thorough. We will see more details of
458this retry process in the next article. 498this 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
465here. 505here.
466 506
467The Linux VFS has a concept of "managed" dentries which is reflected 507The Linux VFS has a concept of "managed" dentries which is reflected
468in function names such as "`follow_managed()`". There are three 508in function names such as "``follow_managed()``". There are three
469potentially interesting things about these dentries corresponding 509potentially interesting things about these dentries corresponding
470to three different flags that might be set in `dentry->d_flags`: 510to three different flags that might be set in ``dentry->d_flags``:
471 511
472### `DCACHE_MANAGE_TRANSIT` ### 512``DCACHE_MANAGE_TRANSIT``
513~~~~~~~~~~~~~~~~~~~~~~~
473 514
474If this flag has been set, then the filesystem has requested that the 515If 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
476mount point. This can perform two particular services: 517mount point. This can perform two particular services:
477 518
478It can block to avoid races. If an automount point is being 519It can block to avoid races. If an automount point is being
479unmounted, the `d_manage()` function will usually wait for that 520unmounted, the ``d_manage()`` function will usually wait for that
480process to complete before letting the new lookup proceed and possibly 521process to complete before letting the new lookup proceed and possibly
481trigger a new automount. 522trigger a new automount.
482 523
483It can selectively allow only some processes to transit through a 524It can selectively allow only some processes to transit through a
484mount point. When a server process is managing automounts, it may 525mount point. When a server process is managing automounts, it may
485need to access a directory without triggering normal automount 526need to access a directory without triggering normal automount
486processing. That server process can identify itself to the `autofs` 527processing. That server process can identify itself to the ``autofs``
487filesystem, which will then give it a special pass through 528filesystem, 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
492This flag is set on every dentry that is mounted on. As Linux 534This flag is set on every dentry that is mounted on. As Linux
493supports multiple filesystem namespaces, it is possible that the 535supports multiple filesystem namespaces, it is possible that the
494dentry may not be mounted on in *this* namespace, just in some 536dentry may not be mounted on in *this* namespace, just in some
495other. So this flag is seen as a hint, not a promise. 537other. So this flag is seen as a hint, not a promise.
496 538
497If this flag is set, and `d_manage()` didn't return `-EISDIR`, 539If 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``
500and a new `dentry` (both with counted references). 542and a new ``dentry`` (both with counted references).
501 543
502### `DCACHE_NEED_AUTOMOUNT` ### 544``DCACHE_NEED_AUTOMOUNT``
545~~~~~~~~~~~~~~~~~~~~~~~
503 546
504If `d_manage()` allowed us to get this far, and `lookup_mnt()` didn't 547If ``d_manage()`` allowed us to get this far, and ``lookup_mnt()`` didn't
505find a mount point, then this flag causes the `d_automount()` dentry 548find a mount point, then this flag causes the ``d_automount()`` dentry
506operation to be called. 549operation to be called.
507 550
508The `d_automount()` operation can be arbitrarily complex and may 551The ``d_automount()`` operation can be arbitrarily complex and may
509communicate with server processes etc. but it should ultimately either 552communicate with server processes etc. but it should ultimately either
510report that there was an error, that there was nothing to mount, or 553report that there was an error, that there was nothing to mount, or
511should provide an updated `struct path` with new `dentry` and `vfsmount`. 554should provide an updated ``struct path`` with new ``dentry`` and ``vfsmount``.
512 555
513In the latter case, `finish_automount()` will be called to safely 556In the latter case, ``finish_automount()`` will be called to safely
514install the new mount point into the mount table. 557install the new mount point into the mount table.
515 558
516There is no new locking of import here and it is important that no 559There 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
567REF-walk. 610REF-walk.
568 611
569This stopping requires getting a counted reference on the current 612This 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 -
571that a path walk with REF-walk would have found the same entries. 614that a path walk with REF-walk would have found the same entries.
572This is an invariant that RCU-walk must guarantee. It can only make 615This is an invariant that RCU-walk must guarantee. It can only make
573decisions, such as selecting the next step, that are decisions which 616decisions, 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
578restarts from the top with REF-walk. 621restarts from the top with REF-walk.
579 622
580This pattern of "try RCU-walk, if that fails try REF-walk" can be 623This pattern of "try RCU-walk, if that fails try REF-walk" can be
581clearly seen in functions like `filename_lookup()`, 624clearly 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
584correspond roughly to the four `path_`* functions we met earlier, 627correspond roughly to the four ``path_``* functions we met earlier,
585each of which calls `link_path_walk()`. The `path_*` functions are 628each of which calls ``link_path_walk()``. The ``path_*`` functions are
586called using different mode flags until a mode is found which works. 629called using different mode flags until a mode is found which works.
587They are first called with `LOOKUP_RCU` set to request "RCU-walk". If 630They are first called with ``LOOKUP_RCU`` set to request "RCU-walk". If
588that fails with the error `ECHILD` they are called again with no 631that fails with the error ``ECHILD`` they are called again with no
589special flag to request "REF-walk". If either of those report the 632special flag to request "REF-walk". If either of those report the
590error `ESTALE` a final attempt is made with `LOOKUP_REVAL` set (and no 633error ``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
592revalidated - normally entries are only revalidated if the filesystem 635revalidated - normally entries are only revalidated if the filesystem
593determines that they are too old to trust. 636determines that they are too old to trust.
594 637
595The `LOOKUP_RCU` attempt may drop that flag internally and switch to 638The ``LOOKUP_RCU`` attempt may drop that flag internally and switch to
596REF-walk, but will never then try to switch back to RCU-walk. Places 639REF-walk, but will never then try to switch back to RCU-walk. Places
597that trip up RCU-walk are much more likely to be near the leaves and 640that trip up RCU-walk are much more likely to be near the leaves and
598so it is very unlikely that there will be much, if any, benefit from 641so 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
604RCU is, unsurprisingly, critical to RCU-walk mode. The 647RCU 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
606down a path. The particular guarantee it provides is that the key 649down a path. The particular guarantee it provides is that the key
607data structures - dentries, inodes, super_blocks, and mounts - will 650data structures - dentries, inodes, super_blocks, and mounts - will
608not be freed while the lock is held. They might be unlinked or 651not be freed while the lock is held. They might be unlinked or
@@ -614,7 +657,7 @@ seqlocks.
614As we saw above, REF-walk holds a counted reference to the current 657As we saw above, REF-walk holds a counted reference to the current
615dentry and the current vfsmount, and does not release those references 658dentry and the current vfsmount, and does not release those references
616before taking references to the "next" dentry or vfsmount. It also 659before taking references to the "next" dentry or vfsmount. It also
617sometimes takes the `d_lock` spinlock. These references and locks are 660sometimes takes the ``d_lock`` spinlock. These references and locks are
618taken to prevent certain changes from happening. RCU-walk must not 661taken to prevent certain changes from happening. RCU-walk must not
619take those references or locks and so cannot prevent such changes. 662take those references or locks and so cannot prevent such changes.
620Instead, it checks to see if a change has been made, and aborts or 663Instead, 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
624decisions that REF-walk could have made), it must make the checks at 667decisions that REF-walk could have made), it must make the checks at
625or near the same places that REF-walk holds the references. So, when 668or near the same places that REF-walk holds the references. So, when
626REF-walk increments a reference count or takes a spinlock, RCU-walk 669REF-walk increments a reference count or takes a spinlock, RCU-walk
627samples the status of a seqlock using `read_seqcount_begin()` or a 670samples the status of a seqlock using ``read_seqcount_begin()`` or a
628similar function. When REF-walk decrements the count or drops the 671similar function. When REF-walk decrements the count or drops the
629lock, RCU-walk checks if the sampled status is still valid using 672lock, 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
632However, there is a little bit more to seqlocks than that. If 675However, there is a little bit more to seqlocks than that. If
633RCU-walk accesses two different fields in a seqlock-protected 676RCU-walk accesses two different fields in a seqlock-protected
634structure, or accesses the same field twice, there is no a priori 677structure, or accesses the same field twice, there is no a priori
635guarantee of any consistency between those accesses. When consistency 678guarantee of any consistency between those accesses. When consistency
636is needed - which it usually is - RCU-walk must take a copy and then 679is needed - which it usually is - RCU-walk must take a copy and then
637use `read_seqcount_retry()` to validate that copy. 680use ``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
640imposes a memory barrier so that no memory-read instruction from 683imposes 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
642CPU or by the compiler. A simple example of this can be seen in 685CPU 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
644byte-wise name equality, calls into the filesystem to compare a name 687byte-wise name equality, calls into the filesystem to compare a name
645against a dentry. The length and name pointer are copied into local 688against a dentry. The length and name pointer are copied into local
646variables, then `read_seqcount_retry()` is called to confirm the two 689variables, then ``read_seqcount_retry()`` is called to confirm the two
647are consistent, and only then is `->d_compare()` called. When 690are consistent, and only then is ``->d_compare()`` called. When
648standard filename comparison is used, `dentry_cmp()` is called 691standard filename comparison is used, ``dentry_cmp()`` is called
649instead. Notably it does _not_ use `read_seqcount_retry()`, but 692instead. Notably it does _not_ use ``read_seqcount_retry()``, but
650instead has a large comment explaining why the consistency guarantee 693instead has a large comment explaining why the consistency guarantee
651isn't necessary. A subsequent `read_seqcount_retry()` will be 694isn't necessary. A subsequent ``read_seqcount_retry()`` will be
652sufficient to catch any problem that could occur at this point. 695sufficient to catch any problem that could occur at this point.
653 696
654With that little refresher on seqlocks out of the way we can look at 697With that little refresher on seqlocks out of the way we can look at
655the bigger picture of how RCU-walk uses seqlocks. 698the 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
659We already met the `mount_lock` seqlock when REF-walk used it to 703We already met the ``mount_lock`` seqlock when REF-walk used it to
660ensure that crossing a mount point is performed safely. RCU-walk uses 704ensure that crossing a mount point is performed safely. RCU-walk uses
661it for that too, but for quite a bit more. 705it for that too, but for quite a bit more.
662 706
663Instead of taking a counted reference to each `vfsmount` as it 707Instead of taking a counted reference to each ``vfsmount`` as it
664descends the tree, RCU-walk samples the state of `mount_lock` at the 708descends the tree, RCU-walk samples the state of ``mount_lock`` at the
665start of the walk and stores this initial sequence number in the 709start 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
667sequence number are used to validate all accesses to all `vfsmounts`, 711sequence number are used to validate all accesses to all ``vfsmounts``,
668and all mount point crossings. As changes to the mount table are 712and all mount point crossings. As changes to the mount table are
669relatively rare, it is reasonable to fall back on REF-walk any time 713relatively rare, it is reasonable to fall back on REF-walk any time
670that any "mount" or "unmount" happens. 714that 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
673sequence, whether switching to REF-walk for the rest of the path or 717sequence, whether switching to REF-walk for the rest of the path or
674when the end of the path is reached. It is also checked when stepping 718when the end of the path is reached. It is also checked when stepping
675down over a mount point (in `__follow_mount_rcu()`) or up (in 719down 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
677whole RCU-walk sequence is aborted and the path is processed again by 721whole RCU-walk sequence is aborted and the path is processed again by
678REF-walk. 722REF-walk.
679 723
680If RCU-walk finds that `mount_lock` hasn't changed then it can be sure 724If RCU-walk finds that ``mount_lock`` hasn't changed then it can be sure
681that, had REF-walk taken counted references on each vfsmount, the 725that, had REF-walk taken counted references on each vfsmount, the
682results would have been the same. This ensures the invariant holds, 726results would have been the same. This ensures the invariant holds,
683at least for vfsmount structures. 727at least for vfsmount structures.
684 728
685### `dentry->d_seq` and `nd->seq`. ### 729``dentry->d_seq`` and ``nd->seq``
730~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
686 731
687In place of taking a count or lock on `d_reflock`, RCU-walk samples 732In place of taking a count or lock on ``d_reflock``, RCU-walk samples
688the per-dentry `d_seq` seqlock, and stores the sequence number in the 733the 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
690the current sequence number of `nd->dentry`. This number needs to be 735the current sequence number of ``nd->dentry``. This number needs to be
691revalidated after copying, and before using, the name, parent, or 736revalidated after copying, and before using, the name, parent, or
692inode of the dentry. 737inode of the dentry.
693 738
694The handling of the name we have already looked at, and the parent is 739The handling of the name we have already looked at, and the parent is
695only accessed in `follow_dotdot_rcu()` which fairly trivially follows 740only accessed in ``follow_dotdot_rcu()`` which fairly trivially follows
696the required pattern, though it does so for three different cases. 741the required pattern, though it does so for three different cases.
697 742
698When not at a mount point, `d_parent` is followed and its `d_seq` is 743When not at a mount point, ``d_parent`` is followed and its ``d_seq`` is
699collected. When we are at a mount point, we instead follow the 744collected. 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
702check if we have landed on a mount point and, if so, must find that 747check if we have landed on a mount point and, if so, must find that
703mount point and follow the `mnt->mnt_root` link. This would imply a 748mount point and follow the ``mnt->mnt_root`` link. This would imply a
704somewhat unusual, but certainly possible, circumstance where the 749somewhat unusual, but certainly possible, circumstance where the
705starting point of the path lookup was in part of the filesystem that 750starting point of the path lookup was in part of the filesystem that
706was mounted on, and so not visible from the root. 751was mounted on, and so not visible from the root.
707 752
708The inode pointer, stored in `->d_inode`, is a little more 753The inode pointer, stored in ``->d_inode``, is a little more
709interesting. The inode will always need to be accessed at least 754interesting. The inode will always need to be accessed at least
710twice, once to determine if it is NULL and once to verify access 755twice, once to determine if it is NULL and once to verify access
711permissions. Symlink handling requires a validated inode pointer too. 756permissions. Symlink handling requires a validated inode pointer too.
712Rather than revalidating on each access, a copy is made on the first 757Rather than revalidating on each access, a copy is made on the first
713access and it is stored in the `inode` field of `nameidata` from where 758access and it is stored in the ``inode`` field of ``nameidata`` from where
714it can be safely accessed without further validation. 759it 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
719of the current dentry. 764of the current dentry.
720 765
721The current `dentry` and current `seq` number are passed to 766The 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
723new `seq` number. `lookup_fast()` then copies the inode pointer and 768new ``seq`` number. ``lookup_fast()`` then copies the inode pointer and
724revalidates the new `seq` number. It then validates the old `dentry` 769revalidates the new ``seq`` number. It then validates the old ``dentry``
725with the old `seq` number one last time and only then continues. This 770with the old ``seq`` number one last time and only then continues. This
726process of getting the `seq` number of the new dentry and then 771process of getting the ``seq`` number of the new dentry and then
727checking the `seq` number of the old exactly mirrors the process of 772checking the ``seq`` number of the old exactly mirrors the process of
728getting a counted reference to the new dentry before dropping that for 773getting a counted reference to the new dentry before dropping that for
729the old dentry which we saw in REF-walk. 774the old dentry which we saw in REF-walk.
730 775
731### No `inode->i_mutex` or even `rename_lock` ### 776No ``inode->i_rwsem`` or even ``rename_lock``
777~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
732 778
733A mutex is a fairly heavyweight lock that can only be taken when it is 779A semaphore is a fairly heavyweight lock that can only be taken when it is
734permissible to sleep. As `rcu_read_lock()` forbids sleeping, 780permissible 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
736take `i_mutex` and modifies the directory in a way that RCU-walk needs 782take ``i_rwsem`` and modifies the directory in a way that RCU-walk needs
737to notice, the result will be either that RCU-walk fails to find the 783to notice, the result will be either that RCU-walk fails to find the
738dentry that it is looking for, or it will find a dentry which 784dentry 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
740REF-walk mode which can take whatever locks are needed. 786REF-walk mode which can take whatever locks are needed.
741 787
742Though `rename_lock` could be used by RCU-walk as it doesn't require 788Though ``rename_lock`` could be used by RCU-walk as it doesn't require
743any sleeping, RCU-walk doesn't bother. REF-walk uses `rename_lock` to 789any sleeping, RCU-walk doesn't bother. REF-walk uses ``rename_lock`` to
744protect against the possibility of hash chains in the dcache changing 790protect against the possibility of hash chains in the dcache changing
745while they are being searched. This can result in failing to find 791while they are being searched. This can result in failing to find
746something that actually is there. When RCU-walk fails to find 792something 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
749locking. This neatly handles all cases, so adding extra checks on 795locking. This neatly handles all cases, so adding extra checks on
750rename_lock would bring no significant value. 796rename_lock would bring no significant value.
751 797
752`unlazy walk()` and `complete_walk()` 798``unlazy walk()`` and ``complete_walk()``
753------------------------------------- 799-------------------------------------
754 800
755That "dropping down to REF-walk" typically involves a call to 801That "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
757referred to as "lazy walk". `unlazy_walk()` is called when 803referred to as "lazy walk". ``unlazy_walk()`` is called when
758following the path down to the current vfsmount/dentry pair seems to 804following the path down to the current vfsmount/dentry pair seems to
759have proceeded successfully, but the next step is problematic. This 805have proceeded successfully, but the next step is problematic. This
760can happen if the next name cannot be found in the dcache, if 806can happen if the next name cannot be found in the dcache, if
761permission checking or name revalidation couldn't be achieved while 807permission checking or name revalidation couldn't be achieved while
762the `rcu_read_lock()` is held (which forbids sleeping), if an 808the ``rcu_read_lock()`` is held (which forbids sleeping), if an
763automount point is found, or in a couple of cases involving symlinks. 809automount point is found, or in a couple of cases involving symlinks.
764It is also called from `complete_walk()` when the lookup has reached 810It is also called from ``complete_walk()`` when the lookup has reached
765the final component, or the very end of the path, depending on which 811the final component, or the very end of the path, depending on which
766particular flavor of lookup is used. 812particular flavor of lookup is used.
767 813
768Other reasons for dropping out of RCU-walk that do not trigger a call 814Other reasons for dropping out of RCU-walk that do not trigger a call
769to `unlazy_walk()` are when some inconsistency is found that cannot be 815to ``unlazy_walk()`` are when some inconsistency is found that cannot be
770handled immediately, such as `mount_lock` or one of the `d_seq` 816handled immediately, such as ``mount_lock`` or one of the ``d_seq``
771seqlocks reporting a change. In these cases the relevant function 817seqlocks reporting a change. In these cases the relevant function
772will return `-ECHILD` which will percolate up until it triggers a new 818will return ``-ECHILD`` which will percolate up until it triggers a new
773attempt from the top using REF-walk. 819attempt from the top using REF-walk.
774 820
775For those cases where `unlazy_walk()` is an option, it essentially 821For those cases where ``unlazy_walk()`` is an option, it essentially
776takes a reference on each of the pointers that it holds (vfsmount, 822takes a reference on each of the pointers that it holds (vfsmount,
777dentry, and possibly some symbolic links) and then verifies that the 823dentry, and possibly some symbolic links) and then verifies that the
778relevant seqlocks have not been changed. If there have been changes, 824relevant seqlocks have not been changed. If there have been changes,
779it, too, aborts with `-ECHILD`, otherwise the transition to REF-walk 825it, too, aborts with ``-ECHILD``, otherwise the transition to REF-walk
780has been a success and the lookup process continues. 826has been a success and the lookup process continues.
781 827
782Taking a reference on those pointers is not quite as simple as just 828Taking a reference on those pointers is not quite as simple as just
783incrementing a counter. That works to take a second reference if you 829incrementing a counter. That works to take a second reference if you
784already have one (often indirectly through another object), but it 830already have one (often indirectly through another object), but it
785isn't sufficient if you don't actually have a counted reference at 831isn't sufficient if you don't actually have a counted reference at
786all. For `dentry->d_lockref`, it is safe to increment the reference 832all. For ``dentry->d_lockref``, it is safe to increment the reference
787counter to get a reference unless it has been explicitly marked as 833counter 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
791For `mnt->mnt_count` it is safe to take a reference as long as 837For ``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
793validation fails, it may *not* be safe to just drop that reference in 839validation fails, it may *not* be safe to just drop that reference in
794the standard way of calling `mnt_put()` - an unmount may have 840the standard way of calling ``mnt_put()`` - an unmount may have
795progressed too far. So the code in `legitimize_mnt()`, when it 841progressed too far. So the code in ``legitimize_mnt()``, when it
796finds that the reference it got might not be safe, checks the 842finds 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
798correct, or if it should just decrement the count and pretend none of 844correct, or if it should just decrement the count and pretend none of
799this ever happened. 845this ever happened.
800 846
801Taking care in filesystems 847Taking care in filesystems
802--------------------------- 848--------------------------
803 849
804RCU-walk depends almost entirely on cached information and often will 850RCU-walk depends almost entirely on cached information and often will
805not call into the filesystem at all. However there are two places, 851not call into the filesystem at all. However there are two places,
@@ -809,26 +855,26 @@ careful.
809 855
810If the filesystem has non-standard permission-checking requirements - 856If the filesystem has non-standard permission-checking requirements -
811such as a networked filesystem which may need to check with the server 857such 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.
813In this case an extra "`MAY_NOT_BLOCK`" flag is passed so that it 859In this case an extra "``MAY_NOT_BLOCK``" flag is passed so that it
814knows not to sleep, but to return `-ECHILD` if it cannot complete 860knows not to sleep, but to return ``-ECHILD`` if it cannot complete
815promptly. `i_op->permission` is given the inode pointer, not the 861promptly. ``i_op->permission`` is given the inode pointer, not the
816dentry, so it doesn't need to worry about further consistency checks. 862dentry, so it doesn't need to worry about further consistency checks.
817However if it accesses any other filesystem data structures, it must 863However if it accesses any other filesystem data structures, it must
818ensure they are safe to be accessed with only the `rcu_read_lock()` 864ensure they are safe to be accessed with only the ``rcu_read_lock()``
819held. This typically means they must be freed using `kfree_rcu()` or 865held. This typically means they must be freed using ``kfree_rcu()`` or
820similar. 866similar.
821 867
822[`READ_ONCE()`]: https://lwn.net/Articles/624126/ 868.. _READ_ONCE: https://lwn.net/Articles/624126/
823 869
824If the filesystem may need to revalidate dcache entries, then 870If 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
828when accessing fields in the dentry. This "extra care" typically 874when accessing fields in the dentry. This "extra care" typically
829involves using [`READ_ONCE()`] to access fields, and verifying the 875involves using `READ_ONCE() <READ_ONCE_>`_ to access fields, and verifying the
830result is not NULL before using it. This pattern can be seen in 876result is not NULL before using it. This pattern can be seen in
831`nfs_lookup_revalidate()`. 877``nfs_lookup_revalidate()``.
832 878
833A pair of patterns 879A pair of patterns
834------------------ 880------------------
@@ -839,14 +885,14 @@ being aware of.
839 885
840The first is "try quickly and check, if that fails try slowly". We 886The first is "try quickly and check, if that fails try slowly". We
841can see that in the high-level approach of first trying RCU-walk and 887can see that in the high-level approach of first trying RCU-walk and
842then trying REF-walk, and in places where `unlazy_walk()` is used to 888then trying REF-walk, and in places where ``unlazy_walk()`` is used to
843switch to REF-walk for the rest of the path. We also saw it earlier 889switch to REF-walk for the rest of the path. We also saw it earlier
844in `dget_parent()` when following a "`..`" link. It tries a quick way 890in ``dget_parent()`` when following a "``..``" link. It tries a quick way
845to get a reference, then falls back to taking locks if needed. 891to get a reference, then falls back to taking locks if needed.
846 892
847The second pattern is "try quickly and check, if that fails try 893The second pattern is "try quickly and check, if that fails try
848again - repeatedly". This is seen with the use of `rename_lock` and 894again - 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 -
850if anything goes wrong it is much safer to just abort and try a more 896if anything goes wrong it is much safer to just abort and try a more
851sedate approach. 897sedate approach.
852 898
@@ -882,8 +928,8 @@ Conceptually, symbolic links could be handled by editing the path. If
882a component name refers to a symbolic link, then that component is 928a component name refers to a symbolic link, then that component is
883replaced by the body of the link and, if that body starts with a '/', 929replaced by the body of the link and, if that body starts with a '/',
884then all preceding parts of the path are discarded. This is what the 930then 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
888Directly editing the path string is not really necessary when looking 934Directly editing the path string is not really necessary when looking
889up a path, and discarding early components is pointless as they aren't 935up 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
899occur in a single path lookup. The most obvious is to avoid loops. 945occur in a single path lookup. The most obvious is to avoid loops.
900If a symlink referred to itself either directly or through 946If a symlink referred to itself either directly or through
901intermediaries, then following the symlink can never complete 947intermediaries, then following the symlink can never complete
902successfully - the error `ELOOP` must be returned. Loops can be 948successfully - the error ``ELOOP`` must be returned. Loops can be
903detected without imposing limits, but limits are the simplest solution 949detected without imposing limits, but limits are the simplest solution
904and, given the second reason for restriction, quite sufficient. 950and, 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
908The second reason was [outlined recently] by Linus: 954The 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
914Linux imposes a limit on the length of any pathname: `PATH_MAX`, which 960Linux imposes a limit on the length of any pathname: ``PATH_MAX``, which
915is 4096. There are a number of reasons for this limit; not letting the 961is 4096. There are a number of reasons for this limit; not letting the
916kernel spend too much time on just one path is one of them. With 962kernel spend too much time on just one path is one of them. With
917symbolic links you can effectively generate much longer paths so some 963symbolic 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
921raised to 40 when a separate stack was implemented, so there is now 967raised to 40 when a separate stack was implemented, so there is now
922just the one limit. 968just the one limit.
923 969
924The `nameidata` structure that we met in an earlier article contains a 970The ``nameidata`` structure that we met in an earlier article contains a
925small stack that can be used to store the remaining part of up to two 971small stack that can be used to store the remaining part of up to two
926symlinks. In many cases this will be sufficient. If it isn't, a 972symlinks. In many cases this will be sufficient. If it isn't, a
927separate stack is allocated with room for 40 symlinks. Pathname 973separate 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
941able to find and temporarily hold onto these cached entries, so that 987able to find and temporarily hold onto these cached entries, so that
942it doesn't need to drop down into REF-walk. 988it 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
946While each filesystem is free to make its own choice, symlinks are 992While each filesystem is free to make its own choice, symlinks are
947typically stored in one of two places. Short symlinks are often 993typically stored in one of two places. Short symlinks are often
948stored directly in the inode. When a filesystem allocates a `struct 994stored directly in the inode. When a filesystem allocates a ``struct
949inode` it typically allocates extra space to store private data (a 995inode`` it typically allocates extra space to store private data (a
950common [object-oriented design pattern] in the kernel). This will 996common `object-oriented design pattern`_ in the kernel). This will
951sometimes include space for a symlink. The other common location is 997sometimes include space for a symlink. The other common location is
952in the page cache, which normally stores the content of files. The 998in the page cache, which normally stores the content of files. The
953pathname in a symlink can be seen as the content of that symlink and 999pathname 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
962on the dentry. This means that the mechanisms that pathname lookup 1008on the dentry. This means that the mechanisms that pathname lookup
963uses to access the dcache and icache (inode cache) safely are quite 1009uses to access the dcache and icache (inode cache) safely are quite
964sufficient for accessing some cached symlinks safely. In these cases, 1010sufficient for accessing some cached symlinks safely. In these cases,
965the `i_link` pointer in the inode is set to point to wherever the 1011the ``i_link`` pointer in the inode is set to point to wherever the
966symlink is stored and it can be accessed directly whenever needed. 1012symlink is stored and it can be accessed directly whenever needed.
967 1013
968When the symlink is stored in the page cache or elsewhere, the 1014When the symlink is stored in the page cache or elsewhere, the
969situation is not so straightforward. A reference on a dentry or even 1015situation is not so straightforward. A reference on a dentry or even
970on an inode does not imply any reference on cached pages of that 1016on an inode does not imply any reference on cached pages of that
971inode, and even an `rcu_read_lock()` is not sufficient to ensure that 1017inode, and even an ``rcu_read_lock()`` is not sufficient to ensure that
972a page will not disappear. So for these symlinks the pathname lookup 1018a page will not disappear. So for these symlinks the pathname lookup
973code needs to ask the filesystem to provide a stable reference and, 1019code needs to ask the filesystem to provide a stable reference and,
974significantly, needs to release that reference when it is finished 1020significantly, 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
978mode. It does require making changes to memory, which is best avoided, 1024mode. It does require making changes to memory, which is best avoided,
979but that isn't necessarily a big cost and it is better than dropping 1025but that isn't necessarily a big cost and it is better than dropping
980out of RCU-walk mode completely. Even filesystems that allocate 1026out of RCU-walk mode completely. Even filesystems that allocate
981space to copy the symlink into can use `GFP_ATOMIC` to often successfully 1027space to copy the symlink into can use ``GFP_ATOMIC`` to often successfully
982allocate memory without the need to drop out of RCU-walk. If a 1028allocate memory without the need to drop out of RCU-walk. If a
983filesystem cannot successfully get a reference in RCU-walk mode, it 1029filesystem cannot successfully get a reference in RCU-walk mode, it
984must return `-ECHILD` and `unlazy_walk()` will be called to return to 1030must return ``-ECHILD`` and ``unlazy_walk()`` will be called to return to
985REF-walk mode in which the filesystem is allowed to sleep. 1031REF-walk mode in which the filesystem is allowed to sleep.
986 1032
987The place for all this to happen is the `i_op->follow_link()` inode 1033The place for all this to happen is the ``i_op->follow_link()`` inode
988method. In the present mainline code this is never actually called in 1034method. In the present mainline code this is never actually called in
989RCU-walk mode as the rewrite is not quite complete. It is likely that 1035RCU-walk mode as the rewrite is not quite complete. It is likely that
990in a future release this method will be passed an `inode` pointer when 1036in a future release this method will be passed an ``inode`` pointer when
991called in RCU-walk mode so it both (1) knows to be careful, and (2) has the 1037called in RCU-walk mode so it both (1) knows to be careful, and (2) has the
992validated pointer. Much like the `i_op->permission()` method we 1038validated pointer. Much like the ``i_op->permission()`` method we
993looked at previously, `->follow_link()` would need to be careful that 1039looked at previously, ``->follow_link()`` would need to be careful that
994all the data structures it references are safe to be accessed while 1040all the data structures it references are safe to be accessed while
995holding no counted reference, only the RCU lock. Though getting a 1041holding no counted reference, only the RCU lock. Though getting a
996reference with `->follow_link()` is not yet done in RCU-walk mode, the 1042reference with ``->follow_link()`` is not yet done in RCU-walk mode, the
997code is ready to release the reference when that does happen. 1043code is ready to release the reference when that does happen.
998 1044
999This need to drop the reference to a symlink adds significant 1045This need to drop the reference to a symlink adds significant
1000complexity. It requires a reference to the inode so that the 1046complexity. 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
1002reference is kept implicitly through a reference to the dentry, so 1048reference is kept implicitly through a reference to the dentry, so
1003keeping the `struct path` of the symlink is easiest. For RCU-walk, 1049keeping the ``struct path`` of the symlink is easiest. For RCU-walk,
1004the pointer to the inode is kept separately. To allow switching from 1050the pointer to the inode is kept separately. To allow switching from
1005RCU-walk back to REF-walk in the middle of processing nested symlinks 1051RCU-walk back to REF-walk in the middle of processing nested symlinks
1006we also need the seq number for the dentry so we can confirm that 1052we also need the seq number for the dentry so we can confirm that
1007switching back was safe. 1053switching back was safe.
1008 1054
1009Finally, when providing a reference to a symlink, the filesystem also 1055Finally, when providing a reference to a symlink, the filesystem also
1010provides an opaque "cookie" that must be passed to `->put_link()` so that it 1056provides an opaque "cookie" that must be passed to ``->put_link()`` so that it
1011knows what to free. This might be the allocated memory area, or a 1057knows what to free. This might be the allocated memory area, or a
1012pointer to the `struct page` in the page cache, or something else 1058pointer to the ``struct page`` in the page cache, or something else
1013completely. Only the filesystem knows what it is. 1059completely. Only the filesystem knows what it is.
1014 1060
1015In order for the reference to each symlink to be dropped when the walk completes, 1061In order for the reference to each symlink to be dropped when the walk completes,
1016whether in RCU-walk or REF-walk, the symlink stack needs to contain, 1062whether in RCU-walk or REF-walk, the symlink stack needs to contain,
1017along with the path remnants: 1063along 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
1024This means that each entry in the symlink stack needs to hold five 1070This means that each entry in the symlink stack needs to hold five
1025pointers and an integer instead of just one pointer (the path 1071pointers 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
1028half a page. So it might seem like a lot, but is by no means 1074half a page. So it might seem like a lot, but is by no means
1029excessive. 1075excessive.
1030 1076
1031Note that, in a given stack frame, the path remnant (`name`) is not 1077Note that, in a given stack frame, the path remnant (``name``) is not
1032part of the symlink that the other fields refer to. It is the remnant 1078part of the symlink that the other fields refer to. It is the remnant
1033to be followed once that symlink has been fully parsed. 1079to be followed once that symlink has been fully parsed.
1034 1080
1035Following the symlink 1081Following the symlink
1036--------------------- 1082---------------------
1037 1083
1038The main loop in `link_path_walk()` iterates seamlessly over all 1084The main loop in ``link_path_walk()`` iterates seamlessly over all
1039components in the path and all of the non-final symlinks. As symlinks 1085components in the path and all of the non-final symlinks. As symlinks
1040are processed, the `name` pointer is adjusted to point to a new 1086are processed, the ``name`` pointer is adjusted to point to a new
1041symlink, or is restored from the stack, so that much of the loop 1087symlink, or is restored from the stack, so that much of the loop
1042doesn't need to notice. Getting this `name` variable on and off the 1088doesn't need to notice. Getting this ``name`` variable on and off the
1043stack is very straightforward; pushing and popping the references is 1089stack is very straightforward; pushing and popping the references is
1044a little more complex. 1090a little more complex.
1045 1091
1046When a symlink is found, `walk_component()` returns the value `1` 1092When 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
1048is, as usual, an error indicator). This causes `get_link()` to be 1094is, as usual, an error indicator). This causes ``get_link()`` to be
1049called; it then gets the link from the filesystem. Providing that 1095called; it then gets the link from the filesystem. Providing that
1050operation is successful, the old path `name` is placed on the stack, 1096operation is successful, the old path ``name`` is placed on the stack,
1051and the new value is used as the `name` for a while. When the end of 1097and the new value is used as the ``name`` for a while. When the end of
1052the path is found (i.e. `*name` is `'\0'`) the old `name` is restored 1098the path is found (i.e. ``*name`` is ``'\0'``) the old ``name`` is restored
1053off the stack and path walking continues. 1099off the stack and path walking continues.
1054 1100
1055Pushing and popping the reference pointers (inode, cookie, etc.) is more 1101Pushing 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
1060just get in the way. 1106just get in the way.
1061 1107
1062It is most convenient to push the new symlink references onto the 1108It is most convenient to push the new symlink references onto the
1063stack in `walk_component()` immediately when the symlink is found; 1109stack 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
1065old symlink as it walks that last component. So it is quite 1111old symlink as it walks that last component. So it is quite
1066convenient for `walk_component()` to release the old symlink and pop 1112convenient for ``walk_component()`` to release the old symlink and pop
1067the references just before pushing the reference information for the 1113the references just before pushing the reference information for the
1068new symlink. It is guided in this by two flags; `WALK_GET`, which 1114new symlink. It is guided in this by two flags; ``WALK_GET``, which
1069gives it permission to follow a symlink if it finds one, and 1115gives 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
1071followed. `WALK_PUT` is tested first, leading to a call to 1117followed. ``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
1074up the stack frame. 1120up the stack frame.
1075 1121
1076### Symlinks with no final component ### 1122Symlinks with no final component
1123~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1077 1124
1078A pair of special-case symlinks deserve a little further explanation. 1125A pair of special-case symlinks deserve a little further explanation.
1079Both result in a new `struct path` (with mount and dentry) being set 1126Both result in a new ``struct path`` (with mount and dentry) being set
1080up in the `nameidata`, and result in `get_link()` returning `NULL`. 1127up in the ``nameidata``, and result in ``get_link()`` returning ``NULL``.
1081 1128
1082The more obvious case is a symlink to "`/`". All symlinks starting 1129The more obvious case is a symlink to "``/``". All symlinks starting
1083with "`/`" are detected in `get_link()` which resets the `nameidata` 1130with "``/``" are detected in ``get_link()`` which resets the ``nameidata``
1084to point to the effective filesystem root. If the symlink only 1131to point to the effective filesystem root. If the symlink only
1085contains "`/`" then there is nothing more to do, no components at all, 1132contains "``/``" then there is nothing more to do, no components at all,
1086so `NULL` is returned to indicate that the symlink can be released and 1133so ``NULL`` is returned to indicate that the symlink can be released and
1087the stack frame discarded. 1134the stack frame discarded.
1088 1135
1089The other case involves things in `/proc` that look like symlinks but 1136The other case involves things in ``/proc`` that look like symlinks but
1090aren't really. 1137aren'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
1095Every open file descriptor in any process is represented in `/proc` by 1142Every open file descriptor in any process is represented in ``/proc`` by
1096something that looks like a symlink. It is really a reference to the 1143something that looks like a symlink. It is really a reference to the
1097target file, not just the name of it. When you `readlink` these 1144target file, not just the name of it. When you ``readlink`` these
1098objects you get a name that might refer to the same file - unless it 1145objects you get a name that might refer to the same file - unless it
1099has been unlinked or mounted over. When `walk_component()` follows 1146has been unlinked or mounted over. When ``walk_component()`` follows
1100one of these, the `->follow_link()` method in "procfs" doesn't return 1147one of these, the ``->follow_link()`` method in "procfs" doesn't return
1101a string name, but instead calls `nd_jump_link()` which updates the 1148a 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
1103returns `NULL`. Again there is no final component and `get_link()` 1150returns ``NULL``. Again there is no final component and ``get_link()``
1104reports this by leaving the `last_type` field of `nameidata` as 1151reports this by leaving the ``last_type`` field of ``nameidata`` as
1105`LAST_BIND`. 1152``LAST_BIND``.
1106 1153
1107Following the symlink in the final component 1154Following the symlink in the final component
1108-------------------------------------------- 1155--------------------------------------------
1109 1156
1110All this leads to `link_path_walk()` walking down every component, and 1157All this leads to ``link_path_walk()`` walking down every component, and
1111following all symbolic links it finds, until it reaches the final 1158following all symbolic links it finds, until it reaches the final
1112component. This is just returned in the `last` field of `nameidata`. 1159component. This is just returned in the ``last`` field of ``nameidata``.
1113For some callers, this is all they need; they want to create that 1160For 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
1115callers will want to follow a symlink if one is found, and possibly 1162callers will want to follow a symlink if one is found, and possibly
1116apply special handling to the last component of that symlink, rather 1163apply special handling to the last component of that symlink, rather
1117than just the last component of the original file name. These callers 1164than just the last component of the original file name. These callers
1118potentially need to call `link_path_walk()` again and again on 1165potentially need to call ``link_path_walk()`` again and again on
1119successive symlinks until one is found that doesn't point to another 1166successive symlinks until one is found that doesn't point to another
1120symlink. 1167symlink.
1121 1168
1122This case is handled by the relevant caller of `link_path_walk()`, such as 1169This 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
1124handles the final component. If the final component is a symlink 1171handles the final component. If the final component is a symlink
1125that needs to be followed, then `trailing_symlink()` is called to set 1172that needs to be followed, then ``trailing_symlink()`` is called to set
1126things up properly and the loop repeats, calling `link_path_walk()` 1173things up properly and the loop repeats, calling ``link_path_walk()``
1127again. This could loop as many as 40 times if the last component of 1174again. This could loop as many as 40 times if the last component of
1128each symlink is another symlink. 1175each symlink is another symlink.
1129 1176
1130The various functions that examine the final component and possibly 1177The various functions that examine the final component and possibly
1131report that it is a symlink are `lookup_last()`, `mountpoint_last()` 1178report that it is a symlink are ``lookup_last()``, ``mountpoint_last()``
1132and `do_last()`, each of which use the same convention as 1179and ``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
1134to be followed. 1181to be followed.
1135 1182
1136Of these, `do_last()` is the most interesting as it is used for 1183Of these, ``do_last()`` is the most interesting as it is used for
1137opening a file. Part of `do_last()` runs with `i_mutex` held and this 1184opening a file. Part of ``do_last()`` runs with ``i_rwsem`` held and this
1138part is in a separate function: `lookup_open()`. 1185part is in a separate function: ``lookup_open()``.
1139 1186
1140Explaining `do_last()` completely is beyond the scope of this article, 1187Explaining ``do_last()`` completely is beyond the scope of this article,
1141but a few highlights should help those interested in exploring the 1188but a few highlights should help those interested in exploring the
1142code. 1189code.
1143 1190
11441. Rather than just finding the target file, `do_last()` needs to open 11911. 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
11532. `vfs_open()` can fail with `-EOPENSTALE` if the cached information 12002. ``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
11593. An open with O_CREAT **does** follow a symlink in the final component, 12063. 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
1171Updating the access time 1218Updating the access time
1172------------------------ 1219------------------------
@@ -1180,110 +1227,112 @@ footprints are best kept to a minimum.
1180One other place where walking down a symlink can involve leaving 1227One other place where walking down a symlink can involve leaving
1181footprints in a way that doesn't affect directories is in updating access times. 1228footprints in a way that doesn't affect directories is in updating access times.
1182In Unix (and Linux) every filesystem object has a "last accessed 1229In Unix (and Linux) every filesystem object has a "last accessed
1183time", or "`atime`". Passing through a directory to access a file 1230time", or "``atime``". Passing through a directory to access a file
1184within is not considered to be an access for the purposes of 1231within 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``.
1186Symlinks are different it seems. Both reading a symlink (with `readlink()`) 1233Symlinks are different it seems. Both reading a symlink (with ``readlink()``)
1187and looking up a symlink on the way to some other destination can 1234and looking up a symlink on the way to some other destination can
1188update the atime on that symlink. 1235update 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
1192It is not clear why this is the case; POSIX has little to say on the 1239It is not clear why this is the case; POSIX has little to say on the
1193subject. The [clearest statement] is that, if a particular implementation 1240subject. The `clearest statement`_ is that, if a particular implementation
1194updates a timestamp in a place not specified by POSIX, this must be 1241updates a timestamp in a place not specified by POSIX, this must be
1195documented "except that any changes caused by pathname resolution need 1242documented "except that any changes caused by pathname resolution need
1196not be documented". This seems to imply that POSIX doesn't really 1243not be documented". This seems to imply that POSIX doesn't really
1197care about access-time updates during pathname lookup. 1244care 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
1201An examination of history shows that prior to [Linux 1.3.87], the ext2 1248An examination of history shows that prior to `Linux 1.3.87`_, the ext2
1202filesystem, at least, didn't update atime when following a link. 1249filesystem, at least, didn't update atime when following a link.
1203Unfortunately we have no record of why that behavior was changed. 1250Unfortunately we have no record of why that behavior was changed.
1204 1251
1205In any case, access time must now be updated and that operation can be 1252In any case, access time must now be updated and that operation can be
1206quite complex. Trying to stay in RCU-walk while doing it is best 1253quite complex. Trying to stay in RCU-walk while doing it is best
1207avoided. Fortunately it is often permitted to skip the `atime` 1254avoided. Fortunately it is often permitted to skip the ``atime``
1208update. Because `atime` updates cause performance problems in various 1255update. Because ``atime`` updates cause performance problems in various
1209areas, Linux supports the `relatime` mount option, which generally 1256areas, Linux supports the ``relatime`` mount option, which generally
1210limits the updates of `atime` to once per day on files that aren't 1257limits the updates of ``atime`` to once per day on files that aren't
1211being changed (and symlinks never change once created). Even without 1258being 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
1213granularity, so only one update per second is required. 1260granularity, so only one update per second is required.
1214 1261
1215It is easy to test if an `atime` update is needed while in RCU-walk 1262It is easy to test if an ``atime`` update is needed while in RCU-walk
1216mode and, if it isn't, the update can be skipped and RCU-walk mode 1263mode and, if it isn't, the update can be skipped and RCU-walk mode
1217continues. Only when an `atime` update is actually required does the 1264continues. Only when an ``atime`` update is actually required does the
1218path walk drop down to REF-walk. All of this is handled in the 1265path walk drop down to REF-walk. All of this is handled in the
1219`get_link()` function. 1266``get_link()`` function.
1220 1267
1221A few flags 1268A few flags
1222----------- 1269-----------
1223 1270
1224A suitable way to wrap up this tour of pathname walking is to list 1271A suitable way to wrap up this tour of pathname walking is to list
1225the various flags that can be stored in the `nameidata` to guide the 1272the various flags that can be stored in the ``nameidata`` to guide the
1226lookup process. Many of these are only meaningful on the final 1273lookup process. Many of these are only meaningful on the final
1227component, others reflect the current state of the pathname lookup. 1274component, others reflect the current state of the pathname lookup.
1228And then there is `LOOKUP_EMPTY`, which doesn't fit conceptually with 1275And then there is ``LOOKUP_EMPTY``, which doesn't fit conceptually with
1229the others. If this is not set, an empty pathname causes an error 1276the others. If this is not set, an empty pathname causes an error
1230very early on. If it is set, empty pathnames are not considered to be 1277very early on. If it is set, empty pathnames are not considered to be
1231an error. 1278an error.
1232 1279
1233### Global state flags ### 1280Global state flags
1281~~~~~~~~~~~~~~~~~~
1234 1282
1235We have already met two global state flags: `LOOKUP_RCU` and 1283We 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
1237to lookup: RCU-walk, REF-walk, and REF-walk with forced revalidation. 1285to 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
1240yet. This is primarily used to tell the audit subsystem the full 1288yet. This is primarily used to tell the audit subsystem the full
1241context of a particular access being audited. 1289context 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
1244provided by the caller, so it shouldn't be released when it is no 1292provided by the caller, so it shouldn't be released when it is no
1245longer needed. 1293longer 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
1248it had the right name but for some other reason. This happens when 1296it had the right name but for some other reason. This happens when
1249following "`..`", following a symlink to `/`, crossing a mount point 1297following "``..``", following a symlink to ``/``, crossing a mount point
1250or accessing a "`/proc/$PID/fd/$FD`" symlink. In this case the 1298or accessing a "``/proc/$PID/fd/$FD``" symlink. In this case the
1251filesystem has not been asked to revalidate the name (with 1299filesystem 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
1253revalidated, so `d_op->d_weak_revalidate()` is called if 1301revalidated, 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
1255final component or, when creating, unlinking, or renaming, at the penultimate component. 1303final component or, when creating, unlinking, or renaming, at the penultimate component.
1256 1304
1257### Final-component flags ### 1305Final-component flags
1306~~~~~~~~~~~~~~~~~~~~~
1258 1307
1259Some of these flags are only set when the final component is being 1308Some of these flags are only set when the final component is being
1260considered. Others are only checked for when considering that final 1309considered. Others are only checked for when considering that final
1261component. 1310component.
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
1264point, then the mount is triggered. Some operations would trigger it 1313point, then the mount is triggered. Some operations would trigger it
1265anyway, but operations like `stat()` deliberately don't. `statfs()` 1314anyway, but operations like ``stat()`` deliberately don't. ``statfs()``
1266needs to trigger the mount but otherwise behaves a lot like `stat()`, so 1315needs to trigger the mount but otherwise behaves a lot like ``stat()``, so
1267it sets `LOOKUP_AUTOMOUNT`, as does "`quotactl()`" and the handling of 1316it 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
1271symlinks. Some system calls set or clear it implicitly, while 1320symlinks. Some system calls set or clear it implicitly, while
1272others have API flags such as `AT_SYMLINK_FOLLOW` and 1321others 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.
1277Various callers set this and it is also set when the final component 1326Various callers set this and it is also set when the final component
1278is found to be followed by a slash. 1327is found to be followed by a slash.
1279 1328
1280Finally `LOOKUP_OPEN`, `LOOKUP_CREATE`, `LOOKUP_EXCL`, and 1329Finally ``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
1282available to the filesystem and particularly the `->d_revalidate()` 1331available to the filesystem and particularly the ``->d_revalidate()``
1283method. A filesystem can choose not to bother revalidating too hard 1332method. A filesystem can choose not to bother revalidating too hard
1284if it knows that it will be asked to open or create the file soon. 1333if it knows that it will be asked to open or create the file soon.
1285These flags were previously useful for `->lookup()` too but with the 1334These flags were previously useful for ``->lookup()`` too but with the
1286introduction of `->atomic_open()` they are less relevant there. 1335introduction of ``->atomic_open()`` they are less relevant there.
1287 1336
1288End of the road 1337End 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).
125The link self points to the process reading the file system. Each process 125The link self points to the process reading the file system. Each process
126subdirectory has the entries listed in Table 1-1. 126subdirectory has the entries listed in Table 1-1.
127 127
128Note that an open a file descriptor to /proc/<pid> or to any of its
129contained files or subdirectories does not prevent <pid> being reused
130for some other process in the event that <pid> exits. Operations on
131open /proc/<pid> file descriptors corresponding to dead processes
132never act on any new process that the kernel may, through chance, have
133also assigned the process ID <pid>. Instead, operations on these FDs
134usually fail with ESRCH.
128 135
129Table 1-1: Process specific entries in /proc 136Table 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
215snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table. 224snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table.
216It's slow but very precise. 225It's slow but very precise.
217 226
218Table 1-2: Contents of the status files (as of 4.8) 227Table 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.
87For more than 16 blocks an indirect addressing in form of another tree is 87For more than 16 blocks an indirect addressing in form of another tree is
88used. (scheme is the same as the one used for the superblock root nodes) 88used. (scheme is the same as the one used for the superblock root nodes)
89 89
90The filesize is stored 64bit. Inode counting starts with 1. (whilst long 90The filesize is stored 64bit. Inode counting starts with 1. (while long
91filename inodes start with 0) 91filename inodes start with 0)
92 92
93Directories 93Directories
@@ -155,7 +155,7 @@ Then userspace.
155The requirement for a static, fixed preallocated system area comes from how 155The requirement for a static, fixed preallocated system area comes from how
156qnx6fs deals with writes. 156qnx6fs deals with writes.
157Each superblock got it's own half of the system area. So superblock #1 157Each superblock got it's own half of the system area. So superblock #1
158always uses blocks from the lower half whilst superblock #2 just writes to 158always uses blocks from the lower half while superblock #2 just writes to
159blocks represented by the upper half bitmap system area bits. 159blocks represented by the upper half bitmap system area bits.
160 160
161Bitmap blocks, Inode blocks and indirect addressing blocks for those two 161Bitmap 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
454ERRORS 454ERRORS
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
110determine the scope of the problem. 110determine the scope of the problem.
111 111
112Different types of metadata have different owner identifiers. For example, 112Different types of metadata have different owner identifiers. For example,
113directory, attribute and extent tree blocks are all owned by an inode, whilst 113directory, attribute and extent tree blocks are all owned by an inode, while
114freespace btree blocks are owned by an allocation group. Hence the size and 114freespace btree blocks are owned by an allocation group. Hence the size and
115contents of the owner field are determined by the type of metadata object we are 115contents of the owner field are determined by the type of metadata object we are
116looking at. The owner information can also identify misplaced writes (e.g. 116looking 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
193EPERM/EACCESS: 193EPERM/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
199ENODEV: 199ENODEV:
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
15nand-disk and sharpsl-charge triggers. With led triggers disabled, the code 15nand-disk and sharpsl-charge triggers. With led triggers disabled, the code
16optimises away. 16optimises away.
17 17
18Complex triggers whilst available to all LEDs have LED specific 18Complex triggers while available to all LEDs have LED specific
19parameters and work on a per LED basis. The timer trigger is an example. 19parameters and work on a per LED basis. The timer trigger is an example.
20The timer trigger will periodically change the LED brightness between 20The timer trigger will periodically change the LED brightness between
21LED_OFF and the current brightness setting. The "on" and "off" time can 21LED_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
4003converts that received signal to lower intermediate frequency (IF) or 4003converts that received signal to lower intermediate frequency (IF) or
4004baseband frequency (BB). Tuners that could do baseband output are often 4004baseband frequency (BB). Tuners that could do baseband output are often
4005called Zero-IF tuners. Older tuners were typically simple PLL tuners 4005called Zero-IF tuners. Older tuners were typically simple PLL tuners
4006inside a metal box, whilst newer ones are highly integrated chips 4006inside a metal box, while newer ones are highly integrated chips
4007without a metal box "silicon tuners". These controls are mostly 4007without a metal box "silicon tuners". These controls are mostly
4008applicable for new feature rich silicon tuners, just because older 4008applicable for new feature rich silicon tuners, just because older
4009tuners does not have much adjustable features. 4009tuners 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
590Whilst this may seem like a failure of coherency or causality maintenance, it 590While this may seem like a failure of coherency or causality maintenance, it
591isn't, and this behaviour can be observed on certain real CPUs (such as the DEC 591isn't, and this behaviour can be observed on certain real CPUs (such as the DEC
592Alpha). 592Alpha).
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.
2508ATOMIC OPERATIONS 2508ATOMIC OPERATIONS
2509----------------- 2509-----------------
2510 2510
2511Whilst they are technically interprocessor interaction considerations, atomic 2511While they are technically interprocessor interaction considerations, atomic
2512operations are noted specially as some of them imply full memory barriers and 2512operations are noted specially as some of them imply full memory barriers and
2513some don't, but they're very heavily relied on as a group throughout the 2513some don't, but they're very heavily relied on as a group throughout the
2514kernel. 2514kernel.
@@ -2531,7 +2531,7 @@ the device to malfunction.
2531 2531
2532Inside of the Linux kernel, I/O should be done through the appropriate accessor 2532Inside of the Linux kernel, I/O should be done through the appropriate accessor
2533routines - such as inb() or writel() - which know how to make such accesses 2533routines - such as inb() or writel() - which know how to make such accesses
2534appropriately sequential. Whilst this, for the most part, renders the explicit 2534appropriately sequential. While this, for the most part, renders the explicit
2535use of memory barriers unnecessary, there are a couple of situations where they 2535use of memory barriers unnecessary, there are a couple of situations where they
2536might be needed: 2536might be needed:
2537 2537
@@ -2555,7 +2555,7 @@ access the device.
2555 2555
2556This may be alleviated - at least in part - by disabling local interrupts (a 2556This may be alleviated - at least in part - by disabling local interrupts (a
2557form of locking), such that the critical operations are all contained within 2557form of locking), such that the critical operations are all contained within
2558the interrupt-disabled section in the driver. Whilst the driver's interrupt 2558the interrupt-disabled section in the driver. While the driver's interrupt
2559routine is executing, the driver's core may not run on the same CPU, and its 2559routine is executing, the driver's core may not run on the same CPU, and its
2560interrupt is not permitted to happen again until the current interrupt has been 2560interrupt is not permitted to happen again until the current interrupt has been
2561handled, thus the interrupt handler does not need to lock against that. 2561handled, thus the interrupt handler does not need to lock against that.
@@ -2763,7 +2763,7 @@ CACHE COHERENCY
2763 2763
2764Life isn't quite as simple as it may appear above, however: for while the 2764Life isn't quite as simple as it may appear above, however: for while the
2765caches are expected to be coherent, there's no guarantee that that coherency 2765caches are expected to be coherent, there's no guarantee that that coherency
2766will be ordered. This means that whilst changes made on one CPU will 2766will be ordered. This means that while changes made on one CPU will
2767eventually become visible on all CPUs, there's no guarantee that they will 2767eventually become visible on all CPUs, there's no guarantee that they will
2768become apparent in the same order on those other CPUs. 2768become 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
2837The above pair of reads may then fail to happen in the expected order, as the 2837The above pair of reads may then fail to happen in the expected order, as the
2838cacheline holding p may get updated in one of the second CPU's caches whilst 2838cacheline holding p may get updated in one of the second CPU's caches while
2839the update to the cacheline holding v is delayed in the other of the second 2839the update to the cacheline holding v is delayed in the other of the second
2840CPU's caches by some other cache event: 2840CPU'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
2858Basically, whilst both cachelines will be updated on CPU 2 eventually, there's 2858Basically, while both cachelines will be updated on CPU 2 eventually, there's
2859no guarantee that, without intervention, the order of update will be the same 2859no guarantee that, without intervention, the order of update will be the same
2860as that committed on CPU 1. 2860as that committed on CPU 1.
2861 2861
@@ -2885,7 +2885,7 @@ coherency queue before processing any further requests:
2885 2885
2886This sort of problem can be encountered on DEC Alpha processors as they have a 2886This sort of problem can be encountered on DEC Alpha processors as they have a
2887split cache that improves performance by making better use of the data bus. 2887split cache that improves performance by making better use of the data bus.
2888Whilst most CPUs do imply a data dependency barrier on the read when a memory 2888While most CPUs do imply a data dependency barrier on the read when a memory
2889access depends on a read, not all do, so it may not be relied on. 2889access depends on a read, not all do, so it may not be relied on.
2890 2890
2891Other CPUs may also have split caches, but must coordinate between the various 2891Other 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
22Some terms used in this document:- 22Some 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
1Introduction 3Introduction
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
315problems. Quite a few "semantic patches" for the kernel have been packaged 315problems. Quite a few "semantic patches" for the kernel have been packaged
316under the scripts/coccinelle directory; running "make coccicheck" will run 316under the scripts/coccinelle directory; running "make coccicheck" will run
317through those semantic patches and report on any problems found. See 317through those semantic patches and report on any problems found. See
318Documentation/dev-tools/coccinelle.rst for more information. 318:ref:`Documentation/dev-tools/coccinelle.rst <devtools_coccinelle>`
319for more information.
319 320
320Other kinds of portability errors are best found by compiling your code for 321Other kinds of portability errors are best found by compiling your code for
321other architectures. If you do not happen to have an S/390 system or a 322other 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
9of conventions and procedures which are used in the posting of patches; 9of conventions and procedures which are used in the posting of patches;
10following them will make life much easier for everybody involved. This 10following them will make life much easier for everybody involved. This
11document will attempt to cover these expectations in reasonable detail; 11document will attempt to cover these expectations in reasonable detail;
12more information can also be found in the files process/submitting-patches.rst, 12more information can also be found in the files
13process/submitting-drivers.rst, and process/submit-checklist.rst in the kernel 13:ref:`Documentation/process/submitting-patches.rst <submittingpatches>`,
14documentation directory. 14:ref:`Documentation/process/submitting-drivers.rst <submittingdrivers>`
15and :ref:`Documentation/process/submit-checklist.rst <submitchecklist>`.
15 16
16 17
17When to post 18When to post
@@ -198,8 +199,10 @@ pass it to diff with the "-X" option.
198 199
199The tags mentioned above are used to describe how various developers have 200The tags mentioned above are used to describe how various developers have
200been associated with the development of this patch. They are described in 201been associated with the development of this patch. They are described in
201detail in the process/submitting-patches.rst document; what follows here is a 202detail in
202brief summary. Each of these lines has the format: 203the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`
204document; what follows here is a brief summary. Each of these lines has
205the 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
6There are numerous sources of information on Linux kernel development and 6There are numerous sources of information on Linux kernel development and
7related topics. First among those will always be the Documentation 7related topics. First among those will always be the Documentation
8directory found in the kernel source distribution. The top-level process/howto.rst 8directory found in the kernel source distribution. The top-level :ref:`process/howto.rst <process_howto>`
9file is an important starting point; process/submitting-patches.rst and 9file is an important starting point; :ref:`process/submitting-patches.rst <submittingpatches>`
10process/submitting-drivers.rst are also something which all kernel developers should 10and :ref:`process/submitting-drivers.rst <submittingdrivers>`
11are also something which all kernel developers should
11read. Many internal kernel APIs are documented using the kerneldoc 12read. Many internal kernel APIs are documented using the kerneldoc
12mechanism; "make htmldocs" or "make pdfdocs" can be used to generate those 13mechanism; "make htmldocs" or "make pdfdocs" can be used to generate those
13documents in HTML or PDF format (though the version of TeX shipped by some 14documents 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
1Adding a New System Call 4Adding 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
326Sphinx 326Sphinx
327------ 327------
328 328
329Please see :ref:`sphinx_install` in ``Documentation/doc-guide/sphinx.rst`` 329Please see :ref:`sphinx_install` in :ref:`Documentation/doc-guide/sphinx.rst <sphinxdoc>`
330for details about Sphinx requirements. 330for details about Sphinx requirements.
331 331
332Getting updated software 332Getting 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/
1075WG14 is the international standardization working group for the programming 1075WG14 is the international standardization working group for the programming
1076language C, URL: http://www.open-std.org/JTC1/SC22/WG14/ 1076language C, URL: http://www.open-std.org/JTC1/SC22/WG14/
1077 1077
1078Kernel process/coding-style.rst, by greg@kroah.com at OLS 2002: 1078Kernel :ref:`process/coding-style.rst <codingstyle>`, by greg@kroah.com at OLS 2002:
1079http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ 1079http://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
1HOWTO do Linux kernel development 3HOWTO 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
296security-related problem, instead, can cause a release to happen almost 298security-related problem, instead, can cause a release to happen almost
297instantly. 299instantly.
298 300
299The file Documentation/process/stable-kernel-rules.rst in the kernel tree 301The file :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
300documents what kinds of changes are acceptable for the -stable tree, and 302in the kernel tree documents what kinds of changes are acceptable for
301how the release process works. 303the -stable tree, and how the release process works.
302 304
3034.x -git patches 3054.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
361The file admin-guide/reporting-bugs.rst in the main kernel source directory has a good 363The file :ref:`admin-guide/reporting-bugs.rst <reportingbugs>`
364in the main kernel source directory has a good
362template for how to report a possible kernel bug, and details what kind 365template for how to report a possible kernel bug, and details what kind
363of information is needed by the kernel developers to help track down the 366of information is needed by the kernel developers to help track down the
364problem. 367problem.
@@ -424,7 +427,7 @@ add your statements between the individual quoted sections instead of
424writing at the top of the mail. 427writing at the top of the mail.
425 428
426If you add patches to your mail, make sure they are plain readable text 429If you add patches to your mail, make sure they are plain readable text
427as stated in Documentation/process/submitting-patches.rst. 430as stated in :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`.
428Kernel developers don't want to deal with 431Kernel developers don't want to deal with
429attachments or compressed patches; they may want to comment on 432attachments or compressed patches; they may want to comment on
430individual lines of your patch, which works only that way. Make sure you 433individual 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
1Kernel Driver Statement 3Kernel 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 @@
1Linux Kernel Enforcement Statement 1.. _process_statement_kernel:
2
3Linux Kernel Enforcement Statement
2---------------------------------- 4----------------------------------
3 5
4As developers of the Linux kernel, we have a keen interest in how our software 6As 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
1Linux magic numbers 3Linux 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
6This is a short document describing the preferred (or made up, depending 6This is a short document describing the preferred (or made up, depending
7on who you ask) management style for the linux kernel. It's meant to 7on who you ask) management style for the linux kernel. It's meant to
8mirror the process/coding-style.rst document to some degree, and mainly written to 8mirror the :ref:`process/coding-style.rst <codingstyle>` document to some
9avoid answering [#f1]_ the same (or similar) questions over and over again. 9degree, and mainly written to avoid answering [#f1]_ the same (or similar)
10questions over and over again.
10 11
11Management style is very personal and much harder to quantify than 12Management style is very personal and much harder to quantify than
12simple coding style rules, so this document may or may not have anything 13simple 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
19Also read the Documentation/process/submitting-patches.rst document. 19Also read the :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`
20document.
20 21
21 22
22Allocating Device Numbers 23Allocating Device Numbers
@@ -27,7 +28,8 @@ by the Linux assigned name and number authority (currently this is
27Torben Mathiasen). The site is http://www.lanana.org/. This 28Torben Mathiasen). The site is http://www.lanana.org/. This
28also deals with allocating numbers for devices that are not going to 29also deals with allocating numbers for devices that are not going to
29be submitted to the mainstream kernel. 30be submitted to the mainstream kernel.
30See Documentation/admin-guide/devices.rst for more information on this. 31See :ref:`Documentation/admin-guide/devices.rst <admin_devices>`
32for more information on this.
31 33
32If you don't use assigned numbers then when your device is submitted it will 34If you don't use assigned numbers then when your device is submitted it will
33be given an assigned number even if that is different from values you may 35be 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
122Control: 124Control:
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
17Sep 2002: Fix tubfs kmalloc()s 17Sep 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
22Sep 2002: Recognize 3270 control unit type 3174 22Sep 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
297To catch accidental credential alteration at compile time, struct task_struct 297To 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()``,
358Accessing Another Task's Credentials 358Accessing Another Task's Credentials
359------------------------------------ 359------------------------------------
360 360
361Whilst a task may access its own credentials without the need for locking, the 361While a task may access its own credentials without the need for locking, the
362same is not true of a task wanting to access another task's credentials. It 362same is not true of a task wanting to access another task's credentials. It
363must use the RCU read lock and ``rcu_dereference()``. 363must 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
384Should it be necessary to hold another task's credentials for a long period of 384Should it be necessary to hold another task's credentials for a long period of
385time, and possibly to sleep whilst doing so, then the caller should get a 385time, and possibly to sleep while doing so, then the caller should get a
386reference on them using:: 386reference 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
442held if successful. It returns NULL if not successful (out of memory). 442held if successful. It returns NULL if not successful (out of memory).
443 443
444The mutex prevents ``ptrace()`` from altering the ptrace state of a process 444The mutex prevents ``ptrace()`` from altering the ptrace state of a process
445whilst security checks on credentials construction and changing is taking place 445while security checks on credentials construction and changing is taking place
446as the ptrace state may alter the outcome, particularly in the case of 446as 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
132Rather than instantiating a key, it is possible for the possessor of an 132Rather than instantiating a key, it is possible for the possessor of an
133authorisation key to negatively instantiate a key that's under construction. 133authorisation key to negatively instantiate a key that's under construction.
134This is a short duration placeholder that causes any attempt at re-requesting 134This is a short duration placeholder that causes any attempt at re-requesting
135the key whilst it exists to fail with error ENOKEY if negated or the specified 135the key while it exists to fail with error ENOKEY if negated or the specified
136error if rejected. 136error if rejected.
137 137
138This is provided to prevent excessive repeated spawning of /sbin/request-key 138This 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
26I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and 26I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and
27Rx lines are used for audio transmission, whilst the bit clock (BCLK) and 27Rx lines are used for audio transmission, while the bit clock (BCLK) and
28left/right clock (LRC) synchronise the link. I2S is flexible in that either the 28left/right clock (LRC) synchronise the link. I2S is flexible in that either the
29controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock 29controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock
30usually varies depending on the sample rate and the master system clock 30usually varies depending on the sample rate and the master system clock
@@ -49,9 +49,9 @@ PCM
49 49
50PCM is another 4 wire interface, very similar to I2S, which can support a more 50PCM is another 4 wire interface, very similar to I2S, which can support a more
51flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used 51flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used
52to synchronise the link whilst the Tx and Rx lines are used to transmit and 52to synchronise the link while the Tx and Rx lines are used to transmit and
53receive the audio data. Bit clock usually varies depending on sample rate 53receive the audio data. Bit clock usually varies depending on sample rate
54whilst sync runs at the sample rate. PCM also supports Time Division 54while sync runs at the sample rate. PCM also supports Time Division
55Multiplexing (TDM) in that several devices can use the bus simultaneously (this 55Multiplexing (TDM) in that several devices can use the bus simultaneously (this
56is sometimes referred to as network mode). 56is 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
221This allows the host CPU to sleep whilst the DSP, MODEM DAI and the BT DAI are 221This allows the host CPU to sleep while the DSP, MODEM DAI and the BT DAI are
222still in operation. 222still in operation.
223 223
224A BE DAI link can also set the codec to a dummy device if the code is a device 224A 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
157Note that switching branches results in some locks being taken, 157Note that switching branches results in some locks being taken,
158particularly the CPU hotplug lock (in order to avoid races against 158particularly the CPU hotplug lock (in order to avoid races against
159CPUs being brought in the kernel whilst the kernel is getting 159CPUs being brought in the kernel while the kernel is getting
160patched). Calling the static key API from within a hotplug notifier is 160patched). Calling the static key API from within a hotplug notifier is
161thus a sure deadlock recipe. In order to still allow use of the 161thus a sure deadlock recipe. In order to still allow use of the
162functionnality, the following functions are provided: 162functionnality, 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
111available capacity at a low temperature. On the other hand, a high 111available capacity at a low temperature. On the other hand, a high
112value of `k_pu` will result in the governor granting very high power 112value of `k_pu` will result in the governor granting very high power
113whilst temperature is low, and may lead to temperature overshooting. 113while temperature is low, and may lead to temperature overshooting.
114 114
115The default value for `k_pu` is: 115The 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
24performance issues that take place outside of user-space. 24performance issues that take place outside of user-space.
25 25
26Although ftrace is typically considered the function tracer, it 26Although ftrace is typically considered the function tracer, it
27is really a frame work of several assorted tracing utilities. 27is really a framework of several assorted tracing utilities.
28There's latency tracing to examine what occurs between interrupts 28There's latency tracing to examine what occurs between interrupts
29disabled and enabled, as well as for preemption and from a time 29disabled and enabled, as well as for preemption and from a time
30a task is woken to the task is actually scheduled in. 30a task is woken to the task is actually scheduled in.
31 31
32One of the most common uses of ftrace is the event tracing. 32One of the most common uses of ftrace is the event tracing.
33Through out the kernel is hundreds of static event points that 33Throughout the kernel is hundreds of static event points that
34can be enabled via the tracefs file system to see what is 34can be enabled via the tracefs file system to see what is
35going on in certain parts of the kernel. 35going 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
2541recordmcount program (located in the scripts directory). This 2541recordmcount program (located in the scripts directory). This
2542program will parse the ELF headers in the C object to find all 2542program will parse the ELF headers in the C object to find all
2543the locations in the .text section that call mcount. Starting 2543the locations in the .text section that call mcount. Starting
2544with gcc verson 4.6, the -mfentry has been added for x86, which 2544with gcc version 4.6, the -mfentry has been added for x86, which
2545calls "__fentry__" instead of "mcount". Which is called before 2545calls "__fentry__" instead of "mcount". Which is called before
2546the creation of the stack frame. 2546the 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
7Rilascio 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
7Bachi 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
593che :c:func:`cache_add()` venga chiamata dal contesto utente, altrimenti 593che :c:func:`cache_add()` venga chiamata dal contesto utente, altrimenti
594questa opzione deve diventare un parametro di :c:func:`cache_add()`. 594questa opzione deve diventare un parametro di :c:func:`cache_add()`.
595 595
596Exposing Objects Outside This File 596Esporre gli oggetti al di fuori del file
597---------------------------------- 597----------------------------------------
598 598
599Se i vostri oggetti contengono più informazioni, potrebbe non essere 599Se i vostri oggetti contengono più informazioni, potrebbe non essere
600sufficiente copiare i dati avanti e indietro: per esempio, altre parti del 600sufficiente 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
8Introduzione
9============
10
11Riepilogo generale
12------------------
13
14Il resto di questa sezione riguarda il processo di sviluppo del kernel e
15quella sorta di frustrazione che gli sviluppatori e i loro datori di lavoro
16potrebbero dover affrontare. Ci sono molte ragioni per le quali del codice
17per il kernel debba essere incorporato nel kernel ufficiale, fra le quali:
18disponibilità immediata agli utilizzatori, supporto della comunità in
19differenti modalità, e la capacità di influenzare la direzione dello sviluppo
20del kernel.
21Il codice che contribuisce al kernel Linux deve essere reso disponibile sotto
22una licenza GPL-compatibile.
23
24La sezione :ref:`it_development_process` introduce il processo di sviluppo,
25il ciclo di rilascio del kernel, ed i meccanismi della finestra
26d'incorporazione. Il capitolo copre le varie fasi di una modifica: sviluppo,
27revisione e ciclo d'incorporazione. Ci sono alcuni dibattiti su strumenti e
28liste di discussione. Gli sviluppatori che sono in attesa di poter sviluppare
29qualcosa per il kernel sono invitati ad individuare e sistemare bachi come
30esercizio iniziale.
31
32La sezione :ref:`it_development_early_stage` copre i primi stadi della
33pianificazione di un progetto di sviluppo, con particolare enfasi sul
34coinvolgimento della comunità, il prima possibile.
35
36La sezione :ref:`it_development_coding` riguarda il processo di scrittura
37del codice. Qui, sono esposte le diverse insidie che sono state già affrontate
38da altri sviluppatori. Il capitolo copre anche alcuni dei requisiti per le
39modifiche, ed esiste un'introduzione ad alcuni strumenti che possono aiutarvi
40nell'assicurarvi che le modifiche per il kernel siano corrette.
41
42La sezione :ref:`it_development_posting` parla del processo di pubblicazione
43delle modifiche per la revisione. Per essere prese in considerazione dalla
44comunità di sviluppo, le modifiche devono essere propriamente formattate ed
45esposte, e devono essere inviate nel posto giusto. Seguire i consigli presenti
46in questa sezione dovrebbe essere d'aiuto nell'assicurare la migliore
47accoglienza possibile del vostro lavoro.
48
49La sezione :ref:`it_development_followthrough` copre ciò che accade dopo
50la pubblicazione delle modifiche; a questo punto il lavoro è lontano
51dall'essere concluso. Lavorare con i revisori è una parte cruciale del
52processo di sviluppo; questa sezione offre una serie di consigli su come
53evitare problemi in questa importante fase. Gli sviluppatori sono diffidenti
54nell'affermare che il lavoro è concluso quando una modifica è incorporata nei
55sorgenti principali.
56
57La sezione :ref:`it_development_advancedtopics` introduce un paio di argomenti
58"avanzati": gestire le modifiche con git e controllare le modifiche pubblicate
59da altri.
60
61La sezione :ref:`it_development_conclusion` chiude il documento con dei
62riferimenti ad altre fonti che forniscono ulteriori informazioni sullo sviluppo
63del kernel.
64
65Di cosa parla questo documento
66------------------------------
67
68Il kernel Linux, ha oltre 8 milioni di linee di codice e ben oltre 1000
69contributori ad ogni rilascio; è uno dei più vasti e più attivi software
70liberi progettati mai esistiti. Sin dal sul modesto inizio nel 1991,
71questo kernel si è evoluto nel miglior componente per sistemi operativi
72che fanno funzionare piccoli riproduttori musicali, PC, grandi super computer
73e tutte le altre tipologie di sistemi fra questi estremi. È una soluzione
74robusta, efficiente ed adattabile a praticamente qualsiasi situazione.
75
76Con la crescita di Linux è arrivato anche un aumento di sviluppatori
77(ed aziende) desiderosi di partecipare a questo sviluppo. I produttori di
78hardware vogliono assicurarsi che il loro prodotti siano supportati da Linux,
79rendendo questi prodotti attrattivi agli utenti Linux. I produttori di
80sistemi integrati, che usano Linux come componente di un prodotto integrato,
81vogliono che Linux sia capace ed adeguato agli obiettivi ed il più possibile
82alla mano. Fornitori ed altri produttori di software che basano i propri
83prodotti su Linux hanno un chiaro interesse verso capacità, prestazioni ed
84affidabilità del kernel Linux. E gli utenti finali, anche, spesso vorrebbero
85cambiare Linux per renderlo più aderente alle proprie necessità.
86
87Una delle caratteristiche più coinvolgenti di Linux è quella dell'accessibilità
88per gli sviluppatori; chiunque con le capacità richieste può migliorare
89Linux ed influenzarne la direzione di sviluppo. Prodotti non open-source non
90possono offrire questo tipo di apertura, che è una caratteristica del software
91libero. Ma, anzi, il kernel è persino più aperto rispetto a molti altri
92progetti di software libero. Un classico ciclo di sviluppo trimestrale può
93coinvolgere 1000 sviluppatori che lavorano per più di 100 differenti aziende
94(o per nessuna azienda).
95
96Lavorare con la comunità di sviluppo del kernel non è particolarmente
97difficile. Ma, ciononostante, diversi potenziali contributori hanno trovato
98delle difficoltà quando hanno cercato di lavorare sul kernel. La comunità del
99kernel utilizza un proprio modo di operare che gli permette di funzionare
100agevolmente (e genera un prodotto di alta qualità) in un ambiente dove migliaia
101di stringhe di codice sono modificate ogni giorni. Quindi non deve sorprendere
102che il processo di sviluppo del kernel differisca notevolmente dai metodi di
103sviluppo privati.
104
105Il processo di sviluppo del Kernel può, dall'altro lato, risultare
106intimidatorio e strano ai nuovi sviluppatori, ma ha dietro di se buone ragioni
107e solide esperienze. Uno sviluppatore che non comprende i modi della comunità
108del kernel (o, peggio, che cerchi di aggirarli o violarli) avrà un'esperienza
109deludente nel proprio bagaglio. La comunità di sviluppo, sebbene sia utile
110a coloro che cercano di imparare, ha poco tempo da dedicare a coloro che non
111ascoltano o coloro che non sono interessati al processo di sviluppo.
112
113Si spera che coloro che leggono questo documento saranno in grado di evitare
114queste esperienze spiacevoli. C'è molto materiale qui, ma lo sforzo della
115lettura sarà ripagato in breve tempo. La comunità di sviluppo ha sempre
116bisogno di sviluppatori che vogliano aiutare a rendere il kernel migliore;
117il testo seguente potrebbe esservi d'aiuto - o essere d'aiuto ai vostri
118collaboratori- per entrare a far parte della nostra comunità.
119
120Crediti
121-------
122
123Questo documento è stato scritto da Jonathan Corbet, corbet@lwn.net.
124È stato migliorato da Johannes Berg, James Berry, Alex Chiang, Roland
125Dreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh,
126Amanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata e Jochen Voß.
127
128Questo lavoro è stato supportato dalla Linux Foundation; un ringraziamento
129speciale ad Amanda McPherson, che ha visto il valore di questo lavoro e lo ha
130reso possibile.
131
132L'importanza d'avere il codice nei sorgenti principali
133------------------------------------------------------
134
135Alcune aziende e sviluppatori ogni tanto si domandano perché dovrebbero
136preoccuparsi di apprendere come lavorare con la comunità del kernel e di
137inserire il loro codice nel ramo di sviluppo principale (per ramo principale
138s'intende quello mantenuto da Linus Torvalds e usato come base dai
139distributori Linux). Nel breve termine, contribuire al codice può sembrare
140un costo inutile; può sembra più facile tenere separato il proprio codice e
141supportare direttamente i suoi utilizzatori. La verità è che il tenere il
142codice separato ("fuori dai sorgenti", *"out-of-tree"*) è un falso risparmio.
143
144Per dimostrare i costi di un codice "fuori dai sorgenti", eccovi
145alcuni aspetti rilevanti del processo di sviluppo kernel; la maggior parte
146di essi saranno approfonditi dettagliatamente più avanti in questo documento.
147Considerate:
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
209Il ragionamento sopra citato si applica ad ogni codice "fuori dai sorgenti"
210dal kernel, incluso il codice proprietario distribuito solamente in formato
211binario. Ci sono, comunque, dei fattori aggiuntivi che dovrebbero essere
212tenuti in conto prima di prendere in considerazione qualsiasi tipo di
213distribuzione 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
243I produttori di sistemi integrati, in particolare, potrebbero esser tentati
244dall'evitare molto di ciò che è stato detto in questa sezione, credendo che
245stiano distribuendo un prodotto finito che utilizza una versione del kernel
246immutabile e che non richiede un ulteriore sviluppo dopo il rilascio. Questa
247idea non comprende il valore di una vasta revisione del codice e il valore
248del permettere ai propri utenti di aggiungere funzionalità al vostro prodotto.
249Ma anche questi prodotti, hanno una vita commerciale limitata, dopo la quale
250deve essere rilasciata una nuova versione. A quel punto, i produttori il cui
251codice è nel ramo principale di sviluppo avranno un codice ben mantenuto e
252saranno in una posizione migliore per ottenere velocemente un nuovo prodotto
253pronto per essere distribuito.
254
255
256Licenza
257-------
258
259IL codice Linux utilizza diverse licenze, ma il codice completo deve essere
260compatibile con la seconda versione della licenza GNU General Public License
261(GPLv2), che è la licenza che copre la distribuzione del kernel.
262Nella pratica, ciò significa che tutti i contributi al codice sono coperti
263anche'essi dalla GPLv2 (con, opzionalmente, una dicitura che permette la
264possibilità di distribuirlo con licenze più recenti di GPL) o dalla licenza
265three-clause BSD. Qualsiasi contributo che non è coperto da una licenza
266compatibile non verrà accettata nel kernel.
267
268Per il codice sottomesso al kernel non è necessario (o richiesto) la
269concessione del Copyright. Tutto il codice inserito nel ramo principale del
270kernel conserva la sua proprietà originale; ne risulta che ora il kernel abbia
271migliaia di proprietari.
272
273Una conseguenza di questa organizzazione della proprietà è che qualsiasi
274tentativo di modifica della licenza del kernel è destinata ad un quasi sicuro
275fallimento. Esistono alcuni scenari pratici nei quali il consenso di tutti
276i detentori di copyright può essere ottenuto (o il loro codice verrà rimosso
277dal kernel). Quindi, in sostanza, non esiste la possibilità che si giunga ad
278una versione 3 della licenza GPL nel prossimo futuro.
279
280È imperativo che tutto il codice che contribuisce al kernel sia legittimamente
281software libero. Per questa ragione, un codice proveniente da un contributore
282anonimo (o sotto pseudonimo) non verrà accettato. È richiesto a tutti i
283contributori di firmare il proprio codice, attestando così che quest'ultimo
284può essere distribuito insieme al kernel sotto la licenza GPL. Il codice che
285non è stato licenziato come software libero dal proprio creatore, o che
286potrebbe creare problemi di copyright per il kernel (come il codice derivante
287da processi di ingegneria inversa senza le opportune tutele), non può essere
288diffuso.
289
290Domande relative a questioni legate al copyright sono frequenti nelle liste
291di discussione dedicate allo sviluppo di Linux. Tali quesiti, normalmente,
292non riceveranno alcuna risposta, ma una cosa deve essere tenuta presente:
293le persone che risponderanno a quelle domande non sono avvocati e non possono
294fornire supporti legali. Se avete questioni legali relative ai sorgenti
295del codice Linux, non esiste alternativa che quella di parlare con un
296avvocato esperto nel settore. Fare affidamento sulle risposte ottenute da
297una 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
8Come funziona il processo di sviluppo
9=====================================
10
11Lo sviluppo del Kernel agli inizi degli anno '90 era abbastanza libero, con
12un numero di utenti e sviluppatori relativamente basso. Con una base
13di milioni di utenti e con 2000 sviluppatori coinvolti nel giro di un anno,
14il kernel da allora ha messo in atto un certo numero di procedure per rendere
15lo sviluppo più agevole. È richiesta una solida conoscenza di come tale
16processo si svolge per poter esserne parte attiva.
17
18Il quadro d'insieme
19-------------------
20
21Gli sviluppatori kernel utilizzano un calendario di rilascio generico, dove
22ogni due o tre mesi viene effettuata un rilascio importante del kernel.
23I 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
34Ciascun rilascio 4.x è un importante rilascio del kernel con nuove
35funzionalità, modifiche interne dell'API, e molto altro. Un tipico
36rilascio 4.x contiene quasi 13,000 gruppi di modifiche con ulteriori
37modifiche a parecchie migliaia di linee di codice. La 4.x. è pertanto la
38linea di confine nello sviluppo del kernel Linux; il kernel utilizza un sistema
39di sviluppo continuo che integra costantemente nuove importanti modifiche.
40
41Viene seguita una disciplina abbastanza lineare per l'inclusione delle
42patch di ogni rilascio. All'inizio di ogni ciclo di sviluppo, la
43"finestra di inclusione" viene dichiarata aperta. In quel momento il codice
44ritenuto sufficientemente stabile(e che è accettato dalla comunità di sviluppo)
45viene incluso nel ramo principale del kernel. La maggior parte delle
46patch per un nuovo ciclo di sviluppo (e tutte le più importanti modifiche)
47saranno inserite durante questo periodo, ad un ritmo che si attesta sulle
481000 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
52raccolti e, verificati in anticipo. Il funzionamento di tale procedimento
53verrà descritto dettagliatamente più avanti).
54
55La finestra di inclusione resta attiva approssimativamente per due settimane.
56Al termine di questo periodo, Linus Torvald dichiarerà che la finestra è
57chiusa e rilascerà il primo degli "rc" del kernel.
58Per il kernel che è destinato ad essere 2.6.40, per esempio, il rilascio
59che emerge al termine della finestra d'inclusione si chiamerà 2.6.40-rc1.
60Questo rilascio indica che il momento di aggiungere nuovi componenti è
61passato, e che è iniziato il periodo di stabilizzazione del prossimo kernel.
62
63Nelle successive sei/dieci settimane, potranno essere sottoposte solo modifiche
64che vanno a risolvere delle problematiche. Occasionalmente potrà essere
65consentita una modifica più consistente, ma tali occasioni sono rare.
66Gli sviluppatori che tenteranno di aggiungere nuovi elementi al di fuori della
67finestra di inclusione, tendenzialmente, riceveranno un accoglienza poco
68amichevole. Come regola generale: se vi perdete la finestra di inclusione per
69un dato componente, la cosa migliore da fare è aspettare il ciclo di sviluppo
70successivo (un'eccezione può essere fatta per i driver per hardware non
71supportati in precedenza; se toccano codice non facente parte di quello
72attuale, che non causino regressioni e che potrebbero essere aggiunti in
73sicurezza in un qualsiasi momento)
74
75Mentre le correzioni si aprono la loro strada all'interno del ramo principale,
76il ritmo delle modifiche rallenta col tempo. Linus rilascia un nuovo
77kernel -rc circa una volta alla settimana; e ne usciranno circa 6 o 9 prima
78che il kernel venga considerato sufficientemente stabile e che il rilascio
79finale 2.6.x venga fatto. A quel punto tutto il processo ricomincerà.
80
81Esempio: 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
97In che modo gli sviluppatori decidono quando chiudere il ciclo di sviluppo e
98creare quindi una rilascio stabile? Un metro valido è il numero di regressioni
99rilevate nel precedente rilascio. Nessun baco è il benvenuto, ma quelli che
100procurano problemi su sistemi che hanno funzionato in passato sono considerati
101particolarmente seri. Per questa ragione, le modifiche che portano ad una
102regressione sono viste sfavorevolmente e verranno quasi sicuramente annullate
103durante il periodo di stabilizzazione.
104
105L'obiettivo degli sviluppatori è quello di aggiustare tutte le regressioni
106conosciute prima che avvenga il rilascio stabile. Nel mondo reale, questo
107tipo di perfezione difficilmente viene raggiunta; esistono troppe variabili
108in un progetto di questa portata. Arriva un punto dove ritardare il rilascio
109finale peggiora la situazione; la quantità di modifiche in attesa della
110prossima finestra di inclusione crescerà enormemente, creando ancor più
111regressioni al giro successivo. Quindi molti kernel 4.x escono con una
112manciata di regressioni delle quali, si spera, nessuna è grave.
113
114Una volta che un rilascio stabile è fatto, il suo costante mantenimento è
115affidato al "squadra stabilità", attualmente composta da Greg Kroah-Hartman.
116Questa squadra rilascia occasionalmente degli aggiornamenti relativi al
117rilascio stabile usando la numerazione 4.x.y. Per essere presa in
118considerazione per un rilascio d'aggiornamento, una modifica deve:
119(1) correggere un baco importante (2) essere già inserita nel ramo principale
120per il prossimo sviluppo del kernel. Solitamente, passato il loro rilascio
121iniziale, i kernel ricevono aggiornamenti per più di un ciclo di sviluppo.
122Quindi, 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
135La 4.13.16 fu l'aggiornamento finale per la versione 4.13.
136
137Alcuni kernel sono destinati ad essere kernel a "lungo termine"; questi
138riceveranno assistenza per un lungo periodo di tempo. Al momento in cui
139scriviamo, 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
150Questa selezione di kernel di lungo periodo sono puramente dovuti ai loro
151manutentori, alla loro necessità e al tempo per tenere aggiornate proprio
152quelle versioni. Non ci sono altri kernel a lungo termine in programma per
153alcun rilascio in arrivo.
154
155Il ciclo di vita di una patch
156-----------------------------
157
158Le patch non passano direttamente dalla tastiera dello sviluppatori
159al ramo principale del kernel. Esiste, invece, una procedura disegnata
160per assicurare che ogni patch sia di buona qualità e desiderata nel
161ramo principale. Questo processo avviene velocemente per le correzioni
162meno importanti, o, nel caso di patch ampie e controverse, va avanti per anni.
163Per uno sviluppatore la maggior frustrazione viene dalla mancanza di
164comprensione di questo processo o dai tentativi di aggirarlo.
165
166Nella speranza di ridurre questa frustrazione, questo documento spiegherà
167come una patch viene inserita nel kernel. Ciò che segue è un'introduzione
168che descrive il processo ideale. Approfondimenti verranno invece trattati
169più avanti.
170
171Una 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
223Uno dei più grandi errori fatti dagli sviluppatori kernel (o dai loro datori
224di lavoro) è quello di cercare di ridurre tutta la procedura ad una singola
225"integrazione nel remo principale". Questo approccio inevitabilmente conduce
226a una condizione di frustrazione per tutti coloro che sono coinvolti.
227
228Come le modifiche finiscono nel Kernel
229--------------------------------------
230
231Esiste una sola persona che può inserire le patch nel repositorio principale
232del kernel: Linus Torvalds. Ma, di tutte le 9500 patch che entrarono nella
233versione 2.6.38 del kernel, solo 112 (circa l'1,3%) furono scelte direttamente
234da Linus in persona. Il progetto del kernel è cresciuto fino a raggiungere
235una dimensione tale per cui un singolo sviluppatore non può controllare e
236selezionare indipendentemente ogni modifica senza essere supportato.
237La via scelta dagli sviluppatori per indirizzare tale crescita è stata quella
238di utilizzare un sistema di "sottotenenti" basato sulla fiducia.
239
240Il codice base del kernel è spezzato in una serie si sottosistemi: rete,
241supporto per specifiche architetture, gestione della memoria, video e
242strumenti, etc. Molti sottosistemi hanno un manutentore designato: ovvero uno
243sviluppatore che ha piena responsabilità di tutto il codice presente in quel
244sottosistema. 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
247del kernel.
248
249I manutentori di sottosistema gestiscono ciascuno la propria parte dei sorgenti
250del kernel, utilizzando abitualmente (ma certamente non sempre) git.
251Strumenti come git (e affini come quilt o mercurial) permettono ai manutentori
252di stilare una lista delle patch, includendo informazioni sull'autore ed
253altri metadati. In ogni momento, il manutentore può individuare quale patch
254nel sua repositorio non si trova nel ramo principale.
255
256Quando la "finestra di integrazione" si apre, i manutentori di alto livello
257chiederanno a Linus di "prendere" dai loro repositori le modifiche che hanno
258selezionato per l'inclusione. Se Linus acconsente, il flusso di patch si
259convoglierà nel repositorio di quest ultimo, divenendo così parte del ramo
260principale del kernel. La quantità d'attenzione che Linus presta alle
261singole patch ricevute durante l'operazione di integrazione varia.
262È chiaro che, qualche volta, guardi più attentamente. Ma, come regola
263generale, Linus confida nel fatto che i manutentori di sottosistema non
264selezionino pessime patch.
265
266I manutentori di sottosistemi, a turno, possono "prendere" patch
267provenienti da altri manutentori. Per esempio, i sorgenti per la rete rete
268sono costruiti da modifiche che si sono accumulate inizialmente nei sorgenti
269dedicati ai driver per dispositivi di rete, rete senza fili, ecc. Tale
270catena di repositori può essere più o meno lunga, benché raramente ecceda
271i due o tre collegamenti. Questo processo è conosciuto come
272"la catena della fiducia", perché ogni manutentore all'interno della
273catena si fida di coloro che gestiscono i livelli più bassi.
274
275Chiaramente, in un sistema come questo, l'inserimento delle patch all'interno
276del kernel si basa sul trovare il manutentore giusto. Di norma, inviare
277patch direttamente a Linus non è la via giusta.
278
279
280Sorgenti -next
281--------------
282
283La catena di sottosistemi guida il flusso di patch all'interno del kernel,
284ma solleva anche un interessante quesito: se qualcuno volesse vedere tutte le
285patch pronte per la prossima finestra di integrazione?
286Gli sviluppatori si interesseranno alle patch in sospeso per verificare
287che non ci siano altri conflitti di cui preoccuparsi; una modifica che, per
288esempio, cambia il prototipo di una funzione fondamentale del kernel andrà in
289conflitto con qualsiasi altra modifica che utilizzi la vecchia versione di
290quella funzione. Revisori e tester vogliono invece avere accesso alle
291modifiche nella loro totalità prima che approdino nel ramo principale del
292kernel. Uno potrebbe prendere le patch provenienti da tutti i sottosistemi
293d'interesse, ma questo sarebbe un lavoro enorme e fallace.
294
295La risposta ci viene sotto forma di sorgenti -next, dove i sottosistemi sono
296raccolti per essere testati e controllati. Il più vecchio di questi sorgenti,
297gestito da Andrew Morton, è chiamato "-mm" (memory management, che è l'inizio
298di tutto). L'-mm integra patch proveniente da una lunga lista di sottosistemi;
299e ha, inoltre, alcune patch destinate al supporto del debugging.
300
301Oltre a questo, -mm contiene una raccolta significativa di patch che sono
302state selezionate da Andrew direttamente. Queste patch potrebbero essere
303state inviate in una lista di discussione, o possono essere applicate ad una
304parte del kernel per la quale non esiste un sottosistema dedicato.
305Di conseguenza, -mm opera come una specie di sottosistema "ultima spiaggia";
306se per una patch non esiste una via chiara per entrare nel ramo principale,
307allora è probabile che finirà in -mm. Le patch passate per -mm
308eventualmente finiranno nel sottosistema più appropriato o saranno inviate
309direttamente a Linus. In un tipico ciclo di sviluppo, circa il 5-10% delle
310patch andrà nel ramo principale attraverso -mm.
311
312La patch -mm correnti sono disponibili nella cartella "mmotm" (-mm of
313the moment) all'indirizzo:
314
315 http://www.ozlabs.org/~akpm/mmotm/
316
317È molto probabile che l'uso dei sorgenti MMOTM diventi un'esperienza
318frustrante; ci sono buone probabilità che non compili nemmeno.
319
320I sorgenti principali per il prossimo ciclo d'integrazione delle patch
321è linux-next, gestito da Stephen Rothwell. I sorgenti linux-next sono, per
322definizione, un'istantanea di come dovrà apparire il ramo principale dopo che
323la prossima finestra di inclusione si chiuderà. I linux-next sono annunciati
324sulla lista di discussione linux-kernel e linux-next nel momento in cui
325vengono assemblati; e possono essere scaricate da:
326
327 http://www.kernel.org/pub/linux/kernel/next/
328
329Linux-next è divenuto parte integrante del processo di sviluppo del kernel;
330tutte le patch incorporate durante una finestra di integrazione dovrebbero
331aver trovato la propria strada in linux-next, a volte anche prima dell'apertura
332della finestra di integrazione.
333
334
335Sorgenti in preparazione
336------------------------
337
338Nei sorgenti del kernel esiste la cartella drivers/staging/, dove risiedono
339molte sotto-cartelle per i driver o i filesystem che stanno per essere aggiunti
340al kernel. Questi restano nella cartella drivers/staging fintanto che avranno
341bisogno di maggior lavoro; una volta completato, possono essere spostate
342all'interno del kernel nel posto più appropriato. Questo è il modo di tener
343traccia dei driver che non sono ancora in linea con gli standard di codifica
344o qualità, ma che le persone potrebbero voler usare ugualmente e tracciarne
345lo sviluppo.
346
347Greg Kroah-Hartman attualmente gestisce i sorgenti in preparazione. I driver
348che non sono completamente pronti vengono inviati a lui, e ciascun driver avrà
349la propria sotto-cartella in drivers/staging/. Assieme ai file sorgenti
350dei driver, dovrebbe essere presente nella stessa cartella anche un file TODO.
351Il file TODO elenca il lavoro ancora da fare su questi driver per poter essere
352accettati nel kernel, e indica anche la lista di persone da inserire in copia
353conoscenza per ogni modifica fatta. Le regole attuali richiedono che i
354driver debbano, come minimo, compilare adeguatamente.
355
356La *preparazione* può essere una via relativamente facile per inserire nuovi
357driver all'interno del ramo principale, dove, con un po' di fortuna, saranno
358notati da altri sviluppatori e migliorati velocemente. Entrare nella fase
359di preparazione non è però la fine della storia, infatti, il codice che si
360trova nella cartella staging che non mostra regolari progressi potrebbe
361essere rimosso. Le distribuzioni, inoltre, tendono a dimostrarsi relativamente
362riluttanti nell'attivare driver in preparazione. Quindi lo preparazione è,
363nel migliore dei casi, una tappa sulla strada verso il divenire un driver
364del ramo principale.
365
366
367Strumenti
368---------
369
370Come è possibile notare dal testo sopra, il processo di sviluppo del kernel
371dipende pesantemente dalla capacità di guidare la raccolta di patch in
372diverse direzioni. L'intera cosa non funzionerebbe se non venisse svolta
373con l'uso di strumenti appropriati e potenti. Spiegare l'uso di tali
374strumenti non è lo scopo di questo documento, ma c'è spazio per alcuni
375consigli.
376
377In assoluto, nella comunità del kernel, predomina l'uso di git come sistema
378di gestione dei sorgenti. Git è una delle diverse tipologie di sistemi
379distribuiti di controllo versione che sono stati sviluppati nella comunità
380del software libero. Esso è calibrato per lo sviluppo del kernel, e si
381comporta abbastanza bene quando ha a che fare con repositori grandi e con un
382vasto numero di patch. Git ha inoltre la reputazione di essere difficile
383da imparare e utilizzare, benché stia migliorando. Agli sviluppatori
384del kernel viene richiesta un po' di familiarità con git; anche se non lo
385utilizzano per il proprio lavoro, hanno bisogno di git per tenersi al passo
386con il lavoro degli altri sviluppatori (e con il ramo principale).
387
388Git è ora compreso in quasi tutte le distribuzioni Linux. Esiste una sito che
389potete consultare:
390
391 http://git-scm.com/
392
393Qui troverete i riferimenti alla documentazione e alle guide passo-passo.
394
395Tra gli sviluppatori Kernel che non usano git, la scelta alternativa più
396popolare è quasi sicuramente Mercurial:
397
398 http://www.selenic.com/mercurial/
399
400Mercurial condivide diverse caratteristiche con git, ma fornisce
401un'interfaccia che potrebbe risultare più semplice da utilizzare.
402
403L'altro strumento che vale la pena conoscere è Quilt:
404
405 http://savannah.nongnu.org/projects/quilt/
406
407
408Quilt è un sistema di gestione delle patch, piuttosto che un sistema
409di gestione dei sorgenti. Non mantiene uno storico degli eventi; ma piuttosto
410è orientato verso il tracciamento di uno specifico insieme di modifiche
411rispetto ad un codice in evoluzione. Molti dei più grandi manutentori di
412sottosistema utilizzano quilt per gestire le patch che dovrebbero essere
413integrate. Per la gestione di certe tipologie di sorgenti (-mm, per esempio),
414quilt è il miglior strumento per svolgere il lavoro.
415
416
417Liste di discussione
418--------------------
419
420Una grossa parte del lavoro di sviluppo del Kernel Linux viene svolto tramite
421le liste di discussione. È difficile essere un membro della comunità
422pienamente coinvolto se non si partecipa almeno ad una lista da qualche
423parte. Ma, le liste di discussione di Linux rappresentano un potenziale
424problema per gli sviluppatori, che rischiano di venir sepolti da un mare di
425email, restare incagliati nelle convenzioni in vigore nelle liste Linux,
426o entrambi.
427
428Molte delle liste di discussione del Kernel girano su vger.kernel.org;
429l'elenco principale lo si trova sul sito:
430
431 http://vger.kernel.org/vger-lists.html
432
433Esistono liste gestite altrove; un certo numero di queste sono in
434lists.redhat.com.
435
436La lista di discussione principale per lo sviluppo del kernel è, ovviamente,
437linux-kernel. Questa lista è un luogo ostile dove trovarsi; i volumi possono
438raggiungere i 500 messaggi al giorno, la quantità di "rumore" è elevata,
439la conversazione può essere strettamente tecnica e i partecipanti non sono
440sempre preoccupati di mostrare un alto livello di educazione. Ma non esiste
441altro luogo dove la comunità di sviluppo del kernel si unisce per intero;
442gli sviluppatori che evitano tale lista si perderanno informazioni importanti.
443
444Ci sono alcuni consigli che possono essere utili per sopravvivere a
445linux-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
477Infine, la ricerca della corretta lista di discussione è uno degli errori più
478comuni per gli sviluppatori principianti. Qualcuno che pone una domanda
479relativa alla rete su linux-kernel riceverà quasi certamente il suggerimento
480di chiedere sulla lista netdev, che è la lista frequentata dagli sviluppatori
481di rete. Ci sono poi altre liste per i sottosistemi SCSI, video4linux, IDE,
482filesystem, etc. Il miglior posto dove cercare una lista di discussione è il
483file MAINTAINERS che si trova nei sorgenti del kernel.
484
485Iniziare con lo sviluppo del Kernel
486-----------------------------------
487
488Sono comuni le domande sul come iniziare con lo sviluppo del kernel - sia da
489singole persone che da aziende. Altrettanto comuni sono i passi falsi che
490rendono l'inizio di tale relazione più difficile di quello che dovrebbe essere.
491
492Le aziende spesso cercano di assumere sviluppatori noti per creare un gruppo
493di sviluppo iniziale. Questo, in effetti, può essere una tecnica efficace.
494Ma risulta anche essere dispendiosa e non va ad accrescere il bacino di
495sviluppatori kernel con esperienza. È possibile anche "portare a casa"
496sviluppatori per accelerare lo sviluppo del kernel, dando comunque
497all'investimento un po' di tempo. Prendersi questo tempo può fornire
498al datore di lavoro un gruppo di sviluppatori che comprendono sia il kernel
499che l'azienda stessa, e che possono supportare la formazione di altre persone.
500Nel medio periodo, questa è spesso uno delle soluzioni più proficue.
501
502I singoli sviluppatori sono spesso, comprensibilmente, una perdita come punto
503di partenza. Iniziare con un grande progetto può rivelarsi intimidatorio;
504spesso all'inizio si vuole solo verificare il terreno con qualcosa di piccolo.
505Questa è una delle motivazioni per le quali molti sviluppatori saltano alla
506creazione di patch che vanno a sistemare errori di battitura o
507problematiche minori legate allo stile del codice. Sfortunatamente, tali
508patch creano un certo livello di rumore che distrae l'intera comunità di
509sviluppo, quindi, sempre di più, esse vengono degradate. I nuovi sviluppatori
510che desiderano presentarsi alla comunità non riceveranno l'accoglienza
511che vorrebbero con questi mezzi.
512
513Andrew 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
526In assenza di problemi ovvi da risolvere, si consiglia agli sviluppatori
527di consultare, in generale, la lista di regressioni e di bachi aperti.
528Non c'è mai carenza di problematiche bisognose di essere sistemate;
529accollandosi tali questioni gli sviluppatori accumuleranno esperienza con
530la procedura, ed allo stesso tempo, aumenteranno la loro rispettabilità
531all'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
8I primi passi della pianificazione
9==================================
10
11Osservando un progetto di sviluppo per il kernel Linux, si potrebbe essere
12tentati dal saltare tutto e iniziare a codificare. Tuttavia, come ogni
13progetto significativo, molta della preparazione per giungere al successo
14viene fatta prima che una sola linea di codice venga scritta. Il tempo speso
15nella pianificazione e la comunicazione può far risparmiare molto
16tempo in futuro.
17
18Specificare il problema
19-----------------------
20
21Come qualsiasi progetto ingegneristico, un miglioramento del kernel di
22successo parte con una chiara descrizione del problema da risolvere.
23In alcuni casi, questo passaggio è facile: ad esempio quando un driver è
24richiesto per un particolare dispositivo. In altri casi invece, si
25tende a confondere il problema reale con le soluzioni proposte e questo
26può portare all'emergere di problemi.
27
28Facciamo un esempio: qualche anno fa, gli sviluppatori che lavoravano con
29linux audio cercarono un modo per far girare le applicazioni senza dropouts
30o altri artefatti dovuti all'eccessivo ritardo nel sistema. La soluzione
31alla quale giunsero fu un modulo del kernel destinato ad agganciarsi al
32framework Linux Security Module (LSM); questo modulo poteva essere
33configurato per dare ad una specifica applicazione accesso allo
34schedulatore *realtime*. Tale modulo fu implementato e inviato nella
35lista di discussione linux-kernel, dove incontrò subito dei problemi.
36
37Per gli sviluppatori audio, questo modulo di sicurezza era sufficiente a
38risolvere il loro problema nell'immediato. Per l'intera comunità kernel,
39invece, era un uso improprio del framework LSM (che non è progettato per
40conferire privilegi a processi che altrimenti non avrebbero potuto ottenerli)
41e un rischio per la stabilità del sistema. Le loro soluzioni di punta nel
42breve periodo, comportavano un accesso alla schedulazione realtime attraverso
43il meccanismo rlimit, e nel lungo periodo un costante lavoro nella riduzione
44dei ritardi.
45
46La comunità audio, comunque, non poteva vedere al di là della singola
47soluzione che avevano implementato; erano riluttanti ad accettare alternative.
48Il conseguente dissenso lasciò in quegli sviluppatori un senso di
49disillusione nei confronti dell'intero processo di sviluppo; uno di loro
50scrisse 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
60La realtà delle cose fu differente; gli sviluppatori del kernel erano molto
61più preoccupati per la stabilità del sistema, per la manutenzione di lungo
62periodo e cercavano la giusta soluzione alla problematica esistente con uno
63specifico modulo. La morale della storia è quella di concentrarsi sul
64problema - non su di una specifica soluzione- e di discuterne con la comunità
65di sviluppo prima di investire tempo nella scrittura del codice.
66
67Quindi, osservando un progetto di sviluppo del kernel, si dovrebbe
68rispondere 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
78Solo dopo ha senso iniziare a considerare le possibili soluzioni.
79
80Prime discussioni
81-----------------
82
83Quando si pianifica un progetto di sviluppo per il kernel, sarebbe quanto meno
84opportuno discuterne inizialmente con la comunità prima di lanciarsi
85nell'implementazione. Una discussione preliminare può far risparmiare sia
86tempo 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
106Anni di esperienza con la comunità di sviluppo del kernel hanno impartito una
107chiara lezione: il codice per il kernel che è pensato e sviluppato a porte
108chiuse, inevitabilmente, ha problematiche che si rivelano solo quando il
109codice viene rilasciato pubblicamente. Qualche volta tali problemi sono
110importanti e richiedono mesi o anni di sforzi prima che il codice possa
111raggiungere gli standard richiesti della comunità.
112Alcuni 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
134Ciascuno di questi casi è stato un travaglio e ha richiesto del lavoro
135straordinario, cose che avrebbero potuto essere evitate con alcune
136"chiacchierate" preliminari con gli sviluppatori kernel.
137
138Con chi parlare?
139----------------
140
141Quando gli sviluppatori hanno deciso di rendere pubblici i propri progetti, la
142domanda successiva sarà: da dove partiamo? La risposta è quella di trovare
143la giusta lista di discussione e il giusto manutentore. Per le liste di
144discussione, il miglior approccio è quello di cercare la lista più adatta
145nel file MAINTAINERS. Se esiste una lista di discussione di sottosistema,
146è preferibile pubblicare lì piuttosto che sulla lista di discussione generale
147del kernel Linux; avrete maggiori probabilità di trovare sviluppatori con
148esperienza sul tema, e l'ambiente che troverete potrebbe essere più
149incoraggiante.
150
151Trovare manutentori può rivelarsi un po' difficoltoso. Ancora, il file
152MAINTAINERS è il posto giusto da dove iniziare. Il file potrebbe non essere
153sempre aggiornato, inoltre, non tutti i sottosistemi sono rappresentati qui.
154Coloro che sono elencati nel file MAINTAINERS potrebbero, in effetti, non
155essere le persone che attualmente svolgono quel determinato ruolo. Quindi,
156quando c'è un dubbio su chi contattare, un trucco utile è quello di usare
157git (git log in particolare) per vedere chi attualmente è attivo all'interno
158del sottosistema interessato. Controllate chi sta scrivendo le patch,
159e chi, se non ci fosse nessuno, sta aggiungendo la propria firma
160(Signed-off-by) a quelle patch. Quelle sono le persone maggiormente
161qualificate per aiutarvi con lo sviluppo di nuovo progetto.
162
163Il compito di trovare il giusto manutentore, a volte, è una tale sfida che
164ha spinto gli sviluppatori del kernel a scrivere uno script che li aiutasse
165in questa ricerca:
166
167::
168
169 .../scripts/get_maintainer.pl
170
171Se questo script viene eseguito con l'opzione "-f" ritornerà il
172manutentore(i) attuale per un dato file o cartella. Se viene passata una
173patch sulla linea di comando, lo script elencherà i manutentori che
174dovrebbero riceverne una copia. Ci sono svariate opzioni che regolano
175quanto a fondo get_maintainer.pl debba cercare i manutentori;
176siate quindi prudenti nell'utilizzare le opzioni più aggressive poiché
177potreste finire per includere sviluppatori che non hanno un vero interesse
178per il codice che state modificando.
179
180Se tutto ciò dovesse fallire, parlare con Andrew Morton potrebbe essere
181un modo efficace per capire chi è il manutentore di un dato pezzo di codice.
182
183Quando pubblicare
184-----------------
185
186Se potete, pubblicate i vostri intenti durante le fasi preliminari, sarà
187molto utile. Descrivete il problema da risolvere e ogni piano che è stato
188elaborato per l'implementazione. Ogni informazione fornita può aiutare
189la comunità di sviluppo a fornire spunti utili per il progetto.
190
191Un evento che potrebbe risultare scoraggiate e che potrebbe accadere in
192questa fase non è il ricevere una risposta ostile, ma, invece, ottenere
193una misera o inesistente reazione. La triste verità è che: (1) gli
194sviluppatori del kernel tendono ad essere occupati, (2) ci sono tante persone
195con grandi progetti e poco codice (o anche solo la prospettiva di
196avere un codice) a cui riferirsi e (3) nessuno è obbligato a revisionare
197o a fare osservazioni in merito ad idee pubblicate da altri. Oltre a
198questo, progetti di alto livello spesso nascondono problematiche che si
199rivelano solo quando qualcuno cerca di implementarle; per questa ragione
200gli sviluppatori kernel preferirebbero vedere il codice.
201
202Quindi, se una richiesta pubblica di commenti riscuote poco successo, non
203pensate che ciò significhi che non ci sia interesse nel progetto.
204Sfortunatamente, non potete nemmeno assumere che non ci siano problemi con
205la vostra idea. La cosa migliore da fare in questa situazione è quella di
206andare avanti e tenere la comunità informata mentre procedete.
207
208Ottenere riscontri ufficiali
209----------------------------
210
211Se il vostro lavoro è stato svolto in un ambiente aziendale - come molto
212del lavoro fatto su Linux - dovete, ovviamente, avere il permesso dei
213dirigenti prima che possiate pubblicare i progetti, o il codice aziendale,
214su una lista di discussione pubblica. La pubblicazione di codice che non
215è stato rilascio espressamente con licenza GPL-compatibile può rivelarsi
216problematico; prima la dirigenza, e il personale legale, troverà una decisione
217sulla pubblicazione di un progetto, meglio sarà per tutte le persone coinvolte.
218
219A questo punto, alcuni lettori potrebbero pensare che il loro lavoro sul
220kernel è preposto a supportare un prodotto che non è ancora ufficialmente
221riconosciuto. Rivelare le intenzioni dei propri datori di lavori in una
222lista di discussione pubblica potrebbe non essere una soluzione valida.
223In questi casi, vale la pena considerare se la segretezza sia necessaria
224o meno; spesso non c'è una reale necessità di mantenere chiusi i progetti di
225sviluppo.
226
227Detto ciò, ci sono anche casi dove l'azienda legittimamente non può rivelare
228le proprie intenzioni in anticipo durante il processo di sviluppo. Le aziende
229che hanno sviluppatori kernel esperti possono scegliere di procedere a
230carte coperte partendo dall'assunto che saranno in grado di evitare, o gestire,
231in futuro, eventuali problemi d'integrazione. Per le aziende senza questo tipo
232di esperti, la migliore opzione è spesso quella di assumere uno sviluppatore
233esterno che revisioni i progetti con un accordo di segretezza.
234La Linux Foundation applica un programma di NDA creato appositamente per
235aiutare le aziende in questa particolare situazione; potrete trovare più
236informazioni sul sito:
237
238 http://www.linuxfoundation.org/en/NDA_program
239
240Questa tipologia di revisione è spesso sufficiente per evitare gravi problemi
241senza 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
8Scrivere codice corretto
9========================
10
11Nonostante ci sia molto da dire sul processo di creazione, sulla sua solidità
12e sul suo orientamento alla comunità, la prova di ogni progetto di sviluppo
13del kernel si trova nel codice stesso. È il codice che sarà esaminato dagli
14altri sviluppatori ed inserito (o no) nel ramo principale. Quindi è la
15qualità di questo codice che determinerà il successo finale del progetto.
16
17Questa sezione esaminerà il processo di codifica. Inizieremo con uno sguardo
18sulle diverse casistiche nelle quali gli sviluppatori kernel possono
19sbagliare. Poi, l'attenzione si sposterà verso "il fare le cose
20correttamente" e sugli strumenti che possono essere utili in questa missione.
21
22Trappole
23--------
24
25Lo stile del codice
26*******************
27
28Il 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>`.
30Per la maggior parte del tempo, la politica descritta in quel file è stata
31praticamente informativa. Ne risulta che ci sia una quantità sostanziale di
32codice nel kernel che non rispetta le linee guida relative allo stile.
33La presenza di quel codice conduce a due distinti pericoli per gli
34sviluppatori kernel.
35
36Il primo di questi è credere che gli standard di codifica del kernel
37non sono importanti e possono non essere applicati. La verità è che
38aggiungere nuovo codice al kernel è davvero difficile se questo non
39rispetta le norme; molti sviluppatori richiederanno che il codice sia
40riformulato prima che anche solo lo revisionino. Una base di codice larga
41quanto il kernel richiede una certa uniformità, in modo da rendere possibile
42per gli sviluppatori una comprensione veloce di ogni sua parte. Non ci sono,
43quindi, più spazi per un codice formattato alla carlona.
44
45Occasionalmente, lo stile di codifica del kernel andrà in conflitto con lo
46stile richiesto da un datore di lavoro. In alcuni casi, lo stile del kernel
47dovrà prevalere prima che il codice venga inserito. Mettere il codice
48all'interno del kernel significa rinunciare a un certo grado di controllo
49in differenti modi - incluso il controllo sul come formattare il codice.
50
51L’altra trappola è quella di pensare che il codice già presente nel kernel
52abbia urgentemente bisogno di essere sistemato. Gli sviluppatori potrebbero
53iniziare a generare patch che correggono lo stile come modo per prendere
54famigliarità con il processo, o come modo per inserire i propri nomi nei
55changelog del kernel – o entrambe. La comunità di sviluppo vede un attività
56di codifica puramente correttiva come "rumore"; queste attività riceveranno
57una fredda accoglienza. Di conseguenza è meglio evitare questo tipo di patch.
58Mentre si lavora su un pezzo di codice è normale correggerne anche lo stile,
59ma le modifiche di stile non dovrebbero essere fatte fini a se stesse.
60
61Il documento sullo stile del codice non dovrebbe essere letto come una legge
62assoluta 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
64nel limite di 80 colonne), fatelo e basta.
65
66Notate che potete utilizzare lo strumento “clang-format” per aiutarvi con
67le regole, per una riformattazione automatica e veloce del vostro codice
68e per revisionare interi file per individuare errori nello stile di codifica,
69refusi e possibili miglioramenti. Inoltre è utile anche per classificare gli
70``#includes``, per allineare variabili/macro, per testi derivati ed altri
71compiti del genere. Consultate il file
72:ref:`Documentation/translations/it_IT/process/clang-format.rst <clangformat>`
73per maggiori dettagli
74
75
76Livelli di astrazione
77*********************
78
79
80I professori di Informatica insegnano ai propri studenti a fare ampio uso dei
81livelli di astrazione nel nome della flessibilità e del nascondere informazioni.
82Certo il kernel fa un grande uso dell'astrazione; nessun progetto con milioni
83di righe di codice potrebbe fare altrimenti e sopravvivere. Ma l'esperienza
84ha dimostrato che un'eccessiva o prematura astrazione può rivelarsi dannosa
85al pari di una prematura ottimizzazione. L'astrazione dovrebbe essere usata
86fino al livello necessario e non oltre.
87
88Ad un livello base, considerate una funzione che ha un argomento che viene
89sempre impostato a zero da tutti i chiamanti. Uno potrebbe mantenere
90quell'argomento nell'eventualità qualcuno volesse sfruttare la flessibilità
91offerta. In ogni caso, tuttavia, ci sono buone possibilità che il codice
92che va ad implementare questo argomento aggiuntivo, sia stato rotto in maniera
93sottile, in un modo che non è mai stato notato - perché non è mai stato usato.
94Oppure, quando sorge la necessità di avere più flessibilità, questo argomento
95non la fornisce in maniera soddisfacente. Gli sviluppatori di Kernel,
96sottopongono costantemente patch che vanno a rimuovere gli argomenti
97inutilizzate; anche se, in generale, non avrebbero dovuto essere aggiunti.
98
99I livelli di astrazione che nascondono l'accesso all'hardware -
100spesso per poter usare dei driver su diversi sistemi operativi - vengono
101particolarmente disapprovati. Tali livelli oscurano il codice e possono
102peggiorare le prestazioni; essi non appartengono al kernel Linux.
103
104D'altro canto, se vi ritrovate a dover copiare una quantità significativa di
105codice proveniente da un altro sottosistema del kernel, è tempo di chiedersi
106se, in effetti, non avrebbe più senso togliere parte di quel codice e metterlo
107in una libreria separata o di implementare quella funzionalità ad un livello
108più elevato. Non c'è utilità nel replicare lo stesso codice per tutto
109il kernel.
110
111
112#ifdef e l'uso del preprocessore in generale
113********************************************
114
115Il preprocessore C sembra essere una fonte di attrazione per qualche
116programmatore C, che ci vede una via per ottenere una grande flessibilità
117all'interno di un file sorgente. Ma il preprocessore non è scritto in C,
118e un suo massiccio impiego conduce a un codice che è molto più difficile
119da leggere per gli altri e che rende più difficile il lavoro di verifica del
120compilatore. L'uso eccessivo del preprocessore è praticamente sempre il segno
121di un codice che necessita di un certo lavoro di pulizia.
122
123La compilazione condizionata con #ifdef è, in effetti, un potente strumento,
124ed esso viene usato all'interno del kernel. Ma esiste un piccolo desiderio:
125quello di vedere il codice coperto solo da una leggera spolverata di
126blocchi #ifdef. Come regola generale, quando possibile, l'uso di #ifdef
127dovrebbe essere confinato nei file d'intestazione. Il codice compilato
128condizionatamente può essere confinato a funzioni tali che, nel caso in cui
129il codice non deve essere presente, diventano vuote. Il compilatore poi
130ottimizzerà la chiamata alla funzione vuota rimuovendola. Il risultato è
131un codice molto più pulito, più facile da seguire.
132
133Le macro del preprocessore C presentano una serie di pericoli, inclusi
134valutazioni multiple di espressioni che hanno effetti collaterali e non
135garantiscono una sicurezza rispetto ai tipi. Se siete tentati dal definire
136una macro, considerate l'idea di creare invece una funzione inline. Il codice
137che ne risulterà sarà lo stesso, ma le funzioni inline sono più leggibili,
138non considerano i propri argomenti più volte, e permettono al compilatore di
139effettuare controlli sul tipo degli argomenti e del valore di ritorno.
140
141
142Funzioni inline
143***************
144
145Comunque, anche le funzioni inline hanno i loro pericoli. I programmatori
146potrebbero innamorarsi dell'efficienza percepita derivata dalla rimozione
147di una chiamata a funzione. Queste funzioni, tuttavia, possono ridurre le
148prestazioni. Dato che il loro codice viene replicato ovunque vi sia una
149chiamata ad esse, si finisce per gonfiare le dimensioni del kernel compilato.
150Questi, a turno, creano pressione sulla memoria cache del processore, e questo
151può causare rallentamenti importanti. Le funzioni inline, di norma, dovrebbero
152essere piccole e usate raramente. Il costo di una chiamata a funzione, dopo
153tutto, non è così alto; la creazione di molte funzioni inline è il classico
154esempio di un'ottimizzazione prematura.
155
156In generale, i programmatori del kernel ignorano gli effetti della cache a
157loro rischio e pericolo. Il classico compromesso tempo/spazio teorizzato
158all'inizio delle lezioni sulle strutture dati spesso non si applica
159all'hardware moderno. Lo spazio *è* tempo, in questo senso un programma
160più grande sarà più lento rispetto ad uno più compatto.
161
162I compilatori più recenti hanno preso un ruolo attivo nel decidere se
163una data funzione deve essere resa inline oppure no. Quindi l'uso
164indiscriminato della parola chiave "inline" potrebbe non essere non solo
165eccessivo, ma anche irrilevante.
166
167Sincronizzazione
168****************
169
170Nel maggio 2006, il sistema di rete "Devicescape" fu rilasciato in pompa magna
171sotto la licenza GPL e reso disponibile per la sua inclusione nella ramo
172principale del kernel. Questa donazione fu una notizia bene accolta;
173il supporto per le reti senza fili era considerata, nel migliore dei casi,
174al di sotto degli standard; il sistema Deviscape offrì la promessa di una
175risoluzione a tale situazione. Tuttavia, questo codice non fu inserito nel
176ramo principale fino al giugno del 2007 (2.6.22). Cosa accadde?
177
178Quel codice mostrava numerosi segnali di uno sviluppo in azienda avvenuto
179a porte chiuse. Ma in particolare, un grosso problema fu che non fu
180progettato per girare in un sistema multiprocessore. Prima che questo
181sistema di rete (ora chiamato mac80211) potesse essere inserito, fu necessario
182un lavoro sugli schemi di sincronizzazione.
183
184Una volta, il codice del kernel Linux poteva essere sviluppato senza pensare
185ai problemi di concorrenza presenti nei sistemi multiprocessore. Ora,
186comunque, questo documento è stato scritto su di un portatile dual-core.
187Persino su sistemi a singolo processore, il lavoro svolto per incrementare
188la capacità di risposta aumenterà il livello di concorrenza interno al kernel.
189I giorni nei quali il codice poteva essere scritto senza pensare alla
190sincronizzazione sono da passati tempo.
191
192Ogni risorsa (strutture dati, registri hardware, etc.) ai quali si potrebbe
193avere accesso simultaneo da più di un thread deve essere sincronizzato. Il
194nuovo codice dovrebbe essere scritto avendo tale accortezza in testa;
195riadattare la sincronizzazione a posteriori è un compito molto più difficile.
196Gli sviluppatori del kernel dovrebbero prendersi il tempo di comprendere bene
197le primitive di sincronizzazione, in modo da sceglier lo strumento corretto
198per eseguire un compito. Il codice che presenta una mancanza di attenzione
199alla concorrenza avrà un percorso difficile all'interno del ramo principale.
200
201Regressioni
202***********
203
204Vale la pena menzionare un ultimo pericolo: potrebbe rivelarsi accattivante
205l'idea di eseguire un cambiamento (che potrebbe portare a grandi
206miglioramenti) che porterà ad alcune rotture per gli utenti esistenti.
207Questa tipologia di cambiamento è chiamata "regressione", e le regressioni son
208diventate mal viste nel ramo principale del kernel. Con alcune eccezioni,
209i cambiamenti che causano regressioni saranno fermati se quest'ultime non
210potranno essere corrette in tempo utile. È molto meglio quindi evitare
211la regressione fin dall'inizio.
212
213Spesso si è argomentato che una regressione può essere giustificata se essa
214porta risolve più problemi di quanti non ne crei. Perché, dunque, non fare
215un cambiamento se questo porta a nuove funzionalità a dieci sistemi per
216ognuno dei quali esso determina una rottura? La migliore risposta a questa
217domanda 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
227Una particolare tipologia di regressione mal vista consiste in una qualsiasi
228sorta di modifica all'ABI dello spazio utente. Una volta che un'interfaccia
229viene esportata verso lo spazio utente, dev'essere supportata all'infinito.
230Questo fatto rende la creazione di interfacce per lo spazio utente
231particolarmente complicato: dato che non possono venir cambiate introducendo
232incompatibilità, esse devono essere fatte bene al primo colpo. Per questa
233ragione sono sempre richieste: ampie riflessioni, documentazione chiara e
234ampie revisioni dell'interfaccia verso lo spazio utente.
235
236
237Strumenti di verifica del codice
238--------------------------------
239Almeno per ora la scrittura di codice priva di errori resta un ideale
240irraggiungibile ai più. Quello che speriamo di poter fare, tuttavia, è
241trovare e correggere molti di questi errori prima che il codice entri nel
242ramo principale del kernel. A tal scopo gli sviluppatori del kernel devono
243mettere insieme una schiera impressionante di strumenti che possano
244localizzare automaticamente un'ampia varietà di problemi. Qualsiasi problema
245trovato dal computer è un problema che non affliggerà l'utente in seguito,
246ne consegue che gli strumenti automatici dovrebbero essere impiegati ovunque
247possibile.
248
249Il primo passo consiste semplicemente nel fare attenzione agli avvertimenti
250proveniente dal compilatore. Versioni moderne di gcc possono individuare
251(e segnalare) un gran numero di potenziali errori. Molto spesso, questi
252avvertimenti indicano problemi reali. Di regola, il codice inviato per la
253revisione non dovrebbe produrre nessun avvertimento da parte del compilatore.
254Per mettere a tacere gli avvertimenti, cercate di comprenderne le cause reali
255e cercate di evitare le "riparazioni" che fan sparire l'avvertimento senza
256però averne trovato la causa.
257
258Tenete a mente che non tutti gli avvertimenti sono disabilitati di default.
259Costruite il kernel con "make EXTRA_CFLAGS=-W" per ottenerli tutti.
260
261Il kernel fornisce differenti opzioni che abilitano funzionalità di debugging;
262molti di queste sono trovano all'interno del sotto menu "kernel hacking".
263La maggior parte di queste opzioni possono essere attivate per qualsiasi
264kernel utilizzato per lo sviluppo o a scopo di test. In particolare dovreste
265attivare:
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
285Esistono ancora delle altre opzioni di debugging, di alcune di esse
286discuteremo qui sotto. Alcune di esse hanno un forte impatto e non dovrebbero
287essere usate tutte le volte. Ma qualche volta il tempo speso nell'capire
288le opzioni disponibili porterà ad un risparmio di tempo nel breve termine.
289
290Uno degli strumenti di debugging più tosti è il *locking checker*, o
291"lockdep". Questo strumento traccerà qualsiasi acquisizione e rilascio di
292ogni *lock* (spinlock o mutex) nel sistema, l'ordine con il quale i *lock*
293sono acquisiti in relazione l'uno con l'altro, l'ambiente corrente di
294interruzione, eccetera. Inoltre esso può assicurare che i *lock* vengano
295acquisiti sempre nello stesso ordine, che le stesse assunzioni sulle
296interruzioni si applichino in tutte le occasioni, e così via. In altre parole,
297lockdep può scovare diversi scenari nei quali il sistema potrebbe, in rari
298casi, 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
300permette di trovare tali problemi automaticamente e in anticipo.
301
302In qualità di programmatore kernel diligente, senza dubbio, dovrete controllare
303il valore di ritorno di ogni operazione (come l'allocazione della memoria)
304poiché esso potrebbe fallire. Il nocciolo della questione è che i percorsi
305di gestione degli errori, con grande probabilità, non sono mai stati
306collaudati del tutto. Il codice collaudato tende ad essere codice bacato;
307potrete quindi essere più a vostro agio con il vostro codice se tutti questi
308percorsi fossero stati verificati un po' di volte.
309
310Il kernel fornisce un framework per l'inserimento di fallimenti che fa
311esattamente al caso, specialmente dove sono coinvolte allocazioni di memoria.
312Con l'opzione per l'inserimento dei fallimenti abilitata, una certa percentuale
313di allocazione di memoria sarà destinata al fallimento; questi fallimenti
314possono essere ridotti ad uno specifico pezzo di codice. Procedere con
315l'inserimento dei fallimenti attivo permette al programmatore di verificare
316come il codice risponde quando le cose vanno male. Consultate:
317Documentation/fault-injection/fault-injection.txt per avere maggiori
318informazioni su come utilizzare questo strumento.
319
320Altre tipologie di errori possono essere riscontrati con lo strumento di
321analisi statica "sparse". Con Sparse, il programmatore può essere avvisato
322circa la confusione tra gli indirizzi dello spazio utente e dello spazio
323kernel, un miscuglio fra quantità big-endian e little-endian, il passaggio
324di un valore intero dove ci sia aspetta un gruppo di flag, e così via.
325Sparse deve essere installato separatamente (se il vostra distribuzione non
326lo prevede, potete trovarlo su https://sparse.wiki.kernel.org/index.php/Main_Page);
327può essere attivato sul codice aggiungendo "C=1" al comando make.
328
329Lo strumento "Coccinelle" (http://coccinelle.lip6.fr/) è in grado di trovare
330una vasta varietà di potenziali problemi di codifica; e può inoltre proporre
331soluzioni per risolverli. Un buon numero di "patch semantiche" per il kernel
332sono state preparate nella cartella scripts/coccinelle; utilizzando
333"make coccicheck" esso percorrerà tali patch semantiche e farà rapporto su
334qualsiasi problema trovato. Per maggiori informazioni, consultate
335:ref:`Documentation/dev-tools/coccinelle.rst <devtools_coccinelle>`.
336
337Altri errori di portabilità sono meglio scovati compilando il vostro codice
338per altre architetture. Se non vi accade di avere un sistema S/390 o una
339scheda di sviluppo Blackfin sotto mano, potete comunque continuare la fase
340di compilazione. Un vasto numero di cross-compilatori per x86 possono
341essere trovati al sito:
342
343 http://www.kernel.org/pub/tools/crosstool/
344
345Il tempo impiegato nell'installare e usare questi compilatori sarà d'aiuto
346nell'evitare situazioni imbarazzanti nel futuro.
347
348
349Documentazione
350--------------
351
352La documentazione è spesso stata più un'eccezione che una regola nello
353sviluppo del kernel. Nonostante questo, un'adeguata documentazione aiuterà
354a facilitare l'inserimento di nuovo codice nel kernel, rende la vita più
355facile per gli altri sviluppatori e sarà utile per i vostri utenti. In molti
356casi, la documentazione è divenuta sostanzialmente obbligatoria.
357
358La prima parte di documentazione per qualsiasi patch è il suo changelog.
359Questi dovrebbero descrivere le problematiche risolte, la tipologia di
360soluzione, le persone che lavorano alla patch, ogni effetto rilevante
361sulle prestazioni e tutto ciò che può servire per la comprensione della
362patch. Assicuratevi che il changelog dica *perché*, vale la pena aggiungere
363la patch; un numero sorprendente di sviluppatori sbaglia nel fornire tale
364informazione.
365
366Qualsiasi codice che aggiunge una nuova interfaccia in spazio utente - inclusi
367nuovi file in sysfs o /proc - dovrebbe includere la documentazione di tale
368interfaccia così da permette agli sviluppatori dello spazio utente di sapere
369con cosa stanno lavorando. Consultate: Documentation/ABI/README per avere una
370descrizione di come questi documenti devono essere impostati e quali
371informazioni devono essere fornite.
372
373Il file :ref:`Documentation/translations/it_IT/admin-guide/kernel-parameters.rst <kernelparameters>`
374descrive tutti i parametri di avvio del kernel. Ogni patch che aggiunga
375nuovi parametri dovrebbe aggiungere nuove voci a questo file.
376
377Ogni nuova configurazione deve essere accompagnata da un testo di supporto
378che spieghi chiaramente le opzioni e spieghi quando l'utente potrebbe volerle
379selezionare.
380
381Per molti sottosistemi le informazioni sull'API interna sono documentate sotto
382forma di commenti formattati in maniera particolare; questi commenti possono
383essere estratti e formattati in differenti modi attraverso lo script
384"kernel-doc". Se state lavorando all'interno di un sottosistema che ha
385commenti kerneldoc dovreste mantenerli e aggiungerli, in maniera appropriata,
386per le funzioni disponibili esternamente. Anche in aree che non sono molto
387documentate, non c'è motivo per non aggiungere commenti kerneldoc per il
388futuro; infatti, questa può essere un'attività utile per sviluppatori novizi
389del kernel. Il formato di questi commenti, assieme alle informazione su come
390creare modelli per kerneldoc, possono essere trovati in
391:ref:`Documentation/translations/it_IT/doc-guide/ <doc_guide>`.
392
393Chiunque legga un ammontare significativo di codice kernel noterà che, spesso,
394i commenti si fanno maggiormente notare per la loro assenza. Ancora una volta,
395le aspettative verso il nuovo codice sono più alte rispetto al passato;
396inserire codice privo di commenti sarà più difficile. Detto ciò, va aggiunto
397che non si desiderano commenti prolissi per il codice. Il codice dovrebbe
398essere, di per sé, leggibile, con dei commenti che spieghino gli aspetti più
399sottili.
400
401Determinate cose dovrebbero essere sempre commentate. L'uso di barriere
402di memoria dovrebbero essere accompagnate da una riga che spieghi perché sia
403necessaria. Le regole di sincronizzazione per le strutture dati, generalmente,
404necessitano di una spiegazioni da qualche parte. Le strutture dati più
405importanti, in generale, hanno bisogno di una documentazione onnicomprensiva.
406Le dipendenze che non sono ovvie tra bit separati di codice dovrebbero essere
407indicate. Tutto ciò che potrebbe indurre un inserviente del codice a fare
408una "pulizia" incorretta, ha bisogno di un commento che dica perché è stato
409fatto in quel modo. E così via.
410
411Cambiamenti interni dell'API
412----------------------------
413
414L'interfaccia binaria fornita dal kernel allo spazio utente non può essere
415rotta tranne che in circostanze eccezionali. L'interfaccia di programmazione
416interna al kernel, invece, è estremamente fluida e può essere modificata al
417bisogno. Se vi trovate a dover lavorare attorno ad un'API del kernel o
418semplicemente non state utilizzando una funzionalità offerta perché questa
419non rispecchia i vostri bisogni, allora questo potrebbe essere un segno che
420l'API ha bisogno di essere cambiata. In qualità di sviluppatore del kernel,
421hai il potere di fare questo tipo di modifica.
422
423Ci sono ovviamente alcuni punti da cogliere. I cambiamenti API possono essere
424fatti, ma devono essere giustificati. Quindi ogni patch che porta ad una
425modifica dell'API interna dovrebbe essere accompagnata da una descrizione
426della modifica in sé e del perché essa è necessaria. Questo tipo di
427cambiamenti dovrebbero, inoltre, essere fatti in una patch separata, invece di
428essere sepolti all'interno di una patch più grande.
429
430L'altro punto da cogliere consiste nel fatto che uno sviluppatore che
431modifica l'API deve, in generale, essere responsabile della correzione
432di tutto il codice del kernel che viene rotto per via della sua modifica.
433Per una funzione ampiamente usata, questo compito può condurre letteralmente
434a centinaia o migliaia di modifiche, molte delle quali sono in conflitto con
435il lavoro svolto da altri sviluppatori. Non c'è bisogno di dire che questo
436può essere un lavoro molto grosso, quindi è meglio essere sicuri che la
437motivazione sia ben solida. Notate che lo strumento Coccinelle può fornire
438un aiuto con modifiche estese dell'API.
439
440Quando viene fatta una modifica API incompatibile, una persona dovrebbe,
441quando possibile, assicurarsi che quel codice non aggiornato sia trovato
442dal compilatore. Questo vi aiuterà ad essere sicuri d'avere trovato,
443tutti gli usi di quell'interfaccia. Inoltre questo avviserà gli sviluppatori
444di codice fuori dal kernel che c'è un cambiamento per il quale è necessario del
445lavoro. Il supporto al codice fuori dal kernel non è qualcosa di cui gli
446sviluppatori del kernel devono preoccuparsi, ma non dobbiamo nemmeno rendere
447più 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
8Pubblicare modifiche
9====================
10
11Prima o poi arriva il momento in cui il vostro lavoro è pronto per essere
12presentato alla comunità per una revisione ed eventualmente per la sua
13inclusione nel ramo principale del kernel. Com'era prevedibile,
14la comunità di sviluppo del kernel ha elaborato un insieme di convenzioni
15e di procedure per la pubblicazione delle patch; seguirle renderà la vita
16più facile a tutti quanti. Questo documento cercherà di coprire questi
17argomenti con un ragionevole livello di dettaglio; più informazioni possono
18essere 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
24Quando pubblicarle
25------------------
26
27C'è sempre una certa resistenza nel pubblicare patch finché non sono
28veramente "pronte". Per semplici patch questo non è un problema.
29Ma quando il lavoro è di una certa complessità, c'è molto da guadagnare
30dai riscontri che la comunità può darvi prima che completiate il lavoro.
31Dovreste considerare l'idea di pubblicare un lavoro incompleto, o anche
32preparare un ramo git disponibile agli sviluppatori interessati, cosicché
33possano stare al passo col vostro lavoro in qualunque momento.
34
35Quando pubblicate del codice che non è considerato pronto per l'inclusione,
36è bene che lo diciate al momento della pubblicazione. Inoltre, aggiungete
37informazioni sulle cose ancora da sviluppare e sui problemi conosciuti.
38Poche persone guarderanno delle patch che si sa essere fatte a metà,
39ma quelli che lo faranno penseranno di potervi aiutare a condurre il vostro
40sviluppo nella giusta direzione.
41
42
43Prima di creare patch
44---------------------
45
46Ci sono un certo numero di cose che dovreste fare prima di considerare
47l'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
67Come regola generale, pensarci un po' di più prima di inviare il codice
68ripaga quasi sempre lo sforzo.
69
70
71Preparazione di una patch
72-------------------------
73
74La preparazione delle patch per la pubblicazione può richiedere una quantità
75di lavoro significativa, ma, ripetiamolo ancora, generalmente sconsigliamo
76di risparmiare tempo in questa fase, anche sul breve periodo.
77
78Le patch devono essere preparate per una specifica versione del kernel.
79Come regola generale, una patch dovrebbe basarsi sul ramo principale attuale
80così come lo si trova nei sorgenti git di Linus. Quando vi basate sul ramo
81principale, cominciate da un punto di rilascio ben noto - uno stabile o
82un -rc - piuttosto che creare il vostro ramo da quello principale in un punto
83a caso.
84
85Per facilitare una revisione e una verifica più estesa, potrebbe diventare
86necessaria la produzione di versioni per -mm, linux-next o i sorgenti di un
87sottosistema. Basare questa patch sui suddetti sorgenti potrebbe richiedere
88un lavoro significativo nella risoluzione dei conflitti e nella correzione dei
89cambiamenti di API; questo potrebbe variare a seconda dell'area d'interesse
90della vostra patch e da quello che succede altrove nel kernel.
91
92Solo le modifiche più semplici dovrebbero essere preparate come una singola
93patch; tutto il resto dovrebbe essere preparato come una serie logica di
94modifiche. Spezzettare le patch è un po' un'arte; alcuni sviluppatori
95passano molto tempo nel capire come farlo in modo che piaccia alla comunità.
96Ci sono alcune regole spannometriche, che comunque possono aiutare
97considerevolmente:
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
143Lavorare per creare la serie di patch perfetta potrebbe essere frustrante
144perché richiede un certo tempo e soprattutto dopo che il "vero lavoro" è
145già stato fatto. Quando ben fatto, comunque, è tempo ben speso.
146
147
148Formattazione delle patch e i changelog
149---------------------------------------
150
151Quindi adesso avete una serie perfetta di patch pronte per la pubblicazione,
152ma il lavoro non è davvero finito. Ogni patch deve essere preparata con
153un messaggio che spieghi al resto del mondo, in modo chiaro e veloce,
154il 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
178Gli elementi qui sopra, assieme, formano il changelog di una patch.
179Scrivere un buon changelog è cruciale ma è spesso un'arte trascurata;
180vale la pena spendere qualche parola in più al riguardo. Quando scrivete
181un changelog dovreste tenere ben presente che molte persone leggeranno
182le vostre parole. Queste includono i manutentori di un sotto-sistema, e i
183revisori che devono decidere se la patch debba essere inclusa o no,
184le distribuzioni e altri manutentori che cercano di valutare se la patch
185debba essere applicata su kernel più vecchi, i cacciatori di bachi che si
186chiederanno se la patch è la causa di un problema che stanno cercando,
187gli utenti che vogliono sapere com'è cambiato il kernel, e molti altri.
188Un buon changelog fornisce le informazioni necessarie a tutte queste
189persone nel modo più diretto e conciso possibile.
190
191A questo scopo, la riga riassuntiva dovrebbe descrivere gli effetti della
192modifica e la motivazione della patch nel modo migliore possibile nonostante
193il limite di una sola riga. La descrizione dettagliata può spiegare meglio
194i temi e fornire maggiori informazioni. Se una patch corregge un baco,
195citate, se possibile, il commit che lo introdusse (e per favore, quando
196citate un commit aggiungete sia il suo identificativo che il titolo),
197Se il problema è associabile ad un file di log o all' output del compilatore,
198includeteli al fine d'aiutare gli altri a trovare soluzioni per lo stesso
199problema. Se la modifica ha lo scopo di essere di supporto a sviluppi
200successivi, ditelo. Se le API interne vengono cambiate, dettagliate queste
201modifiche e come gli altri dovrebbero agire per applicarle. In generale,
202più riuscirete ad entrare nei panni di tutti quelli che leggeranno il
203vostro changelog, meglio sarà il changelog (e il kernel nel suo insieme).
204
205Non serve dirlo, un changelog dovrebbe essere il testo usato nel messaggio
206di 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
212Dovreste evitare di includere nelle patch delle modifiche per file
213irrilevanti (quelli generati dal processo di generazione, per esempio, o i file
214di backup del vostro editor). Il file "dontdiff" nella cartella Documentation
215potrà esservi d'aiuto su questo punto; passatelo a diff con l'opzione "-X".
216
217Le etichette sopra menzionante sono usate per descrivere come i vari
218sviluppatori sono stati associati allo sviluppo di una patch. Sono descritte
219in dettaglio nel documento :ref:`translations/it_IT/process/submitting-patches.rst <it_submittingpatches>`;
220quello che segue è un breve riassunto. Ognuna di queste righe ha il seguente
221formato:
222
223::
224
225 tag: Full Name <email address> optional-other-stuff
226
227Le 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
259State attenti ad aggiungere queste etichette alla vostra patch: solo
260"Cc:" può essere aggiunta senza il permesso esplicito della persona menzionata.
261
262Inviare la modifica
263-------------------
264
265Prima di inviare la vostra patch, ci sarebbero ancora un paio di cose di cui
266dovreste 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
285Le patch dovrebbero essere sempre inviate come testo puro. Per favore non
286inviatele come allegati; questo rende molto più difficile, per i revisori,
287citare parti della patch che si vogliono commentare. Invece, mettete la vostra
288patch direttamente nel messaggio.
289
290Quando inviate le patch, è importante inviarne una copia a tutte le persone che
291potrebbero esserne interessate. Al contrario di altri progetti, il kernel
292incoraggia le persone a peccare nell'invio di tante copie; non presumente che
293le persone interessate vedano i vostri messaggi sulla lista di discussione.
294In 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
317Quando scegliete i destinatari della patch, è bene avere un'idea di chi
318pensiate che sia colui che, eventualmente, accetterà la vostra patch e
319la integrerà. Nonostante sia possibile inviare patch direttamente a
320Linus Torvalds, e lasciare che sia lui ad integrarle,solitamente non è la
321strada migliore da seguire. Linus è occupato, e ci sono dei manutentori di
322sotto-sistema che controllano una parte specifica del kernel. Solitamente,
323vorreste che siano questi manutentori ad integrare le vostre patch. Se non
324c'è un chiaro manutentore, l'ultima spiaggia è spesso Andrew Morton.
325
326Le patch devono avere anche un buon oggetto. Il tipico formato per l'oggetto
327di una patch assomiglia a questo:
328
329::
330
331 [PATCH nn/mm] subsys: one-line description of the patch
332
333dove "nn" è il numero ordinale della patch, "mm" è il numero totale delle patch
334nella serie, e "subsys" è il nome del sottosistema interessato. Chiaramente,
335nn/mm può essere omesso per una serie composta da una singola patch.
336
337Se avete una significative serie di patch, è prassi inviare una descrizione
338introduttiva come parte zero. Tuttavia questa convenzione non è universalmente
339seguita; se la usate, ricordate che le informazioni nell'introduzione non
340faranno parte del changelog del kernel. Quindi per favore, assicuratevi che
341ogni patch abbia un changelog completo.
342
343In generale, la seconda parte e quelle successive di una patch "composta"
344dovrebbero essere inviate come risposta alla prima, cosicché vengano viste
345come un unico *thread*. Strumenti come git e quilt hanno comandi per inviare
346gruppi di patch con la struttura appropriata. Se avete una serie lunga
347e state usando git, per favore state alla larga dall'opzione --chain-reply-to
348per 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=============
9Completamento
10=============
11
12A questo punto, avete seguito le linee guida fino a questo punto e, con
13l'aggiunta delle vostre capacità ingegneristiche, avete pubblicato una serie
14perfetta di patch. Uno dei più grandi errori che possono essere commessi
15persino da sviluppatori kernel esperti è quello di concludere che il
16lavoro sia ormai finito. In verità, la pubblicazione delle patch
17simboleggia una transizione alla fase successiva del processo, con,
18probabilmente, ancora un po' di lavoro da fare.
19
20È raro che una modifica sia così bella alla sua prima pubblicazione che non
21ci sia alcuno spazio di miglioramento. Il programma di sviluppo del kernel
22riconosce questo fatto e quindi, è fortemente orientato al miglioramento
23del codice pubblicato. Voi, in qualità di autori del codice, dovrete
24lavorare con la comunità del kernel per assicurare che il vostro codice
25mantenga gli standard qualitativi richiesti. Un fallimento in questo
26processo è quasi come impedire l'inclusione delle vostre patch nel
27ramo principale.
28
29Lavorare con i revisori
30=======================
31
32Una patch che abbia una certa rilevanza avrà ricevuto numerosi commenti
33da parte di altri sviluppatori dato che avranno revisionato il codice.
34Lavorare con i revisori può rivelarsi, per molti sviluppatori, la parte
35più intimidatoria del processo di sviluppo del kernel. La vita può esservi
36resa 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
63Quello che si sta cercando di dire è che, quando i revisori vi inviano degli
64appunti dovete fare attenzione alle osservazioni tecniche che vi stanno
65facendo. Non lasciate che il loro modo di esprimersi o il vostro orgoglio
66impediscano che ciò accada. Quando avete dei suggerimenti sulla revisione,
67prendetevi il tempo per comprendere cosa il revisore stia cercando di
68comunicarvi. Se possibile, sistemate le cose che il revisore vi chiede di
69modificare. E rispondete al revisore ringraziandolo e spiegando come
70intendete fare.
71
72Notate che non dovete per forza essere d'accordo con ogni singola modifica
73suggerita dai revisori. Se credete che il revisore non abbia compreso
74il vostro codice, spiegateglielo. Se avete un'obiezione tecnica da fargli
75su di una modifica suggerita, spiegatela inserendo anche la vostra soluzione
76al problema. Se la vostra spiegazione ha senso, il revisore la accetterà.
77Tuttavia, la vostra motivazione potrebbe non essere del tutto persuasiva,
78specialmente se altri iniziano ad essere d'accordo con il revisore.
79Prendetevi quindi un po' di tempo per pensare ancora alla cosa. Può risultare
80facile essere accecati dalla propria soluzione al punto che non realizzate che
81c'è qualcosa di fondamentalmente sbagliato o, magari, non state nemmeno
82risolvendo il problema giusto.
83
84Andrew Morton suggerisce che ogni suggerimento di revisione che non è
85presente nella modifica del codice dovrebbe essere inserito in un commento
86aggiuntivo; ciò può essere d'aiuto ai futuri revisori nell'evitare domande
87che sorgono al primo sguardo.
88
89Un errore fatale è quello di ignorare i commenti di revisione nella speranza
90che se ne andranno. Non andranno via. Se pubblicherete nuovamente il
91codice senza aver risposto ai commenti ricevuti, probabilmente le vostre
92modifiche non andranno da nessuna parte.
93
94Parlando di ripubblicazione del codice: per favore tenete a mente che i
95revisori non ricorderanno tutti i dettagli del codice che avete pubblicato
96l'ultima volta. Quindi è sempre una buona idea quella di ricordare ai
97revisori le questioni sollevate precedetemene e come le avete risolte.
98I revisori non dovrebbero star lì a cercare all'interno degli archivi per
99famigliarizzare con ciò che è stato detto l'ultima volta; se li aiutate
100in questo senso, saranno di umore migliore quando riguarderanno il vostro
101codice.
102
103Se invece avete cercato di far tutto correttamente ma le cose continuano
104a non andar bene? Molti disaccordi di natura tecnica possono essere risolti
105attraverso la discussione, ma ci sono volte dove qualcuno deve prendere
106una decisione. Se credete veramente che tale decisione andrà contro di voi
107ingiustamente, potete sempre tentare di rivolgervi a qualcuno più
108in alto di voi. Per cose di questo genere la persona con più potere è
109Andrew Morton. Andrew è una figura molto rispettata all'interno della
110comunità di sviluppo del kernel; lui può spesso sbrogliare situazioni che
111sembrano irrimediabilmente bloccate. Rivolgersi ad Andrew non deve essere
112fatto alla leggera, e non deve essere fatto prima di aver esplorato tutte
113le altre alternative. E tenete a mente, ovviamente, che nemmeno lui
114potrebbe non essere d'accordo con voi.
115
116Cosa accade poi
117===============
118
119Se la modifica è ritenuta un elemento valido da essere aggiunta al kernel,
120e una volta che la maggior parte degli appunti dei revisori sono stati
121sistemati, il passo successivo solitamente è quello di entrare in un
122sottosistema gestito da un manutentore. Come ciò avviene dipende dal
123sottosistema medesimo; ogni manutentore ha il proprio modo di fare le cose.
124In particolare, ci potrebbero essere diversi sorgenti - uno, magari, dedicato
125alle modifiche pianificate per la finestra di fusione successiva, e un altro
126per il lavoro di lungo periodo.
127
128Per le modifiche proposte in aree per le quali non esiste un sottosistema
129preciso (modifiche di gestione della memoria, per esempio), i sorgenti di
130ripiego finiscono per essere -mm. Ed anche le modifiche che riguardano
131più sottosistemi possono finire in quest'ultimo.
132
133L'inclusione nei sorgenti di un sottosistema può comportare per una patch,
134un alto livello di visibilità. Ora altri sviluppatori che stanno lavorando
135in quei medesimi sorgenti avranno le vostre modifiche. I sottosistemi
136solitamente riforniscono anche Linux-next, rendendo i propri contenuti
137visibili all'intera comunità di sviluppo. A questo punto, ci sono buone
138possibilità per voi di ricevere ulteriori commenti da un nuovo gruppo di
139revisori; anche a questi commenti dovrete rispondere come avete già fatto per
140gli altri.
141
142Ciò che potrebbe accadere a questo punto, in base alla natura della vostra
143modifica, riguarda eventuali conflitti con il lavoro svolto da altri.
144Nella peggiore delle situazioni, i conflitti più pesanti tra modifiche possono
145concludersi con la messa a lato di alcuni dei lavori svolti cosicché le
146modifiche restanti possano funzionare ed essere integrate. Altre volte, la
147risoluzione dei conflitti richiederà del lavoro con altri sviluppatori e,
148possibilmente, lo spostamento di alcune patch da dei sorgenti a degli altri
149in modo da assicurare che tutto sia applicato in modo pulito. Questo lavoro
150può rivelarsi una spina nel fianco, ma consideratevi fortunati: prima
151dell'avvento dei sorgenti linux-next, questi conflitti spesso emergevano solo
152durante l'apertura della finestra di integrazione e dovevano essere smaltiti
153in fretta. Ora essi possono essere risolti comodamente, prima dell'apertura
154della finestra.
155
156Un giorno, se tutto va bene, vi collegherete e vedrete che la vostra patch
157è stata inserita nel ramo principale de kernel. Congratulazioni! Terminati
158i festeggiamenti (nel frattempo avrete inserito il vostro nome nel file
159MAINTAINERS) vale la pena ricordare una piccola cosa, ma importante: il
160lavoro non è ancora finito. L'inserimento nel ramo principale porta con se
161nuove sfide.
162
163Cominciamo con il dire che ora la visibilità della vostra modifica è
164ulteriormente cresciuta. Ci potrebbe portare ad una nuova fase di
165commenti dagli sviluppatori che non erano ancora a conoscenza della vostra
166patch. Ignorarli potrebbe essere allettante dato che non ci sono più
167dubbi sull'integrazione della modifica. Resistete a tale tentazione, dovete
168mantenervi disponibili agli sviluppatori che hanno domande o suggerimenti
169per voi.
170
171Ancora più importante: l'inclusione nel ramo principale mette il vostro
172codice nelle mani di un gruppo di *tester* molto più esteso. Anche se avete
173contribuito ad un driver per un hardware che non è ancora disponibile, sarete
174sorpresi da quante persone inseriranno il vostro codice nei loro kernel.
175E, ovviamente, dove ci sono *tester*, ci saranno anche dei rapporti su
176eventuali bachi.
177
178La peggior specie di rapporti sono quelli che indicano delle regressioni.
179Se la vostra modifica causa una regressione, avrete un gran numero di
180occhi puntati su di voi; la regressione deve essere sistemata il prima
181possibile. Se non vorrete o non sarete capaci di sistemarla (e nessuno
182lo farà per voi), la vostra modifica sarà quasi certamente rimossa durante
183la fase di stabilizzazione. Oltre alla perdita di tutto il lavoro svolto
184per far si che la vostra modifica fosse inserita nel ramo principale,
185l'avere una modifica rimossa a causa del fallimento nel sistemare una
186regressione, potrebbe rendere più difficile per voi far accettare
187il vostro lavoro in futuro.
188
189Dopo che ogni regressione è stata affrontata, ci potrebbero essere altri
190bachi ordinari da "sconfiggere". Il periodo di stabilizzazione è la
191vostra migliore opportunità per sistemare questi bachi e assicurarvi che
192il debutto del vostro codice nel ramo principale del kernel sia il più solido
193possibile. Quindi, per favore, rispondete ai rapporti sui bachi e ponete
194rimedio, se possibile, a tutti i problemi. È a questo che serve il periodo
195di stabilizzazione; potete iniziare creando nuove fantastiche modifiche
196una volta che ogni problema con le vecchie sia stato risolto.
197
198Non dimenticate che esistono altre pietre miliari che possono generare
199rapporti sui bachi: il successivo rilascio stabile, quando una distribuzione
200importante usa una versione del kernel nel quale è presente la vostra
201modifica, eccetera. Il continuare a rispondere a questi rapporti è fonte di
202orgoglio per il vostro lavoro. Se questa non è una sufficiente motivazione,
203allora, è anche consigliabile considera che la comunità di sviluppo ricorda
204gli sviluppatori che hanno perso interesse per il loro codice una volta
205integrato. La prossima volta che pubblicherete una patch, la comunità
206la valuterà anche sulla base del fatto che non sarete disponibili a
207prendervene cura anche nel futuro.
208
209
210Altre cose che posso accadere
211=============================
212
213Un giorno, potreste aprire la vostra email e vedere che qualcuno vi ha
214inviato una patch per il vostro codice. Questo, dopo tutto, è uno dei
215vantaggi di avere il vostro codice "là fuori". Se siete d'accordo con
216la modifica, potrete anche inoltrarla ad un manutentore di sottosistema
217(assicuratevi di includere la riga "From:" cosicché l'attribuzione sia
218corretta, e aggiungete una vostra firma "Signed-off-by"), oppure inviate
219un "Acked-by:" e lasciate che l'autore originale la invii.
220
221Se non siete d'accordo con la patch, inviate una risposta educata
222spiegando il perché. Se possibile, dite all'autore quali cambiamenti
223servirebbero per rendere la patch accettabile da voi. C'è una certa
224riluttanza nell'inserire modifiche con un conflitto fra autore
225e manutentore del codice, ma solo fino ad un certo punto. Se siete visti
226come qualcuno che blocca un buon lavoro senza motivo, quelle patch vi
227passeranno oltre e andranno nel ramo principale in ogni caso. Nel kernel
228Linux, nessuno ha potere di veto assoluto su alcun codice. Eccezione
229fatta per Linus, forse.
230
231In rarissime occasioni, potreste vedere qualcosa di completamente diverso:
232un altro sviluppatore che pubblica una soluzione differente al vostro
233problema. A questo punto, c'è una buona probabilità che una delle due
234modifiche non verrà integrata, e il "c'ero prima io" non è considerato
235un argomento tecnico rilevante. Se la modifica di qualcun'altro rimpiazza
236la vostra ed entra nel ramo principale, esiste un unico modo di reagire:
237siate contenti che il vostro problema sia stato risolto e andate avanti con
238il vostro lavoro. L'avere un vostro lavoro spintonato da parte in questo
239modo può essere avvilente e scoraggiante, ma la comunità ricorderà come
240avrete 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
8Argomenti avanzati
9==================
10
11A questo punto, si spera, dovreste avere un'idea su come funziona il processo
12di sviluppo. Ma rimane comunque molto da imparare! Questo capitolo copre
13alcuni argomenti che potrebbero essere utili per gli sviluppatori che stanno
14per diventare parte integrante del processo di sviluppo del kernel.
15
16Gestire le modifiche con git
17-----------------------------
18
19L'uso di un sistema distribuito per il controllo delle versioni del kernel
20ebbe iniziò nel 2002 quando Linux iniziò a provare il programma proprietario
21BitKeeper. Nonostante l'uso di BitKeeper fosse opinabile, di certo il suo
22approccio alla gestione dei sorgenti non lo era. Un sistema distribuito per
23il controllo delle versioni accelerò immediatamente lo sviluppo del kernel.
24Oggigiorno, ci sono diverse alternative libere a BitKeeper. Per il meglio o il
25peggio, il progetto del kernel ha deciso di usare git per gestire i sorgenti.
26
27Gestire le modifiche con git può rendere la vita dello sviluppatore molto
28più facile, specialmente quando il volume delle modifiche cresce.
29Git ha anche i suoi lati taglienti che possono essere pericolosi; è uno
30strumento giovane e potente che è ancora in fase di civilizzazione da parte
31dei suoi sviluppatori. Questo documento non ha lo scopo di insegnare l'uso
32di git ai suoi lettori; ci sarebbe materiale a sufficienza per un lungo
33documento al riguardo. Invece, qui ci concentriamo in particolare su come
34git è parte del processo di sviluppo del kernel. Gli sviluppatori che
35desiderassero diventare agili con git troveranno più informazioni ai
36seguenti indirizzi:
37
38 http://git-scm.com/
39
40 http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
41
42e su varie guide che potrete trovare su internet.
43
44La prima cosa da fare prima di usarlo per produrre patch che saranno
45disponibili ad altri, è quella di leggere i siti qui sopra e di acquisire una
46base solida su come funziona git. Uno sviluppatore che sappia usare git
47dovrebbe essere capace di ottenere una copia del repositorio principale,
48esplorare la storia della revisione, registrare le modifiche, usare i rami,
49eccetera. Una certa comprensione degli strumenti git per riscrivere la storia
50(come ``rebase``) è altrettanto utile. Git ha i propri concetti e la propria
51terminologia; un nuovo utente dovrebbe conoscere *refs*, *remote branch*,
52*index*, *fast-forward merge*, *push* e *pull*, *detached head*, eccetera.
53Il tutto potrebbe essere un po' intimidatorio visto da fuori, ma con un po'
54di studio i concetti non saranno così difficili da capire.
55
56Utilizzare git per produrre patch da sottomettere via email può essere
57un buon esercizio da fare mentre si sta prendendo confidenza con lo strumento.
58
59Quando sarete in grado di creare rami git che siano guardabili da altri,
60vi servirà, ovviamente, un server dal quale sia possibile attingere le vostre
61modifiche. Se avete un server accessibile da Internet, configurarlo per
62eseguire git-daemon è relativamente semplice . Altrimenti, iniziano a
63svilupparsi piattaforme che offrono spazi pubblici, e gratuiti (Github,
64per esempio). Gli sviluppatori permanenti possono ottenere un account
65su kernel.org, ma non è proprio facile da ottenere; per maggiori informazioni
66consultate la pagina web http://kernel.org/faq/.
67
68In git è normale avere a che fare con tanti rami. Ogni linea di sviluppo
69può essere separata in "rami per argomenti" e gestiti indipendentemente.
70In git i rami sono facilissimi, per cui non c'è motivo per non usarli
71in libertà. In ogni caso, non dovreste sviluppare su alcun ramo dal
72quale altri potrebbero attingere. I rami disponibili pubblicamente dovrebbero
73essere creati con attenzione; integrate patch dai rami di sviluppo
74solo quando sono complete e pronte ad essere consegnate - non prima.
75
76Git offre alcuni strumenti che vi permettono di riscrivere la storia del
77vostro sviluppo. Una modifica errata (diciamo, una che rompe la bisezione,
78oppure che ha un qualche tipo di baco evidente) può essere corretta sul posto
79o fatta sparire completamente dalla storia. Una serie di patch può essere
80riscritta come se fosse stata scritta in cima al ramo principale di oggi,
81anche se ci avete lavorato per mesi. Le modifiche possono essere spostate
82in modo trasparente da un ramo ad un altro. E così via. Un uso giudizioso
83di git per revisionare la storia può aiutare nella creazione di una serie
84di patch pulite e con meno problemi.
85
86Un uso eccessivo può portare ad altri tipi di problemi, tuttavia, oltre
87alla semplice ossessione per la creazione di una storia del progetto che sia
88perfetta. Riscrivere la storia riscriverà le patch contenute in quella
89storia, trasformando un kernel verificato (si spera) in uno da verificare.
90Ma, oltre a questo, gli sviluppatori non possono collaborare se non condividono
91la stessa vista sulla storia del progetto; se riscrivete la storia dalla quale
92altri sviluppatori hanno attinto per i loro repositori, renderete la loro vita
93molto più difficile. Quindi tenete conto di questa semplice regola generale:
94la storia che avete esposto ad altri, generalmente, dovrebbe essere vista come
95immutabile.
96
97Dunque, una volta che il vostro insieme di patch è stato reso disponibile
98pubblicamente non dovrebbe essere più sovrascritto. Git tenterà di imporre
99questa regola, e si rifiuterà di pubblicare nuove patch che non risultino
100essere dirette discendenti di quelle pubblicate in precedenza (in altre parole,
101patch che non condividono la stessa storia). È possibile ignorare questo
102controllo, e ci saranno momenti in cui sarà davvero necessario riscrivere
103un ramo già pubblicato. Un esempio è linux-next dove le patch vengono
104spostate da un ramo all'altro al fine di evitare conflitti. Ma questo tipo
105d'azione dovrebbe essere un'eccezione. Questo è uno dei motivi per cui lo
106sviluppo dovrebbe avvenire in rami privati (che possono essere sovrascritti
107quando lo si ritiene necessario) e reso pubblico solo quando è in uno stato
108avanzato.
109
110Man mano che il ramo principale (o altri rami su cui avete basato le
111modifiche) avanza, diventa allettante l'idea di integrare tutte le patch
112per rimanere sempre aggiornati. Per un ramo privato, il *rebase* può essere
113un modo semplice per rimanere aggiornati, ma questa non è un'opzione nel
114momento in cui il vostro ramo è stato esposto al mondo intero.
115*Merge* occasionali possono essere considerati di buon senso, ma quando
116diventano troppo frequenti confondono inutilmente la storia. La tecnica
117suggerita in questi casi è quella di fare *merge* raramente, e più in generale
118solo nei momenti di rilascio (per esempio gli -rc del ramo principale).
119Se siete nervosi circa alcune patch in particolare, potete sempre fare
120dei *merge* di test in un ramo privato. In queste situazioni git "rerere"
121può essere utile; questo strumento si ricorda come i conflitti di *merge*
122furono risolti in passato cosicché non dovrete fare lo stesso lavoro due volte.
123
124Una 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
126facile l'integrazione nel ramo principale di modifiche mediocri, il tutto
127sotto il naso dei revisori. Gli sviluppatori del kernel tendono ad essere
128scontenti quando vedono succedere queste cose; preparare un ramo git con
129patch che non hanno ricevuto alcuna revisione o completamente avulse, potrebbe
130influire sulla vostra capacita di proporre, in futuro, l'integrazione dei
131vostri 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
142Per evitare queste situazioni, assicuratevi che tutte le patch in un ramo
143siano strettamente correlate al tema delle modifiche; un ramo "driver fixes"
144non dovrebbe fare modifiche al codice principale per la gestione della memoria.
145E, più importante ancora, non usate un repositorio git per tentare di
146evitare il processo di revisione. Pubblicate un sommario di quello che il
147vostro ramo contiene sulle liste di discussione più opportune, e , quando
148sarà il momento, richiedete che il vostro ramo venga integrato in linux-next.
149
150Se e quando altri inizieranno ad inviarvi patch per essere incluse nel
151vostro repositorio, non dovete dimenticare di revisionarle. Inoltre
152assicuratevi di mantenerne le informazioni di paternità; al riguardo git "am"
153fa del suo meglio, ma potreste dover aggiungere una riga "From:" alla patch
154nel caso in cui sia arrivata per vie traverse.
155
156Quando richiedete l'integrazione, siate certi di fornire tutte le informazioni:
157dov'è il vostro repositorio, quale ramo integrare, e quali cambiamenti si
158otterranno dall'integrazione. Il comando git request-pull può essere d'aiuto;
159preparerà una richiesta nel modo in cui gli altri sviluppatori se l'aspettano,
160e verificherà che vi siate ricordati di pubblicare quelle patch su un
161server pubblico.
162
163Revisionare le patch
164--------------------
165
166Alcuni lettori potrebbero avere obiezioni sulla presenza di questa sezione
167negli "argomenti avanzati" sulla base che anche gli sviluppatori principianti
168dovrebbero revisionare le patch. É certamente vero che non c'è modo
169migliore di imparare come programmare per il kernel che guardare il codice
170pubblicato dagli altri. In aggiunta, i revisori sono sempre troppo pochi;
171guardando il codice potete apportare un significativo contributo all'intero
172processo.
173
174Revisionare il codice potrebbe risultare intimidatorio, specialmente per i
175nuovi arrivati che potrebbero sentirsi un po' nervosi nel questionare
176il codice - in pubblico - pubblicato da sviluppatori più esperti. Perfino
177il codice scritto dagli sviluppatori più esperti può essere migliorato.
178Forse il suggerimento migliore per i revisori (tutti) è questo: formulate
179i commenti come domande e non come critiche. Chiedere "Come viene rilasciato
180il *lock* in questo percorso?" funziona sempre molto meglio che
181"qui la sincronizzazione è sbagliata".
182
183Diversi sviluppatori revisioneranno il codice con diversi punti di vista.
184Alcuni potrebbero concentrarsi principalmente sullo stile del codice e se
185alcune linee hanno degli spazio bianchi di troppo. Altri si chiederanno
186se accettare una modifica interamente è una cosa positiva per il kernel
187o no. E altri ancora si focalizzeranno sui problemi di sincronizzazione,
188l'uso eccessivo di *stack*, problemi di sicurezza, duplicazione del codice
189in altri contesti, documentazione, effetti negativi sulle prestazioni, cambi
190all'ABI dello spazio utente, eccetera. Qualunque tipo di revisione è ben
191accetta 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
8Per maggiori informazioni
9=========================
10
11Esistono numerose fonti di informazioni sullo sviluppo del kernel Linux
12e argomenti correlati. Primo tra questi sarà sempre la cartella Documentation
13che si trova nei sorgenti kernel.
14
15Il file :ref:`process/howto.rst <it_process_howto>` è un punto di partenza
16importante; :ref:`process/submitting-patches.rst <it_submittingpatches>` e
17:ref:`process/submitting-drivers.rst <it_submittingdrivers>` sono
18anch'essi qualcosa che tutti gli sviluppatori del kernel dovrebbero leggere.
19Molte API interne al kernel sono documentate utilizzando il meccanismo
20kerneldoc; "make htmldocs" o "make pdfdocs" possono essere usati per generare
21quei documenti in HTML o PDF (sebbene le versioni di TeX di alcune
22distribuzioni hanno dei limiti interni e fallisce nel processare
23appropriatamente i documenti).
24
25Diversi siti web approfondiscono lo sviluppo del kernel ad ogni livello
26di dettaglio. Il vostro autore vorrebbe umilmente suggerirvi
27http://lwn.net/ come fonte; usando l'indice 'kernel' su LWN troverete
28molti argomenti specifici sul kernel:
29
30 http://lwn.net/Kernel/Index/
31
32Oltre a ciò, una risorsa valida per gli sviluppatori kernel è:
33
34 http://kernelnewbies.org/
35
36E, ovviamente, una fonte da non dimenticare è http://kernel.org/, il luogo
37definitivo per le informazioni sui rilasci del kernel.
38
39Ci 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
49Tutti questi libri soffrono di un errore comune: tendono a risultare in un
50certo senso obsoleti dal momento che si trovano in libreria da diverso
51tempo. Comunque contengono informazioni abbastanza buone.
52
53La 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
61Conclusioni
62===========
63
64Congratulazioni a chiunque ce l'abbia fatta a terminare questo documento di
65lungo-respiro. Si spera che abbia fornito un'utile comprensione d'insieme
66di come il kernel Linux viene sviluppato e di come potete partecipare a
67tale processo.
68
69Infine, quello che conta è partecipare. Qualsiasi progetto software
70open-source non è altro che la somma di quello che i suoi contributori
71mettono al suo interno. Il kernel Linux è cresciuto velocemente e bene
72perché ha ricevuto il supporto di un impressionante gruppo di sviluppatori,
73ognuno dei quali sta lavorando per renderlo migliore. Il kernel è un esempio
74importante di cosa può essere fatto quando migliaia di persone lavorano
75insieme verso un obiettivo comune.
76
77Il kernel può sempre beneficiare di una larga base di sviluppatori, tuttavia,
78c'è sempre molto lavoro da fare. Ma, cosa non meno importante, molti degli
79altri partecipanti all'ecosistema Linux possono trarre beneficio attraverso
80il contributo al kernel. Inserire codice nel ramo principale è la chiave
81per arrivare ad una qualità del codice più alta, bassa manutenzione e
82bassi prezzi di distribuzione, alti livelli d'influenza sulla direzione
83dello sviluppo del kernel, e molto altro. È una situazione nella quale
84tutti coloro che sono coinvolti vincono. Mollate il vostro editor e
85raggiungeteci; 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
8Aggiungere una nuova chiamata di sistema
9========================================
10
11Questo documento descrive quello che è necessario sapere per aggiungere
12nuove chiamate di sistema al kernel Linux; questo è da considerarsi come
13un'aggiunta ai soliti consigli su come proporre nuove modifiche
14:ref:`Documentation/translations/it_IT/process/submitting-patches.rst <it_submittingpatches>`.
15
16
17Alternative alle chiamate di sistema
18------------------------------------
19
20La prima considerazione da fare quando si aggiunge una nuova chiamata di
21sistema è quella di valutare le alternative. Nonostante le chiamate di sistema
22siano il punto di interazione fra spazio utente e kernel più tradizionale ed
23ovvio, esistono altre possibilità - scegliete quella che meglio si adatta alle
24vostra 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
63Progettare l'API: pianificare le estensioni
64-------------------------------------------
65
66Una nuova chiamata di sistema diventerà parte dell'API del kernel, e
67dev'essere supportata per un periodo indefinito. Per questo, è davvero
68un'ottima idea quella di discutere apertamente l'interfaccia sulla lista
69di discussione del kernel, ed è altrettanto importante pianificarne eventuali
70estensioni future.
71
72(Nella tabella delle chiamate di sistema sono disseminati esempi dove questo
73non fu fatto, assieme ai corrispondenti aggiornamenti -
74``eventfd``/``eventfd2``, ``dup2``/``dup3``, ``inotify_init``/``inotify_init1``,
75``pipe``/``pipe2``, ``renameat``/``renameat2`` --quindi imparate dalla storia
76del kernel e pianificate le estensioni fin dall'inizio)
77
78Per semplici chiamate di sistema che accettano solo un paio di argomenti,
79il modo migliore di permettere l'estensibilità è quello di includere un
80argomento *flags* alla chiamata di sistema. Per assicurarsi che i programmi
81dello spazio utente possano usare in sicurezza *flags* con diverse versioni
82del kernel, verificate se *flags* contiene un qualsiasi valore sconosciuto,
83in 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
90Per chiamate di sistema più sofisticate che coinvolgono un numero più grande di
91argomenti, il modo migliore è quello di incapsularne la maggior parte in una
92struttura dati che verrà passata per puntatore. Questa struttura potrà
93funzionare 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
102Fintanto che un qualsiasi campo nuovo, diciamo ``param_4``, è progettato per
103offrire il comportamento precedente quando vale zero, allora questo permetterà
104di 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
114Vedere :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
118Progettare l'API: altre considerazioni
119--------------------------------------
120
121Se la vostra nuova chiamata di sistema permette allo spazio utente di fare
122riferimento ad un oggetto del kernel, allora questa dovrebbe usare un
123descrittore di file per accesso all'oggetto - non inventatevi nuovi tipi di
124accesso da spazio utente quando il kernel ha già dei meccanismi e una semantica
125ben definita per utilizzare i descrittori di file.
126
127Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` ritorna un nuovo
128descrittore di file, allora l'argomento *flags* dovrebbe includere un valore
129equivalente a ``O_CLOEXEC`` per i nuovi descrittori. Questo rende possibile,
130nello 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
133eseguito (Comunque, resistete alla tentazione di riutilizzare il valore di
134``O_CLOEXEC`` dato che è specifico dell'architettura e fa parte di una
135enumerazione di flag ``O_*`` che è abbastanza ricca).
136
137Se la vostra nuova chiamata di sistema ritorna un nuovo descrittore di file,
138dovreste considerare che significato avrà l'uso delle chiamate di sistema
139della famiglia di :manpage:`poll(2)`. Rendere un descrittore di file pronto
140per la lettura o la scrittura è il tipico modo del kernel per notificare lo
141spazio utente circa un evento associato all'oggetto del kernel.
142
143Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` ha un argomento
144che è il percorso ad un file::
145
146 int sys_xyzzy(const char __user *path, ..., unsigned int flags);
147
148dovreste 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
153Questo permette più flessibilità su come lo spazio utente specificherà il file
154in questione; in particolare, permette allo spazio utente di richiedere la
155funzionalità 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
163man :manpage:`openat(2)`; per un esempio di AT_EMPTY_PATH, leggere la pagina
164man :manpage:`fstatat(2)`).
165
166Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` prevede un parametro
167per descrivere uno scostamento all'interno di un file, usate ``loff_t`` come
168tipo cosicché scostamenti a 64-bit potranno essere supportati anche su
169architetture a 32-bit.
170
171Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` prevede l'uso di
172funzioni 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
175gestire la funzionalità associata, ma evitate la combinazione di diverse
176funzionalità vagamente collegate dietro lo stesso bit, in quanto va contro il
177principio di *capabilities* di separare i poteri di root. In particolare,
178evitate di aggiungere nuovi usi al fin-troppo-generico privilegio
179``CAP_SYS_ADMIN``.
180
181Se la vostra nuova chiamata di sistema :manpage:`xyzzy(2)` manipola altri
182processi oltre a quello chiamato, allora dovrebbe essere limitata (usando
183la chiamata ``ptrace_may_access()``) di modo che solo un processo chiamante
184con gli stessi permessi del processo in oggetto, o con i necessari privilegi,
185possa manipolarlo.
186
187Infine, state attenti che in alcune architetture non-x86 la vita delle chiamate
188di sistema con argomenti a 64-bit viene semplificata se questi argomenti
189ricadono in posizioni dispari (pratica, i parametri 1, 3, 5); questo permette
190l'uso di coppie contigue di registri a 32-bit. (Questo non conta se gli
191argomenti sono parte di una struttura dati che viene passata per puntatore).
192
193
194Proporre l'API
195--------------
196
197Al fine di rendere le nuove chiamate di sistema di facile revisione, è meglio
198che dividiate le modifiche i pezzi separati. Questi dovrebbero includere
199almeno le seguenti voci in *commit* distinti (ognuno dei quali sarà descritto
200più 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
213Le proposte di nuove chiamate di sistema, come ogni altro modifica all'API del
214kernel, deve essere sottomessa alla lista di discussione
215linux-api@vger.kernel.org.
216
217
218Implementazione di chiamate di sistema generiche
219------------------------------------------------
220
221Il principale punto d'accesso alla vostra nuova chiamata di sistema
222:manpage:`xyzzy(2)` verrà chiamato ``sys_xyzzy()``; ma, piuttosto che in modo
223esplicito, lo aggiungerete tramite la macro ``SYSCALL_DEFINEn``. La 'n'
224indica il numero di argomenti della chiamata di sistema; la macro ha come
225argomento il nome della chiamata di sistema, seguito dalle coppie (tipo, nome)
226per definire i suoi parametri. L'uso di questa macro permette di avere
227i metadati della nuova chiamata di sistema disponibili anche per altri
228strumenti.
229
230Il nuovo punto d'accesso necessita anche del suo prototipo di funzione in
231``include/linux/syscalls.h``, marcato come asmlinkage di modo da abbinargli
232il modo in cui quelle chiamate di sistema verranno invocate::
233
234 asmlinkage long sys_xyzzy(...);
235
236Alcune architetture (per esempio x86) hanno le loro specifiche tabelle di
237chiamate di sistema (syscall), ma molte altre architetture condividono una
238tabella comune di syscall. Aggiungete alla lista generica la vostra nuova
239chiamata 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
245Aggiornate anche il contatore __NR_syscalls di modo che sia coerente con
246l'aggiunta della nuove chiamate di sistema; va notato che se più di una nuova
247chiamata di sistema viene aggiunga nella stessa finestra di sviluppo, il numero
248della vostra nuova syscall potrebbe essere aggiustato al fine di risolvere i
249conflitti.
250
251Il file ``kernel/sys_ni.c`` fornisce le implementazioni *stub* di ripiego che
252ritornano ``-ENOSYS``. Aggiungete la vostra nuova chiamata di sistema anche
253qui::
254
255 COND_SYSCALL(xyzzy);
256
257La vostra nuova funzionalità del kernel, e la chiamata di sistema che la
258controlla, dovrebbero essere opzionali. Quindi, aggiungete un'opzione
259``CONFIG`` (solitamente in ``init/Kconfig``). Come al solito per le nuove
260opzioni ``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
272Per 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
281Implementazione delle chiamate di sistema x86
282---------------------------------------------
283
284Per collegare la vostra nuova chiamate di sistema alle piattaforme x86,
285dovete aggiornate la tabella principale di syscall. Assumendo che la vostra
286nuova chiamata di sistema non sia particolarmente speciale (vedere sotto),
287dovete aggiungere un elemento *common* (per x86_64 e x32) in
288arch/x86/entry/syscalls/syscall_64.tbl::
289
290 333 common xyzzy sys_xyzzy
291
292e un elemento per *i386* ``arch/x86/entry/syscalls/syscall_32.tbl``::
293
294 380 i386 xyzzy sys_xyzzy
295
296Ancora una volta, questi numeri potrebbero essere cambiati se generano
297conflitti durante la finestra di integrazione.
298
299
300Chiamate di sistema compatibili (generico)
301------------------------------------------
302
303Per molte chiamate di sistema, la stessa implementazione a 64-bit può essere
304invocata anche quando il programma in spazio utente è a 32-bit; anche se la
305chiamata di sistema include esplicitamente un puntatore, questo viene gestito
306in modo trasparente.
307
308Tuttavia, ci sono un paio di situazione dove diventa necessario avere un
309livello di gestione della compatibilità per risolvere le differenze di
310dimensioni fra 32-bit e 64-bit.
311
312Il primo caso è quando un kernel a 64-bit supporta anche programmi in spazio
313utente a 32-bit, perciò dovrà ispezionare aree della memoria (``__user``) che
314potrebbero 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
325Il secondo caso che richiede un livello di gestione della compatibilità è
326quando uno degli argomenti di una chiamata a sistema è esplicitamente un tipo
327a 64-bit anche su architetture a 32-bit, per esempio ``loff_t`` o ``__u64``.
328In questo caso, un valore che arriva ad un kernel a 64-bit da un'applicazione
329a 32-bit verrà diviso in due valori a 32-bit che dovranno essere riassemblati
330in questo livello di compatibilità.
331
332(Da notare che non serve questo livello di compatibilità per argomenti che
333sono puntatori ad un tipo esplicitamente a 64-bit; per esempio, in
334:manpage:`splice(2)` l'argomento di tipo ``loff_t __user *`` non necessita
335di una chiamata di sistema ``compat_``)
336
337La 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
340dell'implementazione è parte del kernel a 64-bit ma accetta parametri a 32-bit
341che trasformerà secondo le necessità (tipicamente, la versione
342``compat_sys_`` converte questi valori nello loro corrispondente a 64-bit e
343può chiamare la versione ``sys_`` oppure invocare una funzione che implementa
344le parti comuni).
345
346Il punto d'accesso *compat* deve avere il corrispondente prototipo di funzione
347in ``include/linux/compat.h``, marcato come asmlinkage di modo da abbinargli
348il modo in cui quelle chiamate di sistema verranno invocate::
349
350 asmlinkage long compat_sys_xyzzy(...);
351
352Se la chiamata di sistema prevede una struttura dati organizzata in modo
353diverso 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
357dimensione variabile deve avere il proprio tipo ``compat_`` corrispondente
358a quello in ``struct xyzzy_args``. La funzione ``compat_sys_xyzzy()``
359può usare la struttura ``compat_`` per analizzare gli argomenti ricevuti
360da una chiamata a 32-bit.
361
362Per 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
371nella 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
381La lista generica delle chiamate di sistema ha bisogno di essere
382aggiustata al fine di permettere l'uso della versione *compatibile*;
383la 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
389Riassumendo, 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
399Compatibilità delle chiamate di sistema (x86)
400---------------------------------------------
401
402Per collegare una chiamata di sistema, su un'architettura x86, con la sua
403versione *compatibile*, è necessario aggiustare la voce nella tabella
404delle syscall.
405
406Per prima cosa, la voce in ``arch/x86/entry/syscalls/syscall_32.tbl`` prende
407un argomento aggiuntivo per indicare che un programma in spazio utente
408a 32-bit, eseguito su un kernel a 64-bit, dovrebbe accedere tramite il punto
409d'accesso compatibile::
410
411 380 i386 xyzzy sys_xyzzy __ia32_compat_sys_xyzzy
412
413Secondo, dovete capire cosa dovrebbe succedere alla nuova chiamata di sistema
414per la versione dell'ABI x32. Qui C'è una scelta da fare: gli argomenti
415possono corrisponde alla versione a 64-bit o a quella a 32-bit.
416
417Se c'è un puntatore ad un puntatore, la decisione è semplice: x32 è ILP32,
418quindi 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
420x32 eseguano la chiamata *compatibile*::
421
422 333 64 xyzzy sys_xyzzy
423 ...
424 555 x32 xyzzy __x32_compat_sys_xyzzy
425
426Se non ci sono puntatori, allora è preferibile riutilizzare la chiamata di
427sistema a 64-bit per l'ABI x32 (e di conseguenza la voce in
428arch/x86/entry/syscalls/syscall_64.tbl rimane immutata).
429
430In ambo i casi, dovreste verificare che i tipi usati dagli argomenti
431abbiano un'esatta corrispondenza da x32 (-mx32) al loro equivalente a
43232-bit (-m32) o 64-bit (-m64).
433
434
435Chiamate di sistema che ritornano altrove
436-----------------------------------------
437
438Nella maggior parte delle chiamate di sistema, al termine della loro
439esecuzione, i programmi in spazio utente riprendono esattamente dal punto
440in cui si erano interrotti -- quindi dall'istruzione successiva, con lo
441stesso *stack* e con la maggior parte del registri com'erano stati
442lasciati prima della chiamata di sistema, e anche con la stessa memoria
443virtuale.
444
445Tuttavia, alcune chiamata di sistema fanno le cose in modo differente.
446Potrebbero ritornare ad un punto diverso (``rt_sigreturn``) o cambiare
447la memoria in spazio utente (``fork``/``vfork``/``clone``) o perfino
448l'architettura del programma (``execve``/``execveat``).
449
450Per permettere tutto ciò, l'implementazione nel kernel di questo tipo di
451chiamate di sistema potrebbero dover salvare e ripristinare registri
452aggiuntivi nello *stack* del kernel, permettendo così un controllo completo
453su dove e come l'esecuzione dovrà continuare dopo l'esecuzione della
454chiamata di sistema.
455
456Queste saranno specifiche per ogni architettura, ma tipicamente si definiscono
457dei punti d'accesso in *assembly* per salvare/ripristinare i registri
458aggiuntivi e quindi chiamare il vero punto d'accesso per la chiamata di
459sistema.
460
461Per 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
463di syscall (``arch/x86/entry/syscalls/syscall_64.tbl``) verrà corretta di
464conseguenza::
465
466 333 common xyzzy stub_xyzzy
467
468L'equivalente per programmi a 32-bit eseguiti su un kernel a 64-bit viene
469normalmente chiamato ``stub32_xyzzy`` e implementato in
470``arch/x86/entry/entry_64_compat.S`` con la corrispondente voce nella tabella
471di syscall ``arch/x86/entry/syscalls/syscall_32.tbl`` corretta nel
472seguente modo::
473
474 380 i386 xyzzy sys_xyzzy stub32_xyzzy
475
476Se una chiamata di sistema necessita di un livello di compatibilità (come
477nella sezione precedente), allora la versione ``stub32_`` deve invocare
478la versione ``compat_sys_`` piuttosto che quella nativa a 64-bit. In aggiunta,
479se l'implementazione dell'ABI x32 è diversa da quella x86_64, allora la sua
480voce nella tabella di syscall dovrà chiamare uno *stub* che invoca la versione
481``compat_sys_``,
482
483Per completezza, sarebbe carino impostare una mappatura cosicché
484*user-mode* Linux (UML) continui a funzionare -- la sua tabella di syscall
485farà riferimento a stub_xyzzy, ma UML non include l'implementazione
486in ``arch/x86/entry/entry_64.S`` (perché UML simula i registri eccetera).
487Correggerlo è semplice, basta aggiungere una #define in
488``arch/x86/um/sys_call_table_64.c``::
489
490 #define stub_xyzzy sys_xyzzy
491
492
493Altri dettagli
494--------------
495
496La maggior parte dei kernel tratta le chiamate di sistema allo stesso modo,
497ma possono esserci rare eccezioni per le quali potrebbe essere necessario
498l'aggiornamento della vostra chiamata di sistema.
499
500Il sotto-sistema di controllo (*audit subsystem*) è uno di questi casi
501speciali; esso include (per architettura) funzioni che classificano alcuni
502tipi di chiamate di sistema -- in particolare apertura dei file
503(``open``/``openat``), esecuzione dei programmi (``execve``/``exeveat``)
504oppure multiplatori di socket (``socketcall``). Se la vostra nuova chiamata
505di sistema è simile ad una di queste, allora il sistema di controllo dovrebbe
506essere aggiornato.
507
508Più in generale, se esiste una chiamata di sistema che è simile alla vostra,
509vale la pena fare una ricerca con ``grep`` su tutto il kernel per la chiamata
510di sistema esistente per verificare che non ci siano altri casi speciali.
511
512
513Verifica
514--------
515
516Una nuova chiamata di sistema dev'essere, ovviamente, provata; è utile fornire
517ai revisori un programma in spazio utente che mostri l'uso della chiamata di
518sistema. Un buon modo per combinare queste cose è quello di aggiungere un
519semplice programma di auto-verifica in una nuova cartella in
520``tools/testing/selftests/``.
521
522Per una nuova chiamata di sistema, ovviamente, non ci sarà alcuna funzione
523in libc e quindi il programma di verifica dovrà invocarla usando ``syscall()``;
524inoltre, se la nuova chiamata di sistema prevede un nuova struttura dati
525visibile in spazio utente, il file d'intestazione necessario dev'essere
526installato al fine di compilare il programma.
527
528Assicuratevi che il programma di auto-verifica possa essere eseguito
529correttamente su tutte le architetture supportate. Per esempio, verificate che
530funzioni quando viene compilato per x86_64 (-m64), x86_32 (-m32) e x32 (-mx32).
531
532Al fine di una più meticolosa ed estesa verifica della nuova funzionalità,
533dovreste considerare l'aggiunta di nuove verifica al progetto 'Linux Test',
534oppure 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
540Pagine man
541----------
542
543Tutte le nuove chiamate di sistema dovrebbero avere una pagina man completa,
544idealmente usando i marcatori groff, ma anche il puro testo può andare. Se
545state usando groff, è utile che includiate nella email di presentazione una
546versione già convertita in formato ASCII: semplificherà la vita dei revisori.
547
548Le pagine man dovrebbero essere in copia-conoscenza verso
549linux-man@vger.kernel.org
550Per maggiori dettagli, leggere
551https://www.kernel.org/doc/man-pages/patches.html
552
553
554Non invocate chiamate di sistema dal kernel
555-------------------------------------------
556
557Le chiamate di sistema sono, come già detto prima, punti di interazione fra
558lo spazio utente e il kernel. Perciò, le chiamate di sistema come
559``sys_xyzzy()`` o ``compat_sys_xyzzy()`` dovrebbero essere chiamate solo dallo
560spazio utente attraverso la tabella syscall, ma non da nessun altro punto nel
561kernel. Se la nuova funzionalità è utile all'interno del kernel, per esempio
562dev'essere condivisa fra una vecchia e una nuova chiamata di sistema o
563dev'essere utilizzata da una chiamata di sistema e la sua variante compatibile,
564allora dev'essere implementata come una funzione di supporto
565(*helper function*) (per esempio ``kern_xyzzy()``). Questa funzione potrà
566essere chiamata dallo *stub* (``sys_xyzzy()``), dalla variante compatibile
567(``compat_sys_xyzzy()``), e/o da altri parti del kernel.
568
569Sui sistemi x86 a 64-bit, a partire dalla versione v4.17 è un requisito
570fondamentale quello di non invocare chiamate di sistema all'interno del kernel.
571Esso 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
573la chiamata di sistema la quale verrà eseguita successivamente.
574Questo significa che verranno passati solo i parametri che sono davvero
575necessari ad una specifica chiamata di sistema, invece che riempire ogni volta
5766 registri del processore con contenuti presi dallo spazio utente (potrebbe
577causare seri problemi nella sequenza di chiamate).
578
579Inoltre, le regole su come i dati possano essere usati potrebbero differire
580fra il kernel e l'utente. Questo è un altro motivo per cui invocare
581``sys_xyzzy()`` è generalmente una brutta idea.
582
583Eccezioni a questa regola vengono accettate solo per funzioni d'architetture
584che surclassano quelle generiche, per funzioni d'architettura di compatibilità,
585o per altro codice in arch/
586
587
588Riferimenti 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
8Applicare 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
7Requisiti 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
8clang-format
9============
10``clang-format`` è uno strumento per formattare codice C/C++/... secondo
11un gruppo di regole ed euristiche. Come tutti gli strumenti, non è perfetto
12e 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
28Il suo file di configurazione è ``.clang-format`` e si trova nella cartella
29principale dei sorgenti del kernel. Le regole scritte in quel file tentano
30di approssimare le lo stile di codifica del kernel. Si tenta anche di seguire
31il più possibile
32:ref:`Documentation/translations/it_IT/process/coding-style.rst <it_codingstyle>`.
33Dato che non tutto il kernel segue lo stesso stile, potreste voler aggiustare
34le regole di base per un particolare sottosistema o cartella. Per farlo,
35potete sovrascriverle scrivendole in un altro file ``.clang-format`` in
36una sottocartella.
37
38Questo strumento è già stato incluso da molto tempo nelle distribuzioni
39Linux più popolari. Cercate ``clang-format`` nel vostro repositorio.
40Altrimenti, potete scaricare una versione pre-generata dei binari di LLVM/clang
41oppure generarlo dai codici sorgenti:
42
43 http://releases.llvm.org/download.html
44
45Troverete 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
54Revisionare lo stile di codifica per file e modifiche
55-----------------------------------------------------
56
57Eseguendo questo programma, potrete revisionare un intero sottosistema,
58cartella o singoli file alla ricerca di errori di stile, refusi o
59miglioramenti.
60
61Per farlo, potete eseguire qualcosa del genere::
62
63 # Make sure your working directory is clean!
64 clang-format -i kernel/*.[ch]
65
66E poi date un'occhiata a *git diff*.
67
68Osservare le righe di questo diff è utile a migliorare/aggiustare
69le opzioni di stile nel file di configurazione; così come per verificare
70le nuove funzionalità/versioni di ``clang-format``.
71
72``clang-format`` è in grado di leggere diversi diff unificati, quindi
73potrete revisionare facilmente delle modifiche e *git diff*.
74La documentazione si trova al seguente indirizzo:
75
76 https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting
77
78Per evitare che ``clang-format`` formatti alcune parti di un file, potete
79scrivere 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
87Nonostante si attraente l'idea di utilizzarlo per mantenere un file
88sempre in sintonia con ``clang-format``, specialmente per file nuovi o
89se siete un manutentore, ricordatevi che altre persone potrebbero usare
90una versione diversa di ``clang-format`` oppure non utilizzarlo del tutto.
91Quindi, dovreste trattenervi dall'usare questi marcatori nel codice del
92kernel; almeno finché non vediamo che ``clang-format`` è diventato largamente
93utilizzato.
94
95
96.. _it_clangformatreformat:
97
98Riformattare blocchi di codice
99------------------------------
100
101Utilizzando dei plugin per il vostro editor, potete riformattare una
102blocco (selezione) di codice con una singola combinazione di tasti.
103Questo è particolarmente utile: quando si riorganizza il codice, per codice
104complesso, macro multi-riga (e allineare le loro "barre"), eccetera.
105
106Ricordatevi che potete sempre aggiustare le modifiche in quei casi dove
107questo strumento non ha fatto un buon lavoro. Ma come prima approssimazione,
108può essere davvero molto utile.
109
110Questo programma si integra con molti dei più popolari editor. Alcuni di
111essi come vim, emacs, BBEdit, Visaul Studio, lo supportano direttamente.
112Al seguente indirizzo troverete le istruzioni:
113
114 https://clang.llvm.org/docs/ClangFormat.html
115
116Per Atom, Eclipse, Sublime Text, Visual Studio Code, XCode e altri editor
117e IDEs dovreste essere in grado di trovare dei plugin pronti all'uso.
118
119Per questo caso d'uso, considerate l'uso di un secondo ``.clang-format``
120che potete personalizzare con le vostre opzioni.
121Consultare it_clangformatextra_.
122
123
124.. _it_clangformatmissing:
125
126Cose non supportate
127-------------------
128
129``clang-format`` non ha il supporto per alcune cose che sono comuni nel
130codice del kernel. Sono facili da ricordare; quindi, se lo usate
131regolarmente, imparerete rapidamente a evitare/ignorare certi problemi.
132
133In 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
172Funzionalità e opzioni aggiuntive
173---------------------------------
174
175Al fine di minimizzare le differenze fra il codice attuale e l'output
176del programma, alcune opzioni di stile e funzionalità non sono abilitate
177nella configurazione base. In altre parole, lo scopo è di rendere le
178differenze le più piccole possibili, permettendo la semplificazione
179della revisione di file, differenze e modifiche.
180
181In altri casi (per esempio un particolare sottosistema/cartella/file), lo
182stile del kernel potrebbe essere diverso e abilitare alcune di queste
183opzioni potrebbe dare risultati migliori.
184
185Per 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
195Piuttosto che per interi file, solitamente sono utili per la riformattazione
196di 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
7Accordo 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
8Stile del codice per il kernel Linux
9====================================
10
11Questo è un breve documento che descrive lo stile di codice preferito per
12il kernel Linux. Lo stile di codifica è molto personale e non voglio
13**forzare** nessuno ad accettare il mio, ma questo stile è quello che
14dev'essere usato per qualsiasi cosa che io sia in grado di mantenere, e l'ho
15preferito anche per molte altre cose. Per favore, almeno tenete in
16considerazione le osservazioni espresse qui.
17
18La prima cosa che suggerisco è quella di stamparsi una copia degli standard
19di codifica GNU e di NON leggerla. Bruciatela, è un grande gesto simbolico.
20
21Comunque, ecco i punti:
22
231) Indentazione
24---------------
25
26La tabulazione (tab) è di 8 caratteri e così anche le indentazioni. Ci sono
27alcuni movimenti di eretici che vorrebbero l'indentazione a 4 (o perfino 2!)
28caratteri di profondità, che è simile al tentativo di definire il valore del
29pi-greco a 3.
30
31Motivazione: l'idea dell'indentazione è di definire chiaramente dove un blocco
32di controllo inizia e finisce. Specialmente quando siete rimasti a guardare lo
33schermo per 20 ore a file, troverete molto più facile capire i livelli di
34indentazione se questi sono larghi.
35
36Ora, alcuni rivendicano che un'indentazione da 8 caratteri sposta il codice
37troppo a destra e che quindi rende difficile la lettura su schermi a 80
38caratteri. La risposta a questa affermazione è che se vi servono più di 3
39livelli di indentazione, siete comunque fregati e dovreste correggere il vostro
40programma.
41
42In breve, l'indentazione ad 8 caratteri rende più facile la lettura, e in
43aggiunta vi avvisa quando state annidando troppo le vostre funzioni.
44Tenete ben a mente questo avviso.
45
46Al fine di facilitare l'indentazione del costrutto switch, si preferisce
47allineare sulla stessa colonna la parola chiave ``switch`` e i suoi
48subordinati ``case``. In questo modo si evita una doppia indentazione per
49i ``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
70A meno che non vogliate nascondere qualcosa, non mettete più istruzioni sulla
71stessa riga:
72
73.. code-block:: c
74
75 if (condition) do_this;
76 do_something_everytime;
77
78né mettete più assegnamenti sulla stessa riga. Lo stile del kernel
79è ultrasemplice. Evitate espressioni intricate.
80
81Al di fuori dei commenti, della documentazione ed escludendo i Kconfig, gli
82spazi non vengono mai usati per l'indentazione, e l'esempio qui sopra è
83volutamente errato.
84
85Procuratevi un buon editor di testo e non lasciate spazi bianchi alla fine
86delle righe.
87
88
892) Spezzare righe lunghe e stringhe
90-----------------------------------
91
92Lo stile del codice riguarda la leggibilità e la manutenibilità utilizzando
93strumenti comuni.
94
95Il limite delle righe è di 80 colonne e questo e un limite fortemente
96desiderato.
97
98Espressioni più lunghe di 80 colonne saranno spezzettate in pezzi più piccoli,
99a meno che eccedere le 80 colonne non aiuti ad aumentare la leggibilità senza
100nascondere informazioni. I pezzi derivati sono sostanzialmente più corti degli
101originali e vengono posizionati più a destra. Lo stesso si applica, nei file
102d'intestazione, alle funzioni con una lista di argomenti molto lunga. Tuttavia,
103non spezzettate mai le stringhe visibili agli utenti come i messaggi di
104printk, questo perché inibireste la possibilità d'utilizzare grep per cercarle.
105
1063) Posizionamento di parentesi graffe e spazi
107---------------------------------------------
108
109Un altro problema che s'affronta sempre quando si parla di stile in C è
110il posizionamento delle parentesi graffe. Al contrario della dimensione
111dell'indentazione, non ci sono motivi tecnici sulla base dei quali scegliere
112una strategia di posizionamento o un'altra; ma il modo qui preferito,
113come mostratoci dai profeti Kernighan e Ritchie, è quello di
114posizionare la parentesi graffa di apertura per ultima sulla riga, e quella
115di 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
123Questo è valido per tutte le espressioni che non siano funzioni (if, switch,
124for, 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
139Tuttavia, c'è il caso speciale, le funzioni: queste hanno la parentesi graffa
140di 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
149Eretici da tutto il mondo affermano che questa incoerenza è ...
150insomma ... incoerente, ma tutte le persone ragionevoli sanno che (a)
151K&R hanno **ragione** e (b) K&R hanno ragione. A parte questo, le funzioni
152sono comunque speciali (non potete annidarle in C).
153
154Notate che la graffa di chiusura è da sola su una riga propria, ad
155**eccezione** di quei casi dove è seguita dalla continuazione della stessa
156espressione, in pratica ``while`` nell'espressione do-while, oppure ``else``
157nell'espressione if-else, come questo:
158
159.. code-block:: c
160
161 do {
162 body of do-loop
163 } while (condition);
164
165e
166
167.. code-block:: c
168
169 if (x == y) {
170 ..
171 } else if (x > y) {
172 ...
173 } else {
174 ....
175 }
176
177Motivazione: K&R.
178
179Inoltre, notate che questo posizionamento delle graffe minimizza il numero
180di righe vuote senza perdere di leggibilità. In questo modo, dato che le
181righe sul vostro schermo non sono una risorsa illimitata (pensate ad uno
182terminale con 25 righe), avrete delle righe vuote da riempire con dei
183commenti.
184
185Non usate inutilmente le graffe dove una singola espressione è sufficiente.
186
187.. code-block:: c
188
189 if (condition)
190 action();
191
192e
193
194.. code-block:: none
195
196 if (condition)
197 do_this();
198 else
199 do_that();
200
201Questo non vale nel caso in cui solo un ramo dell'espressione if-else
202contiene una sola espressione; in quest'ultimo caso usate le graffe per
203entrambe i rami:
204
205.. code-block:: c
206
207 if (condition) {
208 do_this();
209 do_that();
210 } else {
211 otherwise();
212 }
213
214Inoltre, 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
2233.1) Spazi
224**********
225
226Lo 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,
229alignof, e __attribute__, il cui aspetto è molto simile a quello delle
230funzioni (e in Linux, solitamente, sono usate con le parentesi, anche se il
231linguaggio non lo richiede; come ``sizeof info`` dopo aver dichiarato
232``struct fileinfo info``).
233
234Quindi utilizzate uno spazio dopo le seguenti parole chiave::
235
236 if, switch, case, for, do, while
237
238ma non con sizeof, typeof, alignof, o __attribute__. Ad esempio,
239
240.. code-block:: c
241
242
243 s = sizeof(struct file);
244
245Non aggiungete spazi attorno (dentro) ad un'espressione fra parentesi. Questo
246esempio è **brutto**:
247
248.. code-block:: c
249
250
251 s = sizeof( struct file );
252
253Quando dichiarate un puntatore ad una variabile o una funzione che ritorna un
254puntatore, il posto suggerito per l'asterisco ``*`` è adiacente al nome della
255variabile 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
264Usate uno spazio attorno (da ogni parte) alla maggior parte degli operatori
265binari o ternari, come i seguenti::
266
267 = + - < > * / % | & ^ <= >= == != ? :
268
269ma non mettete spazi dopo gli operatori unari::
270
271 & * + - ~ ! sizeof typeof alignof __attribute__ defined
272
273nessuno spazio dopo l'operatore unario suffisso di incremento o decremento::
274
275 ++ --
276
277nessuno spazio dopo l'operatore unario prefisso di incremento o decremento::
278
279 ++ --
280
281e nessuno spazio attorno agli operatori dei membri di una struttura ``.`` e
282``->``.
283
284Non lasciate spazi bianchi alla fine delle righe. Alcuni editor con
285l'indentazione ``furba`` inseriranno gli spazi bianchi all'inizio di una nuova
286riga in modo appropriato, quindi potrete scrivere la riga di codice successiva
287immediatamente. Tuttavia, alcuni di questi stessi editor non rimuovono
288questi spazi bianchi quando non scrivete nulla sulla nuova riga, ad esempio
289perché volete lasciare una riga vuota. Il risultato è che finirete per avere
290delle righe che contengono spazi bianchi in coda.
291
292Git vi avviserà delle modifiche che aggiungono questi spazi vuoti di fine riga,
293e può opzionalmente rimuoverli per conto vostro; tuttavia, se state applicando
294una serie di modifiche, questo potrebbe far fallire delle modifiche successive
295perché il contesto delle righe verrà cambiato.
296
2974) Assegnare nomi
298-----------------
299
300C è un linguaggio spartano, e così dovrebbero esserlo i vostri nomi. Al
301contrario dei programmatori Modula-2 o Pascal, i programmatori C non usano
302nomi graziosi come ThisVariableIsATemporaryCounter. Un programmatore C
303chiamerebbe questa variabile ``tmp``, che è molto più facile da scrivere e
304non è una delle più difficili da capire.
305
306TUTTAVIA, nonostante i nomi con notazione mista siano da condannare, i nomi
307descrittivi per variabili globali sono un dovere. Chiamare una funzione
308globale ``pippo`` è un insulto.
309
310Le variabili GLOBALI (da usare solo se vi servono **davvero**) devono avere
311dei nomi descrittivi, così come le funzioni globali. Se avete una funzione
312che conta gli utenti attivi, dovreste chiamarla ``count_active_users()`` o
313qualcosa di simile, **non** dovreste chiamarla ``cntusr()``.
314
315Codificare il tipo di funzione nel suo nome (quella cosa chiamata notazione
316ungherese) fa male al cervello - il compilatore conosce comunque il tipo e
317può verificarli, e inoltre confonde i programmatori. Non c'è da
318sorprendersi che MicroSoft faccia programmi bacati.
319
320Le variabili LOCALI dovrebbero avere nomi corti, e significativi. Se avete
321un qualsiasi contatore di ciclo, probabilmente sarà chiamato ``i``.
322Chiamarlo ``loop_counter`` non è produttivo, non ci sono possibilità che
323``i`` possa non essere capito. Analogamente, ``tmp`` può essere una qualsiasi
324variabile che viene usata per salvare temporaneamente un valore.
325
326Se avete paura di fare casino coi nomi delle vostre variabili locali, allora
327avete un altro problema che è chiamato sindrome dello squilibrio dell'ormone
328della crescita delle funzioni. Vedere il capitolo 6 (funzioni).
329
3305) Definizione di tipi (typedef)
331--------------------------------
332
333Per favore non usate cose come ``vps_t``.
334Usare il typedef per strutture e puntatori è uno **sbaglio**. Quando vedete:
335
336.. code-block:: c
337
338 vps_t a;
339
340nei sorgenti, cosa significa?
341Se, invece, dicesse:
342
343.. code-block:: c
344
345 struct virtual_container *a;
346
347potreste dire cos'è effettivamente ``a``.
348
349Molte persone pensano che la definizione dei tipi ``migliori la leggibilità``.
350Non 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
400Magari ci sono altri casi validi, ma la regola di base dovrebbe essere di
401non usare MAI MAI un typedef a meno che non rientri in una delle regole
402descritte qui.
403
404In generale, un puntatore, o una struttura a cui si ha accesso diretto in
405modo ragionevole, non dovrebbero **mai** essere definite con un typedef.
406
4076) Funzioni
408-----------
409
410Le funzioni dovrebbero essere brevi e carine, e fare una cosa sola. Dovrebbero
411occupare uno o due schermi di testo (come tutti sappiamo, la dimensione
412di uno schermo secondo ISO/ANSI è di 80x24), e fare una cosa sola e bene.
413
414La massima lunghezza di una funziona è inversamente proporzionale alla sua
415complessità e al livello di indentazione di quella funzione. Quindi, se avete
416una funzione che è concettualmente semplice ma che è implementata come un
417lunga (ma semplice) sequenza di caso-istruzione, dove avete molte piccole cose
418per molti casi differenti, allora va bene avere funzioni più lunghe.
419
420Comunque, se avete una funzione complessa e sospettate che uno studente
421non particolarmente dotato del primo anno delle scuole superiori potrebbe
422non capire cosa faccia la funzione, allora dovreste attenervi strettamente ai
423limiti. Usate funzioni di supporto con nomi descrittivi (potete chiedere al
424compilatore di renderle inline se credete che sia necessario per le
425prestazioni, e probabilmente farà un lavoro migliore di quanto avreste potuto
426fare voi).
427
428Un'altra misura delle funzioni sono il numero di variabili locali. Non
429dovrebbero eccedere le 5-10, oppure state sbagliando qualcosa. Ripensate la
430funzione, e dividetela in pezzettini. Generalmente, un cervello umano può
431seguire facilmente circa 7 cose diverse, di più lo confonderebbe. Lo sai
432d'essere brillante, ma magari vorresti riuscire a capire cos'avevi fatto due
433settimane prima.
434
435Nei file sorgenti, separate le funzioni con una riga vuota. Se la funzione è
436esportata, la macro **EXPORT** per questa funzione deve seguire immediatamente
437la 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
447Nei prototipi di funzione, includete i nomi dei parametri e i loro tipi.
448Nonostante questo non sia richiesto dal linguaggio C, in Linux viene preferito
449perché è un modo semplice per aggiungere informazioni importanti per il
450lettore.
451
4527) Centralizzare il ritorno delle funzioni
453------------------------------------------
454
455Sebbene sia deprecata da molte persone, l'istruzione goto è impiegata di
456frequente dai compilatori sotto forma di salto incondizionato.
457
458L'istruzione goto diventa utile quando una funzione ha punti d'uscita multipli
459e vanno eseguite alcune procedure di pulizia in comune. Se non è necessario
460pulire alcunché, allora ritornate direttamente.
461
462Assegnate un nome all'etichetta di modo che suggerisca cosa fa la goto o
463perché esiste. Un esempio di un buon nome potrebbe essere ``out_free_buffer:``
464se 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
466punti d'uscita, e inoltre rende difficile verificarne la correttezza.
467
468I 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
499Un baco abbastanza comune di cui bisogna prendere nota è il ``one err bugs``
500che assomiglia a questo:
501
502.. code-block:: c
503
504 err:
505 kfree(foo->bar);
506 kfree(foo);
507 return ret;
508
509Il baco in questo codice è che in alcuni punti d'uscita la variabile ``foo`` è
510NULL. Normalmente si corregge questo baco dividendo la gestione dell'errore in
511due 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
521Idealmente, dovreste simulare condizioni d'errore per verificare i vostri
522percorsi d'uscita.
523
524
5258) Commenti
526-----------
527
528I commenti sono una buona cosa, ma c'è anche il rischio di esagerare. MAI
529spiegare COME funziona il vostro codice in un commento: è molto meglio
530scrivere il codice di modo che il suo funzionamento sia ovvio, inoltre
531spiegare codice scritto male è una perdita di tempo.
532
533Solitamente, i commenti devono dire COSA fa il codice, e non COME lo fa.
534Inoltre, cercate di evitare i commenti nel corpo della funzione: se la
535funzione è così complessa che dovete commentarla a pezzi, allora dovreste
536tornare al punto 6 per un momento. Potete mettere dei piccoli commenti per
537annotare o avvisare il lettore circa un qualcosa di particolarmente arguto
538(o brutto), ma cercate di non esagerare. Invece, mettete i commenti in
539testa alla funzione spiegando alle persone cosa fa, e possibilmente anche
540il PERCHÉ.
541
542Per favore, quando commentate una funzione dell'API del kernel usate il
543formato 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
547Lo 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
560Per i file in net/ e in drivers/net/ lo stile preferito per i commenti
561più 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
573derivati. A questo scopo, dichiarate un dato per riga (niente virgole
574per una dichiarazione multipla). Questo vi lascerà spazio per un piccolo
575commento per spiegarne l'uso.
576
577
5789) Avete fatto un pasticcio
579---------------------------
580
581Va bene, li facciamo tutti. Probabilmente vi è stato detto dal vostro
582aiutante Unix di fiducia che ``GNU emacs`` formatta automaticamente il
583codice C per conto vostro, e avete notato che sì, in effetti lo fa, ma che
584i modi predefiniti non sono proprio allettanti (infatti, sono peggio che
585premere tasti a caso - un numero infinito di scimmie che scrivono in
586GNU emacs non faranno mai un buon programma).
587
588Quindi, potete sbarazzarvi di GNU emacs, o riconfigurarlo con valori più
589sensati. Per fare quest'ultima cosa, potete appiccicare il codice che
590segue 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
624Questo farà funzionare meglio emacs con lo stile del kernel per i file che
625si trovano nella cartella ``~/src/linux-trees``.
626
627Ma anche se doveste fallire nell'ottenere una formattazione sensata in emacs
628non tutto è perduto: usate ``indent``.
629
630Ora, ancora, GNU indent ha la stessa configurazione decerebrata di GNU emacs,
631ed è per questo che dovete passargli alcune opzioni da riga di comando.
632Tuttavia, non è così terribile, perché perfino i creatori di GNU indent
633riconoscono l'autorità di K&R (le persone del progetto GNU non sono cattive,
634sono 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
639riformattare i commenti dovreste dare un'occhiata alle pagine man.
640Ma ricordatevi: ``indent`` non è un correttore per una cattiva programmazione.
641
642Da notare che potete utilizzare anche ``clang-format`` per aiutarvi con queste
643regole, per riformattare rapidamente ad automaticamente alcune parti del
644vostro codice, e per revisionare interi file al fine di identificare errori
645di stile, refusi e possibilmente anche delle migliorie. È anche utile per
646ordinare gli ``#include``, per allineare variabili/macro, per ridistribuire
647il testo e altre cose simili.
648Per maggiori dettagli, consultate il file
649:ref:`Documentation/translations/it_IT/process/clang-format.rst <it_clangformat>`.
650
651
65210) File di configurazione Kconfig
653----------------------------------
654
655Per tutti i file di configurazione Kconfig* che si possono trovare nei
656sorgenti, l'indentazione è un po' differente. Le linee dopo un ``config``
657sono indentate con un tab, mentre il testo descrittivo è indentato di
658ulteriori 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
669Le funzionalità davvero pericolose (per esempio il supporto alla scrittura
670per certi filesystem) dovrebbero essere dichiarate chiaramente come tali
671nella stringa di titolo::
672
673 config ADFS_FS_RW
674 bool "ADFS write support (DANGEROUS)"
675 depends on ADFS_FS
676 ...
677
678Per la documentazione completa sui file di configurazione, consultate
679il documento Documentation/translations/it_IT/kbuild/kconfig-language.txt
680
681
68211) Strutture dati
683------------------
684
685Le strutture dati che hanno una visibilità superiore al contesto del
686singolo thread in cui vengono create e distrutte, dovrebbero sempre
687avere un contatore di riferimenti. Nel kernel non esiste un
688*garbage collector* (e fuori dal kernel i *garbage collector* sono lenti
689e inefficienti), questo significa che **dovete** assolutamente avere un
690contatore di riferimenti per ogni cosa che usate.
691
692Avere un contatore di riferimenti significa che potete evitare la
693sincronizzazione e permette a più utenti di accedere alla struttura dati
694in parallelo - e non doversi preoccupare di una struttura dati che
695improvvisamente sparisce dalla loro vista perché il loro processo dormiva
696o stava facendo altro per un attimo.
697
698Da notare che la sincronizzazione **non** si sostituisce al conteggio dei
699riferimenti. La sincronizzazione ha lo scopo di mantenere le strutture
700dati coerenti, mentre il conteggio dei riferimenti è una tecnica di gestione
701della memoria. Solitamente servono entrambe le cose, e non vanno confuse fra
702di loro.
703
704Quando si hanno diverse classi di utenti, le strutture dati possono avere
705due livelli di contatori di riferimenti. Il contatore di classe conta
706il numero dei suoi utenti, e il contatore globale viene decrementato una
707sola volta quando il contatore di classe va a zero.
708
709Un esempio di questo tipo di conteggio dei riferimenti multi-livello può
710essere trovato nella gestore della memoria (``struct mm_sturct``: mm_user e
711mm_count), e nel codice dei filesystem (``struct super_block``: s_count e
712s_active).
713
714Ricordatevi: se un altro thread può trovare la vostra struttura dati, e non
715avete un contatore di riferimenti per essa, quasi certamente avete un baco.
716
71712) Macro, enumerati e RTL
718---------------------------
719
720I nomi delle macro che definiscono delle costanti e le etichette degli
721enumerati sono scritte in maiuscolo.
722
723.. code-block:: c
724
725 #define CONSTANT 0x12345
726
727Gli enumerati sono da preferire quando si definiscono molte costanti correlate.
728
729I nomi delle macro in MAIUSCOLO sono preferibili ma le macro che assomigliano
730a delle funzioni possono essere scritte in minuscolo.
731
732Generalmente, le funzioni inline sono preferibili rispetto alle macro che
733sembrano funzioni.
734
735Le macro che contengono più istruzioni dovrebbero essere sempre chiuse in un
736blocco 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
746Cose da evitare quando si usano le macro:
747
7481) 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
758sono **proprio** una pessima idea. Sembra una chiamata a funzione ma termina
759la funzione chiamante; non cercate di rompere il decodificatore interno di
760chi legge il codice.
761
7622) 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
768potrebbe sembrare una bella cosa, ma è dannatamente confusionario quando uno
769legge il codice e potrebbe romperlo con una cambiamento che sembra innocente.
770
7713) le macro con argomenti che sono utilizzati come l-values; questo potrebbe
772ritorcervisi contro se qualcuno, per esempio, trasforma FOO in una funzione
773inline.
774
7754) dimenticatevi delle precedenze: le macro che definiscono espressioni devono
776essere racchiuse fra parentesi. State attenti a problemi simili con le macro
777parametrizzate.
778
779.. code-block:: c
780
781 #define CONSTANT 0x4000
782 #define CONSTEXP (CONSTANT | 3)
783
7845) collisione nello spazio dei nomi quando si definisce una variabile locale in
785una 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
796ret è un nome comune per una variabile locale - __foo_ret difficilmente
797andrà in conflitto con una variabile già esistente.
798
799Il manuale di cpp si occupa esaustivamente delle macro. Il manuale di sviluppo
800di gcc copre anche l'RTL che viene usato frequentemente nel kernel per il
801linguaggio assembler.
802
80313) Visualizzare i messaggi del kernel
804--------------------------------------
805
806Agli sviluppatori del kernel piace essere visti come dotti. Tenete un occhio
807di riguardo per l'ortografia e farete una belle figura. In inglese, evitate
808l'uso di parole mozzate come ``dont``: usate ``do not`` oppure ``don't``.
809Scrivete messaggi concisi, chiari, e inequivocabili.
810
811I messaggi del kernel non devono terminare con un punto fermo.
812
813Scrivere i numeri fra parentesi (%d) non migliora alcunché e per questo
814dovrebbero essere evitati.
815
816Ci sono alcune macro per la diagnostica in <linux/device.h> che dovreste
817usare per assicurarvi che i messaggi vengano associati correttamente ai
818dispositivi e ai driver, e che siano etichettati correttamente: dev_err(),
819dev_warn(), dev_info(), e così via. Per messaggi che non sono associati ad
820alcun dispositivo, <linux/printk.h> definisce pr_info(), pr_warn(), pr_err(),
821eccetera.
822
823Tirar fuori un buon messaggio di debug può essere una vera sfida; e quando
824l'avete può essere d'enorme aiuto per risolvere problemi da remoto.
825Tuttavia, i messaggi di debug sono gestiti differentemente rispetto agli
826altri. Le funzioni pr_XXX() stampano incondizionatamente ma pr_debug() no;
827essa non viene compilata nella configurazione predefinita, a meno che
828DEBUG o CONFIG_DYNAMIC_DEBUG non vengono impostati. Questo vale anche per
829dev_dbg() e in aggiunta VERBOSE_DEBUG per aggiungere i messaggi dev_vdbg().
830
831Molti sottosistemi hanno delle opzioni di debug in Kconfig che aggiungono
832-DDEBUG nei corrispettivi Makefile, e in altri casi aggiungono #define DEBUG
833in specifici file. Infine, quando un messaggio di debug dev'essere stampato
834incondizionatamente, per esempio perché siete già in una sezione di debug
835racchiusa in #ifdef, potete usare printk(KERN_DEBUG ...).
836
83714) Assegnare memoria
838---------------------
839
840Il kernel fornisce i seguenti assegnatori ad uso generico:
841kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), e vzalloc().
842Per maggiori informazioni, consultate la documentazione dell'API.
843
844Il modo preferito per passare la dimensione di una struttura è il seguente:
845
846.. code-block:: c
847
848 p = kmalloc(sizeof(*p), ...);
849
850La forma alternativa, dove il nome della struttura viene scritto interamente,
851peggiora la leggibilità e introduce possibili bachi quando il tipo di
852puntatore cambia tipo ma il corrispondente sizeof non viene aggiornato.
853
854Il valore di ritorno è un puntatore void, effettuare un cast su di esso è
855ridondante. La conversione fra un puntatore void e un qualsiasi altro tipo
856di puntatore è garantito dal linguaggio di programmazione C.
857
858Il modo preferito per assegnare un vettore è il seguente:
859
860.. code-block:: c
861
862 p = kmalloc_array(n, sizeof(...), ...);
863
864Il modo preferito per assegnare un vettore a zero è il seguente:
865
866.. code-block:: c
867
868 p = kcalloc(n, sizeof(...), ...);
869
870Entrambe verificano la condizione di overflow per la dimensione
871d'assegnamento n * sizeof(...), se accade ritorneranno NULL.
872
87315) Il morbo inline
874-------------------
875
876Sembra che ci sia la percezione errata che gcc abbia una qualche magica
877opzione "rendimi più veloce" chiamata ``inline``. In alcuni casi l'uso di
878inline è appropriato (per esempio in sostituzione delle macro, vedi
879capitolo 12), ma molto spesso non lo è. L'uso abbondante della parola chiave
880inline porta ad avere un kernel più grande, che si traduce in un sistema nel
881suo complesso più lento per via di una cache per le istruzioni della CPU più
882grande e poi semplicemente perché ci sarà meno spazio disponibile per una
883pagina di cache. Pensateci un attimo; una fallimento nella cache causa una
884ricerca su disco che può tranquillamente richiedere 5 millisecondi. Ci sono
885TANTI cicli di CPU che potrebbero essere usati in questi 5 millisecondi.
886
887Spesso le persone dicono che aggiungere inline a delle funzioni dichiarate
888static e utilizzare una sola volta è sempre una scelta vincente perché non
889ci sono altri compromessi. Questo è tecnicamente vero ma gcc è in grado di
890trasformare automaticamente queste funzioni in inline; i problemi di
891manutenzione del codice per rimuovere gli inline quando compare un secondo
892utente surclassano il potenziale vantaggio nel suggerire a gcc di fare una
893cosa che avrebbe fatto comunque.
894
89516) Nomi e valori di ritorno delle funzioni
896-------------------------------------------
897
898Le 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.
900Questo 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
904Mischiare questi due tipi di rappresentazioni è un terreno fertile per
905i bachi più insidiosi. Se il linguaggio C includesse una forte distinzione
906fra gli interi e i booleani, allora il compilatore potrebbe trovare questi
907errori per conto nostro ... ma questo non c'è. Per evitare di imbattersi
908in 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
915Per esempio, ``add work`` è un comando, e la funzione add_work() ritorna 0
916in 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
9181 se trova il dispositivo corrispondente con successo, altrimenti 0.
919
920Tutte le funzioni esportate (EXPORT) devono rispettare questa convenzione, e
921così dovrebbero anche tutte le funzioni pubbliche. Le funzioni private
922(static) possono non seguire questa convenzione, ma è comunque raccomandato
923che lo facciano.
924
925Le funzioni il cui valore di ritorno è il risultato di una computazione,
926piuttosto che l'indicazione sul successo di tale computazione, non sono
927soggette a questa regola. Solitamente si indicano gli errori ritornando un
928qualche valore fuori dai limiti. Un tipico esempio è quello delle funzioni
929che ritornano un puntatore; queste utilizzano NULL o ERR_PTR come meccanismo
930di notifica degli errori.
931
93217) Non reinventate le macro del kernel
933---------------------------------------
934
935Il file di intestazione include/linux/kernel.h contiene un certo numero
936di macro che dovreste usare piuttosto che implementarne una qualche variante.
937Per esempio, se dovete calcolare la lunghezza di un vettore, sfruttate la
938macro:
939
940.. code-block:: c
941
942 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
943
944Analogamente, se dovete calcolare la dimensione di un qualche campo di una
945struttura, usate
946
947.. code-block:: c
948
949 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
950
951Ci sono anche le macro min() e max() che, se vi serve, effettuano un controllo
952rigido sui tipi. Sentitevi liberi di leggere attentamente questo file
953d'intestazione per scoprire cos'altro è stato definito che non dovreste
954reinventare nel vostro codice.
955
95618) Linee di configurazione degli editor e altre schifezze
957-----------------------------------------------------------
958
959Alcuni editor possono interpretare dei parametri di configurazione integrati
960nei file sorgenti e indicati con dai marcatori speciali. Per esempio, emacs
961interpreta le linee marcate nel seguente modo:
962
963.. code-block:: c
964
965 -*- mode: c -*-
966
967O 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
977Vim interpreta i marcatori come questi:
978
979.. code-block:: c
980
981 /* vim:set sw=8 noet */
982
983Non includete nessuna di queste cose nei file sorgenti. Le persone hanno le
984proprie configurazioni personali per l'editor, e i vostri sorgenti non
985dovrebbero sovrascrivergliele. Questo vale anche per i marcatori
986d'indentazione e di modalità d'uso. Le persone potrebbero aver configurato una
987modalità su misura, oppure potrebbero avere qualche altra magia per far
988funzionare bene l'indentazione.
989
99019) Inline assembly
991---------------------
992
993Nel codice specifico per un'architettura, potreste aver bisogno di codice
994*inline assembly* per interfacciarvi col processore o con una funzionalità
995specifica della piattaforma. Non esitate a farlo quando è necessario.
996Comunque, non usatele gratuitamente quando il C può fare la stessa cosa.
997Potete e dovreste punzecchiare l'hardware in C quando è possibile.
998
999Considerate la scrittura di una semplice funzione che racchiude pezzi comuni
1000di codice assembler piuttosto che continuare a riscrivere delle piccole
1001varianti. Ricordatevi che l' *inline assembly* può utilizzare i parametri C.
1002
1003Il codice assembler più corposo e non banale dovrebbe andare nei file .S,
1004coi rispettivi prototipi C definiti nei file d'intestazione. I prototipi C
1005per le funzioni assembler dovrebbero usare ``asmlinkage``.
1006
1007Potreste aver bisogno di marcare il vostro codice asm come volatile al fine
1008d'evitare che GCC lo rimuova quando pensa che non ci siano effetti collaterali.
1009Non c'è sempre bisogno di farlo, e farlo quando non serve limita le
1010ottimizzazioni.
1011
1012Quando scrivete una singola espressione *inline assembly* contenente più
1013istruzioni, mettete ognuna di queste istruzioni in una stringa e riga diversa;
1014ad eccezione dell'ultima stringa/istruzione, ognuna deve terminare con ``\n\t``
1015al 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
102320) Compilazione sotto condizione
1024---------------------------------
1025
1026Ovunque sia possibile, non usate le direttive condizionali del preprocessore
1027(#if, #ifdef) nei file .c; farlo rende il codice difficile da leggere e da
1028seguire. Invece, usate queste direttive nei file d'intestazione per definire
1029le funzioni usate nei file .c, fornendo i relativi stub nel caso #else,
1030e quindi chiamate queste funzioni senza condizioni di preprocessore. Il
1031compilatore non produrrà alcun codice per le funzioni stub, produrrà gli
1032stessi risultati, e la logica rimarrà semplice da seguire.
1033
1034È preferibile non compilare intere funzioni piuttosto che porzioni d'esse o
1035porzioni d'espressioni. Piuttosto che mettere una ifdef in un'espressione,
1036fattorizzate parte dell'espressione, o interamente, in funzioni e applicate
1037la direttiva condizionale su di esse.
1038
1039Se avete una variabile o funzione che potrebbe non essere usata in alcune
1040configurazioni, e quindi il compilatore potrebbe avvisarvi circa la definizione
1041inutilizzata, marcate questa definizione come __maybe_used piuttosto che
1042racchiuderla in una direttiva condizionale del preprocessore. (Comunque,
1043se una variabile o funzione è *sempre* inutilizzata, rimuovetela).
1044
1045Nel codice, dov'è possibile, usate la macro IS_ENABLED per convertire i
1046simboli Kconfig in espressioni booleane C, e quindi usatela nelle classiche
1047condizioni C:
1048
1049.. code-block:: c
1050
1051 if (IS_ENABLED(CONFIG_SOMETHING)) {
1052 ...
1053 }
1054
1055Il compilatore valuterà la condizione come costante (constant-fold), e quindi
1056includerà o escluderà il blocco di codice come se fosse in un #ifdef, quindi
1057non ne aumenterà il tempo di esecuzione. Tuttavia, questo permette al
1058compilatore C di vedere il codice nel blocco condizionale e verificarne la
1059correttezza (sintassi, tipi, riferimenti ai simboli, eccetera). Quindi
1060dovete comunque utilizzare #ifdef se il codice nel blocco condizionale esiste
1061solo quando la condizione è soddisfatta.
1062
1063Alla fine di un blocco corposo di #if o #ifdef (più di alcune linee),
1064mettete un commento sulla stessa riga di #endif, annotando la condizione
1065che termina. Per esempio:
1066
1067.. code-block:: c
1068
1069 #ifdef CONFIG_SOMETHING
1070 ...
1071 #endif /* CONFIG_SOMETHING */
1072
1073Appendice I) riferimenti
1074------------------------
1075
1076The C Programming Language, Second Edition
1077by Brian W. Kernighan and Dennis M. Ritchie.
1078Prentice Hall, Inc., 1988.
1079ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback).
1080
1081The Practice of Programming
1082by Brian W. Kernighan and Rob Pike.
1083Addison-Wesley, Inc., 1999.
1084ISBN 0-201-61586-X.
1085
1086Manuali GNU - nei casi in cui sono compatibili con K&R e questo documento -
1087per indent, cpp, gcc e i suoi dettagli interni, tutto disponibile qui
1088http://www.gnu.org/manual/
1089
1090WG14 è il gruppo internazionale di standardizzazione per il linguaggio C,
1091URL: http://www.open-std.org/JTC1/SC22/WG14/
1092
1093Kernel process/coding-style.rst, by greg@kroah.com at OLS 2002:
1094http://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
8Una guida al processo di sviluppo del Kernel
9============================================
10
11Contenuti:
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
26Lo scopo di questo documento è quello di aiutare gli sviluppatori (ed i loro
27supervisori) a lavorare con la communità di sviluppo con il minimo sforzo. È
28un tentativo di documentare il funzionamento di questa communità in modo che
29sia accessibile anche a coloro che non hanno famigliarità con lo sviluppo del
30Kernel Linux (o, anzi, con lo sviluppo di software libero in generale). Benchè
31qui sia presente del materiale tecnico, questa è una discussione rivolta in
32particolare al procedimento, e quindi per essere compreso non richiede una
33conoscenza 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
7Informazioni 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
8Come partecipare allo sviluppo del kernel Linux
9===============================================
10
11Questo è il documento fulcro di quanto trattato sull'argomento.
12Esso contiene le istruzioni su come diventare uno sviluppatore
13del kernel Linux e spiega come lavorare con la comunità di
14sviluppo kernel Linux. Il documento non tratterà alcun aspetto
15tecnico relativo alla programmazione del kernel, ma vi aiuterà
16indirizzandovi sulla corretta strada.
17
18Se qualsiasi cosa presente in questo documento diventasse obsoleta,
19vi preghiamo di inviare le correzioni agli amministratori di questo
20file, indicati in fondo al presente documento.
21
22Introduzione
23------------
24Dunque, volete imparare come diventare sviluppatori del kernel Linux?
25O vi è stato detto dal vostro capo, "Vai, scrivi un driver Linux per
26questo dispositivo". Bene, l'obbiettivo di questo documento è quello
27di insegnarvi tutto ciò che dovete sapere per raggiungere il vostro
28scopo descrivendo il procedimento da seguire e consigliandovi
29su come lavorare con la comunità. Il documento cercherà, inoltre,
30di spiegare alcune delle ragioni per le quali la comunità lavora in un
31modo suo particolare.
32
33Il kernel è scritto prevalentemente nel linguaggio C con alcune parti
34specifiche dell'architettura scritte in linguaggio assembly.
35Per lo sviluppo kernel è richiesta una buona conoscenza del linguaggio C.
36L'assembly (di qualsiasi architettura) non è richiesto, a meno che non
37pensiate di fare dello sviluppo di basso livello per un'architettura.
38Sebbene essi non siano un buon sostituto ad un solido studio del
39linguaggio C o ad anni di esperienza, i seguenti libri sono, se non
40altro, 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
46Il kernel è stato scritto usando GNU C e la toolchain GNU.
47Sebbene si attenga allo standard ISO C89, esso utilizza una serie di
48estensioni che non sono previste in questo standard. Il kernel è un
49ambiente C indipendente, che non ha alcuna dipendenza dalle librerie
50C standard, così alcune parti del C standard non sono supportate.
51Le divisioni ``long long`` e numeri in virgola mobile non sono permessi.
52Qualche volta è difficile comprendere gli assunti che il kernel ha
53riguardo gli strumenti e le estensioni in uso, e sfortunatamente non
54esiste alcuna indicazione definitiva. Per maggiori informazioni, controllate,
55la pagina `info gcc`.
56
57Tenete a mente che state cercando di apprendere come lavorare con la comunità
58di sviluppo già esistente. Questo è un gruppo eterogeneo di persone, con alti
59standard di codifica, di stile e di procedura. Questi standard sono stati
60creati nel corso del tempo basandosi su quanto hanno riscontrato funzionare al
61meglio per un squadra così grande e geograficamente sparsa. Cercate di
62imparare, in anticipo, il più possibile circa questi standard, poichè ben
63spiegati; non aspettatevi che gli altri si adattino al vostro modo di fare
64o a quello della vostra azienda.
65
66Note legali
67------------
68Il codice sorgente del kernel Linux è rilasciato sotto GPL. Siete pregati
69di visionare il file, COPYING, presente nella cartella principale dei
70sorgente, per eventuali dettagli sulla licenza. Se avete ulteriori domande
71sulla licenza, contattate un avvocato, non chiedete sulle liste di discussione
72del kernel Linux. Le persone presenti in queste liste non sono avvocati,
73e non dovreste basarvi sulle loro dichiarazioni in materia giuridica.
74
75Per domande più frequenti e risposte sulla licenza GPL, guardare:
76
77 https://www.gnu.org/licenses/gpl-faq.html
78
79Documentazione
80--------------
81I sorgenti del kernel Linux hanno una vasta base di documenti che vi
82insegneranno come interagire con la comunità del kernel. Quando nuove
83funzionalità vengono aggiunte al kernel, si raccomanda di aggiungere anche i
84relativi file di documentatione che spiegano come usarele.
85Quando un cambiamento del kernel genera anche un cambiamento nell'interfaccia
86con lo spazio utente, è raccomandabile che inviate una notifica o una
87correzione alle pagine *man* spiegando tale modifica agli amministratori di
88queste pagine all'indirizzo mtk.manpages@gmail.com, aggiungendo
89in CC la lista linux-api@vger.kernel.org.
90
91Di 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
175Il kernel inoltre ha un vasto numero di documenti che possono essere
176automaticamente generati dal codice sorgente stesso o da file
177ReStructuredText (ReST), come questo. Esso include una completa
178descrizione dell'API interna del kernel, e le regole su come gestire la
179sincronizzazione (locking) correttamente
180
181Tutte queste tipologie di documenti possono essere generati in PDF o in
182HTML utilizzando::
183
184 make pdfdocs
185 make htmldocs
186
187rispettivamente dalla cartella principale dei sorgenti del kernel.
188
189I documenti che impiegano ReST saranno generati nella cartella
190Documentation/output.
191Questi posso essere generati anche in formato LaTex e ePub con::
192
193 make latexdocs
194 make epubdocs
195
196Diventare uno sviluppatore del kernel
197-------------------------------------
198Se non sapete nulla sullo sviluppo del kernel Linux, dovreste dare uno
199sguardo al progetto *Linux KernelNewbies*:
200
201 https://kernelnewbies.org
202
203Esso prevede un'utile lista di discussione dove potete porre più o meno ogni
204tipo di quesito relativo ai concetti fondamentali sullo sviluppo del kernel
205(assicuratevi di cercare negli archivi, prima di chiedere qualcosa alla
206quale è già stata fornita risposta in passato). Esistono inoltre, un canale IRC
207che potete usare per formulare domande in tempo reale, e molti documenti utili
208che vi faciliteranno nell'apprendimento dello sviluppo del kernel Linux.
209
210Il sito internet contiene informazioni di base circa l'organizzazione del
211codice, sottosistemi e progetti attuali (sia interni che esterni a Linux).
212Esso descrive, inoltre, informazioni logistiche di base, riguardanti ad esempio
213la compilazione del kernel e l'applicazione di una modifica.
214
215Se non sapete dove cominciare, ma volete cercare delle attività dalle quali
216partire per partecipare alla comunità di sviluppo, andate al progetto Linux
217Kernel Janitor's.
218
219 https://kernelnewbies.org/KernelJanitors
220
221È un buon posto da cui iniziare. Esso presenta una lista di problematiche
222relativamente semplici da sistemare e pulire all'interno della sorgente del
223kernel Linux. Lavorando con gli sviluppatori incaricati di questo progetto,
224imparerete le basi per l'inserimento delle vostre modifiche all'interno dei
225sorgenti del kernel Linux, e possibilmente, sarete indirizzati al lavoro
226successivo da svolgere, se non ne avrete ancora idea.
227
228Prima di apportare una qualsiasi modifica al codice del kernel Linux,
229è imperativo comprendere come tale codice funziona. A questo scopo, non c'è
230nulla di meglio che leggerlo direttamente (la maggior parte dei bit più
231complessi sono ben commentati), eventualmente anche con l'aiuto di strumenti
232specializzati. Uno degli strumenti che è particolarmente raccomandato è
233il progetto Linux Cross-Reference, che è in grado di presentare codice
234sorgente in un formato autoreferenziale ed indicizzato. Un eccellente ed
235aggiornata fonte di consultazione del codice del kernel la potete trovare qui:
236
237 http://lxr.free-electrons.com/
238
239
240Il processo di sviluppo
241-----------------------
242Il processo di sviluppo del kernel Linux si compone di pochi "rami" principali
243e 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
251I sorgenti kernel 4.x
252~~~~~~~~~~~~~~~~~~~~~
253
254I kernel 4.x sono amministrati da Linus Torvald, e possono essere trovati
255su https://kernel.org nella cartella pub/linux/kernel/v4.x/. Il processo
256di 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
287kernel-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
292I sorgenti stabili del kernel 4.x.y -stable
293~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294
295I kernel con versioni in 3-parti sono "kernel stabili". Essi contengono
296correzioni critiche relativamente piccole nell'ambito della sicurezza
297oppure significative regressioni scoperte in un dato 4.x kernel.
298
299Questo è il ramo raccomandato per gli utenti che vogliono un kernel recente
300e stabile e non sono interessati a dare il proprio contributo alla verifica
301delle versioni di sviluppo o sperimentali.
302
303Se non è disponibile alcun kernel 4.x.y., quello più aggiornato e stabile
304sarà il kernel 4.x con la numerazione più alta.
305
3064.x.y sono amministrati dal gruppo "stable" <stable@vger.kernel.org>, e sono
307rilasciati a seconda delle esigenze. Il normale periodo di rilascio è
308approssimativamente di due settimane, ma può essere più lungo se non si
309verificano problematiche urgenti. Un problema relativo alla sicurezza, invece,
310può determinare un rilascio immediato.
311
312Il file Documentation/process/stable-kernel-rules.rst (nei sorgenti) documenta
313quali tipologie di modifiche sono accettate per i sorgenti -stable, e come
314avviene il processo di rilascio.
315
316Le modifiche in 4.x -git
317~~~~~~~~~~~~~~~~~~~~~~~~
318
319Queste sono istantanee quotidiane del kernel di Linus e sono gestite in
320una repositorio git (da qui il nome). Queste modifiche sono solitamente
321rilasciate giornalmente e rappresentano l'attuale stato dei sorgenti di
322Linus. Queste sono da considerarsi più sperimentali di un -rc in quanto
323generate automaticamente senza nemmeno aver dato una rapida occhiata
324per verificarne lo stato.
325
326
327Sorgenti dei sottosistemi del kernel e le loro patch
328~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329
330I manutentori dei diversi sottosistemi del kernel --- ed anche molti
331sviluppatori di sottosistemi --- mostrano il loro attuale stato di sviluppo
332nei loro repositori. In questo modo, altri possono vedere cosa succede nelle
333diverse parti del kernel. In aree dove lo sviluppo è rapido, potrebbe essere
334chiesto ad uno sviluppatore di basare le proprie modifiche su questi repositori
335in modo da evitare i conflitti fra le sottomissioni ed altri lavori in corso
336
337La maggior parte di questi repositori sono git, ma esistono anche altri SCM
338in uso, o file di patch pubblicate come una serie quilt.
339Gli indirizzi dei repositori di sottosistema sono indicati nel file
340MAINTAINERS. Molti di questi posso essere trovati su https://git.kernel.org/.
341
342Prima che una modifica venga inclusa in questi sottosistemi, sarà soggetta ad
343una revisione che inizialmente avviene tramite liste di discussione (vedere la
344sezione dedicata qui sotto). Per molti sottosistemi del kernel, tale processo
345di revisione è monitorato con lo strumento patchwork.
346Patchwork offre un'interfaccia web che mostra le patch pubblicate, inclusi i
347commenti o le revisioni fatte, e gli amministratori possono indicare le patch
348come "in revisione", "accettate", o "rifiutate". Diversi siti Patchwork sono
349elencati al sito https://patchwork.kernel.org/.
350
351Il kernel 4.x -next per test d'integrazione
352~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
353
354Prima che gli aggiornamenti dei sottosistemi siano accorpati nel ramo
355principale 4.x, sarà necessario un test d'integrazione.
356A tale scopo, esiste un repositorio speciale di test nel quale virtualmente
357tutti i rami dei sottosistemi vengono inclusi su base quotidiana:
358
359 https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
360
361In questo modo, i kernel -next offrono uno sguardo riassuntivo su quello che
362ci si aspetterà essere nel kernel principale nel successivo periodo
363d'incorporazione.
364Coloro che vorranno fare dei test d'esecuzione del kernel -next sono più che
365benvenuti.
366
367
368Riportare Bug
369-------------
370
371https://bugzilla.kernel.org è dove gli sviluppatori del kernel Linux tracciano
372i bachi del kernel. Gli utenti sono incoraggiati nel riportare tutti i bachi
373che trovano utilizzando questo strumento.
374Per maggiori dettagli su come usare il bugzilla del kernel, guardare:
375
376 https://bugzilla.kernel.org/page.cgi?id=faq.html
377
378Il file admin-guide/reporting-bugs.rst nella cartella principale del kernel
379fornisce un buon modello sul come segnalare un baco nel kernel, e spiega quali
380informazioni sono necessarie agli sviluppatori per poter aiutare il
381rintracciamento del problema.
382
383Gestire i rapporti sui bug
384--------------------------
385
386Uno dei modi migliori per mettere in pratica le vostre capacità di hacking è
387quello di riparare bachi riportati da altre persone. Non solo aiuterete a far
388diventare il kernel più stabile, ma imparerete a riparare problemi veri dal
389mondo ed accrescerete le vostre competenze, e gli altri sviluppatori saranno
390al corrente della vostra presenza. Riparare bachi è una delle migliori vie per
391acquisire meriti tra gli altri sviluppatori, perchè non a molte persone piace
392perdere tempo a sistemare i bachi di altri.
393
394Per lavorare sui rapporti di bachi già riportati, andate su
395https://bugzilla.kernel.org.
396
397Liste di discussione
398--------------------
399
400Come descritto in molti dei documenti qui sopra, la maggior parte degli
401sviluppatori del kernel partecipano alla lista di discussione Linux Kernel.
402I dettagli su come iscriversi e disiscriversi dalla lista possono essere
403trovati al sito:
404
405 http://vger.kernel.org/vger-lists.html#linux-kernel
406
407Ci sono diversi archivi della lista di discussione. Usate un qualsiasi motore
408di 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
413sollevare, prima di pubblicarlo sulla lista. Molte cose sono già state
414discusse in dettaglio e registrate negli archivi della lista di discussione.
415
416Molti dei sottosistemi del kernel hanno anche una loro lista di discussione
417dedicata. Guardate nel file MAINTAINERS per avere una lista delle liste di
418discussione e il loro uso.
419
420Molte di queste liste sono gestite su kernel.org. Per informazioni consultate
421la seguente pagina:
422
423 http://vger.kernel.org/vger-lists.html
424
425Per favore ricordatevi della buona educazione quando utilizzate queste liste.
426Sebbene sia un pò dozzinale, il seguente URL contiene alcune semplici linee
427guida per interagire con la lista (o con qualsiasi altra lista):
428
429 http://www.albion.com/netiquette/
430
431Se diverse persone rispondo alla vostra mail, la lista dei riceventi (copia
432conoscenza) potrebbe diventare abbastanza lunga. Non cancellate nessuno dalla
433lista di CC: senza un buon motivo, e non rispondete solo all'indirizzo
434della lista di discussione. Fateci l'abitudine perché capita spesso di
435ricevere la stessa email due volte: una dal mittente ed una dalla lista; e non
436cercate di modificarla aggiungendo intestazioni stravaganti, agli altri non
437piacerà.
438
439Ricordate di rimanere sempre in argomento e di mantenere le attribuzioni
440delle vostre risposte invariate; mantenete il "John Kernelhacker wrote ...:"
441in cima alla vostra replica e aggiungete le vostre risposte fra i singoli
442blocchi citati, non scrivete all'inizio dell'email.
443
444Se aggiungete patch alla vostra mail, assicuratevi che siano del tutto
445leggibili come indicato in Documentation/process/submitting-patches.rst.
446Gli sviluppatori kernel non vogliono avere a che fare con allegati o patch
447compresse; vogliono invece poter commentare le righe dei vostri cambiamenti,
448il che può funzionare solo in questo modo.
449Assicuratevi di utilizzare un gestore di mail che non alterì gli spazi ed i
450caratteri. Un ottimo primo test è quello di inviare a voi stessi una mail e
451cercare di sottoporre la vostra stessa patch. Se non funziona, sistemate il
452vostro programma di posta, o cambiatelo, finché non funziona.
453
454Ed infine, per favore ricordatevi di mostrare rispetto per gli altri
455sottoscriventi.
456
457Lavorare con la comunità
458------------------------
459
460L'obiettivo di questa comunità è quello di fornire il miglior kernel possibile.
461Quando inviate una modifica che volete integrare, sarà valutata esclusivamente
462dal punto di vista tecnico. Quindi, cosa dovreste aspettarvi?
463
464 - critiche
465 - commenti
466 - richieste di cambiamento
467 - richieste di spiegazioni
468 - nulla
469
470Ricordatevi che questo fa parte dell'integrazione della vostra modifica
471all'interno del kernel. Dovete essere in grado di accettare le critiche,
472valutarle a livello tecnico ed eventualmente rielaborare nuovamente le vostre
473modifiche o fornire delle chiare e concise motivazioni per le quali le
474modifiche suggerite non dovrebbero essere fatte.
475Se non riceverete risposte, aspettate qualche giorno e riprovate ancora,
476qualche volta le cose si perdono nell'enorme mucchio di email.
477
478Cosa 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
486In una comunità che è alla ricerca delle migliori soluzioni tecniche possibili,
487ci saranno sempre opinioni differenti sull'utilità di una modifica.
488Siate cooperativi e vogliate adattare la vostra idea in modo che sia inserita
489nel kernel. O almeno vogliate dimostrare che la vostra idea vale.
490Ricordatevi, sbagliare è accettato fintanto che siate disposti a lavorare verso
491una soluzione che è corretta.
492
493È normale che le risposte alla vostra prima modifica possa essere
494semplicemente una lista con dozzine di cose che dovreste correggere.
495Questo **non** implica che la vostra patch non sarà accettata, e questo
496**non** è contro di voi personalmente.
497Semplicemente correggete tutte le questioni sollevate contro la vostra modifica
498ed inviatela nuovamente.
499
500Differenze tra la comunità del kernel e le strutture aziendali
501--------------------------------------------------------------
502
503La comunità del kernel funziona diversamente rispetto a molti ambienti di
504sviluppo aziendali. Qui di seguito una lista di cose che potete provare a
505fare 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
530Un'altra cosa nella quale la comunità del kernel si differenzia dai più
531classici ambienti di ingegneria del software è la natura "senza volto" delle
532interazioni umane. Uno dei benefici dell'uso delle email e di irc come forma
533primordiale di comunicazione è l'assenza di discriminazione basata su genere e
534razza. L'ambienti di lavoro Linux accetta donne e minoranze perchè tutto quello
535che sei è un indirizzo email. Aiuta anche l'aspetto internazionale nel
536livellare il terreno di gioco perchè non è possibile indovinare il genere
537basandosi sul nome di una persona. Un uomo può chiamarsi Andrea ed una donna
538potrebbe chiamarsi Pat. Gran parte delle donne che hanno lavorato al kernel
539Linux e che hanno espresso una personale opinione hanno avuto esperienze
540positive.
541
542La lingua potrebbe essere un ostacolo per quelle persone che non si trovano
543a loro agio con l'inglese. Una buona padronanza del linguaggio può essere
544necessaria per esporre le proprie idee in maniera appropiata all'interno
545delle liste di discussione, quindi è consigliabile che rileggiate le vostre
546email prima di inviarle in modo da essere certi che abbiano senso in inglese.
547
548
549Spezzare le vostre modifiche
550----------------------------
551
552La comunità del kernel Linux non accetta con piacere grossi pezzi di codice
553buttati lì tutti in una volta. Le modifiche necessitano di essere
554adeguatamente presentate, discusse, e suddivise in parti più piccole ed
555indipendenti. Questo è praticamente l'esatto opposto di quello che le
556aziende fanno solitamente. La vostra proposta dovrebbe, inoltre, essere
557presentata prestissimo nel processo di sviluppo, così che possiate ricevere
558un riscontro su quello che state facendo. Lasciate che la comunità
559senta che state lavorando con loro, e che non li stiate sfruttando come
560discarica per le vostre aggiunte. In ogni caso, non inviate 50 email nello
561stesso momento in una lista di discussione, il più delle volte la vostra serie
562di modifiche dovrebbe essere più piccola.
563
564I motivi per i quali dovreste frammentare le cose sono i seguenti:
565
5661) 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
5792) È importante non solo inviare piccole modifiche, ma anche riscriverle e
580 semplificarle (o più semplicemente ordinarle) prima di sottoporle.
581
582Qui 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
596Può essere una vera sfida il saper mantenere l'equilibrio fra una presentazione
597elegante della vostra soluzione, lavorare insieme ad una comunità e dibattere
598su un lavoro incompleto. Pertanto è bene entrare presto nel processo di
599revisione per migliorare il vostro lavoro, ma anche per riuscire a tenere le
600vostre modifiche in pezzettini che potrebbero essere già accettate, nonostante
601la vostra intera attività non lo sia ancora.
602
603In fine, rendetevi conto che non è accettabile inviare delle modifiche
604incomplete con la promessa che saranno "sistemate dopo".
605
606
607Giustificare le vostre modifiche
608--------------------------------
609
610Insieme alla frammentazione delle vostre modifiche, è altrettanto importante
611permettere alla comunità Linux di capire perché dovrebbero accettarle.
612Nuove funzionalità devono essere motivate come necessarie ed utili.
613
614
615Documentare le vostre modifiche
616-------------------------------
617
618Quando inviate le vostre modifiche, fate particolare attenzione a quello che
619scrivete nella vostra email. Questa diventerà il *ChangeLog* per la modifica,
620e sarà visibile a tutti per sempre. Dovrebbe descrivere la modifica nella sua
621interezza, contenendo:
622
623 - perchè la modifica è necessaria
624 - l'approccio d'insieme alla patch
625 - dettagli supplementari
626 - risultati dei test
627
628Per maggiori dettagli su come tutto ciò dovrebbe apparire, riferitevi alla
629sezione ChangeLog del documento:
630
631 "The Perfect Patch"
632 http://www.ozlabs.org/~akpm/stuff/tpp.txt
633
634A volte tutto questo è difficile da realizzare. Il perfezionamento di queste
635pratiche può richiedere anni (eventualmente). È un processo continuo di
636miglioramento che richiede molta pazienza e determinazione. Ma non mollate,
637si può fare. Molti lo hanno fatto prima, ed ognuno ha dovuto iniziare dove
638siete voi ora.
639
640
641
642
643----------
644
645Grazie 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
647Randy Dunlap e Gerrit Huizenga per la lista di cose che dovreste e non
648dovreste dire. Grazie anche a Pat Mochel, Hanna Linder, Randy Dunlap,
649Kay Sievers, Vojtech Pavlik, Jan Kara, Josh Boyer, Kees Cook, Andrew Morton,
650Andi Kleen, Vadim Lobanov, Jesper Juhl, Adrian Bunk, Keri Harris, Frans Pop,
651David A. Wheeler, Junio Hamano, Michael Kerrisk, e Alex Shepard per le
652loro revisioni, commenti e contributi. Senza il loro aiuto, questo documento
653non sarebbe stato possibile.
654
655Manutentore: 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
13Lavorare con la comunità di sviluppo del kernel
14===============================================
15
16Quindi volete diventare sviluppatori del kernel? Benvenuti! C'è molto da
17imparare sul lato tecnico del kernel, ma è anche importante capire come
18funziona la nostra comunità. Leggere questi documenti renderà più facile
19l'accettazione delle vostre modifiche con il minimo sforzo.
20
21Di 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
36Poi ci sono altre guide sulla comunità che sono di interesse per molti
37degli 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
50Ed infine, qui ci sono alcune guide più tecniche che son state messe qua solo
51perché 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
8Indice 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
8Dichiarazioni sui driver per il kernel
9======================================
10
11Presa di posizione sui moduli per il kernel Linux
12-------------------------------------------------
13
14Noi, i sottoscritti sviluppatori del kernel, consideriamo pericoloso
15o indesiderato qualsiasi modulo o driver per il kernel Linux di tipo
16*a sorgenti chiusi* (*closed-source*). Ripetutamente, li abbiamo
17trovati deleteri per gli utenti Linux, le aziende, ed in generale
18l'ecosistema Linux. Questi moduli impediscono l'apertura, la stabilità,
19la flessibilità, e la manutenibilità del modello di sviluppo di Linux
20e impediscono ai loro utenti di beneficiare dell'esperienza dalla
21comunità Linux. I fornitori che distribuiscono codice a sorgenti chiusi
22obbligano i propri utenti a rinunciare ai principali vantaggi di Linux
23o a cercarsi nuovi fornitori.
24Perciò, al fine di sfruttare i vantaggi che codice aperto ha da offrire,
25come l'abbattimento dei costi e un supporto condiviso, spingiamo i
26fornitori ad adottare una politica di supporto ai loro clienti Linux
27che preveda il rilascio dei sorgenti per il kernel.
28
29Parliamo solo per noi stessi, e non per una qualsiasi azienda per la
30quale lavoriamo oggi, o abbiamo lavorato in passato, o lavoreremo in
31futuro.
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
8Applicazione 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
8I numeri magici di Linux
9========================
10
11Questo documento è un registro dei numeri magici in uso. Quando
12aggiungete un numero magico ad una struttura, dovreste aggiungerlo anche
13a questo documento; la cosa migliore è che tutti i numeri magici usati
14dalle varie strutture siano unici.
15
16È **davvero** un'ottima idea proteggere le strutture dati del kernel con
17dei numeri magici. Questo vi permette in fase d'esecuzione di (a) verificare
18se una struttura è stata malmenata, o (b) avete passato a una procedura la
19struttura errata. Quest'ultimo è molto utile - particolarmente quando si passa
20una struttura dati tramite un puntatore void \*. Il codice tty, per esempio,
21effettua questa operazione con regolarità passando avanti e indietro le
22strutture specifiche per driver e discipline.
23
24Per utilizzare un numero magico, dovete dichiararlo all'inizio della struttura
25dati, come di seguito::
26
27 struct tty_ldisc {
28 int magic;
29 ...
30 };
31
32Per favore, seguite questa direttiva quando aggiungerete migliorie al kernel!
33Mi ha risparmiato un numero illimitato di ore di debug, specialmente nei casi
34più ostici dove si è andati oltre la dimensione di un vettore e la struttura
35dati che lo seguiva in memoria è stata sovrascritta. Seguendo questa
36direttiva, questi casi vengono identificati velocemente e in sicurezza.
37
38Registro 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===================== ================ ======================== ==========================================
75Nome magico Numero Struttura File
76===================== ================ ======================== ==========================================
77PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h``
78CMAGIC 0x0111 user ``include/linux/a.out.h``
79MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h``
80HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c``
81APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c``
82CYCLADES_MAGIC 0x4359 cyclades_port ``include/linux/cyclades.h``
83DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c``
84DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c``
85FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
86FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c``
87ISICOM_MAGIC 0x4d54 isi_port ``include/linux/isicom.h``
88PTY_MAGIC 0x5001 ``drivers/char/pty.c``
89PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h``
90SERIAL_MAGIC 0x5301 async_struct ``include/linux/serial.h``
91SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h``
92SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h``
93STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c``
94X25_ASY_MAGIC 0x5303 x25_asy ``drivers/net/x25_asy.h``
95SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h``
96AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h``
97TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h``
98MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c``
99TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h``
100MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c``
101TTY_LDISC_MAGIC 0x5403 tty_ldisc ``include/linux/tty_ldisc.h``
102USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h``
103FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c``
104USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c``
105RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/rfcomm/tty.c``
106USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h``
107CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h``
108RPORT_MAGIC 0x00525001 r_port ``drivers/char/rocket_int.h``
109LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c``
110GDTIOCTL_MAGIC 0x06030f07 gdth_iowr_str ``drivers/scsi/gdth_ioctl.h``
111RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c``
112NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h``
113RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c``
114BAYCOM_MAGIC 0x19730510 baycom_state ``drivers/net/baycom_epp.c``
115ISDN_X25IFACE_MAGIC 0x1e75a2b9 isdn_x25iface_proto_data ``drivers/isdn/isdn_x25iface.h``
116ECP_MAGIC 0x21504345 cdkecpsig ``include/linux/cdk.h``
117LSOMAGIC 0x27091997 lso ``drivers/fc4/fc.c``
118LSMAGIC 0x2a3b4d2a ls ``drivers/fc4/fc.c``
119WANPIPE_MAGIC 0x414C4453 sdla_{dump,exec} ``include/linux/wanpipe.h``
120CS_CARD_MAGIC 0x43525553 cs_card ``sound/oss/cs46xx.c``
121LABELCL_MAGIC 0x4857434c labelcl_info_s ``include/asm/ia64/sn/labelcl.h``
122ISDN_ASYNC_MAGIC 0x49344C01 modem_info ``include/linux/isdn.h``
123CTC_ASYNC_MAGIC 0x49344C01 ctc_tty_info ``drivers/s390/net/ctctty.c``
124ISDN_NET_MAGIC 0x49344C02 isdn_net_local_s ``drivers/isdn/i4l/isdn_net_lib.h``
125SAVEKMSG_MAGIC2 0x4B4D5347 savekmsg ``arch/*/amiga/config.c``
126CS_STATE_MAGIC 0x4c4f4749 cs_state ``sound/oss/cs46xx.c``
127SLAB_C_MAGIC 0x4f17a36d kmem_cache ``mm/slab.c``
128COW_MAGIC 0x4f4f4f4d cow_header_v1 ``arch/um/drivers/ubd_user.c``
129I810_CARD_MAGIC 0x5072696E i810_card ``sound/oss/i810_audio.c``
130TRIDENT_CARD_MAGIC 0x5072696E trident_card ``sound/oss/trident.c``
131ROUTER_MAGIC 0x524d4157 wan_device [in ``wanrouter.h`` pre 3.9]
132SAVEKMSG_MAGIC1 0x53415645 savekmsg ``arch/*/amiga/config.c``
133GDA_MAGIC 0x58464552 gda ``arch/mips/include/asm/sn/gda.h``
134RED_MAGIC1 0x5a2cf071 (any) ``mm/slab.c``
135EEPROM_MAGIC_VALUE 0x5ab478d2 lanai_dev ``drivers/atm/lanai.c``
136HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h``
137PCXX_MAGIC 0x5c6df104 channel ``drivers/char/pcxx.h``
138KV_MAGIC 0x5f4b565f kernel_vars_s ``arch/mips/include/asm/sn/klkernvars.h``
139I810_STATE_MAGIC 0x63657373 i810_state ``sound/oss/i810_audio.c``
140TRIDENT_STATE_MAGIC 0x63657373 trient_state ``sound/oss/trident.c``
141M3_CARD_MAGIC 0x646e6f50 m3_card ``sound/oss/maestro3.c``
142FW_HEADER_MAGIC 0x65726F66 fw_header ``drivers/atm/fore200e.h``
143SLOT_MAGIC 0x67267321 slot ``drivers/hotplug/cpqphp.h``
144SLOT_MAGIC 0x67267322 slot ``drivers/hotplug/acpiphp.h``
145LO_MAGIC 0x68797548 nbd_device ``include/linux/nbd.h``
146OPROFILE_MAGIC 0x6f70726f super_block ``drivers/oprofile/oprofilefs.h``
147M3_STATE_MAGIC 0x734d724d m3_state ``sound/oss/maestro3.c``
148VMALLOC_MAGIC 0x87654320 snd_alloc_track ``sound/core/memory.c``
149KMALLOC_MAGIC 0x87654321 snd_alloc_track ``sound/core/memory.c``
150PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/media/pwc.h``
151NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h``
152ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h``
153CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h``
154DPMEM_MAGIC 0xc0ffee11 gdt_pci_sram ``drivers/scsi/gdth.h``
155YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c``
156CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
157QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c``
158QUEUE_MAGIC_USED 0xf7e1cc33 queue_entry ``drivers/scsi/arm/queue.c``
159HTB_CMAGIC 0xFEFAFEF1 htb_class ``net/sched/sch_htb.c``
160NMI_MAGIC 0x48414d4d455201 nmi_s ``arch/mips/include/asm/sn/nmi.h``
161===================== ================ ======================== ==========================================
162
163Da notare che ci sono anche dei numeri magici specifici per driver nel
164*sound memory management*. Consultate ``include/sound/sndmagic.h`` per una
165lista completa. Molti driver audio OSS hanno i loro numeri magici costruiti a
166partire dall'identificativo PCI della scheda audio - nemmeno questi sono
167elencati in questo file.
168
169Il file-system HFS è un altro grande utilizzatore di numeri magici - potete
170trovarli 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========================================
8Guida 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
7Tipo 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
8L'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
7Tutto 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
7Lista 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
7Sottomettere 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
8Sottomettere 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
8Perché la parola chiave "volatile" non dovrebbe essere usata
9------------------------------------------------------------
10
11Spesso i programmatori C considerano volatili quelle variabili che potrebbero
12essere cambiate al di fuori dal thread di esecuzione corrente; come risultato,
13a volte saranno tentati dall'utilizzare *volatile* nel kernel per le
14strutture dati condivise. In altre parole, gli è stato insegnato ad usare
15*volatile* come una variabile atomica di facile utilizzo, ma non è così.
16L'uso di *volatile* nel kernel non è quasi mai corretto; questo documento ne
17descrive le ragioni.
18
19Il punto chiave da capire su *volatile* è che il suo scopo è quello di
20sopprimere le ottimizzazioni, che non è quasi mai quello che si vuole.
21Nel kernel si devono proteggere le strutture dati condivise contro accessi
22concorrenti e indesiderati: questa è un'attività completamente diversa.
23Il processo di protezione contro gli accessi concorrenti indesiderati eviterà
24anche la maggior parte dei problemi relativi all'ottimizzazione in modo più
25efficiente.
26
27Come *volatile*, le primitive del kernel che rendono sicuro l'accesso ai dati
28(spinlock, mutex, barriere di sincronizzazione, ecc) sono progettate per
29prevenire le ottimizzazioni indesiderate. Se vengono usate opportunamente,
30non ci sarà bisogno di utilizzare *volatile*. Se vi sembra che *volatile* sia
31comunque necessario, ci dev'essere quasi sicuramente un baco da qualche parte.
32In un pezzo di codice kernel scritto a dovere, *volatile* può solo servire a
33rallentare le cose.
34
35Considerate 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
42Se tutto il codice seguisse le regole di sincronizzazione, il valore di un
43dato condiviso non potrebbe cambiare inaspettatamente mentre si trattiene un
44lock. Un qualsiasi altro blocco di codice che vorrà usare quel dato rimarrà
45in attesa del lock. Gli spinlock agiscono come barriere di sincronizzazione
46- sono stati esplicitamente scritti per agire così - il che significa che gli
47accessi al dato condiviso non saranno ottimizzati. Quindi il compilatore
48potrebbe pensare di sapere cosa ci sarà nel dato condiviso ma la chiamata
49spin_lock(), che agisce come una barriera di sincronizzazione, gli imporrà di
50dimenticarsi tutto ciò che sapeva su di esso.
51
52Se il dato condiviso fosse stato dichiarato come *volatile*, la
53sincronizzazione rimarrebbe comunque necessaria. Ma verrà impedito al
54compilatore di ottimizzare gli accessi al dato anche _dentro_ alla sezione
55critica, dove sappiamo che in realtà nessun altro può accedervi. Mentre si
56trattiene un lock, il dato condiviso non è *volatile*. Quando si ha a che
57fare con dei dati condivisi, un'opportuna sincronizzazione rende inutile
58l'uso di *volatile* - anzi potenzialmente dannoso.
59
60L'uso di *volatile* fu originalmente pensato per l'accesso ai registri di I/O
61mappati in memoria. All'interno del kernel, l'accesso ai registri, dovrebbe
62essere protetto dai lock, ma si potrebbe anche desiderare che il compilatore
63non "ottimizzi" l'accesso ai registri all'interno di una sezione critica.
64Ma, all'interno del kernel, l'accesso alla memoria di I/O viene sempre fatto
65attraverso funzioni d'accesso; accedere alla memoria di I/O direttamente
66con i puntatori è sconsigliato e non funziona su tutte le architetture.
67Queste funzioni d'accesso sono scritte per evitare ottimizzazioni indesiderate,
68quindi, di nuovo, *volatile* è inutile.
69
70Un'altra situazione dove qualcuno potrebbe essere tentato dall'uso di
71*volatile*, è nel caso in cui il processore è in un'attesa attiva sul valore
72di 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
77La chiamata cpu_relax() può ridurre il consumo di energia del processore
78o cedere il passo ad un processore hyperthreaded gemello; funziona anche come
79una barriera per il compilatore, quindi, ancora una volta, *volatile* non è
80necessario. Ovviamente, tanto per puntualizzare, le attese attive sono
81generalmente un atto antisociale.
82
83Ci sono comunque alcune rare situazioni dove l'uso di *volatile* nel kernel
84ha 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
109Per la maggior parte del codice, nessuna delle giustificazioni sopracitate può
110essere considerata. Di conseguenza, l'uso di *volatile* è probabile che venga
111visto come un baco e porterà a verifiche aggiuntive. Gli sviluppatori tentati
112dall'uso di *volatile* dovrebbero fermarsi e pensare a cosa vogliono davvero
113ottenere.
114
115Le modifiche che rimuovono variabili *volatile* sono generalmente ben accette
116- purché accompagnate da una giustificazione che dimostri che i problemi di
117concorrenza siano stati opportunamente considerati.
118
119Riferimenti
120===========
121
122[1] http://lwn.net/Articles/233481/
123
124[2] http://lwn.net/Articles/233482/
125
126Crediti
127=======
128
129Impulso e ricerca originale di Randy Dunlap
130
131Scritto da Jonathan Corbet
132
133Migliorato dai commenti di Satyam Sharma, Johannes Stezenbach, Jesper
134Juhl, 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 @@
2Linux Memory Management Documentation 2Linux Memory Management Documentation
3===================================== 3=====================================
4 4
5This is a collection of documents about Linux memory management (mm) subsystem. 5This is a collection of documents about the Linux memory management (mm)
6subsystem. If you are looking for advice on simply allocating memory,
7see the :ref:`memory-allocation`.
6 8
7User guides for MM features 9User 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
60Protocol 2.12: (Kernel 3.8) Added the xloadflags field and extension fields 60Protocol 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 */
532static __always_inline void *kmalloc(size_t size, gfp_t flags) 531static __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 */
435struct kmem_cache * 437struct kmem_cache *
436kmem_cache_create_usercopy(const char *name, 438kmem_cache_create_usercopy(const char *name,
@@ -514,6 +516,31 @@ out_unlock:
514} 516}
515EXPORT_SYMBOL(kmem_cache_create_usercopy); 517EXPORT_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 */
517struct kmem_cache * 544struct kmem_cache *
518kmem_cache_create(const char *name, unsigned int size, unsigned int align, 545kmem_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;
212my $type_constant = '\b``([^\`]+)``\b'; 212my $type_constant = '\b``([^\`]+)``\b';
213my $type_constant2 = '\%([-_\w]+)'; 213my $type_constant2 = '\%([-_\w]+)';
214my $type_func = '(\w+)\(\)'; 214my $type_func = '(\w+)\(\)';
215my $type_param = '\@(\w*(\.\w+)*(\.\.\.)?)'; 215my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
216my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params 216my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
217my $type_env = '(\$\w+)'; 217my $type_env = '(\$\w+)';
218my $type_enum = '\&(enum\s*([_\w]+))'; 218my $type_enum = '\&(enum\s*([_\w]+))';
@@ -361,7 +361,7 @@ my $doc_com = '\s*\*\s*';
361my $doc_com_body = '\s*\* ?'; 361my $doc_com_body = '\s*\* ?';
362my $doc_decl = $doc_com . '(\w+)'; 362my $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
364my $doc_sect = $doc_com . 364my $doc_sect = $doc_com .
365 '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)'; 365 '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)';
366my $doc_content = $doc_com_body . '(.*)'; 366my $doc_content = $doc_com_body . '(.*)';
367my $doc_block = $doc_com . 'DOC:\s*(.*)?'; 367my $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#
755sub highlight_block($) { 755sub 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;