History

Merge branch 'akpm' (incoming from Andrew)

Merge second patch-bomb from Andrew Morton: - various misc bits - the rest of MM - add generic fixmap.h, use it - backlight updates - dynamic_debug updates - printk() updates - checkpatch updates - binfmt_elf - ramfs - init/ - autofs4 - drivers/rtc - nilfs - hfsplus - Documentation/ - coredump - procfs - fork - exec - kexec - kdump - partitions - rapidio - rbtree - userns - memstick - w1 - decompressors * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (197 commits) lib/decompress_unlz4.c: always set an error return code on failures romfs: fix returm err while getting inode in fill_super drivers/w1/masters/w1-gpio.c: add strong pullup emulation drivers/memstick/host/rtsx_pci_ms.c: fix ms card data transfer bug userns: relax the posix_acl_valid() checks arch/sh/kernel/dwarf.c: use rbtree postorder iteration helper instead of solution using repeated rb_erase() fs-ext3-use-rbtree-postorder-iteration-helper-instead-of-opencoding-fix fs/ext3: use rbtree postorder iteration helper instead of opencoding fs/jffs2: use rbtree postorder iteration helper instead of opencoding fs/ext4: use rbtree postorder iteration helper instead of opencoding fs/ubifs: use rbtree postorder iteration helper instead of opencoding net/netfilter/ipset/ip_set_hash_netiface.c: use rbtree postorder iteration instead of opencoding rbtree/test: test rbtree_postorder_for_each_entry_safe() rbtree/test: move rb_node to the middle of the test struct rapidio: add modular rapidio core build into powerpc and mips branches partitions/efi: complete documentation of gpt kernel param purpose kdump: add /sys/kernel/vmcoreinfo ABI documentation kdump: fix exported size of vmcoreinfo note kexec: add sysctl to disable kexec_load fs/exec.c: call arch_pick_mmap_layout() only once ...

Linus Torvalds committed 12 years ago

Commit 3aacd622 parents 7e21774 2a1d689231 files · +3339 −2187Browse files

Unified · Split

231 files
  1. Documentation/ABI/testing/sysfs-kernel-vmcoreinfo +14 −0
  2. Documentation/blockdev/ramdisk.txt +15 −6
  3. Documentation/cpu-hotplug.txt +1 −1
  4. Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt +27 −0
  5. Documentation/devicetree/bindings/rtc/maxim,ds1742.txt +12 −0
  6. Documentation/devicetree/bindings/vendor-prefixes.txt +1 −0
  7. Documentation/dynamic-debug-howto.txt +9 −0
  8. Documentation/filesystems/00-INDEX +45 −13
  9. Documentation/filesystems/nilfs2.txt +56 −0
  10. Documentation/filesystems/sysfs.txt +3 −3
  11. Documentation/kernel-parameters.txt +10 −1
  12. Documentation/printk-formats.txt +9 −2
  13. Documentation/sysctl/kernel.txt +14 −1
  14. Documentation/trace/postprocess/trace-vmscan-postprocess.pl +9 −9
  15. Documentation/vm/locking +0 −130
  16. MAINTAINERS +11 −1
  17. arch/alpha/Kconfig +4 −4
  18. arch/arc/Kconfig +2 −2
  19. arch/arm/Kconfig +6 −6
  20. arch/cris/include/asm/io.h +4 −0
  21. arch/hexagon/include/asm/fixmap.h +1 −39
  22. arch/ia64/Kconfig +1 −0
  23. arch/ia64/include/asm/dmi.h +5 −3
  24. arch/ia64/include/asm/processor.h +1 −0
  25. arch/m32r/Kconfig +4 −4
  26. arch/metag/include/asm/fixmap.h +1 −31
  27. arch/microblaze/Kconfig +1 −0
  28. arch/microblaze/include/asm/fixmap.h +2 −42
  29. arch/mips/Kconfig +5 −5
  30. arch/mips/include/asm/fixmap.h +1 −32
  31. arch/mn10300/Kconfig +4 −4
  32. arch/parisc/Kconfig +4 −4
  33. arch/powerpc/Kconfig +2 −2
  34. arch/powerpc/include/asm/fixmap.h +2 −42
  35. arch/s390/Kconfig +2 −2
  36. arch/sh/Kconfig +4 −4
  37. arch/sh/include/asm/fixmap.h +2 −37
  38. arch/sh/kernel/dwarf.c +4 −14
  39. arch/sparc/Kconfig +2 −2
  40. arch/tile/include/asm/fixmap.h +1 −32
  41. arch/um/include/asm/fixmap.h +1 −39
  42. arch/x86/Kconfig +5 −4
  43. arch/x86/include/asm/dmi.h +4 −2
  44. arch/x86/include/asm/fixmap.h +1 −58
  45. arch/x86/mm/gup.c +4 −4
  46. drivers/block/Kconfig +2 −1
  47. drivers/firmware/Kconfig +3 −0
  48. drivers/firmware/dmi_scan.c +10 −10
  49. drivers/gpu/drm/gma500/backlight.c +2 −2
  50. drivers/mailbox/omap-mbox.h +1 −1
  51. drivers/memstick/host/rtsx_pci_ms.c +20 −10
  52. drivers/mfd/max8998.c +1 −1
  53. drivers/mfd/tps65217.c +1 −1
  54. drivers/rtc/Kconfig +12 −1
  55. drivers/rtc/Makefile +1 −0
  56. drivers/rtc/class.c +20 −4
  57. drivers/rtc/rtc-as3722.c +3 −16
  58. drivers/rtc/rtc-cmos.c +3 −5
  59. drivers/rtc/rtc-ds1305.c +0 −1
  60. drivers/rtc/rtc-ds1742.c +9 −1
  61. drivers/rtc/rtc-hym8563.c +606 −0
  62. drivers/rtc/rtc-max8907.c +5 −6
  63. drivers/rtc/rtc-mxc.c +5 −5
  64. drivers/rtc/rtc-pcf2127.c +1 −4
  65. drivers/rtc/rtc-rx8581.c +68 −13
  66. drivers/rtc/rtc-s5m.c +2 −0
  67. drivers/rtc/rtc-twl.c +13 −25
  68. drivers/rtc/rtc-vr41xx.c +12 −38
  69. drivers/video/aty/aty128fb.c +4 −0
  70. drivers/video/backlight/hp680_bl.c +2 −4
  71. drivers/video/backlight/jornada720_bl.c +3 −12
  72. drivers/video/backlight/jornada720_lcd.c +2 −11
  73. drivers/video/backlight/kb3886_bl.c +1 −1
  74. drivers/video/backlight/l4f00242t03.c +2 −4
  75. drivers/video/backlight/lp855x_bl.c +1 −1
  76. drivers/video/backlight/lp8788_bl.c +3 −3
  77. drivers/video/backlight/omap1_bl.c +2 −12
  78. drivers/video/backlight/ot200_bl.c +3 −6
  79. drivers/video/backlight/tosa_bl.c +3 −4
  80. drivers/video/backlight/tosa_lcd.c +2 −4
  81. drivers/vlynq/vlynq.c +2 −1
  82. drivers/w1/masters/w1-gpio.c +22 −0
  83. drivers/w1/w1_int.c +0 −12
  84. fs/autofs4/autofs_i.h +2 −2
  85. fs/autofs4/dev-ioctl.c +14 −2
  86. fs/autofs4/expire.c +14 −0
  87. fs/autofs4/inode.c +35 −14
  88. fs/autofs4/root.c +3 −3
  89. fs/autofs4/symlink.c +4 −0
  90. fs/autofs4/waitq.c +14 −2
  91. fs/binfmt_elf.c +0 −3
  92. fs/coredump.c +0 −1
  93. fs/coredump.h +0 −6
  94. fs/exec.c +25 −95
  95. fs/ext3/dir.c +9 −35
  96. fs/ext4/block_validity.c +4 −29
  97. fs/ext4/dir.c +5 −30
  98. fs/hfsplus/inode.c +0 −59
  99. fs/jffs2/nodelist.c +2 −26
  100. fs/jffs2/readinode.c +3 −23
  101. fs/logfs/segment.c +2 −1
  102. fs/nilfs2/ioctl.c +370 −1
  103. fs/pipe.c +2 −1
  104. fs/posix_acl.c +0 −10
  105. fs/proc/array.c +4 −14
  106. fs/proc/base.c +36 −33
  107. fs/proc/cmdline.c +1 −1
  108. fs/proc/consoles.c +1 −1
  109. fs/proc/cpuinfo.c +1 −1
  110. fs/proc/devices.c +1 −1
  111. fs/proc/generic.c +1 −2
  112. fs/proc/interrupts.c +1 −1
  113. fs/proc/kcore.c +1 −1
  114. fs/proc/kmsg.c +1 −1
  115. fs/proc/loadavg.c +1 −1
  116. fs/proc/meminfo.c +1 −1
  117. fs/proc/nommu.c +1 −1
  118. fs/proc/page.c +6 −4
  119. fs/proc/proc_devtree.c +3 −2
  120. fs/proc/softirqs.c +1 −1
  121. fs/proc/stat.c +1 −1
  122. fs/proc/uptime.c +1 −1
  123. fs/proc/version.c +1 −1
  124. fs/proc/vmcore.c +1 −1
  125. fs/proc_namespace.c +1 −6
  126. fs/ramfs/file-mmu.c +0 −7
  127. fs/ramfs/file-nommu.c +8 −9
  128. fs/ramfs/inode.c +7 −0
  129. fs/ramfs/internal.h +0 −1
  130. fs/reiserfs/reiserfs.h +0 −2
  131. fs/romfs/super.c +2 −4
  132. fs/ubifs/debug.c +3 −19
  133. fs/ubifs/log.c +2 −19
  134. fs/ubifs/orphan.c +2 −19
  135. fs/ubifs/recovery.c +3 −18
  136. fs/ubifs/super.c +4 −20
  137. fs/ubifs/tnc.c +3 −19
  138. include/asm-generic/fixmap.h +97 −0
  139. include/asm-generic/int-l64.h +0 −49
  140. include/linux/cache.h +2 −2
  141. include/linux/ceph/decode.h +0 −17
  142. include/linux/genalloc.h +2 −0
  143. include/linux/gfp.h +1 −0
  144. include/linux/hugetlb.h +2 −1
  145. include/linux/hugetlb_cgroup.h +3 −2
  146. include/linux/kernel.h +13 −0
  147. include/linux/kexec.h +1 −0
  148. include/linux/memblock.h +1 −0
  149. include/linux/memcontrol.h +13 −10
  150. include/linux/mm.h +13 −14
  151. include/linux/mmdebug.h +9 −0
  152. include/linux/of.h +6 −1
  153. include/linux/page-flags.h +5 −5
  154. include/linux/pagemap.h +5 −5
  155. include/linux/parser.h +1 −0
  156. include/linux/percpu.h +1 −0
  157. include/linux/printk.h +10 −9
  158. include/linux/ramfs.h +0 −7
  159. include/linux/sched.h +19 −11
  160. include/linux/sched/sysctl.h +4 −0
  161. include/linux/slab.h +7 −2
  162. include/linux/w1-gpio.h +1 −0
  163. include/uapi/asm-generic/types.h +1 −2
  164. include/uapi/linux/dn.h +1 −0
  165. include/uapi/linux/nfs4.h +1 −1
  166. include/uapi/linux/perf_event.h +1 −1
  167. include/uapi/linux/ppp-ioctl.h +1 −0
  168. init/initramfs.c +1 −1
  169. init/main.c +4 −7
  170. kernel/fork.c +3 −7
  171. kernel/kexec.c +2 −1
  172. kernel/ksysfs.c +1 −1
  173. kernel/printk/printk.c +6 −3
  174. kernel/sched/core.c +23 −1
  175. kernel/signal.c +3 −4
  176. kernel/sys.c +3 −5
  177. kernel/sysctl.c +22 −0
  178. lib/Kconfig.debug +27 −0
  179. lib/Makefile +2 −0
  180. lib/cmdline.c +6 −8
  181. lib/decompress_unlz4.c +1 −0
  182. lib/dynamic_debug.c +10 −5
  183. lib/kstrtox.c +0 −1
  184. lib/parser.c +56 −6
  185. lib/rbtree_test.c +12 −1
  186. lib/test_module.c +33 −0
  187. lib/test_user_copy.c +110 −0
  188. lib/vsprintf.c +27 −6
  189. mm/balloon_compaction.c +2 −2
  190. mm/cleancache.c +3 −3
  191. mm/compaction.c +5 −2
  192. mm/filemap.c +8 −8
  193. mm/huge_memory.c +26 −20
  194. mm/hugetlb.c +5 −5
  195. mm/hugetlb_cgroup.c +1 −1
  196. mm/internal.h +11 −8
  197. mm/ksm.c +7 −7
  198. mm/memblock.c +16 −13
  199. mm/memcontrol.c +254 −270
  200. mm/memory-failure.c +11 −10
  201. mm/memory.c +5 −5
  202. mm/memory_hotplug.c +5 −4
  203. mm/mempolicy.c +3 −5
  204. mm/migrate.c +3 −5
  205. mm/mincore.c +0 −7
  206. mm/mlock.c +62 −46
  207. mm/mm_init.c +1 −2
  208. mm/mmap.c +13 −5
  209. mm/mmu_notifier.c +1 −2
  210. mm/nobootmem.c +19 −6
  211. mm/oom_kill.c +8 −4
  212. mm/page_alloc.c +72 −30
  213. mm/page_io.c +2 −2
  214. mm/rmap.c +7 −7
  215. mm/shmem.c +4 −4
  216. mm/slab.h +25 −1
  217. mm/slab_common.c +54 −36
  218. mm/slub.c +6 −6
  219. mm/swap.c +18 −18
  220. mm/swap_state.c +8 −8
  221. mm/swapfile.c +6 −5
  222. mm/vmscan.c +41 −23
  223. mm/zswap.c +2 −2
  224. net/ipv4/tcp_illinois.c +0 −1
  225. net/netfilter/ipset/ip_set_hash_netiface.c +4 −23
  226. scripts/checkpatch.pl +163 −17
  227. scripts/get_maintainer.pl +85 −6
  228. scripts/headers_check.pl +5 −1
  229. scripts/sortextable.c +5 −0
  230. tools/testing/selftests/Makefile +1 −0
  231. tools/testing/selftests/user/Makefile +13 −0
Documentation/ABI/testing/sysfs-kernel-vmcoreinfo+14−0
@@ -0,0 +1,14 @@
1+What: /sys/kernel/vmcoreinfo
2+Date: October 2007
3+KernelVersion: 2.6.24
4+Contact: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
5+ Kexec Mailing List <kexec@lists.infradead.org>
6+ Vivek Goyal <vgoyal@redhat.com>
7+Description
8+ Shows physical address and size of vmcoreinfo ELF note.
9+ First value contains physical address of note in hex and
10+ second value contains the size of note in hex. This ELF
11+ note info is parsed by second kernel and exported to user
12+ space as part of ELF note in /proc/vmcore file. This note
13+ contains various information like struct size, symbol
14+ values, page size etc.
Documentation/blockdev/ramdisk.txt+15−6
@@ -36,21 +36,30 @@ allowing one to squeeze more programs onto an average installation or · 35 unmodified lines
3636 rescue floppy disk.
3737
3838
39−2) Kernel Command Line Parameters
39+2) Parameters
4040 ---------------------------------
4141
42+2a) Kernel Command Line Parameters
43+
4244 ramdisk_size=N
4345 ==============
4446
4547 This parameter tells the RAM disk driver to set up RAM disks of N k size. The
46−default is 4096 (4 MB) (8192 (8 MB) on S390).
48+default is 4096 (4 MB).
49+
50+2b) Module parameters
4751
48− ramdisk_blocksize=N
49− ===================
52+ rd_nr
53+ =====
54+ /dev/ramX devices created.
5055
51−This parameter tells the RAM disk driver how many bytes to use per block. The
52−default is 1024 (BLOCK_SIZE).
56+ max_part
57+ ========
58+ Maximum partition number.
5359
60+ rd_size
61+ =======
62+ See ramdisk_size.
5463
5564 3) Using "rdev -r"
5665 ------------------
Documentation/cpu-hotplug.txt+1−1
@@ -285,7 +285,7 @@ A: This is what you would need in your kernel code to receive notifications. · 284 unmodified lines
285285 return NOTIFY_OK;
286286 }
287287
288− static struct notifier_block foobar_cpu_notifer =
288+ static struct notifier_block foobar_cpu_notifier =
289289 {
290290 .notifier_call = foobar_cpu_callback,
291291 };
Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt+27−0
@@ -0,0 +1,27 @@
1+Haoyu Microelectronics HYM8563 Real Time Clock
2+
3+The HYM8563 provides basic rtc and alarm functionality
4+as well as a clock output of up to 32kHz.
5+
6+Required properties:
7+- compatible: should be: "haoyu,hym8563"
8+- reg: i2c address
9+- interrupts: rtc alarm/event interrupt
10+- #clock-cells: the value should be 0
11+
12+Example:
13+
14+hym8563: hym8563@51 {
15+ compatible = "haoyu,hym8563";
16+ reg = <0x51>;
17+
18+ interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
19+
20+ #clock-cells = <0>;
21+};
22+
23+device {
24+...
25+ clocks = <&hym8563>;
26+...
27+};
Documentation/devicetree/bindings/rtc/maxim,ds1742.txt+12−0
@@ -0,0 +1,12 @@
1+* Maxim (Dallas) DS1742/DS1743 Real Time Clock
2+
3+Required properties:
4+- compatible: Should contain "maxim,ds1742".
5+- reg: Physical base address of the RTC and length of memory
6+ mapped region.
7+
8+Example:
9+ rtc: rtc@10000000 {
10+ compatible = "maxim,ds1742";
11+ reg = <0x10000000 0x800>;
12+ };
Documentation/devicetree/bindings/vendor-prefixes.txt+1−0
@@ -34,6 +34,7 @@ fsl Freescale Semiconductor · 33 unmodified lines
3434 GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc.
3535 gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
3636 gmt Global Mixed-mode Technology, Inc.
37+haoyu Haoyu Microelectronic Co. Ltd.
3738 hisilicon Hisilicon Limited.
3839 hp Hewlett Packard
3940 ibm International Business Machines (IBM)
Documentation/dynamic-debug-howto.txt+9−0
@@ -108,6 +108,12 @@ If your query set is big, you can batch them too: · 107 unmodified lines
108108
109109 ~# cat query-batch-file > <debugfs>/dynamic_debug/control
110110
111+A another way is to use wildcard. The match rule support '*' (matches
112+zero or more characters) and '?' (matches exactly one character).For
113+example, you can match all usb drivers:
114+
115+ ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control
116+
111117 At the syntactical level, a command comprises a sequence of match
112118 specifications, followed by a flags change specification.
113119
@@ -315,6 +321,9 @@ nullarbor:~ # echo -n 'func svc_process -p' > · 201 unmodified lines
315321 nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
316322 <debugfs>/dynamic_debug/control
317323
324+// enable messages in files of which the pathes include string "usb"
325+nullarbor:~ # echo -n '*usb* +p' > <debugfs>/dynamic_debug/control
326+
318327 // enable all messages
319328 nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
320329
Documentation/filesystems/00-INDEX+45−13
@@ -10,24 +10,32 @@ afs.txt · 9 unmodified lines
1010 - info and examples for the distributed AFS (Andrew File System) fs.
1111 affs.txt
1212 - info and mount options for the Amiga Fast File System.
13+autofs4-mount-control.txt
14+ - info on device control operations for autofs4 module.
1315 automount-support.txt
1416 - information about filesystem automount support.
1517 befs.txt
1618 - information about the BeOS filesystem for Linux.
1719 bfs.txt
1820 - info for the SCO UnixWare Boot Filesystem (BFS).
21+btrfs.txt
22+ - info for the BTRFS filesystem.
23+caching/
24+ - directory containing filesystem cache documentation.
1925 ceph.txt
20− - info for the Ceph Distributed File System
21−cifs.txt
22− - description of the CIFS filesystem.
26+ - info for the Ceph Distributed File System.
27+cifs/
28+ - directory containing CIFS filesystem documentation and example code.
2329 coda.txt
2430 - description of the CODA filesystem.
2531 configfs/
2632 - directory containing configfs documentation and example code.
2733 cramfs.txt
2834 - info on the cram filesystem for small storage (ROMs etc).
29−dentry-locking.txt
30− - info on the RCU-based dcache locking model.
35+debugfs.txt
36+ - info on the debugfs filesystem.
37+devpts.txt
38+ - info on the devpts filesystem.
3139 directory-locking
3240 - info about the locking scheme used for directory operations.
3341 dlmfs.txt
@@ -35,7 +43,7 @@ dlmfs.txt · 1 unmodified line
3543 dnotify.txt
3644 - info about directory notification in Linux.
3745 dnotify_test.c
38− - example program for dnotify
46+ - example program for dnotify.
3947 ecryptfs.txt
4048 - docs on eCryptfs: stacked cryptographic filesystem for Linux.
4149 efivarfs.txt
@@ -48,12 +56,18 @@ ext3.txt · 6 unmodified lines
4856 - info, mount options and specifications for the Ext3 filesystem.
4957 ext4.txt
5058 - info, mount options and specifications for the Ext4 filesystem.
51−files.txt
52− - info on file management in the Linux kernel.
5359 f2fs.txt
5460 - info and mount options for the F2FS filesystem.
61+fiemap.txt
62+ - info on fiemap ioctl.
63+files.txt
64+ - info on file management in the Linux kernel.
5565 fuse.txt
5666 - info on the Filesystem in User SpacE including mount options.
67+gfs2-glocks.txt
68+ - info on the Global File System 2 - Glock internal locking rules.
69+gfs2-uevents.txt
70+ - info on the Global File System 2 - uevents.
5771 gfs2.txt
5872 - info on the Global File System 2.
5973 hfs.txt
@@ -84,40 +98,58 @@ ntfs.txt · 24 unmodified lines
8498 - info and mount options for the NTFS filesystem (Windows NT).
8599 ocfs2.txt
86100 - info and mount options for the OCFS2 clustered filesystem.
101+omfs.txt
102+ - info on the Optimized MPEG FileSystem.
103+path-lookup.txt
104+ - info on path walking and name lookup locking.
105+pohmelfs/
106+ - directory containing pohmelfs filesystem documentation.
87107 porting
88108 - various information on filesystem porting.
89109 proc.txt
90110 - info on Linux's /proc filesystem.
111+qnx6.txt
112+ - info on the QNX6 filesystem.
113+quota.txt
114+ - info on Quota subsystem.
91115 ramfs-rootfs-initramfs.txt
92116 - info on the 'in memory' filesystems ramfs, rootfs and initramfs.
93−reiser4.txt
94− - info on the Reiser4 filesystem based on dancing tree algorithms.
95117 relay.txt
96118 - info on relay, for efficient streaming from kernel to user space.
97119 romfs.txt
98120 - description of the ROMFS filesystem.
99121 seq_file.txt
100− - how to use the seq_file API
122+ - how to use the seq_file API.
101123 sharedsubtree.txt
102124 - a description of shared subtrees for namespaces.
103125 spufs.txt
104126 - info and mount options for the SPU filesystem used on Cell.
127+squashfs.txt
128+ - info on the squashfs filesystem.
105129 sysfs-pci.txt
106130 - info on accessing PCI device resources through sysfs.
131+sysfs-tagging.txt
132+ - info on sysfs tagging to avoid duplicates.
107133 sysfs.txt
108134 - info on sysfs, a ram-based filesystem for exporting kernel objects.
109135 sysv-fs.txt
110136 - info on the SystemV/V7/Xenix/Coherent filesystem.
111137 tmpfs.txt
112138 - info on tmpfs, a filesystem that holds all files in virtual memory.
139+ubifs.txt
140+ - info on the Unsorted Block Images FileSystem.
113141 udf.txt
114142 - info and mount options for the UDF filesystem.
115143 ufs.txt
116144 - info on the ufs filesystem.
117145 vfat.txt
118− - info on using the VFAT filesystem used in Windows NT and Windows 95
146+ - info on using the VFAT filesystem used in Windows NT and Windows 95.
119147 vfs.txt
120− - overview of the Virtual File System
148+ - overview of the Virtual File System.
149+xfs-delayed-logging-design.txt
150+ - info on the XFS Delayed Logging Design.
151+xfs-self-describing-metadata.txt
152+ - info on XFS Self Describing Metadata.
121153 xfs.txt
122154 - info and mount options for the XFS filesystem.
123155 xip.txt
Documentation/filesystems/nilfs2.txt+56−0
@@ -81,6 +81,62 @@ nodiscard(*) The discard/TRIM commands are sent to the underlying · 80 unmodified lines
8181 block device when blocks are freed. This is useful
8282 for SSD devices and sparse/thinly-provisioned LUNs.
8383
84+Ioctls
85+======
86+
87+There is some NILFS2 specific functionality which can be accessed by applications
88+through the system call interfaces. The list of all NILFS2 specific ioctls are
89+shown in the table below.
90+
91+Table of NILFS2 specific ioctls
92+..............................................................................
93+ Ioctl Description
94+ NILFS_IOCTL_CHANGE_CPMODE Change mode of given checkpoint between
95+ checkpoint and snapshot state. This ioctl is
96+ used in chcp and mkcp utilities.
97+
98+ NILFS_IOCTL_DELETE_CHECKPOINT Remove checkpoint from NILFS2 file system.
99+ This ioctl is used in rmcp utility.
100+
101+ NILFS_IOCTL_GET_CPINFO Return info about requested checkpoints. This
102+ ioctl is used in lscp utility and by
103+ nilfs_cleanerd daemon.
104+
105+ NILFS_IOCTL_GET_CPSTAT Return checkpoints statistics. This ioctl is
106+ used by lscp, rmcp utilities and by
107+ nilfs_cleanerd daemon.
108+
109+ NILFS_IOCTL_GET_SUINFO Return segment usage info about requested
110+ segments. This ioctl is used in lssu,
111+ nilfs_resize utilities and by nilfs_cleanerd
112+ daemon.
113+
114+ NILFS_IOCTL_GET_SUSTAT Return segment usage statistics. This ioctl
115+ is used in lssu, nilfs_resize utilities and
116+ by nilfs_cleanerd daemon.
117+
118+ NILFS_IOCTL_GET_VINFO Return information on virtual block addresses.
119+ This ioctl is used by nilfs_cleanerd daemon.
120+
121+ NILFS_IOCTL_GET_BDESCS Return information about descriptors of disk
122+ block numbers. This ioctl is used by
123+ nilfs_cleanerd daemon.
124+
125+ NILFS_IOCTL_CLEAN_SEGMENTS Do garbage collection operation in the
126+ environment of requested parameters from
127+ userspace. This ioctl is used by
128+ nilfs_cleanerd daemon.
129+
130+ NILFS_IOCTL_SYNC Make a checkpoint. This ioctl is used in
131+ mkcp utility.
132+
133+ NILFS_IOCTL_RESIZE Resize NILFS2 volume. This ioctl is used
134+ by nilfs_resize utility.
135+
136+ NILFS_IOCTL_SET_ALLOC_RANGE Define lower limit of segments in bytes and
137+ upper limit of segments in bytes. This ioctl
138+ is used by nilfs_resize utility.
139+
84140 NILFS2 usage
85141 ============
86142
Documentation/filesystems/sysfs.txt+3−3
@@ -108,12 +108,12 @@ static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo); · 107 unmodified lines
108108 is equivalent to doing:
109109
110110 static struct device_attribute dev_attr_foo = {
111− .attr = {
111+ .attr = {
112112 .name = "foo",
113113 .mode = S_IWUSR | S_IRUGO,
114− .show = show_foo,
115− .store = store_foo,
116114 },
115+ .show = show_foo,
116+ .store = store_foo,
117117 };
118118
119119
Documentation/kernel-parameters.txt+10−1
@@ -1059,7 +1059,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. · 1058 unmodified lines
10591059 debugfs files are removed at module unload time.
10601060
10611061 gpt [EFI] Forces disk with valid GPT signature but
1062− invalid Protective MBR to be treated as GPT.
1062+ invalid Protective MBR to be treated as GPT. If the
1063+ primary GPT is corrupted, it enables the backup/alternate
1064+ GPT to be used instead.
10631065
10641066 grcan.enable0= [HW] Configuration of physical interface 0. Determines
10651067 the "Enable 0" bit of the configuration register.
@@ -1461,6 +1463,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted. · 395 unmodified lines
14611463 Valid arguments: on, off
14621464 Default: on
14631465
1466+ kmemcheck= [X86] Boot-time kmemcheck enable/disable/one-shot mode
1467+ Valid arguments: 0, 1, 2
1468+ kmemcheck=0 (disabled)
1469+ kmemcheck=1 (enabled)
1470+ kmemcheck=2 (one-shot mode)
1471+ Default: 2 (one-shot mode)
1472+
14641473 kstack=N [X86] Print N words from the kernel stack
14651474 in oops dumps.
14661475
Documentation/printk-formats.txt+9−2
@@ -55,14 +55,21 @@ Struct Resources: · 54 unmodified lines
5555 For printing struct resources. The 'R' and 'r' specifiers result in a
5656 printed resource with ('R') or without ('r') a decoded flags member.
5757
58−Physical addresses:
58+Physical addresses types phys_addr_t:
5959
60− %pa 0x01234567 or 0x0123456789abcdef
60+ %pa[p] 0x01234567 or 0x0123456789abcdef
6161
6262 For printing a phys_addr_t type (and its derivatives, such as
6363 resource_size_t) which can vary based on build options, regardless of
6464 the width of the CPU data path. Passed by reference.
6565
66+DMA addresses types dma_addr_t:
67+
68+ %pad 0x01234567 or 0x0123456789abcdef
69+
70+ For printing a dma_addr_t type which can vary based on build options,
71+ regardless of the width of the CPU data path. Passed by reference.
72+
6673 Raw buffer as a hex string:
6774 %*ph 00 01 02 ... 3f
6875 %*phC 00:01:02: ... :3f
Documentation/sysctl/kernel.txt+14−1
@@ -33,6 +33,7 @@ show up in /proc/sys/kernel: · 32 unmodified lines
3333 - domainname
3434 - hostname
3535 - hotplug
36+- kexec_load_disabled
3637 - kptr_restrict
3738 - kstack_depth_to_print [ X86 only ]
3839 - l2cr [ PPC only ]
@@ -287,6 +288,18 @@ Default value is "/sbin/hotplug". · 248 unmodified lines
287288
288289 ==============================================================
289290
291+kexec_load_disabled:
292+
293+A toggle indicating if the kexec_load syscall has been disabled. This
294+value defaults to 0 (false: kexec_load enabled), but can be set to 1
295+(true: kexec_load disabled). Once true, kexec can no longer be used, and
296+the toggle cannot be set back to false. This allows a kexec image to be
297+loaded before disabling the syscall, allowing a system to set up (and
298+later use) an image without it being altered. Generally used together
299+with the "modules_disabled" sysctl.
300+
301+==============================================================
302+
290303 kptr_restrict:
291304
292305 This toggle indicates whether restrictions are placed on
@@ -331,7 +344,7 @@ A toggle value indicating if modules are allowed to be loaded · 38 unmodified lines
331344 in an otherwise modular kernel. This toggle defaults to off
332345 (0), but can be set true (1). Once true, modules can be
333346 neither loaded nor unloaded, and the toggle cannot be set back
334−to false.
347+to false. Generally used with the "kexec_load_disabled" toggle.
335348
336349 ==============================================================
337350
Documentation/trace/postprocess/trace-vmscan-postprocess.pl+9−9
@@ -123,7 +123,7 @@ my $regex_writepage; · 122 unmodified lines
123123
124124 # Static regex used. Specified like this for readability and for use with /o
125125 # (process_pid) (cpus ) ( time ) (tpoint ) (details)
126−my $regex_traceevent = '\s*([a-zA-Z0-9-]*)\s*(\[[0-9]*\])\s*([0-9.]*):\s*([a-zA-Z_]*):\s*(.*)';
126+my $regex_traceevent = '\s*([a-zA-Z0-9-]*)\s*(\[[0-9]*\])(\s*[dX.][Nnp.][Hhs.][0-9a-fA-F.]*|)\s*([0-9.]*):\s*([a-zA-Z_]*):\s*(.*)';
127127 my $regex_statname = '[-0-9]*\s\((.*)\).*';
128128 my $regex_statppid = '[-0-9]*\s\(.*\)\s[A-Za-z]\s([0-9]*).*';
129129
@@ -270,8 +270,8 @@ EVENT_PROCESS: · 140 unmodified lines
270270 while ($traceevent = <STDIN>) {
271271 if ($traceevent =~ /$regex_traceevent/o) {
272272 $process_pid = $1;
273− $timestamp = $3;
274− $tracepoint = $4;
273+ $timestamp = $4;
274+ $tracepoint = $5;
275275
276276 $process_pid =~ /(.*)-([0-9]*)$/;
277277 my $process = $1;
@@ -299,7 +299,7 @@ EVENT_PROCESS: · 21 unmodified lines
299299 $perprocesspid{$process_pid}->{MM_VMSCAN_DIRECT_RECLAIM_BEGIN}++;
300300 $perprocesspid{$process_pid}->{STATE_DIRECT_BEGIN} = $timestamp;
301301
302− $details = $5;
302+ $details = $6;
303303 if ($details !~ /$regex_direct_begin/o) {
304304 print "WARNING: Failed to parse mm_vmscan_direct_reclaim_begin as expected\n";
305305 print " $details\n";
@@ -322,7 +322,7 @@ EVENT_PROCESS: · 16 unmodified lines
322322 $perprocesspid{$process_pid}->{HIGH_DIRECT_RECLAIM_LATENCY}[$index] = "$order-$latency";
323323 }
324324 } elsif ($tracepoint eq "mm_vmscan_kswapd_wake") {
325− $details = $5;
325+ $details = $6;
326326 if ($details !~ /$regex_kswapd_wake/o) {
327327 print "WARNING: Failed to parse mm_vmscan_kswapd_wake as expected\n";
328328 print " $details\n";
@@ -356,7 +356,7 @@ EVENT_PROCESS: · 27 unmodified lines
356356 } elsif ($tracepoint eq "mm_vmscan_wakeup_kswapd") {
357357 $perprocesspid{$process_pid}->{MM_VMSCAN_WAKEUP_KSWAPD}++;
358358
359− $details = $5;
359+ $details = $6;
360360 if ($details !~ /$regex_wakeup_kswapd/o) {
361361 print "WARNING: Failed to parse mm_vmscan_wakeup_kswapd as expected\n";
362362 print " $details\n";
@@ -366,7 +366,7 @@ EVENT_PROCESS: · 3 unmodified lines
366366 my $order = $3;
367367 $perprocesspid{$process_pid}->{MM_VMSCAN_WAKEUP_KSWAPD_PERORDER}[$order]++;
368368 } elsif ($tracepoint eq "mm_vmscan_lru_isolate") {
369− $details = $5;
369+ $details = $6;
370370 if ($details !~ /$regex_lru_isolate/o) {
371371 print "WARNING: Failed to parse mm_vmscan_lru_isolate as expected\n";
372372 print " $details\n";
@@ -387,7 +387,7 @@ EVENT_PROCESS: · 14 unmodified lines
387387 }
388388 $perprocesspid{$process_pid}->{HIGH_NR_CONTIG_DIRTY} += $nr_contig_dirty;
389389 } elsif ($tracepoint eq "mm_vmscan_lru_shrink_inactive") {
390− $details = $5;
390+ $details = $6;
391391 if ($details !~ /$regex_lru_shrink_inactive/o) {
392392 print "WARNING: Failed to parse mm_vmscan_lru_shrink_inactive as expected\n";
393393 print " $details\n";
@@ -397,7 +397,7 @@ EVENT_PROCESS: · 3 unmodified lines
397397 my $nr_reclaimed = $4;
398398 $perprocesspid{$process_pid}->{HIGH_NR_RECLAIMED} += $nr_reclaimed;
399399 } elsif ($tracepoint eq "mm_vmscan_writepage") {
400− $details = $5;
400+ $details = $6;
401401 if ($details !~ /$regex_writepage/o) {
402402 print "WARNING: Failed to parse mm_vmscan_writepage as expected\n";
403403 print " $details\n";
Documentation/vm/locking+0−130
@@ -1,130 +0,0 @@
1−Started Oct 1999 by Kanoj Sarcar <kanojsarcar@yahoo.com>
2−
3−The intent of this file is to have an uptodate, running commentary
4−from different people about how locking and synchronization is done
5−in the Linux vm code.
6−
7−page_table_lock & mmap_sem
8−--------------------------------------
9−
10−Page stealers pick processes out of the process pool and scan for
11−the best process to steal pages from. To guarantee the existence
12−of the victim mm, a mm_count inc and a mmdrop are done in swap_out().
13−Page stealers hold kernel_lock to protect against a bunch of races.
14−The vma list of the victim mm is also scanned by the stealer,
15−and the page_table_lock is used to preserve list sanity against the
16−process adding/deleting to the list. This also guarantees existence
17−of the vma. Vma existence is not guaranteed once try_to_swap_out()
18−drops the page_table_lock. To guarantee the existence of the underlying
19−file structure, a get_file is done before the swapout() method is
20−invoked. The page passed into swapout() is guaranteed not to be reused
21−for a different purpose because the page reference count due to being
22−present in the user's pte is not released till after swapout() returns.
23−
24−Any code that modifies the vmlist, or the vm_start/vm_end/
25−vm_flags:VM_LOCKED/vm_next of any vma *in the list* must prevent
26−kswapd from looking at the chain.
27−
28−The rules are:
29−1. To scan the vmlist (look but don't touch) you must hold the
30− mmap_sem with read bias, i.e. down_read(&mm->mmap_sem)
31−2. To modify the vmlist you need to hold the mmap_sem with
32− read&write bias, i.e. down_write(&mm->mmap_sem) *AND*
33− you need to take the page_table_lock.
34−3. The swapper takes _just_ the page_table_lock, this is done
35− because the mmap_sem can be an extremely long lived lock
36− and the swapper just cannot sleep on that.
37−4. The exception to this rule is expand_stack, which just
38− takes the read lock and the page_table_lock, this is ok
39− because it doesn't really modify fields anybody relies on.
40−5. You must be able to guarantee that while holding page_table_lock
41− or page_table_lock of mm A, you will not try to get either lock
42− for mm B.
43−
44−The caveats are:
45−1. find_vma() makes use of, and updates, the mmap_cache pointer hint.
46−The update of mmap_cache is racy (page stealer can race with other code
47−that invokes find_vma with mmap_sem held), but that is okay, since it
48−is a hint. This can be fixed, if desired, by having find_vma grab the
49−page_table_lock.
50−
51−
52−Code that add/delete elements from the vmlist chain are
53−1. callers of insert_vm_struct
54−2. callers of merge_segments
55−3. callers of avl_remove
56−
57−Code that changes vm_start/vm_end/vm_flags:VM_LOCKED of vma's on
58−the list:
59−1. expand_stack
60−2. mprotect
61−3. mlock
62−4. mremap
63−
64−It is advisable that changes to vm_start/vm_end be protected, although
65−in some cases it is not really needed. Eg, vm_start is modified by
66−expand_stack(), it is hard to come up with a destructive scenario without
67−having the vmlist protection in this case.
68−
69−The page_table_lock nests with the inode i_mmap_mutex and the kmem cache
70−c_spinlock spinlocks. This is okay, since the kmem code asks for pages after
71−dropping c_spinlock. The page_table_lock also nests with pagecache_lock and
72−pagemap_lru_lock spinlocks, and no code asks for memory with these locks
73−held.
74−
75−The page_table_lock is grabbed while holding the kernel_lock spinning monitor.
76−
77−The page_table_lock is a spin lock.
78−
79−Note: PTL can also be used to guarantee that no new clones using the
80−mm start up ... this is a loose form of stability on mm_users. For
81−example, it is used in copy_mm to protect against a racing tlb_gather_mmu
82−single address space optimization, so that the zap_page_range (from
83−truncate) does not lose sending ipi's to cloned threads that might
84−be spawned underneath it and go to user mode to drag in pte's into tlbs.
85−
86−swap_lock
87−--------------
88−The swap devices are chained in priority order from the "swap_list" header.
89−The "swap_list" is used for the round-robin swaphandle allocation strategy.
90−The #free swaphandles is maintained in "nr_swap_pages". These two together
91−are protected by the swap_lock.
92−
93−The swap_lock also protects all the device reference counts on the
94−corresponding swaphandles, maintained in the "swap_map" array, and the
95−"highest_bit" and "lowest_bit" fields.
96−
97−The swap_lock is a spinlock, and is never acquired from intr level.
98−
99−To prevent races between swap space deletion or async readahead swapins
100−deciding whether a swap handle is being used, ie worthy of being read in
101−from disk, and an unmap -> swap_free making the handle unused, the swap
102−delete and readahead code grabs a temp reference on the swaphandle to
103−prevent warning messages from swap_duplicate <- read_swap_cache_async.
104−
105−Swap cache locking
106−------------------
107−Pages are added into the swap cache with kernel_lock held, to make sure
108−that multiple pages are not being added (and hence lost) by associating
109−all of them with the same swaphandle.
110−
111−Pages are guaranteed not to be removed from the scache if the page is
112−"shared": ie, other processes hold reference on the page or the associated
113−swap handle. The only code that does not follow this rule is shrink_mmap,
114−which deletes pages from the swap cache if no process has a reference on
115−the page (multiple processes might have references on the corresponding
116−swap handle though). lookup_swap_cache() races with shrink_mmap, when
117−establishing a reference on a scache page, so, it must check whether the
118−page it located is still in the swapcache, or shrink_mmap deleted it.
119−(This race is due to the fact that shrink_mmap looks at the page ref
120−count with pagecache_lock, but then drops pagecache_lock before deleting
121−the page from the scache).
122−
123−do_wp_page and do_swap_page have MP races in them while trying to figure
124−out whether a page is "shared", by looking at the page_count + swap_count.
125−To preserve the sum of the counts, the page lock _must_ be acquired before
126−calling is_page_shared (else processes might switch their swap_count refs
127−to the page count refs, after the page count ref has been snapshotted).
128−
129−Swap device deletion code currently breaks all the scache assumptions,
130−since it grabs neither mmap_sem nor page_table_lock.
MAINTAINERS+11−1
@@ -93,6 +93,11 @@ Descriptions of section entries: · 92 unmodified lines
9393 N: Files and directories with regex patterns.
9494 N: [^a-z]tegra all files whose path contains the word tegra
9595 One pattern per line. Multiple N: lines acceptable.
96+ scripts/get_maintainer.pl has different behavior for files that
97+ match F: pattern and matches of N: patterns. By default,
98+ get_maintainer will not look at git log history when an F: pattern
99+ match occurs. When an N: match occurs, git log history is used
100+ to also notify the people that have git commit signatures.
96101 X: Files and directories that are NOT maintained, same rules as F:
97102 Files exclusions are tested before file matches.
98103 Can be useful for excluding a specific subdirectory, for instance:
@@ -3375,7 +3380,6 @@ M: Jingoo Han <jg1.han@samsung.com> · 3276 unmodified lines
33753380 L: linux-fbdev@vger.kernel.org
33763381 S: Maintained
33773382 F: drivers/video/exynos/exynos_dp*
3378−F: include/video/exynos_dp*
33793383
33803384 EXYNOS MIPI DISPLAY DRIVERS
33813385 M: Inki Dae <inki.dae@samsung.com>
@@ -3986,6 +3990,12 @@ S: Orphan · 604 unmodified lines
39863990 F: Documentation/filesystems/hfs.txt
39873991 F: fs/hfs/
39883992
3993+HFSPLUS FILESYSTEM
3994+L: linux-fsdevel@vger.kernel.org
3995+S: Orphan
3996+F: Documentation/filesystems/hfsplus.txt
3997+F: fs/hfsplus/
3998+
39893999 HGA FRAMEBUFFER DRIVER
39904000 M: Ferenc Bakonyi <fero@drama.obuda.kando.hu>
39914001 L: linux-nvidia@lists.surfsouth.com
arch/alpha/Kconfig+4−4
@@ -539,13 +539,13 @@ config SMP · 538 unmodified lines
539539 depends on ALPHA_SABLE || ALPHA_LYNX || ALPHA_RAWHIDE || ALPHA_DP264 || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_GENERIC || ALPHA_SHARK || ALPHA_MARVEL
540540 ---help---
541541 This enables support for systems with more than one CPU. If you have
542− a system with only one CPU, like most personal computers, say N. If
543− you have a system with more than one CPU, say Y.
542+ a system with only one CPU, say N. If you have a system with more
543+ than one CPU, say Y.
544544
545− If you say N here, the kernel will run on single and multiprocessor
545+ If you say N here, the kernel will run on uni- and multiprocessor
546546 machines, but will use only one CPU of a multiprocessor machine. If
547547 you say Y here, the kernel will run on many, but not all,
548− singleprocessor machines. On a singleprocessor machine, the kernel
548+ uniprocessor machines. On a uniprocessor machine, the kernel
549549 will run faster if you say N here.
550550
551551 See also the SMP-HOWTO available at
arch/arc/Kconfig+2−2
@@ -128,8 +128,8 @@ config SMP · 127 unmodified lines
128128 default n
129129 help
130130 This enables support for systems with more than one CPU. If you have
131− a system with only one CPU, like most personal computers, say N. If
132− you have a system with more than one CPU, say Y.
131+ a system with only one CPU, say N. If you have a system with more
132+ than one CPU, say Y.
133133
134134 if SMP
135135
arch/arm/Kconfig+6−6
@@ -1470,14 +1470,14 @@ config SMP · 1469 unmodified lines
14701470 depends on MMU || ARM_MPU
14711471 help
14721472 This enables support for systems with more than one CPU. If you have
1473− a system with only one CPU, like most personal computers, say N. If
1474− you have a system with more than one CPU, say Y.
1473+ a system with only one CPU, say N. If you have a system with more
1474+ than one CPU, say Y.
14751475
1476− If you say N here, the kernel will run on single and multiprocessor
1476+ If you say N here, the kernel will run on uni- and multiprocessor
14771477 machines, but will use only one CPU of a multiprocessor machine. If
1478− you say Y here, the kernel will run on many, but not all, single
1479− processor machines. On a single processor machine, the kernel will
1480− run faster if you say N here.
1478+ you say Y here, the kernel will run on many, but not all,
1479+ uniprocessor machines. On a uniprocessor machine, the kernel
1480+ will run faster if you say N here.
14811481
14821482 See also <file:Documentation/x86/i386/IO-APIC.txt>,
14831483 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
arch/cris/include/asm/io.h+4−0
@@ -169,7 +169,11 @@ static inline void outsl(unsigned int port, const void *addr, · 168 unmodified lines
169169 }
170170
171171 #define inb_p(port) inb(port)
172+#define inw_p(port) inw(port)
173+#define inl_p(port) inl(port)
172174 #define outb_p(val, port) outb((val), (port))
175+#define outw_p(val, port) outw((val), (port))
176+#define outl_p(val, port) outl((val), (port))
173177
174178 /*
175179 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
arch/hexagon/include/asm/fixmap.h+1−39
@@ -26,45 +26,7 @@ · 25 unmodified lines
2626 */
2727 #include <asm/mem-layout.h>
2828
29−/*
30− * Full fixmap support involves set_fixmap() functions, but
31− * these may not be needed if all we're after is an area for
32− * highmem kernel mappings.
33− */
34−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
35−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
36−
37−extern void __this_fixmap_does_not_exist(void);
38−
39−/**
40− * fix_to_virt -- "index to address" translation.
41− *
42− * If anyone tries to use the idx directly without translation,
43− * we catch the bug with a NULL-deference kernel oops. Illegal
44− * ranges of incoming indices are caught too.
45− */
46−static inline unsigned long fix_to_virt(const unsigned int idx)
47−{
48− /*
49− * This branch gets completely eliminated after inlining,
50− * except when someone tries to use fixaddr indices in an
51− * illegal way. (such as mixing up address types or using
52− * out-of-range indices).
53− *
54− * If it doesn't get removed, the linker will complain
55− * loudly with a reasonably clear error message..
56− */
57− if (idx >= __end_of_fixed_addresses)
58− __this_fixmap_does_not_exist();
59−
60− return __fix_to_virt(idx);
61−}
62−
63−static inline unsigned long virt_to_fix(const unsigned long vaddr)
64−{
65− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
66− return __virt_to_fix(vaddr);
67−}
29+#include <asm-generic/fixmap.h>
6830
6931 #define kmap_get_fixmap_pte(vaddr) \
7032 pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), \
arch/ia64/Kconfig+1−0
@@ -104,6 +104,7 @@ config HAVE_SETUP_PER_CPU_AREA · 103 unmodified lines
104104 config DMI
105105 bool
106106 default y
107+ select DMI_SCAN_MACHINE_NON_EFI_FALLBACK
107108
108109 config EFI
109110 bool
arch/ia64/include/asm/dmi.h+5−3
@@ -5,8 +5,10 @@ · 4 unmodified lines
55 #include <asm/io.h>
66
77 /* Use normal IO mappings for DMI */
8−#define dmi_ioremap ioremap
9−#define dmi_iounmap(x,l) iounmap(x)
10−#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC)
8+#define dmi_early_remap ioremap
9+#define dmi_early_unmap(x, l) iounmap(x)
10+#define dmi_remap ioremap
11+#define dmi_unmap iounmap
12+#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC)
1113
1214 #endif
arch/ia64/include/asm/processor.h+1−0
@@ -71,6 +71,7 @@ · 70 unmodified lines
7171 #include <linux/compiler.h>
7272 #include <linux/threads.h>
7373 #include <linux/types.h>
74+#include <linux/bitops.h>
7475
7576 #include <asm/fpu.h>
7677 #include <asm/page.h>
arch/m32r/Kconfig+4−4
@@ -277,13 +277,13 @@ config SMP · 276 unmodified lines
277277 bool "Symmetric multi-processing support"
278278 ---help---
279279 This enables support for systems with more than one CPU. If you have
280− a system with only one CPU, like most personal computers, say N. If
281− you have a system with more than one CPU, say Y.
280+ a system with only one CPU, say N. If you have a system with more
281+ than one CPU, say Y.
282282
283− If you say N here, the kernel will run on single and multiprocessor
283+ If you say N here, the kernel will run on uni- and multiprocessor
284284 machines, but will use only one CPU of a multiprocessor machine. If
285285 you say Y here, the kernel will run on many, but not all,
286− singleprocessor machines. On a singleprocessor machine, the kernel
286+ uniprocessor machines. On a uniprocessor machine, the kernel
287287 will run faster if you say N here.
288288
289289 People using multiprocessor machines who say Y here should also say
arch/metag/include/asm/fixmap.h+1−31
@@ -51,37 +51,7 @@ enum fixed_addresses { · 50 unmodified lines
5151 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
5252 #define FIXADDR_START ((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK)
5353
54−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
55−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
56−
57−extern void __this_fixmap_does_not_exist(void);
58−/*
59− * 'index to address' translation. If anyone tries to use the idx
60− * directly without tranlation, we catch the bug with a NULL-deference
61− * kernel oops. Illegal ranges of incoming indices are caught too.
62− */
63−static inline unsigned long fix_to_virt(const unsigned int idx)
64−{
65− /*
66− * this branch gets completely eliminated after inlining,
67− * except when someone tries to use fixaddr indices in an
68− * illegal way. (such as mixing up address types or using
69− * out-of-range indices).
70− *
71− * If it doesn't get removed, the linker will complain
72− * loudly with a reasonably clear error message..
73− */
74− if (idx >= __end_of_fixed_addresses)
75− __this_fixmap_does_not_exist();
76−
77− return __fix_to_virt(idx);
78−}
79−
80−static inline unsigned long virt_to_fix(const unsigned long vaddr)
81−{
82− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
83− return __virt_to_fix(vaddr);
84−}
54+#include <asm-generic/fixmap.h>
8555
8656 #define kmap_get_fixmap_pte(vaddr) \
8757 pte_offset_kernel( \
arch/microblaze/Kconfig+1−0
@@ -30,6 +30,7 @@ config MICROBLAZE · 29 unmodified lines
3030 select MODULES_USE_ELF_RELA
3131 select CLONE_BACKWARDS3
3232 select CLKSRC_OF
33+ select BUILDTIME_EXTABLE_SORT
3334
3435 config SWAP
3536 def_bool n
arch/microblaze/include/asm/fixmap.h+2−42
@@ -58,52 +58,12 @@ enum fixed_addresses { · 57 unmodified lines
5858 extern void __set_fixmap(enum fixed_addresses idx,
5959 phys_addr_t phys, pgprot_t flags);
6060
61−#define set_fixmap(idx, phys) \
62− __set_fixmap(idx, phys, PAGE_KERNEL)
63−/*
64− * Some hardware wants to get fixmapped without caching.
65− */
66−#define set_fixmap_nocache(idx, phys) \
67− __set_fixmap(idx, phys, PAGE_KERNEL_CI)
68−
69−#define clear_fixmap(idx) \
70− __set_fixmap(idx, 0, __pgprot(0))
71−
7261 #define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
7362 #define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
7463
75−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
76−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
77−
78−extern void __this_fixmap_does_not_exist(void);
79−
80−/*
81− * 'index to address' translation. If anyone tries to use the idx
82− * directly without tranlation, we catch the bug with a NULL-deference
83− * kernel oops. Illegal ranges of incoming indices are caught too.
84− */
85−static __always_inline unsigned long fix_to_virt(const unsigned int idx)
86−{
87− /*
88− * this branch gets completely eliminated after inlining,
89− * except when someone tries to use fixaddr indices in an
90− * illegal way. (such as mixing up address types or using
91− * out-of-range indices).
92− *
93− * If it doesn't get removed, the linker will complain
94− * loudly with a reasonably clear error message..
95− */
96− if (idx >= __end_of_fixed_addresses)
97− __this_fixmap_does_not_exist();
98−
99− return __fix_to_virt(idx);
100−}
64+#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_CI
10165
102−static inline unsigned long virt_to_fix(const unsigned long vaddr)
103−{
104− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
105− return __virt_to_fix(vaddr);
106−}
66+#include <asm-generic/fixmap.h>
10767
10868 #endif /* !__ASSEMBLY__ */
10969 #endif
arch/mips/Kconfig+5−5
@@ -2129,13 +2129,13 @@ config SMP · 2128 unmodified lines
21292129 depends on SYS_SUPPORTS_SMP
21302130 help
21312131 This enables support for systems with more than one CPU. If you have
2132− a system with only one CPU, like most personal computers, say N. If
2133− you have a system with more than one CPU, say Y.
2132+ a system with only one CPU, say N. If you have a system with more
2133+ than one CPU, say Y.
21342134
2135− If you say N here, the kernel will run on single and multiprocessor
2135+ If you say N here, the kernel will run on uni- and multiprocessor
21362136 machines, but will use only one CPU of a multiprocessor machine. If
21372137 you say Y here, the kernel will run on many, but not all,
2138− singleprocessor machines. On a singleprocessor machine, the kernel
2138+ uniprocessor machines. On a uniprocessor machine, the kernel
21392139 will run faster if you say N here.
21402140
21412141 People using multiprocessor machines who say Y here should also say
@@ -2430,7 +2430,7 @@ source "drivers/pcmcia/Kconfig" · 288 unmodified lines
24302430 source "drivers/pci/hotplug/Kconfig"
24312431
24322432 config RAPIDIO
2433− bool "RapidIO support"
2433+ tristate "RapidIO support"
24342434 depends on PCI
24352435 default n
24362436 help
arch/mips/include/asm/fixmap.h+1−32
@@ -71,38 +71,7 @@ enum fixed_addresses { · 70 unmodified lines
7171 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
7272 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
7373
74−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
75−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
76−
77−extern void __this_fixmap_does_not_exist(void);
78−
79−/*
80− * 'index to address' translation. If anyone tries to use the idx
81− * directly without tranlation, we catch the bug with a NULL-deference
82− * kernel oops. Illegal ranges of incoming indices are caught too.
83− */
84−static inline unsigned long fix_to_virt(const unsigned int idx)
85−{
86− /*
87− * this branch gets completely eliminated after inlining,
88− * except when someone tries to use fixaddr indices in an
89− * illegal way. (such as mixing up address types or using
90− * out-of-range indices).
91− *
92− * If it doesn't get removed, the linker will complain
93− * loudly with a reasonably clear error message..
94− */
95− if (idx >= __end_of_fixed_addresses)
96− __this_fixmap_does_not_exist();
97−
98− return __fix_to_virt(idx);
99−}
100−
101−static inline unsigned long virt_to_fix(const unsigned long vaddr)
102−{
103− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
104− return __virt_to_fix(vaddr);
105−}
74+#include <asm-generic/fixmap.h>
10675
10776 #define kmap_get_fixmap_pte(vaddr) \
10877 pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr))
arch/mn10300/Kconfig+4−4
@@ -184,13 +184,13 @@ config SMP · 183 unmodified lines
184184 depends on MN10300_PROC_MN2WS0038 || MN10300_PROC_MN2WS0050
185185 ---help---
186186 This enables support for systems with more than one CPU. If you have
187− a system with only one CPU, like most personal computers, say N. If
188− you have a system with more than one CPU, say Y.
187+ a system with only one CPU, say N. If you have a system with more
188+ than one CPU, say Y.
189189
190− If you say N here, the kernel will run on single and multiprocessor
190+ If you say N here, the kernel will run on uni- and multiprocessor
191191 machines, but will use only one CPU of a multiprocessor machine. If
192192 you say Y here, the kernel will run on many, but not all,
193− singleprocessor machines. On a singleprocessor machine, the kernel
193+ uniprocessor machines. On a uniprocessor machine, the kernel
194194 will run faster if you say N here.
195195
196196 See also <file:Documentation/x86/i386/IO-APIC.txt>,
arch/parisc/Kconfig+4−4
@@ -229,13 +229,13 @@ config SMP · 228 unmodified lines
229229 bool "Symmetric multi-processing support"
230230 ---help---
231231 This enables support for systems with more than one CPU. If you have
232− a system with only one CPU, like most personal computers, say N. If
233− you have a system with more than one CPU, say Y.
232+ a system with only one CPU, say N. If you have a system with more
233+ than one CPU, say Y.
234234
235− If you say N here, the kernel will run on single and multiprocessor
235+ If you say N here, the kernel will run on uni- and multiprocessor
236236 machines, but will use only one CPU of a multiprocessor machine. If
237237 you say Y here, the kernel will run on many, but not all,
238− singleprocessor machines. On a singleprocessor machine, the kernel
238+ uniprocessor machines. On a uniprocessor machine, the kernel
239239 will run faster if you say N here.
240240
241241 See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
arch/powerpc/Kconfig+2−2
@@ -794,7 +794,7 @@ config HAS_RAPIDIO · 793 unmodified lines
794794 default n
795795
796796 config RAPIDIO
797− bool "RapidIO support"
797+ tristate "RapidIO support"
798798 depends on HAS_RAPIDIO || PCI
799799 help
800800 If you say Y here, the kernel will include drivers and
@@ -802,7 +802,7 @@ config RAPIDIO · 1 unmodified line
802802
803803 config FSL_RIO
804804 bool "Freescale Embedded SRIO Controller support"
805− depends on RAPIDIO && HAS_RAPIDIO
805+ depends on RAPIDIO = y && HAS_RAPIDIO
806806 default "n"
807807 ---help---
808808 Include support for RapidIO controller on Freescale embedded
arch/powerpc/include/asm/fixmap.h+2−42
@@ -58,52 +58,12 @@ enum fixed_addresses { · 57 unmodified lines
5858 extern void __set_fixmap (enum fixed_addresses idx,
5959 phys_addr_t phys, pgprot_t flags);
6060
61−#define set_fixmap(idx, phys) \
62− __set_fixmap(idx, phys, PAGE_KERNEL)
63−/*
64− * Some hardware wants to get fixmapped without caching.
65− */
66−#define set_fixmap_nocache(idx, phys) \
67− __set_fixmap(idx, phys, PAGE_KERNEL_NCG)
68−
69−#define clear_fixmap(idx) \
70− __set_fixmap(idx, 0, __pgprot(0))
71−
7261 #define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
7362 #define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
7463
75−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
76−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
77−
78−extern void __this_fixmap_does_not_exist(void);
79−
80−/*
81− * 'index to address' translation. If anyone tries to use the idx
82− * directly without tranlation, we catch the bug with a NULL-deference
83− * kernel oops. Illegal ranges of incoming indices are caught too.
84− */
85−static __always_inline unsigned long fix_to_virt(const unsigned int idx)
86−{
87− /*
88− * this branch gets completely eliminated after inlining,
89− * except when someone tries to use fixaddr indices in an
90− * illegal way. (such as mixing up address types or using
91− * out-of-range indices).
92− *
93− * If it doesn't get removed, the linker will complain
94− * loudly with a reasonably clear error message..
95− */
96− if (idx >= __end_of_fixed_addresses)
97− __this_fixmap_does_not_exist();
98−
99− return __fix_to_virt(idx);
100−}
64+#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG
10165
102−static inline unsigned long virt_to_fix(const unsigned long vaddr)
103−{
104− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
105− return __virt_to_fix(vaddr);
106−}
66+#include <asm-generic/fixmap.h>
10767
10868 #endif /* !__ASSEMBLY__ */
10969 #endif
arch/s390/Kconfig+2−2
@@ -334,10 +334,10 @@ config SMP · 333 unmodified lines
334334 a system with only one CPU, like most personal computers, say N. If
335335 you have a system with more than one CPU, say Y.
336336
337− If you say N here, the kernel will run on single and multiprocessor
337+ If you say N here, the kernel will run on uni- and multiprocessor
338338 machines, but will use only one CPU of a multiprocessor machine. If
339339 you say Y here, the kernel will run on many, but not all,
340− singleprocessor machines. On a singleprocessor machine, the kernel
340+ uniprocessor machines. On a uniprocessor machine, the kernel
341341 will run faster if you say N here.
342342
343343 See also the SMP-HOWTO available at
arch/sh/Kconfig+4−4
@@ -701,13 +701,13 @@ config SMP · 700 unmodified lines
701701 depends on SYS_SUPPORTS_SMP
702702 ---help---
703703 This enables support for systems with more than one CPU. If you have
704− a system with only one CPU, like most personal computers, say N. If
705− you have a system with more than one CPU, say Y.
704+ a system with only one CPU, say N. If you have a system with more
705+ than one CPU, say Y.
706706
707− If you say N here, the kernel will run on single and multiprocessor
707+ If you say N here, the kernel will run on uni- and multiprocessor
708708 machines, but will use only one CPU of a multiprocessor machine. If
709709 you say Y here, the kernel will run on many, but not all,
710− singleprocessor machines. On a singleprocessor machine, the kernel
710+ uniprocessor machines. On a uniprocessor machine, the kernel
711711 will run faster if you say N here.
712712
713713 People using multiprocessor machines who say Y here should also say
arch/sh/include/asm/fixmap.h+2−37
@@ -79,13 +79,6 @@ extern void __set_fixmap(enum fixed_addresses idx, · 78 unmodified lines
7979 unsigned long phys, pgprot_t flags);
8080 extern void __clear_fixmap(enum fixed_addresses idx, pgprot_t flags);
8181
82−#define set_fixmap(idx, phys) \
83− __set_fixmap(idx, phys, PAGE_KERNEL)
84−/*
85− * Some hardware wants to get fixmapped without caching.
86− */
87−#define set_fixmap_nocache(idx, phys) \
88− __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
8982 /*
9083 * used by vmalloc.c.
9184 *
@@ -101,36 +94,8 @@ extern void __clear_fixmap(enum fixed_addresses idx, pgprot_t flags); · 9 unmodified lines
10194 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
10295 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
10396
104−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
105−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
106−
107−extern void __this_fixmap_does_not_exist(void);
108−
109−/*
110− * 'index to address' translation. If anyone tries to use the idx
111− * directly without tranlation, we catch the bug with a NULL-deference
112− * kernel oops. Illegal ranges of incoming indices are caught too.
113− */
114−static inline unsigned long fix_to_virt(const unsigned int idx)
115−{
116− /*
117− * this branch gets completely eliminated after inlining,
118− * except when someone tries to use fixaddr indices in an
119− * illegal way. (such as mixing up address types or using
120− * out-of-range indices).
121− *
122− * If it doesn't get removed, the linker will complain
123− * loudly with a reasonably clear error message..
124− */
125− if (idx >= __end_of_fixed_addresses)
126− __this_fixmap_does_not_exist();
97+#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
12798
128− return __fix_to_virt(idx);
129−}
99+#include <asm-generic/fixmap.h>
130100
131−static inline unsigned long virt_to_fix(const unsigned long vaddr)
132−{
133− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
134− return __virt_to_fix(vaddr);
135−}
136101 #endif
arch/sh/kernel/dwarf.c+4−14
@@ -995,29 +995,19 @@ static struct unwinder dwarf_unwinder = { · 994 unmodified lines
995995
996996 static void dwarf_unwinder_cleanup(void)
997997 {
998− struct rb_node **fde_rb_node = &fde_root.rb_node;
999− struct rb_node **cie_rb_node = &cie_root.rb_node;
998+ struct dwarf_fde *fde, *next_fde;
999+ struct dwarf_cie *cie, *next_cie;
10001000
10011001 /*
10021002 * Deallocate all the memory allocated for the DWARF unwinder.
10031003 * Traverse all the FDE/CIE lists and remove and free all the
10041004 * memory associated with those data structures.
10051005 */
1006− while (*fde_rb_node) {
1007− struct dwarf_fde *fde;
1008−
1009− fde = rb_entry(*fde_rb_node, struct dwarf_fde, node);
1010− rb_erase(*fde_rb_node, &fde_root);
1006+ rbtree_postorder_for_each_entry_safe(fde, next_fde, &fde_root, node)
10111007 kfree(fde);
1012− }
10131008
1014− while (*cie_rb_node) {
1015− struct dwarf_cie *cie;
1016−
1017− cie = rb_entry(*cie_rb_node, struct dwarf_cie, node);
1018− rb_erase(*cie_rb_node, &cie_root);
1009+ rbtree_postorder_for_each_entry_safe(cie, next_cie, &cie_root, node)
10191010 kfree(cie);
1020− }
10211011
10221012 kmem_cache_destroy(dwarf_reg_cachep);
10231013 kmem_cache_destroy(dwarf_frame_cachep);
arch/sparc/Kconfig+2−2
@@ -152,10 +152,10 @@ config SMP · 151 unmodified lines
152152 a system with only one CPU, say N. If you have a system with more
153153 than one CPU, say Y.
154154
155− If you say N here, the kernel will run on single and multiprocessor
155+ If you say N here, the kernel will run on uni- and multiprocessor
156156 machines, but will use only one CPU of a multiprocessor machine. If
157157 you say Y here, the kernel will run on many, but not all,
158− singleprocessor machines. On a singleprocessor machine, the kernel
158+ uniprocessor machines. On a uniprocessor machine, the kernel
159159 will run faster if you say N here.
160160
161161 People using multiprocessor machines who say Y here should also say
arch/tile/include/asm/fixmap.h+1−32
@@ -25,9 +25,6 @@ · 24 unmodified lines
2525 #include <asm/kmap_types.h>
2626 #endif
2727
28−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
29−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
30−
3128 /*
3229 * Here we define all the compile-time 'special' virtual
3330 * addresses. The point is to have a constant address at
@@ -83,35 +80,7 @@ enum fixed_addresses { · 49 unmodified lines
8380 #define FIXADDR_START (FIXADDR_TOP + PAGE_SIZE - __FIXADDR_SIZE)
8481 #define FIXADDR_BOOT_START (FIXADDR_TOP + PAGE_SIZE - __FIXADDR_BOOT_SIZE)
8582
86−extern void __this_fixmap_does_not_exist(void);
87−
88−/*
89− * 'index to address' translation. If anyone tries to use the idx
90− * directly without tranlation, we catch the bug with a NULL-deference
91− * kernel oops. Illegal ranges of incoming indices are caught too.
92− */
93−static __always_inline unsigned long fix_to_virt(const unsigned int idx)
94−{
95− /*
96− * this branch gets completely eliminated after inlining,
97− * except when someone tries to use fixaddr indices in an
98− * illegal way. (such as mixing up address types or using
99− * out-of-range indices).
100− *
101− * If it doesn't get removed, the linker will complain
102− * loudly with a reasonably clear error message..
103− */
104− if (idx >= __end_of_fixed_addresses)
105− __this_fixmap_does_not_exist();
106−
107− return __fix_to_virt(idx);
108−}
109−
110−static inline unsigned long virt_to_fix(const unsigned long vaddr)
111−{
112− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
113− return __virt_to_fix(vaddr);
114−}
83+#include <asm-generic/fixmap.h>
11584
11685 #endif /* !__ASSEMBLY__ */
11786
arch/um/include/asm/fixmap.h+1−39
@@ -43,13 +43,6 @@ enum fixed_addresses { · 42 unmodified lines
4343 extern void __set_fixmap (enum fixed_addresses idx,
4444 unsigned long phys, pgprot_t flags);
4545
46−#define set_fixmap(idx, phys) \
47− __set_fixmap(idx, phys, PAGE_KERNEL)
48−/*
49− * Some hardware wants to get fixmapped without caching.
50− */
51−#define set_fixmap_nocache(idx, phys) \
52− __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
5346 /*
5447 * used by vmalloc.c.
5548 *
@@ -62,37 +55,6 @@ extern void __set_fixmap (enum fixed_addresses idx, · 6 unmodified lines
6255 #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
6356 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
6457
65−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
66−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
67−
68−extern void __this_fixmap_does_not_exist(void);
69−
70−/*
71− * 'index to address' translation. If anyone tries to use the idx
72− * directly without tranlation, we catch the bug with a NULL-deference
73− * kernel oops. Illegal ranges of incoming indices are caught too.
74− */
75−static inline unsigned long fix_to_virt(const unsigned int idx)
76−{
77− /*
78− * this branch gets completely eliminated after inlining,
79− * except when someone tries to use fixaddr indices in an
80− * illegal way. (such as mixing up address types or using
81− * out-of-range indices).
82− *
83− * If it doesn't get removed, the linker will complain
84− * loudly with a reasonably clear error message..
85− */
86− if (idx >= __end_of_fixed_addresses)
87− __this_fixmap_does_not_exist();
88−
89− return __fix_to_virt(idx);
90−}
91−
92−static inline unsigned long virt_to_fix(const unsigned long vaddr)
93−{
94− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
95− return __virt_to_fix(vaddr);
96−}
58+#include <asm-generic/fixmap.h>
9759
9860 #endif
arch/x86/Kconfig+5−4
@@ -279,13 +279,13 @@ config SMP · 278 unmodified lines
279279 bool "Symmetric multi-processing support"
280280 ---help---
281281 This enables support for systems with more than one CPU. If you have
282− a system with only one CPU, like most personal computers, say N. If
283− you have a system with more than one CPU, say Y.
282+ a system with only one CPU, say N. If you have a system with more
283+ than one CPU, say Y.
284284
285− If you say N here, the kernel will run on single and multiprocessor
285+ If you say N here, the kernel will run on uni- and multiprocessor
286286 machines, but will use only one CPU of a multiprocessor machine. If
287287 you say Y here, the kernel will run on many, but not all,
288− singleprocessor machines. On a singleprocessor machine, the kernel
288+ uniprocessor machines. On a uniprocessor machine, the kernel
289289 will run faster if you say N here.
290290
291291 Note that if you say Y here and choose architecture "586" or
@@ -731,6 +731,7 @@ config APB_TIMER · 439 unmodified lines
731731 # The code disables itself when not needed.
732732 config DMI
733733 default y
734+ select DMI_SCAN_MACHINE_NON_EFI_FALLBACK
734735 bool "Enable DMI scanning" if EXPERT
735736 ---help---
736737 Enabled scanning of DMI to identify machine quirks. Say Y
arch/x86/include/asm/dmi.h+4−2
@@ -13,7 +13,9 @@ static __always_inline __init void *dmi_alloc(unsigned len) · 12 unmodified lines
1313 }
1414
1515 /* Use early IO mappings for DMI because it's initialized early */
16−#define dmi_ioremap early_ioremap
17−#define dmi_iounmap early_iounmap
16+#define dmi_early_remap early_ioremap
17+#define dmi_early_unmap early_iounmap
18+#define dmi_remap ioremap
19+#define dmi_unmap iounmap
1820
1921 #endif /* _ASM_X86_DMI_H */
arch/x86/include/asm/fixmap.h+1−58
@@ -175,64 +175,7 @@ static inline void __set_fixmap(enum fixed_addresses idx, · 174 unmodified lines
175175 }
176176 #endif
177177
178−#define set_fixmap(idx, phys) \
179− __set_fixmap(idx, phys, PAGE_KERNEL)
180−
181−/*
182− * Some hardware wants to get fixmapped without caching.
183− */
184−#define set_fixmap_nocache(idx, phys) \
185− __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
186−
187−#define clear_fixmap(idx) \
188− __set_fixmap(idx, 0, __pgprot(0))
189−
190−#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
191−#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
192−
193−extern void __this_fixmap_does_not_exist(void);
194−
195−/*
196− * 'index to address' translation. If anyone tries to use the idx
197− * directly without translation, we catch the bug with a NULL-deference
198− * kernel oops. Illegal ranges of incoming indices are caught too.
199− */
200−static __always_inline unsigned long fix_to_virt(const unsigned int idx)
201−{
202− /*
203− * this branch gets completely eliminated after inlining,
204− * except when someone tries to use fixaddr indices in an
205− * illegal way. (such as mixing up address types or using
206− * out-of-range indices).
207− *
208− * If it doesn't get removed, the linker will complain
209− * loudly with a reasonably clear error message..
210− */
211− if (idx >= __end_of_fixed_addresses)
212− __this_fixmap_does_not_exist();
213−
214− return __fix_to_virt(idx);
215−}
216−
217−static inline unsigned long virt_to_fix(const unsigned long vaddr)
218−{
219− BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
220− return __virt_to_fix(vaddr);
221−}
222−
223−/* Return an pointer with offset calculated */
224−static __always_inline unsigned long
225−__set_fixmap_offset(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
226−{
227− __set_fixmap(idx, phys, flags);
228− return fix_to_virt(idx) + (phys & (PAGE_SIZE - 1));
229−}
230−
231−#define set_fixmap_offset(idx, phys) \
232− __set_fixmap_offset(idx, phys, PAGE_KERNEL)
233−
234−#define set_fixmap_offset_nocache(idx, phys) \
235− __set_fixmap_offset(idx, phys, PAGE_KERNEL_NOCACHE)
178+#include <asm-generic/fixmap.h>
236179
237180 #endif /* !__ASSEMBLY__ */
238181 #endif /* _ASM_X86_FIXMAP_H */
arch/x86/mm/gup.c+4−4
@@ -108,8 +108,8 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr, · 107 unmodified lines
108108
109109 static inline void get_head_page_multiple(struct page *page, int nr)
110110 {
111− VM_BUG_ON(page != compound_head(page));
112− VM_BUG_ON(page_count(page) == 0);
111+ VM_BUG_ON_PAGE(page != compound_head(page), page);
112+ VM_BUG_ON_PAGE(page_count(page) == 0, page);
113113 atomic_add(nr, &page->_count);
114114 SetPageReferenced(page);
115115 }
@@ -135,7 +135,7 @@ static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr, · 19 unmodified lines
135135 head = pte_page(pte);
136136 page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
137137 do {
138− VM_BUG_ON(compound_head(page) != head);
138+ VM_BUG_ON_PAGE(compound_head(page) != head, page);
139139 pages[*nr] = page;
140140 if (PageTail(page))
141141 get_huge_page_tail(page);
@@ -212,7 +212,7 @@ static noinline int gup_huge_pud(pud_t pud, unsigned long addr, · 70 unmodified lines
212212 head = pte_page(pte);
213213 page = head + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
214214 do {
215− VM_BUG_ON(compound_head(page) != head);
215+ VM_BUG_ON_PAGE(compound_head(page) != head, page);
216216 pages[*nr] = page;
217217 if (PageTail(page))
218218 get_huge_page_tail(page);
drivers/block/Kconfig+2−1
@@ -368,7 +368,8 @@ config BLK_DEV_RAM · 367 unmodified lines
368368 For details, read <file:Documentation/blockdev/ramdisk.txt>.
369369
370370 To compile this driver as a module, choose M here: the
371− module will be called rd.
371+ module will be called brd. An alias "rd" has been defined
372+ for historical reasons.
372373
373374 Most normal users won't need the RAM disk functionality, and can
374375 thus say N here.
drivers/firmware/Kconfig+3−0
@@ -108,6 +108,9 @@ config DMI_SYSFS · 107 unmodified lines
108108 under /sys/firmware/dmi when this option is enabled and
109109 loaded.
110110
111+config DMI_SCAN_MACHINE_NON_EFI_FALLBACK
112+ bool
113+
111114 config ISCSI_IBFT_FIND
112115 bool "iSCSI Boot Firmware Table Attributes"
113116 depends on X86
drivers/firmware/dmi_scan.c+10−10
@@ -116,7 +116,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, · 115 unmodified lines
116116 {
117117 u8 *buf;
118118
119− buf = dmi_ioremap(dmi_base, dmi_len);
119+ buf = dmi_early_remap(dmi_base, dmi_len);
120120 if (buf == NULL)
121121 return -1;
122122
@@ -124,7 +124,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, · 1 unmodified line
124124
125125 add_device_randomness(buf, dmi_len);
126126
127− dmi_iounmap(buf, dmi_len);
127+ dmi_early_unmap(buf, dmi_len);
128128 return 0;
129129 }
130130
@@ -527,18 +527,18 @@ void __init dmi_scan_machine(void) · 396 unmodified lines
527527 * needed during early boot. This also means we can
528528 * iounmap the space when we're done with it.
529529 */
530− p = dmi_ioremap(efi.smbios, 32);
530+ p = dmi_early_remap(efi.smbios, 32);
531531 if (p == NULL)
532532 goto error;
533533 memcpy_fromio(buf, p, 32);
534− dmi_iounmap(p, 32);
534+ dmi_early_unmap(p, 32);
535535
536536 if (!dmi_present(buf)) {
537537 dmi_available = 1;
538538 goto out;
539539 }
540− } else {
541− p = dmi_ioremap(0xF0000, 0x10000);
540+ } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) {
541+ p = dmi_early_remap(0xF0000, 0x10000);
542542 if (p == NULL)
543543 goto error;
544544
@@ -554,12 +554,12 @@ void __init dmi_scan_machine(void) · 9 unmodified lines
554554 memcpy_fromio(buf + 16, q, 16);
555555 if (!dmi_present(buf)) {
556556 dmi_available = 1;
557− dmi_iounmap(p, 0x10000);
557+ dmi_early_unmap(p, 0x10000);
558558 goto out;
559559 }
560560 memcpy(buf, buf + 16, 16);
561561 }
562− dmi_iounmap(p, 0x10000);
562+ dmi_early_unmap(p, 0x10000);
563563 }
564564 error:
565565 pr_info("DMI not present or invalid.\n");
@@ -831,13 +831,13 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *), · 265 unmodified lines
831831 if (!dmi_available)
832832 return -1;
833833
834− buf = ioremap(dmi_base, dmi_len);
834+ buf = dmi_remap(dmi_base, dmi_len);
835835 if (buf == NULL)
836836 return -1;
837837
838838 dmi_table(buf, dmi_len, dmi_num, decode, private_data);
839839
840− iounmap(buf);
840+ dmi_unmap(buf);
841841 return 0;
842842 }
843843 EXPORT_SYMBOL_GPL(dmi_walk);
drivers/gpu/drm/gma500/backlight.c+2−2
@@ -26,13 +26,13 @@ · 25 unmodified lines
2626 #include "intel_bios.h"
2727 #include "power.h"
2828
29+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
2930 static void do_gma_backlight_set(struct drm_device *dev)
3031 {
31−#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
3232 struct drm_psb_private *dev_priv = dev->dev_private;
3333 backlight_update_status(dev_priv->backlight_device);
34−#endif
3534 }
35+#endif
3636
3737 void gma_backlight_enable(struct drm_device *dev)
3838 {
drivers/mailbox/omap-mbox.h+1−1
@@ -52,7 +52,7 @@ struct omap_mbox_queue { · 51 unmodified lines
5252
5353 struct omap_mbox {
5454 const char *name;
55− unsigned int irq;
55+ int irq;
5656 struct omap_mbox_queue *txq, *rxq;
5757 struct omap_mbox_ops *ops;
5858 struct device *dev;
drivers/memstick/host/rtsx_pci_ms.c+20−10
@@ -145,6 +145,8 @@ static int ms_transfer_data(struct realtek_pci_ms *host, unsigned char data_dir, · 144 unmodified lines
145145 unsigned int length = sg->length;
146146 u16 sec_cnt = (u16)(length / 512);
147147 u8 val, trans_mode, dma_dir;
148+ struct memstick_dev *card = host->msh->card;
149+ bool pro_card = card->id.type == MEMSTICK_TYPE_PRO;
148150
149151 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x, data_dir = %s, length = %d\n",
150152 __func__, tpc, (data_dir == READ) ? "READ" : "WRITE",
@@ -152,19 +154,21 @@ static int ms_transfer_data(struct realtek_pci_ms *host, unsigned char data_dir, · 1 unmodified line
152154
153155 if (data_dir == READ) {
154156 dma_dir = DMA_DIR_FROM_CARD;
155− trans_mode = MS_TM_AUTO_READ;
157+ trans_mode = pro_card ? MS_TM_AUTO_READ : MS_TM_NORMAL_READ;
156158 } else {
157159 dma_dir = DMA_DIR_TO_CARD;
158− trans_mode = MS_TM_AUTO_WRITE;
160+ trans_mode = pro_card ? MS_TM_AUTO_WRITE : MS_TM_NORMAL_WRITE;
159161 }
160162
161163 rtsx_pci_init_cmd(pcr);
162164
163165 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_TPC, 0xFF, tpc);
164− rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_H,
165− 0xFF, (u8)(sec_cnt >> 8));
166− rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_L,
167− 0xFF, (u8)sec_cnt);
166+ if (pro_card) {
167+ rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_H,
168+ 0xFF, (u8)(sec_cnt >> 8));
169+ rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_L,
170+ 0xFF, (u8)sec_cnt);
171+ }
168172 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg);
169173
170174 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, IRQSTAT0,
@@ -192,8 +196,14 @@ static int ms_transfer_data(struct realtek_pci_ms *host, unsigned char data_dir, · 21 unmodified lines
192196 }
193197
194198 rtsx_pci_read_register(pcr, MS_TRANS_CFG, &val);
195− if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT))
196− return -EIO;
199+ if (pro_card) {
200+ if (val & (MS_INT_CMDNK | MS_INT_ERR |
201+ MS_CRC16_ERR | MS_RDY_TIMEOUT))
202+ return -EIO;
203+ } else {
204+ if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT))
205+ return -EIO;
206+ }
197207
198208 return 0;
199209 }
@@ -462,8 +472,8 @@ static int rtsx_pci_ms_set_param(struct memstick_host *msh, · 262 unmodified lines
462472 clock = 19000000;
463473 ssc_depth = RTSX_SSC_DEPTH_500K;
464474
465− err = rtsx_pci_write_register(pcr, MS_CFG,
466− 0x18, MS_BUS_WIDTH_1);
475+ err = rtsx_pci_write_register(pcr, MS_CFG, 0x58,
476+ MS_BUS_WIDTH_1 | PUSH_TIME_DEFAULT);
467477 if (err < 0)
468478 return err;
469479 } else if (value == MEMSTICK_PAR4) {
drivers/mfd/max8998.c+1−1
@@ -175,7 +175,7 @@ static inline int max8998_i2c_get_driver_data(struct i2c_client *i2c, · 174 unmodified lines
175175 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
176176 const struct of_device_id *match;
177177 match = of_match_node(max8998_dt_match, i2c->dev.of_node);
178− return (int)match->data;
178+ return (int)(long)match->data;
179179 }
180180
181181 return (int)id->driver_data;
drivers/mfd/tps65217.c+1−1
@@ -170,7 +170,7 @@ static int tps65217_probe(struct i2c_client *client, · 169 unmodified lines
170170 "Failed to find matching dt id\n");
171171 return -EINVAL;
172172 }
173− chip_id = (unsigned int)match->data;
173+ chip_id = (unsigned int)(unsigned long)match->data;
174174 status_off = of_property_read_bool(client->dev.of_node,
175175 "ti,pmic-shutdown-controller");
176176 }
drivers/rtc/Kconfig+12−1
@@ -212,6 +212,17 @@ config RTC_DRV_DS3232 · 211 unmodified lines
212212 This driver can also be built as a module. If so, the module
213213 will be called rtc-ds3232.
214214
215+config RTC_DRV_HYM8563
216+ tristate "Haoyu Microelectronics HYM8563"
217+ depends on I2C && OF
218+ help
219+ Say Y to enable support for the HYM8563 I2C RTC chip. Apart
220+ from the usual rtc functions it provides a clock output of
221+ up to 32kHz.
222+
223+ This driver can also be built as a module. If so, the module
224+ will be called rtc-hym8563.
225+
215226 config RTC_DRV_LP8788
216227 tristate "TI LP8788 RTC driver"
217228 depends on MFD_LP8788
@@ -637,7 +648,7 @@ comment "Platform RTC drivers" · 419 unmodified lines
637648
638649 config RTC_DRV_CMOS
639650 tristate "PC-style 'CMOS'"
640− depends on X86 || ARM || M32R || ATARI || PPC || MIPS || SPARC64
651+ depends on X86 || ARM || M32R || PPC || MIPS || SPARC64
641652 default y if X86
642653 help
643654 Say "yes" here to get direct support for the real time clock
drivers/rtc/Makefile+1−0
@@ -55,6 +55,7 @@ obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o · 54 unmodified lines
5555 obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o
5656 obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o
5757 obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o
58+obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o
5859 obj-$(CONFIG_RTC_DRV_IMXDI) += rtc-imxdi.o
5960 obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
6061 obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o
drivers/rtc/class.c+20−4
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1515
1616 #include <linux/module.h>
17+#include <linux/of.h>
1718 #include <linux/rtc.h>
1819 #include <linux/kdev_t.h>
1920 #include <linux/idr.h>
@@ -157,12 +158,27 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, · 137 unmodified lines
157158 {
158159 struct rtc_device *rtc;
159160 struct rtc_wkalrm alrm;
160− int id, err;
161+ int of_id = -1, id = -1, err;
162+
163+ if (dev->of_node)
164+ of_id = of_alias_get_id(dev->of_node, "rtc");
165+ else if (dev->parent && dev->parent->of_node)
166+ of_id = of_alias_get_id(dev->parent->of_node, "rtc");
167+
168+ if (of_id >= 0) {
169+ id = ida_simple_get(&rtc_ida, of_id, of_id + 1,
170+ GFP_KERNEL);
171+ if (id < 0)
172+ dev_warn(dev, "/aliases ID %d not available\n",
173+ of_id);
174+ }
161175
162− id = ida_simple_get(&rtc_ida, 0, 0, GFP_KERNEL);
163176 if (id < 0) {
164− err = id;
165− goto exit;
177+ id = ida_simple_get(&rtc_ida, 0, 0, GFP_KERNEL);
178+ if (id < 0) {
179+ err = id;
180+ goto exit;
181+ }
166182 }
167183
168184 rtc = kzalloc(sizeof(struct rtc_device), GFP_KERNEL);
drivers/rtc/rtc-as3722.c+3−16
@@ -198,7 +198,7 @@ static int as3722_rtc_probe(struct platform_device *pdev) · 197 unmodified lines
198198
199199 device_init_wakeup(&pdev->dev, 1);
200200
201− as3722_rtc->rtc = rtc_device_register("as3722", &pdev->dev,
201+ as3722_rtc->rtc = devm_rtc_device_register(&pdev->dev, "as3722-rtc",
202202 &as3722_rtc_ops, THIS_MODULE);
203203 if (IS_ERR(as3722_rtc->rtc)) {
204204 ret = PTR_ERR(as3722_rtc->rtc);
@@ -209,28 +209,16 @@ static int as3722_rtc_probe(struct platform_device *pdev) · 4 unmodified lines
209209 as3722_rtc->alarm_irq = platform_get_irq(pdev, 0);
210210 dev_info(&pdev->dev, "RTC interrupt %d\n", as3722_rtc->alarm_irq);
211211
212− ret = request_threaded_irq(as3722_rtc->alarm_irq, NULL,
212+ ret = devm_request_threaded_irq(&pdev->dev, as3722_rtc->alarm_irq, NULL,
213213 as3722_alarm_irq, IRQF_ONESHOT | IRQF_EARLY_RESUME,
214214 "rtc-alarm", as3722_rtc);
215215 if (ret < 0) {
216216 dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n",
217217 as3722_rtc->alarm_irq, ret);
218− goto scrub;
218+ return ret;
219219 }
220220 disable_irq(as3722_rtc->alarm_irq);
221221 return 0;
222−scrub:
223− rtc_device_unregister(as3722_rtc->rtc);
224− return ret;
225−}
226−
227−static int as3722_rtc_remove(struct platform_device *pdev)
228−{
229− struct as3722_rtc *as3722_rtc = platform_get_drvdata(pdev);
230−
231− free_irq(as3722_rtc->alarm_irq, as3722_rtc);
232− rtc_device_unregister(as3722_rtc->rtc);
233− return 0;
234222 }
235223
236224 #ifdef CONFIG_PM_SLEEP
@@ -260,7 +248,6 @@ static const struct dev_pm_ops as3722_rtc_pm_ops = { · 23 unmodified lines
260248
261249 static struct platform_driver as3722_rtc_driver = {
262250 .probe = as3722_rtc_probe,
263− .remove = as3722_rtc_remove,
264251 .driver = {
265252 .name = "as3722-rtc",
266253 .pm = &as3722_rtc_pm_ops,
drivers/rtc/rtc-cmos.c+3−5
@@ -756,11 +756,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) · 755 unmodified lines
756756 irq_handler_t rtc_cmos_int_handler;
757757
758758 if (is_hpet_enabled()) {
759− int err;
760−
761759 rtc_cmos_int_handler = hpet_rtc_interrupt;
762− err = hpet_register_irq_handler(cmos_interrupt);
763− if (err != 0) {
760+ retval = hpet_register_irq_handler(cmos_interrupt);
761+ if (retval) {
764762 dev_warn(dev, "hpet_register_irq_handler "
765763 " failed in rtc_init().");
766764 goto cleanup1;
@@ -1175,7 +1173,7 @@ static struct platform_driver cmos_platform_driver = { · 408 unmodified lines
11751173 .remove = __exit_p(cmos_platform_remove),
11761174 .shutdown = cmos_platform_shutdown,
11771175 .driver = {
1178− .name = (char *) driver_name,
1176+ .name = driver_name,
11791177 #ifdef CONFIG_PM
11801178 .pm = &cmos_pm_ops,
11811179 #endif
drivers/rtc/rtc-ds1305.c+0−1
@@ -787,7 +787,6 @@ static int ds1305_remove(struct spi_device *spi) · 786 unmodified lines
787787 cancel_work_sync(&ds1305->work);
788788 }
789789
790− spi_set_drvdata(spi, NULL);
791790 return 0;
792791 }
793792
drivers/rtc/rtc-ds1742.c+9−1
@@ -13,12 +13,13 @@ · 12 unmodified lines
1313 */
1414
1515 #include <linux/bcd.h>
16−#include <linux/init.h>
1716 #include <linux/kernel.h>
1817 #include <linux/gfp.h>
1918 #include <linux/delay.h>
2019 #include <linux/jiffies.h>
2120 #include <linux/rtc.h>
21+#include <linux/of.h>
22+#include <linux/of_device.h>
2223 #include <linux/platform_device.h>
2324 #include <linux/io.h>
2425 #include <linux/module.h>
@@ -215,12 +216,19 @@ static int ds1742_rtc_remove(struct platform_device *pdev) · 190 unmodified lines
215216 return 0;
216217 }
217218
219+static struct of_device_id __maybe_unused ds1742_rtc_of_match[] = {
220+ { .compatible = "maxim,ds1742", },
221+ { }
222+};
223+MODULE_DEVICE_TABLE(of, ds1742_rtc_of_match);
224+
218225 static struct platform_driver ds1742_rtc_driver = {
219226 .probe = ds1742_rtc_probe,
220227 .remove = ds1742_rtc_remove,
221228 .driver = {
222229 .name = "rtc-ds1742",
223230 .owner = THIS_MODULE,
231+ .of_match_table = ds1742_rtc_of_match,
224232 },
225233 };
226234
drivers/rtc/rtc-hym8563.c+606−0
@@ -0,0 +1,606 @@
1+/*
2+ * Haoyu HYM8563 RTC driver
3+ *
4+ * Copyright (C) 2013 MundoReader S.L.
5+ * Author: Heiko Stuebner <heiko@sntech.de>
6+ *
7+ * based on rtc-HYM8563
8+ * Copyright (C) 2010 ROCKCHIP, Inc.
9+ *
10+ * This software is licensed under the terms of the GNU General Public
11+ * License version 2, as published by the Free Software Foundation, and
12+ * may be copied, distributed, and modified under those terms.
13+ *
14+ * This program is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ */
19+
20+#include <linux/module.h>
21+#include <linux/clk-provider.h>
22+#include <linux/i2c.h>
23+#include <linux/bcd.h>
24+#include <linux/rtc.h>
25+
26+#define HYM8563_CTL1 0x00
27+#define HYM8563_CTL1_TEST BIT(7)
28+#define HYM8563_CTL1_STOP BIT(5)
29+#define HYM8563_CTL1_TESTC BIT(3)
30+
31+#define HYM8563_CTL2 0x01
32+#define HYM8563_CTL2_TI_TP BIT(4)
33+#define HYM8563_CTL2_AF BIT(3)
34+#define HYM8563_CTL2_TF BIT(2)
35+#define HYM8563_CTL2_AIE BIT(1)
36+#define HYM8563_CTL2_TIE BIT(0)
37+
38+#define HYM8563_SEC 0x02
39+#define HYM8563_SEC_VL BIT(7)
40+#define HYM8563_SEC_MASK 0x7f
41+
42+#define HYM8563_MIN 0x03
43+#define HYM8563_MIN_MASK 0x7f
44+
45+#define HYM8563_HOUR 0x04
46+#define HYM8563_HOUR_MASK 0x3f
47+
48+#define HYM8563_DAY 0x05
49+#define HYM8563_DAY_MASK 0x3f
50+
51+#define HYM8563_WEEKDAY 0x06
52+#define HYM8563_WEEKDAY_MASK 0x07
53+
54+#define HYM8563_MONTH 0x07
55+#define HYM8563_MONTH_CENTURY BIT(7)
56+#define HYM8563_MONTH_MASK 0x1f
57+
58+#define HYM8563_YEAR 0x08
59+
60+#define HYM8563_ALM_MIN 0x09
61+#define HYM8563_ALM_HOUR 0x0a
62+#define HYM8563_ALM_DAY 0x0b
63+#define HYM8563_ALM_WEEK 0x0c
64+
65+/* Each alarm check can be disabled by setting this bit in the register */
66+#define HYM8563_ALM_BIT_DISABLE BIT(7)
67+
68+#define HYM8563_CLKOUT 0x0d
69+#define HYM8563_CLKOUT_DISABLE BIT(7)
70+#define HYM8563_CLKOUT_32768 0
71+#define HYM8563_CLKOUT_1024 1
72+#define HYM8563_CLKOUT_32 2
73+#define HYM8563_CLKOUT_1 3
74+#define HYM8563_CLKOUT_MASK 3
75+
76+#define HYM8563_TMR_CTL 0x0e
77+#define HYM8563_TMR_CTL_ENABLE BIT(7)
78+#define HYM8563_TMR_CTL_4096 0
79+#define HYM8563_TMR_CTL_64 1
80+#define HYM8563_TMR_CTL_1 2
81+#define HYM8563_TMR_CTL_1_60 3
82+#define HYM8563_TMR_CTL_MASK 3
83+
84+#define HYM8563_TMR_CNT 0x0f
85+
86+struct hym8563 {
87+ struct i2c_client *client;
88+ struct rtc_device *rtc;
89+ bool valid;
90+#ifdef CONFIG_COMMON_CLK
91+ struct clk_hw clkout_hw;
92+#endif
93+};
94+
95+/*
96+ * RTC handling
97+ */
98+
99+static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
100+{
101+ struct i2c_client *client = to_i2c_client(dev);
102+ struct hym8563 *hym8563 = i2c_get_clientdata(client);
103+ u8 buf[7];
104+ int ret;
105+
106+ if (!hym8563->valid) {
107+ dev_warn(&client->dev, "no valid clock/calendar values available\n");
108+ return -EPERM;
109+ }
110+
111+ ret = i2c_smbus_read_i2c_block_data(client, HYM8563_SEC, 7, buf);
112+
113+ tm->tm_sec = bcd2bin(buf[0] & HYM8563_SEC_MASK);
114+ tm->tm_min = bcd2bin(buf[1] & HYM8563_MIN_MASK);
115+ tm->tm_hour = bcd2bin(buf[2] & HYM8563_HOUR_MASK);
116+ tm->tm_mday = bcd2bin(buf[3] & HYM8563_DAY_MASK);
117+ tm->tm_wday = bcd2bin(buf[4] & HYM8563_WEEKDAY_MASK); /* 0 = Sun */
118+ tm->tm_mon = bcd2bin(buf[5] & HYM8563_MONTH_MASK) - 1; /* 0 = Jan */
119+ tm->tm_year = bcd2bin(buf[6]) + 100;
120+
121+ return 0;
122+}
123+
124+static int hym8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
125+{
126+ struct i2c_client *client = to_i2c_client(dev);
127+ struct hym8563 *hym8563 = i2c_get_clientdata(client);
128+ u8 buf[7];
129+ int ret;
130+
131+ /* Years >= 2100 are to far in the future, 19XX is to early */
132+ if (tm->tm_year < 100 || tm->tm_year >= 200)
133+ return -EINVAL;
134+
135+ buf[0] = bin2bcd(tm->tm_sec);
136+ buf[1] = bin2bcd(tm->tm_min);
137+ buf[2] = bin2bcd(tm->tm_hour);
138+ buf[3] = bin2bcd(tm->tm_mday);
139+ buf[4] = bin2bcd(tm->tm_wday);
140+ buf[5] = bin2bcd(tm->tm_mon + 1);
141+
142+ /*
143+ * While the HYM8563 has a century flag in the month register,
144+ * it does not seem to carry it over a subsequent write/read.
145+ * So we'll limit ourself to 100 years, starting at 2000 for now.
146+ */
147+ buf[6] = tm->tm_year - 100;
148+
149+ /*
150+ * CTL1 only contains TEST-mode bits apart from stop,
151+ * so no need to read the value first
152+ */
153+ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL1,
154+ HYM8563_CTL1_STOP);
155+ if (ret < 0)
156+ return ret;
157+
158+ ret = i2c_smbus_write_i2c_block_data(client, HYM8563_SEC, 7, buf);
159+ if (ret < 0)
160+ return ret;
161+
162+ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL1, 0);
163+ if (ret < 0)
164+ return ret;
165+
166+ hym8563->valid = true;
167+
168+ return 0;
169+}
170+
171+static int hym8563_rtc_alarm_irq_enable(struct device *dev,
172+ unsigned int enabled)
173+{
174+ struct i2c_client *client = to_i2c_client(dev);
175+ int data;
176+
177+ data = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
178+ if (data < 0)
179+ return data;
180+
181+ if (enabled)
182+ data |= HYM8563_CTL2_AIE;
183+ else
184+ data &= ~HYM8563_CTL2_AIE;
185+
186+ return i2c_smbus_write_byte_data(client, HYM8563_CTL2, data);
187+};
188+
189+static int hym8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
190+{
191+ struct i2c_client *client = to_i2c_client(dev);
192+ struct rtc_time *alm_tm = &alm->time;
193+ u8 buf[4];
194+ int ret;
195+
196+ ret = i2c_smbus_read_i2c_block_data(client, HYM8563_ALM_MIN, 4, buf);
197+ if (ret < 0)
198+ return ret;
199+
200+ /* The alarm only has a minute accuracy */
201+ alm_tm->tm_sec = -1;
202+
203+ alm_tm->tm_min = (buf[0] & HYM8563_ALM_BIT_DISABLE) ?
204+ -1 :
205+ bcd2bin(buf[0] & HYM8563_MIN_MASK);
206+ alm_tm->tm_hour = (buf[1] & HYM8563_ALM_BIT_DISABLE) ?
207+ -1 :
208+ bcd2bin(buf[1] & HYM8563_HOUR_MASK);
209+ alm_tm->tm_mday = (buf[2] & HYM8563_ALM_BIT_DISABLE) ?
210+ -1 :
211+ bcd2bin(buf[2] & HYM8563_DAY_MASK);
212+ alm_tm->tm_wday = (buf[3] & HYM8563_ALM_BIT_DISABLE) ?
213+ -1 :
214+ bcd2bin(buf[3] & HYM8563_WEEKDAY_MASK);
215+
216+ alm_tm->tm_mon = -1;
217+ alm_tm->tm_year = -1;
218+
219+ ret = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
220+ if (ret < 0)
221+ return ret;
222+
223+ if (ret & HYM8563_CTL2_AIE)
224+ alm->enabled = 1;
225+
226+ return 0;
227+}
228+
229+static int hym8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
230+{
231+ struct i2c_client *client = to_i2c_client(dev);
232+ struct rtc_time *alm_tm = &alm->time;
233+ u8 buf[4];
234+ int ret;
235+
236+ /*
237+ * The alarm has no seconds so deal with it
238+ */
239+ if (alm_tm->tm_sec) {
240+ alm_tm->tm_sec = 0;
241+ alm_tm->tm_min++;
242+ if (alm_tm->tm_min >= 60) {
243+ alm_tm->tm_min = 0;
244+ alm_tm->tm_hour++;
245+ if (alm_tm->tm_hour >= 24) {
246+ alm_tm->tm_hour = 0;
247+ alm_tm->tm_mday++;
248+ if (alm_tm->tm_mday > 31)
249+ alm_tm->tm_mday = 0;
250+ }
251+ }
252+ }
253+
254+ ret = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
255+ if (ret < 0)
256+ return ret;
257+
258+ ret &= ~HYM8563_CTL2_AIE;
259+
260+ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL2, ret);
261+ if (ret < 0)
262+ return ret;
263+
264+ buf[0] = (alm_tm->tm_min < 60 && alm_tm->tm_min >= 0) ?
265+ bin2bcd(alm_tm->tm_min) : HYM8563_ALM_BIT_DISABLE;
266+
267+ buf[1] = (alm_tm->tm_hour < 24 && alm_tm->tm_hour >= 0) ?
268+ bin2bcd(alm_tm->tm_hour) : HYM8563_ALM_BIT_DISABLE;
269+
270+ buf[2] = (alm_tm->tm_mday <= 31 && alm_tm->tm_mday >= 1) ?
271+ bin2bcd(alm_tm->tm_mday) : HYM8563_ALM_BIT_DISABLE;
272+
273+ buf[3] = (alm_tm->tm_wday < 7 && alm_tm->tm_wday >= 0) ?
274+ bin2bcd(alm_tm->tm_wday) : HYM8563_ALM_BIT_DISABLE;
275+
276+ ret = i2c_smbus_write_i2c_block_data(client, HYM8563_ALM_MIN, 4, buf);
277+ if (ret < 0)
278+ return ret;
279+
280+ return hym8563_rtc_alarm_irq_enable(dev, alm->enabled);
281+}
282+
283+static const struct rtc_class_ops hym8563_rtc_ops = {
284+ .read_time = hym8563_rtc_read_time,
285+ .set_time = hym8563_rtc_set_time,
286+ .alarm_irq_enable = hym8563_rtc_alarm_irq_enable,
287+ .read_alarm = hym8563_rtc_read_alarm,
288+ .set_alarm = hym8563_rtc_set_alarm,
289+};
290+
291+/*
292+ * Handling of the clkout
293+ */
294+
295+#ifdef CONFIG_COMMON_CLK
296+#define clkout_hw_to_hym8563(_hw) container_of(_hw, struct hym8563, clkout_hw)
297+
298+static int clkout_rates[] = {
299+ 32768,
300+ 1024,
301+ 32,
302+ 1,
303+};
304+
305+static unsigned long hym8563_clkout_recalc_rate(struct clk_hw *hw,
306+ unsigned long parent_rate)
307+{
308+ struct hym8563 *hym8563 = clkout_hw_to_hym8563(hw);
309+ struct i2c_client *client = hym8563->client;
310+ int ret = i2c_smbus_read_byte_data(client, HYM8563_CLKOUT);
311+
312+ if (ret < 0 || ret & HYM8563_CLKOUT_DISABLE)
313+ return 0;
314+
315+ ret &= HYM8563_CLKOUT_MASK;
316+ return clkout_rates[ret];
317+}
318+
319+static long hym8563_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
320+ unsigned long *prate)
321+{
322+ int i;
323+
324+ for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
325+ if (clkout_rates[i] <= rate)
326+ return clkout_rates[i];
327+
328+ return 0;
329+}
330+
331+static int hym8563_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
332+ unsigned long parent_rate)
333+{
334+ struct hym8563 *hym8563 = clkout_hw_to_hym8563(hw);
335+ struct i2c_client *client = hym8563->client;
336+ int ret = i2c_smbus_read_byte_data(client, HYM8563_CLKOUT);
337+ int i;
338+
339+ if (ret < 0)
340+ return ret;
341+
342+ for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
343+ if (clkout_rates[i] == rate) {
344+ ret &= ~HYM8563_CLKOUT_MASK;
345+ ret |= i;
346+ return i2c_smbus_write_byte_data(client,
347+ HYM8563_CLKOUT, ret);
348+ }
349+
350+ return -EINVAL;
351+}
352+
353+static int hym8563_clkout_control(struct clk_hw *hw, bool enable)
354+{
355+ struct hym8563 *hym8563 = clkout_hw_to_hym8563(hw);
356+ struct i2c_client *client = hym8563->client;
357+ int ret = i2c_smbus_read_byte_data(client, HYM8563_CLKOUT);
358+
359+ if (ret < 0)
360+ return ret;
361+
362+ if (enable)
363+ ret &= ~HYM8563_CLKOUT_DISABLE;
364+ else
365+ ret |= HYM8563_CLKOUT_DISABLE;
366+
367+ return i2c_smbus_write_byte_data(client, HYM8563_CLKOUT, ret);
368+}
369+
370+static int hym8563_clkout_prepare(struct clk_hw *hw)
371+{
372+ return hym8563_clkout_control(hw, 1);
373+}
374+
375+static void hym8563_clkout_unprepare(struct clk_hw *hw)
376+{
377+ hym8563_clkout_control(hw, 0);
378+}
379+
380+static int hym8563_clkout_is_prepared(struct clk_hw *hw)
381+{
382+ struct hym8563 *hym8563 = clkout_hw_to_hym8563(hw);
383+ struct i2c_client *client = hym8563->client;
384+ int ret = i2c_smbus_read_byte_data(client, HYM8563_CLKOUT);
385+
386+ if (ret < 0)
387+ return ret;
388+
389+ return !(ret & HYM8563_CLKOUT_DISABLE);
390+}
391+
392+static const struct clk_ops hym8563_clkout_ops = {
393+ .prepare = hym8563_clkout_prepare,
394+ .unprepare = hym8563_clkout_unprepare,
395+ .is_prepared = hym8563_clkout_is_prepared,
396+ .recalc_rate = hym8563_clkout_recalc_rate,
397+ .round_rate = hym8563_clkout_round_rate,
398+ .set_rate = hym8563_clkout_set_rate,
399+};
400+
401+static struct clk *hym8563_clkout_register_clk(struct hym8563 *hym8563)
402+{
403+ struct i2c_client *client = hym8563->client;
404+ struct device_node *node = client->dev.of_node;
405+ struct clk *clk;
406+ struct clk_init_data init;
407+ int ret;
408+
409+ ret = i2c_smbus_write_byte_data(client, HYM8563_CLKOUT,
410+ HYM8563_CLKOUT_DISABLE);
411+ if (ret < 0)
412+ return ERR_PTR(ret);
413+
414+ init.name = "hym8563-clkout";
415+ init.ops = &hym8563_clkout_ops;
416+ init.flags = CLK_IS_ROOT;
417+ init.parent_names = NULL;
418+ init.num_parents = 0;
419+ hym8563->clkout_hw.init = &init;
420+
421+ /* register the clock */
422+ clk = clk_register(&client->dev, &hym8563->clkout_hw);
423+
424+ if (!IS_ERR(clk))
425+ of_clk_add_provider(node, of_clk_src_simple_get, clk);
426+
427+ return clk;
428+}
429+#endif
430+
431+/*
432+ * The alarm interrupt is implemented as a level-low interrupt in the
433+ * hym8563, while the timer interrupt uses a falling edge.
434+ * We don't use the timer at all, so the interrupt is requested to
435+ * use the level-low trigger.
436+ */
437+static irqreturn_t hym8563_irq(int irq, void *dev_id)
438+{
439+ struct hym8563 *hym8563 = (struct hym8563 *)dev_id;
440+ struct i2c_client *client = hym8563->client;
441+ struct mutex *lock = &hym8563->rtc->ops_lock;
442+ int data, ret;
443+
444+ mutex_lock(lock);
445+
446+ /* Clear the alarm flag */
447+
448+ data = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
449+ if (data < 0) {
450+ dev_err(&client->dev, "%s: error reading i2c data %d\n",
451+ __func__, data);
452+ goto out;
453+ }
454+
455+ data &= ~HYM8563_CTL2_AF;
456+
457+ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL2, data);
458+ if (ret < 0) {
459+ dev_err(&client->dev, "%s: error writing i2c data %d\n",
460+ __func__, ret);
461+ }
462+
463+out:
464+ mutex_unlock(lock);
465+ return IRQ_HANDLED;
466+}
467+
468+static int hym8563_init_device(struct i2c_client *client)
469+{
470+ int ret;
471+
472+ /* Clear stop flag if present */
473+ ret = i2c_smbus_write_byte_data(client, HYM8563_CTL1, 0);
474+ if (ret < 0)
475+ return ret;
476+
477+ ret = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
478+ if (ret < 0)
479+ return ret;
480+
481+ /* Disable alarm and timer interrupts */
482+ ret &= ~HYM8563_CTL2_AIE;
483+ ret &= ~HYM8563_CTL2_TIE;
484+
485+ /* Clear any pending alarm and timer flags */
486+ if (ret & HYM8563_CTL2_AF)
487+ ret &= ~HYM8563_CTL2_AF;
488+
489+ if (ret & HYM8563_CTL2_TF)
490+ ret &= ~HYM8563_CTL2_TF;
491+
492+ ret &= ~HYM8563_CTL2_TI_TP;
493+
494+ return i2c_smbus_write_byte_data(client, HYM8563_CTL2, ret);
495+}
496+
497+#ifdef CONFIG_PM_SLEEP
498+static int hym8563_suspend(struct device *dev)
499+{
500+ struct i2c_client *client = to_i2c_client(dev);
501+ int ret;
502+
503+ if (device_may_wakeup(dev)) {
504+ ret = enable_irq_wake(client->irq);
505+ if (ret) {
506+ dev_err(dev, "enable_irq_wake failed, %d\n", ret);
507+ return ret;
508+ }
509+ }
510+
511+ return 0;
512+}
513+
514+static int hym8563_resume(struct device *dev)
515+{
516+ struct i2c_client *client = to_i2c_client(dev);
517+
518+ if (device_may_wakeup(dev))
519+ disable_irq_wake(client->irq);
520+
521+ return 0;
522+}
523+#endif
524+
525+static SIMPLE_DEV_PM_OPS(hym8563_pm_ops, hym8563_suspend, hym8563_resume);
526+
527+static int hym8563_probe(struct i2c_client *client,
528+ const struct i2c_device_id *id)
529+{
530+ struct hym8563 *hym8563;
531+ int ret;
532+
533+ hym8563 = devm_kzalloc(&client->dev, sizeof(*hym8563), GFP_KERNEL);
534+ if (!hym8563)
535+ return -ENOMEM;
536+
537+ hym8563->client = client;
538+ i2c_set_clientdata(client, hym8563);
539+
540+ device_set_wakeup_capable(&client->dev, true);
541+
542+ ret = hym8563_init_device(client);
543+ if (ret) {
544+ dev_err(&client->dev, "could not init device, %d\n", ret);
545+ return ret;
546+ }
547+
548+ ret = devm_request_threaded_irq(&client->dev, client->irq,
549+ NULL, hym8563_irq,
550+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
551+ client->name, hym8563);
552+ if (ret < 0) {
553+ dev_err(&client->dev, "irq %d request failed, %d\n",
554+ client->irq, ret);
555+ return ret;
556+ }
557+
558+ /* check state of calendar information */
559+ ret = i2c_smbus_read_byte_data(client, HYM8563_SEC);
560+ if (ret < 0)
561+ return ret;
562+
563+ hym8563->valid = !(ret & HYM8563_SEC_VL);
564+ dev_dbg(&client->dev, "rtc information is %s\n",
565+ hym8563->valid ? "valid" : "invalid");
566+
567+ hym8563->rtc = devm_rtc_device_register(&client->dev, client->name,
568+ &hym8563_rtc_ops, THIS_MODULE);
569+ if (IS_ERR(hym8563->rtc))
570+ return PTR_ERR(hym8563->rtc);
571+
572+#ifdef CONFIG_COMMON_CLK
573+ hym8563_clkout_register_clk(hym8563);
574+#endif
575+
576+ return 0;
577+}
578+
579+static const struct i2c_device_id hym8563_id[] = {
580+ { "hym8563", 0 },
581+ {},
582+};
583+MODULE_DEVICE_TABLE(i2c, hym8563_id);
584+
585+static struct of_device_id hym8563_dt_idtable[] = {
586+ { .compatible = "haoyu,hym8563" },
587+ {},
588+};
589+MODULE_DEVICE_TABLE(of, hym8563_dt_idtable);
590+
591+static struct i2c_driver hym8563_driver = {
592+ .driver = {
593+ .name = "rtc-hym8563",
594+ .owner = THIS_MODULE,
595+ .pm = &hym8563_pm_ops,
596+ .of_match_table = hym8563_dt_idtable,
597+ },
598+ .probe = hym8563_probe,
599+ .id_table = hym8563_id,
600+};
601+
602+module_i2c_driver(hym8563_driver);
603+
604+MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
605+MODULE_DESCRIPTION("HYM8563 RTC driver");
606+MODULE_LICENSE("GPL");
drivers/rtc/rtc-max8907.c+5−6
@@ -51,7 +51,7 @@ static irqreturn_t max8907_irq_handler(int irq, void *data) · 50 unmodified lines
5151 {
5252 struct max8907_rtc *rtc = data;
5353
54− regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0);
54+ regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0);
5555
5656 rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF);
5757
@@ -64,7 +64,7 @@ static void regs_to_tm(u8 *regs, struct rtc_time *tm) · 6 unmodified lines
6464 bcd2bin(regs[RTC_YEAR1]) - 1900;
6565 tm->tm_mon = bcd2bin(regs[RTC_MONTH] & 0x1f) - 1;
6666 tm->tm_mday = bcd2bin(regs[RTC_DATE] & 0x3f);
67− tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07) - 1;
67+ tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07);
6868 if (regs[RTC_HOUR] & HOUR_12) {
6969 tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x01f);
7070 if (tm->tm_hour == 12)
@@ -88,7 +88,7 @@ static void tm_to_regs(struct rtc_time *tm, u8 *regs) · 17 unmodified lines
8888 regs[RTC_YEAR1] = bin2bcd(low);
8989 regs[RTC_MONTH] = bin2bcd(tm->tm_mon + 1);
9090 regs[RTC_DATE] = bin2bcd(tm->tm_mday);
91− regs[RTC_WEEKDAY] = tm->tm_wday + 1;
91+ regs[RTC_WEEKDAY] = tm->tm_wday;
9292 regs[RTC_HOUR] = bin2bcd(tm->tm_hour);
9393 regs[RTC_MIN] = bin2bcd(tm->tm_min);
9494 regs[RTC_SEC] = bin2bcd(tm->tm_sec);
@@ -153,7 +153,7 @@ static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) · 58 unmodified lines
153153 tm_to_regs(&alrm->time, regs);
154154
155155 /* Disable alarm while we update the target time */
156− ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0);
156+ ret = regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0);
157157 if (ret < 0)
158158 return ret;
159159
@@ -163,8 +163,7 @@ static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) · 3 unmodified lines
163163 return ret;
164164
165165 if (alrm->enabled)
166− ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL,
167− 0x7f, 0x7f);
166+ ret = regmap_write(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x77);
168167
169168 return ret;
170169 }
drivers/rtc/rtc-mxc.c+5−5
@@ -391,11 +391,13 @@ static int mxc_rtc_probe(struct platform_device *pdev) · 390 unmodified lines
391391 pdata->clk = devm_clk_get(&pdev->dev, NULL);
392392 if (IS_ERR(pdata->clk)) {
393393 dev_err(&pdev->dev, "unable to get clock!\n");
394− ret = PTR_ERR(pdata->clk);
395− goto exit_free_pdata;
394+ return PTR_ERR(pdata->clk);
396395 }
397396
398− clk_prepare_enable(pdata->clk);
397+ ret = clk_prepare_enable(pdata->clk);
398+ if (ret)
399+ return ret;
400+
399401 rate = clk_get_rate(pdata->clk);
400402
401403 if (rate == 32768)
@@ -447,8 +449,6 @@ static int mxc_rtc_probe(struct platform_device *pdev) · 45 unmodified lines
447449 exit_put_clk:
448450 clk_disable_unprepare(pdata->clk);
449451
450−exit_free_pdata:
451−
452452 return ret;
453453 }
454454
drivers/rtc/rtc-pcf2127.c+1−4
@@ -197,10 +197,7 @@ static int pcf2127_probe(struct i2c_client *client, · 196 unmodified lines
197197 pcf2127_driver.driver.name,
198198 &pcf2127_rtc_ops, THIS_MODULE);
199199
200− if (IS_ERR(pcf2127->rtc))
201− return PTR_ERR(pcf2127->rtc);
202−
203− return 0;
200+ return PTR_ERR_OR_ZERO(pcf2127->rtc);
204201 }
205202
206203 static const struct i2c_device_id pcf2127_id[] = {
drivers/rtc/rtc-rx8581.c+68−13
@@ -52,8 +52,45 @@ · 51 unmodified lines
5252 #define RX8581_CTRL_STOP 0x02 /* STOP bit */
5353 #define RX8581_CTRL_RESET 0x01 /* RESET bit */
5454
55+struct rx8581 {
56+ struct i2c_client *client;
57+ struct rtc_device *rtc;
58+ s32 (*read_block_data)(const struct i2c_client *client, u8 command,
59+ u8 length, u8 *values);
60+ s32 (*write_block_data)(const struct i2c_client *client, u8 command,
61+ u8 length, const u8 *values);
62+};
63+
5564 static struct i2c_driver rx8581_driver;
5665
66+static int rx8581_read_block_data(const struct i2c_client *client, u8 command,
67+ u8 length, u8 *values)
68+{
69+ s32 i, data;
70+
71+ for (i = 0; i < length; i++) {
72+ data = i2c_smbus_read_byte_data(client, command + i);
73+ if (data < 0)
74+ return data;
75+ values[i] = data;
76+ }
77+ return i;
78+}
79+
80+static int rx8581_write_block_data(const struct i2c_client *client, u8 command,
81+ u8 length, const u8 *values)
82+{
83+ s32 i, ret;
84+
85+ for (i = 0; i < length; i++) {
86+ ret = i2c_smbus_write_byte_data(client, command + i,
87+ values[i]);
88+ if (ret < 0)
89+ return ret;
90+ }
91+ return length;
92+}
93+
5794 /*
5895 * In the routines that deal directly with the rx8581 hardware, we use
5996 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
@@ -62,6 +99,7 @@ static int rx8581_get_datetime(struct i2c_client *client, struct rtc_time *tm) · 2 unmodified lines
6299 {
63100 unsigned char date[7];
64101 int data, err;
102+ struct rx8581 *rx8581 = i2c_get_clientdata(client);
65103
66104 /* First we ensure that the "update flag" is not set, we read the
67105 * time and date then re-read the "update flag". If the update flag
@@ -80,14 +118,13 @@ static int rx8581_get_datetime(struct i2c_client *client, struct rtc_time *tm) · 12 unmodified lines
80118 err = i2c_smbus_write_byte_data(client,
81119 RX8581_REG_FLAG, (data & ~RX8581_FLAG_UF));
82120 if (err != 0) {
83− dev_err(&client->dev, "Unable to write device "
84− "flags\n");
121+ dev_err(&client->dev, "Unable to write device flags\n");
85122 return -EIO;
86123 }
87124 }
88125
89126 /* Now read time and date */
90− err = i2c_smbus_read_i2c_block_data(client, RX8581_REG_SC,
127+ err = rx8581->read_block_data(client, RX8581_REG_SC,
91128 7, date);
92129 if (err < 0) {
93130 dev_err(&client->dev, "Unable to read date\n");
@@ -140,6 +177,7 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm) · 46 unmodified lines
140177 {
141178 int data, err;
142179 unsigned char buf[7];
180+ struct rx8581 *rx8581 = i2c_get_clientdata(client);
143181
144182 dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "
145183 "mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -176,7 +214,7 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm) · 30 unmodified lines
176214 }
177215
178216 /* write register's data */
179− err = i2c_smbus_write_i2c_block_data(client, RX8581_REG_SC, 7, buf);
217+ err = rx8581->write_block_data(client, RX8581_REG_SC, 7, buf);
180218 if (err < 0) {
181219 dev_err(&client->dev, "Unable to write to date registers\n");
182220 return -EIO;
@@ -231,22 +269,39 @@ static const struct rtc_class_ops rx8581_rtc_ops = { · 48 unmodified lines
231269 static int rx8581_probe(struct i2c_client *client,
232270 const struct i2c_device_id *id)
233271 {
234− struct rtc_device *rtc;
272+ struct rx8581 *rx8581;
235273
236274 dev_dbg(&client->dev, "%s\n", __func__);
237275
238− if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
239− return -ENODEV;
276+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)
277+ && !i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
278+ return -EIO;
240279
241− dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
280+ rx8581 = devm_kzalloc(&client->dev, sizeof(struct rx8581), GFP_KERNEL);
281+ if (!rx8581)
282+ return -ENOMEM;
242283
243− rtc = devm_rtc_device_register(&client->dev, rx8581_driver.driver.name,
244− &rx8581_rtc_ops, THIS_MODULE);
284+ i2c_set_clientdata(client, rx8581);
285+ rx8581->client = client;
245286
246− if (IS_ERR(rtc))
247− return PTR_ERR(rtc);
287+ if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
288+ rx8581->read_block_data = i2c_smbus_read_i2c_block_data;
289+ rx8581->write_block_data = i2c_smbus_write_i2c_block_data;
290+ } else {
291+ rx8581->read_block_data = rx8581_read_block_data;
292+ rx8581->write_block_data = rx8581_write_block_data;
293+ }
248294
249− i2c_set_clientdata(client, rtc);
295+ dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
296+
297+ rx8581->rtc = devm_rtc_device_register(&client->dev,
298+ rx8581_driver.driver.name, &rx8581_rtc_ops, THIS_MODULE);
299+
300+ if (IS_ERR(rx8581->rtc)) {
301+ dev_err(&client->dev,
302+ "unable to register the class device\n");
303+ return PTR_ERR(rx8581->rtc);
304+ }
250305
251306 return 0;
252307 }
drivers/rtc/rtc-s5m.c+2−0
@@ -639,6 +639,7 @@ static void s5m_rtc_shutdown(struct platform_device *pdev) · 638 unmodified lines
639639 s5m_rtc_enable_smpl(info, false);
640640 }
641641
642+#ifdef CONFIG_PM_SLEEP
642643 static int s5m_rtc_resume(struct device *dev)
643644 {
644645 struct s5m_rtc_info *info = dev_get_drvdata(dev);
@@ -660,6 +661,7 @@ static int s5m_rtc_suspend(struct device *dev) · 15 unmodified lines
660661
661662 return ret;
662663 }
664+#endif /* CONFIG_PM_SLEEP */
663665
664666 static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops, s5m_rtc_suspend, s5m_rtc_resume);
665667
drivers/rtc/rtc-twl.c+13−25
@@ -479,7 +479,7 @@ static int twl_rtc_probe(struct platform_device *pdev) · 478 unmodified lines
479479 u8 rd_reg;
480480
481481 if (irq <= 0)
482− goto out1;
482+ return ret;
483483
484484 /* Initialize the register map */
485485 if (twl_class_is_4030())
@@ -489,7 +489,7 @@ static int twl_rtc_probe(struct platform_device *pdev) · 3 unmodified lines
489489
490490 ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
491491 if (ret < 0)
492− goto out1;
492+ return ret;
493493
494494 if (rd_reg & BIT_RTC_STATUS_REG_POWER_UP_M)
495495 dev_warn(&pdev->dev, "Power up reset detected.\n");
@@ -500,7 +500,7 @@ static int twl_rtc_probe(struct platform_device *pdev) · 4 unmodified lines
500500 /* Clear RTC Power up reset and pending alarm interrupts */
501501 ret = twl_rtc_write_u8(rd_reg, REG_RTC_STATUS_REG);
502502 if (ret < 0)
503− goto out1;
503+ return ret;
504504
505505 if (twl_class_is_6030()) {
506506 twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
@@ -512,7 +512,7 @@ static int twl_rtc_probe(struct platform_device *pdev) · 5 unmodified lines
512512 dev_info(&pdev->dev, "Enabling TWL-RTC\n");
513513 ret = twl_rtc_write_u8(BIT_RTC_CTRL_REG_STOP_RTC_M, REG_RTC_CTRL_REG);
514514 if (ret < 0)
515− goto out1;
515+ return ret;
516516
517517 /* ensure interrupts are disabled, bootloaders can be strange */
518518 ret = twl_rtc_write_u8(0, REG_RTC_INTERRUPTS_REG);
@@ -522,34 +522,29 @@ static int twl_rtc_probe(struct platform_device *pdev) · 3 unmodified lines
522522 /* init cached IRQ enable bits */
523523 ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
524524 if (ret < 0)
525− goto out1;
525+ return ret;
526526
527527 device_init_wakeup(&pdev->dev, 1);
528528
529− rtc = rtc_device_register(pdev->name,
530− &pdev->dev, &twl_rtc_ops, THIS_MODULE);
529+ rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
530+ &twl_rtc_ops, THIS_MODULE);
531531 if (IS_ERR(rtc)) {
532− ret = PTR_ERR(rtc);
533532 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
534533 PTR_ERR(rtc));
535− goto out1;
534+ return PTR_ERR(rtc);
536535 }
537536
538− ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt,
539− IRQF_TRIGGER_RISING | IRQF_ONESHOT,
540− dev_name(&rtc->dev), rtc);
537+ ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
538+ twl_rtc_interrupt,
539+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
540+ dev_name(&rtc->dev), rtc);
541541 if (ret < 0) {
542542 dev_err(&pdev->dev, "IRQ is not free.\n");
543− goto out2;
543+ return ret;
544544 }
545545
546546 platform_set_drvdata(pdev, rtc);
547547 return 0;
548−
549−out2:
550− rtc_device_unregister(rtc);
551−out1:
552− return ret;
553548 }
554549
555550 /*
@@ -559,9 +554,6 @@ out1: · 3 unmodified lines
559554 static int twl_rtc_remove(struct platform_device *pdev)
560555 {
561556 /* leave rtc running, but disable irqs */
562− struct rtc_device *rtc = platform_get_drvdata(pdev);
563− int irq = platform_get_irq(pdev, 0);
564−
565557 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
566558 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
567559 if (twl_class_is_6030()) {
@@ -571,10 +563,6 @@ static int twl_rtc_remove(struct platform_device *pdev) · 3 unmodified lines
571563 REG_INT_MSK_STS_A);
572564 }
573565
574−
575− free_irq(irq, rtc);
576−
577− rtc_device_unregister(rtc);
578566 return 0;
579567 }
580568
drivers/rtc/rtc-vr41xx.c+12−38
@@ -293,7 +293,7 @@ static int rtc_probe(struct platform_device *pdev) · 292 unmodified lines
293293 if (!res)
294294 return -EBUSY;
295295
296− rtc1_base = ioremap(res->start, resource_size(res));
296+ rtc1_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
297297 if (!rtc1_base)
298298 return -EBUSY;
299299
@@ -303,13 +303,14 @@ static int rtc_probe(struct platform_device *pdev) · 3 unmodified lines
303303 goto err_rtc1_iounmap;
304304 }
305305
306− rtc2_base = ioremap(res->start, resource_size(res));
306+ rtc2_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
307307 if (!rtc2_base) {
308308 retval = -EBUSY;
309309 goto err_rtc1_iounmap;
310310 }
311311
312− rtc = rtc_device_register(rtc_name, &pdev->dev, &vr41xx_rtc_ops, THIS_MODULE);
312+ rtc = devm_rtc_device_register(&pdev->dev, rtc_name, &vr41xx_rtc_ops,
313+ THIS_MODULE);
313314 if (IS_ERR(rtc)) {
314315 retval = PTR_ERR(rtc);
315316 goto err_iounmap_all;
@@ -330,24 +331,24 @@ static int rtc_probe(struct platform_device *pdev) · 14 unmodified lines
330331 aie_irq = platform_get_irq(pdev, 0);
331332 if (aie_irq <= 0) {
332333 retval = -EBUSY;
333− goto err_device_unregister;
334+ goto err_iounmap_all;
334335 }
335336
336− retval = request_irq(aie_irq, elapsedtime_interrupt, 0,
337− "elapsed_time", pdev);
337+ retval = devm_request_irq(&pdev->dev, aie_irq, elapsedtime_interrupt, 0,
338+ "elapsed_time", pdev);
338339 if (retval < 0)
339− goto err_device_unregister;
340+ goto err_iounmap_all;
340341
341342 pie_irq = platform_get_irq(pdev, 1);
342343 if (pie_irq <= 0) {
343344 retval = -EBUSY;
344− goto err_free_irq;
345+ goto err_iounmap_all;
345346 }
346347
347− retval = request_irq(pie_irq, rtclong1_interrupt, 0,
348− "rtclong1", pdev);
348+ retval = devm_request_irq(&pdev->dev, pie_irq, rtclong1_interrupt, 0,
349+ "rtclong1", pdev);
349350 if (retval < 0)
350− goto err_free_irq;
351+ goto err_iounmap_all;
351352
352353 platform_set_drvdata(pdev, rtc);
353354
@@ -358,47 +359,20 @@ static int rtc_probe(struct platform_device *pdev) · 4 unmodified lines
358359
359360 return 0;
360361
361−err_free_irq:
362− free_irq(aie_irq, pdev);
363−
364−err_device_unregister:
365− rtc_device_unregister(rtc);
366−
367362 err_iounmap_all:
368− iounmap(rtc2_base);
369363 rtc2_base = NULL;
370364
371365 err_rtc1_iounmap:
372− iounmap(rtc1_base);
373366 rtc1_base = NULL;
374367
375368 return retval;
376369 }
377370
378−static int rtc_remove(struct platform_device *pdev)
379−{
380− struct rtc_device *rtc;
381−
382− rtc = platform_get_drvdata(pdev);
383− if (rtc)
384− rtc_device_unregister(rtc);
385−
386− free_irq(aie_irq, pdev);
387− free_irq(pie_irq, pdev);
388− if (rtc1_base)
389− iounmap(rtc1_base);
390− if (rtc2_base)
391− iounmap(rtc2_base);
392−
393− return 0;
394−}
395−
396371 /* work with hotplug and coldplug */
397372 MODULE_ALIAS("platform:RTC");
398373
399374 static struct platform_driver rtc_platform_driver = {
400375 .probe = rtc_probe,
401− .remove = rtc_remove,
402376 .driver = {
403377 .name = rtc_name,
404378 .owner = THIS_MODULE,
drivers/video/aty/aty128fb.c+4−0
@@ -357,11 +357,13 @@ static int default_lcd_on = 1; · 356 unmodified lines
357357 static bool mtrr = true;
358358 #endif
359359
360+#ifdef CONFIG_FB_ATY128_BACKLIGHT
360361 #ifdef CONFIG_PMAC_BACKLIGHT
361362 static int backlight = 1;
362363 #else
363364 static int backlight = 0;
364365 #endif
366+#endif
365367
366368 /* PLL constants */
367369 struct aty128_constants {
@@ -1671,7 +1673,9 @@ static int aty128fb_setup(char *options) · 1303 unmodified lines
16711673 default_crt_on = simple_strtoul(this_opt+4, NULL, 0);
16721674 continue;
16731675 } else if (!strncmp(this_opt, "backlight:", 10)) {
1676+#ifdef CONFIG_FB_ATY128_BACKLIGHT
16741677 backlight = simple_strtoul(this_opt+10, NULL, 0);
1678+#endif
16751679 continue;
16761680 }
16771681 #ifdef CONFIG_MTRR
drivers/video/backlight/hp680_bl.c+2−4
@@ -110,8 +110,8 @@ static int hp680bl_probe(struct platform_device *pdev) · 109 unmodified lines
110110 memset(&props, 0, sizeof(struct backlight_properties));
111111 props.type = BACKLIGHT_RAW;
112112 props.max_brightness = HP680_MAX_INTENSITY;
113− bd = backlight_device_register("hp680-bl", &pdev->dev, NULL,
114− &hp680bl_ops, &props);
113+ bd = devm_backlight_device_register(&pdev->dev, "hp680-bl", &pdev->dev,
114+ NULL, &hp680bl_ops, &props);
115115 if (IS_ERR(bd))
116116 return PTR_ERR(bd);
117117
@@ -131,8 +131,6 @@ static int hp680bl_remove(struct platform_device *pdev) · 13 unmodified lines
131131 bd->props.power = 0;
132132 hp680bl_send_intensity(bd);
133133
134− backlight_device_unregister(bd);
135−
136134 return 0;
137135 }
138136
drivers/video/backlight/jornada720_bl.c+3−12
@@ -115,9 +115,10 @@ static int jornada_bl_probe(struct platform_device *pdev) · 114 unmodified lines
115115 memset(&props, 0, sizeof(struct backlight_properties));
116116 props.type = BACKLIGHT_RAW;
117117 props.max_brightness = BL_MAX_BRIGHT;
118− bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL,
119− &jornada_bl_ops, &props);
120118
119+ bd = devm_backlight_device_register(&pdev->dev, S1D_DEVICENAME,
120+ &pdev->dev, NULL, &jornada_bl_ops,
121+ &props);
121122 if (IS_ERR(bd)) {
122123 ret = PTR_ERR(bd);
123124 dev_err(&pdev->dev, "failed to register device, err=%x\n", ret);
@@ -139,18 +140,8 @@ static int jornada_bl_probe(struct platform_device *pdev) · 15 unmodified lines
139140 return 0;
140141 }
141142
142−static int jornada_bl_remove(struct platform_device *pdev)
143−{
144− struct backlight_device *bd = platform_get_drvdata(pdev);
145−
146− backlight_device_unregister(bd);
147−
148− return 0;
149−}
150−
151143 static struct platform_driver jornada_bl_driver = {
152144 .probe = jornada_bl_probe,
153− .remove = jornada_bl_remove,
154145 .driver = {
155146 .name = "jornada_bl",
156147 },
drivers/video/backlight/jornada720_lcd.c+2−11
@@ -100,7 +100,8 @@ static int jornada_lcd_probe(struct platform_device *pdev) · 99 unmodified lines
100100 struct lcd_device *lcd_device;
101101 int ret;
102102
103− lcd_device = lcd_device_register(S1D_DEVICENAME, &pdev->dev, NULL, &jornada_lcd_props);
103+ lcd_device = devm_lcd_device_register(&pdev->dev, S1D_DEVICENAME,
104+ &pdev->dev, NULL, &jornada_lcd_props);
104105
105106 if (IS_ERR(lcd_device)) {
106107 ret = PTR_ERR(lcd_device);
@@ -119,18 +120,8 @@ static int jornada_lcd_probe(struct platform_device *pdev) · 12 unmodified lines
119120 return 0;
120121 }
121122
122−static int jornada_lcd_remove(struct platform_device *pdev)
123−{
124− struct lcd_device *lcd_device = platform_get_drvdata(pdev);
125−
126− lcd_device_unregister(lcd_device);
127−
128− return 0;
129−}
130−
131123 static struct platform_driver jornada_lcd_driver = {
132124 .probe = jornada_lcd_probe,
133− .remove = jornada_lcd_remove,
134125 .driver = {
135126 .name = "jornada_lcd",
136127 },
drivers/video/backlight/kb3886_bl.c+1−1
@@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo; · 77 unmodified lines
7878 static unsigned long kb3886bl_flags;
7979 #define KB3886BL_SUSPENDED 0x01
8080
81−static struct dmi_system_id __initdata kb3886bl_device_table[] = {
81+static struct dmi_system_id kb3886bl_device_table[] __initdata = {
8282 {
8383 .ident = "Sahara Touch-iT",
8484 .matches = {
drivers/video/backlight/l4f00242t03.c+2−4
@@ -223,8 +223,8 @@ static int l4f00242t03_probe(struct spi_device *spi) · 222 unmodified lines
223223 return PTR_ERR(priv->core_reg);
224224 }
225225
226− priv->ld = lcd_device_register("l4f00242t03",
227− &spi->dev, priv, &l4f_ops);
226+ priv->ld = devm_lcd_device_register(&spi->dev, "l4f00242t03", &spi->dev,
227+ priv, &l4f_ops);
228228 if (IS_ERR(priv->ld))
229229 return PTR_ERR(priv->ld);
230230
@@ -243,8 +243,6 @@ static int l4f00242t03_remove(struct spi_device *spi) · 12 unmodified lines
243243 struct l4f00242t03_priv *priv = spi_get_drvdata(spi);
244244
245245 l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN);
246− lcd_device_unregister(priv->ld);
247−
248246 return 0;
249247 }
250248
drivers/video/backlight/lp855x_bl.c+1−1
@@ -125,7 +125,7 @@ static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr) · 124 unmodified lines
125125 return false;
126126 }
127127
128− return (addr >= start && addr <= end);
128+ return addr >= start && addr <= end;
129129 }
130130
131131 static int lp8557_bl_off(struct lp855x *lp)
drivers/video/backlight/lp8788_bl.c+3−3
@@ -63,13 +63,13 @@ static struct lp8788_bl_config default_bl_config = { · 62 unmodified lines
6363
6464 static inline bool is_brightness_ctrl_by_pwm(enum lp8788_bl_ctrl_mode mode)
6565 {
66− return (mode == LP8788_BL_COMB_PWM_BASED);
66+ return mode == LP8788_BL_COMB_PWM_BASED;
6767 }
6868
6969 static inline bool is_brightness_ctrl_by_register(enum lp8788_bl_ctrl_mode mode)
7070 {
71− return (mode == LP8788_BL_REGISTER_ONLY ||
72− mode == LP8788_BL_COMB_REGISTER_BASED);
71+ return mode == LP8788_BL_REGISTER_ONLY ||
72+ mode == LP8788_BL_COMB_REGISTER_BASED;
7373 }
7474
7575 static int lp8788_backlight_configure(struct lp8788_bl *bl)
drivers/video/backlight/omap1_bl.c+2−12
@@ -146,8 +146,8 @@ static int omapbl_probe(struct platform_device *pdev) · 145 unmodified lines
146146 memset(&props, 0, sizeof(struct backlight_properties));
147147 props.type = BACKLIGHT_RAW;
148148 props.max_brightness = OMAPBL_MAX_INTENSITY;
149− dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops,
150− &props);
149+ dev = devm_backlight_device_register(&pdev->dev, "omap-bl", &pdev->dev,
150+ bl, &omapbl_ops, &props);
151151 if (IS_ERR(dev))
152152 return PTR_ERR(dev);
153153
@@ -170,20 +170,10 @@ static int omapbl_probe(struct platform_device *pdev) · 16 unmodified lines
170170 return 0;
171171 }
172172
173−static int omapbl_remove(struct platform_device *pdev)
174−{
175− struct backlight_device *dev = platform_get_drvdata(pdev);
176−
177− backlight_device_unregister(dev);
178−
179− return 0;
180−}
181−
182173 static SIMPLE_DEV_PM_OPS(omapbl_pm_ops, omapbl_suspend, omapbl_resume);
183174
184175 static struct platform_driver omapbl_driver = {
185176 .probe = omapbl_probe,
186− .remove = omapbl_remove,
187177 .driver = {
188178 .name = "omap-bl",
189179 .pm = &omapbl_pm_ops,
drivers/video/backlight/ot200_bl.c+3−6
@@ -118,8 +118,9 @@ static int ot200_backlight_probe(struct platform_device *pdev) · 117 unmodified lines
118118 props.brightness = 100;
119119 props.type = BACKLIGHT_RAW;
120120
121− bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, data,
122− &ot200_backlight_ops, &props);
121+ bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev),
122+ &pdev->dev, data, &ot200_backlight_ops,
123+ &props);
123124 if (IS_ERR(bl)) {
124125 dev_err(&pdev->dev, "failed to register backlight\n");
125126 retval = PTR_ERR(bl);
@@ -137,10 +138,6 @@ error_devm_kzalloc: · 11 unmodified lines
137138
138139 static int ot200_backlight_remove(struct platform_device *pdev)
139140 {
140− struct backlight_device *bl = platform_get_drvdata(pdev);
141−
142− backlight_device_unregister(bl);
143−
144141 /* on module unload set brightness to 100% */
145142 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0);
146143 cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
drivers/video/backlight/tosa_bl.c+3−4
@@ -105,8 +105,9 @@ static int tosa_bl_probe(struct i2c_client *client, · 104 unmodified lines
105105 memset(&props, 0, sizeof(struct backlight_properties));
106106 props.type = BACKLIGHT_RAW;
107107 props.max_brightness = 512 - 1;
108− data->bl = backlight_device_register("tosa-bl", &client->dev, data,
109− &bl_ops, &props);
108+ data->bl = devm_backlight_device_register(&client->dev, "tosa-bl",
109+ &client->dev, data, &bl_ops,
110+ &props);
110111 if (IS_ERR(data->bl)) {
111112 ret = PTR_ERR(data->bl);
112113 goto err_reg;
@@ -128,9 +129,7 @@ static int tosa_bl_remove(struct i2c_client *client) · 15 unmodified lines
128129 {
129130 struct tosa_bl_data *data = i2c_get_clientdata(client);
130131
131− backlight_device_unregister(data->bl);
132132 data->bl = NULL;
133−
134133 return 0;
135134 }
136135
drivers/video/backlight/tosa_lcd.c+2−4
@@ -206,8 +206,8 @@ static int tosa_lcd_probe(struct spi_device *spi) · 205 unmodified lines
206206
207207 tosa_lcd_tg_on(data);
208208
209− data->lcd = lcd_device_register("tosa-lcd", &spi->dev, data,
210− &tosa_lcd_ops);
209+ data->lcd = devm_lcd_device_register(&spi->dev, "tosa-lcd", &spi->dev,
210+ data, &tosa_lcd_ops);
211211
212212 if (IS_ERR(data->lcd)) {
213213 ret = PTR_ERR(data->lcd);
@@ -226,8 +226,6 @@ static int tosa_lcd_remove(struct spi_device *spi) · 12 unmodified lines
226226 {
227227 struct tosa_lcd_data *data = spi_get_drvdata(spi);
228228
229− lcd_device_unregister(data->lcd);
230−
231229 if (data->i2c)
232230 i2c_unregister_device(data->i2c);
233231
drivers/vlynq/vlynq.c+2−1
@@ -762,7 +762,8 @@ static int vlynq_remove(struct platform_device *pdev) · 761 unmodified lines
762762
763763 device_unregister(&dev->dev);
764764 iounmap(dev->local);
765− release_mem_region(dev->regs_start, dev->regs_end - dev->regs_start);
765+ release_mem_region(dev->regs_start,
766+ dev->regs_end - dev->regs_start + 1);
766767
767768 kfree(dev);
768769
drivers/w1/masters/w1-gpio.c+22−0
@@ -18,10 +18,31 @@ · 17 unmodified lines
1818 #include <linux/of_gpio.h>
1919 #include <linux/err.h>
2020 #include <linux/of.h>
21+#include <linux/delay.h>
2122
2223 #include "../w1.h"
2324 #include "../w1_int.h"
2425
26+static u8 w1_gpio_set_pullup(void *data, int delay)
27+{
28+ struct w1_gpio_platform_data *pdata = data;
29+
30+ if (delay) {
31+ pdata->pullup_duration = delay;
32+ } else {
33+ if (pdata->pullup_duration) {
34+ gpio_direction_output(pdata->pin, 1);
35+
36+ msleep(pdata->pullup_duration);
37+
38+ gpio_direction_input(pdata->pin);
39+ }
40+ pdata->pullup_duration = 0;
41+ }
42+
43+ return 0;
44+}
45+
2546 static void w1_gpio_write_bit_dir(void *data, u8 bit)
2647 {
2748 struct w1_gpio_platform_data *pdata = data;
@@ -132,6 +153,7 @@ static int w1_gpio_probe(struct platform_device *pdev) · 104 unmodified lines
132153 } else {
133154 gpio_direction_input(pdata->pin);
134155 master->write_bit = w1_gpio_write_bit_dir;
156+ master->set_pullup = w1_gpio_set_pullup;
135157 }
136158
137159 err = w1_add_master_device(master);
drivers/w1/w1_int.c+0−12
@@ -117,18 +117,6 @@ int w1_add_master_device(struct w1_bus_master *master) · 116 unmodified lines
117117 printk(KERN_ERR "w1_add_master_device: invalid function set\n");
118118 return(-EINVAL);
119119 }
120− /* While it would be electrically possible to make a device that
121− * generated a strong pullup in bit bang mode, only hardware that
122− * controls 1-wire time frames are even expected to support a strong
123− * pullup. w1_io.c would need to support calling set_pullup before
124− * the last write_bit operation of a w1_write_8 which it currently
125− * doesn't.
126− */
127− if (!master->write_byte && !master->touch_bit && master->set_pullup) {
128− printk(KERN_ERR "w1_add_master_device: set_pullup requires "
129− "write_byte or touch_bit, disabling\n");
130− master->set_pullup = NULL;
131− }
132120
133121 /* Lock until the device is added (or not) to w1_masters. */
134122 mutex_lock(&w1_mlock);
fs/autofs4/autofs_i.h+2−2
@@ -104,7 +104,7 @@ struct autofs_sb_info { · 103 unmodified lines
104104 u32 magic;
105105 int pipefd;
106106 struct file *pipe;
107− pid_t oz_pgrp;
107+ struct pid *oz_pgrp;
108108 int catatonic;
109109 int version;
110110 int sub_version;
@@ -140,7 +140,7 @@ static inline struct autofs_info *autofs4_dentry_ino(struct dentry *dentry) · 29 unmodified lines
140140 filesystem without "magic".) */
141141
142142 static inline int autofs4_oz_mode(struct autofs_sb_info *sbi) {
143− return sbi->catatonic || task_pgrp_nr(current) == sbi->oz_pgrp;
143+ return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp;
144144 }
145145
146146 /* Does a dentry have some pending activity? */
fs/autofs4/dev-ioctl.c+14−2
@@ -346,6 +346,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp, · 345 unmodified lines
346346 {
347347 int pipefd;
348348 int err = 0;
349+ struct pid *new_pid = NULL;
349350
350351 if (param->setpipefd.pipefd == -1)
351352 return -EINVAL;
@@ -357,7 +358,17 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp, · 5 unmodified lines
357358 mutex_unlock(&sbi->wq_mutex);
358359 return -EBUSY;
359360 } else {
360− struct file *pipe = fget(pipefd);
361+ struct file *pipe;
362+
363+ new_pid = get_task_pid(current, PIDTYPE_PGID);
364+
365+ if (ns_of_pid(new_pid) != ns_of_pid(sbi->oz_pgrp)) {
366+ AUTOFS_WARN("Not allowed to change PID namespace");
367+ err = -EINVAL;
368+ goto out;
369+ }
370+
371+ pipe = fget(pipefd);
361372 if (!pipe) {
362373 err = -EBADF;
363374 goto out;
@@ -367,12 +378,13 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp, · 3 unmodified lines
367378 fput(pipe);
368379 goto out;
369380 }
370− sbi->oz_pgrp = task_pgrp_nr(current);
381+ swap(sbi->oz_pgrp, new_pid);
371382 sbi->pipefd = pipefd;
372383 sbi->pipe = pipe;
373384 sbi->catatonic = 0;
374385 }
375386 out:
387+ put_pid(new_pid);
376388 mutex_unlock(&sbi->wq_mutex);
377389 return err;
378390 }
fs/autofs4/expire.c+14−0
@@ -402,6 +402,20 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, · 401 unmodified lines
402402 goto next;
403403 }
404404
405+ if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) {
406+ DPRINTK("checking symlink %p %.*s",
407+ dentry, (int)dentry->d_name.len, dentry->d_name.name);
408+ /*
409+ * A symlink can't be "busy" in the usual sense so
410+ * just check last used for expire timeout.
411+ */
412+ if (autofs4_can_expire(dentry, timeout, do_now)) {
413+ expired = dentry;
414+ goto found;
415+ }
416+ goto next;
417+ }
418+
405419 if (simple_empty(dentry))
406420 goto next;
407421
fs/autofs4/inode.c+35−14
@@ -56,8 +56,11 @@ void autofs4_kill_sb(struct super_block *sb) · 55 unmodified lines
5656 * just call kill_anon_super when we are called from
5757 * deactivate_super.
5858 */
59− if (sbi) /* Free wait queues, close pipe */
59+ if (sbi) {
60+ /* Free wait queues, close pipe */
6061 autofs4_catatonic_mode(sbi);
62+ put_pid(sbi->oz_pgrp);
63+ }
6164
6265 DPRINTK("shutting down");
6366 kill_litter_super(sb);
@@ -80,7 +83,7 @@ static int autofs4_show_options(struct seq_file *m, struct dentry *root) · 16 unmodified lines
8083 if (!gid_eq(root_inode->i_gid, GLOBAL_ROOT_GID))
8184 seq_printf(m, ",gid=%u",
8285 from_kgid_munged(&init_user_ns, root_inode->i_gid));
83− seq_printf(m, ",pgrp=%d", sbi->oz_pgrp);
86+ seq_printf(m, ",pgrp=%d", pid_vnr(sbi->oz_pgrp));
8487 seq_printf(m, ",timeout=%lu", sbi->exp_timeout/HZ);
8588 seq_printf(m, ",minproto=%d", sbi->min_proto);
8689 seq_printf(m, ",maxproto=%d", sbi->max_proto);
@@ -124,7 +127,8 @@ static const match_table_t tokens = { · 37 unmodified lines
124127 };
125128
126129 static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
127− pid_t *pgrp, unsigned int *type, int *minproto, int *maxproto)
130+ int *pgrp, bool *pgrp_set, unsigned int *type,
131+ int *minproto, int *maxproto)
128132 {
129133 char *p;
130134 substring_t args[MAX_OPT_ARGS];
@@ -132,7 +136,6 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, · 1 unmodified line
132136
133137 *uid = current_uid();
134138 *gid = current_gid();
135− *pgrp = task_pgrp_nr(current);
136139
137140 *minproto = AUTOFS_MIN_PROTO_VERSION;
138141 *maxproto = AUTOFS_MAX_PROTO_VERSION;
@@ -171,6 +174,7 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, · 32 unmodified lines
171174 if (match_int(args, &option))
172175 return 1;
173176 *pgrp = option;
177+ *pgrp_set = true;
174178 break;
175179 case Opt_minproto:
176180 if (match_int(args, &option))
@@ -206,10 +210,13 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent) · 29 unmodified lines
206210 int pipefd;
207211 struct autofs_sb_info *sbi;
208212 struct autofs_info *ino;
213+ int pgrp;
214+ bool pgrp_set = false;
215+ int ret = -EINVAL;
209216
210217 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
211218 if (!sbi)
212− goto fail_unlock;
219+ return -ENOMEM;
213220 DPRINTK("starting up, sbi = %p",sbi);
214221
215222 s->s_fs_info = sbi;
@@ -218,7 +225,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent) · 2 unmodified lines
218225 sbi->pipe = NULL;
219226 sbi->catatonic = 1;
220227 sbi->exp_timeout = 0;
221− sbi->oz_pgrp = task_pgrp_nr(current);
228+ sbi->oz_pgrp = NULL;
222229 sbi->sb = s;
223230 sbi->version = 0;
224231 sbi->sub_version = 0;
@@ -243,8 +250,10 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent) · 18 unmodified lines
243250 * Get the root inode and dentry, but defer checking for errors.
244251 */
245252 ino = autofs4_new_ino(sbi);
246− if (!ino)
253+ if (!ino) {
254+ ret = -ENOMEM;
247255 goto fail_free;
256+ }
248257 root_inode = autofs4_get_inode(s, S_IFDIR | 0755);
249258 root = d_make_root(root_inode);
250259 if (!root)
@@ -255,12 +264,23 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent) · 4 unmodified lines
255264
256265 /* Can this call block? */
257266 if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid,
258− &sbi->oz_pgrp, &sbi->type, &sbi->min_proto,
259− &sbi->max_proto)) {
267+ &pgrp, &pgrp_set, &sbi->type, &sbi->min_proto,
268+ &sbi->max_proto)) {
260269 printk("autofs: called with bogus options\n");
261270 goto fail_dput;
262271 }
263272
273+ if (pgrp_set) {
274+ sbi->oz_pgrp = find_get_pid(pgrp);
275+ if (!sbi->oz_pgrp) {
276+ pr_warn("autofs: could not find process group %d\n",
277+ pgrp);
278+ goto fail_dput;
279+ }
280+ } else {
281+ sbi->oz_pgrp = get_task_pid(current, PIDTYPE_PGID);
282+ }
283+
264284 if (autofs_type_trigger(sbi->type))
265285 __managed_dentry_set_managed(root);
266286
@@ -284,14 +304,15 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent) · 17 unmodified lines
284304 sbi->version = sbi->max_proto;
285305 sbi->sub_version = AUTOFS_PROTO_SUBVERSION;
286306
287− DPRINTK("pipe fd = %d, pgrp = %u", pipefd, sbi->oz_pgrp);
307+ DPRINTK("pipe fd = %d, pgrp = %u", pipefd, pid_nr(sbi->oz_pgrp));
288308 pipe = fget(pipefd);
289−
309+
290310 if (!pipe) {
291311 printk("autofs: could not open pipe file descriptor\n");
292312 goto fail_dput;
293313 }
294− if (autofs_prepare_pipe(pipe) < 0)
314+ ret = autofs_prepare_pipe(pipe);
315+ if (ret < 0)
295316 goto fail_fput;
296317 sbi->pipe = pipe;
297318 sbi->pipefd = pipefd;
@@ -316,10 +337,10 @@ fail_dput: · 18 unmodified lines
316337 fail_ino:
317338 kfree(ino);
318339 fail_free:
340+ put_pid(sbi->oz_pgrp);
319341 kfree(sbi);
320342 s->s_fs_info = NULL;
321−fail_unlock:
322− return -EINVAL;
343+ return ret;
323344 }
324345
325346 struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode)
fs/autofs4/root.c+3−3
@@ -558,7 +558,7 @@ static int autofs4_dir_symlink(struct inode *dir, · 557 unmodified lines
558558 dget(dentry);
559559 atomic_inc(&ino->count);
560560 p_ino = autofs4_dentry_ino(dentry->d_parent);
561− if (p_ino && dentry->d_parent != dentry)
561+ if (p_ino && !IS_ROOT(dentry))
562562 atomic_inc(&p_ino->count);
563563
564564 dir->i_mtime = CURRENT_TIME;
@@ -593,7 +593,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry) · 28 unmodified lines
593593
594594 if (atomic_dec_and_test(&ino->count)) {
595595 p_ino = autofs4_dentry_ino(dentry->d_parent);
596− if (p_ino && dentry->d_parent != dentry)
596+ if (p_ino && !IS_ROOT(dentry))
597597 atomic_dec(&p_ino->count);
598598 }
599599 dput(ino->dentry);
@@ -732,7 +732,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t m · 132 unmodified lines
732732 dget(dentry);
733733 atomic_inc(&ino->count);
734734 p_ino = autofs4_dentry_ino(dentry->d_parent);
735− if (p_ino && dentry->d_parent != dentry)
735+ if (p_ino && !IS_ROOT(dentry))
736736 atomic_inc(&p_ino->count);
737737 inc_nlink(dir);
738738 dir->i_mtime = CURRENT_TIME;
fs/autofs4/symlink.c+4−0
@@ -14,6 +14,10 @@ · 13 unmodified lines
1414
1515 static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
1616 {
17+ struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
18+ struct autofs_info *ino = autofs4_dentry_ino(dentry);
19+ if (ino && !autofs4_oz_mode(sbi))
20+ ino->last_used = jiffies;
1721 nd_set_link(nd, dentry->d_inode->i_private);
1822 return NULL;
1923 }
fs/autofs4/waitq.c+14−2
@@ -347,11 +347,23 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry, · 346 unmodified lines
347347 struct qstr qstr;
348348 char *name;
349349 int status, ret, type;
350+ pid_t pid;
351+ pid_t tgid;
350352
351353 /* In catatonic mode, we don't wait for nobody */
352354 if (sbi->catatonic)
353355 return -ENOENT;
354356
357+ /*
358+ * Try translating pids to the namespace of the daemon.
359+ *
360+ * Zero means failure: we are in an unrelated pid namespace.
361+ */
362+ pid = task_pid_nr_ns(current, ns_of_pid(sbi->oz_pgrp));
363+ tgid = task_tgid_nr_ns(current, ns_of_pid(sbi->oz_pgrp));
364+ if (pid == 0 || tgid == 0)
365+ return -ENOENT;
366+
355367 if (!dentry->d_inode) {
356368 /*
357369 * A wait for a negative dentry is invalid for certain
@@ -417,8 +429,8 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry, · 59 unmodified lines
417429 wq->ino = autofs4_get_ino(sbi);
418430 wq->uid = current_uid();
419431 wq->gid = current_gid();
420− wq->pid = current->pid;
421− wq->tgid = current->tgid;
432+ wq->pid = pid;
433+ wq->tgid = tgid;
422434 wq->status = -EINTR; /* Status return if interrupted */
423435 wq->wait_ctr = 2;
424436
fs/binfmt_elf.c+0−3
@@ -543,9 +543,6 @@ out: · 542 unmodified lines
543543 * libraries. There is no binary dependent code anywhere else.
544544 */
545545
546−#define INTERPRETER_NONE 0
547−#define INTERPRETER_ELF 2
548−
549546 #ifndef STACK_RND_MASK
550547 #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) /* 8MB of VA */
551548 #endif
fs/coredump.c+0−1
@@ -40,7 +40,6 @@ · 39 unmodified lines
4040
4141 #include <trace/events/task.h>
4242 #include "internal.h"
43−#include "coredump.h"
4443
4544 #include <trace/events/sched.h>
4645
fs/coredump.h+0−6
@@ -1,6 +0,0 @@
1−#ifndef _FS_COREDUMP_H
2−#define _FS_COREDUMP_H
3−
4−extern int __get_dumpable(unsigned long mm_flags);
5−
6−#endif
fs/exec.c+25−95
@@ -62,7 +62,6 @@ · 61 unmodified lines
6262
6363 #include <trace/events/task.h>
6464 #include "internal.h"
65−#include "coredump.h"
6665
6766 #include <trace/events/sched.h>
6867
@@ -843,7 +842,6 @@ static int exec_mmap(struct mm_struct *mm) · 774 unmodified lines
843842 tsk->active_mm = mm;
844843 activate_mm(active_mm, mm);
845844 task_unlock(tsk);
846− arch_pick_mmap_layout(mm);
847845 if (old_mm) {
848846 up_read(&old_mm->mmap_sem);
849847 BUG_ON(active_mm != old_mm);
@@ -1088,8 +1086,8 @@ int flush_old_exec(struct linux_binprm * bprm) · 238 unmodified lines
10881086 bprm->mm = NULL; /* We're using it now */
10891087
10901088 set_fs(USER_DS);
1091− current->flags &=
1092− ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | PF_NOFREEZE);
1089+ current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
1090+ PF_NOFREEZE | PF_NO_SETAFFINITY);
10931091 flush_thread();
10941092 current->personality &= ~bprm->per_clear;
10951093
@@ -1139,9 +1137,7 @@ void setup_new_exec(struct linux_binprm * bprm) · 43 unmodified lines
11391137
11401138 /* An exec changes our domain. We are no longer part of the thread
11411139 group */
1142−
11431140 current->self_exec_id++;
1144−
11451141 flush_signal_handlers(current, 0);
11461142 do_close_on_exec(current->files);
11471143 }
@@ -1173,6 +1169,10 @@ void free_bprm(struct linux_binprm *bprm) · 25 unmodified lines
11731169 mutex_unlock(&current->signal->cred_guard_mutex);
11741170 abort_creds(bprm->cred);
11751171 }
1172+ if (bprm->file) {
1173+ allow_write_access(bprm->file);
1174+ fput(bprm->file);
1175+ }
11761176 /* If a binfmt changed the interp, free it. */
11771177 if (bprm->interp != bprm->filename)
11781178 kfree(bprm->interp);
@@ -1224,11 +1224,10 @@ EXPORT_SYMBOL(install_exec_creds); · 45 unmodified lines
12241224 * - the caller must hold ->cred_guard_mutex to protect against
12251225 * PTRACE_ATTACH
12261226 */
1227−static int check_unsafe_exec(struct linux_binprm *bprm)
1227+static void check_unsafe_exec(struct linux_binprm *bprm)
12281228 {
12291229 struct task_struct *p = current, *t;
12301230 unsigned n_fs;
1231− int res = 0;
12321231
12331232 if (p->ptrace) {
12341233 if (p->ptrace & PT_PTRACE_CAP)
@@ -1244,31 +1243,25 @@ static int check_unsafe_exec(struct linux_binprm *bprm) · 9 unmodified lines
12441243 if (current->no_new_privs)
12451244 bprm->unsafe |= LSM_UNSAFE_NO_NEW_PRIVS;
12461245
1246+ t = p;
12471247 n_fs = 1;
12481248 spin_lock(&p->fs->lock);
12491249 rcu_read_lock();
1250− for (t = next_thread(p); t != p; t = next_thread(t)) {
1250+ while_each_thread(p, t) {
12511251 if (t->fs == p->fs)
12521252 n_fs++;
12531253 }
12541254 rcu_read_unlock();
12551255
1256− if (p->fs->users > n_fs) {
1256+ if (p->fs->users > n_fs)
12571257 bprm->unsafe |= LSM_UNSAFE_SHARE;
1258− } else {
1259− res = -EAGAIN;
1260− if (!p->fs->in_exec) {
1261− p->fs->in_exec = 1;
1262− res = 1;
1263− }
1264− }
1258+ else
1259+ p->fs->in_exec = 1;
12651260 spin_unlock(&p->fs->lock);
1266−
1267− return res;
12681261 }
12691262
1270−/*
1271− * Fill the binprm structure from the inode.
1263+/*
1264+ * Fill the binprm structure from the inode.
12721265 * Check permissions, then read the first 128 (BINPRM_BUF_SIZE) bytes
12731266 *
12741267 * This may be called multiple times for binary chains (scripts for example).
@@ -1430,14 +1423,7 @@ static int exec_binprm(struct linux_binprm *bprm) · 155 unmodified lines
14301423 audit_bprm(bprm);
14311424 trace_sched_process_exec(current, old_pid, bprm);
14321425 ptrace_event(PTRACE_EVENT_EXEC, old_vpid);
1433− current->did_exec = 1;
14341426 proc_exec_connector(current);
1435−
1436− if (bprm->file) {
1437− allow_write_access(bprm->file);
1438− fput(bprm->file);
1439− bprm->file = NULL; /* to catch use-after-free */
1440− }
14411427 }
14421428
14431429 return ret;
@@ -1453,7 +1439,6 @@ static int do_execve_common(const char *filename, · 9 unmodified lines
14531439 struct linux_binprm *bprm;
14541440 struct file *file;
14551441 struct files_struct *displaced;
1456− bool clear_in_exec;
14571442 int retval;
14581443
14591444 /*
@@ -1485,10 +1470,7 @@ static int do_execve_common(const char *filename, · 25 unmodified lines
14851470 if (retval)
14861471 goto out_free;
14871472
1488− retval = check_unsafe_exec(bprm);
1489− if (retval < 0)
1490− goto out_free;
1491− clear_in_exec = retval;
1473+ check_unsafe_exec(bprm);
14921474 current->in_execve = 1;
14931475
14941476 file = open_exec(filename);
@@ -1504,7 +1486,7 @@ static int do_execve_common(const char *filename, · 9 unmodified lines
15041486
15051487 retval = bprm_mm_init(bprm);
15061488 if (retval)
1507− goto out_file;
1489+ goto out_unmark;
15081490
15091491 bprm->argc = count(argv, MAX_ARG_STRINGS);
15101492 if ((retval = bprm->argc) < 0)
@@ -1551,15 +1533,8 @@ out: · 40 unmodified lines
15511533 mmput(bprm->mm);
15521534 }
15531535
1554−out_file:
1555− if (bprm->file) {
1556− allow_write_access(bprm->file);
1557− fput(bprm->file);
1558− }
1559−
15601536 out_unmark:
1561− if (clear_in_exec)
1562− current->fs->in_exec = 0;
1537+ current->fs->in_exec = 0;
15631538 current->in_execve = 0;
15641539
15651540 out_free:
@@ -1609,67 +1584,22 @@ void set_binfmt(struct linux_binfmt *new) · 43 unmodified lines
16091584 if (new)
16101585 __module_get(new->module);
16111586 }
1612−
16131587 EXPORT_SYMBOL(set_binfmt);
16141588
16151589 /*
1616− * set_dumpable converts traditional three-value dumpable to two flags and
1617− * stores them into mm->flags. It modifies lower two bits of mm->flags, but
1618− * these bits are not changed atomically. So get_dumpable can observe the
1619− * intermediate state. To avoid doing unexpected behavior, get get_dumpable
1620− * return either old dumpable or new one by paying attention to the order of
1621− * modifying the bits.
1622− *
1623− * dumpable | mm->flags (binary)
1624− * old new | initial interim final
1625− * ---------+-----------------------
1626− * 0 1 | 00 01 01
1627− * 0 2 | 00 10(*) 11
1628− * 1 0 | 01 00 00
1629− * 1 2 | 01 11 11
1630− * 2 0 | 11 10(*) 00
1631− * 2 1 | 11 11 01
1632− *
1633− * (*) get_dumpable regards interim value of 10 as 11.
1590+ * set_dumpable stores three-value SUID_DUMP_* into mm->flags.
16341591 */
16351592 void set_dumpable(struct mm_struct *mm, int value)
16361593 {
1637− switch (value) {
1638− case SUID_DUMP_DISABLE:
1639− clear_bit(MMF_DUMPABLE, &mm->flags);
1640− smp_wmb();
1641− clear_bit(MMF_DUMP_SECURELY, &mm->flags);
1642− break;
1643− case SUID_DUMP_USER:
1644− set_bit(MMF_DUMPABLE, &mm->flags);
1645− smp_wmb();
1646− clear_bit(MMF_DUMP_SECURELY, &mm->flags);
1647− break;
1648− case SUID_DUMP_ROOT:
1649− set_bit(MMF_DUMP_SECURELY, &mm->flags);
1650− smp_wmb();
1651− set_bit(MMF_DUMPABLE, &mm->flags);
1652− break;
1653− }
1654−}
1655−
1656−int __get_dumpable(unsigned long mm_flags)
1657−{
1658− int ret;
1594+ unsigned long old, new;
16591595
1660− ret = mm_flags & MMF_DUMPABLE_MASK;
1661− return (ret > SUID_DUMP_USER) ? SUID_DUMP_ROOT : ret;
1662−}
1596+ if (WARN_ON((unsigned)value > SUID_DUMP_ROOT))
1597+ return;
16631598
1664−/*
1665− * This returns the actual value of the suid_dumpable flag. For things
1666− * that are using this for checking for privilege transitions, it must
1667− * test against SUID_DUMP_USER rather than treating it as a boolean
1668− * value.
1669− */
1670−int get_dumpable(struct mm_struct *mm)
1671−{
1672− return __get_dumpable(mm->flags);
1599+ do {
1600+ old = ACCESS_ONCE(mm->flags);
1601+ new = (old & ~MMF_DUMPABLE_MASK) | value;
1602+ } while (cmpxchg(&mm->flags, old, new) != old);
16731603 }
16741604
16751605 SYSCALL_DEFINE3(execve,
fs/ext3/dir.c+9−35
@@ -309,43 +309,17 @@ struct fname { · 308 unmodified lines
309309 */
310310 static void free_rb_tree_fname(struct rb_root *root)
311311 {
312− struct rb_node *n = root->rb_node;
313− struct rb_node *parent;
314− struct fname *fname;
315−
316− while (n) {
317− /* Do the node's children first */
318− if (n->rb_left) {
319− n = n->rb_left;
320− continue;
321− }
322− if (n->rb_right) {
323− n = n->rb_right;
324− continue;
325− }
326− /*
327− * The node has no children; free it, and then zero
328− * out parent's link to it. Finally go to the
329− * beginning of the loop and try to free the parent
330− * node.
331− */
332− parent = rb_parent(n);
333− fname = rb_entry(n, struct fname, rb_hash);
334− while (fname) {
335− struct fname * old = fname;
312+ struct fname *fname, *next;
313+
314+ rbtree_postorder_for_each_entry_safe(fname, next, root, rb_hash)
315+ do {
316+ struct fname *old = fname;
336317 fname = fname->next;
337− kfree (old);
338− }
339− if (!parent)
340− *root = RB_ROOT;
341− else if (parent->rb_left == n)
342− parent->rb_left = NULL;
343− else if (parent->rb_right == n)
344− parent->rb_right = NULL;
345− n = parent;
346− }
347−}
318+ kfree(old);
319+ } while (fname);
348320
321+ *root = RB_ROOT;
322+}
349323
350324 static struct dir_private_info *ext3_htree_create_dir_info(struct file *filp,
351325 loff_t pos)
fs/ext4/block_validity.c+4−29
@@ -180,37 +180,12 @@ int ext4_setup_system_zone(struct super_block *sb) · 179 unmodified lines
180180 /* Called when the filesystem is unmounted */
181181 void ext4_release_system_zone(struct super_block *sb)
182182 {
183− struct rb_node *n = EXT4_SB(sb)->system_blks.rb_node;
184− struct rb_node *parent;
185− struct ext4_system_zone *entry;
183+ struct ext4_system_zone *entry, *n;
186184
187− while (n) {
188− /* Do the node's children first */
189− if (n->rb_left) {
190− n = n->rb_left;
191− continue;
192− }
193− if (n->rb_right) {
194− n = n->rb_right;
195− continue;
196− }
197− /*
198− * The node has no children; free it, and then zero
199− * out parent's link to it. Finally go to the
200− * beginning of the loop and try to free the parent
201− * node.
202− */
203− parent = rb_parent(n);
204− entry = rb_entry(n, struct ext4_system_zone, node);
185+ rbtree_postorder_for_each_entry_safe(entry, n,
186+ &EXT4_SB(sb)->system_blks, node)
205187 kmem_cache_free(ext4_system_zone_cachep, entry);
206− if (!parent)
207− EXT4_SB(sb)->system_blks = RB_ROOT;
208− else if (parent->rb_left == n)
209− parent->rb_left = NULL;
210− else if (parent->rb_right == n)
211− parent->rb_right = NULL;
212− n = parent;
213− }
188+
214189 EXT4_SB(sb)->system_blks = RB_ROOT;
215190 }
216191
fs/ext4/dir.c+5−30
@@ -353,41 +353,16 @@ struct fname { · 352 unmodified lines
353353 */
354354 static void free_rb_tree_fname(struct rb_root *root)
355355 {
356− struct rb_node *n = root->rb_node;
357− struct rb_node *parent;
358− struct fname *fname;
359−
360− while (n) {
361− /* Do the node's children first */
362− if (n->rb_left) {
363− n = n->rb_left;
364− continue;
365− }
366− if (n->rb_right) {
367− n = n->rb_right;
368− continue;
369− }
370− /*
371− * The node has no children; free it, and then zero
372− * out parent's link to it. Finally go to the
373− * beginning of the loop and try to free the parent
374− * node.
375− */
376− parent = rb_parent(n);
377− fname = rb_entry(n, struct fname, rb_hash);
356+ struct fname *fname, *next;
357+
358+ rbtree_postorder_for_each_entry_safe(fname, next, root, rb_hash)
378359 while (fname) {
379360 struct fname *old = fname;
380361 fname = fname->next;
381362 kfree(old);
382363 }
383− if (!parent)
384− *root = RB_ROOT;
385− else if (parent->rb_left == n)
386− parent->rb_left = NULL;
387− else if (parent->rb_right == n)
388− parent->rb_right = NULL;
389− n = parent;
390− }
364+
365+ *root = RB_ROOT;
391366 }
392367
393368
fs/hfsplus/inode.c+0−59
@@ -178,64 +178,6 @@ const struct dentry_operations hfsplus_dentry_operations = { · 177 unmodified lines
178178 .d_compare = hfsplus_compare_dentry,
179179 };
180180
181−static struct dentry *hfsplus_file_lookup(struct inode *dir,
182− struct dentry *dentry, unsigned int flags)
183−{
184− struct hfs_find_data fd;
185− struct super_block *sb = dir->i_sb;
186− struct inode *inode = NULL;
187− struct hfsplus_inode_info *hip;
188− int err;
189−
190− if (HFSPLUS_IS_RSRC(dir) || strcmp(dentry->d_name.name, "rsrc"))
191− goto out;
192−
193− inode = HFSPLUS_I(dir)->rsrc_inode;
194− if (inode)
195− goto out;
196−
197− inode = new_inode(sb);
198− if (!inode)
199− return ERR_PTR(-ENOMEM);
200−
201− hip = HFSPLUS_I(inode);
202− inode->i_ino = dir->i_ino;
203− INIT_LIST_HEAD(&hip->open_dir_list);
204− mutex_init(&hip->extents_lock);
205− hip->extent_state = 0;
206− hip->flags = 0;
207− hip->userflags = 0;
208− set_bit(HFSPLUS_I_RSRC, &hip->flags);
209−
210− err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
211− if (!err) {
212− err = hfsplus_find_cat(sb, dir->i_ino, &fd);
213− if (!err)
214− err = hfsplus_cat_read_inode(inode, &fd);
215− hfs_find_exit(&fd);
216− }
217− if (err) {
218− iput(inode);
219− return ERR_PTR(err);
220− }
221− hip->rsrc_inode = dir;
222− HFSPLUS_I(dir)->rsrc_inode = inode;
223− igrab(dir);
224−
225− /*
226− * __mark_inode_dirty expects inodes to be hashed. Since we don't
227− * want resource fork inodes in the regular inode space, we make them
228− * appear hashed, but do not put on any lists. hlist_del()
229− * will work fine and require no locking.
230− */
231− hlist_add_fake(&inode->i_hash);
232−
233− mark_inode_dirty(inode);
234−out:
235− d_add(dentry, inode);
236− return NULL;
237−}
238−
239181 static void hfsplus_get_perms(struct inode *inode,
240182 struct hfsplus_perm *perms, int dir)
241183 {
@@ -385,7 +327,6 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, · 143 unmodified lines
385327 }
386328
387329 static const struct inode_operations hfsplus_file_inode_operations = {
388− .lookup = hfsplus_file_lookup,
389330 .setattr = hfsplus_setattr,
390331 .setxattr = generic_setxattr,
391332 .getxattr = generic_getxattr,
fs/jffs2/nodelist.c+2−26
@@ -564,25 +564,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_ · 563 unmodified lines
564564 they're killed. */
565565 void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
566566 {
567− struct jffs2_node_frag *frag;
568− struct jffs2_node_frag *parent;
569−
570− if (!root->rb_node)
571− return;
567+ struct jffs2_node_frag *frag, *next;
572568
573569 dbg_fragtree("killing\n");
574−
575− frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
576− while(frag) {
577− if (frag->rb.rb_left) {
578− frag = frag_left(frag);
579− continue;
580− }
581− if (frag->rb.rb_right) {
582− frag = frag_right(frag);
583− continue;
584− }
585−
570+ rbtree_postorder_for_each_entry_safe(frag, next, root, rb) {
586571 if (frag->node && !(--frag->node->frags)) {
587572 /* Not a hole, and it's the final remaining frag
588573 of this node. Free the node */
@@ -591,17 +576,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) · 2 unmodified lines
591576
592577 jffs2_free_full_dnode(frag->node);
593578 }
594− parent = frag_parent(frag);
595− if (parent) {
596− if (frag_left(parent) == frag)
597− parent->rb.rb_left = NULL;
598− else
599− parent->rb.rb_right = NULL;
600− }
601579
602580 jffs2_free_node_frag(frag);
603− frag = parent;
604−
605581 cond_resched();
606582 }
607583 }
fs/jffs2/readinode.c+3−23
@@ -543,33 +543,13 @@ static int jffs2_build_inode_fragtree(struct jffs2_sb_info *c, · 542 unmodified lines
543543
544544 static void jffs2_free_tmp_dnode_info_list(struct rb_root *list)
545545 {
546− struct rb_node *this;
547− struct jffs2_tmp_dnode_info *tn;
548−
549− this = list->rb_node;
546+ struct jffs2_tmp_dnode_info *tn, *next;
550547
551− /* Now at bottom of tree */
552− while (this) {
553− if (this->rb_left)
554− this = this->rb_left;
555− else if (this->rb_right)
556− this = this->rb_right;
557− else {
558− tn = rb_entry(this, struct jffs2_tmp_dnode_info, rb);
548+ rbtree_postorder_for_each_entry_safe(tn, next, list, rb) {
559549 jffs2_free_full_dnode(tn->fn);
560550 jffs2_free_tmp_dnode_info(tn);
561−
562− this = rb_parent(this);
563− if (!this)
564− break;
565−
566− if (this->rb_left == &tn->rb)
567− this->rb_left = NULL;
568− else if (this->rb_right == &tn->rb)
569− this->rb_right = NULL;
570− else BUG();
571− }
572551 }
552+
573553 *list = RB_ROOT;
574554 }
575555
fs/logfs/segment.c+2−1
@@ -62,7 +62,8 @@ static struct page *get_mapping_page(struct super_block *sb, pgoff_t index, · 61 unmodified lines
6262 page = read_cache_page(mapping, index, filler, sb);
6363 else {
6464 page = find_or_create_page(mapping, index, GFP_NOFS);
65− unlock_page(page);
65+ if (page)
66+ unlock_page(page);
6667 }
6768 return page;
6869 }
fs/nilfs2/ioctl.c+370−1
@@ -37,7 +37,26 @@ · 36 unmodified lines
3737 #include "sufile.h"
3838 #include "dat.h"
3939
40−
40+/**
41+ * nilfs_ioctl_wrap_copy - wrapping function of get/set metadata info
42+ * @nilfs: nilfs object
43+ * @argv: vector of arguments from userspace
44+ * @dir: set of direction flags
45+ * @dofunc: concrete function of get/set metadata info
46+ *
47+ * Description: nilfs_ioctl_wrap_copy() gets/sets metadata info by means of
48+ * calling dofunc() function on the basis of @argv argument.
49+ *
50+ * Return Value: On success, 0 is returned and requested metadata info
51+ * is copied into userspace. On error, one of the following
52+ * negative error codes is returned.
53+ *
54+ * %-EINVAL - Invalid arguments from userspace.
55+ *
56+ * %-ENOMEM - Insufficient amount of memory available.
57+ *
58+ * %-EFAULT - Failure during execution of requested operation.
59+ */
4160 static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
4261 struct nilfs_argv *argv, int dir,
4362 ssize_t (*dofunc)(struct the_nilfs *,
@@ -57,6 +76,14 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, · 13 unmodified lines
5776 if (argv->v_size > PAGE_SIZE)
5877 return -EINVAL;
5978
79+ /*
80+ * Reject pairs of a start item position (argv->v_index) and a
81+ * total count (argv->v_nmembs) which leads position 'pos' to
82+ * overflow by the increment at the end of the loop.
83+ */
84+ if (argv->v_index > ~(__u64)0 - argv->v_nmembs)
85+ return -EINVAL;
86+
6087 buf = (void *)__get_free_pages(GFP_NOFS, 0);
6188 if (unlikely(!buf))
6289 return -ENOMEM;
@@ -99,6 +126,9 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, · 36 unmodified lines
99126 return ret;
100127 }
101128
129+/**
130+ * nilfs_ioctl_getflags - ioctl to support lsattr
131+ */
102132 static int nilfs_ioctl_getflags(struct inode *inode, void __user *argp)
103133 {
104134 unsigned int flags = NILFS_I(inode)->i_flags & FS_FL_USER_VISIBLE;
@@ -106,6 +136,9 @@ static int nilfs_ioctl_getflags(struct inode *inode, void __user *argp) · 1 unmodified line
106136 return put_user(flags, (int __user *)argp);
107137 }
108138
139+/**
140+ * nilfs_ioctl_setflags - ioctl to support chattr
141+ */
109142 static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp,
110143 void __user *argp)
111144 {
@@ -158,11 +191,33 @@ out: · 46 unmodified lines
158191 return ret;
159192 }
160193
194+/**
195+ * nilfs_ioctl_getversion - get info about a file's version (generation number)
196+ */
161197 static int nilfs_ioctl_getversion(struct inode *inode, void __user *argp)
162198 {
163199 return put_user(inode->i_generation, (int __user *)argp);
164200 }
165201
202+/**
203+ * nilfs_ioctl_change_cpmode - change checkpoint mode (checkpoint/snapshot)
204+ * @inode: inode object
205+ * @filp: file object
206+ * @cmd: ioctl's request code
207+ * @argp: pointer on argument from userspace
208+ *
209+ * Description: nilfs_ioctl_change_cpmode() function changes mode of
210+ * given checkpoint between checkpoint and snapshot state. This ioctl
211+ * is used in chcp and mkcp utilities.
212+ *
213+ * Return Value: On success, 0 is returned and mode of a checkpoint is
214+ * changed. On error, one of the following negative error codes
215+ * is returned.
216+ *
217+ * %-EPERM - Operation not permitted.
218+ *
219+ * %-EFAULT - Failure during checkpoint mode changing.
220+ */
166221 static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
167222 unsigned int cmd, void __user *argp)
168223 {
@@ -198,6 +253,25 @@ out: · 29 unmodified lines
198253 return ret;
199254 }
200255
256+/**
257+ * nilfs_ioctl_delete_checkpoint - remove checkpoint
258+ * @inode: inode object
259+ * @filp: file object
260+ * @cmd: ioctl's request code
261+ * @argp: pointer on argument from userspace
262+ *
263+ * Description: nilfs_ioctl_delete_checkpoint() function removes
264+ * checkpoint from NILFS2 file system. This ioctl is used in rmcp
265+ * utility.
266+ *
267+ * Return Value: On success, 0 is returned and a checkpoint is
268+ * removed. On error, one of the following negative error codes
269+ * is returned.
270+ *
271+ * %-EPERM - Operation not permitted.
272+ *
273+ * %-EFAULT - Failure during checkpoint removing.
274+ */
201275 static int
202276 nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
203277 unsigned int cmd, void __user *argp)
@@ -229,6 +303,21 @@ out: · 25 unmodified lines
229303 return ret;
230304 }
231305
306+/**
307+ * nilfs_ioctl_do_get_cpinfo - callback method getting info about checkpoints
308+ * @nilfs: nilfs object
309+ * @posp: pointer on array of checkpoint's numbers
310+ * @flags: checkpoint mode (checkpoint or snapshot)
311+ * @buf: buffer for storing checkponts' info
312+ * @size: size in bytes of one checkpoint info item in array
313+ * @nmembs: number of checkpoints in array (numbers and infos)
314+ *
315+ * Description: nilfs_ioctl_do_get_cpinfo() function returns info about
316+ * requested checkpoints. The NILFS_IOCTL_GET_CPINFO ioctl is used in
317+ * lscp utility and by nilfs_cleanerd daemon.
318+ *
319+ * Return value: count of nilfs_cpinfo structures in output buffer.
320+ */
232321 static ssize_t
233322 nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
234323 void *buf, size_t size, size_t nmembs)
@@ -242,6 +331,27 @@ nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, · 7 unmodified lines
242331 return ret;
243332 }
244333
334+/**
335+ * nilfs_ioctl_get_cpstat - get checkpoints statistics
336+ * @inode: inode object
337+ * @filp: file object
338+ * @cmd: ioctl's request code
339+ * @argp: pointer on argument from userspace
340+ *
341+ * Description: nilfs_ioctl_get_cpstat() returns information about checkpoints.
342+ * The NILFS_IOCTL_GET_CPSTAT ioctl is used by lscp, rmcp utilities
343+ * and by nilfs_cleanerd daemon.
344+ *
345+ * Return Value: On success, 0 is returned, and checkpoints information is
346+ * copied into userspace pointer @argp. On error, one of the following
347+ * negative error codes is returned.
348+ *
349+ * %-EIO - I/O error.
350+ *
351+ * %-ENOMEM - Insufficient amount of memory available.
352+ *
353+ * %-EFAULT - Failure during getting checkpoints statistics.
354+ */
245355 static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp,
246356 unsigned int cmd, void __user *argp)
247357 {
@@ -260,6 +370,21 @@ static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp, · 12 unmodified lines
260370 return ret;
261371 }
262372
373+/**
374+ * nilfs_ioctl_do_get_suinfo - callback method getting segment usage info
375+ * @nilfs: nilfs object
376+ * @posp: pointer on array of segment numbers
377+ * @flags: *not used*
378+ * @buf: buffer for storing suinfo array
379+ * @size: size in bytes of one suinfo item in array
380+ * @nmembs: count of segment numbers and suinfos in array
381+ *
382+ * Description: nilfs_ioctl_do_get_suinfo() function returns segment usage
383+ * info about requested segments. The NILFS_IOCTL_GET_SUINFO ioctl is used
384+ * in lssu, nilfs_resize utilities and by nilfs_cleanerd daemon.
385+ *
386+ * Return value: count of nilfs_suinfo structures in output buffer.
387+ */
263388 static ssize_t
264389 nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
265390 void *buf, size_t size, size_t nmembs)
@@ -273,6 +398,27 @@ nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, · 7 unmodified lines
273398 return ret;
274399 }
275400
401+/**
402+ * nilfs_ioctl_get_sustat - get segment usage statistics
403+ * @inode: inode object
404+ * @filp: file object
405+ * @cmd: ioctl's request code
406+ * @argp: pointer on argument from userspace
407+ *
408+ * Description: nilfs_ioctl_get_sustat() returns segment usage statistics.
409+ * The NILFS_IOCTL_GET_SUSTAT ioctl is used in lssu, nilfs_resize utilities
410+ * and by nilfs_cleanerd daemon.
411+ *
412+ * Return Value: On success, 0 is returned, and segment usage information is
413+ * copied into userspace pointer @argp. On error, one of the following
414+ * negative error codes is returned.
415+ *
416+ * %-EIO - I/O error.
417+ *
418+ * %-ENOMEM - Insufficient amount of memory available.
419+ *
420+ * %-EFAULT - Failure during getting segment usage statistics.
421+ */
276422 static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp,
277423 unsigned int cmd, void __user *argp)
278424 {
@@ -291,6 +437,21 @@ static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp, · 12 unmodified lines
291437 return ret;
292438 }
293439
440+/**
441+ * nilfs_ioctl_do_get_vinfo - callback method getting virtual blocks info
442+ * @nilfs: nilfs object
443+ * @posp: *not used*
444+ * @flags: *not used*
445+ * @buf: buffer for storing array of nilfs_vinfo structures
446+ * @size: size in bytes of one vinfo item in array
447+ * @nmembs: count of vinfos in array
448+ *
449+ * Description: nilfs_ioctl_do_get_vinfo() function returns information
450+ * on virtual block addresses. The NILFS_IOCTL_GET_VINFO ioctl is used
451+ * by nilfs_cleanerd daemon.
452+ *
453+ * Return value: count of nilfs_vinfo structures in output buffer.
454+ */
294455 static ssize_t
295456 nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
296457 void *buf, size_t size, size_t nmembs)
@@ -303,6 +464,21 @@ nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, · 6 unmodified lines
303464 return ret;
304465 }
305466
467+/**
468+ * nilfs_ioctl_do_get_bdescs - callback method getting disk block descriptors
469+ * @nilfs: nilfs object
470+ * @posp: *not used*
471+ * @flags: *not used*
472+ * @buf: buffer for storing array of nilfs_bdesc structures
473+ * @size: size in bytes of one bdesc item in array
474+ * @nmembs: count of bdescs in array
475+ *
476+ * Description: nilfs_ioctl_do_get_bdescs() function returns information
477+ * about descriptors of disk block numbers. The NILFS_IOCTL_GET_BDESCS ioctl
478+ * is used by nilfs_cleanerd daemon.
479+ *
480+ * Return value: count of nilfs_bdescs structures in output buffer.
481+ */
306482 static ssize_t
307483 nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags,
308484 void *buf, size_t size, size_t nmembs)
@@ -329,6 +505,29 @@ nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags, · 20 unmodified lines
329505 return nmembs;
330506 }
331507
508+/**
509+ * nilfs_ioctl_get_bdescs - get disk block descriptors
510+ * @inode: inode object
511+ * @filp: file object
512+ * @cmd: ioctl's request code
513+ * @argp: pointer on argument from userspace
514+ *
515+ * Description: nilfs_ioctl_do_get_bdescs() function returns information
516+ * about descriptors of disk block numbers. The NILFS_IOCTL_GET_BDESCS ioctl
517+ * is used by nilfs_cleanerd daemon.
518+ *
519+ * Return Value: On success, 0 is returned, and disk block descriptors are
520+ * copied into userspace pointer @argp. On error, one of the following
521+ * negative error codes is returned.
522+ *
523+ * %-EINVAL - Invalid arguments from userspace.
524+ *
525+ * %-EIO - I/O error.
526+ *
527+ * %-ENOMEM - Insufficient amount of memory available.
528+ *
529+ * %-EFAULT - Failure during getting disk block descriptors.
530+ */
332531 static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp,
333532 unsigned int cmd, void __user *argp)
334533 {
@@ -352,6 +551,26 @@ static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp, · 17 unmodified lines
352551 return ret;
353552 }
354553
554+/**
555+ * nilfs_ioctl_move_inode_block - prepare data/node block for moving by GC
556+ * @inode: inode object
557+ * @vdesc: descriptor of virtual block number
558+ * @buffers: list of moving buffers
559+ *
560+ * Description: nilfs_ioctl_move_inode_block() function registers data/node
561+ * buffer in the GC pagecache and submit read request.
562+ *
563+ * Return Value: On success, 0 is returned. On error, one of the following
564+ * negative error codes is returned.
565+ *
566+ * %-EIO - I/O error.
567+ *
568+ * %-ENOMEM - Insufficient amount of memory available.
569+ *
570+ * %-ENOENT - Requested block doesn't exist.
571+ *
572+ * %-EEXIST - Blocks conflict is detected.
573+ */
355574 static int nilfs_ioctl_move_inode_block(struct inode *inode,
356575 struct nilfs_vdesc *vdesc,
357576 struct list_head *buffers)
@@ -397,6 +616,19 @@ static int nilfs_ioctl_move_inode_block(struct inode *inode, · 39 unmodified lines
397616 return 0;
398617 }
399618
619+/**
620+ * nilfs_ioctl_move_blocks - move valid inode's blocks during garbage collection
621+ * @sb: superblock object
622+ * @argv: vector of arguments from userspace
623+ * @buf: array of nilfs_vdesc structures
624+ *
625+ * Description: nilfs_ioctl_move_blocks() function reads valid data/node
626+ * blocks that garbage collector specified with the array of nilfs_vdesc
627+ * structures and stores them into page caches of GC inodes.
628+ *
629+ * Return Value: Number of processed nilfs_vdesc structures or
630+ * error code, otherwise.
631+ */
400632 static int nilfs_ioctl_move_blocks(struct super_block *sb,
401633 struct nilfs_argv *argv, void *buf)
402634 {
@@ -462,6 +694,25 @@ static int nilfs_ioctl_move_blocks(struct super_block *sb, · 59 unmodified lines
462694 return ret;
463695 }
464696
697+/**
698+ * nilfs_ioctl_delete_checkpoints - delete checkpoints
699+ * @nilfs: nilfs object
700+ * @argv: vector of arguments from userspace
701+ * @buf: array of periods of checkpoints numbers
702+ *
703+ * Description: nilfs_ioctl_delete_checkpoints() function deletes checkpoints
704+ * in the period from p_start to p_end, excluding p_end itself. The checkpoints
705+ * which have been already deleted are ignored.
706+ *
707+ * Return Value: Number of processed nilfs_period structures or
708+ * error code, otherwise.
709+ *
710+ * %-EIO - I/O error.
711+ *
712+ * %-ENOMEM - Insufficient amount of memory available.
713+ *
714+ * %-EINVAL - invalid checkpoints.
715+ */
465716 static int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs,
466717 struct nilfs_argv *argv, void *buf)
467718 {
@@ -479,6 +730,24 @@ static int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs, · 11 unmodified lines
479730 return nmembs;
480731 }
481732
733+/**
734+ * nilfs_ioctl_free_vblocknrs - free virtual block numbers
735+ * @nilfs: nilfs object
736+ * @argv: vector of arguments from userspace
737+ * @buf: array of virtual block numbers
738+ *
739+ * Description: nilfs_ioctl_free_vblocknrs() function frees
740+ * the virtual block numbers specified by @buf and @argv->v_nmembs.
741+ *
742+ * Return Value: Number of processed virtual block numbers or
743+ * error code, otherwise.
744+ *
745+ * %-EIO - I/O error.
746+ *
747+ * %-ENOMEM - Insufficient amount of memory available.
748+ *
749+ * %-ENOENT - The virtual block number have not been allocated.
750+ */
482751 static int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs,
483752 struct nilfs_argv *argv, void *buf)
484753 {
@@ -490,6 +759,24 @@ static int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs, · 5 unmodified lines
490759 return (ret < 0) ? ret : nmembs;
491760 }
492761
762+/**
763+ * nilfs_ioctl_mark_blocks_dirty - mark blocks dirty
764+ * @nilfs: nilfs object
765+ * @argv: vector of arguments from userspace
766+ * @buf: array of block descriptors
767+ *
768+ * Description: nilfs_ioctl_mark_blocks_dirty() function marks
769+ * metadata file or data blocks as dirty.
770+ *
771+ * Return Value: Number of processed block descriptors or
772+ * error code, otherwise.
773+ *
774+ * %-ENOMEM - Insufficient memory available.
775+ *
776+ * %-EIO - I/O error
777+ *
778+ * %-ENOENT - the specified block does not exist (hole block)
779+ */
493780 static int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs,
494781 struct nilfs_argv *argv, void *buf)
495782 {
@@ -571,6 +858,20 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, · 75 unmodified lines
571858 return ret;
572859 }
573860
861+/**
862+ * nilfs_ioctl_clean_segments - clean segments
863+ * @inode: inode object
864+ * @filp: file object
865+ * @cmd: ioctl's request code
866+ * @argp: pointer on argument from userspace
867+ *
868+ * Description: nilfs_ioctl_clean_segments() function makes garbage
869+ * collection operation in the environment of requested parameters
870+ * from userspace. The NILFS_IOCTL_CLEAN_SEGMENTS ioctl is used by
871+ * nilfs_cleanerd daemon.
872+ *
873+ * Return Value: On success, 0 is returned or error code, otherwise.
874+ */
574875 static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
575876 unsigned int cmd, void __user *argp)
576877 {
@@ -682,6 +983,33 @@ out: · 105 unmodified lines
682983 return ret;
683984 }
684985
986+/**
987+ * nilfs_ioctl_sync - make a checkpoint
988+ * @inode: inode object
989+ * @filp: file object
990+ * @cmd: ioctl's request code
991+ * @argp: pointer on argument from userspace
992+ *
993+ * Description: nilfs_ioctl_sync() function constructs a logical segment
994+ * for checkpointing. This function guarantees that all modified data
995+ * and metadata are written out to the device when it successfully
996+ * returned.
997+ *
998+ * Return Value: On success, 0 is retured. On errors, one of the following
999+ * negative error code is returned.
1000+ *
1001+ * %-EROFS - Read only filesystem.
1002+ *
1003+ * %-EIO - I/O error
1004+ *
1005+ * %-ENOSPC - No space left on device (only in a panic state).
1006+ *
1007+ * %-ERESTARTSYS - Interrupted.
1008+ *
1009+ * %-ENOMEM - Insufficient memory available.
1010+ *
1011+ * %-EFAULT - Failure during execution of requested operation.
1012+ */
6851013 static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
6861014 unsigned int cmd, void __user *argp)
6871015 {
@@ -710,6 +1038,14 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, · 22 unmodified lines
7101038 return 0;
7111039 }
7121040
1041+/**
1042+ * nilfs_ioctl_resize - resize NILFS2 volume
1043+ * @inode: inode object
1044+ * @filp: file object
1045+ * @argp: pointer on argument from userspace
1046+ *
1047+ * Return Value: On success, 0 is returned or error code, otherwise.
1048+ */
7131049 static int nilfs_ioctl_resize(struct inode *inode, struct file *filp,
7141050 void __user *argp)
7151051 {
@@ -735,6 +1071,17 @@ out: · 19 unmodified lines
7351071 return ret;
7361072 }
7371073
1074+/**
1075+ * nilfs_ioctl_set_alloc_range - limit range of segments to be allocated
1076+ * @inode: inode object
1077+ * @argp: pointer on argument from userspace
1078+ *
1079+ * Decription: nilfs_ioctl_set_alloc_range() function defines lower limit
1080+ * of segments in bytes and upper limit of segments in bytes.
1081+ * The NILFS_IOCTL_SET_ALLOC_RANGE is used by nilfs_resize utility.
1082+ *
1083+ * Return Value: On success, 0 is returned or error code, otherwise.
1084+ */
7381085 static int nilfs_ioctl_set_alloc_range(struct inode *inode, void __user *argp)
7391086 {
7401087 struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
@@ -767,6 +1114,28 @@ out: · 26 unmodified lines
7671114 return ret;
7681115 }
7691116
1117+/**
1118+ * nilfs_ioctl_get_info - wrapping function of get metadata info
1119+ * @inode: inode object
1120+ * @filp: file object
1121+ * @cmd: ioctl's request code
1122+ * @argp: pointer on argument from userspace
1123+ * @membsz: size of an item in bytes
1124+ * @dofunc: concrete function of getting metadata info
1125+ *
1126+ * Description: nilfs_ioctl_get_info() gets metadata info by means of
1127+ * calling dofunc() function.
1128+ *
1129+ * Return Value: On success, 0 is returned and requested metadata info
1130+ * is copied into userspace. On error, one of the following
1131+ * negative error codes is returned.
1132+ *
1133+ * %-EINVAL - Invalid arguments from userspace.
1134+ *
1135+ * %-ENOMEM - Insufficient amount of memory available.
1136+ *
1137+ * %-EFAULT - Failure during execution of requested operation.
1138+ */
7701139 static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp,
7711140 unsigned int cmd, void __user *argp,
7721141 size_t membsz,
fs/pipe.c+2−1
@@ -663,10 +663,11 @@ out: · 662 unmodified lines
663663 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLRDNORM);
664664 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
665665 }
666− if (ret > 0) {
666+ if (ret > 0 && sb_start_write_trylock(file_inode(filp)->i_sb)) {
667667 int err = file_update_time(filp);
668668 if (err)
669669 ret = err;
670+ sb_end_write(file_inode(filp)->i_sb);
670671 }
671672 return ret;
672673 }
fs/posix_acl.c+0−10
@@ -149,8 +149,6 @@ posix_acl_valid(const struct posix_acl *acl) · 148 unmodified lines
149149 {
150150 const struct posix_acl_entry *pa, *pe;
151151 int state = ACL_USER_OBJ;
152− kuid_t prev_uid = INVALID_UID;
153− kgid_t prev_gid = INVALID_GID;
154152 int needs_mask = 0;
155153
156154 FOREACH_ACL_ENTRY(pa, acl, pe) {
@@ -169,10 +167,6 @@ posix_acl_valid(const struct posix_acl *acl) · 12 unmodified lines
169167 return -EINVAL;
170168 if (!uid_valid(pa->e_uid))
171169 return -EINVAL;
172− if (uid_valid(prev_uid) &&
173− uid_lte(pa->e_uid, prev_uid))
174− return -EINVAL;
175− prev_uid = pa->e_uid;
176170 needs_mask = 1;
177171 break;
178172
@@ -188,10 +182,6 @@ posix_acl_valid(const struct posix_acl *acl) · 9 unmodified lines
188182 return -EINVAL;
189183 if (!gid_valid(pa->e_gid))
190184 return -EINVAL;
191− if (gid_valid(prev_gid) &&
192− gid_lte(pa->e_gid, prev_gid))
193− return -EINVAL;
194− prev_gid = pa->e_gid;
195185 needs_mask = 1;
196186 break;
197187
fs/proc/array.c+4−14
@@ -140,24 +140,15 @@ static const char * const task_state_array[] = { · 139 unmodified lines
140140 "t (tracing stop)", /* 8 */
141141 "Z (zombie)", /* 16 */
142142 "X (dead)", /* 32 */
143− "x (dead)", /* 64 */
144− "K (wakekill)", /* 128 */
145− "W (waking)", /* 256 */
146− "P (parked)", /* 512 */
147143 };
148144
149145 static inline const char *get_task_state(struct task_struct *tsk)
150146 {
151− unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
152− const char * const *p = &task_state_array[0];
147+ unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT;
153148
154− BUILD_BUG_ON(1 + ilog2(TASK_STATE_MAX) != ARRAY_SIZE(task_state_array));
149+ BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1);
155150
156− while (state) {
157− p++;
158− state >>= 1;
159− }
160− return *p;
151+ return task_state_array[fls(state)];
161152 }
162153
163154 static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
@@ -453,8 +444,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, · 289 unmodified lines
453444 min_flt += t->min_flt;
454445 maj_flt += t->maj_flt;
455446 gtime += task_gtime(t);
456− t = next_thread(t);
457− } while (t != task);
447+ } while_each_thread(task, t);
458448
459449 min_flt += sig->min_flt;
460450 maj_flt += sig->maj_flt;
fs/proc/base.c+36−33
@@ -1658,13 +1658,18 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags) · 1657 unmodified lines
16581658 return 0;
16591659 }
16601660
1661+static inline bool proc_inode_is_dead(struct inode *inode)
1662+{
1663+ return !proc_pid(inode)->tasks[PIDTYPE_PID].first;
1664+}
1665+
16611666 int pid_delete_dentry(const struct dentry *dentry)
16621667 {
16631668 /* Is the task we represent dead?
16641669 * If so, then don't put the dentry on the lru list,
16651670 * kill it immediately.
16661671 */
1667− return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first;
1672+ return proc_inode_is_dead(dentry->d_inode);
16681673 }
16691674
16701675 const struct dentry_operations pid_dentry_operations =
@@ -3092,34 +3097,42 @@ out_no_task: · 1421 unmodified lines
30923097 * In the case of a seek we start with the leader and walk nr
30933098 * threads past it.
30943099 */
3095−static struct task_struct *first_tid(struct task_struct *leader,
3096− int tid, int nr, struct pid_namespace *ns)
3100+static struct task_struct *first_tid(struct pid *pid, int tid, loff_t f_pos,
3101+ struct pid_namespace *ns)
30973102 {
3098− struct task_struct *pos;
3103+ struct task_struct *pos, *task;
3104+ unsigned long nr = f_pos;
3105+
3106+ if (nr != f_pos) /* 32bit overflow? */
3107+ return NULL;
30993108
31003109 rcu_read_lock();
3101− /* Attempt to start with the pid of a thread */
3102− if (tid && (nr > 0)) {
3110+ task = pid_task(pid, PIDTYPE_PID);
3111+ if (!task)
3112+ goto fail;
3113+
3114+ /* Attempt to start with the tid of a thread */
3115+ if (tid && nr) {
31033116 pos = find_task_by_pid_ns(tid, ns);
3104− if (pos && (pos->group_leader == leader))
3117+ if (pos && same_thread_group(pos, task))
31053118 goto found;
31063119 }
31073120
31083121 /* If nr exceeds the number of threads there is nothing todo */
3109− pos = NULL;
3110− if (nr && nr >= get_nr_threads(leader))
3111− goto out;
3122+ if (nr >= get_nr_threads(task))
3123+ goto fail;
31123124
31133125 /* If we haven't found our starting place yet start
31143126 * with the leader and walk nr threads forward.
31153127 */
3116− for (pos = leader; nr > 0; --nr) {
3117− pos = next_thread(pos);
3118− if (pos == leader) {
3119− pos = NULL;
3120− goto out;
3121− }
3122− }
3128+ pos = task = task->group_leader;
3129+ do {
3130+ if (!nr--)
3131+ goto found;
3132+ } while_each_thread(task, pos);
3133+fail:
3134+ pos = NULL;
3135+ goto out;
31233136 found:
31243137 get_task_struct(pos);
31253138 out:
@@ -3152,25 +3165,16 @@ static struct task_struct *next_tid(struct task_struct *start) · 26 unmodified lines
31523165 /* for the /proc/TGID/task/ directories */
31533166 static int proc_task_readdir(struct file *file, struct dir_context *ctx)
31543167 {
3155− struct task_struct *leader = NULL;
3156− struct task_struct *task = get_proc_task(file_inode(file));
3168+ struct inode *inode = file_inode(file);
3169+ struct task_struct *task;
31573170 struct pid_namespace *ns;
31583171 int tid;
31593172
3160− if (!task)
3161− return -ENOENT;
3162− rcu_read_lock();
3163− if (pid_alive(task)) {
3164− leader = task->group_leader;
3165− get_task_struct(leader);
3166− }
3167− rcu_read_unlock();
3168− put_task_struct(task);
3169− if (!leader)
3173+ if (proc_inode_is_dead(inode))
31703174 return -ENOENT;
31713175
31723176 if (!dir_emit_dots(file, ctx))
3173− goto out;
3177+ return 0;
31743178
31753179 /* f_version caches the tgid value that the last readdir call couldn't
31763180 * return. lseek aka telldir automagically resets f_version to 0.
@@ -3178,7 +3182,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx) · 1 unmodified line
31783182 ns = file->f_dentry->d_sb->s_fs_info;
31793183 tid = (int)file->f_version;
31803184 file->f_version = 0;
3181− for (task = first_tid(leader, tid, ctx->pos - 2, ns);
3185+ for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);
31823186 task;
31833187 task = next_tid(task), ctx->pos++) {
31843188 char name[PROC_NUMBUF];
@@ -3194,8 +3198,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx) · 9 unmodified lines
31943198 break;
31953199 }
31963200 }
3197−out:
3198− put_task_struct(leader);
3201+
31993202 return 0;
32003203 }
32013204
fs/proc/cmdline.c+1−1
@@ -26,4 +26,4 @@ static int __init proc_cmdline_init(void) · 25 unmodified lines
2626 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
2727 return 0;
2828 }
29−module_init(proc_cmdline_init);
29+fs_initcall(proc_cmdline_init);
fs/proc/consoles.c+1−1
@@ -109,4 +109,4 @@ static int __init proc_consoles_init(void) · 108 unmodified lines
109109 proc_create("consoles", 0, NULL, &proc_consoles_operations);
110110 return 0;
111111 }
112−module_init(proc_consoles_init);
112+fs_initcall(proc_consoles_init);
fs/proc/cpuinfo.c+1−1
@@ -21,4 +21,4 @@ static int __init proc_cpuinfo_init(void) · 20 unmodified lines
2121 proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
2222 return 0;
2323 }
24−module_init(proc_cpuinfo_init);
24+fs_initcall(proc_cpuinfo_init);
fs/proc/devices.c+1−1
@@ -67,4 +67,4 @@ static int __init proc_devices_init(void) · 66 unmodified lines
6767 proc_create("devices", 0, NULL, &proc_devinfo_operations);
6868 return 0;
6969 }
70−module_init(proc_devices_init);
70+fs_initcall(proc_devices_init);
fs/proc/generic.c+1−2
@@ -49,8 +49,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) · 48 unmodified lines
4949 setattr_copy(inode, iattr);
5050 mark_inode_dirty(inode);
5151
52− de->uid = inode->i_uid;
53− de->gid = inode->i_gid;
52+ proc_set_user(de, inode->i_uid, inode->i_gid);
5453 de->mode = inode->i_mode;
5554 return 0;
5655 }
fs/proc/interrupts.c+1−1
@@ -50,4 +50,4 @@ static int __init proc_interrupts_init(void) · 49 unmodified lines
5050 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
5151 return 0;
5252 }
53−module_init(proc_interrupts_init);
53+fs_initcall(proc_interrupts_init);
fs/proc/kcore.c+1−1
@@ -639,4 +639,4 @@ static int __init proc_kcore_init(void) · 638 unmodified lines
639639
640640 return 0;
641641 }
642−module_init(proc_kcore_init);
642+fs_initcall(proc_kcore_init);
fs/proc/kmsg.c+1−1
@@ -61,4 +61,4 @@ static int __init proc_kmsg_init(void) · 60 unmodified lines
6161 proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
6262 return 0;
6363 }
64−module_init(proc_kmsg_init);
64+fs_initcall(proc_kmsg_init);
fs/proc/loadavg.c+1−1
@@ -42,4 +42,4 @@ static int __init proc_loadavg_init(void) · 41 unmodified lines
4242 proc_create("loadavg", 0, NULL, &loadavg_proc_fops);
4343 return 0;
4444 }
45−module_init(proc_loadavg_init);
45+fs_initcall(proc_loadavg_init);
fs/proc/meminfo.c+1−1
@@ -220,4 +220,4 @@ static int __init proc_meminfo_init(void) · 219 unmodified lines
220220 proc_create("meminfo", 0, NULL, &meminfo_proc_fops);
221221 return 0;
222222 }
223−module_init(proc_meminfo_init);
223+fs_initcall(proc_meminfo_init);
fs/proc/nommu.c+1−1
@@ -131,4 +131,4 @@ static int __init proc_nommu_init(void) · 130 unmodified lines
131131 return 0;
132132 }
133133
134−module_init(proc_nommu_init);
134+fs_initcall(proc_nommu_init);
fs/proc/page.c+6−4
@@ -118,10 +118,12 @@ u64 stable_page_flags(struct page *page) · 117 unmodified lines
118118 /*
119119 * PageTransCompound can be true for non-huge compound pages (slab
120120 * pages or pages allocated by drivers with __GFP_COMP) because it
121− * just checks PG_head/PG_tail, so we need to check PageLRU to make
122− * sure a given page is a thp, not a non-huge compound page.
121+ * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon
122+ * to make sure a given page is a thp, not a non-huge compound page.
123123 */
124− else if (PageTransCompound(page) && PageLRU(compound_trans_head(page)))
124+ else if (PageTransCompound(page) &&
125+ (PageLRU(compound_trans_head(page)) ||
126+ PageAnon(compound_trans_head(page))))
125127 u |= 1 << KPF_THP;
126128
127129 /*
@@ -217,4 +219,4 @@ static int __init proc_page_init(void) · 89 unmodified lines
217219 proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations);
218220 return 0;
219221 }
220−module_init(proc_page_init);
222+fs_initcall(proc_page_init);
fs/proc/proc_devtree.c+3−2
@@ -74,9 +74,9 @@ __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp, · 73 unmodified lines
7474 return NULL;
7575
7676 if (!strncmp(name, "security-", 9))
77− ent->size = 0; /* don't leak number of password chars */
77+ proc_set_size(ent, 0); /* don't leak number of password chars */
7878 else
79− ent->size = pp->length;
79+ proc_set_size(ent, pp->length);
8080
8181 return ent;
8282 }
@@ -232,6 +232,7 @@ void __init proc_device_tree_init(void) · 149 unmodified lines
232232 return;
233233 root = of_find_node_by_path("/");
234234 if (root == NULL) {
235+ remove_proc_entry("device-tree", NULL);
235236 pr_debug("/proc/device-tree: can't find root\n");
236237 return;
237238 }
fs/proc/softirqs.c+1−1
@@ -41,4 +41,4 @@ static int __init proc_softirqs_init(void) · 40 unmodified lines
4141 proc_create("softirqs", 0, NULL, &proc_softirqs_operations);
4242 return 0;
4343 }
44−module_init(proc_softirqs_init);
44+fs_initcall(proc_softirqs_init);
fs/proc/stat.c+1−1
@@ -221,4 +221,4 @@ static int __init proc_stat_init(void) · 220 unmodified lines
221221 proc_create("stat", 0, NULL, &proc_stat_operations);
222222 return 0;
223223 }
224−module_init(proc_stat_init);
224+fs_initcall(proc_stat_init);
fs/proc/uptime.c+1−1
@@ -49,4 +49,4 @@ static int __init proc_uptime_init(void) · 48 unmodified lines
4949 proc_create("uptime", 0, NULL, &uptime_proc_fops);
5050 return 0;
5151 }
52−module_init(proc_uptime_init);
52+fs_initcall(proc_uptime_init);
fs/proc/version.c+1−1
@@ -31,4 +31,4 @@ static int __init proc_version_init(void) · 30 unmodified lines
3131 proc_create("version", 0, NULL, &version_proc_fops);
3232 return 0;
3333 }
34−module_init(proc_version_init);
34+fs_initcall(proc_version_init);
fs/proc/vmcore.c+1−1
@@ -1082,7 +1082,7 @@ static int __init vmcore_init(void) · 1081 unmodified lines
10821082 proc_vmcore->size = vmcore_size;
10831083 return 0;
10841084 }
1085−module_init(vmcore_init)
1085+fs_initcall(vmcore_init);
10861086
10871087 /* Cleanup function for vmcore module. */
10881088 void vmcore_cleanup(void)
fs/proc_namespace.c+1−6
@@ -234,17 +234,12 @@ static int mounts_open_common(struct inode *inode, struct file *file, · 233 unmodified lines
234234
235235 rcu_read_lock();
236236 nsp = task_nsproxy(task);
237− if (!nsp) {
237+ if (!nsp || !nsp->mnt_ns) {
238238 rcu_read_unlock();
239239 put_task_struct(task);
240240 goto err;
241241 }
242242 ns = nsp->mnt_ns;
243− if (!ns) {
244− rcu_read_unlock();
245− put_task_struct(task);
246− goto err;
247− }
248243 get_mnt_ns(ns);
249244 rcu_read_unlock();
250245 task_lock(task);
fs/ramfs/file-mmu.c+0−7
@@ -30,13 +30,6 @@ · 29 unmodified lines
3030
3131 #include "internal.h"
3232
33−const struct address_space_operations ramfs_aops = {
34− .readpage = simple_readpage,
35− .write_begin = simple_write_begin,
36− .write_end = simple_write_end,
37− .set_page_dirty = __set_page_dirty_no_writeback,
38−};
39−
4033 const struct file_operations ramfs_file_operations = {
4134 .read = do_sync_read,
4235 .aio_read = generic_file_aio_read,
fs/ramfs/file-nommu.c+8−9
@@ -27,13 +27,12 @@ · 26 unmodified lines
2727 #include "internal.h"
2828
2929 static int ramfs_nommu_setattr(struct dentry *, struct iattr *);
30−
31−const struct address_space_operations ramfs_aops = {
32− .readpage = simple_readpage,
33− .write_begin = simple_write_begin,
34− .write_end = simple_write_end,
35− .set_page_dirty = __set_page_dirty_no_writeback,
36−};
30+static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
31+ unsigned long addr,
32+ unsigned long len,
33+ unsigned long pgoff,
34+ unsigned long flags);
35+static int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma);
3736
3837 const struct file_operations ramfs_file_operations = {
3938 .mmap = ramfs_nommu_mmap,
@@ -197,7 +196,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) · 157 unmodified lines
197196 * - the pages to be mapped must exist
198197 * - the pages be physically contiguous in sequence
199198 */
200−unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
199+static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
201200 unsigned long addr, unsigned long len,
202201 unsigned long pgoff, unsigned long flags)
203202 {
@@ -256,7 +255,7 @@ out: · 52 unmodified lines
256255 /*
257256 * set up a mapping for shared memory segments
258257 */
259−int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
258+static int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
260259 {
261260 if (!(vma->vm_flags & VM_SHARED))
262261 return -ENOSYS;
fs/ramfs/inode.c+7−0
@@ -43,6 +43,13 @@ · 42 unmodified lines
4343 static const struct super_operations ramfs_ops;
4444 static const struct inode_operations ramfs_dir_inode_operations;
4545
46+static const struct address_space_operations ramfs_aops = {
47+ .readpage = simple_readpage,
48+ .write_begin = simple_write_begin,
49+ .write_end = simple_write_end,
50+ .set_page_dirty = __set_page_dirty_no_writeback,
51+};
52+
4653 static struct backing_dev_info ramfs_backing_dev_info = {
4754 .name = "ramfs",
4855 .ra_pages = 0, /* No readahead */
fs/ramfs/internal.h+0−1
@@ -10,5 +10,4 @@ · 9 unmodified lines
1010 */
1111
1212
13−extern const struct address_space_operations ramfs_aops;
1413 extern const struct inode_operations ramfs_file_inode_operations;
fs/reiserfs/reiserfs.h+0−2
@@ -1958,8 +1958,6 @@ struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,} · 1957 unmodified lines
19581958 #define MAX_US_INT 0xffff
19591959
19601960 // reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset
1961−#define U32_MAX (~(__u32)0)
1962−
19631961 static inline loff_t max_reiserfs_offset(struct inode *inode)
19641962 {
19651963 if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
fs/romfs/super.c+2−4
@@ -533,16 +533,14 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent) · 532 unmodified lines
533533
534534 root = romfs_iget(sb, pos);
535535 if (IS_ERR(root))
536− goto error;
536+ return PTR_ERR(root);
537537
538538 sb->s_root = d_make_root(root);
539539 if (!sb->s_root)
540− goto error;
540+ return -ENOMEM;
541541
542542 return 0;
543543
544−error:
545− return -EINVAL;
546544 error_rsb_inval:
547545 ret = -EINVAL;
548546 error_rsb:
fs/ubifs/debug.c+3−19
@@ -2118,26 +2118,10 @@ out_free: · 2117 unmodified lines
21182118 */
21192119 static void free_inodes(struct fsck_data *fsckd)
21202120 {
2121− struct rb_node *this = fsckd->inodes.rb_node;
2122− struct fsck_inode *fscki;
2121+ struct fsck_inode *fscki, *n;
21232122
2124− while (this) {
2125− if (this->rb_left)
2126− this = this->rb_left;
2127− else if (this->rb_right)
2128− this = this->rb_right;
2129− else {
2130− fscki = rb_entry(this, struct fsck_inode, rb);
2131− this = rb_parent(this);
2132− if (this) {
2133− if (this->rb_left == &fscki->rb)
2134− this->rb_left = NULL;
2135− else
2136− this->rb_right = NULL;
2137− }
2138− kfree(fscki);
2139− }
2140− }
2123+ rbtree_postorder_for_each_entry_safe(fscki, n, &fsckd->inodes, rb)
2124+ kfree(fscki);
21412125 }
21422126
21432127 /**
fs/ubifs/log.c+2−19
@@ -574,27 +574,10 @@ static int done_already(struct rb_root *done_tree, int lnum) · 573 unmodified lines
574574 */
575575 static void destroy_done_tree(struct rb_root *done_tree)
576576 {
577− struct rb_node *this = done_tree->rb_node;
578− struct done_ref *dr;
577+ struct done_ref *dr, *n;
579578
580− while (this) {
581− if (this->rb_left) {
582− this = this->rb_left;
583− continue;
584− } else if (this->rb_right) {
585− this = this->rb_right;
586− continue;
587− }
588− dr = rb_entry(this, struct done_ref, rb);
589− this = rb_parent(this);
590− if (this) {
591− if (this->rb_left == &dr->rb)
592− this->rb_left = NULL;
593− else
594− this->rb_right = NULL;
595− }
579+ rbtree_postorder_for_each_entry_safe(dr, n, done_tree, rb)
596580 kfree(dr);
597− }
598581 }
599582
600583 /**
fs/ubifs/orphan.c+2−19
@@ -815,27 +815,10 @@ static int dbg_find_check_orphan(struct rb_root *root, ino_t inum) · 814 unmodified lines
815815
816816 static void dbg_free_check_tree(struct rb_root *root)
817817 {
818− struct rb_node *this = root->rb_node;
819− struct check_orphan *o;
818+ struct check_orphan *o, *n;
820819
821− while (this) {
822− if (this->rb_left) {
823− this = this->rb_left;
824− continue;
825− } else if (this->rb_right) {
826− this = this->rb_right;
827− continue;
828− }
829− o = rb_entry(this, struct check_orphan, rb);
830− this = rb_parent(this);
831− if (this) {
832− if (this->rb_left == &o->rb)
833− this->rb_left = NULL;
834− else
835− this->rb_right = NULL;
836− }
820+ rbtree_postorder_for_each_entry_safe(o, n, root, rb)
837821 kfree(o);
838− }
839822 }
840823
841824 static int dbg_orphan_check(struct ubifs_info *c, struct ubifs_zbranch *zbr,
fs/ubifs/recovery.c+3−18
@@ -1335,29 +1335,14 @@ static void remove_ino(struct ubifs_info *c, ino_t inum) · 1334 unmodified lines
13351335 */
13361336 void ubifs_destroy_size_tree(struct ubifs_info *c)
13371337 {
1338− struct rb_node *this = c->size_tree.rb_node;
1339− struct size_entry *e;
1338+ struct size_entry *e, *n;
13401339
1341− while (this) {
1342− if (this->rb_left) {
1343− this = this->rb_left;
1344− continue;
1345− } else if (this->rb_right) {
1346− this = this->rb_right;
1347− continue;
1348− }
1349− e = rb_entry(this, struct size_entry, rb);
1340+ rbtree_postorder_for_each_entry_safe(e, n, &c->size_tree, rb) {
13501341 if (e->inode)
13511342 iput(e->inode);
1352− this = rb_parent(this);
1353− if (this) {
1354− if (this->rb_left == &e->rb)
1355− this->rb_left = NULL;
1356− else
1357− this->rb_right = NULL;
1358− }
13591343 kfree(e);
13601344 }
1345+
13611346 c->size_tree = RB_ROOT;
13621347 }
13631348
fs/ubifs/super.c+4−20
@@ -873,26 +873,10 @@ static void free_orphans(struct ubifs_info *c) · 872 unmodified lines
873873 */
874874 static void free_buds(struct ubifs_info *c)
875875 {
876− struct rb_node *this = c->buds.rb_node;
877− struct ubifs_bud *bud;
878−
879− while (this) {
880− if (this->rb_left)
881− this = this->rb_left;
882− else if (this->rb_right)
883− this = this->rb_right;
884− else {
885− bud = rb_entry(this, struct ubifs_bud, rb);
886− this = rb_parent(this);
887− if (this) {
888− if (this->rb_left == &bud->rb)
889− this->rb_left = NULL;
890− else
891− this->rb_right = NULL;
892− }
893− kfree(bud);
894− }
895− }
876+ struct ubifs_bud *bud, *n;
877+
878+ rbtree_postorder_for_each_entry_safe(bud, n, &c->buds, rb)
879+ kfree(bud);
896880 }
897881
898882 /**
fs/ubifs/tnc.c+3−19
@@ -178,27 +178,11 @@ static int ins_clr_old_idx_znode(struct ubifs_info *c, · 177 unmodified lines
178178 */
179179 void destroy_old_idx(struct ubifs_info *c)
180180 {
181− struct rb_node *this = c->old_idx.rb_node;
182− struct ubifs_old_idx *old_idx;
181+ struct ubifs_old_idx *old_idx, *n;
183182
184− while (this) {
185− if (this->rb_left) {
186− this = this->rb_left;
187− continue;
188− } else if (this->rb_right) {
189− this = this->rb_right;
190− continue;
191− }
192− old_idx = rb_entry(this, struct ubifs_old_idx, rb);
193− this = rb_parent(this);
194− if (this) {
195− if (this->rb_left == &old_idx->rb)
196− this->rb_left = NULL;
197− else
198− this->rb_right = NULL;
199− }
183+ rbtree_postorder_for_each_entry_safe(old_idx, n, &c->old_idx, rb)
200184 kfree(old_idx);
201− }
185+
202186 c->old_idx = RB_ROOT;
203187 }
204188
include/asm-generic/fixmap.h+97−0
@@ -0,0 +1,97 @@
1+/*
2+ * fixmap.h: compile-time virtual memory allocation
3+ *
4+ * This file is subject to the terms and conditions of the GNU General Public
5+ * License. See the file "COPYING" in the main directory of this archive
6+ * for more details.
7+ *
8+ * Copyright (C) 1998 Ingo Molnar
9+ *
10+ * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
11+ * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009
12+ * Break out common bits to asm-generic by Mark Salter, November 2013
13+ */
14+
15+#ifndef __ASM_GENERIC_FIXMAP_H
16+#define __ASM_GENERIC_FIXMAP_H
17+
18+#include <linux/bug.h>
19+
20+#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
21+#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
22+
23+#ifndef __ASSEMBLY__
24+/*
25+ * 'index to address' translation. If anyone tries to use the idx
26+ * directly without translation, we catch the bug with a NULL-deference
27+ * kernel oops. Illegal ranges of incoming indices are caught too.
28+ */
29+static __always_inline unsigned long fix_to_virt(const unsigned int idx)
30+{
31+ BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
32+ return __fix_to_virt(idx);
33+}
34+
35+static inline unsigned long virt_to_fix(const unsigned long vaddr)
36+{
37+ BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
38+ return __virt_to_fix(vaddr);
39+}
40+
41+/*
42+ * Provide some reasonable defaults for page flags.
43+ * Not all architectures use all of these different types and some
44+ * architectures use different names.
45+ */
46+#ifndef FIXMAP_PAGE_NORMAL
47+#define FIXMAP_PAGE_NORMAL PAGE_KERNEL
48+#endif
49+#ifndef FIXMAP_PAGE_NOCACHE
50+#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
51+#endif
52+#ifndef FIXMAP_PAGE_IO
53+#define FIXMAP_PAGE_IO PAGE_KERNEL_IO
54+#endif
55+#ifndef FIXMAP_PAGE_CLEAR
56+#define FIXMAP_PAGE_CLEAR __pgprot(0)
57+#endif
58+
59+#ifndef set_fixmap
60+#define set_fixmap(idx, phys) \
61+ __set_fixmap(idx, phys, FIXMAP_PAGE_NORMAL)
62+#endif
63+
64+#ifndef clear_fixmap
65+#define clear_fixmap(idx) \
66+ __set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR)
67+#endif
68+
69+/* Return a pointer with offset calculated */
70+#define __set_fixmap_offset(idx, phys, flags) \
71+({ \
72+ unsigned long addr; \
73+ __set_fixmap(idx, phys, flags); \
74+ addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
75+ addr; \
76+})
77+
78+#define set_fixmap_offset(idx, phys) \
79+ __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL)
80+
81+/*
82+ * Some hardware wants to get fixmapped without caching.
83+ */
84+#define set_fixmap_nocache(idx, phys) \
85+ __set_fixmap(idx, phys, FIXMAP_PAGE_NOCACHE)
86+
87+#define set_fixmap_offset_nocache(idx, phys) \
88+ __set_fixmap_offset(idx, phys, FIXMAP_PAGE_NOCACHE)
89+
90+/*
91+ * Some fixmaps are for IO
92+ */
93+#define set_fixmap_io(idx, phys) \
94+ __set_fixmap(idx, phys, FIXMAP_PAGE_IO)
95+
96+#endif /* __ASSEMBLY__ */
97+#endif /* __ASM_GENERIC_FIXMAP_H */
include/asm-generic/int-l64.h+0−49
@@ -1,49 +0,0 @@
1−/*
2− * asm-generic/int-l64.h
3− *
4− * Integer declarations for architectures which use "long"
5− * for 64-bit types.
6− */
7−#ifndef _ASM_GENERIC_INT_L64_H
8−#define _ASM_GENERIC_INT_L64_H
9−
10−#include <uapi/asm-generic/int-l64.h>
11−
12−
13−#ifndef __ASSEMBLY__
14−
15−typedef signed char s8;
16−typedef unsigned char u8;
17−
18−typedef signed short s16;
19−typedef unsigned short u16;
20−
21−typedef signed int s32;
22−typedef unsigned int u32;
23−
24−typedef signed long s64;
25−typedef unsigned long u64;
26−
27−#define S8_C(x) x
28−#define U8_C(x) x ## U
29−#define S16_C(x) x
30−#define U16_C(x) x ## U
31−#define S32_C(x) x
32−#define U32_C(x) x ## U
33−#define S64_C(x) x ## L
34−#define U64_C(x) x ## UL
35−
36−#else /* __ASSEMBLY__ */
37−
38−#define S8_C(x) x
39−#define U8_C(x) x
40−#define S16_C(x) x
41−#define U16_C(x) x
42−#define S32_C(x) x
43−#define U32_C(x) x
44−#define S64_C(x) x
45−#define U64_C(x) x
46−
47−#endif /* __ASSEMBLY__ */
48−
49−#endif /* _ASM_GENERIC_INT_L64_H */
include/linux/cache.h+2−2
@@ -1,11 +1,11 @@
11 #ifndef __LINUX_CACHE_H
22 #define __LINUX_CACHE_H
33
4−#include <linux/kernel.h>
4+#include <uapi/linux/kernel.h>
55 #include <asm/cache.h>
66
77 #ifndef L1_CACHE_ALIGN
8−#define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES)
8+#define L1_CACHE_ALIGN(x) __ALIGN_KERNEL(x, L1_CACHE_BYTES)
99 #endif
1010
1111 #ifndef SMP_CACHE_BYTES
include/linux/ceph/decode.h+0−17
@@ -8,23 +8,6 @@ · 7 unmodified lines
88
99 #include <linux/ceph/types.h>
1010
11−/* This seemed to be the easiest place to define these */
12−
13−#define U8_MAX ((u8)(~0U))
14−#define U16_MAX ((u16)(~0U))
15−#define U32_MAX ((u32)(~0U))
16−#define U64_MAX ((u64)(~0ULL))
17−
18−#define S8_MAX ((s8)(U8_MAX >> 1))
19−#define S16_MAX ((s16)(U16_MAX >> 1))
20−#define S32_MAX ((s32)(U32_MAX >> 1))
21−#define S64_MAX ((s64)(U64_MAX >> 1LL))
22−
23−#define S8_MIN ((s8)(-S8_MAX - 1))
24−#define S16_MIN ((s16)(-S16_MAX - 1))
25−#define S32_MIN ((s32)(-S32_MAX - 1))
26−#define S64_MIN ((s64)(-S64_MAX - 1LL))
27−
2811 /*
2912 * in all cases,
3013 * void **p pointer to position pointer
include/linux/genalloc.h+2−0
@@ -30,6 +30,8 @@ · 29 unmodified lines
3030 #ifndef __GENALLOC_H__
3131 #define __GENALLOC_H__
3232
33+#include <linux/spinlock_types.h>
34+
3335 struct device;
3436 struct device_node;
3537
include/linux/gfp.h+1−0
@@ -1,6 +1,7 @@
11 #ifndef __LINUX_GFP_H
22 #define __LINUX_GFP_H
33
4+#include <linux/mmdebug.h>
45 #include <linux/mmzone.h>
56 #include <linux/stddef.h>
67 #include <linux/linkage.h>
include/linux/hugetlb.h+2−1
@@ -2,6 +2,7 @@ · 1 unmodified line
22 #define _LINUX_HUGETLB_H
33
44 #include <linux/mm_types.h>
5+#include <linux/mmdebug.h>
56 #include <linux/fs.h>
67 #include <linux/hugetlb_inline.h>
78 #include <linux/cgroup.h>
@@ -354,7 +355,7 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma, · 346 unmodified lines
354355
355356 static inline struct hstate *page_hstate(struct page *page)
356357 {
357− VM_BUG_ON(!PageHuge(page));
358+ VM_BUG_ON_PAGE(!PageHuge(page), page);
358359 return size_to_hstate(PAGE_SIZE << compound_order(page));
359360 }
360361
include/linux/hugetlb_cgroup.h+3−2
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #ifndef _LINUX_HUGETLB_CGROUP_H
1616 #define _LINUX_HUGETLB_CGROUP_H
1717
18+#include <linux/mmdebug.h>
1819 #include <linux/res_counter.h>
1920
2021 struct hugetlb_cgroup;
@@ -28,7 +29,7 @@ struct hugetlb_cgroup; · 7 unmodified lines
2829
2930 static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page)
3031 {
31− VM_BUG_ON(!PageHuge(page));
32+ VM_BUG_ON_PAGE(!PageHuge(page), page);
3233
3334 if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
3435 return NULL;
@@ -38,7 +39,7 @@ static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page) · 3 unmodified lines
3839 static inline
3940 int set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg)
4041 {
41− VM_BUG_ON(!PageHuge(page));
42+ VM_BUG_ON_PAGE(!PageHuge(page), page);
4243
4344 if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
4445 return -1;
include/linux/kernel.h+13−0
@@ -29,6 +29,19 @@ · 28 unmodified lines
2929 #define ULLONG_MAX (~0ULL)
3030 #define SIZE_MAX (~(size_t)0)
3131
32+#define U8_MAX ((u8)~0U)
33+#define S8_MAX ((s8)(U8_MAX>>1))
34+#define S8_MIN ((s8)(-S8_MAX - 1))
35+#define U16_MAX ((u16)~0U)
36+#define S16_MAX ((s16)(U16_MAX>>1))
37+#define S16_MIN ((s16)(-S16_MAX - 1))
38+#define U32_MAX ((u32)~0U)
39+#define S32_MAX ((s32)(U32_MAX>>1))
40+#define S32_MIN ((s32)(-S32_MAX - 1))
41+#define U64_MAX ((u64)~0ULL)
42+#define S64_MAX ((s64)(U64_MAX>>1))
43+#define S64_MIN ((s64)(-S64_MAX - 1))
44+
3245 #define STACK_MAGIC 0xdeadbeef
3346
3447 #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
include/linux/kexec.h+1−0
@@ -170,6 +170,7 @@ unsigned long paddr_vmcoreinfo_note(void); · 169 unmodified lines
170170
171171 extern struct kimage *kexec_image;
172172 extern struct kimage *kexec_crash_image;
173+extern int kexec_load_disabled;
173174
174175 #ifndef kexec_flush_icache_page
175176 #define kexec_flush_icache_page(page)
include/linux/memblock.h+1−0
@@ -61,6 +61,7 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align, · 60 unmodified lines
6161 phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
6262 phys_addr_t size, phys_addr_t align);
6363 phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
64+phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
6465 void memblock_allow_resize(void);
6566 int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
6667 int memblock_add(phys_addr_t base, phys_addr_t size);
include/linux/memcontrol.h+13−10
@@ -497,10 +497,11 @@ void __memcg_kmem_commit_charge(struct page *page, · 496 unmodified lines
497497 void __memcg_kmem_uncharge_pages(struct page *page, int order);
498498
499499 int memcg_cache_id(struct mem_cgroup *memcg);
500−int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
501− struct kmem_cache *root_cache);
502−void memcg_release_cache(struct kmem_cache *cachep);
503−void memcg_cache_list_add(struct mem_cgroup *memcg, struct kmem_cache *cachep);
500+int memcg_alloc_cache_params(struct mem_cgroup *memcg, struct kmem_cache *s,
501+ struct kmem_cache *root_cache);
502+void memcg_free_cache_params(struct kmem_cache *s);
503+void memcg_register_cache(struct kmem_cache *s);
504+void memcg_unregister_cache(struct kmem_cache *s);
504505
505506 int memcg_update_cache_size(struct kmem_cache *s, int num_groups);
506507 void memcg_update_array_size(int num_groups);
@@ -640,19 +641,21 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg) · 133 unmodified lines
640641 return -1;
641642 }
642643
643−static inline int
644−memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
645− struct kmem_cache *root_cache)
644+static inline int memcg_alloc_cache_params(struct mem_cgroup *memcg,
645+ struct kmem_cache *s, struct kmem_cache *root_cache)
646646 {
647647 return 0;
648648 }
649649
650−static inline void memcg_release_cache(struct kmem_cache *cachep)
650+static inline void memcg_free_cache_params(struct kmem_cache *s)
651+{
652+}
653+
654+static inline void memcg_register_cache(struct kmem_cache *s)
651655 {
652656 }
653657
654−static inline void memcg_cache_list_add(struct mem_cgroup *memcg,
655− struct kmem_cache *s)
658+static inline void memcg_unregister_cache(struct kmem_cache *s)
656659 {
657660 }
658661
include/linux/mm.h+13−14
@@ -5,6 +5,7 @@ · 4 unmodified lines
55
66 #ifdef __KERNEL__
77
8+#include <linux/mmdebug.h>
89 #include <linux/gfp.h>
910 #include <linux/bug.h>
1011 #include <linux/list.h>
@@ -303,7 +304,7 @@ static inline int get_freepage_migratetype(struct page *page) · 292 unmodified lines
303304 */
304305 static inline int put_page_testzero(struct page *page)
305306 {
306− VM_BUG_ON(atomic_read(&page->_count) == 0);
307+ VM_BUG_ON_PAGE(atomic_read(&page->_count) == 0, page);
307308 return atomic_dec_and_test(&page->_count);
308309 }
309310
@@ -364,7 +365,7 @@ static inline int is_vmalloc_or_module_addr(const void *x) · 54 unmodified lines
364365 static inline void compound_lock(struct page *page)
365366 {
366367 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
367− VM_BUG_ON(PageSlab(page));
368+ VM_BUG_ON_PAGE(PageSlab(page), page);
368369 bit_spin_lock(PG_compound_lock, &page->flags);
369370 #endif
370371 }
@@ -372,7 +373,7 @@ static inline void compound_lock(struct page *page) · 1 unmodified line
372373 static inline void compound_unlock(struct page *page)
373374 {
374375 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
375− VM_BUG_ON(PageSlab(page));
376+ VM_BUG_ON_PAGE(PageSlab(page), page);
376377 bit_spin_unlock(PG_compound_lock, &page->flags);
377378 #endif
378379 }
@@ -447,7 +448,7 @@ static inline bool __compound_tail_refcounted(struct page *page) · 68 unmodified lines
447448 */
448449 static inline bool compound_tail_refcounted(struct page *page)
449450 {
450− VM_BUG_ON(!PageHead(page));
451+ VM_BUG_ON_PAGE(!PageHead(page), page);
451452 return __compound_tail_refcounted(page);
452453 }
453454
@@ -456,9 +457,9 @@ static inline void get_huge_page_tail(struct page *page) · 2 unmodified lines
456457 /*
457458 * __split_huge_page_refcount() cannot run from under us.
458459 */
459− VM_BUG_ON(!PageTail(page));
460− VM_BUG_ON(page_mapcount(page) < 0);
461− VM_BUG_ON(atomic_read(&page->_count) != 0);
460+ VM_BUG_ON_PAGE(!PageTail(page), page);
461+ VM_BUG_ON_PAGE(page_mapcount(page) < 0, page);
462+ VM_BUG_ON_PAGE(atomic_read(&page->_count) != 0, page);
462463 if (compound_tail_refcounted(page->first_page))
463464 atomic_inc(&page->_mapcount);
464465 }
@@ -474,7 +475,7 @@ static inline void get_page(struct page *page) · 9 unmodified lines
474475 * Getting a normal page or the head of a compound page
475476 * requires to already have an elevated page->_count.
476477 */
477− VM_BUG_ON(atomic_read(&page->_count) <= 0);
478+ VM_BUG_ON_PAGE(atomic_read(&page->_count) <= 0, page);
478479 atomic_inc(&page->_count);
479480 }
480481
@@ -511,13 +512,13 @@ static inline int PageBuddy(struct page *page) · 30 unmodified lines
511512
512513 static inline void __SetPageBuddy(struct page *page)
513514 {
514− VM_BUG_ON(atomic_read(&page->_mapcount) != -1);
515+ VM_BUG_ON_PAGE(atomic_read(&page->_mapcount) != -1, page);
515516 atomic_set(&page->_mapcount, PAGE_BUDDY_MAPCOUNT_VALUE);
516517 }
517518
518519 static inline void __ClearPageBuddy(struct page *page)
519520 {
520− VM_BUG_ON(!PageBuddy(page));
521+ VM_BUG_ON_PAGE(!PageBuddy(page), page);
521522 atomic_set(&page->_mapcount, -1);
522523 }
523524
@@ -1401,7 +1402,7 @@ static inline bool ptlock_init(struct page *page) · 877 unmodified lines
14011402 * slab code uses page->slab_cache and page->first_page (for tail
14021403 * pages), which share storage with page->ptl.
14031404 */
1404− VM_BUG_ON(*(unsigned long *)&page->ptl);
1405+ VM_BUG_ON_PAGE(*(unsigned long *)&page->ptl, page);
14051406 if (!ptlock_alloc(page))
14061407 return false;
14071408 spin_lock_init(ptlock_ptr(page));
@@ -1492,7 +1493,7 @@ static inline bool pgtable_pmd_page_ctor(struct page *page) · 84 unmodified lines
14921493 static inline void pgtable_pmd_page_dtor(struct page *page)
14931494 {
14941495 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
1495− VM_BUG_ON(page->pmd_huge_pte);
1496+ VM_BUG_ON_PAGE(page->pmd_huge_pte, page);
14961497 #endif
14971498 ptlock_free(page);
14981499 }
@@ -2029,8 +2030,6 @@ extern void shake_page(struct page *p, int access); · 530 unmodified lines
20292030 extern atomic_long_t num_poisoned_pages;
20302031 extern int soft_offline_page(struct page *page, int flags);
20312032
2032−extern void dump_page(struct page *page);
2033−
20342033 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
20352034 extern void clear_huge_page(struct page *page,
20362035 unsigned long addr,
include/linux/mmdebug.h+9−0
@@ -1,10 +1,19 @@
11 #ifndef LINUX_MM_DEBUG_H
22 #define LINUX_MM_DEBUG_H 1
33
4+struct page;
5+
6+extern void dump_page(struct page *page, char *reason);
7+extern void dump_page_badflags(struct page *page, char *reason,
8+ unsigned long badflags);
9+
410 #ifdef CONFIG_DEBUG_VM
511 #define VM_BUG_ON(cond) BUG_ON(cond)
12+#define VM_BUG_ON_PAGE(cond, page) \
13+ do { if (unlikely(cond)) { dump_page(page, NULL); BUG(); } } while (0)
614 #else
715 #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
16+#define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
817 #endif
918
1019 #ifdef CONFIG_DEBUG_VIRTUAL
include/linux/of.h+6−1
@@ -377,8 +377,13 @@ static inline bool of_have_populated_dt(void) · 376 unmodified lines
377377 return false;
378378 }
379379
380+/* Kill an unused variable warning on a device_node pointer */
381+static inline void __of_use_dn(const struct device_node *np)
382+{
383+}
384+
380385 #define for_each_child_of_node(parent, child) \
381− while (0)
386+ while (__of_use_dn(parent), __of_use_dn(child), 0)
382387
383388 #define for_each_available_child_of_node(parent, child) \
384389 while (0)
include/linux/page-flags.h+5−5
@@ -412,7 +412,7 @@ static inline void ClearPageCompound(struct page *page) · 411 unmodified lines
412412 */
413413 static inline int PageTransHuge(struct page *page)
414414 {
415− VM_BUG_ON(PageTail(page));
415+ VM_BUG_ON_PAGE(PageTail(page), page);
416416 return PageHead(page);
417417 }
418418
@@ -460,25 +460,25 @@ static inline int PageTransTail(struct page *page) · 41 unmodified lines
460460 */
461461 static inline int PageSlabPfmemalloc(struct page *page)
462462 {
463− VM_BUG_ON(!PageSlab(page));
463+ VM_BUG_ON_PAGE(!PageSlab(page), page);
464464 return PageActive(page);
465465 }
466466
467467 static inline void SetPageSlabPfmemalloc(struct page *page)
468468 {
469− VM_BUG_ON(!PageSlab(page));
469+ VM_BUG_ON_PAGE(!PageSlab(page), page);
470470 SetPageActive(page);
471471 }
472472
473473 static inline void __ClearPageSlabPfmemalloc(struct page *page)
474474 {
475− VM_BUG_ON(!PageSlab(page));
475+ VM_BUG_ON_PAGE(!PageSlab(page), page);
476476 __ClearPageActive(page);
477477 }
478478
479479 static inline void ClearPageSlabPfmemalloc(struct page *page)
480480 {
481− VM_BUG_ON(!PageSlab(page));
481+ VM_BUG_ON_PAGE(!PageSlab(page), page);
482482 ClearPageActive(page);
483483 }
484484
include/linux/pagemap.h+5−5
@@ -162,7 +162,7 @@ static inline int page_cache_get_speculative(struct page *page) · 161 unmodified lines
162162 * disabling preempt, and hence no need for the "speculative get" that
163163 * SMP requires.
164164 */
165− VM_BUG_ON(page_count(page) == 0);
165+ VM_BUG_ON_PAGE(page_count(page) == 0, page);
166166 atomic_inc(&page->_count);
167167
168168 #else
@@ -175,7 +175,7 @@ static inline int page_cache_get_speculative(struct page *page) · 6 unmodified lines
175175 return 0;
176176 }
177177 #endif
178− VM_BUG_ON(PageTail(page));
178+ VM_BUG_ON_PAGE(PageTail(page), page);
179179
180180 return 1;
181181 }
@@ -191,14 +191,14 @@ static inline int page_cache_add_speculative(struct page *page, int count) · 9 unmodified lines
191191 # ifdef CONFIG_PREEMPT_COUNT
192192 VM_BUG_ON(!in_atomic());
193193 # endif
194− VM_BUG_ON(page_count(page) == 0);
194+ VM_BUG_ON_PAGE(page_count(page) == 0, page);
195195 atomic_add(count, &page->_count);
196196
197197 #else
198198 if (unlikely(!atomic_add_unless(&page->_count, count, 0)))
199199 return 0;
200200 #endif
201− VM_BUG_ON(PageCompound(page) && page != compound_head(page));
201+ VM_BUG_ON_PAGE(PageCompound(page) && page != compound_head(page), page);
202202
203203 return 1;
204204 }
@@ -210,7 +210,7 @@ static inline int page_freeze_refs(struct page *page, int count) · 5 unmodified lines
210210
211211 static inline void page_unfreeze_refs(struct page *page, int count)
212212 {
213− VM_BUG_ON(page_count(page) != 0);
213+ VM_BUG_ON_PAGE(page_count(page) != 0, page);
214214 VM_BUG_ON(count == 0);
215215
216216 atomic_set(&page->_count, count);
include/linux/parser.h+1−0
@@ -29,5 +29,6 @@ int match_token(char *, const match_table_t table, substring_t args[]); · 28 unmodified lines
2929 int match_int(substring_t *, int *result);
3030 int match_octal(substring_t *, int *result);
3131 int match_hex(substring_t *, int *result);
32+bool match_wildcard(const char *pattern, const char *str);
3233 size_t match_strlcpy(char *, const substring_t *, size_t);
3334 char *match_strdup(const substring_t *);
include/linux/percpu.h+1−0
@@ -1,6 +1,7 @@
11 #ifndef __LINUX_PERCPU_H
22 #define __LINUX_PERCPU_H
33
4+#include <linux/mmdebug.h>
45 #include <linux/preempt.h>
56 #include <linux/smp.h>
67 #include <linux/cpumask.h>
include/linux/printk.h+10−9
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 #include <linux/init.h>
66 #include <linux/kern_levels.h>
77 #include <linux/linkage.h>
8+#include <linux/cache.h>
89
910 extern const char linux_banner[];
1011 extern const char linux_proc_banner[];
@@ -253,17 +254,17 @@ extern asmlinkage void dump_stack(void) __cold; · 242 unmodified lines
253254 */
254255
255256 #ifdef CONFIG_PRINTK
256−#define printk_once(fmt, ...) \
257−({ \
258− static bool __print_once; \
259− \
260− if (!__print_once) { \
261− __print_once = true; \
262− printk(fmt, ##__VA_ARGS__); \
263− } \
257+#define printk_once(fmt, ...) \
258+({ \
259+ static bool __print_once __read_mostly; \
260+ \
261+ if (!__print_once) { \
262+ __print_once = true; \
263+ printk(fmt, ##__VA_ARGS__); \
264+ } \
264265 })
265266 #else
266−#define printk_once(fmt, ...) \
267+#define printk_once(fmt, ...) \
267268 no_printk(fmt, ##__VA_ARGS__)
268269 #endif
269270
include/linux/ramfs.h+0−7
@@ -14,13 +14,6 @@ ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) · 13 unmodified lines
1414 }
1515 #else
1616 extern int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize);
17−extern unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
18− unsigned long addr,
19− unsigned long len,
20− unsigned long pgoff,
21− unsigned long flags);
22−
23−extern int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma);
2417 #endif
2518
2619 extern const struct file_operations ramfs_file_operations;
include/linux/sched.h+19−11
@@ -229,7 +229,7 @@ extern char ___assert_task_state[1 - 2*!!( · 228 unmodified lines
229229 /* get_task_state() */
230230 #define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
231231 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
232− __TASK_TRACED)
232+ __TASK_TRACED | EXIT_ZOMBIE | EXIT_DEAD)
233233
234234 #define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
235235 #define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
@@ -391,22 +391,33 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, · 155 unmodified lines
391391 static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
392392 #endif
393393
394−
395−extern void set_dumpable(struct mm_struct *mm, int value);
396−extern int get_dumpable(struct mm_struct *mm);
397−
398394 #define SUID_DUMP_DISABLE 0 /* No setuid dumping */
399395 #define SUID_DUMP_USER 1 /* Dump as user of process */
400396 #define SUID_DUMP_ROOT 2 /* Dump as root */
401397
402398 /* mm flags */
403−/* dumpable bits */
404−#define MMF_DUMPABLE 0 /* core dump is permitted */
405−#define MMF_DUMP_SECURELY 1 /* core file is readable only by root */
406399
400+/* for SUID_DUMP_* above */
407401 #define MMF_DUMPABLE_BITS 2
408402 #define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
409403
404+extern void set_dumpable(struct mm_struct *mm, int value);
405+/*
406+ * This returns the actual value of the suid_dumpable flag. For things
407+ * that are using this for checking for privilege transitions, it must
408+ * test against SUID_DUMP_USER rather than treating it as a boolean
409+ * value.
410+ */
411+static inline int __get_dumpable(unsigned long mm_flags)
412+{
413+ return mm_flags & MMF_DUMPABLE_MASK;
414+}
415+
416+static inline int get_dumpable(struct mm_struct *mm)
417+{
418+ return __get_dumpable(mm->flags);
419+}
420+
410421 /* coredump filter bits */
411422 #define MMF_DUMP_ANON_PRIVATE 2
412423 #define MMF_DUMP_ANON_SHARED 3
@@ -1228,7 +1239,6 @@ struct task_struct { · 815 unmodified lines
12281239 /* Used for emulating ABI behavior of previous Linux versions */
12291240 unsigned int personality;
12301241
1231− unsigned did_exec:1;
12321242 unsigned in_execve:1; /* Tell the LSMs that the process is doing an
12331243 * execve */
12341244 unsigned in_iowait:1;
@@ -2284,8 +2294,6 @@ extern struct mm_struct *get_task_mm(struct task_struct *task); · 1049 unmodified lines
22842294 extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
22852295 /* Remove the current tasks stale references to the old mm_struct */
22862296 extern void mm_release(struct task_struct *, struct mm_struct *);
2287−/* Allocate a new mm structure and copy contents from tsk->mm */
2288−extern struct mm_struct *dup_mm(struct task_struct *tsk);
22892297
22902298 extern int copy_thread(unsigned long, unsigned long, unsigned long,
22912299 struct task_struct *);
include/linux/sched/sysctl.h+4−0
@@ -99,4 +99,8 @@ extern int sched_rt_handler(struct ctl_table *table, int write, · 98 unmodified lines
9999 void __user *buffer, size_t *lenp,
100100 loff_t *ppos);
101101
102+extern int sysctl_numa_balancing(struct ctl_table *table, int write,
103+ void __user *buffer, size_t *lenp,
104+ loff_t *ppos);
105+
102106 #endif /* _SCHED_SYSCTL_H */
include/linux/slab.h+7−2
@@ -513,7 +513,9 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) · 512 unmodified lines
513513 *
514514 * Both the root cache and the child caches will have it. For the root cache,
515515 * this will hold a dynamically allocated array large enough to hold
516− * information about the currently limited memcgs in the system.
516+ * information about the currently limited memcgs in the system. To allow the
517+ * array to be accessed without taking any locks, on relocation we free the old
518+ * version only after a grace period.
517519 *
518520 * Child caches will hold extra metadata needed for its operation. Fields are:
519521 *
@@ -528,7 +530,10 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) · 8 unmodified lines
528530 struct memcg_cache_params {
529531 bool is_root_cache;
530532 union {
531− struct kmem_cache *memcg_caches[0];
533+ struct {
534+ struct rcu_head rcu_head;
535+ struct kmem_cache *memcg_caches[0];
536+ };
532537 struct {
533538 struct mem_cgroup *memcg;
534539 struct list_head list;
include/linux/w1-gpio.h+1−0
@@ -20,6 +20,7 @@ struct w1_gpio_platform_data { · 19 unmodified lines
2020 unsigned int is_open_drain:1;
2121 void (*enable_external_pullup)(int enable);
2222 unsigned int ext_pullup_enable_pin;
23+ unsigned int pullup_duration;
2324 };
2425
2526 #endif /* _LINUX_W1_GPIO_H */
include/uapi/asm-generic/types.h+1−2
@@ -1,8 +1,7 @@
11 #ifndef _ASM_GENERIC_TYPES_H
22 #define _ASM_GENERIC_TYPES_H
33 /*
4− * int-ll64 is used practically everywhere now,
5− * so use it as a reasonable default.
4+ * int-ll64 is used everywhere now.
65 */
76 #include <asm-generic/int-ll64.h>
87
include/uapi/linux/dn.h+1−0
@@ -1,6 +1,7 @@
11 #ifndef _LINUX_DN_H
22 #define _LINUX_DN_H
33
4+#include <linux/ioctl.h>
45 #include <linux/types.h>
56 #include <linux/if_ether.h>
67
include/uapi/linux/nfs4.h+1−1
@@ -150,7 +150,7 @@ · 149 unmodified lines
150150 #define NFS4_SECINFO_STYLE4_CURRENT_FH 0
151151 #define NFS4_SECINFO_STYLE4_PARENT 1
152152
153−#define NFS4_MAX_UINT64 (~(u64)0)
153+#define NFS4_MAX_UINT64 (~(__u64)0)
154154
155155 /* An NFS4 sessions server must support at least NFS4_MAX_OPS operations.
156156 * If a compound requires more operations, adjust NFS4_MAX_OPS accordingly.
include/uapi/linux/perf_event.h+1−1
@@ -788,7 +788,7 @@ union perf_mem_data_src { · 787 unmodified lines
788788 #define PERF_MEM_TLB_SHIFT 26
789789
790790 #define PERF_MEM_S(a, s) \
791− (((u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)
791+ (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)
792792
793793 /*
794794 * single taken branch record layout:
include/uapi/linux/ppp-ioctl.h+1−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212
1313 #include <linux/types.h>
1414 #include <linux/compiler.h>
15+#include <linux/ppp_defs.h>
1516
1617 /*
1718 * Bit definitions for flags argument to PPPIOCGFLAGS/PPPIOCSFLAGS.
init/initramfs.c+1−1
@@ -583,7 +583,7 @@ static int __init populate_rootfs(void) · 582 unmodified lines
583583 {
584584 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
585585 if (err)
586− panic(err); /* Failed to decompress INTERNAL initramfs */
586+ panic("%s", err); /* Failed to decompress INTERNAL initramfs */
587587 if (initrd_start) {
588588 #ifdef CONFIG_BLK_DEV_RAM
589589 int fd;
init/main.c+4−7
@@ -99,10 +99,6 @@ extern void radix_tree_init(void); · 98 unmodified lines
9999 static inline void mark_rodata_ro(void) { }
100100 #endif
101101
102−#ifdef CONFIG_TC
103−extern void tc_init(void);
104−#endif
105−
106102 /*
107103 * Debug helper: via this flag we know that we are in 'early bootup code'
108104 * where only the boot processor is running with IRQ disabled. This means
@@ -282,7 +278,7 @@ static int __init unknown_bootoption(char *param, char *val, const char *unused) · 173 unmodified lines
282278 unsigned int i;
283279 for (i = 0; envp_init[i]; i++) {
284280 if (i == MAX_INIT_ENVS) {
285− panic_later = "Too many boot env vars at `%s'";
281+ panic_later = "env";
286282 panic_param = param;
287283 }
288284 if (!strncmp(param, envp_init[i], val - param))
@@ -294,7 +290,7 @@ static int __init unknown_bootoption(char *param, char *val, const char *unused) · 5 unmodified lines
294290 unsigned int i;
295291 for (i = 0; argv_init[i]; i++) {
296292 if (i == MAX_INIT_ARGS) {
297− panic_later = "Too many boot init vars at `%s'";
293+ panic_later = "init";
298294 panic_param = param;
299295 }
300296 }
@@ -586,7 +582,8 @@ asmlinkage void __init start_kernel(void) · 285 unmodified lines
586582 */
587583 console_init();
588584 if (panic_later)
589− panic(panic_later, panic_param);
585+ panic("Too many boot %s vars at `%s'", panic_later,
586+ panic_param);
590587
591588 lockdep_info();
592589
kernel/fork.c+3−7
@@ -800,14 +800,11 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) · 799 unmodified lines
800800 * Allocate a new mm structure and copy contents from the
801801 * mm structure of the passed in task structure.
802802 */
803−struct mm_struct *dup_mm(struct task_struct *tsk)
803+static struct mm_struct *dup_mm(struct task_struct *tsk)
804804 {
805805 struct mm_struct *mm, *oldmm = current->mm;
806806 int err;
807807
808− if (!oldmm)
809− return NULL;
810−
811808 mm = allocate_mm();
812809 if (!mm)
813810 goto fail_nomem;
@@ -1229,7 +1226,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, · 415 unmodified lines
12291226 if (!try_module_get(task_thread_info(p)->exec_domain->module))
12301227 goto bad_fork_cleanup_count;
12311228
1232− p->did_exec = 0;
12331229 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
12341230 copy_flags(clone_flags, p);
12351231 INIT_LIST_HEAD(&p->children);
@@ -1654,7 +1650,7 @@ SYSCALL_DEFINE0(fork) · 418 unmodified lines
16541650 return do_fork(SIGCHLD, 0, 0, NULL, NULL);
16551651 #else
16561652 /* can not support in nommu mode */
1657− return(-EINVAL);
1653+ return -EINVAL;
16581654 #endif
16591655 }
16601656 #endif
@@ -1662,7 +1658,7 @@ SYSCALL_DEFINE0(fork) · 1 unmodified line
16621658 #ifdef __ARCH_WANT_SYS_VFORK
16631659 SYSCALL_DEFINE0(vfork)
16641660 {
1665− return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
1661+ return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
16661662 0, NULL, NULL);
16671663 }
16681664 #endif
kernel/kexec.c+2−1
@@ -932,6 +932,7 @@ static int kimage_load_segment(struct kimage *image, · 931 unmodified lines
932932 */
933933 struct kimage *kexec_image;
934934 struct kimage *kexec_crash_image;
935+int kexec_load_disabled;
935936
936937 static DEFINE_MUTEX(kexec_mutex);
937938
@@ -942,7 +943,7 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, · 4 unmodified lines
942943 int result;
943944
944945 /* We only trust the superuser with rebooting the system. */
945− if (!capable(CAP_SYS_BOOT))
946+ if (!capable(CAP_SYS_BOOT) || kexec_load_disabled)
946947 return -EPERM;
947948
948949 /*
kernel/ksysfs.c+1−1
@@ -126,7 +126,7 @@ static ssize_t vmcoreinfo_show(struct kobject *kobj, · 125 unmodified lines
126126 {
127127 return sprintf(buf, "%lx %x\n",
128128 paddr_vmcoreinfo_note(),
129− (unsigned int)vmcoreinfo_max_size);
129+ (unsigned int)sizeof(vmcoreinfo_note));
130130 }
131131 KERNEL_ATTR_RO(vmcoreinfo);
132132
kernel/printk/printk.c+6−3
@@ -1595,10 +1595,13 @@ asmlinkage int vprintk_emit(int facility, int level, · 1594 unmodified lines
15951595 * either merge it with the current buffer and flush, or if
15961596 * there was a race with interrupts (prefix == true) then just
15971597 * flush it out and store this line separately.
1598+ * If the preceding printk was from a different task and missed
1599+ * a newline, flush and append the newline.
15981600 */
1599− if (cont.len && cont.owner == current) {
1600− if (!(lflags & LOG_PREFIX))
1601− stored = cont_add(facility, level, text, text_len);
1601+ if (cont.len) {
1602+ if (cont.owner == current && !(lflags & LOG_PREFIX))
1603+ stored = cont_add(facility, level, text,
1604+ text_len);
16021605 cont_flush(LOG_NEWLINE);
16031606 }
16041607
kernel/sched/core.c+23−1
@@ -1770,7 +1770,29 @@ void set_numabalancing_state(bool enabled) · 1769 unmodified lines
17701770 numabalancing_enabled = enabled;
17711771 }
17721772 #endif /* CONFIG_SCHED_DEBUG */
1773−#endif /* CONFIG_NUMA_BALANCING */
1773+
1774+#ifdef CONFIG_PROC_SYSCTL
1775+int sysctl_numa_balancing(struct ctl_table *table, int write,
1776+ void __user *buffer, size_t *lenp, loff_t *ppos)
1777+{
1778+ struct ctl_table t;
1779+ int err;
1780+ int state = numabalancing_enabled;
1781+
1782+ if (write && !capable(CAP_SYS_ADMIN))
1783+ return -EPERM;
1784+
1785+ t = *table;
1786+ t.data = &state;
1787+ err = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
1788+ if (err < 0)
1789+ return err;
1790+ if (write)
1791+ set_numabalancing_state(state);
1792+ return err;
1793+}
1794+#endif
1795+#endif
17741796
17751797 /*
17761798 * fork()/clone()-time setup:
kernel/signal.c+3−4
@@ -2047,8 +2047,8 @@ static bool do_signal_stop(int signr) · 2046 unmodified lines
20472047 if (task_set_jobctl_pending(current, signr | gstop))
20482048 sig->group_stop_count++;
20492049
2050− for (t = next_thread(current); t != current;
2051− t = next_thread(t)) {
2050+ t = current;
2051+ while_each_thread(current, t) {
20522052 /*
20532053 * Setting state to TASK_STOPPED for a group
20542054 * stop is always done with the siglock held,
@@ -3125,8 +3125,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) · 1070 unmodified lines
31253125 rm_from_queue_full(&mask, &t->signal->shared_pending);
31263126 do {
31273127 rm_from_queue_full(&mask, &t->pending);
3128− t = next_thread(t);
3129− } while (t != current);
3128+ } while_each_thread(current, t);
31303129 }
31313130 }
31323131
kernel/sys.c+3−5
@@ -895,8 +895,7 @@ SYSCALL_DEFINE1(times, struct tms __user *, tbuf) · 894 unmodified lines
895895 * only important on a multi-user system anyway, to make sure one user
896896 * can't send a signal to a process owned by another. -TYT, 12/12/91
897897 *
898− * Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
899− * LBT 04.03.94
898+ * !PF_FORKNOEXEC check to conform completely to POSIX.
900899 */
901900 SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
902901 {
@@ -932,7 +931,7 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) · 29 unmodified lines
932931 if (task_session(p) != task_session(group_leader))
933932 goto out;
934933 err = -EACCES;
935− if (p->did_exec)
934+ if (!(p->flags & PF_FORKNOEXEC))
936935 goto out;
937936 } else {
938937 err = -ESRCH;
@@ -1572,8 +1571,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) · 633 unmodified lines
15721571 t = p;
15731572 do {
15741573 accumulate_thread_rusage(t, r);
1575− t = next_thread(t);
1576− } while (t != p);
1574+ } while_each_thread(p, t);
15771575 break;
15781576
15791577 default:
kernel/sysctl.c+22−0
@@ -62,6 +62,7 @@ · 61 unmodified lines
6262 #include <linux/capability.h>
6363 #include <linux/binfmts.h>
6464 #include <linux/sched/sysctl.h>
65+#include <linux/kexec.h>
6566
6667 #include <asm/uaccess.h>
6768 #include <asm/processor.h>
@@ -389,6 +390,15 @@ static struct ctl_table kern_table[] = { · 321 unmodified lines
389390 .mode = 0644,
390391 .proc_handler = proc_dointvec,
391392 },
393+ {
394+ .procname = "numa_balancing",
395+ .data = NULL, /* filled in by handler */
396+ .maxlen = sizeof(unsigned int),
397+ .mode = 0644,
398+ .proc_handler = sysctl_numa_balancing,
399+ .extra1 = &zero,
400+ .extra2 = &one,
401+ },
392402 #endif /* CONFIG_NUMA_BALANCING */
393403 #endif /* CONFIG_SCHED_DEBUG */
394404 {
@@ -605,6 +615,18 @@ static struct ctl_table kern_table[] = { · 210 unmodified lines
605615 .proc_handler = proc_dointvec,
606616 },
607617 #endif
618+#ifdef CONFIG_KEXEC
619+ {
620+ .procname = "kexec_load_disabled",
621+ .data = &kexec_load_disabled,
622+ .maxlen = sizeof(int),
623+ .mode = 0644,
624+ /* only handle a transition from default "0" to "1" */
625+ .proc_handler = proc_dointvec_minmax,
626+ .extra1 = &one,
627+ .extra2 = &one,
628+ },
629+#endif
608630 #ifdef CONFIG_MODULES
609631 {
610632 .procname = "modprobe",
lib/Kconfig.debug+27−0
@@ -1595,6 +1595,33 @@ config DMA_API_DEBUG · 1594 unmodified lines
15951595
15961596 If unsure, say N.
15971597
1598+config TEST_MODULE
1599+ tristate "Test module loading with 'hello world' module"
1600+ default n
1601+ depends on m
1602+ help
1603+ This builds the "test_module" module that emits "Hello, world"
1604+ on printk when loaded. It is designed to be used for basic
1605+ evaluation of the module loading subsystem (for example when
1606+ validating module verification). It lacks any extra dependencies,
1607+ and will not normally be loaded by the system unless explicitly
1608+ requested by name.
1609+
1610+ If unsure, say N.
1611+
1612+config TEST_USER_COPY
1613+ tristate "Test user/kernel boundary protections"
1614+ default n
1615+ depends on m
1616+ help
1617+ This builds the "test_user_copy" module that runs sanity checks
1618+ on the copy_to/from_user infrastructure, making sure basic
1619+ user/kernel boundary testing is working. If it fails to load,
1620+ a regression has been detected in the user/kernel memory boundary
1621+ protections.
1622+
1623+ If unsure, say N.
1624+
15981625 source "samples/Kconfig"
15991626
16001627 source "lib/Kconfig.kgdb"
lib/Makefile+2−0
@@ -31,6 +31,8 @@ obj-y += string_helpers.o · 30 unmodified lines
3131 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
3232 obj-y += kstrtox.o
3333 obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
34+obj-$(CONFIG_TEST_MODULE) += test_module.o
35+obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
3436
3537 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
3638 CFLAGS_kobject.o += -DDEBUG
lib/cmdline.c+6−8
@@ -49,13 +49,13 @@ static int get_range(char **str, int *pint) · 48 unmodified lines
4949 * 3 - hyphen found to denote a range
5050 */
5151
52−int get_option (char **str, int *pint)
52+int get_option(char **str, int *pint)
5353 {
5454 char *cur = *str;
5555
5656 if (!cur || !(*cur))
5757 return 0;
58− *pint = simple_strtol (cur, str, 0);
58+ *pint = simple_strtol(cur, str, 0);
5959 if (cur == *str)
6060 return 0;
6161 if (**str == ',') {
@@ -67,6 +67,7 @@ int get_option (char **str, int *pint) · 5 unmodified lines
6767
6868 return 1;
6969 }
70+EXPORT_SYMBOL(get_option);
7071
7172 /**
7273 * get_options - Parse a string into a list of integers
@@ -84,13 +85,13 @@ int get_option (char **str, int *pint) · 11 unmodified lines
8485 * the parse to end (typically a null terminator, if @str is
8586 * completely parseable).
8687 */
87−
88+
8889 char *get_options(const char *str, int nints, int *ints)
8990 {
9091 int res, i = 1;
9192
9293 while (i < nints) {
93− res = get_option ((char **)&str, ints + i);
94+ res = get_option((char **)&str, ints + i);
9495 if (res == 0)
9596 break;
9697 if (res == 3) {
@@ -112,6 +113,7 @@ char *get_options(const char *str, int nints, int *ints) · 15 unmodified lines
112113 ints[0] = i - 1;
113114 return (char *)str;
114115 }
116+EXPORT_SYMBOL(get_options);
115117
116118 /**
117119 * memparse - parse a string with mem suffixes into a number
@@ -152,8 +154,4 @@ unsigned long long memparse(const char *ptr, char **retptr) · 34 unmodified lines
152154
153155 return ret;
154156 }
155−
156−
157157 EXPORT_SYMBOL(memparse);
158−EXPORT_SYMBOL(get_option);
159−EXPORT_SYMBOL(get_options);
lib/decompress_unlz4.c+1−0
@@ -141,6 +141,7 @@ STATIC inline int INIT unlz4(u8 *input, int in_len, · 140 unmodified lines
141141 goto exit_2;
142142 }
143143
144+ ret = -1;
144145 if (flush && flush(outp, dest_len) != dest_len)
145146 goto exit_2;
146147 if (output)
lib/dynamic_debug.c+10−5
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 * By Greg Banks <gnb@melbourne.sgi.com>
99 * Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved.
1010 * Copyright (C) 2011 Bart Van Assche. All Rights Reserved.
11+ * Copyright (C) 2013 Du, Changbin <changbin.du@gmail.com>
1112 */
1213
1314 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
@@ -24,6 +25,7 @@ · 10 unmodified lines
2425 #include <linux/sysctl.h>
2526 #include <linux/ctype.h>
2627 #include <linux/string.h>
28+#include <linux/parser.h>
2729 #include <linux/string_helpers.h>
2830 #include <linux/uaccess.h>
2931 #include <linux/dynamic_debug.h>
@@ -147,7 +149,8 @@ static int ddebug_change(const struct ddebug_query *query, · 117 unmodified lines
147149 list_for_each_entry(dt, &ddebug_tables, link) {
148150
149151 /* match against the module name */
150− if (query->module && strcmp(query->module, dt->mod_name))
152+ if (query->module &&
153+ !match_wildcard(query->module, dt->mod_name))
151154 continue;
152155
153156 for (i = 0; i < dt->num_ddebugs; i++) {
@@ -155,14 +158,16 @@ static int ddebug_change(const struct ddebug_query *query, · 1 unmodified line
155158
156159 /* match against the source filename */
157160 if (query->filename &&
158− strcmp(query->filename, dp->filename) &&
159− strcmp(query->filename, kbasename(dp->filename)) &&
160− strcmp(query->filename, trim_prefix(dp->filename)))
161+ !match_wildcard(query->filename, dp->filename) &&
162+ !match_wildcard(query->filename,
163+ kbasename(dp->filename)) &&
164+ !match_wildcard(query->filename,
165+ trim_prefix(dp->filename)))
161166 continue;
162167
163168 /* match against the function */
164169 if (query->function &&
165− strcmp(query->function, dp->function))
170+ !match_wildcard(query->function, dp->function))
166171 continue;
167172
168173 /* match against the format */
lib/kstrtox.c+0−1
@@ -92,7 +92,6 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) · 91 unmodified lines
9292 rv = _parse_integer(s, base, &_res);
9393 if (rv & KSTRTOX_OVERFLOW)
9494 return -ERANGE;
95− rv &= ~KSTRTOX_OVERFLOW;
9695 if (rv == 0)
9796 return -EINVAL;
9897 s += rv;
lib/parser.c+56−6
@@ -113,6 +113,7 @@ int match_token(char *s, const match_table_t table, substring_t args[]) · 112 unmodified lines
113113
114114 return p->token;
115115 }
116+EXPORT_SYMBOL(match_token);
116117
117118 /**
118119 * match_number: scan a number in the given base from a substring_t
@@ -163,6 +164,7 @@ int match_int(substring_t *s, int *result) · 44 unmodified lines
163164 {
164165 return match_number(s, result, 0);
165166 }
167+EXPORT_SYMBOL(match_int);
166168
167169 /**
168170 * match_octal: - scan an octal representation of an integer from a substring_t
@@ -177,6 +179,7 @@ int match_octal(substring_t *s, int *result) · 8 unmodified lines
177179 {
178180 return match_number(s, result, 8);
179181 }
182+EXPORT_SYMBOL(match_octal);
180183
181184 /**
182185 * match_hex: - scan a hex representation of an integer from a substring_t
@@ -191,6 +194,58 @@ int match_hex(substring_t *s, int *result) · 8 unmodified lines
191194 {
192195 return match_number(s, result, 16);
193196 }
197+EXPORT_SYMBOL(match_hex);
198+
199+/**
200+ * match_wildcard: - parse if a string matches given wildcard pattern
201+ * @pattern: wildcard pattern
202+ * @str: the string to be parsed
203+ *
204+ * Description: Parse the string @str to check if matches wildcard
205+ * pattern @pattern. The pattern may contain two type wildcardes:
206+ * '*' - matches zero or more characters
207+ * '?' - matches one character
208+ * If it's matched, return true, else return false.
209+ */
210+bool match_wildcard(const char *pattern, const char *str)
211+{
212+ const char *s = str;
213+ const char *p = pattern;
214+ bool star = false;
215+
216+ while (*s) {
217+ switch (*p) {
218+ case '?':
219+ s++;
220+ p++;
221+ break;
222+ case '*':
223+ star = true;
224+ str = s;
225+ if (!*++p)
226+ return true;
227+ pattern = p;
228+ break;
229+ default:
230+ if (*s == *p) {
231+ s++;
232+ p++;
233+ } else {
234+ if (!star)
235+ return false;
236+ str++;
237+ s = str;
238+ p = pattern;
239+ }
240+ break;
241+ }
242+ }
243+
244+ if (*p == '*')
245+ ++p;
246+ return !*p;
247+}
248+EXPORT_SYMBOL(match_wildcard);
194249
195250 /**
196251 * match_strlcpy: - Copy the characters from a substring_t to a sized buffer
@@ -213,6 +268,7 @@ size_t match_strlcpy(char *dest, const substring_t *src, size_t size) · 16 unmodified lines
213268 }
214269 return ret;
215270 }
271+EXPORT_SYMBOL(match_strlcpy);
216272
217273 /**
218274 * match_strdup: - allocate a new string with the contents of a substring_t
@@ -230,10 +286,4 @@ char *match_strdup(const substring_t *s) · 11 unmodified lines
230286 match_strlcpy(p, s, sz);
231287 return p;
232288 }
233−
234−EXPORT_SYMBOL(match_token);
235−EXPORT_SYMBOL(match_int);
236−EXPORT_SYMBOL(match_octal);
237−EXPORT_SYMBOL(match_hex);
238−EXPORT_SYMBOL(match_strlcpy);
239289 EXPORT_SYMBOL(match_strdup);
lib/rbtree_test.c+12−1
@@ -8,8 +8,8 @@ · 7 unmodified lines
88 #define CHECK_LOOPS 100
99
1010 struct test_node {
11− struct rb_node rb;
1211 u32 key;
12+ struct rb_node rb;
1313
1414 /* following fields used for testing augmented rbtree functionality */
1515 u32 val;
@@ -114,6 +114,16 @@ static int black_path_count(struct rb_node *rb) · 98 unmodified lines
114114 return count;
115115 }
116116
117+static void check_postorder_foreach(int nr_nodes)
118+{
119+ struct test_node *cur, *n;
120+ int count = 0;
121+ rbtree_postorder_for_each_entry_safe(cur, n, &root, rb)
122+ count++;
123+
124+ WARN_ON_ONCE(count != nr_nodes);
125+}
126+
117127 static void check_postorder(int nr_nodes)
118128 {
119129 struct rb_node *rb;
@@ -148,6 +158,7 @@ static void check(int nr_nodes) · 28 unmodified lines
148158 WARN_ON_ONCE(count < (1 << black_path_count(rb_last(&root))) - 1);
149159
150160 check_postorder(nr_nodes);
161+ check_postorder_foreach(nr_nodes);
151162 }
152163
153164 static void check_augmented(int nr_nodes)
lib/test_module.c+33−0
@@ -0,0 +1,33 @@
1+/*
2+ * This module emits "Hello, world" on printk when loaded.
3+ *
4+ * It is designed to be used for basic evaluation of the module loading
5+ * subsystem (for example when validating module signing/verification). It
6+ * lacks any extra dependencies, and will not normally be loaded by the
7+ * system unless explicitly requested by name.
8+ */
9+
10+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11+
12+#include <linux/init.h>
13+#include <linux/module.h>
14+#include <linux/printk.h>
15+
16+static int __init test_module_init(void)
17+{
18+ pr_warn("Hello, world\n");
19+
20+ return 0;
21+}
22+
23+module_init(test_module_init);
24+
25+static void __exit test_module_exit(void)
26+{
27+ pr_warn("Goodbye\n");
28+}
29+
30+module_exit(test_module_exit);
31+
32+MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
33+MODULE_LICENSE("GPL");
lib/test_user_copy.c+110−0
@@ -0,0 +1,110 @@
1+/*
2+ * Kernel module for testing copy_to/from_user infrastructure.
3+ *
4+ * Copyright 2013 Google Inc. All Rights Reserved
5+ *
6+ * Authors:
7+ * Kees Cook <keescook@chromium.org>
8+ *
9+ * This software is licensed under the terms of the GNU General Public
10+ * License version 2, as published by the Free Software Foundation, and
11+ * may be copied, distributed, and modified under those terms.
12+ *
13+ * This program is distributed in the hope that it will be useful,
14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ * GNU General Public License for more details.
17+ */
18+
19+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20+
21+#include <linux/mman.h>
22+#include <linux/module.h>
23+#include <linux/sched.h>
24+#include <linux/slab.h>
25+#include <linux/uaccess.h>
26+#include <linux/vmalloc.h>
27+
28+#define test(condition, msg) \
29+({ \
30+ int cond = (condition); \
31+ if (cond) \
32+ pr_warn("%s\n", msg); \
33+ cond; \
34+})
35+
36+static int __init test_user_copy_init(void)
37+{
38+ int ret = 0;
39+ char *kmem;
40+ char __user *usermem;
41+ char *bad_usermem;
42+ unsigned long user_addr;
43+ unsigned long value = 0x5A;
44+
45+ kmem = kmalloc(PAGE_SIZE * 2, GFP_KERNEL);
46+ if (!kmem)
47+ return -ENOMEM;
48+
49+ user_addr = vm_mmap(NULL, 0, PAGE_SIZE * 2,
50+ PROT_READ | PROT_WRITE | PROT_EXEC,
51+ MAP_ANONYMOUS | MAP_PRIVATE, 0);
52+ if (user_addr >= (unsigned long)(TASK_SIZE)) {
53+ pr_warn("Failed to allocate user memory\n");
54+ kfree(kmem);
55+ return -ENOMEM;
56+ }
57+
58+ usermem = (char __user *)user_addr;
59+ bad_usermem = (char *)user_addr;
60+
61+ /* Legitimate usage: none of these should fail. */
62+ ret |= test(copy_from_user(kmem, usermem, PAGE_SIZE),
63+ "legitimate copy_from_user failed");
64+ ret |= test(copy_to_user(usermem, kmem, PAGE_SIZE),
65+ "legitimate copy_to_user failed");
66+ ret |= test(get_user(value, (unsigned long __user *)usermem),
67+ "legitimate get_user failed");
68+ ret |= test(put_user(value, (unsigned long __user *)usermem),
69+ "legitimate put_user failed");
70+
71+ /* Invalid usage: none of these should succeed. */
72+ ret |= test(!copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE),
73+ PAGE_SIZE),
74+ "illegal all-kernel copy_from_user passed");
75+ ret |= test(!copy_from_user(bad_usermem, (char __user *)kmem,
76+ PAGE_SIZE),
77+ "illegal reversed copy_from_user passed");
78+ ret |= test(!copy_to_user((char __user *)kmem, kmem + PAGE_SIZE,
79+ PAGE_SIZE),
80+ "illegal all-kernel copy_to_user passed");
81+ ret |= test(!copy_to_user((char __user *)kmem, bad_usermem,
82+ PAGE_SIZE),
83+ "illegal reversed copy_to_user passed");
84+ ret |= test(!get_user(value, (unsigned long __user *)kmem),
85+ "illegal get_user passed");
86+ ret |= test(!put_user(value, (unsigned long __user *)kmem),
87+ "illegal put_user passed");
88+
89+ vm_munmap(user_addr, PAGE_SIZE * 2);
90+ kfree(kmem);
91+
92+ if (ret == 0) {
93+ pr_info("tests passed.\n");
94+ return 0;
95+ }
96+
97+ return -EINVAL;
98+}
99+
100+module_init(test_user_copy_init);
101+
102+static void __exit test_user_copy_exit(void)
103+{
104+ pr_info("unloaded.\n");
105+}
106+
107+module_exit(test_user_copy_exit);
108+
109+MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
110+MODULE_LICENSE("GPL");
lib/vsprintf.c+27−6
@@ -1155,6 +1155,30 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr, · 1154 unmodified lines
11551155 return number(buf, end, *(const netdev_features_t *)addr, spec);
11561156 }
11571157
1158+static noinline_for_stack
1159+char *address_val(char *buf, char *end, const void *addr,
1160+ struct printf_spec spec, const char *fmt)
1161+{
1162+ unsigned long long num;
1163+
1164+ spec.flags |= SPECIAL | SMALL | ZEROPAD;
1165+ spec.base = 16;
1166+
1167+ switch (fmt[1]) {
1168+ case 'd':
1169+ num = *(const dma_addr_t *)addr;
1170+ spec.field_width = sizeof(dma_addr_t) * 2 + 2;
1171+ break;
1172+ case 'p':
1173+ default:
1174+ num = *(const phys_addr_t *)addr;
1175+ spec.field_width = sizeof(phys_addr_t) * 2 + 2;
1176+ break;
1177+ }
1178+
1179+ return number(buf, end, num, spec);
1180+}
1181+
11581182 int kptr_restrict __read_mostly;
11591183
11601184 /*
@@ -1218,7 +1242,8 @@ int kptr_restrict __read_mostly; · 57 unmodified lines
12181242 * N no separator
12191243 * The maximum supported length is 64 bytes of the input. Consider
12201244 * to use print_hex_dump() for the larger input.
1221− * - 'a' For a phys_addr_t type and its derivative types (passed by reference)
1245+ * - 'a[pd]' For address types [p] phys_addr_t, [d] dma_addr_t and derivatives
1246+ * (default assumed to be phys_addr_t, passed by reference)
12221247 * - 'd[234]' For a dentry name (optionally 2-4 last components)
12231248 * - 'D[234]' Same as 'd' but for a struct file
12241249 *
@@ -1353,11 +1378,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, · 128 unmodified lines
13531378 }
13541379 break;
13551380 case 'a':
1356− spec.flags |= SPECIAL | SMALL | ZEROPAD;
1357− spec.field_width = sizeof(phys_addr_t) * 2 + 2;
1358− spec.base = 16;
1359− return number(buf, end,
1360− (unsigned long long) *((phys_addr_t *)ptr), spec);
1381+ return address_val(buf, end, ptr, spec, fmt);
13611382 case 'd':
13621383 return dentry_name(buf, end, ptr, spec, fmt);
13631384 case 'D':
mm/balloon_compaction.c+2−2
@@ -267,7 +267,7 @@ void balloon_page_putback(struct page *page) · 266 unmodified lines
267267 put_page(page);
268268 } else {
269269 WARN_ON(1);
270− dump_page(page);
270+ dump_page(page, "not movable balloon page");
271271 }
272272 unlock_page(page);
273273 }
@@ -287,7 +287,7 @@ int balloon_page_migrate(struct page *newpage, · 13 unmodified lines
287287 BUG_ON(!trylock_page(newpage));
288288
289289 if (WARN_ON(!__is_movable_balloon_page(page))) {
290− dump_page(page);
290+ dump_page(page, "not movable balloon page");
291291 unlock_page(newpage);
292292 return rc;
293293 }
mm/cleancache.c+3−3
@@ -237,7 +237,7 @@ int __cleancache_get_page(struct page *page) · 236 unmodified lines
237237 goto out;
238238 }
239239
240− VM_BUG_ON(!PageLocked(page));
240+ VM_BUG_ON_PAGE(!PageLocked(page), page);
241241 fake_pool_id = page->mapping->host->i_sb->cleancache_poolid;
242242 if (fake_pool_id < 0)
243243 goto out;
@@ -279,7 +279,7 @@ void __cleancache_put_page(struct page *page) · 35 unmodified lines
279279 return;
280280 }
281281
282− VM_BUG_ON(!PageLocked(page));
282+ VM_BUG_ON_PAGE(!PageLocked(page), page);
283283 fake_pool_id = page->mapping->host->i_sb->cleancache_poolid;
284284 if (fake_pool_id < 0)
285285 return;
@@ -318,7 +318,7 @@ void __cleancache_invalidate_page(struct address_space *mapping, · 32 unmodified lines
318318 if (pool_id < 0)
319319 return;
320320
321− VM_BUG_ON(!PageLocked(page));
321+ VM_BUG_ON_PAGE(!PageLocked(page), page);
322322 if (cleancache_get_key(mapping->host, &key) >= 0) {
323323 cleancache_ops->invalidate_page(pool_id,
324324 key, page->index);
mm/compaction.c+5−2
@@ -523,7 +523,10 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc, · 522 unmodified lines
523523 if (!isolation_suitable(cc, page))
524524 goto next_pageblock;
525525
526− /* Skip if free */
526+ /*
527+ * Skip if free. page_order cannot be used without zone->lock
528+ * as nothing prevents parallel allocations or buddy merging.
529+ */
527530 if (PageBuddy(page))
528531 continue;
529532
@@ -601,7 +604,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc, · 71 unmodified lines
601604 if (__isolate_lru_page(page, mode) != 0)
602605 continue;
603606
604− VM_BUG_ON(PageTransCompound(page));
607+ VM_BUG_ON_PAGE(PageTransCompound(page), page);
605608
606609 /* Successfully isolated */
607610 cc->finished_update_migrate = true;
mm/filemap.c+8−8
@@ -409,9 +409,9 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · 408 unmodified lines
409409 {
410410 int error;
411411
412− VM_BUG_ON(!PageLocked(old));
413− VM_BUG_ON(!PageLocked(new));
414− VM_BUG_ON(new->mapping);
412+ VM_BUG_ON_PAGE(!PageLocked(old), old);
413+ VM_BUG_ON_PAGE(!PageLocked(new), new);
414+ VM_BUG_ON_PAGE(new->mapping, new);
415415
416416 error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);
417417 if (!error) {
@@ -461,8 +461,8 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping, · 43 unmodified lines
461461 {
462462 int error;
463463
464− VM_BUG_ON(!PageLocked(page));
465− VM_BUG_ON(PageSwapBacked(page));
464+ VM_BUG_ON_PAGE(!PageLocked(page), page);
465+ VM_BUG_ON_PAGE(PageSwapBacked(page), page);
466466
467467 error = mem_cgroup_cache_charge(page, current->mm,
468468 gfp_mask & GFP_RECLAIM_MASK);
@@ -607,7 +607,7 @@ EXPORT_SYMBOL_GPL(add_page_wait_queue); · 138 unmodified lines
607607 */
608608 void unlock_page(struct page *page)
609609 {
610− VM_BUG_ON(!PageLocked(page));
610+ VM_BUG_ON_PAGE(!PageLocked(page), page);
611611 clear_bit_unlock(PG_locked, &page->flags);
612612 smp_mb__after_clear_bit();
613613 wake_up_page(page, PG_locked);
@@ -760,7 +760,7 @@ repeat: · 146 unmodified lines
760760 page_cache_release(page);
761761 goto repeat;
762762 }
763− VM_BUG_ON(page->index != offset);
763+ VM_BUG_ON_PAGE(page->index != offset, page);
764764 }
765765 return page;
766766 }
@@ -1656,7 +1656,7 @@ retry_find: · 889 unmodified lines
16561656 put_page(page);
16571657 goto retry_find;
16581658 }
1659− VM_BUG_ON(page->index != offset);
1659+ VM_BUG_ON_PAGE(page->index != offset, page);
16601660
16611661 /*
16621662 * We have a locked page in the page cache, now we need to check
mm/huge_memory.c+26−20
@@ -130,8 +130,14 @@ static int set_recommended_min_free_kbytes(void) · 129 unmodified lines
130130 (unsigned long) nr_free_buffer_pages() / 20);
131131 recommended_min <<= (PAGE_SHIFT-10);
132132
133− if (recommended_min > min_free_kbytes)
133+ if (recommended_min > min_free_kbytes) {
134+ if (user_min_free_kbytes >= 0)
135+ pr_info("raising min_free_kbytes from %d to %lu "
136+ "to help transparent hugepage allocations\n",
137+ min_free_kbytes, recommended_min);
138+
134139 min_free_kbytes = recommended_min;
140+ }
135141 setup_per_zone_wmarks();
136142 return 0;
137143 }
@@ -655,7 +661,7 @@ out: · 517 unmodified lines
655661 hugepage_exit_sysfs(hugepage_kobj);
656662 return err;
657663 }
658−module_init(hugepage_init)
664+subsys_initcall(hugepage_init);
659665
660666 static int __init setup_transparent_hugepage(char *str)
661667 {
@@ -712,7 +718,7 @@ static int __do_huge_pmd_anonymous_page(struct mm_struct *mm, · 50 unmodified lines
712718 pgtable_t pgtable;
713719 spinlock_t *ptl;
714720
715− VM_BUG_ON(!PageCompound(page));
721+ VM_BUG_ON_PAGE(!PageCompound(page), page);
716722 pgtable = pte_alloc_one(mm, haddr);
717723 if (unlikely(!pgtable))
718724 return VM_FAULT_OOM;
@@ -893,7 +899,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, · 174 unmodified lines
893899 goto out;
894900 }
895901 src_page = pmd_page(pmd);
896− VM_BUG_ON(!PageHead(src_page));
902+ VM_BUG_ON_PAGE(!PageHead(src_page), src_page);
897903 get_page(src_page);
898904 page_dup_rmap(src_page);
899905 add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR);
@@ -1067,7 +1073,7 @@ static int do_huge_pmd_wp_page_fallback(struct mm_struct *mm, · 167 unmodified lines
10671073 ptl = pmd_lock(mm, pmd);
10681074 if (unlikely(!pmd_same(*pmd, orig_pmd)))
10691075 goto out_free_pages;
1070− VM_BUG_ON(!PageHead(page));
1076+ VM_BUG_ON_PAGE(!PageHead(page), page);
10711077
10721078 pmdp_clear_flush(vma, haddr, pmd);
10731079 /* leave pmd empty until pte is filled */
@@ -1133,7 +1139,7 @@ int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma, · 59 unmodified lines
11331139 goto out_unlock;
11341140
11351141 page = pmd_page(orig_pmd);
1136− VM_BUG_ON(!PageCompound(page) || !PageHead(page));
1142+ VM_BUG_ON_PAGE(!PageCompound(page) || !PageHead(page), page);
11371143 if (page_mapcount(page) == 1) {
11381144 pmd_t entry;
11391145 entry = pmd_mkyoung(orig_pmd);
@@ -1211,7 +1217,7 @@ alloc: · 71 unmodified lines
12111217 add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR);
12121218 put_huge_zero_page();
12131219 } else {
1214− VM_BUG_ON(!PageHead(page));
1220+ VM_BUG_ON_PAGE(!PageHead(page), page);
12151221 page_remove_rmap(page);
12161222 put_page(page);
12171223 }
@@ -1249,7 +1255,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, · 31 unmodified lines
12491255 goto out;
12501256
12511257 page = pmd_page(*pmd);
1252− VM_BUG_ON(!PageHead(page));
1258+ VM_BUG_ON_PAGE(!PageHead(page), page);
12531259 if (flags & FOLL_TOUCH) {
12541260 pmd_t _pmd;
12551261 /*
@@ -1274,7 +1280,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, · 18 unmodified lines
12741280 }
12751281 }
12761282 page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT;
1277− VM_BUG_ON(!PageCompound(page));
1283+ VM_BUG_ON_PAGE(!PageCompound(page), page);
12781284 if (flags & FOLL_GET)
12791285 get_page_foll(page);
12801286
@@ -1432,9 +1438,9 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, · 151 unmodified lines
14321438 } else {
14331439 page = pmd_page(orig_pmd);
14341440 page_remove_rmap(page);
1435− VM_BUG_ON(page_mapcount(page) < 0);
1441+ VM_BUG_ON_PAGE(page_mapcount(page) < 0, page);
14361442 add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR);
1437− VM_BUG_ON(!PageHead(page));
1443+ VM_BUG_ON_PAGE(!PageHead(page), page);
14381444 atomic_long_dec(&tlb->mm->nr_ptes);
14391445 spin_unlock(ptl);
14401446 tlb_remove_page(tlb, page);
@@ -2176,9 +2182,9 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, · 735 unmodified lines
21762182 if (unlikely(!page))
21772183 goto out;
21782184
2179− VM_BUG_ON(PageCompound(page));
2180− BUG_ON(!PageAnon(page));
2181− VM_BUG_ON(!PageSwapBacked(page));
2185+ VM_BUG_ON_PAGE(PageCompound(page), page);
2186+ VM_BUG_ON_PAGE(!PageAnon(page), page);
2187+ VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
21822188
21832189 /* cannot use mapcount: can't collapse if there's a gup pin */
21842190 if (page_count(page) != 1)
@@ -2201,8 +2207,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, · 16 unmodified lines
22012207 }
22022208 /* 0 stands for page_is_file_cache(page) == false */
22032209 inc_zone_page_state(page, NR_ISOLATED_ANON + 0);
2204− VM_BUG_ON(!PageLocked(page));
2205− VM_BUG_ON(PageLRU(page));
2210+ VM_BUG_ON_PAGE(!PageLocked(page), page);
2211+ VM_BUG_ON_PAGE(PageLRU(page), page);
22062212
22072213 /* If there is no mapped pte young don't collapse the page */
22082214 if (pte_young(pteval) || PageReferenced(page) ||
@@ -2232,7 +2238,7 @@ static void __collapse_huge_page_copy(pte_t *pte, struct page *page, · 23 unmodified lines
22322238 } else {
22332239 src_page = pte_page(pteval);
22342240 copy_user_highpage(page, src_page, address, vma);
2235− VM_BUG_ON(page_mapcount(src_page) != 1);
2241+ VM_BUG_ON_PAGE(page_mapcount(src_page) != 1, src_page);
22362242 release_pte_page(src_page);
22372243 /*
22382244 * ptl mostly unnecessary, but preempt has to
@@ -2311,7 +2317,7 @@ static struct page · 72 unmodified lines
23112317 struct vm_area_struct *vma, unsigned long address,
23122318 int node)
23132319 {
2314− VM_BUG_ON(*hpage);
2320+ VM_BUG_ON_PAGE(*hpage, *hpage);
23152321 /*
23162322 * Allocate the page while the vma is still valid and under
23172323 * the mmap_sem read mode so there is no memory allocation
@@ -2580,7 +2586,7 @@ static int khugepaged_scan_pmd(struct mm_struct *mm, · 262 unmodified lines
25802586 */
25812587 node = page_to_nid(page);
25822588 khugepaged_node_load[node]++;
2583− VM_BUG_ON(PageCompound(page));
2589+ VM_BUG_ON_PAGE(PageCompound(page), page);
25842590 if (!PageLRU(page) || PageLocked(page) || !PageAnon(page))
25852591 goto out_unmap;
25862592 /* cannot use mapcount: can't collapse if there's a gup pin */
@@ -2876,7 +2882,7 @@ again: · 289 unmodified lines
28762882 return;
28772883 }
28782884 page = pmd_page(*pmd);
2879− VM_BUG_ON(!page_count(page));
2885+ VM_BUG_ON_PAGE(!page_count(page), page);
28802886 get_page(page);
28812887 spin_unlock(ptl);
28822888 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
mm/hugetlb.c+5−5
@@ -584,7 +584,7 @@ static void update_and_free_page(struct hstate *h, struct page *page) · 583 unmodified lines
584584 1 << PG_active | 1 << PG_reserved |
585585 1 << PG_private | 1 << PG_writeback);
586586 }
587− VM_BUG_ON(hugetlb_cgroup_from_page(page));
587+ VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page);
588588 set_compound_page_dtor(page, NULL);
589589 set_page_refcounted(page);
590590 arch_release_hugepage(page);
@@ -1089,7 +1089,7 @@ retry: · 498 unmodified lines
10891089 * no users -- drop the buddy allocator's reference.
10901090 */
10911091 put_page_testzero(page);
1092− VM_BUG_ON(page_count(page));
1092+ VM_BUG_ON_PAGE(page_count(page), page);
10931093 enqueue_huge_page(h, page);
10941094 }
10951095 free:
@@ -3503,7 +3503,7 @@ int dequeue_hwpoisoned_huge_page(struct page *hpage) · 2407 unmodified lines
35033503
35043504 bool isolate_huge_page(struct page *page, struct list_head *list)
35053505 {
3506− VM_BUG_ON(!PageHead(page));
3506+ VM_BUG_ON_PAGE(!PageHead(page), page);
35073507 if (!get_page_unless_zero(page))
35083508 return false;
35093509 spin_lock(&hugetlb_lock);
@@ -3514,7 +3514,7 @@ bool isolate_huge_page(struct page *page, struct list_head *list) · 4 unmodified lines
35143514
35153515 void putback_active_hugepage(struct page *page)
35163516 {
3517− VM_BUG_ON(!PageHead(page));
3517+ VM_BUG_ON_PAGE(!PageHead(page), page);
35183518 spin_lock(&hugetlb_lock);
35193519 list_move_tail(&page->lru, &(page_hstate(page))->hugepage_activelist);
35203520 spin_unlock(&hugetlb_lock);
@@ -3523,7 +3523,7 @@ void putback_active_hugepage(struct page *page) · 2 unmodified lines
35233523
35243524 bool is_hugepage_active(struct page *page)
35253525 {
3526− VM_BUG_ON(!PageHuge(page));
3526+ VM_BUG_ON_PAGE(!PageHuge(page), page);
35273527 /*
35283528 * This function can be called for a tail page because the caller,
35293529 * scan_movable_pages, scans through a given pfn-range which typically
mm/hugetlb_cgroup.c+1−1
@@ -390,7 +390,7 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) · 389 unmodified lines
390390 if (hugetlb_cgroup_disabled())
391391 return;
392392
393− VM_BUG_ON(!PageHuge(oldhpage));
393+ VM_BUG_ON_PAGE(!PageHuge(oldhpage), oldhpage);
394394 spin_lock(&hugetlb_lock);
395395 h_cg = hugetlb_cgroup_from_page(oldhpage);
396396 set_hugetlb_cgroup(oldhpage, NULL);
mm/internal.h+11−8
@@ -27,8 +27,8 @@ static inline void set_page_count(struct page *page, int v) · 26 unmodified lines
2727 */
2828 static inline void set_page_refcounted(struct page *page)
2929 {
30− VM_BUG_ON(PageTail(page));
31− VM_BUG_ON(atomic_read(&page->_count));
30+ VM_BUG_ON_PAGE(PageTail(page), page);
31+ VM_BUG_ON_PAGE(atomic_read(&page->_count), page);
3232 set_page_count(page, 1);
3333 }
3434
@@ -46,7 +46,7 @@ static inline void __get_page_tail_foll(struct page *page, · 11 unmodified lines
4646 * speculative page access (like in
4747 * page_cache_get_speculative()) on tail pages.
4848 */
49− VM_BUG_ON(atomic_read(&page->first_page->_count) <= 0);
49+ VM_BUG_ON_PAGE(atomic_read(&page->first_page->_count) <= 0, page);
5050 if (get_page_head)
5151 atomic_inc(&page->first_page->_count);
5252 get_huge_page_tail(page);
@@ -71,7 +71,7 @@ static inline void get_page_foll(struct page *page) · 18 unmodified lines
7171 * Getting a normal page or the head of a compound page
7272 * requires to already have an elevated page->_count.
7373 */
74− VM_BUG_ON(atomic_read(&page->_count) <= 0);
74+ VM_BUG_ON_PAGE(atomic_read(&page->_count) <= 0, page);
7575 atomic_inc(&page->_count);
7676 }
7777 }
@@ -99,6 +99,7 @@ extern void prep_compound_page(struct page *page, unsigned long order); · 21 unmodified lines
9999 #ifdef CONFIG_MEMORY_FAILURE
100100 extern bool is_free_buddy_page(struct page *page);
101101 #endif
102+extern int user_min_free_kbytes;
102103
103104 #if defined CONFIG_COMPACTION || defined CONFIG_CMA
104105
@@ -142,9 +143,11 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc, · 37 unmodified lines
142143 #endif
143144
144145 /*
145− * function for dealing with page's order in buddy system.
146− * zone->lock is already acquired when we use these.
147− * So, we don't need atomic page->flags operations here.
146+ * This function returns the order of a free page in the buddy system. In
147+ * general, page_zone(page)->lock must be held by the caller to prevent the
148+ * page from being allocated in parallel and returning garbage as the order.
149+ * If a caller does not hold page_zone(page)->lock, it must guarantee that the
150+ * page cannot be allocated or merged in parallel.
148151 */
149152 static inline unsigned long page_order(struct page *page)
150153 {
@@ -173,7 +176,7 @@ static inline void munlock_vma_pages_all(struct vm_area_struct *vma) · 22 unmodified lines
173176 static inline int mlocked_vma_newpage(struct vm_area_struct *vma,
174177 struct page *page)
175178 {
176− VM_BUG_ON(PageLRU(page));
179+ VM_BUG_ON_PAGE(PageLRU(page), page);
177180
178181 if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED))
179182 return 0;
mm/ksm.c+7−7
@@ -1898,13 +1898,13 @@ int rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc) · 1897 unmodified lines
18981898 int ret = SWAP_AGAIN;
18991899 int search_new_forks = 0;
19001900
1901− VM_BUG_ON(!PageKsm(page));
1901+ VM_BUG_ON_PAGE(!PageKsm(page), page);
19021902
19031903 /*
19041904 * Rely on the page lock to protect against concurrent modifications
19051905 * to that page's node of the stable tree.
19061906 */
1907− VM_BUG_ON(!PageLocked(page));
1907+ VM_BUG_ON_PAGE(!PageLocked(page), page);
19081908
19091909 stable_node = page_stable_node(page);
19101910 if (!stable_node)
@@ -1958,13 +1958,13 @@ void ksm_migrate_page(struct page *newpage, struct page *oldpage) · 47 unmodified lines
19581958 {
19591959 struct stable_node *stable_node;
19601960
1961− VM_BUG_ON(!PageLocked(oldpage));
1962− VM_BUG_ON(!PageLocked(newpage));
1963− VM_BUG_ON(newpage->mapping != oldpage->mapping);
1961+ VM_BUG_ON_PAGE(!PageLocked(oldpage), oldpage);
1962+ VM_BUG_ON_PAGE(!PageLocked(newpage), newpage);
1963+ VM_BUG_ON_PAGE(newpage->mapping != oldpage->mapping, newpage);
19641964
19651965 stable_node = page_stable_node(newpage);
19661966 if (stable_node) {
1967− VM_BUG_ON(stable_node->kpfn != page_to_pfn(oldpage));
1967+ VM_BUG_ON_PAGE(stable_node->kpfn != page_to_pfn(oldpage), oldpage);
19681968 stable_node->kpfn = page_to_pfn(newpage);
19691969 /*
19701970 * newpage->mapping was set in advance; now we need smp_wmb()
@@ -2345,4 +2345,4 @@ out_free: · 374 unmodified lines
23452345 out:
23462346 return err;
23472347 }
2348−module_init(ksm_init)
2348+subsys_initcall(ksm_init);
mm/memblock.c+16−13
@@ -266,31 +266,34 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u · 265 unmodified lines
266266 }
267267 }
268268
269+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
270+
269271 phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
270272 phys_addr_t *addr)
271273 {
272274 if (memblock.reserved.regions == memblock_reserved_init_regions)
273275 return 0;
274276
275− /*
276− * Don't allow nobootmem allocator to free reserved memory regions
277− * array if
278− * - CONFIG_DEBUG_FS is enabled;
279− * - CONFIG_ARCH_DISCARD_MEMBLOCK is not enabled;
280− * - reserved memory regions array have been resized during boot.
281− * Otherwise debug_fs entry "sys/kernel/debug/memblock/reserved"
282− * will show garbage instead of state of memory reservations.
283− */
284− if (IS_ENABLED(CONFIG_DEBUG_FS) &&
285− !IS_ENABLED(CONFIG_ARCH_DISCARD_MEMBLOCK))
286− return 0;
287−
288277 *addr = __pa(memblock.reserved.regions);
289278
290279 return PAGE_ALIGN(sizeof(struct memblock_region) *
291280 memblock.reserved.max);
292281 }
293282
283+phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
284+ phys_addr_t *addr)
285+{
286+ if (memblock.memory.regions == memblock_memory_init_regions)
287+ return 0;
288+
289+ *addr = __pa(memblock.memory.regions);
290+
291+ return PAGE_ALIGN(sizeof(struct memblock_region) *
292+ memblock.memory.max);
293+}
294+
295+#endif
296+
294297 /**
295298 * memblock_double_array - double the size of the memblock regions array
296299 * @type: memblock type of the regions array being doubled
mm/memcontrol.c+254−270
@@ -49,7 +49,6 @@ · 48 unmodified lines
4949 #include <linux/sort.h>
5050 #include <linux/fs.h>
5151 #include <linux/seq_file.h>
52−#include <linux/vmalloc.h>
5352 #include <linux/vmpressure.h>
5453 #include <linux/mm_inline.h>
5554 #include <linux/page_cgroup.h>
@@ -150,7 +149,7 @@ struct mem_cgroup_reclaim_iter { · 94 unmodified lines
150149 * matches memcg->dead_count of the hierarchy root group.
151150 */
152151 struct mem_cgroup *last_visited;
153− unsigned long last_dead_count;
152+ int last_dead_count;
154153
155154 /* scan generation, increased every round-trip */
156155 unsigned int generation;
@@ -381,23 +380,12 @@ struct mem_cgroup { · 224 unmodified lines
381380 /* WARNING: nodeinfo must be the last member here */
382381 };
383382
384−static size_t memcg_size(void)
385−{
386− return sizeof(struct mem_cgroup) +
387− nr_node_ids * sizeof(struct mem_cgroup_per_node *);
388−}
389−
390383 /* internal only representation about the status of kmem accounting. */
391384 enum {
392− KMEM_ACCOUNTED_ACTIVE = 0, /* accounted by this cgroup itself */
393− KMEM_ACCOUNTED_ACTIVATED, /* static key enabled. */
385+ KMEM_ACCOUNTED_ACTIVE, /* accounted by this cgroup itself */
394386 KMEM_ACCOUNTED_DEAD, /* dead memcg with pending kmem charges */
395387 };
396388
397−/* We account when limit is on, but only after call sites are patched */
398−#define KMEM_ACCOUNTED_MASK \
399− ((1 << KMEM_ACCOUNTED_ACTIVE) | (1 << KMEM_ACCOUNTED_ACTIVATED))
400−
401389 #ifdef CONFIG_MEMCG_KMEM
402390 static inline void memcg_kmem_set_active(struct mem_cgroup *memcg)
403391 {
@@ -409,16 +397,6 @@ static bool memcg_kmem_is_active(struct mem_cgroup *memcg) · 5 unmodified lines
409397 return test_bit(KMEM_ACCOUNTED_ACTIVE, &memcg->kmem_account_flags);
410398 }
411399
412−static void memcg_kmem_set_activated(struct mem_cgroup *memcg)
413−{
414− set_bit(KMEM_ACCOUNTED_ACTIVATED, &memcg->kmem_account_flags);
415−}
416−
417−static void memcg_kmem_clear_activated(struct mem_cgroup *memcg)
418−{
419− clear_bit(KMEM_ACCOUNTED_ACTIVATED, &memcg->kmem_account_flags);
420−}
421−
422400 static void memcg_kmem_mark_dead(struct mem_cgroup *memcg)
423401 {
424402 /*
@@ -1139,16 +1117,22 @@ skip_node: · 714 unmodified lines
11391117 * skipped and we should continue the tree walk.
11401118 * last_visited css is safe to use because it is
11411119 * protected by css_get and the tree walk is rcu safe.
1120+ *
1121+ * We do not take a reference on the root of the tree walk
1122+ * because we might race with the root removal when it would
1123+ * be the only node in the iterated hierarchy and mem_cgroup_iter
1124+ * would end up in an endless loop because it expects that at
1125+ * least one valid node will be returned. Root cannot disappear
1126+ * because caller of the iterator should hold it already so
1127+ * skipping css reference should be safe.
11421128 */
11431129 if (next_css) {
1144− struct mem_cgroup *mem = mem_cgroup_from_css(next_css);
1130+ if ((next_css->flags & CSS_ONLINE) &&
1131+ (next_css == &root->css || css_tryget(next_css)))
1132+ return mem_cgroup_from_css(next_css);
11451133
1146− if (css_tryget(&mem->css))
1147− return mem;
1148− else {
1149− prev_css = next_css;
1150− goto skip_node;
1151− }
1134+ prev_css = next_css;
1135+ goto skip_node;
11521136 }
11531137
11541138 return NULL;
@@ -1182,7 +1166,15 @@ mem_cgroup_iter_load(struct mem_cgroup_reclaim_iter *iter, · 27 unmodified lines
11821166 if (iter->last_dead_count == *sequence) {
11831167 smp_rmb();
11841168 position = iter->last_visited;
1185− if (position && !css_tryget(&position->css))
1169+
1170+ /*
1171+ * We cannot take a reference to root because we might race
1172+ * with root removal and returning NULL would end up in
1173+ * an endless loop on the iterator user level when root
1174+ * would be returned all the time.
1175+ */
1176+ if (position && position != root &&
1177+ !css_tryget(&position->css))
11861178 position = NULL;
11871179 }
11881180 return position;
@@ -1191,9 +1183,11 @@ mem_cgroup_iter_load(struct mem_cgroup_reclaim_iter *iter, · 2 unmodified lines
11911183 static void mem_cgroup_iter_update(struct mem_cgroup_reclaim_iter *iter,
11921184 struct mem_cgroup *last_visited,
11931185 struct mem_cgroup *new_position,
1186+ struct mem_cgroup *root,
11941187 int sequence)
11951188 {
1196− if (last_visited)
1189+ /* root reference counting symmetric to mem_cgroup_iter_load */
1190+ if (last_visited && last_visited != root)
11971191 css_put(&last_visited->css);
11981192 /*
11991193 * We store the sequence count from the time @last_visited was
@@ -1268,7 +1262,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, · 68 unmodified lines
12681262 memcg = __mem_cgroup_iter_next(root, last_visited);
12691263
12701264 if (reclaim) {
1271− mem_cgroup_iter_update(iter, last_visited, memcg, seq);
1265+ mem_cgroup_iter_update(iter, last_visited, memcg, root,
1266+ seq);
12721267
12731268 if (!memcg)
12741269 iter->generation++;
@@ -1865,13 +1860,18 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, · 590 unmodified lines
18651860 break;
18661861 };
18671862 points = oom_badness(task, memcg, NULL, totalpages);
1868− if (points > chosen_points) {
1869− if (chosen)
1870− put_task_struct(chosen);
1871− chosen = task;
1872− chosen_points = points;
1873− get_task_struct(chosen);
1874− }
1863+ if (!points || points < chosen_points)
1864+ continue;
1865+ /* Prefer thread group leaders for display purposes */
1866+ if (points == chosen_points &&
1867+ thread_group_leader(chosen))
1868+ continue;
1869+
1870+ if (chosen)
1871+ put_task_struct(chosen);
1872+ chosen = task;
1873+ chosen_points = points;
1874+ get_task_struct(chosen);
18751875 }
18761876 css_task_iter_end(&it);
18771877 }
@@ -2904,7 +2904,7 @@ struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page) · 1026 unmodified lines
29042904 unsigned short id;
29052905 swp_entry_t ent;
29062906
2907− VM_BUG_ON(!PageLocked(page));
2907+ VM_BUG_ON_PAGE(!PageLocked(page), page);
29082908
29092909 pc = lookup_page_cgroup(page);
29102910 lock_page_cgroup(pc);
@@ -2938,7 +2938,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, · 27 unmodified lines
29382938 bool anon;
29392939
29402940 lock_page_cgroup(pc);
2941− VM_BUG_ON(PageCgroupUsed(pc));
2941+ VM_BUG_ON_PAGE(PageCgroupUsed(pc), page);
29422942 /*
29432943 * we don't need page_cgroup_lock about tail pages, becase they are not
29442944 * accessed by any other context at this point.
@@ -2973,7 +2973,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, · 28 unmodified lines
29732973 if (lrucare) {
29742974 if (was_on_lru) {
29752975 lruvec = mem_cgroup_zone_lruvec(zone, pc->mem_cgroup);
2976− VM_BUG_ON(PageLRU(page));
2976+ VM_BUG_ON_PAGE(PageLRU(page), page);
29772977 SetPageLRU(page);
29782978 add_page_to_lru_list(page, lruvec, page_lru(page));
29792979 }
@@ -2999,11 +2999,12 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, · 19 unmodified lines
29992999 static DEFINE_MUTEX(set_limit_mutex);
30003000
30013001 #ifdef CONFIG_MEMCG_KMEM
3002+static DEFINE_MUTEX(activate_kmem_mutex);
3003+
30023004 static inline bool memcg_can_account_kmem(struct mem_cgroup *memcg)
30033005 {
30043006 return !mem_cgroup_disabled() && !mem_cgroup_is_root(memcg) &&
3005− (memcg->kmem_account_flags & KMEM_ACCOUNTED_MASK) ==
3006− KMEM_ACCOUNTED_MASK;
3007+ memcg_kmem_is_active(memcg);
30073008 }
30083009
30093010 /*
@@ -3102,16 +3103,6 @@ static void memcg_uncharge_kmem(struct mem_cgroup *memcg, u64 size) · 92 unmodified lines
31023103 css_put(&memcg->css);
31033104 }
31043105
3105−void memcg_cache_list_add(struct mem_cgroup *memcg, struct kmem_cache *cachep)
3106−{
3107− if (!memcg)
3108− return;
3109−
3110− mutex_lock(&memcg->slab_caches_mutex);
3111− list_add(&cachep->memcg_params->list, &memcg->memcg_slab_caches);
3112− mutex_unlock(&memcg->slab_caches_mutex);
3113−}
3114−
31153106 /*
31163107 * helper for acessing a memcg's index. It will be used as an index in the
31173108 * child cache array in kmem_cache, and also to derive its name. This function
@@ -3122,43 +3113,6 @@ int memcg_cache_id(struct mem_cgroup *memcg) · 4 unmodified lines
31223113 return memcg ? memcg->kmemcg_id : -1;
31233114 }
31243115
3125−/*
3126− * This ends up being protected by the set_limit mutex, during normal
3127− * operation, because that is its main call site.
3128− *
3129− * But when we create a new cache, we can call this as well if its parent
3130− * is kmem-limited. That will have to hold set_limit_mutex as well.
3131− */
3132−static int memcg_update_cache_sizes(struct mem_cgroup *memcg)
3133−{
3134− int num, ret;
3135−
3136− num = ida_simple_get(&kmem_limited_groups,
3137− 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL);
3138− if (num < 0)
3139− return num;
3140− /*
3141− * After this point, kmem_accounted (that we test atomically in
3142− * the beginning of this conditional), is no longer 0. This
3143− * guarantees only one process will set the following boolean
3144− * to true. We don't need test_and_set because we're protected
3145− * by the set_limit_mutex anyway.
3146− */
3147− memcg_kmem_set_activated(memcg);
3148−
3149− ret = memcg_update_all_caches(num+1);
3150− if (ret) {
3151− ida_simple_remove(&kmem_limited_groups, num);
3152− memcg_kmem_clear_activated(memcg);
3153− return ret;
3154− }
3155−
3156− memcg->kmemcg_id = num;
3157− INIT_LIST_HEAD(&memcg->memcg_slab_caches);
3158− mutex_init(&memcg->slab_caches_mutex);
3159− return 0;
3160−}
3161−
31623116 static size_t memcg_caches_array_size(int num_groups)
31633117 {
31643118 ssize_t size;
@@ -3195,18 +3149,17 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups) · 30 unmodified lines
31953149
31963150 if (num_groups > memcg_limited_groups_array_size) {
31973151 int i;
3152+ struct memcg_cache_params *new_params;
31983153 ssize_t size = memcg_caches_array_size(num_groups);
31993154
32003155 size *= sizeof(void *);
32013156 size += offsetof(struct memcg_cache_params, memcg_caches);
32023157
3203− s->memcg_params = kzalloc(size, GFP_KERNEL);
3204− if (!s->memcg_params) {
3205− s->memcg_params = cur_params;
3158+ new_params = kzalloc(size, GFP_KERNEL);
3159+ if (!new_params)
32063160 return -ENOMEM;
3207− }
32083161
3209− s->memcg_params->is_root_cache = true;
3162+ new_params->is_root_cache = true;
32103163
32113164 /*
32123165 * There is the chance it will be bigger than
@@ -3220,7 +3173,7 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups) · 7 unmodified lines
32203173 for (i = 0; i < memcg_limited_groups_array_size; i++) {
32213174 if (!cur_params->memcg_caches[i])
32223175 continue;
3223− s->memcg_params->memcg_caches[i] =
3176+ new_params->memcg_caches[i] =
32243177 cur_params->memcg_caches[i];
32253178 }
32263179
@@ -3233,13 +3186,15 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups) · 6 unmodified lines
32333186 * bigger than the others. And all updates will reset this
32343187 * anyway.
32353188 */
3236− kfree(cur_params);
3189+ rcu_assign_pointer(s->memcg_params, new_params);
3190+ if (cur_params)
3191+ kfree_rcu(cur_params, rcu_head);
32373192 }
32383193 return 0;
32393194 }
32403195
3241−int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
3242− struct kmem_cache *root_cache)
3196+int memcg_alloc_cache_params(struct mem_cgroup *memcg, struct kmem_cache *s,
3197+ struct kmem_cache *root_cache)
32433198 {
32443199 size_t size;
32453200
@@ -3267,35 +3222,85 @@ int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s, · 21 unmodified lines
32673222 return 0;
32683223 }
32693224
3270−void memcg_release_cache(struct kmem_cache *s)
3225+void memcg_free_cache_params(struct kmem_cache *s)
3226+{
3227+ kfree(s->memcg_params);
3228+}
3229+
3230+void memcg_register_cache(struct kmem_cache *s)
32713231 {
32723232 struct kmem_cache *root;
32733233 struct mem_cgroup *memcg;
32743234 int id;
32753235
3276− /*
3277− * This happens, for instance, when a root cache goes away before we
3278− * add any memcg.
3279− */
3280− if (!s->memcg_params)
3236+ if (is_root_cache(s))
32813237 return;
32823238
3283− if (s->memcg_params->is_root_cache)
3284− goto out;
3239+ /*
3240+ * Holding the slab_mutex assures nobody will touch the memcg_caches
3241+ * array while we are modifying it.
3242+ */
3243+ lockdep_assert_held(&slab_mutex);
32853244
3245+ root = s->memcg_params->root_cache;
32863246 memcg = s->memcg_params->memcg;
3287− id = memcg_cache_id(memcg);
3247+ id = memcg_cache_id(memcg);
3248+
3249+ css_get(&memcg->css);
3250+
3251+
3252+ /*
3253+ * Since readers won't lock (see cache_from_memcg_idx()), we need a
3254+ * barrier here to ensure nobody will see the kmem_cache partially
3255+ * initialized.
3256+ */
3257+ smp_wmb();
3258+
3259+ /*
3260+ * Initialize the pointer to this cache in its parent's memcg_params
3261+ * before adding it to the memcg_slab_caches list, otherwise we can
3262+ * fail to convert memcg_params_to_cache() while traversing the list.
3263+ */
3264+ VM_BUG_ON(root->memcg_params->memcg_caches[id]);
3265+ root->memcg_params->memcg_caches[id] = s;
3266+
3267+ mutex_lock(&memcg->slab_caches_mutex);
3268+ list_add(&s->memcg_params->list, &memcg->memcg_slab_caches);
3269+ mutex_unlock(&memcg->slab_caches_mutex);
3270+}
3271+
3272+void memcg_unregister_cache(struct kmem_cache *s)
3273+{
3274+ struct kmem_cache *root;
3275+ struct mem_cgroup *memcg;
3276+ int id;
3277+
3278+ if (is_root_cache(s))
3279+ return;
3280+
3281+ /*
3282+ * Holding the slab_mutex assures nobody will touch the memcg_caches
3283+ * array while we are modifying it.
3284+ */
3285+ lockdep_assert_held(&slab_mutex);
32883286
32893287 root = s->memcg_params->root_cache;
3290− root->memcg_params->memcg_caches[id] = NULL;
3288+ memcg = s->memcg_params->memcg;
3289+ id = memcg_cache_id(memcg);
32913290
32923291 mutex_lock(&memcg->slab_caches_mutex);
32933292 list_del(&s->memcg_params->list);
32943293 mutex_unlock(&memcg->slab_caches_mutex);
32953294
3295+ /*
3296+ * Clear the pointer to this cache in its parent's memcg_params only
3297+ * after removing it from the memcg_slab_caches list, otherwise we can
3298+ * fail to convert memcg_params_to_cache() while traversing the list.
3299+ */
3300+ VM_BUG_ON(!root->memcg_params->memcg_caches[id]);
3301+ root->memcg_params->memcg_caches[id] = NULL;
3302+
32963303 css_put(&memcg->css);
3297−out:
3298− kfree(s->memcg_params);
32993304 }
33003305
33013306 /*
@@ -3354,11 +3359,9 @@ static void kmem_cache_destroy_work_func(struct work_struct *w) · 52 unmodified lines
33543359 * So if we aren't down to zero, we'll just schedule a worker and try
33553360 * again
33563361 */
3357− if (atomic_read(&cachep->memcg_params->nr_pages) != 0) {
3362+ if (atomic_read(&cachep->memcg_params->nr_pages) != 0)
33583363 kmem_cache_shrink(cachep);
3359− if (atomic_read(&cachep->memcg_params->nr_pages) == 0)
3360− return;
3361− } else
3364+ else
33623365 kmem_cache_destroy(cachep);
33633366 }
33643367
@@ -3394,27 +3397,16 @@ void mem_cgroup_destroy_cache(struct kmem_cache *cachep) · 29 unmodified lines
33943397 schedule_work(&cachep->memcg_params->destroy);
33953398 }
33963399
3397−/*
3398− * This lock protects updaters, not readers. We want readers to be as fast as
3399− * they can, and they will either see NULL or a valid cache value. Our model
3400− * allow them to see NULL, in which case the root memcg will be selected.
3401− *
3402− * We need this lock because multiple allocations to the same cache from a non
3403− * will span more than one worker. Only one of them can create the cache.
3404− */
3405−static DEFINE_MUTEX(memcg_cache_mutex);
3406−
3407−/*
3408− * Called with memcg_cache_mutex held
3409− */
3410−static struct kmem_cache *kmem_cache_dup(struct mem_cgroup *memcg,
3411− struct kmem_cache *s)
3400+static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
3401+ struct kmem_cache *s)
34123402 {
34133403 struct kmem_cache *new;
34143404 static char *tmp_name = NULL;
3405+ static DEFINE_MUTEX(mutex); /* protects tmp_name */
34153406
3416− lockdep_assert_held(&memcg_cache_mutex);
3407+ BUG_ON(!memcg_can_account_kmem(memcg));
34173408
3409+ mutex_lock(&mutex);
34183410 /*
34193411 * kmem_cache_create_memcg duplicates the given name and
34203412 * cgroup_name for this name requires RCU context.
@@ -3437,47 +3429,13 @@ static struct kmem_cache *kmem_cache_dup(struct mem_cgroup *memcg, · 16 unmodified lines
34373429
34383430 if (new)
34393431 new->allocflags |= __GFP_KMEMCG;
3432+ else
3433+ new = s;
34403434
3435+ mutex_unlock(&mutex);
34413436 return new;
34423437 }
34433438
3444−static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
3445− struct kmem_cache *cachep)
3446−{
3447− struct kmem_cache *new_cachep;
3448− int idx;
3449−
3450− BUG_ON(!memcg_can_account_kmem(memcg));
3451−
3452− idx = memcg_cache_id(memcg);
3453−
3454− mutex_lock(&memcg_cache_mutex);
3455− new_cachep = cache_from_memcg_idx(cachep, idx);
3456− if (new_cachep) {
3457− css_put(&memcg->css);
3458− goto out;
3459− }
3460−
3461− new_cachep = kmem_cache_dup(memcg, cachep);
3462− if (new_cachep == NULL) {
3463− new_cachep = cachep;
3464− css_put(&memcg->css);
3465− goto out;
3466− }
3467−
3468− atomic_set(&new_cachep->memcg_params->nr_pages , 0);
3469−
3470− cachep->memcg_params->memcg_caches[idx] = new_cachep;
3471− /*
3472− * the readers won't lock, make sure everybody sees the updated value,
3473− * so they won't put stuff in the queue again for no reason
3474− */
3475− wmb();
3476−out:
3477− mutex_unlock(&memcg_cache_mutex);
3478− return new_cachep;
3479−}
3480−
34813439 void kmem_cache_destroy_memcg_children(struct kmem_cache *s)
34823440 {
34833441 struct kmem_cache *c;
@@ -3495,9 +3453,10 @@ void kmem_cache_destroy_memcg_children(struct kmem_cache *s) · 11 unmodified lines
34953453 *
34963454 * Still, we don't want anyone else freeing memcg_caches under our
34973455 * noses, which can happen if a new memcg comes to life. As usual,
3498− * we'll take the set_limit_mutex to protect ourselves against this.
3456+ * we'll take the activate_kmem_mutex to protect ourselves against
3457+ * this.
34993458 */
3500− mutex_lock(&set_limit_mutex);
3459+ mutex_lock(&activate_kmem_mutex);
35013460 for_each_memcg_cache_index(i) {
35023461 c = cache_from_memcg_idx(s, i);
35033462 if (!c)
@@ -3520,7 +3479,7 @@ void kmem_cache_destroy_memcg_children(struct kmem_cache *s) · 16 unmodified lines
35203479 cancel_work_sync(&c->memcg_params->destroy);
35213480 kmem_cache_destroy(c);
35223481 }
3523− mutex_unlock(&set_limit_mutex);
3482+ mutex_unlock(&activate_kmem_mutex);
35243483 }
35253484
35263485 struct create_work {
@@ -3552,6 +3511,7 @@ static void memcg_create_cache_work_func(struct work_struct *w) · 25 unmodified lines
35523511
35533512 cw = container_of(w, struct create_work, work);
35543513 memcg_create_kmem_cache(cw->memcg, cw->cachep);
3514+ css_put(&cw->memcg->css);
35553515 kfree(cw);
35563516 }
35573517
@@ -3611,7 +3571,7 @@ struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep, · 53 unmodified lines
36113571 gfp_t gfp)
36123572 {
36133573 struct mem_cgroup *memcg;
3614− int idx;
3574+ struct kmem_cache *memcg_cachep;
36153575
36163576 VM_BUG_ON(!cachep->memcg_params);
36173577 VM_BUG_ON(!cachep->memcg_params->is_root_cache);
@@ -3625,15 +3585,9 @@ struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep, · 7 unmodified lines
36253585 if (!memcg_can_account_kmem(memcg))
36263586 goto out;
36273587
3628− idx = memcg_cache_id(memcg);
3629−
3630− /*
3631− * barrier to mare sure we're always seeing the up to date value. The
3632− * code updating memcg_caches will issue a write barrier to match this.
3633− */
3634− read_barrier_depends();
3635− if (likely(cache_from_memcg_idx(cachep, idx))) {
3636− cachep = cache_from_memcg_idx(cachep, idx);
3588+ memcg_cachep = cache_from_memcg_idx(cachep, memcg_cache_id(memcg));
3589+ if (likely(memcg_cachep)) {
3590+ cachep = memcg_cachep;
36373591 goto out;
36383592 }
36393593
@@ -3787,7 +3741,7 @@ void __memcg_kmem_uncharge_pages(struct page *page, int order) · 147 unmodified lines
37873741 if (!memcg)
37883742 return;
37893743
3790− VM_BUG_ON(mem_cgroup_is_root(memcg));
3744+ VM_BUG_ON_PAGE(mem_cgroup_is_root(memcg), page);
37913745 memcg_uncharge_kmem(memcg, PAGE_SIZE << order);
37923746 }
37933747 #else
@@ -3866,7 +3820,7 @@ static int mem_cgroup_move_account(struct page *page, · 72 unmodified lines
38663820 bool anon = PageAnon(page);
38673821
38683822 VM_BUG_ON(from == to);
3869− VM_BUG_ON(PageLRU(page));
3823+ VM_BUG_ON_PAGE(PageLRU(page), page);
38703824 /*
38713825 * The page is isolated from LRU. So, collapse function
38723826 * will not handle this page. But page splitting can happen.
@@ -3959,7 +3913,7 @@ static int mem_cgroup_move_parent(struct page *page, · 86 unmodified lines
39593913 parent = root_mem_cgroup;
39603914
39613915 if (nr_pages > 1) {
3962− VM_BUG_ON(!PageTransHuge(page));
3916+ VM_BUG_ON_PAGE(!PageTransHuge(page), page);
39633917 flags = compound_lock_irqsave(page);
39643918 }
39653919
@@ -3993,7 +3947,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, · 27 unmodified lines
39933947
39943948 if (PageTransHuge(page)) {
39953949 nr_pages <<= compound_order(page);
3996− VM_BUG_ON(!PageTransHuge(page));
3950+ VM_BUG_ON_PAGE(!PageTransHuge(page), page);
39973951 /*
39983952 * Never OOM-kill a process for a huge page. The
39993953 * fault handler will fall back to regular pages.
@@ -4013,8 +3967,8 @@ int mem_cgroup_newpage_charge(struct page *page, · 13 unmodified lines
40133967 {
40143968 if (mem_cgroup_disabled())
40153969 return 0;
4016− VM_BUG_ON(page_mapped(page));
4017− VM_BUG_ON(page->mapping && !PageAnon(page));
3970+ VM_BUG_ON_PAGE(page_mapped(page), page);
3971+ VM_BUG_ON_PAGE(page->mapping && !PageAnon(page), page);
40183972 VM_BUG_ON(!mm);
40193973 return mem_cgroup_charge_common(page, mm, gfp_mask,
40203974 MEM_CGROUP_CHARGE_TYPE_ANON);
@@ -4218,7 +4172,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype, · 197 unmodified lines
42184172
42194173 if (PageTransHuge(page)) {
42204174 nr_pages <<= compound_order(page);
4221− VM_BUG_ON(!PageTransHuge(page));
4175+ VM_BUG_ON_PAGE(!PageTransHuge(page), page);
42224176 }
42234177 /*
42244178 * Check if our page_cgroup is valid
@@ -4310,7 +4264,7 @@ void mem_cgroup_uncharge_page(struct page *page) · 85 unmodified lines
43104264 /* early check. */
43114265 if (page_mapped(page))
43124266 return;
4313− VM_BUG_ON(page->mapping && !PageAnon(page));
4267+ VM_BUG_ON_PAGE(page->mapping && !PageAnon(page), page);
43144268 /*
43154269 * If the page is in swap cache, uncharge should be deferred
43164270 * to the swap path, which also properly accounts swap usage
@@ -4330,8 +4284,8 @@ void mem_cgroup_uncharge_page(struct page *page) · 13 unmodified lines
43304284
43314285 void mem_cgroup_uncharge_cache_page(struct page *page)
43324286 {
4333− VM_BUG_ON(page_mapped(page));
4334− VM_BUG_ON(page->mapping);
4287+ VM_BUG_ON_PAGE(page_mapped(page), page);
4288+ VM_BUG_ON_PAGE(page->mapping, page);
43354289 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false);
43364290 }
43374291
@@ -5189,11 +5143,23 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css, · 851 unmodified lines
51895143 return val;
51905144 }
51915145
5192−static int memcg_update_kmem_limit(struct cgroup_subsys_state *css, u64 val)
5193−{
5194− int ret = -EINVAL;
51955146 #ifdef CONFIG_MEMCG_KMEM
5196− struct mem_cgroup *memcg = mem_cgroup_from_css(css);
5147+/* should be called with activate_kmem_mutex held */
5148+static int __memcg_activate_kmem(struct mem_cgroup *memcg,
5149+ unsigned long long limit)
5150+{
5151+ int err = 0;
5152+ int memcg_id;
5153+
5154+ if (memcg_kmem_is_active(memcg))
5155+ return 0;
5156+
5157+ /*
5158+ * We are going to allocate memory for data shared by all memory
5159+ * cgroups so let's stop accounting here.
5160+ */
5161+ memcg_stop_kmem_account();
5162+
51975163 /*
51985164 * For simplicity, we won't allow this to be disabled. It also can't
51995165 * be changed if the cgroup has children already, or if tasks had
@@ -5207,72 +5173,101 @@ static int memcg_update_kmem_limit(struct cgroup_subsys_state *css, u64 val) · 7 unmodified lines
52075173 * of course permitted.
52085174 */
52095175 mutex_lock(&memcg_create_mutex);
5210− mutex_lock(&set_limit_mutex);
5211− if (!memcg->kmem_account_flags && val != RES_COUNTER_MAX) {
5212− if (cgroup_task_count(css->cgroup) || memcg_has_children(memcg)) {
5213− ret = -EBUSY;
5214− goto out;
5215− }
5216− ret = res_counter_set_limit(&memcg->kmem, val);
5217− VM_BUG_ON(ret);
5176+ if (cgroup_task_count(memcg->css.cgroup) || memcg_has_children(memcg))
5177+ err = -EBUSY;
5178+ mutex_unlock(&memcg_create_mutex);
5179+ if (err)
5180+ goto out;
52185181
5219− ret = memcg_update_cache_sizes(memcg);
5220− if (ret) {
5221− res_counter_set_limit(&memcg->kmem, RES_COUNTER_MAX);
5222− goto out;
5223− }
5224− static_key_slow_inc(&memcg_kmem_enabled_key);
5225− /*
5226− * setting the active bit after the inc will guarantee no one
5227− * starts accounting before all call sites are patched
5228− */
5229− memcg_kmem_set_active(memcg);
5230− } else
5231− ret = res_counter_set_limit(&memcg->kmem, val);
5182+ memcg_id = ida_simple_get(&kmem_limited_groups,
5183+ 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL);
5184+ if (memcg_id < 0) {
5185+ err = memcg_id;
5186+ goto out;
5187+ }
5188+
5189+ /*
5190+ * Make sure we have enough space for this cgroup in each root cache's
5191+ * memcg_params.
5192+ */
5193+ err = memcg_update_all_caches(memcg_id + 1);
5194+ if (err)
5195+ goto out_rmid;
5196+
5197+ memcg->kmemcg_id = memcg_id;
5198+ INIT_LIST_HEAD(&memcg->memcg_slab_caches);
5199+ mutex_init(&memcg->slab_caches_mutex);
5200+
5201+ /*
5202+ * We couldn't have accounted to this cgroup, because it hasn't got the
5203+ * active bit set yet, so this should succeed.
5204+ */
5205+ err = res_counter_set_limit(&memcg->kmem, limit);
5206+ VM_BUG_ON(err);
5207+
5208+ static_key_slow_inc(&memcg_kmem_enabled_key);
5209+ /*
5210+ * Setting the active bit after enabling static branching will
5211+ * guarantee no one starts accounting before all call sites are
5212+ * patched.
5213+ */
5214+ memcg_kmem_set_active(memcg);
52325215 out:
5233− mutex_unlock(&set_limit_mutex);
5234− mutex_unlock(&memcg_create_mutex);
5235−#endif
5216+ memcg_resume_kmem_account();
5217+ return err;
5218+
5219+out_rmid:
5220+ ida_simple_remove(&kmem_limited_groups, memcg_id);
5221+ goto out;
5222+}
5223+
5224+static int memcg_activate_kmem(struct mem_cgroup *memcg,
5225+ unsigned long long limit)
5226+{
5227+ int ret;
5228+
5229+ mutex_lock(&activate_kmem_mutex);
5230+ ret = __memcg_activate_kmem(memcg, limit);
5231+ mutex_unlock(&activate_kmem_mutex);
5232+ return ret;
5233+}
5234+
5235+static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
5236+ unsigned long long val)
5237+{
5238+ int ret;
5239+
5240+ if (!memcg_kmem_is_active(memcg))
5241+ ret = memcg_activate_kmem(memcg, val);
5242+ else
5243+ ret = res_counter_set_limit(&memcg->kmem, val);
52365244 return ret;
52375245 }
52385246
5239−#ifdef CONFIG_MEMCG_KMEM
52405247 static int memcg_propagate_kmem(struct mem_cgroup *memcg)
52415248 {
52425249 int ret = 0;
52435250 struct mem_cgroup *parent = parent_mem_cgroup(memcg);
5244− if (!parent)
5245− goto out;
52465251
5247− memcg->kmem_account_flags = parent->kmem_account_flags;
5248− /*
5249− * When that happen, we need to disable the static branch only on those
5250− * memcgs that enabled it. To achieve this, we would be forced to
5251− * complicate the code by keeping track of which memcgs were the ones
5252− * that actually enabled limits, and which ones got it from its
5253− * parents.
5254− *
5255− * It is a lot simpler just to do static_key_slow_inc() on every child
5256− * that is accounted.
5257− */
5258− if (!memcg_kmem_is_active(memcg))
5259− goto out;
5252+ if (!parent)
5253+ return 0;
52605254
5255+ mutex_lock(&activate_kmem_mutex);
52615256 /*
5262− * __mem_cgroup_free() will issue static_key_slow_dec() because this
5263− * memcg is active already. If the later initialization fails then the
5264− * cgroup core triggers the cleanup so we do not have to do it here.
5257+ * If the parent cgroup is not kmem-active now, it cannot be activated
5258+ * after this point, because it has at least one child already.
52655259 */
5266− static_key_slow_inc(&memcg_kmem_enabled_key);
5267−
5268− mutex_lock(&set_limit_mutex);
5269− memcg_stop_kmem_account();
5270− ret = memcg_update_cache_sizes(memcg);
5271− memcg_resume_kmem_account();
5272− mutex_unlock(&set_limit_mutex);
5273−out:
5260+ if (memcg_kmem_is_active(parent))
5261+ ret = __memcg_activate_kmem(memcg, RES_COUNTER_MAX);
5262+ mutex_unlock(&activate_kmem_mutex);
52745263 return ret;
52755264 }
5265+#else
5266+static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
5267+ unsigned long long val)
5268+{
5269+ return -EINVAL;
5270+}
52765271 #endif /* CONFIG_MEMCG_KMEM */
52775272
52785273 /*
@@ -5306,7 +5301,7 @@ static int mem_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, · 27 unmodified lines
53065301 else if (type == _MEMSWAP)
53075302 ret = mem_cgroup_resize_memsw_limit(memcg, val);
53085303 else if (type == _KMEM)
5309− ret = memcg_update_kmem_limit(css, val);
5304+ ret = memcg_update_kmem_limit(memcg, val);
53105305 else
53115306 return -EINVAL;
53125307 break;
@@ -6405,14 +6400,12 @@ static void free_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) · 1092 unmodified lines
64056400 static struct mem_cgroup *mem_cgroup_alloc(void)
64066401 {
64076402 struct mem_cgroup *memcg;
6408− size_t size = memcg_size();
6403+ size_t size;
64096404
6410− /* Can be very big if nr_node_ids is very big */
6411− if (size < PAGE_SIZE)
6412− memcg = kzalloc(size, GFP_KERNEL);
6413− else
6414− memcg = vzalloc(size);
6405+ size = sizeof(struct mem_cgroup);
6406+ size += nr_node_ids * sizeof(struct mem_cgroup_per_node *);
64156407
6408+ memcg = kzalloc(size, GFP_KERNEL);
64166409 if (!memcg)
64176410 return NULL;
64186411
@@ -6423,10 +6416,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) · 4 unmodified lines
64236416 return memcg;
64246417
64256418 out_free:
6426− if (size < PAGE_SIZE)
6427− kfree(memcg);
6428− else
6429− vfree(memcg);
6419+ kfree(memcg);
64306420 return NULL;
64316421 }
64326422
@@ -6444,7 +6434,6 @@ out_free: · 11 unmodified lines
64446434 static void __mem_cgroup_free(struct mem_cgroup *memcg)
64456435 {
64466436 int node;
6447− size_t size = memcg_size();
64486437
64496438 mem_cgroup_remove_from_trees(memcg);
64506439
@@ -6465,10 +6454,7 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg) · 14 unmodified lines
64656454 * the cgroup_lock.
64666455 */
64676456 disarm_static_keys(memcg);
6468− if (size < PAGE_SIZE)
6469− kfree(memcg);
6470− else
6471− vfree(memcg);
6457+ kfree(memcg);
64726458 }
64736459
64746460 /*
@@ -6549,7 +6535,6 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) · 74 unmodified lines
65496535 {
65506536 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
65516537 struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css));
6552− int error = 0;
65536538
65546539 if (css->cgroup->id > MEM_CGROUP_ID_MAX)
65556540 return -ENOSPC;
@@ -6584,10 +6569,9 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) · 28 unmodified lines
65846569 if (parent != root_mem_cgroup)
65856570 mem_cgroup_subsys.broken_hierarchy = true;
65866571 }
6587−
6588− error = memcg_init_kmem(memcg, &mem_cgroup_subsys);
65896572 mutex_unlock(&memcg_create_mutex);
6590− return error;
6573+
6574+ return memcg_init_kmem(memcg, &mem_cgroup_subsys);
65916575 }
65926576
65936577 /*
@@ -6896,7 +6880,7 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma, · 302 unmodified lines
68966880 enum mc_target_type ret = MC_TARGET_NONE;
68976881
68986882 page = pmd_page(pmd);
6899− VM_BUG_ON(!page || !PageHead(page));
6883+ VM_BUG_ON_PAGE(!page || !PageHead(page), page);
69006884 if (!move_anon())
69016885 return ret;
69026886 pc = lookup_page_cgroup(page);
mm/memory-failure.c+11−10
@@ -856,14 +856,14 @@ static int page_action(struct page_state *ps, struct page *p, · 855 unmodified lines
856856 * the pages and send SIGBUS to the processes if the data was dirty.
857857 */
858858 static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
859− int trapno, int flags)
859+ int trapno, int flags, struct page **hpagep)
860860 {
861861 enum ttu_flags ttu = TTU_UNMAP | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
862862 struct address_space *mapping;
863863 LIST_HEAD(tokill);
864864 int ret;
865865 int kill = 1, forcekill;
866− struct page *hpage = compound_head(p);
866+ struct page *hpage = *hpagep;
867867 struct page *ppage;
868868
869869 if (PageReserved(p) || PageSlab(p))
@@ -942,11 +942,14 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, · 72 unmodified lines
942942 * We pinned the head page for hwpoison handling,
943943 * now we split the thp and we are interested in
944944 * the hwpoisoned raw page, so move the refcount
945− * to it.
945+ * to it. Similarly, page lock is shifted.
946946 */
947947 if (hpage != p) {
948948 put_page(hpage);
949949 get_page(p);
950+ lock_page(p);
951+ unlock_page(hpage);
952+ *hpagep = p;
950953 }
951954 /* THP is split, so ppage should be the real poisoned page. */
952955 ppage = p;
@@ -964,17 +967,11 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, · 11 unmodified lines
964967 if (kill)
965968 collect_procs(ppage, &tokill);
966969
967− if (hpage != ppage)
968− lock_page(ppage);
969−
970970 ret = try_to_unmap(ppage, ttu);
971971 if (ret != SWAP_SUCCESS)
972972 printk(KERN_ERR "MCE %#lx: failed to unmap page (mapcount=%d)\n",
973973 pfn, page_mapcount(ppage));
974974
975− if (hpage != ppage)
976− unlock_page(ppage);
977−
978975 /*
979976 * Now that the dirty bit has been propagated to the
980977 * struct page and all unmaps done we can decide if
@@ -1193,8 +1190,12 @@ int memory_failure(unsigned long pfn, int trapno, int flags) · 212 unmodified lines
11931190 /*
11941191 * Now take care of user space mappings.
11951192 * Abort on fail: __delete_from_page_cache() assumes unmapped page.
1193+ *
1194+ * When the raw error page is thp tail page, hpage points to the raw
1195+ * page after thp split.
11961196 */
1197− if (hwpoison_user_mappings(p, pfn, trapno, flags) != SWAP_SUCCESS) {
1197+ if (hwpoison_user_mappings(p, pfn, trapno, flags, &hpage)
1198+ != SWAP_SUCCESS) {
11981199 printk(KERN_ERR "MCE %#lx: cannot unmap page, give up\n", pfn);
11991200 res = -EBUSY;
12001201 goto out;
mm/memory.c+5−5
@@ -289,7 +289,7 @@ int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) · 288 unmodified lines
289289 return 0;
290290 batch = tlb->active;
291291 }
292− VM_BUG_ON(batch->nr > batch->max);
292+ VM_BUG_ON_PAGE(batch->nr > batch->max, page);
293293
294294 return batch->max - batch->nr;
295295 }
@@ -671,7 +671,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr, · 375 unmodified lines
671671 current->comm,
672672 (long long)pte_val(pte), (long long)pmd_val(*pmd));
673673 if (page)
674− dump_page(page);
674+ dump_page(page, "bad pte");
675675 printk(KERN_ALERT
676676 "addr:%p vm_flags:%08lx anon_vma:%p mapping:%p index:%lx\n",
677677 (void *)addr, vma->vm_flags, vma->anon_vma, mapping, index);
@@ -2702,7 +2702,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma, · 2024 unmodified lines
27022702 goto unwritable_page;
27032703 }
27042704 } else
2705− VM_BUG_ON(!PageLocked(old_page));
2705+ VM_BUG_ON_PAGE(!PageLocked(old_page), old_page);
27062706
27072707 /*
27082708 * Since we dropped the lock we need to revalidate
@@ -3358,7 +3358,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma, · 649 unmodified lines
33583358 if (unlikely(!(ret & VM_FAULT_LOCKED)))
33593359 lock_page(vmf.page);
33603360 else
3361− VM_BUG_ON(!PageLocked(vmf.page));
3361+ VM_BUG_ON_PAGE(!PageLocked(vmf.page), vmf.page);
33623362
33633363 /*
33643364 * Should we do an early C-O-W break?
@@ -3395,7 +3395,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma, · 30 unmodified lines
33953395 goto unwritable_page;
33963396 }
33973397 } else
3398− VM_BUG_ON(!PageLocked(page));
3398+ VM_BUG_ON_PAGE(!PageLocked(page), page);
33993399 page_mkwrite = 1;
34003400 }
34013401 }
mm/memory_hotplug.c+5−4
@@ -1107,17 +1107,18 @@ int __ref add_memory(int nid, u64 start, u64 size) · 1106 unmodified lines
11071107 if (ret)
11081108 return ret;
11091109
1110− lock_memory_hotplug();
1111−
11121110 res = register_memory_resource(start, size);
11131111 ret = -EEXIST;
11141112 if (!res)
1115− goto out;
1113+ return ret;
11161114
11171115 { /* Stupid hack to suppress address-never-null warning */
11181116 void *p = NODE_DATA(nid);
11191117 new_pgdat = !p;
11201118 }
1119+
1120+ lock_memory_hotplug();
1121+
11211122 new_node = !node_online(nid);
11221123 if (new_node) {
11231124 pgdat = hotadd_new_pgdat(nid, start);
@@ -1309,7 +1310,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) · 185 unmodified lines
13091310 #ifdef CONFIG_DEBUG_VM
13101311 printk(KERN_ALERT "removing pfn %lx from LRU failed\n",
13111312 pfn);
1312− dump_page(page);
1313+ dump_page(page, "failed to remove from LRU");
13131314 #endif
13141315 put_page(page);
13151316 /* Because we don't have big zone->lock. we should
mm/mempolicy.c+3−5
@@ -1199,10 +1199,8 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int * · 1198 unmodified lines
11991199 }
12001200
12011201 if (PageHuge(page)) {
1202− if (vma)
1203− return alloc_huge_page_noerr(vma, address, 1);
1204− else
1205− return NULL;
1202+ BUG_ON(!vma);
1203+ return alloc_huge_page_noerr(vma, address, 1);
12061204 }
12071205 /*
12081206 * if !vma, alloc_page_vma() will use task or system default policy
@@ -2668,7 +2666,7 @@ static void __init check_numabalancing_enable(void) · 1459 unmodified lines
26682666
26692667 if (nr_node_ids > 1 && !numabalancing_override) {
26702668 printk(KERN_INFO "Enabling automatic NUMA balancing. "
2671− "Configure with numa_balancing= or sysctl");
2669+ "Configure with numa_balancing= or the kernel.numa_balancing sysctl");
26722670 set_numabalancing_state(numabalancing_default);
26732671 }
26742672 }
mm/migrate.c+3−5
@@ -499,7 +499,7 @@ void migrate_page_copy(struct page *newpage, struct page *page) · 498 unmodified lines
499499 if (PageUptodate(page))
500500 SetPageUptodate(newpage);
501501 if (TestClearPageActive(page)) {
502− VM_BUG_ON(PageUnevictable(page));
502+ VM_BUG_ON_PAGE(PageUnevictable(page), page);
503503 SetPageActive(newpage);
504504 } else if (TestClearPageUnevictable(page))
505505 SetPageUnevictable(newpage);
@@ -871,7 +871,7 @@ static int __unmap_and_move(struct page *page, struct page *newpage, · 365 unmodified lines
871871 * free the metadata, so the page can be freed.
872872 */
873873 if (!page->mapping) {
874− VM_BUG_ON(PageAnon(page));
874+ VM_BUG_ON_PAGE(PageAnon(page), page);
875875 if (page_has_private(page)) {
876876 try_to_free_buffers(page);
877877 goto uncharge;
@@ -1618,7 +1618,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) · 740 unmodified lines
16181618 {
16191619 int page_lru;
16201620
1621− VM_BUG_ON(compound_order(page) && !PageTransHuge(page));
1621+ VM_BUG_ON_PAGE(compound_order(page) && !PageTransHuge(page), page);
16221622
16231623 /* Avoid migrating to a node that is nearly full */
16241624 if (!migrate_balanced_pgdat(pgdat, 1UL << compound_order(page)))
@@ -1753,8 +1753,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 128 unmodified lines
17531753 if (!new_page)
17541754 goto out_fail;
17551755
1756− page_cpupid_xchg_last(new_page, page_cpupid_last(page));
1757−
17581756 isolated = numamigrate_isolate_page(pgdat, page);
17591757 if (!isolated) {
17601758 put_page(new_page);
mm/mincore.c+0−7
@@ -225,13 +225,6 @@ static long do_mincore(unsigned long addr, unsigned long pages, unsigned char *v · 224 unmodified lines
225225
226226 end = min(vma->vm_end, addr + (pages << PAGE_SHIFT));
227227
228− if (is_vm_hugetlb_page(vma)) {
229− mincore_hugetlb_page_range(vma, addr, end, vec);
230− return (end - addr) >> PAGE_SHIFT;
231− }
232−
233− end = pmd_addr_end(addr, end);
234−
235228 if (is_vm_hugetlb_page(vma))
236229 mincore_hugetlb_page_range(vma, addr, end, vec);
237230 else
mm/mlock.c+62−46
@@ -90,6 +90,26 @@ void mlock_vma_page(struct page *page) · 89 unmodified lines
9090 }
9191 }
9292
93+/*
94+ * Isolate a page from LRU with optional get_page() pin.
95+ * Assumes lru_lock already held and page already pinned.
96+ */
97+static bool __munlock_isolate_lru_page(struct page *page, bool getpage)
98+{
99+ if (PageLRU(page)) {
100+ struct lruvec *lruvec;
101+
102+ lruvec = mem_cgroup_page_lruvec(page, page_zone(page));
103+ if (getpage)
104+ get_page(page);
105+ ClearPageLRU(page);
106+ del_page_from_lru_list(page, lruvec, page_lru(page));
107+ return true;
108+ }
109+
110+ return false;
111+}
112+
93113 /*
94114 * Finish munlock after successful page isolation
95115 *
@@ -126,9 +146,9 @@ static void __munlock_isolated_page(struct page *page) · 30 unmodified lines
126146 static void __munlock_isolation_failed(struct page *page)
127147 {
128148 if (PageUnevictable(page))
129− count_vm_event(UNEVICTABLE_PGSTRANDED);
149+ __count_vm_event(UNEVICTABLE_PGSTRANDED);
130150 else
131− count_vm_event(UNEVICTABLE_PGMUNLOCKED);
151+ __count_vm_event(UNEVICTABLE_PGMUNLOCKED);
132152 }
133153
134154 /**
@@ -152,28 +172,34 @@ static void __munlock_isolation_failed(struct page *page) · 17 unmodified lines
152172 unsigned int munlock_vma_page(struct page *page)
153173 {
154174 unsigned int nr_pages;
175+ struct zone *zone = page_zone(page);
155176
156177 BUG_ON(!PageLocked(page));
157178
158− if (TestClearPageMlocked(page)) {
159− nr_pages = hpage_nr_pages(page);
160− mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages);
161− if (!isolate_lru_page(page))
162− __munlock_isolated_page(page);
163− else
164− __munlock_isolation_failed(page);
165− } else {
166− nr_pages = hpage_nr_pages(page);
167− }
168−
169179 /*
170− * Regardless of the original PageMlocked flag, we determine nr_pages
171− * after touching the flag. This leaves a possible race with a THP page
172− * split, such that a whole THP page was munlocked, but nr_pages == 1.
173− * Returning a smaller mask due to that is OK, the worst that can
174− * happen is subsequent useless scanning of the former tail pages.
175− * The NR_MLOCK accounting can however become broken.
180+ * Serialize with any parallel __split_huge_page_refcount() which
181+ * might otherwise copy PageMlocked to part of the tail pages before
182+ * we clear it in the head page. It also stabilizes hpage_nr_pages().
176183 */
184+ spin_lock_irq(&zone->lru_lock);
185+
186+ nr_pages = hpage_nr_pages(page);
187+ if (!TestClearPageMlocked(page))
188+ goto unlock_out;
189+
190+ __mod_zone_page_state(zone, NR_MLOCK, -nr_pages);
191+
192+ if (__munlock_isolate_lru_page(page, true)) {
193+ spin_unlock_irq(&zone->lru_lock);
194+ __munlock_isolated_page(page);
195+ goto out;
196+ }
197+ __munlock_isolation_failed(page);
198+
199+unlock_out:
200+ spin_unlock_irq(&zone->lru_lock);
201+
202+out:
177203 return nr_pages - 1;
178204 }
179205
@@ -253,8 +279,8 @@ static int __mlock_posix_error_return(long retval) · 73 unmodified lines
253279 static bool __putback_lru_fast_prepare(struct page *page, struct pagevec *pvec,
254280 int *pgrescued)
255281 {
256− VM_BUG_ON(PageLRU(page));
257− VM_BUG_ON(!PageLocked(page));
282+ VM_BUG_ON_PAGE(PageLRU(page), page);
283+ VM_BUG_ON_PAGE(!PageLocked(page), page);
258284
259285 if (page_mapcount(page) <= 1 && page_evictable(page)) {
260286 pagevec_add(pvec, page);
@@ -310,34 +336,24 @@ static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone) · 49 unmodified lines
310336 struct page *page = pvec->pages[i];
311337
312338 if (TestClearPageMlocked(page)) {
313− struct lruvec *lruvec;
314− int lru;
315−
316− if (PageLRU(page)) {
317− lruvec = mem_cgroup_page_lruvec(page, zone);
318− lru = page_lru(page);
319− /*
320− * We already have pin from follow_page_mask()
321− * so we can spare the get_page() here.
322− */
323− ClearPageLRU(page);
324− del_page_from_lru_list(page, lruvec, lru);
325− } else {
326− __munlock_isolation_failed(page);
327− goto skip_munlock;
328− }
329−
330− } else {
331−skip_munlock:
332339 /*
333− * We won't be munlocking this page in the next phase
334− * but we still need to release the follow_page_mask()
335− * pin. We cannot do it under lru_lock however. If it's
336− * the last pin, __page_cache_release would deadlock.
340+ * We already have pin from follow_page_mask()
341+ * so we can spare the get_page() here.
337342 */
338− pagevec_add(&pvec_putback, pvec->pages[i]);
339− pvec->pages[i] = NULL;
343+ if (__munlock_isolate_lru_page(page, false))
344+ continue;
345+ else
346+ __munlock_isolation_failed(page);
340347 }
348+
349+ /*
350+ * We won't be munlocking this page in the next phase
351+ * but we still need to release the follow_page_mask()
352+ * pin. We cannot do it under lru_lock however. If it's
353+ * the last pin, __page_cache_release() would deadlock.
354+ */
355+ pagevec_add(&pvec_putback, pvec->pages[i]);
356+ pvec->pages[i] = NULL;
341357 }
342358 delta_munlocked = -nr + pagevec_count(&pvec_putback);
343359 __mod_zone_page_state(zone, NR_MLOCK, delta_munlocked);
mm/mm_init.c+1−2
@@ -202,5 +202,4 @@ static int __init mm_sysfs_init(void) · 201 unmodified lines
202202
203203 return 0;
204204 }
205−
206−__initcall(mm_sysfs_init);
205+pure_initcall(mm_sysfs_init);
mm/mmap.c+13−5
@@ -894,7 +894,15 @@ again: remove_next = 1 + (end > next->vm_end); · 893 unmodified lines
894894 static inline int is_mergeable_vma(struct vm_area_struct *vma,
895895 struct file *file, unsigned long vm_flags)
896896 {
897− if (vma->vm_flags ^ vm_flags)
897+ /*
898+ * VM_SOFTDIRTY should not prevent from VMA merging, if we
899+ * match the flags but dirty bit -- the caller should mark
900+ * merged VMA as dirty. If dirty bit won't be excluded from
901+ * comparison, we increase pressue on the memory system forcing
902+ * the kernel to generate new VMAs when old one could be
903+ * extended instead.
904+ */
905+ if ((vma->vm_flags ^ vm_flags) & ~VM_SOFTDIRTY)
898906 return 0;
899907 if (vma->vm_file != file)
900908 return 0;
@@ -1083,7 +1091,7 @@ static int anon_vma_compatible(struct vm_area_struct *a, struct vm_area_struct * · 182 unmodified lines
10831091 return a->vm_end == b->vm_start &&
10841092 mpol_equal(vma_policy(a), vma_policy(b)) &&
10851093 a->vm_file == b->vm_file &&
1086− !((a->vm_flags ^ b->vm_flags) & ~(VM_READ|VM_WRITE|VM_EXEC)) &&
1094+ !((a->vm_flags ^ b->vm_flags) & ~(VM_READ|VM_WRITE|VM_EXEC|VM_SOFTDIRTY)) &&
10871095 b->vm_pgoff == a->vm_pgoff + ((b->vm_start - a->vm_start) >> PAGE_SHIFT);
10881096 }
10891097
@@ -3142,7 +3150,7 @@ static int init_user_reserve(void) · 2052 unmodified lines
31423150 sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
31433151 return 0;
31443152 }
3145−module_init(init_user_reserve)
3153+subsys_initcall(init_user_reserve);
31463154
31473155 /*
31483156 * Initialise sysctl_admin_reserve_kbytes.
@@ -3163,7 +3171,7 @@ static int init_admin_reserve(void) · 14 unmodified lines
31633171 sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
31643172 return 0;
31653173 }
3166−module_init(init_admin_reserve)
3174+subsys_initcall(init_admin_reserve);
31673175
31683176 /*
31693177 * Reinititalise user and admin reserves if memory is added or removed.
@@ -3233,4 +3241,4 @@ static int __meminit init_reserve_notifier(void) · 63 unmodified lines
32333241
32343242 return 0;
32353243 }
3236−module_init(init_reserve_notifier)
3244+subsys_initcall(init_reserve_notifier);
mm/mmu_notifier.c+1−2
@@ -329,5 +329,4 @@ static int __init mmu_notifier_init(void) · 328 unmodified lines
329329 {
330330 return init_srcu_struct(&srcu);
331331 }
332−
333−module_init(mmu_notifier_init);
332+subsys_initcall(mmu_notifier_init);
mm/nobootmem.c+19−6
@@ -45,7 +45,9 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align, · 44 unmodified lines
4545 if (!addr)
4646 return NULL;
4747
48− memblock_reserve(addr, size);
48+ if (memblock_reserve(addr, size))
49+ return NULL;
50+
4951 ptr = phys_to_virt(addr);
5052 memset(ptr, 0, size);
5153 /*
@@ -114,16 +116,27 @@ static unsigned long __init __free_memory_core(phys_addr_t start, · 62 unmodified lines
114116 static unsigned long __init free_low_memory_core_early(void)
115117 {
116118 unsigned long count = 0;
117− phys_addr_t start, end, size;
119+ phys_addr_t start, end;
118120 u64 i;
119121
120122 for_each_free_mem_range(i, NUMA_NO_NODE, &start, &end, NULL)
121123 count += __free_memory_core(start, end);
122124
123− /* free range that is used for reserved array if we allocate it */
124− size = get_allocated_memblock_reserved_regions_info(&start);
125− if (size)
126− count += __free_memory_core(start, start + size);
125+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
126+ {
127+ phys_addr_t size;
128+
129+ /* Free memblock.reserved array if it was allocated */
130+ size = get_allocated_memblock_reserved_regions_info(&start);
131+ if (size)
132+ count += __free_memory_core(start, start + size);
133+
134+ /* Free memblock.memory array if it was allocated */
135+ size = get_allocated_memblock_memory_regions_info(&start);
136+ if (size)
137+ count += __free_memory_core(start, start + size);
138+ }
139+#endif
127140
128141 return count;
129142 }
mm/oom_kill.c+8−4
@@ -327,10 +327,14 @@ static struct task_struct *select_bad_process(unsigned int *ppoints, · 326 unmodified lines
327327 break;
328328 };
329329 points = oom_badness(p, NULL, nodemask, totalpages);
330− if (points > chosen_points) {
331− chosen = p;
332− chosen_points = points;
333− }
330+ if (!points || points < chosen_points)
331+ continue;
332+ /* Prefer thread group leaders for display purposes */
333+ if (points == chosen_points && thread_group_leader(chosen))
334+ continue;
335+
336+ chosen = p;
337+ chosen_points = points;
334338 }
335339 if (chosen)
336340 get_task_struct(chosen);
mm/page_alloc.c+72−30
@@ -205,7 +205,7 @@ static char * const zone_names[MAX_NR_ZONES] = { · 204 unmodified lines
205205 };
206206
207207 int min_free_kbytes = 1024;
208−int user_min_free_kbytes;
208+int user_min_free_kbytes = -1;
209209
210210 static unsigned long __meminitdata nr_kernel_pages;
211211 static unsigned long __meminitdata nr_all_pages;
@@ -295,7 +295,7 @@ static inline int bad_range(struct zone *zone, struct page *page) · 83 unmodified lines
295295 }
296296 #endif
297297
298−static void bad_page(struct page *page)
298+static void bad_page(struct page *page, char *reason, unsigned long bad_flags)
299299 {
300300 static unsigned long resume;
301301 static unsigned long nr_shown;
@@ -329,7 +329,7 @@ static void bad_page(struct page *page) · 27 unmodified lines
329329
330330 printk(KERN_ALERT "BUG: Bad page state in process %s pfn:%05lx\n",
331331 current->comm, page_to_pfn(page));
332− dump_page(page);
332+ dump_page_badflags(page, reason, bad_flags);
333333
334334 print_modules();
335335 dump_stack();
@@ -383,7 +383,7 @@ static int destroy_compound_page(struct page *page, unsigned long order) · 47 unmodified lines
383383 int bad = 0;
384384
385385 if (unlikely(compound_order(page) != order)) {
386− bad_page(page);
386+ bad_page(page, "wrong compound order", 0);
387387 bad++;
388388 }
389389
@@ -392,8 +392,11 @@ static int destroy_compound_page(struct page *page, unsigned long order) · 2 unmodified lines
392392 for (i = 1; i < nr_pages; i++) {
393393 struct page *p = page + i;
394394
395− if (unlikely(!PageTail(p) || (p->first_page != page))) {
396− bad_page(page);
395+ if (unlikely(!PageTail(p))) {
396+ bad_page(page, "PageTail not set", 0);
397+ bad++;
398+ } else if (unlikely(p->first_page != page)) {
399+ bad_page(page, "first_page not consistent", 0);
397400 bad++;
398401 }
399402 __ClearPageTail(p);
@@ -506,12 +509,12 @@ static inline int page_is_buddy(struct page *page, struct page *buddy, · 106 unmodified lines
506509 return 0;
507510
508511 if (page_is_guard(buddy) && page_order(buddy) == order) {
509− VM_BUG_ON(page_count(buddy) != 0);
512+ VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
510513 return 1;
511514 }
512515
513516 if (PageBuddy(buddy) && page_order(buddy) == order) {
514− VM_BUG_ON(page_count(buddy) != 0);
517+ VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
515518 return 1;
516519 }
517520 return 0;
@@ -561,8 +564,8 @@ static inline void __free_one_page(struct page *page, · 43 unmodified lines
561564
562565 page_idx = page_to_pfn(page) & ((1 << MAX_ORDER) - 1);
563566
564− VM_BUG_ON(page_idx & ((1 << order) - 1));
565− VM_BUG_ON(bad_range(zone, page));
567+ VM_BUG_ON_PAGE(page_idx & ((1 << order) - 1), page);
568+ VM_BUG_ON_PAGE(bad_range(zone, page), page);
566569
567570 while (order < MAX_ORDER-1) {
568571 buddy_idx = __find_buddy_index(page_idx, order);
@@ -618,12 +621,23 @@ out: · 49 unmodified lines
618621
619622 static inline int free_pages_check(struct page *page)
620623 {
621− if (unlikely(page_mapcount(page) |
622− (page->mapping != NULL) |
623− (atomic_read(&page->_count) != 0) |
624− (page->flags & PAGE_FLAGS_CHECK_AT_FREE) |
625− (mem_cgroup_bad_page_check(page)))) {
626− bad_page(page);
624+ char *bad_reason = NULL;
625+ unsigned long bad_flags = 0;
626+
627+ if (unlikely(page_mapcount(page)))
628+ bad_reason = "nonzero mapcount";
629+ if (unlikely(page->mapping != NULL))
630+ bad_reason = "non-NULL mapping";
631+ if (unlikely(atomic_read(&page->_count) != 0))
632+ bad_reason = "nonzero _count";
633+ if (unlikely(page->flags & PAGE_FLAGS_CHECK_AT_FREE)) {
634+ bad_reason = "PAGE_FLAGS_CHECK_AT_FREE flag(s) set";
635+ bad_flags = PAGE_FLAGS_CHECK_AT_FREE;
636+ }
637+ if (unlikely(mem_cgroup_bad_page_check(page)))
638+ bad_reason = "cgroup check failed";
639+ if (unlikely(bad_reason)) {
640+ bad_page(page, bad_reason, bad_flags);
627641 return 1;
628642 }
629643 page_cpupid_reset_last(page);
@@ -813,7 +827,7 @@ static inline void expand(struct zone *zone, struct page *page, · 183 unmodified lines
813827 area--;
814828 high--;
815829 size >>= 1;
816− VM_BUG_ON(bad_range(zone, &page[size]));
830+ VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]);
817831
818832 #ifdef CONFIG_DEBUG_PAGEALLOC
819833 if (high < debug_guardpage_minorder()) {
@@ -843,12 +857,23 @@ static inline void expand(struct zone *zone, struct page *page, · 23 unmodified lines
843857 */
844858 static inline int check_new_page(struct page *page)
845859 {
846− if (unlikely(page_mapcount(page) |
847− (page->mapping != NULL) |
848− (atomic_read(&page->_count) != 0) |
849− (page->flags & PAGE_FLAGS_CHECK_AT_PREP) |
850− (mem_cgroup_bad_page_check(page)))) {
851− bad_page(page);
860+ char *bad_reason = NULL;
861+ unsigned long bad_flags = 0;
862+
863+ if (unlikely(page_mapcount(page)))
864+ bad_reason = "nonzero mapcount";
865+ if (unlikely(page->mapping != NULL))
866+ bad_reason = "non-NULL mapping";
867+ if (unlikely(atomic_read(&page->_count) != 0))
868+ bad_reason = "nonzero _count";
869+ if (unlikely(page->flags & PAGE_FLAGS_CHECK_AT_PREP)) {
870+ bad_reason = "PAGE_FLAGS_CHECK_AT_PREP flag set";
871+ bad_flags = PAGE_FLAGS_CHECK_AT_PREP;
872+ }
873+ if (unlikely(mem_cgroup_bad_page_check(page)))
874+ bad_reason = "cgroup check failed";
875+ if (unlikely(bad_reason)) {
876+ bad_page(page, bad_reason, bad_flags);
852877 return 1;
853878 }
854879 return 0;
@@ -955,7 +980,7 @@ int move_freepages(struct zone *zone, · 100 unmodified lines
955980
956981 for (page = start_page; page <= end_page;) {
957982 /* Make sure we are not inadvertently changing nodes */
958− VM_BUG_ON(page_to_nid(page) != zone_to_nid(zone));
983+ VM_BUG_ON_PAGE(page_to_nid(page) != zone_to_nid(zone), page);
959984
960985 if (!pfn_valid_within(page_to_pfn(page))) {
961986 page++;
@@ -1404,8 +1429,8 @@ void split_page(struct page *page, unsigned int order) · 442 unmodified lines
14041429 {
14051430 int i;
14061431
1407− VM_BUG_ON(PageCompound(page));
1408− VM_BUG_ON(!page_count(page));
1432+ VM_BUG_ON_PAGE(PageCompound(page), page);
1433+ VM_BUG_ON_PAGE(!page_count(page), page);
14091434
14101435 #ifdef CONFIG_KMEMCHECK
14111436 /*
@@ -1552,7 +1577,7 @@ again: · 140 unmodified lines
15521577 zone_statistics(preferred_zone, zone, gfp_flags);
15531578 local_irq_restore(flags);
15541579
1555− VM_BUG_ON(bad_range(zone, page));
1580+ VM_BUG_ON_PAGE(bad_range(zone, page), page);
15561581 if (prep_new_page(page, order, gfp_flags))
15571582 goto again;
15581583 return page;
@@ -5729,7 +5754,12 @@ module_init(init_per_zone_wmark_min) · 4170 unmodified lines
57295754 int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
57305755 void __user *buffer, size_t *length, loff_t *ppos)
57315756 {
5732− proc_dointvec(table, write, buffer, length, ppos);
5757+ int rc;
5758+
5759+ rc = proc_dointvec_minmax(table, write, buffer, length, ppos);
5760+ if (rc)
5761+ return rc;
5762+
57335763 if (write) {
57345764 user_min_free_kbytes = min_free_kbytes;
57355765 setup_per_zone_wmarks();
@@ -5996,7 +6026,7 @@ void set_pageblock_flags_group(struct page *page, unsigned long flags, · 260 unmodified lines
59966026 pfn = page_to_pfn(page);
59976027 bitmap = get_pageblock_bitmap(zone, pfn);
59986028 bitidx = pfn_to_bitidx(zone, pfn);
5999− VM_BUG_ON(!zone_spans_pfn(zone, pfn));
6029+ VM_BUG_ON_PAGE(!zone_spans_pfn(zone, pfn), page);
60006030
60016031 for (; start_bitidx <= end_bitidx; start_bitidx++, value <<= 1)
60026032 if (flags & value)
@@ -6494,12 +6524,24 @@ static void dump_page_flags(unsigned long flags) · 491 unmodified lines
64946524 printk(")\n");
64956525 }
64966526
6497−void dump_page(struct page *page)
6527+void dump_page_badflags(struct page *page, char *reason, unsigned long badflags)
64986528 {
64996529 printk(KERN_ALERT
65006530 "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n",
65016531 page, atomic_read(&page->_count), page_mapcount(page),
65026532 page->mapping, page->index);
65036533 dump_page_flags(page->flags);
6534+ if (reason)
6535+ pr_alert("page dumped because: %s\n", reason);
6536+ if (page->flags & badflags) {
6537+ pr_alert("bad because of flags:\n");
6538+ dump_page_flags(page->flags & badflags);
6539+ }
65046540 mem_cgroup_print_bad_page(page);
65056541 }
6542+
6543+void dump_page(struct page *page, char *reason)
6544+{
6545+ dump_page_badflags(page, reason, 0);
6546+}
6547+EXPORT_SYMBOL_GPL(dump_page);
mm/page_io.c+2−2
@@ -320,8 +320,8 @@ int swap_readpage(struct page *page) · 319 unmodified lines
320320 int ret = 0;
321321 struct swap_info_struct *sis = page_swap_info(page);
322322
323− VM_BUG_ON(!PageLocked(page));
324− VM_BUG_ON(PageUptodate(page));
323+ VM_BUG_ON_PAGE(!PageLocked(page), page);
324+ VM_BUG_ON_PAGE(PageUptodate(page), page);
325325 if (frontswap_load(page) == 0) {
326326 SetPageUptodate(page);
327327 unlock_page(page);
mm/rmap.c+7−7
@@ -848,9 +848,9 @@ out: · 847 unmodified lines
848848 static bool invalid_mkclean_vma(struct vm_area_struct *vma, void *arg)
849849 {
850850 if (vma->vm_flags & VM_SHARED)
851− return 0;
851+ return false;
852852
853− return 1;
853+ return true;
854854 }
855855
856856 int page_mkclean(struct page *page)
@@ -894,9 +894,9 @@ void page_move_anon_rmap(struct page *page, · 37 unmodified lines
894894 {
895895 struct anon_vma *anon_vma = vma->anon_vma;
896896
897− VM_BUG_ON(!PageLocked(page));
897+ VM_BUG_ON_PAGE(!PageLocked(page), page);
898898 VM_BUG_ON(!anon_vma);
899− VM_BUG_ON(page->index != linear_page_index(vma, address));
899+ VM_BUG_ON_PAGE(page->index != linear_page_index(vma, address), page);
900900
901901 anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
902902 page->mapping = (struct address_space *) anon_vma;
@@ -995,7 +995,7 @@ void do_page_add_anon_rmap(struct page *page, · 92 unmodified lines
995995 if (unlikely(PageKsm(page)))
996996 return;
997997
998− VM_BUG_ON(!PageLocked(page));
998+ VM_BUG_ON_PAGE(!PageLocked(page), page);
999999 /* address might be in next vma when migration races vma_adjust */
10001000 if (first)
10011001 __page_set_anon_rmap(page, vma, address, exclusive);
@@ -1481,7 +1481,7 @@ int try_to_unmap(struct page *page, enum ttu_flags flags) · 479 unmodified lines
14811481 .anon_lock = page_lock_anon_vma_read,
14821482 };
14831483
1484− VM_BUG_ON(!PageHuge(page) && PageTransHuge(page));
1484+ VM_BUG_ON_PAGE(!PageHuge(page) && PageTransHuge(page), page);
14851485
14861486 /*
14871487 * During exec, a temporary VMA is setup and later moved.
@@ -1533,7 +1533,7 @@ int try_to_munlock(struct page *page) · 45 unmodified lines
15331533
15341534 };
15351535
1536− VM_BUG_ON(!PageLocked(page) || PageLRU(page));
1536+ VM_BUG_ON_PAGE(!PageLocked(page) || PageLRU(page), page);
15371537
15381538 ret = rmap_walk(page, &rwc);
15391539 return ret;
mm/shmem.c+4−4
@@ -285,8 +285,8 @@ static int shmem_add_to_page_cache(struct page *page, · 284 unmodified lines
285285 {
286286 int error;
287287
288− VM_BUG_ON(!PageLocked(page));
289− VM_BUG_ON(!PageSwapBacked(page));
288+ VM_BUG_ON_PAGE(!PageLocked(page), page);
289+ VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
290290
291291 page_cache_get(page);
292292 page->mapping = mapping;
@@ -491,7 +491,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, · 198 unmodified lines
491491 continue;
492492 if (!unfalloc || !PageUptodate(page)) {
493493 if (page->mapping == mapping) {
494− VM_BUG_ON(PageWriteback(page));
494+ VM_BUG_ON_PAGE(PageWriteback(page), page);
495495 truncate_inode_page(mapping, page);
496496 }
497497 }
@@ -568,7 +568,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, · 70 unmodified lines
568568 lock_page(page);
569569 if (!unfalloc || !PageUptodate(page)) {
570570 if (page->mapping == mapping) {
571− VM_BUG_ON(PageWriteback(page));
571+ VM_BUG_ON_PAGE(PageWriteback(page), page);
572572 truncate_inode_page(mapping, page);
573573 }
574574 }
mm/slab.h+25−1
@@ -160,12 +160,36 @@ static inline const char *cache_name(struct kmem_cache *s) · 159 unmodified lines
160160 return s->name;
161161 }
162162
163+/*
164+ * Note, we protect with RCU only the memcg_caches array, not per-memcg caches.
165+ * That said the caller must assure the memcg's cache won't go away. Since once
166+ * created a memcg's cache is destroyed only along with the root cache, it is
167+ * true if we are going to allocate from the cache or hold a reference to the
168+ * root cache by other means. Otherwise, we should hold either the slab_mutex
169+ * or the memcg's slab_caches_mutex while calling this function and accessing
170+ * the returned value.
171+ */
163172 static inline struct kmem_cache *
164173 cache_from_memcg_idx(struct kmem_cache *s, int idx)
165174 {
175+ struct kmem_cache *cachep;
176+ struct memcg_cache_params *params;
177+
166178 if (!s->memcg_params)
167179 return NULL;
168− return s->memcg_params->memcg_caches[idx];
180+
181+ rcu_read_lock();
182+ params = rcu_dereference(s->memcg_params);
183+ cachep = params->memcg_caches[idx];
184+ rcu_read_unlock();
185+
186+ /*
187+ * Make sure we will access the up-to-date value. The code updating
188+ * memcg_caches issues a write barrier to match this (see
189+ * memcg_register_cache()).
190+ */
191+ smp_read_barrier_depends();
192+ return cachep;
169193 }
170194
171195 static inline struct kmem_cache *memcg_root_cache(struct kmem_cache *s)
mm/slab_common.c+54−36
@@ -171,13 +171,26 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size, · 170 unmodified lines
171171 struct kmem_cache *parent_cache)
172172 {
173173 struct kmem_cache *s = NULL;
174− int err = 0;
174+ int err;
175175
176176 get_online_cpus();
177177 mutex_lock(&slab_mutex);
178178
179− if (!kmem_cache_sanity_check(memcg, name, size) == 0)
180− goto out_locked;
179+ err = kmem_cache_sanity_check(memcg, name, size);
180+ if (err)
181+ goto out_unlock;
182+
183+ if (memcg) {
184+ /*
185+ * Since per-memcg caches are created asynchronously on first
186+ * allocation (see memcg_kmem_get_cache()), several threads can
187+ * try to create the same cache, but only one of them may
188+ * succeed. Therefore if we get here and see the cache has
189+ * already been created, we silently return NULL.
190+ */
191+ if (cache_from_memcg_idx(parent_cache, memcg_cache_id(memcg)))
192+ goto out_unlock;
193+ }
181194
182195 /*
183196 * Some allocators will constraint the set of valid flags to a subset
@@ -189,45 +202,45 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size, · 5 unmodified lines
189202
190203 s = __kmem_cache_alias(memcg, name, size, align, flags, ctor);
191204 if (s)
192− goto out_locked;
205+ goto out_unlock;
193206
207+ err = -ENOMEM;
194208 s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL);
195− if (s) {
196− s->object_size = s->size = size;
197− s->align = calculate_alignment(flags, align, size);
198− s->ctor = ctor;
209+ if (!s)
210+ goto out_unlock;
199211
200− if (memcg_register_cache(memcg, s, parent_cache)) {
201− kmem_cache_free(kmem_cache, s);
202− err = -ENOMEM;
203− goto out_locked;
204− }
212+ s->object_size = s->size = size;
213+ s->align = calculate_alignment(flags, align, size);
214+ s->ctor = ctor;
205215
206− s->name = kstrdup(name, GFP_KERNEL);
207− if (!s->name) {
208− kmem_cache_free(kmem_cache, s);
209− err = -ENOMEM;
210− goto out_locked;
211− }
216+ s->name = kstrdup(name, GFP_KERNEL);
217+ if (!s->name)
218+ goto out_free_cache;
212219
213− err = __kmem_cache_create(s, flags);
214− if (!err) {
215− s->refcount = 1;
216− list_add(&s->list, &slab_caches);
217− memcg_cache_list_add(memcg, s);
218− } else {
219− kfree(s->name);
220− kmem_cache_free(kmem_cache, s);
221− }
222− } else
223− err = -ENOMEM;
220+ err = memcg_alloc_cache_params(memcg, s, parent_cache);
221+ if (err)
222+ goto out_free_cache;
223+
224+ err = __kmem_cache_create(s, flags);
225+ if (err)
226+ goto out_free_cache;
224227
225−out_locked:
228+ s->refcount = 1;
229+ list_add(&s->list, &slab_caches);
230+ memcg_register_cache(s);
231+
232+out_unlock:
226233 mutex_unlock(&slab_mutex);
227234 put_online_cpus();
228235
229− if (err) {
230−
236+ /*
237+ * There is no point in flooding logs with warnings or especially
238+ * crashing the system if we fail to create a cache for a memcg. In
239+ * this case we will be accounting the memcg allocation to the root
240+ * cgroup until we succeed to create its own cache, but it isn't that
241+ * critical.
242+ */
243+ if (err && !memcg) {
231244 if (flags & SLAB_PANIC)
232245 panic("kmem_cache_create: Failed to create slab '%s'. Error %d\n",
233246 name, err);
@@ -236,11 +249,15 @@ out_locked: · 2 unmodified lines
236249 name, err);
237250 dump_stack();
238251 }
239−
240252 return NULL;
241253 }
242−
243254 return s;
255+
256+out_free_cache:
257+ memcg_free_cache_params(s);
258+ kfree(s->name);
259+ kmem_cache_free(kmem_cache, s);
260+ goto out_unlock;
244261 }
245262
246263 struct kmem_cache *
@@ -263,11 +280,12 @@ void kmem_cache_destroy(struct kmem_cache *s) · 16 unmodified lines
263280 list_del(&s->list);
264281
265282 if (!__kmem_cache_shutdown(s)) {
283+ memcg_unregister_cache(s);
266284 mutex_unlock(&slab_mutex);
267285 if (s->flags & SLAB_DESTROY_BY_RCU)
268286 rcu_barrier();
269287
270− memcg_release_cache(s);
288+ memcg_free_cache_params(s);
271289 kfree(s->name);
272290 kmem_cache_free(kmem_cache, s);
273291 } else {
mm/slub.c+6−6
@@ -1559,7 +1559,7 @@ static inline void *acquire_slab(struct kmem_cache *s, · 1558 unmodified lines
15591559 new.freelist = freelist;
15601560 }
15611561
1562− VM_BUG_ON(new.frozen);
1562+ VM_BUG_ON_PAGE(new.frozen, &new);
15631563 new.frozen = 1;
15641564
15651565 if (!__cmpxchg_double_slab(s, page,
@@ -1812,7 +1812,7 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, · 246 unmodified lines
18121812 set_freepointer(s, freelist, prior);
18131813 new.counters = counters;
18141814 new.inuse--;
1815− VM_BUG_ON(!new.frozen);
1815+ VM_BUG_ON_PAGE(!new.frozen, &new);
18161816
18171817 } while (!__cmpxchg_double_slab(s, page,
18181818 prior, counters,
@@ -1840,7 +1840,7 @@ redo: · 21 unmodified lines
18401840
18411841 old.freelist = page->freelist;
18421842 old.counters = page->counters;
1843− VM_BUG_ON(!old.frozen);
1843+ VM_BUG_ON_PAGE(!old.frozen, &old);
18441844
18451845 /* Determine target state of the slab */
18461846 new.counters = old.counters;
@@ -1952,7 +1952,7 @@ static void unfreeze_partials(struct kmem_cache *s, · 105 unmodified lines
19521952
19531953 old.freelist = page->freelist;
19541954 old.counters = page->counters;
1955− VM_BUG_ON(!old.frozen);
1955+ VM_BUG_ON_PAGE(!old.frozen, &old);
19561956
19571957 new.counters = old.counters;
19581958 new.freelist = old.freelist;
@@ -2225,7 +2225,7 @@ static inline void *get_freelist(struct kmem_cache *s, struct page *page) · 266 unmodified lines
22252225 counters = page->counters;
22262226
22272227 new.counters = counters;
2228− VM_BUG_ON(!new.frozen);
2228+ VM_BUG_ON_PAGE(!new.frozen, &new);
22292229
22302230 new.inuse = page->objects;
22312231 new.frozen = freelist != NULL;
@@ -2319,7 +2319,7 @@ load_freelist: · 87 unmodified lines
23192319 * page is pointing to the page from which the objects are obtained.
23202320 * That page must be frozen for per cpu allocations to work.
23212321 */
2322− VM_BUG_ON(!c->page->frozen);
2322+ VM_BUG_ON_PAGE(!c->page->frozen, c->page);
23232323 c->freelist = get_freepointer(s, freelist);
23242324 c->tid = next_tid(c->tid);
23252325 local_irq_restore(flags);
mm/swap.c+18−18
@@ -57,7 +57,7 @@ static void __page_cache_release(struct page *page) · 56 unmodified lines
5757
5858 spin_lock_irqsave(&zone->lru_lock, flags);
5959 lruvec = mem_cgroup_page_lruvec(page, zone);
60− VM_BUG_ON(!PageLRU(page));
60+ VM_BUG_ON_PAGE(!PageLRU(page), page);
6161 __ClearPageLRU(page);
6262 del_page_from_lru_list(page, lruvec, page_off_lru(page));
6363 spin_unlock_irqrestore(&zone->lru_lock, flags);
@@ -130,8 +130,8 @@ static void put_compound_page(struct page *page) · 66 unmodified lines
130130 * __split_huge_page_refcount cannot race
131131 * here.
132132 */
133− VM_BUG_ON(!PageHead(page_head));
134− VM_BUG_ON(page_mapcount(page) != 0);
133+ VM_BUG_ON_PAGE(!PageHead(page_head), page_head);
134+ VM_BUG_ON_PAGE(page_mapcount(page) != 0, page);
135135 if (put_page_testzero(page_head)) {
136136 /*
137137 * If this is the tail of a slab
@@ -148,7 +148,7 @@ static void put_compound_page(struct page *page) · 10 unmodified lines
148148 * the compound page enters the buddy
149149 * allocator.
150150 */
151− VM_BUG_ON(PageSlab(page_head));
151+ VM_BUG_ON_PAGE(PageSlab(page_head), page_head);
152152 __put_compound_page(page_head);
153153 }
154154 return;
@@ -199,7 +199,7 @@ out_put_single: · 44 unmodified lines
199199 __put_single_page(page);
200200 return;
201201 }
202− VM_BUG_ON(page_head != page->first_page);
202+ VM_BUG_ON_PAGE(page_head != page->first_page, page);
203203 /*
204204 * We can release the refcount taken by
205205 * get_page_unless_zero() now that
@@ -207,12 +207,12 @@ out_put_single: · 1 unmodified line
207207 * compound_lock.
208208 */
209209 if (put_page_testzero(page_head))
210− VM_BUG_ON(1);
210+ VM_BUG_ON_PAGE(1, page_head);
211211 /* __split_huge_page_refcount will wait now */
212− VM_BUG_ON(page_mapcount(page) <= 0);
212+ VM_BUG_ON_PAGE(page_mapcount(page) <= 0, page);
213213 atomic_dec(&page->_mapcount);
214− VM_BUG_ON(atomic_read(&page_head->_count) <= 0);
215− VM_BUG_ON(atomic_read(&page->_count) != 0);
214+ VM_BUG_ON_PAGE(atomic_read(&page_head->_count) <= 0, page_head);
215+ VM_BUG_ON_PAGE(atomic_read(&page->_count) != 0, page);
216216 compound_unlock_irqrestore(page_head, flags);
217217
218218 if (put_page_testzero(page_head)) {
@@ -223,7 +223,7 @@ out_put_single: · 4 unmodified lines
223223 }
224224 } else {
225225 /* page_head is a dangling pointer */
226− VM_BUG_ON(PageTail(page));
226+ VM_BUG_ON_PAGE(PageTail(page), page);
227227 goto out_put_single;
228228 }
229229 }
@@ -264,7 +264,7 @@ bool __get_page_tail(struct page *page) · 34 unmodified lines
264264 * page. __split_huge_page_refcount
265265 * cannot race here.
266266 */
267− VM_BUG_ON(!PageHead(page_head));
267+ VM_BUG_ON_PAGE(!PageHead(page_head), page_head);
268268 __get_page_tail_foll(page, true);
269269 return true;
270270 } else {
@@ -604,8 +604,8 @@ EXPORT_SYMBOL(__lru_cache_add); · 333 unmodified lines
604604 */
605605 void lru_cache_add(struct page *page)
606606 {
607− VM_BUG_ON(PageActive(page) && PageUnevictable(page));
608− VM_BUG_ON(PageLRU(page));
607+ VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page);
608+ VM_BUG_ON_PAGE(PageLRU(page), page);
609609 __lru_cache_add(page);
610610 }
611611
@@ -846,7 +846,7 @@ void release_pages(struct page **pages, int nr, int cold) · 234 unmodified lines
846846 }
847847
848848 lruvec = mem_cgroup_page_lruvec(page, zone);
849− VM_BUG_ON(!PageLRU(page));
849+ VM_BUG_ON_PAGE(!PageLRU(page), page);
850850 __ClearPageLRU(page);
851851 del_page_from_lru_list(page, lruvec, page_off_lru(page));
852852 }
@@ -888,9 +888,9 @@ void lru_add_page_tail(struct page *page, struct page *page_tail, · 35 unmodified lines
888888 {
889889 const int file = 0;
890890
891− VM_BUG_ON(!PageHead(page));
892− VM_BUG_ON(PageCompound(page_tail));
893− VM_BUG_ON(PageLRU(page_tail));
891+ VM_BUG_ON_PAGE(!PageHead(page), page);
892+ VM_BUG_ON_PAGE(PageCompound(page_tail), page);
893+ VM_BUG_ON_PAGE(PageLRU(page_tail), page);
894894 VM_BUG_ON(NR_CPUS != 1 &&
895895 !spin_is_locked(&lruvec_zone(lruvec)->lru_lock));
896896
@@ -929,7 +929,7 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, · 32 unmodified lines
929929 int active = PageActive(page);
930930 enum lru_list lru = page_lru(page);
931931
932− VM_BUG_ON(PageLRU(page));
932+ VM_BUG_ON_PAGE(PageLRU(page), page);
933933
934934 SetPageLRU(page);
935935 add_page_to_lru_list(page, lruvec, lru);
mm/swap_state.c+8−8
@@ -83,9 +83,9 @@ int __add_to_swap_cache(struct page *page, swp_entry_t entry) · 82 unmodified lines
8383 int error;
8484 struct address_space *address_space;
8585
86− VM_BUG_ON(!PageLocked(page));
87− VM_BUG_ON(PageSwapCache(page));
88− VM_BUG_ON(!PageSwapBacked(page));
86+ VM_BUG_ON_PAGE(!PageLocked(page), page);
87+ VM_BUG_ON_PAGE(PageSwapCache(page), page);
88+ VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
8989
9090 page_cache_get(page);
9191 SetPageSwapCache(page);
@@ -139,9 +139,9 @@ void __delete_from_swap_cache(struct page *page) · 47 unmodified lines
139139 swp_entry_t entry;
140140 struct address_space *address_space;
141141
142− VM_BUG_ON(!PageLocked(page));
143− VM_BUG_ON(!PageSwapCache(page));
144− VM_BUG_ON(PageWriteback(page));
142+ VM_BUG_ON_PAGE(!PageLocked(page), page);
143+ VM_BUG_ON_PAGE(!PageSwapCache(page), page);
144+ VM_BUG_ON_PAGE(PageWriteback(page), page);
145145
146146 entry.val = page_private(page);
147147 address_space = swap_address_space(entry);
@@ -165,8 +165,8 @@ int add_to_swap(struct page *page, struct list_head *list) · 17 unmodified lines
165165 swp_entry_t entry;
166166 int err;
167167
168− VM_BUG_ON(!PageLocked(page));
169− VM_BUG_ON(!PageUptodate(page));
168+ VM_BUG_ON_PAGE(!PageLocked(page), page);
169+ VM_BUG_ON_PAGE(!PageUptodate(page), page);
170170
171171 entry = get_swap_page();
172172 if (!entry.val)
mm/swapfile.c+6−5
@@ -616,7 +616,7 @@ scan: · 615 unmodified lines
616616 }
617617 }
618618 offset = si->lowest_bit;
619− while (++offset < scan_base) {
619+ while (offset < scan_base) {
620620 if (!si->swap_map[offset]) {
621621 spin_lock(&si->lock);
622622 goto checks;
@@ -629,6 +629,7 @@ scan: · 6 unmodified lines
629629 cond_resched();
630630 latency_ration = LATENCY_LIMIT;
631631 }
632+ offset++;
632633 }
633634 spin_lock(&si->lock);
634635
@@ -906,7 +907,7 @@ int reuse_swap_page(struct page *page) · 271 unmodified lines
906907 {
907908 int count;
908909
909− VM_BUG_ON(!PageLocked(page));
910+ VM_BUG_ON_PAGE(!PageLocked(page), page);
910911 if (unlikely(PageKsm(page)))
911912 return 0;
912913 count = page_mapcount(page);
@@ -926,7 +927,7 @@ int reuse_swap_page(struct page *page) · 13 unmodified lines
926927 */
927928 int try_to_free_swap(struct page *page)
928929 {
929− VM_BUG_ON(!PageLocked(page));
930+ VM_BUG_ON_PAGE(!PageLocked(page), page);
930931
931932 if (!PageSwapCache(page))
932933 return 0;
@@ -2714,7 +2715,7 @@ struct swap_info_struct *page_swap_info(struct page *page) · 1781 unmodified lines
27142715 */
27152716 struct address_space *__page_file_mapping(struct page *page)
27162717 {
2717− VM_BUG_ON(!PageSwapCache(page));
2718+ VM_BUG_ON_PAGE(!PageSwapCache(page), page);
27182719 return page_swap_info(page)->swap_file->f_mapping;
27192720 }
27202721 EXPORT_SYMBOL_GPL(__page_file_mapping);
@@ -2722,7 +2723,7 @@ EXPORT_SYMBOL_GPL(__page_file_mapping); · 1 unmodified line
27222723 pgoff_t __page_file_index(struct page *page)
27232724 {
27242725 swp_entry_t swap = { .val = page_private(page) };
2725− VM_BUG_ON(!PageSwapCache(page));
2726+ VM_BUG_ON_PAGE(!PageSwapCache(page), page);
27262727 return swp_offset(swap);
27272728 }
27282729 EXPORT_SYMBOL_GPL(__page_file_index);
mm/vmscan.c+41−23
@@ -281,17 +281,34 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker, · 280 unmodified lines
281281 nr_pages_scanned, lru_pages,
282282 max_pass, delta, total_scan);
283283
284− while (total_scan >= batch_size) {
284+ /*
285+ * Normally, we should not scan less than batch_size objects in one
286+ * pass to avoid too frequent shrinker calls, but if the slab has less
287+ * than batch_size objects in total and we are really tight on memory,
288+ * we will try to reclaim all available objects, otherwise we can end
289+ * up failing allocations although there are plenty of reclaimable
290+ * objects spread over several slabs with usage less than the
291+ * batch_size.
292+ *
293+ * We detect the "tight on memory" situations by looking at the total
294+ * number of objects we want to scan (total_scan). If it is greater
295+ * than the total number of objects on slab (max_pass), we must be
296+ * scanning at high prio and therefore should try to reclaim as much as
297+ * possible.
298+ */
299+ while (total_scan >= batch_size ||
300+ total_scan >= max_pass) {
285301 unsigned long ret;
302+ unsigned long nr_to_scan = min(batch_size, total_scan);
286303
287− shrinkctl->nr_to_scan = batch_size;
304+ shrinkctl->nr_to_scan = nr_to_scan;
288305 ret = shrinker->scan_objects(shrinker, shrinkctl);
289306 if (ret == SHRINK_STOP)
290307 break;
291308 freed += ret;
292309
293− count_vm_events(SLABS_SCANNED, batch_size);
294− total_scan -= batch_size;
310+ count_vm_events(SLABS_SCANNED, nr_to_scan);
311+ total_scan -= nr_to_scan;
295312
296313 cond_resched();
297314 }
@@ -352,16 +369,17 @@ unsigned long shrink_slab(struct shrink_control *shrinkctl, · 54 unmodified lines
352369 }
353370
354371 list_for_each_entry(shrinker, &shrinker_list, list) {
355− for_each_node_mask(shrinkctl->nid, shrinkctl->nodes_to_scan) {
356− if (!node_online(shrinkctl->nid))
357− continue;
358−
359− if (!(shrinker->flags & SHRINKER_NUMA_AWARE) &&
360− (shrinkctl->nid != 0))
361− break;
362−
372+ if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) {
373+ shrinkctl->nid = 0;
363374 freed += shrink_slab_node(shrinkctl, shrinker,
364− nr_pages_scanned, lru_pages);
375+ nr_pages_scanned, lru_pages);
376+ continue;
377+ }
378+
379+ for_each_node_mask(shrinkctl->nid, shrinkctl->nodes_to_scan) {
380+ if (node_online(shrinkctl->nid))
381+ freed += shrink_slab_node(shrinkctl, shrinker,
382+ nr_pages_scanned, lru_pages);
365383
366384 }
367385 }
@@ -603,7 +621,7 @@ void putback_lru_page(struct page *page) · 235 unmodified lines
603621 bool is_unevictable;
604622 int was_unevictable = PageUnevictable(page);
605623
606− VM_BUG_ON(PageLRU(page));
624+ VM_BUG_ON_PAGE(PageLRU(page), page);
607625
608626 redo:
609627 ClearPageUnevictable(page);
@@ -794,8 +812,8 @@ static unsigned long shrink_page_list(struct list_head *page_list, · 184 unmodified lines
794812 if (!trylock_page(page))
795813 goto keep;
796814
797− VM_BUG_ON(PageActive(page));
798− VM_BUG_ON(page_zone(page) != zone);
815+ VM_BUG_ON_PAGE(PageActive(page), page);
816+ VM_BUG_ON_PAGE(page_zone(page) != zone, page);
799817
800818 sc->nr_scanned++;
801819
@@ -1079,14 +1097,14 @@ activate_locked: · 277 unmodified lines
10791097 /* Not a candidate for swapping, so reclaim swap space. */
10801098 if (PageSwapCache(page) && vm_swap_full())
10811099 try_to_free_swap(page);
1082− VM_BUG_ON(PageActive(page));
1100+ VM_BUG_ON_PAGE(PageActive(page), page);
10831101 SetPageActive(page);
10841102 pgactivate++;
10851103 keep_locked:
10861104 unlock_page(page);
10871105 keep:
10881106 list_add(&page->lru, &ret_pages);
1089− VM_BUG_ON(PageLRU(page) || PageUnevictable(page));
1107+ VM_BUG_ON_PAGE(PageLRU(page) || PageUnevictable(page), page);
10901108 }
10911109
10921110 free_hot_cold_page_list(&free_pages, 1);
@@ -1240,7 +1258,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, · 147 unmodified lines
12401258 page = lru_to_page(src);
12411259 prefetchw_prev_lru_page(page, src, flags);
12421260
1243− VM_BUG_ON(!PageLRU(page));
1261+ VM_BUG_ON_PAGE(!PageLRU(page), page);
12441262
12451263 switch (__isolate_lru_page(page, mode)) {
12461264 case 0:
@@ -1295,7 +1313,7 @@ int isolate_lru_page(struct page *page) · 48 unmodified lines
12951313 {
12961314 int ret = -EBUSY;
12971315
1298− VM_BUG_ON(!page_count(page));
1316+ VM_BUG_ON_PAGE(!page_count(page), page);
12991317
13001318 if (PageLRU(page)) {
13011319 struct zone *zone = page_zone(page);
@@ -1366,7 +1384,7 @@ putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) · 64 unmodified lines
13661384 struct page *page = lru_to_page(page_list);
13671385 int lru;
13681386
1369− VM_BUG_ON(PageLRU(page));
1387+ VM_BUG_ON_PAGE(PageLRU(page), page);
13701388 list_del(&page->lru);
13711389 if (unlikely(!page_evictable(page))) {
13721390 spin_unlock_irq(&zone->lru_lock);
@@ -1586,7 +1604,7 @@ static void move_active_pages_to_lru(struct lruvec *lruvec, · 213 unmodified lines
15861604 page = lru_to_page(list);
15871605 lruvec = mem_cgroup_page_lruvec(page, zone);
15881606
1589− VM_BUG_ON(PageLRU(page));
1607+ VM_BUG_ON_PAGE(PageLRU(page), page);
15901608 SetPageLRU(page);
15911609
15921610 nr_pages = hpage_nr_pages(page);
@@ -3701,7 +3719,7 @@ void check_move_unevictable_pages(struct page **pages, int nr_pages) · 2108 unmodified lines
37013719 if (page_evictable(page)) {
37023720 enum lru_list lru = page_lru_base_type(page);
37033721
3704− VM_BUG_ON(PageActive(page));
3722+ VM_BUG_ON_PAGE(PageActive(page), page);
37053723 ClearPageUnevictable(page);
37063724 del_page_from_lru_list(page, lruvec, LRU_UNEVICTABLE);
37073725 add_page_to_lru_list(page, lruvec, lru);
mm/zswap.c+2−2
@@ -77,12 +77,12 @@ static u64 zswap_duplicate_entry; · 76 unmodified lines
7777 **********************************/
7878 /* Enable/disable zswap (disabled by default, fixed at boot for now) */
7979 static bool zswap_enabled __read_mostly;
80−module_param_named(enabled, zswap_enabled, bool, 0);
80+module_param_named(enabled, zswap_enabled, bool, 0444);
8181
8282 /* Compressor to be used by zswap (fixed at boot for now) */
8383 #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
8484 static char *zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT;
85−module_param_named(compressor, zswap_compressor, charp, 0);
85+module_param_named(compressor, zswap_compressor, charp, 0444);
8686
8787 /* The maximum percentage of memory that the compressed pool can occupy */
8888 static unsigned int zswap_max_pool_percent = 20;
net/ipv4/tcp_illinois.c+0−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #define ALPHA_MIN ((3*ALPHA_SCALE)/10) /* ~0.3 */
2424 #define ALPHA_MAX (10*ALPHA_SCALE) /* 10.0 */
2525 #define ALPHA_BASE ALPHA_SCALE /* 1.0 */
26−#define U32_MAX ((u32)~0U)
2726 #define RTT_MAX (U32_MAX / ALPHA_MAX) /* 3.3 secs */
2827
2928 #define BETA_SHIFT 6
net/netfilter/ipset/ip_set_hash_netiface.c+4−23
@@ -46,31 +46,12 @@ struct iface_node { · 45 unmodified lines
4646 static void
4747 rbtree_destroy(struct rb_root *root)
4848 {
49− struct rb_node *p, *n = root->rb_node;
50− struct iface_node *node;
51−
52− /* Non-recursive destroy, like in ext3 */
53− while (n) {
54− if (n->rb_left) {
55− n = n->rb_left;
56− continue;
57− }
58− if (n->rb_right) {
59− n = n->rb_right;
60− continue;
61− }
62− p = rb_parent(n);
63− node = rb_entry(n, struct iface_node, node);
64− if (!p)
65− *root = RB_ROOT;
66− else if (p->rb_left == n)
67− p->rb_left = NULL;
68− else if (p->rb_right == n)
69− p->rb_right = NULL;
49+ struct iface_node *node, *next;
7050
51+ rbtree_postorder_for_each_entry_safe(node, next, root, node)
7152 kfree(node);
72− n = p;
73− }
53+
54+ *root = RB_ROOT;
7455 }
7556
7657 static int
scripts/checkpatch.pl+163−17
@@ -29,6 +29,7 @@ my $mailback = 0; · 28 unmodified lines
2929 my $summary_file = 0;
3030 my $show_types = 0;
3131 my $fix = 0;
32+my $fix_inplace = 0;
3233 my $root;
3334 my %debug;
3435 my %camelcase = ();
@@ -76,6 +77,9 @@ Options: · 41 unmodified lines
7677 "<inputfile>.EXPERIMENTAL-checkpatch-fixes"
7778 with potential errors corrected to the preferred
7879 checkpatch style
80+ --fix-inplace EXPERIMENTAL - may create horrible results
81+ Is the same as --fix, but overwrites the input
82+ file. It's your fault if there's no backup or git
7983 --ignore-perl-version override checking of perl version. expect
8084 runtime errors.
8185 -h, --help, --version display this help and exit
@@ -131,6 +135,7 @@ GetOptions( · 49 unmodified lines
131135 'mailback!' => \$mailback,
132136 'summary-file!' => \$summary_file,
133137 'fix!' => \$fix,
138+ 'fix-inplace!' => \$fix_inplace,
134139 'ignore-perl-version!' => \$ignore_perl_version,
135140 'debug=s' => \%debug,
136141 'test-only=s' => \$tst_only,
@@ -140,6 +145,8 @@ GetOptions( · 3 unmodified lines
140145
141146 help(0) if ($help);
142147
148+$fix = 1 if ($fix_inplace);
149+
143150 my $exit = 0;
144151
145152 if ($^V && $^V lt $minimum_perl_version) {
@@ -1963,15 +1970,14 @@ sub process { · 1817 unmodified lines
19631970 }
19641971
19651972 # Check for FSF mailing addresses.
1966− if ($rawline =~ /You should have received a copy/ ||
1967− $rawline =~ /write to the Free Software/ ||
1968− $rawline =~ /59 Temple Place/ ||
1969− $rawline =~ /51 Franklin Street/) {
1973+ if ($rawline =~ /\bwrite to the Free/i ||
1974+ $rawline =~ /\b59\s+Temple\s+Pl/i ||
1975+ $rawline =~ /\b51\s+Franklin\s+St/i) {
19701976 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
19711977 my $msg_type = \&ERROR;
19721978 $msg_type = \&CHK if ($file);
19731979 &{$msg_type}("FSF_MAILING_ADDRESS",
1974− "Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL.\n" . $herevet)
1980+ "Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL.\n" . $herevet)
19751981 }
19761982
19771983 # check for Kconfig help text having a real description
@@ -2034,6 +2040,33 @@ sub process { · 56 unmodified lines
20342040 "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
20352041 }
20362042
2043+# check for DT compatible documentation
2044+ if (defined $root && $realfile =~ /\.dts/ &&
2045+ $rawline =~ /^\+\s*compatible\s*=/) {
2046+ my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g;
2047+
2048+ foreach my $compat (@compats) {
2049+ my $compat2 = $compat;
2050+ my $dt_path = $root . "/Documentation/devicetree/bindings/";
2051+ $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/;
2052+ `grep -Erq "$compat|$compat2" $dt_path`;
2053+ if ( $? >> 8 ) {
2054+ WARN("UNDOCUMENTED_DT_STRING",
2055+ "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
2056+ }
2057+
2058+ my $vendor = $compat;
2059+ my $vendor_path = $dt_path . "vendor-prefixes.txt";
2060+ next if (! -f $vendor_path);
2061+ $vendor =~ s/^([a-zA-Z0-9]+)\,.*/$1/;
2062+ `grep -Eq "$vendor" $vendor_path`;
2063+ if ( $? >> 8 ) {
2064+ WARN("UNDOCUMENTED_DT_STRING",
2065+ "DT compatible string vendor \"$vendor\" appears un-documented -- check $vendor_path\n" . $herecurr);
2066+ }
2067+ }
2068+ }
2069+
20372070 # check we are in a valid source file if not then ignore this hunk
20382071 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
20392072
@@ -2049,16 +2082,12 @@ sub process { · 9 unmodified lines
20492082 }
20502083
20512084 # Check for user-visible strings broken across lines, which breaks the ability
2052−# to grep for the string. Limited to strings used as parameters (those
2053−# following an open parenthesis), which almost completely eliminates false
2054−# positives, as well as warning only once per parameter rather than once per
2055−# line of the string. Make an exception when the previous string ends in a
2056−# newline (multiple lines in one string constant) or \n\t (common in inline
2057−# assembly to indent the instruction on the following line).
2085+# to grep for the string. Make exceptions when the previous string ends in a
2086+# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
2087+# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
20582088 if ($line =~ /^\+\s*"/ &&
20592089 $prevline =~ /"\s*$/ &&
2060− $prevline =~ /\(/ &&
2061− $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
2090+ $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
20622091 WARN("SPLIT_STRING",
20632092 "quoted string split across lines\n" . $hereprev);
20642093 }
@@ -2115,8 +2144,10 @@ sub process { · 50 unmodified lines
21152144 if (WARN("SPACE_BEFORE_TAB",
21162145 "please, no space before tabs\n" . $herevet) &&
21172146 $fix) {
2118− $fixed[$linenr - 1] =~
2119− s/(^\+.*) +\t/$1\t/;
2147+ while ($fixed[$linenr - 1] =~
2148+ s/(^\+.*) {8,8}+\t/$1\t\t/) {}
2149+ while ($fixed[$linenr - 1] =~
2150+ s/(^\+.*) +\t/$1\t/) {}
21202151 }
21212152 }
21222153
@@ -2805,6 +2836,65 @@ sub process { · 682 unmodified lines
28052836 }
28062837 }
28072838
2839+# Function pointer declarations
2840+# check spacing between type, funcptr, and args
2841+# canonical declaration is "type (*funcptr)(args...)"
2842+#
2843+# the $Declare variable will capture all spaces after the type
2844+# so check it for trailing missing spaces or multiple spaces
2845+ if ($line =~ /^.\s*($Declare)\((\s*)\*(\s*)$Ident(\s*)\)(\s*)\(/) {
2846+ my $declare = $1;
2847+ my $pre_pointer_space = $2;
2848+ my $post_pointer_space = $3;
2849+ my $funcname = $4;
2850+ my $post_funcname_space = $5;
2851+ my $pre_args_space = $6;
2852+
2853+ if ($declare !~ /\s$/) {
2854+ WARN("SPACING",
2855+ "missing space after return type\n" . $herecurr);
2856+ }
2857+
2858+# unnecessary space "type (*funcptr)(args...)"
2859+ elsif ($declare =~ /\s{2,}$/) {
2860+ WARN("SPACING",
2861+ "Multiple spaces after return type\n" . $herecurr);
2862+ }
2863+
2864+# unnecessary space "type ( *funcptr)(args...)"
2865+ if (defined $pre_pointer_space &&
2866+ $pre_pointer_space =~ /^\s/) {
2867+ WARN("SPACING",
2868+ "Unnecessary space after function pointer open parenthesis\n" . $herecurr);
2869+ }
2870+
2871+# unnecessary space "type (* funcptr)(args...)"
2872+ if (defined $post_pointer_space &&
2873+ $post_pointer_space =~ /^\s/) {
2874+ WARN("SPACING",
2875+ "Unnecessary space before function pointer name\n" . $herecurr);
2876+ }
2877+
2878+# unnecessary space "type (*funcptr )(args...)"
2879+ if (defined $post_funcname_space &&
2880+ $post_funcname_space =~ /^\s/) {
2881+ WARN("SPACING",
2882+ "Unnecessary space after function pointer name\n" . $herecurr);
2883+ }
2884+
2885+# unnecessary space "type (*funcptr) (args...)"
2886+ if (defined $pre_args_space &&
2887+ $pre_args_space =~ /^\s/) {
2888+ WARN("SPACING",
2889+ "Unnecessary space before function pointer arguments\n" . $herecurr);
2890+ }
2891+
2892+ if (show_type("SPACING") && $fix) {
2893+ $fixed[$linenr - 1] =~
2894+ s/^(.\s*$Declare)\(\s*\*\s*($Ident)\s*\)\s*\(/rtrim($1) . " " . "\(\*$2\)\("/ex;
2895+ }
2896+ }
2897+
28082898 # check for spacing round square brackets; allowed:
28092899 # 1. with a type on the left -- int [] a;
28102900 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
@@ -3125,7 +3215,7 @@ sub process { · 314 unmodified lines
31253215 }
31263216
31273217 # check for whitespace before a non-naked semicolon
3128− if ($line =~ /^\+.*\S\s+;/) {
3218+ if ($line =~ /^\+.*\S\s+;\s*$/) {
31293219 if (WARN("SPACING",
31303220 "space prohibited before semicolon\n" . $herecurr) &&
31313221 $fix) {
@@ -3249,6 +3339,20 @@ sub process { · 117 unmodified lines
32493339 }
32503340 }
32513341
3342+# if statements using unnecessary parentheses - ie: if ((foo == bar))
3343+ if ($^V && $^V ge 5.10.0 &&
3344+ $line =~ /\bif\s*((?:\(\s*){2,})/) {
3345+ my $openparens = $1;
3346+ my $count = $openparens =~ tr@\(@\(@;
3347+ my $msg = "";
3348+ if ($line =~ /\bif\s*(?:\(\s*){$count,$count}$LvalOrFunc\s*($Compare)\s*$LvalOrFunc(?:\s*\)){$count,$count}/) {
3349+ my $comp = $4; #Not $1 because of $LvalOrFunc
3350+ $msg = " - maybe == should be = ?" if ($comp eq "==");
3351+ WARN("UNNECESSARY_PARENTHESES",
3352+ "Unnecessary parentheses$msg\n" . $herecurr);
3353+ }
3354+ }
3355+
32523356 # Return of what appears to be an errno should normally be -'ve
32533357 if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
32543358 my $name = $1;
@@ -3983,6 +4087,16 @@ sub process { · 728 unmodified lines
39834087 }
39844088 }
39854089
4090+# Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar)
4091+ if ($^V && $^V ge 5.10.0 &&
4092+ $line =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/s) {
4093+ if (WARN("PREFER_ETHER_ADDR_COPY",
4094+ "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . $herecurr) &&
4095+ $fix) {
4096+ $fixed[$linenr - 1] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/;
4097+ }
4098+ }
4099+
39864100 # typecasts on min/max could be min_t/max_t
39874101 if ($^V && $^V ge 5.10.0 &&
39884102 defined $stat &&
@@ -4117,6 +4231,12 @@ sub process { · 128 unmodified lines
41174231 "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
41184232 }
41194233
4234+# check for GFP_NOWAIT use
4235+ if ($line =~ /\b__GFP_NOFAIL\b/) {
4236+ WARN("__GFP_NOFAIL",
4237+ "Use of __GFP_NOFAIL is deprecated, no new users should be added\n" . $herecurr);
4238+ }
4239+
41204240 # check for multiple semicolons
41214241 if ($line =~ /;\s*;\s*$/) {
41224242 if (WARN("ONE_SEMICOLON",
@@ -4126,6 +4246,31 @@ sub process { · 3 unmodified lines
41264246 }
41274247 }
41284248
4249+# check for case / default statements not preceeded by break/fallthrough/switch
4250+ if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
4251+ my $has_break = 0;
4252+ my $has_statement = 0;
4253+ my $count = 0;
4254+ my $prevline = $linenr;
4255+ while ($prevline > 1 && $count < 3 && !$has_break) {
4256+ $prevline--;
4257+ my $rline = $rawlines[$prevline - 1];
4258+ my $fline = $lines[$prevline - 1];
4259+ last if ($fline =~ /^\@\@/);
4260+ next if ($fline =~ /^\-/);
4261+ next if ($fline =~ /^.(?:\s*(?:case\s+(?:$Ident|$Constant)[\s$;]*|default):[\s$;]*)*$/);
4262+ $has_break = 1 if ($rline =~ /fall[\s_-]*(through|thru)/i);
4263+ next if ($fline =~ /^.[\s$;]*$/);
4264+ $has_statement = 1;
4265+ $count++;
4266+ $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/);
4267+ }
4268+ if (!$has_break && $has_statement) {
4269+ WARN("MISSING_BREAK",
4270+ "Possible switch case/default not preceeded by break or fallthrough comment\n" . $herecurr);
4271+ }
4272+ }
4273+
41294274 # check for switch/default statements without a break;
41304275 if ($^V && $^V ge 5.10.0 &&
41314276 defined $stat &&
@@ -4361,7 +4506,8 @@ sub process { · 229 unmodified lines
43614506 hash_show_words(\%ignore_type, "Ignored");
43624507
43634508 if ($clean == 0 && $fix && "@rawlines" ne "@fixed") {
4364− my $newfile = $filename . ".EXPERIMENTAL-checkpatch-fixes";
4509+ my $newfile = $filename;
4510+ $newfile .= ".EXPERIMENTAL-checkpatch-fixes" if (!$fix_inplace);
43654511 my $linecount = 0;
43664512 my $f;
43674513
scripts/get_maintainer.pl+85−6
@@ -98,6 +98,7 @@ my %VCS_cmds_git = ( · 97 unmodified lines
9898 "available" => '(which("git") ne "") && (-d ".git")',
9999 "find_signers_cmd" =>
100100 "git log --no-color --follow --since=\$email_git_since " .
101+ '--numstat --no-merges ' .
101102 '--format="GitCommit: %H%n' .
102103 'GitAuthor: %an <%ae>%n' .
103104 'GitDate: %aD%n' .
@@ -106,6 +107,7 @@ my %VCS_cmds_git = ( · 2 unmodified lines
106107 " -- \$file",
107108 "find_commit_signers_cmd" =>
108109 "git log --no-color " .
110+ '--numstat ' .
109111 '--format="GitCommit: %H%n' .
110112 'GitAuthor: %an <%ae>%n' .
111113 'GitDate: %aD%n' .
@@ -114,6 +116,7 @@ my %VCS_cmds_git = ( · 2 unmodified lines
114116 " -1 \$commit",
115117 "find_commit_author_cmd" =>
116118 "git log --no-color " .
119+ '--numstat ' .
117120 '--format="GitCommit: %H%n' .
118121 'GitAuthor: %an <%ae>%n' .
119122 'GitDate: %aD%n' .
@@ -125,6 +128,7 @@ my %VCS_cmds_git = ( · 5 unmodified lines
125128 "blame_commit_pattern" => "^([0-9a-f]+) ",
126129 "author_pattern" => "^GitAuthor: (.*)",
127130 "subject_pattern" => "^GitSubject: (.*)",
131+ "stat_pattern" => "^(\\d+)\\t(\\d+)\\t\$file\$",
128132 );
129133
130134 my %VCS_cmds_hg = (
@@ -152,6 +156,7 @@ my %VCS_cmds_hg = ( · 21 unmodified lines
152156 "blame_commit_pattern" => "^([ 0-9a-f]+):",
153157 "author_pattern" => "^HgAuthor: (.*)",
154158 "subject_pattern" => "^HgSubject: (.*)",
159+ "stat_pattern" => "^(\\d+)\t(\\d+)\t\$file\$",
155160 );
156161
157162 my $conf = which_conf(".get_maintainer.conf");
@@ -1269,20 +1274,30 @@ sub extract_formatted_signatures { · 1111 unmodified lines
12691274 }
12701275
12711276 sub vcs_find_signers {
1272− my ($cmd) = @_;
1277+ my ($cmd, $file) = @_;
12731278 my $commits;
12741279 my @lines = ();
12751280 my @signatures = ();
1281+ my @authors = ();
1282+ my @stats = ();
12761283
12771284 @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
12781285
12791286 my $pattern = $VCS_cmds{"commit_pattern"};
1287+ my $author_pattern = $VCS_cmds{"author_pattern"};
1288+ my $stat_pattern = $VCS_cmds{"stat_pattern"};
1289+
1290+ $stat_pattern =~ s/(\$\w+)/$1/eeg; #interpolate $stat_pattern
12801291
12811292 $commits = grep(/$pattern/, @lines); # of commits
12821293
1294+ @authors = grep(/$author_pattern/, @lines);
12831295 @signatures = grep(/^[ \t]*${signature_pattern}.*\@.*$/, @lines);
1296+ @stats = grep(/$stat_pattern/, @lines);
12841297
1285− return (0, @signatures) if !@signatures;
1298+# print("stats: <@stats>\n");
1299+
1300+ return (0, \@signatures, \@authors, \@stats) if !@signatures;
12861301
12871302 save_commits_by_author(@lines) if ($interactive);
12881303 save_commits_by_signer(@lines) if ($interactive);
@@ -1291,9 +1306,10 @@ sub vcs_find_signers { · 2 unmodified lines
12911306 @signatures = grep(!/${penguin_chiefs}/i, @signatures);
12921307 }
12931308
1309+ my ($author_ref, $authors_ref) = extract_formatted_signatures(@authors);
12941310 my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures);
12951311
1296− return ($commits, @$signers_ref);
1312+ return ($commits, $signers_ref, $authors_ref, \@stats);
12971313 }
12981314
12991315 sub vcs_find_author {
@@ -1849,7 +1865,12 @@ sub vcs_assign { · 549 unmodified lines
18491865 sub vcs_file_signoffs {
18501866 my ($file) = @_;
18511867
1868+ my $authors_ref;
1869+ my $signers_ref;
1870+ my $stats_ref;
1871+ my @authors = ();
18521872 my @signers = ();
1873+ my @stats = ();
18531874 my $commits;
18541875
18551876 $vcs_used = vcs_exists();
@@ -1858,13 +1879,59 @@ sub vcs_file_signoffs { · 2 unmodified lines
18581879 my $cmd = $VCS_cmds{"find_signers_cmd"};
18591880 $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd
18601881
1861− ($commits, @signers) = vcs_find_signers($cmd);
1882+ ($commits, $signers_ref, $authors_ref, $stats_ref) = vcs_find_signers($cmd, $file);
1883+
1884+ @signers = @{$signers_ref} if defined $signers_ref;
1885+ @authors = @{$authors_ref} if defined $authors_ref;
1886+ @stats = @{$stats_ref} if defined $stats_ref;
1887+
1888+# print("commits: <$commits>\nsigners:<@signers>\nauthors: <@authors>\nstats: <@stats>\n");
18621889
18631890 foreach my $signer (@signers) {
18641891 $signer = deduplicate_email($signer);
18651892 }
18661893
18671894 vcs_assign("commit_signer", $commits, @signers);
1895+ vcs_assign("authored", $commits, @authors);
1896+ if ($#authors == $#stats) {
1897+ my $stat_pattern = $VCS_cmds{"stat_pattern"};
1898+ $stat_pattern =~ s/(\$\w+)/$1/eeg; #interpolate $stat_pattern
1899+
1900+ my $added = 0;
1901+ my $deleted = 0;
1902+ for (my $i = 0; $i <= $#stats; $i++) {
1903+ if ($stats[$i] =~ /$stat_pattern/) {
1904+ $added += $1;
1905+ $deleted += $2;
1906+ }
1907+ }
1908+ my @tmp_authors = uniq(@authors);
1909+ foreach my $author (@tmp_authors) {
1910+ $author = deduplicate_email($author);
1911+ }
1912+ @tmp_authors = uniq(@tmp_authors);
1913+ my @list_added = ();
1914+ my @list_deleted = ();
1915+ foreach my $author (@tmp_authors) {
1916+ my $auth_added = 0;
1917+ my $auth_deleted = 0;
1918+ for (my $i = 0; $i <= $#stats; $i++) {
1919+ if ($author eq deduplicate_email($authors[$i]) &&
1920+ $stats[$i] =~ /$stat_pattern/) {
1921+ $auth_added += $1;
1922+ $auth_deleted += $2;
1923+ }
1924+ }
1925+ for (my $i = 0; $i < $auth_added; $i++) {
1926+ push(@list_added, $author);
1927+ }
1928+ for (my $i = 0; $i < $auth_deleted; $i++) {
1929+ push(@list_deleted, $author);
1930+ }
1931+ }
1932+ vcs_assign("added_lines", $added, @list_added);
1933+ vcs_assign("removed_lines", $deleted, @list_deleted);
1934+ }
18681935 }
18691936
18701937 sub vcs_file_blame {
@@ -1887,6 +1954,10 @@ sub vcs_file_blame { · 16 unmodified lines
18871954 if ($email_git_blame_signatures) {
18881955 if (vcs_is_hg()) {
18891956 my $commit_count;
1957+ my $commit_authors_ref;
1958+ my $commit_signers_ref;
1959+ my $stats_ref;
1960+ my @commit_authors = ();
18901961 my @commit_signers = ();
18911962 my $commit = join(" -r ", @commits);
18921963 my $cmd;
@@ -1894,19 +1965,27 @@ sub vcs_file_blame { · 1 unmodified line
18941965 $cmd = $VCS_cmds{"find_commit_signers_cmd"};
18951966 $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
18961967
1897− ($commit_count, @commit_signers) = vcs_find_signers($cmd);
1968+ ($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, $file);
1969+ @commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
1970+ @commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
18981971
18991972 push(@signers, @commit_signers);
19001973 } else {
19011974 foreach my $commit (@commits) {
19021975 my $commit_count;
1976+ my $commit_authors_ref;
1977+ my $commit_signers_ref;
1978+ my $stats_ref;
1979+ my @commit_authors = ();
19031980 my @commit_signers = ();
19041981 my $cmd;
19051982
19061983 $cmd = $VCS_cmds{"find_commit_signers_cmd"};
19071984 $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
19081985
1909− ($commit_count, @commit_signers) = vcs_find_signers($cmd);
1986+ ($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, $file);
1987+ @commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
1988+ @commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
19101989
19111990 push(@signers, @commit_signers);
19121991 }
scripts/headers_check.pl+5−1
@@ -65,7 +65,11 @@ sub check_include · 64 unmodified lines
6565
6666 sub check_declarations
6767 {
68− if ($line =~m/^(\s*extern|unsigned|char|short|int|long|void)\b/) {
68+ # soundcard.h is what it is
69+ if ($line =~ m/^void seqbuf_dump\(void\);/) {
70+ return;
71+ }
72+ if ($line =~ m/^(\s*extern|unsigned|char|short|int|long|void)\b/) {
6973 printf STDERR "$filename:$lineno: " .
7074 "userspace cannot reference function or " .
7175 "variable defined in the kernel\n";
scripts/sortextable.c+5−0
@@ -39,6 +39,10 @@ · 38 unmodified lines
3939 #define EM_AARCH64 183
4040 #endif
4141
42+#ifndef EM_MICROBLAZE
43+#define EM_MICROBLAZE 189
44+#endif
45+
4246 static int fd_map; /* File descriptor for file being modified. */
4347 static int mmap_failed; /* Boolean flag. */
4448 static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */
@@ -275,6 +279,7 @@ do_file(char const *const fname) · 230 unmodified lines
275279 case EM_ARCOMPACT:
276280 case EM_ARM:
277281 case EM_AARCH64:
282+ case EM_MICROBLAZE:
278283 case EM_MIPS:
279284 break;
280285 } /* end switch */
tools/testing/selftests/Makefile+1−0
@@ -9,6 +9,7 @@ TARGETS += ptrace · 8 unmodified lines
99 TARGETS += timers
1010 TARGETS += vm
1111 TARGETS += powerpc
12+TARGETS += user
1213
1314 all:
1415 for TARGET in $(TARGETS); do \
tools/testing/selftests/user/Makefile+13−0
@@ -0,0 +1,13 @@
1+# Makefile for user memory selftests
2+
3+# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
4+all:
5+
6+run_tests: all
7+ @if /sbin/modprobe test_user_copy ; then \
8+ rmmod test_user_copy; \
9+ echo "user_copy: ok"; \
10+ else \
11+ echo "user_copy: [FAIL]"; \
12+ exit 1; \
13+ fi