aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-09 13:30:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-09 13:30:07 -0400
commitfbf4432ff71b7a25bef993a5312906946d27f446 (patch)
treecf3e0024af4b8f9376eff75743f1fa1526e40900
parentc054be10ffdbd5507a1fd738067d76acfb4808fd (diff)
parent0cfb6aee70bddbef6ec796b255f588ce0e126766 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: - most of the rest of MM - a small number of misc things - lib/ updates - checkpatch - autofs updates - ipc/ updates * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (126 commits) ipc: optimize semget/shmget/msgget for lots of keys ipc/sem: play nicer with large nsops allocations ipc/sem: drop sem_checkid helper ipc: convert kern_ipc_perm.refcount from atomic_t to refcount_t ipc: convert sem_undo_list.refcnt from atomic_t to refcount_t ipc: convert ipc_namespace.count from atomic_t to refcount_t kcov: support compat processes sh: defconfig: cleanup from old Kconfig options mn10300: defconfig: cleanup from old Kconfig options m32r: defconfig: cleanup from old Kconfig options drivers/pps: use surrounding "if PPS" to remove numerous dependency checks drivers/pps: aesthetic tweaks to PPS-related content cpumask: make cpumask_next() out-of-line kmod: move #ifdef CONFIG_MODULES wrapper to Makefile kmod: split off umh headers into its own file MAINTAINERS: clarify kmod is just a kernel module loader kmod: split out umh code into its own file test_kmod: flip INT checks to be consistent test_kmod: remove paranoid UINT_MAX check on uint range processing vfat: deduplicate hex2bin() ...
-rw-r--r--Documentation/devicetree/bindings/pps/pps-gpio.txt8
-rw-r--r--Documentation/pps/pps.txt44
-rw-r--r--Documentation/rbtree.txt33
-rw-r--r--Documentation/vm/hmm.txt384
-rw-r--r--MAINTAINERS19
-rw-r--r--arch/alpha/include/asm/string.h15
-rw-r--r--arch/alpha/include/asm/vga.h2
-rw-r--r--arch/alpha/lib/memset.S10
-rw-r--r--arch/arm/include/asm/string.h14
-rw-r--r--arch/arm/kernel/armksyms.c2
-rw-r--r--arch/arm/lib/memset.S24
-rw-r--r--arch/arm64/kernel/smp.c2
-rw-r--r--arch/frv/Kconfig3
-rw-r--r--arch/h8300/Kconfig3
-rw-r--r--arch/m32r/configs/m32104ut_defconfig4
-rw-r--r--arch/m32r/configs/m32700ut.smp_defconfig3
-rw-r--r--arch/m32r/configs/m32700ut.up_defconfig3
-rw-r--r--arch/m32r/configs/mappi.nommu_defconfig2
-rw-r--r--arch/m32r/configs/mappi.smp_defconfig4
-rw-r--r--arch/m32r/configs/mappi.up_defconfig4
-rw-r--r--arch/m32r/configs/mappi2.opsp_defconfig2
-rw-r--r--arch/m32r/configs/mappi2.vdec2_defconfig2
-rw-r--r--arch/m32r/configs/mappi3.smp_defconfig4
-rw-r--r--arch/m32r/configs/oaks32r_defconfig2
-rw-r--r--arch/m32r/configs/opsput_defconfig2
-rw-r--r--arch/m32r/configs/usrv_defconfig5
-rw-r--r--arch/m68k/Kconfig3
-rw-r--r--arch/microblaze/Kconfig16
-rw-r--r--arch/microblaze/Makefile2
-rw-r--r--arch/mips/include/asm/vga.h7
-rw-r--r--arch/mn10300/configs/asb2303_defconfig6
-rw-r--r--arch/mn10300/configs/asb2364_defconfig8
-rw-r--r--arch/openrisc/Kconfig3
-rw-r--r--arch/parisc/Kconfig3
-rw-r--r--arch/powerpc/include/asm/vga.h8
-rw-r--r--arch/powerpc/kernel/paca.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c2
-rw-r--r--arch/powerpc/sysdev/xive/native.c4
-rw-r--r--arch/sh/configs/ap325rxa_defconfig10
-rw-r--r--arch/sh/configs/apsh4a3a_defconfig9
-rw-r--r--arch/sh/configs/apsh4ad0a_defconfig6
-rw-r--r--arch/sh/configs/cayman_defconfig4
-rw-r--r--arch/sh/configs/dreamcast_defconfig6
-rw-r--r--arch/sh/configs/ecovec24-romimage_defconfig7
-rw-r--r--arch/sh/configs/ecovec24_defconfig9
-rw-r--r--arch/sh/configs/edosk7705_defconfig2
-rw-r--r--arch/sh/configs/edosk7760_defconfig11
-rw-r--r--arch/sh/configs/espt_defconfig10
-rw-r--r--arch/sh/configs/hp6xx_defconfig4
-rw-r--r--arch/sh/configs/kfr2r09-romimage_defconfig5
-rw-r--r--arch/sh/configs/kfr2r09_defconfig7
-rw-r--r--arch/sh/configs/landisk_defconfig4
-rw-r--r--arch/sh/configs/lboxre2_defconfig3
-rw-r--r--arch/sh/configs/magicpanelr2_defconfig9
-rw-r--r--arch/sh/configs/microdev_defconfig3
-rw-r--r--arch/sh/configs/migor_defconfig8
-rw-r--r--arch/sh/configs/polaris_defconfig9
-rw-r--r--arch/sh/configs/r7780mp_defconfig4
-rw-r--r--arch/sh/configs/r7785rp_defconfig3
-rw-r--r--arch/sh/configs/rsk7201_defconfig8
-rw-r--r--arch/sh/configs/rsk7203_defconfig10
-rw-r--r--arch/sh/configs/rsk7264_defconfig3
-rw-r--r--arch/sh/configs/rsk7269_defconfig4
-rw-r--r--arch/sh/configs/rts7751r2d1_defconfig5
-rw-r--r--arch/sh/configs/rts7751r2dplus_defconfig8
-rw-r--r--arch/sh/configs/sdk7780_defconfig9
-rw-r--r--arch/sh/configs/sdk7786_defconfig9
-rw-r--r--arch/sh/configs/se7206_defconfig8
-rw-r--r--arch/sh/configs/se7343_defconfig9
-rw-r--r--arch/sh/configs/se7619_defconfig5
-rw-r--r--arch/sh/configs/se7705_defconfig5
-rw-r--r--arch/sh/configs/se7712_defconfig7
-rw-r--r--arch/sh/configs/se7721_defconfig6
-rw-r--r--arch/sh/configs/se7722_defconfig3
-rw-r--r--arch/sh/configs/se7724_defconfig9
-rw-r--r--arch/sh/configs/se7750_defconfig5
-rw-r--r--arch/sh/configs/se7751_defconfig5
-rw-r--r--arch/sh/configs/se7780_defconfig7
-rw-r--r--arch/sh/configs/secureedge5410_defconfig9
-rw-r--r--arch/sh/configs/sh03_defconfig4
-rw-r--r--arch/sh/configs/sh2007_defconfig8
-rw-r--r--arch/sh/configs/sh7710voipgw_defconfig5
-rw-r--r--arch/sh/configs/sh7724_generic_defconfig3
-rw-r--r--arch/sh/configs/sh7757lcr_defconfig4
-rw-r--r--arch/sh/configs/sh7763rdp_defconfig9
-rw-r--r--arch/sh/configs/sh7770_generic_defconfig3
-rw-r--r--arch/sh/configs/sh7785lcr_32bit_defconfig10
-rw-r--r--arch/sh/configs/sh7785lcr_defconfig9
-rw-r--r--arch/sh/configs/shmin_defconfig4
-rw-r--r--arch/sh/configs/shx3_defconfig6
-rw-r--r--arch/sh/configs/titan_defconfig8
-rw-r--r--arch/sh/configs/ul2_defconfig9
-rw-r--r--arch/sh/configs/urquell_defconfig9
-rw-r--r--arch/sparc/Kconfig3
-rw-r--r--arch/sparc/include/asm/vga.h25
-rw-r--r--arch/tile/kernel/setup.c2
-rw-r--r--arch/x86/Kconfig8
-rw-r--r--arch/x86/include/asm/pgtable.h17
-rw-r--r--arch/x86/include/asm/pgtable_64.h14
-rw-r--r--arch/x86/include/asm/pgtable_types.h10
-rw-r--r--arch/x86/include/asm/string_32.h24
-rw-r--r--arch/x86/include/asm/string_64.h36
-rw-r--r--arch/x86/kernel/apic/apic.c2
-rw-r--r--arch/x86/kernel/setup_percpu.c2
-rw-r--r--arch/x86/kernel/smpboot.c2
-rw-r--r--arch/x86/mm/init_64.c22
-rw-r--r--block/cfq-iosched.c81
-rw-r--r--drivers/base/cpu.c4
-rw-r--r--drivers/base/node.c22
-rw-r--r--drivers/block/zram/zram_drv.c13
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h2
-rw-r--r--drivers/gpu/drm/drm_mm.c19
-rw-r--r--drivers/gpu/drm/drm_vma_manager.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_userptr.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_mn.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_vm.c7
-rw-r--r--drivers/infiniband/core/umem_rbtree.c4
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c2
-rw-r--r--drivers/infiniband/hw/hfi1/mmu_rb.c10
-rw-r--r--drivers/infiniband/hw/usnic/usnic_uiom.c6
-rw-r--r--drivers/infiniband/hw/usnic/usnic_uiom.h2
-rw-r--r--drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.c15
-rw-r--r--drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.h12
-rw-r--r--drivers/mtd/nand/denali.c3
-rw-r--r--drivers/pps/Kconfig7
-rw-r--r--drivers/pps/clients/Kconfig7
-rw-r--r--drivers/pps/generators/Kconfig3
-rw-r--r--drivers/scsi/scsi_debug.c2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c11
-rw-r--r--drivers/vhost/vhost.c2
-rw-r--r--drivers/vhost/vhost.h2
-rw-r--r--fs/aio.c8
-rw-r--r--fs/autofs4/autofs_i.h22
-rw-r--r--fs/autofs4/dev-ioctl.c44
-rw-r--r--fs/binfmt_flat.c8
-rw-r--r--fs/eventpoll.c30
-rw-r--r--fs/f2fs/data.c5
-rw-r--r--fs/fat/namei_vfat.c35
-rw-r--r--fs/hugetlbfs/inode.c11
-rw-r--r--fs/inode.c2
-rw-r--r--fs/namei.c15
-rw-r--r--fs/proc/generic.c34
-rw-r--r--fs/proc/internal.h2
-rw-r--r--fs/proc/proc_net.c2
-rw-r--r--fs/proc/root.c2
-rw-r--r--fs/proc/task_mmu.c81
-rw-r--r--fs/proc/task_nommu.c5
-rw-r--r--fs/ubifs/file.c5
-rw-r--r--fs/userfaultfd.c20
-rw-r--r--include/asm-generic/pgtable.h52
-rw-r--r--include/drm/drm_mm.h2
-rw-r--r--include/linux/bitmap.h32
-rw-r--r--include/linux/bitops.h5
-rw-r--r--include/linux/byteorder/big_endian.h4
-rw-r--r--include/linux/byteorder/little_endian.h4
-rw-r--r--include/linux/cpumask.h21
-rw-r--r--include/linux/fs.h7
-rw-r--r--include/linux/hmm.h520
-rw-r--r--include/linux/huge_mm.h24
-rw-r--r--include/linux/init_task.h5
-rw-r--r--include/linux/interval_tree.h8
-rw-r--r--include/linux/interval_tree_generic.h48
-rw-r--r--include/linux/ioport.h2
-rw-r--r--include/linux/ipc.h6
-rw-r--r--include/linux/ipc_namespace.h8
-rw-r--r--include/linux/kernel.h7
-rw-r--r--include/linux/kmod.h60
-rw-r--r--include/linux/memory_hotplug.h11
-rw-r--r--include/linux/memremap.h99
-rw-r--r--include/linux/migrate.h152
-rw-r--r--include/linux/migrate_mode.h5
-rw-r--r--include/linux/mm.h58
-rw-r--r--include/linux/mm_types.h6
-rw-r--r--include/linux/mmzone.h24
-rw-r--r--include/linux/pps-gpio.h2
-rw-r--r--include/linux/pps_kernel.h16
-rw-r--r--include/linux/proc_fs.h8
-rw-r--r--include/linux/rbtree.h21
-rw-r--r--include/linux/rbtree_augmented.h33
-rw-r--r--include/linux/rhashtable.h2
-rw-r--r--include/linux/rmap.h7
-rw-r--r--include/linux/rtmutex.h11
-rw-r--r--include/linux/sched.h3
-rw-r--r--include/linux/string.h30
-rw-r--r--include/linux/swap.h24
-rw-r--r--include/linux/swapops.h143
-rw-r--r--include/linux/umh.h69
-rw-r--r--include/linux/vmstat.h33
-rw-r--r--include/linux/vt_buffer.h13
-rw-r--r--include/rdma/ib_umem_odp.h11
-rw-r--r--include/rdma/ib_verbs.h2
-rw-r--r--include/uapi/linux/auto_dev-ioctl.h2
-rw-r--r--include/uapi/linux/auto_fs4.h2
-rw-r--r--include/uapi/linux/pps.h4
-rw-r--r--init/main.c13
-rw-r--r--ipc/msg.c10
-rw-r--r--ipc/msgutil.c2
-rw-r--r--ipc/namespace.c24
-rw-r--r--ipc/sem.c25
-rw-r--r--ipc/shm.c12
-rw-r--r--ipc/util.c106
-rw-r--r--ipc/util.h21
-rw-r--r--kernel/Makefile3
-rw-r--r--kernel/fork.c6
-rw-r--r--kernel/kcov.c1
-rw-r--r--kernel/kmod.c563
-rw-r--r--kernel/locking/rtmutex-debug.c2
-rw-r--r--kernel/locking/rtmutex.c35
-rw-r--r--kernel/locking/rtmutex_common.h12
-rw-r--r--kernel/memremap.c60
-rw-r--r--kernel/rcu/tree.c2
-rw-r--r--kernel/rcu/tree_plugin.h2
-rw-r--r--kernel/sched/deadline.c50
-rw-r--r--kernel/sched/debug.c2
-rw-r--r--kernel/sched/fair.c39
-rw-r--r--kernel/sched/sched.h9
-rw-r--r--kernel/sched/topology.c2
-rw-r--r--kernel/smp.c2
-rw-r--r--kernel/time/timekeeping.c2
-rw-r--r--kernel/trace/trace_functions_graph.c2
-rw-r--r--kernel/umh.c568
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/Kconfig.debug11
-rw-r--r--lib/Makefile1
-rw-r--r--lib/bitmap.c18
-rw-r--r--lib/cmdline.c1
-rw-r--r--lib/cpumask.c16
-rw-r--r--lib/hexdump.c5
-rw-r--r--lib/interval_tree_test.c4
-rw-r--r--lib/oid_registry.c4
-rw-r--r--lib/radix-tree.c9
-rw-r--r--lib/rbtree.c65
-rw-r--r--lib/rbtree_test.c230
-rw-r--r--lib/string.c207
-rw-r--r--lib/test_bitmap.c91
-rw-r--r--lib/test_debug_virtual.c49
-rw-r--r--lib/test_kmod.c4
-rw-r--r--mm/Kconfig54
-rw-r--r--mm/Makefile1
-rw-r--r--mm/balloon_compaction.c8
-rw-r--r--mm/fadvise.c6
-rw-r--r--mm/gup.c29
-rw-r--r--mm/hmm.c1257
-rw-r--r--mm/huge_memory.c174
-rw-r--r--mm/interval_tree.c10
-rw-r--r--mm/madvise.c2
-rw-r--r--mm/memcontrol.c256
-rw-r--r--mm/memory.c138
-rw-r--r--mm/memory_hotplug.c14
-rw-r--r--mm/mempolicy.c142
-rw-r--r--mm/migrate.c1007
-rw-r--r--mm/mlock.c10
-rw-r--r--mm/mmap.c10
-rw-r--r--mm/mprotect.c18
-rw-r--r--mm/mremap.c2
-rw-r--r--mm/page_alloc.c13
-rw-r--r--mm/page_vma_mapped.c28
-rw-r--r--mm/pgtable-generic.c3
-rw-r--r--mm/rmap.c50
-rw-r--r--mm/slub.c2
-rw-r--r--mm/sparse.c2
-rw-r--r--mm/swap.c11
-rw-r--r--mm/swapfile.c3
-rw-r--r--mm/vmstat.c154
-rw-r--r--mm/zsmalloc.c17
-rwxr-xr-xscripts/checkpatch.pl61
-rw-r--r--sound/soc/codecs/pcm512x.c3
-rw-r--r--tools/testing/selftests/kcmp/kcmp_test.c60
271 files changed, 7222 insertions, 2011 deletions
diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt b/Documentation/devicetree/bindings/pps/pps-gpio.txt
index 40bf9c3564a5..0de23b793657 100644
--- a/Documentation/devicetree/bindings/pps/pps-gpio.txt
+++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt
@@ -13,8 +13,12 @@ Optional properties:
13 13
14Example: 14Example:
15 pps { 15 pps {
16 compatible = "pps-gpio"; 16 pinctrl-names = "default";
17 gpios = <&gpio2 6 0>; 17 pinctrl-0 = <&pinctrl_pps>;
18 18
19 gpios = <&gpio1 26 GPIO_ACTIVE_HIGH>;
19 assert-falling-edge; 20 assert-falling-edge;
21
22 compatible = "pps-gpio";
23 status = "okay";
20 }; 24 };
diff --git a/Documentation/pps/pps.txt b/Documentation/pps/pps.txt
index 1fdbd5447216..99f5d8c4c652 100644
--- a/Documentation/pps/pps.txt
+++ b/Documentation/pps/pps.txt
@@ -48,12 +48,12 @@ problem:
48 time_pps_create(). 48 time_pps_create().
49 49
50This implies that the source has a /dev/... entry. This assumption is 50This implies that the source has a /dev/... entry. This assumption is
51ok for the serial and parallel port, where you can do something 51OK for the serial and parallel port, where you can do something
52useful besides(!) the gathering of timestamps as it is the central 52useful besides(!) the gathering of timestamps as it is the central
53task for a PPS-API. But this assumption does not work for a single 53task for a PPS API. But this assumption does not work for a single
54purpose GPIO line. In this case even basic file-related functionality 54purpose GPIO line. In this case even basic file-related functionality
55(like read() and write()) makes no sense at all and should not be a 55(like read() and write()) makes no sense at all and should not be a
56precondition for the use of a PPS-API. 56precondition for the use of a PPS API.
57 57
58The problem can be simply solved if you consider that a PPS source is 58The problem can be simply solved if you consider that a PPS source is
59not always connected with a GPS data source. 59not always connected with a GPS data source.
@@ -88,13 +88,13 @@ Coding example
88-------------- 88--------------
89 89
90To register a PPS source into the kernel you should define a struct 90To register a PPS source into the kernel you should define a struct
91pps_source_info_s as follows: 91pps_source_info as follows:
92 92
93 static struct pps_source_info pps_ktimer_info = { 93 static struct pps_source_info pps_ktimer_info = {
94 .name = "ktimer", 94 .name = "ktimer",
95 .path = "", 95 .path = "",
96 .mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT | \ 96 .mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT |
97 PPS_ECHOASSERT | \ 97 PPS_ECHOASSERT |
98 PPS_CANWAIT | PPS_TSFMT_TSPEC, 98 PPS_CANWAIT | PPS_TSFMT_TSPEC,
99 .echo = pps_ktimer_echo, 99 .echo = pps_ktimer_echo,
100 .owner = THIS_MODULE, 100 .owner = THIS_MODULE,
@@ -108,13 +108,13 @@ initialization routine as follows:
108 108
109The pps_register_source() prototype is: 109The pps_register_source() prototype is:
110 110
111 int pps_register_source(struct pps_source_info_s *info, int default_params) 111 int pps_register_source(struct pps_source_info *info, int default_params)
112 112
113where "info" is a pointer to a structure that describes a particular 113where "info" is a pointer to a structure that describes a particular
114PPS source, "default_params" tells the system what the initial default 114PPS source, "default_params" tells the system what the initial default
115parameters for the device should be (it is obvious that these parameters 115parameters for the device should be (it is obvious that these parameters
116must be a subset of ones defined in the struct 116must be a subset of ones defined in the struct
117pps_source_info_s which describe the capabilities of the driver). 117pps_source_info which describe the capabilities of the driver).
118 118
119Once you have registered a new PPS source into the system you can 119Once you have registered a new PPS source into the system you can
120signal an assert event (for example in the interrupt handler routine) 120signal an assert event (for example in the interrupt handler routine)
@@ -142,8 +142,10 @@ If the SYSFS filesystem is enabled in the kernel it provides a new class:
142Every directory is the ID of a PPS sources defined in the system and 142Every directory is the ID of a PPS sources defined in the system and
143inside you find several files: 143inside you find several files:
144 144
145 $ ls /sys/class/pps/pps0/ 145 $ ls -F /sys/class/pps/pps0/
146 assert clear echo mode name path subsystem@ uevent 146 assert dev mode path subsystem@
147 clear echo name power/ uevent
148
147 149
148Inside each "assert" and "clear" file you can find the timestamp and a 150Inside each "assert" and "clear" file you can find the timestamp and a
149sequence number: 151sequence number:
@@ -154,32 +156,32 @@ sequence number:
154Where before the "#" is the timestamp in seconds; after it is the 156Where before the "#" is the timestamp in seconds; after it is the
155sequence number. Other files are: 157sequence number. Other files are:
156 158
157* echo: reports if the PPS source has an echo function or not; 159 * echo: reports if the PPS source has an echo function or not;
158 160
159* mode: reports available PPS functioning modes; 161 * mode: reports available PPS functioning modes;
160 162
161* name: reports the PPS source's name; 163 * name: reports the PPS source's name;
162 164
163* path: reports the PPS source's device path, that is the device the 165 * path: reports the PPS source's device path, that is the device the
164 PPS source is connected to (if it exists). 166 PPS source is connected to (if it exists).
165 167
166 168
167Testing the PPS support 169Testing the PPS support
168----------------------- 170-----------------------
169 171
170In order to test the PPS support even without specific hardware you can use 172In order to test the PPS support even without specific hardware you can use
171the ktimer driver (see the client subsection in the PPS configuration menu) 173the pps-ktimer driver (see the client subsection in the PPS configuration menu)
172and the userland tools available in your distribution's pps-tools package, 174and the userland tools available in your distribution's pps-tools package,
173http://linuxpps.org , or https://github.com/ago/pps-tools . 175http://linuxpps.org , or https://github.com/redlab-i/pps-tools.
174 176
175Once you have enabled the compilation of ktimer just modprobe it (if 177Once you have enabled the compilation of pps-ktimer just modprobe it (if
176not statically compiled): 178not statically compiled):
177 179
178 # modprobe ktimer 180 # modprobe pps-ktimer
179 181
180and the run ppstest as follow: 182and the run ppstest as follow:
181 183
182 $ ./ppstest /dev/pps0 184 $ ./ppstest /dev/pps1
183 trying PPS source "/dev/pps1" 185 trying PPS source "/dev/pps1"
184 found PPS source "/dev/pps1" 186 found PPS source "/dev/pps1"
185 ok, found 1 source(s), now start fetching data... 187 ok, found 1 source(s), now start fetching data...
@@ -187,7 +189,7 @@ and the run ppstest as follow:
187 source 0 - assert 1186592700.388931295, sequence: 365 - clear 0.000000000, sequence: 0 189 source 0 - assert 1186592700.388931295, sequence: 365 - clear 0.000000000, sequence: 0
188 source 0 - assert 1186592701.389032765, sequence: 366 - clear 0.000000000, sequence: 0 190 source 0 - assert 1186592701.389032765, sequence: 366 - clear 0.000000000, sequence: 0
189 191
190Please, note that to compile userland programs you need the file timepps.h . 192Please note that to compile userland programs, you need the file timepps.h.
191This is available in the pps-tools repository mentioned above. 193This is available in the pps-tools repository mentioned above.
192 194
193 195
diff --git a/Documentation/rbtree.txt b/Documentation/rbtree.txt
index b8a8c70b0188..c42a21b99046 100644
--- a/Documentation/rbtree.txt
+++ b/Documentation/rbtree.txt
@@ -193,6 +193,39 @@ Example::
193 for (node = rb_first(&mytree); node; node = rb_next(node)) 193 for (node = rb_first(&mytree); node; node = rb_next(node))
194 printk("key=%s\n", rb_entry(node, struct mytype, node)->keystring); 194 printk("key=%s\n", rb_entry(node, struct mytype, node)->keystring);
195 195
196Cached rbtrees
197--------------
198
199Computing the leftmost (smallest) node is quite a common task for binary
200search trees, such as for traversals or users relying on a the particular
201order for their own logic. To this end, users can use 'struct rb_root_cached'
202to optimize O(logN) rb_first() calls to a simple pointer fetch avoiding
203potentially expensive tree iterations. This is done at negligible runtime
204overhead for maintanence; albeit larger memory footprint.
205
206Similar to the rb_root structure, cached rbtrees are initialized to be
207empty via:
208
209 struct rb_root_cached mytree = RB_ROOT_CACHED;
210
211Cached rbtree is simply a regular rb_root with an extra pointer to cache the
212leftmost node. This allows rb_root_cached to exist wherever rb_root does,
213which permits augmented trees to be supported as well as only a few extra
214interfaces:
215
216 struct rb_node *rb_first_cached(struct rb_root_cached *tree);
217 void rb_insert_color_cached(struct rb_node *, struct rb_root_cached *, bool);
218 void rb_erase_cached(struct rb_node *node, struct rb_root_cached *);
219
220Both insert and erase calls have their respective counterpart of augmented
221trees:
222
223 void rb_insert_augmented_cached(struct rb_node *node, struct rb_root_cached *,
224 bool, struct rb_augment_callbacks *);
225 void rb_erase_augmented_cached(struct rb_node *, struct rb_root_cached *,
226 struct rb_augment_callbacks *);
227
228
196Support for Augmented rbtrees 229Support for Augmented rbtrees
197----------------------------- 230-----------------------------
198 231
diff --git a/Documentation/vm/hmm.txt b/Documentation/vm/hmm.txt
new file mode 100644
index 000000000000..4d3aac9f4a5d
--- /dev/null
+++ b/Documentation/vm/hmm.txt
@@ -0,0 +1,384 @@
1Heterogeneous Memory Management (HMM)
2
3Transparently allow any component of a program to use any memory region of said
4program with a device without using device specific memory allocator. This is
5becoming a requirement to simplify the use of advance heterogeneous computing
6where GPU, DSP or FPGA are use to perform various computations.
7
8This document is divided as follow, in the first section i expose the problems
9related to the use of a device specific allocator. The second section i expose
10the hardware limitations that are inherent to many platforms. The third section
11gives an overview of HMM designs. The fourth section explains how CPU page-
12table mirroring works and what is HMM purpose in this context. Fifth section
13deals with how device memory is represented inside the kernel. Finaly the last
14section present the new migration helper that allow to leverage the device DMA
15engine.
16
17
181) Problems of using device specific memory allocator:
192) System bus, device memory characteristics
203) Share address space and migration
214) Address space mirroring implementation and API
225) Represent and manage device memory from core kernel point of view
236) Migrate to and from device memory
247) Memory cgroup (memcg) and rss accounting
25
26
27-------------------------------------------------------------------------------
28
291) Problems of using device specific memory allocator:
30
31Device with large amount of on board memory (several giga bytes) like GPU have
32historically manage their memory through dedicated driver specific API. This
33creates a disconnect between memory allocated and managed by device driver and
34regular application memory (private anonymous, share memory or regular file
35back memory). From here on i will refer to this aspect as split address space.
36I use share address space to refer to the opposite situation ie one in which
37any memory region can be use by device transparently.
38
39Split address space because device can only access memory allocated through the
40device specific API. This imply that all memory object in a program are not
41equal from device point of view which complicate large program that rely on a
42wide set of libraries.
43
44Concretly this means that code that wants to leverage device like GPU need to
45copy object between genericly allocated memory (malloc, mmap private/share/)
46and memory allocated through the device driver API (this still end up with an
47mmap but of the device file).
48
49For flat dataset (array, grid, image, ...) this isn't too hard to achieve but
50complex data-set (list, tree, ...) are hard to get right. Duplicating a complex
51data-set need to re-map all the pointer relations between each of its elements.
52This is error prone and program gets harder to debug because of the duplicate
53data-set.
54
55Split address space also means that library can not transparently use data they
56are getting from core program or other library and thus each library might have
57to duplicate its input data-set using specific memory allocator. Large project
58suffer from this and waste resources because of the various memory copy.
59
60Duplicating each library API to accept as input or output memory allocted by
61each device specific allocator is not a viable option. It would lead to a
62combinatorial explosions in the library entry points.
63
64Finaly with the advance of high level language constructs (in C++ but in other
65language too) it is now possible for compiler to leverage GPU or other devices
66without even the programmer knowledge. Some of compiler identified patterns are
67only do-able with a share address. It is as well more reasonable to use a share
68address space for all the other patterns.
69
70
71-------------------------------------------------------------------------------
72
732) System bus, device memory characteristics
74
75System bus cripple share address due to few limitations. Most system bus only
76allow basic memory access from device to main memory, even cache coherency is
77often optional. Access to device memory from CPU is even more limited, most
78often than not it is not cache coherent.
79
80If we only consider the PCIE bus than device can access main memory (often
81through an IOMMU) and be cache coherent with the CPUs. However it only allows
82a limited set of atomic operation from device on main memory. This is worse
83in the other direction the CPUs can only access a limited range of the device
84memory and can not perform atomic operations on it. Thus device memory can not
85be consider like regular memory from kernel point of view.
86
87Another crippling factor is the limited bandwidth (~32GBytes/s with PCIE 4.0
88and 16 lanes). This is 33 times less that fastest GPU memory (1 TBytes/s).
89The final limitation is latency, access to main memory from the device has an
90order of magnitude higher latency than when the device access its own memory.
91
92Some platform are developing new system bus or additions/modifications to PCIE
93to address some of those limitations (OpenCAPI, CCIX). They mainly allow two
94way cache coherency between CPU and device and allow all atomic operations the
95architecture supports. Saddly not all platform are following this trends and
96some major architecture are left without hardware solutions to those problems.
97
98So for share address space to make sense not only we must allow device to
99access any memory memory but we must also permit any memory to be migrated to
100device memory while device is using it (blocking CPU access while it happens).
101
102
103-------------------------------------------------------------------------------
104
1053) Share address space and migration
106
107HMM intends to provide two main features. First one is to share the address
108space by duplication the CPU page table into the device page table so same
109address point to same memory and this for any valid main memory address in
110the process address space.
111
112To achieve this, HMM offer a set of helpers to populate the device page table
113while keeping track of CPU page table updates. Device page table updates are
114not as easy as CPU page table updates. To update the device page table you must
115allow a buffer (or use a pool of pre-allocated buffer) and write GPU specifics
116commands in it to perform the update (unmap, cache invalidations and flush,
117...). This can not be done through common code for all device. Hence why HMM
118provides helpers to factor out everything that can be while leaving the gory
119details to the device driver.
120
121The second mechanism HMM provide is a new kind of ZONE_DEVICE memory that does
122allow to allocate a struct page for each page of the device memory. Those page
123are special because the CPU can not map them. They however allow to migrate
124main memory to device memory using exhisting migration mechanism and everything
125looks like if page was swap out to disk from CPU point of view. Using a struct
126page gives the easiest and cleanest integration with existing mm mechanisms.
127Again here HMM only provide helpers, first to hotplug new ZONE_DEVICE memory
128for the device memory and second to perform migration. Policy decision of what
129and when to migrate things is left to the device driver.
130
131Note that any CPU access to a device page trigger a page fault and a migration
132back to main memory ie when a page backing an given address A is migrated from
133a main memory page to a device page then any CPU access to address A trigger a
134page fault and initiate a migration back to main memory.
135
136
137With this two features, HMM not only allow a device to mirror a process address
138space and keeps both CPU and device page table synchronize, but also allow to
139leverage device memory by migrating part of data-set that is actively use by a
140device.
141
142
143-------------------------------------------------------------------------------
144
1454) Address space mirroring implementation and API
146
147Address space mirroring main objective is to allow to duplicate range of CPU
148page table into a device page table and HMM helps keeping both synchronize. A
149device driver that want to mirror a process address space must start with the
150registration of an hmm_mirror struct:
151
152 int hmm_mirror_register(struct hmm_mirror *mirror,
153 struct mm_struct *mm);
154 int hmm_mirror_register_locked(struct hmm_mirror *mirror,
155 struct mm_struct *mm);
156
157The locked variant is to be use when the driver is already holding the mmap_sem
158of the mm in write mode. The mirror struct has a set of callback that are use
159to propagate CPU page table:
160
161 struct hmm_mirror_ops {
162 /* sync_cpu_device_pagetables() - synchronize page tables
163 *
164 * @mirror: pointer to struct hmm_mirror
165 * @update_type: type of update that occurred to the CPU page table
166 * @start: virtual start address of the range to update
167 * @end: virtual end address of the range to update
168 *
169 * This callback ultimately originates from mmu_notifiers when the CPU
170 * page table is updated. The device driver must update its page table
171 * in response to this callback. The update argument tells what action
172 * to perform.
173 *
174 * The device driver must not return from this callback until the device
175 * page tables are completely updated (TLBs flushed, etc); this is a
176 * synchronous call.
177 */
178 void (*update)(struct hmm_mirror *mirror,
179 enum hmm_update action,
180 unsigned long start,
181 unsigned long end);
182 };
183
184Device driver must perform update to the range following action (turn range
185read only, or fully unmap, ...). Once driver callback returns the device must
186be done with the update.
187
188
189When device driver wants to populate a range of virtual address it can use
190either:
191 int hmm_vma_get_pfns(struct vm_area_struct *vma,
192 struct hmm_range *range,
193 unsigned long start,
194 unsigned long end,
195 hmm_pfn_t *pfns);
196 int hmm_vma_fault(struct vm_area_struct *vma,
197 struct hmm_range *range,
198 unsigned long start,
199 unsigned long end,
200 hmm_pfn_t *pfns,
201 bool write,
202 bool block);
203
204First one (hmm_vma_get_pfns()) will only fetch present CPU page table entry and
205will not trigger a page fault on missing or non present entry. The second one
206do trigger page fault on missing or read only entry if write parameter is true.
207Page fault use the generic mm page fault code path just like a CPU page fault.
208
209Both function copy CPU page table into their pfns array argument. Each entry in
210that array correspond to an address in the virtual range. HMM provide a set of
211flags to help driver identify special CPU page table entries.
212
213Locking with the update() callback is the most important aspect the driver must
214respect in order to keep things properly synchronize. The usage pattern is :
215
216 int driver_populate_range(...)
217 {
218 struct hmm_range range;
219 ...
220 again:
221 ret = hmm_vma_get_pfns(vma, &range, start, end, pfns);
222 if (ret)
223 return ret;
224 take_lock(driver->update);
225 if (!hmm_vma_range_done(vma, &range)) {
226 release_lock(driver->update);
227 goto again;
228 }
229
230 // Use pfns array content to update device page table
231
232 release_lock(driver->update);
233 return 0;
234 }
235
236The driver->update lock is the same lock that driver takes inside its update()
237callback. That lock must be call before hmm_vma_range_done() to avoid any race
238with a concurrent CPU page table update.
239
240HMM implements all this on top of the mmu_notifier API because we wanted to a
241simpler API and also to be able to perform optimization latter own like doing
242concurrent device update in multi-devices scenario.
243
244HMM also serve as an impedence missmatch between how CPU page table update are
245done (by CPU write to the page table and TLB flushes) from how device update
246their own page table. Device update is a multi-step process, first appropriate
247commands are write to a buffer, then this buffer is schedule for execution on
248the device. It is only once the device has executed commands in the buffer that
249the update is done. Creating and scheduling update command buffer can happen
250concurrently for multiple devices. Waiting for each device to report commands
251as executed is serialize (there is no point in doing this concurrently).
252
253
254-------------------------------------------------------------------------------
255
2565) Represent and manage device memory from core kernel point of view
257
258Several differents design were try to support device memory. First one use
259device specific data structure to keep information about migrated memory and
260HMM hooked itself in various place of mm code to handle any access to address
261that were back by device memory. It turns out that this ended up replicating
262most of the fields of struct page and also needed many kernel code path to be
263updated to understand this new kind of memory.
264
265Thing is most kernel code path never try to access the memory behind a page
266but only care about struct page contents. Because of this HMM switchted to
267directly using struct page for device memory which left most kernel code path
268un-aware of the difference. We only need to make sure that no one ever try to
269map those page from the CPU side.
270
271HMM provide a set of helpers to register and hotplug device memory as a new
272region needing struct page. This is offer through a very simple API:
273
274 struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
275 struct device *device,
276 unsigned long size);
277 void hmm_devmem_remove(struct hmm_devmem *devmem);
278
279The hmm_devmem_ops is where most of the important things are:
280
281 struct hmm_devmem_ops {
282 void (*free)(struct hmm_devmem *devmem, struct page *page);
283 int (*fault)(struct hmm_devmem *devmem,
284 struct vm_area_struct *vma,
285 unsigned long addr,
286 struct page *page,
287 unsigned flags,
288 pmd_t *pmdp);
289 };
290
291The first callback (free()) happens when the last reference on a device page is
292drop. This means the device page is now free and no longer use by anyone. The
293second callback happens whenever CPU try to access a device page which it can
294not do. This second callback must trigger a migration back to system memory.
295
296
297-------------------------------------------------------------------------------
298
2996) Migrate to and from device memory
300
301Because CPU can not access device memory, migration must use device DMA engine
302to perform copy from and to device memory. For this we need a new migration
303helper:
304
305 int migrate_vma(const struct migrate_vma_ops *ops,
306 struct vm_area_struct *vma,
307 unsigned long mentries,
308 unsigned long start,
309 unsigned long end,
310 unsigned long *src,
311 unsigned long *dst,
312 void *private);
313
314Unlike other migration function it works on a range of virtual address, there
315is two reasons for that. First device DMA copy has a high setup overhead cost
316and thus batching multiple pages is needed as otherwise the migration overhead
317make the whole excersie pointless. The second reason is because driver trigger
318such migration base on range of address the device is actively accessing.
319
320The migrate_vma_ops struct define two callbacks. First one (alloc_and_copy())
321control destination memory allocation and copy operation. Second one is there
322to allow device driver to perform cleanup operation after migration.
323
324 struct migrate_vma_ops {
325 void (*alloc_and_copy)(struct vm_area_struct *vma,
326 const unsigned long *src,
327 unsigned long *dst,
328 unsigned long start,
329 unsigned long end,
330 void *private);
331 void (*finalize_and_map)(struct vm_area_struct *vma,
332 const unsigned long *src,
333 const unsigned long *dst,
334 unsigned long start,
335 unsigned long end,
336 void *private);
337 };
338
339It is important to stress that this migration helpers allow for hole in the
340virtual address range. Some pages in the range might not be migrated for all
341the usual reasons (page is pin, page is lock, ...). This helper does not fail
342but just skip over those pages.
343
344The alloc_and_copy() might as well decide to not migrate all pages in the
345range (for reasons under the callback control). For those the callback just
346have to leave the corresponding dst entry empty.
347
348Finaly the migration of the struct page might fails (for file back page) for
349various reasons (failure to freeze reference, or update page cache, ...). If
350that happens then the finalize_and_map() can catch any pages that was not
351migrated. Note those page were still copied to new page and thus we wasted
352bandwidth but this is considered as a rare event and a price that we are
353willing to pay to keep all the code simpler.
354
355
356-------------------------------------------------------------------------------
357
3587) Memory cgroup (memcg) and rss accounting
359
360For now device memory is accounted as any regular page in rss counters (either
361anonymous if device page is use for anonymous, file if device page is use for
362file back page or shmem if device page is use for share memory). This is a
363deliberate choice to keep existing application that might start using device
364memory without knowing about it to keep runing unimpacted.
365
366Drawbacks is that OOM killer might kill an application using a lot of device
367memory and not a lot of regular system memory and thus not freeing much system
368memory. We want to gather more real world experience on how application and
369system react under memory pressure in the presence of device memory before
370deciding to account device memory differently.
371
372
373Same decision was made for memory cgroup. Device memory page are accounted
374against same memory cgroup a regular page would be accounted to. This does
375simplify migration to and from device memory. This also means that migration
376back from device memory to regular memory can not fail because it would
377go above memory cgroup limit. We might revisit this choice latter on once we
378get more experience in how device memory is use and its impact on memory
379resource control.
380
381
382Note that device memory can never be pin nor by device driver nor through GUP
383and thus such memory is always free upon process exit. Or when last reference
384is drop in case of share memory or file back memory.
diff --git a/MAINTAINERS b/MAINTAINERS
index fe7a27ed0bdb..7f32b510fdea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7457,6 +7457,13 @@ S: Maintained
7457F: tools/testing/selftests/ 7457F: tools/testing/selftests/
7458F: Documentation/dev-tools/kselftest* 7458F: Documentation/dev-tools/kselftest*
7459 7459
7460KERNEL USERMODE HELPER
7461M: "Luis R. Rodriguez" <mcgrof@kernel.org>
7462L: linux-kernel@vger.kernel.org
7463S: Maintained
7464F: kernel/umh.c
7465F: include/linux/umh.h
7466
7460KERNEL VIRTUAL MACHINE (KVM) 7467KERNEL VIRTUAL MACHINE (KVM)
7461M: Paolo Bonzini <pbonzini@redhat.com> 7468M: Paolo Bonzini <pbonzini@redhat.com>
7462M: Radim Krčmář <rkrcmar@redhat.com> 7469M: Radim Krčmář <rkrcmar@redhat.com>
@@ -7632,7 +7639,7 @@ F: include/linux/kmemleak.h
7632F: mm/kmemleak.c 7639F: mm/kmemleak.c
7633F: mm/kmemleak-test.c 7640F: mm/kmemleak-test.c
7634 7641
7635KMOD MODULE USERMODE HELPER 7642KMOD KERNEL MODULE LOADER - USERMODE HELPER
7636M: "Luis R. Rodriguez" <mcgrof@kernel.org> 7643M: "Luis R. Rodriguez" <mcgrof@kernel.org>
7637L: linux-kernel@vger.kernel.org 7644L: linux-kernel@vger.kernel.org
7638S: Maintained 7645S: Maintained
@@ -7790,6 +7797,13 @@ M: Sasha Levin <alexander.levin@verizon.com>
7790S: Maintained 7797S: Maintained
7791F: tools/lib/lockdep/ 7798F: tools/lib/lockdep/
7792 7799
7800HMM - Heterogeneous Memory Management
7801M: Jérôme Glisse <jglisse@redhat.com>
7802L: linux-mm@kvack.org
7803S: Maintained
7804F: mm/hmm*
7805F: include/linux/hmm*
7806
7793LIBNVDIMM BLK: MMIO-APERTURE DRIVER 7807LIBNVDIMM BLK: MMIO-APERTURE DRIVER
7794M: Ross Zwisler <ross.zwisler@linux.intel.com> 7808M: Ross Zwisler <ross.zwisler@linux.intel.com>
7795L: linux-nvdimm@lists.01.org 7809L: linux-nvdimm@lists.01.org
@@ -10727,8 +10741,11 @@ W: http://wiki.enneenne.com/index.php/LinuxPPS_support
10727L: linuxpps@ml.enneenne.com (subscribers-only) 10741L: linuxpps@ml.enneenne.com (subscribers-only)
10728S: Maintained 10742S: Maintained
10729F: Documentation/pps/ 10743F: Documentation/pps/
10744F: Documentation/devicetree/bindings/pps/pps-gpio.txt
10745F: Documentation/ABI/testing/sysfs-pps
10730F: drivers/pps/ 10746F: drivers/pps/
10731F: include/linux/pps*.h 10747F: include/linux/pps*.h
10748F: include/uapi/linux/pps.h
10732 10749
10733PPTP DRIVER 10750PPTP DRIVER
10734M: Dmitry Kozlov <xeb@mail.ru> 10751M: Dmitry Kozlov <xeb@mail.ru>
diff --git a/arch/alpha/include/asm/string.h b/arch/alpha/include/asm/string.h
index c2911f591704..9eb9933d845f 100644
--- a/arch/alpha/include/asm/string.h
+++ b/arch/alpha/include/asm/string.h
@@ -65,13 +65,14 @@ extern void * memchr(const void *, int, size_t);
65 aligned values. The DEST and COUNT parameters must be even for 65 aligned values. The DEST and COUNT parameters must be even for
66 correct operation. */ 66 correct operation. */
67 67
68#define __HAVE_ARCH_MEMSETW 68#define __HAVE_ARCH_MEMSET16
69extern void * __memsetw(void *dest, unsigned short, size_t count); 69extern void * __memset16(void *dest, unsigned short, size_t count);
70 70static inline void *memset16(uint16_t *p, uint16_t v, size_t n)
71#define memsetw(s, c, n) \ 71{
72(__builtin_constant_p(c) \ 72 if (__builtin_constant_p(v))
73 ? __constant_c_memset((s),0x0001000100010001UL*(unsigned short)(c),(n)) \ 73 return __constant_c_memset(p, 0x0001000100010001UL * v, n * 2);
74 : __memsetw((s),(c),(n))) 74 return __memset16(p, v, n * 2);
75}
75 76
76#endif /* __KERNEL__ */ 77#endif /* __KERNEL__ */
77 78
diff --git a/arch/alpha/include/asm/vga.h b/arch/alpha/include/asm/vga.h
index c00106bac521..3c1c2b6128e7 100644
--- a/arch/alpha/include/asm/vga.h
+++ b/arch/alpha/include/asm/vga.h
@@ -34,7 +34,7 @@ static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
34 if (__is_ioaddr(s)) 34 if (__is_ioaddr(s))
35 memsetw_io((u16 __iomem *) s, c, count); 35 memsetw_io((u16 __iomem *) s, c, count);
36 else 36 else
37 memsetw(s, c, count); 37 memset16(s, c, count / 2);
38} 38}
39 39
40/* Do not trust that the usage will be correct; analyze the arguments. */ 40/* Do not trust that the usage will be correct; analyze the arguments. */
diff --git a/arch/alpha/lib/memset.S b/arch/alpha/lib/memset.S
index 89a26f5e89de..f824969e9e77 100644
--- a/arch/alpha/lib/memset.S
+++ b/arch/alpha/lib/memset.S
@@ -20,7 +20,7 @@
20 .globl memset 20 .globl memset
21 .globl __memset 21 .globl __memset
22 .globl ___memset 22 .globl ___memset
23 .globl __memsetw 23 .globl __memset16
24 .globl __constant_c_memset 24 .globl __constant_c_memset
25 25
26 .ent ___memset 26 .ent ___memset
@@ -110,8 +110,8 @@ EXPORT_SYMBOL(___memset)
110EXPORT_SYMBOL(__constant_c_memset) 110EXPORT_SYMBOL(__constant_c_memset)
111 111
112 .align 5 112 .align 5
113 .ent __memsetw 113 .ent __memset16
114__memsetw: 114__memset16:
115 .prologue 0 115 .prologue 0
116 116
117 inswl $17,0,$1 /* E0 */ 117 inswl $17,0,$1 /* E0 */
@@ -123,8 +123,8 @@ __memsetw:
123 or $1,$4,$17 /* E0 */ 123 or $1,$4,$17 /* E0 */
124 br __constant_c_memset /* .. E1 */ 124 br __constant_c_memset /* .. E1 */
125 125
126 .end __memsetw 126 .end __memset16
127EXPORT_SYMBOL(__memsetw) 127EXPORT_SYMBOL(__memset16)
128 128
129memset = ___memset 129memset = ___memset
130__memset = ___memset 130__memset = ___memset
diff --git a/arch/arm/include/asm/string.h b/arch/arm/include/asm/string.h
index cf4f3aad0fc1..fe1c6af3a1b1 100644
--- a/arch/arm/include/asm/string.h
+++ b/arch/arm/include/asm/string.h
@@ -24,6 +24,20 @@ extern void * memchr(const void *, int, __kernel_size_t);
24#define __HAVE_ARCH_MEMSET 24#define __HAVE_ARCH_MEMSET
25extern void * memset(void *, int, __kernel_size_t); 25extern void * memset(void *, int, __kernel_size_t);
26 26
27#define __HAVE_ARCH_MEMSET32
28extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
29static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
30{
31 return __memset32(p, v, n * 4);
32}
33
34#define __HAVE_ARCH_MEMSET64
35extern void *__memset64(uint64_t *, uint32_t low, __kernel_size_t, uint32_t hi);
36static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
37{
38 return __memset64(p, v, n * 8, v >> 32);
39}
40
27extern void __memzero(void *ptr, __kernel_size_t n); 41extern void __memzero(void *ptr, __kernel_size_t n);
28 42
29#define memset(p,v,n) \ 43#define memset(p,v,n) \
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index 8e8d20cdbce7..5266fd9ad6b4 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -87,6 +87,8 @@ EXPORT_SYMBOL(__raw_writesl);
87EXPORT_SYMBOL(strchr); 87EXPORT_SYMBOL(strchr);
88EXPORT_SYMBOL(strrchr); 88EXPORT_SYMBOL(strrchr);
89EXPORT_SYMBOL(memset); 89EXPORT_SYMBOL(memset);
90EXPORT_SYMBOL(__memset32);
91EXPORT_SYMBOL(__memset64);
90EXPORT_SYMBOL(memcpy); 92EXPORT_SYMBOL(memcpy);
91EXPORT_SYMBOL(memmove); 93EXPORT_SYMBOL(memmove);
92EXPORT_SYMBOL(memchr); 94EXPORT_SYMBOL(memchr);
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 3c65e3bd790f..ed6d35d9cdb5 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -28,7 +28,7 @@ UNWIND( .fnstart )
281: orr r1, r1, r1, lsl #8 281: orr r1, r1, r1, lsl #8
29 orr r1, r1, r1, lsl #16 29 orr r1, r1, r1, lsl #16
30 mov r3, r1 30 mov r3, r1
31 cmp r2, #16 317: cmp r2, #16
32 blt 4f 32 blt 4f
33 33
34#if ! CALGN(1)+0 34#if ! CALGN(1)+0
@@ -41,7 +41,7 @@ UNWIND( .fnend )
41UNWIND( .fnstart ) 41UNWIND( .fnstart )
42UNWIND( .save {r8, lr} ) 42UNWIND( .save {r8, lr} )
43 mov r8, r1 43 mov r8, r1
44 mov lr, r1 44 mov lr, r3
45 45
462: subs r2, r2, #64 462: subs r2, r2, #64
47 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time. 47 stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
@@ -73,11 +73,11 @@ UNWIND( .fnend )
73UNWIND( .fnstart ) 73UNWIND( .fnstart )
74UNWIND( .save {r4-r8, lr} ) 74UNWIND( .save {r4-r8, lr} )
75 mov r4, r1 75 mov r4, r1
76 mov r5, r1 76 mov r5, r3
77 mov r6, r1 77 mov r6, r1
78 mov r7, r1 78 mov r7, r3
79 mov r8, r1 79 mov r8, r1
80 mov lr, r1 80 mov lr, r3
81 81
82 cmp r2, #96 82 cmp r2, #96
83 tstgt ip, #31 83 tstgt ip, #31
@@ -114,7 +114,7 @@ UNWIND( .fnstart )
114 tst r2, #4 114 tst r2, #4
115 strne r1, [ip], #4 115 strne r1, [ip], #4
116/* 116/*
117 * When we get here, we've got less than 4 bytes to zero. We 117 * When we get here, we've got less than 4 bytes to set. We
118 * may have an unaligned pointer as well. 118 * may have an unaligned pointer as well.
119 */ 119 */
1205: tst r2, #2 1205: tst r2, #2
@@ -135,3 +135,15 @@ UNWIND( .fnstart )
135UNWIND( .fnend ) 135UNWIND( .fnend )
136ENDPROC(memset) 136ENDPROC(memset)
137ENDPROC(mmioset) 137ENDPROC(mmioset)
138
139ENTRY(__memset32)
140UNWIND( .fnstart )
141 mov r3, r1 @ copy r1 to r3 and fall into memset64
142UNWIND( .fnend )
143ENDPROC(__memset32)
144ENTRY(__memset64)
145UNWIND( .fnstart )
146 mov ip, r0 @ preserve r0 as return value
147 b 7b @ jump into the middle of memset
148UNWIND( .fnend )
149ENDPROC(__memset64)
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index ffe089942ac4..9f7195a5773e 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -690,7 +690,7 @@ void __init smp_init_cpus(void)
690 acpi_parse_gic_cpu_interface, 0); 690 acpi_parse_gic_cpu_interface, 0);
691 691
692 if (cpu_count > nr_cpu_ids) 692 if (cpu_count > nr_cpu_ids)
693 pr_warn("Number of cores (%d) exceeds configured maximum of %d - clipping\n", 693 pr_warn("Number of cores (%d) exceeds configured maximum of %u - clipping\n",
694 cpu_count, nr_cpu_ids); 694 cpu_count, nr_cpu_ids);
695 695
696 if (!bootcpu_valid) { 696 if (!bootcpu_valid) {
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index eefd9a4ed156..1cce8243449e 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -17,6 +17,9 @@ config FRV
17 select HAVE_DEBUG_STACKOVERFLOW 17 select HAVE_DEBUG_STACKOVERFLOW
18 select ARCH_NO_COHERENT_DMA_MMAP 18 select ARCH_NO_COHERENT_DMA_MMAP
19 19
20config CPU_BIG_ENDIAN
21 def_bool y
22
20config ZONE_DMA 23config ZONE_DMA
21 bool 24 bool
22 default y 25 default y
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 6e3d36f37a02..3089f7fe2abd 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -23,6 +23,9 @@ config H8300
23 select HAVE_ARCH_HASH 23 select HAVE_ARCH_HASH
24 select CPU_NO_EFFICIENT_FFS 24 select CPU_NO_EFFICIENT_FFS
25 25
26config CPU_BIG_ENDIAN
27 def_bool y
28
26config RWSEM_GENERIC_SPINLOCK 29config RWSEM_GENERIC_SPINLOCK
27 def_bool y 30 def_bool y
28 31
diff --git a/arch/m32r/configs/m32104ut_defconfig b/arch/m32r/configs/m32104ut_defconfig
index be30e094db71..4aa42acbd512 100644
--- a/arch/m32r/configs/m32104ut_defconfig
+++ b/arch/m32r/configs/m32104ut_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -40,7 +39,6 @@ CONFIG_NETFILTER_XT_MATCH_REALM=m
40CONFIG_NETFILTER_XT_MATCH_SCTP=m 39CONFIG_NETFILTER_XT_MATCH_SCTP=m
41CONFIG_NETFILTER_XT_MATCH_STRING=m 40CONFIG_NETFILTER_XT_MATCH_STRING=m
42CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 41CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
43CONFIG_IP_NF_QUEUE=m
44CONFIG_IP_NF_IPTABLES=m 42CONFIG_IP_NF_IPTABLES=m
45CONFIG_IP_NF_MATCH_ADDRTYPE=m 43CONFIG_IP_NF_MATCH_ADDRTYPE=m
46CONFIG_IP_NF_MATCH_ECN=m 44CONFIG_IP_NF_MATCH_ECN=m
@@ -48,7 +46,6 @@ CONFIG_IP_NF_MATCH_TTL=m
48CONFIG_IP_NF_FILTER=m 46CONFIG_IP_NF_FILTER=m
49CONFIG_IP_NF_TARGET_REJECT=m 47CONFIG_IP_NF_TARGET_REJECT=m
50CONFIG_IP_NF_TARGET_LOG=m 48CONFIG_IP_NF_TARGET_LOG=m
51CONFIG_IP_NF_TARGET_ULOG=m
52CONFIG_IP_NF_MANGLE=m 49CONFIG_IP_NF_MANGLE=m
53CONFIG_IP_NF_TARGET_ECN=m 50CONFIG_IP_NF_TARGET_ECN=m
54CONFIG_IP_NF_TARGET_TTL=m 51CONFIG_IP_NF_TARGET_TTL=m
@@ -106,7 +103,6 @@ CONFIG_SENSORS_SMSC47M1=m
106CONFIG_SENSORS_W83781D=m 103CONFIG_SENSORS_W83781D=m
107CONFIG_SENSORS_W83L785TS=m 104CONFIG_SENSORS_W83L785TS=m
108CONFIG_SENSORS_W83627HF=m 105CONFIG_SENSORS_W83627HF=m
109CONFIG_VIDEO_OUTPUT_CONTROL=m
110CONFIG_EXT2_FS=y 106CONFIG_EXT2_FS=y
111CONFIG_EXT2_FS_XATTR=y 107CONFIG_EXT2_FS_XATTR=y
112CONFIG_EXT2_FS_POSIX_ACL=y 108CONFIG_EXT2_FS_POSIX_ACL=y
diff --git a/arch/m32r/configs/m32700ut.smp_defconfig b/arch/m32r/configs/m32700ut.smp_defconfig
index a3d727ed6a16..41a0495b65df 100644
--- a/arch/m32r/configs/m32700ut.smp_defconfig
+++ b/arch/m32r/configs/m32700ut.smp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -30,7 +29,6 @@ CONFIG_IP_PNP=y
30CONFIG_IP_PNP_DHCP=y 29CONFIG_IP_PNP_DHCP=y
31# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
32CONFIG_MTD=y 31CONFIG_MTD=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_REDBOOT_PARTS=y 32CONFIG_MTD_REDBOOT_PARTS=y
35CONFIG_MTD_BLOCK=y 33CONFIG_MTD_BLOCK=y
36CONFIG_MTD_CFI=m 34CONFIG_MTD_CFI=m
@@ -63,7 +61,6 @@ CONFIG_SERIAL_M32R_SIO_CONSOLE=y
63CONFIG_SERIAL_M32R_PLDSIO=y 61CONFIG_SERIAL_M32R_PLDSIO=y
64CONFIG_HW_RANDOM=y 62CONFIG_HW_RANDOM=y
65CONFIG_DS1302=y 63CONFIG_DS1302=y
66CONFIG_VIDEO_OUTPUT_CONTROL=m
67CONFIG_FB=y 64CONFIG_FB=y
68CONFIG_FIRMWARE_EDID=y 65CONFIG_FIRMWARE_EDID=y
69CONFIG_FB_S1D13XXX=y 66CONFIG_FB_S1D13XXX=y
diff --git a/arch/m32r/configs/m32700ut.up_defconfig b/arch/m32r/configs/m32700ut.up_defconfig
index b8334163099d..20078a866f45 100644
--- a/arch/m32r/configs/m32700ut.up_defconfig
+++ b/arch/m32r/configs/m32700ut.up_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -29,7 +28,6 @@ CONFIG_IP_PNP=y
29CONFIG_IP_PNP_DHCP=y 28CONFIG_IP_PNP_DHCP=y
30# CONFIG_IPV6 is not set 29# CONFIG_IPV6 is not set
31CONFIG_MTD=y 30CONFIG_MTD=y
32CONFIG_MTD_PARTITIONS=y
33CONFIG_MTD_REDBOOT_PARTS=y 31CONFIG_MTD_REDBOOT_PARTS=y
34CONFIG_MTD_BLOCK=y 32CONFIG_MTD_BLOCK=y
35CONFIG_MTD_CFI=m 33CONFIG_MTD_CFI=m
@@ -62,7 +60,6 @@ CONFIG_SERIAL_M32R_SIO_CONSOLE=y
62CONFIG_SERIAL_M32R_PLDSIO=y 60CONFIG_SERIAL_M32R_PLDSIO=y
63CONFIG_HW_RANDOM=y 61CONFIG_HW_RANDOM=y
64CONFIG_DS1302=y 62CONFIG_DS1302=y
65CONFIG_VIDEO_OUTPUT_CONTROL=m
66CONFIG_FB=y 63CONFIG_FB=y
67CONFIG_FIRMWARE_EDID=y 64CONFIG_FIRMWARE_EDID=y
68CONFIG_FB_S1D13XXX=y 65CONFIG_FB_S1D13XXX=y
diff --git a/arch/m32r/configs/mappi.nommu_defconfig b/arch/m32r/configs/mappi.nommu_defconfig
index 7c90ce2fc42b..4bf3820e054a 100644
--- a/arch/m32r/configs/mappi.nommu_defconfig
+++ b/arch/m32r/configs/mappi.nommu_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_BSD_PROCESS_ACCT=y 1CONFIG_BSD_PROCESS_ACCT=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
@@ -39,7 +38,6 @@ CONFIG_NETDEVICES=y
39# CONFIG_VT is not set 38# CONFIG_VT is not set
40CONFIG_SERIAL_M32R_SIO_CONSOLE=y 39CONFIG_SERIAL_M32R_SIO_CONSOLE=y
41CONFIG_HW_RANDOM=y 40CONFIG_HW_RANDOM=y
42CONFIG_VIDEO_OUTPUT_CONTROL=m
43CONFIG_EXT2_FS=y 41CONFIG_EXT2_FS=y
44CONFIG_EXT3_FS=y 42CONFIG_EXT3_FS=y
45CONFIG_NFS_FS=y 43CONFIG_NFS_FS=y
diff --git a/arch/m32r/configs/mappi.smp_defconfig b/arch/m32r/configs/mappi.smp_defconfig
index 367d07cebcd3..f9ed7bdbf4de 100644
--- a/arch/m32r/configs/mappi.smp_defconfig
+++ b/arch/m32r/configs/mappi.smp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -31,9 +30,7 @@ CONFIG_IP_PNP_DHCP=y
31# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
32# CONFIG_STANDALONE is not set 31# CONFIG_STANDALONE is not set
33CONFIG_MTD=y 32CONFIG_MTD=y
34CONFIG_MTD_PARTITIONS=y
35CONFIG_MTD_REDBOOT_PARTS=y 33CONFIG_MTD_REDBOOT_PARTS=y
36CONFIG_MTD_CHAR=y
37CONFIG_MTD_BLOCK=y 34CONFIG_MTD_BLOCK=y
38CONFIG_BLK_DEV_LOOP=y 35CONFIG_BLK_DEV_LOOP=y
39CONFIG_BLK_DEV_NBD=m 36CONFIG_BLK_DEV_NBD=m
@@ -50,7 +47,6 @@ CONFIG_NETDEVICES=y
50# CONFIG_VT is not set 47# CONFIG_VT is not set
51CONFIG_SERIAL_M32R_SIO_CONSOLE=y 48CONFIG_SERIAL_M32R_SIO_CONSOLE=y
52CONFIG_HW_RANDOM=y 49CONFIG_HW_RANDOM=y
53CONFIG_VIDEO_OUTPUT_CONTROL=m
54CONFIG_EXT2_FS=y 50CONFIG_EXT2_FS=y
55CONFIG_EXT3_FS=y 51CONFIG_EXT3_FS=y
56CONFIG_ISO9660_FS=y 52CONFIG_ISO9660_FS=y
diff --git a/arch/m32r/configs/mappi.up_defconfig b/arch/m32r/configs/mappi.up_defconfig
index cb11384386ce..289ae7421e12 100644
--- a/arch/m32r/configs/mappi.up_defconfig
+++ b/arch/m32r/configs/mappi.up_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -29,9 +28,7 @@ CONFIG_IP_PNP_DHCP=y
29# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
30# CONFIG_STANDALONE is not set 29# CONFIG_STANDALONE is not set
31CONFIG_MTD=y 30CONFIG_MTD=y
32CONFIG_MTD_PARTITIONS=y
33CONFIG_MTD_REDBOOT_PARTS=y 31CONFIG_MTD_REDBOOT_PARTS=y
34CONFIG_MTD_CHAR=y
35CONFIG_MTD_BLOCK=y 32CONFIG_MTD_BLOCK=y
36CONFIG_BLK_DEV_LOOP=y 33CONFIG_BLK_DEV_LOOP=y
37CONFIG_BLK_DEV_NBD=m 34CONFIG_BLK_DEV_NBD=m
@@ -48,7 +45,6 @@ CONFIG_NETDEVICES=y
48# CONFIG_VT is not set 45# CONFIG_VT is not set
49CONFIG_SERIAL_M32R_SIO_CONSOLE=y 46CONFIG_SERIAL_M32R_SIO_CONSOLE=y
50CONFIG_HW_RANDOM=y 47CONFIG_HW_RANDOM=y
51CONFIG_VIDEO_OUTPUT_CONTROL=m
52CONFIG_EXT2_FS=y 48CONFIG_EXT2_FS=y
53CONFIG_EXT3_FS=y 49CONFIG_EXT3_FS=y
54CONFIG_ISO9660_FS=y 50CONFIG_ISO9660_FS=y
diff --git a/arch/m32r/configs/mappi2.opsp_defconfig b/arch/m32r/configs/mappi2.opsp_defconfig
index 3bff779259b4..2852f6e7e246 100644
--- a/arch/m32r/configs/mappi2.opsp_defconfig
+++ b/arch/m32r/configs/mappi2.opsp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -50,7 +49,6 @@ CONFIG_SMC91X=y
50# CONFIG_SERIO_I8042 is not set 49# CONFIG_SERIO_I8042 is not set
51CONFIG_SERIAL_M32R_SIO_CONSOLE=y 50CONFIG_SERIAL_M32R_SIO_CONSOLE=y
52CONFIG_HW_RANDOM=y 51CONFIG_HW_RANDOM=y
53CONFIG_VIDEO_OUTPUT_CONTROL=m
54# CONFIG_VGA_CONSOLE is not set 52# CONFIG_VGA_CONSOLE is not set
55CONFIG_EXT2_FS=y 53CONFIG_EXT2_FS=y
56CONFIG_EXT3_FS=y 54CONFIG_EXT3_FS=y
diff --git a/arch/m32r/configs/mappi2.vdec2_defconfig b/arch/m32r/configs/mappi2.vdec2_defconfig
index 75246c9c1af8..8da4dbad8510 100644
--- a/arch/m32r/configs/mappi2.vdec2_defconfig
+++ b/arch/m32r/configs/mappi2.vdec2_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -49,7 +48,6 @@ CONFIG_SMC91X=y
49# CONFIG_SERIO_I8042 is not set 48# CONFIG_SERIO_I8042 is not set
50CONFIG_SERIAL_M32R_SIO_CONSOLE=y 49CONFIG_SERIAL_M32R_SIO_CONSOLE=y
51CONFIG_HW_RANDOM=y 50CONFIG_HW_RANDOM=y
52CONFIG_VIDEO_OUTPUT_CONTROL=m
53# CONFIG_VGA_CONSOLE is not set 51# CONFIG_VGA_CONSOLE is not set
54CONFIG_EXT2_FS=y 52CONFIG_EXT2_FS=y
55CONFIG_EXT3_FS=y 53CONFIG_EXT3_FS=y
diff --git a/arch/m32r/configs/mappi3.smp_defconfig b/arch/m32r/configs/mappi3.smp_defconfig
index 27cefd41ac1f..5605b23e2faf 100644
--- a/arch/m32r/configs/mappi3.smp_defconfig
+++ b/arch/m32r/configs/mappi3.smp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -29,9 +28,7 @@ CONFIG_IP_PNP=y
29CONFIG_IP_PNP_DHCP=y 28CONFIG_IP_PNP_DHCP=y
30# CONFIG_IPV6 is not set 29# CONFIG_IPV6 is not set
31CONFIG_MTD=y 30CONFIG_MTD=y
32CONFIG_MTD_PARTITIONS=y
33CONFIG_MTD_REDBOOT_PARTS=y 31CONFIG_MTD_REDBOOT_PARTS=y
34CONFIG_MTD_CHAR=y
35CONFIG_MTD_BLOCK=y 32CONFIG_MTD_BLOCK=y
36CONFIG_BLK_DEV_LOOP=y 33CONFIG_BLK_DEV_LOOP=y
37CONFIG_BLK_DEV_NBD=m 34CONFIG_BLK_DEV_NBD=m
@@ -50,7 +47,6 @@ CONFIG_SMC91X=y
50# CONFIG_VT is not set 47# CONFIG_VT is not set
51CONFIG_SERIAL_M32R_SIO_CONSOLE=y 48CONFIG_SERIAL_M32R_SIO_CONSOLE=y
52CONFIG_HW_RANDOM=y 49CONFIG_HW_RANDOM=y
53CONFIG_VIDEO_OUTPUT_CONTROL=m
54CONFIG_EXT2_FS=y 50CONFIG_EXT2_FS=y
55CONFIG_EXT3_FS=y 51CONFIG_EXT3_FS=y
56CONFIG_ISO9660_FS=y 52CONFIG_ISO9660_FS=y
diff --git a/arch/m32r/configs/oaks32r_defconfig b/arch/m32r/configs/oaks32r_defconfig
index 5087a510ca4f..5ccab127f6ad 100644
--- a/arch/m32r/configs/oaks32r_defconfig
+++ b/arch/m32r/configs/oaks32r_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_BSD_PROCESS_ACCT=y 1CONFIG_BSD_PROCESS_ACCT=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 3# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -37,7 +36,6 @@ CONFIG_NETDEVICES=y
37# CONFIG_VT is not set 36# CONFIG_VT is not set
38CONFIG_SERIAL_M32R_SIO_CONSOLE=y 37CONFIG_SERIAL_M32R_SIO_CONSOLE=y
39CONFIG_HW_RANDOM=y 38CONFIG_HW_RANDOM=y
40CONFIG_VIDEO_OUTPUT_CONTROL=m
41CONFIG_EXT2_FS=y 39CONFIG_EXT2_FS=y
42CONFIG_NFS_FS=y 40CONFIG_NFS_FS=y
43CONFIG_NFS_V3=y 41CONFIG_NFS_V3=y
diff --git a/arch/m32r/configs/opsput_defconfig b/arch/m32r/configs/opsput_defconfig
index 50c6f525db20..3ce1d08355e5 100644
--- a/arch/m32r/configs/opsput_defconfig
+++ b/arch/m32r/configs/opsput_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -46,7 +45,6 @@ CONFIG_SERIAL_M32R_SIO_CONSOLE=y
46CONFIG_SERIAL_M32R_PLDSIO=y 45CONFIG_SERIAL_M32R_PLDSIO=y
47CONFIG_HW_RANDOM=y 46CONFIG_HW_RANDOM=y
48CONFIG_DS1302=y 47CONFIG_DS1302=y
49CONFIG_VIDEO_OUTPUT_CONTROL=m
50CONFIG_EXT2_FS=y 48CONFIG_EXT2_FS=y
51CONFIG_EXT3_FS=y 49CONFIG_EXT3_FS=y
52CONFIG_ISO9660_FS=m 50CONFIG_ISO9660_FS=m
diff --git a/arch/m32r/configs/usrv_defconfig b/arch/m32r/configs/usrv_defconfig
index a3cfaaedab60..cb8c051c3d46 100644
--- a/arch/m32r/configs/usrv_defconfig
+++ b/arch/m32r/configs/usrv_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -34,9 +33,6 @@ CONFIG_INET_ESP=y
34CONFIG_INET_IPCOMP=y 33CONFIG_INET_IPCOMP=y
35# CONFIG_IPV6 is not set 34# CONFIG_IPV6 is not set
36CONFIG_MTD=y 35CONFIG_MTD=y
37CONFIG_MTD_CONCAT=y
38CONFIG_MTD_PARTITIONS=y
39CONFIG_MTD_CHAR=y
40CONFIG_MTD_BLOCK=y 36CONFIG_MTD_BLOCK=y
41CONFIG_MTD_CFI=y 37CONFIG_MTD_CFI=y
42CONFIG_MTD_CFI_ADV_OPTIONS=y 38CONFIG_MTD_CFI_ADV_OPTIONS=y
@@ -62,7 +58,6 @@ CONFIG_SERIAL_8250=y
62CONFIG_SERIAL_8250_CONSOLE=y 58CONFIG_SERIAL_8250_CONSOLE=y
63# CONFIG_SERIAL_M32R_SIO is not set 59# CONFIG_SERIAL_M32R_SIO is not set
64# CONFIG_HWMON is not set 60# CONFIG_HWMON is not set
65CONFIG_VIDEO_OUTPUT_CONTROL=m
66CONFIG_EXT2_FS=y 61CONFIG_EXT2_FS=y
67CONFIG_EXT3_FS=y 62CONFIG_EXT3_FS=y
68# CONFIG_EXT3_FS_XATTR is not set 63# CONFIG_EXT3_FS_XATTR is not set
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 5abb548f0e70..353d90487c2b 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -24,6 +24,9 @@ config M68K
24 select OLD_SIGSUSPEND3 24 select OLD_SIGSUSPEND3
25 select OLD_SIGACTION 25 select OLD_SIGACTION
26 26
27config CPU_BIG_ENDIAN
28 def_bool y
29
27config RWSEM_GENERIC_SPINLOCK 30config RWSEM_GENERIC_SPINLOCK
28 bool 31 bool
29 default y 32 default y
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 4ed8ebf33509..9d26abdf0dc1 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -36,6 +36,22 @@ config MICROBLAZE
36 select VIRT_TO_BUS 36 select VIRT_TO_BUS
37 select CPU_NO_EFFICIENT_FFS 37 select CPU_NO_EFFICIENT_FFS
38 38
39# Endianness selection
40choice
41 prompt "Endianness selection"
42 default CPU_BIG_ENDIAN
43 help
44 microblaze architectures can be configured for either little or
45 big endian formats. Be sure to select the appropriate mode.
46
47config CPU_BIG_ENDIAN
48 bool "Big endian"
49
50config CPU_LITTLE_ENDIAN
51 bool "Little endian"
52
53endchoice
54
39config SWAP 55config SWAP
40 def_bool n 56 def_bool n
41 57
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index 740f2b82a182..1f6c486826a0 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -35,6 +35,8 @@ endif
35CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div 35CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
36CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift 36CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
37CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare 37CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
38CPUFLAGS-$(CONFIG_BIG_ENDIAN) += -mbig-endian
39CPUFLAGS-$(CONFIG_LITTLE_ENDIAN) += -mlittle-endian
38 40
39CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 41CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
40 42
diff --git a/arch/mips/include/asm/vga.h b/arch/mips/include/asm/vga.h
index f82c83749a08..975ff51f80c4 100644
--- a/arch/mips/include/asm/vga.h
+++ b/arch/mips/include/asm/vga.h
@@ -6,6 +6,7 @@
6#ifndef _ASM_VGA_H 6#ifndef _ASM_VGA_H
7#define _ASM_VGA_H 7#define _ASM_VGA_H
8 8
9#include <linux/string.h>
9#include <asm/addrspace.h> 10#include <asm/addrspace.h>
10#include <asm/byteorder.h> 11#include <asm/byteorder.h>
11 12
@@ -40,9 +41,15 @@ static inline u16 scr_readw(volatile const u16 *addr)
40 return le16_to_cpu(*addr); 41 return le16_to_cpu(*addr);
41} 42}
42 43
44static inline void scr_memsetw(u16 *s, u16 v, unsigned int count)
45{
46 memset16(s, cpu_to_le16(v), count / 2);
47}
48
43#define scr_memcpyw(d, s, c) memcpy(d, s, c) 49#define scr_memcpyw(d, s, c) memcpy(d, s, c)
44#define scr_memmovew(d, s, c) memmove(d, s, c) 50#define scr_memmovew(d, s, c) memmove(d, s, c)
45#define VT_BUF_HAVE_MEMCPYW 51#define VT_BUF_HAVE_MEMCPYW
46#define VT_BUF_HAVE_MEMMOVEW 52#define VT_BUF_HAVE_MEMMOVEW
53#define VT_BUF_HAVE_MEMSETW
47 54
48#endif /* _ASM_VGA_H */ 55#endif /* _ASM_VGA_H */
diff --git a/arch/mn10300/configs/asb2303_defconfig b/arch/mn10300/configs/asb2303_defconfig
index 1fd41ec1dfb5..d06dae131139 100644
--- a/arch/mn10300/configs/asb2303_defconfig
+++ b/arch/mn10300/configs/asb2303_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_TINY_RCU=y 3CONFIG_TINY_RCU=y
@@ -28,16 +27,13 @@ CONFIG_IP_PNP_BOOTP=y
28# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 27# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
29# CONFIG_INET_XFRM_MODE_TUNNEL is not set 28# CONFIG_INET_XFRM_MODE_TUNNEL is not set
30# CONFIG_INET_XFRM_MODE_BEET is not set 29# CONFIG_INET_XFRM_MODE_BEET is not set
31# CONFIG_INET_LRO is not set
32# CONFIG_INET_DIAG is not set 30# CONFIG_INET_DIAG is not set
33# CONFIG_IPV6 is not set 31# CONFIG_IPV6 is not set
34# CONFIG_WIRELESS is not set 32# CONFIG_WIRELESS is not set
35CONFIG_MTD=y 33CONFIG_MTD=y
36CONFIG_MTD_DEBUG=y 34CONFIG_MTD_DEBUG=y
37CONFIG_MTD_PARTITIONS=y
38CONFIG_MTD_REDBOOT_PARTS=y 35CONFIG_MTD_REDBOOT_PARTS=y
39CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y 36CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
40CONFIG_MTD_CHAR=y
41CONFIG_MTD_CFI=y 37CONFIG_MTD_CFI=y
42CONFIG_MTD_JEDECPROBE=y 38CONFIG_MTD_JEDECPROBE=y
43CONFIG_MTD_CFI_ADV_OPTIONS=y 39CONFIG_MTD_CFI_ADV_OPTIONS=y
@@ -48,8 +44,6 @@ CONFIG_MTD_PHYSMAP=y
48CONFIG_NETDEVICES=y 44CONFIG_NETDEVICES=y
49CONFIG_NET_ETHERNET=y 45CONFIG_NET_ETHERNET=y
50CONFIG_SMC91X=y 46CONFIG_SMC91X=y
51# CONFIG_NETDEV_1000 is not set
52# CONFIG_NETDEV_10000 is not set
53# CONFIG_WLAN is not set 47# CONFIG_WLAN is not set
54# CONFIG_INPUT is not set 48# CONFIG_INPUT is not set
55# CONFIG_SERIO is not set 49# CONFIG_SERIO is not set
diff --git a/arch/mn10300/configs/asb2364_defconfig b/arch/mn10300/configs/asb2364_defconfig
index cd0a6cb17dee..b1d80cee97ee 100644
--- a/arch/mn10300/configs/asb2364_defconfig
+++ b/arch/mn10300/configs/asb2364_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -40,7 +39,6 @@ CONFIG_IP_PNP_BOOTP=y
40# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 39# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
41# CONFIG_INET_XFRM_MODE_TUNNEL is not set 40# CONFIG_INET_XFRM_MODE_TUNNEL is not set
42# CONFIG_INET_XFRM_MODE_BEET is not set 41# CONFIG_INET_XFRM_MODE_BEET is not set
43# CONFIG_INET_LRO is not set
44# CONFIG_INET_DIAG is not set 42# CONFIG_INET_DIAG is not set
45CONFIG_IPV6=y 43CONFIG_IPV6=y
46# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set 44# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
@@ -50,10 +48,8 @@ CONFIG_IPV6=y
50CONFIG_CONNECTOR=y 48CONFIG_CONNECTOR=y
51CONFIG_MTD=y 49CONFIG_MTD=y
52CONFIG_MTD_DEBUG=y 50CONFIG_MTD_DEBUG=y
53CONFIG_MTD_PARTITIONS=y
54CONFIG_MTD_REDBOOT_PARTS=y 51CONFIG_MTD_REDBOOT_PARTS=y
55CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y 52CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
56CONFIG_MTD_CHAR=y
57CONFIG_MTD_CFI=y 53CONFIG_MTD_CFI=y
58CONFIG_MTD_JEDECPROBE=y 54CONFIG_MTD_JEDECPROBE=y
59CONFIG_MTD_CFI_ADV_OPTIONS=y 55CONFIG_MTD_CFI_ADV_OPTIONS=y
@@ -64,8 +60,6 @@ CONFIG_MTD_PHYSMAP=y
64CONFIG_NETDEVICES=y 60CONFIG_NETDEVICES=y
65CONFIG_NET_ETHERNET=y 61CONFIG_NET_ETHERNET=y
66CONFIG_SMSC911X=y 62CONFIG_SMSC911X=y
67# CONFIG_NETDEV_1000 is not set
68# CONFIG_NETDEV_10000 is not set
69# CONFIG_INPUT_MOUSEDEV is not set 63# CONFIG_INPUT_MOUSEDEV is not set
70# CONFIG_INPUT_KEYBOARD is not set 64# CONFIG_INPUT_KEYBOARD is not set
71# CONFIG_INPUT_MOUSE is not set 65# CONFIG_INPUT_MOUSE is not set
@@ -77,7 +71,6 @@ CONFIG_SERIAL_8250_EXTENDED=y
77CONFIG_SERIAL_8250_SHARE_IRQ=y 71CONFIG_SERIAL_8250_SHARE_IRQ=y
78# CONFIG_HW_RANDOM is not set 72# CONFIG_HW_RANDOM is not set
79# CONFIG_HWMON is not set 73# CONFIG_HWMON is not set
80# CONFIG_HID_SUPPORT is not set
81# CONFIG_USB_SUPPORT is not set 74# CONFIG_USB_SUPPORT is not set
82CONFIG_PROC_KCORE=y 75CONFIG_PROC_KCORE=y
83# CONFIG_PROC_PAGE_MONITOR is not set 76# CONFIG_PROC_PAGE_MONITOR is not set
@@ -93,4 +86,3 @@ CONFIG_DEBUG_KERNEL=y
93CONFIG_DETECT_HUNG_TASK=y 86CONFIG_DETECT_HUNG_TASK=y
94# CONFIG_DEBUG_BUGVERBOSE is not set 87# CONFIG_DEBUG_BUGVERBOSE is not set
95CONFIG_DEBUG_INFO=y 88CONFIG_DEBUG_INFO=y
96# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 1e95920b0737..a0f2e4a323c1 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -29,6 +29,9 @@ config OPENRISC
29 select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1 29 select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
30 select NO_BOOTMEM 30 select NO_BOOTMEM
31 31
32config CPU_BIG_ENDIAN
33 def_bool y
34
32config MMU 35config MMU
33 def_bool y 36 def_bool y
34 37
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 13648519bd41..ba7b7ddc3844 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -59,6 +59,9 @@ config PARISC
59config CPU_BIG_ENDIAN 59config CPU_BIG_ENDIAN
60 def_bool y 60 def_bool y
61 61
62config CPU_BIG_ENDIAN
63 def_bool y
64
62config MMU 65config MMU
63 def_bool y 66 def_bool y
64 67
diff --git a/arch/powerpc/include/asm/vga.h b/arch/powerpc/include/asm/vga.h
index ab3acd2f2786..7a7b541b7493 100644
--- a/arch/powerpc/include/asm/vga.h
+++ b/arch/powerpc/include/asm/vga.h
@@ -33,8 +33,16 @@ static inline u16 scr_readw(volatile const u16 *addr)
33 return le16_to_cpu(*addr); 33 return le16_to_cpu(*addr);
34} 34}
35 35
36#define VT_BUF_HAVE_MEMSETW
37static inline void scr_memsetw(u16 *s, u16 v, unsigned int n)
38{
39 memset16(s, cpu_to_le16(v), n / 2);
40}
41
36#define VT_BUF_HAVE_MEMCPYW 42#define VT_BUF_HAVE_MEMCPYW
43#define VT_BUF_HAVE_MEMMOVEW
37#define scr_memcpyw memcpy 44#define scr_memcpyw memcpy
45#define scr_memmovew memmove
38 46
39#endif /* !CONFIG_VGA_CONSOLE && !CONFIG_MDA_CONSOLE */ 47#endif /* !CONFIG_VGA_CONSOLE && !CONFIG_MDA_CONSOLE */
40 48
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index 70f073d6c3b2..2ff2b8a19f71 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -224,7 +224,7 @@ void __init allocate_pacas(void)
224 paca = __va(memblock_alloc_base(paca_size, PAGE_SIZE, limit)); 224 paca = __va(memblock_alloc_base(paca_size, PAGE_SIZE, limit));
225 memset(paca, 0, paca_size); 225 memset(paca, 0, paca_size);
226 226
227 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n", 227 printk(KERN_DEBUG "Allocated %u bytes for %u pacas at %p\n",
228 paca_size, nr_cpu_ids, paca); 228 paca_size, nr_cpu_ids, paca);
229 229
230 allocate_lppacas(nr_cpu_ids, limit); 230 allocate_lppacas(nr_cpu_ids, limit);
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 7de73589d8e2..0ac741fae90e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -551,7 +551,7 @@ void __init smp_setup_cpu_maps(void)
551 if (maxcpus > nr_cpu_ids) { 551 if (maxcpus > nr_cpu_ids) {
552 printk(KERN_WARNING 552 printk(KERN_WARNING
553 "Partition configured for %d cpus, " 553 "Partition configured for %d cpus, "
554 "operating system maximum is %d.\n", 554 "operating system maximum is %u.\n",
555 maxcpus, nr_cpu_ids); 555 maxcpus, nr_cpu_ids);
556 maxcpus = nr_cpu_ids; 556 maxcpus = nr_cpu_ids;
557 } else 557 } else
diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
index 44f3a25ca630..ebc244b08d67 100644
--- a/arch/powerpc/sysdev/xive/native.c
+++ b/arch/powerpc/sysdev/xive/native.c
@@ -511,13 +511,13 @@ static bool xive_parse_provisioning(struct device_node *np)
511static void xive_native_setup_pools(void) 511static void xive_native_setup_pools(void)
512{ 512{
513 /* Allocate a pool big enough */ 513 /* Allocate a pool big enough */
514 pr_debug("XIVE: Allocating VP block for pool size %d\n", nr_cpu_ids); 514 pr_debug("XIVE: Allocating VP block for pool size %u\n", nr_cpu_ids);
515 515
516 xive_pool_vps = xive_native_alloc_vp_block(nr_cpu_ids); 516 xive_pool_vps = xive_native_alloc_vp_block(nr_cpu_ids);
517 if (WARN_ON(xive_pool_vps == XIVE_INVALID_VP)) 517 if (WARN_ON(xive_pool_vps == XIVE_INVALID_VP))
518 pr_err("XIVE: Failed to allocate pool VP, KVM might not function\n"); 518 pr_err("XIVE: Failed to allocate pool VP, KVM might not function\n");
519 519
520 pr_debug("XIVE: Pool VPs allocated at 0x%x for %d max CPUs\n", 520 pr_debug("XIVE: Pool VPs allocated at 0x%x for %u max CPUs\n",
521 xive_pool_vps, nr_cpu_ids); 521 xive_pool_vps, nr_cpu_ids);
522} 522}
523 523
diff --git a/arch/sh/configs/ap325rxa_defconfig b/arch/sh/configs/ap325rxa_defconfig
index e5335123b5e9..72b72e50a92e 100644
--- a/arch/sh/configs/ap325rxa_defconfig
+++ b/arch/sh/configs/ap325rxa_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -28,14 +27,10 @@ CONFIG_IP_PNP_DHCP=y
28# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 27# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
29# CONFIG_INET_XFRM_MODE_TUNNEL is not set 28# CONFIG_INET_XFRM_MODE_TUNNEL is not set
30# CONFIG_INET_XFRM_MODE_BEET is not set 29# CONFIG_INET_XFRM_MODE_BEET is not set
31# CONFIG_INET_LRO is not set
32# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
33CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
34CONFIG_MTD=y 32CONFIG_MTD=y
35CONFIG_MTD_CONCAT=y
36CONFIG_MTD_PARTITIONS=y
37CONFIG_MTD_CMDLINE_PARTS=y 33CONFIG_MTD_CMDLINE_PARTS=y
38CONFIG_MTD_CHAR=y
39CONFIG_MTD_BLOCK=y 34CONFIG_MTD_BLOCK=y
40CONFIG_MTD_CFI=y 35CONFIG_MTD_CFI=y
41CONFIG_MTD_CFI_AMDSTD=y 36CONFIG_MTD_CFI_AMDSTD=y
@@ -51,8 +46,6 @@ CONFIG_NETDEVICES=y
51CONFIG_SMSC_PHY=y 46CONFIG_SMSC_PHY=y
52CONFIG_NET_ETHERNET=y 47CONFIG_NET_ETHERNET=y
53CONFIG_SMSC911X=y 48CONFIG_SMSC911X=y
54# CONFIG_NETDEV_1000 is not set
55# CONFIG_NETDEV_10000 is not set
56# CONFIG_INPUT_MOUSEDEV is not set 49# CONFIG_INPUT_MOUSEDEV is not set
57# CONFIG_INPUT_KEYBOARD is not set 50# CONFIG_INPUT_KEYBOARD is not set
58# CONFIG_INPUT_MOUSE is not set 51# CONFIG_INPUT_MOUSE is not set
@@ -82,7 +75,6 @@ CONFIG_FB=y
82CONFIG_FB_SH_MOBILE_LCDC=y 75CONFIG_FB_SH_MOBILE_LCDC=y
83CONFIG_FRAMEBUFFER_CONSOLE=y 76CONFIG_FRAMEBUFFER_CONSOLE=y
84CONFIG_LOGO=y 77CONFIG_LOGO=y
85# CONFIG_HID_SUPPORT is not set
86# CONFIG_USB_SUPPORT is not set 78# CONFIG_USB_SUPPORT is not set
87CONFIG_MMC=y 79CONFIG_MMC=y
88CONFIG_MMC_SPI=y 80CONFIG_MMC_SPI=y
@@ -110,8 +102,6 @@ CONFIG_NLS_CODEPAGE_437=y
110CONFIG_NLS_CODEPAGE_932=y 102CONFIG_NLS_CODEPAGE_932=y
111CONFIG_NLS_ISO8859_1=y 103CONFIG_NLS_ISO8859_1=y
112# CONFIG_ENABLE_MUST_CHECK is not set 104# CONFIG_ENABLE_MUST_CHECK is not set
113# CONFIG_RCU_CPU_STALL_DETECTOR is not set
114CONFIG_SYSCTL_SYSCALL_CHECK=y
115CONFIG_CRYPTO=y 105CONFIG_CRYPTO=y
116CONFIG_CRYPTO_CBC=y 106CONFIG_CRYPTO_CBC=y
117# CONFIG_CRYPTO_ANSI_CPRNG is not set 107# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/apsh4a3a_defconfig b/arch/sh/configs/apsh4a3a_defconfig
index 6cb327977d13..4710df43a5b5 100644
--- a/arch/sh/configs/apsh4a3a_defconfig
+++ b/arch/sh/configs/apsh4a3a_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -28,15 +27,11 @@ CONFIG_INET=y
28CONFIG_IP_ADVANCED_ROUTER=y 27CONFIG_IP_ADVANCED_ROUTER=y
29CONFIG_IP_PNP=y 28CONFIG_IP_PNP=y
30CONFIG_IP_PNP_DHCP=y 29CONFIG_IP_PNP_DHCP=y
31# CONFIG_INET_LRO is not set
32# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
33# CONFIG_WIRELESS is not set 31# CONFIG_WIRELESS is not set
34CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 32CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
35# CONFIG_FW_LOADER is not set 33# CONFIG_FW_LOADER is not set
36CONFIG_MTD=y 34CONFIG_MTD=y
37CONFIG_MTD_CONCAT=y
38CONFIG_MTD_PARTITIONS=y
39CONFIG_MTD_CHAR=y
40CONFIG_MTD_BLOCK=y 35CONFIG_MTD_BLOCK=y
41CONFIG_MTD_CFI=y 36CONFIG_MTD_CFI=y
42CONFIG_MTD_CFI_AMDSTD=y 37CONFIG_MTD_CFI_AMDSTD=y
@@ -46,8 +41,6 @@ CONFIG_BLK_DEV_RAM_SIZE=16384
46CONFIG_NETDEVICES=y 41CONFIG_NETDEVICES=y
47CONFIG_NET_ETHERNET=y 42CONFIG_NET_ETHERNET=y
48CONFIG_SMSC911X=y 43CONFIG_SMSC911X=y
49# CONFIG_NETDEV_1000 is not set
50# CONFIG_NETDEV_10000 is not set
51# CONFIG_WLAN is not set 44# CONFIG_WLAN is not set
52# CONFIG_INPUT_MOUSEDEV is not set 45# CONFIG_INPUT_MOUSEDEV is not set
53# CONFIG_INPUT_KEYBOARD is not set 46# CONFIG_INPUT_KEYBOARD is not set
@@ -66,7 +59,6 @@ CONFIG_FONTS=y
66CONFIG_FONT_8x8=y 59CONFIG_FONT_8x8=y
67CONFIG_FONT_8x16=y 60CONFIG_FONT_8x16=y
68CONFIG_LOGO=y 61CONFIG_LOGO=y
69# CONFIG_HID_SUPPORT is not set
70# CONFIG_USB_SUPPORT is not set 62# CONFIG_USB_SUPPORT is not set
71CONFIG_EXT2_FS=y 63CONFIG_EXT2_FS=y
72CONFIG_EXT3_FS=y 64CONFIG_EXT3_FS=y
@@ -96,7 +88,6 @@ CONFIG_DEBUG_KERNEL=y
96# CONFIG_DEBUG_PREEMPT is not set 88# CONFIG_DEBUG_PREEMPT is not set
97# CONFIG_DEBUG_BUGVERBOSE is not set 89# CONFIG_DEBUG_BUGVERBOSE is not set
98CONFIG_DEBUG_INFO=y 90CONFIG_DEBUG_INFO=y
99# CONFIG_RCU_CPU_STALL_DETECTOR is not set
100# CONFIG_FTRACE is not set 91# CONFIG_FTRACE is not set
101# CONFIG_CRYPTO_ANSI_CPRNG is not set 92# CONFIG_CRYPTO_ANSI_CPRNG is not set
102# CONFIG_CRYPTO_HW is not set 93# CONFIG_CRYPTO_HW is not set
diff --git a/arch/sh/configs/apsh4ad0a_defconfig b/arch/sh/configs/apsh4ad0a_defconfig
index fe45d2c9b151..825c641726c4 100644
--- a/arch/sh/configs/apsh4ad0a_defconfig
+++ b/arch/sh/configs/apsh4ad0a_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -53,7 +52,6 @@ CONFIG_PACKET=y
53CONFIG_UNIX=y 52CONFIG_UNIX=y
54CONFIG_NET_KEY=y 53CONFIG_NET_KEY=y
55CONFIG_INET=y 54CONFIG_INET=y
56# CONFIG_INET_LRO is not set
57# CONFIG_IPV6 is not set 55# CONFIG_IPV6 is not set
58# CONFIG_WIRELESS is not set 56# CONFIG_WIRELESS is not set
59CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 57CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -70,8 +68,6 @@ CONFIG_NETDEVICES=y
70CONFIG_MDIO_BITBANG=y 68CONFIG_MDIO_BITBANG=y
71CONFIG_NET_ETHERNET=y 69CONFIG_NET_ETHERNET=y
72CONFIG_SMSC911X=y 70CONFIG_SMSC911X=y
73# CONFIG_NETDEV_1000 is not set
74# CONFIG_NETDEV_10000 is not set
75# CONFIG_WLAN is not set 71# CONFIG_WLAN is not set
76CONFIG_INPUT_EVDEV=y 72CONFIG_INPUT_EVDEV=y
77# CONFIG_INPUT_KEYBOARD is not set 73# CONFIG_INPUT_KEYBOARD is not set
@@ -83,7 +79,6 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
83# CONFIG_LEGACY_PTYS is not set 79# CONFIG_LEGACY_PTYS is not set
84# CONFIG_HW_RANDOM is not set 80# CONFIG_HW_RANDOM is not set
85# CONFIG_HWMON is not set 81# CONFIG_HWMON is not set
86CONFIG_VIDEO_OUTPUT_CONTROL=y
87CONFIG_FB=y 82CONFIG_FB=y
88CONFIG_FB_SH7785FB=y 83CONFIG_FB_SH7785FB=y
89CONFIG_FRAMEBUFFER_CONSOLE=y 84CONFIG_FRAMEBUFFER_CONSOLE=y
@@ -124,6 +119,5 @@ CONFIG_DEBUG_SHIRQ=y
124CONFIG_DETECT_HUNG_TASK=y 119CONFIG_DETECT_HUNG_TASK=y
125CONFIG_DEBUG_INFO=y 120CONFIG_DEBUG_INFO=y
126CONFIG_DEBUG_VM=y 121CONFIG_DEBUG_VM=y
127# CONFIG_RCU_CPU_STALL_DETECTOR is not set
128CONFIG_DWARF_UNWINDER=y 122CONFIG_DWARF_UNWINDER=y
129# CONFIG_CRYPTO_ANSI_CPRNG is not set 123# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/cayman_defconfig b/arch/sh/configs/cayman_defconfig
index 67e150631ea5..5a90e24aa8a6 100644
--- a/arch/sh/configs/cayman_defconfig
+++ b/arch/sh/configs/cayman_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_POSIX_MQUEUE=y 1CONFIG_POSIX_MQUEUE=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 3# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -19,7 +18,6 @@ CONFIG_PACKET=y
19CONFIG_UNIX=y 18CONFIG_UNIX=y
20CONFIG_INET=y 19CONFIG_INET=y
21CONFIG_IP_PNP=y 20CONFIG_IP_PNP=y
22# CONFIG_INET_LRO is not set
23# CONFIG_IPV6 is not set 21# CONFIG_IPV6 is not set
24CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 22CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
25# CONFIG_FW_LOADER is not set 23# CONFIG_FW_LOADER is not set
@@ -38,7 +36,6 @@ CONFIG_NET_ETHERNET=y
38CONFIG_HW_RANDOM=y 36CONFIG_HW_RANDOM=y
39CONFIG_I2C=m 37CONFIG_I2C=m
40CONFIG_WATCHDOG=y 38CONFIG_WATCHDOG=y
41CONFIG_VIDEO_OUTPUT_CONTROL=y
42CONFIG_FB=y 39CONFIG_FB=y
43CONFIG_FIRMWARE_EDID=y 40CONFIG_FIRMWARE_EDID=y
44CONFIG_FB_MODE_HELPERS=y 41CONFIG_FB_MODE_HELPERS=y
@@ -67,5 +64,4 @@ CONFIG_DEBUG_KERNEL=y
67CONFIG_DETECT_HUNG_TASK=y 64CONFIG_DETECT_HUNG_TASK=y
68CONFIG_SCHEDSTATS=y 65CONFIG_SCHEDSTATS=y
69CONFIG_FRAME_POINTER=y 66CONFIG_FRAME_POINTER=y
70# CONFIG_RCU_CPU_STALL_DETECTOR is not set
71# CONFIG_CRYPTO_ANSI_CPRNG is not set 67# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/dreamcast_defconfig b/arch/sh/configs/dreamcast_defconfig
index ec243ca29529..3f08dc54480b 100644
--- a/arch/sh/configs/dreamcast_defconfig
+++ b/arch/sh/configs/dreamcast_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
@@ -32,7 +31,6 @@ CONFIG_NET=y
32CONFIG_PACKET=y 31CONFIG_PACKET=y
33CONFIG_UNIX=y 32CONFIG_UNIX=y
34CONFIG_INET=y 33CONFIG_INET=y
35# CONFIG_INET_LRO is not set
36# CONFIG_IPV6 is not set 34# CONFIG_IPV6 is not set
37CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 35CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
38# CONFIG_STANDALONE is not set 36# CONFIG_STANDALONE is not set
@@ -43,8 +41,6 @@ CONFIG_NET_ETHERNET=y
43CONFIG_NET_PCI=y 41CONFIG_NET_PCI=y
44CONFIG_8139TOO=y 42CONFIG_8139TOO=y
45# CONFIG_8139TOO_PIO is not set 43# CONFIG_8139TOO_PIO is not set
46# CONFIG_NETDEV_1000 is not set
47# CONFIG_NETDEV_10000 is not set
48# CONFIG_KEYBOARD_ATKBD is not set 44# CONFIG_KEYBOARD_ATKBD is not set
49CONFIG_KEYBOARD_MAPLE=y 45CONFIG_KEYBOARD_MAPLE=y
50# CONFIG_MOUSE_PS2 is not set 46# CONFIG_MOUSE_PS2 is not set
@@ -56,7 +52,6 @@ CONFIG_HW_RANDOM=y
56# CONFIG_HWMON is not set 52# CONFIG_HWMON is not set
57CONFIG_WATCHDOG=y 53CONFIG_WATCHDOG=y
58CONFIG_SH_WDT=y 54CONFIG_SH_WDT=y
59CONFIG_VIDEO_OUTPUT_CONTROL=m
60CONFIG_FB=y 55CONFIG_FB=y
61CONFIG_FIRMWARE_EDID=y 56CONFIG_FIRMWARE_EDID=y
62CONFIG_FB_PVR2=y 57CONFIG_FB_PVR2=y
@@ -74,5 +69,4 @@ CONFIG_LOGO=y
74CONFIG_PROC_KCORE=y 69CONFIG_PROC_KCORE=y
75CONFIG_TMPFS=y 70CONFIG_TMPFS=y
76CONFIG_HUGETLBFS=y 71CONFIG_HUGETLBFS=y
77# CONFIG_RCU_CPU_STALL_DETECTOR is not set
78# CONFIG_CRYPTO_ANSI_CPRNG is not set 72# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/ecovec24-romimage_defconfig b/arch/sh/configs/ecovec24-romimage_defconfig
index 5fcb17bff24a..0c5dfccbfe37 100644
--- a/arch/sh/configs/ecovec24-romimage_defconfig
+++ b/arch/sh/configs/ecovec24-romimage_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -26,19 +25,15 @@ CONFIG_INET=y
26# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 25# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
27# CONFIG_INET_XFRM_MODE_TUNNEL is not set 26# CONFIG_INET_XFRM_MODE_TUNNEL is not set
28# CONFIG_INET_XFRM_MODE_BEET is not set 27# CONFIG_INET_XFRM_MODE_BEET is not set
29# CONFIG_INET_LRO is not set
30# CONFIG_INET_DIAG is not set 28# CONFIG_INET_DIAG is not set
31# CONFIG_IPV6 is not set 29# CONFIG_IPV6 is not set
32CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
33# CONFIG_MISC_DEVICES is not set
34CONFIG_SCSI=y 31CONFIG_SCSI=y
35CONFIG_BLK_DEV_SD=y 32CONFIG_BLK_DEV_SD=y
36# CONFIG_SCSI_LOWLEVEL is not set 33# CONFIG_SCSI_LOWLEVEL is not set
37CONFIG_NETDEVICES=y 34CONFIG_NETDEVICES=y
38CONFIG_NET_ETHERNET=y 35CONFIG_NET_ETHERNET=y
39CONFIG_SH_ETH=y 36CONFIG_SH_ETH=y
40# CONFIG_NETDEV_1000 is not set
41# CONFIG_NETDEV_10000 is not set
42# CONFIG_INPUT_MOUSEDEV is not set 37# CONFIG_INPUT_MOUSEDEV is not set
43# CONFIG_INPUT_KEYBOARD is not set 38# CONFIG_INPUT_KEYBOARD is not set
44# CONFIG_INPUT_MOUSE is not set 39# CONFIG_INPUT_MOUSE is not set
@@ -51,7 +46,6 @@ CONFIG_I2C=y
51CONFIG_I2C_SH_MOBILE=y 46CONFIG_I2C_SH_MOBILE=y
52CONFIG_GPIO_SYSFS=y 47CONFIG_GPIO_SYSFS=y
53# CONFIG_HWMON is not set 48# CONFIG_HWMON is not set
54# CONFIG_HID_SUPPORT is not set
55CONFIG_USB=y 49CONFIG_USB=y
56CONFIG_USB_R8A66597_HCD=y 50CONFIG_USB_R8A66597_HCD=y
57CONFIG_USB_STORAGE=y 51CONFIG_USB_STORAGE=y
@@ -64,4 +58,3 @@ CONFIG_TMPFS=y
64# CONFIG_NETWORK_FILESYSTEMS is not set 58# CONFIG_NETWORK_FILESYSTEMS is not set
65# CONFIG_ENABLE_MUST_CHECK is not set 59# CONFIG_ENABLE_MUST_CHECK is not set
66CONFIG_DEBUG_FS=y 60CONFIG_DEBUG_FS=y
67# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/sh/configs/ecovec24_defconfig b/arch/sh/configs/ecovec24_defconfig
index 0b364e3b0ff8..3568310c2c2f 100644
--- a/arch/sh/configs/ecovec24_defconfig
+++ b/arch/sh/configs/ecovec24_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -29,16 +28,12 @@ CONFIG_IP_PNP_DHCP=y
29# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 28# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
30# CONFIG_INET_XFRM_MODE_TUNNEL is not set 29# CONFIG_INET_XFRM_MODE_TUNNEL is not set
31# CONFIG_INET_XFRM_MODE_BEET is not set 30# CONFIG_INET_XFRM_MODE_BEET is not set
32# CONFIG_INET_LRO is not set
33# CONFIG_IPV6 is not set 31# CONFIG_IPV6 is not set
34CONFIG_IRDA=y 32CONFIG_IRDA=y
35CONFIG_SH_SIR=y 33CONFIG_SH_SIR=y
36CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 34CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
37CONFIG_MTD=y 35CONFIG_MTD=y
38CONFIG_MTD_CONCAT=y
39CONFIG_MTD_PARTITIONS=y
40CONFIG_MTD_CMDLINE_PARTS=y 36CONFIG_MTD_CMDLINE_PARTS=y
41CONFIG_MTD_CHAR=y
42CONFIG_MTD_BLOCK=y 37CONFIG_MTD_BLOCK=y
43CONFIG_MTD_CFI=y 38CONFIG_MTD_CFI=y
44CONFIG_MTD_CFI_AMDSTD=y 39CONFIG_MTD_CFI_AMDSTD=y
@@ -53,8 +48,6 @@ CONFIG_NETDEVICES=y
53CONFIG_SMSC_PHY=y 48CONFIG_SMSC_PHY=y
54CONFIG_NET_ETHERNET=y 49CONFIG_NET_ETHERNET=y
55CONFIG_SH_ETH=y 50CONFIG_SH_ETH=y
56# CONFIG_NETDEV_1000 is not set
57# CONFIG_NETDEV_10000 is not set
58# CONFIG_INPUT_MOUSEDEV is not set 51# CONFIG_INPUT_MOUSEDEV is not set
59CONFIG_INPUT_EVDEV=y 52CONFIG_INPUT_EVDEV=y
60# CONFIG_KEYBOARD_ATKBD is not set 53# CONFIG_KEYBOARD_ATKBD is not set
@@ -140,8 +133,6 @@ CONFIG_NLS_CODEPAGE_932=y
140CONFIG_NLS_ISO8859_1=y 133CONFIG_NLS_ISO8859_1=y
141# CONFIG_ENABLE_MUST_CHECK is not set 134# CONFIG_ENABLE_MUST_CHECK is not set
142CONFIG_DEBUG_FS=y 135CONFIG_DEBUG_FS=y
143# CONFIG_RCU_CPU_STALL_DETECTOR is not set
144CONFIG_SYSCTL_SYSCALL_CHECK=y
145CONFIG_CRYPTO=y 136CONFIG_CRYPTO=y
146CONFIG_CRYPTO_CBC=y 137CONFIG_CRYPTO_CBC=y
147# CONFIG_CRYPTO_ANSI_CPRNG is not set 138# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/edosk7705_defconfig b/arch/sh/configs/edosk7705_defconfig
index 41fa3a7eed96..db756e099052 100644
--- a/arch/sh/configs/edosk7705_defconfig
+++ b/arch/sh/configs/edosk7705_defconfig
@@ -20,7 +20,6 @@ CONFIG_CPU_SUBTYPE_SH7705=y
20CONFIG_SH_EDOSK7705=y 20CONFIG_SH_EDOSK7705=y
21CONFIG_SH_PCLK_FREQ=31250000 21CONFIG_SH_PCLK_FREQ=31250000
22# CONFIG_PREVENT_FIRMWARE_BUILD is not set 22# CONFIG_PREVENT_FIRMWARE_BUILD is not set
23# CONFIG_MISC_DEVICES is not set
24# CONFIG_INPUT is not set 23# CONFIG_INPUT is not set
25# CONFIG_SERIO is not set 24# CONFIG_SERIO is not set
26# CONFIG_VT is not set 25# CONFIG_VT is not set
@@ -35,5 +34,4 @@ CONFIG_SH_PCLK_FREQ=31250000
35# CONFIG_SYSFS is not set 34# CONFIG_SYSFS is not set
36# CONFIG_ENABLE_WARN_DEPRECATED is not set 35# CONFIG_ENABLE_WARN_DEPRECATED is not set
37# CONFIG_ENABLE_MUST_CHECK is not set 36# CONFIG_ENABLE_MUST_CHECK is not set
38# CONFIG_RCU_CPU_STALL_DETECTOR is not set
39# CONFIG_CRC32 is not set 37# CONFIG_CRC32 is not set
diff --git a/arch/sh/configs/edosk7760_defconfig b/arch/sh/configs/edosk7760_defconfig
index e1077a041ac3..aab4ff1e247c 100644
--- a/arch/sh/configs/edosk7760_defconfig
+++ b/arch/sh/configs/edosk7760_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_LOCALVERSION="_edosk7760" 1CONFIG_LOCALVERSION="_edosk7760"
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -31,7 +30,6 @@ CONFIG_IP_PNP_BOOTP=y
31# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 30# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
32# CONFIG_INET_XFRM_MODE_TUNNEL is not set 31# CONFIG_INET_XFRM_MODE_TUNNEL is not set
33# CONFIG_INET_XFRM_MODE_BEET is not set 32# CONFIG_INET_XFRM_MODE_BEET is not set
34# CONFIG_INET_LRO is not set
35# CONFIG_IPV6 is not set 33# CONFIG_IPV6 is not set
36CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 34CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
37# CONFIG_FW_LOADER is not set 35# CONFIG_FW_LOADER is not set
@@ -39,10 +37,7 @@ CONFIG_DEBUG_DRIVER=y
39CONFIG_DEBUG_DEVRES=y 37CONFIG_DEBUG_DEVRES=y
40CONFIG_MTD=y 38CONFIG_MTD=y
41CONFIG_MTD_DEBUG=y 39CONFIG_MTD_DEBUG=y
42CONFIG_MTD_CONCAT=y
43CONFIG_MTD_PARTITIONS=y
44CONFIG_MTD_CMDLINE_PARTS=y 40CONFIG_MTD_CMDLINE_PARTS=y
45CONFIG_MTD_CHAR=y
46CONFIG_MTD_BLOCK=y 41CONFIG_MTD_BLOCK=y
47CONFIG_MTD_CFI=y 42CONFIG_MTD_CFI=y
48CONFIG_MTD_JEDECPROBE=y 43CONFIG_MTD_JEDECPROBE=y
@@ -62,12 +57,9 @@ CONFIG_MTD_ABSENT=y
62CONFIG_MTD_PHYSMAP=y 57CONFIG_MTD_PHYSMAP=y
63CONFIG_BLK_DEV_RAM=y 58CONFIG_BLK_DEV_RAM=y
64CONFIG_BLK_DEV_RAM_SIZE=26000 59CONFIG_BLK_DEV_RAM_SIZE=26000
65# CONFIG_MISC_DEVICES is not set
66CONFIG_NETDEVICES=y 60CONFIG_NETDEVICES=y
67CONFIG_NET_ETHERNET=y 61CONFIG_NET_ETHERNET=y
68CONFIG_SMC91X=y 62CONFIG_SMC91X=y
69# CONFIG_NETDEV_1000 is not set
70# CONFIG_NETDEV_10000 is not set
71# CONFIG_INPUT_MOUSEDEV is not set 63# CONFIG_INPUT_MOUSEDEV is not set
72# CONFIG_INPUT_KEYBOARD is not set 64# CONFIG_INPUT_KEYBOARD is not set
73# CONFIG_INPUT_MOUSE is not set 65# CONFIG_INPUT_MOUSE is not set
@@ -92,7 +84,6 @@ CONFIG_SND=y
92# CONFIG_SND_VERBOSE_PROCFS is not set 84# CONFIG_SND_VERBOSE_PROCFS is not set
93CONFIG_SND_VERBOSE_PRINTK=y 85CONFIG_SND_VERBOSE_PRINTK=y
94CONFIG_SND_SOC=y 86CONFIG_SND_SOC=y
95# CONFIG_HID_SUPPORT is not set
96# CONFIG_USB_SUPPORT is not set 87# CONFIG_USB_SUPPORT is not set
97CONFIG_EXT2_FS=y 88CONFIG_EXT2_FS=y
98CONFIG_EXT2_FS_XATTR=y 89CONFIG_EXT2_FS_XATTR=y
@@ -119,8 +110,6 @@ CONFIG_DETECT_HUNG_TASK=y
119# CONFIG_SCHED_DEBUG is not set 110# CONFIG_SCHED_DEBUG is not set
120CONFIG_TIMER_STATS=y 111CONFIG_TIMER_STATS=y
121CONFIG_DEBUG_INFO=y 112CONFIG_DEBUG_INFO=y
122# CONFIG_RCU_CPU_STALL_DETECTOR is not set
123CONFIG_SYSCTL_SYSCALL_CHECK=y
124CONFIG_CRYPTO=y 113CONFIG_CRYPTO=y
125CONFIG_CRYPTO_MD5=y 114CONFIG_CRYPTO_MD5=y
126CONFIG_CRYPTO_DES=y 115CONFIG_CRYPTO_DES=y
diff --git a/arch/sh/configs/espt_defconfig b/arch/sh/configs/espt_defconfig
index 67cb1094a033..2985fe7c6d50 100644
--- a/arch/sh/configs/espt_defconfig
+++ b/arch/sh/configs/espt_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -26,13 +25,10 @@ CONFIG_INET=y
26CONFIG_IP_PNP=y 25CONFIG_IP_PNP=y
27CONFIG_IP_PNP_DHCP=y 26CONFIG_IP_PNP_DHCP=y
28CONFIG_IP_PNP_BOOTP=y 27CONFIG_IP_PNP_BOOTP=y
29# CONFIG_INET_LRO is not set
30# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
32CONFIG_MTD=y 30CONFIG_MTD=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_CMDLINE_PARTS=y 31CONFIG_MTD_CMDLINE_PARTS=y
35CONFIG_MTD_CHAR=y
36CONFIG_MTD_BLOCK=y 32CONFIG_MTD_BLOCK=y
37CONFIG_MTD_CFI=y 33CONFIG_MTD_CFI=y
38CONFIG_MTD_JEDECPROBE=y 34CONFIG_MTD_JEDECPROBE=y
@@ -43,14 +39,11 @@ CONFIG_MTD_CFI_GEOMETRY=y
43CONFIG_MTD_CFI_AMDSTD=y 39CONFIG_MTD_CFI_AMDSTD=y
44CONFIG_MTD_COMPLEX_MAPPINGS=y 40CONFIG_MTD_COMPLEX_MAPPINGS=y
45CONFIG_MTD_PHYSMAP=y 41CONFIG_MTD_PHYSMAP=y
46# CONFIG_MISC_DEVICES is not set
47CONFIG_SCSI=y 42CONFIG_SCSI=y
48CONFIG_BLK_DEV_SD=y 43CONFIG_BLK_DEV_SD=y
49CONFIG_NETDEVICES=y 44CONFIG_NETDEVICES=y
50CONFIG_NET_ETHERNET=y 45CONFIG_NET_ETHERNET=y
51CONFIG_SH_ETH=y 46CONFIG_SH_ETH=y
52# CONFIG_NETDEV_1000 is not set
53# CONFIG_NETDEV_10000 is not set
54# CONFIG_INPUT_MOUSEDEV is not set 47# CONFIG_INPUT_MOUSEDEV is not set
55# CONFIG_INPUT_KEYBOARD is not set 48# CONFIG_INPUT_KEYBOARD is not set
56# CONFIG_INPUT_MOUSE is not set 49# CONFIG_INPUT_MOUSE is not set
@@ -65,7 +58,6 @@ CONFIG_FB_FOREIGN_ENDIAN=y
65CONFIG_FB_SH7760=y 58CONFIG_FB_SH7760=y
66CONFIG_FRAMEBUFFER_CONSOLE=y 59CONFIG_FRAMEBUFFER_CONSOLE=y
67CONFIG_LOGO=y 60CONFIG_LOGO=y
68# CONFIG_HID_SUPPORT is not set
69CONFIG_USB=y 61CONFIG_USB=y
70CONFIG_USB_MON=y 62CONFIG_USB_MON=y
71CONFIG_USB_OHCI_HCD=y 63CONFIG_USB_OHCI_HCD=y
@@ -73,7 +65,6 @@ CONFIG_USB_STORAGE=y
73CONFIG_EXT2_FS=y 65CONFIG_EXT2_FS=y
74CONFIG_EXT3_FS=y 66CONFIG_EXT3_FS=y
75# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 67# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
76CONFIG_AUTOFS_FS=y
77CONFIG_AUTOFS4_FS=y 68CONFIG_AUTOFS4_FS=y
78CONFIG_PROC_KCORE=y 69CONFIG_PROC_KCORE=y
79CONFIG_TMPFS=y 70CONFIG_TMPFS=y
@@ -123,6 +114,5 @@ CONFIG_NLS_UTF8=y
123# CONFIG_ENABLE_WARN_DEPRECATED is not set 114# CONFIG_ENABLE_WARN_DEPRECATED is not set
124# CONFIG_ENABLE_MUST_CHECK is not set 115# CONFIG_ENABLE_MUST_CHECK is not set
125CONFIG_DEBUG_FS=y 116CONFIG_DEBUG_FS=y
126# CONFIG_RCU_CPU_STALL_DETECTOR is not set
127# CONFIG_CRYPTO_ANSI_CPRNG is not set 117# CONFIG_CRYPTO_ANSI_CPRNG is not set
128CONFIG_CRC_T10DIF=y 118CONFIG_CRC_T10DIF=y
diff --git a/arch/sh/configs/hp6xx_defconfig b/arch/sh/configs/hp6xx_defconfig
index 496edcdf95a3..4dcf7f552582 100644
--- a/arch/sh/configs/hp6xx_defconfig
+++ b/arch/sh/configs/hp6xx_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_BSD_PROCESS_ACCT=y 1CONFIG_BSD_PROCESS_ACCT=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -37,7 +36,6 @@ CONFIG_SERIAL_SH_SCI_NR_UARTS=3
37CONFIG_SERIAL_SH_SCI_CONSOLE=y 36CONFIG_SERIAL_SH_SCI_CONSOLE=y
38CONFIG_LEGACY_PTY_COUNT=64 37CONFIG_LEGACY_PTY_COUNT=64
39# CONFIG_HWMON is not set 38# CONFIG_HWMON is not set
40CONFIG_VIDEO_OUTPUT_CONTROL=y
41CONFIG_FB=y 39CONFIG_FB=y
42CONFIG_FIRMWARE_EDID=y 40CONFIG_FIRMWARE_EDID=y
43CONFIG_FB_HIT=y 41CONFIG_FB_HIT=y
@@ -46,7 +44,6 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y
46CONFIG_FRAMEBUFFER_CONSOLE=y 44CONFIG_FRAMEBUFFER_CONSOLE=y
47CONFIG_FONTS=y 45CONFIG_FONTS=y
48CONFIG_FONT_PEARL_8x8=y 46CONFIG_FONT_PEARL_8x8=y
49# CONFIG_HID_SUPPORT is not set
50# CONFIG_USB_SUPPORT is not set 47# CONFIG_USB_SUPPORT is not set
51CONFIG_RTC_CLASS=y 48CONFIG_RTC_CLASS=y
52CONFIG_RTC_DRV_SH=y 49CONFIG_RTC_DRV_SH=y
@@ -55,7 +52,6 @@ CONFIG_MSDOS_FS=y
55CONFIG_VFAT_FS=y 52CONFIG_VFAT_FS=y
56CONFIG_PROC_KCORE=y 53CONFIG_PROC_KCORE=y
57CONFIG_NLS_CODEPAGE_850=y 54CONFIG_NLS_CODEPAGE_850=y
58# CONFIG_RCU_CPU_STALL_DETECTOR is not set
59CONFIG_CRYPTO=y 55CONFIG_CRYPTO=y
60CONFIG_CRYPTO_CBC=y 56CONFIG_CRYPTO_CBC=y
61CONFIG_CRYPTO_ECB=y 57CONFIG_CRYPTO_ECB=y
diff --git a/arch/sh/configs/kfr2r09-romimage_defconfig b/arch/sh/configs/kfr2r09-romimage_defconfig
index 029a506ca325..9cc37f29e3b4 100644
--- a/arch/sh/configs/kfr2r09-romimage_defconfig
+++ b/arch/sh/configs/kfr2r09-romimage_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -26,12 +25,10 @@ CONFIG_INET=y
26# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 25# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
27# CONFIG_INET_XFRM_MODE_TUNNEL is not set 26# CONFIG_INET_XFRM_MODE_TUNNEL is not set
28# CONFIG_INET_XFRM_MODE_BEET is not set 27# CONFIG_INET_XFRM_MODE_BEET is not set
29# CONFIG_INET_LRO is not set
30# CONFIG_INET_DIAG is not set 28# CONFIG_INET_DIAG is not set
31# CONFIG_IPV6 is not set 29# CONFIG_IPV6 is not set
32# CONFIG_WIRELESS is not set 30# CONFIG_WIRELESS is not set
33CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
34# CONFIG_MISC_DEVICES is not set
35# CONFIG_INPUT_MOUSEDEV is not set 32# CONFIG_INPUT_MOUSEDEV is not set
36# CONFIG_INPUT_KEYBOARD is not set 33# CONFIG_INPUT_KEYBOARD is not set
37# CONFIG_INPUT_MOUSE is not set 34# CONFIG_INPUT_MOUSE is not set
@@ -44,7 +41,6 @@ CONFIG_I2C=y
44CONFIG_I2C_SH_MOBILE=y 41CONFIG_I2C_SH_MOBILE=y
45CONFIG_GPIO_SYSFS=y 42CONFIG_GPIO_SYSFS=y
46# CONFIG_HWMON is not set 43# CONFIG_HWMON is not set
47# CONFIG_HID_SUPPORT is not set
48CONFIG_USB_GADGET=y 44CONFIG_USB_GADGET=y
49CONFIG_USB_CDC_COMPOSITE=y 45CONFIG_USB_CDC_COMPOSITE=y
50# CONFIG_DNOTIFY is not set 46# CONFIG_DNOTIFY is not set
@@ -55,5 +51,4 @@ CONFIG_TMPFS=y
55# CONFIG_NETWORK_FILESYSTEMS is not set 51# CONFIG_NETWORK_FILESYSTEMS is not set
56# CONFIG_ENABLE_MUST_CHECK is not set 52# CONFIG_ENABLE_MUST_CHECK is not set
57CONFIG_DEBUG_FS=y 53CONFIG_DEBUG_FS=y
58# CONFIG_RCU_CPU_STALL_DETECTOR is not set
59# CONFIG_CRC32 is not set 54# CONFIG_CRC32 is not set
diff --git a/arch/sh/configs/kfr2r09_defconfig b/arch/sh/configs/kfr2r09_defconfig
index fac13ded07b2..46693d033644 100644
--- a/arch/sh/configs/kfr2r09_defconfig
+++ b/arch/sh/configs/kfr2r09_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -33,15 +32,12 @@ CONFIG_INET=y
33# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 32# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
34# CONFIG_INET_XFRM_MODE_TUNNEL is not set 33# CONFIG_INET_XFRM_MODE_TUNNEL is not set
35# CONFIG_INET_XFRM_MODE_BEET is not set 34# CONFIG_INET_XFRM_MODE_BEET is not set
36# CONFIG_INET_LRO is not set
37# CONFIG_INET_DIAG is not set 35# CONFIG_INET_DIAG is not set
38# CONFIG_IPV6 is not set 36# CONFIG_IPV6 is not set
39# CONFIG_WIRELESS is not set 37# CONFIG_WIRELESS is not set
40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 38CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
41CONFIG_MTD=y 39CONFIG_MTD=y
42CONFIG_MTD_CONCAT=y
43CONFIG_MTD_CMDLINE_PARTS=y 40CONFIG_MTD_CMDLINE_PARTS=y
44CONFIG_MTD_CHAR=y
45CONFIG_MTD_BLOCK=y 41CONFIG_MTD_BLOCK=y
46CONFIG_MTD_CFI=y 42CONFIG_MTD_CFI=y
47CONFIG_MTD_CFI_INTELEXT=y 43CONFIG_MTD_CFI_INTELEXT=y
@@ -49,7 +45,6 @@ CONFIG_MTD_PHYSMAP=y
49CONFIG_MTD_ONENAND=y 45CONFIG_MTD_ONENAND=y
50CONFIG_MTD_ONENAND_GENERIC=y 46CONFIG_MTD_ONENAND_GENERIC=y
51CONFIG_MTD_UBI=y 47CONFIG_MTD_UBI=y
52# CONFIG_MISC_DEVICES is not set
53# CONFIG_INPUT_MOUSEDEV is not set 48# CONFIG_INPUT_MOUSEDEV is not set
54CONFIG_INPUT_EVDEV=y 49CONFIG_INPUT_EVDEV=y
55# CONFIG_KEYBOARD_ATKBD is not set 50# CONFIG_KEYBOARD_ATKBD is not set
@@ -77,7 +72,6 @@ CONFIG_LOGO=y
77# CONFIG_LOGO_LINUX_CLUT224 is not set 72# CONFIG_LOGO_LINUX_CLUT224 is not set
78# CONFIG_LOGO_SUPERH_MONO is not set 73# CONFIG_LOGO_SUPERH_MONO is not set
79# CONFIG_LOGO_SUPERH_CLUT224 is not set 74# CONFIG_LOGO_SUPERH_CLUT224 is not set
80# CONFIG_HID_SUPPORT is not set
81CONFIG_USB_GADGET=y 75CONFIG_USB_GADGET=y
82CONFIG_USB_CDC_COMPOSITE=m 76CONFIG_USB_CDC_COMPOSITE=m
83CONFIG_MMC=y 77CONFIG_MMC=y
@@ -91,4 +85,3 @@ CONFIG_TMPFS=y
91# CONFIG_NETWORK_FILESYSTEMS is not set 85# CONFIG_NETWORK_FILESYSTEMS is not set
92# CONFIG_ENABLE_MUST_CHECK is not set 86# CONFIG_ENABLE_MUST_CHECK is not set
93CONFIG_DEBUG_FS=y 87CONFIG_DEBUG_FS=y
94# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/sh/configs/landisk_defconfig b/arch/sh/configs/landisk_defconfig
index 6783f31315c7..467f4d2d8e87 100644
--- a/arch/sh/configs/landisk_defconfig
+++ b/arch/sh/configs/landisk_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_SYSCTL_SYSCALL is not set 3# CONFIG_SYSCTL_SYSCALL is not set
@@ -24,10 +23,8 @@ CONFIG_UNIX=y
24CONFIG_INET=y 23CONFIG_INET=y
25CONFIG_IP_ADVANCED_ROUTER=y 24CONFIG_IP_ADVANCED_ROUTER=y
26CONFIG_IP_PNP=y 25CONFIG_IP_PNP=y
27# CONFIG_INET_LRO is not set
28# CONFIG_IPV6 is not set 26# CONFIG_IPV6 is not set
29CONFIG_NETFILTER=y 27CONFIG_NETFILTER=y
30CONFIG_IP_NF_QUEUE=m
31CONFIG_ATALK=m 28CONFIG_ATALK=m
32CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
33CONFIG_BLK_DEV_LOOP=y 30CONFIG_BLK_DEV_LOOP=y
@@ -118,7 +115,6 @@ CONFIG_NFSD_V3=y
118CONFIG_SMB_FS=m 115CONFIG_SMB_FS=m
119CONFIG_NLS_CODEPAGE_437=y 116CONFIG_NLS_CODEPAGE_437=y
120CONFIG_NLS_CODEPAGE_932=y 117CONFIG_NLS_CODEPAGE_932=y
121# CONFIG_RCU_CPU_STALL_DETECTOR is not set
122CONFIG_SH_STANDARD_BIOS=y 118CONFIG_SH_STANDARD_BIOS=y
123# CONFIG_CRYPTO_ANSI_CPRNG is not set 119# CONFIG_CRYPTO_ANSI_CPRNG is not set
124CONFIG_CRC_T10DIF=y 120CONFIG_CRC_T10DIF=y
diff --git a/arch/sh/configs/lboxre2_defconfig b/arch/sh/configs/lboxre2_defconfig
index e3c0894b1bb4..9e3edfdf9b2e 100644
--- a/arch/sh/configs/lboxre2_defconfig
+++ b/arch/sh/configs/lboxre2_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_SYSCTL_SYSCALL is not set 3# CONFIG_SYSCTL_SYSCALL is not set
@@ -28,7 +27,6 @@ CONFIG_UNIX=y
28CONFIG_INET=y 27CONFIG_INET=y
29CONFIG_IP_ADVANCED_ROUTER=y 28CONFIG_IP_ADVANCED_ROUTER=y
30CONFIG_IP_PNP=y 29CONFIG_IP_PNP=y
31# CONFIG_INET_LRO is not set
32# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
33CONFIG_NETFILTER=y 31CONFIG_NETFILTER=y
34CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 32CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -61,7 +59,6 @@ CONFIG_VFAT_FS=y
61CONFIG_TMPFS=y 59CONFIG_TMPFS=y
62CONFIG_ROMFS_FS=y 60CONFIG_ROMFS_FS=y
63CONFIG_NLS_CODEPAGE_437=y 61CONFIG_NLS_CODEPAGE_437=y
64# CONFIG_RCU_CPU_STALL_DETECTOR is not set
65CONFIG_SH_STANDARD_BIOS=y 62CONFIG_SH_STANDARD_BIOS=y
66# CONFIG_CRYPTO_ANSI_CPRNG is not set 63# CONFIG_CRYPTO_ANSI_CPRNG is not set
67CONFIG_CRC_T10DIF=y 64CONFIG_CRC_T10DIF=y
diff --git a/arch/sh/configs/magicpanelr2_defconfig b/arch/sh/configs/magicpanelr2_defconfig
index 9479872b1ae6..fb7415dbc102 100644
--- a/arch/sh/configs/magicpanelr2_defconfig
+++ b/arch/sh/configs/magicpanelr2_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -35,16 +34,13 @@ CONFIG_IP_PNP_DHCP=y
35# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 34# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
36# CONFIG_INET_XFRM_MODE_TUNNEL is not set 35# CONFIG_INET_XFRM_MODE_TUNNEL is not set
37# CONFIG_INET_XFRM_MODE_BEET is not set 36# CONFIG_INET_XFRM_MODE_BEET is not set
38# CONFIG_INET_LRO is not set
39# CONFIG_IPV6 is not set 37# CONFIG_IPV6 is not set
40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 38CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
41# CONFIG_STANDALONE is not set 39# CONFIG_STANDALONE is not set
42# CONFIG_PREVENT_FIRMWARE_BUILD is not set 40# CONFIG_PREVENT_FIRMWARE_BUILD is not set
43CONFIG_MTD=y 41CONFIG_MTD=y
44CONFIG_MTD_PARTITIONS=y
45CONFIG_MTD_REDBOOT_PARTS=y 42CONFIG_MTD_REDBOOT_PARTS=y
46CONFIG_MTD_CMDLINE_PARTS=y 43CONFIG_MTD_CMDLINE_PARTS=y
47CONFIG_MTD_CHAR=y
48CONFIG_MTD_BLOCK=y 44CONFIG_MTD_BLOCK=y
49CONFIG_MTD_CFI=y 45CONFIG_MTD_CFI=y
50CONFIG_MTD_CFI_AMDSTD=y 46CONFIG_MTD_CFI_AMDSTD=y
@@ -55,8 +51,6 @@ CONFIG_NETDEVICES=y
55CONFIG_SMSC_PHY=y 51CONFIG_SMSC_PHY=y
56CONFIG_NET_ETHERNET=y 52CONFIG_NET_ETHERNET=y
57CONFIG_SMSC911X=y 53CONFIG_SMSC911X=y
58# CONFIG_NETDEV_1000 is not set
59# CONFIG_NETDEV_10000 is not set
60CONFIG_INPUT_EVDEV=y 54CONFIG_INPUT_EVDEV=y
61# CONFIG_MOUSE_PS2 is not set 55# CONFIG_MOUSE_PS2 is not set
62CONFIG_SERIAL_8250=y 56CONFIG_SERIAL_8250=y
@@ -68,7 +62,6 @@ CONFIG_SERIAL_SH_SCI=y
68CONFIG_SERIAL_SH_SCI_CONSOLE=y 62CONFIG_SERIAL_SH_SCI_CONSOLE=y
69# CONFIG_HW_RANDOM is not set 63# CONFIG_HW_RANDOM is not set
70# CONFIG_HWMON is not set 64# CONFIG_HWMON is not set
71# CONFIG_HID_SUPPORT is not set
72# CONFIG_USB_SUPPORT is not set 65# CONFIG_USB_SUPPORT is not set
73CONFIG_RTC_CLASS=y 66CONFIG_RTC_CLASS=y
74# CONFIG_RTC_HCTOSYS is not set 67# CONFIG_RTC_HCTOSYS is not set
@@ -96,7 +89,5 @@ CONFIG_DEBUG_KERNEL=y
96CONFIG_DEBUG_KOBJECT=y 89CONFIG_DEBUG_KOBJECT=y
97CONFIG_DEBUG_INFO=y 90CONFIG_DEBUG_INFO=y
98CONFIG_FRAME_POINTER=y 91CONFIG_FRAME_POINTER=y
99# CONFIG_RCU_CPU_STALL_DETECTOR is not set
100CONFIG_SYSCTL_SYSCALL_CHECK=y
101CONFIG_CRC_CCITT=m 92CONFIG_CRC_CCITT=m
102CONFIG_CRC16=m 93CONFIG_CRC16=m
diff --git a/arch/sh/configs/microdev_defconfig b/arch/sh/configs/microdev_defconfig
index f1d2e1b5ee41..c3f7d5899922 100644
--- a/arch/sh/configs/microdev_defconfig
+++ b/arch/sh/configs/microdev_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_BSD_PROCESS_ACCT=y 1CONFIG_BSD_PROCESS_ACCT=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y 3CONFIG_BLK_DEV_INITRD=y
@@ -19,7 +18,6 @@ CONFIG_SUPERHYWAY=y
19CONFIG_NET=y 18CONFIG_NET=y
20CONFIG_INET=y 19CONFIG_INET=y
21CONFIG_IP_PNP=y 20CONFIG_IP_PNP=y
22# CONFIG_INET_LRO is not set
23# CONFIG_IPV6 is not set 21# CONFIG_IPV6 is not set
24CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 22CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
25# CONFIG_FW_LOADER is not set 23# CONFIG_FW_LOADER is not set
@@ -45,6 +43,5 @@ CONFIG_NFS_FS=y
45CONFIG_NFS_V3=y 43CONFIG_NFS_V3=y
46CONFIG_NFS_V4=y 44CONFIG_NFS_V4=y
47CONFIG_ROOT_NFS=y 45CONFIG_ROOT_NFS=y
48# CONFIG_RCU_CPU_STALL_DETECTOR is not set
49CONFIG_CRYPTO_ECB=y 46CONFIG_CRYPTO_ECB=y
50# CONFIG_CRYPTO_ANSI_CPRNG is not set 47# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/migor_defconfig b/arch/sh/configs/migor_defconfig
index cc61eda44922..e04f21be0756 100644
--- a/arch/sh/configs/migor_defconfig
+++ b/arch/sh/configs/migor_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -26,15 +25,11 @@ CONFIG_UNIX=y
26CONFIG_INET=y 25CONFIG_INET=y
27CONFIG_IP_PNP=y 26CONFIG_IP_PNP=y
28CONFIG_IP_PNP_DHCP=y 27CONFIG_IP_PNP_DHCP=y
29# CONFIG_INET_LRO is not set
30# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
32CONFIG_FW_LOADER=m 30CONFIG_FW_LOADER=m
33CONFIG_MTD=y 31CONFIG_MTD=y
34CONFIG_MTD_CONCAT=y
35CONFIG_MTD_PARTITIONS=y
36CONFIG_MTD_CMDLINE_PARTS=y 32CONFIG_MTD_CMDLINE_PARTS=y
37CONFIG_MTD_CHAR=y
38CONFIG_MTD_BLOCK=y 33CONFIG_MTD_BLOCK=y
39CONFIG_MTD_CFI=y 34CONFIG_MTD_CFI=y
40CONFIG_MTD_CFI_AMDSTD=y 35CONFIG_MTD_CFI_AMDSTD=y
@@ -47,8 +42,6 @@ CONFIG_BLK_DEV_SD=y
47CONFIG_NETDEVICES=y 42CONFIG_NETDEVICES=y
48CONFIG_NET_ETHERNET=y 43CONFIG_NET_ETHERNET=y
49CONFIG_SMC91X=y 44CONFIG_SMC91X=y
50# CONFIG_NETDEV_1000 is not set
51# CONFIG_NETDEV_10000 is not set
52# CONFIG_INPUT_MOUSEDEV is not set 45# CONFIG_INPUT_MOUSEDEV is not set
53CONFIG_INPUT_EVDEV=y 46CONFIG_INPUT_EVDEV=y
54# CONFIG_KEYBOARD_ATKBD is not set 47# CONFIG_KEYBOARD_ATKBD is not set
@@ -101,7 +94,6 @@ CONFIG_TMPFS=y
101CONFIG_NFS_FS=y 94CONFIG_NFS_FS=y
102CONFIG_ROOT_NFS=y 95CONFIG_ROOT_NFS=y
103CONFIG_DEBUG_FS=y 96CONFIG_DEBUG_FS=y
104# CONFIG_RCU_CPU_STALL_DETECTOR is not set
105CONFIG_CRYPTO_MANAGER=y 97CONFIG_CRYPTO_MANAGER=y
106# CONFIG_CRYPTO_ANSI_CPRNG is not set 98# CONFIG_CRYPTO_ANSI_CPRNG is not set
107# CONFIG_CRYPTO_HW is not set 99# CONFIG_CRYPTO_HW is not set
diff --git a/arch/sh/configs/polaris_defconfig b/arch/sh/configs/polaris_defconfig
index f3d5d9f76310..0a432b5f50e7 100644
--- a/arch/sh/configs/polaris_defconfig
+++ b/arch/sh/configs/polaris_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
@@ -37,14 +36,11 @@ CONFIG_IP_MULTICAST=y
37# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 36# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
38# CONFIG_INET_XFRM_MODE_TUNNEL is not set 37# CONFIG_INET_XFRM_MODE_TUNNEL is not set
39# CONFIG_INET_XFRM_MODE_BEET is not set 38# CONFIG_INET_XFRM_MODE_BEET is not set
40# CONFIG_INET_LRO is not set
41# CONFIG_IPV6 is not set 39# CONFIG_IPV6 is not set
42CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
43# CONFIG_FIRMWARE_IN_KERNEL is not set 41# CONFIG_FIRMWARE_IN_KERNEL is not set
44CONFIG_MTD=y 42CONFIG_MTD=y
45CONFIG_MTD_PARTITIONS=y
46CONFIG_MTD_CMDLINE_PARTS=y 43CONFIG_MTD_CMDLINE_PARTS=y
47CONFIG_MTD_CHAR=y
48CONFIG_MTD_BLOCK=y 44CONFIG_MTD_BLOCK=y
49CONFIG_MTD_CFI=y 45CONFIG_MTD_CFI=y
50CONFIG_MTD_CFI_ADV_OPTIONS=y 46CONFIG_MTD_CFI_ADV_OPTIONS=y
@@ -57,8 +53,6 @@ CONFIG_NETDEVICES=y
57CONFIG_SMSC_PHY=y 53CONFIG_SMSC_PHY=y
58CONFIG_NET_ETHERNET=y 54CONFIG_NET_ETHERNET=y
59CONFIG_SMSC911X=y 55CONFIG_SMSC911X=y
60# CONFIG_NETDEV_1000 is not set
61# CONFIG_NETDEV_10000 is not set
62# CONFIG_INPUT_MOUSEDEV is not set 56# CONFIG_INPUT_MOUSEDEV is not set
63# CONFIG_INPUT_KEYBOARD is not set 57# CONFIG_INPUT_KEYBOARD is not set
64# CONFIG_INPUT_MOUSE is not set 58# CONFIG_INPUT_MOUSE is not set
@@ -71,7 +65,6 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
71# CONFIG_LEGACY_PTYS is not set 65# CONFIG_LEGACY_PTYS is not set
72# CONFIG_HW_RANDOM is not set 66# CONFIG_HW_RANDOM is not set
73# CONFIG_HWMON is not set 67# CONFIG_HWMON is not set
74# CONFIG_HID_SUPPORT is not set
75# CONFIG_USB_SUPPORT is not set 68# CONFIG_USB_SUPPORT is not set
76CONFIG_RTC_CLASS=y 69CONFIG_RTC_CLASS=y
77CONFIG_RTC_DRV_SH=y 70CONFIG_RTC_DRV_SH=y
@@ -91,5 +84,3 @@ CONFIG_DEBUG_LOCK_ALLOC=y
91CONFIG_DEBUG_SPINLOCK_SLEEP=y 84CONFIG_DEBUG_SPINLOCK_SLEEP=y
92CONFIG_DEBUG_INFO=y 85CONFIG_DEBUG_INFO=y
93CONFIG_DEBUG_SG=y 86CONFIG_DEBUG_SG=y
94# CONFIG_RCU_CPU_STALL_DETECTOR is not set
95CONFIG_SYSCTL_SYSCALL_CHECK=y
diff --git a/arch/sh/configs/r7780mp_defconfig b/arch/sh/configs/r7780mp_defconfig
index 920b8471ceb7..435bcd66c667 100644
--- a/arch/sh/configs/r7780mp_defconfig
+++ b/arch/sh/configs/r7780mp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -35,13 +34,11 @@ CONFIG_INET=y
35CONFIG_IP_ADVANCED_ROUTER=y 34CONFIG_IP_ADVANCED_ROUTER=y
36CONFIG_IP_PNP=y 35CONFIG_IP_PNP=y
37CONFIG_IP_PNP_DHCP=y 36CONFIG_IP_PNP_DHCP=y
38# CONFIG_INET_LRO is not set
39# CONFIG_IPV6 is not set 37# CONFIG_IPV6 is not set
40CONFIG_BRIDGE=m 38CONFIG_BRIDGE=m
41CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
42CONFIG_FW_LOADER=m 40CONFIG_FW_LOADER=m
43CONFIG_MTD=y 41CONFIG_MTD=y
44CONFIG_MTD_PARTITIONS=y
45CONFIG_MTD_CFI=y 42CONFIG_MTD_CFI=y
46CONFIG_MTD_CFI_AMDSTD=y 43CONFIG_MTD_CFI_AMDSTD=y
47CONFIG_MTD_COMPLEX_MAPPINGS=y 44CONFIG_MTD_COMPLEX_MAPPINGS=y
@@ -110,7 +107,6 @@ CONFIG_DEBUG_KERNEL=y
110CONFIG_DETECT_HUNG_TASK=y 107CONFIG_DETECT_HUNG_TASK=y
111# CONFIG_DEBUG_PREEMPT is not set 108# CONFIG_DEBUG_PREEMPT is not set
112CONFIG_DEBUG_INFO=y 109CONFIG_DEBUG_INFO=y
113# CONFIG_RCU_CPU_STALL_DETECTOR is not set
114CONFIG_CRYPTO_ECB=m 110CONFIG_CRYPTO_ECB=m
115CONFIG_CRYPTO_PCBC=m 111CONFIG_CRYPTO_PCBC=m
116CONFIG_CRYPTO_HMAC=y 112CONFIG_CRYPTO_HMAC=y
diff --git a/arch/sh/configs/r7785rp_defconfig b/arch/sh/configs/r7785rp_defconfig
index c77da6be06b8..5877e6d1f285 100644
--- a/arch/sh/configs/r7785rp_defconfig
+++ b/arch/sh/configs/r7785rp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -42,7 +41,6 @@ CONFIG_INET=y
42CONFIG_IP_ADVANCED_ROUTER=y 41CONFIG_IP_ADVANCED_ROUTER=y
43CONFIG_IP_PNP=y 42CONFIG_IP_PNP=y
44CONFIG_IP_PNP_DHCP=y 43CONFIG_IP_PNP_DHCP=y
45# CONFIG_INET_LRO is not set
46# CONFIG_IPV6 is not set 44# CONFIG_IPV6 is not set
47CONFIG_BRIDGE=m 45CONFIG_BRIDGE=m
48CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 46CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -104,7 +102,6 @@ CONFIG_DEBUG_KERNEL=y
104CONFIG_DEBUG_LOCK_ALLOC=y 102CONFIG_DEBUG_LOCK_ALLOC=y
105CONFIG_DEBUG_LOCKING_API_SELFTESTS=y 103CONFIG_DEBUG_LOCKING_API_SELFTESTS=y
106CONFIG_DEBUG_INFO=y 104CONFIG_DEBUG_INFO=y
107# CONFIG_RCU_CPU_STALL_DETECTOR is not set
108CONFIG_SH_STANDARD_BIOS=y 105CONFIG_SH_STANDARD_BIOS=y
109CONFIG_DEBUG_STACK_USAGE=y 106CONFIG_DEBUG_STACK_USAGE=y
110CONFIG_4KSTACKS=y 107CONFIG_4KSTACKS=y
diff --git a/arch/sh/configs/rsk7201_defconfig b/arch/sh/configs/rsk7201_defconfig
index 5df916d931c5..b195bc01e406 100644
--- a/arch/sh/configs/rsk7201_defconfig
+++ b/arch/sh/configs/rsk7201_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -37,10 +36,7 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
37# CONFIG_PREVENT_FIRMWARE_BUILD is not set 36# CONFIG_PREVENT_FIRMWARE_BUILD is not set
38# CONFIG_FW_LOADER is not set 37# CONFIG_FW_LOADER is not set
39CONFIG_MTD=y 38CONFIG_MTD=y
40CONFIG_MTD_CONCAT=y
41CONFIG_MTD_PARTITIONS=y
42CONFIG_MTD_REDBOOT_PARTS=y 39CONFIG_MTD_REDBOOT_PARTS=y
43CONFIG_MTD_CHAR=y
44CONFIG_MTD_BLOCK=y 40CONFIG_MTD_BLOCK=y
45CONFIG_MTD_CFI=y 41CONFIG_MTD_CFI=y
46CONFIG_MTD_CFI_AMDSTD=y 42CONFIG_MTD_CFI_AMDSTD=y
@@ -58,8 +54,6 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
58# CONFIG_HW_RANDOM is not set 54# CONFIG_HW_RANDOM is not set
59# CONFIG_HWMON is not set 55# CONFIG_HWMON is not set
60CONFIG_THERMAL=y 56CONFIG_THERMAL=y
61CONFIG_VIDEO_OUTPUT_CONTROL=y
62# CONFIG_HID_SUPPORT is not set
63# CONFIG_USB_SUPPORT is not set 57# CONFIG_USB_SUPPORT is not set
64CONFIG_RTC_CLASS=y 58CONFIG_RTC_CLASS=y
65CONFIG_RTC_DRV_SH=y 59CONFIG_RTC_DRV_SH=y
@@ -71,5 +65,3 @@ CONFIG_ROMFS_FS=y
71# CONFIG_ENABLE_MUST_CHECK is not set 65# CONFIG_ENABLE_MUST_CHECK is not set
72CONFIG_MAGIC_SYSRQ=y 66CONFIG_MAGIC_SYSRQ=y
73CONFIG_DEBUG_FS=y 67CONFIG_DEBUG_FS=y
74# CONFIG_RCU_CPU_STALL_DETECTOR is not set
75CONFIG_SYSCTL_SYSCALL_CHECK=y
diff --git a/arch/sh/configs/rsk7203_defconfig b/arch/sh/configs/rsk7203_defconfig
index 3c4f6f4d52b0..8c471959bbc7 100644
--- a/arch/sh/configs/rsk7203_defconfig
+++ b/arch/sh/configs/rsk7203_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -44,7 +43,6 @@ CONFIG_IP_PNP_DHCP=y
44# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 43# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
45# CONFIG_INET_XFRM_MODE_TUNNEL is not set 44# CONFIG_INET_XFRM_MODE_TUNNEL is not set
46# CONFIG_INET_XFRM_MODE_BEET is not set 45# CONFIG_INET_XFRM_MODE_BEET is not set
47# CONFIG_INET_LRO is not set
48# CONFIG_INET_DIAG is not set 46# CONFIG_INET_DIAG is not set
49# CONFIG_IPV6 is not set 47# CONFIG_IPV6 is not set
50CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 48CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -52,10 +50,7 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
52# CONFIG_PREVENT_FIRMWARE_BUILD is not set 50# CONFIG_PREVENT_FIRMWARE_BUILD is not set
53# CONFIG_FW_LOADER is not set 51# CONFIG_FW_LOADER is not set
54CONFIG_MTD=y 52CONFIG_MTD=y
55CONFIG_MTD_CONCAT=y
56CONFIG_MTD_PARTITIONS=y
57CONFIG_MTD_REDBOOT_PARTS=y 53CONFIG_MTD_REDBOOT_PARTS=y
58CONFIG_MTD_CHAR=y
59CONFIG_MTD_BLOCK=y 54CONFIG_MTD_BLOCK=y
60CONFIG_MTD_CFI=y 55CONFIG_MTD_CFI=y
61CONFIG_MTD_CFI_AMDSTD=y 56CONFIG_MTD_CFI_AMDSTD=y
@@ -64,8 +59,6 @@ CONFIG_NETDEVICES=y
64CONFIG_SMSC_PHY=y 59CONFIG_SMSC_PHY=y
65CONFIG_NET_ETHERNET=y 60CONFIG_NET_ETHERNET=y
66CONFIG_SMSC911X=y 61CONFIG_SMSC911X=y
67# CONFIG_NETDEV_1000 is not set
68# CONFIG_NETDEV_10000 is not set
69CONFIG_INPUT_FF_MEMLESS=m 62CONFIG_INPUT_FF_MEMLESS=m
70# CONFIG_INPUT_MOUSEDEV is not set 63# CONFIG_INPUT_MOUSEDEV is not set
71# CONFIG_INPUT_KEYBOARD is not set 64# CONFIG_INPUT_KEYBOARD is not set
@@ -81,7 +74,6 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
81# CONFIG_HWMON is not set 74# CONFIG_HWMON is not set
82CONFIG_THERMAL=y 75CONFIG_THERMAL=y
83CONFIG_REGULATOR=y 76CONFIG_REGULATOR=y
84CONFIG_VIDEO_OUTPUT_CONTROL=y
85CONFIG_HID_A4TECH=y 77CONFIG_HID_A4TECH=y
86CONFIG_HID_APPLE=y 78CONFIG_HID_APPLE=y
87CONFIG_HID_BELKIN=y 79CONFIG_HID_BELKIN=y
@@ -130,6 +122,4 @@ CONFIG_DEBUG_VM=y
130CONFIG_DEBUG_LIST=y 122CONFIG_DEBUG_LIST=y
131CONFIG_DEBUG_SG=y 123CONFIG_DEBUG_SG=y
132CONFIG_FRAME_POINTER=y 124CONFIG_FRAME_POINTER=y
133# CONFIG_RCU_CPU_STALL_DETECTOR is not set
134CONFIG_SYSCTL_SYSCALL_CHECK=y
135CONFIG_DEBUG_STACK_USAGE=y 125CONFIG_DEBUG_STACK_USAGE=y
diff --git a/arch/sh/configs/rsk7264_defconfig b/arch/sh/configs/rsk7264_defconfig
index eecdf65bb789..2b9b731fc86b 100644
--- a/arch/sh/configs/rsk7264_defconfig
+++ b/arch/sh/configs/rsk7264_defconfig
@@ -35,7 +35,6 @@ CONFIG_IP_PNP_DHCP=y
35# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 35# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
36# CONFIG_INET_XFRM_MODE_TUNNEL is not set 36# CONFIG_INET_XFRM_MODE_TUNNEL is not set
37# CONFIG_INET_XFRM_MODE_BEET is not set 37# CONFIG_INET_XFRM_MODE_BEET is not set
38# CONFIG_INET_LRO is not set
39# CONFIG_INET_DIAG is not set 38# CONFIG_INET_DIAG is not set
40# CONFIG_IPV6 is not set 39# CONFIG_IPV6 is not set
41CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -61,11 +60,9 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
61# CONFIG_HWMON is not set 60# CONFIG_HWMON is not set
62CONFIG_USB=y 61CONFIG_USB=y
63CONFIG_USB_ANNOUNCE_NEW_DEVICES=y 62CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
64# CONFIG_USB_DEVICE_CLASS is not set
65CONFIG_USB_R8A66597_HCD=y 63CONFIG_USB_R8A66597_HCD=y
66CONFIG_USB_STORAGE=y 64CONFIG_USB_STORAGE=y
67CONFIG_USB_STORAGE_DEBUG=y 65CONFIG_USB_STORAGE_DEBUG=y
68CONFIG_USB_LIBUSUAL=y
69CONFIG_EXT2_FS=y 66CONFIG_EXT2_FS=y
70CONFIG_EXT3_FS=y 67CONFIG_EXT3_FS=y
71# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 68# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/sh/configs/rsk7269_defconfig b/arch/sh/configs/rsk7269_defconfig
index 8370b10df357..d041f7bcb84c 100644
--- a/arch/sh/configs/rsk7269_defconfig
+++ b/arch/sh/configs/rsk7269_defconfig
@@ -24,7 +24,6 @@ CONFIG_IP_PNP_DHCP=y
24# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 24# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
25# CONFIG_INET_XFRM_MODE_TUNNEL is not set 25# CONFIG_INET_XFRM_MODE_TUNNEL is not set
26# CONFIG_INET_XFRM_MODE_BEET is not set 26# CONFIG_INET_XFRM_MODE_BEET is not set
27# CONFIG_INET_LRO is not set
28# CONFIG_INET_DIAG is not set 27# CONFIG_INET_DIAG is not set
29# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -44,11 +43,9 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
44# CONFIG_HWMON is not set 43# CONFIG_HWMON is not set
45CONFIG_USB=y 44CONFIG_USB=y
46CONFIG_USB_ANNOUNCE_NEW_DEVICES=y 45CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
47# CONFIG_USB_DEVICE_CLASS is not set
48CONFIG_USB_R8A66597_HCD=y 46CONFIG_USB_R8A66597_HCD=y
49CONFIG_USB_STORAGE=y 47CONFIG_USB_STORAGE=y
50CONFIG_USB_STORAGE_DEBUG=y 48CONFIG_USB_STORAGE_DEBUG=y
51CONFIG_USB_LIBUSUAL=y
52CONFIG_EXT2_FS=y 49CONFIG_EXT2_FS=y
53CONFIG_EXT3_FS=y 50CONFIG_EXT3_FS=y
54# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 51# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
@@ -60,5 +57,4 @@ CONFIG_PARTITION_ADVANCED=y
60CONFIG_NLS_CODEPAGE_437=y 57CONFIG_NLS_CODEPAGE_437=y
61CONFIG_NLS_ISO8859_1=y 58CONFIG_NLS_ISO8859_1=y
62# CONFIG_ENABLE_MUST_CHECK is not set 59# CONFIG_ENABLE_MUST_CHECK is not set
63CONFIG_SYSCTL_SYSCALL_CHECK=y
64# CONFIG_FTRACE is not set 60# CONFIG_FTRACE is not set
diff --git a/arch/sh/configs/rts7751r2d1_defconfig b/arch/sh/configs/rts7751r2d1_defconfig
index a3d081095ce2..379d673f5ce8 100644
--- a/arch/sh/configs/rts7751r2d1_defconfig
+++ b/arch/sh/configs/rts7751r2d1_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 3# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -22,7 +21,6 @@ CONFIG_NET=y
22CONFIG_PACKET=y 21CONFIG_PACKET=y
23CONFIG_UNIX=y 22CONFIG_UNIX=y
24CONFIG_INET=y 23CONFIG_INET=y
25# CONFIG_INET_LRO is not set
26# CONFIG_IPV6 is not set 24# CONFIG_IPV6 is not set
27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 25CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
28CONFIG_FW_LOADER=m 26CONFIG_FW_LOADER=m
@@ -48,7 +46,6 @@ CONFIG_HW_RANDOM=y
48CONFIG_SPI=y 46CONFIG_SPI=y
49CONFIG_SPI_SH_SCI=y 47CONFIG_SPI_SH_SCI=y
50CONFIG_MFD_SM501=y 48CONFIG_MFD_SM501=y
51CONFIG_VIDEO_OUTPUT_CONTROL=m
52CONFIG_FB=y 49CONFIG_FB=y
53CONFIG_FB_SH_MOBILE_LCDC=m 50CONFIG_FB_SH_MOBILE_LCDC=m
54CONFIG_FB_SM501=y 51CONFIG_FB_SM501=y
@@ -83,7 +80,6 @@ CONFIG_USB=y
83CONFIG_USB_ANNOUNCE_NEW_DEVICES=y 80CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
84CONFIG_USB_OHCI_HCD=y 81CONFIG_USB_OHCI_HCD=y
85CONFIG_USB_STORAGE=y 82CONFIG_USB_STORAGE=y
86CONFIG_USB_LIBUSUAL=y
87CONFIG_RTC_CLASS=y 83CONFIG_RTC_CLASS=y
88CONFIG_RTC_DRV_R9701=y 84CONFIG_RTC_DRV_R9701=y
89CONFIG_EXT2_FS=y 85CONFIG_EXT2_FS=y
@@ -94,6 +90,5 @@ CONFIG_TMPFS=y
94CONFIG_MINIX_FS=y 90CONFIG_MINIX_FS=y
95CONFIG_NLS_CODEPAGE_932=y 91CONFIG_NLS_CODEPAGE_932=y
96CONFIG_DEBUG_FS=y 92CONFIG_DEBUG_FS=y
97# CONFIG_RCU_CPU_STALL_DETECTOR is not set
98# CONFIG_CRYPTO_ANSI_CPRNG is not set 93# CONFIG_CRYPTO_ANSI_CPRNG is not set
99CONFIG_CRC_T10DIF=y 94CONFIG_CRC_T10DIF=y
diff --git a/arch/sh/configs/rts7751r2dplus_defconfig b/arch/sh/configs/rts7751r2dplus_defconfig
index b1a04f3c598b..11177bceda83 100644
--- a/arch/sh/configs/rts7751r2dplus_defconfig
+++ b/arch/sh/configs/rts7751r2dplus_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 3# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -22,15 +21,11 @@ CONFIG_NET=y
22CONFIG_PACKET=y 21CONFIG_PACKET=y
23CONFIG_UNIX=y 22CONFIG_UNIX=y
24CONFIG_INET=y 23CONFIG_INET=y
25# CONFIG_INET_LRO is not set
26# CONFIG_IPV6 is not set 24# CONFIG_IPV6 is not set
27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 25CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
28CONFIG_FW_LOADER=m 26CONFIG_FW_LOADER=m
29CONFIG_MTD=y 27CONFIG_MTD=y
30CONFIG_MTD_CONCAT=y
31CONFIG_MTD_PARTITIONS=y
32CONFIG_MTD_CMDLINE_PARTS=y 28CONFIG_MTD_CMDLINE_PARTS=y
33CONFIG_MTD_CHAR=y
34CONFIG_MTD_CFI=y 29CONFIG_MTD_CFI=y
35CONFIG_MTD_CFI_AMDSTD=y 30CONFIG_MTD_CFI_AMDSTD=y
36CONFIG_MTD_PHYSMAP=y 31CONFIG_MTD_PHYSMAP=y
@@ -56,7 +51,6 @@ CONFIG_HW_RANDOM=y
56CONFIG_SPI=y 51CONFIG_SPI=y
57CONFIG_SPI_SH_SCI=y 52CONFIG_SPI_SH_SCI=y
58CONFIG_MFD_SM501=y 53CONFIG_MFD_SM501=y
59CONFIG_VIDEO_OUTPUT_CONTROL=m
60CONFIG_FB=y 54CONFIG_FB=y
61CONFIG_FB_SH_MOBILE_LCDC=m 55CONFIG_FB_SH_MOBILE_LCDC=m
62CONFIG_FB_SM501=y 56CONFIG_FB_SM501=y
@@ -91,7 +85,6 @@ CONFIG_USB=y
91CONFIG_USB_ANNOUNCE_NEW_DEVICES=y 85CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
92CONFIG_USB_OHCI_HCD=y 86CONFIG_USB_OHCI_HCD=y
93CONFIG_USB_STORAGE=y 87CONFIG_USB_STORAGE=y
94CONFIG_USB_LIBUSUAL=y
95CONFIG_RTC_CLASS=y 88CONFIG_RTC_CLASS=y
96CONFIG_RTC_DRV_R9701=y 89CONFIG_RTC_DRV_R9701=y
97CONFIG_EXT2_FS=y 90CONFIG_EXT2_FS=y
@@ -102,6 +95,5 @@ CONFIG_TMPFS=y
102CONFIG_MINIX_FS=y 95CONFIG_MINIX_FS=y
103CONFIG_NLS_CODEPAGE_932=y 96CONFIG_NLS_CODEPAGE_932=y
104CONFIG_DEBUG_FS=y 97CONFIG_DEBUG_FS=y
105# CONFIG_RCU_CPU_STALL_DETECTOR is not set
106# CONFIG_CRYPTO_ANSI_CPRNG is not set 98# CONFIG_CRYPTO_ANSI_CPRNG is not set
107CONFIG_CRC_T10DIF=y 99CONFIG_CRC_T10DIF=y
diff --git a/arch/sh/configs/sdk7780_defconfig b/arch/sh/configs/sdk7780_defconfig
index bbd4c2298708..95e5208b8260 100644
--- a/arch/sh/configs/sdk7780_defconfig
+++ b/arch/sh/configs/sdk7780_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_LOCALVERSION="_SDK7780" 1CONFIG_LOCALVERSION="_SDK7780"
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -39,7 +38,6 @@ CONFIG_IP_ADVANCED_ROUTER=y
39CONFIG_IP_PNP=y 38CONFIG_IP_PNP=y
40CONFIG_IP_PNP_BOOTP=y 39CONFIG_IP_PNP_BOOTP=y
41# CONFIG_INET_XFRM_MODE_BEET is not set 40# CONFIG_INET_XFRM_MODE_BEET is not set
42# CONFIG_INET_LRO is not set
43CONFIG_IPV6=y 41CONFIG_IPV6=y
44# CONFIG_INET6_XFRM_MODE_BEET is not set 42# CONFIG_INET6_XFRM_MODE_BEET is not set
45CONFIG_NET_SCHED=y 43CONFIG_NET_SCHED=y
@@ -47,7 +45,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
47CONFIG_PARPORT=y 45CONFIG_PARPORT=y
48CONFIG_BLK_DEV_LOOP=y 46CONFIG_BLK_DEV_LOOP=y
49CONFIG_BLK_DEV_RAM=y 47CONFIG_BLK_DEV_RAM=y
50# CONFIG_MISC_DEVICES is not set
51CONFIG_IDE=y 48CONFIG_IDE=y
52CONFIG_BLK_DEV_IDECD=y 49CONFIG_BLK_DEV_IDECD=y
53CONFIG_BLK_DEV_PLATFORM=y 50CONFIG_BLK_DEV_PLATFORM=y
@@ -63,8 +60,6 @@ CONFIG_BLK_DEV_DM=y
63CONFIG_NETDEVICES=y 60CONFIG_NETDEVICES=y
64CONFIG_NET_ETHERNET=y 61CONFIG_NET_ETHERNET=y
65CONFIG_SMC91X=y 62CONFIG_SMC91X=y
66# CONFIG_NETDEV_1000 is not set
67# CONFIG_NETDEV_10000 is not set
68CONFIG_NETCONSOLE=y 63CONFIG_NETCONSOLE=y
69CONFIG_INPUT_FF_MEMLESS=m 64CONFIG_INPUT_FF_MEMLESS=m
70CONFIG_INPUT_EVDEV=y 65CONFIG_INPUT_EVDEV=y
@@ -78,7 +73,6 @@ CONFIG_SSB=y
78CONFIG_SSB_DRIVER_PCICORE=y 73CONFIG_SSB_DRIVER_PCICORE=y
79CONFIG_FB=y 74CONFIG_FB=y
80CONFIG_FB_SH_MOBILE_LCDC=m 75CONFIG_FB_SH_MOBILE_LCDC=m
81CONFIG_DISPLAY_SUPPORT=y
82CONFIG_FRAMEBUFFER_CONSOLE=y 76CONFIG_FRAMEBUFFER_CONSOLE=y
83CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y 77CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
84CONFIG_LOGO=y 78CONFIG_LOGO=y
@@ -101,7 +95,6 @@ CONFIG_HID_SAMSUNG=y
101CONFIG_HID_SONY=y 95CONFIG_HID_SONY=y
102CONFIG_HID_SUNPLUS=y 96CONFIG_HID_SUNPLUS=y
103CONFIG_USB=y 97CONFIG_USB=y
104# CONFIG_USB_DEVICE_CLASS is not set
105CONFIG_USB_MON=y 98CONFIG_USB_MON=y
106CONFIG_USB_EHCI_HCD=y 99CONFIG_USB_EHCI_HCD=y
107# CONFIG_USB_EHCI_TT_NEWSCHED is not set 100# CONFIG_USB_EHCI_TT_NEWSCHED is not set
@@ -144,8 +137,6 @@ CONFIG_DETECT_HUNG_TASK=y
144# CONFIG_SCHED_DEBUG is not set 137# CONFIG_SCHED_DEBUG is not set
145CONFIG_TIMER_STATS=y 138CONFIG_TIMER_STATS=y
146CONFIG_DEBUG_INFO=y 139CONFIG_DEBUG_INFO=y
147# CONFIG_RCU_CPU_STALL_DETECTOR is not set
148CONFIG_SYSCTL_SYSCALL_CHECK=y
149CONFIG_SH_STANDARD_BIOS=y 140CONFIG_SH_STANDARD_BIOS=y
150CONFIG_CRYPTO_MD5=y 141CONFIG_CRYPTO_MD5=y
151CONFIG_CRYPTO_DES=y 142CONFIG_CRYPTO_DES=y
diff --git a/arch/sh/configs/sdk7786_defconfig b/arch/sh/configs/sdk7786_defconfig
index 36642ec2cb97..e9ee0c878ead 100644
--- a/arch/sh/configs/sdk7786_defconfig
+++ b/arch/sh/configs/sdk7786_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_KERNEL_LZO=y 1CONFIG_KERNEL_LZO=y
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -90,13 +89,11 @@ CONFIG_NET_KEY=y
90CONFIG_INET=y 89CONFIG_INET=y
91CONFIG_IP_PNP=y 90CONFIG_IP_PNP=y
92CONFIG_IP_PNP_DHCP=y 91CONFIG_IP_PNP_DHCP=y
93# CONFIG_INET_LRO is not set
94# CONFIG_IPV6 is not set 92# CONFIG_IPV6 is not set
95# CONFIG_WIRELESS is not set 93# CONFIG_WIRELESS is not set
96CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 94CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
97# CONFIG_FW_LOADER is not set 95# CONFIG_FW_LOADER is not set
98CONFIG_MTD=y 96CONFIG_MTD=y
99CONFIG_MTD_PARTITIONS=y
100CONFIG_MTD_CMDLINE_PARTS=y 97CONFIG_MTD_CMDLINE_PARTS=y
101CONFIG_MTD_BLOCK=y 98CONFIG_MTD_BLOCK=y
102CONFIG_FTL=y 99CONFIG_FTL=y
@@ -119,7 +116,6 @@ CONFIG_MTD_UBI_GLUEBI=m
119CONFIG_BLK_DEV_LOOP=y 116CONFIG_BLK_DEV_LOOP=y
120CONFIG_BLK_DEV_CRYPTOLOOP=y 117CONFIG_BLK_DEV_CRYPTOLOOP=y
121CONFIG_BLK_DEV_RAM=y 118CONFIG_BLK_DEV_RAM=y
122# CONFIG_MISC_DEVICES is not set
123CONFIG_IDE=y 119CONFIG_IDE=y
124CONFIG_BLK_DEV_IDECD=y 120CONFIG_BLK_DEV_IDECD=y
125CONFIG_BLK_DEV_PLATFORM=y 121CONFIG_BLK_DEV_PLATFORM=y
@@ -140,8 +136,6 @@ CONFIG_MDIO_BITBANG=y
140CONFIG_NET_ETHERNET=y 136CONFIG_NET_ETHERNET=y
141CONFIG_SMC91X=y 137CONFIG_SMC91X=y
142CONFIG_SMSC911X=y 138CONFIG_SMSC911X=y
143# CONFIG_NETDEV_1000 is not set
144# CONFIG_NETDEV_10000 is not set
145# CONFIG_WLAN is not set 139# CONFIG_WLAN is not set
146CONFIG_VT_HW_CONSOLE_BINDING=y 140CONFIG_VT_HW_CONSOLE_BINDING=y
147CONFIG_SERIAL_SH_SCI=y 141CONFIG_SERIAL_SH_SCI=y
@@ -157,7 +151,6 @@ CONFIG_SPI=y
157# CONFIG_HWMON is not set 151# CONFIG_HWMON is not set
158CONFIG_WATCHDOG=y 152CONFIG_WATCHDOG=y
159CONFIG_SH_WDT=y 153CONFIG_SH_WDT=y
160CONFIG_VIDEO_OUTPUT_CONTROL=m
161CONFIG_USB=y 154CONFIG_USB=y
162CONFIG_USB_MON=y 155CONFIG_USB_MON=y
163CONFIG_USB_OHCI_HCD=y 156CONFIG_USB_OHCI_HCD=y
@@ -223,9 +216,7 @@ CONFIG_DEBUG_KERNEL=y
223CONFIG_DETECT_HUNG_TASK=y 216CONFIG_DETECT_HUNG_TASK=y
224CONFIG_TIMER_STATS=y 217CONFIG_TIMER_STATS=y
225CONFIG_DEBUG_MEMORY_INIT=y 218CONFIG_DEBUG_MEMORY_INIT=y
226# CONFIG_RCU_CPU_STALL_VERBOSE is not set
227CONFIG_LATENCYTOP=y 219CONFIG_LATENCYTOP=y
228CONFIG_SYSCTL_SYSCALL_CHECK=y
229CONFIG_FUNCTION_TRACER=y 220CONFIG_FUNCTION_TRACER=y
230# CONFIG_FUNCTION_GRAPH_TRACER is not set 221# CONFIG_FUNCTION_GRAPH_TRACER is not set
231CONFIG_DMA_API_DEBUG=y 222CONFIG_DMA_API_DEBUG=y
diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig
index 91853a67ec34..3553acd5edb1 100644
--- a/arch/sh/configs/se7206_defconfig
+++ b/arch/sh/configs/se7206_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -57,7 +56,6 @@ CONFIG_IP_PNP_DHCP=y
57# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 56# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
58# CONFIG_INET_XFRM_MODE_TUNNEL is not set 57# CONFIG_INET_XFRM_MODE_TUNNEL is not set
59# CONFIG_INET_XFRM_MODE_BEET is not set 58# CONFIG_INET_XFRM_MODE_BEET is not set
60# CONFIG_INET_LRO is not set
61# CONFIG_INET_DIAG is not set 59# CONFIG_INET_DIAG is not set
62# CONFIG_IPV6 is not set 60# CONFIG_IPV6 is not set
63CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 61CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -65,9 +63,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
65# CONFIG_PREVENT_FIRMWARE_BUILD is not set 63# CONFIG_PREVENT_FIRMWARE_BUILD is not set
66# CONFIG_FW_LOADER is not set 64# CONFIG_FW_LOADER is not set
67CONFIG_MTD=y 65CONFIG_MTD=y
68CONFIG_MTD_CONCAT=y
69CONFIG_MTD_PARTITIONS=y
70CONFIG_MTD_CHAR=y
71CONFIG_MTD_BLOCK=y 66CONFIG_MTD_BLOCK=y
72CONFIG_MTD_CFI=y 67CONFIG_MTD_CFI=y
73CONFIG_MTD_CFI_AMDSTD=y 68CONFIG_MTD_CFI_AMDSTD=y
@@ -78,8 +73,6 @@ CONFIG_EEPROM_93CX6=y
78CONFIG_NETDEVICES=y 73CONFIG_NETDEVICES=y
79CONFIG_NET_ETHERNET=y 74CONFIG_NET_ETHERNET=y
80CONFIG_SMC91X=y 75CONFIG_SMC91X=y
81# CONFIG_NETDEV_1000 is not set
82# CONFIG_NETDEV_10000 is not set
83# CONFIG_INPUT is not set 76# CONFIG_INPUT is not set
84# CONFIG_SERIO is not set 77# CONFIG_SERIO is not set
85# CONFIG_VT is not set 78# CONFIG_VT is not set
@@ -109,7 +102,6 @@ CONFIG_DEBUG_SPINLOCK_SLEEP=y
109CONFIG_DEBUG_VM=y 102CONFIG_DEBUG_VM=y
110CONFIG_DEBUG_LIST=y 103CONFIG_DEBUG_LIST=y
111CONFIG_FRAME_POINTER=y 104CONFIG_FRAME_POINTER=y
112# CONFIG_RCU_CPU_STALL_DETECTOR is not set
113CONFIG_DEBUG_STACK_USAGE=y 105CONFIG_DEBUG_STACK_USAGE=y
114CONFIG_CRYPTO_DEFLATE=y 106CONFIG_CRYPTO_DEFLATE=y
115CONFIG_CRYPTO_LZO=y 107CONFIG_CRYPTO_LZO=y
diff --git a/arch/sh/configs/se7343_defconfig b/arch/sh/configs/se7343_defconfig
index 201acb4652f7..fc77a67b16e7 100644
--- a/arch/sh/configs/se7343_defconfig
+++ b/arch/sh/configs/se7343_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -27,26 +26,19 @@ CONFIG_PACKET=y
27CONFIG_UNIX=y 26CONFIG_UNIX=y
28CONFIG_INET=y 27CONFIG_INET=y
29CONFIG_SYN_COOKIES=y 28CONFIG_SYN_COOKIES=y
30# CONFIG_INET_LRO is not set
31# CONFIG_INET_DIAG is not set 29# CONFIG_INET_DIAG is not set
32# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
33CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
34CONFIG_MTD=y 32CONFIG_MTD=y
35CONFIG_MTD_CONCAT=y
36CONFIG_MTD_PARTITIONS=y
37CONFIG_MTD_CHAR=y
38CONFIG_MTD_BLOCK=y 33CONFIG_MTD_BLOCK=y
39CONFIG_MTD_CFI=y 34CONFIG_MTD_CFI=y
40CONFIG_MTD_CFI_AMDSTD=y 35CONFIG_MTD_CFI_AMDSTD=y
41CONFIG_MTD_RAM=y 36CONFIG_MTD_RAM=y
42CONFIG_MTD_PHYSMAP=y 37CONFIG_MTD_PHYSMAP=y
43# CONFIG_MISC_DEVICES is not set
44CONFIG_SCSI=y 38CONFIG_SCSI=y
45CONFIG_SCSI_MULTI_LUN=y 39CONFIG_SCSI_MULTI_LUN=y
46# CONFIG_SCSI_LOWLEVEL is not set 40# CONFIG_SCSI_LOWLEVEL is not set
47CONFIG_NETDEVICES=y 41CONFIG_NETDEVICES=y
48# CONFIG_NETDEV_1000 is not set
49# CONFIG_NETDEV_10000 is not set
50CONFIG_USB_USBNET=y 42CONFIG_USB_USBNET=y
51# CONFIG_USB_NET_AX8817X is not set 43# CONFIG_USB_NET_AX8817X is not set
52CONFIG_USB_NET_DM9601=y 44CONFIG_USB_NET_DM9601=y
@@ -104,5 +96,4 @@ CONFIG_CRAMFS=y
104CONFIG_NFS_FS=y 96CONFIG_NFS_FS=y
105CONFIG_NFS_V3=y 97CONFIG_NFS_V3=y
106CONFIG_NFSD=y 98CONFIG_NFSD=y
107# CONFIG_RCU_CPU_STALL_DETECTOR is not set
108# CONFIG_CRYPTO_ANSI_CPRNG is not set 99# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7619_defconfig b/arch/sh/configs/se7619_defconfig
index 9a9ad9adf959..f54722dbc8f5 100644
--- a/arch/sh/configs/se7619_defconfig
+++ b/arch/sh/configs/se7619_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_UID16 is not set 3# CONFIG_UID16 is not set
@@ -24,10 +23,7 @@ CONFIG_BINFMT_ZFLAT=y
24# CONFIG_STANDALONE is not set 23# CONFIG_STANDALONE is not set
25# CONFIG_PREVENT_FIRMWARE_BUILD is not set 24# CONFIG_PREVENT_FIRMWARE_BUILD is not set
26CONFIG_MTD=y 25CONFIG_MTD=y
27CONFIG_MTD_CONCAT=y
28CONFIG_MTD_PARTITIONS=y
29CONFIG_MTD_REDBOOT_PARTS=y 26CONFIG_MTD_REDBOOT_PARTS=y
30CONFIG_MTD_CHAR=y
31CONFIG_MTD_BLOCK=y 27CONFIG_MTD_BLOCK=y
32CONFIG_MTD_CFI=y 28CONFIG_MTD_CFI=y
33CONFIG_MTD_CFI_AMDSTD=y 29CONFIG_MTD_CFI_AMDSTD=y
@@ -48,4 +44,3 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
48# CONFIG_SYSFS is not set 44# CONFIG_SYSFS is not set
49CONFIG_ROMFS_FS=y 45CONFIG_ROMFS_FS=y
50# CONFIG_ENABLE_MUST_CHECK is not set 46# CONFIG_ENABLE_MUST_CHECK is not set
51# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/sh/configs/se7705_defconfig b/arch/sh/configs/se7705_defconfig
index 044e0844fda1..ddfc69841955 100644
--- a/arch/sh/configs/se7705_defconfig
+++ b/arch/sh/configs/se7705_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y 3CONFIG_BLK_DEV_INITRD=y
@@ -27,11 +26,8 @@ CONFIG_IP_PNP=y
27CONFIG_IP_PNP_DHCP=y 26CONFIG_IP_PNP_DHCP=y
28CONFIG_IP_PNP_BOOTP=y 27CONFIG_IP_PNP_BOOTP=y
29CONFIG_IP_PNP_RARP=y 28CONFIG_IP_PNP_RARP=y
30# CONFIG_INET_LRO is not set
31# CONFIG_IPV6 is not set 29# CONFIG_IPV6 is not set
32CONFIG_MTD=y 30CONFIG_MTD=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_CHAR=y
35CONFIG_MTD_BLOCK=y 31CONFIG_MTD_BLOCK=y
36CONFIG_MTD_CFI=y 32CONFIG_MTD_CFI=y
37CONFIG_MTD_CFI_AMDSTD=y 33CONFIG_MTD_CFI_AMDSTD=y
@@ -58,5 +54,4 @@ CONFIG_PROC_KCORE=y
58CONFIG_JFFS2_FS=y 54CONFIG_JFFS2_FS=y
59CONFIG_NFS_FS=y 55CONFIG_NFS_FS=y
60CONFIG_ROOT_NFS=y 56CONFIG_ROOT_NFS=y
61# CONFIG_RCU_CPU_STALL_DETECTOR is not set
62# CONFIG_CRYPTO_ANSI_CPRNG is not set 57# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7712_defconfig b/arch/sh/configs/se7712_defconfig
index 1248635e4f88..5a1097641247 100644
--- a/arch/sh/configs/se7712_defconfig
+++ b/arch/sh/configs/se7712_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
@@ -47,7 +46,6 @@ CONFIG_SYN_COOKIES=y
47CONFIG_INET_AH=y 46CONFIG_INET_AH=y
48CONFIG_INET_ESP=y 47CONFIG_INET_ESP=y
49CONFIG_INET_IPCOMP=y 48CONFIG_INET_IPCOMP=y
50# CONFIG_INET_LRO is not set
51# CONFIG_INET_DIAG is not set 49# CONFIG_INET_DIAG is not set
52# CONFIG_IPV6 is not set 50# CONFIG_IPV6 is not set
53CONFIG_NET_SCHED=y 51CONFIG_NET_SCHED=y
@@ -68,9 +66,6 @@ CONFIG_NET_CLS_FW=y
68CONFIG_NET_CLS_IND=y 66CONFIG_NET_CLS_IND=y
69CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 67CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
70CONFIG_MTD=y 68CONFIG_MTD=y
71CONFIG_MTD_CONCAT=y
72CONFIG_MTD_PARTITIONS=y
73CONFIG_MTD_CHAR=y
74CONFIG_MTD_BLOCK=y 69CONFIG_MTD_BLOCK=y
75CONFIG_MTD_CFI=y 70CONFIG_MTD_CFI=y
76CONFIG_MTD_CFI_AMDSTD=y 71CONFIG_MTD_CFI_AMDSTD=y
@@ -104,8 +99,6 @@ CONFIG_ROOT_NFS=y
104CONFIG_DEBUG_KERNEL=y 99CONFIG_DEBUG_KERNEL=y
105CONFIG_DEBUG_INFO=y 100CONFIG_DEBUG_INFO=y
106CONFIG_FRAME_POINTER=y 101CONFIG_FRAME_POINTER=y
107# CONFIG_RCU_CPU_STALL_DETECTOR is not set
108CONFIG_SYSCTL_SYSCALL_CHECK=y
109CONFIG_CRYPTO_ECB=m 102CONFIG_CRYPTO_ECB=m
110CONFIG_CRYPTO_PCBC=m 103CONFIG_CRYPTO_PCBC=m
111# CONFIG_CRYPTO_ANSI_CPRNG is not set 104# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7721_defconfig b/arch/sh/configs/se7721_defconfig
index c3ba6e8a9818..9c0ef13bee10 100644
--- a/arch/sh/configs/se7721_defconfig
+++ b/arch/sh/configs/se7721_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
@@ -46,7 +45,6 @@ CONFIG_SYN_COOKIES=y
46CONFIG_INET_AH=y 45CONFIG_INET_AH=y
47CONFIG_INET_ESP=y 46CONFIG_INET_ESP=y
48CONFIG_INET_IPCOMP=y 47CONFIG_INET_IPCOMP=y
49# CONFIG_INET_LRO is not set
50# CONFIG_INET_DIAG is not set 48# CONFIG_INET_DIAG is not set
51# CONFIG_IPV6 is not set 49# CONFIG_IPV6 is not set
52CONFIG_NET_SCHED=y 50CONFIG_NET_SCHED=y
@@ -67,9 +65,6 @@ CONFIG_NET_CLS_FW=y
67CONFIG_NET_CLS_IND=y 65CONFIG_NET_CLS_IND=y
68CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 66CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
69CONFIG_MTD=y 67CONFIG_MTD=y
70CONFIG_MTD_CONCAT=y
71CONFIG_MTD_PARTITIONS=y
72CONFIG_MTD_CHAR=y
73CONFIG_MTD_BLOCK=y 68CONFIG_MTD_BLOCK=y
74CONFIG_MTD_CFI=y 69CONFIG_MTD_CFI=y
75CONFIG_MTD_CFI_AMDSTD=y 70CONFIG_MTD_CFI_AMDSTD=y
@@ -132,6 +127,5 @@ CONFIG_NLS_ISO8859_1=y
132CONFIG_DEBUG_KERNEL=y 127CONFIG_DEBUG_KERNEL=y
133CONFIG_DEBUG_INFO=y 128CONFIG_DEBUG_INFO=y
134CONFIG_FRAME_POINTER=y 129CONFIG_FRAME_POINTER=y
135# CONFIG_RCU_CPU_STALL_DETECTOR is not set
136# CONFIG_CRYPTO_ANSI_CPRNG is not set 130# CONFIG_CRYPTO_ANSI_CPRNG is not set
137CONFIG_CRC_CCITT=y 131CONFIG_CRC_CCITT=y
diff --git a/arch/sh/configs/se7722_defconfig b/arch/sh/configs/se7722_defconfig
index ae998c7e2ee0..ccc7fc423fde 100644
--- a/arch/sh/configs/se7722_defconfig
+++ b/arch/sh/configs/se7722_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -26,7 +25,6 @@ CONFIG_NET=y
26CONFIG_PACKET=y 25CONFIG_PACKET=y
27CONFIG_UNIX=y 26CONFIG_UNIX=y
28CONFIG_INET=y 27CONFIG_INET=y
29# CONFIG_INET_LRO is not set
30# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
32# CONFIG_FW_LOADER is not set 30# CONFIG_FW_LOADER is not set
@@ -57,6 +55,5 @@ CONFIG_PRINTK_TIME=y
57# CONFIG_ENABLE_MUST_CHECK is not set 55# CONFIG_ENABLE_MUST_CHECK is not set
58CONFIG_MAGIC_SYSRQ=y 56CONFIG_MAGIC_SYSRQ=y
59CONFIG_DEBUG_FS=y 57CONFIG_DEBUG_FS=y
60# CONFIG_RCU_CPU_STALL_DETECTOR is not set
61CONFIG_SH_STANDARD_BIOS=y 58CONFIG_SH_STANDARD_BIOS=y
62# CONFIG_CRYPTO_ANSI_CPRNG is not set 59# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7724_defconfig b/arch/sh/configs/se7724_defconfig
index 1faa788aecae..aedb3a2d9a10 100644
--- a/arch/sh/configs/se7724_defconfig
+++ b/arch/sh/configs/se7724_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -30,14 +29,10 @@ CONFIG_IP_PNP_DHCP=y
30# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 29# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
31# CONFIG_INET_XFRM_MODE_TUNNEL is not set 30# CONFIG_INET_XFRM_MODE_TUNNEL is not set
32# CONFIG_INET_XFRM_MODE_BEET is not set 31# CONFIG_INET_XFRM_MODE_BEET is not set
33# CONFIG_INET_LRO is not set
34# CONFIG_IPV6 is not set 32# CONFIG_IPV6 is not set
35CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 33CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
36CONFIG_MTD=y 34CONFIG_MTD=y
37CONFIG_MTD_CONCAT=y
38CONFIG_MTD_PARTITIONS=y
39CONFIG_MTD_CMDLINE_PARTS=y 35CONFIG_MTD_CMDLINE_PARTS=y
40CONFIG_MTD_CHAR=y
41CONFIG_MTD_BLOCK=y 36CONFIG_MTD_BLOCK=y
42CONFIG_MTD_CFI=y 37CONFIG_MTD_CFI=y
43CONFIG_MTD_CFI_AMDSTD=y 38CONFIG_MTD_CFI_AMDSTD=y
@@ -53,8 +48,6 @@ CONFIG_SMSC_PHY=y
53CONFIG_NET_ETHERNET=y 48CONFIG_NET_ETHERNET=y
54CONFIG_SH_ETH=y 49CONFIG_SH_ETH=y
55CONFIG_SMC91X=y 50CONFIG_SMC91X=y
56# CONFIG_NETDEV_1000 is not set
57# CONFIG_NETDEV_10000 is not set
58# CONFIG_INPUT_MOUSEDEV is not set 51# CONFIG_INPUT_MOUSEDEV is not set
59CONFIG_INPUT_EVDEV=y 52CONFIG_INPUT_EVDEV=y
60# CONFIG_KEYBOARD_ATKBD is not set 53# CONFIG_KEYBOARD_ATKBD is not set
@@ -137,8 +130,6 @@ CONFIG_NLS_CODEPAGE_437=y
137CONFIG_NLS_CODEPAGE_932=y 130CONFIG_NLS_CODEPAGE_932=y
138CONFIG_NLS_ISO8859_1=y 131CONFIG_NLS_ISO8859_1=y
139# CONFIG_ENABLE_MUST_CHECK is not set 132# CONFIG_ENABLE_MUST_CHECK is not set
140# CONFIG_RCU_CPU_STALL_DETECTOR is not set
141CONFIG_SYSCTL_SYSCALL_CHECK=y
142CONFIG_CRYPTO=y 133CONFIG_CRYPTO=y
143CONFIG_CRYPTO_CBC=y 134CONFIG_CRYPTO_CBC=y
144# CONFIG_CRYPTO_ANSI_CPRNG is not set 135# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7750_defconfig b/arch/sh/configs/se7750_defconfig
index 912c98590e22..b23f67542728 100644
--- a/arch/sh/configs/se7750_defconfig
+++ b/arch/sh/configs/se7750_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -25,11 +24,8 @@ CONFIG_INET=y
25CONFIG_IP_MULTICAST=y 24CONFIG_IP_MULTICAST=y
26CONFIG_IP_PNP=y 25CONFIG_IP_PNP=y
27CONFIG_IP_PNP_BOOTP=y 26CONFIG_IP_PNP_BOOTP=y
28# CONFIG_INET_LRO is not set
29# CONFIG_IPV6 is not set 27# CONFIG_IPV6 is not set
30CONFIG_MTD=y 28CONFIG_MTD=y
31CONFIG_MTD_PARTITIONS=y
32CONFIG_MTD_CHAR=y
33CONFIG_MTD_BLOCK=y 29CONFIG_MTD_BLOCK=y
34CONFIG_MTD_CFI=y 30CONFIG_MTD_CFI=y
35CONFIG_MTD_CFI_AMDSTD=y 31CONFIG_MTD_CFI_AMDSTD=y
@@ -58,5 +54,4 @@ CONFIG_ROOT_NFS=y
58CONFIG_PARTITION_ADVANCED=y 54CONFIG_PARTITION_ADVANCED=y
59# CONFIG_MSDOS_PARTITION is not set 55# CONFIG_MSDOS_PARTITION is not set
60# CONFIG_ENABLE_MUST_CHECK is not set 56# CONFIG_ENABLE_MUST_CHECK is not set
61# CONFIG_RCU_CPU_STALL_DETECTOR is not set
62# CONFIG_CRYPTO_ANSI_CPRNG is not set 57# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7751_defconfig b/arch/sh/configs/se7751_defconfig
index 56b5e4ce8d4a..162343683937 100644
--- a/arch/sh/configs/se7751_defconfig
+++ b/arch/sh/configs/se7751_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
@@ -25,12 +24,9 @@ CONFIG_IP_PNP=y
25CONFIG_IP_PNP_DHCP=y 24CONFIG_IP_PNP_DHCP=y
26CONFIG_IP_PNP_BOOTP=y 25CONFIG_IP_PNP_BOOTP=y
27CONFIG_IP_PNP_RARP=y 26CONFIG_IP_PNP_RARP=y
28# CONFIG_INET_LRO is not set
29# CONFIG_IPV6 is not set 27# CONFIG_IPV6 is not set
30CONFIG_NETFILTER=y 28CONFIG_NETFILTER=y
31CONFIG_IP_NF_QUEUE=y
32CONFIG_MTD=y 29CONFIG_MTD=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_BLOCK=y 30CONFIG_MTD_BLOCK=y
35CONFIG_MTD_CFI=y 31CONFIG_MTD_CFI=y
36CONFIG_MTD_CFI_AMDSTD=y 32CONFIG_MTD_CFI_AMDSTD=y
@@ -48,5 +44,4 @@ CONFIG_EXT2_FS=y
48CONFIG_PROC_KCORE=y 44CONFIG_PROC_KCORE=y
49CONFIG_TMPFS=y 45CONFIG_TMPFS=y
50CONFIG_JFFS2_FS=y 46CONFIG_JFFS2_FS=y
51# CONFIG_RCU_CPU_STALL_DETECTOR is not set
52# CONFIG_CRYPTO_ANSI_CPRNG is not set 47# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/se7780_defconfig b/arch/sh/configs/se7780_defconfig
index b0ef63ce525a..ec32c82646ed 100644
--- a/arch/sh/configs/se7780_defconfig
+++ b/arch/sh/configs/se7780_defconfig
@@ -24,7 +24,6 @@ CONFIG_UNIX=y
24CONFIG_INET=y 24CONFIG_INET=y
25CONFIG_IP_MULTICAST=y 25CONFIG_IP_MULTICAST=y
26CONFIG_IP_PNP=y 26CONFIG_IP_PNP=y
27# CONFIG_INET_LRO is not set
28CONFIG_IPV6=y 27CONFIG_IPV6=y
29# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set 28# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
30# CONFIG_INET6_XFRM_MODE_TUNNEL is not set 29# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
@@ -32,8 +31,6 @@ CONFIG_IPV6=y
32# CONFIG_IPV6_SIT is not set 31# CONFIG_IPV6_SIT is not set
33# CONFIG_PREVENT_FIRMWARE_BUILD is not set 32# CONFIG_PREVENT_FIRMWARE_BUILD is not set
34CONFIG_MTD=y 33CONFIG_MTD=y
35CONFIG_MTD_PARTITIONS=y
36CONFIG_MTD_CHAR=y
37CONFIG_MTD_BLOCK=y 34CONFIG_MTD_BLOCK=y
38CONFIG_MTD_CFI=y 35CONFIG_MTD_CFI=y
39CONFIG_MTD_CFI_ADV_OPTIONS=y 36CONFIG_MTD_CFI_ADV_OPTIONS=y
@@ -54,8 +51,6 @@ CONFIG_SMSC_PHY=y
54CONFIG_NET_ETHERNET=y 51CONFIG_NET_ETHERNET=y
55CONFIG_SMC91X=y 52CONFIG_SMC91X=y
56CONFIG_NET_PCI=y 53CONFIG_NET_PCI=y
57# CONFIG_NETDEV_1000 is not set
58# CONFIG_NETDEV_10000 is not set
59CONFIG_INPUT_FF_MEMLESS=m 54CONFIG_INPUT_FF_MEMLESS=m
60# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 55# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
61# CONFIG_INPUT_KEYBOARD is not set 56# CONFIG_INPUT_KEYBOARD is not set
@@ -94,7 +89,6 @@ CONFIG_HID_SAMSUNG=y
94CONFIG_HID_SONY=y 89CONFIG_HID_SONY=y
95CONFIG_HID_SUNPLUS=y 90CONFIG_HID_SUNPLUS=y
96CONFIG_USB=y 91CONFIG_USB=y
97# CONFIG_USB_DEVICE_CLASS is not set
98CONFIG_USB_MON=y 92CONFIG_USB_MON=y
99CONFIG_USB_EHCI_HCD=y 93CONFIG_USB_EHCI_HCD=y
100CONFIG_USB_OHCI_HCD=y 94CONFIG_USB_OHCI_HCD=y
@@ -110,5 +104,4 @@ CONFIG_NFS_FS=y
110CONFIG_NFS_V3=y 104CONFIG_NFS_V3=y
111CONFIG_ROOT_NFS=y 105CONFIG_ROOT_NFS=y
112CONFIG_DEBUG_FS=y 106CONFIG_DEBUG_FS=y
113# CONFIG_RCU_CPU_STALL_DETECTOR is not set
114# CONFIG_CRYPTO_ANSI_CPRNG is not set 107# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/secureedge5410_defconfig b/arch/sh/configs/secureedge5410_defconfig
index 7eae4e59d7f0..360592d63a2f 100644
--- a/arch/sh/configs/secureedge5410_defconfig
+++ b/arch/sh/configs/secureedge5410_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y 3CONFIG_BLK_DEV_INITRD=y
@@ -18,12 +17,9 @@ CONFIG_INET=y
18# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 17# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
19# CONFIG_INET_XFRM_MODE_TUNNEL is not set 18# CONFIG_INET_XFRM_MODE_TUNNEL is not set
20# CONFIG_INET_XFRM_MODE_BEET is not set 19# CONFIG_INET_XFRM_MODE_BEET is not set
21# CONFIG_INET_LRO is not set
22# CONFIG_INET_DIAG is not set 20# CONFIG_INET_DIAG is not set
23# CONFIG_IPV6 is not set 21# CONFIG_IPV6 is not set
24CONFIG_MTD=y 22CONFIG_MTD=y
25CONFIG_MTD_PARTITIONS=y
26CONFIG_MTD_CHAR=y
27CONFIG_MTD_BLOCK_RO=y 23CONFIG_MTD_BLOCK_RO=y
28CONFIG_MTD_CFI=y 24CONFIG_MTD_CFI=y
29CONFIG_MTD_CFI_ADV_OPTIONS=y 25CONFIG_MTD_CFI_ADV_OPTIONS=y
@@ -34,14 +30,11 @@ CONFIG_MTD_CFI_GEOMETRY=y
34CONFIG_MTD_CFI_INTELEXT=y 30CONFIG_MTD_CFI_INTELEXT=y
35CONFIG_MTD_PLATRAM=y 31CONFIG_MTD_PLATRAM=y
36CONFIG_BLK_DEV_RAM=y 32CONFIG_BLK_DEV_RAM=y
37# CONFIG_MISC_DEVICES is not set
38CONFIG_NETDEVICES=y 33CONFIG_NETDEVICES=y
39CONFIG_NET_ETHERNET=y 34CONFIG_NET_ETHERNET=y
40CONFIG_NET_PCI=y 35CONFIG_NET_PCI=y
41CONFIG_8139CP=y 36CONFIG_8139CP=y
42CONFIG_8139TOO=y 37CONFIG_8139TOO=y
43# CONFIG_NETDEV_1000 is not set
44# CONFIG_NETDEV_10000 is not set
45# CONFIG_INPUT_MOUSEDEV is not set 38# CONFIG_INPUT_MOUSEDEV is not set
46# CONFIG_INPUT_KEYBOARD is not set 39# CONFIG_INPUT_KEYBOARD is not set
47# CONFIG_INPUT_MOUSE is not set 40# CONFIG_INPUT_MOUSE is not set
@@ -51,7 +44,6 @@ CONFIG_SERIAL_SH_SCI=y
51CONFIG_SERIAL_SH_SCI_CONSOLE=y 44CONFIG_SERIAL_SH_SCI_CONSOLE=y
52# CONFIG_HW_RANDOM is not set 45# CONFIG_HW_RANDOM is not set
53# CONFIG_HWMON is not set 46# CONFIG_HWMON is not set
54# CONFIG_HID_SUPPORT is not set
55# CONFIG_USB_SUPPORT is not set 47# CONFIG_USB_SUPPORT is not set
56CONFIG_RTC_CLASS=y 48CONFIG_RTC_CLASS=y
57CONFIG_RTC_DRV_DS1302=y 49CONFIG_RTC_DRV_DS1302=y
@@ -60,4 +52,3 @@ CONFIG_EXT2_FS=y
60CONFIG_TMPFS=y 52CONFIG_TMPFS=y
61CONFIG_CRAMFS=y 53CONFIG_CRAMFS=y
62CONFIG_ROMFS_FS=y 54CONFIG_ROMFS_FS=y
63# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/sh/configs/sh03_defconfig b/arch/sh/configs/sh03_defconfig
index 0cf4097b71e8..2156223405a1 100644
--- a/arch/sh/configs/sh03_defconfig
+++ b/arch/sh/configs/sh03_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -34,7 +33,6 @@ CONFIG_IP_PNP=y
34CONFIG_IP_PNP_DHCP=y 33CONFIG_IP_PNP_DHCP=y
35CONFIG_IP_PNP_BOOTP=y 34CONFIG_IP_PNP_BOOTP=y
36CONFIG_IP_PNP_RARP=y 35CONFIG_IP_PNP_RARP=y
37# CONFIG_INET_LRO is not set
38# CONFIG_IPV6 is not set 36# CONFIG_IPV6 is not set
39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 37CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
40# CONFIG_STANDALONE is not set 38# CONFIG_STANDALONE is not set
@@ -70,7 +68,6 @@ CONFIG_EXT2_FS_XATTR=y
70CONFIG_EXT3_FS=y 68CONFIG_EXT3_FS=y
71# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 69# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
72CONFIG_EXT3_FS_POSIX_ACL=y 70CONFIG_EXT3_FS_POSIX_ACL=y
73CONFIG_AUTOFS_FS=y
74CONFIG_AUTOFS4_FS=y 71CONFIG_AUTOFS4_FS=y
75CONFIG_ISO9660_FS=m 72CONFIG_ISO9660_FS=m
76CONFIG_JOLIET=y 73CONFIG_JOLIET=y
@@ -126,7 +123,6 @@ CONFIG_NLS_KOI8_R=m
126CONFIG_NLS_KOI8_U=m 123CONFIG_NLS_KOI8_U=m
127CONFIG_NLS_UTF8=m 124CONFIG_NLS_UTF8=m
128CONFIG_DEBUG_FS=y 125CONFIG_DEBUG_FS=y
129# CONFIG_RCU_CPU_STALL_DETECTOR is not set
130CONFIG_SH_STANDARD_BIOS=y 126CONFIG_SH_STANDARD_BIOS=y
131CONFIG_CRYPTO_ECB=m 127CONFIG_CRYPTO_ECB=m
132CONFIG_CRYPTO_HMAC=y 128CONFIG_CRYPTO_HMAC=y
diff --git a/arch/sh/configs/sh2007_defconfig b/arch/sh/configs/sh2007_defconfig
index df25ae774ee0..34094e05e892 100644
--- a/arch/sh/configs/sh2007_defconfig
+++ b/arch/sh/configs/sh2007_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -42,7 +41,6 @@ CONFIG_NET_IPIP=y
42# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 41# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
43# CONFIG_INET_XFRM_MODE_TUNNEL is not set 42# CONFIG_INET_XFRM_MODE_TUNNEL is not set
44# CONFIG_INET_XFRM_MODE_BEET is not set 43# CONFIG_INET_XFRM_MODE_BEET is not set
45# CONFIG_INET_LRO is not set
46# CONFIG_IPV6 is not set 44# CONFIG_IPV6 is not set
47CONFIG_NETWORK_SECMARK=y 45CONFIG_NETWORK_SECMARK=y
48CONFIG_NET_PKTGEN=y 46CONFIG_NET_PKTGEN=y
@@ -50,7 +48,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
50CONFIG_BLK_DEV_LOOP=y 48CONFIG_BLK_DEV_LOOP=y
51CONFIG_BLK_DEV_RAM=y 49CONFIG_BLK_DEV_RAM=y
52CONFIG_CDROM_PKTCDVD=y 50CONFIG_CDROM_PKTCDVD=y
53# CONFIG_MISC_DEVICES is not set
54CONFIG_RAID_ATTRS=y 51CONFIG_RAID_ATTRS=y
55CONFIG_SCSI=y 52CONFIG_SCSI=y
56CONFIG_BLK_DEV_SD=y 53CONFIG_BLK_DEV_SD=y
@@ -72,8 +69,6 @@ CONFIG_TUN=y
72CONFIG_VETH=y 69CONFIG_VETH=y
73CONFIG_NET_ETHERNET=y 70CONFIG_NET_ETHERNET=y
74CONFIG_SMSC911X=y 71CONFIG_SMSC911X=y
75# CONFIG_NETDEV_1000 is not set
76# CONFIG_NETDEV_10000 is not set
77# CONFIG_WLAN is not set 72# CONFIG_WLAN is not set
78CONFIG_INPUT_FF_MEMLESS=y 73CONFIG_INPUT_FF_MEMLESS=y
79# CONFIG_INPUT_MOUSEDEV is not set 74# CONFIG_INPUT_MOUSEDEV is not set
@@ -95,9 +90,7 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y
95CONFIG_FRAMEBUFFER_CONSOLE=y 90CONFIG_FRAMEBUFFER_CONSOLE=y
96CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y 91CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
97CONFIG_LOGO=y 92CONFIG_LOGO=y
98# CONFIG_HID_SUPPORT is not set
99CONFIG_USB=y 93CONFIG_USB=y
100# CONFIG_USB_DEVICE_CLASS is not set
101CONFIG_USB_MON=y 94CONFIG_USB_MON=y
102CONFIG_NEW_LEDS=y 95CONFIG_NEW_LEDS=y
103CONFIG_LEDS_CLASS=y 96CONFIG_LEDS_CLASS=y
@@ -172,7 +165,6 @@ CONFIG_DEBUG_KERNEL=y
172# CONFIG_SCHED_DEBUG is not set 165# CONFIG_SCHED_DEBUG is not set
173CONFIG_DEBUG_INFO=y 166CONFIG_DEBUG_INFO=y
174CONFIG_FRAME_POINTER=y 167CONFIG_FRAME_POINTER=y
175# CONFIG_RCU_CPU_STALL_DETECTOR is not set
176CONFIG_SH_STANDARD_BIOS=y 168CONFIG_SH_STANDARD_BIOS=y
177CONFIG_CRYPTO_NULL=y 169CONFIG_CRYPTO_NULL=y
178CONFIG_CRYPTO_AUTHENC=y 170CONFIG_CRYPTO_AUTHENC=y
diff --git a/arch/sh/configs/sh7710voipgw_defconfig b/arch/sh/configs/sh7710voipgw_defconfig
index f92ad17cd629..65a1aad899c8 100644
--- a/arch/sh/configs/sh7710voipgw_defconfig
+++ b/arch/sh/configs/sh7710voipgw_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -24,7 +23,6 @@ CONFIG_PACKET=y
24CONFIG_UNIX=y 23CONFIG_UNIX=y
25CONFIG_INET=y 24CONFIG_INET=y
26CONFIG_SYN_COOKIES=y 25CONFIG_SYN_COOKIES=y
27# CONFIG_INET_LRO is not set
28# CONFIG_INET_DIAG is not set 26# CONFIG_INET_DIAG is not set
29# CONFIG_IPV6 is not set 27# CONFIG_IPV6 is not set
30CONFIG_NETFILTER=y 28CONFIG_NETFILTER=y
@@ -36,8 +34,6 @@ CONFIG_NET_CLS_ROUTE4=y
36CONFIG_NET_CLS_U32=y 34CONFIG_NET_CLS_U32=y
37CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 35CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
38CONFIG_MTD=y 36CONFIG_MTD=y
39CONFIG_MTD_PARTITIONS=y
40CONFIG_MTD_CHAR=y
41CONFIG_MTD_BLOCK=y 37CONFIG_MTD_BLOCK=y
42CONFIG_MTD_CFI=y 38CONFIG_MTD_CFI=y
43CONFIG_MTD_CFI_AMDSTD=y 39CONFIG_MTD_CFI_AMDSTD=y
@@ -59,5 +55,4 @@ CONFIG_THERMAL=y
59# CONFIG_DNOTIFY is not set 55# CONFIG_DNOTIFY is not set
60CONFIG_JFFS2_FS=y 56CONFIG_JFFS2_FS=y
61CONFIG_DEBUG_FS=y 57CONFIG_DEBUG_FS=y
62# CONFIG_RCU_CPU_STALL_DETECTOR is not set
63# CONFIG_CRYPTO_ANSI_CPRNG is not set 58# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/sh7724_generic_defconfig b/arch/sh/configs/sh7724_generic_defconfig
index f83ac7b0b031..d15e53647983 100644
--- a/arch/sh/configs/sh7724_generic_defconfig
+++ b/arch/sh/configs/sh7724_generic_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_CGROUPS=y 3CONFIG_CGROUPS=y
@@ -18,7 +17,6 @@ CONFIG_HIBERNATION=y
18CONFIG_CPU_IDLE=y 17CONFIG_CPU_IDLE=y
19CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 18CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
20# CONFIG_PREVENT_FIRMWARE_BUILD is not set 19# CONFIG_PREVENT_FIRMWARE_BUILD is not set
21# CONFIG_MISC_DEVICES is not set
22# CONFIG_INPUT is not set 20# CONFIG_INPUT is not set
23# CONFIG_SERIO is not set 21# CONFIG_SERIO is not set
24# CONFIG_VT is not set 22# CONFIG_VT is not set
@@ -44,5 +42,4 @@ CONFIG_UIO_PDRV_GENIRQ=y
44# CONFIG_MISC_FILESYSTEMS is not set 42# CONFIG_MISC_FILESYSTEMS is not set
45# CONFIG_ENABLE_WARN_DEPRECATED is not set 43# CONFIG_ENABLE_WARN_DEPRECATED is not set
46# CONFIG_ENABLE_MUST_CHECK is not set 44# CONFIG_ENABLE_MUST_CHECK is not set
47# CONFIG_RCU_CPU_STALL_DETECTOR is not set
48# CONFIG_CRC32 is not set 45# CONFIG_CRC32 is not set
diff --git a/arch/sh/configs/sh7757lcr_defconfig b/arch/sh/configs/sh7757lcr_defconfig
index cfde98ddb29d..b0c4bc830fb8 100644
--- a/arch/sh/configs/sh7757lcr_defconfig
+++ b/arch/sh/configs/sh7757lcr_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -32,13 +31,11 @@ CONFIG_INET=y
32CONFIG_IP_MULTICAST=y 31CONFIG_IP_MULTICAST=y
33CONFIG_IP_PNP=y 32CONFIG_IP_PNP=y
34CONFIG_IP_PNP_DHCP=y 33CONFIG_IP_PNP_DHCP=y
35# CONFIG_INET_LRO is not set
36CONFIG_IPV6=y 34CONFIG_IPV6=y
37# CONFIG_WIRELESS is not set 35# CONFIG_WIRELESS is not set
38CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 36CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
39# CONFIG_FW_LOADER is not set 37# CONFIG_FW_LOADER is not set
40CONFIG_MTD=y 38CONFIG_MTD=y
41CONFIG_MTD_CHAR=y
42CONFIG_MTD_BLOCK=y 39CONFIG_MTD_BLOCK=y
43CONFIG_MTD_M25P80=y 40CONFIG_MTD_M25P80=y
44CONFIG_BLK_DEV_RAM=y 41CONFIG_BLK_DEV_RAM=y
@@ -48,7 +45,6 @@ CONFIG_NETDEVICES=y
48CONFIG_VITESSE_PHY=y 45CONFIG_VITESSE_PHY=y
49CONFIG_NET_ETHERNET=y 46CONFIG_NET_ETHERNET=y
50CONFIG_SH_ETH=y 47CONFIG_SH_ETH=y
51# CONFIG_NETDEV_10000 is not set
52# CONFIG_WLAN is not set 48# CONFIG_WLAN is not set
53# CONFIG_KEYBOARD_ATKBD is not set 49# CONFIG_KEYBOARD_ATKBD is not set
54# CONFIG_MOUSE_PS2 is not set 50# CONFIG_MOUSE_PS2 is not set
diff --git a/arch/sh/configs/sh7763rdp_defconfig b/arch/sh/configs/sh7763rdp_defconfig
index 479536440264..2ef780fb9813 100644
--- a/arch/sh/configs/sh7763rdp_defconfig
+++ b/arch/sh/configs/sh7763rdp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 2CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 3CONFIG_IKCONFIG_PROC=y
@@ -26,11 +25,9 @@ CONFIG_INET=y
26CONFIG_IP_PNP=y 25CONFIG_IP_PNP=y
27CONFIG_IP_PNP_DHCP=y 26CONFIG_IP_PNP_DHCP=y
28CONFIG_IP_PNP_BOOTP=y 27CONFIG_IP_PNP_BOOTP=y
29# CONFIG_INET_LRO is not set
30# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
32CONFIG_MTD=y 30CONFIG_MTD=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_CMDLINE_PARTS=y 31CONFIG_MTD_CMDLINE_PARTS=y
35CONFIG_MTD_BLKDEVS=y 32CONFIG_MTD_BLKDEVS=y
36CONFIG_MTD_CFI=y 33CONFIG_MTD_CFI=y
@@ -43,14 +40,11 @@ CONFIG_MTD_CFI_AMDSTD=y
43CONFIG_MTD_CFI_STAA=y 40CONFIG_MTD_CFI_STAA=y
44CONFIG_MTD_COMPLEX_MAPPINGS=y 41CONFIG_MTD_COMPLEX_MAPPINGS=y
45CONFIG_MTD_PHYSMAP=y 42CONFIG_MTD_PHYSMAP=y
46# CONFIG_MISC_DEVICES is not set
47CONFIG_SCSI=y 43CONFIG_SCSI=y
48CONFIG_BLK_DEV_SD=y 44CONFIG_BLK_DEV_SD=y
49CONFIG_NETDEVICES=y 45CONFIG_NETDEVICES=y
50CONFIG_NET_ETHERNET=y 46CONFIG_NET_ETHERNET=y
51CONFIG_SH_ETH=y 47CONFIG_SH_ETH=y
52# CONFIG_NETDEV_1000 is not set
53# CONFIG_NETDEV_10000 is not set
54# CONFIG_INPUT_MOUSEDEV is not set 48# CONFIG_INPUT_MOUSEDEV is not set
55# CONFIG_INPUT_KEYBOARD is not set 49# CONFIG_INPUT_KEYBOARD is not set
56# CONFIG_INPUT_MOUSE is not set 50# CONFIG_INPUT_MOUSE is not set
@@ -65,7 +59,6 @@ CONFIG_FB_FOREIGN_ENDIAN=y
65CONFIG_FB_SH7760=y 59CONFIG_FB_SH7760=y
66CONFIG_FRAMEBUFFER_CONSOLE=y 60CONFIG_FRAMEBUFFER_CONSOLE=y
67CONFIG_LOGO=y 61CONFIG_LOGO=y
68# CONFIG_HID_SUPPORT is not set
69CONFIG_USB=y 62CONFIG_USB=y
70CONFIG_USB_MON=y 63CONFIG_USB_MON=y
71CONFIG_USB_OHCI_HCD=y 64CONFIG_USB_OHCI_HCD=y
@@ -74,7 +67,6 @@ CONFIG_MMC=y
74CONFIG_EXT2_FS=y 67CONFIG_EXT2_FS=y
75CONFIG_EXT3_FS=y 68CONFIG_EXT3_FS=y
76# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 69# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
77CONFIG_AUTOFS_FS=y
78CONFIG_AUTOFS4_FS=y 70CONFIG_AUTOFS4_FS=y
79CONFIG_MSDOS_FS=y 71CONFIG_MSDOS_FS=y
80CONFIG_VFAT_FS=y 72CONFIG_VFAT_FS=y
@@ -124,6 +116,5 @@ CONFIG_NLS_UTF8=y
124# CONFIG_ENABLE_WARN_DEPRECATED is not set 116# CONFIG_ENABLE_WARN_DEPRECATED is not set
125# CONFIG_ENABLE_MUST_CHECK is not set 117# CONFIG_ENABLE_MUST_CHECK is not set
126CONFIG_DEBUG_FS=y 118CONFIG_DEBUG_FS=y
127# CONFIG_RCU_CPU_STALL_DETECTOR is not set
128# CONFIG_CRYPTO_ANSI_CPRNG is not set 119# CONFIG_CRYPTO_ANSI_CPRNG is not set
129CONFIG_CRC_T10DIF=y 120CONFIG_CRC_T10DIF=y
diff --git a/arch/sh/configs/sh7770_generic_defconfig b/arch/sh/configs/sh7770_generic_defconfig
index 025bd3ac5ab0..742634b37c0a 100644
--- a/arch/sh/configs/sh7770_generic_defconfig
+++ b/arch/sh/configs/sh7770_generic_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_CGROUPS=y 3CONFIG_CGROUPS=y
@@ -20,7 +19,6 @@ CONFIG_HIBERNATION=y
20CONFIG_CPU_IDLE=y 19CONFIG_CPU_IDLE=y
21CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 20CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
22# CONFIG_PREVENT_FIRMWARE_BUILD is not set 21# CONFIG_PREVENT_FIRMWARE_BUILD is not set
23# CONFIG_MISC_DEVICES is not set
24# CONFIG_INPUT is not set 22# CONFIG_INPUT is not set
25# CONFIG_SERIO is not set 23# CONFIG_SERIO is not set
26# CONFIG_VT is not set 24# CONFIG_VT is not set
@@ -46,5 +44,4 @@ CONFIG_UIO_PDRV_GENIRQ=y
46# CONFIG_MISC_FILESYSTEMS is not set 44# CONFIG_MISC_FILESYSTEMS is not set
47# CONFIG_ENABLE_WARN_DEPRECATED is not set 45# CONFIG_ENABLE_WARN_DEPRECATED is not set
48# CONFIG_ENABLE_MUST_CHECK is not set 46# CONFIG_ENABLE_MUST_CHECK is not set
49# CONFIG_RCU_CPU_STALL_DETECTOR is not set
50# CONFIG_CRC32 is not set 47# CONFIG_CRC32 is not set
diff --git a/arch/sh/configs/sh7785lcr_32bit_defconfig b/arch/sh/configs/sh7785lcr_32bit_defconfig
index 2fce54d9c388..2ddf5ca7094e 100644
--- a/arch/sh/configs/sh7785lcr_32bit_defconfig
+++ b/arch/sh/configs/sh7785lcr_32bit_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -44,13 +43,9 @@ CONFIG_INET=y
44CONFIG_IP_ADVANCED_ROUTER=y 43CONFIG_IP_ADVANCED_ROUTER=y
45CONFIG_IP_PNP=y 44CONFIG_IP_PNP=y
46CONFIG_IP_PNP_DHCP=y 45CONFIG_IP_PNP_DHCP=y
47# CONFIG_INET_LRO is not set
48# CONFIG_IPV6 is not set 46# CONFIG_IPV6 is not set
49CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 47CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
50CONFIG_MTD=y 48CONFIG_MTD=y
51CONFIG_MTD_CONCAT=y
52CONFIG_MTD_PARTITIONS=y
53CONFIG_MTD_CHAR=y
54CONFIG_MTD_BLOCK=y 49CONFIG_MTD_BLOCK=y
55CONFIG_MTD_CFI=y 50CONFIG_MTD_CFI=y
56CONFIG_MTD_CFI_AMDSTD=y 51CONFIG_MTD_CFI_AMDSTD=y
@@ -58,7 +53,6 @@ CONFIG_MTD_PHYSMAP=y
58CONFIG_BLK_DEV_LOOP=y 53CONFIG_BLK_DEV_LOOP=y
59CONFIG_BLK_DEV_CRYPTOLOOP=m 54CONFIG_BLK_DEV_CRYPTOLOOP=m
60CONFIG_BLK_DEV_RAM=y 55CONFIG_BLK_DEV_RAM=y
61# CONFIG_MISC_DEVICES is not set
62# CONFIG_SCSI_PROC_FS is not set 56# CONFIG_SCSI_PROC_FS is not set
63CONFIG_BLK_DEV_SD=y 57CONFIG_BLK_DEV_SD=y
64# CONFIG_SCSI_LOWLEVEL is not set 58# CONFIG_SCSI_LOWLEVEL is not set
@@ -69,7 +63,6 @@ CONFIG_NET_ETHERNET=y
69CONFIG_NET_VENDOR_3COM=y 63CONFIG_NET_VENDOR_3COM=y
70CONFIG_VORTEX=y 64CONFIG_VORTEX=y
71CONFIG_R8169=y 65CONFIG_R8169=y
72# CONFIG_NETDEV_10000 is not set
73# CONFIG_WLAN is not set 66# CONFIG_WLAN is not set
74CONFIG_INPUT_FF_MEMLESS=m 67CONFIG_INPUT_FF_MEMLESS=m
75CONFIG_INPUT_EVDEV=y 68CONFIG_INPUT_EVDEV=y
@@ -113,7 +106,6 @@ CONFIG_SND_CMIPCI=y
113CONFIG_SND_EMU10K1=y 106CONFIG_SND_EMU10K1=y
114# CONFIG_SND_SUPERH is not set 107# CONFIG_SND_SUPERH is not set
115CONFIG_USB=y 108CONFIG_USB=y
116# CONFIG_USB_DEVICE_CLASS is not set
117CONFIG_USB_R8A66597_HCD=y 109CONFIG_USB_R8A66597_HCD=y
118CONFIG_USB_STORAGE=y 110CONFIG_USB_STORAGE=y
119CONFIG_MMC=y 111CONFIG_MMC=y
@@ -154,9 +146,7 @@ CONFIG_DEBUG_SPINLOCK=y
154CONFIG_DEBUG_MUTEXES=y 146CONFIG_DEBUG_MUTEXES=y
155CONFIG_DEBUG_SPINLOCK_SLEEP=y 147CONFIG_DEBUG_SPINLOCK_SLEEP=y
156CONFIG_DEBUG_INFO=y 148CONFIG_DEBUG_INFO=y
157# CONFIG_RCU_CPU_STALL_DETECTOR is not set
158CONFIG_LATENCYTOP=y 149CONFIG_LATENCYTOP=y
159CONFIG_SYSCTL_SYSCALL_CHECK=y
160# CONFIG_FTRACE is not set 150# CONFIG_FTRACE is not set
161CONFIG_CRYPTO_HMAC=y 151CONFIG_CRYPTO_HMAC=y
162# CONFIG_CRYPTO_ANSI_CPRNG is not set 152# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/sh7785lcr_defconfig b/arch/sh/configs/sh7785lcr_defconfig
index d29da4a0f6c2..7098828d392e 100644
--- a/arch/sh/configs/sh7785lcr_defconfig
+++ b/arch/sh/configs/sh7785lcr_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -26,27 +25,21 @@ CONFIG_INET=y
26CONFIG_IP_ADVANCED_ROUTER=y 25CONFIG_IP_ADVANCED_ROUTER=y
27CONFIG_IP_PNP=y 26CONFIG_IP_PNP=y
28CONFIG_IP_PNP_DHCP=y 27CONFIG_IP_PNP_DHCP=y
29# CONFIG_INET_LRO is not set
30# CONFIG_IPV6 is not set 28# CONFIG_IPV6 is not set
31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
32# CONFIG_FW_LOADER is not set 30# CONFIG_FW_LOADER is not set
33CONFIG_MTD=y 31CONFIG_MTD=y
34CONFIG_MTD_CONCAT=y
35CONFIG_MTD_PARTITIONS=y
36CONFIG_MTD_CHAR=y
37CONFIG_MTD_BLOCK=y 32CONFIG_MTD_BLOCK=y
38CONFIG_MTD_CFI=y 33CONFIG_MTD_CFI=y
39CONFIG_MTD_CFI_AMDSTD=y 34CONFIG_MTD_CFI_AMDSTD=y
40CONFIG_MTD_PHYSMAP=y 35CONFIG_MTD_PHYSMAP=y
41CONFIG_BLK_DEV_RAM=y 36CONFIG_BLK_DEV_RAM=y
42# CONFIG_MISC_DEVICES is not set
43CONFIG_BLK_DEV_SD=y 37CONFIG_BLK_DEV_SD=y
44# CONFIG_SCSI_LOWLEVEL is not set 38# CONFIG_SCSI_LOWLEVEL is not set
45CONFIG_ATA=y 39CONFIG_ATA=y
46CONFIG_SATA_SIL=y 40CONFIG_SATA_SIL=y
47CONFIG_NETDEVICES=y 41CONFIG_NETDEVICES=y
48CONFIG_R8169=y 42CONFIG_R8169=y
49# CONFIG_NETDEV_10000 is not set
50CONFIG_INPUT_FF_MEMLESS=m 43CONFIG_INPUT_FF_MEMLESS=m
51# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 44# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
52# CONFIG_KEYBOARD_ATKBD is not set 45# CONFIG_KEYBOARD_ATKBD is not set
@@ -121,8 +114,6 @@ CONFIG_NLS_ISO8859_1=y
121CONFIG_DEBUG_KERNEL=y 114CONFIG_DEBUG_KERNEL=y
122CONFIG_DETECT_HUNG_TASK=y 115CONFIG_DETECT_HUNG_TASK=y
123# CONFIG_DEBUG_BUGVERBOSE is not set 116# CONFIG_DEBUG_BUGVERBOSE is not set
124# CONFIG_RCU_CPU_STALL_DETECTOR is not set
125CONFIG_SYSCTL_SYSCALL_CHECK=y
126CONFIG_CRYPTO_HMAC=y 117CONFIG_CRYPTO_HMAC=y
127# CONFIG_CRYPTO_ANSI_CPRNG is not set 118# CONFIG_CRYPTO_ANSI_CPRNG is not set
128# CONFIG_CRYPTO_HW is not set 119# CONFIG_CRYPTO_HW is not set
diff --git a/arch/sh/configs/shmin_defconfig b/arch/sh/configs/shmin_defconfig
index 4802e14a4649..d589cfdfb7eb 100644
--- a/arch/sh/configs/shmin_defconfig
+++ b/arch/sh/configs/shmin_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
4# CONFIG_UID16 is not set 3# CONFIG_UID16 is not set
@@ -28,10 +27,8 @@ CONFIG_NET=y
28CONFIG_UNIX=y 27CONFIG_UNIX=y
29CONFIG_INET=y 28CONFIG_INET=y
30CONFIG_IP_PNP=y 29CONFIG_IP_PNP=y
31# CONFIG_INET_LRO is not set
32# CONFIG_IPV6 is not set 30# CONFIG_IPV6 is not set
33CONFIG_MTD=y 31CONFIG_MTD=y
34CONFIG_MTD_PARTITIONS=y
35CONFIG_MTD_CMDLINE_PARTS=y 32CONFIG_MTD_CMDLINE_PARTS=y
36CONFIG_MTD_BLOCK=y 33CONFIG_MTD_BLOCK=y
37CONFIG_MTD_CFI=y 34CONFIG_MTD_CFI=y
@@ -53,6 +50,5 @@ CONFIG_CRAMFS=y
53CONFIG_NFS_FS=y 50CONFIG_NFS_FS=y
54CONFIG_NFS_V3=y 51CONFIG_NFS_V3=y
55CONFIG_ROOT_NFS=y 52CONFIG_ROOT_NFS=y
56# CONFIG_RCU_CPU_STALL_DETECTOR is not set
57CONFIG_SH_STANDARD_BIOS=y 53CONFIG_SH_STANDARD_BIOS=y
58# CONFIG_CRYPTO_ANSI_CPRNG is not set 54# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/shx3_defconfig b/arch/sh/configs/shx3_defconfig
index 4a4269ad5b04..755c4f73c718 100644
--- a/arch/sh/configs/shx3_defconfig
+++ b/arch/sh/configs/shx3_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -56,7 +55,6 @@ CONFIG_NET=y
56CONFIG_INET=y 55CONFIG_INET=y
57CONFIG_IP_PNP=y 56CONFIG_IP_PNP=y
58CONFIG_IP_PNP_DHCP=y 57CONFIG_IP_PNP_DHCP=y
59# CONFIG_INET_LRO is not set
60CONFIG_CAN=m 58CONFIG_CAN=m
61CONFIG_CAN_RAW=m 59CONFIG_CAN_RAW=m
62CONFIG_CAN_BCM=m 60CONFIG_CAN_BCM=m
@@ -70,8 +68,6 @@ CONFIG_PATA_PLATFORM=y
70CONFIG_NETDEVICES=y 68CONFIG_NETDEVICES=y
71CONFIG_NET_ETHERNET=y 69CONFIG_NET_ETHERNET=y
72CONFIG_SMC91X=y 70CONFIG_SMC91X=y
73# CONFIG_NETDEV_1000 is not set
74# CONFIG_NETDEV_10000 is not set
75# CONFIG_INPUT is not set 71# CONFIG_INPUT is not set
76# CONFIG_SERIO is not set 72# CONFIG_SERIO is not set
77# CONFIG_VT is not set 73# CONFIG_VT is not set
@@ -82,7 +78,6 @@ CONFIG_I2C=m
82CONFIG_SPI=y 78CONFIG_SPI=y
83# CONFIG_HWMON is not set 79# CONFIG_HWMON is not set
84CONFIG_WATCHDOG=y 80CONFIG_WATCHDOG=y
85CONFIG_VIDEO_OUTPUT_CONTROL=m
86CONFIG_USB=y 81CONFIG_USB=y
87CONFIG_USB_MON=y 82CONFIG_USB_MON=y
88CONFIG_USB_R8A66597_HCD=m 83CONFIG_USB_R8A66597_HCD=m
@@ -104,7 +99,6 @@ CONFIG_DEBUG_SHIRQ=y
104CONFIG_DETECT_HUNG_TASK=y 99CONFIG_DETECT_HUNG_TASK=y
105CONFIG_DEBUG_VM=y 100CONFIG_DEBUG_VM=y
106CONFIG_FRAME_POINTER=y 101CONFIG_FRAME_POINTER=y
107# CONFIG_RCU_CPU_STALL_DETECTOR is not set
108CONFIG_SH_STANDARD_BIOS=y 102CONFIG_SH_STANDARD_BIOS=y
109CONFIG_DEBUG_STACK_USAGE=y 103CONFIG_DEBUG_STACK_USAGE=y
110# CONFIG_CRYPTO_ANSI_CPRNG is not set 104# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/titan_defconfig b/arch/sh/configs/titan_defconfig
index a77b778c745b..ceb48e9b70f4 100644
--- a/arch/sh/configs/titan_defconfig
+++ b/arch/sh/configs/titan_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -49,7 +48,6 @@ CONFIG_SYN_COOKIES=y
49CONFIG_INET_AH=y 48CONFIG_INET_AH=y
50CONFIG_INET_ESP=y 49CONFIG_INET_ESP=y
51CONFIG_INET_IPCOMP=y 50CONFIG_INET_IPCOMP=y
52# CONFIG_INET_LRO is not set
53CONFIG_INET_DIAG=m 51CONFIG_INET_DIAG=m
54CONFIG_IPV6=y 52CONFIG_IPV6=y
55CONFIG_IPV6_PRIVACY=y 53CONFIG_IPV6_PRIVACY=y
@@ -79,7 +77,6 @@ CONFIG_NETFILTER_XT_MATCH_REALM=m
79CONFIG_NETFILTER_XT_MATCH_SCTP=m 77CONFIG_NETFILTER_XT_MATCH_SCTP=m
80CONFIG_NETFILTER_XT_MATCH_STRING=m 78CONFIG_NETFILTER_XT_MATCH_STRING=m
81CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 79CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
82CONFIG_IP_NF_QUEUE=m
83CONFIG_IP_NF_IPTABLES=m 80CONFIG_IP_NF_IPTABLES=m
84CONFIG_IP_NF_MATCH_ADDRTYPE=m 81CONFIG_IP_NF_MATCH_ADDRTYPE=m
85CONFIG_IP_NF_MATCH_AH=m 82CONFIG_IP_NF_MATCH_AH=m
@@ -88,7 +85,6 @@ CONFIG_IP_NF_MATCH_TTL=m
88CONFIG_IP_NF_FILTER=m 85CONFIG_IP_NF_FILTER=m
89CONFIG_IP_NF_TARGET_REJECT=m 86CONFIG_IP_NF_TARGET_REJECT=m
90CONFIG_IP_NF_TARGET_LOG=m 87CONFIG_IP_NF_TARGET_LOG=m
91CONFIG_IP_NF_TARGET_ULOG=m
92CONFIG_IP_NF_MANGLE=m 88CONFIG_IP_NF_MANGLE=m
93CONFIG_IP_NF_TARGET_ECN=m 89CONFIG_IP_NF_TARGET_ECN=m
94CONFIG_IP_NF_TARGET_TTL=m 90CONFIG_IP_NF_TARGET_TTL=m
@@ -96,7 +92,6 @@ CONFIG_IP_NF_RAW=m
96CONFIG_IP_NF_ARPTABLES=m 92CONFIG_IP_NF_ARPTABLES=m
97CONFIG_IP_NF_ARPFILTER=m 93CONFIG_IP_NF_ARPFILTER=m
98CONFIG_IP_NF_ARP_MANGLE=m 94CONFIG_IP_NF_ARP_MANGLE=m
99CONFIG_IP6_NF_QUEUE=m
100CONFIG_IP6_NF_IPTABLES=m 95CONFIG_IP6_NF_IPTABLES=m
101CONFIG_IP6_NF_MATCH_AH=m 96CONFIG_IP6_NF_MATCH_AH=m
102CONFIG_IP6_NF_MATCH_EUI64=m 97CONFIG_IP6_NF_MATCH_EUI64=m
@@ -106,7 +101,6 @@ CONFIG_IP6_NF_MATCH_HL=m
106CONFIG_IP6_NF_MATCH_IPV6HEADER=m 101CONFIG_IP6_NF_MATCH_IPV6HEADER=m
107CONFIG_IP6_NF_MATCH_RT=m 102CONFIG_IP6_NF_MATCH_RT=m
108CONFIG_IP6_NF_TARGET_HL=m 103CONFIG_IP6_NF_TARGET_HL=m
109CONFIG_IP6_NF_TARGET_LOG=m
110CONFIG_IP6_NF_FILTER=m 104CONFIG_IP6_NF_FILTER=m
111CONFIG_IP6_NF_TARGET_REJECT=m 105CONFIG_IP6_NF_TARGET_REJECT=m
112CONFIG_IP6_NF_MANGLE=m 106CONFIG_IP6_NF_MANGLE=m
@@ -154,7 +148,6 @@ CONFIG_FW_LOADER=m
154CONFIG_CONNECTOR=m 148CONFIG_CONNECTOR=m
155CONFIG_MTD=m 149CONFIG_MTD=m
156CONFIG_MTD_DEBUG=y 150CONFIG_MTD_DEBUG=y
157CONFIG_MTD_CHAR=m
158CONFIG_MTD_BLOCK=m 151CONFIG_MTD_BLOCK=m
159CONFIG_FTL=m 152CONFIG_FTL=m
160CONFIG_NFTL=m 153CONFIG_NFTL=m
@@ -261,7 +254,6 @@ CONFIG_NLS_UTF8=m
261CONFIG_MAGIC_SYSRQ=y 254CONFIG_MAGIC_SYSRQ=y
262CONFIG_DEBUG_KERNEL=y 255CONFIG_DEBUG_KERNEL=y
263# CONFIG_DEBUG_BUGVERBOSE is not set 256# CONFIG_DEBUG_BUGVERBOSE is not set
264# CONFIG_RCU_CPU_STALL_DETECTOR is not set
265CONFIG_CRYPTO_NULL=m 257CONFIG_CRYPTO_NULL=m
266CONFIG_CRYPTO_ECB=y 258CONFIG_CRYPTO_ECB=y
267CONFIG_CRYPTO_MD4=m 259CONFIG_CRYPTO_MD4=m
diff --git a/arch/sh/configs/ul2_defconfig b/arch/sh/configs/ul2_defconfig
index 2d288b887fbd..5f2921a85192 100644
--- a/arch/sh/configs/ul2_defconfig
+++ b/arch/sh/configs/ul2_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
@@ -29,7 +28,6 @@ CONFIG_UNIX=y
29CONFIG_INET=y 28CONFIG_INET=y
30CONFIG_IP_PNP=y 29CONFIG_IP_PNP=y
31CONFIG_IP_PNP_DHCP=y 30CONFIG_IP_PNP_DHCP=y
32# CONFIG_INET_LRO is not set
33# CONFIG_IPV6 is not set 31# CONFIG_IPV6 is not set
34CONFIG_CFG80211=y 32CONFIG_CFG80211=y
35CONFIG_MAC80211=y 33CONFIG_MAC80211=y
@@ -37,9 +35,6 @@ CONFIG_MAC80211_RC_PID=y
37# CONFIG_MAC80211_RC_MINSTREL is not set 35# CONFIG_MAC80211_RC_MINSTREL is not set
38CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 36CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
39CONFIG_MTD=y 37CONFIG_MTD=y
40CONFIG_MTD_CONCAT=y
41CONFIG_MTD_PARTITIONS=y
42CONFIG_MTD_CHAR=y
43CONFIG_MTD_BLOCK=y 38CONFIG_MTD_BLOCK=y
44CONFIG_MTD_CFI=y 39CONFIG_MTD_CFI=y
45CONFIG_MTD_CFI_AMDSTD=y 40CONFIG_MTD_CFI_AMDSTD=y
@@ -50,8 +45,6 @@ CONFIG_ATA=y
50CONFIG_PATA_PLATFORM=y 45CONFIG_PATA_PLATFORM=y
51CONFIG_NETDEVICES=y 46CONFIG_NETDEVICES=y
52CONFIG_NET_ETHERNET=y 47CONFIG_NET_ETHERNET=y
53# CONFIG_NETDEV_1000 is not set
54# CONFIG_NETDEV_10000 is not set
55CONFIG_LIBERTAS=m 48CONFIG_LIBERTAS=m
56CONFIG_LIBERTAS_SDIO=m 49CONFIG_LIBERTAS_SDIO=m
57CONFIG_LIBERTAS_DEBUG=y 50CONFIG_LIBERTAS_DEBUG=y
@@ -70,7 +63,6 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
70# CONFIG_UNIX98_PTYS is not set 63# CONFIG_UNIX98_PTYS is not set
71# CONFIG_LEGACY_PTYS is not set 64# CONFIG_LEGACY_PTYS is not set
72# CONFIG_HW_RANDOM is not set 65# CONFIG_HW_RANDOM is not set
73# CONFIG_HID_SUPPORT is not set
74CONFIG_USB=y 66CONFIG_USB=y
75CONFIG_USB_MON=y 67CONFIG_USB_MON=y
76CONFIG_USB_R8A66597_HCD=y 68CONFIG_USB_R8A66597_HCD=y
@@ -92,6 +84,5 @@ CONFIG_NLS_CODEPAGE_932=y
92CONFIG_NLS_ISO8859_1=y 84CONFIG_NLS_ISO8859_1=y
93# CONFIG_ENABLE_WARN_DEPRECATED is not set 85# CONFIG_ENABLE_WARN_DEPRECATED is not set
94# CONFIG_ENABLE_MUST_CHECK is not set 86# CONFIG_ENABLE_MUST_CHECK is not set
95# CONFIG_RCU_CPU_STALL_DETECTOR is not set
96CONFIG_CRYPTO_MICHAEL_MIC=y 87CONFIG_CRYPTO_MICHAEL_MIC=y
97# CONFIG_CRYPTO_ANSI_CPRNG is not set 88# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/urquell_defconfig b/arch/sh/configs/urquell_defconfig
index 01c9a91ee896..7d5591b7c088 100644
--- a/arch/sh/configs/urquell_defconfig
+++ b/arch/sh/configs/urquell_defconfig
@@ -1,4 +1,3 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
@@ -46,20 +45,15 @@ CONFIG_INET=y
46CONFIG_IP_ADVANCED_ROUTER=y 45CONFIG_IP_ADVANCED_ROUTER=y
47CONFIG_IP_PNP=y 46CONFIG_IP_PNP=y
48CONFIG_IP_PNP_DHCP=y 47CONFIG_IP_PNP_DHCP=y
49# CONFIG_INET_LRO is not set
50# CONFIG_IPV6 is not set 48# CONFIG_IPV6 is not set
51CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 49CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
52# CONFIG_FW_LOADER is not set 50# CONFIG_FW_LOADER is not set
53CONFIG_MTD=y 51CONFIG_MTD=y
54CONFIG_MTD_CONCAT=y
55CONFIG_MTD_PARTITIONS=y
56CONFIG_MTD_CHAR=y
57CONFIG_MTD_BLOCK=y 52CONFIG_MTD_BLOCK=y
58CONFIG_MTD_CFI=y 53CONFIG_MTD_CFI=y
59CONFIG_MTD_CFI_AMDSTD=y 54CONFIG_MTD_CFI_AMDSTD=y
60CONFIG_MTD_PHYSMAP=y 55CONFIG_MTD_PHYSMAP=y
61CONFIG_BLK_DEV_RAM=y 56CONFIG_BLK_DEV_RAM=y
62# CONFIG_MISC_DEVICES is not set
63CONFIG_BLK_DEV_SD=y 57CONFIG_BLK_DEV_SD=y
64# CONFIG_SCSI_LOWLEVEL is not set 58# CONFIG_SCSI_LOWLEVEL is not set
65CONFIG_ATA=y 59CONFIG_ATA=y
@@ -73,7 +67,6 @@ CONFIG_NET_PCI=y
73CONFIG_8139CP=y 67CONFIG_8139CP=y
74CONFIG_SKY2=y 68CONFIG_SKY2=y
75CONFIG_SKY2_DEBUG=y 69CONFIG_SKY2_DEBUG=y
76# CONFIG_NETDEV_10000 is not set
77CONFIG_INPUT_FF_MEMLESS=m 70CONFIG_INPUT_FF_MEMLESS=m
78# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 71# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
79# CONFIG_KEYBOARD_ATKBD is not set 72# CONFIG_KEYBOARD_ATKBD is not set
@@ -150,8 +143,6 @@ CONFIG_DEBUG_KERNEL=y
150CONFIG_DETECT_HUNG_TASK=y 143CONFIG_DETECT_HUNG_TASK=y
151CONFIG_DEBUG_INFO=y 144CONFIG_DEBUG_INFO=y
152CONFIG_FRAME_POINTER=y 145CONFIG_FRAME_POINTER=y
153# CONFIG_RCU_CPU_STALL_DETECTOR is not set
154CONFIG_SYSCTL_SYSCALL_CHECK=y
155# CONFIG_FTRACE is not set 146# CONFIG_FTRACE is not set
156# CONFIG_DUMP_CODE is not set 147# CONFIG_DUMP_CODE is not set
157CONFIG_CRYPTO_HMAC=y 148CONFIG_CRYPTO_HMAC=y
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index a4a626199c47..0be3828752e5 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -97,6 +97,9 @@ config ARCH_PROC_KCORE_TEXT
97config CPU_BIG_ENDIAN 97config CPU_BIG_ENDIAN
98 def_bool y 98 def_bool y
99 99
100config CPU_BIG_ENDIAN
101 def_bool y
102
100config ARCH_ATU 103config ARCH_ATU
101 bool 104 bool
102 default y if SPARC64 105 default y if SPARC64
diff --git a/arch/sparc/include/asm/vga.h b/arch/sparc/include/asm/vga.h
index ec0e9967d93d..f54e8b6fb197 100644
--- a/arch/sparc/include/asm/vga.h
+++ b/arch/sparc/include/asm/vga.h
@@ -8,9 +8,13 @@
8#define _LINUX_ASM_VGA_H_ 8#define _LINUX_ASM_VGA_H_
9 9
10#include <linux/bug.h> 10#include <linux/bug.h>
11#include <linux/string.h>
11#include <asm/types.h> 12#include <asm/types.h>
12 13
13#define VT_BUF_HAVE_RW 14#define VT_BUF_HAVE_RW
15#define VT_BUF_HAVE_MEMSETW
16#define VT_BUF_HAVE_MEMCPYW
17#define VT_BUF_HAVE_MEMMOVEW
14 18
15#undef scr_writew 19#undef scr_writew
16#undef scr_readw 20#undef scr_readw
@@ -29,6 +33,27 @@ static inline u16 scr_readw(const u16 *addr)
29 return *addr; 33 return *addr;
30} 34}
31 35
36static inline void scr_memsetw(u16 *p, u16 v, unsigned int n)
37{
38 BUG_ON((long) p >= 0);
39
40 memset16(p, cpu_to_le16(v), n / 2);
41}
42
43static inline void scr_memcpyw(u16 *d, u16 *s, unsigned int n)
44{
45 BUG_ON((long) d >= 0);
46
47 memcpy(d, s, n);
48}
49
50static inline void scr_memmovew(u16 *d, u16 *s, unsigned int n)
51{
52 BUG_ON((long) d >= 0);
53
54 memmove(d, s, n);
55}
56
32#define VGA_MAP_MEM(x,s) (x) 57#define VGA_MAP_MEM(x,s) (x)
33 58
34#endif 59#endif
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index 443a70bccc1c..6becb96c60a0 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -1200,7 +1200,7 @@ static void __init validate_hv(void)
1200 * We use a struct cpumask for this, so it must be big enough. 1200 * We use a struct cpumask for this, so it must be big enough.
1201 */ 1201 */
1202 if ((smp_height * smp_width) > nr_cpu_ids) 1202 if ((smp_height * smp_width) > nr_cpu_ids)
1203 early_panic("Hypervisor %d x %d grid too big for Linux NR_CPUS %d\n", 1203 early_panic("Hypervisor %d x %d grid too big for Linux NR_CPUS %u\n",
1204 smp_height, smp_width, nr_cpu_ids); 1204 smp_height, smp_width, nr_cpu_ids);
1205#endif 1205#endif
1206 1206
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 4b278a33ccbb..a3e6e6136a47 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2323,6 +2323,10 @@ source "kernel/livepatch/Kconfig"
2323 2323
2324endmenu 2324endmenu
2325 2325
2326config ARCH_HAS_ADD_PAGES
2327 def_bool y
2328 depends on X86_64 && ARCH_ENABLE_MEMORY_HOTPLUG
2329
2326config ARCH_ENABLE_MEMORY_HOTPLUG 2330config ARCH_ENABLE_MEMORY_HOTPLUG
2327 def_bool y 2331 def_bool y
2328 depends on X86_64 || (X86_32 && HIGHMEM) 2332 depends on X86_64 || (X86_32 && HIGHMEM)
@@ -2343,6 +2347,10 @@ config ARCH_ENABLE_HUGEPAGE_MIGRATION
2343 def_bool y 2347 def_bool y
2344 depends on X86_64 && HUGETLB_PAGE && MIGRATION 2348 depends on X86_64 && HUGETLB_PAGE && MIGRATION
2345 2349
2350config ARCH_ENABLE_THP_MIGRATION
2351 def_bool y
2352 depends on X86_64 && TRANSPARENT_HUGEPAGE
2353
2346menu "Power management and ACPI options" 2354menu "Power management and ACPI options"
2347 2355
2348config ARCH_HIBERNATION_HEADER 2356config ARCH_HIBERNATION_HEADER
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index bbeae4a2bd01..5b4c44d419c5 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1172,6 +1172,23 @@ static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
1172{ 1172{
1173 return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY); 1173 return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
1174} 1174}
1175
1176#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
1177static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd)
1178{
1179 return pmd_set_flags(pmd, _PAGE_SWP_SOFT_DIRTY);
1180}
1181
1182static inline int pmd_swp_soft_dirty(pmd_t pmd)
1183{
1184 return pmd_flags(pmd) & _PAGE_SWP_SOFT_DIRTY;
1185}
1186
1187static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd)
1188{
1189 return pmd_clear_flags(pmd, _PAGE_SWP_SOFT_DIRTY);
1190}
1191#endif
1175#endif 1192#endif
1176 1193
1177#define PKRU_AD_BIT 0x1 1194#define PKRU_AD_BIT 0x1
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 2160c1fee920..972a4698c530 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -180,15 +180,21 @@ static inline int pgd_large(pgd_t pgd) { return 0; }
180/* 180/*
181 * Encode and de-code a swap entry 181 * Encode and de-code a swap entry
182 * 182 *
183 * | ... | 11| 10| 9|8|7|6|5| 4| 3|2|1|0| <- bit number 183 * | ... | 11| 10| 9|8|7|6|5| 4| 3|2| 1|0| <- bit number
184 * | ... |SW3|SW2|SW1|G|L|D|A|CD|WT|U|W|P| <- bit names 184 * | ... |SW3|SW2|SW1|G|L|D|A|CD|WT|U| W|P| <- bit names
185 * | OFFSET (14->63) | TYPE (9-13) |0|X|X|X| X| X|X|X|0| <- swp entry 185 * | OFFSET (14->63) | TYPE (9-13) |0|0|X|X| X| X|X|SD|0| <- swp entry
186 * 186 *
187 * G (8) is aliased and used as a PROT_NONE indicator for 187 * G (8) is aliased and used as a PROT_NONE indicator for
188 * !present ptes. We need to start storing swap entries above 188 * !present ptes. We need to start storing swap entries above
189 * there. We also need to avoid using A and D because of an 189 * there. We also need to avoid using A and D because of an
190 * erratum where they can be incorrectly set by hardware on 190 * erratum where they can be incorrectly set by hardware on
191 * non-present PTEs. 191 * non-present PTEs.
192 *
193 * SD (1) in swp entry is used to store soft dirty bit, which helps us
194 * remember soft dirty over page migration
195 *
196 * Bit 7 in swp entry should be 0 because pmd_present checks not only P,
197 * but also L and G.
192 */ 198 */
193#define SWP_TYPE_FIRST_BIT (_PAGE_BIT_PROTNONE + 1) 199#define SWP_TYPE_FIRST_BIT (_PAGE_BIT_PROTNONE + 1)
194#define SWP_TYPE_BITS 5 200#define SWP_TYPE_BITS 5
@@ -204,7 +210,9 @@ static inline int pgd_large(pgd_t pgd) { return 0; }
204 ((type) << (SWP_TYPE_FIRST_BIT)) \ 210 ((type) << (SWP_TYPE_FIRST_BIT)) \
205 | ((offset) << SWP_OFFSET_FIRST_BIT) }) 211 | ((offset) << SWP_OFFSET_FIRST_BIT) })
206#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val((pte)) }) 212#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val((pte)) })
213#define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val((pmd)) })
207#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) 214#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val })
215#define __swp_entry_to_pmd(x) ((pmd_t) { .pmd = (x).val })
208 216
209extern int kern_addr_valid(unsigned long addr); 217extern int kern_addr_valid(unsigned long addr);
210extern void cleanup_highmap(void); 218extern void cleanup_highmap(void);
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 399261ce904c..f1492473f10e 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -99,15 +99,15 @@
99/* 99/*
100 * Tracking soft dirty bit when a page goes to a swap is tricky. 100 * Tracking soft dirty bit when a page goes to a swap is tricky.
101 * We need a bit which can be stored in pte _and_ not conflict 101 * We need a bit which can be stored in pte _and_ not conflict
102 * with swap entry format. On x86 bits 6 and 7 are *not* involved 102 * with swap entry format. On x86 bits 1-4 are *not* involved
103 * into swap entry computation, but bit 6 is used for nonlinear 103 * into swap entry computation, but bit 7 is used for thp migration,
104 * file mapping, so we borrow bit 7 for soft dirty tracking. 104 * so we borrow bit 1 for soft dirty tracking.
105 * 105 *
106 * Please note that this bit must be treated as swap dirty page 106 * Please note that this bit must be treated as swap dirty page
107 * mark if and only if the PTE has present bit clear! 107 * mark if and only if the PTE/PMD has present bit clear!
108 */ 108 */
109#ifdef CONFIG_MEM_SOFT_DIRTY 109#ifdef CONFIG_MEM_SOFT_DIRTY
110#define _PAGE_SWP_SOFT_DIRTY _PAGE_PSE 110#define _PAGE_SWP_SOFT_DIRTY _PAGE_RW
111#else 111#else
112#define _PAGE_SWP_SOFT_DIRTY (_AT(pteval_t, 0)) 112#define _PAGE_SWP_SOFT_DIRTY (_AT(pteval_t, 0))
113#endif 113#endif
diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
index e9ee84873de5..e371e7229042 100644
--- a/arch/x86/include/asm/string_32.h
+++ b/arch/x86/include/asm/string_32.h
@@ -340,6 +340,30 @@ extern void *memset(void *, int, size_t);
340#endif 340#endif
341#endif /* !CONFIG_FORTIFY_SOURCE */ 341#endif /* !CONFIG_FORTIFY_SOURCE */
342 342
343#define __HAVE_ARCH_MEMSET16
344static inline void *memset16(uint16_t *s, uint16_t v, size_t n)
345{
346 int d0, d1;
347 asm volatile("rep\n\t"
348 "stosw"
349 : "=&c" (d0), "=&D" (d1)
350 : "a" (v), "1" (s), "0" (n)
351 : "memory");
352 return s;
353}
354
355#define __HAVE_ARCH_MEMSET32
356static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
357{
358 int d0, d1;
359 asm volatile("rep\n\t"
360 "stosl"
361 : "=&c" (d0), "=&D" (d1)
362 : "a" (v), "1" (s), "0" (n)
363 : "memory");
364 return s;
365}
366
343/* 367/*
344 * find the first occurrence of byte 'c', or 1 past the area if none 368 * find the first occurrence of byte 'c', or 1 past the area if none
345 */ 369 */
diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h
index 2a8c822de1fc..f372a70a523f 100644
--- a/arch/x86/include/asm/string_64.h
+++ b/arch/x86/include/asm/string_64.h
@@ -58,6 +58,42 @@ extern void *__memcpy(void *to, const void *from, size_t len);
58void *memset(void *s, int c, size_t n); 58void *memset(void *s, int c, size_t n);
59void *__memset(void *s, int c, size_t n); 59void *__memset(void *s, int c, size_t n);
60 60
61#define __HAVE_ARCH_MEMSET16
62static inline void *memset16(uint16_t *s, uint16_t v, size_t n)
63{
64 long d0, d1;
65 asm volatile("rep\n\t"
66 "stosw"
67 : "=&c" (d0), "=&D" (d1)
68 : "a" (v), "1" (s), "0" (n)
69 : "memory");
70 return s;
71}
72
73#define __HAVE_ARCH_MEMSET32
74static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
75{
76 long d0, d1;
77 asm volatile("rep\n\t"
78 "stosl"
79 : "=&c" (d0), "=&D" (d1)
80 : "a" (v), "1" (s), "0" (n)
81 : "memory");
82 return s;
83}
84
85#define __HAVE_ARCH_MEMSET64
86static inline void *memset64(uint64_t *s, uint64_t v, size_t n)
87{
88 long d0, d1;
89 asm volatile("rep\n\t"
90 "stosq"
91 : "=&c" (d0), "=&D" (d1)
92 : "a" (v), "1" (s), "0" (n)
93 : "memory");
94 return s;
95}
96
61#define __HAVE_ARCH_MEMMOVE 97#define __HAVE_ARCH_MEMMOVE
62void *memmove(void *dest, const void *src, size_t count); 98void *memmove(void *dest, const void *src, size_t count);
63void *__memmove(void *dest, const void *src, size_t count); 99void *__memmove(void *dest, const void *src, size_t count);
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 7834f73efbf1..8315e2f517a7 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2097,7 +2097,7 @@ static int allocate_logical_cpuid(int apicid)
2097 2097
2098 /* Allocate a new cpuid. */ 2098 /* Allocate a new cpuid. */
2099 if (nr_logical_cpuids >= nr_cpu_ids) { 2099 if (nr_logical_cpuids >= nr_cpu_ids) {
2100 WARN_ONCE(1, "APIC: NR_CPUS/possible_cpus limit of %i reached. " 2100 WARN_ONCE(1, "APIC: NR_CPUS/possible_cpus limit of %u reached. "
2101 "Processor %d/0x%x and the rest are ignored.\n", 2101 "Processor %d/0x%x and the rest are ignored.\n",
2102 nr_cpu_ids, nr_logical_cpuids, apicid); 2102 nr_cpu_ids, nr_logical_cpuids, apicid);
2103 return -EINVAL; 2103 return -EINVAL;
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 6e8fcb6f7e1e..28dafed6c682 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -168,7 +168,7 @@ void __init setup_per_cpu_areas(void)
168 unsigned long delta; 168 unsigned long delta;
169 int rc; 169 int rc;
170 170
171 pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n", 171 pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%u nr_node_ids:%d\n",
172 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids); 172 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids);
173 173
174 /* 174 /*
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 54b9e89d4d6b..cd6622c3204e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1461,7 +1461,7 @@ __init void prefill_possible_map(void)
1461 1461
1462 /* nr_cpu_ids could be reduced via nr_cpus= */ 1462 /* nr_cpu_ids could be reduced via nr_cpus= */
1463 if (possible > nr_cpu_ids) { 1463 if (possible > nr_cpu_ids) {
1464 pr_warn("%d Processors exceeds NR_CPUS limit of %d\n", 1464 pr_warn("%d Processors exceeds NR_CPUS limit of %u\n",
1465 possible, nr_cpu_ids); 1465 possible, nr_cpu_ids);
1466 possible = nr_cpu_ids; 1466 possible = nr_cpu_ids;
1467 } 1467 }
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 136422d7d539..048fbe8fc274 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -761,7 +761,7 @@ void __init paging_init(void)
761 * After memory hotplug the variables max_pfn, max_low_pfn and high_memory need 761 * After memory hotplug the variables max_pfn, max_low_pfn and high_memory need
762 * updating. 762 * updating.
763 */ 763 */
764static void update_end_of_memory_vars(u64 start, u64 size) 764static void update_end_of_memory_vars(u64 start, u64 size)
765{ 765{
766 unsigned long end_pfn = PFN_UP(start + size); 766 unsigned long end_pfn = PFN_UP(start + size);
767 767
@@ -772,22 +772,30 @@ static void update_end_of_memory_vars(u64 start, u64 size)
772 } 772 }
773} 773}
774 774
775int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock) 775int add_pages(int nid, unsigned long start_pfn,
776 unsigned long nr_pages, bool want_memblock)
776{ 777{
777 unsigned long start_pfn = start >> PAGE_SHIFT;
778 unsigned long nr_pages = size >> PAGE_SHIFT;
779 int ret; 778 int ret;
780 779
781 init_memory_mapping(start, start + size);
782
783 ret = __add_pages(nid, start_pfn, nr_pages, want_memblock); 780 ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
784 WARN_ON_ONCE(ret); 781 WARN_ON_ONCE(ret);
785 782
786 /* update max_pfn, max_low_pfn and high_memory */ 783 /* update max_pfn, max_low_pfn and high_memory */
787 update_end_of_memory_vars(start, size); 784 update_end_of_memory_vars(start_pfn << PAGE_SHIFT,
785 nr_pages << PAGE_SHIFT);
788 786
789 return ret; 787 return ret;
790} 788}
789
790int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
791{
792 unsigned long start_pfn = start >> PAGE_SHIFT;
793 unsigned long nr_pages = size >> PAGE_SHIFT;
794
795 init_memory_mapping(start, start + size);
796
797 return add_pages(nid, start_pfn, nr_pages, want_memblock);
798}
791EXPORT_SYMBOL_GPL(arch_add_memory); 799EXPORT_SYMBOL_GPL(arch_add_memory);
792 800
793#define PAGE_INUSE 0xFD 801#define PAGE_INUSE 0xFD
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 9b86e9b352e9..9f342ef1ad42 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -93,13 +93,14 @@ struct cfq_ttime {
93 * move this into the elevator for the rq sorting as well. 93 * move this into the elevator for the rq sorting as well.
94 */ 94 */
95struct cfq_rb_root { 95struct cfq_rb_root {
96 struct rb_root rb; 96 struct rb_root_cached rb;
97 struct rb_node *left; 97 struct rb_node *rb_rightmost;
98 unsigned count; 98 unsigned count;
99 u64 min_vdisktime; 99 u64 min_vdisktime;
100 struct cfq_ttime ttime; 100 struct cfq_ttime ttime;
101}; 101};
102#define CFQ_RB_ROOT (struct cfq_rb_root) { .rb = RB_ROOT, \ 102#define CFQ_RB_ROOT (struct cfq_rb_root) { .rb = RB_ROOT_CACHED, \
103 .rb_rightmost = NULL, \
103 .ttime = {.last_end_request = ktime_get_ns(),},} 104 .ttime = {.last_end_request = ktime_get_ns(),},}
104 105
105/* 106/*
@@ -981,10 +982,9 @@ static inline u64 max_vdisktime(u64 min_vdisktime, u64 vdisktime)
981 982
982static void update_min_vdisktime(struct cfq_rb_root *st) 983static void update_min_vdisktime(struct cfq_rb_root *st)
983{ 984{
984 struct cfq_group *cfqg; 985 if (!RB_EMPTY_ROOT(&st->rb.rb_root)) {
986 struct cfq_group *cfqg = rb_entry_cfqg(st->rb.rb_leftmost);
985 987
986 if (st->left) {
987 cfqg = rb_entry_cfqg(st->left);
988 st->min_vdisktime = max_vdisktime(st->min_vdisktime, 988 st->min_vdisktime = max_vdisktime(st->min_vdisktime,
989 cfqg->vdisktime); 989 cfqg->vdisktime);
990 } 990 }
@@ -1166,46 +1166,28 @@ cfq_choose_req(struct cfq_data *cfqd, struct request *rq1, struct request *rq2,
1166 } 1166 }
1167} 1167}
1168 1168
1169/*
1170 * The below is leftmost cache rbtree addon
1171 */
1172static struct cfq_queue *cfq_rb_first(struct cfq_rb_root *root) 1169static struct cfq_queue *cfq_rb_first(struct cfq_rb_root *root)
1173{ 1170{
1174 /* Service tree is empty */ 1171 /* Service tree is empty */
1175 if (!root->count) 1172 if (!root->count)
1176 return NULL; 1173 return NULL;
1177 1174
1178 if (!root->left) 1175 return rb_entry(rb_first_cached(&root->rb), struct cfq_queue, rb_node);
1179 root->left = rb_first(&root->rb);
1180
1181 if (root->left)
1182 return rb_entry(root->left, struct cfq_queue, rb_node);
1183
1184 return NULL;
1185} 1176}
1186 1177
1187static struct cfq_group *cfq_rb_first_group(struct cfq_rb_root *root) 1178static struct cfq_group *cfq_rb_first_group(struct cfq_rb_root *root)
1188{ 1179{
1189 if (!root->left) 1180 return rb_entry_cfqg(rb_first_cached(&root->rb));
1190 root->left = rb_first(&root->rb);
1191
1192 if (root->left)
1193 return rb_entry_cfqg(root->left);
1194
1195 return NULL;
1196} 1181}
1197 1182
1198static void rb_erase_init(struct rb_node *n, struct rb_root *root) 1183static void cfq_rb_erase(struct rb_node *n, struct cfq_rb_root *root)
1199{ 1184{
1200 rb_erase(n, root); 1185 if (root->rb_rightmost == n)
1186 root->rb_rightmost = rb_prev(n);
1187
1188 rb_erase_cached(n, &root->rb);
1201 RB_CLEAR_NODE(n); 1189 RB_CLEAR_NODE(n);
1202}
1203 1190
1204static void cfq_rb_erase(struct rb_node *n, struct cfq_rb_root *root)
1205{
1206 if (root->left == n)
1207 root->left = NULL;
1208 rb_erase_init(n, &root->rb);
1209 --root->count; 1191 --root->count;
1210} 1192}
1211 1193
@@ -1255,29 +1237,30 @@ cfqg_key(struct cfq_rb_root *st, struct cfq_group *cfqg)
1255static void 1237static void
1256__cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg) 1238__cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1257{ 1239{
1258 struct rb_node **node = &st->rb.rb_node; 1240 struct rb_node **node = &st->rb.rb_root.rb_node;
1259 struct rb_node *parent = NULL; 1241 struct rb_node *parent = NULL;
1260 struct cfq_group *__cfqg; 1242 struct cfq_group *__cfqg;
1261 s64 key = cfqg_key(st, cfqg); 1243 s64 key = cfqg_key(st, cfqg);
1262 int left = 1; 1244 bool leftmost = true, rightmost = true;
1263 1245
1264 while (*node != NULL) { 1246 while (*node != NULL) {
1265 parent = *node; 1247 parent = *node;
1266 __cfqg = rb_entry_cfqg(parent); 1248 __cfqg = rb_entry_cfqg(parent);
1267 1249
1268 if (key < cfqg_key(st, __cfqg)) 1250 if (key < cfqg_key(st, __cfqg)) {
1269 node = &parent->rb_left; 1251 node = &parent->rb_left;
1270 else { 1252 rightmost = false;
1253 } else {
1271 node = &parent->rb_right; 1254 node = &parent->rb_right;
1272 left = 0; 1255 leftmost = false;
1273 } 1256 }
1274 } 1257 }
1275 1258
1276 if (left) 1259 if (rightmost)
1277 st->left = &cfqg->rb_node; 1260 st->rb_rightmost = &cfqg->rb_node;
1278 1261
1279 rb_link_node(&cfqg->rb_node, parent, node); 1262 rb_link_node(&cfqg->rb_node, parent, node);
1280 rb_insert_color(&cfqg->rb_node, &st->rb); 1263 rb_insert_color_cached(&cfqg->rb_node, &st->rb, leftmost);
1281} 1264}
1282 1265
1283/* 1266/*
@@ -1378,7 +1361,7 @@ cfq_group_notify_queue_add(struct cfq_data *cfqd, struct cfq_group *cfqg)
1378 * so that groups get lesser vtime based on their weights, so that 1361 * so that groups get lesser vtime based on their weights, so that
1379 * if group does not loose all if it was not continuously backlogged. 1362 * if group does not loose all if it was not continuously backlogged.
1380 */ 1363 */
1381 n = rb_last(&st->rb); 1364 n = st->rb_rightmost;
1382 if (n) { 1365 if (n) {
1383 __cfqg = rb_entry_cfqg(n); 1366 __cfqg = rb_entry_cfqg(n);
1384 cfqg->vdisktime = __cfqg->vdisktime + 1367 cfqg->vdisktime = __cfqg->vdisktime +
@@ -2220,14 +2203,14 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
2220 struct cfq_queue *__cfqq; 2203 struct cfq_queue *__cfqq;
2221 u64 rb_key; 2204 u64 rb_key;
2222 struct cfq_rb_root *st; 2205 struct cfq_rb_root *st;
2223 int left; 2206 bool leftmost = true;
2224 int new_cfqq = 1; 2207 int new_cfqq = 1;
2225 u64 now = ktime_get_ns(); 2208 u64 now = ktime_get_ns();
2226 2209
2227 st = st_for(cfqq->cfqg, cfqq_class(cfqq), cfqq_type(cfqq)); 2210 st = st_for(cfqq->cfqg, cfqq_class(cfqq), cfqq_type(cfqq));
2228 if (cfq_class_idle(cfqq)) { 2211 if (cfq_class_idle(cfqq)) {
2229 rb_key = CFQ_IDLE_DELAY; 2212 rb_key = CFQ_IDLE_DELAY;
2230 parent = rb_last(&st->rb); 2213 parent = st->rb_rightmost;
2231 if (parent && parent != &cfqq->rb_node) { 2214 if (parent && parent != &cfqq->rb_node) {
2232 __cfqq = rb_entry(parent, struct cfq_queue, rb_node); 2215 __cfqq = rb_entry(parent, struct cfq_queue, rb_node);
2233 rb_key += __cfqq->rb_key; 2216 rb_key += __cfqq->rb_key;
@@ -2261,10 +2244,9 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
2261 cfqq->service_tree = NULL; 2244 cfqq->service_tree = NULL;
2262 } 2245 }
2263 2246
2264 left = 1;
2265 parent = NULL; 2247 parent = NULL;
2266 cfqq->service_tree = st; 2248 cfqq->service_tree = st;
2267 p = &st->rb.rb_node; 2249 p = &st->rb.rb_root.rb_node;
2268 while (*p) { 2250 while (*p) {
2269 parent = *p; 2251 parent = *p;
2270 __cfqq = rb_entry(parent, struct cfq_queue, rb_node); 2252 __cfqq = rb_entry(parent, struct cfq_queue, rb_node);
@@ -2276,16 +2258,13 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
2276 p = &parent->rb_left; 2258 p = &parent->rb_left;
2277 else { 2259 else {
2278 p = &parent->rb_right; 2260 p = &parent->rb_right;
2279 left = 0; 2261 leftmost = false;
2280 } 2262 }
2281 } 2263 }
2282 2264
2283 if (left)
2284 st->left = &cfqq->rb_node;
2285
2286 cfqq->rb_key = rb_key; 2265 cfqq->rb_key = rb_key;
2287 rb_link_node(&cfqq->rb_node, parent, p); 2266 rb_link_node(&cfqq->rb_node, parent, p);
2288 rb_insert_color(&cfqq->rb_node, &st->rb); 2267 rb_insert_color_cached(&cfqq->rb_node, &st->rb, leftmost);
2289 st->count++; 2268 st->count++;
2290 if (add_front || !new_cfqq) 2269 if (add_front || !new_cfqq)
2291 return; 2270 return;
@@ -2732,7 +2711,7 @@ static struct cfq_queue *cfq_get_next_queue(struct cfq_data *cfqd)
2732 /* There is nothing to dispatch */ 2711 /* There is nothing to dispatch */
2733 if (!st) 2712 if (!st)
2734 return NULL; 2713 return NULL;
2735 if (RB_EMPTY_ROOT(&st->rb)) 2714 if (RB_EMPTY_ROOT(&st->rb.rb_root))
2736 return NULL; 2715 return NULL;
2737 return cfq_rb_first(st); 2716 return cfq_rb_first(st);
2738} 2717}
@@ -3219,7 +3198,7 @@ static struct cfq_group *cfq_get_next_cfqg(struct cfq_data *cfqd)
3219 struct cfq_rb_root *st = &cfqd->grp_service_tree; 3198 struct cfq_rb_root *st = &cfqd->grp_service_tree;
3220 struct cfq_group *cfqg; 3199 struct cfq_group *cfqg;
3221 3200
3222 if (RB_EMPTY_ROOT(&st->rb)) 3201 if (RB_EMPTY_ROOT(&st->rb.rb_root))
3223 return NULL; 3202 return NULL;
3224 cfqg = cfq_rb_first_group(st); 3203 cfqg = cfq_rb_first_group(st);
3225 update_min_vdisktime(st); 3204 update_min_vdisktime(st);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 2c3b359b3536..321cd7b4d817 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -256,9 +256,9 @@ static ssize_t print_cpus_offline(struct device *dev,
256 buf[n++] = ','; 256 buf[n++] = ',';
257 257
258 if (nr_cpu_ids == total_cpus-1) 258 if (nr_cpu_ids == total_cpus-1)
259 n += snprintf(&buf[n], len - n, "%d", nr_cpu_ids); 259 n += snprintf(&buf[n], len - n, "%u", nr_cpu_ids);
260 else 260 else
261 n += snprintf(&buf[n], len - n, "%d-%d", 261 n += snprintf(&buf[n], len - n, "%u-%d",
262 nr_cpu_ids, total_cpus-1); 262 nr_cpu_ids, total_cpus-1);
263 } 263 }
264 264
diff --git a/drivers/base/node.c b/drivers/base/node.c
index d8dc83017d8d..3855902f2c5b 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -160,12 +160,12 @@ static ssize_t node_read_numastat(struct device *dev,
160 "interleave_hit %lu\n" 160 "interleave_hit %lu\n"
161 "local_node %lu\n" 161 "local_node %lu\n"
162 "other_node %lu\n", 162 "other_node %lu\n",
163 sum_zone_node_page_state(dev->id, NUMA_HIT), 163 sum_zone_numa_state(dev->id, NUMA_HIT),
164 sum_zone_node_page_state(dev->id, NUMA_MISS), 164 sum_zone_numa_state(dev->id, NUMA_MISS),
165 sum_zone_node_page_state(dev->id, NUMA_FOREIGN), 165 sum_zone_numa_state(dev->id, NUMA_FOREIGN),
166 sum_zone_node_page_state(dev->id, NUMA_INTERLEAVE_HIT), 166 sum_zone_numa_state(dev->id, NUMA_INTERLEAVE_HIT),
167 sum_zone_node_page_state(dev->id, NUMA_LOCAL), 167 sum_zone_numa_state(dev->id, NUMA_LOCAL),
168 sum_zone_node_page_state(dev->id, NUMA_OTHER)); 168 sum_zone_numa_state(dev->id, NUMA_OTHER));
169} 169}
170static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); 170static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
171 171
@@ -181,9 +181,17 @@ static ssize_t node_read_vmstat(struct device *dev,
181 n += sprintf(buf+n, "%s %lu\n", vmstat_text[i], 181 n += sprintf(buf+n, "%s %lu\n", vmstat_text[i],
182 sum_zone_node_page_state(nid, i)); 182 sum_zone_node_page_state(nid, i));
183 183
184 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) 184#ifdef CONFIG_NUMA
185 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
185 n += sprintf(buf+n, "%s %lu\n", 186 n += sprintf(buf+n, "%s %lu\n",
186 vmstat_text[i + NR_VM_ZONE_STAT_ITEMS], 187 vmstat_text[i + NR_VM_ZONE_STAT_ITEMS],
188 sum_zone_numa_state(nid, i));
189#endif
190
191 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
192 n += sprintf(buf+n, "%s %lu\n",
193 vmstat_text[i + NR_VM_ZONE_STAT_ITEMS +
194 NR_VM_NUMA_STAT_ITEMS],
187 node_page_state(pgdat, i)); 195 node_page_state(pgdat, i));
188 196
189 return n; 197 return n;
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 4063f3f59f4f..2981c27d3aae 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -175,20 +175,11 @@ static inline void update_used_max(struct zram *zram,
175 } while (old_max != cur_max); 175 } while (old_max != cur_max);
176} 176}
177 177
178static inline void zram_fill_page(char *ptr, unsigned long len, 178static inline void zram_fill_page(void *ptr, unsigned long len,
179 unsigned long value) 179 unsigned long value)
180{ 180{
181 int i;
182 unsigned long *page = (unsigned long *)ptr;
183
184 WARN_ON_ONCE(!IS_ALIGNED(len, sizeof(unsigned long))); 181 WARN_ON_ONCE(!IS_ALIGNED(len, sizeof(unsigned long)));
185 182 memset_l(ptr, value, len / sizeof(unsigned long));
186 if (likely(value == 0)) {
187 memset(ptr, 0, len);
188 } else {
189 for (i = 0; i < len / sizeof(*page); i++)
190 page[i] = value;
191 }
192} 183}
193 184
194static bool page_same_filled(void *ptr, unsigned long *element) 185static bool page_same_filled(void *ptr, unsigned long *element)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
index e1cde6b80027..3b0f2ec6eec7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
@@ -51,7 +51,7 @@ struct amdgpu_mn {
51 51
52 /* objects protected by lock */ 52 /* objects protected by lock */
53 struct mutex lock; 53 struct mutex lock;
54 struct rb_root objects; 54 struct rb_root_cached objects;
55}; 55};
56 56
57struct amdgpu_mn_node { 57struct amdgpu_mn_node {
@@ -76,8 +76,8 @@ static void amdgpu_mn_destroy(struct work_struct *work)
76 mutex_lock(&adev->mn_lock); 76 mutex_lock(&adev->mn_lock);
77 mutex_lock(&rmn->lock); 77 mutex_lock(&rmn->lock);
78 hash_del(&rmn->node); 78 hash_del(&rmn->node);
79 rbtree_postorder_for_each_entry_safe(node, next_node, &rmn->objects, 79 rbtree_postorder_for_each_entry_safe(node, next_node,
80 it.rb) { 80 &rmn->objects.rb_root, it.rb) {
81 list_for_each_entry_safe(bo, next_bo, &node->bos, mn_list) { 81 list_for_each_entry_safe(bo, next_bo, &node->bos, mn_list) {
82 bo->mn = NULL; 82 bo->mn = NULL;
83 list_del_init(&bo->mn_list); 83 list_del_init(&bo->mn_list);
@@ -221,7 +221,7 @@ static struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev)
221 rmn->mm = mm; 221 rmn->mm = mm;
222 rmn->mn.ops = &amdgpu_mn_ops; 222 rmn->mn.ops = &amdgpu_mn_ops;
223 mutex_init(&rmn->lock); 223 mutex_init(&rmn->lock);
224 rmn->objects = RB_ROOT; 224 rmn->objects = RB_ROOT_CACHED;
225 225
226 r = __mmu_notifier_register(&rmn->mn, mm); 226 r = __mmu_notifier_register(&rmn->mn, mm);
227 if (r) 227 if (r)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 6b1343e5541d..b9a5a77eedaf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2475,7 +2475,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
2475 u64 flags; 2475 u64 flags;
2476 uint64_t init_pde_value = 0; 2476 uint64_t init_pde_value = 0;
2477 2477
2478 vm->va = RB_ROOT; 2478 vm->va = RB_ROOT_CACHED;
2479 vm->client_id = atomic64_inc_return(&adev->vm_manager.client_counter); 2479 vm->client_id = atomic64_inc_return(&adev->vm_manager.client_counter);
2480 for (i = 0; i < AMDGPU_MAX_VMHUBS; i++) 2480 for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
2481 vm->reserved_vmid[i] = NULL; 2481 vm->reserved_vmid[i] = NULL;
@@ -2596,10 +2596,11 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
2596 2596
2597 amd_sched_entity_fini(vm->entity.sched, &vm->entity); 2597 amd_sched_entity_fini(vm->entity.sched, &vm->entity);
2598 2598
2599 if (!RB_EMPTY_ROOT(&vm->va)) { 2599 if (!RB_EMPTY_ROOT(&vm->va.rb_root)) {
2600 dev_err(adev->dev, "still active bo inside vm\n"); 2600 dev_err(adev->dev, "still active bo inside vm\n");
2601 } 2601 }
2602 rbtree_postorder_for_each_entry_safe(mapping, tmp, &vm->va, rb) { 2602 rbtree_postorder_for_each_entry_safe(mapping, tmp,
2603 &vm->va.rb_root, rb) {
2603 list_del(&mapping->list); 2604 list_del(&mapping->list);
2604 amdgpu_vm_it_remove(mapping, &vm->va); 2605 amdgpu_vm_it_remove(mapping, &vm->va);
2605 kfree(mapping); 2606 kfree(mapping);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index ba6691b58ee7..6716355403ec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -118,7 +118,7 @@ struct amdgpu_vm_pt {
118 118
119struct amdgpu_vm { 119struct amdgpu_vm {
120 /* tree of virtual addresses mapped */ 120 /* tree of virtual addresses mapped */
121 struct rb_root va; 121 struct rb_root_cached va;
122 122
123 /* protecting invalidated */ 123 /* protecting invalidated */
124 spinlock_t status_lock; 124 spinlock_t status_lock;
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index f794089d30ac..61a1c8ea74bc 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -169,7 +169,7 @@ INTERVAL_TREE_DEFINE(struct drm_mm_node, rb,
169struct drm_mm_node * 169struct drm_mm_node *
170__drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last) 170__drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last)
171{ 171{
172 return drm_mm_interval_tree_iter_first((struct rb_root *)&mm->interval_tree, 172 return drm_mm_interval_tree_iter_first((struct rb_root_cached *)&mm->interval_tree,
173 start, last) ?: (struct drm_mm_node *)&mm->head_node; 173 start, last) ?: (struct drm_mm_node *)&mm->head_node;
174} 174}
175EXPORT_SYMBOL(__drm_mm_interval_first); 175EXPORT_SYMBOL(__drm_mm_interval_first);
@@ -180,6 +180,7 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
180 struct drm_mm *mm = hole_node->mm; 180 struct drm_mm *mm = hole_node->mm;
181 struct rb_node **link, *rb; 181 struct rb_node **link, *rb;
182 struct drm_mm_node *parent; 182 struct drm_mm_node *parent;
183 bool leftmost = true;
183 184
184 node->__subtree_last = LAST(node); 185 node->__subtree_last = LAST(node);
185 186
@@ -196,9 +197,10 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
196 197
197 rb = &hole_node->rb; 198 rb = &hole_node->rb;
198 link = &hole_node->rb.rb_right; 199 link = &hole_node->rb.rb_right;
200 leftmost = false;
199 } else { 201 } else {
200 rb = NULL; 202 rb = NULL;
201 link = &mm->interval_tree.rb_node; 203 link = &mm->interval_tree.rb_root.rb_node;
202 } 204 }
203 205
204 while (*link) { 206 while (*link) {
@@ -208,14 +210,15 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
208 parent->__subtree_last = node->__subtree_last; 210 parent->__subtree_last = node->__subtree_last;
209 if (node->start < parent->start) 211 if (node->start < parent->start)
210 link = &parent->rb.rb_left; 212 link = &parent->rb.rb_left;
211 else 213 else {
212 link = &parent->rb.rb_right; 214 link = &parent->rb.rb_right;
215 leftmost = true;
216 }
213 } 217 }
214 218
215 rb_link_node(&node->rb, rb, link); 219 rb_link_node(&node->rb, rb, link);
216 rb_insert_augmented(&node->rb, 220 rb_insert_augmented_cached(&node->rb, &mm->interval_tree, leftmost,
217 &mm->interval_tree, 221 &drm_mm_interval_tree_augment);
218 &drm_mm_interval_tree_augment);
219} 222}
220 223
221#define RB_INSERT(root, member, expr) do { \ 224#define RB_INSERT(root, member, expr) do { \
@@ -577,7 +580,7 @@ void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
577 *new = *old; 580 *new = *old;
578 581
579 list_replace(&old->node_list, &new->node_list); 582 list_replace(&old->node_list, &new->node_list);
580 rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree); 583 rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree.rb_root);
581 584
582 if (drm_mm_hole_follows(old)) { 585 if (drm_mm_hole_follows(old)) {
583 list_replace(&old->hole_stack, &new->hole_stack); 586 list_replace(&old->hole_stack, &new->hole_stack);
@@ -863,7 +866,7 @@ void drm_mm_init(struct drm_mm *mm, u64 start, u64 size)
863 mm->color_adjust = NULL; 866 mm->color_adjust = NULL;
864 867
865 INIT_LIST_HEAD(&mm->hole_stack); 868 INIT_LIST_HEAD(&mm->hole_stack);
866 mm->interval_tree = RB_ROOT; 869 mm->interval_tree = RB_ROOT_CACHED;
867 mm->holes_size = RB_ROOT; 870 mm->holes_size = RB_ROOT;
868 mm->holes_addr = RB_ROOT; 871 mm->holes_addr = RB_ROOT;
869 872
diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
index d9100b565198..28f1226576f8 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -147,7 +147,7 @@ struct drm_vma_offset_node *drm_vma_offset_lookup_locked(struct drm_vma_offset_m
147 struct rb_node *iter; 147 struct rb_node *iter;
148 unsigned long offset; 148 unsigned long offset;
149 149
150 iter = mgr->vm_addr_space_mm.interval_tree.rb_node; 150 iter = mgr->vm_addr_space_mm.interval_tree.rb_root.rb_node;
151 best = NULL; 151 best = NULL;
152 152
153 while (likely(iter)) { 153 while (likely(iter)) {
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index f152a38d7079..23fd18bd1b56 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -49,7 +49,7 @@ struct i915_mmu_notifier {
49 spinlock_t lock; 49 spinlock_t lock;
50 struct hlist_node node; 50 struct hlist_node node;
51 struct mmu_notifier mn; 51 struct mmu_notifier mn;
52 struct rb_root objects; 52 struct rb_root_cached objects;
53 struct workqueue_struct *wq; 53 struct workqueue_struct *wq;
54}; 54};
55 55
@@ -123,7 +123,7 @@ static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
123 struct interval_tree_node *it; 123 struct interval_tree_node *it;
124 LIST_HEAD(cancelled); 124 LIST_HEAD(cancelled);
125 125
126 if (RB_EMPTY_ROOT(&mn->objects)) 126 if (RB_EMPTY_ROOT(&mn->objects.rb_root))
127 return; 127 return;
128 128
129 /* interval ranges are inclusive, but invalidate range is exclusive */ 129 /* interval ranges are inclusive, but invalidate range is exclusive */
@@ -172,7 +172,7 @@ i915_mmu_notifier_create(struct mm_struct *mm)
172 172
173 spin_lock_init(&mn->lock); 173 spin_lock_init(&mn->lock);
174 mn->mn.ops = &i915_gem_userptr_notifier; 174 mn->mn.ops = &i915_gem_userptr_notifier;
175 mn->objects = RB_ROOT; 175 mn->objects = RB_ROOT_CACHED;
176 mn->wq = alloc_workqueue("i915-userptr-release", WQ_UNBOUND, 0); 176 mn->wq = alloc_workqueue("i915-userptr-release", WQ_UNBOUND, 0);
177 if (mn->wq == NULL) { 177 if (mn->wq == NULL) {
178 kfree(mn); 178 kfree(mn);
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index ec63bc5e9de7..8cbaeec090c9 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -924,7 +924,7 @@ struct radeon_vm_id {
924struct radeon_vm { 924struct radeon_vm {
925 struct mutex mutex; 925 struct mutex mutex;
926 926
927 struct rb_root va; 927 struct rb_root_cached va;
928 928
929 /* protecting invalidated and freed */ 929 /* protecting invalidated and freed */
930 spinlock_t status_lock; 930 spinlock_t status_lock;
diff --git a/drivers/gpu/drm/radeon/radeon_mn.c b/drivers/gpu/drm/radeon/radeon_mn.c
index 896f2cf51e4e..1d62288b7ee3 100644
--- a/drivers/gpu/drm/radeon/radeon_mn.c
+++ b/drivers/gpu/drm/radeon/radeon_mn.c
@@ -50,7 +50,7 @@ struct radeon_mn {
50 50
51 /* objects protected by lock */ 51 /* objects protected by lock */
52 struct mutex lock; 52 struct mutex lock;
53 struct rb_root objects; 53 struct rb_root_cached objects;
54}; 54};
55 55
56struct radeon_mn_node { 56struct radeon_mn_node {
@@ -75,8 +75,8 @@ static void radeon_mn_destroy(struct work_struct *work)
75 mutex_lock(&rdev->mn_lock); 75 mutex_lock(&rdev->mn_lock);
76 mutex_lock(&rmn->lock); 76 mutex_lock(&rmn->lock);
77 hash_del(&rmn->node); 77 hash_del(&rmn->node);
78 rbtree_postorder_for_each_entry_safe(node, next_node, &rmn->objects, 78 rbtree_postorder_for_each_entry_safe(node, next_node,
79 it.rb) { 79 &rmn->objects.rb_root, it.rb) {
80 80
81 interval_tree_remove(&node->it, &rmn->objects); 81 interval_tree_remove(&node->it, &rmn->objects);
82 list_for_each_entry_safe(bo, next_bo, &node->bos, mn_list) { 82 list_for_each_entry_safe(bo, next_bo, &node->bos, mn_list) {
@@ -205,7 +205,7 @@ static struct radeon_mn *radeon_mn_get(struct radeon_device *rdev)
205 rmn->mm = mm; 205 rmn->mm = mm;
206 rmn->mn.ops = &radeon_mn_ops; 206 rmn->mn.ops = &radeon_mn_ops;
207 mutex_init(&rmn->lock); 207 mutex_init(&rmn->lock);
208 rmn->objects = RB_ROOT; 208 rmn->objects = RB_ROOT_CACHED;
209 209
210 r = __mmu_notifier_register(&rmn->mn, mm); 210 r = __mmu_notifier_register(&rmn->mn, mm);
211 if (r) 211 if (r)
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index 5e82b408d522..e5c0e635e371 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -1185,7 +1185,7 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
1185 vm->ids[i].last_id_use = NULL; 1185 vm->ids[i].last_id_use = NULL;
1186 } 1186 }
1187 mutex_init(&vm->mutex); 1187 mutex_init(&vm->mutex);
1188 vm->va = RB_ROOT; 1188 vm->va = RB_ROOT_CACHED;
1189 spin_lock_init(&vm->status_lock); 1189 spin_lock_init(&vm->status_lock);
1190 INIT_LIST_HEAD(&vm->invalidated); 1190 INIT_LIST_HEAD(&vm->invalidated);
1191 INIT_LIST_HEAD(&vm->freed); 1191 INIT_LIST_HEAD(&vm->freed);
@@ -1232,10 +1232,11 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
1232 struct radeon_bo_va *bo_va, *tmp; 1232 struct radeon_bo_va *bo_va, *tmp;
1233 int i, r; 1233 int i, r;
1234 1234
1235 if (!RB_EMPTY_ROOT(&vm->va)) { 1235 if (!RB_EMPTY_ROOT(&vm->va.rb_root)) {
1236 dev_err(rdev->dev, "still active bo inside vm\n"); 1236 dev_err(rdev->dev, "still active bo inside vm\n");
1237 } 1237 }
1238 rbtree_postorder_for_each_entry_safe(bo_va, tmp, &vm->va, it.rb) { 1238 rbtree_postorder_for_each_entry_safe(bo_va, tmp,
1239 &vm->va.rb_root, it.rb) {
1239 interval_tree_remove(&bo_va->it, &vm->va); 1240 interval_tree_remove(&bo_va->it, &vm->va);
1240 r = radeon_bo_reserve(bo_va->bo, false); 1241 r = radeon_bo_reserve(bo_va->bo, false);
1241 if (!r) { 1242 if (!r) {
diff --git a/drivers/infiniband/core/umem_rbtree.c b/drivers/infiniband/core/umem_rbtree.c
index d176597b4d78..fc801920e341 100644
--- a/drivers/infiniband/core/umem_rbtree.c
+++ b/drivers/infiniband/core/umem_rbtree.c
@@ -72,7 +72,7 @@ INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, __subtree_last,
72/* @last is not a part of the interval. See comment for function 72/* @last is not a part of the interval. See comment for function
73 * node_last. 73 * node_last.
74 */ 74 */
75int rbt_ib_umem_for_each_in_range(struct rb_root *root, 75int rbt_ib_umem_for_each_in_range(struct rb_root_cached *root,
76 u64 start, u64 last, 76 u64 start, u64 last,
77 umem_call_back cb, 77 umem_call_back cb,
78 void *cookie) 78 void *cookie)
@@ -95,7 +95,7 @@ int rbt_ib_umem_for_each_in_range(struct rb_root *root,
95} 95}
96EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range); 96EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range);
97 97
98struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root *root, 98struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root,
99 u64 addr, u64 length) 99 u64 addr, u64 length)
100{ 100{
101 struct umem_odp_node *node; 101 struct umem_odp_node *node;
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index e0cb99860934..4ab30d832ac5 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -118,7 +118,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
118 ucontext->closing = 0; 118 ucontext->closing = 0;
119 119
120#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING 120#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
121 ucontext->umem_tree = RB_ROOT; 121 ucontext->umem_tree = RB_ROOT_CACHED;
122 init_rwsem(&ucontext->umem_rwsem); 122 init_rwsem(&ucontext->umem_rwsem);
123 ucontext->odp_mrs_count = 0; 123 ucontext->odp_mrs_count = 0;
124 INIT_LIST_HEAD(&ucontext->no_private_counters); 124 INIT_LIST_HEAD(&ucontext->no_private_counters);
diff --git a/drivers/infiniband/hw/hfi1/mmu_rb.c b/drivers/infiniband/hw/hfi1/mmu_rb.c
index 2f0d285dc278..175002c046ed 100644
--- a/drivers/infiniband/hw/hfi1/mmu_rb.c
+++ b/drivers/infiniband/hw/hfi1/mmu_rb.c
@@ -54,7 +54,7 @@
54 54
55struct mmu_rb_handler { 55struct mmu_rb_handler {
56 struct mmu_notifier mn; 56 struct mmu_notifier mn;
57 struct rb_root root; 57 struct rb_root_cached root;
58 void *ops_arg; 58 void *ops_arg;
59 spinlock_t lock; /* protect the RB tree */ 59 spinlock_t lock; /* protect the RB tree */
60 struct mmu_rb_ops *ops; 60 struct mmu_rb_ops *ops;
@@ -108,7 +108,7 @@ int hfi1_mmu_rb_register(void *ops_arg, struct mm_struct *mm,
108 if (!handlr) 108 if (!handlr)
109 return -ENOMEM; 109 return -ENOMEM;
110 110
111 handlr->root = RB_ROOT; 111 handlr->root = RB_ROOT_CACHED;
112 handlr->ops = ops; 112 handlr->ops = ops;
113 handlr->ops_arg = ops_arg; 113 handlr->ops_arg = ops_arg;
114 INIT_HLIST_NODE(&handlr->mn.hlist); 114 INIT_HLIST_NODE(&handlr->mn.hlist);
@@ -149,9 +149,9 @@ void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler)
149 INIT_LIST_HEAD(&del_list); 149 INIT_LIST_HEAD(&del_list);
150 150
151 spin_lock_irqsave(&handler->lock, flags); 151 spin_lock_irqsave(&handler->lock, flags);
152 while ((node = rb_first(&handler->root))) { 152 while ((node = rb_first_cached(&handler->root))) {
153 rbnode = rb_entry(node, struct mmu_rb_node, node); 153 rbnode = rb_entry(node, struct mmu_rb_node, node);
154 rb_erase(node, &handler->root); 154 rb_erase_cached(node, &handler->root);
155 /* move from LRU list to delete list */ 155 /* move from LRU list to delete list */
156 list_move(&rbnode->list, &del_list); 156 list_move(&rbnode->list, &del_list);
157 } 157 }
@@ -300,7 +300,7 @@ static void mmu_notifier_mem_invalidate(struct mmu_notifier *mn,
300{ 300{
301 struct mmu_rb_handler *handler = 301 struct mmu_rb_handler *handler =
302 container_of(mn, struct mmu_rb_handler, mn); 302 container_of(mn, struct mmu_rb_handler, mn);
303 struct rb_root *root = &handler->root; 303 struct rb_root_cached *root = &handler->root;
304 struct mmu_rb_node *node, *ptr = NULL; 304 struct mmu_rb_node *node, *ptr = NULL;
305 unsigned long flags; 305 unsigned long flags;
306 bool added = false; 306 bool added = false;
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index c49db7c33979..4381c0a9a873 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -227,7 +227,7 @@ static void __usnic_uiom_reg_release(struct usnic_uiom_pd *pd,
227 vpn_last = vpn_start + npages - 1; 227 vpn_last = vpn_start + npages - 1;
228 228
229 spin_lock(&pd->lock); 229 spin_lock(&pd->lock);
230 usnic_uiom_remove_interval(&pd->rb_root, vpn_start, 230 usnic_uiom_remove_interval(&pd->root, vpn_start,
231 vpn_last, &rm_intervals); 231 vpn_last, &rm_intervals);
232 usnic_uiom_unmap_sorted_intervals(&rm_intervals, pd); 232 usnic_uiom_unmap_sorted_intervals(&rm_intervals, pd);
233 233
@@ -379,7 +379,7 @@ struct usnic_uiom_reg *usnic_uiom_reg_get(struct usnic_uiom_pd *pd,
379 err = usnic_uiom_get_intervals_diff(vpn_start, vpn_last, 379 err = usnic_uiom_get_intervals_diff(vpn_start, vpn_last,
380 (writable) ? IOMMU_WRITE : 0, 380 (writable) ? IOMMU_WRITE : 0,
381 IOMMU_WRITE, 381 IOMMU_WRITE,
382 &pd->rb_root, 382 &pd->root,
383 &sorted_diff_intervals); 383 &sorted_diff_intervals);
384 if (err) { 384 if (err) {
385 usnic_err("Failed disjoint interval vpn [0x%lx,0x%lx] err %d\n", 385 usnic_err("Failed disjoint interval vpn [0x%lx,0x%lx] err %d\n",
@@ -395,7 +395,7 @@ struct usnic_uiom_reg *usnic_uiom_reg_get(struct usnic_uiom_pd *pd,
395 395
396 } 396 }
397 397
398 err = usnic_uiom_insert_interval(&pd->rb_root, vpn_start, vpn_last, 398 err = usnic_uiom_insert_interval(&pd->root, vpn_start, vpn_last,
399 (writable) ? IOMMU_WRITE : 0); 399 (writable) ? IOMMU_WRITE : 0);
400 if (err) { 400 if (err) {
401 usnic_err("Failed insert interval vpn [0x%lx,0x%lx] err %d\n", 401 usnic_err("Failed insert interval vpn [0x%lx,0x%lx] err %d\n",
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.h b/drivers/infiniband/hw/usnic/usnic_uiom.h
index 45ca7c1613a7..431efe4143f4 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.h
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.h
@@ -55,7 +55,7 @@ struct usnic_uiom_dev {
55struct usnic_uiom_pd { 55struct usnic_uiom_pd {
56 struct iommu_domain *domain; 56 struct iommu_domain *domain;
57 spinlock_t lock; 57 spinlock_t lock;
58 struct rb_root rb_root; 58 struct rb_root_cached root;
59 struct list_head devs; 59 struct list_head devs;
60 int dev_cnt; 60 int dev_cnt;
61}; 61};
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.c b/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.c
index 42b4b4c4e452..d399523206c7 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.c
@@ -100,9 +100,9 @@ static int interval_cmp(void *priv, struct list_head *a, struct list_head *b)
100} 100}
101 101
102static void 102static void
103find_intervals_intersection_sorted(struct rb_root *root, unsigned long start, 103find_intervals_intersection_sorted(struct rb_root_cached *root,
104 unsigned long last, 104 unsigned long start, unsigned long last,
105 struct list_head *list) 105 struct list_head *list)
106{ 106{
107 struct usnic_uiom_interval_node *node; 107 struct usnic_uiom_interval_node *node;
108 108
@@ -118,7 +118,7 @@ find_intervals_intersection_sorted(struct rb_root *root, unsigned long start,
118 118
119int usnic_uiom_get_intervals_diff(unsigned long start, unsigned long last, 119int usnic_uiom_get_intervals_diff(unsigned long start, unsigned long last,
120 int flags, int flag_mask, 120 int flags, int flag_mask,
121 struct rb_root *root, 121 struct rb_root_cached *root,
122 struct list_head *diff_set) 122 struct list_head *diff_set)
123{ 123{
124 struct usnic_uiom_interval_node *interval, *tmp; 124 struct usnic_uiom_interval_node *interval, *tmp;
@@ -175,7 +175,7 @@ void usnic_uiom_put_interval_set(struct list_head *intervals)
175 kfree(interval); 175 kfree(interval);
176} 176}
177 177
178int usnic_uiom_insert_interval(struct rb_root *root, unsigned long start, 178int usnic_uiom_insert_interval(struct rb_root_cached *root, unsigned long start,
179 unsigned long last, int flags) 179 unsigned long last, int flags)
180{ 180{
181 struct usnic_uiom_interval_node *interval, *tmp; 181 struct usnic_uiom_interval_node *interval, *tmp;
@@ -246,8 +246,9 @@ err_out:
246 return err; 246 return err;
247} 247}
248 248
249void usnic_uiom_remove_interval(struct rb_root *root, unsigned long start, 249void usnic_uiom_remove_interval(struct rb_root_cached *root,
250 unsigned long last, struct list_head *removed) 250 unsigned long start, unsigned long last,
251 struct list_head *removed)
251{ 252{
252 struct usnic_uiom_interval_node *interval; 253 struct usnic_uiom_interval_node *interval;
253 254
diff --git a/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.h b/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.h
index c0b0b876ab90..1d7fc3226bca 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.h
+++ b/drivers/infiniband/hw/usnic/usnic_uiom_interval_tree.h
@@ -48,12 +48,12 @@ struct usnic_uiom_interval_node {
48 48
49extern void 49extern void
50usnic_uiom_interval_tree_insert(struct usnic_uiom_interval_node *node, 50usnic_uiom_interval_tree_insert(struct usnic_uiom_interval_node *node,
51 struct rb_root *root); 51 struct rb_root_cached *root);
52extern void 52extern void
53usnic_uiom_interval_tree_remove(struct usnic_uiom_interval_node *node, 53usnic_uiom_interval_tree_remove(struct usnic_uiom_interval_node *node,
54 struct rb_root *root); 54 struct rb_root_cached *root);
55extern struct usnic_uiom_interval_node * 55extern struct usnic_uiom_interval_node *
56usnic_uiom_interval_tree_iter_first(struct rb_root *root, 56usnic_uiom_interval_tree_iter_first(struct rb_root_cached *root,
57 unsigned long start, 57 unsigned long start,
58 unsigned long last); 58 unsigned long last);
59extern struct usnic_uiom_interval_node * 59extern struct usnic_uiom_interval_node *
@@ -63,7 +63,7 @@ usnic_uiom_interval_tree_iter_next(struct usnic_uiom_interval_node *node,
63 * Inserts {start...last} into {root}. If there are overlaps, 63 * Inserts {start...last} into {root}. If there are overlaps,
64 * nodes will be broken up and merged 64 * nodes will be broken up and merged
65 */ 65 */
66int usnic_uiom_insert_interval(struct rb_root *root, 66int usnic_uiom_insert_interval(struct rb_root_cached *root,
67 unsigned long start, unsigned long last, 67 unsigned long start, unsigned long last,
68 int flags); 68 int flags);
69/* 69/*
@@ -71,7 +71,7 @@ int usnic_uiom_insert_interval(struct rb_root *root,
71 * 'removed.' The caller is responsibile for freeing memory of nodes in 71 * 'removed.' The caller is responsibile for freeing memory of nodes in
72 * 'removed.' 72 * 'removed.'
73 */ 73 */
74void usnic_uiom_remove_interval(struct rb_root *root, 74void usnic_uiom_remove_interval(struct rb_root_cached *root,
75 unsigned long start, unsigned long last, 75 unsigned long start, unsigned long last,
76 struct list_head *removed); 76 struct list_head *removed);
77/* 77/*
@@ -81,7 +81,7 @@ void usnic_uiom_remove_interval(struct rb_root *root,
81int usnic_uiom_get_intervals_diff(unsigned long start, 81int usnic_uiom_get_intervals_diff(unsigned long start,
82 unsigned long last, int flags, 82 unsigned long last, int flags,
83 int flag_mask, 83 int flag_mask,
84 struct rb_root *root, 84 struct rb_root_cached *root,
85 struct list_head *diff_set); 85 struct list_head *diff_set);
86/* Call this to free diff_set returned by usnic_uiom_get_intervals_diff */ 86/* Call this to free diff_set returned by usnic_uiom_get_intervals_diff */
87void usnic_uiom_put_interval_set(struct list_head *intervals); 87void usnic_uiom_put_interval_set(struct list_head *intervals);
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index d723be352148..3087b0ba7b7f 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -980,9 +980,6 @@ static int denali_erase(struct mtd_info *mtd, int page)
980 return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL; 980 return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL;
981} 981}
982 982
983#define DIV_ROUND_DOWN_ULL(ll, d) \
984 ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
985
986static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr, 983static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr,
987 const struct nand_data_interface *conf) 984 const struct nand_data_interface *conf)
988{ 985{
diff --git a/drivers/pps/Kconfig b/drivers/pps/Kconfig
index 4b29a7182d7b..c6008f296605 100644
--- a/drivers/pps/Kconfig
+++ b/drivers/pps/Kconfig
@@ -19,9 +19,10 @@ menuconfig PPS
19 To compile this driver as a module, choose M here: the module 19 To compile this driver as a module, choose M here: the module
20 will be called pps_core.ko. 20 will be called pps_core.ko.
21 21
22if PPS
23
22config PPS_DEBUG 24config PPS_DEBUG
23 bool "PPS debugging messages" 25 bool "PPS debugging messages"
24 depends on PPS
25 help 26 help
26 Say Y here if you want the PPS support to produce a bunch of debug 27 Say Y here if you want the PPS support to produce a bunch of debug
27 messages to the system log. Select this if you are having a 28 messages to the system log. Select this if you are having a
@@ -29,7 +30,7 @@ config PPS_DEBUG
29 30
30config NTP_PPS 31config NTP_PPS
31 bool "PPS kernel consumer support" 32 bool "PPS kernel consumer support"
32 depends on PPS && !NO_HZ_COMMON 33 depends on !NO_HZ_COMMON
33 help 34 help
34 This option adds support for direct in-kernel time 35 This option adds support for direct in-kernel time
35 synchronization using an external PPS signal. 36 synchronization using an external PPS signal.
@@ -39,3 +40,5 @@ config NTP_PPS
39source drivers/pps/clients/Kconfig 40source drivers/pps/clients/Kconfig
40 41
41source drivers/pps/generators/Kconfig 42source drivers/pps/generators/Kconfig
43
44endif # PPS
diff --git a/drivers/pps/clients/Kconfig b/drivers/pps/clients/Kconfig
index efec021ce662..7f02a9b1a1fd 100644
--- a/drivers/pps/clients/Kconfig
+++ b/drivers/pps/clients/Kconfig
@@ -3,11 +3,9 @@
3# 3#
4 4
5comment "PPS clients support" 5comment "PPS clients support"
6 depends on PPS
7 6
8config PPS_CLIENT_KTIMER 7config PPS_CLIENT_KTIMER
9 tristate "Kernel timer client (Testing client, use for debug)" 8 tristate "Kernel timer client (Testing client, use for debug)"
10 depends on PPS
11 help 9 help
12 If you say yes here you get support for a PPS debugging client 10 If you say yes here you get support for a PPS debugging client
13 which uses a kernel timer to generate the PPS signal. 11 which uses a kernel timer to generate the PPS signal.
@@ -17,21 +15,20 @@ config PPS_CLIENT_KTIMER
17 15
18config PPS_CLIENT_LDISC 16config PPS_CLIENT_LDISC
19 tristate "PPS line discipline" 17 tristate "PPS line discipline"
20 depends on PPS && TTY 18 depends on TTY
21 help 19 help
22 If you say yes here you get support for a PPS source connected 20 If you say yes here you get support for a PPS source connected
23 with the CD (Carrier Detect) pin of your serial port. 21 with the CD (Carrier Detect) pin of your serial port.
24 22
25config PPS_CLIENT_PARPORT 23config PPS_CLIENT_PARPORT
26 tristate "Parallel port PPS client" 24 tristate "Parallel port PPS client"
27 depends on PPS && PARPORT 25 depends on PARPORT
28 help 26 help
29 If you say yes here you get support for a PPS source connected 27 If you say yes here you get support for a PPS source connected
30 with the interrupt pin of your parallel port. 28 with the interrupt pin of your parallel port.
31 29
32config PPS_CLIENT_GPIO 30config PPS_CLIENT_GPIO
33 tristate "PPS client using GPIO" 31 tristate "PPS client using GPIO"
34 depends on PPS
35 help 32 help
36 If you say yes here you get support for a PPS source using 33 If you say yes here you get support for a PPS source using
37 GPIO. To be useful you must also register a platform device 34 GPIO. To be useful you must also register a platform device
diff --git a/drivers/pps/generators/Kconfig b/drivers/pps/generators/Kconfig
index 86b59378e71f..e4c4f3dc0728 100644
--- a/drivers/pps/generators/Kconfig
+++ b/drivers/pps/generators/Kconfig
@@ -3,11 +3,10 @@
3# 3#
4 4
5comment "PPS generators support" 5comment "PPS generators support"
6 depends on PPS
7 6
8config PPS_GENERATOR_PARPORT 7config PPS_GENERATOR_PARPORT
9 tristate "Parallel port PPS signal generator" 8 tristate "Parallel port PPS signal generator"
10 depends on PPS && PARPORT && BROKEN 9 depends on PARPORT && BROKEN
11 help 10 help
12 If you say yes here you get support for a PPS signal generator which 11 If you say yes here you get support for a PPS signal generator which
13 utilizes STROBE pin of a parallel port to send PPS signals. It uses 12 utilizes STROBE pin of a parallel port to send PPS signals. It uses
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 77a0335eb757..09ba494f8896 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5465,7 +5465,7 @@ static int sdebug_driver_probe(struct device * dev)
5465 return error; 5465 return error;
5466 } 5466 }
5467 if (submit_queues > nr_cpu_ids) { 5467 if (submit_queues > nr_cpu_ids) {
5468 pr_warn("%s: trim submit_queues (was %d) to nr_cpu_ids=%d\n", 5468 pr_warn("%s: trim submit_queues (was %d) to nr_cpu_ids=%u\n",
5469 my_name, submit_queues, nr_cpu_ids); 5469 my_name, submit_queues, nr_cpu_ids);
5470 submit_queues = nr_cpu_ids; 5470 submit_queues = nr_cpu_ids;
5471 } 5471 }
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index 15ff285a9f8f..ca360daa6a25 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -4985,13 +4985,10 @@ struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
4985 * Compute the bus address of this table. 4985 * Compute the bus address of this table.
4986 */ 4986 */
4987 if (ln && !tp->luntbl) { 4987 if (ln && !tp->luntbl) {
4988 int i;
4989
4990 tp->luntbl = sym_calloc_dma(256, "LUNTBL"); 4988 tp->luntbl = sym_calloc_dma(256, "LUNTBL");
4991 if (!tp->luntbl) 4989 if (!tp->luntbl)
4992 goto fail; 4990 goto fail;
4993 for (i = 0 ; i < 64 ; i++) 4991 memset32(tp->luntbl, cpu_to_scr(vtobus(&np->badlun_sa)), 64);
4994 tp->luntbl[i] = cpu_to_scr(vtobus(&np->badlun_sa));
4995 tp->head.luntbl_sa = cpu_to_scr(vtobus(tp->luntbl)); 4992 tp->head.luntbl_sa = cpu_to_scr(vtobus(tp->luntbl));
4996 } 4993 }
4997 4994
@@ -5077,8 +5074,7 @@ static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln)
5077 /* 5074 /*
5078 * Initialize the task table with invalid entries. 5075 * Initialize the task table with invalid entries.
5079 */ 5076 */
5080 for (i = 0 ; i < SYM_CONF_MAX_TASK ; i++) 5077 memset32(lp->itlq_tbl, cpu_to_scr(np->notask_ba), SYM_CONF_MAX_TASK);
5081 lp->itlq_tbl[i] = cpu_to_scr(np->notask_ba);
5082 5078
5083 /* 5079 /*
5084 * Fill up the tag buffer with tag numbers. 5080 * Fill up the tag buffer with tag numbers.
@@ -5764,8 +5760,7 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram
5764 goto attach_failed; 5760 goto attach_failed;
5765 5761
5766 np->badlun_sa = cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); 5762 np->badlun_sa = cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun));
5767 for (i = 0 ; i < 64 ; i++) /* 64 luns/target, no less */ 5763 memset32(np->badluntbl, cpu_to_scr(vtobus(&np->badlun_sa)), 64);
5768 np->badluntbl[i] = cpu_to_scr(vtobus(&np->badlun_sa));
5769 5764
5770 /* 5765 /*
5771 * Prepare the bus address array that contains the bus 5766 * Prepare the bus address array that contains the bus
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 9cb3f722dce1..d6dbb28245e6 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1271,7 +1271,7 @@ static struct vhost_umem *vhost_umem_alloc(void)
1271 if (!umem) 1271 if (!umem)
1272 return NULL; 1272 return NULL;
1273 1273
1274 umem->umem_tree = RB_ROOT; 1274 umem->umem_tree = RB_ROOT_CACHED;
1275 umem->numem = 0; 1275 umem->numem = 0;
1276 INIT_LIST_HEAD(&umem->umem_list); 1276 INIT_LIST_HEAD(&umem->umem_list);
1277 1277
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index bb7c29b8b9fc..d59a9cc65f9d 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -71,7 +71,7 @@ struct vhost_umem_node {
71}; 71};
72 72
73struct vhost_umem { 73struct vhost_umem {
74 struct rb_root umem_tree; 74 struct rb_root_cached umem_tree;
75 struct list_head umem_list; 75 struct list_head umem_list;
76 int numem; 76 int numem;
77}; 77};
diff --git a/fs/aio.c b/fs/aio.c
index 8f0127526299..b5d69f28d8b1 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -373,6 +373,14 @@ static int aio_migratepage(struct address_space *mapping, struct page *new,
373 pgoff_t idx; 373 pgoff_t idx;
374 int rc; 374 int rc;
375 375
376 /*
377 * We cannot support the _NO_COPY case here, because copy needs to
378 * happen under the ctx->completion_lock. That does not work with the
379 * migration workflow of MIGRATE_SYNC_NO_COPY.
380 */
381 if (mode == MIGRATE_SYNC_NO_COPY)
382 return -EINVAL;
383
376 rc = 0; 384 rc = 0;
377 385
378 /* mapping->private_lock here protects against the kioctx teardown. */ 386 /* mapping->private_lock here protects against the kioctx teardown. */
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index beef981aa54f..4737615f0eaa 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -11,10 +11,21 @@
11 11
12#include <linux/auto_fs4.h> 12#include <linux/auto_fs4.h>
13#include <linux/auto_dev-ioctl.h> 13#include <linux/auto_dev-ioctl.h>
14
15#include <linux/kernel.h>
16#include <linux/slab.h>
17#include <linux/time.h>
18#include <linux/string.h>
19#include <linux/wait.h>
20#include <linux/sched.h>
21#include <linux/mount.h>
22#include <linux/namei.h>
23#include <linux/uaccess.h>
14#include <linux/mutex.h> 24#include <linux/mutex.h>
15#include <linux/spinlock.h> 25#include <linux/spinlock.h>
16#include <linux/list.h> 26#include <linux/list.h>
17#include <linux/completion.h> 27#include <linux/completion.h>
28#include <asm/current.h>
18 29
19/* This is the range of ioctl() numbers we claim as ours */ 30/* This is the range of ioctl() numbers we claim as ours */
20#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY 31#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
@@ -24,17 +35,6 @@
24#define AUTOFS_DEV_IOCTL_IOC_COUNT \ 35#define AUTOFS_DEV_IOCTL_IOC_COUNT \
25 (AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD - AUTOFS_DEV_IOCTL_VERSION_CMD) 36 (AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD - AUTOFS_DEV_IOCTL_VERSION_CMD)
26 37
27#include <linux/kernel.h>
28#include <linux/slab.h>
29#include <linux/time.h>
30#include <linux/string.h>
31#include <linux/wait.h>
32#include <linux/sched.h>
33#include <linux/mount.h>
34#include <linux/namei.h>
35#include <asm/current.h>
36#include <linux/uaccess.h>
37
38#ifdef pr_fmt 38#ifdef pr_fmt
39#undef pr_fmt 39#undef pr_fmt
40#endif 40#endif
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index dd9f1bebb5a3..b7c816f39404 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -93,17 +93,17 @@ static int check_dev_ioctl_version(int cmd, struct autofs_dev_ioctl *param)
93 * at the end of the struct. 93 * at the end of the struct.
94 */ 94 */
95static struct autofs_dev_ioctl * 95static struct autofs_dev_ioctl *
96 copy_dev_ioctl(struct autofs_dev_ioctl __user *in) 96copy_dev_ioctl(struct autofs_dev_ioctl __user *in)
97{ 97{
98 struct autofs_dev_ioctl tmp, *res; 98 struct autofs_dev_ioctl tmp, *res;
99 99
100 if (copy_from_user(&tmp, in, sizeof(tmp))) 100 if (copy_from_user(&tmp, in, AUTOFS_DEV_IOCTL_SIZE))
101 return ERR_PTR(-EFAULT); 101 return ERR_PTR(-EFAULT);
102 102
103 if (tmp.size < sizeof(tmp)) 103 if (tmp.size < AUTOFS_DEV_IOCTL_SIZE)
104 return ERR_PTR(-EINVAL); 104 return ERR_PTR(-EINVAL);
105 105
106 if (tmp.size > (PATH_MAX + sizeof(tmp))) 106 if (tmp.size > AUTOFS_DEV_IOCTL_SIZE + PATH_MAX)
107 return ERR_PTR(-ENAMETOOLONG); 107 return ERR_PTR(-ENAMETOOLONG);
108 108
109 res = memdup_user(in, tmp.size); 109 res = memdup_user(in, tmp.size);
@@ -133,8 +133,8 @@ static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
133 goto out; 133 goto out;
134 } 134 }
135 135
136 if (param->size > sizeof(*param)) { 136 if (param->size > AUTOFS_DEV_IOCTL_SIZE) {
137 err = invalid_str(param->path, param->size - sizeof(*param)); 137 err = invalid_str(param->path, param->size - AUTOFS_DEV_IOCTL_SIZE);
138 if (err) { 138 if (err) {
139 pr_warn( 139 pr_warn(
140 "path string terminator missing for cmd(0x%08x)\n", 140 "path string terminator missing for cmd(0x%08x)\n",
@@ -258,11 +258,6 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
258 if (err) 258 if (err)
259 goto out; 259 goto out;
260 260
261 /*
262 * Find autofs super block that has the device number
263 * corresponding to the autofs fs we want to open.
264 */
265
266 filp = dentry_open(&path, O_RDONLY, current_cred()); 261 filp = dentry_open(&path, O_RDONLY, current_cred());
267 path_put(&path); 262 path_put(&path);
268 if (IS_ERR(filp)) { 263 if (IS_ERR(filp)) {
@@ -451,7 +446,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
451 dev_t devid; 446 dev_t devid;
452 int err = -ENOENT; 447 int err = -ENOENT;
453 448
454 if (param->size <= sizeof(*param)) { 449 if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
455 err = -EINVAL; 450 err = -EINVAL;
456 goto out; 451 goto out;
457 } 452 }
@@ -539,7 +534,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
539 unsigned int devid, magic; 534 unsigned int devid, magic;
540 int err = -ENOENT; 535 int err = -ENOENT;
541 536
542 if (param->size <= sizeof(*param)) { 537 if (param->size <= AUTOFS_DEV_IOCTL_SIZE) {
543 err = -EINVAL; 538 err = -EINVAL;
544 goto out; 539 goto out;
545 } 540 }
@@ -628,10 +623,6 @@ static int _autofs_dev_ioctl(unsigned int command,
628 ioctl_fn fn = NULL; 623 ioctl_fn fn = NULL;
629 int err = 0; 624 int err = 0;
630 625
631 /* only root can play with this */
632 if (!capable(CAP_SYS_ADMIN))
633 return -EPERM;
634
635 cmd_first = _IOC_NR(AUTOFS_DEV_IOCTL_IOC_FIRST); 626 cmd_first = _IOC_NR(AUTOFS_DEV_IOCTL_IOC_FIRST);
636 cmd = _IOC_NR(command); 627 cmd = _IOC_NR(command);
637 628
@@ -640,6 +631,14 @@ static int _autofs_dev_ioctl(unsigned int command,
640 return -ENOTTY; 631 return -ENOTTY;
641 } 632 }
642 633
634 /* Only root can use ioctls other than AUTOFS_DEV_IOCTL_VERSION_CMD
635 * and AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD
636 */
637 if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD &&
638 cmd != AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD &&
639 !capable(CAP_SYS_ADMIN))
640 return -EPERM;
641
643 /* Copy the parameters into kernel space. */ 642 /* Copy the parameters into kernel space. */
644 param = copy_dev_ioctl(user); 643 param = copy_dev_ioctl(user);
645 if (IS_ERR(param)) 644 if (IS_ERR(param))
@@ -706,7 +705,8 @@ out:
706 return err; 705 return err;
707} 706}
708 707
709static long autofs_dev_ioctl(struct file *file, uint command, ulong u) 708static long autofs_dev_ioctl(struct file *file, unsigned int command,
709 unsigned long u)
710{ 710{
711 int err; 711 int err;
712 712
@@ -715,9 +715,10 @@ static long autofs_dev_ioctl(struct file *file, uint command, ulong u)
715} 715}
716 716
717#ifdef CONFIG_COMPAT 717#ifdef CONFIG_COMPAT
718static long autofs_dev_ioctl_compat(struct file *file, uint command, ulong u) 718static long autofs_dev_ioctl_compat(struct file *file, unsigned int command,
719 unsigned long u)
719{ 720{
720 return (long) autofs_dev_ioctl(file, command, (ulong) compat_ptr(u)); 721 return autofs_dev_ioctl(file, command, (unsigned long) compat_ptr(u));
721} 722}
722#else 723#else
723#define autofs_dev_ioctl_compat NULL 724#define autofs_dev_ioctl_compat NULL
@@ -733,7 +734,8 @@ static const struct file_operations _dev_ioctl_fops = {
733static struct miscdevice _autofs_dev_ioctl_misc = { 734static struct miscdevice _autofs_dev_ioctl_misc = {
734 .minor = AUTOFS_MINOR, 735 .minor = AUTOFS_MINOR,
735 .name = AUTOFS_DEVICE_NAME, 736 .name = AUTOFS_DEVICE_NAME,
736 .fops = &_dev_ioctl_fops 737 .fops = &_dev_ioctl_fops,
738 .mode = 0644,
737}; 739};
738 740
739MODULE_ALIAS_MISCDEV(AUTOFS_MINOR); 741MODULE_ALIAS_MISCDEV(AUTOFS_MINOR);
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 604a176df0c2..ce6537c50ec1 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -192,13 +192,11 @@ static int decompress_exec(
192 192
193 memset(&strm, 0, sizeof(strm)); 193 memset(&strm, 0, sizeof(strm));
194 strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); 194 strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
195 if (strm.workspace == NULL) { 195 if (!strm.workspace)
196 pr_debug("no memory for decompress workspace\n");
197 return -ENOMEM; 196 return -ENOMEM;
198 } 197
199 buf = kmalloc(LBUFSIZE, GFP_KERNEL); 198 buf = kmalloc(LBUFSIZE, GFP_KERNEL);
200 if (buf == NULL) { 199 if (!buf) {
201 pr_debug("no memory for read buffer\n");
202 retval = -ENOMEM; 200 retval = -ENOMEM;
203 goto out_free; 201 goto out_free;
204 } 202 }
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index adbe328b957c..2fabd19cdeea 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -205,7 +205,7 @@ struct eventpoll {
205 struct list_head rdllist; 205 struct list_head rdllist;
206 206
207 /* RB tree root used to store monitored fd structs */ 207 /* RB tree root used to store monitored fd structs */
208 struct rb_root rbr; 208 struct rb_root_cached rbr;
209 209
210 /* 210 /*
211 * This is a single linked list that chains all the "struct epitem" that 211 * This is a single linked list that chains all the "struct epitem" that
@@ -796,7 +796,7 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)
796 list_del_rcu(&epi->fllink); 796 list_del_rcu(&epi->fllink);
797 spin_unlock(&file->f_lock); 797 spin_unlock(&file->f_lock);
798 798
799 rb_erase(&epi->rbn, &ep->rbr); 799 rb_erase_cached(&epi->rbn, &ep->rbr);
800 800
801 spin_lock_irqsave(&ep->lock, flags); 801 spin_lock_irqsave(&ep->lock, flags);
802 if (ep_is_linked(&epi->rdllink)) 802 if (ep_is_linked(&epi->rdllink))
@@ -840,7 +840,7 @@ static void ep_free(struct eventpoll *ep)
840 /* 840 /*
841 * Walks through the whole tree by unregistering poll callbacks. 841 * Walks through the whole tree by unregistering poll callbacks.
842 */ 842 */
843 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 843 for (rbp = rb_first_cached(&ep->rbr); rbp; rbp = rb_next(rbp)) {
844 epi = rb_entry(rbp, struct epitem, rbn); 844 epi = rb_entry(rbp, struct epitem, rbn);
845 845
846 ep_unregister_pollwait(ep, epi); 846 ep_unregister_pollwait(ep, epi);
@@ -856,7 +856,7 @@ static void ep_free(struct eventpoll *ep)
856 * a lockdep warning. 856 * a lockdep warning.
857 */ 857 */
858 mutex_lock(&ep->mtx); 858 mutex_lock(&ep->mtx);
859 while ((rbp = rb_first(&ep->rbr)) != NULL) { 859 while ((rbp = rb_first_cached(&ep->rbr)) != NULL) {
860 epi = rb_entry(rbp, struct epitem, rbn); 860 epi = rb_entry(rbp, struct epitem, rbn);
861 ep_remove(ep, epi); 861 ep_remove(ep, epi);
862 cond_resched(); 862 cond_resched();
@@ -963,7 +963,7 @@ static void ep_show_fdinfo(struct seq_file *m, struct file *f)
963 struct rb_node *rbp; 963 struct rb_node *rbp;
964 964
965 mutex_lock(&ep->mtx); 965 mutex_lock(&ep->mtx);
966 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 966 for (rbp = rb_first_cached(&ep->rbr); rbp; rbp = rb_next(rbp)) {
967 struct epitem *epi = rb_entry(rbp, struct epitem, rbn); 967 struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
968 struct inode *inode = file_inode(epi->ffd.file); 968 struct inode *inode = file_inode(epi->ffd.file);
969 969
@@ -1040,7 +1040,7 @@ static int ep_alloc(struct eventpoll **pep)
1040 init_waitqueue_head(&ep->wq); 1040 init_waitqueue_head(&ep->wq);
1041 init_waitqueue_head(&ep->poll_wait); 1041 init_waitqueue_head(&ep->poll_wait);
1042 INIT_LIST_HEAD(&ep->rdllist); 1042 INIT_LIST_HEAD(&ep->rdllist);
1043 ep->rbr = RB_ROOT; 1043 ep->rbr = RB_ROOT_CACHED;
1044 ep->ovflist = EP_UNACTIVE_PTR; 1044 ep->ovflist = EP_UNACTIVE_PTR;
1045 ep->user = user; 1045 ep->user = user;
1046 1046
@@ -1066,7 +1066,7 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd)
1066 struct epoll_filefd ffd; 1066 struct epoll_filefd ffd;
1067 1067
1068 ep_set_ffd(&ffd, file, fd); 1068 ep_set_ffd(&ffd, file, fd);
1069 for (rbp = ep->rbr.rb_node; rbp; ) { 1069 for (rbp = ep->rbr.rb_root.rb_node; rbp; ) {
1070 epi = rb_entry(rbp, struct epitem, rbn); 1070 epi = rb_entry(rbp, struct epitem, rbn);
1071 kcmp = ep_cmp_ffd(&ffd, &epi->ffd); 1071 kcmp = ep_cmp_ffd(&ffd, &epi->ffd);
1072 if (kcmp > 0) 1072 if (kcmp > 0)
@@ -1088,7 +1088,7 @@ static struct epitem *ep_find_tfd(struct eventpoll *ep, int tfd, unsigned long t
1088 struct rb_node *rbp; 1088 struct rb_node *rbp;
1089 struct epitem *epi; 1089 struct epitem *epi;
1090 1090
1091 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 1091 for (rbp = rb_first_cached(&ep->rbr); rbp; rbp = rb_next(rbp)) {
1092 epi = rb_entry(rbp, struct epitem, rbn); 1092 epi = rb_entry(rbp, struct epitem, rbn);
1093 if (epi->ffd.fd == tfd) { 1093 if (epi->ffd.fd == tfd) {
1094 if (toff == 0) 1094 if (toff == 0)
@@ -1273,20 +1273,22 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
1273static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi) 1273static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
1274{ 1274{
1275 int kcmp; 1275 int kcmp;
1276 struct rb_node **p = &ep->rbr.rb_node, *parent = NULL; 1276 struct rb_node **p = &ep->rbr.rb_root.rb_node, *parent = NULL;
1277 struct epitem *epic; 1277 struct epitem *epic;
1278 bool leftmost = true;
1278 1279
1279 while (*p) { 1280 while (*p) {
1280 parent = *p; 1281 parent = *p;
1281 epic = rb_entry(parent, struct epitem, rbn); 1282 epic = rb_entry(parent, struct epitem, rbn);
1282 kcmp = ep_cmp_ffd(&epi->ffd, &epic->ffd); 1283 kcmp = ep_cmp_ffd(&epi->ffd, &epic->ffd);
1283 if (kcmp > 0) 1284 if (kcmp > 0) {
1284 p = &parent->rb_right; 1285 p = &parent->rb_right;
1285 else 1286 leftmost = false;
1287 } else
1286 p = &parent->rb_left; 1288 p = &parent->rb_left;
1287 } 1289 }
1288 rb_link_node(&epi->rbn, parent, p); 1290 rb_link_node(&epi->rbn, parent, p);
1289 rb_insert_color(&epi->rbn, &ep->rbr); 1291 rb_insert_color_cached(&epi->rbn, &ep->rbr, leftmost);
1290} 1292}
1291 1293
1292 1294
@@ -1530,7 +1532,7 @@ error_remove_epi:
1530 list_del_rcu(&epi->fllink); 1532 list_del_rcu(&epi->fllink);
1531 spin_unlock(&tfile->f_lock); 1533 spin_unlock(&tfile->f_lock);
1532 1534
1533 rb_erase(&epi->rbn, &ep->rbr); 1535 rb_erase_cached(&epi->rbn, &ep->rbr);
1534 1536
1535error_unregister: 1537error_unregister:
1536 ep_unregister_pollwait(ep, epi); 1538 ep_unregister_pollwait(ep, epi);
@@ -1878,7 +1880,7 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests)
1878 mutex_lock_nested(&ep->mtx, call_nests + 1); 1880 mutex_lock_nested(&ep->mtx, call_nests + 1);
1879 ep->visited = 1; 1881 ep->visited = 1;
1880 list_add(&ep->visited_list_link, &visited_list); 1882 list_add(&ep->visited_list_link, &visited_list);
1881 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 1883 for (rbp = rb_first_cached(&ep->rbr); rbp; rbp = rb_next(rbp)) {
1882 epi = rb_entry(rbp, struct epitem, rbn); 1884 epi = rb_entry(rbp, struct epitem, rbn);
1883 if (unlikely(is_file_epoll(epi->ffd.file))) { 1885 if (unlikely(is_file_epoll(epi->ffd.file))) {
1884 ep_tovisit = epi->ffd.file->private_data; 1886 ep_tovisit = epi->ffd.file->private_data;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a791aac4c5af..fb96bb71da00 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2253,7 +2253,10 @@ int f2fs_migrate_page(struct address_space *mapping,
2253 SetPagePrivate(newpage); 2253 SetPagePrivate(newpage);
2254 set_page_private(newpage, page_private(page)); 2254 set_page_private(newpage, page_private(page));
2255 2255
2256 migrate_page_copy(newpage, page); 2256 if (mode != MIGRATE_SYNC_NO_COPY)
2257 migrate_page_copy(newpage, page);
2258 else
2259 migrate_page_states(newpage, page);
2257 2260
2258 return MIGRATEPAGE_SUCCESS; 2261 return MIGRATEPAGE_SUCCESS;
2259} 2262}
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 6a7152d0c250..02c066663a3a 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -19,6 +19,8 @@
19#include <linux/ctype.h> 19#include <linux/ctype.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/namei.h> 21#include <linux/namei.h>
22#include <linux/kernel.h>
23
22#include "fat.h" 24#include "fat.h"
23 25
24static inline unsigned long vfat_d_version(struct dentry *dentry) 26static inline unsigned long vfat_d_version(struct dentry *dentry)
@@ -510,10 +512,8 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
510 struct nls_table *nls) 512 struct nls_table *nls)
511{ 513{
512 const unsigned char *ip; 514 const unsigned char *ip;
513 unsigned char nc;
514 unsigned char *op; 515 unsigned char *op;
515 unsigned int ec; 516 int i, fill;
516 int i, k, fill;
517 int charlen; 517 int charlen;
518 518
519 if (utf8) { 519 if (utf8) {
@@ -530,33 +530,22 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
530 i < len && *outlen < FAT_LFN_LEN; 530 i < len && *outlen < FAT_LFN_LEN;
531 *outlen += 1) { 531 *outlen += 1) {
532 if (escape && (*ip == ':')) { 532 if (escape && (*ip == ':')) {
533 u8 uc[2];
534
533 if (i > len - 5) 535 if (i > len - 5)
534 return -EINVAL; 536 return -EINVAL;
535 ec = 0; 537
536 for (k = 1; k < 5; k++) { 538 if (hex2bin(uc, ip + 1, 2) < 0)
537 nc = ip[k];
538 ec <<= 4;
539 if (nc >= '0' && nc <= '9') {
540 ec |= nc - '0';
541 continue;
542 }
543 if (nc >= 'a' && nc <= 'f') {
544 ec |= nc - ('a' - 10);
545 continue;
546 }
547 if (nc >= 'A' && nc <= 'F') {
548 ec |= nc - ('A' - 10);
549 continue;
550 }
551 return -EINVAL; 539 return -EINVAL;
552 } 540
553 *op++ = ec & 0xFF; 541 *(wchar_t *)op = uc[0] << 8 | uc[1];
554 *op++ = ec >> 8; 542
543 op += 2;
555 ip += 5; 544 ip += 5;
556 i += 5; 545 i += 5;
557 } else { 546 } else {
558 charlen = nls->char2uni(ip, len - i, 547 charlen = nls->char2uni(ip, len - i,
559 (wchar_t *)op); 548 (wchar_t *)op);
560 if (charlen < 0) 549 if (charlen < 0)
561 return -EINVAL; 550 return -EINVAL;
562 ip += charlen; 551 ip += charlen;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7c02b3f738e1..59073e9f01a4 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -334,7 +334,7 @@ static void remove_huge_page(struct page *page)
334} 334}
335 335
336static void 336static void
337hugetlb_vmdelete_list(struct rb_root *root, pgoff_t start, pgoff_t end) 337hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end)
338{ 338{
339 struct vm_area_struct *vma; 339 struct vm_area_struct *vma;
340 340
@@ -498,7 +498,7 @@ static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
498 498
499 i_size_write(inode, offset); 499 i_size_write(inode, offset);
500 i_mmap_lock_write(mapping); 500 i_mmap_lock_write(mapping);
501 if (!RB_EMPTY_ROOT(&mapping->i_mmap)) 501 if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
502 hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0); 502 hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0);
503 i_mmap_unlock_write(mapping); 503 i_mmap_unlock_write(mapping);
504 remove_inode_hugepages(inode, offset, LLONG_MAX); 504 remove_inode_hugepages(inode, offset, LLONG_MAX);
@@ -523,7 +523,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
523 523
524 inode_lock(inode); 524 inode_lock(inode);
525 i_mmap_lock_write(mapping); 525 i_mmap_lock_write(mapping);
526 if (!RB_EMPTY_ROOT(&mapping->i_mmap)) 526 if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
527 hugetlb_vmdelete_list(&mapping->i_mmap, 527 hugetlb_vmdelete_list(&mapping->i_mmap,
528 hole_start >> PAGE_SHIFT, 528 hole_start >> PAGE_SHIFT,
529 hole_end >> PAGE_SHIFT); 529 hole_end >> PAGE_SHIFT);
@@ -830,7 +830,10 @@ static int hugetlbfs_migrate_page(struct address_space *mapping,
830 rc = migrate_huge_page_move_mapping(mapping, newpage, page); 830 rc = migrate_huge_page_move_mapping(mapping, newpage, page);
831 if (rc != MIGRATEPAGE_SUCCESS) 831 if (rc != MIGRATEPAGE_SUCCESS)
832 return rc; 832 return rc;
833 migrate_page_copy(newpage, page); 833 if (mode != MIGRATE_SYNC_NO_COPY)
834 migrate_page_copy(newpage, page);
835 else
836 migrate_page_states(newpage, page);
834 837
835 return MIGRATEPAGE_SUCCESS; 838 return MIGRATEPAGE_SUCCESS;
836} 839}
diff --git a/fs/inode.c b/fs/inode.c
index 6a1626e0edaf..210054157a49 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -353,7 +353,7 @@ void address_space_init_once(struct address_space *mapping)
353 init_rwsem(&mapping->i_mmap_rwsem); 353 init_rwsem(&mapping->i_mmap_rwsem);
354 INIT_LIST_HEAD(&mapping->private_list); 354 INIT_LIST_HEAD(&mapping->private_list);
355 spin_lock_init(&mapping->private_lock); 355 spin_lock_init(&mapping->private_lock);
356 mapping->i_mmap = RB_ROOT; 356 mapping->i_mmap = RB_ROOT_CACHED;
357} 357}
358EXPORT_SYMBOL(address_space_init_once); 358EXPORT_SYMBOL(address_space_init_once);
359 359
diff --git a/fs/namei.c b/fs/namei.c
index ddb6a7c2b3d4..1180f9c58093 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1129,9 +1129,18 @@ static int follow_automount(struct path *path, struct nameidata *nd,
1129 * of the daemon to instantiate them before they can be used. 1129 * of the daemon to instantiate them before they can be used.
1130 */ 1130 */
1131 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | 1131 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
1132 LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) && 1132 LOOKUP_OPEN | LOOKUP_CREATE |
1133 path->dentry->d_inode) 1133 LOOKUP_AUTOMOUNT))) {
1134 return -EISDIR; 1134 /* Positive dentry that isn't meant to trigger an
1135 * automount, EISDIR will allow it to be used,
1136 * otherwise there's no mount here "now" so return
1137 * ENOENT.
1138 */
1139 if (path->dentry->d_inode)
1140 return -EISDIR;
1141 else
1142 return -ENOENT;
1143 }
1135 1144
1136 if (path->dentry->d_sb->s_user_ns != &init_user_ns) 1145 if (path->dentry->d_sb->s_user_ns != &init_user_ns)
1137 return -EACCES; 1146 return -EACCES;
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index e3cda0b5968f..793a67574668 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -40,8 +40,8 @@ static int proc_match(unsigned int len, const char *name, struct proc_dir_entry
40 40
41static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir) 41static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir)
42{ 42{
43 return rb_entry_safe(rb_first(&dir->subdir), struct proc_dir_entry, 43 return rb_entry_safe(rb_first_cached(&dir->subdir),
44 subdir_node); 44 struct proc_dir_entry, subdir_node);
45} 45}
46 46
47static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir) 47static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir)
@@ -54,7 +54,7 @@ static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
54 const char *name, 54 const char *name,
55 unsigned int len) 55 unsigned int len)
56{ 56{
57 struct rb_node *node = dir->subdir.rb_node; 57 struct rb_node *node = dir->subdir.rb_root.rb_node;
58 58
59 while (node) { 59 while (node) {
60 struct proc_dir_entry *de = rb_entry(node, 60 struct proc_dir_entry *de = rb_entry(node,
@@ -75,8 +75,9 @@ static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
75static bool pde_subdir_insert(struct proc_dir_entry *dir, 75static bool pde_subdir_insert(struct proc_dir_entry *dir,
76 struct proc_dir_entry *de) 76 struct proc_dir_entry *de)
77{ 77{
78 struct rb_root *root = &dir->subdir; 78 struct rb_root_cached *root = &dir->subdir;
79 struct rb_node **new = &root->rb_node, *parent = NULL; 79 struct rb_node **new = &root->rb_root.rb_node, *parent = NULL;
80 bool leftmost = true;
80 81
81 /* Figure out where to put new node */ 82 /* Figure out where to put new node */
82 while (*new) { 83 while (*new) {
@@ -88,15 +89,16 @@ static bool pde_subdir_insert(struct proc_dir_entry *dir,
88 parent = *new; 89 parent = *new;
89 if (result < 0) 90 if (result < 0)
90 new = &(*new)->rb_left; 91 new = &(*new)->rb_left;
91 else if (result > 0) 92 else if (result > 0) {
92 new = &(*new)->rb_right; 93 new = &(*new)->rb_right;
93 else 94 leftmost = false;
95 } else
94 return false; 96 return false;
95 } 97 }
96 98
97 /* Add new node and rebalance tree. */ 99 /* Add new node and rebalance tree. */
98 rb_link_node(&de->subdir_node, parent, new); 100 rb_link_node(&de->subdir_node, parent, new);
99 rb_insert_color(&de->subdir_node, root); 101 rb_insert_color_cached(&de->subdir_node, root, leftmost);
100 return true; 102 return true;
101} 103}
102 104
@@ -369,7 +371,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
369 ent->namelen = qstr.len; 371 ent->namelen = qstr.len;
370 ent->mode = mode; 372 ent->mode = mode;
371 ent->nlink = nlink; 373 ent->nlink = nlink;
372 ent->subdir = RB_ROOT; 374 ent->subdir = RB_ROOT_CACHED;
373 atomic_set(&ent->count, 1); 375 atomic_set(&ent->count, 1);
374 spin_lock_init(&ent->pde_unload_lock); 376 spin_lock_init(&ent->pde_unload_lock);
375 INIT_LIST_HEAD(&ent->pde_openers); 377 INIT_LIST_HEAD(&ent->pde_openers);
@@ -499,6 +501,14 @@ out:
499} 501}
500EXPORT_SYMBOL(proc_create_data); 502EXPORT_SYMBOL(proc_create_data);
501 503
504struct proc_dir_entry *proc_create(const char *name, umode_t mode,
505 struct proc_dir_entry *parent,
506 const struct file_operations *proc_fops)
507{
508 return proc_create_data(name, mode, parent, proc_fops, NULL);
509}
510EXPORT_SYMBOL(proc_create);
511
502void proc_set_size(struct proc_dir_entry *de, loff_t size) 512void proc_set_size(struct proc_dir_entry *de, loff_t size)
503{ 513{
504 de->size = size; 514 de->size = size;
@@ -545,7 +555,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
545 555
546 de = pde_subdir_find(parent, fn, len); 556 de = pde_subdir_find(parent, fn, len);
547 if (de) 557 if (de)
548 rb_erase(&de->subdir_node, &parent->subdir); 558 rb_erase_cached(&de->subdir_node, &parent->subdir);
549 write_unlock(&proc_subdir_lock); 559 write_unlock(&proc_subdir_lock);
550 if (!de) { 560 if (!de) {
551 WARN(1, "name '%s'\n", name); 561 WARN(1, "name '%s'\n", name);
@@ -582,13 +592,13 @@ int remove_proc_subtree(const char *name, struct proc_dir_entry *parent)
582 write_unlock(&proc_subdir_lock); 592 write_unlock(&proc_subdir_lock);
583 return -ENOENT; 593 return -ENOENT;
584 } 594 }
585 rb_erase(&root->subdir_node, &parent->subdir); 595 rb_erase_cached(&root->subdir_node, &parent->subdir);
586 596
587 de = root; 597 de = root;
588 while (1) { 598 while (1) {
589 next = pde_subdir_first(de); 599 next = pde_subdir_first(de);
590 if (next) { 600 if (next) {
591 rb_erase(&next->subdir_node, &de->subdir); 601 rb_erase_cached(&next->subdir_node, &de->subdir);
592 de = next; 602 de = next;
593 continue; 603 continue;
594 } 604 }
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 2cbfcd32e884..a34195e92b20 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -40,7 +40,7 @@ struct proc_dir_entry {
40 const struct inode_operations *proc_iops; 40 const struct inode_operations *proc_iops;
41 const struct file_operations *proc_fops; 41 const struct file_operations *proc_fops;
42 struct proc_dir_entry *parent; 42 struct proc_dir_entry *parent;
43 struct rb_root subdir; 43 struct rb_root_cached subdir;
44 struct rb_node subdir_node; 44 struct rb_node subdir_node;
45 void *data; 45 void *data;
46 atomic_t count; /* use count */ 46 atomic_t count; /* use count */
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index d72fc40241d9..a2bf369c923d 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -196,7 +196,7 @@ static __net_init int proc_net_ns_init(struct net *net)
196 if (!netd) 196 if (!netd)
197 goto out; 197 goto out;
198 198
199 netd->subdir = RB_ROOT; 199 netd->subdir = RB_ROOT_CACHED;
200 netd->data = net; 200 netd->data = net;
201 netd->nlink = 2; 201 netd->nlink = 2;
202 netd->namelen = 3; 202 netd->namelen = 3;
diff --git a/fs/proc/root.c b/fs/proc/root.c
index deecb397daa3..926fb27f4ca2 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -210,7 +210,7 @@ struct proc_dir_entry proc_root = {
210 .proc_iops = &proc_root_inode_operations, 210 .proc_iops = &proc_root_inode_operations,
211 .proc_fops = &proc_root_operations, 211 .proc_fops = &proc_root_operations,
212 .parent = &proc_root, 212 .parent = &proc_root,
213 .subdir = RB_ROOT, 213 .subdir = RB_ROOT_CACHED,
214 .name = "/proc", 214 .name = "/proc",
215}; 215};
216 216
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index a290966f91ec..7b40e11ede9b 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -268,8 +268,7 @@ static int do_maps_open(struct inode *inode, struct file *file,
268 * Indicate if the VMA is a stack for the given task; for 268 * Indicate if the VMA is a stack for the given task; for
269 * /proc/PID/maps that is the stack of the main task. 269 * /proc/PID/maps that is the stack of the main task.
270 */ 270 */
271static int is_stack(struct proc_maps_private *priv, 271static int is_stack(struct vm_area_struct *vma)
272 struct vm_area_struct *vma)
273{ 272{
274 /* 273 /*
275 * We make no effort to guess what a given thread considers to be 274 * We make no effort to guess what a given thread considers to be
@@ -302,7 +301,6 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
302{ 301{
303 struct mm_struct *mm = vma->vm_mm; 302 struct mm_struct *mm = vma->vm_mm;
304 struct file *file = vma->vm_file; 303 struct file *file = vma->vm_file;
305 struct proc_maps_private *priv = m->private;
306 vm_flags_t flags = vma->vm_flags; 304 vm_flags_t flags = vma->vm_flags;
307 unsigned long ino = 0; 305 unsigned long ino = 0;
308 unsigned long long pgoff = 0; 306 unsigned long long pgoff = 0;
@@ -350,7 +348,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
350 goto done; 348 goto done;
351 } 349 }
352 350
353 if (is_stack(priv, vma)) 351 if (is_stack(vma))
354 name = "[stack]"; 352 name = "[stack]";
355 } 353 }
356 354
@@ -549,6 +547,8 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
549 } 547 }
550 } else if (is_migration_entry(swpent)) 548 } else if (is_migration_entry(swpent))
551 page = migration_entry_to_page(swpent); 549 page = migration_entry_to_page(swpent);
550 else if (is_device_private_entry(swpent))
551 page = device_private_entry_to_page(swpent);
552 } else if (unlikely(IS_ENABLED(CONFIG_SHMEM) && mss->check_shmem_swap 552 } else if (unlikely(IS_ENABLED(CONFIG_SHMEM) && mss->check_shmem_swap
553 && pte_none(*pte))) { 553 && pte_none(*pte))) {
554 page = find_get_entry(vma->vm_file->f_mapping, 554 page = find_get_entry(vma->vm_file->f_mapping,
@@ -608,13 +608,14 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
608 608
609 ptl = pmd_trans_huge_lock(pmd, vma); 609 ptl = pmd_trans_huge_lock(pmd, vma);
610 if (ptl) { 610 if (ptl) {
611 smaps_pmd_entry(pmd, addr, walk); 611 if (pmd_present(*pmd))
612 smaps_pmd_entry(pmd, addr, walk);
612 spin_unlock(ptl); 613 spin_unlock(ptl);
613 return 0; 614 goto out;
614 } 615 }
615 616
616 if (pmd_trans_unstable(pmd)) 617 if (pmd_trans_unstable(pmd))
617 return 0; 618 goto out;
618 /* 619 /*
619 * The mmap_sem held all the way back in m_start() is what 620 * The mmap_sem held all the way back in m_start() is what
620 * keeps khugepaged out of here and from collapsing things 621 * keeps khugepaged out of here and from collapsing things
@@ -624,6 +625,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
624 for (; addr != end; pte++, addr += PAGE_SIZE) 625 for (; addr != end; pte++, addr += PAGE_SIZE)
625 smaps_pte_entry(pte, addr, walk); 626 smaps_pte_entry(pte, addr, walk);
626 pte_unmap_unlock(pte - 1, ptl); 627 pte_unmap_unlock(pte - 1, ptl);
628out:
627 cond_resched(); 629 cond_resched();
628 return 0; 630 return 0;
629} 631}
@@ -712,6 +714,8 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask,
712 714
713 if (is_migration_entry(swpent)) 715 if (is_migration_entry(swpent))
714 page = migration_entry_to_page(swpent); 716 page = migration_entry_to_page(swpent);
717 else if (is_device_private_entry(swpent))
718 page = device_private_entry_to_page(swpent);
715 } 719 }
716 if (page) { 720 if (page) {
717 int mapcount = page_mapcount(page); 721 int mapcount = page_mapcount(page);
@@ -977,17 +981,22 @@ static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma,
977{ 981{
978 pmd_t pmd = *pmdp; 982 pmd_t pmd = *pmdp;
979 983
980 /* See comment in change_huge_pmd() */ 984 if (pmd_present(pmd)) {
981 pmdp_invalidate(vma, addr, pmdp); 985 /* See comment in change_huge_pmd() */
982 if (pmd_dirty(*pmdp)) 986 pmdp_invalidate(vma, addr, pmdp);
983 pmd = pmd_mkdirty(pmd); 987 if (pmd_dirty(*pmdp))
984 if (pmd_young(*pmdp)) 988 pmd = pmd_mkdirty(pmd);
985 pmd = pmd_mkyoung(pmd); 989 if (pmd_young(*pmdp))
986 990 pmd = pmd_mkyoung(pmd);
987 pmd = pmd_wrprotect(pmd); 991
988 pmd = pmd_clear_soft_dirty(pmd); 992 pmd = pmd_wrprotect(pmd);
989 993 pmd = pmd_clear_soft_dirty(pmd);
990 set_pmd_at(vma->vm_mm, addr, pmdp, pmd); 994
995 set_pmd_at(vma->vm_mm, addr, pmdp, pmd);
996 } else if (is_migration_entry(pmd_to_swp_entry(pmd))) {
997 pmd = pmd_swp_clear_soft_dirty(pmd);
998 set_pmd_at(vma->vm_mm, addr, pmdp, pmd);
999 }
991} 1000}
992#else 1001#else
993static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma, 1002static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma,
@@ -1012,6 +1021,9 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
1012 goto out; 1021 goto out;
1013 } 1022 }
1014 1023
1024 if (!pmd_present(*pmd))
1025 goto out;
1026
1015 page = pmd_page(*pmd); 1027 page = pmd_page(*pmd);
1016 1028
1017 /* Clear accessed and referenced bits. */ 1029 /* Clear accessed and referenced bits. */
@@ -1254,7 +1266,7 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
1254 if (pm->show_pfn) 1266 if (pm->show_pfn)
1255 frame = pte_pfn(pte); 1267 frame = pte_pfn(pte);
1256 flags |= PM_PRESENT; 1268 flags |= PM_PRESENT;
1257 page = vm_normal_page(vma, addr, pte); 1269 page = _vm_normal_page(vma, addr, pte, true);
1258 if (pte_soft_dirty(pte)) 1270 if (pte_soft_dirty(pte))
1259 flags |= PM_SOFT_DIRTY; 1271 flags |= PM_SOFT_DIRTY;
1260 } else if (is_swap_pte(pte)) { 1272 } else if (is_swap_pte(pte)) {
@@ -1267,6 +1279,9 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
1267 flags |= PM_SWAP; 1279 flags |= PM_SWAP;
1268 if (is_migration_entry(entry)) 1280 if (is_migration_entry(entry))
1269 page = migration_entry_to_page(entry); 1281 page = migration_entry_to_page(entry);
1282
1283 if (is_device_private_entry(entry))
1284 page = device_private_entry_to_page(entry);
1270 } 1285 }
1271 1286
1272 if (page && !PageAnon(page)) 1287 if (page && !PageAnon(page))
@@ -1293,27 +1308,33 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
1293 if (ptl) { 1308 if (ptl) {
1294 u64 flags = 0, frame = 0; 1309 u64 flags = 0, frame = 0;
1295 pmd_t pmd = *pmdp; 1310 pmd_t pmd = *pmdp;
1311 struct page *page = NULL;
1296 1312
1297 if ((vma->vm_flags & VM_SOFTDIRTY) || pmd_soft_dirty(pmd)) 1313 if ((vma->vm_flags & VM_SOFTDIRTY) || pmd_soft_dirty(pmd))
1298 flags |= PM_SOFT_DIRTY; 1314 flags |= PM_SOFT_DIRTY;
1299 1315
1300 /*
1301 * Currently pmd for thp is always present because thp
1302 * can not be swapped-out, migrated, or HWPOISONed
1303 * (split in such cases instead.)
1304 * This if-check is just to prepare for future implementation.
1305 */
1306 if (pmd_present(pmd)) { 1316 if (pmd_present(pmd)) {
1307 struct page *page = pmd_page(pmd); 1317 page = pmd_page(pmd);
1308
1309 if (page_mapcount(page) == 1)
1310 flags |= PM_MMAP_EXCLUSIVE;
1311 1318
1312 flags |= PM_PRESENT; 1319 flags |= PM_PRESENT;
1313 if (pm->show_pfn) 1320 if (pm->show_pfn)
1314 frame = pmd_pfn(pmd) + 1321 frame = pmd_pfn(pmd) +
1315 ((addr & ~PMD_MASK) >> PAGE_SHIFT); 1322 ((addr & ~PMD_MASK) >> PAGE_SHIFT);
1316 } 1323 }
1324#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
1325 else if (is_swap_pmd(pmd)) {
1326 swp_entry_t entry = pmd_to_swp_entry(pmd);
1327
1328 frame = swp_type(entry) |
1329 (swp_offset(entry) << MAX_SWAPFILES_SHIFT);
1330 flags |= PM_SWAP;
1331 VM_BUG_ON(!is_pmd_migration_entry(pmd));
1332 page = migration_entry_to_page(entry);
1333 }
1334#endif
1335
1336 if (page && page_mapcount(page) == 1)
1337 flags |= PM_MMAP_EXCLUSIVE;
1317 1338
1318 for (; addr != end; addr += PAGE_SIZE) { 1339 for (; addr != end; addr += PAGE_SIZE) {
1319 pagemap_entry_t pme = make_pme(frame, flags); 1340 pagemap_entry_t pme = make_pme(frame, flags);
@@ -1746,7 +1767,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
1746 seq_file_path(m, file, "\n\t= "); 1767 seq_file_path(m, file, "\n\t= ");
1747 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 1768 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
1748 seq_puts(m, " heap"); 1769 seq_puts(m, " heap");
1749 } else if (is_stack(proc_priv, vma)) { 1770 } else if (is_stack(vma)) {
1750 seq_puts(m, " stack"); 1771 seq_puts(m, " stack");
1751 } 1772 }
1752 1773
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 23266694db11..dea90b566a6e 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -125,8 +125,7 @@ unsigned long task_statm(struct mm_struct *mm,
125 return size; 125 return size;
126} 126}
127 127
128static int is_stack(struct proc_maps_private *priv, 128static int is_stack(struct vm_area_struct *vma)
129 struct vm_area_struct *vma)
130{ 129{
131 struct mm_struct *mm = vma->vm_mm; 130 struct mm_struct *mm = vma->vm_mm;
132 131
@@ -178,7 +177,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
178 if (file) { 177 if (file) {
179 seq_pad(m, ' '); 178 seq_pad(m, ' ');
180 seq_file_path(m, file, ""); 179 seq_file_path(m, file, "");
181 } else if (mm && is_stack(priv, vma)) { 180 } else if (mm && is_stack(vma)) {
182 seq_pad(m, ' '); 181 seq_pad(m, ' ');
183 seq_printf(m, "[stack]"); 182 seq_printf(m, "[stack]");
184 } 183 }
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index f90a466ea5db..a02aa59d1e24 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1490,7 +1490,10 @@ static int ubifs_migrate_page(struct address_space *mapping,
1490 SetPagePrivate(newpage); 1490 SetPagePrivate(newpage);
1491 } 1491 }
1492 1492
1493 migrate_page_copy(newpage, page); 1493 if (mode != MIGRATE_SYNC_NO_COPY)
1494 migrate_page_copy(newpage, page);
1495 else
1496 migrate_page_states(newpage, page);
1494 return MIGRATEPAGE_SUCCESS; 1497 return MIGRATEPAGE_SUCCESS;
1495} 1498}
1496#endif 1499#endif
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 5419e7da82ba..ef4b48d1ea42 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -381,8 +381,26 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
381 * in __get_user_pages if userfaultfd_release waits on the 381 * in __get_user_pages if userfaultfd_release waits on the
382 * caller of handle_userfault to release the mmap_sem. 382 * caller of handle_userfault to release the mmap_sem.
383 */ 383 */
384 if (unlikely(ACCESS_ONCE(ctx->released))) 384 if (unlikely(ACCESS_ONCE(ctx->released))) {
385 /*
386 * Don't return VM_FAULT_SIGBUS in this case, so a non
387 * cooperative manager can close the uffd after the
388 * last UFFDIO_COPY, without risking to trigger an
389 * involuntary SIGBUS if the process was starting the
390 * userfaultfd while the userfaultfd was still armed
391 * (but after the last UFFDIO_COPY). If the uffd
392 * wasn't already closed when the userfault reached
393 * this point, that would normally be solved by
394 * userfaultfd_must_wait returning 'false'.
395 *
396 * If we were to return VM_FAULT_SIGBUS here, the non
397 * cooperative manager would be instead forced to
398 * always call UFFDIO_UNREGISTER before it can safely
399 * close the uffd.
400 */
401 ret = VM_FAULT_NOPAGE;
385 goto out; 402 goto out;
403 }
386 404
387 /* 405 /*
388 * Check that we can return VM_FAULT_RETRY. 406 * Check that we can return VM_FAULT_RETRY.
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 4d7bb98f4134..8e0243036564 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -630,7 +630,24 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,
630#define arch_start_context_switch(prev) do {} while (0) 630#define arch_start_context_switch(prev) do {} while (0)
631#endif 631#endif
632 632
633#ifndef CONFIG_HAVE_ARCH_SOFT_DIRTY 633#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
634#ifndef CONFIG_ARCH_ENABLE_THP_MIGRATION
635static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd)
636{
637 return pmd;
638}
639
640static inline int pmd_swp_soft_dirty(pmd_t pmd)
641{
642 return 0;
643}
644
645static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd)
646{
647 return pmd;
648}
649#endif
650#else /* !CONFIG_HAVE_ARCH_SOFT_DIRTY */
634static inline int pte_soft_dirty(pte_t pte) 651static inline int pte_soft_dirty(pte_t pte)
635{ 652{
636 return 0; 653 return 0;
@@ -675,6 +692,21 @@ static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
675{ 692{
676 return pte; 693 return pte;
677} 694}
695
696static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd)
697{
698 return pmd;
699}
700
701static inline int pmd_swp_soft_dirty(pmd_t pmd)
702{
703 return 0;
704}
705
706static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd)
707{
708 return pmd;
709}
678#endif 710#endif
679 711
680#ifndef __HAVE_PFNMAP_TRACKING 712#ifndef __HAVE_PFNMAP_TRACKING
@@ -846,7 +878,23 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
846#ifdef CONFIG_TRANSPARENT_HUGEPAGE 878#ifdef CONFIG_TRANSPARENT_HUGEPAGE
847 barrier(); 879 barrier();
848#endif 880#endif
849 if (pmd_none(pmdval) || pmd_trans_huge(pmdval)) 881 /*
882 * !pmd_present() checks for pmd migration entries
883 *
884 * The complete check uses is_pmd_migration_entry() in linux/swapops.h
885 * But using that requires moving current function and pmd_trans_unstable()
886 * to linux/swapops.h to resovle dependency, which is too much code move.
887 *
888 * !pmd_present() is equivalent to is_pmd_migration_entry() currently,
889 * because !pmd_present() pages can only be under migration not swapped
890 * out.
891 *
892 * pmd_none() is preseved for future condition checks on pmd migration
893 * entries and not confusing with this function name, although it is
894 * redundant with !pmd_present().
895 */
896 if (pmd_none(pmdval) || pmd_trans_huge(pmdval) ||
897 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
850 return 1; 898 return 1;
851 if (unlikely(pmd_bad(pmdval))) { 899 if (unlikely(pmd_bad(pmdval))) {
852 pmd_clear_bad(pmd); 900 pmd_clear_bad(pmd);
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 49b292e98fec..8d10fc97801c 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -172,7 +172,7 @@ struct drm_mm {
172 * according to the (increasing) start address of the memory node. */ 172 * according to the (increasing) start address of the memory node. */
173 struct drm_mm_node head_node; 173 struct drm_mm_node head_node;
174 /* Keep an interval_tree for fast lookup of drm_mm_nodes by address. */ 174 /* Keep an interval_tree for fast lookup of drm_mm_nodes by address. */
175 struct rb_root interval_tree; 175 struct rb_root_cached interval_tree;
176 struct rb_root holes_size; 176 struct rb_root holes_size;
177 struct rb_root holes_addr; 177 struct rb_root holes_addr;
178 178
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 5797ca6fdfe2..700cf5f67118 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -361,6 +361,38 @@ static inline int bitmap_parse(const char *buf, unsigned int buflen,
361} 361}
362 362
363/* 363/*
364 * BITMAP_FROM_U64() - Represent u64 value in the format suitable for bitmap.
365 *
366 * Linux bitmaps are internally arrays of unsigned longs, i.e. 32-bit
367 * integers in 32-bit environment, and 64-bit integers in 64-bit one.
368 *
369 * There are four combinations of endianness and length of the word in linux
370 * ABIs: LE64, BE64, LE32 and BE32.
371 *
372 * On 64-bit kernels 64-bit LE and BE numbers are naturally ordered in
373 * bitmaps and therefore don't require any special handling.
374 *
375 * On 32-bit kernels 32-bit LE ABI orders lo word of 64-bit number in memory
376 * prior to hi, and 32-bit BE orders hi word prior to lo. The bitmap on the
377 * other hand is represented as an array of 32-bit words and the position of
378 * bit N may therefore be calculated as: word #(N/32) and bit #(N%32) in that
379 * word. For example, bit #42 is located at 10th position of 2nd word.
380 * It matches 32-bit LE ABI, and we can simply let the compiler store 64-bit
381 * values in memory as it usually does. But for BE we need to swap hi and lo
382 * words manually.
383 *
384 * With all that, the macro BITMAP_FROM_U64() does explicit reordering of hi and
385 * lo parts of u64. For LE32 it does nothing, and for BE environment it swaps
386 * hi and lo words, as is expected by bitmap.
387 */
388#if __BITS_PER_LONG == 64
389#define BITMAP_FROM_U64(n) (n)
390#else
391#define BITMAP_FROM_U64(n) ((unsigned long) ((u64)(n) & ULONG_MAX)), \
392 ((unsigned long) ((u64)(n) >> 32))
393#endif
394
395/*
364 * bitmap_from_u64 - Check and swap words within u64. 396 * bitmap_from_u64 - Check and swap words within u64.
365 * @mask: source bitmap 397 * @mask: source bitmap
366 * @dst: destination bitmap 398 * @dst: destination bitmap
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a83c822c35c2..8fbe259b197c 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -19,10 +19,11 @@
19 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. 19 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
20 */ 20 */
21#define GENMASK(h, l) \ 21#define GENMASK(h, l) \
22 (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) 22 (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
23 23
24#define GENMASK_ULL(h, l) \ 24#define GENMASK_ULL(h, l) \
25 (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) 25 (((~0ULL) - (1ULL << (l)) + 1) & \
26 (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
26 27
27extern unsigned int __sw_hweight8(unsigned int w); 28extern unsigned int __sw_hweight8(unsigned int w);
28extern unsigned int __sw_hweight16(unsigned int w); 29extern unsigned int __sw_hweight16(unsigned int w);
diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index 392041475c72..ffd215988392 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -3,5 +3,9 @@
3 3
4#include <uapi/linux/byteorder/big_endian.h> 4#include <uapi/linux/byteorder/big_endian.h>
5 5
6#ifndef CONFIG_CPU_BIG_ENDIAN
7#warning inconsistent configuration, needs CONFIG_CPU_BIG_ENDIAN
8#endif
9
6#include <linux/byteorder/generic.h> 10#include <linux/byteorder/generic.h>
7#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */ 11#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index 08057377aa23..ba910bb9aad0 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -3,5 +3,9 @@
3 3
4#include <uapi/linux/byteorder/little_endian.h> 4#include <uapi/linux/byteorder/little_endian.h>
5 5
6#ifdef CONFIG_CPU_BIG_ENDIAN
7#warning inconsistent configuration, CONFIG_CPU_BIG_ENDIAN is set
8#endif
9
6#include <linux/byteorder/generic.h> 10#include <linux/byteorder/generic.h>
7#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ 11#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 4bf4479a3a80..cd415b733c2a 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -32,15 +32,15 @@ typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
32#define cpumask_pr_args(maskp) nr_cpu_ids, cpumask_bits(maskp) 32#define cpumask_pr_args(maskp) nr_cpu_ids, cpumask_bits(maskp)
33 33
34#if NR_CPUS == 1 34#if NR_CPUS == 1
35#define nr_cpu_ids 1 35#define nr_cpu_ids 1U
36#else 36#else
37extern int nr_cpu_ids; 37extern unsigned int nr_cpu_ids;
38#endif 38#endif
39 39
40#ifdef CONFIG_CPUMASK_OFFSTACK 40#ifdef CONFIG_CPUMASK_OFFSTACK
41/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also, 41/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
42 * not all bits may be allocated. */ 42 * not all bits may be allocated. */
43#define nr_cpumask_bits ((unsigned int)nr_cpu_ids) 43#define nr_cpumask_bits nr_cpu_ids
44#else 44#else
45#define nr_cpumask_bits ((unsigned int)NR_CPUS) 45#define nr_cpumask_bits ((unsigned int)NR_CPUS)
46#endif 46#endif
@@ -178,20 +178,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
178 return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits); 178 return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits);
179} 179}
180 180
181/** 181unsigned int cpumask_next(int n, const struct cpumask *srcp);
182 * cpumask_next - get the next cpu in a cpumask
183 * @n: the cpu prior to the place to search (ie. return will be > @n)
184 * @srcp: the cpumask pointer
185 *
186 * Returns >= nr_cpu_ids if no further cpus set.
187 */
188static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
189{
190 /* -1 is a legal arg here. */
191 if (n != -1)
192 cpumask_check(n);
193 return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
194}
195 182
196/** 183/**
197 * cpumask_next_zero - get the next unset cpu in a cpumask 184 * cpumask_next_zero - get the next unset cpu in a cpumask
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 509434aaf5a4..2d0e6748e46e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -392,7 +392,7 @@ struct address_space {
392 struct radix_tree_root page_tree; /* radix tree of all pages */ 392 struct radix_tree_root page_tree; /* radix tree of all pages */
393 spinlock_t tree_lock; /* and lock protecting it */ 393 spinlock_t tree_lock; /* and lock protecting it */
394 atomic_t i_mmap_writable;/* count VM_SHARED mappings */ 394 atomic_t i_mmap_writable;/* count VM_SHARED mappings */
395 struct rb_root i_mmap; /* tree of private and shared mappings */ 395 struct rb_root_cached i_mmap; /* tree of private and shared mappings */
396 struct rw_semaphore i_mmap_rwsem; /* protect tree, count, list */ 396 struct rw_semaphore i_mmap_rwsem; /* protect tree, count, list */
397 /* Protected by tree_lock together with the radix tree */ 397 /* Protected by tree_lock together with the radix tree */
398 unsigned long nrpages; /* number of total pages */ 398 unsigned long nrpages; /* number of total pages */
@@ -487,7 +487,7 @@ static inline void i_mmap_unlock_read(struct address_space *mapping)
487 */ 487 */
488static inline int mapping_mapped(struct address_space *mapping) 488static inline int mapping_mapped(struct address_space *mapping)
489{ 489{
490 return !RB_EMPTY_ROOT(&mapping->i_mmap); 490 return !RB_EMPTY_ROOT(&mapping->i_mmap.rb_root);
491} 491}
492 492
493/* 493/*
@@ -3043,8 +3043,7 @@ static inline int vfs_lstat(const char __user *name, struct kstat *stat)
3043static inline int vfs_fstatat(int dfd, const char __user *filename, 3043static inline int vfs_fstatat(int dfd, const char __user *filename,
3044 struct kstat *stat, int flags) 3044 struct kstat *stat, int flags)
3045{ 3045{
3046 return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, 3046 return vfs_statx(dfd, filename, flags, stat, STATX_BASIC_STATS);
3047 stat, STATX_BASIC_STATS);
3048} 3047}
3049static inline int vfs_fstat(int fd, struct kstat *stat) 3048static inline int vfs_fstat(int fd, struct kstat *stat)
3050{ 3049{
diff --git a/include/linux/hmm.h b/include/linux/hmm.h
new file mode 100644
index 000000000000..96e69979f84d
--- /dev/null
+++ b/include/linux/hmm.h
@@ -0,0 +1,520 @@
1/*
2 * Copyright 2013 Red Hat Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * Authors: Jérôme Glisse <jglisse@redhat.com>
15 */
16/*
17 * Heterogeneous Memory Management (HMM)
18 *
19 * See Documentation/vm/hmm.txt for reasons and overview of what HMM is and it
20 * is for. Here we focus on the HMM API description, with some explanation of
21 * the underlying implementation.
22 *
23 * Short description: HMM provides a set of helpers to share a virtual address
24 * space between CPU and a device, so that the device can access any valid
25 * address of the process (while still obeying memory protection). HMM also
26 * provides helpers to migrate process memory to device memory, and back. Each
27 * set of functionality (address space mirroring, and migration to and from
28 * device memory) can be used independently of the other.
29 *
30 *
31 * HMM address space mirroring API:
32 *
33 * Use HMM address space mirroring if you want to mirror range of the CPU page
34 * table of a process into a device page table. Here, "mirror" means "keep
35 * synchronized". Prerequisites: the device must provide the ability to write-
36 * protect its page tables (at PAGE_SIZE granularity), and must be able to
37 * recover from the resulting potential page faults.
38 *
39 * HMM guarantees that at any point in time, a given virtual address points to
40 * either the same memory in both CPU and device page tables (that is: CPU and
41 * device page tables each point to the same pages), or that one page table (CPU
42 * or device) points to no entry, while the other still points to the old page
43 * for the address. The latter case happens when the CPU page table update
44 * happens first, and then the update is mirrored over to the device page table.
45 * This does not cause any issue, because the CPU page table cannot start
46 * pointing to a new page until the device page table is invalidated.
47 *
48 * HMM uses mmu_notifiers to monitor the CPU page tables, and forwards any
49 * updates to each device driver that has registered a mirror. It also provides
50 * some API calls to help with taking a snapshot of the CPU page table, and to
51 * synchronize with any updates that might happen concurrently.
52 *
53 *
54 * HMM migration to and from device memory:
55 *
56 * HMM provides a set of helpers to hotplug device memory as ZONE_DEVICE, with
57 * a new MEMORY_DEVICE_PRIVATE type. This provides a struct page for each page
58 * of the device memory, and allows the device driver to manage its memory
59 * using those struct pages. Having struct pages for device memory makes
60 * migration easier. Because that memory is not addressable by the CPU it must
61 * never be pinned to the device; in other words, any CPU page fault can always
62 * cause the device memory to be migrated (copied/moved) back to regular memory.
63 *
64 * A new migrate helper (migrate_vma()) has been added (see mm/migrate.c) that
65 * allows use of a device DMA engine to perform the copy operation between
66 * regular system memory and device memory.
67 */
68#ifndef LINUX_HMM_H
69#define LINUX_HMM_H
70
71#include <linux/kconfig.h>
72
73#if IS_ENABLED(CONFIG_HMM)
74
75#include <linux/device.h>
76#include <linux/migrate.h>
77#include <linux/memremap.h>
78#include <linux/completion.h>
79
80struct hmm;
81
82/*
83 * hmm_pfn_t - HMM uses its own pfn type to keep several flags per page
84 *
85 * Flags:
86 * HMM_PFN_VALID: pfn is valid
87 * HMM_PFN_READ: CPU page table has read permission set
88 * HMM_PFN_WRITE: CPU page table has write permission set
89 * HMM_PFN_ERROR: corresponding CPU page table entry points to poisoned memory
90 * HMM_PFN_EMPTY: corresponding CPU page table entry is pte_none()
91 * HMM_PFN_SPECIAL: corresponding CPU page table entry is special; i.e., the
92 * result of vm_insert_pfn() or vm_insert_page(). Therefore, it should not
93 * be mirrored by a device, because the entry will never have HMM_PFN_VALID
94 * set and the pfn value is undefined.
95 * HMM_PFN_DEVICE_UNADDRESSABLE: unaddressable device memory (ZONE_DEVICE)
96 */
97typedef unsigned long hmm_pfn_t;
98
99#define HMM_PFN_VALID (1 << 0)
100#define HMM_PFN_READ (1 << 1)
101#define HMM_PFN_WRITE (1 << 2)
102#define HMM_PFN_ERROR (1 << 3)
103#define HMM_PFN_EMPTY (1 << 4)
104#define HMM_PFN_SPECIAL (1 << 5)
105#define HMM_PFN_DEVICE_UNADDRESSABLE (1 << 6)
106#define HMM_PFN_SHIFT 7
107
108/*
109 * hmm_pfn_t_to_page() - return struct page pointed to by a valid hmm_pfn_t
110 * @pfn: hmm_pfn_t to convert to struct page
111 * Returns: struct page pointer if pfn is a valid hmm_pfn_t, NULL otherwise
112 *
113 * If the hmm_pfn_t is valid (ie valid flag set) then return the struct page
114 * matching the pfn value stored in the hmm_pfn_t. Otherwise return NULL.
115 */
116static inline struct page *hmm_pfn_t_to_page(hmm_pfn_t pfn)
117{
118 if (!(pfn & HMM_PFN_VALID))
119 return NULL;
120 return pfn_to_page(pfn >> HMM_PFN_SHIFT);
121}
122
123/*
124 * hmm_pfn_t_to_pfn() - return pfn value store in a hmm_pfn_t
125 * @pfn: hmm_pfn_t to extract pfn from
126 * Returns: pfn value if hmm_pfn_t is valid, -1UL otherwise
127 */
128static inline unsigned long hmm_pfn_t_to_pfn(hmm_pfn_t pfn)
129{
130 if (!(pfn & HMM_PFN_VALID))
131 return -1UL;
132 return (pfn >> HMM_PFN_SHIFT);
133}
134
135/*
136 * hmm_pfn_t_from_page() - create a valid hmm_pfn_t value from struct page
137 * @page: struct page pointer for which to create the hmm_pfn_t
138 * Returns: valid hmm_pfn_t for the page
139 */
140static inline hmm_pfn_t hmm_pfn_t_from_page(struct page *page)
141{
142 return (page_to_pfn(page) << HMM_PFN_SHIFT) | HMM_PFN_VALID;
143}
144
145/*
146 * hmm_pfn_t_from_pfn() - create a valid hmm_pfn_t value from pfn
147 * @pfn: pfn value for which to create the hmm_pfn_t
148 * Returns: valid hmm_pfn_t for the pfn
149 */
150static inline hmm_pfn_t hmm_pfn_t_from_pfn(unsigned long pfn)
151{
152 return (pfn << HMM_PFN_SHIFT) | HMM_PFN_VALID;
153}
154
155
156#if IS_ENABLED(CONFIG_HMM_MIRROR)
157/*
158 * Mirroring: how to synchronize device page table with CPU page table.
159 *
160 * A device driver that is participating in HMM mirroring must always
161 * synchronize with CPU page table updates. For this, device drivers can either
162 * directly use mmu_notifier APIs or they can use the hmm_mirror API. Device
163 * drivers can decide to register one mirror per device per process, or just
164 * one mirror per process for a group of devices. The pattern is:
165 *
166 * int device_bind_address_space(..., struct mm_struct *mm, ...)
167 * {
168 * struct device_address_space *das;
169 *
170 * // Device driver specific initialization, and allocation of das
171 * // which contains an hmm_mirror struct as one of its fields.
172 * ...
173 *
174 * ret = hmm_mirror_register(&das->mirror, mm, &device_mirror_ops);
175 * if (ret) {
176 * // Cleanup on error
177 * return ret;
178 * }
179 *
180 * // Other device driver specific initialization
181 * ...
182 * }
183 *
184 * Once an hmm_mirror is registered for an address space, the device driver
185 * will get callbacks through sync_cpu_device_pagetables() operation (see
186 * hmm_mirror_ops struct).
187 *
188 * Device driver must not free the struct containing the hmm_mirror struct
189 * before calling hmm_mirror_unregister(). The expected usage is to do that when
190 * the device driver is unbinding from an address space.
191 *
192 *
193 * void device_unbind_address_space(struct device_address_space *das)
194 * {
195 * // Device driver specific cleanup
196 * ...
197 *
198 * hmm_mirror_unregister(&das->mirror);
199 *
200 * // Other device driver specific cleanup, and now das can be freed
201 * ...
202 * }
203 */
204
205struct hmm_mirror;
206
207/*
208 * enum hmm_update_type - type of update
209 * @HMM_UPDATE_INVALIDATE: invalidate range (no indication as to why)
210 */
211enum hmm_update_type {
212 HMM_UPDATE_INVALIDATE,
213};
214
215/*
216 * struct hmm_mirror_ops - HMM mirror device operations callback
217 *
218 * @update: callback to update range on a device
219 */
220struct hmm_mirror_ops {
221 /* sync_cpu_device_pagetables() - synchronize page tables
222 *
223 * @mirror: pointer to struct hmm_mirror
224 * @update_type: type of update that occurred to the CPU page table
225 * @start: virtual start address of the range to update
226 * @end: virtual end address of the range to update
227 *
228 * This callback ultimately originates from mmu_notifiers when the CPU
229 * page table is updated. The device driver must update its page table
230 * in response to this callback. The update argument tells what action
231 * to perform.
232 *
233 * The device driver must not return from this callback until the device
234 * page tables are completely updated (TLBs flushed, etc); this is a
235 * synchronous call.
236 */
237 void (*sync_cpu_device_pagetables)(struct hmm_mirror *mirror,
238 enum hmm_update_type update_type,
239 unsigned long start,
240 unsigned long end);
241};
242
243/*
244 * struct hmm_mirror - mirror struct for a device driver
245 *
246 * @hmm: pointer to struct hmm (which is unique per mm_struct)
247 * @ops: device driver callback for HMM mirror operations
248 * @list: for list of mirrors of a given mm
249 *
250 * Each address space (mm_struct) being mirrored by a device must register one
251 * instance of an hmm_mirror struct with HMM. HMM will track the list of all
252 * mirrors for each mm_struct.
253 */
254struct hmm_mirror {
255 struct hmm *hmm;
256 const struct hmm_mirror_ops *ops;
257 struct list_head list;
258};
259
260int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm);
261void hmm_mirror_unregister(struct hmm_mirror *mirror);
262
263
264/*
265 * struct hmm_range - track invalidation lock on virtual address range
266 *
267 * @list: all range lock are on a list
268 * @start: range virtual start address (inclusive)
269 * @end: range virtual end address (exclusive)
270 * @pfns: array of pfns (big enough for the range)
271 * @valid: pfns array did not change since it has been fill by an HMM function
272 */
273struct hmm_range {
274 struct list_head list;
275 unsigned long start;
276 unsigned long end;
277 hmm_pfn_t *pfns;
278 bool valid;
279};
280
281/*
282 * To snapshot the CPU page table, call hmm_vma_get_pfns(), then take a device
283 * driver lock that serializes device page table updates, then call
284 * hmm_vma_range_done(), to check if the snapshot is still valid. The same
285 * device driver page table update lock must also be used in the
286 * hmm_mirror_ops.sync_cpu_device_pagetables() callback, so that CPU page
287 * table invalidation serializes on it.
288 *
289 * YOU MUST CALL hmm_vma_range_done() ONCE AND ONLY ONCE EACH TIME YOU CALL
290 * hmm_vma_get_pfns() WITHOUT ERROR !
291 *
292 * IF YOU DO NOT FOLLOW THE ABOVE RULE THE SNAPSHOT CONTENT MIGHT BE INVALID !
293 */
294int hmm_vma_get_pfns(struct vm_area_struct *vma,
295 struct hmm_range *range,
296 unsigned long start,
297 unsigned long end,
298 hmm_pfn_t *pfns);
299bool hmm_vma_range_done(struct vm_area_struct *vma, struct hmm_range *range);
300
301
302/*
303 * Fault memory on behalf of device driver. Unlike handle_mm_fault(), this will
304 * not migrate any device memory back to system memory. The hmm_pfn_t array will
305 * be updated with the fault result and current snapshot of the CPU page table
306 * for the range.
307 *
308 * The mmap_sem must be taken in read mode before entering and it might be
309 * dropped by the function if the block argument is false. In that case, the
310 * function returns -EAGAIN.
311 *
312 * Return value does not reflect if the fault was successful for every single
313 * address or not. Therefore, the caller must to inspect the hmm_pfn_t array to
314 * determine fault status for each address.
315 *
316 * Trying to fault inside an invalid vma will result in -EINVAL.
317 *
318 * See the function description in mm/hmm.c for further documentation.
319 */
320int hmm_vma_fault(struct vm_area_struct *vma,
321 struct hmm_range *range,
322 unsigned long start,
323 unsigned long end,
324 hmm_pfn_t *pfns,
325 bool write,
326 bool block);
327#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
328
329
330#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC)
331struct hmm_devmem;
332
333struct page *hmm_vma_alloc_locked_page(struct vm_area_struct *vma,
334 unsigned long addr);
335
336/*
337 * struct hmm_devmem_ops - callback for ZONE_DEVICE memory events
338 *
339 * @free: call when refcount on page reach 1 and thus is no longer use
340 * @fault: call when there is a page fault to unaddressable memory
341 *
342 * Both callback happens from page_free() and page_fault() callback of struct
343 * dev_pagemap respectively. See include/linux/memremap.h for more details on
344 * those.
345 *
346 * The hmm_devmem_ops callback are just here to provide a coherent and
347 * uniq API to device driver and device driver should not register their
348 * own page_free() or page_fault() but rely on the hmm_devmem_ops call-
349 * back.
350 */
351struct hmm_devmem_ops {
352 /*
353 * free() - free a device page
354 * @devmem: device memory structure (see struct hmm_devmem)
355 * @page: pointer to struct page being freed
356 *
357 * Call back occurs whenever a device page refcount reach 1 which
358 * means that no one is holding any reference on the page anymore
359 * (ZONE_DEVICE page have an elevated refcount of 1 as default so
360 * that they are not release to the general page allocator).
361 *
362 * Note that callback has exclusive ownership of the page (as no
363 * one is holding any reference).
364 */
365 void (*free)(struct hmm_devmem *devmem, struct page *page);
366 /*
367 * fault() - CPU page fault or get user page (GUP)
368 * @devmem: device memory structure (see struct hmm_devmem)
369 * @vma: virtual memory area containing the virtual address
370 * @addr: virtual address that faulted or for which there is a GUP
371 * @page: pointer to struct page backing virtual address (unreliable)
372 * @flags: FAULT_FLAG_* (see include/linux/mm.h)
373 * @pmdp: page middle directory
374 * Returns: VM_FAULT_MINOR/MAJOR on success or one of VM_FAULT_ERROR
375 * on error
376 *
377 * The callback occurs whenever there is a CPU page fault or GUP on a
378 * virtual address. This means that the device driver must migrate the
379 * page back to regular memory (CPU accessible).
380 *
381 * The device driver is free to migrate more than one page from the
382 * fault() callback as an optimization. However if device decide to
383 * migrate more than one page it must always priotirize the faulting
384 * address over the others.
385 *
386 * The struct page pointer is only given as an hint to allow quick
387 * lookup of internal device driver data. A concurrent migration
388 * might have already free that page and the virtual address might
389 * not longer be back by it. So it should not be modified by the
390 * callback.
391 *
392 * Note that mmap semaphore is held in read mode at least when this
393 * callback occurs, hence the vma is valid upon callback entry.
394 */
395 int (*fault)(struct hmm_devmem *devmem,
396 struct vm_area_struct *vma,
397 unsigned long addr,
398 const struct page *page,
399 unsigned int flags,
400 pmd_t *pmdp);
401};
402
403/*
404 * struct hmm_devmem - track device memory
405 *
406 * @completion: completion object for device memory
407 * @pfn_first: first pfn for this resource (set by hmm_devmem_add())
408 * @pfn_last: last pfn for this resource (set by hmm_devmem_add())
409 * @resource: IO resource reserved for this chunk of memory
410 * @pagemap: device page map for that chunk
411 * @device: device to bind resource to
412 * @ops: memory operations callback
413 * @ref: per CPU refcount
414 *
415 * This an helper structure for device drivers that do not wish to implement
416 * the gory details related to hotplugging new memoy and allocating struct
417 * pages.
418 *
419 * Device drivers can directly use ZONE_DEVICE memory on their own if they
420 * wish to do so.
421 */
422struct hmm_devmem {
423 struct completion completion;
424 unsigned long pfn_first;
425 unsigned long pfn_last;
426 struct resource *resource;
427 struct device *device;
428 struct dev_pagemap pagemap;
429 const struct hmm_devmem_ops *ops;
430 struct percpu_ref ref;
431};
432
433/*
434 * To add (hotplug) device memory, HMM assumes that there is no real resource
435 * that reserves a range in the physical address space (this is intended to be
436 * use by unaddressable device memory). It will reserve a physical range big
437 * enough and allocate struct page for it.
438 *
439 * The device driver can wrap the hmm_devmem struct inside a private device
440 * driver struct. The device driver must call hmm_devmem_remove() before the
441 * device goes away and before freeing the hmm_devmem struct memory.
442 */
443struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
444 struct device *device,
445 unsigned long size);
446struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
447 struct device *device,
448 struct resource *res);
449void hmm_devmem_remove(struct hmm_devmem *devmem);
450
451/*
452 * hmm_devmem_page_set_drvdata - set per-page driver data field
453 *
454 * @page: pointer to struct page
455 * @data: driver data value to set
456 *
457 * Because page can not be on lru we have an unsigned long that driver can use
458 * to store a per page field. This just a simple helper to do that.
459 */
460static inline void hmm_devmem_page_set_drvdata(struct page *page,
461 unsigned long data)
462{
463 unsigned long *drvdata = (unsigned long *)&page->pgmap;
464
465 drvdata[1] = data;
466}
467
468/*
469 * hmm_devmem_page_get_drvdata - get per page driver data field
470 *
471 * @page: pointer to struct page
472 * Return: driver data value
473 */
474static inline unsigned long hmm_devmem_page_get_drvdata(struct page *page)
475{
476 unsigned long *drvdata = (unsigned long *)&page->pgmap;
477
478 return drvdata[1];
479}
480
481
482/*
483 * struct hmm_device - fake device to hang device memory onto
484 *
485 * @device: device struct
486 * @minor: device minor number
487 */
488struct hmm_device {
489 struct device device;
490 unsigned int minor;
491};
492
493/*
494 * A device driver that wants to handle multiple devices memory through a
495 * single fake device can use hmm_device to do so. This is purely a helper and
496 * it is not strictly needed, in order to make use of any HMM functionality.
497 */
498struct hmm_device *hmm_device_new(void *drvdata);
499void hmm_device_put(struct hmm_device *hmm_device);
500#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
501#endif /* IS_ENABLED(CONFIG_HMM) */
502
503/* Below are for HMM internal use only! Not to be used by device driver! */
504#if IS_ENABLED(CONFIG_HMM_MIRROR)
505void hmm_mm_destroy(struct mm_struct *mm);
506
507static inline void hmm_mm_init(struct mm_struct *mm)
508{
509 mm->hmm = NULL;
510}
511#else /* IS_ENABLED(CONFIG_HMM_MIRROR) */
512static inline void hmm_mm_destroy(struct mm_struct *mm) {}
513static inline void hmm_mm_init(struct mm_struct *mm) {}
514#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
515
516
517#else /* IS_ENABLED(CONFIG_HMM) */
518static inline void hmm_mm_destroy(struct mm_struct *mm) {}
519static inline void hmm_mm_init(struct mm_struct *mm) {}
520#endif /* LINUX_HMM_H */
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index ee696347f928..14bc21c2ee7f 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -147,7 +147,7 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
147#define split_huge_pmd(__vma, __pmd, __address) \ 147#define split_huge_pmd(__vma, __pmd, __address) \
148 do { \ 148 do { \
149 pmd_t *____pmd = (__pmd); \ 149 pmd_t *____pmd = (__pmd); \
150 if (pmd_trans_huge(*____pmd) \ 150 if (is_swap_pmd(*____pmd) || pmd_trans_huge(*____pmd) \
151 || pmd_devmap(*____pmd)) \ 151 || pmd_devmap(*____pmd)) \
152 __split_huge_pmd(__vma, __pmd, __address, \ 152 __split_huge_pmd(__vma, __pmd, __address, \
153 false, NULL); \ 153 false, NULL); \
@@ -178,12 +178,18 @@ extern spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd,
178 struct vm_area_struct *vma); 178 struct vm_area_struct *vma);
179extern spinlock_t *__pud_trans_huge_lock(pud_t *pud, 179extern spinlock_t *__pud_trans_huge_lock(pud_t *pud,
180 struct vm_area_struct *vma); 180 struct vm_area_struct *vma);
181
182static inline int is_swap_pmd(pmd_t pmd)
183{
184 return !pmd_none(pmd) && !pmd_present(pmd);
185}
186
181/* mmap_sem must be held on entry */ 187/* mmap_sem must be held on entry */
182static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, 188static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd,
183 struct vm_area_struct *vma) 189 struct vm_area_struct *vma)
184{ 190{
185 VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma); 191 VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma);
186 if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) 192 if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd))
187 return __pmd_trans_huge_lock(pmd, vma); 193 return __pmd_trans_huge_lock(pmd, vma);
188 else 194 else
189 return NULL; 195 return NULL;
@@ -233,6 +239,11 @@ void mm_put_huge_zero_page(struct mm_struct *mm);
233 239
234#define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot)) 240#define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot))
235 241
242static inline bool thp_migration_supported(void)
243{
244 return IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION);
245}
246
236#else /* CONFIG_TRANSPARENT_HUGEPAGE */ 247#else /* CONFIG_TRANSPARENT_HUGEPAGE */
237#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) 248#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
238#define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) 249#define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; })
@@ -294,6 +305,10 @@ static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
294 long adjust_next) 305 long adjust_next)
295{ 306{
296} 307}
308static inline int is_swap_pmd(pmd_t pmd)
309{
310 return 0;
311}
297static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, 312static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd,
298 struct vm_area_struct *vma) 313 struct vm_area_struct *vma)
299{ 314{
@@ -336,6 +351,11 @@ static inline struct page *follow_devmap_pud(struct vm_area_struct *vma,
336{ 351{
337 return NULL; 352 return NULL;
338} 353}
354
355static inline bool thp_migration_supported(void)
356{
357 return false;
358}
339#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 359#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
340 360
341#endif /* _LINUX_HUGE_MM_H */ 361#endif /* _LINUX_HUGE_MM_H */
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 0e849715e5be..3c07ace5b431 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -175,9 +175,8 @@ extern struct cred init_cred;
175 175
176#ifdef CONFIG_RT_MUTEXES 176#ifdef CONFIG_RT_MUTEXES
177# define INIT_RT_MUTEXES(tsk) \ 177# define INIT_RT_MUTEXES(tsk) \
178 .pi_waiters = RB_ROOT, \ 178 .pi_waiters = RB_ROOT_CACHED, \
179 .pi_top_task = NULL, \ 179 .pi_top_task = NULL,
180 .pi_waiters_leftmost = NULL,
181#else 180#else
182# define INIT_RT_MUTEXES(tsk) 181# define INIT_RT_MUTEXES(tsk)
183#endif 182#endif
diff --git a/include/linux/interval_tree.h b/include/linux/interval_tree.h
index 724556aa3c95..202ee1283f4b 100644
--- a/include/linux/interval_tree.h
+++ b/include/linux/interval_tree.h
@@ -11,13 +11,15 @@ struct interval_tree_node {
11}; 11};
12 12
13extern void 13extern void
14interval_tree_insert(struct interval_tree_node *node, struct rb_root *root); 14interval_tree_insert(struct interval_tree_node *node,
15 struct rb_root_cached *root);
15 16
16extern void 17extern void
17interval_tree_remove(struct interval_tree_node *node, struct rb_root *root); 18interval_tree_remove(struct interval_tree_node *node,
19 struct rb_root_cached *root);
18 20
19extern struct interval_tree_node * 21extern struct interval_tree_node *
20interval_tree_iter_first(struct rb_root *root, 22interval_tree_iter_first(struct rb_root_cached *root,
21 unsigned long start, unsigned long last); 23 unsigned long start, unsigned long last);
22 24
23extern struct interval_tree_node * 25extern struct interval_tree_node *
diff --git a/include/linux/interval_tree_generic.h b/include/linux/interval_tree_generic.h
index 58370e1862ad..1f97ce26cccc 100644
--- a/include/linux/interval_tree_generic.h
+++ b/include/linux/interval_tree_generic.h
@@ -33,7 +33,7 @@
33 * ITSTATIC: 'static' or empty 33 * ITSTATIC: 'static' or empty
34 * ITPREFIX: prefix to use for the inline tree definitions 34 * ITPREFIX: prefix to use for the inline tree definitions
35 * 35 *
36 * Note - before using this, please consider if non-generic version 36 * Note - before using this, please consider if generic version
37 * (interval_tree.h) would work for you... 37 * (interval_tree.h) would work for you...
38 */ 38 */
39 39
@@ -65,11 +65,13 @@ RB_DECLARE_CALLBACKS(static, ITPREFIX ## _augment, ITSTRUCT, ITRB, \
65 \ 65 \
66/* Insert / remove interval nodes from the tree */ \ 66/* Insert / remove interval nodes from the tree */ \
67 \ 67 \
68ITSTATIC void ITPREFIX ## _insert(ITSTRUCT *node, struct rb_root *root) \ 68ITSTATIC void ITPREFIX ## _insert(ITSTRUCT *node, \
69 struct rb_root_cached *root) \
69{ \ 70{ \
70 struct rb_node **link = &root->rb_node, *rb_parent = NULL; \ 71 struct rb_node **link = &root->rb_root.rb_node, *rb_parent = NULL; \
71 ITTYPE start = ITSTART(node), last = ITLAST(node); \ 72 ITTYPE start = ITSTART(node), last = ITLAST(node); \
72 ITSTRUCT *parent; \ 73 ITSTRUCT *parent; \
74 bool leftmost = true; \
73 \ 75 \
74 while (*link) { \ 76 while (*link) { \
75 rb_parent = *link; \ 77 rb_parent = *link; \
@@ -78,18 +80,22 @@ ITSTATIC void ITPREFIX ## _insert(ITSTRUCT *node, struct rb_root *root) \
78 parent->ITSUBTREE = last; \ 80 parent->ITSUBTREE = last; \
79 if (start < ITSTART(parent)) \ 81 if (start < ITSTART(parent)) \
80 link = &parent->ITRB.rb_left; \ 82 link = &parent->ITRB.rb_left; \
81 else \ 83 else { \
82 link = &parent->ITRB.rb_right; \ 84 link = &parent->ITRB.rb_right; \
85 leftmost = false; \
86 } \
83 } \ 87 } \
84 \ 88 \
85 node->ITSUBTREE = last; \ 89 node->ITSUBTREE = last; \
86 rb_link_node(&node->ITRB, rb_parent, link); \ 90 rb_link_node(&node->ITRB, rb_parent, link); \
87 rb_insert_augmented(&node->ITRB, root, &ITPREFIX ## _augment); \ 91 rb_insert_augmented_cached(&node->ITRB, root, \
92 leftmost, &ITPREFIX ## _augment); \
88} \ 93} \
89 \ 94 \
90ITSTATIC void ITPREFIX ## _remove(ITSTRUCT *node, struct rb_root *root) \ 95ITSTATIC void ITPREFIX ## _remove(ITSTRUCT *node, \
96 struct rb_root_cached *root) \
91{ \ 97{ \
92 rb_erase_augmented(&node->ITRB, root, &ITPREFIX ## _augment); \ 98 rb_erase_augmented_cached(&node->ITRB, root, &ITPREFIX ## _augment); \
93} \ 99} \
94 \ 100 \
95/* \ 101/* \
@@ -140,15 +146,35 @@ ITPREFIX ## _subtree_search(ITSTRUCT *node, ITTYPE start, ITTYPE last) \
140} \ 146} \
141 \ 147 \
142ITSTATIC ITSTRUCT * \ 148ITSTATIC ITSTRUCT * \
143ITPREFIX ## _iter_first(struct rb_root *root, ITTYPE start, ITTYPE last) \ 149ITPREFIX ## _iter_first(struct rb_root_cached *root, \
150 ITTYPE start, ITTYPE last) \
144{ \ 151{ \
145 ITSTRUCT *node; \ 152 ITSTRUCT *node, *leftmost; \
146 \ 153 \
147 if (!root->rb_node) \ 154 if (!root->rb_root.rb_node) \
148 return NULL; \ 155 return NULL; \
149 node = rb_entry(root->rb_node, ITSTRUCT, ITRB); \ 156 \
157 /* \
158 * Fastpath range intersection/overlap between A: [a0, a1] and \
159 * B: [b0, b1] is given by: \
160 * \
161 * a0 <= b1 && b0 <= a1 \
162 * \
163 * ... where A holds the lock range and B holds the smallest \
164 * 'start' and largest 'last' in the tree. For the later, we \
165 * rely on the root node, which by augmented interval tree \
166 * property, holds the largest value in its last-in-subtree. \
167 * This allows mitigating some of the tree walk overhead for \
168 * for non-intersecting ranges, maintained and consulted in O(1). \
169 */ \
170 node = rb_entry(root->rb_root.rb_node, ITSTRUCT, ITRB); \
150 if (node->ITSUBTREE < start) \ 171 if (node->ITSUBTREE < start) \
151 return NULL; \ 172 return NULL; \
173 \
174 leftmost = rb_entry(root->rb_leftmost, ITSTRUCT, ITRB); \
175 if (ITSTART(leftmost) > last) \
176 return NULL; \
177 \
152 return ITPREFIX ## _subtree_search(node, start, last); \ 178 return ITPREFIX ## _subtree_search(node, start, last); \
153} \ 179} \
154 \ 180 \
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 6230064d7f95..f5cf32e80041 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -130,6 +130,8 @@ enum {
130 IORES_DESC_ACPI_NV_STORAGE = 3, 130 IORES_DESC_ACPI_NV_STORAGE = 3,
131 IORES_DESC_PERSISTENT_MEMORY = 4, 131 IORES_DESC_PERSISTENT_MEMORY = 4,
132 IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, 132 IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5,
133 IORES_DESC_DEVICE_PRIVATE_MEMORY = 6,
134 IORES_DESC_DEVICE_PUBLIC_MEMORY = 7,
133}; 135};
134 136
135/* helpers to define resources */ 137/* helpers to define resources */
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index fadd579d577d..92a2ccff80c5 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -3,7 +3,9 @@
3 3
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <linux/uidgid.h> 5#include <linux/uidgid.h>
6#include <linux/rhashtable.h>
6#include <uapi/linux/ipc.h> 7#include <uapi/linux/ipc.h>
8#include <linux/refcount.h>
7 9
8#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */ 10#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
9 11
@@ -21,8 +23,10 @@ struct kern_ipc_perm {
21 unsigned long seq; 23 unsigned long seq;
22 void *security; 24 void *security;
23 25
26 struct rhash_head khtnode;
27
24 struct rcu_head rcu; 28 struct rcu_head rcu;
25 atomic_t refcount; 29 refcount_t refcount;
26} ____cacheline_aligned_in_smp __randomize_layout; 30} ____cacheline_aligned_in_smp __randomize_layout;
27 31
28#endif /* _LINUX_IPC_H */ 32#endif /* _LINUX_IPC_H */
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 65327ee0936b..83f0bf7a587d 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -7,19 +7,23 @@
7#include <linux/notifier.h> 7#include <linux/notifier.h>
8#include <linux/nsproxy.h> 8#include <linux/nsproxy.h>
9#include <linux/ns_common.h> 9#include <linux/ns_common.h>
10#include <linux/refcount.h>
11#include <linux/rhashtable.h>
10 12
11struct user_namespace; 13struct user_namespace;
12 14
13struct ipc_ids { 15struct ipc_ids {
14 int in_use; 16 int in_use;
15 unsigned short seq; 17 unsigned short seq;
18 bool tables_initialized;
16 struct rw_semaphore rwsem; 19 struct rw_semaphore rwsem;
17 struct idr ipcs_idr; 20 struct idr ipcs_idr;
18 int next_id; 21 int next_id;
22 struct rhashtable key_ht;
19}; 23};
20 24
21struct ipc_namespace { 25struct ipc_namespace {
22 atomic_t count; 26 refcount_t count;
23 struct ipc_ids ids[3]; 27 struct ipc_ids ids[3];
24 28
25 int sem_ctls[4]; 29 int sem_ctls[4];
@@ -118,7 +122,7 @@ extern struct ipc_namespace *copy_ipcs(unsigned long flags,
118static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) 122static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
119{ 123{
120 if (ns) 124 if (ns)
121 atomic_inc(&ns->count); 125 refcount_inc(&ns->count);
122 return ns; 126 return ns;
123} 127}
124 128
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6607225d0ea4..0ad4c3044cf9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -78,8 +78,11 @@
78 78
79#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 79#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
80#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP 80#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
81#define DIV_ROUND_UP_ULL(ll,d) \ 81
82 ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) 82#define DIV_ROUND_DOWN_ULL(ll, d) \
83 ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
84
85#define DIV_ROUND_UP_ULL(ll, d) DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d))
83 86
84#if BITS_PER_LONG == 32 87#if BITS_PER_LONG == 32
85# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d) 88# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d)
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 655082c88fd9..40c89ad4bea6 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/umh.h>
22#include <linux/gfp.h> 23#include <linux/gfp.h>
23#include <linux/stddef.h> 24#include <linux/stddef.h>
24#include <linux/errno.h> 25#include <linux/errno.h>
@@ -44,63 +45,4 @@ static inline int request_module_nowait(const char *name, ...) { return -ENOSYS;
44#define try_then_request_module(x, mod...) (x) 45#define try_then_request_module(x, mod...) (x)
45#endif 46#endif
46 47
47
48struct cred;
49struct file;
50
51#define UMH_NO_WAIT 0 /* don't wait at all */
52#define UMH_WAIT_EXEC 1 /* wait for the exec, but not the process */
53#define UMH_WAIT_PROC 2 /* wait for the process to complete */
54#define UMH_KILLABLE 4 /* wait for EXEC/PROC killable */
55
56struct subprocess_info {
57 struct work_struct work;
58 struct completion *complete;
59 const char *path;
60 char **argv;
61 char **envp;
62 int wait;
63 int retval;
64 int (*init)(struct subprocess_info *info, struct cred *new);
65 void (*cleanup)(struct subprocess_info *info);
66 void *data;
67} __randomize_layout;
68
69extern int
70call_usermodehelper(const char *path, char **argv, char **envp, int wait);
71
72extern struct subprocess_info *
73call_usermodehelper_setup(const char *path, char **argv, char **envp,
74 gfp_t gfp_mask,
75 int (*init)(struct subprocess_info *info, struct cred *new),
76 void (*cleanup)(struct subprocess_info *), void *data);
77
78extern int
79call_usermodehelper_exec(struct subprocess_info *info, int wait);
80
81extern struct ctl_table usermodehelper_table[];
82
83enum umh_disable_depth {
84 UMH_ENABLED = 0,
85 UMH_FREEZING,
86 UMH_DISABLED,
87};
88
89extern int __usermodehelper_disable(enum umh_disable_depth depth);
90extern void __usermodehelper_set_disable_depth(enum umh_disable_depth depth);
91
92static inline int usermodehelper_disable(void)
93{
94 return __usermodehelper_disable(UMH_DISABLED);
95}
96
97static inline void usermodehelper_enable(void)
98{
99 __usermodehelper_set_disable_depth(UMH_ENABLED);
100}
101
102extern int usermodehelper_read_trylock(void);
103extern long usermodehelper_read_lock_wait(long timeout);
104extern void usermodehelper_read_unlock(void);
105
106#endif /* __LINUX_KMOD_H__ */ 48#endif /* __LINUX_KMOD_H__ */
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 5e6e4cc36ff4..0995e1a2b458 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -133,6 +133,17 @@ extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
133extern int __add_pages(int nid, unsigned long start_pfn, 133extern int __add_pages(int nid, unsigned long start_pfn,
134 unsigned long nr_pages, bool want_memblock); 134 unsigned long nr_pages, bool want_memblock);
135 135
136#ifndef CONFIG_ARCH_HAS_ADD_PAGES
137static inline int add_pages(int nid, unsigned long start_pfn,
138 unsigned long nr_pages, bool want_memblock)
139{
140 return __add_pages(nid, start_pfn, nr_pages, want_memblock);
141}
142#else /* ARCH_HAS_ADD_PAGES */
143int add_pages(int nid, unsigned long start_pfn,
144 unsigned long nr_pages, bool want_memblock);
145#endif /* ARCH_HAS_ADD_PAGES */
146
136#ifdef CONFIG_NUMA 147#ifdef CONFIG_NUMA
137extern int memory_add_physaddr_to_nid(u64 start); 148extern int memory_add_physaddr_to_nid(u64 start);
138#else 149#else
diff --git a/include/linux/memremap.h b/include/linux/memremap.h
index 93416196ba64..79f8ba7c3894 100644
--- a/include/linux/memremap.h
+++ b/include/linux/memremap.h
@@ -4,6 +4,8 @@
4#include <linux/ioport.h> 4#include <linux/ioport.h>
5#include <linux/percpu-refcount.h> 5#include <linux/percpu-refcount.h>
6 6
7#include <asm/pgtable.h>
8
7struct resource; 9struct resource;
8struct device; 10struct device;
9 11
@@ -35,24 +37,107 @@ static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)
35} 37}
36#endif 38#endif
37 39
40/*
41 * Specialize ZONE_DEVICE memory into multiple types each having differents
42 * usage.
43 *
44 * MEMORY_DEVICE_HOST:
45 * Persistent device memory (pmem): struct page might be allocated in different
46 * memory and architecture might want to perform special actions. It is similar
47 * to regular memory, in that the CPU can access it transparently. However,
48 * it is likely to have different bandwidth and latency than regular memory.
49 * See Documentation/nvdimm/nvdimm.txt for more information.
50 *
51 * MEMORY_DEVICE_PRIVATE:
52 * Device memory that is not directly addressable by the CPU: CPU can neither
53 * read nor write private memory. In this case, we do still have struct pages
54 * backing the device memory. Doing so simplifies the implementation, but it is
55 * important to remember that there are certain points at which the struct page
56 * must be treated as an opaque object, rather than a "normal" struct page.
57 *
58 * A more complete discussion of unaddressable memory may be found in
59 * include/linux/hmm.h and Documentation/vm/hmm.txt.
60 *
61 * MEMORY_DEVICE_PUBLIC:
62 * Device memory that is cache coherent from device and CPU point of view. This
63 * is use on platform that have an advance system bus (like CAPI or CCIX). A
64 * driver can hotplug the device memory using ZONE_DEVICE and with that memory
65 * type. Any page of a process can be migrated to such memory. However no one
66 * should be allow to pin such memory so that it can always be evicted.
67 */
68enum memory_type {
69 MEMORY_DEVICE_HOST = 0,
70 MEMORY_DEVICE_PRIVATE,
71 MEMORY_DEVICE_PUBLIC,
72};
73
74/*
75 * For MEMORY_DEVICE_PRIVATE we use ZONE_DEVICE and extend it with two
76 * callbacks:
77 * page_fault()
78 * page_free()
79 *
80 * Additional notes about MEMORY_DEVICE_PRIVATE may be found in
81 * include/linux/hmm.h and Documentation/vm/hmm.txt. There is also a brief
82 * explanation in include/linux/memory_hotplug.h.
83 *
84 * The page_fault() callback must migrate page back, from device memory to
85 * system memory, so that the CPU can access it. This might fail for various
86 * reasons (device issues, device have been unplugged, ...). When such error
87 * conditions happen, the page_fault() callback must return VM_FAULT_SIGBUS and
88 * set the CPU page table entry to "poisoned".
89 *
90 * Note that because memory cgroup charges are transferred to the device memory,
91 * this should never fail due to memory restrictions. However, allocation
92 * of a regular system page might still fail because we are out of memory. If
93 * that happens, the page_fault() callback must return VM_FAULT_OOM.
94 *
95 * The page_fault() callback can also try to migrate back multiple pages in one
96 * chunk, as an optimization. It must, however, prioritize the faulting address
97 * over all the others.
98 *
99 *
100 * The page_free() callback is called once the page refcount reaches 1
101 * (ZONE_DEVICE pages never reach 0 refcount unless there is a refcount bug.
102 * This allows the device driver to implement its own memory management.)
103 *
104 * For MEMORY_DEVICE_PUBLIC only the page_free() callback matter.
105 */
106typedef int (*dev_page_fault_t)(struct vm_area_struct *vma,
107 unsigned long addr,
108 const struct page *page,
109 unsigned int flags,
110 pmd_t *pmdp);
111typedef void (*dev_page_free_t)(struct page *page, void *data);
112
38/** 113/**
39 * struct dev_pagemap - metadata for ZONE_DEVICE mappings 114 * struct dev_pagemap - metadata for ZONE_DEVICE mappings
115 * @page_fault: callback when CPU fault on an unaddressable device page
116 * @page_free: free page callback when page refcount reaches 1
40 * @altmap: pre-allocated/reserved memory for vmemmap allocations 117 * @altmap: pre-allocated/reserved memory for vmemmap allocations
41 * @res: physical address range covered by @ref 118 * @res: physical address range covered by @ref
42 * @ref: reference count that pins the devm_memremap_pages() mapping 119 * @ref: reference count that pins the devm_memremap_pages() mapping
43 * @dev: host device of the mapping for debug 120 * @dev: host device of the mapping for debug
121 * @data: private data pointer for page_free()
122 * @type: memory type: see MEMORY_* in memory_hotplug.h
44 */ 123 */
45struct dev_pagemap { 124struct dev_pagemap {
125 dev_page_fault_t page_fault;
126 dev_page_free_t page_free;
46 struct vmem_altmap *altmap; 127 struct vmem_altmap *altmap;
47 const struct resource *res; 128 const struct resource *res;
48 struct percpu_ref *ref; 129 struct percpu_ref *ref;
49 struct device *dev; 130 struct device *dev;
131 void *data;
132 enum memory_type type;
50}; 133};
51 134
52#ifdef CONFIG_ZONE_DEVICE 135#ifdef CONFIG_ZONE_DEVICE
53void *devm_memremap_pages(struct device *dev, struct resource *res, 136void *devm_memremap_pages(struct device *dev, struct resource *res,
54 struct percpu_ref *ref, struct vmem_altmap *altmap); 137 struct percpu_ref *ref, struct vmem_altmap *altmap);
55struct dev_pagemap *find_dev_pagemap(resource_size_t phys); 138struct dev_pagemap *find_dev_pagemap(resource_size_t phys);
139
140static inline bool is_zone_device_page(const struct page *page);
56#else 141#else
57static inline void *devm_memremap_pages(struct device *dev, 142static inline void *devm_memremap_pages(struct device *dev,
58 struct resource *res, struct percpu_ref *ref, 143 struct resource *res, struct percpu_ref *ref,
@@ -73,6 +158,20 @@ static inline struct dev_pagemap *find_dev_pagemap(resource_size_t phys)
73} 158}
74#endif 159#endif
75 160
161#if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC)
162static inline bool is_device_private_page(const struct page *page)
163{
164 return is_zone_device_page(page) &&
165 page->pgmap->type == MEMORY_DEVICE_PRIVATE;
166}
167
168static inline bool is_device_public_page(const struct page *page)
169{
170 return is_zone_device_page(page) &&
171 page->pgmap->type == MEMORY_DEVICE_PUBLIC;
172}
173#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
174
76/** 175/**
77 * get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn 176 * get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn
78 * @pfn: page frame number to lookup page_map 177 * @pfn: page frame number to lookup page_map
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 3e0d405dc842..643c7ae7d7b4 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -35,15 +35,28 @@ static inline struct page *new_page_nodemask(struct page *page,
35 int preferred_nid, nodemask_t *nodemask) 35 int preferred_nid, nodemask_t *nodemask)
36{ 36{
37 gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; 37 gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
38 unsigned int order = 0;
39 struct page *new_page = NULL;
38 40
39 if (PageHuge(page)) 41 if (PageHuge(page))
40 return alloc_huge_page_nodemask(page_hstate(compound_head(page)), 42 return alloc_huge_page_nodemask(page_hstate(compound_head(page)),
41 preferred_nid, nodemask); 43 preferred_nid, nodemask);
42 44
45 if (thp_migration_supported() && PageTransHuge(page)) {
46 order = HPAGE_PMD_ORDER;
47 gfp_mask |= GFP_TRANSHUGE;
48 }
49
43 if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE)) 50 if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
44 gfp_mask |= __GFP_HIGHMEM; 51 gfp_mask |= __GFP_HIGHMEM;
45 52
46 return __alloc_pages_nodemask(gfp_mask, 0, preferred_nid, nodemask); 53 new_page = __alloc_pages_nodemask(gfp_mask, order,
54 preferred_nid, nodemask);
55
56 if (new_page && PageTransHuge(page))
57 prep_transhuge_page(new_page);
58
59 return new_page;
47} 60}
48 61
49#ifdef CONFIG_MIGRATION 62#ifdef CONFIG_MIGRATION
@@ -59,6 +72,7 @@ extern void putback_movable_page(struct page *page);
59 72
60extern int migrate_prep(void); 73extern int migrate_prep(void);
61extern int migrate_prep_local(void); 74extern int migrate_prep_local(void);
75extern void migrate_page_states(struct page *newpage, struct page *page);
62extern void migrate_page_copy(struct page *newpage, struct page *page); 76extern void migrate_page_copy(struct page *newpage, struct page *page);
63extern int migrate_huge_page_move_mapping(struct address_space *mapping, 77extern int migrate_huge_page_move_mapping(struct address_space *mapping,
64 struct page *newpage, struct page *page); 78 struct page *newpage, struct page *page);
@@ -79,6 +93,10 @@ static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
79static inline int migrate_prep(void) { return -ENOSYS; } 93static inline int migrate_prep(void) { return -ENOSYS; }
80static inline int migrate_prep_local(void) { return -ENOSYS; } 94static inline int migrate_prep_local(void) { return -ENOSYS; }
81 95
96static inline void migrate_page_states(struct page *newpage, struct page *page)
97{
98}
99
82static inline void migrate_page_copy(struct page *newpage, 100static inline void migrate_page_copy(struct page *newpage,
83 struct page *page) {} 101 struct page *page) {}
84 102
@@ -138,4 +156,136 @@ static inline int migrate_misplaced_transhuge_page(struct mm_struct *mm,
138} 156}
139#endif /* CONFIG_NUMA_BALANCING && CONFIG_TRANSPARENT_HUGEPAGE*/ 157#endif /* CONFIG_NUMA_BALANCING && CONFIG_TRANSPARENT_HUGEPAGE*/
140 158
159
160#ifdef CONFIG_MIGRATION
161
162/*
163 * Watch out for PAE architecture, which has an unsigned long, and might not
164 * have enough bits to store all physical address and flags. So far we have
165 * enough room for all our flags.
166 */
167#define MIGRATE_PFN_VALID (1UL << 0)
168#define MIGRATE_PFN_MIGRATE (1UL << 1)
169#define MIGRATE_PFN_LOCKED (1UL << 2)
170#define MIGRATE_PFN_WRITE (1UL << 3)
171#define MIGRATE_PFN_DEVICE (1UL << 4)
172#define MIGRATE_PFN_ERROR (1UL << 5)
173#define MIGRATE_PFN_SHIFT 6
174
175static inline struct page *migrate_pfn_to_page(unsigned long mpfn)
176{
177 if (!(mpfn & MIGRATE_PFN_VALID))
178 return NULL;
179 return pfn_to_page(mpfn >> MIGRATE_PFN_SHIFT);
180}
181
182static inline unsigned long migrate_pfn(unsigned long pfn)
183{
184 return (pfn << MIGRATE_PFN_SHIFT) | MIGRATE_PFN_VALID;
185}
186
187/*
188 * struct migrate_vma_ops - migrate operation callback
189 *
190 * @alloc_and_copy: alloc destination memory and copy source memory to it
191 * @finalize_and_map: allow caller to map the successfully migrated pages
192 *
193 *
194 * The alloc_and_copy() callback happens once all source pages have been locked,
195 * unmapped and checked (checked whether pinned or not). All pages that can be
196 * migrated will have an entry in the src array set with the pfn value of the
197 * page and with the MIGRATE_PFN_VALID and MIGRATE_PFN_MIGRATE flag set (other
198 * flags might be set but should be ignored by the callback).
199 *
200 * The alloc_and_copy() callback can then allocate destination memory and copy
201 * source memory to it for all those entries (ie with MIGRATE_PFN_VALID and
202 * MIGRATE_PFN_MIGRATE flag set). Once these are allocated and copied, the
203 * callback must update each corresponding entry in the dst array with the pfn
204 * value of the destination page and with the MIGRATE_PFN_VALID and
205 * MIGRATE_PFN_LOCKED flags set (destination pages must have their struct pages
206 * locked, via lock_page()).
207 *
208 * At this point the alloc_and_copy() callback is done and returns.
209 *
210 * Note that the callback does not have to migrate all the pages that are
211 * marked with MIGRATE_PFN_MIGRATE flag in src array unless this is a migration
212 * from device memory to system memory (ie the MIGRATE_PFN_DEVICE flag is also
213 * set in the src array entry). If the device driver cannot migrate a device
214 * page back to system memory, then it must set the corresponding dst array
215 * entry to MIGRATE_PFN_ERROR. This will trigger a SIGBUS if CPU tries to
216 * access any of the virtual addresses originally backed by this page. Because
217 * a SIGBUS is such a severe result for the userspace process, the device
218 * driver should avoid setting MIGRATE_PFN_ERROR unless it is really in an
219 * unrecoverable state.
220 *
221 * For empty entry inside CPU page table (pte_none() or pmd_none() is true) we
222 * do set MIGRATE_PFN_MIGRATE flag inside the corresponding source array thus
223 * allowing device driver to allocate device memory for those unback virtual
224 * address. For this the device driver simply have to allocate device memory
225 * and properly set the destination entry like for regular migration. Note that
226 * this can still fails and thus inside the device driver must check if the
227 * migration was successful for those entry inside the finalize_and_map()
228 * callback just like for regular migration.
229 *
230 * THE alloc_and_copy() CALLBACK MUST NOT CHANGE ANY OF THE SRC ARRAY ENTRIES
231 * OR BAD THINGS WILL HAPPEN !
232 *
233 *
234 * The finalize_and_map() callback happens after struct page migration from
235 * source to destination (destination struct pages are the struct pages for the
236 * memory allocated by the alloc_and_copy() callback). Migration can fail, and
237 * thus the finalize_and_map() allows the driver to inspect which pages were
238 * successfully migrated, and which were not. Successfully migrated pages will
239 * have the MIGRATE_PFN_MIGRATE flag set for their src array entry.
240 *
241 * It is safe to update device page table from within the finalize_and_map()
242 * callback because both destination and source page are still locked, and the
243 * mmap_sem is held in read mode (hence no one can unmap the range being
244 * migrated).
245 *
246 * Once callback is done cleaning up things and updating its page table (if it
247 * chose to do so, this is not an obligation) then it returns. At this point,
248 * the HMM core will finish up the final steps, and the migration is complete.
249 *
250 * THE finalize_and_map() CALLBACK MUST NOT CHANGE ANY OF THE SRC OR DST ARRAY
251 * ENTRIES OR BAD THINGS WILL HAPPEN !
252 */
253struct migrate_vma_ops {
254 void (*alloc_and_copy)(struct vm_area_struct *vma,
255 const unsigned long *src,
256 unsigned long *dst,
257 unsigned long start,
258 unsigned long end,
259 void *private);
260 void (*finalize_and_map)(struct vm_area_struct *vma,
261 const unsigned long *src,
262 const unsigned long *dst,
263 unsigned long start,
264 unsigned long end,
265 void *private);
266};
267
268#if defined(CONFIG_MIGRATE_VMA_HELPER)
269int migrate_vma(const struct migrate_vma_ops *ops,
270 struct vm_area_struct *vma,
271 unsigned long start,
272 unsigned long end,
273 unsigned long *src,
274 unsigned long *dst,
275 void *private);
276#else
277static inline int migrate_vma(const struct migrate_vma_ops *ops,
278 struct vm_area_struct *vma,
279 unsigned long start,
280 unsigned long end,
281 unsigned long *src,
282 unsigned long *dst,
283 void *private)
284{
285 return -EINVAL;
286}
287#endif /* IS_ENABLED(CONFIG_MIGRATE_VMA_HELPER) */
288
289#endif /* CONFIG_MIGRATION */
290
141#endif /* _LINUX_MIGRATE_H */ 291#endif /* _LINUX_MIGRATE_H */
diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h
index ebf3d89a3919..bdf66af9b937 100644
--- a/include/linux/migrate_mode.h
+++ b/include/linux/migrate_mode.h
@@ -6,11 +6,16 @@
6 * on most operations but not ->writepage as the potential stall time 6 * on most operations but not ->writepage as the potential stall time
7 * is too significant 7 * is too significant
8 * MIGRATE_SYNC will block when migrating pages 8 * MIGRATE_SYNC will block when migrating pages
9 * MIGRATE_SYNC_NO_COPY will block when migrating pages but will not copy pages
10 * with the CPU. Instead, page copy happens outside the migratepage()
11 * callback and is likely using a DMA engine. See migrate_vma() and HMM
12 * (mm/hmm.c) for users of this mode.
9 */ 13 */
10enum migrate_mode { 14enum migrate_mode {
11 MIGRATE_ASYNC, 15 MIGRATE_ASYNC,
12 MIGRATE_SYNC_LIGHT, 16 MIGRATE_SYNC_LIGHT,
13 MIGRATE_SYNC, 17 MIGRATE_SYNC,
18 MIGRATE_SYNC_NO_COPY,
14}; 19};
15 20
16#endif /* MIGRATE_MODE_H_INCLUDED */ 21#endif /* MIGRATE_MODE_H_INCLUDED */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 39db8e54c5d5..f8c10d336e42 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -23,6 +23,7 @@
23#include <linux/page_ext.h> 23#include <linux/page_ext.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/page_ref.h> 25#include <linux/page_ref.h>
26#include <linux/memremap.h>
26 27
27struct mempolicy; 28struct mempolicy;
28struct anon_vma; 29struct anon_vma;
@@ -799,6 +800,28 @@ static inline bool is_zone_device_page(const struct page *page)
799} 800}
800#endif 801#endif
801 802
803#if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC)
804void put_zone_device_private_or_public_page(struct page *page);
805DECLARE_STATIC_KEY_FALSE(device_private_key);
806#define IS_HMM_ENABLED static_branch_unlikely(&device_private_key)
807static inline bool is_device_private_page(const struct page *page);
808static inline bool is_device_public_page(const struct page *page);
809#else /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
810static inline void put_zone_device_private_or_public_page(struct page *page)
811{
812}
813#define IS_HMM_ENABLED 0
814static inline bool is_device_private_page(const struct page *page)
815{
816 return false;
817}
818static inline bool is_device_public_page(const struct page *page)
819{
820 return false;
821}
822#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
823
824
802static inline void get_page(struct page *page) 825static inline void get_page(struct page *page)
803{ 826{
804 page = compound_head(page); 827 page = compound_head(page);
@@ -814,6 +837,18 @@ static inline void put_page(struct page *page)
814{ 837{
815 page = compound_head(page); 838 page = compound_head(page);
816 839
840 /*
841 * For private device pages we need to catch refcount transition from
842 * 2 to 1, when refcount reach one it means the private device page is
843 * free and we need to inform the device driver through callback. See
844 * include/linux/memremap.h and HMM for details.
845 */
846 if (IS_HMM_ENABLED && unlikely(is_device_private_page(page) ||
847 unlikely(is_device_public_page(page)))) {
848 put_zone_device_private_or_public_page(page);
849 return;
850 }
851
817 if (put_page_testzero(page)) 852 if (put_page_testzero(page))
818 __put_page(page); 853 __put_page(page);
819} 854}
@@ -1199,8 +1234,10 @@ struct zap_details {
1199 pgoff_t last_index; /* Highest page->index to unmap */ 1234 pgoff_t last_index; /* Highest page->index to unmap */
1200}; 1235};
1201 1236
1202struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, 1237struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
1203 pte_t pte); 1238 pte_t pte, bool with_public_device);
1239#define vm_normal_page(vma, addr, pte) _vm_normal_page(vma, addr, pte, false)
1240
1204struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, 1241struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
1205 pmd_t pmd); 1242 pmd_t pmd);
1206 1243
@@ -1997,13 +2034,13 @@ extern int nommu_shrink_inode_mappings(struct inode *, size_t, size_t);
1997 2034
1998/* interval_tree.c */ 2035/* interval_tree.c */
1999void vma_interval_tree_insert(struct vm_area_struct *node, 2036void vma_interval_tree_insert(struct vm_area_struct *node,
2000 struct rb_root *root); 2037 struct rb_root_cached *root);
2001void vma_interval_tree_insert_after(struct vm_area_struct *node, 2038void vma_interval_tree_insert_after(struct vm_area_struct *node,
2002 struct vm_area_struct *prev, 2039 struct vm_area_struct *prev,
2003 struct rb_root *root); 2040 struct rb_root_cached *root);
2004void vma_interval_tree_remove(struct vm_area_struct *node, 2041void vma_interval_tree_remove(struct vm_area_struct *node,
2005 struct rb_root *root); 2042 struct rb_root_cached *root);
2006struct vm_area_struct *vma_interval_tree_iter_first(struct rb_root *root, 2043struct vm_area_struct *vma_interval_tree_iter_first(struct rb_root_cached *root,
2007 unsigned long start, unsigned long last); 2044 unsigned long start, unsigned long last);
2008struct vm_area_struct *vma_interval_tree_iter_next(struct vm_area_struct *node, 2045struct vm_area_struct *vma_interval_tree_iter_next(struct vm_area_struct *node,
2009 unsigned long start, unsigned long last); 2046 unsigned long start, unsigned long last);
@@ -2013,11 +2050,12 @@ struct vm_area_struct *vma_interval_tree_iter_next(struct vm_area_struct *node,
2013 vma; vma = vma_interval_tree_iter_next(vma, start, last)) 2050 vma; vma = vma_interval_tree_iter_next(vma, start, last))
2014 2051
2015void anon_vma_interval_tree_insert(struct anon_vma_chain *node, 2052void anon_vma_interval_tree_insert(struct anon_vma_chain *node,
2016 struct rb_root *root); 2053 struct rb_root_cached *root);
2017void anon_vma_interval_tree_remove(struct anon_vma_chain *node, 2054void anon_vma_interval_tree_remove(struct anon_vma_chain *node,
2018 struct rb_root *root); 2055 struct rb_root_cached *root);
2019struct anon_vma_chain *anon_vma_interval_tree_iter_first( 2056struct anon_vma_chain *
2020 struct rb_root *root, unsigned long start, unsigned long last); 2057anon_vma_interval_tree_iter_first(struct rb_root_cached *root,
2058 unsigned long start, unsigned long last);
2021struct anon_vma_chain *anon_vma_interval_tree_iter_next( 2059struct anon_vma_chain *anon_vma_interval_tree_iter_next(
2022 struct anon_vma_chain *node, unsigned long start, unsigned long last); 2060 struct anon_vma_chain *node, unsigned long start, unsigned long last);
2023#ifdef CONFIG_DEBUG_VM_RB 2061#ifdef CONFIG_DEBUG_VM_RB
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index f45ad815b7d7..46f4ecf5479a 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -23,6 +23,7 @@
23 23
24struct address_space; 24struct address_space;
25struct mem_cgroup; 25struct mem_cgroup;
26struct hmm;
26 27
27/* 28/*
28 * Each physical page in the system has a struct page associated with 29 * Each physical page in the system has a struct page associated with
@@ -503,6 +504,11 @@ struct mm_struct {
503 atomic_long_t hugetlb_usage; 504 atomic_long_t hugetlb_usage;
504#endif 505#endif
505 struct work_struct async_put_work; 506 struct work_struct async_put_work;
507
508#if IS_ENABLED(CONFIG_HMM)
509 /* HMM needs to track a few things per mm */
510 struct hmm *hmm;
511#endif
506} __randomize_layout; 512} __randomize_layout;
507 513
508extern struct mm_struct init_mm; 514extern struct mm_struct init_mm;
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e7e92c8f4883..356a814e7c8e 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -114,6 +114,20 @@ struct zone_padding {
114#define ZONE_PADDING(name) 114#define ZONE_PADDING(name)
115#endif 115#endif
116 116
117#ifdef CONFIG_NUMA
118enum numa_stat_item {
119 NUMA_HIT, /* allocated in intended node */
120 NUMA_MISS, /* allocated in non intended node */
121 NUMA_FOREIGN, /* was intended here, hit elsewhere */
122 NUMA_INTERLEAVE_HIT, /* interleaver preferred this zone */
123 NUMA_LOCAL, /* allocation from local node */
124 NUMA_OTHER, /* allocation from other node */
125 NR_VM_NUMA_STAT_ITEMS
126};
127#else
128#define NR_VM_NUMA_STAT_ITEMS 0
129#endif
130
117enum zone_stat_item { 131enum zone_stat_item {
118 /* First 128 byte cacheline (assuming 64 bit words) */ 132 /* First 128 byte cacheline (assuming 64 bit words) */
119 NR_FREE_PAGES, 133 NR_FREE_PAGES,
@@ -132,14 +146,6 @@ enum zone_stat_item {
132#if IS_ENABLED(CONFIG_ZSMALLOC) 146#if IS_ENABLED(CONFIG_ZSMALLOC)
133 NR_ZSPAGES, /* allocated in zsmalloc */ 147 NR_ZSPAGES, /* allocated in zsmalloc */
134#endif 148#endif
135#ifdef CONFIG_NUMA
136 NUMA_HIT, /* allocated in intended node */
137 NUMA_MISS, /* allocated in non intended node */
138 NUMA_FOREIGN, /* was intended here, hit elsewhere */
139 NUMA_INTERLEAVE_HIT, /* interleaver preferred this zone */
140 NUMA_LOCAL, /* allocation from local node */
141 NUMA_OTHER, /* allocation from other node */
142#endif
143 NR_FREE_CMA_PAGES, 149 NR_FREE_CMA_PAGES,
144 NR_VM_ZONE_STAT_ITEMS }; 150 NR_VM_ZONE_STAT_ITEMS };
145 151
@@ -276,6 +282,7 @@ struct per_cpu_pageset {
276 struct per_cpu_pages pcp; 282 struct per_cpu_pages pcp;
277#ifdef CONFIG_NUMA 283#ifdef CONFIG_NUMA
278 s8 expire; 284 s8 expire;
285 u16 vm_numa_stat_diff[NR_VM_NUMA_STAT_ITEMS];
279#endif 286#endif
280#ifdef CONFIG_SMP 287#ifdef CONFIG_SMP
281 s8 stat_threshold; 288 s8 stat_threshold;
@@ -496,6 +503,7 @@ struct zone {
496 ZONE_PADDING(_pad3_) 503 ZONE_PADDING(_pad3_)
497 /* Zone statistics */ 504 /* Zone statistics */
498 atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS]; 505 atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
506 atomic_long_t vm_numa_stat[NR_VM_NUMA_STAT_ITEMS];
499} ____cacheline_internodealigned_in_smp; 507} ____cacheline_internodealigned_in_smp;
500 508
501enum pgdat_flags { 509enum pgdat_flags {
diff --git a/include/linux/pps-gpio.h b/include/linux/pps-gpio.h
index 0035abe41b9a..56f35dd3d01d 100644
--- a/include/linux/pps-gpio.h
+++ b/include/linux/pps-gpio.h
@@ -29,4 +29,4 @@ struct pps_gpio_platform_data {
29 const char *gpio_label; 29 const char *gpio_label;
30}; 30};
31 31
32#endif 32#endif /* _PPS_GPIO_H */
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
index 35ac903956c7..80a980cc8d95 100644
--- a/include/linux/pps_kernel.h
+++ b/include/linux/pps_kernel.h
@@ -22,7 +22,6 @@
22#define LINUX_PPS_KERNEL_H 22#define LINUX_PPS_KERNEL_H
23 23
24#include <linux/pps.h> 24#include <linux/pps.h>
25
26#include <linux/cdev.h> 25#include <linux/cdev.h>
27#include <linux/device.h> 26#include <linux/device.h>
28#include <linux/time.h> 27#include <linux/time.h>
@@ -35,9 +34,9 @@ struct pps_device;
35 34
36/* The specific PPS source info */ 35/* The specific PPS source info */
37struct pps_source_info { 36struct pps_source_info {
38 char name[PPS_MAX_NAME_LEN]; /* simbolic name */ 37 char name[PPS_MAX_NAME_LEN]; /* symbolic name */
39 char path[PPS_MAX_NAME_LEN]; /* path of connected device */ 38 char path[PPS_MAX_NAME_LEN]; /* path of connected device */
40 int mode; /* PPS's allowed mode */ 39 int mode; /* PPS allowed mode */
41 40
42 void (*echo)(struct pps_device *pps, 41 void (*echo)(struct pps_device *pps,
43 int event, void *data); /* PPS echo function */ 42 int event, void *data); /* PPS echo function */
@@ -57,10 +56,10 @@ struct pps_event_time {
57struct pps_device { 56struct pps_device {
58 struct pps_source_info info; /* PSS source info */ 57 struct pps_source_info info; /* PSS source info */
59 58
60 struct pps_kparams params; /* PPS's current params */ 59 struct pps_kparams params; /* PPS current params */
61 60
62 __u32 assert_sequence; /* PPS' assert event seq # */ 61 __u32 assert_sequence; /* PPS assert event seq # */
63 __u32 clear_sequence; /* PPS' clear event seq # */ 62 __u32 clear_sequence; /* PPS clear event seq # */
64 struct pps_ktime assert_tu; 63 struct pps_ktime assert_tu;
65 struct pps_ktime clear_tu; 64 struct pps_ktime clear_tu;
66 int current_mode; /* PPS mode at event time */ 65 int current_mode; /* PPS mode at event time */
@@ -69,7 +68,7 @@ struct pps_device {
69 wait_queue_head_t queue; /* PPS event queue */ 68 wait_queue_head_t queue; /* PPS event queue */
70 69
71 unsigned int id; /* PPS source unique ID */ 70 unsigned int id; /* PPS source unique ID */
72 void const *lookup_cookie; /* pps_lookup_dev only */ 71 void const *lookup_cookie; /* For pps_lookup_dev() only */
73 struct cdev cdev; 72 struct cdev cdev;
74 struct device *dev; 73 struct device *dev;
75 struct fasync_struct *async_queue; /* fasync method */ 74 struct fasync_struct *async_queue; /* fasync method */
@@ -101,7 +100,7 @@ extern struct pps_device *pps_register_source(
101extern void pps_unregister_source(struct pps_device *pps); 100extern void pps_unregister_source(struct pps_device *pps);
102extern void pps_event(struct pps_device *pps, 101extern void pps_event(struct pps_device *pps,
103 struct pps_event_time *ts, int event, void *data); 102 struct pps_event_time *ts, int event, void *data);
104/* Look up a pps device by magic cookie */ 103/* Look up a pps_device by magic cookie */
105struct pps_device *pps_lookup_dev(void const *cookie); 104struct pps_device *pps_lookup_dev(void const *cookie);
106 105
107static inline void timespec_to_pps_ktime(struct pps_ktime *kt, 106static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
@@ -132,4 +131,3 @@ static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec64 delta
132} 131}
133 132
134#endif /* LINUX_PPS_KERNEL_H */ 133#endif /* LINUX_PPS_KERNEL_H */
135
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 2d2bf592d9db..76124dd4e36d 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -28,13 +28,7 @@ extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
28 const struct file_operations *, 28 const struct file_operations *,
29 void *); 29 void *);
30 30
31static inline struct proc_dir_entry *proc_create( 31struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops);
32 const char *name, umode_t mode, struct proc_dir_entry *parent,
33 const struct file_operations *proc_fops)
34{
35 return proc_create_data(name, mode, parent, proc_fops, NULL);
36}
37
38extern void proc_set_size(struct proc_dir_entry *, loff_t); 32extern void proc_set_size(struct proc_dir_entry *, loff_t);
39extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); 33extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
40extern void *PDE_DATA(const struct inode *); 34extern void *PDE_DATA(const struct inode *);
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index e585018498d5..d574361943ea 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -44,10 +44,25 @@ struct rb_root {
44 struct rb_node *rb_node; 44 struct rb_node *rb_node;
45}; 45};
46 46
47/*
48 * Leftmost-cached rbtrees.
49 *
50 * We do not cache the rightmost node based on footprint
51 * size vs number of potential users that could benefit
52 * from O(1) rb_last(). Just not worth it, users that want
53 * this feature can always implement the logic explicitly.
54 * Furthermore, users that want to cache both pointers may
55 * find it a bit asymmetric, but that's ok.
56 */
57struct rb_root_cached {
58 struct rb_root rb_root;
59 struct rb_node *rb_leftmost;
60};
47 61
48#define rb_parent(r) ((struct rb_node *)((r)->__rb_parent_color & ~3)) 62#define rb_parent(r) ((struct rb_node *)((r)->__rb_parent_color & ~3))
49 63
50#define RB_ROOT (struct rb_root) { NULL, } 64#define RB_ROOT (struct rb_root) { NULL, }
65#define RB_ROOT_CACHED (struct rb_root_cached) { {NULL, }, NULL }
51#define rb_entry(ptr, type, member) container_of(ptr, type, member) 66#define rb_entry(ptr, type, member) container_of(ptr, type, member)
52 67
53#define RB_EMPTY_ROOT(root) (READ_ONCE((root)->rb_node) == NULL) 68#define RB_EMPTY_ROOT(root) (READ_ONCE((root)->rb_node) == NULL)
@@ -69,6 +84,12 @@ extern struct rb_node *rb_prev(const struct rb_node *);
69extern struct rb_node *rb_first(const struct rb_root *); 84extern struct rb_node *rb_first(const struct rb_root *);
70extern struct rb_node *rb_last(const struct rb_root *); 85extern struct rb_node *rb_last(const struct rb_root *);
71 86
87extern void rb_insert_color_cached(struct rb_node *,
88 struct rb_root_cached *, bool);
89extern void rb_erase_cached(struct rb_node *node, struct rb_root_cached *);
90/* Same as rb_first(), but O(1) */
91#define rb_first_cached(root) (root)->rb_leftmost
92
72/* Postorder iteration - always visit the parent after its children */ 93/* Postorder iteration - always visit the parent after its children */
73extern struct rb_node *rb_first_postorder(const struct rb_root *); 94extern struct rb_node *rb_first_postorder(const struct rb_root *);
74extern struct rb_node *rb_next_postorder(const struct rb_node *); 95extern struct rb_node *rb_next_postorder(const struct rb_node *);
diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index 9702b6e183bc..6bfd2b581f75 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -41,7 +41,9 @@ struct rb_augment_callbacks {
41 void (*rotate)(struct rb_node *old, struct rb_node *new); 41 void (*rotate)(struct rb_node *old, struct rb_node *new);
42}; 42};
43 43
44extern void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 44extern void __rb_insert_augmented(struct rb_node *node,
45 struct rb_root *root,
46 bool newleft, struct rb_node **leftmost,
45 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)); 47 void (*augment_rotate)(struct rb_node *old, struct rb_node *new));
46/* 48/*
47 * Fixup the rbtree and update the augmented information when rebalancing. 49 * Fixup the rbtree and update the augmented information when rebalancing.
@@ -57,7 +59,16 @@ static inline void
57rb_insert_augmented(struct rb_node *node, struct rb_root *root, 59rb_insert_augmented(struct rb_node *node, struct rb_root *root,
58 const struct rb_augment_callbacks *augment) 60 const struct rb_augment_callbacks *augment)
59{ 61{
60 __rb_insert_augmented(node, root, augment->rotate); 62 __rb_insert_augmented(node, root, false, NULL, augment->rotate);
63}
64
65static inline void
66rb_insert_augmented_cached(struct rb_node *node,
67 struct rb_root_cached *root, bool newleft,
68 const struct rb_augment_callbacks *augment)
69{
70 __rb_insert_augmented(node, &root->rb_root,
71 newleft, &root->rb_leftmost, augment->rotate);
61} 72}
62 73
63#define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \ 74#define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \
@@ -150,6 +161,7 @@ extern void __rb_erase_color(struct rb_node *parent, struct rb_root *root,
150 161
151static __always_inline struct rb_node * 162static __always_inline struct rb_node *
152__rb_erase_augmented(struct rb_node *node, struct rb_root *root, 163__rb_erase_augmented(struct rb_node *node, struct rb_root *root,
164 struct rb_node **leftmost,
153 const struct rb_augment_callbacks *augment) 165 const struct rb_augment_callbacks *augment)
154{ 166{
155 struct rb_node *child = node->rb_right; 167 struct rb_node *child = node->rb_right;
@@ -157,6 +169,9 @@ __rb_erase_augmented(struct rb_node *node, struct rb_root *root,
157 struct rb_node *parent, *rebalance; 169 struct rb_node *parent, *rebalance;
158 unsigned long pc; 170 unsigned long pc;
159 171
172 if (leftmost && node == *leftmost)
173 *leftmost = rb_next(node);
174
160 if (!tmp) { 175 if (!tmp) {
161 /* 176 /*
162 * Case 1: node to erase has no more than 1 child (easy!) 177 * Case 1: node to erase has no more than 1 child (easy!)
@@ -256,9 +271,21 @@ static __always_inline void
256rb_erase_augmented(struct rb_node *node, struct rb_root *root, 271rb_erase_augmented(struct rb_node *node, struct rb_root *root,
257 const struct rb_augment_callbacks *augment) 272 const struct rb_augment_callbacks *augment)
258{ 273{
259 struct rb_node *rebalance = __rb_erase_augmented(node, root, augment); 274 struct rb_node *rebalance = __rb_erase_augmented(node, root,
275 NULL, augment);
260 if (rebalance) 276 if (rebalance)
261 __rb_erase_color(rebalance, root, augment->rotate); 277 __rb_erase_color(rebalance, root, augment->rotate);
262} 278}
263 279
280static __always_inline void
281rb_erase_augmented_cached(struct rb_node *node, struct rb_root_cached *root,
282 const struct rb_augment_callbacks *augment)
283{
284 struct rb_node *rebalance = __rb_erase_augmented(node, &root->rb_root,
285 &root->rb_leftmost,
286 augment);
287 if (rebalance)
288 __rb_erase_color(rebalance, &root->rb_root, augment->rotate);
289}
290
264#endif /* _LINUX_RBTREE_AUGMENTED_H */ 291#endif /* _LINUX_RBTREE_AUGMENTED_H */
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 7d56a7ea2b2e..361c08e35dbc 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -127,7 +127,7 @@ struct rhashtable;
127 * @head_offset: Offset of rhash_head in struct to be hashed 127 * @head_offset: Offset of rhash_head in struct to be hashed
128 * @max_size: Maximum size while expanding 128 * @max_size: Maximum size while expanding
129 * @min_size: Minimum size while shrinking 129 * @min_size: Minimum size while shrinking
130 * @locks_mul: Number of bucket locks to allocate per cpu (default: 128) 130 * @locks_mul: Number of bucket locks to allocate per cpu (default: 32)
131 * @automatic_shrinking: Enable automatic shrinking of tables 131 * @automatic_shrinking: Enable automatic shrinking of tables
132 * @nulls_base: Base value to generate nulls marker 132 * @nulls_base: Base value to generate nulls marker
133 * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash) 133 * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash)
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 43ef2c30cb0f..733d3d8181e2 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -55,7 +55,9 @@ struct anon_vma {
55 * is serialized by a system wide lock only visible to 55 * is serialized by a system wide lock only visible to
56 * mm_take_all_locks() (mm_all_locks_mutex). 56 * mm_take_all_locks() (mm_all_locks_mutex).
57 */ 57 */
58 struct rb_root rb_root; /* Interval tree of private "related" vmas */ 58
59 /* Interval tree of private "related" vmas */
60 struct rb_root_cached rb_root;
59}; 61};
60 62
61/* 63/*
@@ -93,8 +95,9 @@ enum ttu_flags {
93 TTU_BATCH_FLUSH = 0x40, /* Batch TLB flushes where possible 95 TTU_BATCH_FLUSH = 0x40, /* Batch TLB flushes where possible
94 * and caller guarantees they will 96 * and caller guarantees they will
95 * do a final flush if necessary */ 97 * do a final flush if necessary */
96 TTU_RMAP_LOCKED = 0x80 /* do not grab rmap lock: 98 TTU_RMAP_LOCKED = 0x80, /* do not grab rmap lock:
97 * caller holds it */ 99 * caller holds it */
100 TTU_SPLIT_FREEZE = 0x100, /* freeze pte under splitting thp */
98}; 101};
99 102
100#ifdef CONFIG_MMU 103#ifdef CONFIG_MMU
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 44fd002f7cd5..53fcbe9de7fd 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -22,18 +22,17 @@ extern int max_lock_depth; /* for sysctl */
22 * The rt_mutex structure 22 * The rt_mutex structure
23 * 23 *
24 * @wait_lock: spinlock to protect the structure 24 * @wait_lock: spinlock to protect the structure
25 * @waiters: rbtree root to enqueue waiters in priority order 25 * @waiters: rbtree root to enqueue waiters in priority order;
26 * @waiters_leftmost: top waiter 26 * caches top-waiter (leftmost node).
27 * @owner: the mutex owner 27 * @owner: the mutex owner
28 */ 28 */
29struct rt_mutex { 29struct rt_mutex {
30 raw_spinlock_t wait_lock; 30 raw_spinlock_t wait_lock;
31 struct rb_root waiters; 31 struct rb_root_cached waiters;
32 struct rb_node *waiters_leftmost;
33 struct task_struct *owner; 32 struct task_struct *owner;
34#ifdef CONFIG_DEBUG_RT_MUTEXES 33#ifdef CONFIG_DEBUG_RT_MUTEXES
35 int save_state; 34 int save_state;
36 const char *name, *file; 35 const char *name, *file;
37 int line; 36 int line;
38 void *magic; 37 void *magic;
39#endif 38#endif
@@ -84,7 +83,7 @@ do { \
84 83
85#define __RT_MUTEX_INITIALIZER(mutexname) \ 84#define __RT_MUTEX_INITIALIZER(mutexname) \
86 { .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \ 85 { .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
87 , .waiters = RB_ROOT \ 86 , .waiters = RB_ROOT_CACHED \
88 , .owner = NULL \ 87 , .owner = NULL \
89 __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \ 88 __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \
90 __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname)} 89 __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname)}
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 68b38335d33c..92fb8dd5a9e4 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -812,8 +812,7 @@ struct task_struct {
812 812
813#ifdef CONFIG_RT_MUTEXES 813#ifdef CONFIG_RT_MUTEXES
814 /* PI waiters blocked on a rt_mutex held by this task: */ 814 /* PI waiters blocked on a rt_mutex held by this task: */
815 struct rb_root pi_waiters; 815 struct rb_root_cached pi_waiters;
816 struct rb_node *pi_waiters_leftmost;
817 /* Updated under owner's pi_lock and rq lock */ 816 /* Updated under owner's pi_lock and rq lock */
818 struct task_struct *pi_top_task; 817 struct task_struct *pi_top_task;
819 /* Deadlock detection and priority inheritance handling: */ 818 /* Deadlock detection and priority inheritance handling: */
diff --git a/include/linux/string.h b/include/linux/string.h
index a467e617eeb0..c8bdafffd2f0 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -99,6 +99,36 @@ extern __kernel_size_t strcspn(const char *,const char *);
99#ifndef __HAVE_ARCH_MEMSET 99#ifndef __HAVE_ARCH_MEMSET
100extern void * memset(void *,int,__kernel_size_t); 100extern void * memset(void *,int,__kernel_size_t);
101#endif 101#endif
102
103#ifndef __HAVE_ARCH_MEMSET16
104extern void *memset16(uint16_t *, uint16_t, __kernel_size_t);
105#endif
106
107#ifndef __HAVE_ARCH_MEMSET32
108extern void *memset32(uint32_t *, uint32_t, __kernel_size_t);
109#endif
110
111#ifndef __HAVE_ARCH_MEMSET64
112extern void *memset64(uint64_t *, uint64_t, __kernel_size_t);
113#endif
114
115static inline void *memset_l(unsigned long *p, unsigned long v,
116 __kernel_size_t n)
117{
118 if (BITS_PER_LONG == 32)
119 return memset32((uint32_t *)p, v, n);
120 else
121 return memset64((uint64_t *)p, v, n);
122}
123
124static inline void *memset_p(void **p, void *v, __kernel_size_t n)
125{
126 if (BITS_PER_LONG == 32)
127 return memset32((uint32_t *)p, (uintptr_t)v, n);
128 else
129 return memset64((uint64_t *)p, (uintptr_t)v, n);
130}
131
102#ifndef __HAVE_ARCH_MEMCPY 132#ifndef __HAVE_ARCH_MEMCPY
103extern void * memcpy(void *,const void *,__kernel_size_t); 133extern void * memcpy(void *,const void *,__kernel_size_t);
104#endif 134#endif
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 8bf3487fb204..8a807292037f 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -51,6 +51,23 @@ static inline int current_is_kswapd(void)
51 */ 51 */
52 52
53/* 53/*
54 * Unaddressable device memory support. See include/linux/hmm.h and
55 * Documentation/vm/hmm.txt. Short description is we need struct pages for
56 * device memory that is unaddressable (inaccessible) by CPU, so that we can
57 * migrate part of a process memory to device memory.
58 *
59 * When a page is migrated from CPU to device, we set the CPU page table entry
60 * to a special SWP_DEVICE_* entry.
61 */
62#ifdef CONFIG_DEVICE_PRIVATE
63#define SWP_DEVICE_NUM 2
64#define SWP_DEVICE_WRITE (MAX_SWAPFILES+SWP_HWPOISON_NUM+SWP_MIGRATION_NUM)
65#define SWP_DEVICE_READ (MAX_SWAPFILES+SWP_HWPOISON_NUM+SWP_MIGRATION_NUM+1)
66#else
67#define SWP_DEVICE_NUM 0
68#endif
69
70/*
54 * NUMA node memory migration support 71 * NUMA node memory migration support
55 */ 72 */
56#ifdef CONFIG_MIGRATION 73#ifdef CONFIG_MIGRATION
@@ -72,7 +89,8 @@ static inline int current_is_kswapd(void)
72#endif 89#endif
73 90
74#define MAX_SWAPFILES \ 91#define MAX_SWAPFILES \
75 ((1 << MAX_SWAPFILES_SHIFT) - SWP_MIGRATION_NUM - SWP_HWPOISON_NUM) 92 ((1 << MAX_SWAPFILES_SHIFT) - SWP_DEVICE_NUM - \
93 SWP_MIGRATION_NUM - SWP_HWPOISON_NUM)
76 94
77/* 95/*
78 * Magic header for a swap area. The first part of the union is 96 * Magic header for a swap area. The first part of the union is
@@ -469,8 +487,8 @@ static inline void show_swap_cache_info(void)
469{ 487{
470} 488}
471 489
472#define free_swap_and_cache(swp) is_migration_entry(swp) 490#define free_swap_and_cache(e) ({(is_migration_entry(e) || is_device_private_entry(e));})
473#define swapcache_prepare(swp) is_migration_entry(swp) 491#define swapcache_prepare(e) ({(is_migration_entry(e) || is_device_private_entry(e));})
474 492
475static inline int add_swap_count_continuation(swp_entry_t swp, gfp_t gfp_mask) 493static inline int add_swap_count_continuation(swp_entry_t swp, gfp_t gfp_mask)
476{ 494{
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index c5ff7b217ee6..291c4b534658 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -100,10 +100,79 @@ static inline void *swp_to_radix_entry(swp_entry_t entry)
100 return (void *)(value | RADIX_TREE_EXCEPTIONAL_ENTRY); 100 return (void *)(value | RADIX_TREE_EXCEPTIONAL_ENTRY);
101} 101}
102 102
103#if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
104static inline swp_entry_t make_device_private_entry(struct page *page, bool write)
105{
106 return swp_entry(write ? SWP_DEVICE_WRITE : SWP_DEVICE_READ,
107 page_to_pfn(page));
108}
109
110static inline bool is_device_private_entry(swp_entry_t entry)
111{
112 int type = swp_type(entry);
113 return type == SWP_DEVICE_READ || type == SWP_DEVICE_WRITE;
114}
115
116static inline void make_device_private_entry_read(swp_entry_t *entry)
117{
118 *entry = swp_entry(SWP_DEVICE_READ, swp_offset(*entry));
119}
120
121static inline bool is_write_device_private_entry(swp_entry_t entry)
122{
123 return unlikely(swp_type(entry) == SWP_DEVICE_WRITE);
124}
125
126static inline struct page *device_private_entry_to_page(swp_entry_t entry)
127{
128 return pfn_to_page(swp_offset(entry));
129}
130
131int device_private_entry_fault(struct vm_area_struct *vma,
132 unsigned long addr,
133 swp_entry_t entry,
134 unsigned int flags,
135 pmd_t *pmdp);
136#else /* CONFIG_DEVICE_PRIVATE */
137static inline swp_entry_t make_device_private_entry(struct page *page, bool write)
138{
139 return swp_entry(0, 0);
140}
141
142static inline void make_device_private_entry_read(swp_entry_t *entry)
143{
144}
145
146static inline bool is_device_private_entry(swp_entry_t entry)
147{
148 return false;
149}
150
151static inline bool is_write_device_private_entry(swp_entry_t entry)
152{
153 return false;
154}
155
156static inline struct page *device_private_entry_to_page(swp_entry_t entry)
157{
158 return NULL;
159}
160
161static inline int device_private_entry_fault(struct vm_area_struct *vma,
162 unsigned long addr,
163 swp_entry_t entry,
164 unsigned int flags,
165 pmd_t *pmdp)
166{
167 return VM_FAULT_SIGBUS;
168}
169#endif /* CONFIG_DEVICE_PRIVATE */
170
103#ifdef CONFIG_MIGRATION 171#ifdef CONFIG_MIGRATION
104static inline swp_entry_t make_migration_entry(struct page *page, int write) 172static inline swp_entry_t make_migration_entry(struct page *page, int write)
105{ 173{
106 BUG_ON(!PageLocked(page)); 174 BUG_ON(!PageLocked(compound_head(page)));
175
107 return swp_entry(write ? SWP_MIGRATION_WRITE : SWP_MIGRATION_READ, 176 return swp_entry(write ? SWP_MIGRATION_WRITE : SWP_MIGRATION_READ,
108 page_to_pfn(page)); 177 page_to_pfn(page));
109} 178}
@@ -126,7 +195,7 @@ static inline struct page *migration_entry_to_page(swp_entry_t entry)
126 * Any use of migration entries may only occur while the 195 * Any use of migration entries may only occur while the
127 * corresponding page is locked 196 * corresponding page is locked
128 */ 197 */
129 BUG_ON(!PageLocked(p)); 198 BUG_ON(!PageLocked(compound_head(p)));
130 return p; 199 return p;
131} 200}
132 201
@@ -148,7 +217,11 @@ static inline int is_migration_entry(swp_entry_t swp)
148{ 217{
149 return 0; 218 return 0;
150} 219}
151#define migration_entry_to_page(swp) NULL 220static inline struct page *migration_entry_to_page(swp_entry_t entry)
221{
222 return NULL;
223}
224
152static inline void make_migration_entry_read(swp_entry_t *entryp) { } 225static inline void make_migration_entry_read(swp_entry_t *entryp) { }
153static inline void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep, 226static inline void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep,
154 spinlock_t *ptl) { } 227 spinlock_t *ptl) { }
@@ -163,6 +236,70 @@ static inline int is_write_migration_entry(swp_entry_t entry)
163 236
164#endif 237#endif
165 238
239struct page_vma_mapped_walk;
240
241#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
242extern void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
243 struct page *page);
244
245extern void remove_migration_pmd(struct page_vma_mapped_walk *pvmw,
246 struct page *new);
247
248extern void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd);
249
250static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd)
251{
252 swp_entry_t arch_entry;
253
254 if (pmd_swp_soft_dirty(pmd))
255 pmd = pmd_swp_clear_soft_dirty(pmd);
256 arch_entry = __pmd_to_swp_entry(pmd);
257 return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
258}
259
260static inline pmd_t swp_entry_to_pmd(swp_entry_t entry)
261{
262 swp_entry_t arch_entry;
263
264 arch_entry = __swp_entry(swp_type(entry), swp_offset(entry));
265 return __swp_entry_to_pmd(arch_entry);
266}
267
268static inline int is_pmd_migration_entry(pmd_t pmd)
269{
270 return !pmd_present(pmd) && is_migration_entry(pmd_to_swp_entry(pmd));
271}
272#else
273static inline void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
274 struct page *page)
275{
276 BUILD_BUG();
277}
278
279static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw,
280 struct page *new)
281{
282 BUILD_BUG();
283}
284
285static inline void pmd_migration_entry_wait(struct mm_struct *m, pmd_t *p) { }
286
287static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd)
288{
289 return swp_entry(0, 0);
290}
291
292static inline pmd_t swp_entry_to_pmd(swp_entry_t entry)
293{
294 return __pmd(0);
295}
296
297static inline int is_pmd_migration_entry(pmd_t pmd)
298{
299 return 0;
300}
301#endif
302
166#ifdef CONFIG_MEMORY_FAILURE 303#ifdef CONFIG_MEMORY_FAILURE
167 304
168extern atomic_long_t num_poisoned_pages __read_mostly; 305extern atomic_long_t num_poisoned_pages __read_mostly;
diff --git a/include/linux/umh.h b/include/linux/umh.h
new file mode 100644
index 000000000000..244aff638220
--- /dev/null
+++ b/include/linux/umh.h
@@ -0,0 +1,69 @@
1#ifndef __LINUX_UMH_H__
2#define __LINUX_UMH_H__
3
4#include <linux/gfp.h>
5#include <linux/stddef.h>
6#include <linux/errno.h>
7#include <linux/compiler.h>
8#include <linux/workqueue.h>
9#include <linux/sysctl.h>
10
11struct cred;
12struct file;
13
14#define UMH_NO_WAIT 0 /* don't wait at all */
15#define UMH_WAIT_EXEC 1 /* wait for the exec, but not the process */
16#define UMH_WAIT_PROC 2 /* wait for the process to complete */
17#define UMH_KILLABLE 4 /* wait for EXEC/PROC killable */
18
19struct subprocess_info {
20 struct work_struct work;
21 struct completion *complete;
22 const char *path;
23 char **argv;
24 char **envp;
25 int wait;
26 int retval;
27 int (*init)(struct subprocess_info *info, struct cred *new);
28 void (*cleanup)(struct subprocess_info *info);
29 void *data;
30} __randomize_layout;
31
32extern int
33call_usermodehelper(const char *path, char **argv, char **envp, int wait);
34
35extern struct subprocess_info *
36call_usermodehelper_setup(const char *path, char **argv, char **envp,
37 gfp_t gfp_mask,
38 int (*init)(struct subprocess_info *info, struct cred *new),
39 void (*cleanup)(struct subprocess_info *), void *data);
40
41extern int
42call_usermodehelper_exec(struct subprocess_info *info, int wait);
43
44extern struct ctl_table usermodehelper_table[];
45
46enum umh_disable_depth {
47 UMH_ENABLED = 0,
48 UMH_FREEZING,
49 UMH_DISABLED,
50};
51
52extern int __usermodehelper_disable(enum umh_disable_depth depth);
53extern void __usermodehelper_set_disable_depth(enum umh_disable_depth depth);
54
55static inline int usermodehelper_disable(void)
56{
57 return __usermodehelper_disable(UMH_DISABLED);
58}
59
60static inline void usermodehelper_enable(void)
61{
62 __usermodehelper_set_disable_depth(UMH_ENABLED);
63}
64
65extern int usermodehelper_read_trylock(void);
66extern long usermodehelper_read_lock_wait(long timeout);
67extern void usermodehelper_read_unlock(void);
68
69#endif /* __LINUX_UMH_H__ */
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 97e11ab573f0..ade7cb5f1359 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -107,8 +107,37 @@ static inline void vm_events_fold_cpu(int cpu)
107 * Zone and node-based page accounting with per cpu differentials. 107 * Zone and node-based page accounting with per cpu differentials.
108 */ 108 */
109extern atomic_long_t vm_zone_stat[NR_VM_ZONE_STAT_ITEMS]; 109extern atomic_long_t vm_zone_stat[NR_VM_ZONE_STAT_ITEMS];
110extern atomic_long_t vm_numa_stat[NR_VM_NUMA_STAT_ITEMS];
110extern atomic_long_t vm_node_stat[NR_VM_NODE_STAT_ITEMS]; 111extern atomic_long_t vm_node_stat[NR_VM_NODE_STAT_ITEMS];
111 112
113#ifdef CONFIG_NUMA
114static inline void zone_numa_state_add(long x, struct zone *zone,
115 enum numa_stat_item item)
116{
117 atomic_long_add(x, &zone->vm_numa_stat[item]);
118 atomic_long_add(x, &vm_numa_stat[item]);
119}
120
121static inline unsigned long global_numa_state(enum numa_stat_item item)
122{
123 long x = atomic_long_read(&vm_numa_stat[item]);
124
125 return x;
126}
127
128static inline unsigned long zone_numa_state_snapshot(struct zone *zone,
129 enum numa_stat_item item)
130{
131 long x = atomic_long_read(&zone->vm_numa_stat[item]);
132 int cpu;
133
134 for_each_online_cpu(cpu)
135 x += per_cpu_ptr(zone->pageset, cpu)->vm_numa_stat_diff[item];
136
137 return x;
138}
139#endif /* CONFIG_NUMA */
140
112static inline void zone_page_state_add(long x, struct zone *zone, 141static inline void zone_page_state_add(long x, struct zone *zone,
113 enum zone_stat_item item) 142 enum zone_stat_item item)
114{ 143{
@@ -194,8 +223,10 @@ static inline unsigned long node_page_state_snapshot(pg_data_t *pgdat,
194 223
195 224
196#ifdef CONFIG_NUMA 225#ifdef CONFIG_NUMA
226extern void __inc_numa_state(struct zone *zone, enum numa_stat_item item);
197extern unsigned long sum_zone_node_page_state(int node, 227extern unsigned long sum_zone_node_page_state(int node,
198 enum zone_stat_item item); 228 enum zone_stat_item item);
229extern unsigned long sum_zone_numa_state(int node, enum numa_stat_item item);
199extern unsigned long node_page_state(struct pglist_data *pgdat, 230extern unsigned long node_page_state(struct pglist_data *pgdat,
200 enum node_stat_item item); 231 enum node_stat_item item);
201#else 232#else
diff --git a/include/linux/vt_buffer.h b/include/linux/vt_buffer.h
index f38c10ba3ff5..30b6e0d2a942 100644
--- a/include/linux/vt_buffer.h
+++ b/include/linux/vt_buffer.h
@@ -13,6 +13,7 @@
13#ifndef _LINUX_VT_BUFFER_H_ 13#ifndef _LINUX_VT_BUFFER_H_
14#define _LINUX_VT_BUFFER_H_ 14#define _LINUX_VT_BUFFER_H_
15 15
16#include <linux/string.h>
16 17
17#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE) 18#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
18#include <asm/vga.h> 19#include <asm/vga.h>
@@ -26,24 +27,33 @@
26#ifndef VT_BUF_HAVE_MEMSETW 27#ifndef VT_BUF_HAVE_MEMSETW
27static inline void scr_memsetw(u16 *s, u16 c, unsigned int count) 28static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
28{ 29{
30#ifdef VT_BUF_HAVE_RW
29 count /= 2; 31 count /= 2;
30 while (count--) 32 while (count--)
31 scr_writew(c, s++); 33 scr_writew(c, s++);
34#else
35 memset16(s, c, count / 2);
36#endif
32} 37}
33#endif 38#endif
34 39
35#ifndef VT_BUF_HAVE_MEMCPYW 40#ifndef VT_BUF_HAVE_MEMCPYW
36static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count) 41static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
37{ 42{
43#ifdef VT_BUF_HAVE_RW
38 count /= 2; 44 count /= 2;
39 while (count--) 45 while (count--)
40 scr_writew(scr_readw(s++), d++); 46 scr_writew(scr_readw(s++), d++);
47#else
48 memcpy(d, s, count);
49#endif
41} 50}
42#endif 51#endif
43 52
44#ifndef VT_BUF_HAVE_MEMMOVEW 53#ifndef VT_BUF_HAVE_MEMMOVEW
45static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count) 54static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
46{ 55{
56#ifdef VT_BUF_HAVE_RW
47 if (d < s) 57 if (d < s)
48 scr_memcpyw(d, s, count); 58 scr_memcpyw(d, s, count);
49 else { 59 else {
@@ -53,6 +63,9 @@ static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
53 while (count--) 63 while (count--)
54 scr_writew(scr_readw(--s), --d); 64 scr_writew(scr_readw(--s), --d);
55 } 65 }
66#else
67 memmove(d, s, count);
68#endif
56} 69}
57#endif 70#endif
58 71
diff --git a/include/rdma/ib_umem_odp.h b/include/rdma/ib_umem_odp.h
index fb67554aabd6..5eb7f5bc8248 100644
--- a/include/rdma/ib_umem_odp.h
+++ b/include/rdma/ib_umem_odp.h
@@ -111,22 +111,25 @@ int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 start_offset, u64 bcnt,
111void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 start_offset, 111void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 start_offset,
112 u64 bound); 112 u64 bound);
113 113
114void rbt_ib_umem_insert(struct umem_odp_node *node, struct rb_root *root); 114void rbt_ib_umem_insert(struct umem_odp_node *node,
115void rbt_ib_umem_remove(struct umem_odp_node *node, struct rb_root *root); 115 struct rb_root_cached *root);
116void rbt_ib_umem_remove(struct umem_odp_node *node,
117 struct rb_root_cached *root);
116typedef int (*umem_call_back)(struct ib_umem *item, u64 start, u64 end, 118typedef int (*umem_call_back)(struct ib_umem *item, u64 start, u64 end,
117 void *cookie); 119 void *cookie);
118/* 120/*
119 * Call the callback on each ib_umem in the range. Returns the logical or of 121 * Call the callback on each ib_umem in the range. Returns the logical or of
120 * the return values of the functions called. 122 * the return values of the functions called.
121 */ 123 */
122int rbt_ib_umem_for_each_in_range(struct rb_root *root, u64 start, u64 end, 124int rbt_ib_umem_for_each_in_range(struct rb_root_cached *root,
125 u64 start, u64 end,
123 umem_call_back cb, void *cookie); 126 umem_call_back cb, void *cookie);
124 127
125/* 128/*
126 * Find first region intersecting with address range. 129 * Find first region intersecting with address range.
127 * Return NULL if not found 130 * Return NULL if not found
128 */ 131 */
129struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root *root, 132struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root,
130 u64 addr, u64 length); 133 u64 addr, u64 length);
131 134
132static inline int ib_umem_mmu_notifier_retry(struct ib_umem *item, 135static inline int ib_umem_mmu_notifier_retry(struct ib_umem *item,
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e6df68048517..bdb1279a415b 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1457,7 +1457,7 @@ struct ib_ucontext {
1457 1457
1458 struct pid *tgid; 1458 struct pid *tgid;
1459#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING 1459#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
1460 struct rb_root umem_tree; 1460 struct rb_root_cached umem_tree;
1461 /* 1461 /*
1462 * Protects .umem_rbroot and tree, as well as odp_mrs_count and 1462 * Protects .umem_rbroot and tree, as well as odp_mrs_count and
1463 * mmu notifiers registration. 1463 * mmu notifiers registration.
diff --git a/include/uapi/linux/auto_dev-ioctl.h b/include/uapi/linux/auto_dev-ioctl.h
index 744b3d060968..5558db8e6646 100644
--- a/include/uapi/linux/auto_dev-ioctl.h
+++ b/include/uapi/linux/auto_dev-ioctl.h
@@ -16,7 +16,7 @@
16#define AUTOFS_DEVICE_NAME "autofs" 16#define AUTOFS_DEVICE_NAME "autofs"
17 17
18#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1 18#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1
19#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0 19#define AUTOFS_DEV_IOCTL_VERSION_MINOR 1
20 20
21#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl) 21#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl)
22 22
diff --git a/include/uapi/linux/auto_fs4.h b/include/uapi/linux/auto_fs4.h
index 7c6da423d54e..9453e9a07c9d 100644
--- a/include/uapi/linux/auto_fs4.h
+++ b/include/uapi/linux/auto_fs4.h
@@ -155,8 +155,6 @@ enum {
155}; 155};
156 156
157#define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, AUTOFS_IOC_EXPIRE_MULTI_CMD, int) 157#define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
158#define AUTOFS_IOC_EXPIRE_INDIRECT AUTOFS_IOC_EXPIRE_MULTI
159#define AUTOFS_IOC_EXPIRE_DIRECT AUTOFS_IOC_EXPIRE_MULTI
160#define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, AUTOFS_IOC_PROTOSUBVER_CMD, int) 158#define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, AUTOFS_IOC_PROTOSUBVER_CMD, int)
161#define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, AUTOFS_IOC_ASKUMOUNT_CMD, int) 159#define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, AUTOFS_IOC_ASKUMOUNT_CMD, int)
162 160
diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
index c1cb3825a8bc..c29d6b791c08 100644
--- a/include/uapi/linux/pps.h
+++ b/include/uapi/linux/pps.h
@@ -95,8 +95,8 @@ struct pps_kparams {
95#define PPS_CAPTURECLEAR 0x02 /* capture clear events */ 95#define PPS_CAPTURECLEAR 0x02 /* capture clear events */
96#define PPS_CAPTUREBOTH 0x03 /* capture assert and clear events */ 96#define PPS_CAPTUREBOTH 0x03 /* capture assert and clear events */
97 97
98#define PPS_OFFSETASSERT 0x10 /* apply compensation for assert ev. */ 98#define PPS_OFFSETASSERT 0x10 /* apply compensation for assert event */
99#define PPS_OFFSETCLEAR 0x20 /* apply compensation for clear ev. */ 99#define PPS_OFFSETCLEAR 0x20 /* apply compensation for clear event */
100 100
101#define PPS_CANWAIT 0x100 /* can we wait for an event? */ 101#define PPS_CANWAIT 0x100 /* can we wait for an event? */
102#define PPS_CANPOLL 0x200 /* bit reserved for future use */ 102#define PPS_CANPOLL 0x200 /* bit reserved for future use */
diff --git a/init/main.c b/init/main.c
index 949306bb5b6a..0ee9c6866ada 100644
--- a/init/main.c
+++ b/init/main.c
@@ -515,12 +515,6 @@ asmlinkage __visible void __init start_kernel(void)
515 smp_setup_processor_id(); 515 smp_setup_processor_id();
516 debug_objects_early_init(); 516 debug_objects_early_init();
517 517
518 /*
519 * Set up the initial canary ASAP:
520 */
521 add_latent_entropy();
522 boot_init_stack_canary();
523
524 cgroup_init_early(); 518 cgroup_init_early();
525 519
526 local_irq_disable(); 520 local_irq_disable();
@@ -534,6 +528,13 @@ asmlinkage __visible void __init start_kernel(void)
534 page_address_init(); 528 page_address_init();
535 pr_notice("%s", linux_banner); 529 pr_notice("%s", linux_banner);
536 setup_arch(&command_line); 530 setup_arch(&command_line);
531 /*
532 * Set up the the initial canary and entropy after arch
533 * and after adding latent and command line entropy.
534 */
535 add_latent_entropy();
536 add_device_randomness(command_line, strlen(command_line));
537 boot_init_stack_canary();
537 mm_init_cpumask(&init_mm); 538 mm_init_cpumask(&init_mm);
538 setup_command_line(command_line); 539 setup_command_line(command_line);
539 setup_nr_cpu_ids(); 540 setup_nr_cpu_ids();
diff --git a/ipc/msg.c b/ipc/msg.c
index 2c38f10d1483..df82bc9a5531 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -1011,7 +1011,7 @@ SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,
1011} 1011}
1012 1012
1013 1013
1014void msg_init_ns(struct ipc_namespace *ns) 1014int msg_init_ns(struct ipc_namespace *ns)
1015{ 1015{
1016 ns->msg_ctlmax = MSGMAX; 1016 ns->msg_ctlmax = MSGMAX;
1017 ns->msg_ctlmnb = MSGMNB; 1017 ns->msg_ctlmnb = MSGMNB;
@@ -1019,7 +1019,7 @@ void msg_init_ns(struct ipc_namespace *ns)
1019 1019
1020 atomic_set(&ns->msg_bytes, 0); 1020 atomic_set(&ns->msg_bytes, 0);
1021 atomic_set(&ns->msg_hdrs, 0); 1021 atomic_set(&ns->msg_hdrs, 0);
1022 ipc_init_ids(&ns->ids[IPC_MSG_IDS]); 1022 return ipc_init_ids(&ns->ids[IPC_MSG_IDS]);
1023} 1023}
1024 1024
1025#ifdef CONFIG_IPC_NS 1025#ifdef CONFIG_IPC_NS
@@ -1027,6 +1027,7 @@ void msg_exit_ns(struct ipc_namespace *ns)
1027{ 1027{
1028 free_ipcs(ns, &msg_ids(ns), freeque); 1028 free_ipcs(ns, &msg_ids(ns), freeque);
1029 idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); 1029 idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr);
1030 rhashtable_destroy(&ns->ids[IPC_MSG_IDS].key_ht);
1030} 1031}
1031#endif 1032#endif
1032 1033
@@ -1058,11 +1059,12 @@ static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
1058} 1059}
1059#endif 1060#endif
1060 1061
1061void __init msg_init(void) 1062int __init msg_init(void)
1062{ 1063{
1063 msg_init_ns(&init_ipc_ns); 1064 const int err = msg_init_ns(&init_ipc_ns);
1064 1065
1065 ipc_init_proc_interface("sysvipc/msg", 1066 ipc_init_proc_interface("sysvipc/msg",
1066 " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", 1067 " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n",
1067 IPC_MSG_IDS, sysvipc_msg_proc_show); 1068 IPC_MSG_IDS, sysvipc_msg_proc_show);
1069 return err;
1068} 1070}
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index bf74eaa5c39f..84598025a6ad 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -29,7 +29,7 @@ DEFINE_SPINLOCK(mq_lock);
29 * and not CONFIG_IPC_NS. 29 * and not CONFIG_IPC_NS.
30 */ 30 */
31struct ipc_namespace init_ipc_ns = { 31struct ipc_namespace init_ipc_ns = {
32 .count = ATOMIC_INIT(1), 32 .count = REFCOUNT_INIT(1),
33 .user_ns = &init_user_ns, 33 .user_ns = &init_user_ns,
34 .ns.inum = PROC_IPC_INIT_INO, 34 .ns.inum = PROC_IPC_INIT_INO,
35#ifdef CONFIG_IPC_NS 35#ifdef CONFIG_IPC_NS
diff --git a/ipc/namespace.c b/ipc/namespace.c
index b4d80f9f7246..fc850c526698 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -50,20 +50,32 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
50 goto fail_free; 50 goto fail_free;
51 ns->ns.ops = &ipcns_operations; 51 ns->ns.ops = &ipcns_operations;
52 52
53 atomic_set(&ns->count, 1); 53 refcount_set(&ns->count, 1);
54 ns->user_ns = get_user_ns(user_ns); 54 ns->user_ns = get_user_ns(user_ns);
55 ns->ucounts = ucounts; 55 ns->ucounts = ucounts;
56 56
57 err = mq_init_ns(ns); 57 err = sem_init_ns(ns);
58 if (err) 58 if (err)
59 goto fail_put; 59 goto fail_put;
60 err = msg_init_ns(ns);
61 if (err)
62 goto fail_destroy_sem;
63 err = shm_init_ns(ns);
64 if (err)
65 goto fail_destroy_msg;
60 66
61 sem_init_ns(ns); 67 err = mq_init_ns(ns);
62 msg_init_ns(ns); 68 if (err)
63 shm_init_ns(ns); 69 goto fail_destroy_shm;
64 70
65 return ns; 71 return ns;
66 72
73fail_destroy_shm:
74 shm_exit_ns(ns);
75fail_destroy_msg:
76 msg_exit_ns(ns);
77fail_destroy_sem:
78 sem_exit_ns(ns);
67fail_put: 79fail_put:
68 put_user_ns(ns->user_ns); 80 put_user_ns(ns->user_ns);
69 ns_free_inum(&ns->ns); 81 ns_free_inum(&ns->ns);
@@ -144,7 +156,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)
144 */ 156 */
145void put_ipc_ns(struct ipc_namespace *ns) 157void put_ipc_ns(struct ipc_namespace *ns)
146{ 158{
147 if (atomic_dec_and_lock(&ns->count, &mq_lock)) { 159 if (refcount_dec_and_lock(&ns->count, &mq_lock)) {
148 mq_clear_sbinfo(ns); 160 mq_clear_sbinfo(ns);
149 spin_unlock(&mq_lock); 161 spin_unlock(&mq_lock);
150 mq_put_mnt(ns); 162 mq_put_mnt(ns);
diff --git a/ipc/sem.c b/ipc/sem.c
index c6c50370504c..013c7981f3c7 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -122,7 +122,7 @@ struct sem_undo {
122 * that may be shared among all a CLONE_SYSVSEM task group. 122 * that may be shared among all a CLONE_SYSVSEM task group.
123 */ 123 */
124struct sem_undo_list { 124struct sem_undo_list {
125 atomic_t refcnt; 125 refcount_t refcnt;
126 spinlock_t lock; 126 spinlock_t lock;
127 struct list_head list_proc; 127 struct list_head list_proc;
128}; 128};
@@ -130,8 +130,6 @@ struct sem_undo_list {
130 130
131#define sem_ids(ns) ((ns)->ids[IPC_SEM_IDS]) 131#define sem_ids(ns) ((ns)->ids[IPC_SEM_IDS])
132 132
133#define sem_checkid(sma, semid) ipc_checkid(&sma->sem_perm, semid)
134
135static int newary(struct ipc_namespace *, struct ipc_params *); 133static int newary(struct ipc_namespace *, struct ipc_params *);
136static void freeary(struct ipc_namespace *, struct kern_ipc_perm *); 134static void freeary(struct ipc_namespace *, struct kern_ipc_perm *);
137#ifdef CONFIG_PROC_FS 135#ifdef CONFIG_PROC_FS
@@ -185,14 +183,14 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it);
185#define sc_semopm sem_ctls[2] 183#define sc_semopm sem_ctls[2]
186#define sc_semmni sem_ctls[3] 184#define sc_semmni sem_ctls[3]
187 185
188void sem_init_ns(struct ipc_namespace *ns) 186int sem_init_ns(struct ipc_namespace *ns)
189{ 187{
190 ns->sc_semmsl = SEMMSL; 188 ns->sc_semmsl = SEMMSL;
191 ns->sc_semmns = SEMMNS; 189 ns->sc_semmns = SEMMNS;
192 ns->sc_semopm = SEMOPM; 190 ns->sc_semopm = SEMOPM;
193 ns->sc_semmni = SEMMNI; 191 ns->sc_semmni = SEMMNI;
194 ns->used_sems = 0; 192 ns->used_sems = 0;
195 ipc_init_ids(&ns->ids[IPC_SEM_IDS]); 193 return ipc_init_ids(&ns->ids[IPC_SEM_IDS]);
196} 194}
197 195
198#ifdef CONFIG_IPC_NS 196#ifdef CONFIG_IPC_NS
@@ -200,15 +198,18 @@ void sem_exit_ns(struct ipc_namespace *ns)
200{ 198{
201 free_ipcs(ns, &sem_ids(ns), freeary); 199 free_ipcs(ns, &sem_ids(ns), freeary);
202 idr_destroy(&ns->ids[IPC_SEM_IDS].ipcs_idr); 200 idr_destroy(&ns->ids[IPC_SEM_IDS].ipcs_idr);
201 rhashtable_destroy(&ns->ids[IPC_SEM_IDS].key_ht);
203} 202}
204#endif 203#endif
205 204
206void __init sem_init(void) 205int __init sem_init(void)
207{ 206{
208 sem_init_ns(&init_ipc_ns); 207 const int err = sem_init_ns(&init_ipc_ns);
208
209 ipc_init_proc_interface("sysvipc/sem", 209 ipc_init_proc_interface("sysvipc/sem",
210 " key semid perms nsems uid gid cuid cgid otime ctime\n", 210 " key semid perms nsems uid gid cuid cgid otime ctime\n",
211 IPC_SEM_IDS, sysvipc_sem_proc_show); 211 IPC_SEM_IDS, sysvipc_sem_proc_show);
212 return err;
212} 213}
213 214
214/** 215/**
@@ -1642,7 +1643,7 @@ static inline int get_undo_list(struct sem_undo_list **undo_listp)
1642 if (undo_list == NULL) 1643 if (undo_list == NULL)
1643 return -ENOMEM; 1644 return -ENOMEM;
1644 spin_lock_init(&undo_list->lock); 1645 spin_lock_init(&undo_list->lock);
1645 atomic_set(&undo_list->refcnt, 1); 1646 refcount_set(&undo_list->refcnt, 1);
1646 INIT_LIST_HEAD(&undo_list->list_proc); 1647 INIT_LIST_HEAD(&undo_list->list_proc);
1647 1648
1648 current->sysvsem.undo_list = undo_list; 1649 current->sysvsem.undo_list = undo_list;
@@ -1786,7 +1787,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1786 if (nsops > ns->sc_semopm) 1787 if (nsops > ns->sc_semopm)
1787 return -E2BIG; 1788 return -E2BIG;
1788 if (nsops > SEMOPM_FAST) { 1789 if (nsops > SEMOPM_FAST) {
1789 sops = kmalloc(sizeof(*sops)*nsops, GFP_KERNEL); 1790 sops = kvmalloc(sizeof(*sops)*nsops, GFP_KERNEL);
1790 if (sops == NULL) 1791 if (sops == NULL)
1791 return -ENOMEM; 1792 return -ENOMEM;
1792 } 1793 }
@@ -2018,7 +2019,7 @@ out_unlock_free:
2018 rcu_read_unlock(); 2019 rcu_read_unlock();
2019out_free: 2020out_free:
2020 if (sops != fast_sops) 2021 if (sops != fast_sops)
2021 kfree(sops); 2022 kvfree(sops);
2022 return error; 2023 return error;
2023} 2024}
2024 2025
@@ -2041,7 +2042,7 @@ int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
2041 error = get_undo_list(&undo_list); 2042 error = get_undo_list(&undo_list);
2042 if (error) 2043 if (error)
2043 return error; 2044 return error;
2044 atomic_inc(&undo_list->refcnt); 2045 refcount_inc(&undo_list->refcnt);
2045 tsk->sysvsem.undo_list = undo_list; 2046 tsk->sysvsem.undo_list = undo_list;
2046 } else 2047 } else
2047 tsk->sysvsem.undo_list = NULL; 2048 tsk->sysvsem.undo_list = NULL;
@@ -2070,7 +2071,7 @@ void exit_sem(struct task_struct *tsk)
2070 return; 2071 return;
2071 tsk->sysvsem.undo_list = NULL; 2072 tsk->sysvsem.undo_list = NULL;
2072 2073
2073 if (!atomic_dec_and_test(&ulp->refcnt)) 2074 if (!refcount_dec_and_test(&ulp->refcnt))
2074 return; 2075 return;
2075 2076
2076 for (;;) { 2077 for (;;) {
diff --git a/ipc/shm.c b/ipc/shm.c
index 8828b4c3a190..8fc97beb5234 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -72,14 +72,14 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
72static int sysvipc_shm_proc_show(struct seq_file *s, void *it); 72static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73#endif 73#endif
74 74
75void shm_init_ns(struct ipc_namespace *ns) 75int shm_init_ns(struct ipc_namespace *ns)
76{ 76{
77 ns->shm_ctlmax = SHMMAX; 77 ns->shm_ctlmax = SHMMAX;
78 ns->shm_ctlall = SHMALL; 78 ns->shm_ctlall = SHMALL;
79 ns->shm_ctlmni = SHMMNI; 79 ns->shm_ctlmni = SHMMNI;
80 ns->shm_rmid_forced = 0; 80 ns->shm_rmid_forced = 0;
81 ns->shm_tot = 0; 81 ns->shm_tot = 0;
82 ipc_init_ids(&shm_ids(ns)); 82 return ipc_init_ids(&shm_ids(ns));
83} 83}
84 84
85/* 85/*
@@ -95,7 +95,7 @@ static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
95 if (shp->shm_nattch) { 95 if (shp->shm_nattch) {
96 shp->shm_perm.mode |= SHM_DEST; 96 shp->shm_perm.mode |= SHM_DEST;
97 /* Do not find it any more */ 97 /* Do not find it any more */
98 shp->shm_perm.key = IPC_PRIVATE; 98 ipc_set_key_private(&shm_ids(ns), &shp->shm_perm);
99 shm_unlock(shp); 99 shm_unlock(shp);
100 } else 100 } else
101 shm_destroy(ns, shp); 101 shm_destroy(ns, shp);
@@ -106,13 +106,15 @@ void shm_exit_ns(struct ipc_namespace *ns)
106{ 106{
107 free_ipcs(ns, &shm_ids(ns), do_shm_rmid); 107 free_ipcs(ns, &shm_ids(ns), do_shm_rmid);
108 idr_destroy(&ns->ids[IPC_SHM_IDS].ipcs_idr); 108 idr_destroy(&ns->ids[IPC_SHM_IDS].ipcs_idr);
109 rhashtable_destroy(&ns->ids[IPC_SHM_IDS].key_ht);
109} 110}
110#endif 111#endif
111 112
112static int __init ipc_ns_init(void) 113static int __init ipc_ns_init(void)
113{ 114{
114 shm_init_ns(&init_ipc_ns); 115 const int err = shm_init_ns(&init_ipc_ns);
115 return 0; 116 WARN(err, "ipc: sysv shm_init_ns failed: %d\n", err);
117 return err;
116} 118}
117 119
118pure_initcall(ipc_ns_init); 120pure_initcall(ipc_ns_init);
diff --git a/ipc/util.c b/ipc/util.c
index 1a2cb02467ab..78755873cc5b 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -83,27 +83,46 @@ struct ipc_proc_iface {
83 */ 83 */
84static int __init ipc_init(void) 84static int __init ipc_init(void)
85{ 85{
86 sem_init(); 86 int err_sem, err_msg;
87 msg_init(); 87
88 err_sem = sem_init();
89 WARN(err_sem, "ipc: sysv sem_init failed: %d\n", err_sem);
90 err_msg = msg_init();
91 WARN(err_msg, "ipc: sysv msg_init failed: %d\n", err_msg);
88 shm_init(); 92 shm_init();
89 return 0; 93
94 return err_msg ? err_msg : err_sem;
90} 95}
91device_initcall(ipc_init); 96device_initcall(ipc_init);
92 97
98static const struct rhashtable_params ipc_kht_params = {
99 .head_offset = offsetof(struct kern_ipc_perm, khtnode),
100 .key_offset = offsetof(struct kern_ipc_perm, key),
101 .key_len = FIELD_SIZEOF(struct kern_ipc_perm, key),
102 .locks_mul = 1,
103 .automatic_shrinking = true,
104};
105
93/** 106/**
94 * ipc_init_ids - initialise ipc identifiers 107 * ipc_init_ids - initialise ipc identifiers
95 * @ids: ipc identifier set 108 * @ids: ipc identifier set
96 * 109 *
97 * Set up the sequence range to use for the ipc identifier range (limited 110 * Set up the sequence range to use for the ipc identifier range (limited
98 * below IPCMNI) then initialise the ids idr. 111 * below IPCMNI) then initialise the keys hashtable and ids idr.
99 */ 112 */
100void ipc_init_ids(struct ipc_ids *ids) 113int ipc_init_ids(struct ipc_ids *ids)
101{ 114{
115 int err;
102 ids->in_use = 0; 116 ids->in_use = 0;
103 ids->seq = 0; 117 ids->seq = 0;
104 ids->next_id = -1; 118 ids->next_id = -1;
105 init_rwsem(&ids->rwsem); 119 init_rwsem(&ids->rwsem);
120 err = rhashtable_init(&ids->key_ht, &ipc_kht_params);
121 if (err)
122 return err;
106 idr_init(&ids->ipcs_idr); 123 idr_init(&ids->ipcs_idr);
124 ids->tables_initialized = true;
125 return 0;
107} 126}
108 127
109#ifdef CONFIG_PROC_FS 128#ifdef CONFIG_PROC_FS
@@ -147,28 +166,20 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
147 * Returns the locked pointer to the ipc structure if found or NULL 166 * Returns the locked pointer to the ipc structure if found or NULL
148 * otherwise. If key is found ipc points to the owning ipc structure 167 * otherwise. If key is found ipc points to the owning ipc structure
149 * 168 *
150 * Called with ipc_ids.rwsem held. 169 * Called with writer ipc_ids.rwsem held.
151 */ 170 */
152static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key) 171static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key)
153{ 172{
154 struct kern_ipc_perm *ipc; 173 struct kern_ipc_perm *ipcp = NULL;
155 int next_id;
156 int total;
157
158 for (total = 0, next_id = 0; total < ids->in_use; next_id++) {
159 ipc = idr_find(&ids->ipcs_idr, next_id);
160
161 if (ipc == NULL)
162 continue;
163 174
164 if (ipc->key != key) { 175 if (likely(ids->tables_initialized))
165 total++; 176 ipcp = rhashtable_lookup_fast(&ids->key_ht, &key,
166 continue; 177 ipc_kht_params);
167 }
168 178
179 if (ipcp) {
169 rcu_read_lock(); 180 rcu_read_lock();
170 ipc_lock_object(ipc); 181 ipc_lock_object(ipcp);
171 return ipc; 182 return ipcp;
172 } 183 }
173 184
174 return NULL; 185 return NULL;
@@ -221,18 +232,18 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size)
221{ 232{
222 kuid_t euid; 233 kuid_t euid;
223 kgid_t egid; 234 kgid_t egid;
224 int id; 235 int id, err;
225 int next_id = ids->next_id; 236 int next_id = ids->next_id;
226 237
227 if (size > IPCMNI) 238 if (size > IPCMNI)
228 size = IPCMNI; 239 size = IPCMNI;
229 240
230 if (ids->in_use >= size) 241 if (!ids->tables_initialized || ids->in_use >= size)
231 return -ENOSPC; 242 return -ENOSPC;
232 243
233 idr_preload(GFP_KERNEL); 244 idr_preload(GFP_KERNEL);
234 245
235 atomic_set(&new->refcount, 1); 246 refcount_set(&new->refcount, 1);
236 spin_lock_init(&new->lock); 247 spin_lock_init(&new->lock);
237 new->deleted = false; 248 new->deleted = false;
238 rcu_read_lock(); 249 rcu_read_lock();
@@ -246,6 +257,15 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size)
246 (next_id < 0) ? 0 : ipcid_to_idx(next_id), 0, 257 (next_id < 0) ? 0 : ipcid_to_idx(next_id), 0,
247 GFP_NOWAIT); 258 GFP_NOWAIT);
248 idr_preload_end(); 259 idr_preload_end();
260
261 if (id >= 0 && new->key != IPC_PRIVATE) {
262 err = rhashtable_insert_fast(&ids->key_ht, &new->khtnode,
263 ipc_kht_params);
264 if (err < 0) {
265 idr_remove(&ids->ipcs_idr, id);
266 id = err;
267 }
268 }
249 if (id < 0) { 269 if (id < 0) {
250 spin_unlock(&new->lock); 270 spin_unlock(&new->lock);
251 rcu_read_unlock(); 271 rcu_read_unlock();
@@ -377,6 +397,20 @@ static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
377 return err; 397 return err;
378} 398}
379 399
400/**
401 * ipc_kht_remove - remove an ipc from the key hashtable
402 * @ids: ipc identifier set
403 * @ipcp: ipc perm structure containing the key to remove
404 *
405 * ipc_ids.rwsem (as a writer) and the spinlock for this ID are held
406 * before this function is called, and remain locked on the exit.
407 */
408static void ipc_kht_remove(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
409{
410 if (ipcp->key != IPC_PRIVATE)
411 rhashtable_remove_fast(&ids->key_ht, &ipcp->khtnode,
412 ipc_kht_params);
413}
380 414
381/** 415/**
382 * ipc_rmid - remove an ipc identifier 416 * ipc_rmid - remove an ipc identifier
@@ -391,19 +425,34 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
391 int lid = ipcid_to_idx(ipcp->id); 425 int lid = ipcid_to_idx(ipcp->id);
392 426
393 idr_remove(&ids->ipcs_idr, lid); 427 idr_remove(&ids->ipcs_idr, lid);
428 ipc_kht_remove(ids, ipcp);
394 ids->in_use--; 429 ids->in_use--;
395 ipcp->deleted = true; 430 ipcp->deleted = true;
396} 431}
397 432
433/**
434 * ipc_set_key_private - switch the key of an existing ipc to IPC_PRIVATE
435 * @ids: ipc identifier set
436 * @ipcp: ipc perm structure containing the key to modify
437 *
438 * ipc_ids.rwsem (as a writer) and the spinlock for this ID are held
439 * before this function is called, and remain locked on the exit.
440 */
441void ipc_set_key_private(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
442{
443 ipc_kht_remove(ids, ipcp);
444 ipcp->key = IPC_PRIVATE;
445}
446
398int ipc_rcu_getref(struct kern_ipc_perm *ptr) 447int ipc_rcu_getref(struct kern_ipc_perm *ptr)
399{ 448{
400 return atomic_inc_not_zero(&ptr->refcount); 449 return refcount_inc_not_zero(&ptr->refcount);
401} 450}
402 451
403void ipc_rcu_putref(struct kern_ipc_perm *ptr, 452void ipc_rcu_putref(struct kern_ipc_perm *ptr,
404 void (*func)(struct rcu_head *head)) 453 void (*func)(struct rcu_head *head))
405{ 454{
406 if (!atomic_dec_and_test(&ptr->refcount)) 455 if (!refcount_dec_and_test(&ptr->refcount))
407 return; 456 return;
408 457
409 call_rcu(&ptr->rcu, func); 458 call_rcu(&ptr->rcu, func);
@@ -485,7 +534,7 @@ void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out)
485} 534}
486 535
487/** 536/**
488 * ipc_obtain_object 537 * ipc_obtain_object_idr
489 * @ids: ipc identifier set 538 * @ids: ipc identifier set
490 * @id: ipc id to look for 539 * @id: ipc id to look for
491 * 540 *
@@ -499,6 +548,9 @@ struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id)
499 struct kern_ipc_perm *out; 548 struct kern_ipc_perm *out;
500 int lid = ipcid_to_idx(id); 549 int lid = ipcid_to_idx(id);
501 550
551 if (unlikely(!ids->tables_initialized))
552 return ERR_PTR(-EINVAL);
553
502 out = idr_find(&ids->ipcs_idr, lid); 554 out = idr_find(&ids->ipcs_idr, lid);
503 if (!out) 555 if (!out)
504 return ERR_PTR(-EINVAL); 556 return ERR_PTR(-EINVAL);
diff --git a/ipc/util.h b/ipc/util.h
index c692010e6f0a..80c9f51c3f07 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -15,8 +15,8 @@
15 15
16#define SEQ_MULTIPLIER (IPCMNI) 16#define SEQ_MULTIPLIER (IPCMNI)
17 17
18void sem_init(void); 18int sem_init(void);
19void msg_init(void); 19int msg_init(void);
20void shm_init(void); 20void shm_init(void);
21 21
22struct ipc_namespace; 22struct ipc_namespace;
@@ -30,17 +30,17 @@ static inline void mq_put_mnt(struct ipc_namespace *ns) { }
30#endif 30#endif
31 31
32#ifdef CONFIG_SYSVIPC 32#ifdef CONFIG_SYSVIPC
33void sem_init_ns(struct ipc_namespace *ns); 33int sem_init_ns(struct ipc_namespace *ns);
34void msg_init_ns(struct ipc_namespace *ns); 34int msg_init_ns(struct ipc_namespace *ns);
35void shm_init_ns(struct ipc_namespace *ns); 35int shm_init_ns(struct ipc_namespace *ns);
36 36
37void sem_exit_ns(struct ipc_namespace *ns); 37void sem_exit_ns(struct ipc_namespace *ns);
38void msg_exit_ns(struct ipc_namespace *ns); 38void msg_exit_ns(struct ipc_namespace *ns);
39void shm_exit_ns(struct ipc_namespace *ns); 39void shm_exit_ns(struct ipc_namespace *ns);
40#else 40#else
41static inline void sem_init_ns(struct ipc_namespace *ns) { } 41static inline int sem_init_ns(struct ipc_namespace *ns) { return 0; }
42static inline void msg_init_ns(struct ipc_namespace *ns) { } 42static inline int msg_init_ns(struct ipc_namespace *ns) { return 0; }
43static inline void shm_init_ns(struct ipc_namespace *ns) { } 43static inline int shm_init_ns(struct ipc_namespace *ns) { return 0; }
44 44
45static inline void sem_exit_ns(struct ipc_namespace *ns) { } 45static inline void sem_exit_ns(struct ipc_namespace *ns) { }
46static inline void msg_exit_ns(struct ipc_namespace *ns) { } 46static inline void msg_exit_ns(struct ipc_namespace *ns) { }
@@ -79,7 +79,7 @@ struct ipc_ops {
79struct seq_file; 79struct seq_file;
80struct ipc_ids; 80struct ipc_ids;
81 81
82void ipc_init_ids(struct ipc_ids *); 82int ipc_init_ids(struct ipc_ids *);
83#ifdef CONFIG_PROC_FS 83#ifdef CONFIG_PROC_FS
84void __init ipc_init_proc_interface(const char *path, const char *header, 84void __init ipc_init_proc_interface(const char *path, const char *header,
85 int ids, int (*show)(struct seq_file *, void *)); 85 int ids, int (*show)(struct seq_file *, void *));
@@ -104,6 +104,9 @@ int ipc_get_maxid(struct ipc_ids *);
104/* must be called with both locks acquired. */ 104/* must be called with both locks acquired. */
105void ipc_rmid(struct ipc_ids *, struct kern_ipc_perm *); 105void ipc_rmid(struct ipc_ids *, struct kern_ipc_perm *);
106 106
107/* must be called with both locks acquired. */
108void ipc_set_key_private(struct ipc_ids *, struct kern_ipc_perm *);
109
107/* must be called with ipcp locked */ 110/* must be called with ipcp locked */
108int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flg); 111int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flg);
109 112
diff --git a/kernel/Makefile b/kernel/Makefile
index 9c323a6daa46..ed470aac53da 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -5,12 +5,13 @@
5obj-y = fork.o exec_domain.o panic.o \ 5obj-y = fork.o exec_domain.o panic.o \
6 cpu.o exit.o softirq.o resource.o \ 6 cpu.o exit.o softirq.o resource.o \
7 sysctl.o sysctl_binary.o capability.o ptrace.o user.o \ 7 sysctl.o sysctl_binary.o capability.o ptrace.o user.o \
8 signal.o sys.o kmod.o workqueue.o pid.o task_work.o \ 8 signal.o sys.o umh.o workqueue.o pid.o task_work.o \
9 extable.o params.o \ 9 extable.o params.o \
10 kthread.o sys_ni.o nsproxy.o \ 10 kthread.o sys_ni.o nsproxy.o \
11 notifier.o ksysfs.o cred.o reboot.o \ 11 notifier.o ksysfs.o cred.o reboot.o \
12 async.o range.o smpboot.o ucount.o 12 async.o range.o smpboot.o ucount.o
13 13
14obj-$(CONFIG_MODULES) += kmod.o
14obj-$(CONFIG_MULTIUSER) += groups.o 15obj-$(CONFIG_MULTIUSER) += groups.o
15 16
16ifdef CONFIG_FUNCTION_TRACER 17ifdef CONFIG_FUNCTION_TRACER
diff --git a/kernel/fork.c b/kernel/fork.c
index 24a4c0be80d5..6f1b0af00bda 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -37,6 +37,7 @@
37#include <linux/binfmts.h> 37#include <linux/binfmts.h>
38#include <linux/mman.h> 38#include <linux/mman.h>
39#include <linux/mmu_notifier.h> 39#include <linux/mmu_notifier.h>
40#include <linux/hmm.h>
40#include <linux/fs.h> 41#include <linux/fs.h>
41#include <linux/mm.h> 42#include <linux/mm.h>
42#include <linux/vmacache.h> 43#include <linux/vmacache.h>
@@ -824,6 +825,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
824 mm_init_owner(mm, p); 825 mm_init_owner(mm, p);
825 RCU_INIT_POINTER(mm->exe_file, NULL); 826 RCU_INIT_POINTER(mm->exe_file, NULL);
826 mmu_notifier_mm_init(mm); 827 mmu_notifier_mm_init(mm);
828 hmm_mm_init(mm);
827 init_tlb_flush_pending(mm); 829 init_tlb_flush_pending(mm);
828#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS 830#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
829 mm->pmd_huge_pte = NULL; 831 mm->pmd_huge_pte = NULL;
@@ -903,6 +905,7 @@ void __mmdrop(struct mm_struct *mm)
903 BUG_ON(mm == &init_mm); 905 BUG_ON(mm == &init_mm);
904 mm_free_pgd(mm); 906 mm_free_pgd(mm);
905 destroy_context(mm); 907 destroy_context(mm);
908 hmm_mm_destroy(mm);
906 mmu_notifier_mm_destroy(mm); 909 mmu_notifier_mm_destroy(mm);
907 check_mm(mm); 910 check_mm(mm);
908 put_user_ns(mm->user_ns); 911 put_user_ns(mm->user_ns);
@@ -1459,8 +1462,7 @@ static void rt_mutex_init_task(struct task_struct *p)
1459{ 1462{
1460 raw_spin_lock_init(&p->pi_lock); 1463 raw_spin_lock_init(&p->pi_lock);
1461#ifdef CONFIG_RT_MUTEXES 1464#ifdef CONFIG_RT_MUTEXES
1462 p->pi_waiters = RB_ROOT; 1465 p->pi_waiters = RB_ROOT_CACHED;
1463 p->pi_waiters_leftmost = NULL;
1464 p->pi_top_task = NULL; 1466 p->pi_top_task = NULL;
1465 p->pi_blocked_on = NULL; 1467 p->pi_blocked_on = NULL;
1466#endif 1468#endif
diff --git a/kernel/kcov.c b/kernel/kcov.c
index cd771993f96f..3f693a0f6f3e 100644
--- a/kernel/kcov.c
+++ b/kernel/kcov.c
@@ -270,6 +270,7 @@ static long kcov_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
270static const struct file_operations kcov_fops = { 270static const struct file_operations kcov_fops = {
271 .open = kcov_open, 271 .open = kcov_open,
272 .unlocked_ioctl = kcov_ioctl, 272 .unlocked_ioctl = kcov_ioctl,
273 .compat_ioctl = kcov_ioctl,
273 .mmap = kcov_mmap, 274 .mmap = kcov_mmap,
274 .release = kcov_close, 275 .release = kcov_close,
275}; 276};
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 2f37acde640b..bc6addd9152b 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -1,23 +1,6 @@
1/* 1/*
2 kmod, the new module loader (replaces kerneld) 2 * kmod - the kernel module loader
3 Kirk Petersen 3 */
4
5 Reorganized not to be a daemon by Adam Richter, with guidance
6 from Greg Zornetzer.
7
8 Modified to avoid chroot and file sharing problems.
9 Mikael Pettersson
10
11 Limit the concurrent number of kmod modprobes to catch loops from
12 "modprobe needs a service that is in a module".
13 Keith Owens <kaos@ocs.com.au> December 1999
14
15 Unblock all signals when we exec a usermode process.
16 Shuu Yamaguchi <shuu@wondernetworkresources.com> December 2000
17
18 call_usermodehelper wait flag, and remove exec_usermodehelper.
19 Rusty Russell <rusty@rustcorp.com.au> Jan 2003
20*/
21#include <linux/module.h> 4#include <linux/module.h>
22#include <linux/sched.h> 5#include <linux/sched.h>
23#include <linux/sched/task.h> 6#include <linux/sched/task.h>
@@ -45,15 +28,6 @@
45 28
46#include <trace/events/module.h> 29#include <trace/events/module.h>
47 30
48#define CAP_BSET (void *)1
49#define CAP_PI (void *)2
50
51static kernel_cap_t usermodehelper_bset = CAP_FULL_SET;
52static kernel_cap_t usermodehelper_inheritable = CAP_FULL_SET;
53static DEFINE_SPINLOCK(umh_sysctl_lock);
54static DECLARE_RWSEM(umhelper_sem);
55
56#ifdef CONFIG_MODULES
57/* 31/*
58 * Assuming: 32 * Assuming:
59 * 33 *
@@ -202,536 +176,3 @@ int __request_module(bool wait, const char *fmt, ...)
202 return ret; 176 return ret;
203} 177}
204EXPORT_SYMBOL(__request_module); 178EXPORT_SYMBOL(__request_module);
205
206#endif /* CONFIG_MODULES */
207
208static void call_usermodehelper_freeinfo(struct subprocess_info *info)
209{
210 if (info->cleanup)
211 (*info->cleanup)(info);
212 kfree(info);
213}
214
215static void umh_complete(struct subprocess_info *sub_info)
216{
217 struct completion *comp = xchg(&sub_info->complete, NULL);
218 /*
219 * See call_usermodehelper_exec(). If xchg() returns NULL
220 * we own sub_info, the UMH_KILLABLE caller has gone away
221 * or the caller used UMH_NO_WAIT.
222 */
223 if (comp)
224 complete(comp);
225 else
226 call_usermodehelper_freeinfo(sub_info);
227}
228
229/*
230 * This is the task which runs the usermode application
231 */
232static int call_usermodehelper_exec_async(void *data)
233{
234 struct subprocess_info *sub_info = data;
235 struct cred *new;
236 int retval;
237
238 spin_lock_irq(&current->sighand->siglock);
239 flush_signal_handlers(current, 1);
240 spin_unlock_irq(&current->sighand->siglock);
241
242 /*
243 * Our parent (unbound workqueue) runs with elevated scheduling
244 * priority. Avoid propagating that into the userspace child.
245 */
246 set_user_nice(current, 0);
247
248 retval = -ENOMEM;
249 new = prepare_kernel_cred(current);
250 if (!new)
251 goto out;
252
253 spin_lock(&umh_sysctl_lock);
254 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset);
255 new->cap_inheritable = cap_intersect(usermodehelper_inheritable,
256 new->cap_inheritable);
257 spin_unlock(&umh_sysctl_lock);
258
259 if (sub_info->init) {
260 retval = sub_info->init(sub_info, new);
261 if (retval) {
262 abort_creds(new);
263 goto out;
264 }
265 }
266
267 commit_creds(new);
268
269 retval = do_execve(getname_kernel(sub_info->path),
270 (const char __user *const __user *)sub_info->argv,
271 (const char __user *const __user *)sub_info->envp);
272out:
273 sub_info->retval = retval;
274 /*
275 * call_usermodehelper_exec_sync() will call umh_complete
276 * if UHM_WAIT_PROC.
277 */
278 if (!(sub_info->wait & UMH_WAIT_PROC))
279 umh_complete(sub_info);
280 if (!retval)
281 return 0;
282 do_exit(0);
283}
284
285/* Handles UMH_WAIT_PROC. */
286static void call_usermodehelper_exec_sync(struct subprocess_info *sub_info)
287{
288 pid_t pid;
289
290 /* If SIGCLD is ignored sys_wait4 won't populate the status. */
291 kernel_sigaction(SIGCHLD, SIG_DFL);
292 pid = kernel_thread(call_usermodehelper_exec_async, sub_info, SIGCHLD);
293 if (pid < 0) {
294 sub_info->retval = pid;
295 } else {
296 int ret = -ECHILD;
297 /*
298 * Normally it is bogus to call wait4() from in-kernel because
299 * wait4() wants to write the exit code to a userspace address.
300 * But call_usermodehelper_exec_sync() always runs as kernel
301 * thread (workqueue) and put_user() to a kernel address works
302 * OK for kernel threads, due to their having an mm_segment_t
303 * which spans the entire address space.
304 *
305 * Thus the __user pointer cast is valid here.
306 */
307 sys_wait4(pid, (int __user *)&ret, 0, NULL);
308
309 /*
310 * If ret is 0, either call_usermodehelper_exec_async failed and
311 * the real error code is already in sub_info->retval or
312 * sub_info->retval is 0 anyway, so don't mess with it then.
313 */
314 if (ret)
315 sub_info->retval = ret;
316 }
317
318 /* Restore default kernel sig handler */
319 kernel_sigaction(SIGCHLD, SIG_IGN);
320
321 umh_complete(sub_info);
322}
323
324/*
325 * We need to create the usermodehelper kernel thread from a task that is affine
326 * to an optimized set of CPUs (or nohz housekeeping ones) such that they
327 * inherit a widest affinity irrespective of call_usermodehelper() callers with
328 * possibly reduced affinity (eg: per-cpu workqueues). We don't want
329 * usermodehelper targets to contend a busy CPU.
330 *
331 * Unbound workqueues provide such wide affinity and allow to block on
332 * UMH_WAIT_PROC requests without blocking pending request (up to some limit).
333 *
334 * Besides, workqueues provide the privilege level that caller might not have
335 * to perform the usermodehelper request.
336 *
337 */
338static void call_usermodehelper_exec_work(struct work_struct *work)
339{
340 struct subprocess_info *sub_info =
341 container_of(work, struct subprocess_info, work);
342
343 if (sub_info->wait & UMH_WAIT_PROC) {
344 call_usermodehelper_exec_sync(sub_info);
345 } else {
346 pid_t pid;
347 /*
348 * Use CLONE_PARENT to reparent it to kthreadd; we do not
349 * want to pollute current->children, and we need a parent
350 * that always ignores SIGCHLD to ensure auto-reaping.
351 */
352 pid = kernel_thread(call_usermodehelper_exec_async, sub_info,
353 CLONE_PARENT | SIGCHLD);
354 if (pid < 0) {
355 sub_info->retval = pid;
356 umh_complete(sub_info);
357 }
358 }
359}
360
361/*
362 * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
363 * (used for preventing user land processes from being created after the user
364 * land has been frozen during a system-wide hibernation or suspend operation).
365 * Should always be manipulated under umhelper_sem acquired for write.
366 */
367static enum umh_disable_depth usermodehelper_disabled = UMH_DISABLED;
368
369/* Number of helpers running */
370static atomic_t running_helpers = ATOMIC_INIT(0);
371
372/*
373 * Wait queue head used by usermodehelper_disable() to wait for all running
374 * helpers to finish.
375 */
376static DECLARE_WAIT_QUEUE_HEAD(running_helpers_waitq);
377
378/*
379 * Used by usermodehelper_read_lock_wait() to wait for usermodehelper_disabled
380 * to become 'false'.
381 */
382static DECLARE_WAIT_QUEUE_HEAD(usermodehelper_disabled_waitq);
383
384/*
385 * Time to wait for running_helpers to become zero before the setting of
386 * usermodehelper_disabled in usermodehelper_disable() fails
387 */
388#define RUNNING_HELPERS_TIMEOUT (5 * HZ)
389
390int usermodehelper_read_trylock(void)
391{
392 DEFINE_WAIT(wait);
393 int ret = 0;
394
395 down_read(&umhelper_sem);
396 for (;;) {
397 prepare_to_wait(&usermodehelper_disabled_waitq, &wait,
398 TASK_INTERRUPTIBLE);
399 if (!usermodehelper_disabled)
400 break;
401
402 if (usermodehelper_disabled == UMH_DISABLED)
403 ret = -EAGAIN;
404
405 up_read(&umhelper_sem);
406
407 if (ret)
408 break;
409
410 schedule();
411 try_to_freeze();
412
413 down_read(&umhelper_sem);
414 }
415 finish_wait(&usermodehelper_disabled_waitq, &wait);
416 return ret;
417}
418EXPORT_SYMBOL_GPL(usermodehelper_read_trylock);
419
420long usermodehelper_read_lock_wait(long timeout)
421{
422 DEFINE_WAIT(wait);
423
424 if (timeout < 0)
425 return -EINVAL;
426
427 down_read(&umhelper_sem);
428 for (;;) {
429 prepare_to_wait(&usermodehelper_disabled_waitq, &wait,
430 TASK_UNINTERRUPTIBLE);
431 if (!usermodehelper_disabled)
432 break;
433
434 up_read(&umhelper_sem);
435
436 timeout = schedule_timeout(timeout);
437 if (!timeout)
438 break;
439
440 down_read(&umhelper_sem);
441 }
442 finish_wait(&usermodehelper_disabled_waitq, &wait);
443 return timeout;
444}
445EXPORT_SYMBOL_GPL(usermodehelper_read_lock_wait);
446
447void usermodehelper_read_unlock(void)
448{
449 up_read(&umhelper_sem);
450}
451EXPORT_SYMBOL_GPL(usermodehelper_read_unlock);
452
453/**
454 * __usermodehelper_set_disable_depth - Modify usermodehelper_disabled.
455 * @depth: New value to assign to usermodehelper_disabled.
456 *
457 * Change the value of usermodehelper_disabled (under umhelper_sem locked for
458 * writing) and wakeup tasks waiting for it to change.
459 */
460void __usermodehelper_set_disable_depth(enum umh_disable_depth depth)
461{
462 down_write(&umhelper_sem);
463 usermodehelper_disabled = depth;
464 wake_up(&usermodehelper_disabled_waitq);
465 up_write(&umhelper_sem);
466}
467
468/**
469 * __usermodehelper_disable - Prevent new helpers from being started.
470 * @depth: New value to assign to usermodehelper_disabled.
471 *
472 * Set usermodehelper_disabled to @depth and wait for running helpers to exit.
473 */
474int __usermodehelper_disable(enum umh_disable_depth depth)
475{
476 long retval;
477
478 if (!depth)
479 return -EINVAL;
480
481 down_write(&umhelper_sem);
482 usermodehelper_disabled = depth;
483 up_write(&umhelper_sem);
484
485 /*
486 * From now on call_usermodehelper_exec() won't start any new
487 * helpers, so it is sufficient if running_helpers turns out to
488 * be zero at one point (it may be increased later, but that
489 * doesn't matter).
490 */
491 retval = wait_event_timeout(running_helpers_waitq,
492 atomic_read(&running_helpers) == 0,
493 RUNNING_HELPERS_TIMEOUT);
494 if (retval)
495 return 0;
496
497 __usermodehelper_set_disable_depth(UMH_ENABLED);
498 return -EAGAIN;
499}
500
501static void helper_lock(void)
502{
503 atomic_inc(&running_helpers);
504 smp_mb__after_atomic();
505}
506
507static void helper_unlock(void)
508{
509 if (atomic_dec_and_test(&running_helpers))
510 wake_up(&running_helpers_waitq);
511}
512
513/**
514 * call_usermodehelper_setup - prepare to call a usermode helper
515 * @path: path to usermode executable
516 * @argv: arg vector for process
517 * @envp: environment for process
518 * @gfp_mask: gfp mask for memory allocation
519 * @cleanup: a cleanup function
520 * @init: an init function
521 * @data: arbitrary context sensitive data
522 *
523 * Returns either %NULL on allocation failure, or a subprocess_info
524 * structure. This should be passed to call_usermodehelper_exec to
525 * exec the process and free the structure.
526 *
527 * The init function is used to customize the helper process prior to
528 * exec. A non-zero return code causes the process to error out, exit,
529 * and return the failure to the calling process
530 *
531 * The cleanup function is just before ethe subprocess_info is about to
532 * be freed. This can be used for freeing the argv and envp. The
533 * Function must be runnable in either a process context or the
534 * context in which call_usermodehelper_exec is called.
535 */
536struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
537 char **envp, gfp_t gfp_mask,
538 int (*init)(struct subprocess_info *info, struct cred *new),
539 void (*cleanup)(struct subprocess_info *info),
540 void *data)
541{
542 struct subprocess_info *sub_info;
543 sub_info = kzalloc(sizeof(struct subprocess_info), gfp_mask);
544 if (!sub_info)
545 goto out;
546
547 INIT_WORK(&sub_info->work, call_usermodehelper_exec_work);
548
549#ifdef CONFIG_STATIC_USERMODEHELPER
550 sub_info->path = CONFIG_STATIC_USERMODEHELPER_PATH;
551#else
552 sub_info->path = path;
553#endif
554 sub_info->argv = argv;
555 sub_info->envp = envp;
556
557 sub_info->cleanup = cleanup;
558 sub_info->init = init;
559 sub_info->data = data;
560 out:
561 return sub_info;
562}
563EXPORT_SYMBOL(call_usermodehelper_setup);
564
565/**
566 * call_usermodehelper_exec - start a usermode application
567 * @sub_info: information about the subprocessa
568 * @wait: wait for the application to finish and return status.
569 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
570 * when the program couldn't be exec'ed. This makes it safe to call
571 * from interrupt context.
572 *
573 * Runs a user-space application. The application is started
574 * asynchronously if wait is not set, and runs as a child of system workqueues.
575 * (ie. it runs with full root capabilities and optimized affinity).
576 */
577int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
578{
579 DECLARE_COMPLETION_ONSTACK(done);
580 int retval = 0;
581
582 if (!sub_info->path) {
583 call_usermodehelper_freeinfo(sub_info);
584 return -EINVAL;
585 }
586 helper_lock();
587 if (usermodehelper_disabled) {
588 retval = -EBUSY;
589 goto out;
590 }
591
592 /*
593 * If there is no binary for us to call, then just return and get out of
594 * here. This allows us to set STATIC_USERMODEHELPER_PATH to "" and
595 * disable all call_usermodehelper() calls.
596 */
597 if (strlen(sub_info->path) == 0)
598 goto out;
599
600 /*
601 * Set the completion pointer only if there is a waiter.
602 * This makes it possible to use umh_complete to free
603 * the data structure in case of UMH_NO_WAIT.
604 */
605 sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done;
606 sub_info->wait = wait;
607
608 queue_work(system_unbound_wq, &sub_info->work);
609 if (wait == UMH_NO_WAIT) /* task has freed sub_info */
610 goto unlock;
611
612 if (wait & UMH_KILLABLE) {
613 retval = wait_for_completion_killable(&done);
614 if (!retval)
615 goto wait_done;
616
617 /* umh_complete() will see NULL and free sub_info */
618 if (xchg(&sub_info->complete, NULL))
619 goto unlock;
620 /* fallthrough, umh_complete() was already called */
621 }
622
623 wait_for_completion(&done);
624wait_done:
625 retval = sub_info->retval;
626out:
627 call_usermodehelper_freeinfo(sub_info);
628unlock:
629 helper_unlock();
630 return retval;
631}
632EXPORT_SYMBOL(call_usermodehelper_exec);
633
634/**
635 * call_usermodehelper() - prepare and start a usermode application
636 * @path: path to usermode executable
637 * @argv: arg vector for process
638 * @envp: environment for process
639 * @wait: wait for the application to finish and return status.
640 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
641 * when the program couldn't be exec'ed. This makes it safe to call
642 * from interrupt context.
643 *
644 * This function is the equivalent to use call_usermodehelper_setup() and
645 * call_usermodehelper_exec().
646 */
647int call_usermodehelper(const char *path, char **argv, char **envp, int wait)
648{
649 struct subprocess_info *info;
650 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
651
652 info = call_usermodehelper_setup(path, argv, envp, gfp_mask,
653 NULL, NULL, NULL);
654 if (info == NULL)
655 return -ENOMEM;
656
657 return call_usermodehelper_exec(info, wait);
658}
659EXPORT_SYMBOL(call_usermodehelper);
660
661static int proc_cap_handler(struct ctl_table *table, int write,
662 void __user *buffer, size_t *lenp, loff_t *ppos)
663{
664 struct ctl_table t;
665 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
666 kernel_cap_t new_cap;
667 int err, i;
668
669 if (write && (!capable(CAP_SETPCAP) ||
670 !capable(CAP_SYS_MODULE)))
671 return -EPERM;
672
673 /*
674 * convert from the global kernel_cap_t to the ulong array to print to
675 * userspace if this is a read.
676 */
677 spin_lock(&umh_sysctl_lock);
678 for (i = 0; i < _KERNEL_CAPABILITY_U32S; i++) {
679 if (table->data == CAP_BSET)
680 cap_array[i] = usermodehelper_bset.cap[i];
681 else if (table->data == CAP_PI)
682 cap_array[i] = usermodehelper_inheritable.cap[i];
683 else
684 BUG();
685 }
686 spin_unlock(&umh_sysctl_lock);
687
688 t = *table;
689 t.data = &cap_array;
690
691 /*
692 * actually read or write and array of ulongs from userspace. Remember
693 * these are least significant 32 bits first
694 */
695 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
696 if (err < 0)
697 return err;
698
699 /*
700 * convert from the sysctl array of ulongs to the kernel_cap_t
701 * internal representation
702 */
703 for (i = 0; i < _KERNEL_CAPABILITY_U32S; i++)
704 new_cap.cap[i] = cap_array[i];
705
706 /*
707 * Drop everything not in the new_cap (but don't add things)
708 */
709 spin_lock(&umh_sysctl_lock);
710 if (write) {
711 if (table->data == CAP_BSET)
712 usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
713 if (table->data == CAP_PI)
714 usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
715 }
716 spin_unlock(&umh_sysctl_lock);
717
718 return 0;
719}
720
721struct ctl_table usermodehelper_table[] = {
722 {
723 .procname = "bset",
724 .data = CAP_BSET,
725 .maxlen = _KERNEL_CAPABILITY_U32S * sizeof(unsigned long),
726 .mode = 0600,
727 .proc_handler = proc_cap_handler,
728 },
729 {
730 .procname = "inheritable",
731 .data = CAP_PI,
732 .maxlen = _KERNEL_CAPABILITY_U32S * sizeof(unsigned long),
733 .mode = 0600,
734 .proc_handler = proc_cap_handler,
735 },
736 { }
737};
diff --git a/kernel/locking/rtmutex-debug.c b/kernel/locking/rtmutex-debug.c
index ac35e648b0e5..f4a74e78d467 100644
--- a/kernel/locking/rtmutex-debug.c
+++ b/kernel/locking/rtmutex-debug.c
@@ -58,7 +58,7 @@ static void printk_lock(struct rt_mutex *lock, int print_owner)
58 58
59void rt_mutex_debug_task_free(struct task_struct *task) 59void rt_mutex_debug_task_free(struct task_struct *task)
60{ 60{
61 DEBUG_LOCKS_WARN_ON(!RB_EMPTY_ROOT(&task->pi_waiters)); 61 DEBUG_LOCKS_WARN_ON(!RB_EMPTY_ROOT(&task->pi_waiters.rb_root));
62 DEBUG_LOCKS_WARN_ON(task->pi_blocked_on); 62 DEBUG_LOCKS_WARN_ON(task->pi_blocked_on);
63} 63}
64 64
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 649dc9d3951a..6f3dba6e4e9e 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -271,10 +271,10 @@ rt_mutex_waiter_equal(struct rt_mutex_waiter *left,
271static void 271static void
272rt_mutex_enqueue(struct rt_mutex *lock, struct rt_mutex_waiter *waiter) 272rt_mutex_enqueue(struct rt_mutex *lock, struct rt_mutex_waiter *waiter)
273{ 273{
274 struct rb_node **link = &lock->waiters.rb_node; 274 struct rb_node **link = &lock->waiters.rb_root.rb_node;
275 struct rb_node *parent = NULL; 275 struct rb_node *parent = NULL;
276 struct rt_mutex_waiter *entry; 276 struct rt_mutex_waiter *entry;
277 int leftmost = 1; 277 bool leftmost = true;
278 278
279 while (*link) { 279 while (*link) {
280 parent = *link; 280 parent = *link;
@@ -283,15 +283,12 @@ rt_mutex_enqueue(struct rt_mutex *lock, struct rt_mutex_waiter *waiter)
283 link = &parent->rb_left; 283 link = &parent->rb_left;
284 } else { 284 } else {
285 link = &parent->rb_right; 285 link = &parent->rb_right;
286 leftmost = 0; 286 leftmost = false;
287 } 287 }
288 } 288 }
289 289
290 if (leftmost)
291 lock->waiters_leftmost = &waiter->tree_entry;
292
293 rb_link_node(&waiter->tree_entry, parent, link); 290 rb_link_node(&waiter->tree_entry, parent, link);
294 rb_insert_color(&waiter->tree_entry, &lock->waiters); 291 rb_insert_color_cached(&waiter->tree_entry, &lock->waiters, leftmost);
295} 292}
296 293
297static void 294static void
@@ -300,20 +297,17 @@ rt_mutex_dequeue(struct rt_mutex *lock, struct rt_mutex_waiter *waiter)
300 if (RB_EMPTY_NODE(&waiter->tree_entry)) 297 if (RB_EMPTY_NODE(&waiter->tree_entry))
301 return; 298 return;
302 299
303 if (lock->waiters_leftmost == &waiter->tree_entry) 300 rb_erase_cached(&waiter->tree_entry, &lock->waiters);
304 lock->waiters_leftmost = rb_next(&waiter->tree_entry);
305
306 rb_erase(&waiter->tree_entry, &lock->waiters);
307 RB_CLEAR_NODE(&waiter->tree_entry); 301 RB_CLEAR_NODE(&waiter->tree_entry);
308} 302}
309 303
310static void 304static void
311rt_mutex_enqueue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter) 305rt_mutex_enqueue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter)
312{ 306{
313 struct rb_node **link = &task->pi_waiters.rb_node; 307 struct rb_node **link = &task->pi_waiters.rb_root.rb_node;
314 struct rb_node *parent = NULL; 308 struct rb_node *parent = NULL;
315 struct rt_mutex_waiter *entry; 309 struct rt_mutex_waiter *entry;
316 int leftmost = 1; 310 bool leftmost = true;
317 311
318 while (*link) { 312 while (*link) {
319 parent = *link; 313 parent = *link;
@@ -322,15 +316,12 @@ rt_mutex_enqueue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter)
322 link = &parent->rb_left; 316 link = &parent->rb_left;
323 } else { 317 } else {
324 link = &parent->rb_right; 318 link = &parent->rb_right;
325 leftmost = 0; 319 leftmost = false;
326 } 320 }
327 } 321 }
328 322
329 if (leftmost)
330 task->pi_waiters_leftmost = &waiter->pi_tree_entry;
331
332 rb_link_node(&waiter->pi_tree_entry, parent, link); 323 rb_link_node(&waiter->pi_tree_entry, parent, link);
333 rb_insert_color(&waiter->pi_tree_entry, &task->pi_waiters); 324 rb_insert_color_cached(&waiter->pi_tree_entry, &task->pi_waiters, leftmost);
334} 325}
335 326
336static void 327static void
@@ -339,10 +330,7 @@ rt_mutex_dequeue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter)
339 if (RB_EMPTY_NODE(&waiter->pi_tree_entry)) 330 if (RB_EMPTY_NODE(&waiter->pi_tree_entry))
340 return; 331 return;
341 332
342 if (task->pi_waiters_leftmost == &waiter->pi_tree_entry) 333 rb_erase_cached(&waiter->pi_tree_entry, &task->pi_waiters);
343 task->pi_waiters_leftmost = rb_next(&waiter->pi_tree_entry);
344
345 rb_erase(&waiter->pi_tree_entry, &task->pi_waiters);
346 RB_CLEAR_NODE(&waiter->pi_tree_entry); 334 RB_CLEAR_NODE(&waiter->pi_tree_entry);
347} 335}
348 336
@@ -1657,8 +1645,7 @@ void __rt_mutex_init(struct rt_mutex *lock, const char *name,
1657{ 1645{
1658 lock->owner = NULL; 1646 lock->owner = NULL;
1659 raw_spin_lock_init(&lock->wait_lock); 1647 raw_spin_lock_init(&lock->wait_lock);
1660 lock->waiters = RB_ROOT; 1648 lock->waiters = RB_ROOT_CACHED;
1661 lock->waiters_leftmost = NULL;
1662 1649
1663 if (name && key) 1650 if (name && key)
1664 debug_rt_mutex_init(lock, name, key); 1651 debug_rt_mutex_init(lock, name, key);
diff --git a/kernel/locking/rtmutex_common.h b/kernel/locking/rtmutex_common.h
index 8d039b928d61..7453be0485a5 100644
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -45,7 +45,7 @@ struct rt_mutex_waiter {
45 45
46static inline int rt_mutex_has_waiters(struct rt_mutex *lock) 46static inline int rt_mutex_has_waiters(struct rt_mutex *lock)
47{ 47{
48 return !RB_EMPTY_ROOT(&lock->waiters); 48 return !RB_EMPTY_ROOT(&lock->waiters.rb_root);
49} 49}
50 50
51static inline struct rt_mutex_waiter * 51static inline struct rt_mutex_waiter *
@@ -53,8 +53,8 @@ rt_mutex_top_waiter(struct rt_mutex *lock)
53{ 53{
54 struct rt_mutex_waiter *w; 54 struct rt_mutex_waiter *w;
55 55
56 w = rb_entry(lock->waiters_leftmost, struct rt_mutex_waiter, 56 w = rb_entry(lock->waiters.rb_leftmost,
57 tree_entry); 57 struct rt_mutex_waiter, tree_entry);
58 BUG_ON(w->lock != lock); 58 BUG_ON(w->lock != lock);
59 59
60 return w; 60 return w;
@@ -62,14 +62,14 @@ rt_mutex_top_waiter(struct rt_mutex *lock)
62 62
63static inline int task_has_pi_waiters(struct task_struct *p) 63static inline int task_has_pi_waiters(struct task_struct *p)
64{ 64{
65 return !RB_EMPTY_ROOT(&p->pi_waiters); 65 return !RB_EMPTY_ROOT(&p->pi_waiters.rb_root);
66} 66}
67 67
68static inline struct rt_mutex_waiter * 68static inline struct rt_mutex_waiter *
69task_top_pi_waiter(struct task_struct *p) 69task_top_pi_waiter(struct task_struct *p)
70{ 70{
71 return rb_entry(p->pi_waiters_leftmost, struct rt_mutex_waiter, 71 return rb_entry(p->pi_waiters.rb_leftmost,
72 pi_tree_entry); 72 struct rt_mutex_waiter, pi_tree_entry);
73} 73}
74 74
75#else 75#else
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 066e73c2fcc9..6bcbfbf1a8fd 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -11,13 +11,14 @@
11 * General Public License for more details. 11 * General Public License for more details.
12 */ 12 */
13#include <linux/radix-tree.h> 13#include <linux/radix-tree.h>
14#include <linux/memremap.h>
15#include <linux/device.h> 14#include <linux/device.h>
16#include <linux/types.h> 15#include <linux/types.h>
17#include <linux/pfn_t.h> 16#include <linux/pfn_t.h>
18#include <linux/io.h> 17#include <linux/io.h>
19#include <linux/mm.h> 18#include <linux/mm.h>
20#include <linux/memory_hotplug.h> 19#include <linux/memory_hotplug.h>
20#include <linux/swap.h>
21#include <linux/swapops.h>
21 22
22#ifndef ioremap_cache 23#ifndef ioremap_cache
23/* temporary while we convert existing ioremap_cache users to memremap */ 24/* temporary while we convert existing ioremap_cache users to memremap */
@@ -219,6 +220,34 @@ static unsigned long order_at(struct resource *res, unsigned long pgoff)
219 for (pgoff = 0, order = order_at((res), pgoff); order < ULONG_MAX; \ 220 for (pgoff = 0, order = order_at((res), pgoff); order < ULONG_MAX; \
220 pgoff += 1UL << order, order = order_at((res), pgoff)) 221 pgoff += 1UL << order, order = order_at((res), pgoff))
221 222
223#if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
224int device_private_entry_fault(struct vm_area_struct *vma,
225 unsigned long addr,
226 swp_entry_t entry,
227 unsigned int flags,
228 pmd_t *pmdp)
229{
230 struct page *page = device_private_entry_to_page(entry);
231
232 /*
233 * The page_fault() callback must migrate page back to system memory
234 * so that CPU can access it. This might fail for various reasons
235 * (device issue, device was unsafely unplugged, ...). When such
236 * error conditions happen, the callback must return VM_FAULT_SIGBUS.
237 *
238 * Note that because memory cgroup charges are accounted to the device
239 * memory, this should never fail because of memory restrictions (but
240 * allocation of regular system page might still fail because we are
241 * out of memory).
242 *
243 * There is a more in-depth description of what that callback can and
244 * cannot do, in include/linux/memremap.h
245 */
246 return page->pgmap->page_fault(vma, addr, page, flags, pmdp);
247}
248EXPORT_SYMBOL(device_private_entry_fault);
249#endif /* CONFIG_DEVICE_PRIVATE */
250
222static void pgmap_radix_release(struct resource *res) 251static void pgmap_radix_release(struct resource *res)
223{ 252{
224 unsigned long pgoff, order; 253 unsigned long pgoff, order;
@@ -356,6 +385,10 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
356 } 385 }
357 pgmap->ref = ref; 386 pgmap->ref = ref;
358 pgmap->res = &page_map->res; 387 pgmap->res = &page_map->res;
388 pgmap->type = MEMORY_DEVICE_HOST;
389 pgmap->page_fault = NULL;
390 pgmap->page_free = NULL;
391 pgmap->data = NULL;
359 392
360 mutex_lock(&pgmap_lock); 393 mutex_lock(&pgmap_lock);
361 error = 0; 394 error = 0;
@@ -466,3 +499,28 @@ struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)
466 return pgmap ? pgmap->altmap : NULL; 499 return pgmap ? pgmap->altmap : NULL;
467} 500}
468#endif /* CONFIG_ZONE_DEVICE */ 501#endif /* CONFIG_ZONE_DEVICE */
502
503
504#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC)
505void put_zone_device_private_or_public_page(struct page *page)
506{
507 int count = page_ref_dec_return(page);
508
509 /*
510 * If refcount is 1 then page is freed and refcount is stable as nobody
511 * holds a reference on the page.
512 */
513 if (count == 1) {
514 /* Clear Active bit in case of parallel mark_page_accessed */
515 __ClearPageActive(page);
516 __ClearPageWaiters(page);
517
518 page->mapping = NULL;
519 mem_cgroup_uncharge(page);
520
521 page->pgmap->page_free(page, page->pgmap->data);
522 } else if (!count)
523 __put_page(page);
524}
525EXPORT_SYMBOL(put_zone_device_private_or_public_page);
526#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 84fe96641b2e..1250e4bd4b85 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -4091,7 +4091,7 @@ static void __init rcu_init_geometry(void)
4091 if (rcu_fanout_leaf == RCU_FANOUT_LEAF && 4091 if (rcu_fanout_leaf == RCU_FANOUT_LEAF &&
4092 nr_cpu_ids == NR_CPUS) 4092 nr_cpu_ids == NR_CPUS)
4093 return; 4093 return;
4094 pr_info("RCU: Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%d\n", 4094 pr_info("RCU: Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
4095 rcu_fanout_leaf, nr_cpu_ids); 4095 rcu_fanout_leaf, nr_cpu_ids);
4096 4096
4097 /* 4097 /*
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 55bde94b9572..e012b9be777e 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -89,7 +89,7 @@ static void __init rcu_bootup_announce_oddness(void)
89 if (rcu_fanout_leaf != RCU_FANOUT_LEAF) 89 if (rcu_fanout_leaf != RCU_FANOUT_LEAF)
90 pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf); 90 pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
91 if (nr_cpu_ids != NR_CPUS) 91 if (nr_cpu_ids != NR_CPUS)
92 pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%d.\n", NR_CPUS, nr_cpu_ids); 92 pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u.\n", NR_CPUS, nr_cpu_ids);
93#ifdef CONFIG_RCU_BOOST 93#ifdef CONFIG_RCU_BOOST
94 pr_info("\tRCU priority boosting: priority %d delay %d ms.\n", kthread_prio, CONFIG_RCU_BOOST_DELAY); 94 pr_info("\tRCU priority boosting: priority %d delay %d ms.\n", kthread_prio, CONFIG_RCU_BOOST_DELAY);
95#endif 95#endif
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 9e38df7649f4..0191ec7667c3 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -296,7 +296,7 @@ static inline int is_leftmost(struct task_struct *p, struct dl_rq *dl_rq)
296{ 296{
297 struct sched_dl_entity *dl_se = &p->dl; 297 struct sched_dl_entity *dl_se = &p->dl;
298 298
299 return dl_rq->rb_leftmost == &dl_se->rb_node; 299 return dl_rq->root.rb_leftmost == &dl_se->rb_node;
300} 300}
301 301
302void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime) 302void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime)
@@ -320,7 +320,7 @@ void init_dl_bw(struct dl_bw *dl_b)
320 320
321void init_dl_rq(struct dl_rq *dl_rq) 321void init_dl_rq(struct dl_rq *dl_rq)
322{ 322{
323 dl_rq->rb_root = RB_ROOT; 323 dl_rq->root = RB_ROOT_CACHED;
324 324
325#ifdef CONFIG_SMP 325#ifdef CONFIG_SMP
326 /* zero means no -deadline tasks */ 326 /* zero means no -deadline tasks */
@@ -328,7 +328,7 @@ void init_dl_rq(struct dl_rq *dl_rq)
328 328
329 dl_rq->dl_nr_migratory = 0; 329 dl_rq->dl_nr_migratory = 0;
330 dl_rq->overloaded = 0; 330 dl_rq->overloaded = 0;
331 dl_rq->pushable_dl_tasks_root = RB_ROOT; 331 dl_rq->pushable_dl_tasks_root = RB_ROOT_CACHED;
332#else 332#else
333 init_dl_bw(&dl_rq->dl_bw); 333 init_dl_bw(&dl_rq->dl_bw);
334#endif 334#endif
@@ -410,10 +410,10 @@ static void dec_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
410static void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p) 410static void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p)
411{ 411{
412 struct dl_rq *dl_rq = &rq->dl; 412 struct dl_rq *dl_rq = &rq->dl;
413 struct rb_node **link = &dl_rq->pushable_dl_tasks_root.rb_node; 413 struct rb_node **link = &dl_rq->pushable_dl_tasks_root.rb_root.rb_node;
414 struct rb_node *parent = NULL; 414 struct rb_node *parent = NULL;
415 struct task_struct *entry; 415 struct task_struct *entry;
416 int leftmost = 1; 416 bool leftmost = true;
417 417
418 BUG_ON(!RB_EMPTY_NODE(&p->pushable_dl_tasks)); 418 BUG_ON(!RB_EMPTY_NODE(&p->pushable_dl_tasks));
419 419
@@ -425,17 +425,16 @@ static void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p)
425 link = &parent->rb_left; 425 link = &parent->rb_left;
426 else { 426 else {
427 link = &parent->rb_right; 427 link = &parent->rb_right;
428 leftmost = 0; 428 leftmost = false;
429 } 429 }
430 } 430 }
431 431
432 if (leftmost) { 432 if (leftmost)
433 dl_rq->pushable_dl_tasks_leftmost = &p->pushable_dl_tasks;
434 dl_rq->earliest_dl.next = p->dl.deadline; 433 dl_rq->earliest_dl.next = p->dl.deadline;
435 }
436 434
437 rb_link_node(&p->pushable_dl_tasks, parent, link); 435 rb_link_node(&p->pushable_dl_tasks, parent, link);
438 rb_insert_color(&p->pushable_dl_tasks, &dl_rq->pushable_dl_tasks_root); 436 rb_insert_color_cached(&p->pushable_dl_tasks,
437 &dl_rq->pushable_dl_tasks_root, leftmost);
439} 438}
440 439
441static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p) 440static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p)
@@ -445,24 +444,23 @@ static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p)
445 if (RB_EMPTY_NODE(&p->pushable_dl_tasks)) 444 if (RB_EMPTY_NODE(&p->pushable_dl_tasks))
446 return; 445 return;
447 446
448 if (dl_rq->pushable_dl_tasks_leftmost == &p->pushable_dl_tasks) { 447 if (dl_rq->pushable_dl_tasks_root.rb_leftmost == &p->pushable_dl_tasks) {
449 struct rb_node *next_node; 448 struct rb_node *next_node;
450 449
451 next_node = rb_next(&p->pushable_dl_tasks); 450 next_node = rb_next(&p->pushable_dl_tasks);
452 dl_rq->pushable_dl_tasks_leftmost = next_node;
453 if (next_node) { 451 if (next_node) {
454 dl_rq->earliest_dl.next = rb_entry(next_node, 452 dl_rq->earliest_dl.next = rb_entry(next_node,
455 struct task_struct, pushable_dl_tasks)->dl.deadline; 453 struct task_struct, pushable_dl_tasks)->dl.deadline;
456 } 454 }
457 } 455 }
458 456
459 rb_erase(&p->pushable_dl_tasks, &dl_rq->pushable_dl_tasks_root); 457 rb_erase_cached(&p->pushable_dl_tasks, &dl_rq->pushable_dl_tasks_root);
460 RB_CLEAR_NODE(&p->pushable_dl_tasks); 458 RB_CLEAR_NODE(&p->pushable_dl_tasks);
461} 459}
462 460
463static inline int has_pushable_dl_tasks(struct rq *rq) 461static inline int has_pushable_dl_tasks(struct rq *rq)
464{ 462{
465 return !RB_EMPTY_ROOT(&rq->dl.pushable_dl_tasks_root); 463 return !RB_EMPTY_ROOT(&rq->dl.pushable_dl_tasks_root.rb_root);
466} 464}
467 465
468static int push_dl_task(struct rq *rq); 466static int push_dl_task(struct rq *rq);
@@ -1266,7 +1264,7 @@ static void dec_dl_deadline(struct dl_rq *dl_rq, u64 deadline)
1266 dl_rq->earliest_dl.next = 0; 1264 dl_rq->earliest_dl.next = 0;
1267 cpudl_clear(&rq->rd->cpudl, rq->cpu); 1265 cpudl_clear(&rq->rd->cpudl, rq->cpu);
1268 } else { 1266 } else {
1269 struct rb_node *leftmost = dl_rq->rb_leftmost; 1267 struct rb_node *leftmost = dl_rq->root.rb_leftmost;
1270 struct sched_dl_entity *entry; 1268 struct sched_dl_entity *entry;
1271 1269
1272 entry = rb_entry(leftmost, struct sched_dl_entity, rb_node); 1270 entry = rb_entry(leftmost, struct sched_dl_entity, rb_node);
@@ -1313,7 +1311,7 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
1313static void __enqueue_dl_entity(struct sched_dl_entity *dl_se) 1311static void __enqueue_dl_entity(struct sched_dl_entity *dl_se)
1314{ 1312{
1315 struct dl_rq *dl_rq = dl_rq_of_se(dl_se); 1313 struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
1316 struct rb_node **link = &dl_rq->rb_root.rb_node; 1314 struct rb_node **link = &dl_rq->root.rb_root.rb_node;
1317 struct rb_node *parent = NULL; 1315 struct rb_node *parent = NULL;
1318 struct sched_dl_entity *entry; 1316 struct sched_dl_entity *entry;
1319 int leftmost = 1; 1317 int leftmost = 1;
@@ -1331,11 +1329,8 @@ static void __enqueue_dl_entity(struct sched_dl_entity *dl_se)
1331 } 1329 }
1332 } 1330 }
1333 1331
1334 if (leftmost)
1335 dl_rq->rb_leftmost = &dl_se->rb_node;
1336
1337 rb_link_node(&dl_se->rb_node, parent, link); 1332 rb_link_node(&dl_se->rb_node, parent, link);
1338 rb_insert_color(&dl_se->rb_node, &dl_rq->rb_root); 1333 rb_insert_color_cached(&dl_se->rb_node, &dl_rq->root, leftmost);
1339 1334
1340 inc_dl_tasks(dl_se, dl_rq); 1335 inc_dl_tasks(dl_se, dl_rq);
1341} 1336}
@@ -1347,14 +1342,7 @@ static void __dequeue_dl_entity(struct sched_dl_entity *dl_se)
1347 if (RB_EMPTY_NODE(&dl_se->rb_node)) 1342 if (RB_EMPTY_NODE(&dl_se->rb_node))
1348 return; 1343 return;
1349 1344
1350 if (dl_rq->rb_leftmost == &dl_se->rb_node) { 1345 rb_erase_cached(&dl_se->rb_node, &dl_rq->root);
1351 struct rb_node *next_node;
1352
1353 next_node = rb_next(&dl_se->rb_node);
1354 dl_rq->rb_leftmost = next_node;
1355 }
1356
1357 rb_erase(&dl_se->rb_node, &dl_rq->rb_root);
1358 RB_CLEAR_NODE(&dl_se->rb_node); 1346 RB_CLEAR_NODE(&dl_se->rb_node);
1359 1347
1360 dec_dl_tasks(dl_se, dl_rq); 1348 dec_dl_tasks(dl_se, dl_rq);
@@ -1647,7 +1635,7 @@ static void start_hrtick_dl(struct rq *rq, struct task_struct *p)
1647static struct sched_dl_entity *pick_next_dl_entity(struct rq *rq, 1635static struct sched_dl_entity *pick_next_dl_entity(struct rq *rq,
1648 struct dl_rq *dl_rq) 1636 struct dl_rq *dl_rq)
1649{ 1637{
1650 struct rb_node *left = dl_rq->rb_leftmost; 1638 struct rb_node *left = rb_first_cached(&dl_rq->root);
1651 1639
1652 if (!left) 1640 if (!left)
1653 return NULL; 1641 return NULL;
@@ -1771,7 +1759,7 @@ static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu)
1771 */ 1759 */
1772static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu) 1760static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu)
1773{ 1761{
1774 struct rb_node *next_node = rq->dl.pushable_dl_tasks_leftmost; 1762 struct rb_node *next_node = rq->dl.pushable_dl_tasks_root.rb_leftmost;
1775 struct task_struct *p = NULL; 1763 struct task_struct *p = NULL;
1776 1764
1777 if (!has_pushable_dl_tasks(rq)) 1765 if (!has_pushable_dl_tasks(rq))
@@ -1945,7 +1933,7 @@ static struct task_struct *pick_next_pushable_dl_task(struct rq *rq)
1945 if (!has_pushable_dl_tasks(rq)) 1933 if (!has_pushable_dl_tasks(rq))
1946 return NULL; 1934 return NULL;
1947 1935
1948 p = rb_entry(rq->dl.pushable_dl_tasks_leftmost, 1936 p = rb_entry(rq->dl.pushable_dl_tasks_root.rb_leftmost,
1949 struct task_struct, pushable_dl_tasks); 1937 struct task_struct, pushable_dl_tasks);
1950 1938
1951 BUG_ON(rq->cpu != task_cpu(p)); 1939 BUG_ON(rq->cpu != task_cpu(p));
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 4a23bbc3111b..8e536d963652 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -530,7 +530,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
530 SPLIT_NS(cfs_rq->exec_clock)); 530 SPLIT_NS(cfs_rq->exec_clock));
531 531
532 raw_spin_lock_irqsave(&rq->lock, flags); 532 raw_spin_lock_irqsave(&rq->lock, flags);
533 if (cfs_rq->rb_leftmost) 533 if (rb_first_cached(&cfs_rq->tasks_timeline))
534 MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime; 534 MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime;
535 last = __pick_last_entity(cfs_rq); 535 last = __pick_last_entity(cfs_rq);
536 if (last) 536 if (last)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8bc0a883d190..a5d83ed8dd82 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -513,6 +513,7 @@ static inline int entity_before(struct sched_entity *a,
513static void update_min_vruntime(struct cfs_rq *cfs_rq) 513static void update_min_vruntime(struct cfs_rq *cfs_rq)
514{ 514{
515 struct sched_entity *curr = cfs_rq->curr; 515 struct sched_entity *curr = cfs_rq->curr;
516 struct rb_node *leftmost = rb_first_cached(&cfs_rq->tasks_timeline);
516 517
517 u64 vruntime = cfs_rq->min_vruntime; 518 u64 vruntime = cfs_rq->min_vruntime;
518 519
@@ -523,10 +524,9 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq)
523 curr = NULL; 524 curr = NULL;
524 } 525 }
525 526
526 if (cfs_rq->rb_leftmost) { 527 if (leftmost) { /* non-empty tree */
527 struct sched_entity *se = rb_entry(cfs_rq->rb_leftmost, 528 struct sched_entity *se;
528 struct sched_entity, 529 se = rb_entry(leftmost, struct sched_entity, run_node);
529 run_node);
530 530
531 if (!curr) 531 if (!curr)
532 vruntime = se->vruntime; 532 vruntime = se->vruntime;
@@ -547,10 +547,10 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq)
547 */ 547 */
548static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) 548static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
549{ 549{
550 struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; 550 struct rb_node **link = &cfs_rq->tasks_timeline.rb_root.rb_node;
551 struct rb_node *parent = NULL; 551 struct rb_node *parent = NULL;
552 struct sched_entity *entry; 552 struct sched_entity *entry;
553 int leftmost = 1; 553 bool leftmost = true;
554 554
555 /* 555 /*
556 * Find the right place in the rbtree: 556 * Find the right place in the rbtree:
@@ -566,36 +566,23 @@ static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
566 link = &parent->rb_left; 566 link = &parent->rb_left;
567 } else { 567 } else {
568 link = &parent->rb_right; 568 link = &parent->rb_right;
569 leftmost = 0; 569 leftmost = false;
570 } 570 }
571 } 571 }
572 572
573 /*
574 * Maintain a cache of leftmost tree entries (it is frequently
575 * used):
576 */
577 if (leftmost)
578 cfs_rq->rb_leftmost = &se->run_node;
579
580 rb_link_node(&se->run_node, parent, link); 573 rb_link_node(&se->run_node, parent, link);
581 rb_insert_color(&se->run_node, &cfs_rq->tasks_timeline); 574 rb_insert_color_cached(&se->run_node,
575 &cfs_rq->tasks_timeline, leftmost);
582} 576}
583 577
584static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) 578static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
585{ 579{
586 if (cfs_rq->rb_leftmost == &se->run_node) { 580 rb_erase_cached(&se->run_node, &cfs_rq->tasks_timeline);
587 struct rb_node *next_node;
588
589 next_node = rb_next(&se->run_node);
590 cfs_rq->rb_leftmost = next_node;
591 }
592
593 rb_erase(&se->run_node, &cfs_rq->tasks_timeline);
594} 581}
595 582
596struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq) 583struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
597{ 584{
598 struct rb_node *left = cfs_rq->rb_leftmost; 585 struct rb_node *left = rb_first_cached(&cfs_rq->tasks_timeline);
599 586
600 if (!left) 587 if (!left)
601 return NULL; 588 return NULL;
@@ -616,7 +603,7 @@ static struct sched_entity *__pick_next_entity(struct sched_entity *se)
616#ifdef CONFIG_SCHED_DEBUG 603#ifdef CONFIG_SCHED_DEBUG
617struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) 604struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
618{ 605{
619 struct rb_node *last = rb_last(&cfs_rq->tasks_timeline); 606 struct rb_node *last = rb_last(&cfs_rq->tasks_timeline.rb_root);
620 607
621 if (!last) 608 if (!last)
622 return NULL; 609 return NULL;
@@ -9312,7 +9299,7 @@ static void set_curr_task_fair(struct rq *rq)
9312 9299
9313void init_cfs_rq(struct cfs_rq *cfs_rq) 9300void init_cfs_rq(struct cfs_rq *cfs_rq)
9314{ 9301{
9315 cfs_rq->tasks_timeline = RB_ROOT; 9302 cfs_rq->tasks_timeline = RB_ROOT_CACHED;
9316 cfs_rq->min_vruntime = (u64)(-(1LL << 20)); 9303 cfs_rq->min_vruntime = (u64)(-(1LL << 20));
9317#ifndef CONFIG_64BIT 9304#ifndef CONFIG_64BIT
9318 cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime; 9305 cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 6ed7962dc896..746ac78ff492 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -426,8 +426,7 @@ struct cfs_rq {
426 u64 min_vruntime_copy; 426 u64 min_vruntime_copy;
427#endif 427#endif
428 428
429 struct rb_root tasks_timeline; 429 struct rb_root_cached tasks_timeline;
430 struct rb_node *rb_leftmost;
431 430
432 /* 431 /*
433 * 'curr' points to currently running entity on this cfs_rq. 432 * 'curr' points to currently running entity on this cfs_rq.
@@ -550,8 +549,7 @@ struct rt_rq {
550/* Deadline class' related fields in a runqueue */ 549/* Deadline class' related fields in a runqueue */
551struct dl_rq { 550struct dl_rq {
552 /* runqueue is an rbtree, ordered by deadline */ 551 /* runqueue is an rbtree, ordered by deadline */
553 struct rb_root rb_root; 552 struct rb_root_cached root;
554 struct rb_node *rb_leftmost;
555 553
556 unsigned long dl_nr_running; 554 unsigned long dl_nr_running;
557 555
@@ -575,8 +573,7 @@ struct dl_rq {
575 * an rb-tree, ordered by tasks' deadlines, with caching 573 * an rb-tree, ordered by tasks' deadlines, with caching
576 * of the leftmost (earliest deadline) element. 574 * of the leftmost (earliest deadline) element.
577 */ 575 */
578 struct rb_root pushable_dl_tasks_root; 576 struct rb_root_cached pushable_dl_tasks_root;
579 struct rb_node *pushable_dl_tasks_leftmost;
580#else 577#else
581 struct dl_bw dl_bw; 578 struct dl_bw dl_bw;
582#endif 579#endif
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 6f7b43982f73..5d0062cc10cb 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -473,7 +473,7 @@ static int __init isolated_cpu_setup(char *str)
473 alloc_bootmem_cpumask_var(&cpu_isolated_map); 473 alloc_bootmem_cpumask_var(&cpu_isolated_map);
474 ret = cpulist_parse(str, cpu_isolated_map); 474 ret = cpulist_parse(str, cpu_isolated_map);
475 if (ret) { 475 if (ret) {
476 pr_err("sched: Error, all isolcpus= values must be between 0 and %d\n", nr_cpu_ids); 476 pr_err("sched: Error, all isolcpus= values must be between 0 and %u\n", nr_cpu_ids);
477 return 0; 477 return 0;
478 } 478 }
479 return 1; 479 return 1;
diff --git a/kernel/smp.c b/kernel/smp.c
index 81cfca9b4cc3..c94dd85c8d41 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -550,7 +550,7 @@ static int __init maxcpus(char *str)
550early_param("maxcpus", maxcpus); 550early_param("maxcpus", maxcpus);
551 551
552/* Setup number of possible processor ids */ 552/* Setup number of possible processor ids */
553int nr_cpu_ids __read_mostly = NR_CPUS; 553unsigned int nr_cpu_ids __read_mostly = NR_CPUS;
554EXPORT_SYMBOL(nr_cpu_ids); 554EXPORT_SYMBOL(nr_cpu_ids);
555 555
556/* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */ 556/* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 8ea4fb315719..2cafb49aa65e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2316,7 +2316,7 @@ void hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts)
2316 raw_spin_unlock_irqrestore(&timekeeper_lock, flags); 2316 raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
2317} 2317}
2318EXPORT_SYMBOL(hardpps); 2318EXPORT_SYMBOL(hardpps);
2319#endif 2319#endif /* CONFIG_NTP_PPS */
2320 2320
2321/** 2321/**
2322 * xtime_update() - advances the timekeeping infrastructure 2322 * xtime_update() - advances the timekeeping infrastructure
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index d56123cdcc89..b8f1f54731af 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -1543,7 +1543,7 @@ fs_initcall(init_graph_tracefs);
1543 1543
1544static __init int init_graph_trace(void) 1544static __init int init_graph_trace(void)
1545{ 1545{
1546 max_bytes_for_cpu = snprintf(NULL, 0, "%d", nr_cpu_ids - 1); 1546 max_bytes_for_cpu = snprintf(NULL, 0, "%u", nr_cpu_ids - 1);
1547 1547
1548 if (!register_trace_event(&graph_trace_entry_event)) { 1548 if (!register_trace_event(&graph_trace_entry_event)) {
1549 pr_warn("Warning: could not register graph trace events\n"); 1549 pr_warn("Warning: could not register graph trace events\n");
diff --git a/kernel/umh.c b/kernel/umh.c
new file mode 100644
index 000000000000..6ff9905250ff
--- /dev/null
+++ b/kernel/umh.c
@@ -0,0 +1,568 @@
1/*
2 * umh - the kernel usermode helper
3 */
4#include <linux/module.h>
5#include <linux/sched.h>
6#include <linux/sched/task.h>
7#include <linux/binfmts.h>
8#include <linux/syscalls.h>
9#include <linux/unistd.h>
10#include <linux/kmod.h>
11#include <linux/slab.h>
12#include <linux/completion.h>
13#include <linux/cred.h>
14#include <linux/file.h>
15#include <linux/fdtable.h>
16#include <linux/workqueue.h>
17#include <linux/security.h>
18#include <linux/mount.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/resource.h>
22#include <linux/notifier.h>
23#include <linux/suspend.h>
24#include <linux/rwsem.h>
25#include <linux/ptrace.h>
26#include <linux/async.h>
27#include <linux/uaccess.h>
28
29#include <trace/events/module.h>
30
31#define CAP_BSET (void *)1
32#define CAP_PI (void *)2
33
34static kernel_cap_t usermodehelper_bset = CAP_FULL_SET;
35static kernel_cap_t usermodehelper_inheritable = CAP_FULL_SET;
36static DEFINE_SPINLOCK(umh_sysctl_lock);
37static DECLARE_RWSEM(umhelper_sem);
38
39static void call_usermodehelper_freeinfo(struct subprocess_info *info)
40{
41 if (info->cleanup)
42 (*info->cleanup)(info);
43 kfree(info);
44}
45
46static void umh_complete(struct subprocess_info *sub_info)
47{
48 struct completion *comp = xchg(&sub_info->complete, NULL);
49 /*
50 * See call_usermodehelper_exec(). If xchg() returns NULL
51 * we own sub_info, the UMH_KILLABLE caller has gone away
52 * or the caller used UMH_NO_WAIT.
53 */
54 if (comp)
55 complete(comp);
56 else
57 call_usermodehelper_freeinfo(sub_info);
58}
59
60/*
61 * This is the task which runs the usermode application
62 */
63static int call_usermodehelper_exec_async(void *data)
64{
65 struct subprocess_info *sub_info = data;
66 struct cred *new;
67 int retval;
68
69 spin_lock_irq(&current->sighand->siglock);
70 flush_signal_handlers(current, 1);
71 spin_unlock_irq(&current->sighand->siglock);
72
73 /*
74 * Our parent (unbound workqueue) runs with elevated scheduling
75 * priority. Avoid propagating that into the userspace child.
76 */
77 set_user_nice(current, 0);
78
79 retval = -ENOMEM;
80 new = prepare_kernel_cred(current);
81 if (!new)
82 goto out;
83
84 spin_lock(&umh_sysctl_lock);
85 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset);
86 new->cap_inheritable = cap_intersect(usermodehelper_inheritable,
87 new->cap_inheritable);
88 spin_unlock(&umh_sysctl_lock);
89
90 if (sub_info->init) {
91 retval = sub_info->init(sub_info, new);
92 if (retval) {
93 abort_creds(new);
94 goto out;
95 }
96 }
97
98 commit_creds(new);
99
100 retval = do_execve(getname_kernel(sub_info->path),
101 (const char __user *const __user *)sub_info->argv,
102 (const char __user *const __user *)sub_info->envp);
103out:
104 sub_info->retval = retval;
105 /*
106 * call_usermodehelper_exec_sync() will call umh_complete
107 * if UHM_WAIT_PROC.
108 */
109 if (!(sub_info->wait & UMH_WAIT_PROC))
110 umh_complete(sub_info);
111 if (!retval)
112 return 0;
113 do_exit(0);
114}
115
116/* Handles UMH_WAIT_PROC. */
117static void call_usermodehelper_exec_sync(struct subprocess_info *sub_info)
118{
119 pid_t pid;
120
121 /* If SIGCLD is ignored sys_wait4 won't populate the status. */
122 kernel_sigaction(SIGCHLD, SIG_DFL);
123 pid = kernel_thread(call_usermodehelper_exec_async, sub_info, SIGCHLD);
124 if (pid < 0) {
125 sub_info->retval = pid;
126 } else {
127 int ret = -ECHILD;
128 /*
129 * Normally it is bogus to call wait4() from in-kernel because
130 * wait4() wants to write the exit code to a userspace address.
131 * But call_usermodehelper_exec_sync() always runs as kernel
132 * thread (workqueue) and put_user() to a kernel address works
133 * OK for kernel threads, due to their having an mm_segment_t
134 * which spans the entire address space.
135 *
136 * Thus the __user pointer cast is valid here.
137 */
138 sys_wait4(pid, (int __user *)&ret, 0, NULL);
139
140 /*
141 * If ret is 0, either call_usermodehelper_exec_async failed and
142 * the real error code is already in sub_info->retval or
143 * sub_info->retval is 0 anyway, so don't mess with it then.
144 */
145 if (ret)
146 sub_info->retval = ret;
147 }
148
149 /* Restore default kernel sig handler */
150 kernel_sigaction(SIGCHLD, SIG_IGN);
151
152 umh_complete(sub_info);
153}
154
155/*
156 * We need to create the usermodehelper kernel thread from a task that is affine
157 * to an optimized set of CPUs (or nohz housekeeping ones) such that they
158 * inherit a widest affinity irrespective of call_usermodehelper() callers with
159 * possibly reduced affinity (eg: per-cpu workqueues). We don't want
160 * usermodehelper targets to contend a busy CPU.
161 *
162 * Unbound workqueues provide such wide affinity and allow to block on
163 * UMH_WAIT_PROC requests without blocking pending request (up to some limit).
164 *
165 * Besides, workqueues provide the privilege level that caller might not have
166 * to perform the usermodehelper request.
167 *
168 */
169static void call_usermodehelper_exec_work(struct work_struct *work)
170{
171 struct subprocess_info *sub_info =
172 container_of(work, struct subprocess_info, work);
173
174 if (sub_info->wait & UMH_WAIT_PROC) {
175 call_usermodehelper_exec_sync(sub_info);
176 } else {
177 pid_t pid;
178 /*
179 * Use CLONE_PARENT to reparent it to kthreadd; we do not
180 * want to pollute current->children, and we need a parent
181 * that always ignores SIGCHLD to ensure auto-reaping.
182 */
183 pid = kernel_thread(call_usermodehelper_exec_async, sub_info,
184 CLONE_PARENT | SIGCHLD);
185 if (pid < 0) {
186 sub_info->retval = pid;
187 umh_complete(sub_info);
188 }
189 }
190}
191
192/*
193 * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
194 * (used for preventing user land processes from being created after the user
195 * land has been frozen during a system-wide hibernation or suspend operation).
196 * Should always be manipulated under umhelper_sem acquired for write.
197 */
198static enum umh_disable_depth usermodehelper_disabled = UMH_DISABLED;
199
200/* Number of helpers running */
201static atomic_t running_helpers = ATOMIC_INIT(0);
202
203/*
204 * Wait queue head used by usermodehelper_disable() to wait for all running
205 * helpers to finish.
206 */
207static DECLARE_WAIT_QUEUE_HEAD(running_helpers_waitq);
208
209/*
210 * Used by usermodehelper_read_lock_wait() to wait for usermodehelper_disabled
211 * to become 'false'.
212 */
213static DECLARE_WAIT_QUEUE_HEAD(usermodehelper_disabled_waitq);
214
215/*
216 * Time to wait for running_helpers to become zero before the setting of
217 * usermodehelper_disabled in usermodehelper_disable() fails
218 */
219#define RUNNING_HELPERS_TIMEOUT (5 * HZ)
220
221int usermodehelper_read_trylock(void)
222{
223 DEFINE_WAIT(wait);
224 int ret = 0;
225
226 down_read(&umhelper_sem);
227 for (;;) {
228 prepare_to_wait(&usermodehelper_disabled_waitq, &wait,
229 TASK_INTERRUPTIBLE);
230 if (!usermodehelper_disabled)
231 break;
232
233 if (usermodehelper_disabled == UMH_DISABLED)
234 ret = -EAGAIN;
235
236 up_read(&umhelper_sem);
237
238 if (ret)
239 break;
240
241 schedule();
242 try_to_freeze();
243
244 down_read(&umhelper_sem);
245 }
246 finish_wait(&usermodehelper_disabled_waitq, &wait);
247 return ret;
248}
249EXPORT_SYMBOL_GPL(usermodehelper_read_trylock);
250
251long usermodehelper_read_lock_wait(long timeout)
252{
253 DEFINE_WAIT(wait);
254
255 if (timeout < 0)
256 return -EINVAL;
257
258 down_read(&umhelper_sem);
259 for (;;) {
260 prepare_to_wait(&usermodehelper_disabled_waitq, &wait,
261 TASK_UNINTERRUPTIBLE);
262 if (!usermodehelper_disabled)
263 break;
264
265 up_read(&umhelper_sem);
266
267 timeout = schedule_timeout(timeout);
268 if (!timeout)
269 break;
270
271 down_read(&umhelper_sem);
272 }
273 finish_wait(&usermodehelper_disabled_waitq, &wait);
274 return timeout;
275}
276EXPORT_SYMBOL_GPL(usermodehelper_read_lock_wait);
277
278void usermodehelper_read_unlock(void)
279{
280 up_read(&umhelper_sem);
281}
282EXPORT_SYMBOL_GPL(usermodehelper_read_unlock);
283
284/**
285 * __usermodehelper_set_disable_depth - Modify usermodehelper_disabled.
286 * @depth: New value to assign to usermodehelper_disabled.
287 *
288 * Change the value of usermodehelper_disabled (under umhelper_sem locked for
289 * writing) and wakeup tasks waiting for it to change.
290 */
291void __usermodehelper_set_disable_depth(enum umh_disable_depth depth)
292{
293 down_write(&umhelper_sem);
294 usermodehelper_disabled = depth;
295 wake_up(&usermodehelper_disabled_waitq);
296 up_write(&umhelper_sem);
297}
298
299/**
300 * __usermodehelper_disable - Prevent new helpers from being started.
301 * @depth: New value to assign to usermodehelper_disabled.
302 *
303 * Set usermodehelper_disabled to @depth and wait for running helpers to exit.
304 */
305int __usermodehelper_disable(enum umh_disable_depth depth)
306{
307 long retval;
308
309 if (!depth)
310 return -EINVAL;
311
312 down_write(&umhelper_sem);
313 usermodehelper_disabled = depth;
314 up_write(&umhelper_sem);
315
316 /*
317 * From now on call_usermodehelper_exec() won't start any new
318 * helpers, so it is sufficient if running_helpers turns out to
319 * be zero at one point (it may be increased later, but that
320 * doesn't matter).
321 */
322 retval = wait_event_timeout(running_helpers_waitq,
323 atomic_read(&running_helpers) == 0,
324 RUNNING_HELPERS_TIMEOUT);
325 if (retval)
326 return 0;
327
328 __usermodehelper_set_disable_depth(UMH_ENABLED);
329 return -EAGAIN;
330}
331
332static void helper_lock(void)
333{
334 atomic_inc(&running_helpers);
335 smp_mb__after_atomic();
336}
337
338static void helper_unlock(void)
339{
340 if (atomic_dec_and_test(&running_helpers))
341 wake_up(&running_helpers_waitq);
342}
343
344/**
345 * call_usermodehelper_setup - prepare to call a usermode helper
346 * @path: path to usermode executable
347 * @argv: arg vector for process
348 * @envp: environment for process
349 * @gfp_mask: gfp mask for memory allocation
350 * @cleanup: a cleanup function
351 * @init: an init function
352 * @data: arbitrary context sensitive data
353 *
354 * Returns either %NULL on allocation failure, or a subprocess_info
355 * structure. This should be passed to call_usermodehelper_exec to
356 * exec the process and free the structure.
357 *
358 * The init function is used to customize the helper process prior to
359 * exec. A non-zero return code causes the process to error out, exit,
360 * and return the failure to the calling process
361 *
362 * The cleanup function is just before ethe subprocess_info is about to
363 * be freed. This can be used for freeing the argv and envp. The
364 * Function must be runnable in either a process context or the
365 * context in which call_usermodehelper_exec is called.
366 */
367struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
368 char **envp, gfp_t gfp_mask,
369 int (*init)(struct subprocess_info *info, struct cred *new),
370 void (*cleanup)(struct subprocess_info *info),
371 void *data)
372{
373 struct subprocess_info *sub_info;
374 sub_info = kzalloc(sizeof(struct subprocess_info), gfp_mask);
375 if (!sub_info)
376 goto out;
377
378 INIT_WORK(&sub_info->work, call_usermodehelper_exec_work);
379
380#ifdef CONFIG_STATIC_USERMODEHELPER
381 sub_info->path = CONFIG_STATIC_USERMODEHELPER_PATH;
382#else
383 sub_info->path = path;
384#endif
385 sub_info->argv = argv;
386 sub_info->envp = envp;
387
388 sub_info->cleanup = cleanup;
389 sub_info->init = init;
390 sub_info->data = data;
391 out:
392 return sub_info;
393}
394EXPORT_SYMBOL(call_usermodehelper_setup);
395
396/**
397 * call_usermodehelper_exec - start a usermode application
398 * @sub_info: information about the subprocessa
399 * @wait: wait for the application to finish and return status.
400 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
401 * when the program couldn't be exec'ed. This makes it safe to call
402 * from interrupt context.
403 *
404 * Runs a user-space application. The application is started
405 * asynchronously if wait is not set, and runs as a child of system workqueues.
406 * (ie. it runs with full root capabilities and optimized affinity).
407 */
408int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
409{
410 DECLARE_COMPLETION_ONSTACK(done);
411 int retval = 0;
412
413 if (!sub_info->path) {
414 call_usermodehelper_freeinfo(sub_info);
415 return -EINVAL;
416 }
417 helper_lock();
418 if (usermodehelper_disabled) {
419 retval = -EBUSY;
420 goto out;
421 }
422
423 /*
424 * If there is no binary for us to call, then just return and get out of
425 * here. This allows us to set STATIC_USERMODEHELPER_PATH to "" and
426 * disable all call_usermodehelper() calls.
427 */
428 if (strlen(sub_info->path) == 0)
429 goto out;
430
431 /*
432 * Set the completion pointer only if there is a waiter.
433 * This makes it possible to use umh_complete to free
434 * the data structure in case of UMH_NO_WAIT.
435 */
436 sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done;
437 sub_info->wait = wait;
438
439 queue_work(system_unbound_wq, &sub_info->work);
440 if (wait == UMH_NO_WAIT) /* task has freed sub_info */
441 goto unlock;
442
443 if (wait & UMH_KILLABLE) {
444 retval = wait_for_completion_killable(&done);
445 if (!retval)
446 goto wait_done;
447
448 /* umh_complete() will see NULL and free sub_info */
449 if (xchg(&sub_info->complete, NULL))
450 goto unlock;
451 /* fallthrough, umh_complete() was already called */
452 }
453
454 wait_for_completion(&done);
455wait_done:
456 retval = sub_info->retval;
457out:
458 call_usermodehelper_freeinfo(sub_info);
459unlock:
460 helper_unlock();
461 return retval;
462}
463EXPORT_SYMBOL(call_usermodehelper_exec);
464
465/**
466 * call_usermodehelper() - prepare and start a usermode application
467 * @path: path to usermode executable
468 * @argv: arg vector for process
469 * @envp: environment for process
470 * @wait: wait for the application to finish and return status.
471 * when UMH_NO_WAIT don't wait at all, but you get no useful error back
472 * when the program couldn't be exec'ed. This makes it safe to call
473 * from interrupt context.
474 *
475 * This function is the equivalent to use call_usermodehelper_setup() and
476 * call_usermodehelper_exec().
477 */
478int call_usermodehelper(const char *path, char **argv, char **envp, int wait)
479{
480 struct subprocess_info *info;
481 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
482
483 info = call_usermodehelper_setup(path, argv, envp, gfp_mask,
484 NULL, NULL, NULL);
485 if (info == NULL)
486 return -ENOMEM;
487
488 return call_usermodehelper_exec(info, wait);
489}
490EXPORT_SYMBOL(call_usermodehelper);
491
492static int proc_cap_handler(struct ctl_table *table, int write,
493 void __user *buffer, size_t *lenp, loff_t *ppos)
494{
495 struct ctl_table t;
496 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
497 kernel_cap_t new_cap;
498 int err, i;
499
500 if (write && (!capable(CAP_SETPCAP) ||
501 !capable(CAP_SYS_MODULE)))
502 return -EPERM;
503
504 /*
505 * convert from the global kernel_cap_t to the ulong array to print to
506 * userspace if this is a read.
507 */
508 spin_lock(&umh_sysctl_lock);
509 for (i = 0; i < _KERNEL_CAPABILITY_U32S; i++) {
510 if (table->data == CAP_BSET)
511 cap_array[i] = usermodehelper_bset.cap[i];
512 else if (table->data == CAP_PI)
513 cap_array[i] = usermodehelper_inheritable.cap[i];
514 else
515 BUG();
516 }
517 spin_unlock(&umh_sysctl_lock);
518
519 t = *table;
520 t.data = &cap_array;
521
522 /*
523 * actually read or write and array of ulongs from userspace. Remember
524 * these are least significant 32 bits first
525 */
526 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
527 if (err < 0)
528 return err;
529
530 /*
531 * convert from the sysctl array of ulongs to the kernel_cap_t
532 * internal representation
533 */
534 for (i = 0; i < _KERNEL_CAPABILITY_U32S; i++)
535 new_cap.cap[i] = cap_array[i];
536
537 /*
538 * Drop everything not in the new_cap (but don't add things)
539 */
540 spin_lock(&umh_sysctl_lock);
541 if (write) {
542 if (table->data == CAP_BSET)
543 usermodehelper_bset = cap_intersect(usermodehelper_bset, new_cap);
544 if (table->data == CAP_PI)
545 usermodehelper_inheritable = cap_intersect(usermodehelper_inheritable, new_cap);
546 }
547 spin_unlock(&umh_sysctl_lock);
548
549 return 0;
550}
551
552struct ctl_table usermodehelper_table[] = {
553 {
554 .procname = "bset",
555 .data = CAP_BSET,
556 .maxlen = _KERNEL_CAPABILITY_U32S * sizeof(unsigned long),
557 .mode = 0600,
558 .proc_handler = proc_cap_handler,
559 },
560 {
561 .procname = "inheritable",
562 .data = CAP_PI,
563 .maxlen = _KERNEL_CAPABILITY_U32S * sizeof(unsigned long),
564 .mode = 0600,
565 .proc_handler = proc_cap_handler,
566 },
567 { }
568};
diff --git a/lib/Kconfig b/lib/Kconfig
index 6762529ad9e4..40b114a11d7c 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -575,4 +575,7 @@ config PARMAN
575config PRIME_NUMBERS 575config PRIME_NUMBERS
576 tristate 576 tristate
577 577
578config STRING_SELFTEST
579 bool "Test string functions"
580
578endmenu 581endmenu
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 7396f5044397..b19c491cbc4e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1930,6 +1930,17 @@ config TEST_KMOD
1930 1930
1931 If unsure, say N. 1931 If unsure, say N.
1932 1932
1933config TEST_DEBUG_VIRTUAL
1934 tristate "Test CONFIG_DEBUG_VIRTUAL feature"
1935 depends on DEBUG_VIRTUAL
1936 help
1937 Test the kernel's ability to detect incorrect calls to
1938 virt_to_phys() done against the non-linear part of the
1939 kernel's virtual address map.
1940
1941 If unsure, say N.
1942
1943
1933source "samples/Kconfig" 1944source "samples/Kconfig"
1934 1945
1935source "lib/Kconfig.kgdb" 1946source "lib/Kconfig.kgdb"
diff --git a/lib/Makefile b/lib/Makefile
index 40c18372b301..469ce5e24e4f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
62obj-$(CONFIG_TEST_UUID) += test_uuid.o 62obj-$(CONFIG_TEST_UUID) += test_uuid.o
63obj-$(CONFIG_TEST_PARMAN) += test_parman.o 63obj-$(CONFIG_TEST_PARMAN) += test_parman.o
64obj-$(CONFIG_TEST_KMOD) += test_kmod.o 64obj-$(CONFIG_TEST_KMOD) += test_kmod.o
65obj-$(CONFIG_TEST_DEBUG_VIRTUAL) += test_debug_virtual.o
65 66
66ifeq ($(CONFIG_DEBUG_KOBJECT),y) 67ifeq ($(CONFIG_DEBUG_KOBJECT),y)
67CFLAGS_kobject.o += -DDEBUG 68CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 9a532805364b..c82c61b66e16 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -513,7 +513,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
513 int nmaskbits) 513 int nmaskbits)
514{ 514{
515 unsigned int a, b, old_a, old_b; 515 unsigned int a, b, old_a, old_b;
516 unsigned int group_size, used_size; 516 unsigned int group_size, used_size, off;
517 int c, old_c, totaldigits, ndigits; 517 int c, old_c, totaldigits, ndigits;
518 const char __user __force *ubuf = (const char __user __force *)buf; 518 const char __user __force *ubuf = (const char __user __force *)buf;
519 int at_start, in_range, in_partial_range; 519 int at_start, in_range, in_partial_range;
@@ -599,6 +599,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
599 a = old_a; 599 a = old_a;
600 b = old_b; 600 b = old_b;
601 old_a = old_b = 0; 601 old_a = old_b = 0;
602 } else {
603 used_size = group_size = b - a + 1;
602 } 604 }
603 /* if no digit is after '-', it's wrong*/ 605 /* if no digit is after '-', it's wrong*/
604 if (at_start && in_range) 606 if (at_start && in_range)
@@ -608,17 +610,9 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
608 if (b >= nmaskbits) 610 if (b >= nmaskbits)
609 return -ERANGE; 611 return -ERANGE;
610 while (a <= b) { 612 while (a <= b) {
611 if (in_partial_range) { 613 off = min(b - a + 1, used_size);
612 static int pos_in_group = 1; 614 bitmap_set(maskp, a, off);
613 615 a += group_size;
614 if (pos_in_group <= used_size)
615 set_bit(a, maskp);
616
617 if (a == b || ++pos_in_group > group_size)
618 pos_in_group = 1;
619 } else
620 set_bit(a, maskp);
621 a++;
622 } 616 }
623 } while (buflen && c == ','); 617 } while (buflen && c == ',');
624 return 0; 618 return 0;
diff --git a/lib/cmdline.c b/lib/cmdline.c
index 4c0888c4a68d..171c19b6888e 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -244,5 +244,4 @@ char *next_arg(char *args, char **param, char **val)
244 244
245 /* Chew up trailing spaces. */ 245 /* Chew up trailing spaces. */
246 return skip_spaces(next); 246 return skip_spaces(next);
247 //return next;
248} 247}
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 4731a0895760..8b1a1bd77539 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -6,6 +6,22 @@
6#include <linux/bootmem.h> 6#include <linux/bootmem.h>
7 7
8/** 8/**
9 * cpumask_next - get the next cpu in a cpumask
10 * @n: the cpu prior to the place to search (ie. return will be > @n)
11 * @srcp: the cpumask pointer
12 *
13 * Returns >= nr_cpu_ids if no further cpus set.
14 */
15unsigned int cpumask_next(int n, const struct cpumask *srcp)
16{
17 /* -1 is a legal arg here. */
18 if (n != -1)
19 cpumask_check(n);
20 return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
21}
22EXPORT_SYMBOL(cpumask_next);
23
24/**
9 * cpumask_next_and - get the next cpu in *src1p & *src2p 25 * cpumask_next_and - get the next cpu in *src1p & *src2p
10 * @n: the cpu prior to the place to search (ie. return will be > @n) 26 * @n: the cpu prior to the place to search (ie. return will be > @n)
11 * @src1p: the first cpumask pointer 27 * @src1p: the first cpumask pointer
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 992457b1284c..81b70ed37209 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/ctype.h> 11#include <linux/ctype.h>
12#include <linux/errno.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/export.h> 14#include <linux/export.h>
14#include <asm/unaligned.h> 15#include <asm/unaligned.h>
@@ -42,7 +43,7 @@ EXPORT_SYMBOL(hex_to_bin);
42 * @src: ascii hexadecimal string 43 * @src: ascii hexadecimal string
43 * @count: result length 44 * @count: result length
44 * 45 *
45 * Return 0 on success, -1 in case of bad input. 46 * Return 0 on success, -EINVAL in case of bad input.
46 */ 47 */
47int hex2bin(u8 *dst, const char *src, size_t count) 48int hex2bin(u8 *dst, const char *src, size_t count)
48{ 49{
@@ -51,7 +52,7 @@ int hex2bin(u8 *dst, const char *src, size_t count)
51 int lo = hex_to_bin(*src++); 52 int lo = hex_to_bin(*src++);
52 53
53 if ((hi < 0) || (lo < 0)) 54 if ((hi < 0) || (lo < 0))
54 return -1; 55 return -EINVAL;
55 56
56 *dst++ = (hi << 4) | lo; 57 *dst++ = (hi << 4) | lo;
57 } 58 }
diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c
index df495fe81421..0e343fd29570 100644
--- a/lib/interval_tree_test.c
+++ b/lib/interval_tree_test.c
@@ -19,14 +19,14 @@ __param(bool, search_all, false, "Searches will iterate all nodes in the tree");
19 19
20__param(uint, max_endpoint, ~0, "Largest value for the interval's endpoint"); 20__param(uint, max_endpoint, ~0, "Largest value for the interval's endpoint");
21 21
22static struct rb_root root = RB_ROOT; 22static struct rb_root_cached root = RB_ROOT_CACHED;
23static struct interval_tree_node *nodes = NULL; 23static struct interval_tree_node *nodes = NULL;
24static u32 *queries = NULL; 24static u32 *queries = NULL;
25 25
26static struct rnd_state rnd; 26static struct rnd_state rnd;
27 27
28static inline unsigned long 28static inline unsigned long
29search(struct rb_root *root, unsigned long start, unsigned long last) 29search(struct rb_root_cached *root, unsigned long start, unsigned long last)
30{ 30{
31 struct interval_tree_node *node; 31 struct interval_tree_node *node;
32 unsigned long results = 0; 32 unsigned long results = 0;
diff --git a/lib/oid_registry.c b/lib/oid_registry.c
index 318f382a010d..41b9e50711a7 100644
--- a/lib/oid_registry.c
+++ b/lib/oid_registry.c
@@ -142,9 +142,9 @@ int sprint_oid(const void *data, size_t datasize, char *buffer, size_t bufsize)
142 } 142 }
143 ret += count = snprintf(buffer, bufsize, ".%lu", num); 143 ret += count = snprintf(buffer, bufsize, ".%lu", num);
144 buffer += count; 144 buffer += count;
145 bufsize -= count; 145 if (bufsize <= count)
146 if (bufsize == 0)
147 return -ENOBUFS; 146 return -ENOBUFS;
147 bufsize -= count;
148 } 148 }
149 149
150 return ret; 150 return ret;
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 9717e2a50374..8b1feca1230a 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -463,7 +463,7 @@ radix_tree_node_free(struct radix_tree_node *node)
463 * To make use of this facility, the radix tree must be initialised without 463 * To make use of this facility, the radix tree must be initialised without
464 * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE(). 464 * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE().
465 */ 465 */
466static int __radix_tree_preload(gfp_t gfp_mask, unsigned nr) 466static __must_check int __radix_tree_preload(gfp_t gfp_mask, unsigned nr)
467{ 467{
468 struct radix_tree_preload *rtp; 468 struct radix_tree_preload *rtp;
469 struct radix_tree_node *node; 469 struct radix_tree_node *node;
@@ -2104,7 +2104,8 @@ EXPORT_SYMBOL(radix_tree_tagged);
2104 */ 2104 */
2105void idr_preload(gfp_t gfp_mask) 2105void idr_preload(gfp_t gfp_mask)
2106{ 2106{
2107 __radix_tree_preload(gfp_mask, IDR_PRELOAD_SIZE); 2107 if (__radix_tree_preload(gfp_mask, IDR_PRELOAD_SIZE))
2108 preempt_disable();
2108} 2109}
2109EXPORT_SYMBOL(idr_preload); 2110EXPORT_SYMBOL(idr_preload);
2110 2111
@@ -2118,13 +2119,13 @@ EXPORT_SYMBOL(idr_preload);
2118 */ 2119 */
2119int ida_pre_get(struct ida *ida, gfp_t gfp) 2120int ida_pre_get(struct ida *ida, gfp_t gfp)
2120{ 2121{
2121 __radix_tree_preload(gfp, IDA_PRELOAD_SIZE);
2122 /* 2122 /*
2123 * The IDA API has no preload_end() equivalent. Instead, 2123 * The IDA API has no preload_end() equivalent. Instead,
2124 * ida_get_new() can return -EAGAIN, prompting the caller 2124 * ida_get_new() can return -EAGAIN, prompting the caller
2125 * to return to the ida_pre_get() step. 2125 * to return to the ida_pre_get() step.
2126 */ 2126 */
2127 preempt_enable(); 2127 if (!__radix_tree_preload(gfp, IDA_PRELOAD_SIZE))
2128 preempt_enable();
2128 2129
2129 if (!this_cpu_read(ida_bitmap)) { 2130 if (!this_cpu_read(ida_bitmap)) {
2130 struct ida_bitmap *bitmap = kmalloc(sizeof(*bitmap), gfp); 2131 struct ida_bitmap *bitmap = kmalloc(sizeof(*bitmap), gfp);
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 4ba2828a67c0..ba4a9d165f1b 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -95,22 +95,35 @@ __rb_rotate_set_parents(struct rb_node *old, struct rb_node *new,
95 95
96static __always_inline void 96static __always_inline void
97__rb_insert(struct rb_node *node, struct rb_root *root, 97__rb_insert(struct rb_node *node, struct rb_root *root,
98 bool newleft, struct rb_node **leftmost,
98 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 99 void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
99{ 100{
100 struct rb_node *parent = rb_red_parent(node), *gparent, *tmp; 101 struct rb_node *parent = rb_red_parent(node), *gparent, *tmp;
101 102
103 if (newleft)
104 *leftmost = node;
105
102 while (true) { 106 while (true) {
103 /* 107 /*
104 * Loop invariant: node is red 108 * Loop invariant: node is red.
105 *
106 * If there is a black parent, we are done.
107 * Otherwise, take some corrective action as we don't
108 * want a red root or two consecutive red nodes.
109 */ 109 */
110 if (!parent) { 110 if (unlikely(!parent)) {
111 /*
112 * The inserted node is root. Either this is the
113 * first node, or we recursed at Case 1 below and
114 * are no longer violating 4).
115 */
111 rb_set_parent_color(node, NULL, RB_BLACK); 116 rb_set_parent_color(node, NULL, RB_BLACK);
112 break; 117 break;
113 } else if (rb_is_black(parent)) 118 }
119
120 /*
121 * If there is a black parent, we are done.
122 * Otherwise, take some corrective action as,
123 * per 4), we don't want a red root or two
124 * consecutive red nodes.
125 */
126 if(rb_is_black(parent))
114 break; 127 break;
115 128
116 gparent = rb_red_parent(parent); 129 gparent = rb_red_parent(parent);
@@ -119,7 +132,7 @@ __rb_insert(struct rb_node *node, struct rb_root *root,
119 if (parent != tmp) { /* parent == gparent->rb_left */ 132 if (parent != tmp) { /* parent == gparent->rb_left */
120 if (tmp && rb_is_red(tmp)) { 133 if (tmp && rb_is_red(tmp)) {
121 /* 134 /*
122 * Case 1 - color flips 135 * Case 1 - node's uncle is red (color flips).
123 * 136 *
124 * G g 137 * G g
125 * / \ / \ 138 * / \ / \
@@ -142,7 +155,8 @@ __rb_insert(struct rb_node *node, struct rb_root *root,
142 tmp = parent->rb_right; 155 tmp = parent->rb_right;
143 if (node == tmp) { 156 if (node == tmp) {
144 /* 157 /*
145 * Case 2 - left rotate at parent 158 * Case 2 - node's uncle is black and node is
159 * the parent's right child (left rotate at parent).
146 * 160 *
147 * G G 161 * G G
148 * / \ / \ 162 * / \ / \
@@ -166,7 +180,8 @@ __rb_insert(struct rb_node *node, struct rb_root *root,
166 } 180 }
167 181
168 /* 182 /*
169 * Case 3 - right rotate at gparent 183 * Case 3 - node's uncle is black and node is
184 * the parent's left child (right rotate at gparent).
170 * 185 *
171 * G P 186 * G P
172 * / \ / \ 187 * / \ / \
@@ -434,19 +449,38 @@ static const struct rb_augment_callbacks dummy_callbacks = {
434 449
435void rb_insert_color(struct rb_node *node, struct rb_root *root) 450void rb_insert_color(struct rb_node *node, struct rb_root *root)
436{ 451{
437 __rb_insert(node, root, dummy_rotate); 452 __rb_insert(node, root, false, NULL, dummy_rotate);
438} 453}
439EXPORT_SYMBOL(rb_insert_color); 454EXPORT_SYMBOL(rb_insert_color);
440 455
441void rb_erase(struct rb_node *node, struct rb_root *root) 456void rb_erase(struct rb_node *node, struct rb_root *root)
442{ 457{
443 struct rb_node *rebalance; 458 struct rb_node *rebalance;
444 rebalance = __rb_erase_augmented(node, root, &dummy_callbacks); 459 rebalance = __rb_erase_augmented(node, root,
460 NULL, &dummy_callbacks);
445 if (rebalance) 461 if (rebalance)
446 ____rb_erase_color(rebalance, root, dummy_rotate); 462 ____rb_erase_color(rebalance, root, dummy_rotate);
447} 463}
448EXPORT_SYMBOL(rb_erase); 464EXPORT_SYMBOL(rb_erase);
449 465
466void rb_insert_color_cached(struct rb_node *node,
467 struct rb_root_cached *root, bool leftmost)
468{
469 __rb_insert(node, &root->rb_root, leftmost,
470 &root->rb_leftmost, dummy_rotate);
471}
472EXPORT_SYMBOL(rb_insert_color_cached);
473
474void rb_erase_cached(struct rb_node *node, struct rb_root_cached *root)
475{
476 struct rb_node *rebalance;
477 rebalance = __rb_erase_augmented(node, &root->rb_root,
478 &root->rb_leftmost, &dummy_callbacks);
479 if (rebalance)
480 ____rb_erase_color(rebalance, &root->rb_root, dummy_rotate);
481}
482EXPORT_SYMBOL(rb_erase_cached);
483
450/* 484/*
451 * Augmented rbtree manipulation functions. 485 * Augmented rbtree manipulation functions.
452 * 486 *
@@ -455,9 +489,10 @@ EXPORT_SYMBOL(rb_erase);
455 */ 489 */
456 490
457void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 491void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
492 bool newleft, struct rb_node **leftmost,
458 void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 493 void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
459{ 494{
460 __rb_insert(node, root, augment_rotate); 495 __rb_insert(node, root, newleft, leftmost, augment_rotate);
461} 496}
462EXPORT_SYMBOL(__rb_insert_augmented); 497EXPORT_SYMBOL(__rb_insert_augmented);
463 498
@@ -502,7 +537,7 @@ struct rb_node *rb_next(const struct rb_node *node)
502 * as we can. 537 * as we can.
503 */ 538 */
504 if (node->rb_right) { 539 if (node->rb_right) {
505 node = node->rb_right; 540 node = node->rb_right;
506 while (node->rb_left) 541 while (node->rb_left)
507 node=node->rb_left; 542 node=node->rb_left;
508 return (struct rb_node *)node; 543 return (struct rb_node *)node;
@@ -534,7 +569,7 @@ struct rb_node *rb_prev(const struct rb_node *node)
534 * as we can. 569 * as we can.
535 */ 570 */
536 if (node->rb_left) { 571 if (node->rb_left) {
537 node = node->rb_left; 572 node = node->rb_left;
538 while (node->rb_right) 573 while (node->rb_right)
539 node=node->rb_right; 574 node=node->rb_right;
540 return (struct rb_node *)node; 575 return (struct rb_node *)node;
diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index 8b3c9dc88262..191a238e5a9d 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -1,11 +1,18 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/moduleparam.h>
2#include <linux/rbtree_augmented.h> 3#include <linux/rbtree_augmented.h>
3#include <linux/random.h> 4#include <linux/random.h>
5#include <linux/slab.h>
4#include <asm/timex.h> 6#include <asm/timex.h>
5 7
6#define NODES 100 8#define __param(type, name, init, msg) \
7#define PERF_LOOPS 100000 9 static type name = init; \
8#define CHECK_LOOPS 100 10 module_param(name, type, 0444); \
11 MODULE_PARM_DESC(name, msg);
12
13__param(int, nnodes, 100, "Number of nodes in the rb-tree");
14__param(int, perf_loops, 100000, "Number of iterations modifying the rb-tree");
15__param(int, check_loops, 100, "Number of iterations modifying and verifying the rb-tree");
9 16
10struct test_node { 17struct test_node {
11 u32 key; 18 u32 key;
@@ -16,14 +23,14 @@ struct test_node {
16 u32 augmented; 23 u32 augmented;
17}; 24};
18 25
19static struct rb_root root = RB_ROOT; 26static struct rb_root_cached root = RB_ROOT_CACHED;
20static struct test_node nodes[NODES]; 27static struct test_node *nodes = NULL;
21 28
22static struct rnd_state rnd; 29static struct rnd_state rnd;
23 30
24static void insert(struct test_node *node, struct rb_root *root) 31static void insert(struct test_node *node, struct rb_root_cached *root)
25{ 32{
26 struct rb_node **new = &root->rb_node, *parent = NULL; 33 struct rb_node **new = &root->rb_root.rb_node, *parent = NULL;
27 u32 key = node->key; 34 u32 key = node->key;
28 35
29 while (*new) { 36 while (*new) {
@@ -35,14 +42,40 @@ static void insert(struct test_node *node, struct rb_root *root)
35 } 42 }
36 43
37 rb_link_node(&node->rb, parent, new); 44 rb_link_node(&node->rb, parent, new);
38 rb_insert_color(&node->rb, root); 45 rb_insert_color(&node->rb, &root->rb_root);
46}
47
48static void insert_cached(struct test_node *node, struct rb_root_cached *root)
49{
50 struct rb_node **new = &root->rb_root.rb_node, *parent = NULL;
51 u32 key = node->key;
52 bool leftmost = true;
53
54 while (*new) {
55 parent = *new;
56 if (key < rb_entry(parent, struct test_node, rb)->key)
57 new = &parent->rb_left;
58 else {
59 new = &parent->rb_right;
60 leftmost = false;
61 }
62 }
63
64 rb_link_node(&node->rb, parent, new);
65 rb_insert_color_cached(&node->rb, root, leftmost);
39} 66}
40 67
41static inline void erase(struct test_node *node, struct rb_root *root) 68static inline void erase(struct test_node *node, struct rb_root_cached *root)
42{ 69{
43 rb_erase(&node->rb, root); 70 rb_erase(&node->rb, &root->rb_root);
44} 71}
45 72
73static inline void erase_cached(struct test_node *node, struct rb_root_cached *root)
74{
75 rb_erase_cached(&node->rb, root);
76}
77
78
46static inline u32 augment_recompute(struct test_node *node) 79static inline u32 augment_recompute(struct test_node *node)
47{ 80{
48 u32 max = node->val, child_augmented; 81 u32 max = node->val, child_augmented;
@@ -64,9 +97,10 @@ static inline u32 augment_recompute(struct test_node *node)
64RB_DECLARE_CALLBACKS(static, augment_callbacks, struct test_node, rb, 97RB_DECLARE_CALLBACKS(static, augment_callbacks, struct test_node, rb,
65 u32, augmented, augment_recompute) 98 u32, augmented, augment_recompute)
66 99
67static void insert_augmented(struct test_node *node, struct rb_root *root) 100static void insert_augmented(struct test_node *node,
101 struct rb_root_cached *root)
68{ 102{
69 struct rb_node **new = &root->rb_node, *rb_parent = NULL; 103 struct rb_node **new = &root->rb_root.rb_node, *rb_parent = NULL;
70 u32 key = node->key; 104 u32 key = node->key;
71 u32 val = node->val; 105 u32 val = node->val;
72 struct test_node *parent; 106 struct test_node *parent;
@@ -84,18 +118,53 @@ static void insert_augmented(struct test_node *node, struct rb_root *root)
84 118
85 node->augmented = val; 119 node->augmented = val;
86 rb_link_node(&node->rb, rb_parent, new); 120 rb_link_node(&node->rb, rb_parent, new);
87 rb_insert_augmented(&node->rb, root, &augment_callbacks); 121 rb_insert_augmented(&node->rb, &root->rb_root, &augment_callbacks);
122}
123
124static void insert_augmented_cached(struct test_node *node,
125 struct rb_root_cached *root)
126{
127 struct rb_node **new = &root->rb_root.rb_node, *rb_parent = NULL;
128 u32 key = node->key;
129 u32 val = node->val;
130 struct test_node *parent;
131 bool leftmost = true;
132
133 while (*new) {
134 rb_parent = *new;
135 parent = rb_entry(rb_parent, struct test_node, rb);
136 if (parent->augmented < val)
137 parent->augmented = val;
138 if (key < parent->key)
139 new = &parent->rb.rb_left;
140 else {
141 new = &parent->rb.rb_right;
142 leftmost = false;
143 }
144 }
145
146 node->augmented = val;
147 rb_link_node(&node->rb, rb_parent, new);
148 rb_insert_augmented_cached(&node->rb, root,
149 leftmost, &augment_callbacks);
150}
151
152
153static void erase_augmented(struct test_node *node, struct rb_root_cached *root)
154{
155 rb_erase_augmented(&node->rb, &root->rb_root, &augment_callbacks);
88} 156}
89 157
90static void erase_augmented(struct test_node *node, struct rb_root *root) 158static void erase_augmented_cached(struct test_node *node,
159 struct rb_root_cached *root)
91{ 160{
92 rb_erase_augmented(&node->rb, root, &augment_callbacks); 161 rb_erase_augmented_cached(&node->rb, root, &augment_callbacks);
93} 162}
94 163
95static void init(void) 164static void init(void)
96{ 165{
97 int i; 166 int i;
98 for (i = 0; i < NODES; i++) { 167 for (i = 0; i < nnodes; i++) {
99 nodes[i].key = prandom_u32_state(&rnd); 168 nodes[i].key = prandom_u32_state(&rnd);
100 nodes[i].val = prandom_u32_state(&rnd); 169 nodes[i].val = prandom_u32_state(&rnd);
101 } 170 }
@@ -118,7 +187,7 @@ static void check_postorder_foreach(int nr_nodes)
118{ 187{
119 struct test_node *cur, *n; 188 struct test_node *cur, *n;
120 int count = 0; 189 int count = 0;
121 rbtree_postorder_for_each_entry_safe(cur, n, &root, rb) 190 rbtree_postorder_for_each_entry_safe(cur, n, &root.rb_root, rb)
122 count++; 191 count++;
123 192
124 WARN_ON_ONCE(count != nr_nodes); 193 WARN_ON_ONCE(count != nr_nodes);
@@ -128,7 +197,7 @@ static void check_postorder(int nr_nodes)
128{ 197{
129 struct rb_node *rb; 198 struct rb_node *rb;
130 int count = 0; 199 int count = 0;
131 for (rb = rb_first_postorder(&root); rb; rb = rb_next_postorder(rb)) 200 for (rb = rb_first_postorder(&root.rb_root); rb; rb = rb_next_postorder(rb))
132 count++; 201 count++;
133 202
134 WARN_ON_ONCE(count != nr_nodes); 203 WARN_ON_ONCE(count != nr_nodes);
@@ -140,7 +209,7 @@ static void check(int nr_nodes)
140 int count = 0, blacks = 0; 209 int count = 0, blacks = 0;
141 u32 prev_key = 0; 210 u32 prev_key = 0;
142 211
143 for (rb = rb_first(&root); rb; rb = rb_next(rb)) { 212 for (rb = rb_first(&root.rb_root); rb; rb = rb_next(rb)) {
144 struct test_node *node = rb_entry(rb, struct test_node, rb); 213 struct test_node *node = rb_entry(rb, struct test_node, rb);
145 WARN_ON_ONCE(node->key < prev_key); 214 WARN_ON_ONCE(node->key < prev_key);
146 WARN_ON_ONCE(is_red(rb) && 215 WARN_ON_ONCE(is_red(rb) &&
@@ -155,7 +224,7 @@ static void check(int nr_nodes)
155 } 224 }
156 225
157 WARN_ON_ONCE(count != nr_nodes); 226 WARN_ON_ONCE(count != nr_nodes);
158 WARN_ON_ONCE(count < (1 << black_path_count(rb_last(&root))) - 1); 227 WARN_ON_ONCE(count < (1 << black_path_count(rb_last(&root.rb_root))) - 1);
159 228
160 check_postorder(nr_nodes); 229 check_postorder(nr_nodes);
161 check_postorder_foreach(nr_nodes); 230 check_postorder_foreach(nr_nodes);
@@ -166,7 +235,7 @@ static void check_augmented(int nr_nodes)
166 struct rb_node *rb; 235 struct rb_node *rb;
167 236
168 check(nr_nodes); 237 check(nr_nodes);
169 for (rb = rb_first(&root); rb; rb = rb_next(rb)) { 238 for (rb = rb_first(&root.rb_root); rb; rb = rb_next(rb)) {
170 struct test_node *node = rb_entry(rb, struct test_node, rb); 239 struct test_node *node = rb_entry(rb, struct test_node, rb);
171 WARN_ON_ONCE(node->augmented != augment_recompute(node)); 240 WARN_ON_ONCE(node->augmented != augment_recompute(node));
172 } 241 }
@@ -176,6 +245,11 @@ static int __init rbtree_test_init(void)
176{ 245{
177 int i, j; 246 int i, j;
178 cycles_t time1, time2, time; 247 cycles_t time1, time2, time;
248 struct rb_node *node;
249
250 nodes = kmalloc(nnodes * sizeof(*nodes), GFP_KERNEL);
251 if (!nodes)
252 return -ENOMEM;
179 253
180 printk(KERN_ALERT "rbtree testing"); 254 printk(KERN_ALERT "rbtree testing");
181 255
@@ -184,27 +258,88 @@ static int __init rbtree_test_init(void)
184 258
185 time1 = get_cycles(); 259 time1 = get_cycles();
186 260
187 for (i = 0; i < PERF_LOOPS; i++) { 261 for (i = 0; i < perf_loops; i++) {
188 for (j = 0; j < NODES; j++) 262 for (j = 0; j < nnodes; j++)
189 insert(nodes + j, &root); 263 insert(nodes + j, &root);
190 for (j = 0; j < NODES; j++) 264 for (j = 0; j < nnodes; j++)
191 erase(nodes + j, &root); 265 erase(nodes + j, &root);
192 } 266 }
193 267
194 time2 = get_cycles(); 268 time2 = get_cycles();
195 time = time2 - time1; 269 time = time2 - time1;
196 270
197 time = div_u64(time, PERF_LOOPS); 271 time = div_u64(time, perf_loops);
198 printk(" -> %llu cycles\n", (unsigned long long)time); 272 printk(" -> test 1 (latency of nnodes insert+delete): %llu cycles\n",
273 (unsigned long long)time);
274
275 time1 = get_cycles();
276
277 for (i = 0; i < perf_loops; i++) {
278 for (j = 0; j < nnodes; j++)
279 insert_cached(nodes + j, &root);
280 for (j = 0; j < nnodes; j++)
281 erase_cached(nodes + j, &root);
282 }
283
284 time2 = get_cycles();
285 time = time2 - time1;
286
287 time = div_u64(time, perf_loops);
288 printk(" -> test 2 (latency of nnodes cached insert+delete): %llu cycles\n",
289 (unsigned long long)time);
290
291 for (i = 0; i < nnodes; i++)
292 insert(nodes + i, &root);
293
294 time1 = get_cycles();
295
296 for (i = 0; i < perf_loops; i++) {
297 for (node = rb_first(&root.rb_root); node; node = rb_next(node))
298 ;
299 }
300
301 time2 = get_cycles();
302 time = time2 - time1;
303
304 time = div_u64(time, perf_loops);
305 printk(" -> test 3 (latency of inorder traversal): %llu cycles\n",
306 (unsigned long long)time);
307
308 time1 = get_cycles();
309
310 for (i = 0; i < perf_loops; i++)
311 node = rb_first(&root.rb_root);
312
313 time2 = get_cycles();
314 time = time2 - time1;
315
316 time = div_u64(time, perf_loops);
317 printk(" -> test 4 (latency to fetch first node)\n");
318 printk(" non-cached: %llu cycles\n", (unsigned long long)time);
319
320 time1 = get_cycles();
321
322 for (i = 0; i < perf_loops; i++)
323 node = rb_first_cached(&root);
324
325 time2 = get_cycles();
326 time = time2 - time1;
327
328 time = div_u64(time, perf_loops);
329 printk(" cached: %llu cycles\n", (unsigned long long)time);
199 330
200 for (i = 0; i < CHECK_LOOPS; i++) { 331 for (i = 0; i < nnodes; i++)
332 erase(nodes + i, &root);
333
334 /* run checks */
335 for (i = 0; i < check_loops; i++) {
201 init(); 336 init();
202 for (j = 0; j < NODES; j++) { 337 for (j = 0; j < nnodes; j++) {
203 check(j); 338 check(j);
204 insert(nodes + j, &root); 339 insert(nodes + j, &root);
205 } 340 }
206 for (j = 0; j < NODES; j++) { 341 for (j = 0; j < nnodes; j++) {
207 check(NODES - j); 342 check(nnodes - j);
208 erase(nodes + j, &root); 343 erase(nodes + j, &root);
209 } 344 }
210 check(0); 345 check(0);
@@ -216,32 +351,49 @@ static int __init rbtree_test_init(void)
216 351
217 time1 = get_cycles(); 352 time1 = get_cycles();
218 353
219 for (i = 0; i < PERF_LOOPS; i++) { 354 for (i = 0; i < perf_loops; i++) {
220 for (j = 0; j < NODES; j++) 355 for (j = 0; j < nnodes; j++)
221 insert_augmented(nodes + j, &root); 356 insert_augmented(nodes + j, &root);
222 for (j = 0; j < NODES; j++) 357 for (j = 0; j < nnodes; j++)
223 erase_augmented(nodes + j, &root); 358 erase_augmented(nodes + j, &root);
224 } 359 }
225 360
226 time2 = get_cycles(); 361 time2 = get_cycles();
227 time = time2 - time1; 362 time = time2 - time1;
228 363
229 time = div_u64(time, PERF_LOOPS); 364 time = div_u64(time, perf_loops);
230 printk(" -> %llu cycles\n", (unsigned long long)time); 365 printk(" -> test 1 (latency of nnodes insert+delete): %llu cycles\n", (unsigned long long)time);
366
367 time1 = get_cycles();
368
369 for (i = 0; i < perf_loops; i++) {
370 for (j = 0; j < nnodes; j++)
371 insert_augmented_cached(nodes + j, &root);
372 for (j = 0; j < nnodes; j++)
373 erase_augmented_cached(nodes + j, &root);
374 }
375
376 time2 = get_cycles();
377 time = time2 - time1;
378
379 time = div_u64(time, perf_loops);
380 printk(" -> test 2 (latency of nnodes cached insert+delete): %llu cycles\n", (unsigned long long)time);
231 381
232 for (i = 0; i < CHECK_LOOPS; i++) { 382 for (i = 0; i < check_loops; i++) {
233 init(); 383 init();
234 for (j = 0; j < NODES; j++) { 384 for (j = 0; j < nnodes; j++) {
235 check_augmented(j); 385 check_augmented(j);
236 insert_augmented(nodes + j, &root); 386 insert_augmented(nodes + j, &root);
237 } 387 }
238 for (j = 0; j < NODES; j++) { 388 for (j = 0; j < nnodes; j++) {
239 check_augmented(NODES - j); 389 check_augmented(nnodes - j);
240 erase_augmented(nodes + j, &root); 390 erase_augmented(nodes + j, &root);
241 } 391 }
242 check_augmented(0); 392 check_augmented(0);
243 } 393 }
244 394
395 kfree(nodes);
396
245 return -EAGAIN; /* Fail will directly unload the module */ 397 return -EAGAIN; /* Fail will directly unload the module */
246} 398}
247 399
diff --git a/lib/string.c b/lib/string.c
index ebbb99c775bd..9921dc202db4 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -723,6 +723,72 @@ void memzero_explicit(void *s, size_t count)
723} 723}
724EXPORT_SYMBOL(memzero_explicit); 724EXPORT_SYMBOL(memzero_explicit);
725 725
726#ifndef __HAVE_ARCH_MEMSET16
727/**
728 * memset16() - Fill a memory area with a uint16_t
729 * @s: Pointer to the start of the area.
730 * @v: The value to fill the area with
731 * @count: The number of values to store
732 *
733 * Differs from memset() in that it fills with a uint16_t instead
734 * of a byte. Remember that @count is the number of uint16_ts to
735 * store, not the number of bytes.
736 */
737void *memset16(uint16_t *s, uint16_t v, size_t count)
738{
739 uint16_t *xs = s;
740
741 while (count--)
742 *xs++ = v;
743 return s;
744}
745EXPORT_SYMBOL(memset16);
746#endif
747
748#ifndef __HAVE_ARCH_MEMSET32
749/**
750 * memset32() - Fill a memory area with a uint32_t
751 * @s: Pointer to the start of the area.
752 * @v: The value to fill the area with
753 * @count: The number of values to store
754 *
755 * Differs from memset() in that it fills with a uint32_t instead
756 * of a byte. Remember that @count is the number of uint32_ts to
757 * store, not the number of bytes.
758 */
759void *memset32(uint32_t *s, uint32_t v, size_t count)
760{
761 uint32_t *xs = s;
762
763 while (count--)
764 *xs++ = v;
765 return s;
766}
767EXPORT_SYMBOL(memset32);
768#endif
769
770#ifndef __HAVE_ARCH_MEMSET64
771/**
772 * memset64() - Fill a memory area with a uint64_t
773 * @s: Pointer to the start of the area.
774 * @v: The value to fill the area with
775 * @count: The number of values to store
776 *
777 * Differs from memset() in that it fills with a uint64_t instead
778 * of a byte. Remember that @count is the number of uint64_ts to
779 * store, not the number of bytes.
780 */
781void *memset64(uint64_t *s, uint64_t v, size_t count)
782{
783 uint64_t *xs = s;
784
785 while (count--)
786 *xs++ = v;
787 return s;
788}
789EXPORT_SYMBOL(memset64);
790#endif
791
726#ifndef __HAVE_ARCH_MEMCPY 792#ifndef __HAVE_ARCH_MEMCPY
727/** 793/**
728 * memcpy - Copy one area of memory to another 794 * memcpy - Copy one area of memory to another
@@ -985,3 +1051,144 @@ void fortify_panic(const char *name)
985 BUG(); 1051 BUG();
986} 1052}
987EXPORT_SYMBOL(fortify_panic); 1053EXPORT_SYMBOL(fortify_panic);
1054
1055#ifdef CONFIG_STRING_SELFTEST
1056#include <linux/slab.h>
1057#include <linux/module.h>
1058
1059static __init int memset16_selftest(void)
1060{
1061 unsigned i, j, k;
1062 u16 v, *p;
1063
1064 p = kmalloc(256 * 2 * 2, GFP_KERNEL);
1065 if (!p)
1066 return -1;
1067
1068 for (i = 0; i < 256; i++) {
1069 for (j = 0; j < 256; j++) {
1070 memset(p, 0xa1, 256 * 2 * sizeof(v));
1071 memset16(p + i, 0xb1b2, j);
1072 for (k = 0; k < 512; k++) {
1073 v = p[k];
1074 if (k < i) {
1075 if (v != 0xa1a1)
1076 goto fail;
1077 } else if (k < i + j) {
1078 if (v != 0xb1b2)
1079 goto fail;
1080 } else {
1081 if (v != 0xa1a1)
1082 goto fail;
1083 }
1084 }
1085 }
1086 }
1087
1088fail:
1089 kfree(p);
1090 if (i < 256)
1091 return (i << 24) | (j << 16) | k;
1092 return 0;
1093}
1094
1095static __init int memset32_selftest(void)
1096{
1097 unsigned i, j, k;
1098 u32 v, *p;
1099
1100 p = kmalloc(256 * 2 * 4, GFP_KERNEL);
1101 if (!p)
1102 return -1;
1103
1104 for (i = 0; i < 256; i++) {
1105 for (j = 0; j < 256; j++) {
1106 memset(p, 0xa1, 256 * 2 * sizeof(v));
1107 memset32(p + i, 0xb1b2b3b4, j);
1108 for (k = 0; k < 512; k++) {
1109 v = p[k];
1110 if (k < i) {
1111 if (v != 0xa1a1a1a1)
1112 goto fail;
1113 } else if (k < i + j) {
1114 if (v != 0xb1b2b3b4)
1115 goto fail;
1116 } else {
1117 if (v != 0xa1a1a1a1)
1118 goto fail;
1119 }
1120 }
1121 }
1122 }
1123
1124fail:
1125 kfree(p);
1126 if (i < 256)
1127 return (i << 24) | (j << 16) | k;
1128 return 0;
1129}
1130
1131static __init int memset64_selftest(void)
1132{
1133 unsigned i, j, k;
1134 u64 v, *p;
1135
1136 p = kmalloc(256 * 2 * 8, GFP_KERNEL);
1137 if (!p)
1138 return -1;
1139
1140 for (i = 0; i < 256; i++) {
1141 for (j = 0; j < 256; j++) {
1142 memset(p, 0xa1, 256 * 2 * sizeof(v));
1143 memset64(p + i, 0xb1b2b3b4b5b6b7b8ULL, j);
1144 for (k = 0; k < 512; k++) {
1145 v = p[k];
1146 if (k < i) {
1147 if (v != 0xa1a1a1a1a1a1a1a1ULL)
1148 goto fail;
1149 } else if (k < i + j) {
1150 if (v != 0xb1b2b3b4b5b6b7b8ULL)
1151 goto fail;
1152 } else {
1153 if (v != 0xa1a1a1a1a1a1a1a1ULL)
1154 goto fail;
1155 }
1156 }
1157 }
1158 }
1159
1160fail:
1161 kfree(p);
1162 if (i < 256)
1163 return (i << 24) | (j << 16) | k;
1164 return 0;
1165}
1166
1167static __init int string_selftest_init(void)
1168{
1169 int test, subtest;
1170
1171 test = 1;
1172 subtest = memset16_selftest();
1173 if (subtest)
1174 goto fail;
1175
1176 test = 2;
1177 subtest = memset32_selftest();
1178 if (subtest)
1179 goto fail;
1180
1181 test = 3;
1182 subtest = memset64_selftest();
1183 if (subtest)
1184 goto fail;
1185
1186 pr_info("String selftests succeeded\n");
1187 return 0;
1188fail:
1189 pr_crit("String selftest failure %d.%08x\n", test, subtest);
1190 return 0;
1191}
1192
1193module_init(string_selftest_init);
1194#endif /* CONFIG_STRING_SELFTEST */
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 2526a2975c51..599c6713f2a2 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -165,6 +165,96 @@ static void __init test_zero_fill_copy(void)
165 expect_eq_pbl("128-1023", bmap2, 1024); 165 expect_eq_pbl("128-1023", bmap2, 1024);
166} 166}
167 167
168#define PARSE_TIME 0x1
169
170struct test_bitmap_parselist{
171 const int errno;
172 const char *in;
173 const unsigned long *expected;
174 const int nbits;
175 const int flags;
176};
177
178static const unsigned long exp[] __initconst = {
179 BITMAP_FROM_U64(1),
180 BITMAP_FROM_U64(2),
181 BITMAP_FROM_U64(0x0000ffff),
182 BITMAP_FROM_U64(0xffff0000),
183 BITMAP_FROM_U64(0x55555555),
184 BITMAP_FROM_U64(0xaaaaaaaa),
185 BITMAP_FROM_U64(0x11111111),
186 BITMAP_FROM_U64(0x22222222),
187 BITMAP_FROM_U64(0xffffffff),
188 BITMAP_FROM_U64(0xfffffffe),
189 BITMAP_FROM_U64(0x3333333311111111),
190 BITMAP_FROM_U64(0xffffffff77777777)
191};
192
193static const unsigned long exp2[] __initconst = {
194 BITMAP_FROM_U64(0x3333333311111111),
195 BITMAP_FROM_U64(0xffffffff77777777)
196};
197
198static const struct test_bitmap_parselist parselist_tests[] __initconst = {
199#define step (sizeof(u64) / sizeof(unsigned long))
200
201 {0, "0", &exp[0], 8, 0},
202 {0, "1", &exp[1 * step], 8, 0},
203 {0, "0-15", &exp[2 * step], 32, 0},
204 {0, "16-31", &exp[3 * step], 32, 0},
205 {0, "0-31:1/2", &exp[4 * step], 32, 0},
206 {0, "1-31:1/2", &exp[5 * step], 32, 0},
207 {0, "0-31:1/4", &exp[6 * step], 32, 0},
208 {0, "1-31:1/4", &exp[7 * step], 32, 0},
209 {0, "0-31:4/4", &exp[8 * step], 32, 0},
210 {0, "1-31:4/4", &exp[9 * step], 32, 0},
211 {0, "0-31:1/4,32-63:2/4", &exp[10 * step], 64, 0},
212 {0, "0-31:3/4,32-63:4/4", &exp[11 * step], 64, 0},
213
214 {0, "0-31:1/4,32-63:2/4,64-95:3/4,96-127:4/4", exp2, 128, 0},
215
216 {0, "0-2047:128/256", NULL, 2048, PARSE_TIME},
217
218 {-EINVAL, "-1", NULL, 8, 0},
219 {-EINVAL, "-0", NULL, 8, 0},
220 {-EINVAL, "10-1", NULL, 8, 0},
221 {-EINVAL, "0-31:10/1", NULL, 8, 0},
222};
223
224static void __init test_bitmap_parselist(void)
225{
226 int i;
227 int err;
228 cycles_t cycles;
229 DECLARE_BITMAP(bmap, 2048);
230
231 for (i = 0; i < ARRAY_SIZE(parselist_tests); i++) {
232#define ptest parselist_tests[i]
233
234 cycles = get_cycles();
235 err = bitmap_parselist(ptest.in, bmap, ptest.nbits);
236 cycles = get_cycles() - cycles;
237
238 if (err != ptest.errno) {
239 pr_err("test %d: input is %s, errno is %d, expected %d\n",
240 i, ptest.in, err, ptest.errno);
241 continue;
242 }
243
244 if (!err && ptest.expected
245 && !__bitmap_equal(bmap, ptest.expected, ptest.nbits)) {
246 pr_err("test %d: input is %s, result is 0x%lx, expected 0x%lx\n",
247 i, ptest.in, bmap[0], *ptest.expected);
248 continue;
249 }
250
251 if (ptest.flags & PARSE_TIME)
252 pr_err("test %d: input is '%s' OK, Time: %llu\n",
253 i, ptest.in,
254 (unsigned long long)cycles);
255 }
256}
257
168static void __init test_bitmap_u32_array_conversions(void) 258static void __init test_bitmap_u32_array_conversions(void)
169{ 259{
170 DECLARE_BITMAP(bmap1, 1024); 260 DECLARE_BITMAP(bmap1, 1024);
@@ -365,6 +455,7 @@ static int __init test_bitmap_init(void)
365{ 455{
366 test_zero_fill_copy(); 456 test_zero_fill_copy();
367 test_bitmap_u32_array_conversions(); 457 test_bitmap_u32_array_conversions();
458 test_bitmap_parselist();
368 test_mem_optimisations(); 459 test_mem_optimisations();
369 460
370 if (failed_tests == 0) 461 if (failed_tests == 0)
diff --git a/lib/test_debug_virtual.c b/lib/test_debug_virtual.c
new file mode 100644
index 000000000000..b9cdeecc19dc
--- /dev/null
+++ b/lib/test_debug_virtual.c
@@ -0,0 +1,49 @@
1#include <linux/kernel.h>
2#include <linux/module.h>
3#include <linux/export.h>
4#include <linux/mm.h>
5#include <linux/vmalloc.h>
6#include <linux/slab.h>
7#include <linux/sizes.h>
8
9#include <asm/page.h>
10#ifdef CONFIG_MIPS
11#include <asm/bootinfo.h>
12#endif
13
14struct foo {
15 unsigned int bar;
16};
17
18struct foo *foo;
19
20static int __init test_debug_virtual_init(void)
21{
22 phys_addr_t pa;
23 void *va;
24
25 va = (void *)VMALLOC_START;
26 pa = virt_to_phys(va);
27
28 pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va);
29
30 foo = kzalloc(sizeof(*foo), GFP_KERNEL);
31 if (!foo)
32 return -ENOMEM;
33
34 pa = virt_to_phys(foo);
35 va = foo;
36 pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va);
37
38 return 0;
39}
40module_init(test_debug_virtual_init);
41
42static void __exit test_debug_virtual_exit(void)
43{
44 kfree(foo);
45}
46module_exit(test_debug_virtual_exit);
47
48MODULE_LICENSE("GPL");
49MODULE_DESCRIPTION("Test module for CONFIG_DEBUG_VIRTUAL");
diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index ff9148969b92..fba78d25e825 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -924,7 +924,7 @@ static int test_dev_config_update_uint_range(struct kmod_test_device *test_dev,
924 if (ret) 924 if (ret)
925 return ret; 925 return ret;
926 926
927 if (new < min || new > max || new > UINT_MAX) 927 if (new < min || new > max)
928 return -EINVAL; 928 return -EINVAL;
929 929
930 mutex_lock(&test_dev->config_mutex); 930 mutex_lock(&test_dev->config_mutex);
@@ -946,7 +946,7 @@ static int test_dev_config_update_int(struct kmod_test_device *test_dev,
946 if (ret) 946 if (ret)
947 return ret; 947 return ret;
948 948
949 if (new > INT_MAX || new < INT_MIN) 949 if (new < INT_MIN || new > INT_MAX)
950 return -EINVAL; 950 return -EINVAL;
951 951
952 mutex_lock(&test_dev->config_mutex); 952 mutex_lock(&test_dev->config_mutex);
diff --git a/mm/Kconfig b/mm/Kconfig
index 0ded10a22639..9c4bdddd80c2 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -262,6 +262,9 @@ config MIGRATION
262config ARCH_ENABLE_HUGEPAGE_MIGRATION 262config ARCH_ENABLE_HUGEPAGE_MIGRATION
263 bool 263 bool
264 264
265config ARCH_ENABLE_THP_MIGRATION
266 bool
267
265config PHYS_ADDR_T_64BIT 268config PHYS_ADDR_T_64BIT
266 def_bool 64BIT || ARCH_PHYS_ADDR_T_64BIT 269 def_bool 64BIT || ARCH_PHYS_ADDR_T_64BIT
267 270
@@ -673,7 +676,7 @@ config ARCH_HAS_ZONE_DEVICE
673 bool 676 bool
674 677
675config ZONE_DEVICE 678config ZONE_DEVICE
676 bool "Device memory (pmem, etc...) hotplug support" 679 bool "Device memory (pmem, HMM, etc...) hotplug support"
677 depends on MEMORY_HOTPLUG 680 depends on MEMORY_HOTPLUG
678 depends on MEMORY_HOTREMOVE 681 depends on MEMORY_HOTREMOVE
679 depends on SPARSEMEM_VMEMMAP 682 depends on SPARSEMEM_VMEMMAP
@@ -689,6 +692,55 @@ config ZONE_DEVICE
689 692
690 If FS_DAX is enabled, then say Y. 693 If FS_DAX is enabled, then say Y.
691 694
695config ARCH_HAS_HMM
696 bool
697 default y
698 depends on (X86_64 || PPC64)
699 depends on ZONE_DEVICE
700 depends on MMU && 64BIT
701 depends on MEMORY_HOTPLUG
702 depends on MEMORY_HOTREMOVE
703 depends on SPARSEMEM_VMEMMAP
704
705config MIGRATE_VMA_HELPER
706 bool
707
708config HMM
709 bool
710 select MIGRATE_VMA_HELPER
711
712config HMM_MIRROR
713 bool "HMM mirror CPU page table into a device page table"
714 depends on ARCH_HAS_HMM
715 select MMU_NOTIFIER
716 select HMM
717 help
718 Select HMM_MIRROR if you want to mirror range of the CPU page table of a
719 process into a device page table. Here, mirror means "keep synchronized".
720 Prerequisites: the device must provide the ability to write-protect its
721 page tables (at PAGE_SIZE granularity), and must be able to recover from
722 the resulting potential page faults.
723
724config DEVICE_PRIVATE
725 bool "Unaddressable device memory (GPU memory, ...)"
726 depends on ARCH_HAS_HMM
727 select HMM
728
729 help
730 Allows creation of struct pages to represent unaddressable device
731 memory; i.e., memory that is only accessible from the device (or
732 group of devices). You likely also want to select HMM_MIRROR.
733
734config DEVICE_PUBLIC
735 bool "Addressable device memory (like GPU memory)"
736 depends on ARCH_HAS_HMM
737 select HMM
738
739 help
740 Allows creation of struct pages to represent addressable device
741 memory; i.e., memory that is accessible from both the device and
742 the CPU
743
692config FRAME_VECTOR 744config FRAME_VECTOR
693 bool 745 bool
694 746
diff --git a/mm/Makefile b/mm/Makefile
index 411bd24d4a7c..e3ac3aeb533b 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -104,3 +104,4 @@ obj-$(CONFIG_FRAME_VECTOR) += frame_vector.o
104obj-$(CONFIG_DEBUG_PAGE_REF) += debug_page_ref.o 104obj-$(CONFIG_DEBUG_PAGE_REF) += debug_page_ref.o
105obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o 105obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
106obj-$(CONFIG_PERCPU_STATS) += percpu-stats.o 106obj-$(CONFIG_PERCPU_STATS) += percpu-stats.o
107obj-$(CONFIG_HMM) += hmm.o
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index b06d9fe23a28..68d28924ba79 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -139,6 +139,14 @@ int balloon_page_migrate(struct address_space *mapping,
139{ 139{
140 struct balloon_dev_info *balloon = balloon_page_device(page); 140 struct balloon_dev_info *balloon = balloon_page_device(page);
141 141
142 /*
143 * We can not easily support the no copy case here so ignore it as it
144 * is unlikely to be use with ballon pages. See include/linux/hmm.h for
145 * user of the MIGRATE_SYNC_NO_COPY mode.
146 */
147 if (mode == MIGRATE_SYNC_NO_COPY)
148 return -EINVAL;
149
142 VM_BUG_ON_PAGE(!PageLocked(page), page); 150 VM_BUG_ON_PAGE(!PageLocked(page), page);
143 VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); 151 VM_BUG_ON_PAGE(!PageLocked(newpage), newpage);
144 152
diff --git a/mm/fadvise.c b/mm/fadvise.c
index a43013112581..702f239cd6db 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -52,7 +52,9 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
52 goto out; 52 goto out;
53 } 53 }
54 54
55 if (IS_DAX(inode)) { 55 bdi = inode_to_bdi(mapping->host);
56
57 if (IS_DAX(inode) || (bdi == &noop_backing_dev_info)) {
56 switch (advice) { 58 switch (advice) {
57 case POSIX_FADV_NORMAL: 59 case POSIX_FADV_NORMAL:
58 case POSIX_FADV_RANDOM: 60 case POSIX_FADV_RANDOM:
@@ -75,8 +77,6 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
75 else 77 else
76 endbyte--; /* inclusive */ 78 endbyte--; /* inclusive */
77 79
78 bdi = inode_to_bdi(mapping->host);
79
80 switch (advice) { 80 switch (advice) {
81 case POSIX_FADV_NORMAL: 81 case POSIX_FADV_NORMAL:
82 f.file->f_ra.ra_pages = bdi->ra_pages; 82 f.file->f_ra.ra_pages = bdi->ra_pages;
diff --git a/mm/gup.c b/mm/gup.c
index 33d651deeae2..b2b4d4263768 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -234,6 +234,16 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma,
234 return page; 234 return page;
235 return no_page_table(vma, flags); 235 return no_page_table(vma, flags);
236 } 236 }
237retry:
238 if (!pmd_present(*pmd)) {
239 if (likely(!(flags & FOLL_MIGRATION)))
240 return no_page_table(vma, flags);
241 VM_BUG_ON(thp_migration_supported() &&
242 !is_pmd_migration_entry(*pmd));
243 if (is_pmd_migration_entry(*pmd))
244 pmd_migration_entry_wait(mm, pmd);
245 goto retry;
246 }
237 if (pmd_devmap(*pmd)) { 247 if (pmd_devmap(*pmd)) {
238 ptl = pmd_lock(mm, pmd); 248 ptl = pmd_lock(mm, pmd);
239 page = follow_devmap_pmd(vma, address, pmd, flags); 249 page = follow_devmap_pmd(vma, address, pmd, flags);
@@ -247,7 +257,15 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma,
247 if ((flags & FOLL_NUMA) && pmd_protnone(*pmd)) 257 if ((flags & FOLL_NUMA) && pmd_protnone(*pmd))
248 return no_page_table(vma, flags); 258 return no_page_table(vma, flags);
249 259
260retry_locked:
250 ptl = pmd_lock(mm, pmd); 261 ptl = pmd_lock(mm, pmd);
262 if (unlikely(!pmd_present(*pmd))) {
263 spin_unlock(ptl);
264 if (likely(!(flags & FOLL_MIGRATION)))
265 return no_page_table(vma, flags);
266 pmd_migration_entry_wait(mm, pmd);
267 goto retry_locked;
268 }
251 if (unlikely(!pmd_trans_huge(*pmd))) { 269 if (unlikely(!pmd_trans_huge(*pmd))) {
252 spin_unlock(ptl); 270 spin_unlock(ptl);
253 return follow_page_pte(vma, address, pmd, flags); 271 return follow_page_pte(vma, address, pmd, flags);
@@ -424,7 +442,7 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
424 pud = pud_offset(p4d, address); 442 pud = pud_offset(p4d, address);
425 BUG_ON(pud_none(*pud)); 443 BUG_ON(pud_none(*pud));
426 pmd = pmd_offset(pud, address); 444 pmd = pmd_offset(pud, address);
427 if (pmd_none(*pmd)) 445 if (!pmd_present(*pmd))
428 return -EFAULT; 446 return -EFAULT;
429 VM_BUG_ON(pmd_trans_huge(*pmd)); 447 VM_BUG_ON(pmd_trans_huge(*pmd));
430 pte = pte_offset_map(pmd, address); 448 pte = pte_offset_map(pmd, address);
@@ -438,6 +456,13 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
438 if ((gup_flags & FOLL_DUMP) || !is_zero_pfn(pte_pfn(*pte))) 456 if ((gup_flags & FOLL_DUMP) || !is_zero_pfn(pte_pfn(*pte)))
439 goto unmap; 457 goto unmap;
440 *page = pte_page(*pte); 458 *page = pte_page(*pte);
459
460 /*
461 * This should never happen (a device public page in the gate
462 * area).
463 */
464 if (is_device_public_page(*page))
465 goto unmap;
441 } 466 }
442 get_page(*page); 467 get_page(*page);
443out: 468out:
@@ -1534,7 +1559,7 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
1534 pmd_t pmd = READ_ONCE(*pmdp); 1559 pmd_t pmd = READ_ONCE(*pmdp);
1535 1560
1536 next = pmd_addr_end(addr, end); 1561 next = pmd_addr_end(addr, end);
1537 if (pmd_none(pmd)) 1562 if (!pmd_present(pmd))
1538 return 0; 1563 return 0;
1539 1564
1540 if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd))) { 1565 if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd))) {
diff --git a/mm/hmm.c b/mm/hmm.c
new file mode 100644
index 000000000000..a88a847bccba
--- /dev/null
+++ b/mm/hmm.c
@@ -0,0 +1,1257 @@
1/*
2 * Copyright 2013 Red Hat Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * Authors: Jérôme Glisse <jglisse@redhat.com>
15 */
16/*
17 * Refer to include/linux/hmm.h for information about heterogeneous memory
18 * management or HMM for short.
19 */
20#include <linux/mm.h>
21#include <linux/hmm.h>
22#include <linux/init.h>
23#include <linux/rmap.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sched.h>
27#include <linux/mmzone.h>
28#include <linux/pagemap.h>
29#include <linux/swapops.h>
30#include <linux/hugetlb.h>
31#include <linux/memremap.h>
32#include <linux/jump_label.h>
33#include <linux/mmu_notifier.h>
34#include <linux/memory_hotplug.h>
35
36#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT)
37
38#if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC)
39/*
40 * Device private memory see HMM (Documentation/vm/hmm.txt) or hmm.h
41 */
42DEFINE_STATIC_KEY_FALSE(device_private_key);
43EXPORT_SYMBOL(device_private_key);
44#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
45
46
47#if IS_ENABLED(CONFIG_HMM_MIRROR)
48static const struct mmu_notifier_ops hmm_mmu_notifier_ops;
49
50/*
51 * struct hmm - HMM per mm struct
52 *
53 * @mm: mm struct this HMM struct is bound to
54 * @lock: lock protecting ranges list
55 * @sequence: we track updates to the CPU page table with a sequence number
56 * @ranges: list of range being snapshotted
57 * @mirrors: list of mirrors for this mm
58 * @mmu_notifier: mmu notifier to track updates to CPU page table
59 * @mirrors_sem: read/write semaphore protecting the mirrors list
60 */
61struct hmm {
62 struct mm_struct *mm;
63 spinlock_t lock;
64 atomic_t sequence;
65 struct list_head ranges;
66 struct list_head mirrors;
67 struct mmu_notifier mmu_notifier;
68 struct rw_semaphore mirrors_sem;
69};
70
71/*
72 * hmm_register - register HMM against an mm (HMM internal)
73 *
74 * @mm: mm struct to attach to
75 *
76 * This is not intended to be used directly by device drivers. It allocates an
77 * HMM struct if mm does not have one, and initializes it.
78 */
79static struct hmm *hmm_register(struct mm_struct *mm)
80{
81 struct hmm *hmm = READ_ONCE(mm->hmm);
82 bool cleanup = false;
83
84 /*
85 * The hmm struct can only be freed once the mm_struct goes away,
86 * hence we should always have pre-allocated an new hmm struct
87 * above.
88 */
89 if (hmm)
90 return hmm;
91
92 hmm = kmalloc(sizeof(*hmm), GFP_KERNEL);
93 if (!hmm)
94 return NULL;
95 INIT_LIST_HEAD(&hmm->mirrors);
96 init_rwsem(&hmm->mirrors_sem);
97 atomic_set(&hmm->sequence, 0);
98 hmm->mmu_notifier.ops = NULL;
99 INIT_LIST_HEAD(&hmm->ranges);
100 spin_lock_init(&hmm->lock);
101 hmm->mm = mm;
102
103 /*
104 * We should only get here if hold the mmap_sem in write mode ie on
105 * registration of first mirror through hmm_mirror_register()
106 */
107 hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops;
108 if (__mmu_notifier_register(&hmm->mmu_notifier, mm)) {
109 kfree(hmm);
110 return NULL;
111 }
112
113 spin_lock(&mm->page_table_lock);
114 if (!mm->hmm)
115 mm->hmm = hmm;
116 else
117 cleanup = true;
118 spin_unlock(&mm->page_table_lock);
119
120 if (cleanup) {
121 mmu_notifier_unregister(&hmm->mmu_notifier, mm);
122 kfree(hmm);
123 }
124
125 return mm->hmm;
126}
127
128void hmm_mm_destroy(struct mm_struct *mm)
129{
130 kfree(mm->hmm);
131}
132
133static void hmm_invalidate_range(struct hmm *hmm,
134 enum hmm_update_type action,
135 unsigned long start,
136 unsigned long end)
137{
138 struct hmm_mirror *mirror;
139 struct hmm_range *range;
140
141 spin_lock(&hmm->lock);
142 list_for_each_entry(range, &hmm->ranges, list) {
143 unsigned long addr, idx, npages;
144
145 if (end < range->start || start >= range->end)
146 continue;
147
148 range->valid = false;
149 addr = max(start, range->start);
150 idx = (addr - range->start) >> PAGE_SHIFT;
151 npages = (min(range->end, end) - addr) >> PAGE_SHIFT;
152 memset(&range->pfns[idx], 0, sizeof(*range->pfns) * npages);
153 }
154 spin_unlock(&hmm->lock);
155
156 down_read(&hmm->mirrors_sem);
157 list_for_each_entry(mirror, &hmm->mirrors, list)
158 mirror->ops->sync_cpu_device_pagetables(mirror, action,
159 start, end);
160 up_read(&hmm->mirrors_sem);
161}
162
163static void hmm_invalidate_range_start(struct mmu_notifier *mn,
164 struct mm_struct *mm,
165 unsigned long start,
166 unsigned long end)
167{
168 struct hmm *hmm = mm->hmm;
169
170 VM_BUG_ON(!hmm);
171
172 atomic_inc(&hmm->sequence);
173}
174
175static void hmm_invalidate_range_end(struct mmu_notifier *mn,
176 struct mm_struct *mm,
177 unsigned long start,
178 unsigned long end)
179{
180 struct hmm *hmm = mm->hmm;
181
182 VM_BUG_ON(!hmm);
183
184 hmm_invalidate_range(mm->hmm, HMM_UPDATE_INVALIDATE, start, end);
185}
186
187static const struct mmu_notifier_ops hmm_mmu_notifier_ops = {
188 .invalidate_range_start = hmm_invalidate_range_start,
189 .invalidate_range_end = hmm_invalidate_range_end,
190};
191
192/*
193 * hmm_mirror_register() - register a mirror against an mm
194 *
195 * @mirror: new mirror struct to register
196 * @mm: mm to register against
197 *
198 * To start mirroring a process address space, the device driver must register
199 * an HMM mirror struct.
200 *
201 * THE mm->mmap_sem MUST BE HELD IN WRITE MODE !
202 */
203int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm)
204{
205 /* Sanity check */
206 if (!mm || !mirror || !mirror->ops)
207 return -EINVAL;
208
209 mirror->hmm = hmm_register(mm);
210 if (!mirror->hmm)
211 return -ENOMEM;
212
213 down_write(&mirror->hmm->mirrors_sem);
214 list_add(&mirror->list, &mirror->hmm->mirrors);
215 up_write(&mirror->hmm->mirrors_sem);
216
217 return 0;
218}
219EXPORT_SYMBOL(hmm_mirror_register);
220
221/*
222 * hmm_mirror_unregister() - unregister a mirror
223 *
224 * @mirror: new mirror struct to register
225 *
226 * Stop mirroring a process address space, and cleanup.
227 */
228void hmm_mirror_unregister(struct hmm_mirror *mirror)
229{
230 struct hmm *hmm = mirror->hmm;
231
232 down_write(&hmm->mirrors_sem);
233 list_del(&mirror->list);
234 up_write(&hmm->mirrors_sem);
235}
236EXPORT_SYMBOL(hmm_mirror_unregister);
237
238struct hmm_vma_walk {
239 struct hmm_range *range;
240 unsigned long last;
241 bool fault;
242 bool block;
243 bool write;
244};
245
246static int hmm_vma_do_fault(struct mm_walk *walk,
247 unsigned long addr,
248 hmm_pfn_t *pfn)
249{
250 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_REMOTE;
251 struct hmm_vma_walk *hmm_vma_walk = walk->private;
252 struct vm_area_struct *vma = walk->vma;
253 int r;
254
255 flags |= hmm_vma_walk->block ? 0 : FAULT_FLAG_ALLOW_RETRY;
256 flags |= hmm_vma_walk->write ? FAULT_FLAG_WRITE : 0;
257 r = handle_mm_fault(vma, addr, flags);
258 if (r & VM_FAULT_RETRY)
259 return -EBUSY;
260 if (r & VM_FAULT_ERROR) {
261 *pfn = HMM_PFN_ERROR;
262 return -EFAULT;
263 }
264
265 return -EAGAIN;
266}
267
268static void hmm_pfns_special(hmm_pfn_t *pfns,
269 unsigned long addr,
270 unsigned long end)
271{
272 for (; addr < end; addr += PAGE_SIZE, pfns++)
273 *pfns = HMM_PFN_SPECIAL;
274}
275
276static int hmm_pfns_bad(unsigned long addr,
277 unsigned long end,
278 struct mm_walk *walk)
279{
280 struct hmm_range *range = walk->private;
281 hmm_pfn_t *pfns = range->pfns;
282 unsigned long i;
283
284 i = (addr - range->start) >> PAGE_SHIFT;
285 for (; addr < end; addr += PAGE_SIZE, i++)
286 pfns[i] = HMM_PFN_ERROR;
287
288 return 0;
289}
290
291static void hmm_pfns_clear(hmm_pfn_t *pfns,
292 unsigned long addr,
293 unsigned long end)
294{
295 for (; addr < end; addr += PAGE_SIZE, pfns++)
296 *pfns = 0;
297}
298
299static int hmm_vma_walk_hole(unsigned long addr,
300 unsigned long end,
301 struct mm_walk *walk)
302{
303 struct hmm_vma_walk *hmm_vma_walk = walk->private;
304 struct hmm_range *range = hmm_vma_walk->range;
305 hmm_pfn_t *pfns = range->pfns;
306 unsigned long i;
307
308 hmm_vma_walk->last = addr;
309 i = (addr - range->start) >> PAGE_SHIFT;
310 for (; addr < end; addr += PAGE_SIZE, i++) {
311 pfns[i] = HMM_PFN_EMPTY;
312 if (hmm_vma_walk->fault) {
313 int ret;
314
315 ret = hmm_vma_do_fault(walk, addr, &pfns[i]);
316 if (ret != -EAGAIN)
317 return ret;
318 }
319 }
320
321 return hmm_vma_walk->fault ? -EAGAIN : 0;
322}
323
324static int hmm_vma_walk_clear(unsigned long addr,
325 unsigned long end,
326 struct mm_walk *walk)
327{
328 struct hmm_vma_walk *hmm_vma_walk = walk->private;
329 struct hmm_range *range = hmm_vma_walk->range;
330 hmm_pfn_t *pfns = range->pfns;
331 unsigned long i;
332
333 hmm_vma_walk->last = addr;
334 i = (addr - range->start) >> PAGE_SHIFT;
335 for (; addr < end; addr += PAGE_SIZE, i++) {
336 pfns[i] = 0;
337 if (hmm_vma_walk->fault) {
338 int ret;
339
340 ret = hmm_vma_do_fault(walk, addr, &pfns[i]);
341 if (ret != -EAGAIN)
342 return ret;
343 }
344 }
345
346 return hmm_vma_walk->fault ? -EAGAIN : 0;
347}
348
349static int hmm_vma_walk_pmd(pmd_t *pmdp,
350 unsigned long start,
351 unsigned long end,
352 struct mm_walk *walk)
353{
354 struct hmm_vma_walk *hmm_vma_walk = walk->private;
355 struct hmm_range *range = hmm_vma_walk->range;
356 struct vm_area_struct *vma = walk->vma;
357 hmm_pfn_t *pfns = range->pfns;
358 unsigned long addr = start, i;
359 bool write_fault;
360 hmm_pfn_t flag;
361 pte_t *ptep;
362
363 i = (addr - range->start) >> PAGE_SHIFT;
364 flag = vma->vm_flags & VM_READ ? HMM_PFN_READ : 0;
365 write_fault = hmm_vma_walk->fault & hmm_vma_walk->write;
366
367again:
368 if (pmd_none(*pmdp))
369 return hmm_vma_walk_hole(start, end, walk);
370
371 if (pmd_huge(*pmdp) && vma->vm_flags & VM_HUGETLB)
372 return hmm_pfns_bad(start, end, walk);
373
374 if (pmd_devmap(*pmdp) || pmd_trans_huge(*pmdp)) {
375 unsigned long pfn;
376 pmd_t pmd;
377
378 /*
379 * No need to take pmd_lock here, even if some other threads
380 * is splitting the huge pmd we will get that event through
381 * mmu_notifier callback.
382 *
383 * So just read pmd value and check again its a transparent
384 * huge or device mapping one and compute corresponding pfn
385 * values.
386 */
387 pmd = pmd_read_atomic(pmdp);
388 barrier();
389 if (!pmd_devmap(pmd) && !pmd_trans_huge(pmd))
390 goto again;
391 if (pmd_protnone(pmd))
392 return hmm_vma_walk_clear(start, end, walk);
393
394 if (write_fault && !pmd_write(pmd))
395 return hmm_vma_walk_clear(start, end, walk);
396
397 pfn = pmd_pfn(pmd) + pte_index(addr);
398 flag |= pmd_write(pmd) ? HMM_PFN_WRITE : 0;
399 for (; addr < end; addr += PAGE_SIZE, i++, pfn++)
400 pfns[i] = hmm_pfn_t_from_pfn(pfn) | flag;
401 return 0;
402 }
403
404 if (pmd_bad(*pmdp))
405 return hmm_pfns_bad(start, end, walk);
406
407 ptep = pte_offset_map(pmdp, addr);
408 for (; addr < end; addr += PAGE_SIZE, ptep++, i++) {
409 pte_t pte = *ptep;
410
411 pfns[i] = 0;
412
413 if (pte_none(pte)) {
414 pfns[i] = HMM_PFN_EMPTY;
415 if (hmm_vma_walk->fault)
416 goto fault;
417 continue;
418 }
419
420 if (!pte_present(pte)) {
421 swp_entry_t entry;
422
423 if (!non_swap_entry(entry)) {
424 if (hmm_vma_walk->fault)
425 goto fault;
426 continue;
427 }
428
429 entry = pte_to_swp_entry(pte);
430
431 /*
432 * This is a special swap entry, ignore migration, use
433 * device and report anything else as error.
434 */
435 if (is_device_private_entry(entry)) {
436 pfns[i] = hmm_pfn_t_from_pfn(swp_offset(entry));
437 if (is_write_device_private_entry(entry)) {
438 pfns[i] |= HMM_PFN_WRITE;
439 } else if (write_fault)
440 goto fault;
441 pfns[i] |= HMM_PFN_DEVICE_UNADDRESSABLE;
442 pfns[i] |= flag;
443 } else if (is_migration_entry(entry)) {
444 if (hmm_vma_walk->fault) {
445 pte_unmap(ptep);
446 hmm_vma_walk->last = addr;
447 migration_entry_wait(vma->vm_mm,
448 pmdp, addr);
449 return -EAGAIN;
450 }
451 continue;
452 } else {
453 /* Report error for everything else */
454 pfns[i] = HMM_PFN_ERROR;
455 }
456 continue;
457 }
458
459 if (write_fault && !pte_write(pte))
460 goto fault;
461
462 pfns[i] = hmm_pfn_t_from_pfn(pte_pfn(pte)) | flag;
463 pfns[i] |= pte_write(pte) ? HMM_PFN_WRITE : 0;
464 continue;
465
466fault:
467 pte_unmap(ptep);
468 /* Fault all pages in range */
469 return hmm_vma_walk_clear(start, end, walk);
470 }
471 pte_unmap(ptep - 1);
472
473 return 0;
474}
475
476/*
477 * hmm_vma_get_pfns() - snapshot CPU page table for a range of virtual addresses
478 * @vma: virtual memory area containing the virtual address range
479 * @range: used to track snapshot validity
480 * @start: range virtual start address (inclusive)
481 * @end: range virtual end address (exclusive)
482 * @entries: array of hmm_pfn_t: provided by the caller, filled in by function
483 * Returns: -EINVAL if invalid argument, -ENOMEM out of memory, 0 success
484 *
485 * This snapshots the CPU page table for a range of virtual addresses. Snapshot
486 * validity is tracked by range struct. See hmm_vma_range_done() for further
487 * information.
488 *
489 * The range struct is initialized here. It tracks the CPU page table, but only
490 * if the function returns success (0), in which case the caller must then call
491 * hmm_vma_range_done() to stop CPU page table update tracking on this range.
492 *
493 * NOT CALLING hmm_vma_range_done() IF FUNCTION RETURNS 0 WILL LEAD TO SERIOUS
494 * MEMORY CORRUPTION ! YOU HAVE BEEN WARNED !
495 */
496int hmm_vma_get_pfns(struct vm_area_struct *vma,
497 struct hmm_range *range,
498 unsigned long start,
499 unsigned long end,
500 hmm_pfn_t *pfns)
501{
502 struct hmm_vma_walk hmm_vma_walk;
503 struct mm_walk mm_walk;
504 struct hmm *hmm;
505
506 /* FIXME support hugetlb fs */
507 if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) {
508 hmm_pfns_special(pfns, start, end);
509 return -EINVAL;
510 }
511
512 /* Sanity check, this really should not happen ! */
513 if (start < vma->vm_start || start >= vma->vm_end)
514 return -EINVAL;
515 if (end < vma->vm_start || end > vma->vm_end)
516 return -EINVAL;
517
518 hmm = hmm_register(vma->vm_mm);
519 if (!hmm)
520 return -ENOMEM;
521 /* Caller must have registered a mirror, via hmm_mirror_register() ! */
522 if (!hmm->mmu_notifier.ops)
523 return -EINVAL;
524
525 /* Initialize range to track CPU page table update */
526 range->start = start;
527 range->pfns = pfns;
528 range->end = end;
529 spin_lock(&hmm->lock);
530 range->valid = true;
531 list_add_rcu(&range->list, &hmm->ranges);
532 spin_unlock(&hmm->lock);
533
534 hmm_vma_walk.fault = false;
535 hmm_vma_walk.range = range;
536 mm_walk.private = &hmm_vma_walk;
537
538 mm_walk.vma = vma;
539 mm_walk.mm = vma->vm_mm;
540 mm_walk.pte_entry = NULL;
541 mm_walk.test_walk = NULL;
542 mm_walk.hugetlb_entry = NULL;
543 mm_walk.pmd_entry = hmm_vma_walk_pmd;
544 mm_walk.pte_hole = hmm_vma_walk_hole;
545
546 walk_page_range(start, end, &mm_walk);
547 return 0;
548}
549EXPORT_SYMBOL(hmm_vma_get_pfns);
550
551/*
552 * hmm_vma_range_done() - stop tracking change to CPU page table over a range
553 * @vma: virtual memory area containing the virtual address range
554 * @range: range being tracked
555 * Returns: false if range data has been invalidated, true otherwise
556 *
557 * Range struct is used to track updates to the CPU page table after a call to
558 * either hmm_vma_get_pfns() or hmm_vma_fault(). Once the device driver is done
559 * using the data, or wants to lock updates to the data it got from those
560 * functions, it must call the hmm_vma_range_done() function, which will then
561 * stop tracking CPU page table updates.
562 *
563 * Note that device driver must still implement general CPU page table update
564 * tracking either by using hmm_mirror (see hmm_mirror_register()) or by using
565 * the mmu_notifier API directly.
566 *
567 * CPU page table update tracking done through hmm_range is only temporary and
568 * to be used while trying to duplicate CPU page table contents for a range of
569 * virtual addresses.
570 *
571 * There are two ways to use this :
572 * again:
573 * hmm_vma_get_pfns(vma, range, start, end, pfns); or hmm_vma_fault(...);
574 * trans = device_build_page_table_update_transaction(pfns);
575 * device_page_table_lock();
576 * if (!hmm_vma_range_done(vma, range)) {
577 * device_page_table_unlock();
578 * goto again;
579 * }
580 * device_commit_transaction(trans);
581 * device_page_table_unlock();
582 *
583 * Or:
584 * hmm_vma_get_pfns(vma, range, start, end, pfns); or hmm_vma_fault(...);
585 * device_page_table_lock();
586 * hmm_vma_range_done(vma, range);
587 * device_update_page_table(pfns);
588 * device_page_table_unlock();
589 */
590bool hmm_vma_range_done(struct vm_area_struct *vma, struct hmm_range *range)
591{
592 unsigned long npages = (range->end - range->start) >> PAGE_SHIFT;
593 struct hmm *hmm;
594
595 if (range->end <= range->start) {
596 BUG();
597 return false;
598 }
599
600 hmm = hmm_register(vma->vm_mm);
601 if (!hmm) {
602 memset(range->pfns, 0, sizeof(*range->pfns) * npages);
603 return false;
604 }
605
606 spin_lock(&hmm->lock);
607 list_del_rcu(&range->list);
608 spin_unlock(&hmm->lock);
609
610 return range->valid;
611}
612EXPORT_SYMBOL(hmm_vma_range_done);
613
614/*
615 * hmm_vma_fault() - try to fault some address in a virtual address range
616 * @vma: virtual memory area containing the virtual address range
617 * @range: use to track pfns array content validity
618 * @start: fault range virtual start address (inclusive)
619 * @end: fault range virtual end address (exclusive)
620 * @pfns: array of hmm_pfn_t, only entry with fault flag set will be faulted
621 * @write: is it a write fault
622 * @block: allow blocking on fault (if true it sleeps and do not drop mmap_sem)
623 * Returns: 0 success, error otherwise (-EAGAIN means mmap_sem have been drop)
624 *
625 * This is similar to a regular CPU page fault except that it will not trigger
626 * any memory migration if the memory being faulted is not accessible by CPUs.
627 *
628 * On error, for one virtual address in the range, the function will set the
629 * hmm_pfn_t error flag for the corresponding pfn entry.
630 *
631 * Expected use pattern:
632 * retry:
633 * down_read(&mm->mmap_sem);
634 * // Find vma and address device wants to fault, initialize hmm_pfn_t
635 * // array accordingly
636 * ret = hmm_vma_fault(vma, start, end, pfns, allow_retry);
637 * switch (ret) {
638 * case -EAGAIN:
639 * hmm_vma_range_done(vma, range);
640 * // You might want to rate limit or yield to play nicely, you may
641 * // also commit any valid pfn in the array assuming that you are
642 * // getting true from hmm_vma_range_monitor_end()
643 * goto retry;
644 * case 0:
645 * break;
646 * default:
647 * // Handle error !
648 * up_read(&mm->mmap_sem)
649 * return;
650 * }
651 * // Take device driver lock that serialize device page table update
652 * driver_lock_device_page_table_update();
653 * hmm_vma_range_done(vma, range);
654 * // Commit pfns we got from hmm_vma_fault()
655 * driver_unlock_device_page_table_update();
656 * up_read(&mm->mmap_sem)
657 *
658 * YOU MUST CALL hmm_vma_range_done() AFTER THIS FUNCTION RETURN SUCCESS (0)
659 * BEFORE FREEING THE range struct OR YOU WILL HAVE SERIOUS MEMORY CORRUPTION !
660 *
661 * YOU HAVE BEEN WARNED !
662 */
663int hmm_vma_fault(struct vm_area_struct *vma,
664 struct hmm_range *range,
665 unsigned long start,
666 unsigned long end,
667 hmm_pfn_t *pfns,
668 bool write,
669 bool block)
670{
671 struct hmm_vma_walk hmm_vma_walk;
672 struct mm_walk mm_walk;
673 struct hmm *hmm;
674 int ret;
675
676 /* Sanity check, this really should not happen ! */
677 if (start < vma->vm_start || start >= vma->vm_end)
678 return -EINVAL;
679 if (end < vma->vm_start || end > vma->vm_end)
680 return -EINVAL;
681
682 hmm = hmm_register(vma->vm_mm);
683 if (!hmm) {
684 hmm_pfns_clear(pfns, start, end);
685 return -ENOMEM;
686 }
687 /* Caller must have registered a mirror using hmm_mirror_register() */
688 if (!hmm->mmu_notifier.ops)
689 return -EINVAL;
690
691 /* Initialize range to track CPU page table update */
692 range->start = start;
693 range->pfns = pfns;
694 range->end = end;
695 spin_lock(&hmm->lock);
696 range->valid = true;
697 list_add_rcu(&range->list, &hmm->ranges);
698 spin_unlock(&hmm->lock);
699
700 /* FIXME support hugetlb fs */
701 if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) {
702 hmm_pfns_special(pfns, start, end);
703 return 0;
704 }
705
706 hmm_vma_walk.fault = true;
707 hmm_vma_walk.write = write;
708 hmm_vma_walk.block = block;
709 hmm_vma_walk.range = range;
710 mm_walk.private = &hmm_vma_walk;
711 hmm_vma_walk.last = range->start;
712
713 mm_walk.vma = vma;
714 mm_walk.mm = vma->vm_mm;
715 mm_walk.pte_entry = NULL;
716 mm_walk.test_walk = NULL;
717 mm_walk.hugetlb_entry = NULL;
718 mm_walk.pmd_entry = hmm_vma_walk_pmd;
719 mm_walk.pte_hole = hmm_vma_walk_hole;
720
721 do {
722 ret = walk_page_range(start, end, &mm_walk);
723 start = hmm_vma_walk.last;
724 } while (ret == -EAGAIN);
725
726 if (ret) {
727 unsigned long i;
728
729 i = (hmm_vma_walk.last - range->start) >> PAGE_SHIFT;
730 hmm_pfns_clear(&pfns[i], hmm_vma_walk.last, end);
731 hmm_vma_range_done(vma, range);
732 }
733 return ret;
734}
735EXPORT_SYMBOL(hmm_vma_fault);
736#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
737
738
739#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC)
740struct page *hmm_vma_alloc_locked_page(struct vm_area_struct *vma,
741 unsigned long addr)
742{
743 struct page *page;
744
745 page = alloc_page_vma(GFP_HIGHUSER, vma, addr);
746 if (!page)
747 return NULL;
748 lock_page(page);
749 return page;
750}
751EXPORT_SYMBOL(hmm_vma_alloc_locked_page);
752
753
754static void hmm_devmem_ref_release(struct percpu_ref *ref)
755{
756 struct hmm_devmem *devmem;
757
758 devmem = container_of(ref, struct hmm_devmem, ref);
759 complete(&devmem->completion);
760}
761
762static void hmm_devmem_ref_exit(void *data)
763{
764 struct percpu_ref *ref = data;
765 struct hmm_devmem *devmem;
766
767 devmem = container_of(ref, struct hmm_devmem, ref);
768 percpu_ref_exit(ref);
769 devm_remove_action(devmem->device, &hmm_devmem_ref_exit, data);
770}
771
772static void hmm_devmem_ref_kill(void *data)
773{
774 struct percpu_ref *ref = data;
775 struct hmm_devmem *devmem;
776
777 devmem = container_of(ref, struct hmm_devmem, ref);
778 percpu_ref_kill(ref);
779 wait_for_completion(&devmem->completion);
780 devm_remove_action(devmem->device, &hmm_devmem_ref_kill, data);
781}
782
783static int hmm_devmem_fault(struct vm_area_struct *vma,
784 unsigned long addr,
785 const struct page *page,
786 unsigned int flags,
787 pmd_t *pmdp)
788{
789 struct hmm_devmem *devmem = page->pgmap->data;
790
791 return devmem->ops->fault(devmem, vma, addr, page, flags, pmdp);
792}
793
794static void hmm_devmem_free(struct page *page, void *data)
795{
796 struct hmm_devmem *devmem = data;
797
798 devmem->ops->free(devmem, page);
799}
800
801static DEFINE_MUTEX(hmm_devmem_lock);
802static RADIX_TREE(hmm_devmem_radix, GFP_KERNEL);
803
804static void hmm_devmem_radix_release(struct resource *resource)
805{
806 resource_size_t key, align_start, align_size, align_end;
807
808 align_start = resource->start & ~(PA_SECTION_SIZE - 1);
809 align_size = ALIGN(resource_size(resource), PA_SECTION_SIZE);
810 align_end = align_start + align_size - 1;
811
812 mutex_lock(&hmm_devmem_lock);
813 for (key = resource->start;
814 key <= resource->end;
815 key += PA_SECTION_SIZE)
816 radix_tree_delete(&hmm_devmem_radix, key >> PA_SECTION_SHIFT);
817 mutex_unlock(&hmm_devmem_lock);
818}
819
820static void hmm_devmem_release(struct device *dev, void *data)
821{
822 struct hmm_devmem *devmem = data;
823 struct resource *resource = devmem->resource;
824 unsigned long start_pfn, npages;
825 struct zone *zone;
826 struct page *page;
827
828 if (percpu_ref_tryget_live(&devmem->ref)) {
829 dev_WARN(dev, "%s: page mapping is still live!\n", __func__);
830 percpu_ref_put(&devmem->ref);
831 }
832
833 /* pages are dead and unused, undo the arch mapping */
834 start_pfn = (resource->start & ~(PA_SECTION_SIZE - 1)) >> PAGE_SHIFT;
835 npages = ALIGN(resource_size(resource), PA_SECTION_SIZE) >> PAGE_SHIFT;
836
837 page = pfn_to_page(start_pfn);
838 zone = page_zone(page);
839
840 mem_hotplug_begin();
841 if (resource->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY)
842 __remove_pages(zone, start_pfn, npages);
843 else
844 arch_remove_memory(start_pfn << PAGE_SHIFT,
845 npages << PAGE_SHIFT);
846 mem_hotplug_done();
847
848 hmm_devmem_radix_release(resource);
849}
850
851static struct hmm_devmem *hmm_devmem_find(resource_size_t phys)
852{
853 WARN_ON_ONCE(!rcu_read_lock_held());
854
855 return radix_tree_lookup(&hmm_devmem_radix, phys >> PA_SECTION_SHIFT);
856}
857
858static int hmm_devmem_pages_create(struct hmm_devmem *devmem)
859{
860 resource_size_t key, align_start, align_size, align_end;
861 struct device *device = devmem->device;
862 int ret, nid, is_ram;
863 unsigned long pfn;
864
865 align_start = devmem->resource->start & ~(PA_SECTION_SIZE - 1);
866 align_size = ALIGN(devmem->resource->start +
867 resource_size(devmem->resource),
868 PA_SECTION_SIZE) - align_start;
869
870 is_ram = region_intersects(align_start, align_size,
871 IORESOURCE_SYSTEM_RAM,
872 IORES_DESC_NONE);
873 if (is_ram == REGION_MIXED) {
874 WARN_ONCE(1, "%s attempted on mixed region %pr\n",
875 __func__, devmem->resource);
876 return -ENXIO;
877 }
878 if (is_ram == REGION_INTERSECTS)
879 return -ENXIO;
880
881 if (devmem->resource->desc == IORES_DESC_DEVICE_PUBLIC_MEMORY)
882 devmem->pagemap.type = MEMORY_DEVICE_PUBLIC;
883 else
884 devmem->pagemap.type = MEMORY_DEVICE_PRIVATE;
885
886 devmem->pagemap.res = devmem->resource;
887 devmem->pagemap.page_fault = hmm_devmem_fault;
888 devmem->pagemap.page_free = hmm_devmem_free;
889 devmem->pagemap.dev = devmem->device;
890 devmem->pagemap.ref = &devmem->ref;
891 devmem->pagemap.data = devmem;
892
893 mutex_lock(&hmm_devmem_lock);
894 align_end = align_start + align_size - 1;
895 for (key = align_start; key <= align_end; key += PA_SECTION_SIZE) {
896 struct hmm_devmem *dup;
897
898 rcu_read_lock();
899 dup = hmm_devmem_find(key);
900 rcu_read_unlock();
901 if (dup) {
902 dev_err(device, "%s: collides with mapping for %s\n",
903 __func__, dev_name(dup->device));
904 mutex_unlock(&hmm_devmem_lock);
905 ret = -EBUSY;
906 goto error;
907 }
908 ret = radix_tree_insert(&hmm_devmem_radix,
909 key >> PA_SECTION_SHIFT,
910 devmem);
911 if (ret) {
912 dev_err(device, "%s: failed: %d\n", __func__, ret);
913 mutex_unlock(&hmm_devmem_lock);
914 goto error_radix;
915 }
916 }
917 mutex_unlock(&hmm_devmem_lock);
918
919 nid = dev_to_node(device);
920 if (nid < 0)
921 nid = numa_mem_id();
922
923 mem_hotplug_begin();
924 /*
925 * For device private memory we call add_pages() as we only need to
926 * allocate and initialize struct page for the device memory. More-
927 * over the device memory is un-accessible thus we do not want to
928 * create a linear mapping for the memory like arch_add_memory()
929 * would do.
930 *
931 * For device public memory, which is accesible by the CPU, we do
932 * want the linear mapping and thus use arch_add_memory().
933 */
934 if (devmem->pagemap.type == MEMORY_DEVICE_PUBLIC)
935 ret = arch_add_memory(nid, align_start, align_size, false);
936 else
937 ret = add_pages(nid, align_start >> PAGE_SHIFT,
938 align_size >> PAGE_SHIFT, false);
939 if (ret) {
940 mem_hotplug_done();
941 goto error_add_memory;
942 }
943 move_pfn_range_to_zone(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
944 align_start >> PAGE_SHIFT,
945 align_size >> PAGE_SHIFT);
946 mem_hotplug_done();
947
948 for (pfn = devmem->pfn_first; pfn < devmem->pfn_last; pfn++) {
949 struct page *page = pfn_to_page(pfn);
950
951 page->pgmap = &devmem->pagemap;
952 }
953 return 0;
954
955error_add_memory:
956 untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
957error_radix:
958 hmm_devmem_radix_release(devmem->resource);
959error:
960 return ret;
961}
962
963static int hmm_devmem_match(struct device *dev, void *data, void *match_data)
964{
965 struct hmm_devmem *devmem = data;
966
967 return devmem->resource == match_data;
968}
969
970static void hmm_devmem_pages_remove(struct hmm_devmem *devmem)
971{
972 devres_release(devmem->device, &hmm_devmem_release,
973 &hmm_devmem_match, devmem->resource);
974}
975
976/*
977 * hmm_devmem_add() - hotplug ZONE_DEVICE memory for device memory
978 *
979 * @ops: memory event device driver callback (see struct hmm_devmem_ops)
980 * @device: device struct to bind the resource too
981 * @size: size in bytes of the device memory to add
982 * Returns: pointer to new hmm_devmem struct ERR_PTR otherwise
983 *
984 * This function first finds an empty range of physical address big enough to
985 * contain the new resource, and then hotplugs it as ZONE_DEVICE memory, which
986 * in turn allocates struct pages. It does not do anything beyond that; all
987 * events affecting the memory will go through the various callbacks provided
988 * by hmm_devmem_ops struct.
989 *
990 * Device driver should call this function during device initialization and
991 * is then responsible of memory management. HMM only provides helpers.
992 */
993struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
994 struct device *device,
995 unsigned long size)
996{
997 struct hmm_devmem *devmem;
998 resource_size_t addr;
999 int ret;
1000
1001 static_branch_enable(&device_private_key);
1002
1003 devmem = devres_alloc_node(&hmm_devmem_release, sizeof(*devmem),
1004 GFP_KERNEL, dev_to_node(device));
1005 if (!devmem)
1006 return ERR_PTR(-ENOMEM);
1007
1008 init_completion(&devmem->completion);
1009 devmem->pfn_first = -1UL;
1010 devmem->pfn_last = -1UL;
1011 devmem->resource = NULL;
1012 devmem->device = device;
1013 devmem->ops = ops;
1014
1015 ret = percpu_ref_init(&devmem->ref, &hmm_devmem_ref_release,
1016 0, GFP_KERNEL);
1017 if (ret)
1018 goto error_percpu_ref;
1019
1020 ret = devm_add_action(device, hmm_devmem_ref_exit, &devmem->ref);
1021 if (ret)
1022 goto error_devm_add_action;
1023
1024 size = ALIGN(size, PA_SECTION_SIZE);
1025 addr = min((unsigned long)iomem_resource.end,
1026 (1UL << MAX_PHYSMEM_BITS) - 1);
1027 addr = addr - size + 1UL;
1028
1029 /*
1030 * FIXME add a new helper to quickly walk resource tree and find free
1031 * range
1032 *
1033 * FIXME what about ioport_resource resource ?
1034 */
1035 for (; addr > size && addr >= iomem_resource.start; addr -= size) {
1036 ret = region_intersects(addr, size, 0, IORES_DESC_NONE);
1037 if (ret != REGION_DISJOINT)
1038 continue;
1039
1040 devmem->resource = devm_request_mem_region(device, addr, size,
1041 dev_name(device));
1042 if (!devmem->resource) {
1043 ret = -ENOMEM;
1044 goto error_no_resource;
1045 }
1046 break;
1047 }
1048 if (!devmem->resource) {
1049 ret = -ERANGE;
1050 goto error_no_resource;
1051 }
1052
1053 devmem->resource->desc = IORES_DESC_DEVICE_PRIVATE_MEMORY;
1054 devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT;
1055 devmem->pfn_last = devmem->pfn_first +
1056 (resource_size(devmem->resource) >> PAGE_SHIFT);
1057
1058 ret = hmm_devmem_pages_create(devmem);
1059 if (ret)
1060 goto error_pages;
1061
1062 devres_add(device, devmem);
1063
1064 ret = devm_add_action(device, hmm_devmem_ref_kill, &devmem->ref);
1065 if (ret) {
1066 hmm_devmem_remove(devmem);
1067 return ERR_PTR(ret);
1068 }
1069
1070 return devmem;
1071
1072error_pages:
1073 devm_release_mem_region(device, devmem->resource->start,
1074 resource_size(devmem->resource));
1075error_no_resource:
1076error_devm_add_action:
1077 hmm_devmem_ref_kill(&devmem->ref);
1078 hmm_devmem_ref_exit(&devmem->ref);
1079error_percpu_ref:
1080 devres_free(devmem);
1081 return ERR_PTR(ret);
1082}
1083EXPORT_SYMBOL(hmm_devmem_add);
1084
1085struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
1086 struct device *device,
1087 struct resource *res)
1088{
1089 struct hmm_devmem *devmem;
1090 int ret;
1091
1092 if (res->desc != IORES_DESC_DEVICE_PUBLIC_MEMORY)
1093 return ERR_PTR(-EINVAL);
1094
1095 static_branch_enable(&device_private_key);
1096
1097 devmem = devres_alloc_node(&hmm_devmem_release, sizeof(*devmem),
1098 GFP_KERNEL, dev_to_node(device));
1099 if (!devmem)
1100 return ERR_PTR(-ENOMEM);
1101
1102 init_completion(&devmem->completion);
1103 devmem->pfn_first = -1UL;
1104 devmem->pfn_last = -1UL;
1105 devmem->resource = res;
1106 devmem->device = device;
1107 devmem->ops = ops;
1108
1109 ret = percpu_ref_init(&devmem->ref, &hmm_devmem_ref_release,
1110 0, GFP_KERNEL);
1111 if (ret)
1112 goto error_percpu_ref;
1113
1114 ret = devm_add_action(device, hmm_devmem_ref_exit, &devmem->ref);
1115 if (ret)
1116 goto error_devm_add_action;
1117
1118
1119 devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT;
1120 devmem->pfn_last = devmem->pfn_first +
1121 (resource_size(devmem->resource) >> PAGE_SHIFT);
1122
1123 ret = hmm_devmem_pages_create(devmem);
1124 if (ret)
1125 goto error_devm_add_action;
1126
1127 devres_add(device, devmem);
1128
1129 ret = devm_add_action(device, hmm_devmem_ref_kill, &devmem->ref);
1130 if (ret) {
1131 hmm_devmem_remove(devmem);
1132 return ERR_PTR(ret);
1133 }
1134
1135 return devmem;
1136
1137error_devm_add_action:
1138 hmm_devmem_ref_kill(&devmem->ref);
1139 hmm_devmem_ref_exit(&devmem->ref);
1140error_percpu_ref:
1141 devres_free(devmem);
1142 return ERR_PTR(ret);
1143}
1144EXPORT_SYMBOL(hmm_devmem_add_resource);
1145
1146/*
1147 * hmm_devmem_remove() - remove device memory (kill and free ZONE_DEVICE)
1148 *
1149 * @devmem: hmm_devmem struct use to track and manage the ZONE_DEVICE memory
1150 *
1151 * This will hot-unplug memory that was hotplugged by hmm_devmem_add on behalf
1152 * of the device driver. It will free struct page and remove the resource that
1153 * reserved the physical address range for this device memory.
1154 */
1155void hmm_devmem_remove(struct hmm_devmem *devmem)
1156{
1157 resource_size_t start, size;
1158 struct device *device;
1159 bool cdm = false;
1160
1161 if (!devmem)
1162 return;
1163
1164 device = devmem->device;
1165 start = devmem->resource->start;
1166 size = resource_size(devmem->resource);
1167
1168 cdm = devmem->resource->desc == IORES_DESC_DEVICE_PUBLIC_MEMORY;
1169 hmm_devmem_ref_kill(&devmem->ref);
1170 hmm_devmem_ref_exit(&devmem->ref);
1171 hmm_devmem_pages_remove(devmem);
1172
1173 if (!cdm)
1174 devm_release_mem_region(device, start, size);
1175}
1176EXPORT_SYMBOL(hmm_devmem_remove);
1177
1178/*
1179 * A device driver that wants to handle multiple devices memory through a
1180 * single fake device can use hmm_device to do so. This is purely a helper
1181 * and it is not needed to make use of any HMM functionality.
1182 */
1183#define HMM_DEVICE_MAX 256
1184
1185static DECLARE_BITMAP(hmm_device_mask, HMM_DEVICE_MAX);
1186static DEFINE_SPINLOCK(hmm_device_lock);
1187static struct class *hmm_device_class;
1188static dev_t hmm_device_devt;
1189
1190static void hmm_device_release(struct device *device)
1191{
1192 struct hmm_device *hmm_device;
1193
1194 hmm_device = container_of(device, struct hmm_device, device);
1195 spin_lock(&hmm_device_lock);
1196 clear_bit(hmm_device->minor, hmm_device_mask);
1197 spin_unlock(&hmm_device_lock);
1198
1199 kfree(hmm_device);
1200}
1201
1202struct hmm_device *hmm_device_new(void *drvdata)
1203{
1204 struct hmm_device *hmm_device;
1205
1206 hmm_device = kzalloc(sizeof(*hmm_device), GFP_KERNEL);
1207 if (!hmm_device)
1208 return ERR_PTR(-ENOMEM);
1209
1210 spin_lock(&hmm_device_lock);
1211 hmm_device->minor = find_first_zero_bit(hmm_device_mask, HMM_DEVICE_MAX);
1212 if (hmm_device->minor >= HMM_DEVICE_MAX) {
1213 spin_unlock(&hmm_device_lock);
1214 kfree(hmm_device);
1215 return ERR_PTR(-EBUSY);
1216 }
1217 set_bit(hmm_device->minor, hmm_device_mask);
1218 spin_unlock(&hmm_device_lock);
1219
1220 dev_set_name(&hmm_device->device, "hmm_device%d", hmm_device->minor);
1221 hmm_device->device.devt = MKDEV(MAJOR(hmm_device_devt),
1222 hmm_device->minor);
1223 hmm_device->device.release = hmm_device_release;
1224 dev_set_drvdata(&hmm_device->device, drvdata);
1225 hmm_device->device.class = hmm_device_class;
1226 device_initialize(&hmm_device->device);
1227
1228 return hmm_device;
1229}
1230EXPORT_SYMBOL(hmm_device_new);
1231
1232void hmm_device_put(struct hmm_device *hmm_device)
1233{
1234 put_device(&hmm_device->device);
1235}
1236EXPORT_SYMBOL(hmm_device_put);
1237
1238static int __init hmm_init(void)
1239{
1240 int ret;
1241
1242 ret = alloc_chrdev_region(&hmm_device_devt, 0,
1243 HMM_DEVICE_MAX,
1244 "hmm_device");
1245 if (ret)
1246 return ret;
1247
1248 hmm_device_class = class_create(THIS_MODULE, "hmm_device");
1249 if (IS_ERR(hmm_device_class)) {
1250 unregister_chrdev_region(hmm_device_devt, HMM_DEVICE_MAX);
1251 return PTR_ERR(hmm_device_class);
1252 }
1253 return 0;
1254}
1255
1256device_initcall(hmm_init);
1257#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 0b51e70e0a8b..269b5df58543 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -928,6 +928,25 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
928 928
929 ret = -EAGAIN; 929 ret = -EAGAIN;
930 pmd = *src_pmd; 930 pmd = *src_pmd;
931
932#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
933 if (unlikely(is_swap_pmd(pmd))) {
934 swp_entry_t entry = pmd_to_swp_entry(pmd);
935
936 VM_BUG_ON(!is_pmd_migration_entry(pmd));
937 if (is_write_migration_entry(entry)) {
938 make_migration_entry_read(&entry);
939 pmd = swp_entry_to_pmd(entry);
940 if (pmd_swp_soft_dirty(*src_pmd))
941 pmd = pmd_swp_mksoft_dirty(pmd);
942 set_pmd_at(src_mm, addr, src_pmd, pmd);
943 }
944 set_pmd_at(dst_mm, addr, dst_pmd, pmd);
945 ret = 0;
946 goto out_unlock;
947 }
948#endif
949
931 if (unlikely(!pmd_trans_huge(pmd))) { 950 if (unlikely(!pmd_trans_huge(pmd))) {
932 pte_free(dst_mm, pgtable); 951 pte_free(dst_mm, pgtable);
933 goto out_unlock; 952 goto out_unlock;
@@ -1599,6 +1618,12 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
1599 if (is_huge_zero_pmd(orig_pmd)) 1618 if (is_huge_zero_pmd(orig_pmd))
1600 goto out; 1619 goto out;
1601 1620
1621 if (unlikely(!pmd_present(orig_pmd))) {
1622 VM_BUG_ON(thp_migration_supported() &&
1623 !is_pmd_migration_entry(orig_pmd));
1624 goto out;
1625 }
1626
1602 page = pmd_page(orig_pmd); 1627 page = pmd_page(orig_pmd);
1603 /* 1628 /*
1604 * If other processes are mapping this page, we couldn't discard 1629 * If other processes are mapping this page, we couldn't discard
@@ -1684,10 +1709,24 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
1684 spin_unlock(ptl); 1709 spin_unlock(ptl);
1685 tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE); 1710 tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE);
1686 } else { 1711 } else {
1687 struct page *page = pmd_page(orig_pmd); 1712 struct page *page = NULL;
1688 page_remove_rmap(page, true); 1713 int flush_needed = 1;
1689 VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); 1714
1690 VM_BUG_ON_PAGE(!PageHead(page), page); 1715 if (pmd_present(orig_pmd)) {
1716 page = pmd_page(orig_pmd);
1717 page_remove_rmap(page, true);
1718 VM_BUG_ON_PAGE(page_mapcount(page) < 0, page);
1719 VM_BUG_ON_PAGE(!PageHead(page), page);
1720 } else if (thp_migration_supported()) {
1721 swp_entry_t entry;
1722
1723 VM_BUG_ON(!is_pmd_migration_entry(orig_pmd));
1724 entry = pmd_to_swp_entry(orig_pmd);
1725 page = pfn_to_page(swp_offset(entry));
1726 flush_needed = 0;
1727 } else
1728 WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!");
1729
1691 if (PageAnon(page)) { 1730 if (PageAnon(page)) {
1692 zap_deposited_table(tlb->mm, pmd); 1731 zap_deposited_table(tlb->mm, pmd);
1693 add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); 1732 add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR);
@@ -1696,8 +1735,10 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
1696 zap_deposited_table(tlb->mm, pmd); 1735 zap_deposited_table(tlb->mm, pmd);
1697 add_mm_counter(tlb->mm, MM_FILEPAGES, -HPAGE_PMD_NR); 1736 add_mm_counter(tlb->mm, MM_FILEPAGES, -HPAGE_PMD_NR);
1698 } 1737 }
1738
1699 spin_unlock(ptl); 1739 spin_unlock(ptl);
1700 tlb_remove_page_size(tlb, page, HPAGE_PMD_SIZE); 1740 if (flush_needed)
1741 tlb_remove_page_size(tlb, page, HPAGE_PMD_SIZE);
1701 } 1742 }
1702 return 1; 1743 return 1;
1703} 1744}
@@ -1717,6 +1758,17 @@ static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
1717} 1758}
1718#endif 1759#endif
1719 1760
1761static pmd_t move_soft_dirty_pmd(pmd_t pmd)
1762{
1763#ifdef CONFIG_MEM_SOFT_DIRTY
1764 if (unlikely(is_pmd_migration_entry(pmd)))
1765 pmd = pmd_swp_mksoft_dirty(pmd);
1766 else if (pmd_present(pmd))
1767 pmd = pmd_mksoft_dirty(pmd);
1768#endif
1769 return pmd;
1770}
1771
1720bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, 1772bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
1721 unsigned long new_addr, unsigned long old_end, 1773 unsigned long new_addr, unsigned long old_end,
1722 pmd_t *old_pmd, pmd_t *new_pmd, bool *need_flush) 1774 pmd_t *old_pmd, pmd_t *new_pmd, bool *need_flush)
@@ -1759,7 +1811,8 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
1759 pgtable = pgtable_trans_huge_withdraw(mm, old_pmd); 1811 pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
1760 pgtable_trans_huge_deposit(mm, new_pmd, pgtable); 1812 pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
1761 } 1813 }
1762 set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd)); 1814 pmd = move_soft_dirty_pmd(pmd);
1815 set_pmd_at(mm, new_addr, new_pmd, pmd);
1763 if (new_ptl != old_ptl) 1816 if (new_ptl != old_ptl)
1764 spin_unlock(new_ptl); 1817 spin_unlock(new_ptl);
1765 if (force_flush) 1818 if (force_flush)
@@ -1794,6 +1847,27 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
1794 preserve_write = prot_numa && pmd_write(*pmd); 1847 preserve_write = prot_numa && pmd_write(*pmd);
1795 ret = 1; 1848 ret = 1;
1796 1849
1850#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
1851 if (is_swap_pmd(*pmd)) {
1852 swp_entry_t entry = pmd_to_swp_entry(*pmd);
1853
1854 VM_BUG_ON(!is_pmd_migration_entry(*pmd));
1855 if (is_write_migration_entry(entry)) {
1856 pmd_t newpmd;
1857 /*
1858 * A protection check is difficult so
1859 * just be safe and disable write
1860 */
1861 make_migration_entry_read(&entry);
1862 newpmd = swp_entry_to_pmd(entry);
1863 if (pmd_swp_soft_dirty(*pmd))
1864 newpmd = pmd_swp_mksoft_dirty(newpmd);
1865 set_pmd_at(mm, addr, pmd, newpmd);
1866 }
1867 goto unlock;
1868 }
1869#endif
1870
1797 /* 1871 /*
1798 * Avoid trapping faults against the zero page. The read-only 1872 * Avoid trapping faults against the zero page. The read-only
1799 * data is likely to be read-cached on the local CPU and 1873 * data is likely to be read-cached on the local CPU and
@@ -1859,7 +1933,8 @@ spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
1859{ 1933{
1860 spinlock_t *ptl; 1934 spinlock_t *ptl;
1861 ptl = pmd_lock(vma->vm_mm, pmd); 1935 ptl = pmd_lock(vma->vm_mm, pmd);
1862 if (likely(pmd_trans_huge(*pmd) || pmd_devmap(*pmd))) 1936 if (likely(is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) ||
1937 pmd_devmap(*pmd)))
1863 return ptl; 1938 return ptl;
1864 spin_unlock(ptl); 1939 spin_unlock(ptl);
1865 return NULL; 1940 return NULL;
@@ -1977,14 +2052,15 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
1977 struct page *page; 2052 struct page *page;
1978 pgtable_t pgtable; 2053 pgtable_t pgtable;
1979 pmd_t _pmd; 2054 pmd_t _pmd;
1980 bool young, write, dirty, soft_dirty; 2055 bool young, write, dirty, soft_dirty, pmd_migration = false;
1981 unsigned long addr; 2056 unsigned long addr;
1982 int i; 2057 int i;
1983 2058
1984 VM_BUG_ON(haddr & ~HPAGE_PMD_MASK); 2059 VM_BUG_ON(haddr & ~HPAGE_PMD_MASK);
1985 VM_BUG_ON_VMA(vma->vm_start > haddr, vma); 2060 VM_BUG_ON_VMA(vma->vm_start > haddr, vma);
1986 VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PMD_SIZE, vma); 2061 VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PMD_SIZE, vma);
1987 VM_BUG_ON(!pmd_trans_huge(*pmd) && !pmd_devmap(*pmd)); 2062 VM_BUG_ON(!is_pmd_migration_entry(*pmd) && !pmd_trans_huge(*pmd)
2063 && !pmd_devmap(*pmd));
1988 2064
1989 count_vm_event(THP_SPLIT_PMD); 2065 count_vm_event(THP_SPLIT_PMD);
1990 2066
@@ -2009,7 +2085,16 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
2009 return __split_huge_zero_page_pmd(vma, haddr, pmd); 2085 return __split_huge_zero_page_pmd(vma, haddr, pmd);
2010 } 2086 }
2011 2087
2012 page = pmd_page(*pmd); 2088#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
2089 pmd_migration = is_pmd_migration_entry(*pmd);
2090 if (pmd_migration) {
2091 swp_entry_t entry;
2092
2093 entry = pmd_to_swp_entry(*pmd);
2094 page = pfn_to_page(swp_offset(entry));
2095 } else
2096#endif
2097 page = pmd_page(*pmd);
2013 VM_BUG_ON_PAGE(!page_count(page), page); 2098 VM_BUG_ON_PAGE(!page_count(page), page);
2014 page_ref_add(page, HPAGE_PMD_NR - 1); 2099 page_ref_add(page, HPAGE_PMD_NR - 1);
2015 write = pmd_write(*pmd); 2100 write = pmd_write(*pmd);
@@ -2028,7 +2113,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
2028 * transferred to avoid any possibility of altering 2113 * transferred to avoid any possibility of altering
2029 * permissions across VMAs. 2114 * permissions across VMAs.
2030 */ 2115 */
2031 if (freeze) { 2116 if (freeze || pmd_migration) {
2032 swp_entry_t swp_entry; 2117 swp_entry_t swp_entry;
2033 swp_entry = make_migration_entry(page + i, write); 2118 swp_entry = make_migration_entry(page + i, write);
2034 entry = swp_entry_to_pte(swp_entry); 2119 entry = swp_entry_to_pte(swp_entry);
@@ -2127,7 +2212,7 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
2127 page = pmd_page(*pmd); 2212 page = pmd_page(*pmd);
2128 if (PageMlocked(page)) 2213 if (PageMlocked(page))
2129 clear_page_mlock(page); 2214 clear_page_mlock(page);
2130 } else if (!pmd_devmap(*pmd)) 2215 } else if (!(pmd_devmap(*pmd) || is_pmd_migration_entry(*pmd)))
2131 goto out; 2216 goto out;
2132 __split_huge_pmd_locked(vma, pmd, haddr, freeze); 2217 __split_huge_pmd_locked(vma, pmd, haddr, freeze);
2133out: 2218out:
@@ -2210,7 +2295,7 @@ static void freeze_page(struct page *page)
2210 VM_BUG_ON_PAGE(!PageHead(page), page); 2295 VM_BUG_ON_PAGE(!PageHead(page), page);
2211 2296
2212 if (PageAnon(page)) 2297 if (PageAnon(page))
2213 ttu_flags |= TTU_MIGRATION; 2298 ttu_flags |= TTU_SPLIT_FREEZE;
2214 2299
2215 unmap_success = try_to_unmap(page, ttu_flags); 2300 unmap_success = try_to_unmap(page, ttu_flags);
2216 VM_BUG_ON_PAGE(!unmap_success, page); 2301 VM_BUG_ON_PAGE(!unmap_success, page);
@@ -2745,3 +2830,66 @@ static int __init split_huge_pages_debugfs(void)
2745} 2830}
2746late_initcall(split_huge_pages_debugfs); 2831late_initcall(split_huge_pages_debugfs);
2747#endif 2832#endif
2833
2834#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
2835void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
2836 struct page *page)
2837{
2838 struct vm_area_struct *vma = pvmw->vma;
2839 struct mm_struct *mm = vma->vm_mm;
2840 unsigned long address = pvmw->address;
2841 pmd_t pmdval;
2842 swp_entry_t entry;
2843 pmd_t pmdswp;
2844
2845 if (!(pvmw->pmd && !pvmw->pte))
2846 return;
2847
2848 mmu_notifier_invalidate_range_start(mm, address,
2849 address + HPAGE_PMD_SIZE);
2850
2851 flush_cache_range(vma, address, address + HPAGE_PMD_SIZE);
2852 pmdval = *pvmw->pmd;
2853 pmdp_invalidate(vma, address, pvmw->pmd);
2854 if (pmd_dirty(pmdval))
2855 set_page_dirty(page);
2856 entry = make_migration_entry(page, pmd_write(pmdval));
2857 pmdswp = swp_entry_to_pmd(entry);
2858 if (pmd_soft_dirty(pmdval))
2859 pmdswp = pmd_swp_mksoft_dirty(pmdswp);
2860 set_pmd_at(mm, address, pvmw->pmd, pmdswp);
2861 page_remove_rmap(page, true);
2862 put_page(page);
2863
2864 mmu_notifier_invalidate_range_end(mm, address,
2865 address + HPAGE_PMD_SIZE);
2866}
2867
2868void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)
2869{
2870 struct vm_area_struct *vma = pvmw->vma;
2871 struct mm_struct *mm = vma->vm_mm;
2872 unsigned long address = pvmw->address;
2873 unsigned long mmun_start = address & HPAGE_PMD_MASK;
2874 pmd_t pmde;
2875 swp_entry_t entry;
2876
2877 if (!(pvmw->pmd && !pvmw->pte))
2878 return;
2879
2880 entry = pmd_to_swp_entry(*pvmw->pmd);
2881 get_page(new);
2882 pmde = pmd_mkold(mk_huge_pmd(new, vma->vm_page_prot));
2883 if (pmd_swp_soft_dirty(*pvmw->pmd))
2884 pmde = pmd_mksoft_dirty(pmde);
2885 if (is_write_migration_entry(entry))
2886 pmde = maybe_pmd_mkwrite(pmde, vma);
2887
2888 flush_cache_range(vma, mmun_start, mmun_start + HPAGE_PMD_SIZE);
2889 page_add_anon_rmap(new, vma, mmun_start, true);
2890 set_pmd_at(mm, mmun_start, pvmw->pmd, pmde);
2891 if (vma->vm_flags & VM_LOCKED)
2892 mlock_vma_page(new);
2893 update_mmu_cache_pmd(vma, address, pvmw->pmd);
2894}
2895#endif
diff --git a/mm/interval_tree.c b/mm/interval_tree.c
index f2c2492681bf..b47664358796 100644
--- a/mm/interval_tree.c
+++ b/mm/interval_tree.c
@@ -28,7 +28,7 @@ INTERVAL_TREE_DEFINE(struct vm_area_struct, shared.rb,
28/* Insert node immediately after prev in the interval tree */ 28/* Insert node immediately after prev in the interval tree */
29void vma_interval_tree_insert_after(struct vm_area_struct *node, 29void vma_interval_tree_insert_after(struct vm_area_struct *node,
30 struct vm_area_struct *prev, 30 struct vm_area_struct *prev,
31 struct rb_root *root) 31 struct rb_root_cached *root)
32{ 32{
33 struct rb_node **link; 33 struct rb_node **link;
34 struct vm_area_struct *parent; 34 struct vm_area_struct *parent;
@@ -55,7 +55,7 @@ void vma_interval_tree_insert_after(struct vm_area_struct *node,
55 55
56 node->shared.rb_subtree_last = last; 56 node->shared.rb_subtree_last = last;
57 rb_link_node(&node->shared.rb, &parent->shared.rb, link); 57 rb_link_node(&node->shared.rb, &parent->shared.rb, link);
58 rb_insert_augmented(&node->shared.rb, root, 58 rb_insert_augmented(&node->shared.rb, &root->rb_root,
59 &vma_interval_tree_augment); 59 &vma_interval_tree_augment);
60} 60}
61 61
@@ -74,7 +74,7 @@ INTERVAL_TREE_DEFINE(struct anon_vma_chain, rb, unsigned long, rb_subtree_last,
74 static inline, __anon_vma_interval_tree) 74 static inline, __anon_vma_interval_tree)
75 75
76void anon_vma_interval_tree_insert(struct anon_vma_chain *node, 76void anon_vma_interval_tree_insert(struct anon_vma_chain *node,
77 struct rb_root *root) 77 struct rb_root_cached *root)
78{ 78{
79#ifdef CONFIG_DEBUG_VM_RB 79#ifdef CONFIG_DEBUG_VM_RB
80 node->cached_vma_start = avc_start_pgoff(node); 80 node->cached_vma_start = avc_start_pgoff(node);
@@ -84,13 +84,13 @@ void anon_vma_interval_tree_insert(struct anon_vma_chain *node,
84} 84}
85 85
86void anon_vma_interval_tree_remove(struct anon_vma_chain *node, 86void anon_vma_interval_tree_remove(struct anon_vma_chain *node,
87 struct rb_root *root) 87 struct rb_root_cached *root)
88{ 88{
89 __anon_vma_interval_tree_remove(node, root); 89 __anon_vma_interval_tree_remove(node, root);
90} 90}
91 91
92struct anon_vma_chain * 92struct anon_vma_chain *
93anon_vma_interval_tree_iter_first(struct rb_root *root, 93anon_vma_interval_tree_iter_first(struct rb_root_cached *root,
94 unsigned long first, unsigned long last) 94 unsigned long first, unsigned long last)
95{ 95{
96 return __anon_vma_interval_tree_iter_first(root, first, last); 96 return __anon_vma_interval_tree_iter_first(root, first, last);
diff --git a/mm/madvise.c b/mm/madvise.c
index eea1c733286f..21261ff0466f 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -355,7 +355,7 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
355 continue; 355 continue;
356 } 356 }
357 357
358 page = vm_normal_page(vma, addr, ptent); 358 page = _vm_normal_page(vma, addr, ptent, true);
359 if (!page) 359 if (!page)
360 continue; 360 continue;
361 361
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6532b219b222..15af3da5af02 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -119,6 +119,7 @@ static const char *const mem_cgroup_lru_names[] = {
119 119
120struct mem_cgroup_tree_per_node { 120struct mem_cgroup_tree_per_node {
121 struct rb_root rb_root; 121 struct rb_root rb_root;
122 struct rb_node *rb_rightmost;
122 spinlock_t lock; 123 spinlock_t lock;
123}; 124};
124 125
@@ -386,6 +387,7 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
386 struct rb_node **p = &mctz->rb_root.rb_node; 387 struct rb_node **p = &mctz->rb_root.rb_node;
387 struct rb_node *parent = NULL; 388 struct rb_node *parent = NULL;
388 struct mem_cgroup_per_node *mz_node; 389 struct mem_cgroup_per_node *mz_node;
390 bool rightmost = true;
389 391
390 if (mz->on_tree) 392 if (mz->on_tree)
391 return; 393 return;
@@ -397,8 +399,11 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
397 parent = *p; 399 parent = *p;
398 mz_node = rb_entry(parent, struct mem_cgroup_per_node, 400 mz_node = rb_entry(parent, struct mem_cgroup_per_node,
399 tree_node); 401 tree_node);
400 if (mz->usage_in_excess < mz_node->usage_in_excess) 402 if (mz->usage_in_excess < mz_node->usage_in_excess) {
401 p = &(*p)->rb_left; 403 p = &(*p)->rb_left;
404 rightmost = false;
405 }
406
402 /* 407 /*
403 * We can't avoid mem cgroups that are over their soft 408 * We can't avoid mem cgroups that are over their soft
404 * limit by the same amount 409 * limit by the same amount
@@ -406,6 +411,10 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
406 else if (mz->usage_in_excess >= mz_node->usage_in_excess) 411 else if (mz->usage_in_excess >= mz_node->usage_in_excess)
407 p = &(*p)->rb_right; 412 p = &(*p)->rb_right;
408 } 413 }
414
415 if (rightmost)
416 mctz->rb_rightmost = &mz->tree_node;
417
409 rb_link_node(&mz->tree_node, parent, p); 418 rb_link_node(&mz->tree_node, parent, p);
410 rb_insert_color(&mz->tree_node, &mctz->rb_root); 419 rb_insert_color(&mz->tree_node, &mctz->rb_root);
411 mz->on_tree = true; 420 mz->on_tree = true;
@@ -416,6 +425,10 @@ static void __mem_cgroup_remove_exceeded(struct mem_cgroup_per_node *mz,
416{ 425{
417 if (!mz->on_tree) 426 if (!mz->on_tree)
418 return; 427 return;
428
429 if (&mz->tree_node == mctz->rb_rightmost)
430 mctz->rb_rightmost = rb_prev(&mz->tree_node);
431
419 rb_erase(&mz->tree_node, &mctz->rb_root); 432 rb_erase(&mz->tree_node, &mctz->rb_root);
420 mz->on_tree = false; 433 mz->on_tree = false;
421} 434}
@@ -496,16 +509,15 @@ static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg)
496static struct mem_cgroup_per_node * 509static struct mem_cgroup_per_node *
497__mem_cgroup_largest_soft_limit_node(struct mem_cgroup_tree_per_node *mctz) 510__mem_cgroup_largest_soft_limit_node(struct mem_cgroup_tree_per_node *mctz)
498{ 511{
499 struct rb_node *rightmost = NULL;
500 struct mem_cgroup_per_node *mz; 512 struct mem_cgroup_per_node *mz;
501 513
502retry: 514retry:
503 mz = NULL; 515 mz = NULL;
504 rightmost = rb_last(&mctz->rb_root); 516 if (!mctz->rb_rightmost)
505 if (!rightmost)
506 goto done; /* Nothing to reclaim from */ 517 goto done; /* Nothing to reclaim from */
507 518
508 mz = rb_entry(rightmost, struct mem_cgroup_per_node, tree_node); 519 mz = rb_entry(mctz->rb_rightmost,
520 struct mem_cgroup_per_node, tree_node);
509 /* 521 /*
510 * Remove the node now but someone else can add it back, 522 * Remove the node now but someone else can add it back,
511 * we will to add it back at the end of reclaim to its correct 523 * we will to add it back at the end of reclaim to its correct
@@ -1792,6 +1804,9 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
1792 } 1804 }
1793 stock->nr_pages += nr_pages; 1805 stock->nr_pages += nr_pages;
1794 1806
1807 if (stock->nr_pages > CHARGE_BATCH)
1808 drain_stock(stock);
1809
1795 local_irq_restore(flags); 1810 local_irq_restore(flags);
1796} 1811}
1797 1812
@@ -4414,12 +4429,13 @@ enum mc_target_type {
4414 MC_TARGET_NONE = 0, 4429 MC_TARGET_NONE = 0,
4415 MC_TARGET_PAGE, 4430 MC_TARGET_PAGE,
4416 MC_TARGET_SWAP, 4431 MC_TARGET_SWAP,
4432 MC_TARGET_DEVICE,
4417}; 4433};
4418 4434
4419static struct page *mc_handle_present_pte(struct vm_area_struct *vma, 4435static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
4420 unsigned long addr, pte_t ptent) 4436 unsigned long addr, pte_t ptent)
4421{ 4437{
4422 struct page *page = vm_normal_page(vma, addr, ptent); 4438 struct page *page = _vm_normal_page(vma, addr, ptent, true);
4423 4439
4424 if (!page || !page_mapped(page)) 4440 if (!page || !page_mapped(page))
4425 return NULL; 4441 return NULL;
@@ -4436,7 +4452,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
4436 return page; 4452 return page;
4437} 4453}
4438 4454
4439#ifdef CONFIG_SWAP 4455#if defined(CONFIG_SWAP) || defined(CONFIG_DEVICE_PRIVATE)
4440static struct page *mc_handle_swap_pte(struct vm_area_struct *vma, 4456static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
4441 pte_t ptent, swp_entry_t *entry) 4457 pte_t ptent, swp_entry_t *entry)
4442{ 4458{
@@ -4445,6 +4461,23 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
4445 4461
4446 if (!(mc.flags & MOVE_ANON) || non_swap_entry(ent)) 4462 if (!(mc.flags & MOVE_ANON) || non_swap_entry(ent))
4447 return NULL; 4463 return NULL;
4464
4465 /*
4466 * Handle MEMORY_DEVICE_PRIVATE which are ZONE_DEVICE page belonging to
4467 * a device and because they are not accessible by CPU they are store
4468 * as special swap entry in the CPU page table.
4469 */
4470 if (is_device_private_entry(ent)) {
4471 page = device_private_entry_to_page(ent);
4472 /*
4473 * MEMORY_DEVICE_PRIVATE means ZONE_DEVICE page and which have
4474 * a refcount of 1 when free (unlike normal page)
4475 */
4476 if (!page_ref_add_unless(page, 1, 1))
4477 return NULL;
4478 return page;
4479 }
4480
4448 /* 4481 /*
4449 * Because lookup_swap_cache() updates some statistics counter, 4482 * Because lookup_swap_cache() updates some statistics counter,
4450 * we call find_get_page() with swapper_space directly. 4483 * we call find_get_page() with swapper_space directly.
@@ -4605,6 +4638,13 @@ out:
4605 * 2(MC_TARGET_SWAP): if the swap entry corresponding to this pte is a 4638 * 2(MC_TARGET_SWAP): if the swap entry corresponding to this pte is a
4606 * target for charge migration. if @target is not NULL, the entry is stored 4639 * target for charge migration. if @target is not NULL, the entry is stored
4607 * in target->ent. 4640 * in target->ent.
4641 * 3(MC_TARGET_DEVICE): like MC_TARGET_PAGE but page is MEMORY_DEVICE_PUBLIC
4642 * or MEMORY_DEVICE_PRIVATE (so ZONE_DEVICE page and thus not on the lru).
4643 * For now we such page is charge like a regular page would be as for all
4644 * intent and purposes it is just special memory taking the place of a
4645 * regular page.
4646 *
4647 * See Documentations/vm/hmm.txt and include/linux/hmm.h
4608 * 4648 *
4609 * Called with pte lock held. 4649 * Called with pte lock held.
4610 */ 4650 */
@@ -4633,6 +4673,9 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
4633 */ 4673 */
4634 if (page->mem_cgroup == mc.from) { 4674 if (page->mem_cgroup == mc.from) {
4635 ret = MC_TARGET_PAGE; 4675 ret = MC_TARGET_PAGE;
4676 if (is_device_private_page(page) ||
4677 is_device_public_page(page))
4678 ret = MC_TARGET_DEVICE;
4636 if (target) 4679 if (target)
4637 target->page = page; 4680 target->page = page;
4638 } 4681 }
@@ -4664,6 +4707,11 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma,
4664 struct page *page = NULL; 4707 struct page *page = NULL;
4665 enum mc_target_type ret = MC_TARGET_NONE; 4708 enum mc_target_type ret = MC_TARGET_NONE;
4666 4709
4710 if (unlikely(is_swap_pmd(pmd))) {
4711 VM_BUG_ON(thp_migration_supported() &&
4712 !is_pmd_migration_entry(pmd));
4713 return ret;
4714 }
4667 page = pmd_page(pmd); 4715 page = pmd_page(pmd);
4668 VM_BUG_ON_PAGE(!page || !PageHead(page), page); 4716 VM_BUG_ON_PAGE(!page || !PageHead(page), page);
4669 if (!(mc.flags & MOVE_ANON)) 4717 if (!(mc.flags & MOVE_ANON))
@@ -4695,6 +4743,11 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
4695 4743
4696 ptl = pmd_trans_huge_lock(pmd, vma); 4744 ptl = pmd_trans_huge_lock(pmd, vma);
4697 if (ptl) { 4745 if (ptl) {
4746 /*
4747 * Note their can not be MC_TARGET_DEVICE for now as we do not
4748 * support transparent huge page with MEMORY_DEVICE_PUBLIC or
4749 * MEMORY_DEVICE_PRIVATE but this might change.
4750 */
4698 if (get_mctgt_type_thp(vma, addr, *pmd, NULL) == MC_TARGET_PAGE) 4751 if (get_mctgt_type_thp(vma, addr, *pmd, NULL) == MC_TARGET_PAGE)
4699 mc.precharge += HPAGE_PMD_NR; 4752 mc.precharge += HPAGE_PMD_NR;
4700 spin_unlock(ptl); 4753 spin_unlock(ptl);
@@ -4910,6 +4963,14 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
4910 putback_lru_page(page); 4963 putback_lru_page(page);
4911 } 4964 }
4912 put_page(page); 4965 put_page(page);
4966 } else if (target_type == MC_TARGET_DEVICE) {
4967 page = target.page;
4968 if (!mem_cgroup_move_account(page, true,
4969 mc.from, mc.to)) {
4970 mc.precharge -= HPAGE_PMD_NR;
4971 mc.moved_charge += HPAGE_PMD_NR;
4972 }
4973 put_page(page);
4913 } 4974 }
4914 spin_unlock(ptl); 4975 spin_unlock(ptl);
4915 return 0; 4976 return 0;
@@ -4921,12 +4982,16 @@ retry:
4921 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 4982 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
4922 for (; addr != end; addr += PAGE_SIZE) { 4983 for (; addr != end; addr += PAGE_SIZE) {
4923 pte_t ptent = *(pte++); 4984 pte_t ptent = *(pte++);
4985 bool device = false;
4924 swp_entry_t ent; 4986 swp_entry_t ent;
4925 4987
4926 if (!mc.precharge) 4988 if (!mc.precharge)
4927 break; 4989 break;
4928 4990
4929 switch (get_mctgt_type(vma, addr, ptent, &target)) { 4991 switch (get_mctgt_type(vma, addr, ptent, &target)) {
4992 case MC_TARGET_DEVICE:
4993 device = true;
4994 /* fall through */
4930 case MC_TARGET_PAGE: 4995 case MC_TARGET_PAGE:
4931 page = target.page; 4996 page = target.page;
4932 /* 4997 /*
@@ -4937,7 +5002,7 @@ retry:
4937 */ 5002 */
4938 if (PageTransCompound(page)) 5003 if (PageTransCompound(page))
4939 goto put; 5004 goto put;
4940 if (isolate_lru_page(page)) 5005 if (!device && isolate_lru_page(page))
4941 goto put; 5006 goto put;
4942 if (!mem_cgroup_move_account(page, false, 5007 if (!mem_cgroup_move_account(page, false,
4943 mc.from, mc.to)) { 5008 mc.from, mc.to)) {
@@ -4945,7 +5010,8 @@ retry:
4945 /* we uncharge from mc.from later. */ 5010 /* we uncharge from mc.from later. */
4946 mc.moved_charge++; 5011 mc.moved_charge++;
4947 } 5012 }
4948 putback_lru_page(page); 5013 if (!device)
5014 putback_lru_page(page);
4949put: /* get_mctgt_type() gets the page */ 5015put: /* get_mctgt_type() gets the page */
4950 put_page(page); 5016 put_page(page);
4951 break; 5017 break;
@@ -5535,48 +5601,102 @@ void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg,
5535 cancel_charge(memcg, nr_pages); 5601 cancel_charge(memcg, nr_pages);
5536} 5602}
5537 5603
5538static void uncharge_batch(struct mem_cgroup *memcg, unsigned long pgpgout, 5604struct uncharge_gather {
5539 unsigned long nr_anon, unsigned long nr_file, 5605 struct mem_cgroup *memcg;
5540 unsigned long nr_kmem, unsigned long nr_huge, 5606 unsigned long pgpgout;
5541 unsigned long nr_shmem, struct page *dummy_page) 5607 unsigned long nr_anon;
5608 unsigned long nr_file;
5609 unsigned long nr_kmem;
5610 unsigned long nr_huge;
5611 unsigned long nr_shmem;
5612 struct page *dummy_page;
5613};
5614
5615static inline void uncharge_gather_clear(struct uncharge_gather *ug)
5616{
5617 memset(ug, 0, sizeof(*ug));
5618}
5619
5620static void uncharge_batch(const struct uncharge_gather *ug)
5542{ 5621{
5543 unsigned long nr_pages = nr_anon + nr_file + nr_kmem; 5622 unsigned long nr_pages = ug->nr_anon + ug->nr_file + ug->nr_kmem;
5544 unsigned long flags; 5623 unsigned long flags;
5545 5624
5546 if (!mem_cgroup_is_root(memcg)) { 5625 if (!mem_cgroup_is_root(ug->memcg)) {
5547 page_counter_uncharge(&memcg->memory, nr_pages); 5626 page_counter_uncharge(&ug->memcg->memory, nr_pages);
5548 if (do_memsw_account()) 5627 if (do_memsw_account())
5549 page_counter_uncharge(&memcg->memsw, nr_pages); 5628 page_counter_uncharge(&ug->memcg->memsw, nr_pages);
5550 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && nr_kmem) 5629 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && ug->nr_kmem)
5551 page_counter_uncharge(&memcg->kmem, nr_kmem); 5630 page_counter_uncharge(&ug->memcg->kmem, ug->nr_kmem);
5552 memcg_oom_recover(memcg); 5631 memcg_oom_recover(ug->memcg);
5553 } 5632 }
5554 5633
5555 local_irq_save(flags); 5634 local_irq_save(flags);
5556 __this_cpu_sub(memcg->stat->count[MEMCG_RSS], nr_anon); 5635 __this_cpu_sub(ug->memcg->stat->count[MEMCG_RSS], ug->nr_anon);
5557 __this_cpu_sub(memcg->stat->count[MEMCG_CACHE], nr_file); 5636 __this_cpu_sub(ug->memcg->stat->count[MEMCG_CACHE], ug->nr_file);
5558 __this_cpu_sub(memcg->stat->count[MEMCG_RSS_HUGE], nr_huge); 5637 __this_cpu_sub(ug->memcg->stat->count[MEMCG_RSS_HUGE], ug->nr_huge);
5559 __this_cpu_sub(memcg->stat->count[NR_SHMEM], nr_shmem); 5638 __this_cpu_sub(ug->memcg->stat->count[NR_SHMEM], ug->nr_shmem);
5560 __this_cpu_add(memcg->stat->events[PGPGOUT], pgpgout); 5639 __this_cpu_add(ug->memcg->stat->events[PGPGOUT], ug->pgpgout);
5561 __this_cpu_add(memcg->stat->nr_page_events, nr_pages); 5640 __this_cpu_add(ug->memcg->stat->nr_page_events, nr_pages);
5562 memcg_check_events(memcg, dummy_page); 5641 memcg_check_events(ug->memcg, ug->dummy_page);
5563 local_irq_restore(flags); 5642 local_irq_restore(flags);
5564 5643
5565 if (!mem_cgroup_is_root(memcg)) 5644 if (!mem_cgroup_is_root(ug->memcg))
5566 css_put_many(&memcg->css, nr_pages); 5645 css_put_many(&ug->memcg->css, nr_pages);
5646}
5647
5648static void uncharge_page(struct page *page, struct uncharge_gather *ug)
5649{
5650 VM_BUG_ON_PAGE(PageLRU(page), page);
5651 VM_BUG_ON_PAGE(!PageHWPoison(page) && page_count(page), page);
5652
5653 if (!page->mem_cgroup)
5654 return;
5655
5656 /*
5657 * Nobody should be changing or seriously looking at
5658 * page->mem_cgroup at this point, we have fully
5659 * exclusive access to the page.
5660 */
5661
5662 if (ug->memcg != page->mem_cgroup) {
5663 if (ug->memcg) {
5664 uncharge_batch(ug);
5665 uncharge_gather_clear(ug);
5666 }
5667 ug->memcg = page->mem_cgroup;
5668 }
5669
5670 if (!PageKmemcg(page)) {
5671 unsigned int nr_pages = 1;
5672
5673 if (PageTransHuge(page)) {
5674 nr_pages <<= compound_order(page);
5675 ug->nr_huge += nr_pages;
5676 }
5677 if (PageAnon(page))
5678 ug->nr_anon += nr_pages;
5679 else {
5680 ug->nr_file += nr_pages;
5681 if (PageSwapBacked(page))
5682 ug->nr_shmem += nr_pages;
5683 }
5684 ug->pgpgout++;
5685 } else {
5686 ug->nr_kmem += 1 << compound_order(page);
5687 __ClearPageKmemcg(page);
5688 }
5689
5690 ug->dummy_page = page;
5691 page->mem_cgroup = NULL;
5567} 5692}
5568 5693
5569static void uncharge_list(struct list_head *page_list) 5694static void uncharge_list(struct list_head *page_list)
5570{ 5695{
5571 struct mem_cgroup *memcg = NULL; 5696 struct uncharge_gather ug;
5572 unsigned long nr_shmem = 0;
5573 unsigned long nr_anon = 0;
5574 unsigned long nr_file = 0;
5575 unsigned long nr_huge = 0;
5576 unsigned long nr_kmem = 0;
5577 unsigned long pgpgout = 0;
5578 struct list_head *next; 5697 struct list_head *next;
5579 struct page *page; 5698
5699 uncharge_gather_clear(&ug);
5580 5700
5581 /* 5701 /*
5582 * Note that the list can be a single page->lru; hence the 5702 * Note that the list can be a single page->lru; hence the
@@ -5584,57 +5704,16 @@ static void uncharge_list(struct list_head *page_list)
5584 */ 5704 */
5585 next = page_list->next; 5705 next = page_list->next;
5586 do { 5706 do {
5707 struct page *page;
5708
5587 page = list_entry(next, struct page, lru); 5709 page = list_entry(next, struct page, lru);
5588 next = page->lru.next; 5710 next = page->lru.next;
5589 5711
5590 VM_BUG_ON_PAGE(PageLRU(page), page); 5712 uncharge_page(page, &ug);
5591 VM_BUG_ON_PAGE(!PageHWPoison(page) && page_count(page), page);
5592
5593 if (!page->mem_cgroup)
5594 continue;
5595
5596 /*
5597 * Nobody should be changing or seriously looking at
5598 * page->mem_cgroup at this point, we have fully
5599 * exclusive access to the page.
5600 */
5601
5602 if (memcg != page->mem_cgroup) {
5603 if (memcg) {
5604 uncharge_batch(memcg, pgpgout, nr_anon, nr_file,
5605 nr_kmem, nr_huge, nr_shmem, page);
5606 pgpgout = nr_anon = nr_file = nr_kmem = 0;
5607 nr_huge = nr_shmem = 0;
5608 }
5609 memcg = page->mem_cgroup;
5610 }
5611
5612 if (!PageKmemcg(page)) {
5613 unsigned int nr_pages = 1;
5614
5615 if (PageTransHuge(page)) {
5616 nr_pages <<= compound_order(page);
5617 nr_huge += nr_pages;
5618 }
5619 if (PageAnon(page))
5620 nr_anon += nr_pages;
5621 else {
5622 nr_file += nr_pages;
5623 if (PageSwapBacked(page))
5624 nr_shmem += nr_pages;
5625 }
5626 pgpgout++;
5627 } else {
5628 nr_kmem += 1 << compound_order(page);
5629 __ClearPageKmemcg(page);
5630 }
5631
5632 page->mem_cgroup = NULL;
5633 } while (next != page_list); 5713 } while (next != page_list);
5634 5714
5635 if (memcg) 5715 if (ug.memcg)
5636 uncharge_batch(memcg, pgpgout, nr_anon, nr_file, 5716 uncharge_batch(&ug);
5637 nr_kmem, nr_huge, nr_shmem, page);
5638} 5717}
5639 5718
5640/** 5719/**
@@ -5646,6 +5725,8 @@ static void uncharge_list(struct list_head *page_list)
5646 */ 5725 */
5647void mem_cgroup_uncharge(struct page *page) 5726void mem_cgroup_uncharge(struct page *page)
5648{ 5727{
5728 struct uncharge_gather ug;
5729
5649 if (mem_cgroup_disabled()) 5730 if (mem_cgroup_disabled())
5650 return; 5731 return;
5651 5732
@@ -5653,8 +5734,9 @@ void mem_cgroup_uncharge(struct page *page)
5653 if (!page->mem_cgroup) 5734 if (!page->mem_cgroup)
5654 return; 5735 return;
5655 5736
5656 INIT_LIST_HEAD(&page->lru); 5737 uncharge_gather_clear(&ug);
5657 uncharge_list(&page->lru); 5738 uncharge_page(page, &ug);
5739 uncharge_batch(&ug);
5658} 5740}
5659 5741
5660/** 5742/**
@@ -5819,8 +5901,7 @@ void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5819 5901
5820 this_cpu_sub(memcg->stat->count[MEMCG_SOCK], nr_pages); 5902 this_cpu_sub(memcg->stat->count[MEMCG_SOCK], nr_pages);
5821 5903
5822 page_counter_uncharge(&memcg->memory, nr_pages); 5904 refill_stock(memcg, nr_pages);
5823 css_put_many(&memcg->css, nr_pages);
5824} 5905}
5825 5906
5826static int __init cgroup_memory(char *s) 5907static int __init cgroup_memory(char *s)
@@ -5876,6 +5957,7 @@ static int __init mem_cgroup_init(void)
5876 node_online(node) ? node : NUMA_NO_NODE); 5957 node_online(node) ? node : NUMA_NO_NODE);
5877 5958
5878 rtpn->rb_root = RB_ROOT; 5959 rtpn->rb_root = RB_ROOT;
5960 rtpn->rb_rightmost = NULL;
5879 spin_lock_init(&rtpn->lock); 5961 spin_lock_init(&rtpn->lock);
5880 soft_limit_tree.rb_tree_per_node[node] = rtpn; 5962 soft_limit_tree.rb_tree_per_node[node] = rtpn;
5881 } 5963 }
diff --git a/mm/memory.c b/mm/memory.c
index 13ee83b43878..ec4e15494901 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -49,6 +49,7 @@
49#include <linux/swap.h> 49#include <linux/swap.h>
50#include <linux/highmem.h> 50#include <linux/highmem.h>
51#include <linux/pagemap.h> 51#include <linux/pagemap.h>
52#include <linux/memremap.h>
52#include <linux/ksm.h> 53#include <linux/ksm.h>
53#include <linux/rmap.h> 54#include <linux/rmap.h>
54#include <linux/export.h> 55#include <linux/export.h>
@@ -817,8 +818,8 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
817#else 818#else
818# define HAVE_PTE_SPECIAL 0 819# define HAVE_PTE_SPECIAL 0
819#endif 820#endif
820struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, 821struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
821 pte_t pte) 822 pte_t pte, bool with_public_device)
822{ 823{
823 unsigned long pfn = pte_pfn(pte); 824 unsigned long pfn = pte_pfn(pte);
824 825
@@ -829,8 +830,31 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
829 return vma->vm_ops->find_special_page(vma, addr); 830 return vma->vm_ops->find_special_page(vma, addr);
830 if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) 831 if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
831 return NULL; 832 return NULL;
832 if (!is_zero_pfn(pfn)) 833 if (is_zero_pfn(pfn))
833 print_bad_pte(vma, addr, pte, NULL); 834 return NULL;
835
836 /*
837 * Device public pages are special pages (they are ZONE_DEVICE
838 * pages but different from persistent memory). They behave
839 * allmost like normal pages. The difference is that they are
840 * not on the lru and thus should never be involve with any-
841 * thing that involve lru manipulation (mlock, numa balancing,
842 * ...).
843 *
844 * This is why we still want to return NULL for such page from
845 * vm_normal_page() so that we do not have to special case all
846 * call site of vm_normal_page().
847 */
848 if (likely(pfn < highest_memmap_pfn)) {
849 struct page *page = pfn_to_page(pfn);
850
851 if (is_device_public_page(page)) {
852 if (with_public_device)
853 return page;
854 return NULL;
855 }
856 }
857 print_bad_pte(vma, addr, pte, NULL);
834 return NULL; 858 return NULL;
835 } 859 }
836 860
@@ -956,6 +980,35 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
956 pte = pte_swp_mksoft_dirty(pte); 980 pte = pte_swp_mksoft_dirty(pte);
957 set_pte_at(src_mm, addr, src_pte, pte); 981 set_pte_at(src_mm, addr, src_pte, pte);
958 } 982 }
983 } else if (is_device_private_entry(entry)) {
984 page = device_private_entry_to_page(entry);
985
986 /*
987 * Update rss count even for unaddressable pages, as
988 * they should treated just like normal pages in this
989 * respect.
990 *
991 * We will likely want to have some new rss counters
992 * for unaddressable pages, at some point. But for now
993 * keep things as they are.
994 */
995 get_page(page);
996 rss[mm_counter(page)]++;
997 page_dup_rmap(page, false);
998
999 /*
1000 * We do not preserve soft-dirty information, because so
1001 * far, checkpoint/restore is the only feature that
1002 * requires that. And checkpoint/restore does not work
1003 * when a device driver is involved (you cannot easily
1004 * save and restore device driver state).
1005 */
1006 if (is_write_device_private_entry(entry) &&
1007 is_cow_mapping(vm_flags)) {
1008 make_device_private_entry_read(&entry);
1009 pte = swp_entry_to_pte(entry);
1010 set_pte_at(src_mm, addr, src_pte, pte);
1011 }
959 } 1012 }
960 goto out_set_pte; 1013 goto out_set_pte;
961 } 1014 }
@@ -982,6 +1035,19 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
982 get_page(page); 1035 get_page(page);
983 page_dup_rmap(page, false); 1036 page_dup_rmap(page, false);
984 rss[mm_counter(page)]++; 1037 rss[mm_counter(page)]++;
1038 } else if (pte_devmap(pte)) {
1039 page = pte_page(pte);
1040
1041 /*
1042 * Cache coherent device memory behave like regular page and
1043 * not like persistent memory page. For more informations see
1044 * MEMORY_DEVICE_CACHE_COHERENT in memory_hotplug.h
1045 */
1046 if (is_device_public_page(page)) {
1047 get_page(page);
1048 page_dup_rmap(page, false);
1049 rss[mm_counter(page)]++;
1050 }
985 } 1051 }
986 1052
987out_set_pte: 1053out_set_pte:
@@ -1065,7 +1131,8 @@ static inline int copy_pmd_range(struct mm_struct *dst_mm, struct mm_struct *src
1065 src_pmd = pmd_offset(src_pud, addr); 1131 src_pmd = pmd_offset(src_pud, addr);
1066 do { 1132 do {
1067 next = pmd_addr_end(addr, end); 1133 next = pmd_addr_end(addr, end);
1068 if (pmd_trans_huge(*src_pmd) || pmd_devmap(*src_pmd)) { 1134 if (is_swap_pmd(*src_pmd) || pmd_trans_huge(*src_pmd)
1135 || pmd_devmap(*src_pmd)) {
1069 int err; 1136 int err;
1070 VM_BUG_ON_VMA(next-addr != HPAGE_PMD_SIZE, vma); 1137 VM_BUG_ON_VMA(next-addr != HPAGE_PMD_SIZE, vma);
1071 err = copy_huge_pmd(dst_mm, src_mm, 1138 err = copy_huge_pmd(dst_mm, src_mm,
@@ -1236,7 +1303,7 @@ again:
1236 if (pte_present(ptent)) { 1303 if (pte_present(ptent)) {
1237 struct page *page; 1304 struct page *page;
1238 1305
1239 page = vm_normal_page(vma, addr, ptent); 1306 page = _vm_normal_page(vma, addr, ptent, true);
1240 if (unlikely(details) && page) { 1307 if (unlikely(details) && page) {
1241 /* 1308 /*
1242 * unmap_shared_mapping_pages() wants to 1309 * unmap_shared_mapping_pages() wants to
@@ -1273,6 +1340,29 @@ again:
1273 } 1340 }
1274 continue; 1341 continue;
1275 } 1342 }
1343
1344 entry = pte_to_swp_entry(ptent);
1345 if (non_swap_entry(entry) && is_device_private_entry(entry)) {
1346 struct page *page = device_private_entry_to_page(entry);
1347
1348 if (unlikely(details && details->check_mapping)) {
1349 /*
1350 * unmap_shared_mapping_pages() wants to
1351 * invalidate cache without truncating:
1352 * unmap shared but keep private pages.
1353 */
1354 if (details->check_mapping !=
1355 page_rmapping(page))
1356 continue;
1357 }
1358
1359 pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
1360 rss[mm_counter(page)]--;
1361 page_remove_rmap(page, false);
1362 put_page(page);
1363 continue;
1364 }
1365
1276 /* If details->check_mapping, we leave swap entries. */ 1366 /* If details->check_mapping, we leave swap entries. */
1277 if (unlikely(details)) 1367 if (unlikely(details))
1278 continue; 1368 continue;
@@ -1326,7 +1416,7 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
1326 pmd = pmd_offset(pud, addr); 1416 pmd = pmd_offset(pud, addr);
1327 do { 1417 do {
1328 next = pmd_addr_end(addr, end); 1418 next = pmd_addr_end(addr, end);
1329 if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { 1419 if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
1330 if (next - addr != HPAGE_PMD_SIZE) { 1420 if (next - addr != HPAGE_PMD_SIZE) {
1331 VM_BUG_ON_VMA(vma_is_anonymous(vma) && 1421 VM_BUG_ON_VMA(vma_is_anonymous(vma) &&
1332 !rwsem_is_locked(&tlb->mm->mmap_sem), vma); 1422 !rwsem_is_locked(&tlb->mm->mmap_sem), vma);
@@ -2671,7 +2761,7 @@ static void unmap_mapping_range_vma(struct vm_area_struct *vma,
2671 zap_page_range_single(vma, start_addr, end_addr - start_addr, details); 2761 zap_page_range_single(vma, start_addr, end_addr - start_addr, details);
2672} 2762}
2673 2763
2674static inline void unmap_mapping_range_tree(struct rb_root *root, 2764static inline void unmap_mapping_range_tree(struct rb_root_cached *root,
2675 struct zap_details *details) 2765 struct zap_details *details)
2676{ 2766{
2677 struct vm_area_struct *vma; 2767 struct vm_area_struct *vma;
@@ -2735,7 +2825,7 @@ void unmap_mapping_range(struct address_space *mapping,
2735 details.last_index = ULONG_MAX; 2825 details.last_index = ULONG_MAX;
2736 2826
2737 i_mmap_lock_write(mapping); 2827 i_mmap_lock_write(mapping);
2738 if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap))) 2828 if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
2739 unmap_mapping_range_tree(&mapping->i_mmap, &details); 2829 unmap_mapping_range_tree(&mapping->i_mmap, &details);
2740 i_mmap_unlock_write(mapping); 2830 i_mmap_unlock_write(mapping);
2741} 2831}
@@ -2775,6 +2865,14 @@ int do_swap_page(struct vm_fault *vmf)
2775 if (is_migration_entry(entry)) { 2865 if (is_migration_entry(entry)) {
2776 migration_entry_wait(vma->vm_mm, vmf->pmd, 2866 migration_entry_wait(vma->vm_mm, vmf->pmd,
2777 vmf->address); 2867 vmf->address);
2868 } else if (is_device_private_entry(entry)) {
2869 /*
2870 * For un-addressable device memory we call the pgmap
2871 * fault handler callback. The callback must migrate
2872 * the page back to some CPU accessible page.
2873 */
2874 ret = device_private_entry_fault(vma, vmf->address, entry,
2875 vmf->flags, vmf->pmd);
2778 } else if (is_hwpoison_entry(entry)) { 2876 } else if (is_hwpoison_entry(entry)) {
2779 ret = VM_FAULT_HWPOISON; 2877 ret = VM_FAULT_HWPOISON;
2780 } else { 2878 } else {
@@ -3863,6 +3961,7 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3863 .pgoff = linear_page_index(vma, address), 3961 .pgoff = linear_page_index(vma, address),
3864 .gfp_mask = __get_fault_gfp_mask(vma), 3962 .gfp_mask = __get_fault_gfp_mask(vma),
3865 }; 3963 };
3964 unsigned int dirty = flags & FAULT_FLAG_WRITE;
3866 struct mm_struct *mm = vma->vm_mm; 3965 struct mm_struct *mm = vma->vm_mm;
3867 pgd_t *pgd; 3966 pgd_t *pgd;
3868 p4d_t *p4d; 3967 p4d_t *p4d;
@@ -3885,7 +3984,6 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3885 3984
3886 barrier(); 3985 barrier();
3887 if (pud_trans_huge(orig_pud) || pud_devmap(orig_pud)) { 3986 if (pud_trans_huge(orig_pud) || pud_devmap(orig_pud)) {
3888 unsigned int dirty = flags & FAULT_FLAG_WRITE;
3889 3987
3890 /* NUMA case for anonymous PUDs would go here */ 3988 /* NUMA case for anonymous PUDs would go here */
3891 3989
@@ -3911,12 +4009,18 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3911 pmd_t orig_pmd = *vmf.pmd; 4009 pmd_t orig_pmd = *vmf.pmd;
3912 4010
3913 barrier(); 4011 barrier();
4012 if (unlikely(is_swap_pmd(orig_pmd))) {
4013 VM_BUG_ON(thp_migration_supported() &&
4014 !is_pmd_migration_entry(orig_pmd));
4015 if (is_pmd_migration_entry(orig_pmd))
4016 pmd_migration_entry_wait(mm, vmf.pmd);
4017 return 0;
4018 }
3914 if (pmd_trans_huge(orig_pmd) || pmd_devmap(orig_pmd)) { 4019 if (pmd_trans_huge(orig_pmd) || pmd_devmap(orig_pmd)) {
3915 if (pmd_protnone(orig_pmd) && vma_is_accessible(vma)) 4020 if (pmd_protnone(orig_pmd) && vma_is_accessible(vma))
3916 return do_huge_pmd_numa_page(&vmf, orig_pmd); 4021 return do_huge_pmd_numa_page(&vmf, orig_pmd);
3917 4022
3918 if ((vmf.flags & FAULT_FLAG_WRITE) && 4023 if (dirty && !pmd_write(orig_pmd)) {
3919 !pmd_write(orig_pmd)) {
3920 ret = wp_huge_pmd(&vmf, orig_pmd); 4024 ret = wp_huge_pmd(&vmf, orig_pmd);
3921 if (!(ret & VM_FAULT_FALLBACK)) 4025 if (!(ret & VM_FAULT_FALLBACK))
3922 return ret; 4026 return ret;
@@ -3949,6 +4053,11 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3949 /* do counter updates before entering really critical section. */ 4053 /* do counter updates before entering really critical section. */
3950 check_sync_rss_stat(current); 4054 check_sync_rss_stat(current);
3951 4055
4056 if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
4057 flags & FAULT_FLAG_INSTRUCTION,
4058 flags & FAULT_FLAG_REMOTE))
4059 return VM_FAULT_SIGSEGV;
4060
3952 /* 4061 /*
3953 * Enable the memcg OOM handling for faults triggered in user 4062 * Enable the memcg OOM handling for faults triggered in user
3954 * space. Kernel faults are handled more gracefully. 4063 * space. Kernel faults are handled more gracefully.
@@ -3956,11 +4065,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3956 if (flags & FAULT_FLAG_USER) 4065 if (flags & FAULT_FLAG_USER)
3957 mem_cgroup_oom_enable(); 4066 mem_cgroup_oom_enable();
3958 4067
3959 if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
3960 flags & FAULT_FLAG_INSTRUCTION,
3961 flags & FAULT_FLAG_REMOTE))
3962 return VM_FAULT_SIGSEGV;
3963
3964 if (unlikely(is_vm_hugetlb_page(vma))) 4068 if (unlikely(is_vm_hugetlb_page(vma)))
3965 ret = hugetlb_fault(vma->vm_mm, vma, address, flags); 4069 ret = hugetlb_fault(vma->vm_mm, vma, address, flags);
3966 else 4070 else
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 73bf17df6899..e882cb6da994 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -99,7 +99,7 @@ void mem_hotplug_done(void)
99/* add this memory to iomem resource */ 99/* add this memory to iomem resource */
100static struct resource *register_memory_resource(u64 start, u64 size) 100static struct resource *register_memory_resource(u64 start, u64 size)
101{ 101{
102 struct resource *res; 102 struct resource *res, *conflict;
103 res = kzalloc(sizeof(struct resource), GFP_KERNEL); 103 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
104 if (!res) 104 if (!res)
105 return ERR_PTR(-ENOMEM); 105 return ERR_PTR(-ENOMEM);
@@ -108,7 +108,13 @@ static struct resource *register_memory_resource(u64 start, u64 size)
108 res->start = start; 108 res->start = start;
109 res->end = start + size - 1; 109 res->end = start + size - 1;
110 res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; 110 res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
111 if (request_resource(&iomem_resource, res) < 0) { 111 conflict = request_resource_conflict(&iomem_resource, res);
112 if (conflict) {
113 if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) {
114 pr_debug("Device unaddressable memory block "
115 "memory hotplug at %#010llx !\n",
116 (unsigned long long)start);
117 }
112 pr_debug("System RAM resource %pR cannot be added\n", res); 118 pr_debug("System RAM resource %pR cannot be added\n", res);
113 kfree(res); 119 kfree(res);
114 return ERR_PTR(-EEXIST); 120 return ERR_PTR(-EEXIST);
@@ -1380,7 +1386,9 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
1380 if (isolate_huge_page(page, &source)) 1386 if (isolate_huge_page(page, &source))
1381 move_pages -= 1 << compound_order(head); 1387 move_pages -= 1 << compound_order(head);
1382 continue; 1388 continue;
1383 } 1389 } else if (thp_migration_supported() && PageTransHuge(page))
1390 pfn = page_to_pfn(compound_head(page))
1391 + hpage_nr_pages(page) - 1;
1384 1392
1385 if (!get_page_unless_zero(page)) 1393 if (!get_page_unless_zero(page))
1386 continue; 1394 continue;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 618ab125228b..006ba625c0b8 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -97,6 +97,7 @@
97#include <linux/mm_inline.h> 97#include <linux/mm_inline.h>
98#include <linux/mmu_notifier.h> 98#include <linux/mmu_notifier.h>
99#include <linux/printk.h> 99#include <linux/printk.h>
100#include <linux/swapops.h>
100 101
101#include <asm/tlbflush.h> 102#include <asm/tlbflush.h>
102#include <linux/uaccess.h> 103#include <linux/uaccess.h>
@@ -412,6 +413,64 @@ struct queue_pages {
412}; 413};
413 414
414/* 415/*
416 * Check if the page's nid is in qp->nmask.
417 *
418 * If MPOL_MF_INVERT is set in qp->flags, check if the nid is
419 * in the invert of qp->nmask.
420 */
421static inline bool queue_pages_required(struct page *page,
422 struct queue_pages *qp)
423{
424 int nid = page_to_nid(page);
425 unsigned long flags = qp->flags;
426
427 return node_isset(nid, *qp->nmask) == !(flags & MPOL_MF_INVERT);
428}
429
430static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,
431 unsigned long end, struct mm_walk *walk)
432{
433 int ret = 0;
434 struct page *page;
435 struct queue_pages *qp = walk->private;
436 unsigned long flags;
437
438 if (unlikely(is_pmd_migration_entry(*pmd))) {
439 ret = 1;
440 goto unlock;
441 }
442 page = pmd_page(*pmd);
443 if (is_huge_zero_page(page)) {
444 spin_unlock(ptl);
445 __split_huge_pmd(walk->vma, pmd, addr, false, NULL);
446 goto out;
447 }
448 if (!thp_migration_supported()) {
449 get_page(page);
450 spin_unlock(ptl);
451 lock_page(page);
452 ret = split_huge_page(page);
453 unlock_page(page);
454 put_page(page);
455 goto out;
456 }
457 if (!queue_pages_required(page, qp)) {
458 ret = 1;
459 goto unlock;
460 }
461
462 ret = 1;
463 flags = qp->flags;
464 /* go to thp migration */
465 if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
466 migrate_page_add(page, qp->pagelist, flags);
467unlock:
468 spin_unlock(ptl);
469out:
470 return ret;
471}
472
473/*
415 * Scan through pages checking if pages follow certain conditions, 474 * Scan through pages checking if pages follow certain conditions,
416 * and move them to the pagelist if they do. 475 * and move them to the pagelist if they do.
417 */ 476 */
@@ -422,30 +481,15 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
422 struct page *page; 481 struct page *page;
423 struct queue_pages *qp = walk->private; 482 struct queue_pages *qp = walk->private;
424 unsigned long flags = qp->flags; 483 unsigned long flags = qp->flags;
425 int nid, ret; 484 int ret;
426 pte_t *pte; 485 pte_t *pte;
427 spinlock_t *ptl; 486 spinlock_t *ptl;
428 487
429 if (pmd_trans_huge(*pmd)) { 488 ptl = pmd_trans_huge_lock(pmd, vma);
430 ptl = pmd_lock(walk->mm, pmd); 489 if (ptl) {
431 if (pmd_trans_huge(*pmd)) { 490 ret = queue_pages_pmd(pmd, ptl, addr, end, walk);
432 page = pmd_page(*pmd); 491 if (ret)
433 if (is_huge_zero_page(page)) { 492 return 0;
434 spin_unlock(ptl);
435 __split_huge_pmd(vma, pmd, addr, false, NULL);
436 } else {
437 get_page(page);
438 spin_unlock(ptl);
439 lock_page(page);
440 ret = split_huge_page(page);
441 unlock_page(page);
442 put_page(page);
443 if (ret)
444 return 0;
445 }
446 } else {
447 spin_unlock(ptl);
448 }
449 } 493 }
450 494
451 if (pmd_trans_unstable(pmd)) 495 if (pmd_trans_unstable(pmd))
@@ -464,10 +508,9 @@ retry:
464 */ 508 */
465 if (PageReserved(page)) 509 if (PageReserved(page))
466 continue; 510 continue;
467 nid = page_to_nid(page); 511 if (!queue_pages_required(page, qp))
468 if (node_isset(nid, *qp->nmask) == !!(flags & MPOL_MF_INVERT))
469 continue; 512 continue;
470 if (PageTransCompound(page)) { 513 if (PageTransCompound(page) && !thp_migration_supported()) {
471 get_page(page); 514 get_page(page);
472 pte_unmap_unlock(pte, ptl); 515 pte_unmap_unlock(pte, ptl);
473 lock_page(page); 516 lock_page(page);
@@ -497,7 +540,6 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
497#ifdef CONFIG_HUGETLB_PAGE 540#ifdef CONFIG_HUGETLB_PAGE
498 struct queue_pages *qp = walk->private; 541 struct queue_pages *qp = walk->private;
499 unsigned long flags = qp->flags; 542 unsigned long flags = qp->flags;
500 int nid;
501 struct page *page; 543 struct page *page;
502 spinlock_t *ptl; 544 spinlock_t *ptl;
503 pte_t entry; 545 pte_t entry;
@@ -507,8 +549,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
507 if (!pte_present(entry)) 549 if (!pte_present(entry))
508 goto unlock; 550 goto unlock;
509 page = pte_page(entry); 551 page = pte_page(entry);
510 nid = page_to_nid(page); 552 if (!queue_pages_required(page, qp))
511 if (node_isset(nid, *qp->nmask) == !!(flags & MPOL_MF_INVERT))
512 goto unlock; 553 goto unlock;
513 /* With MPOL_MF_MOVE, we migrate only unshared hugepage. */ 554 /* With MPOL_MF_MOVE, we migrate only unshared hugepage. */
514 if (flags & (MPOL_MF_MOVE_ALL) || 555 if (flags & (MPOL_MF_MOVE_ALL) ||
@@ -881,19 +922,21 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
881 922
882#ifdef CONFIG_MIGRATION 923#ifdef CONFIG_MIGRATION
883/* 924/*
884 * page migration 925 * page migration, thp tail pages can be passed.
885 */ 926 */
886static void migrate_page_add(struct page *page, struct list_head *pagelist, 927static void migrate_page_add(struct page *page, struct list_head *pagelist,
887 unsigned long flags) 928 unsigned long flags)
888{ 929{
930 struct page *head = compound_head(page);
889 /* 931 /*
890 * Avoid migrating a page that is shared with others. 932 * Avoid migrating a page that is shared with others.
891 */ 933 */
892 if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(page) == 1) { 934 if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(head) == 1) {
893 if (!isolate_lru_page(page)) { 935 if (!isolate_lru_page(head)) {
894 list_add_tail(&page->lru, pagelist); 936 list_add_tail(&head->lru, pagelist);
895 inc_node_page_state(page, NR_ISOLATED_ANON + 937 mod_node_page_state(page_pgdat(head),
896 page_is_file_cache(page)); 938 NR_ISOLATED_ANON + page_is_file_cache(head),
939 hpage_nr_pages(head));
897 } 940 }
898 } 941 }
899} 942}
@@ -903,7 +946,17 @@ static struct page *new_node_page(struct page *page, unsigned long node, int **x
903 if (PageHuge(page)) 946 if (PageHuge(page))
904 return alloc_huge_page_node(page_hstate(compound_head(page)), 947 return alloc_huge_page_node(page_hstate(compound_head(page)),
905 node); 948 node);
906 else 949 else if (thp_migration_supported() && PageTransHuge(page)) {
950 struct page *thp;
951
952 thp = alloc_pages_node(node,
953 (GFP_TRANSHUGE | __GFP_THISNODE),
954 HPAGE_PMD_ORDER);
955 if (!thp)
956 return NULL;
957 prep_transhuge_page(thp);
958 return thp;
959 } else
907 return __alloc_pages_node(node, GFP_HIGHUSER_MOVABLE | 960 return __alloc_pages_node(node, GFP_HIGHUSER_MOVABLE |
908 __GFP_THISNODE, 0); 961 __GFP_THISNODE, 0);
909} 962}
@@ -1069,6 +1122,15 @@ static struct page *new_page(struct page *page, unsigned long start, int **x)
1069 if (PageHuge(page)) { 1122 if (PageHuge(page)) {
1070 BUG_ON(!vma); 1123 BUG_ON(!vma);
1071 return alloc_huge_page_noerr(vma, address, 1); 1124 return alloc_huge_page_noerr(vma, address, 1);
1125 } else if (thp_migration_supported() && PageTransHuge(page)) {
1126 struct page *thp;
1127
1128 thp = alloc_hugepage_vma(GFP_TRANSHUGE, vma, address,
1129 HPAGE_PMD_ORDER);
1130 if (!thp)
1131 return NULL;
1132 prep_transhuge_page(thp);
1133 return thp;
1072 } 1134 }
1073 /* 1135 /*
1074 * if !vma, alloc_page_vma() will use task or system default policy 1136 * if !vma, alloc_page_vma() will use task or system default policy
@@ -1683,8 +1745,7 @@ unsigned int mempolicy_slab_node(void)
1683 * node in pol->v.nodes (starting from n=0), wrapping around if n exceeds the 1745 * node in pol->v.nodes (starting from n=0), wrapping around if n exceeds the
1684 * number of present nodes. 1746 * number of present nodes.
1685 */ 1747 */
1686static unsigned offset_il_node(struct mempolicy *pol, 1748static unsigned offset_il_node(struct mempolicy *pol, unsigned long n)
1687 struct vm_area_struct *vma, unsigned long n)
1688{ 1749{
1689 unsigned nnodes = nodes_weight(pol->v.nodes); 1750 unsigned nnodes = nodes_weight(pol->v.nodes);
1690 unsigned target; 1751 unsigned target;
@@ -1717,7 +1778,7 @@ static inline unsigned interleave_nid(struct mempolicy *pol,
1717 BUG_ON(shift < PAGE_SHIFT); 1778 BUG_ON(shift < PAGE_SHIFT);
1718 off = vma->vm_pgoff >> (shift - PAGE_SHIFT); 1779 off = vma->vm_pgoff >> (shift - PAGE_SHIFT);
1719 off += (addr - vma->vm_start) >> shift; 1780 off += (addr - vma->vm_start) >> shift;
1720 return offset_il_node(pol, vma, off); 1781 return offset_il_node(pol, off);
1721 } else 1782 } else
1722 return interleave_nodes(pol); 1783 return interleave_nodes(pol);
1723} 1784}
@@ -2172,20 +2233,15 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
2172 int polnid = -1; 2233 int polnid = -1;
2173 int ret = -1; 2234 int ret = -1;
2174 2235
2175 BUG_ON(!vma);
2176
2177 pol = get_vma_policy(vma, addr); 2236 pol = get_vma_policy(vma, addr);
2178 if (!(pol->flags & MPOL_F_MOF)) 2237 if (!(pol->flags & MPOL_F_MOF))
2179 goto out; 2238 goto out;
2180 2239
2181 switch (pol->mode) { 2240 switch (pol->mode) {
2182 case MPOL_INTERLEAVE: 2241 case MPOL_INTERLEAVE:
2183 BUG_ON(addr >= vma->vm_end);
2184 BUG_ON(addr < vma->vm_start);
2185
2186 pgoff = vma->vm_pgoff; 2242 pgoff = vma->vm_pgoff;
2187 pgoff += (addr - vma->vm_start) >> PAGE_SHIFT; 2243 pgoff += (addr - vma->vm_start) >> PAGE_SHIFT;
2188 polnid = offset_il_node(pol, vma, pgoff); 2244 polnid = offset_il_node(pol, pgoff);
2189 break; 2245 break;
2190 2246
2191 case MPOL_PREFERRED: 2247 case MPOL_PREFERRED:
diff --git a/mm/migrate.c b/mm/migrate.c
index e84eeb4e4356..6954c1435833 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -36,6 +36,9 @@
36#include <linux/hugetlb.h> 36#include <linux/hugetlb.h>
37#include <linux/hugetlb_cgroup.h> 37#include <linux/hugetlb_cgroup.h>
38#include <linux/gfp.h> 38#include <linux/gfp.h>
39#include <linux/pfn_t.h>
40#include <linux/memremap.h>
41#include <linux/userfaultfd_k.h>
39#include <linux/balloon_compaction.h> 42#include <linux/balloon_compaction.h>
40#include <linux/mmu_notifier.h> 43#include <linux/mmu_notifier.h>
41#include <linux/page_idle.h> 44#include <linux/page_idle.h>
@@ -185,8 +188,8 @@ void putback_movable_pages(struct list_head *l)
185 unlock_page(page); 188 unlock_page(page);
186 put_page(page); 189 put_page(page);
187 } else { 190 } else {
188 dec_node_page_state(page, NR_ISOLATED_ANON + 191 mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON +
189 page_is_file_cache(page)); 192 page_is_file_cache(page), -hpage_nr_pages(page));
190 putback_lru_page(page); 193 putback_lru_page(page);
191 } 194 }
192 } 195 }
@@ -216,6 +219,15 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
216 new = page - pvmw.page->index + 219 new = page - pvmw.page->index +
217 linear_page_index(vma, pvmw.address); 220 linear_page_index(vma, pvmw.address);
218 221
222#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
223 /* PMD-mapped THP migration entry */
224 if (!pvmw.pte) {
225 VM_BUG_ON_PAGE(PageHuge(page) || !PageTransCompound(page), page);
226 remove_migration_pmd(&pvmw, new);
227 continue;
228 }
229#endif
230
219 get_page(new); 231 get_page(new);
220 pte = pte_mkold(mk_pte(new, READ_ONCE(vma->vm_page_prot))); 232 pte = pte_mkold(mk_pte(new, READ_ONCE(vma->vm_page_prot)));
221 if (pte_swp_soft_dirty(*pvmw.pte)) 233 if (pte_swp_soft_dirty(*pvmw.pte))
@@ -228,7 +240,17 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
228 if (is_write_migration_entry(entry)) 240 if (is_write_migration_entry(entry))
229 pte = maybe_mkwrite(pte, vma); 241 pte = maybe_mkwrite(pte, vma);
230 242
231 flush_dcache_page(new); 243 if (unlikely(is_zone_device_page(new))) {
244 if (is_device_private_page(new)) {
245 entry = make_device_private_entry(new, pte_write(pte));
246 pte = swp_entry_to_pte(entry);
247 } else if (is_device_public_page(new)) {
248 pte = pte_mkdevmap(pte);
249 flush_dcache_page(new);
250 }
251 } else
252 flush_dcache_page(new);
253
232#ifdef CONFIG_HUGETLB_PAGE 254#ifdef CONFIG_HUGETLB_PAGE
233 if (PageHuge(new)) { 255 if (PageHuge(new)) {
234 pte = pte_mkhuge(pte); 256 pte = pte_mkhuge(pte);
@@ -330,6 +352,27 @@ void migration_entry_wait_huge(struct vm_area_struct *vma,
330 __migration_entry_wait(mm, pte, ptl); 352 __migration_entry_wait(mm, pte, ptl);
331} 353}
332 354
355#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
356void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd)
357{
358 spinlock_t *ptl;
359 struct page *page;
360
361 ptl = pmd_lock(mm, pmd);
362 if (!is_pmd_migration_entry(*pmd))
363 goto unlock;
364 page = migration_entry_to_page(pmd_to_swp_entry(*pmd));
365 if (!get_page_unless_zero(page))
366 goto unlock;
367 spin_unlock(ptl);
368 wait_on_page_locked(page);
369 put_page(page);
370 return;
371unlock:
372 spin_unlock(ptl);
373}
374#endif
375
333#ifdef CONFIG_BLOCK 376#ifdef CONFIG_BLOCK
334/* Returns true if all buffers are successfully locked */ 377/* Returns true if all buffers are successfully locked */
335static bool buffer_migrate_lock_buffers(struct buffer_head *head, 378static bool buffer_migrate_lock_buffers(struct buffer_head *head,
@@ -398,6 +441,13 @@ int migrate_page_move_mapping(struct address_space *mapping,
398 int expected_count = 1 + extra_count; 441 int expected_count = 1 + extra_count;
399 void **pslot; 442 void **pslot;
400 443
444 /*
445 * Device public or private pages have an extra refcount as they are
446 * ZONE_DEVICE pages.
447 */
448 expected_count += is_device_private_page(page);
449 expected_count += is_device_public_page(page);
450
401 if (!mapping) { 451 if (!mapping) {
402 /* Anonymous page without mapping */ 452 /* Anonymous page without mapping */
403 if (page_count(page) != expected_count) 453 if (page_count(page) != expected_count)
@@ -604,15 +654,10 @@ static void copy_huge_page(struct page *dst, struct page *src)
604/* 654/*
605 * Copy the page to its new location 655 * Copy the page to its new location
606 */ 656 */
607void migrate_page_copy(struct page *newpage, struct page *page) 657void migrate_page_states(struct page *newpage, struct page *page)
608{ 658{
609 int cpupid; 659 int cpupid;
610 660
611 if (PageHuge(page) || PageTransHuge(page))
612 copy_huge_page(newpage, page);
613 else
614 copy_highpage(newpage, page);
615
616 if (PageError(page)) 661 if (PageError(page))
617 SetPageError(newpage); 662 SetPageError(newpage);
618 if (PageReferenced(page)) 663 if (PageReferenced(page))
@@ -666,6 +711,17 @@ void migrate_page_copy(struct page *newpage, struct page *page)
666 711
667 mem_cgroup_migrate(page, newpage); 712 mem_cgroup_migrate(page, newpage);
668} 713}
714EXPORT_SYMBOL(migrate_page_states);
715
716void migrate_page_copy(struct page *newpage, struct page *page)
717{
718 if (PageHuge(page) || PageTransHuge(page))
719 copy_huge_page(newpage, page);
720 else
721 copy_highpage(newpage, page);
722
723 migrate_page_states(newpage, page);
724}
669EXPORT_SYMBOL(migrate_page_copy); 725EXPORT_SYMBOL(migrate_page_copy);
670 726
671/************************************************************ 727/************************************************************
@@ -691,7 +747,10 @@ int migrate_page(struct address_space *mapping,
691 if (rc != MIGRATEPAGE_SUCCESS) 747 if (rc != MIGRATEPAGE_SUCCESS)
692 return rc; 748 return rc;
693 749
694 migrate_page_copy(newpage, page); 750 if (mode != MIGRATE_SYNC_NO_COPY)
751 migrate_page_copy(newpage, page);
752 else
753 migrate_page_states(newpage, page);
695 return MIGRATEPAGE_SUCCESS; 754 return MIGRATEPAGE_SUCCESS;
696} 755}
697EXPORT_SYMBOL(migrate_page); 756EXPORT_SYMBOL(migrate_page);
@@ -741,12 +800,15 @@ int buffer_migrate_page(struct address_space *mapping,
741 800
742 SetPagePrivate(newpage); 801 SetPagePrivate(newpage);
743 802
744 migrate_page_copy(newpage, page); 803 if (mode != MIGRATE_SYNC_NO_COPY)
804 migrate_page_copy(newpage, page);
805 else
806 migrate_page_states(newpage, page);
745 807
746 bh = head; 808 bh = head;
747 do { 809 do {
748 unlock_buffer(bh); 810 unlock_buffer(bh);
749 put_bh(bh); 811 put_bh(bh);
750 bh = bh->b_this_page; 812 bh = bh->b_this_page;
751 813
752 } while (bh != head); 814 } while (bh != head);
@@ -805,8 +867,13 @@ static int fallback_migrate_page(struct address_space *mapping,
805{ 867{
806 if (PageDirty(page)) { 868 if (PageDirty(page)) {
807 /* Only writeback pages in full synchronous migration */ 869 /* Only writeback pages in full synchronous migration */
808 if (mode != MIGRATE_SYNC) 870 switch (mode) {
871 case MIGRATE_SYNC:
872 case MIGRATE_SYNC_NO_COPY:
873 break;
874 default:
809 return -EBUSY; 875 return -EBUSY;
876 }
810 return writeout(mapping, page); 877 return writeout(mapping, page);
811 } 878 }
812 879
@@ -943,7 +1010,11 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
943 * the retry loop is too short and in the sync-light case, 1010 * the retry loop is too short and in the sync-light case,
944 * the overhead of stalling is too much 1011 * the overhead of stalling is too much
945 */ 1012 */
946 if (mode != MIGRATE_SYNC) { 1013 switch (mode) {
1014 case MIGRATE_SYNC:
1015 case MIGRATE_SYNC_NO_COPY:
1016 break;
1017 default:
947 rc = -EBUSY; 1018 rc = -EBUSY;
948 goto out_unlock; 1019 goto out_unlock;
949 } 1020 }
@@ -1088,7 +1159,7 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,
1088 goto out; 1159 goto out;
1089 } 1160 }
1090 1161
1091 if (unlikely(PageTransHuge(page))) { 1162 if (unlikely(PageTransHuge(page) && !PageTransHuge(newpage))) {
1092 lock_page(page); 1163 lock_page(page);
1093 rc = split_huge_page(page); 1164 rc = split_huge_page(page);
1094 unlock_page(page); 1165 unlock_page(page);
@@ -1116,8 +1187,8 @@ out:
1116 * as __PageMovable 1187 * as __PageMovable
1117 */ 1188 */
1118 if (likely(!__PageMovable(page))) 1189 if (likely(!__PageMovable(page)))
1119 dec_node_page_state(page, NR_ISOLATED_ANON + 1190 mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON +
1120 page_is_file_cache(page)); 1191 page_is_file_cache(page), -hpage_nr_pages(page));
1121 } 1192 }
1122 1193
1123 /* 1194 /*
@@ -1213,8 +1284,15 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
1213 return -ENOMEM; 1284 return -ENOMEM;
1214 1285
1215 if (!trylock_page(hpage)) { 1286 if (!trylock_page(hpage)) {
1216 if (!force || mode != MIGRATE_SYNC) 1287 if (!force)
1288 goto out;
1289 switch (mode) {
1290 case MIGRATE_SYNC:
1291 case MIGRATE_SYNC_NO_COPY:
1292 break;
1293 default:
1217 goto out; 1294 goto out;
1295 }
1218 lock_page(hpage); 1296 lock_page(hpage);
1219 } 1297 }
1220 1298
@@ -1391,7 +1469,17 @@ static struct page *new_page_node(struct page *p, unsigned long private,
1391 if (PageHuge(p)) 1469 if (PageHuge(p))
1392 return alloc_huge_page_node(page_hstate(compound_head(p)), 1470 return alloc_huge_page_node(page_hstate(compound_head(p)),
1393 pm->node); 1471 pm->node);
1394 else 1472 else if (thp_migration_supported() && PageTransHuge(p)) {
1473 struct page *thp;
1474
1475 thp = alloc_pages_node(pm->node,
1476 (GFP_TRANSHUGE | __GFP_THISNODE) & ~__GFP_RECLAIM,
1477 HPAGE_PMD_ORDER);
1478 if (!thp)
1479 return NULL;
1480 prep_transhuge_page(thp);
1481 return thp;
1482 } else
1395 return __alloc_pages_node(pm->node, 1483 return __alloc_pages_node(pm->node,
1396 GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, 0); 1484 GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, 0);
1397} 1485}
@@ -1418,6 +1506,8 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
1418 for (pp = pm; pp->node != MAX_NUMNODES; pp++) { 1506 for (pp = pm; pp->node != MAX_NUMNODES; pp++) {
1419 struct vm_area_struct *vma; 1507 struct vm_area_struct *vma;
1420 struct page *page; 1508 struct page *page;
1509 struct page *head;
1510 unsigned int follflags;
1421 1511
1422 err = -EFAULT; 1512 err = -EFAULT;
1423 vma = find_vma(mm, pp->addr); 1513 vma = find_vma(mm, pp->addr);
@@ -1425,8 +1515,10 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
1425 goto set_status; 1515 goto set_status;
1426 1516
1427 /* FOLL_DUMP to ignore special (like zero) pages */ 1517 /* FOLL_DUMP to ignore special (like zero) pages */
1428 page = follow_page(vma, pp->addr, 1518 follflags = FOLL_GET | FOLL_DUMP;
1429 FOLL_GET | FOLL_SPLIT | FOLL_DUMP); 1519 if (!thp_migration_supported())
1520 follflags |= FOLL_SPLIT;
1521 page = follow_page(vma, pp->addr, follflags);
1430 1522
1431 err = PTR_ERR(page); 1523 err = PTR_ERR(page);
1432 if (IS_ERR(page)) 1524 if (IS_ERR(page))
@@ -1436,7 +1528,6 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
1436 if (!page) 1528 if (!page)
1437 goto set_status; 1529 goto set_status;
1438 1530
1439 pp->page = page;
1440 err = page_to_nid(page); 1531 err = page_to_nid(page);
1441 1532
1442 if (err == pp->node) 1533 if (err == pp->node)
@@ -1451,16 +1542,22 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
1451 goto put_and_set; 1542 goto put_and_set;
1452 1543
1453 if (PageHuge(page)) { 1544 if (PageHuge(page)) {
1454 if (PageHead(page)) 1545 if (PageHead(page)) {
1455 isolate_huge_page(page, &pagelist); 1546 isolate_huge_page(page, &pagelist);
1547 err = 0;
1548 pp->page = page;
1549 }
1456 goto put_and_set; 1550 goto put_and_set;
1457 } 1551 }
1458 1552
1459 err = isolate_lru_page(page); 1553 pp->page = compound_head(page);
1554 head = compound_head(page);
1555 err = isolate_lru_page(head);
1460 if (!err) { 1556 if (!err) {
1461 list_add_tail(&page->lru, &pagelist); 1557 list_add_tail(&head->lru, &pagelist);
1462 inc_node_page_state(page, NR_ISOLATED_ANON + 1558 mod_node_page_state(page_pgdat(head),
1463 page_is_file_cache(page)); 1559 NR_ISOLATED_ANON + page_is_file_cache(head),
1560 hpage_nr_pages(head));
1464 } 1561 }
1465put_and_set: 1562put_and_set:
1466 /* 1563 /*
@@ -2029,3 +2126,859 @@ out_unlock:
2029#endif /* CONFIG_NUMA_BALANCING */ 2126#endif /* CONFIG_NUMA_BALANCING */
2030 2127
2031#endif /* CONFIG_NUMA */ 2128#endif /* CONFIG_NUMA */
2129
2130#if defined(CONFIG_MIGRATE_VMA_HELPER)
2131struct migrate_vma {
2132 struct vm_area_struct *vma;
2133 unsigned long *dst;
2134 unsigned long *src;
2135 unsigned long cpages;
2136 unsigned long npages;
2137 unsigned long start;
2138 unsigned long end;
2139};
2140
2141static int migrate_vma_collect_hole(unsigned long start,
2142 unsigned long end,
2143 struct mm_walk *walk)
2144{
2145 struct migrate_vma *migrate = walk->private;
2146 unsigned long addr;
2147
2148 for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
2149 migrate->src[migrate->npages++] = MIGRATE_PFN_MIGRATE;
2150 migrate->dst[migrate->npages] = 0;
2151 migrate->cpages++;
2152 }
2153
2154 return 0;
2155}
2156
2157static int migrate_vma_collect_skip(unsigned long start,
2158 unsigned long end,
2159 struct mm_walk *walk)
2160{
2161 struct migrate_vma *migrate = walk->private;
2162 unsigned long addr;
2163
2164 for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
2165 migrate->dst[migrate->npages] = 0;
2166 migrate->src[migrate->npages++] = 0;
2167 }
2168
2169 return 0;
2170}
2171
2172static int migrate_vma_collect_pmd(pmd_t *pmdp,
2173 unsigned long start,
2174 unsigned long end,
2175 struct mm_walk *walk)
2176{
2177 struct migrate_vma *migrate = walk->private;
2178 struct vm_area_struct *vma = walk->vma;
2179 struct mm_struct *mm = vma->vm_mm;
2180 unsigned long addr = start, unmapped = 0;
2181 spinlock_t *ptl;
2182 pte_t *ptep;
2183
2184again:
2185 if (pmd_none(*pmdp))
2186 return migrate_vma_collect_hole(start, end, walk);
2187
2188 if (pmd_trans_huge(*pmdp)) {
2189 struct page *page;
2190
2191 ptl = pmd_lock(mm, pmdp);
2192 if (unlikely(!pmd_trans_huge(*pmdp))) {
2193 spin_unlock(ptl);
2194 goto again;
2195 }
2196
2197 page = pmd_page(*pmdp);
2198 if (is_huge_zero_page(page)) {
2199 spin_unlock(ptl);
2200 split_huge_pmd(vma, pmdp, addr);
2201 if (pmd_trans_unstable(pmdp))
2202 return migrate_vma_collect_skip(start, end,
2203 walk);
2204 } else {
2205 int ret;
2206
2207 get_page(page);
2208 spin_unlock(ptl);
2209 if (unlikely(!trylock_page(page)))
2210 return migrate_vma_collect_skip(start, end,
2211 walk);
2212 ret = split_huge_page(page);
2213 unlock_page(page);
2214 put_page(page);
2215 if (ret)
2216 return migrate_vma_collect_skip(start, end,
2217 walk);
2218 if (pmd_none(*pmdp))
2219 return migrate_vma_collect_hole(start, end,
2220 walk);
2221 }
2222 }
2223
2224 if (unlikely(pmd_bad(*pmdp)))
2225 return migrate_vma_collect_skip(start, end, walk);
2226
2227 ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl);
2228 arch_enter_lazy_mmu_mode();
2229
2230 for (; addr < end; addr += PAGE_SIZE, ptep++) {
2231 unsigned long mpfn, pfn;
2232 struct page *page;
2233 swp_entry_t entry;
2234 pte_t pte;
2235
2236 pte = *ptep;
2237 pfn = pte_pfn(pte);
2238
2239 if (pte_none(pte)) {
2240 mpfn = MIGRATE_PFN_MIGRATE;
2241 migrate->cpages++;
2242 pfn = 0;
2243 goto next;
2244 }
2245
2246 if (!pte_present(pte)) {
2247 mpfn = pfn = 0;
2248
2249 /*
2250 * Only care about unaddressable device page special
2251 * page table entry. Other special swap entries are not
2252 * migratable, and we ignore regular swapped page.
2253 */
2254 entry = pte_to_swp_entry(pte);
2255 if (!is_device_private_entry(entry))
2256 goto next;
2257
2258 page = device_private_entry_to_page(entry);
2259 mpfn = migrate_pfn(page_to_pfn(page))|
2260 MIGRATE_PFN_DEVICE | MIGRATE_PFN_MIGRATE;
2261 if (is_write_device_private_entry(entry))
2262 mpfn |= MIGRATE_PFN_WRITE;
2263 } else {
2264 if (is_zero_pfn(pfn)) {
2265 mpfn = MIGRATE_PFN_MIGRATE;
2266 migrate->cpages++;
2267 pfn = 0;
2268 goto next;
2269 }
2270 page = _vm_normal_page(migrate->vma, addr, pte, true);
2271 mpfn = migrate_pfn(pfn) | MIGRATE_PFN_MIGRATE;
2272 mpfn |= pte_write(pte) ? MIGRATE_PFN_WRITE : 0;
2273 }
2274
2275 /* FIXME support THP */
2276 if (!page || !page->mapping || PageTransCompound(page)) {
2277 mpfn = pfn = 0;
2278 goto next;
2279 }
2280 pfn = page_to_pfn(page);
2281
2282 /*
2283 * By getting a reference on the page we pin it and that blocks
2284 * any kind of migration. Side effect is that it "freezes" the
2285 * pte.
2286 *
2287 * We drop this reference after isolating the page from the lru
2288 * for non device page (device page are not on the lru and thus
2289 * can't be dropped from it).
2290 */
2291 get_page(page);
2292 migrate->cpages++;
2293
2294 /*
2295 * Optimize for the common case where page is only mapped once
2296 * in one process. If we can lock the page, then we can safely
2297 * set up a special migration page table entry now.
2298 */
2299 if (trylock_page(page)) {
2300 pte_t swp_pte;
2301
2302 mpfn |= MIGRATE_PFN_LOCKED;
2303 ptep_get_and_clear(mm, addr, ptep);
2304
2305 /* Setup special migration page table entry */
2306 entry = make_migration_entry(page, pte_write(pte));
2307 swp_pte = swp_entry_to_pte(entry);
2308 if (pte_soft_dirty(pte))
2309 swp_pte = pte_swp_mksoft_dirty(swp_pte);
2310 set_pte_at(mm, addr, ptep, swp_pte);
2311
2312 /*
2313 * This is like regular unmap: we remove the rmap and
2314 * drop page refcount. Page won't be freed, as we took
2315 * a reference just above.
2316 */
2317 page_remove_rmap(page, false);
2318 put_page(page);
2319
2320 if (pte_present(pte))
2321 unmapped++;
2322 }
2323
2324next:
2325 migrate->dst[migrate->npages] = 0;
2326 migrate->src[migrate->npages++] = mpfn;
2327 }
2328 arch_leave_lazy_mmu_mode();
2329 pte_unmap_unlock(ptep - 1, ptl);
2330
2331 /* Only flush the TLB if we actually modified any entries */
2332 if (unmapped)
2333 flush_tlb_range(walk->vma, start, end);
2334
2335 return 0;
2336}
2337
2338/*
2339 * migrate_vma_collect() - collect pages over a range of virtual addresses
2340 * @migrate: migrate struct containing all migration information
2341 *
2342 * This will walk the CPU page table. For each virtual address backed by a
2343 * valid page, it updates the src array and takes a reference on the page, in
2344 * order to pin the page until we lock it and unmap it.
2345 */
2346static void migrate_vma_collect(struct migrate_vma *migrate)
2347{
2348 struct mm_walk mm_walk;
2349
2350 mm_walk.pmd_entry = migrate_vma_collect_pmd;
2351 mm_walk.pte_entry = NULL;
2352 mm_walk.pte_hole = migrate_vma_collect_hole;
2353 mm_walk.hugetlb_entry = NULL;
2354 mm_walk.test_walk = NULL;
2355 mm_walk.vma = migrate->vma;
2356 mm_walk.mm = migrate->vma->vm_mm;
2357 mm_walk.private = migrate;
2358
2359 mmu_notifier_invalidate_range_start(mm_walk.mm,
2360 migrate->start,
2361 migrate->end);
2362 walk_page_range(migrate->start, migrate->end, &mm_walk);
2363 mmu_notifier_invalidate_range_end(mm_walk.mm,
2364 migrate->start,
2365 migrate->end);
2366
2367 migrate->end = migrate->start + (migrate->npages << PAGE_SHIFT);
2368}
2369
2370/*
2371 * migrate_vma_check_page() - check if page is pinned or not
2372 * @page: struct page to check
2373 *
2374 * Pinned pages cannot be migrated. This is the same test as in
2375 * migrate_page_move_mapping(), except that here we allow migration of a
2376 * ZONE_DEVICE page.
2377 */
2378static bool migrate_vma_check_page(struct page *page)
2379{
2380 /*
2381 * One extra ref because caller holds an extra reference, either from
2382 * isolate_lru_page() for a regular page, or migrate_vma_collect() for
2383 * a device page.
2384 */
2385 int extra = 1;
2386
2387 /*
2388 * FIXME support THP (transparent huge page), it is bit more complex to
2389 * check them than regular pages, because they can be mapped with a pmd
2390 * or with a pte (split pte mapping).
2391 */
2392 if (PageCompound(page))
2393 return false;
2394
2395 /* Page from ZONE_DEVICE have one extra reference */
2396 if (is_zone_device_page(page)) {
2397 /*
2398 * Private page can never be pin as they have no valid pte and
2399 * GUP will fail for those. Yet if there is a pending migration
2400 * a thread might try to wait on the pte migration entry and
2401 * will bump the page reference count. Sadly there is no way to
2402 * differentiate a regular pin from migration wait. Hence to
2403 * avoid 2 racing thread trying to migrate back to CPU to enter
2404 * infinite loop (one stoping migration because the other is
2405 * waiting on pte migration entry). We always return true here.
2406 *
2407 * FIXME proper solution is to rework migration_entry_wait() so
2408 * it does not need to take a reference on page.
2409 */
2410 if (is_device_private_page(page))
2411 return true;
2412
2413 /*
2414 * Only allow device public page to be migrated and account for
2415 * the extra reference count imply by ZONE_DEVICE pages.
2416 */
2417 if (!is_device_public_page(page))
2418 return false;
2419 extra++;
2420 }
2421
2422 /* For file back page */
2423 if (page_mapping(page))
2424 extra += 1 + page_has_private(page);
2425
2426 if ((page_count(page) - extra) > page_mapcount(page))
2427 return false;
2428
2429 return true;
2430}
2431
2432/*
2433 * migrate_vma_prepare() - lock pages and isolate them from the lru
2434 * @migrate: migrate struct containing all migration information
2435 *
2436 * This locks pages that have been collected by migrate_vma_collect(). Once each
2437 * page is locked it is isolated from the lru (for non-device pages). Finally,
2438 * the ref taken by migrate_vma_collect() is dropped, as locked pages cannot be
2439 * migrated by concurrent kernel threads.
2440 */
2441static void migrate_vma_prepare(struct migrate_vma *migrate)
2442{
2443 const unsigned long npages = migrate->npages;
2444 const unsigned long start = migrate->start;
2445 unsigned long addr, i, restore = 0;
2446 bool allow_drain = true;
2447
2448 lru_add_drain();
2449
2450 for (i = 0; (i < npages) && migrate->cpages; i++) {
2451 struct page *page = migrate_pfn_to_page(migrate->src[i]);
2452 bool remap = true;
2453
2454 if (!page)
2455 continue;
2456
2457 if (!(migrate->src[i] & MIGRATE_PFN_LOCKED)) {
2458 /*
2459 * Because we are migrating several pages there can be
2460 * a deadlock between 2 concurrent migration where each
2461 * are waiting on each other page lock.
2462 *
2463 * Make migrate_vma() a best effort thing and backoff
2464 * for any page we can not lock right away.
2465 */
2466 if (!trylock_page(page)) {
2467 migrate->src[i] = 0;
2468 migrate->cpages--;
2469 put_page(page);
2470 continue;
2471 }
2472 remap = false;
2473 migrate->src[i] |= MIGRATE_PFN_LOCKED;
2474 }
2475
2476 /* ZONE_DEVICE pages are not on LRU */
2477 if (!is_zone_device_page(page)) {
2478 if (!PageLRU(page) && allow_drain) {
2479 /* Drain CPU's pagevec */
2480 lru_add_drain_all();
2481 allow_drain = false;
2482 }
2483
2484 if (isolate_lru_page(page)) {
2485 if (remap) {
2486 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2487 migrate->cpages--;
2488 restore++;
2489 } else {
2490 migrate->src[i] = 0;
2491 unlock_page(page);
2492 migrate->cpages--;
2493 put_page(page);
2494 }
2495 continue;
2496 }
2497
2498 /* Drop the reference we took in collect */
2499 put_page(page);
2500 }
2501
2502 if (!migrate_vma_check_page(page)) {
2503 if (remap) {
2504 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2505 migrate->cpages--;
2506 restore++;
2507
2508 if (!is_zone_device_page(page)) {
2509 get_page(page);
2510 putback_lru_page(page);
2511 }
2512 } else {
2513 migrate->src[i] = 0;
2514 unlock_page(page);
2515 migrate->cpages--;
2516
2517 if (!is_zone_device_page(page))
2518 putback_lru_page(page);
2519 else
2520 put_page(page);
2521 }
2522 }
2523 }
2524
2525 for (i = 0, addr = start; i < npages && restore; i++, addr += PAGE_SIZE) {
2526 struct page *page = migrate_pfn_to_page(migrate->src[i]);
2527
2528 if (!page || (migrate->src[i] & MIGRATE_PFN_MIGRATE))
2529 continue;
2530
2531 remove_migration_pte(page, migrate->vma, addr, page);
2532
2533 migrate->src[i] = 0;
2534 unlock_page(page);
2535 put_page(page);
2536 restore--;
2537 }
2538}
2539
2540/*
2541 * migrate_vma_unmap() - replace page mapping with special migration pte entry
2542 * @migrate: migrate struct containing all migration information
2543 *
2544 * Replace page mapping (CPU page table pte) with a special migration pte entry
2545 * and check again if it has been pinned. Pinned pages are restored because we
2546 * cannot migrate them.
2547 *
2548 * This is the last step before we call the device driver callback to allocate
2549 * destination memory and copy contents of original page over to new page.
2550 */
2551static void migrate_vma_unmap(struct migrate_vma *migrate)
2552{
2553 int flags = TTU_MIGRATION | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
2554 const unsigned long npages = migrate->npages;
2555 const unsigned long start = migrate->start;
2556 unsigned long addr, i, restore = 0;
2557
2558 for (i = 0; i < npages; i++) {
2559 struct page *page = migrate_pfn_to_page(migrate->src[i]);
2560
2561 if (!page || !(migrate->src[i] & MIGRATE_PFN_MIGRATE))
2562 continue;
2563
2564 if (page_mapped(page)) {
2565 try_to_unmap(page, flags);
2566 if (page_mapped(page))
2567 goto restore;
2568 }
2569
2570 if (migrate_vma_check_page(page))
2571 continue;
2572
2573restore:
2574 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2575 migrate->cpages--;
2576 restore++;
2577 }
2578
2579 for (addr = start, i = 0; i < npages && restore; addr += PAGE_SIZE, i++) {
2580 struct page *page = migrate_pfn_to_page(migrate->src[i]);
2581
2582 if (!page || (migrate->src[i] & MIGRATE_PFN_MIGRATE))
2583 continue;
2584
2585 remove_migration_ptes(page, page, false);
2586
2587 migrate->src[i] = 0;
2588 unlock_page(page);
2589 restore--;
2590
2591 if (is_zone_device_page(page))
2592 put_page(page);
2593 else
2594 putback_lru_page(page);
2595 }
2596}
2597
2598static void migrate_vma_insert_page(struct migrate_vma *migrate,
2599 unsigned long addr,
2600 struct page *page,
2601 unsigned long *src,
2602 unsigned long *dst)
2603{
2604 struct vm_area_struct *vma = migrate->vma;
2605 struct mm_struct *mm = vma->vm_mm;
2606 struct mem_cgroup *memcg;
2607 bool flush = false;
2608 spinlock_t *ptl;
2609 pte_t entry;
2610 pgd_t *pgdp;
2611 p4d_t *p4dp;
2612 pud_t *pudp;
2613 pmd_t *pmdp;
2614 pte_t *ptep;
2615
2616 /* Only allow populating anonymous memory */
2617 if (!vma_is_anonymous(vma))
2618 goto abort;
2619
2620 pgdp = pgd_offset(mm, addr);
2621 p4dp = p4d_alloc(mm, pgdp, addr);
2622 if (!p4dp)
2623 goto abort;
2624 pudp = pud_alloc(mm, p4dp, addr);
2625 if (!pudp)
2626 goto abort;
2627 pmdp = pmd_alloc(mm, pudp, addr);
2628 if (!pmdp)
2629 goto abort;
2630
2631 if (pmd_trans_huge(*pmdp) || pmd_devmap(*pmdp))
2632 goto abort;
2633
2634 /*
2635 * Use pte_alloc() instead of pte_alloc_map(). We can't run
2636 * pte_offset_map() on pmds where a huge pmd might be created
2637 * from a different thread.
2638 *
2639 * pte_alloc_map() is safe to use under down_write(mmap_sem) or when
2640 * parallel threads are excluded by other means.
2641 *
2642 * Here we only have down_read(mmap_sem).
2643 */
2644 if (pte_alloc(mm, pmdp, addr))
2645 goto abort;
2646
2647 /* See the comment in pte_alloc_one_map() */
2648 if (unlikely(pmd_trans_unstable(pmdp)))
2649 goto abort;
2650
2651 if (unlikely(anon_vma_prepare(vma)))
2652 goto abort;
2653 if (mem_cgroup_try_charge(page, vma->vm_mm, GFP_KERNEL, &memcg, false))
2654 goto abort;
2655
2656 /*
2657 * The memory barrier inside __SetPageUptodate makes sure that
2658 * preceding stores to the page contents become visible before
2659 * the set_pte_at() write.
2660 */
2661 __SetPageUptodate(page);
2662
2663 if (is_zone_device_page(page)) {
2664 if (is_device_private_page(page)) {
2665 swp_entry_t swp_entry;
2666
2667 swp_entry = make_device_private_entry(page, vma->vm_flags & VM_WRITE);
2668 entry = swp_entry_to_pte(swp_entry);
2669 } else if (is_device_public_page(page)) {
2670 entry = pte_mkold(mk_pte(page, READ_ONCE(vma->vm_page_prot)));
2671 if (vma->vm_flags & VM_WRITE)
2672 entry = pte_mkwrite(pte_mkdirty(entry));
2673 entry = pte_mkdevmap(entry);
2674 }
2675 } else {
2676 entry = mk_pte(page, vma->vm_page_prot);
2677 if (vma->vm_flags & VM_WRITE)
2678 entry = pte_mkwrite(pte_mkdirty(entry));
2679 }
2680
2681 ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl);
2682
2683 if (pte_present(*ptep)) {
2684 unsigned long pfn = pte_pfn(*ptep);
2685
2686 if (!is_zero_pfn(pfn)) {
2687 pte_unmap_unlock(ptep, ptl);
2688 mem_cgroup_cancel_charge(page, memcg, false);
2689 goto abort;
2690 }
2691 flush = true;
2692 } else if (!pte_none(*ptep)) {
2693 pte_unmap_unlock(ptep, ptl);
2694 mem_cgroup_cancel_charge(page, memcg, false);
2695 goto abort;
2696 }
2697
2698 /*
2699 * Check for usefaultfd but do not deliver the fault. Instead,
2700 * just back off.
2701 */
2702 if (userfaultfd_missing(vma)) {
2703 pte_unmap_unlock(ptep, ptl);
2704 mem_cgroup_cancel_charge(page, memcg, false);
2705 goto abort;
2706 }
2707
2708 inc_mm_counter(mm, MM_ANONPAGES);
2709 page_add_new_anon_rmap(page, vma, addr, false);
2710 mem_cgroup_commit_charge(page, memcg, false, false);
2711 if (!is_zone_device_page(page))
2712 lru_cache_add_active_or_unevictable(page, vma);
2713 get_page(page);
2714
2715 if (flush) {
2716 flush_cache_page(vma, addr, pte_pfn(*ptep));
2717 ptep_clear_flush_notify(vma, addr, ptep);
2718 set_pte_at_notify(mm, addr, ptep, entry);
2719 update_mmu_cache(vma, addr, ptep);
2720 } else {
2721 /* No need to invalidate - it was non-present before */
2722 set_pte_at(mm, addr, ptep, entry);
2723 update_mmu_cache(vma, addr, ptep);
2724 }
2725
2726 pte_unmap_unlock(ptep, ptl);
2727 *src = MIGRATE_PFN_MIGRATE;
2728 return;
2729
2730abort:
2731 *src &= ~MIGRATE_PFN_MIGRATE;
2732}
2733
2734/*
2735 * migrate_vma_pages() - migrate meta-data from src page to dst page
2736 * @migrate: migrate struct containing all migration information
2737 *
2738 * This migrates struct page meta-data from source struct page to destination
2739 * struct page. This effectively finishes the migration from source page to the
2740 * destination page.
2741 */
2742static void migrate_vma_pages(struct migrate_vma *migrate)
2743{
2744 const unsigned long npages = migrate->npages;
2745 const unsigned long start = migrate->start;
2746 struct vm_area_struct *vma = migrate->vma;
2747 struct mm_struct *mm = vma->vm_mm;
2748 unsigned long addr, i, mmu_start;
2749 bool notified = false;
2750
2751 for (i = 0, addr = start; i < npages; addr += PAGE_SIZE, i++) {
2752 struct page *newpage = migrate_pfn_to_page(migrate->dst[i]);
2753 struct page *page = migrate_pfn_to_page(migrate->src[i]);
2754 struct address_space *mapping;
2755 int r;
2756
2757 if (!newpage) {
2758 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2759 continue;
2760 }
2761
2762 if (!page) {
2763 if (!(migrate->src[i] & MIGRATE_PFN_MIGRATE)) {
2764 continue;
2765 }
2766 if (!notified) {
2767 mmu_start = addr;
2768 notified = true;
2769 mmu_notifier_invalidate_range_start(mm,
2770 mmu_start,
2771 migrate->end);
2772 }
2773 migrate_vma_insert_page(migrate, addr, newpage,
2774 &migrate->src[i],
2775 &migrate->dst[i]);
2776 continue;
2777 }
2778
2779 mapping = page_mapping(page);
2780
2781 if (is_zone_device_page(newpage)) {
2782 if (is_device_private_page(newpage)) {
2783 /*
2784 * For now only support private anonymous when
2785 * migrating to un-addressable device memory.
2786 */
2787 if (mapping) {
2788 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2789 continue;
2790 }
2791 } else if (!is_device_public_page(newpage)) {
2792 /*
2793 * Other types of ZONE_DEVICE page are not
2794 * supported.
2795 */
2796 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2797 continue;
2798 }
2799 }
2800
2801 r = migrate_page(mapping, newpage, page, MIGRATE_SYNC_NO_COPY);
2802 if (r != MIGRATEPAGE_SUCCESS)
2803 migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
2804 }
2805
2806 if (notified)
2807 mmu_notifier_invalidate_range_end(mm, mmu_start,
2808 migrate->end);
2809}
2810
2811/*
2812 * migrate_vma_finalize() - restore CPU page table entry
2813 * @migrate: migrate struct containing all migration information
2814 *
2815 * This replaces the special migration pte entry with either a mapping to the
2816 * new page if migration was successful for that page, or to the original page
2817 * otherwise.
2818 *
2819 * This also unlocks the pages and puts them back on the lru, or drops the extra
2820 * refcount, for device pages.
2821 */
2822static void migrate_vma_finalize(struct migrate_vma *migrate)
2823{
2824 const unsigned long npages = migrate->npages;
2825 unsigned long i;
2826
2827 for (i = 0; i < npages; i++) {
2828 struct page *newpage = migrate_pfn_to_page(migrate->dst[i]);
2829 struct page *page = migrate_pfn_to_page(migrate->src[i]);
2830
2831 if (!page) {
2832 if (newpage) {
2833 unlock_page(newpage);
2834 put_page(newpage);
2835 }
2836 continue;
2837 }
2838
2839 if (!(migrate->src[i] & MIGRATE_PFN_MIGRATE) || !newpage) {
2840 if (newpage) {
2841 unlock_page(newpage);
2842 put_page(newpage);
2843 }
2844 newpage = page;
2845 }
2846
2847 remove_migration_ptes(page, newpage, false);
2848 unlock_page(page);
2849 migrate->cpages--;
2850
2851 if (is_zone_device_page(page))
2852 put_page(page);
2853 else
2854 putback_lru_page(page);
2855
2856 if (newpage != page) {
2857 unlock_page(newpage);
2858 if (is_zone_device_page(newpage))
2859 put_page(newpage);
2860 else
2861 putback_lru_page(newpage);
2862 }
2863 }
2864}
2865
2866/*
2867 * migrate_vma() - migrate a range of memory inside vma
2868 *
2869 * @ops: migration callback for allocating destination memory and copying
2870 * @vma: virtual memory area containing the range to be migrated
2871 * @start: start address of the range to migrate (inclusive)
2872 * @end: end address of the range to migrate (exclusive)
2873 * @src: array of hmm_pfn_t containing source pfns
2874 * @dst: array of hmm_pfn_t containing destination pfns
2875 * @private: pointer passed back to each of the callback
2876 * Returns: 0 on success, error code otherwise
2877 *
2878 * This function tries to migrate a range of memory virtual address range, using
2879 * callbacks to allocate and copy memory from source to destination. First it
2880 * collects all the pages backing each virtual address in the range, saving this
2881 * inside the src array. Then it locks those pages and unmaps them. Once the pages
2882 * are locked and unmapped, it checks whether each page is pinned or not. Pages
2883 * that aren't pinned have the MIGRATE_PFN_MIGRATE flag set (by this function)
2884 * in the corresponding src array entry. It then restores any pages that are
2885 * pinned, by remapping and unlocking those pages.
2886 *
2887 * At this point it calls the alloc_and_copy() callback. For documentation on
2888 * what is expected from that callback, see struct migrate_vma_ops comments in
2889 * include/linux/migrate.h
2890 *
2891 * After the alloc_and_copy() callback, this function goes over each entry in
2892 * the src array that has the MIGRATE_PFN_VALID and MIGRATE_PFN_MIGRATE flag
2893 * set. If the corresponding entry in dst array has MIGRATE_PFN_VALID flag set,
2894 * then the function tries to migrate struct page information from the source
2895 * struct page to the destination struct page. If it fails to migrate the struct
2896 * page information, then it clears the MIGRATE_PFN_MIGRATE flag in the src
2897 * array.
2898 *
2899 * At this point all successfully migrated pages have an entry in the src
2900 * array with MIGRATE_PFN_VALID and MIGRATE_PFN_MIGRATE flag set and the dst
2901 * array entry with MIGRATE_PFN_VALID flag set.
2902 *
2903 * It then calls the finalize_and_map() callback. See comments for "struct
2904 * migrate_vma_ops", in include/linux/migrate.h for details about
2905 * finalize_and_map() behavior.
2906 *
2907 * After the finalize_and_map() callback, for successfully migrated pages, this
2908 * function updates the CPU page table to point to new pages, otherwise it
2909 * restores the CPU page table to point to the original source pages.
2910 *
2911 * Function returns 0 after the above steps, even if no pages were migrated
2912 * (The function only returns an error if any of the arguments are invalid.)
2913 *
2914 * Both src and dst array must be big enough for (end - start) >> PAGE_SHIFT
2915 * unsigned long entries.
2916 */
2917int migrate_vma(const struct migrate_vma_ops *ops,
2918 struct vm_area_struct *vma,
2919 unsigned long start,
2920 unsigned long end,
2921 unsigned long *src,
2922 unsigned long *dst,
2923 void *private)
2924{
2925 struct migrate_vma migrate;
2926
2927 /* Sanity check the arguments */
2928 start &= PAGE_MASK;
2929 end &= PAGE_MASK;
2930 if (!vma || is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL))
2931 return -EINVAL;
2932 if (start < vma->vm_start || start >= vma->vm_end)
2933 return -EINVAL;
2934 if (end <= vma->vm_start || end > vma->vm_end)
2935 return -EINVAL;
2936 if (!ops || !src || !dst || start >= end)
2937 return -EINVAL;
2938
2939 memset(src, 0, sizeof(*src) * ((end - start) >> PAGE_SHIFT));
2940 migrate.src = src;
2941 migrate.dst = dst;
2942 migrate.start = start;
2943 migrate.npages = 0;
2944 migrate.cpages = 0;
2945 migrate.end = end;
2946 migrate.vma = vma;
2947
2948 /* Collect, and try to unmap source pages */
2949 migrate_vma_collect(&migrate);
2950 if (!migrate.cpages)
2951 return 0;
2952
2953 /* Lock and isolate page */
2954 migrate_vma_prepare(&migrate);
2955 if (!migrate.cpages)
2956 return 0;
2957
2958 /* Unmap pages */
2959 migrate_vma_unmap(&migrate);
2960 if (!migrate.cpages)
2961 return 0;
2962
2963 /*
2964 * At this point pages are locked and unmapped, and thus they have
2965 * stable content and can safely be copied to destination memory that
2966 * is allocated by the callback.
2967 *
2968 * Note that migration can fail in migrate_vma_struct_page() for each
2969 * individual page.
2970 */
2971 ops->alloc_and_copy(vma, src, dst, start, end, private);
2972
2973 /* This does the real migration of struct page */
2974 migrate_vma_pages(&migrate);
2975
2976 ops->finalize_and_map(vma, src, dst, start, end, private);
2977
2978 /* Unlock and remap pages */
2979 migrate_vma_finalize(&migrate);
2980
2981 return 0;
2982}
2983EXPORT_SYMBOL(migrate_vma);
2984#endif /* defined(MIGRATE_VMA_HELPER) */
diff --git a/mm/mlock.c b/mm/mlock.c
index b562b5523a65..dfc6f1912176 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -365,8 +365,8 @@ static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone)
365 * @start + PAGE_SIZE when no page could be added by the pte walk. 365 * @start + PAGE_SIZE when no page could be added by the pte walk.
366 */ 366 */
367static unsigned long __munlock_pagevec_fill(struct pagevec *pvec, 367static unsigned long __munlock_pagevec_fill(struct pagevec *pvec,
368 struct vm_area_struct *vma, int zoneid, unsigned long start, 368 struct vm_area_struct *vma, struct zone *zone,
369 unsigned long end) 369 unsigned long start, unsigned long end)
370{ 370{
371 pte_t *pte; 371 pte_t *pte;
372 spinlock_t *ptl; 372 spinlock_t *ptl;
@@ -394,7 +394,7 @@ static unsigned long __munlock_pagevec_fill(struct pagevec *pvec,
394 * Break if page could not be obtained or the page's node+zone does not 394 * Break if page could not be obtained or the page's node+zone does not
395 * match 395 * match
396 */ 396 */
397 if (!page || page_zone_id(page) != zoneid) 397 if (!page || page_zone(page) != zone)
398 break; 398 break;
399 399
400 /* 400 /*
@@ -446,7 +446,6 @@ void munlock_vma_pages_range(struct vm_area_struct *vma,
446 unsigned long page_increm; 446 unsigned long page_increm;
447 struct pagevec pvec; 447 struct pagevec pvec;
448 struct zone *zone; 448 struct zone *zone;
449 int zoneid;
450 449
451 pagevec_init(&pvec, 0); 450 pagevec_init(&pvec, 0);
452 /* 451 /*
@@ -481,7 +480,6 @@ void munlock_vma_pages_range(struct vm_area_struct *vma,
481 */ 480 */
482 pagevec_add(&pvec, page); 481 pagevec_add(&pvec, page);
483 zone = page_zone(page); 482 zone = page_zone(page);
484 zoneid = page_zone_id(page);
485 483
486 /* 484 /*
487 * Try to fill the rest of pagevec using fast 485 * Try to fill the rest of pagevec using fast
@@ -490,7 +488,7 @@ void munlock_vma_pages_range(struct vm_area_struct *vma,
490 * pagevec. 488 * pagevec.
491 */ 489 */
492 start = __munlock_pagevec_fill(&pvec, vma, 490 start = __munlock_pagevec_fill(&pvec, vma,
493 zoneid, start, end); 491 zone, start, end);
494 __munlock_pagevec(&pvec, zone); 492 __munlock_pagevec(&pvec, zone);
495 goto next; 493 goto next;
496 } 494 }
diff --git a/mm/mmap.c b/mm/mmap.c
index 4c5981651407..680506faceae 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -685,7 +685,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
685 struct mm_struct *mm = vma->vm_mm; 685 struct mm_struct *mm = vma->vm_mm;
686 struct vm_area_struct *next = vma->vm_next, *orig_vma = vma; 686 struct vm_area_struct *next = vma->vm_next, *orig_vma = vma;
687 struct address_space *mapping = NULL; 687 struct address_space *mapping = NULL;
688 struct rb_root *root = NULL; 688 struct rb_root_cached *root = NULL;
689 struct anon_vma *anon_vma = NULL; 689 struct anon_vma *anon_vma = NULL;
690 struct file *file = vma->vm_file; 690 struct file *file = vma->vm_file;
691 bool start_changed = false, end_changed = false; 691 bool start_changed = false, end_changed = false;
@@ -3340,7 +3340,7 @@ static DEFINE_MUTEX(mm_all_locks_mutex);
3340 3340
3341static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma) 3341static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma)
3342{ 3342{
3343 if (!test_bit(0, (unsigned long *) &anon_vma->root->rb_root.rb_node)) { 3343 if (!test_bit(0, (unsigned long *) &anon_vma->root->rb_root.rb_root.rb_node)) {
3344 /* 3344 /*
3345 * The LSB of head.next can't change from under us 3345 * The LSB of head.next can't change from under us
3346 * because we hold the mm_all_locks_mutex. 3346 * because we hold the mm_all_locks_mutex.
@@ -3356,7 +3356,7 @@ static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma)
3356 * anon_vma->root->rwsem. 3356 * anon_vma->root->rwsem.
3357 */ 3357 */
3358 if (__test_and_set_bit(0, (unsigned long *) 3358 if (__test_and_set_bit(0, (unsigned long *)
3359 &anon_vma->root->rb_root.rb_node)) 3359 &anon_vma->root->rb_root.rb_root.rb_node))
3360 BUG(); 3360 BUG();
3361 } 3361 }
3362} 3362}
@@ -3458,7 +3458,7 @@ out_unlock:
3458 3458
3459static void vm_unlock_anon_vma(struct anon_vma *anon_vma) 3459static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
3460{ 3460{
3461 if (test_bit(0, (unsigned long *) &anon_vma->root->rb_root.rb_node)) { 3461 if (test_bit(0, (unsigned long *) &anon_vma->root->rb_root.rb_root.rb_node)) {
3462 /* 3462 /*
3463 * The LSB of head.next can't change to 0 from under 3463 * The LSB of head.next can't change to 0 from under
3464 * us because we hold the mm_all_locks_mutex. 3464 * us because we hold the mm_all_locks_mutex.
@@ -3472,7 +3472,7 @@ static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
3472 * anon_vma->root->rwsem. 3472 * anon_vma->root->rwsem.
3473 */ 3473 */
3474 if (!__test_and_clear_bit(0, (unsigned long *) 3474 if (!__test_and_clear_bit(0, (unsigned long *)
3475 &anon_vma->root->rb_root.rb_node)) 3475 &anon_vma->root->rb_root.rb_root.rb_node))
3476 BUG(); 3476 BUG();
3477 anon_vma_unlock_write(anon_vma); 3477 anon_vma_unlock_write(anon_vma);
3478 } 3478 }
diff --git a/mm/mprotect.c b/mm/mprotect.c
index bd0f409922cb..6d3e2f082290 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -125,6 +125,20 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
125 125
126 pages++; 126 pages++;
127 } 127 }
128
129 if (is_write_device_private_entry(entry)) {
130 pte_t newpte;
131
132 /*
133 * We do not preserve soft-dirtiness. See
134 * copy_one_pte() for explanation.
135 */
136 make_device_private_entry_read(&entry);
137 newpte = swp_entry_to_pte(entry);
138 set_pte_at(mm, addr, pte, newpte);
139
140 pages++;
141 }
128 } 142 }
129 } while (pte++, addr += PAGE_SIZE, addr != end); 143 } while (pte++, addr += PAGE_SIZE, addr != end);
130 arch_leave_lazy_mmu_mode(); 144 arch_leave_lazy_mmu_mode();
@@ -149,7 +163,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,
149 unsigned long this_pages; 163 unsigned long this_pages;
150 164
151 next = pmd_addr_end(addr, end); 165 next = pmd_addr_end(addr, end);
152 if (!pmd_trans_huge(*pmd) && !pmd_devmap(*pmd) 166 if (!is_swap_pmd(*pmd) && !pmd_trans_huge(*pmd) && !pmd_devmap(*pmd)
153 && pmd_none_or_clear_bad(pmd)) 167 && pmd_none_or_clear_bad(pmd))
154 continue; 168 continue;
155 169
@@ -159,7 +173,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,
159 mmu_notifier_invalidate_range_start(mm, mni_start, end); 173 mmu_notifier_invalidate_range_start(mm, mni_start, end);
160 } 174 }
161 175
162 if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { 176 if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
163 if (next - addr != HPAGE_PMD_SIZE) { 177 if (next - addr != HPAGE_PMD_SIZE) {
164 __split_huge_pmd(vma, pmd, addr, false, NULL); 178 __split_huge_pmd(vma, pmd, addr, false, NULL);
165 } else { 179 } else {
diff --git a/mm/mremap.c b/mm/mremap.c
index 7395564daa6c..cfec004c4ff9 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -223,7 +223,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
223 new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr); 223 new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr);
224 if (!new_pmd) 224 if (!new_pmd)
225 break; 225 break;
226 if (pmd_trans_huge(*old_pmd)) { 226 if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) {
227 if (extent == HPAGE_PMD_SIZE) { 227 if (extent == HPAGE_PMD_SIZE) {
228 bool moved; 228 bool moved;
229 /* See comment in move_ptes() */ 229 /* See comment in move_ptes() */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a9add06fe768..c841af88836a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2741,18 +2741,18 @@ int __isolate_free_page(struct page *page, unsigned int order)
2741static inline void zone_statistics(struct zone *preferred_zone, struct zone *z) 2741static inline void zone_statistics(struct zone *preferred_zone, struct zone *z)
2742{ 2742{
2743#ifdef CONFIG_NUMA 2743#ifdef CONFIG_NUMA
2744 enum zone_stat_item local_stat = NUMA_LOCAL; 2744 enum numa_stat_item local_stat = NUMA_LOCAL;
2745 2745
2746 if (z->node != numa_node_id()) 2746 if (z->node != numa_node_id())
2747 local_stat = NUMA_OTHER; 2747 local_stat = NUMA_OTHER;
2748 2748
2749 if (z->node == preferred_zone->node) 2749 if (z->node == preferred_zone->node)
2750 __inc_zone_state(z, NUMA_HIT); 2750 __inc_numa_state(z, NUMA_HIT);
2751 else { 2751 else {
2752 __inc_zone_state(z, NUMA_MISS); 2752 __inc_numa_state(z, NUMA_MISS);
2753 __inc_zone_state(preferred_zone, NUMA_FOREIGN); 2753 __inc_numa_state(preferred_zone, NUMA_FOREIGN);
2754 } 2754 }
2755 __inc_zone_state(z, local_stat); 2755 __inc_numa_state(z, local_stat);
2756#endif 2756#endif
2757} 2757}
2758 2758
@@ -4183,10 +4183,11 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
4183{ 4183{
4184 struct page *page; 4184 struct page *page;
4185 unsigned int alloc_flags = ALLOC_WMARK_LOW; 4185 unsigned int alloc_flags = ALLOC_WMARK_LOW;
4186 gfp_t alloc_mask = gfp_mask; /* The gfp_t that was actually used for allocation */ 4186 gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */
4187 struct alloc_context ac = { }; 4187 struct alloc_context ac = { };
4188 4188
4189 gfp_mask &= gfp_allowed_mask; 4189 gfp_mask &= gfp_allowed_mask;
4190 alloc_mask = gfp_mask;
4190 if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags)) 4191 if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))
4191 return NULL; 4192 return NULL;
4192 4193
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index 8ec6ba230bb9..6a03946469a9 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -48,6 +48,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw)
48 if (!is_swap_pte(*pvmw->pte)) 48 if (!is_swap_pte(*pvmw->pte))
49 return false; 49 return false;
50 entry = pte_to_swp_entry(*pvmw->pte); 50 entry = pte_to_swp_entry(*pvmw->pte);
51
51 if (!is_migration_entry(entry)) 52 if (!is_migration_entry(entry))
52 return false; 53 return false;
53 if (migration_entry_to_page(entry) - pvmw->page >= 54 if (migration_entry_to_page(entry) - pvmw->page >=
@@ -60,6 +61,15 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw)
60 WARN_ON_ONCE(1); 61 WARN_ON_ONCE(1);
61#endif 62#endif
62 } else { 63 } else {
64 if (is_swap_pte(*pvmw->pte)) {
65 swp_entry_t entry;
66
67 entry = pte_to_swp_entry(*pvmw->pte);
68 if (is_device_private_entry(entry) &&
69 device_private_entry_to_page(entry) == pvmw->page)
70 return true;
71 }
72
63 if (!pte_present(*pvmw->pte)) 73 if (!pte_present(*pvmw->pte))
64 return false; 74 return false;
65 75
@@ -138,16 +148,28 @@ restart:
138 if (!pud_present(*pud)) 148 if (!pud_present(*pud))
139 return false; 149 return false;
140 pvmw->pmd = pmd_offset(pud, pvmw->address); 150 pvmw->pmd = pmd_offset(pud, pvmw->address);
141 if (pmd_trans_huge(*pvmw->pmd)) { 151 if (pmd_trans_huge(*pvmw->pmd) || is_pmd_migration_entry(*pvmw->pmd)) {
142 pvmw->ptl = pmd_lock(mm, pvmw->pmd); 152 pvmw->ptl = pmd_lock(mm, pvmw->pmd);
143 if (!pmd_present(*pvmw->pmd))
144 return not_found(pvmw);
145 if (likely(pmd_trans_huge(*pvmw->pmd))) { 153 if (likely(pmd_trans_huge(*pvmw->pmd))) {
146 if (pvmw->flags & PVMW_MIGRATION) 154 if (pvmw->flags & PVMW_MIGRATION)
147 return not_found(pvmw); 155 return not_found(pvmw);
148 if (pmd_page(*pvmw->pmd) != page) 156 if (pmd_page(*pvmw->pmd) != page)
149 return not_found(pvmw); 157 return not_found(pvmw);
150 return true; 158 return true;
159 } else if (!pmd_present(*pvmw->pmd)) {
160 if (thp_migration_supported()) {
161 if (!(pvmw->flags & PVMW_MIGRATION))
162 return not_found(pvmw);
163 if (is_migration_entry(pmd_to_swp_entry(*pvmw->pmd))) {
164 swp_entry_t entry = pmd_to_swp_entry(*pvmw->pmd);
165
166 if (migration_entry_to_page(entry) != page)
167 return not_found(pvmw);
168 return true;
169 }
170 } else
171 WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!");
172 return not_found(pvmw);
151 } else { 173 } else {
152 /* THP pmd was split under us: handle on pte level */ 174 /* THP pmd was split under us: handle on pte level */
153 spin_unlock(pvmw->ptl); 175 spin_unlock(pvmw->ptl);
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index c99d9512a45b..1175f6a24fdb 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -124,7 +124,8 @@ pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address,
124{ 124{
125 pmd_t pmd; 125 pmd_t pmd;
126 VM_BUG_ON(address & ~HPAGE_PMD_MASK); 126 VM_BUG_ON(address & ~HPAGE_PMD_MASK);
127 VM_BUG_ON(!pmd_trans_huge(*pmdp) && !pmd_devmap(*pmdp)); 127 VM_BUG_ON((pmd_present(*pmdp) && !pmd_trans_huge(*pmdp) &&
128 !pmd_devmap(*pmdp)) || !pmd_present(*pmdp));
128 pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp); 129 pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
129 flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); 130 flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
130 return pmd; 131 return pmd;
diff --git a/mm/rmap.c b/mm/rmap.c
index c570f82e6827..b874c4761e84 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -63,6 +63,7 @@
63#include <linux/hugetlb.h> 63#include <linux/hugetlb.h>
64#include <linux/backing-dev.h> 64#include <linux/backing-dev.h>
65#include <linux/page_idle.h> 65#include <linux/page_idle.h>
66#include <linux/memremap.h>
66 67
67#include <asm/tlbflush.h> 68#include <asm/tlbflush.h>
68 69
@@ -390,7 +391,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
390 * Leave empty anon_vmas on the list - we'll need 391 * Leave empty anon_vmas on the list - we'll need
391 * to free them outside the lock. 392 * to free them outside the lock.
392 */ 393 */
393 if (RB_EMPTY_ROOT(&anon_vma->rb_root)) { 394 if (RB_EMPTY_ROOT(&anon_vma->rb_root.rb_root)) {
394 anon_vma->parent->degree--; 395 anon_vma->parent->degree--;
395 continue; 396 continue;
396 } 397 }
@@ -424,7 +425,7 @@ static void anon_vma_ctor(void *data)
424 425
425 init_rwsem(&anon_vma->rwsem); 426 init_rwsem(&anon_vma->rwsem);
426 atomic_set(&anon_vma->refcount, 0); 427 atomic_set(&anon_vma->refcount, 0);
427 anon_vma->rb_root = RB_ROOT; 428 anon_vma->rb_root = RB_ROOT_CACHED;
428} 429}
429 430
430void __init anon_vma_init(void) 431void __init anon_vma_init(void)
@@ -1346,9 +1347,13 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1346 if ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED)) 1347 if ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED))
1347 return true; 1348 return true;
1348 1349
1350 if (IS_ENABLED(CONFIG_MIGRATION) && (flags & TTU_MIGRATION) &&
1351 is_zone_device_page(page) && !is_device_private_page(page))
1352 return true;
1353
1349 if (flags & TTU_SPLIT_HUGE_PMD) { 1354 if (flags & TTU_SPLIT_HUGE_PMD) {
1350 split_huge_pmd_address(vma, address, 1355 split_huge_pmd_address(vma, address,
1351 flags & TTU_MIGRATION, page); 1356 flags & TTU_SPLIT_FREEZE, page);
1352 } 1357 }
1353 1358
1354 /* 1359 /*
@@ -1360,6 +1365,19 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1360 mmu_notifier_invalidate_range_start(vma->vm_mm, start, end); 1365 mmu_notifier_invalidate_range_start(vma->vm_mm, start, end);
1361 1366
1362 while (page_vma_mapped_walk(&pvmw)) { 1367 while (page_vma_mapped_walk(&pvmw)) {
1368#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
1369 /* PMD-mapped THP migration entry */
1370 if (!pvmw.pte && (flags & TTU_MIGRATION)) {
1371 VM_BUG_ON_PAGE(PageHuge(page) || !PageTransCompound(page), page);
1372
1373 if (!PageAnon(page))
1374 continue;
1375
1376 set_pmd_migration_entry(&pvmw, page);
1377 continue;
1378 }
1379#endif
1380
1363 /* 1381 /*
1364 * If the page is mlock()d, we cannot swap it out. 1382 * If the page is mlock()d, we cannot swap it out.
1365 * If it's recently referenced (perhaps page_referenced 1383 * If it's recently referenced (perhaps page_referenced
@@ -1390,6 +1408,27 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1390 address = pvmw.address; 1408 address = pvmw.address;
1391 1409
1392 1410
1411 if (IS_ENABLED(CONFIG_MIGRATION) &&
1412 (flags & TTU_MIGRATION) &&
1413 is_zone_device_page(page)) {
1414 swp_entry_t entry;
1415 pte_t swp_pte;
1416
1417 pteval = ptep_get_and_clear(mm, pvmw.address, pvmw.pte);
1418
1419 /*
1420 * Store the pfn of the page in a special migration
1421 * pte. do_swap_page() will wait until the migration
1422 * pte is removed and then restart fault handling.
1423 */
1424 entry = make_migration_entry(page, 0);
1425 swp_pte = swp_entry_to_pte(entry);
1426 if (pte_soft_dirty(pteval))
1427 swp_pte = pte_swp_mksoft_dirty(swp_pte);
1428 set_pte_at(mm, pvmw.address, pvmw.pte, swp_pte);
1429 goto discard;
1430 }
1431
1393 if (!(flags & TTU_IGNORE_ACCESS)) { 1432 if (!(flags & TTU_IGNORE_ACCESS)) {
1394 if (ptep_clear_flush_young_notify(vma, address, 1433 if (ptep_clear_flush_young_notify(vma, address,
1395 pvmw.pte)) { 1434 pvmw.pte)) {
@@ -1445,7 +1484,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1445 */ 1484 */
1446 dec_mm_counter(mm, mm_counter(page)); 1485 dec_mm_counter(mm, mm_counter(page));
1447 } else if (IS_ENABLED(CONFIG_MIGRATION) && 1486 } else if (IS_ENABLED(CONFIG_MIGRATION) &&
1448 (flags & TTU_MIGRATION)) { 1487 (flags & (TTU_MIGRATION|TTU_SPLIT_FREEZE))) {
1449 swp_entry_t entry; 1488 swp_entry_t entry;
1450 pte_t swp_pte; 1489 pte_t swp_pte;
1451 /* 1490 /*
@@ -1575,7 +1614,8 @@ bool try_to_unmap(struct page *page, enum ttu_flags flags)
1575 * locking requirements of exec(), migration skips 1614 * locking requirements of exec(), migration skips
1576 * temporary VMAs until after exec() completes. 1615 * temporary VMAs until after exec() completes.
1577 */ 1616 */
1578 if ((flags & TTU_MIGRATION) && !PageKsm(page) && PageAnon(page)) 1617 if ((flags & (TTU_MIGRATION|TTU_SPLIT_FREEZE))
1618 && !PageKsm(page) && PageAnon(page))
1579 rwc.invalid_vma = invalid_migration_vma; 1619 rwc.invalid_vma = invalid_migration_vma;
1580 1620
1581 if (flags & TTU_RMAP_LOCKED) 1621 if (flags & TTU_RMAP_LOCKED)
diff --git a/mm/slub.c b/mm/slub.c
index ddb04576b342..d39a5d3834b3 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4232,7 +4232,7 @@ void __init kmem_cache_init(void)
4232 cpuhp_setup_state_nocalls(CPUHP_SLUB_DEAD, "slub:dead", NULL, 4232 cpuhp_setup_state_nocalls(CPUHP_SLUB_DEAD, "slub:dead", NULL,
4233 slub_cpu_dead); 4233 slub_cpu_dead);
4234 4234
4235 pr_info("SLUB: HWalign=%d, Order=%d-%d, MinObjects=%d, CPUs=%d, Nodes=%d\n", 4235 pr_info("SLUB: HWalign=%d, Order=%d-%d, MinObjects=%d, CPUs=%u, Nodes=%d\n",
4236 cache_line_size(), 4236 cache_line_size(),
4237 slub_min_order, slub_max_order, slub_min_objects, 4237 slub_min_order, slub_max_order, slub_min_objects,
4238 nr_cpu_ids, nr_node_ids); 4238 nr_cpu_ids, nr_node_ids);
diff --git a/mm/sparse.c b/mm/sparse.c
index a9783acf2bb9..83b3bf6461af 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -626,7 +626,7 @@ void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn)
626 unsigned long pfn; 626 unsigned long pfn;
627 627
628 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 628 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
629 unsigned long section_nr = pfn_to_section_nr(start_pfn); 629 unsigned long section_nr = pfn_to_section_nr(pfn);
630 struct mem_section *ms; 630 struct mem_section *ms;
631 631
632 /* onlining code should never touch invalid ranges */ 632 /* onlining code should never touch invalid ranges */
diff --git a/mm/swap.c b/mm/swap.c
index 62d96b8e5eb3..9295ae960d66 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -765,6 +765,17 @@ void release_pages(struct page **pages, int nr, bool cold)
765 if (is_huge_zero_page(page)) 765 if (is_huge_zero_page(page))
766 continue; 766 continue;
767 767
768 /* Device public page can not be huge page */
769 if (is_device_public_page(page)) {
770 if (locked_pgdat) {
771 spin_unlock_irqrestore(&locked_pgdat->lru_lock,
772 flags);
773 locked_pgdat = NULL;
774 }
775 put_zone_device_private_or_public_page(page);
776 continue;
777 }
778
768 page = compound_head(page); 779 page = compound_head(page);
769 if (!put_page_testzero(page)) 780 if (!put_page_testzero(page))
770 continue; 781 continue;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d483278ee35b..bf91dc9e7a79 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3290,7 +3290,8 @@ bad_swap:
3290 p->flags = 0; 3290 p->flags = 0;
3291 spin_unlock(&swap_lock); 3291 spin_unlock(&swap_lock);
3292 vfree(swap_map); 3292 vfree(swap_map);
3293 vfree(cluster_info); 3293 kvfree(cluster_info);
3294 kvfree(frontswap_map);
3294 if (swap_file) { 3295 if (swap_file) {
3295 if (inode && S_ISREG(inode->i_mode)) { 3296 if (inode && S_ISREG(inode->i_mode)) {
3296 inode_unlock(inode); 3297 inode_unlock(inode);
diff --git a/mm/vmstat.c b/mm/vmstat.c
index c7e4b8458023..4bb13e72ac97 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -30,6 +30,8 @@
30 30
31#include "internal.h" 31#include "internal.h"
32 32
33#define NUMA_STATS_THRESHOLD (U16_MAX - 2)
34
33#ifdef CONFIG_VM_EVENT_COUNTERS 35#ifdef CONFIG_VM_EVENT_COUNTERS
34DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; 36DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
35EXPORT_PER_CPU_SYMBOL(vm_event_states); 37EXPORT_PER_CPU_SYMBOL(vm_event_states);
@@ -87,8 +89,10 @@ void vm_events_fold_cpu(int cpu)
87 * vm_stat contains the global counters 89 * vm_stat contains the global counters
88 */ 90 */
89atomic_long_t vm_zone_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp; 91atomic_long_t vm_zone_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92atomic_long_t vm_numa_stat[NR_VM_NUMA_STAT_ITEMS] __cacheline_aligned_in_smp;
90atomic_long_t vm_node_stat[NR_VM_NODE_STAT_ITEMS] __cacheline_aligned_in_smp; 93atomic_long_t vm_node_stat[NR_VM_NODE_STAT_ITEMS] __cacheline_aligned_in_smp;
91EXPORT_SYMBOL(vm_zone_stat); 94EXPORT_SYMBOL(vm_zone_stat);
95EXPORT_SYMBOL(vm_numa_stat);
92EXPORT_SYMBOL(vm_node_stat); 96EXPORT_SYMBOL(vm_node_stat);
93 97
94#ifdef CONFIG_SMP 98#ifdef CONFIG_SMP
@@ -604,6 +608,32 @@ EXPORT_SYMBOL(dec_node_page_state);
604 * Fold a differential into the global counters. 608 * Fold a differential into the global counters.
605 * Returns the number of counters updated. 609 * Returns the number of counters updated.
606 */ 610 */
611#ifdef CONFIG_NUMA
612static int fold_diff(int *zone_diff, int *numa_diff, int *node_diff)
613{
614 int i;
615 int changes = 0;
616
617 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
618 if (zone_diff[i]) {
619 atomic_long_add(zone_diff[i], &vm_zone_stat[i]);
620 changes++;
621 }
622
623 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
624 if (numa_diff[i]) {
625 atomic_long_add(numa_diff[i], &vm_numa_stat[i]);
626 changes++;
627 }
628
629 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
630 if (node_diff[i]) {
631 atomic_long_add(node_diff[i], &vm_node_stat[i]);
632 changes++;
633 }
634 return changes;
635}
636#else
607static int fold_diff(int *zone_diff, int *node_diff) 637static int fold_diff(int *zone_diff, int *node_diff)
608{ 638{
609 int i; 639 int i;
@@ -622,6 +652,7 @@ static int fold_diff(int *zone_diff, int *node_diff)
622 } 652 }
623 return changes; 653 return changes;
624} 654}
655#endif /* CONFIG_NUMA */
625 656
626/* 657/*
627 * Update the zone counters for the current cpu. 658 * Update the zone counters for the current cpu.
@@ -645,6 +676,9 @@ static int refresh_cpu_vm_stats(bool do_pagesets)
645 struct zone *zone; 676 struct zone *zone;
646 int i; 677 int i;
647 int global_zone_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, }; 678 int global_zone_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, };
679#ifdef CONFIG_NUMA
680 int global_numa_diff[NR_VM_NUMA_STAT_ITEMS] = { 0, };
681#endif
648 int global_node_diff[NR_VM_NODE_STAT_ITEMS] = { 0, }; 682 int global_node_diff[NR_VM_NODE_STAT_ITEMS] = { 0, };
649 int changes = 0; 683 int changes = 0;
650 684
@@ -666,6 +700,18 @@ static int refresh_cpu_vm_stats(bool do_pagesets)
666 } 700 }
667 } 701 }
668#ifdef CONFIG_NUMA 702#ifdef CONFIG_NUMA
703 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++) {
704 int v;
705
706 v = this_cpu_xchg(p->vm_numa_stat_diff[i], 0);
707 if (v) {
708
709 atomic_long_add(v, &zone->vm_numa_stat[i]);
710 global_numa_diff[i] += v;
711 __this_cpu_write(p->expire, 3);
712 }
713 }
714
669 if (do_pagesets) { 715 if (do_pagesets) {
670 cond_resched(); 716 cond_resched();
671 /* 717 /*
@@ -712,7 +758,12 @@ static int refresh_cpu_vm_stats(bool do_pagesets)
712 } 758 }
713 } 759 }
714 760
761#ifdef CONFIG_NUMA
762 changes += fold_diff(global_zone_diff, global_numa_diff,
763 global_node_diff);
764#else
715 changes += fold_diff(global_zone_diff, global_node_diff); 765 changes += fold_diff(global_zone_diff, global_node_diff);
766#endif
716 return changes; 767 return changes;
717} 768}
718 769
@@ -727,6 +778,9 @@ void cpu_vm_stats_fold(int cpu)
727 struct zone *zone; 778 struct zone *zone;
728 int i; 779 int i;
729 int global_zone_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, }; 780 int global_zone_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, };
781#ifdef CONFIG_NUMA
782 int global_numa_diff[NR_VM_NUMA_STAT_ITEMS] = { 0, };
783#endif
730 int global_node_diff[NR_VM_NODE_STAT_ITEMS] = { 0, }; 784 int global_node_diff[NR_VM_NODE_STAT_ITEMS] = { 0, };
731 785
732 for_each_populated_zone(zone) { 786 for_each_populated_zone(zone) {
@@ -743,6 +797,18 @@ void cpu_vm_stats_fold(int cpu)
743 atomic_long_add(v, &zone->vm_stat[i]); 797 atomic_long_add(v, &zone->vm_stat[i]);
744 global_zone_diff[i] += v; 798 global_zone_diff[i] += v;
745 } 799 }
800
801#ifdef CONFIG_NUMA
802 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
803 if (p->vm_numa_stat_diff[i]) {
804 int v;
805
806 v = p->vm_numa_stat_diff[i];
807 p->vm_numa_stat_diff[i] = 0;
808 atomic_long_add(v, &zone->vm_numa_stat[i]);
809 global_numa_diff[i] += v;
810 }
811#endif
746 } 812 }
747 813
748 for_each_online_pgdat(pgdat) { 814 for_each_online_pgdat(pgdat) {
@@ -761,7 +827,11 @@ void cpu_vm_stats_fold(int cpu)
761 } 827 }
762 } 828 }
763 829
830#ifdef CONFIG_NUMA
831 fold_diff(global_zone_diff, global_numa_diff, global_node_diff);
832#else
764 fold_diff(global_zone_diff, global_node_diff); 833 fold_diff(global_zone_diff, global_node_diff);
834#endif
765} 835}
766 836
767/* 837/*
@@ -779,10 +849,36 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
779 atomic_long_add(v, &zone->vm_stat[i]); 849 atomic_long_add(v, &zone->vm_stat[i]);
780 atomic_long_add(v, &vm_zone_stat[i]); 850 atomic_long_add(v, &vm_zone_stat[i]);
781 } 851 }
852
853#ifdef CONFIG_NUMA
854 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
855 if (pset->vm_numa_stat_diff[i]) {
856 int v = pset->vm_numa_stat_diff[i];
857
858 pset->vm_numa_stat_diff[i] = 0;
859 atomic_long_add(v, &zone->vm_numa_stat[i]);
860 atomic_long_add(v, &vm_numa_stat[i]);
861 }
862#endif
782} 863}
783#endif 864#endif
784 865
785#ifdef CONFIG_NUMA 866#ifdef CONFIG_NUMA
867void __inc_numa_state(struct zone *zone,
868 enum numa_stat_item item)
869{
870 struct per_cpu_pageset __percpu *pcp = zone->pageset;
871 u16 __percpu *p = pcp->vm_numa_stat_diff + item;
872 u16 v;
873
874 v = __this_cpu_inc_return(*p);
875
876 if (unlikely(v > NUMA_STATS_THRESHOLD)) {
877 zone_numa_state_add(v, zone, item);
878 __this_cpu_write(*p, 0);
879 }
880}
881
786/* 882/*
787 * Determine the per node value of a stat item. This function 883 * Determine the per node value of a stat item. This function
788 * is called frequently in a NUMA machine, so try to be as 884 * is called frequently in a NUMA machine, so try to be as
@@ -802,6 +898,23 @@ unsigned long sum_zone_node_page_state(int node,
802} 898}
803 899
804/* 900/*
901 * Determine the per node value of a numa stat item. To avoid deviation,
902 * the per cpu stat number in vm_numa_stat_diff[] is also included.
903 */
904unsigned long sum_zone_numa_state(int node,
905 enum numa_stat_item item)
906{
907 struct zone *zones = NODE_DATA(node)->node_zones;
908 int i;
909 unsigned long count = 0;
910
911 for (i = 0; i < MAX_NR_ZONES; i++)
912 count += zone_numa_state_snapshot(zones + i, item);
913
914 return count;
915}
916
917/*
805 * Determine the per node value of a stat item. 918 * Determine the per node value of a stat item.
806 */ 919 */
807unsigned long node_page_state(struct pglist_data *pgdat, 920unsigned long node_page_state(struct pglist_data *pgdat,
@@ -937,6 +1050,9 @@ const char * const vmstat_text[] = {
937#if IS_ENABLED(CONFIG_ZSMALLOC) 1050#if IS_ENABLED(CONFIG_ZSMALLOC)
938 "nr_zspages", 1051 "nr_zspages",
939#endif 1052#endif
1053 "nr_free_cma",
1054
1055 /* enum numa_stat_item counters */
940#ifdef CONFIG_NUMA 1056#ifdef CONFIG_NUMA
941 "numa_hit", 1057 "numa_hit",
942 "numa_miss", 1058 "numa_miss",
@@ -945,7 +1061,6 @@ const char * const vmstat_text[] = {
945 "numa_local", 1061 "numa_local",
946 "numa_other", 1062 "numa_other",
947#endif 1063#endif
948 "nr_free_cma",
949 1064
950 /* Node-based counters */ 1065 /* Node-based counters */
951 "nr_inactive_anon", 1066 "nr_inactive_anon",
@@ -1106,7 +1221,6 @@ const char * const vmstat_text[] = {
1106}; 1221};
1107#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */ 1222#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
1108 1223
1109
1110#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \ 1224#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \
1111 defined(CONFIG_PROC_FS) 1225 defined(CONFIG_PROC_FS)
1112static void *frag_start(struct seq_file *m, loff_t *pos) 1226static void *frag_start(struct seq_file *m, loff_t *pos)
@@ -1384,7 +1498,8 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
1384 seq_printf(m, "\n per-node stats"); 1498 seq_printf(m, "\n per-node stats");
1385 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { 1499 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) {
1386 seq_printf(m, "\n %-12s %lu", 1500 seq_printf(m, "\n %-12s %lu",
1387 vmstat_text[i + NR_VM_ZONE_STAT_ITEMS], 1501 vmstat_text[i + NR_VM_ZONE_STAT_ITEMS +
1502 NR_VM_NUMA_STAT_ITEMS],
1388 node_page_state(pgdat, i)); 1503 node_page_state(pgdat, i));
1389 } 1504 }
1390 } 1505 }
@@ -1421,6 +1536,13 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
1421 seq_printf(m, "\n %-12s %lu", vmstat_text[i], 1536 seq_printf(m, "\n %-12s %lu", vmstat_text[i],
1422 zone_page_state(zone, i)); 1537 zone_page_state(zone, i));
1423 1538
1539#ifdef CONFIG_NUMA
1540 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
1541 seq_printf(m, "\n %-12s %lu",
1542 vmstat_text[i + NR_VM_ZONE_STAT_ITEMS],
1543 zone_numa_state_snapshot(zone, i));
1544#endif
1545
1424 seq_printf(m, "\n pagesets"); 1546 seq_printf(m, "\n pagesets");
1425 for_each_online_cpu(i) { 1547 for_each_online_cpu(i) {
1426 struct per_cpu_pageset *pageset; 1548 struct per_cpu_pageset *pageset;
@@ -1497,6 +1619,7 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
1497 if (*pos >= ARRAY_SIZE(vmstat_text)) 1619 if (*pos >= ARRAY_SIZE(vmstat_text))
1498 return NULL; 1620 return NULL;
1499 stat_items_size = NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long) + 1621 stat_items_size = NR_VM_ZONE_STAT_ITEMS * sizeof(unsigned long) +
1622 NR_VM_NUMA_STAT_ITEMS * sizeof(unsigned long) +
1500 NR_VM_NODE_STAT_ITEMS * sizeof(unsigned long) + 1623 NR_VM_NODE_STAT_ITEMS * sizeof(unsigned long) +
1501 NR_VM_WRITEBACK_STAT_ITEMS * sizeof(unsigned long); 1624 NR_VM_WRITEBACK_STAT_ITEMS * sizeof(unsigned long);
1502 1625
@@ -1512,6 +1635,12 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
1512 v[i] = global_zone_page_state(i); 1635 v[i] = global_zone_page_state(i);
1513 v += NR_VM_ZONE_STAT_ITEMS; 1636 v += NR_VM_ZONE_STAT_ITEMS;
1514 1637
1638#ifdef CONFIG_NUMA
1639 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
1640 v[i] = global_numa_state(i);
1641 v += NR_VM_NUMA_STAT_ITEMS;
1642#endif
1643
1515 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) 1644 for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
1516 v[i] = global_node_page_state(i); 1645 v[i] = global_node_page_state(i);
1517 v += NR_VM_NODE_STAT_ITEMS; 1646 v += NR_VM_NODE_STAT_ITEMS;
@@ -1613,6 +1742,16 @@ int vmstat_refresh(struct ctl_table *table, int write,
1613 err = -EINVAL; 1742 err = -EINVAL;
1614 } 1743 }
1615 } 1744 }
1745#ifdef CONFIG_NUMA
1746 for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++) {
1747 val = atomic_long_read(&vm_numa_stat[i]);
1748 if (val < 0) {
1749 pr_warn("%s: %s %ld\n",
1750 __func__, vmstat_text[i + NR_VM_ZONE_STAT_ITEMS], val);
1751 err = -EINVAL;
1752 }
1753 }
1754#endif
1616 if (err) 1755 if (err)
1617 return err; 1756 return err;
1618 if (write) 1757 if (write)
@@ -1654,13 +1793,20 @@ static bool need_update(int cpu)
1654 struct per_cpu_pageset *p = per_cpu_ptr(zone->pageset, cpu); 1793 struct per_cpu_pageset *p = per_cpu_ptr(zone->pageset, cpu);
1655 1794
1656 BUILD_BUG_ON(sizeof(p->vm_stat_diff[0]) != 1); 1795 BUILD_BUG_ON(sizeof(p->vm_stat_diff[0]) != 1);
1796#ifdef CONFIG_NUMA
1797 BUILD_BUG_ON(sizeof(p->vm_numa_stat_diff[0]) != 2);
1798#endif
1799
1657 /* 1800 /*
1658 * The fast way of checking if there are any vmstat diffs. 1801 * The fast way of checking if there are any vmstat diffs.
1659 * This works because the diffs are byte sized items. 1802 * This works because the diffs are byte sized items.
1660 */ 1803 */
1661 if (memchr_inv(p->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS)) 1804 if (memchr_inv(p->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS))
1662 return true; 1805 return true;
1663 1806#ifdef CONFIG_NUMA
1807 if (memchr_inv(p->vm_numa_stat_diff, 0, NR_VM_NUMA_STAT_ITEMS))
1808 return true;
1809#endif
1664 } 1810 }
1665 return false; 1811 return false;
1666} 1812}
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 62457eb82330..7c38e850a8fc 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -551,20 +551,23 @@ static int get_size_class_index(int size)
551 return min_t(int, ZS_SIZE_CLASSES - 1, idx); 551 return min_t(int, ZS_SIZE_CLASSES - 1, idx);
552} 552}
553 553
554/* type can be of enum type zs_stat_type or fullness_group */
554static inline void zs_stat_inc(struct size_class *class, 555static inline void zs_stat_inc(struct size_class *class,
555 enum zs_stat_type type, unsigned long cnt) 556 int type, unsigned long cnt)
556{ 557{
557 class->stats.objs[type] += cnt; 558 class->stats.objs[type] += cnt;
558} 559}
559 560
561/* type can be of enum type zs_stat_type or fullness_group */
560static inline void zs_stat_dec(struct size_class *class, 562static inline void zs_stat_dec(struct size_class *class,
561 enum zs_stat_type type, unsigned long cnt) 563 int type, unsigned long cnt)
562{ 564{
563 class->stats.objs[type] -= cnt; 565 class->stats.objs[type] -= cnt;
564} 566}
565 567
568/* type can be of enum type zs_stat_type or fullness_group */
566static inline unsigned long zs_stat_get(struct size_class *class, 569static inline unsigned long zs_stat_get(struct size_class *class,
567 enum zs_stat_type type) 570 int type)
568{ 571{
569 return class->stats.objs[type]; 572 return class->stats.objs[type];
570} 573}
@@ -1969,6 +1972,14 @@ int zs_page_migrate(struct address_space *mapping, struct page *newpage,
1969 unsigned int obj_idx; 1972 unsigned int obj_idx;
1970 int ret = -EAGAIN; 1973 int ret = -EAGAIN;
1971 1974
1975 /*
1976 * We cannot support the _NO_COPY case here, because copy needs to
1977 * happen under the zs lock, which does not work with
1978 * MIGRATE_SYNC_NO_COPY workflow.
1979 */
1980 if (mode == MIGRATE_SYNC_NO_COPY)
1981 return -EINVAL;
1982
1972 VM_BUG_ON_PAGE(!PageMovable(page), page); 1983 VM_BUG_ON_PAGE(!PageMovable(page), page);
1973 VM_BUG_ON_PAGE(!PageIsolated(page), page); 1984 VM_BUG_ON_PAGE(!PageIsolated(page), page);
1974 1985
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2287a0bca863..dd2c262aebbf 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -145,7 +145,8 @@ sub list_types {
145 close($script); 145 close($script);
146 146
147 my @types = (); 147 my @types = ();
148 for ($text =~ /\b(?:(?:CHK|WARN|ERROR)\s*\(\s*"([^"]+)")/g) { 148 # Also catch when type or level is passed through a variable
149 for ($text =~ /(?:(?:\bCHK|\bWARN|\bERROR|&\{\$msg_level})\s*\(|\$msg_type\s*=)\s*"([^"]+)"/g) {
149 push (@types, $_); 150 push (@types, $_);
150 } 151 }
151 @types = sort(uniq(@types)); 152 @types = sort(uniq(@types));
@@ -2715,10 +2716,10 @@ sub process {
2715 my $typo_fix = $spelling_fix{lc($typo)}; 2716 my $typo_fix = $spelling_fix{lc($typo)};
2716 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/); 2717 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
2717 $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/); 2718 $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
2718 my $msg_type = \&WARN; 2719 my $msg_level = \&WARN;
2719 $msg_type = \&CHK if ($file); 2720 $msg_level = \&CHK if ($file);
2720 if (&{$msg_type}("TYPO_SPELLING", 2721 if (&{$msg_level}("TYPO_SPELLING",
2721 "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) && 2722 "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) &&
2722 $fix) { 2723 $fix) {
2723 $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/; 2724 $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
2724 } 2725 }
@@ -2753,10 +2754,10 @@ sub process {
2753 $rawline =~ /\b59\s+Temple\s+Pl/i || 2754 $rawline =~ /\b59\s+Temple\s+Pl/i ||
2754 $rawline =~ /\b51\s+Franklin\s+St/i) { 2755 $rawline =~ /\b51\s+Franklin\s+St/i) {
2755 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 2756 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
2756 my $msg_type = \&ERROR; 2757 my $msg_level = \&ERROR;
2757 $msg_type = \&CHK if ($file); 2758 $msg_level = \&CHK if ($file);
2758 &{$msg_type}("FSF_MAILING_ADDRESS", 2759 &{$msg_level}("FSF_MAILING_ADDRESS",
2759 "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) 2760 "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)
2760 } 2761 }
2761 2762
2762# check for Kconfig help text having a real description 2763# check for Kconfig help text having a real description
@@ -2875,7 +2876,7 @@ sub process {
2875# #defines that are a single string 2876# #defines that are a single string
2876# 2877#
2877# There are 3 different line length message types: 2878# There are 3 different line length message types:
2878# LONG_LINE_COMMENT a comment starts before but extends beyond $max_linelength 2879# LONG_LINE_COMMENT a comment starts before but extends beyond $max_line_length
2879# LONG_LINE_STRING a string starts before but extends beyond $max_line_length 2880# LONG_LINE_STRING a string starts before but extends beyond $max_line_length
2880# LONG_LINE all other lines longer than $max_line_length 2881# LONG_LINE all other lines longer than $max_line_length
2881# 2882#
@@ -3810,10 +3811,10 @@ sub process {
3810 3811
3811# avoid BUG() or BUG_ON() 3812# avoid BUG() or BUG_ON()
3812 if ($line =~ /\b(?:BUG|BUG_ON)\b/) { 3813 if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
3813 my $msg_type = \&WARN; 3814 my $msg_level = \&WARN;
3814 $msg_type = \&CHK if ($file); 3815 $msg_level = \&CHK if ($file);
3815 &{$msg_type}("AVOID_BUG", 3816 &{$msg_level}("AVOID_BUG",
3816 "Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr); 3817 "Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr);
3817 } 3818 }
3818 3819
3819# avoid LINUX_VERSION_CODE 3820# avoid LINUX_VERSION_CODE
@@ -4339,11 +4340,11 @@ sub process {
4339 4340
4340 # messages are ERROR, but ?: are CHK 4341 # messages are ERROR, but ?: are CHK
4341 if ($ok == 0) { 4342 if ($ok == 0) {
4342 my $msg_type = \&ERROR; 4343 my $msg_level = \&ERROR;
4343 $msg_type = \&CHK if (($op eq '?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/); 4344 $msg_level = \&CHK if (($op eq '?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/);
4344 4345
4345 if (&{$msg_type}("SPACING", 4346 if (&{$msg_level}("SPACING",
4346 "spaces required around that '$op' $at\n" . $hereptr)) { 4347 "spaces required around that '$op' $at\n" . $hereptr)) {
4347 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; 4348 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
4348 if (defined $fix_elements[$n + 2]) { 4349 if (defined $fix_elements[$n + 2]) {
4349 $fix_elements[$n + 2] =~ s/^\s+//; 4350 $fix_elements[$n + 2] =~ s/^\s+//;
@@ -4496,6 +4497,30 @@ sub process {
4496 } 4497 }
4497 } 4498 }
4498 4499
4500# check for unnecessary parentheses around comparisons in if uses
4501 if ($^V && $^V ge 5.10.0 && defined($stat) &&
4502 $stat =~ /(^.\s*if\s*($balanced_parens))/) {
4503 my $if_stat = $1;
4504 my $test = substr($2, 1, -1);
4505 my $herectx;
4506 while ($test =~ /(?:^|[^\w\&\!\~])+\s*\(\s*([\&\!\~]?\s*$Lval\s*(?:$Compare\s*$FuncArg)?)\s*\)/g) {
4507 my $match = $1;
4508 # avoid parentheses around potential macro args
4509 next if ($match =~ /^\s*\w+\s*$/);
4510 if (!defined($herectx)) {
4511 $herectx = $here . "\n";
4512 my $cnt = statement_rawlines($if_stat);
4513 for (my $n = 0; $n < $cnt; $n++) {
4514 my $rl = raw_line($linenr, $n);
4515 $herectx .= $rl . "\n";
4516 last if $rl =~ /^[ \+].*\{/;
4517 }
4518 }
4519 CHK("UNNECESSARY_PARENTHESES",
4520 "Unnecessary parentheses around '$match'\n" . $herectx);
4521 }
4522 }
4523
4499#goto labels aren't indented, allow a single space however 4524#goto labels aren't indented, allow a single space however
4500 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and 4525 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
4501 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { 4526 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index f1005a31c709..68feae262476 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -30,9 +30,6 @@
30 30
31#include "pcm512x.h" 31#include "pcm512x.h"
32 32
33#define DIV_ROUND_DOWN_ULL(ll, d) \
34 ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
35
36#define PCM512x_NUM_SUPPLIES 3 33#define PCM512x_NUM_SUPPLIES 3
37static const char * const pcm512x_supply_names[PCM512x_NUM_SUPPLIES] = { 34static const char * const pcm512x_supply_names[PCM512x_NUM_SUPPLIES] = {
38 "AVDD", 35 "AVDD",
diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c
index a5a4da856dfe..73684c4a1ed6 100644
--- a/tools/testing/selftests/kcmp/kcmp_test.c
+++ b/tools/testing/selftests/kcmp/kcmp_test.c
@@ -8,7 +8,6 @@
8#include <errno.h> 8#include <errno.h>
9#include <string.h> 9#include <string.h>
10#include <fcntl.h> 10#include <fcntl.h>
11
12#include <linux/unistd.h> 11#include <linux/unistd.h>
13#include <linux/kcmp.h> 12#include <linux/kcmp.h>
14 13
@@ -16,20 +15,28 @@
16#include <sys/types.h> 15#include <sys/types.h>
17#include <sys/stat.h> 16#include <sys/stat.h>
18#include <sys/wait.h> 17#include <sys/wait.h>
18#include <sys/epoll.h>
19 19
20#include "../kselftest.h" 20#include "../kselftest.h"
21 21
22static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) 22static long sys_kcmp(int pid1, int pid2, int type, unsigned long fd1, unsigned long fd2)
23{ 23{
24 return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); 24 return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
25} 25}
26 26
27static const unsigned int duped_num = 64;
28
27int main(int argc, char **argv) 29int main(int argc, char **argv)
28{ 30{
29 const char kpath[] = "kcmp-test-file"; 31 const char kpath[] = "kcmp-test-file";
32 struct kcmp_epoll_slot epoll_slot;
33 struct epoll_event ev;
30 int pid1, pid2; 34 int pid1, pid2;
35 int pipefd[2];
31 int fd1, fd2; 36 int fd1, fd2;
37 int epollfd;
32 int status; 38 int status;
39 int fddup;
33 40
34 fd1 = open(kpath, O_RDWR | O_CREAT | O_TRUNC, 0644); 41 fd1 = open(kpath, O_RDWR | O_CREAT | O_TRUNC, 0644);
35 pid1 = getpid(); 42 pid1 = getpid();
@@ -39,6 +46,37 @@ int main(int argc, char **argv)
39 ksft_exit_fail(); 46 ksft_exit_fail();
40 } 47 }
41 48
49 if (pipe(pipefd)) {
50 perror("Can't create pipe");
51 ksft_exit_fail();
52 }
53
54 epollfd = epoll_create1(0);
55 if (epollfd < 0) {
56 perror("epoll_create1 failed");
57 ksft_exit_fail();
58 }
59
60 memset(&ev, 0xff, sizeof(ev));
61 ev.events = EPOLLIN | EPOLLOUT;
62
63 if (epoll_ctl(epollfd, EPOLL_CTL_ADD, pipefd[0], &ev)) {
64 perror("epoll_ctl failed");
65 ksft_exit_fail();
66 }
67
68 fddup = dup2(pipefd[1], duped_num);
69 if (fddup < 0) {
70 perror("dup2 failed");
71 ksft_exit_fail();
72 }
73
74 if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fddup, &ev)) {
75 perror("epoll_ctl failed");
76 ksft_exit_fail();
77 }
78 close(fddup);
79
42 pid2 = fork(); 80 pid2 = fork();
43 if (pid2 < 0) { 81 if (pid2 < 0) {
44 perror("fork failed"); 82 perror("fork failed");
@@ -95,6 +133,24 @@ int main(int argc, char **argv)
95 ksft_inc_pass_cnt(); 133 ksft_inc_pass_cnt();
96 } 134 }
97 135
136 /* Compare epoll target */
137 epoll_slot = (struct kcmp_epoll_slot) {
138 .efd = epollfd,
139 .tfd = duped_num,
140 .toff = 0,
141 };
142 ret = sys_kcmp(pid1, pid1, KCMP_EPOLL_TFD, pipefd[1],
143 (unsigned long)(void *)&epoll_slot);
144 if (ret) {
145 printf("FAIL: 0 expected but %d returned (%s)\n",
146 ret, strerror(errno));
147 ksft_inc_fail_cnt();
148 ret = -1;
149 } else {
150 printf("PASS: 0 returned as expected\n");
151 ksft_inc_pass_cnt();
152 }
153
98 ksft_print_cnts(); 154 ksft_print_cnts();
99 155
100 if (ret) 156 if (ret)