aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 22:42:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 22:42:40 -0500
commit7c225c69f86c934e3be9be63ecde754e286838d7 (patch)
treeff2df419b0c4886b37407235f7d21215e4cf45e4 /include
parent6363b3f3ac5be096d08c8c504128befa0c033529 (diff)
parent1b7176aea0a924ac59c6a283129d3e8eb00aa915 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge updates from Andrew Morton: - a few misc bits - ocfs2 updates - almost all of MM * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (131 commits) memory hotplug: fix comments when adding section mm: make alloc_node_mem_map a void call if we don't have CONFIG_FLAT_NODE_MEM_MAP mm: simplify nodemask printing mm,oom_reaper: remove pointless kthread_run() error check mm/page_ext.c: check if page_ext is not prepared writeback: remove unused function parameter mm: do not rely on preempt_count in print_vma_addr mm, sparse: do not swamp log with huge vmemmap allocation failures mm/hmm: remove redundant variable align_end mm/list_lru.c: mark expected switch fall-through mm/shmem.c: mark expected switch fall-through mm/page_alloc.c: broken deferred calculation mm: don't warn about allocations which stall for too long fs: fuse: account fuse_inode slab memory as reclaimable mm, page_alloc: fix potential false positive in __zone_watermark_ok mm: mlock: remove lru_add_drain_all() mm, sysctl: make NUMA stats configurable shmem: convert shmem_init_inodecache() to void Unify migrate_pages and move_pages access checks mm, pagevec: rename pagevec drained field ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/backing-dev.h10
-rw-r--r--include/linux/bootmem.h27
-rw-r--r--include/linux/c2port.h4
-rw-r--r--include/linux/dma-mapping.h8
-rw-r--r--include/linux/filter.h2
-rw-r--r--include/linux/gfp.h18
-rw-r--r--include/linux/hmm.h4
-rw-r--r--include/linux/interrupt.h15
-rw-r--r--include/linux/kasan.h4
-rw-r--r--include/linux/kmemcheck.h171
-rw-r--r--include/linux/kmemleak.h8
-rw-r--r--include/linux/memblock.h24
-rw-r--r--include/linux/mm.h83
-rw-r--r--include/linux/mm_types.h19
-rw-r--r--include/linux/mmu_notifier.h20
-rw-r--r--include/linux/mmzone.h9
-rw-r--r--include/linux/net.h3
-rw-r--r--include/linux/nodemask.h4
-rw-r--r--include/linux/page-flags.h2
-rw-r--r--include/linux/page-isolation.h2
-rw-r--r--include/linux/pagemap.h26
-rw-r--r--include/linux/pagevec.h20
-rw-r--r--include/linux/radix-tree.h7
-rw-r--r--include/linux/ring_buffer.h3
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--include/linux/slab.h81
-rw-r--r--include/linux/slab_def.h2
-rw-r--r--include/linux/slub_def.h2
-rw-r--r--include/linux/swap.h35
-rw-r--r--include/linux/thread_info.h5
-rw-r--r--include/linux/types.h1
-rw-r--r--include/linux/vmstat.h10
-rw-r--r--include/net/inet_sock.h3
-rw-r--r--include/net/inet_timewait_sock.h4
-rw-r--r--include/net/sock.h5
-rw-r--r--include/trace/events/kmem.h11
-rw-r--r--include/trace/events/mmflags.h2
37 files changed, 300 insertions, 359 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index f41ca8486e02..e54e7e0033eb 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -93,7 +93,7 @@ extern void wb_writeout_inc(struct bdi_writeback *wb);
93/* 93/*
94 * maximal error of a stat counter. 94 * maximal error of a stat counter.
95 */ 95 */
96static inline unsigned long wb_stat_error(struct bdi_writeback *wb) 96static inline unsigned long wb_stat_error(void)
97{ 97{
98#ifdef CONFIG_SMP 98#ifdef CONFIG_SMP
99 return nr_cpu_ids * WB_STAT_BATCH; 99 return nr_cpu_ids * WB_STAT_BATCH;
@@ -122,6 +122,8 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
122 * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold. 122 * BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
123 * 123 *
124 * BDI_CAP_CGROUP_WRITEBACK: Supports cgroup-aware writeback. 124 * BDI_CAP_CGROUP_WRITEBACK: Supports cgroup-aware writeback.
125 * BDI_CAP_SYNCHRONOUS_IO: Device is so fast that asynchronous IO would be
126 * inefficient.
125 */ 127 */
126#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 128#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
127#define BDI_CAP_NO_WRITEBACK 0x00000002 129#define BDI_CAP_NO_WRITEBACK 0x00000002
@@ -129,6 +131,7 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
129#define BDI_CAP_STABLE_WRITES 0x00000008 131#define BDI_CAP_STABLE_WRITES 0x00000008
130#define BDI_CAP_STRICTLIMIT 0x00000010 132#define BDI_CAP_STRICTLIMIT 0x00000010
131#define BDI_CAP_CGROUP_WRITEBACK 0x00000020 133#define BDI_CAP_CGROUP_WRITEBACK 0x00000020
134#define BDI_CAP_SYNCHRONOUS_IO 0x00000040
132 135
133#define BDI_CAP_NO_ACCT_AND_WRITEBACK \ 136#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
134 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB) 137 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
@@ -174,6 +177,11 @@ static inline int wb_congested(struct bdi_writeback *wb, int cong_bits)
174long congestion_wait(int sync, long timeout); 177long congestion_wait(int sync, long timeout);
175long wait_iff_congested(struct pglist_data *pgdat, int sync, long timeout); 178long wait_iff_congested(struct pglist_data *pgdat, int sync, long timeout);
176 179
180static inline bool bdi_cap_synchronous_io(struct backing_dev_info *bdi)
181{
182 return bdi->capabilities & BDI_CAP_SYNCHRONOUS_IO;
183}
184
177static inline bool bdi_cap_stable_pages_required(struct backing_dev_info *bdi) 185static inline bool bdi_cap_stable_pages_required(struct backing_dev_info *bdi)
178{ 186{
179 return bdi->capabilities & BDI_CAP_STABLE_WRITES; 187 return bdi->capabilities & BDI_CAP_STABLE_WRITES;
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index fdf40ca04b3c..a53063e9d7d8 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -161,6 +161,9 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
161#define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0) 161#define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0)
162 162
163/* FIXME: Move to memblock.h at a point where we remove nobootmem.c */ 163/* FIXME: Move to memblock.h at a point where we remove nobootmem.c */
164void *memblock_virt_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align,
165 phys_addr_t min_addr,
166 phys_addr_t max_addr, int nid);
164void *memblock_virt_alloc_try_nid_nopanic(phys_addr_t size, 167void *memblock_virt_alloc_try_nid_nopanic(phys_addr_t size,
165 phys_addr_t align, phys_addr_t min_addr, 168 phys_addr_t align, phys_addr_t min_addr,
166 phys_addr_t max_addr, int nid); 169 phys_addr_t max_addr, int nid);
@@ -177,6 +180,14 @@ static inline void * __init memblock_virt_alloc(
177 NUMA_NO_NODE); 180 NUMA_NO_NODE);
178} 181}
179 182
183static inline void * __init memblock_virt_alloc_raw(
184 phys_addr_t size, phys_addr_t align)
185{
186 return memblock_virt_alloc_try_nid_raw(size, align, BOOTMEM_LOW_LIMIT,
187 BOOTMEM_ALLOC_ACCESSIBLE,
188 NUMA_NO_NODE);
189}
190
180static inline void * __init memblock_virt_alloc_nopanic( 191static inline void * __init memblock_virt_alloc_nopanic(
181 phys_addr_t size, phys_addr_t align) 192 phys_addr_t size, phys_addr_t align)
182{ 193{
@@ -258,6 +269,14 @@ static inline void * __init memblock_virt_alloc(
258 return __alloc_bootmem(size, align, BOOTMEM_LOW_LIMIT); 269 return __alloc_bootmem(size, align, BOOTMEM_LOW_LIMIT);
259} 270}
260 271
272static inline void * __init memblock_virt_alloc_raw(
273 phys_addr_t size, phys_addr_t align)
274{
275 if (!align)
276 align = SMP_CACHE_BYTES;
277 return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT);
278}
279
261static inline void * __init memblock_virt_alloc_nopanic( 280static inline void * __init memblock_virt_alloc_nopanic(
262 phys_addr_t size, phys_addr_t align) 281 phys_addr_t size, phys_addr_t align)
263{ 282{
@@ -310,6 +329,14 @@ static inline void * __init memblock_virt_alloc_try_nid(phys_addr_t size,
310 min_addr); 329 min_addr);
311} 330}
312 331
332static inline void * __init memblock_virt_alloc_try_nid_raw(
333 phys_addr_t size, phys_addr_t align,
334 phys_addr_t min_addr, phys_addr_t max_addr, int nid)
335{
336 return ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align,
337 min_addr, max_addr);
338}
339
313static inline void * __init memblock_virt_alloc_try_nid_nopanic( 340static inline void * __init memblock_virt_alloc_try_nid_nopanic(
314 phys_addr_t size, phys_addr_t align, 341 phys_addr_t size, phys_addr_t align,
315 phys_addr_t min_addr, phys_addr_t max_addr, int nid) 342 phys_addr_t min_addr, phys_addr_t max_addr, int nid)
diff --git a/include/linux/c2port.h b/include/linux/c2port.h
index 4efabcb51347..f2736348ca26 100644
--- a/include/linux/c2port.h
+++ b/include/linux/c2port.h
@@ -9,8 +9,6 @@
9 * the Free Software Foundation 9 * the Free Software Foundation
10 */ 10 */
11 11
12#include <linux/kmemcheck.h>
13
14#define C2PORT_NAME_LEN 32 12#define C2PORT_NAME_LEN 32
15 13
16struct device; 14struct device;
@@ -22,10 +20,8 @@ struct device;
22/* Main struct */ 20/* Main struct */
23struct c2port_ops; 21struct c2port_ops;
24struct c2port_device { 22struct c2port_device {
25 kmemcheck_bitfield_begin(flags);
26 unsigned int access:1; 23 unsigned int access:1;
27 unsigned int flash_access:1; 24 unsigned int flash_access:1;
28 kmemcheck_bitfield_end(flags);
29 25
30 int id; 26 int id;
31 char name[C2PORT_NAME_LEN]; 27 char name[C2PORT_NAME_LEN];
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eee1499db396..e8f8e8fb244d 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -9,7 +9,6 @@
9#include <linux/dma-debug.h> 9#include <linux/dma-debug.h>
10#include <linux/dma-direction.h> 10#include <linux/dma-direction.h>
11#include <linux/scatterlist.h> 11#include <linux/scatterlist.h>
12#include <linux/kmemcheck.h>
13#include <linux/bug.h> 12#include <linux/bug.h>
14#include <linux/mem_encrypt.h> 13#include <linux/mem_encrypt.h>
15 14
@@ -232,7 +231,6 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
232 const struct dma_map_ops *ops = get_dma_ops(dev); 231 const struct dma_map_ops *ops = get_dma_ops(dev);
233 dma_addr_t addr; 232 dma_addr_t addr;
234 233
235 kmemcheck_mark_initialized(ptr, size);
236 BUG_ON(!valid_dma_direction(dir)); 234 BUG_ON(!valid_dma_direction(dir));
237 addr = ops->map_page(dev, virt_to_page(ptr), 235 addr = ops->map_page(dev, virt_to_page(ptr),
238 offset_in_page(ptr), size, 236 offset_in_page(ptr), size,
@@ -265,11 +263,8 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
265 unsigned long attrs) 263 unsigned long attrs)
266{ 264{
267 const struct dma_map_ops *ops = get_dma_ops(dev); 265 const struct dma_map_ops *ops = get_dma_ops(dev);
268 int i, ents; 266 int ents;
269 struct scatterlist *s;
270 267
271 for_each_sg(sg, s, nents, i)
272 kmemcheck_mark_initialized(sg_virt(s), s->length);
273 BUG_ON(!valid_dma_direction(dir)); 268 BUG_ON(!valid_dma_direction(dir));
274 ents = ops->map_sg(dev, sg, nents, dir, attrs); 269 ents = ops->map_sg(dev, sg, nents, dir, attrs);
275 BUG_ON(ents < 0); 270 BUG_ON(ents < 0);
@@ -299,7 +294,6 @@ static inline dma_addr_t dma_map_page_attrs(struct device *dev,
299 const struct dma_map_ops *ops = get_dma_ops(dev); 294 const struct dma_map_ops *ops = get_dma_ops(dev);
300 dma_addr_t addr; 295 dma_addr_t addr;
301 296
302 kmemcheck_mark_initialized(page_address(page) + offset, size);
303 BUG_ON(!valid_dma_direction(dir)); 297 BUG_ON(!valid_dma_direction(dir));
304 addr = ops->map_page(dev, page, offset, size, dir, attrs); 298 addr = ops->map_page(dev, page, offset, size, dir, attrs);
305 debug_dma_map_page(dev, page, offset, size, dir, addr, false); 299 debug_dma_map_page(dev, page, offset, size, dir, addr, false);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 0cd02ff4ae30..80b5b482cb46 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -454,13 +454,11 @@ struct bpf_binary_header {
454 454
455struct bpf_prog { 455struct bpf_prog {
456 u16 pages; /* Number of allocated pages */ 456 u16 pages; /* Number of allocated pages */
457 kmemcheck_bitfield_begin(meta);
458 u16 jited:1, /* Is our filter JIT'ed? */ 457 u16 jited:1, /* Is our filter JIT'ed? */
459 locked:1, /* Program image locked? */ 458 locked:1, /* Program image locked? */
460 gpl_compatible:1, /* Is filter GPL compatible? */ 459 gpl_compatible:1, /* Is filter GPL compatible? */
461 cb_access:1, /* Is control block accessed? */ 460 cb_access:1, /* Is control block accessed? */
462 dst_needed:1; /* Do we need dst entry? */ 461 dst_needed:1; /* Do we need dst entry? */
463 kmemcheck_bitfield_end(meta);
464 enum bpf_prog_type type; /* Type of BPF program */ 462 enum bpf_prog_type type; /* Type of BPF program */
465 u32 len; /* Number of filter blocks */ 463 u32 len; /* Number of filter blocks */
466 u32 jited_len; /* Size of jited insns in bytes */ 464 u32 jited_len; /* Size of jited insns in bytes */
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 710143741eb5..1a4582b44d32 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -24,7 +24,6 @@ struct vm_area_struct;
24#define ___GFP_HIGH 0x20u 24#define ___GFP_HIGH 0x20u
25#define ___GFP_IO 0x40u 25#define ___GFP_IO 0x40u
26#define ___GFP_FS 0x80u 26#define ___GFP_FS 0x80u
27#define ___GFP_COLD 0x100u
28#define ___GFP_NOWARN 0x200u 27#define ___GFP_NOWARN 0x200u
29#define ___GFP_RETRY_MAYFAIL 0x400u 28#define ___GFP_RETRY_MAYFAIL 0x400u
30#define ___GFP_NOFAIL 0x800u 29#define ___GFP_NOFAIL 0x800u
@@ -37,7 +36,6 @@ struct vm_area_struct;
37#define ___GFP_THISNODE 0x40000u 36#define ___GFP_THISNODE 0x40000u
38#define ___GFP_ATOMIC 0x80000u 37#define ___GFP_ATOMIC 0x80000u
39#define ___GFP_ACCOUNT 0x100000u 38#define ___GFP_ACCOUNT 0x100000u
40#define ___GFP_NOTRACK 0x200000u
41#define ___GFP_DIRECT_RECLAIM 0x400000u 39#define ___GFP_DIRECT_RECLAIM 0x400000u
42#define ___GFP_WRITE 0x800000u 40#define ___GFP_WRITE 0x800000u
43#define ___GFP_KSWAPD_RECLAIM 0x1000000u 41#define ___GFP_KSWAPD_RECLAIM 0x1000000u
@@ -193,27 +191,15 @@ struct vm_area_struct;
193/* 191/*
194 * Action modifiers 192 * Action modifiers
195 * 193 *
196 * __GFP_COLD indicates that the caller does not expect to be used in the near
197 * future. Where possible, a cache-cold page will be returned.
198 *
199 * __GFP_NOWARN suppresses allocation failure reports. 194 * __GFP_NOWARN suppresses allocation failure reports.
200 * 195 *
201 * __GFP_COMP address compound page metadata. 196 * __GFP_COMP address compound page metadata.
202 * 197 *
203 * __GFP_ZERO returns a zeroed page on success. 198 * __GFP_ZERO returns a zeroed page on success.
204 *
205 * __GFP_NOTRACK avoids tracking with kmemcheck.
206 *
207 * __GFP_NOTRACK_FALSE_POSITIVE is an alias of __GFP_NOTRACK. It's a means of
208 * distinguishing in the source between false positives and allocations that
209 * cannot be supported (e.g. page tables).
210 */ 199 */
211#define __GFP_COLD ((__force gfp_t)___GFP_COLD)
212#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) 200#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN)
213#define __GFP_COMP ((__force gfp_t)___GFP_COMP) 201#define __GFP_COMP ((__force gfp_t)___GFP_COMP)
214#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) 202#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO)
215#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK)
216#define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
217 203
218/* Disable lockdep for GFP context tracking */ 204/* Disable lockdep for GFP context tracking */
219#define __GFP_NOLOCKDEP ((__force gfp_t)___GFP_NOLOCKDEP) 205#define __GFP_NOLOCKDEP ((__force gfp_t)___GFP_NOLOCKDEP)
@@ -539,8 +525,8 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask);
539 525
540extern void __free_pages(struct page *page, unsigned int order); 526extern void __free_pages(struct page *page, unsigned int order);
541extern void free_pages(unsigned long addr, unsigned int order); 527extern void free_pages(unsigned long addr, unsigned int order);
542extern void free_hot_cold_page(struct page *page, bool cold); 528extern void free_unref_page(struct page *page);
543extern void free_hot_cold_page_list(struct list_head *list, bool cold); 529extern void free_unref_page_list(struct list_head *list);
544 530
545struct page_frag_cache; 531struct page_frag_cache;
546extern void __page_frag_cache_drain(struct page *page, unsigned int count); 532extern void __page_frag_cache_drain(struct page *page, unsigned int count);
diff --git a/include/linux/hmm.h b/include/linux/hmm.h
index 96e69979f84d..325017ad9311 100644
--- a/include/linux/hmm.h
+++ b/include/linux/hmm.h
@@ -471,9 +471,9 @@ static inline void hmm_devmem_page_set_drvdata(struct page *page,
471 * @page: pointer to struct page 471 * @page: pointer to struct page
472 * Return: driver data value 472 * Return: driver data value
473 */ 473 */
474static inline unsigned long hmm_devmem_page_get_drvdata(struct page *page) 474static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page)
475{ 475{
476 unsigned long *drvdata = (unsigned long *)&page->pgmap; 476 const unsigned long *drvdata = (const unsigned long *)&page->pgmap;
477 477
478 return drvdata[1]; 478 return drvdata[1];
479} 479}
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index baeb872283d9..69c238210325 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -594,21 +594,6 @@ static inline void tasklet_hi_schedule(struct tasklet_struct *t)
594 __tasklet_hi_schedule(t); 594 __tasklet_hi_schedule(t);
595} 595}
596 596
597extern void __tasklet_hi_schedule_first(struct tasklet_struct *t);
598
599/*
600 * This version avoids touching any other tasklets. Needed for kmemcheck
601 * in order not to take any page faults while enqueueing this tasklet;
602 * consider VERY carefully whether you really need this or
603 * tasklet_hi_schedule()...
604 */
605static inline void tasklet_hi_schedule_first(struct tasklet_struct *t)
606{
607 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
608 __tasklet_hi_schedule_first(t);
609}
610
611
612static inline void tasklet_disable_nosync(struct tasklet_struct *t) 597static inline void tasklet_disable_nosync(struct tasklet_struct *t)
613{ 598{
614 atomic_inc(&t->count); 599 atomic_inc(&t->count);
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index 5017269e3f04..e3eb834c9a35 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -46,7 +46,7 @@ void kasan_alloc_pages(struct page *page, unsigned int order);
46void kasan_free_pages(struct page *page, unsigned int order); 46void kasan_free_pages(struct page *page, unsigned int order);
47 47
48void kasan_cache_create(struct kmem_cache *cache, size_t *size, 48void kasan_cache_create(struct kmem_cache *cache, size_t *size,
49 unsigned long *flags); 49 slab_flags_t *flags);
50void kasan_cache_shrink(struct kmem_cache *cache); 50void kasan_cache_shrink(struct kmem_cache *cache);
51void kasan_cache_shutdown(struct kmem_cache *cache); 51void kasan_cache_shutdown(struct kmem_cache *cache);
52 52
@@ -95,7 +95,7 @@ static inline void kasan_free_pages(struct page *page, unsigned int order) {}
95 95
96static inline void kasan_cache_create(struct kmem_cache *cache, 96static inline void kasan_cache_create(struct kmem_cache *cache,
97 size_t *size, 97 size_t *size,
98 unsigned long *flags) {} 98 slab_flags_t *flags) {}
99static inline void kasan_cache_shrink(struct kmem_cache *cache) {} 99static inline void kasan_cache_shrink(struct kmem_cache *cache) {}
100static inline void kasan_cache_shutdown(struct kmem_cache *cache) {} 100static inline void kasan_cache_shutdown(struct kmem_cache *cache) {}
101 101
diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h
index 7b1d7bead7d9..ea32a7d3cf1b 100644
--- a/include/linux/kmemcheck.h
+++ b/include/linux/kmemcheck.h
@@ -1,172 +1 @@
1/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
2#ifndef LINUX_KMEMCHECK_H
3#define LINUX_KMEMCHECK_H
4
5#include <linux/mm_types.h>
6#include <linux/types.h>
7
8#ifdef CONFIG_KMEMCHECK
9extern int kmemcheck_enabled;
10
11/* The slab-related functions. */
12void kmemcheck_alloc_shadow(struct page *page, int order, gfp_t flags, int node);
13void kmemcheck_free_shadow(struct page *page, int order);
14void kmemcheck_slab_alloc(struct kmem_cache *s, gfp_t gfpflags, void *object,
15 size_t size);
16void kmemcheck_slab_free(struct kmem_cache *s, void *object, size_t size);
17
18void kmemcheck_pagealloc_alloc(struct page *p, unsigned int order,
19 gfp_t gfpflags);
20
21void kmemcheck_show_pages(struct page *p, unsigned int n);
22void kmemcheck_hide_pages(struct page *p, unsigned int n);
23
24bool kmemcheck_page_is_tracked(struct page *p);
25
26void kmemcheck_mark_unallocated(void *address, unsigned int n);
27void kmemcheck_mark_uninitialized(void *address, unsigned int n);
28void kmemcheck_mark_initialized(void *address, unsigned int n);
29void kmemcheck_mark_freed(void *address, unsigned int n);
30
31void kmemcheck_mark_unallocated_pages(struct page *p, unsigned int n);
32void kmemcheck_mark_uninitialized_pages(struct page *p, unsigned int n);
33void kmemcheck_mark_initialized_pages(struct page *p, unsigned int n);
34
35int kmemcheck_show_addr(unsigned long address);
36int kmemcheck_hide_addr(unsigned long address);
37
38bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size);
39
40/*
41 * Bitfield annotations
42 *
43 * How to use: If you have a struct using bitfields, for example
44 *
45 * struct a {
46 * int x:8, y:8;
47 * };
48 *
49 * then this should be rewritten as
50 *
51 * struct a {
52 * kmemcheck_bitfield_begin(flags);
53 * int x:8, y:8;
54 * kmemcheck_bitfield_end(flags);
55 * };
56 *
57 * Now the "flags_begin" and "flags_end" members may be used to refer to the
58 * beginning and end, respectively, of the bitfield (and things like
59 * &x.flags_begin is allowed). As soon as the struct is allocated, the bit-
60 * fields should be annotated:
61 *
62 * struct a *a = kmalloc(sizeof(struct a), GFP_KERNEL);
63 * kmemcheck_annotate_bitfield(a, flags);
64 */
65#define kmemcheck_bitfield_begin(name) \
66 int name##_begin[0];
67
68#define kmemcheck_bitfield_end(name) \
69 int name##_end[0];
70
71#define kmemcheck_annotate_bitfield(ptr, name) \
72 do { \
73 int _n; \
74 \
75 if (!ptr) \
76 break; \
77 \
78 _n = (long) &((ptr)->name##_end) \
79 - (long) &((ptr)->name##_begin); \
80 BUILD_BUG_ON(_n < 0); \
81 \
82 kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
83 } while (0)
84
85#define kmemcheck_annotate_variable(var) \
86 do { \
87 kmemcheck_mark_initialized(&(var), sizeof(var)); \
88 } while (0) \
89
90#else
91#define kmemcheck_enabled 0
92
93static inline void
94kmemcheck_alloc_shadow(struct page *page, int order, gfp_t flags, int node)
95{
96}
97
98static inline void
99kmemcheck_free_shadow(struct page *page, int order)
100{
101}
102
103static inline void
104kmemcheck_slab_alloc(struct kmem_cache *s, gfp_t gfpflags, void *object,
105 size_t size)
106{
107}
108
109static inline void kmemcheck_slab_free(struct kmem_cache *s, void *object,
110 size_t size)
111{
112}
113
114static inline void kmemcheck_pagealloc_alloc(struct page *p,
115 unsigned int order, gfp_t gfpflags)
116{
117}
118
119static inline bool kmemcheck_page_is_tracked(struct page *p)
120{
121 return false;
122}
123
124static inline void kmemcheck_mark_unallocated(void *address, unsigned int n)
125{
126}
127
128static inline void kmemcheck_mark_uninitialized(void *address, unsigned int n)
129{
130}
131
132static inline void kmemcheck_mark_initialized(void *address, unsigned int n)
133{
134}
135
136static inline void kmemcheck_mark_freed(void *address, unsigned int n)
137{
138}
139
140static inline void kmemcheck_mark_unallocated_pages(struct page *p,
141 unsigned int n)
142{
143}
144
145static inline void kmemcheck_mark_uninitialized_pages(struct page *p,
146 unsigned int n)
147{
148}
149
150static inline void kmemcheck_mark_initialized_pages(struct page *p,
151 unsigned int n)
152{
153}
154
155static inline bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size)
156{
157 return true;
158}
159
160#define kmemcheck_bitfield_begin(name)
161#define kmemcheck_bitfield_end(name)
162#define kmemcheck_annotate_bitfield(ptr, name) \
163 do { \
164 } while (0)
165
166#define kmemcheck_annotate_variable(var) \
167 do { \
168 } while (0)
169
170#endif /* CONFIG_KMEMCHECK */
171
172#endif /* LINUX_KMEMCHECK_H */
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
index 590343f6c1b1..5ac416e2d339 100644
--- a/include/linux/kmemleak.h
+++ b/include/linux/kmemleak.h
@@ -48,14 +48,14 @@ extern void kmemleak_not_leak_phys(phys_addr_t phys) __ref;
48extern void kmemleak_ignore_phys(phys_addr_t phys) __ref; 48extern void kmemleak_ignore_phys(phys_addr_t phys) __ref;
49 49
50static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 50static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
51 int min_count, unsigned long flags, 51 int min_count, slab_flags_t flags,
52 gfp_t gfp) 52 gfp_t gfp)
53{ 53{
54 if (!(flags & SLAB_NOLEAKTRACE)) 54 if (!(flags & SLAB_NOLEAKTRACE))
55 kmemleak_alloc(ptr, size, min_count, gfp); 55 kmemleak_alloc(ptr, size, min_count, gfp);
56} 56}
57 57
58static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 58static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags)
59{ 59{
60 if (!(flags & SLAB_NOLEAKTRACE)) 60 if (!(flags & SLAB_NOLEAKTRACE))
61 kmemleak_free(ptr); 61 kmemleak_free(ptr);
@@ -76,7 +76,7 @@ static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
76{ 76{
77} 77}
78static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 78static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
79 int min_count, unsigned long flags, 79 int min_count, slab_flags_t flags,
80 gfp_t gfp) 80 gfp_t gfp)
81{ 81{
82} 82}
@@ -94,7 +94,7 @@ static inline void kmemleak_free(const void *ptr)
94static inline void kmemleak_free_part(const void *ptr, size_t size) 94static inline void kmemleak_free_part(const void *ptr, size_t size)
95{ 95{
96} 96}
97static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 97static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags)
98{ 98{
99} 99}
100static inline void kmemleak_free_percpu(const void __percpu *ptr) 100static inline void kmemleak_free_percpu(const void __percpu *ptr)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index bae11c7e7bf3..7ed0f7782d16 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -237,6 +237,22 @@ unsigned long memblock_next_valid_pfn(unsigned long pfn, unsigned long max_pfn);
237 for_each_mem_range_rev(i, &memblock.memory, &memblock.reserved, \ 237 for_each_mem_range_rev(i, &memblock.memory, &memblock.reserved, \
238 nid, flags, p_start, p_end, p_nid) 238 nid, flags, p_start, p_end, p_nid)
239 239
240/**
241 * for_each_resv_unavail_range - iterate through reserved and unavailable memory
242 * @i: u64 used as loop variable
243 * @flags: pick from blocks based on memory attributes
244 * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
245 * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
246 *
247 * Walks over unavailable but reserved (reserved && !memory) areas of memblock.
248 * Available as soon as memblock is initialized.
249 * Note: because this memory does not belong to any physical node, flags and
250 * nid arguments do not make sense and thus not exported as arguments.
251 */
252#define for_each_resv_unavail_range(i, p_start, p_end) \
253 for_each_mem_range(i, &memblock.reserved, &memblock.memory, \
254 NUMA_NO_NODE, MEMBLOCK_NONE, p_start, p_end, NULL)
255
240static inline void memblock_set_region_flags(struct memblock_region *r, 256static inline void memblock_set_region_flags(struct memblock_region *r,
241 unsigned long flags) 257 unsigned long flags)
242{ 258{
@@ -389,10 +405,10 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
389 region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \ 405 region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
390 region++) 406 region++)
391 407
392#define for_each_memblock_type(memblock_type, rgn) \ 408#define for_each_memblock_type(i, memblock_type, rgn) \
393 for (idx = 0, rgn = &memblock_type->regions[0]; \ 409 for (i = 0, rgn = &memblock_type->regions[0]; \
394 idx < memblock_type->cnt; \ 410 i < memblock_type->cnt; \
395 idx++, rgn = &memblock_type->regions[idx]) 411 i++, rgn = &memblock_type->regions[i])
396 412
397#ifdef CONFIG_MEMTEST 413#ifdef CONFIG_MEMTEST
398extern void early_memtest(phys_addr_t start, phys_addr_t end); 414extern void early_memtest(phys_addr_t start, phys_addr_t end);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 91b46f99b4d2..c7b1d617dff6 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -96,6 +96,15 @@ extern int mmap_rnd_compat_bits __read_mostly;
96#endif 96#endif
97 97
98/* 98/*
99 * On some architectures it is expensive to call memset() for small sizes.
100 * Those architectures should provide their own implementation of "struct page"
101 * zeroing by defining this macro in <asm/pgtable.h>.
102 */
103#ifndef mm_zero_struct_page
104#define mm_zero_struct_page(pp) ((void)memset((pp), 0, sizeof(struct page)))
105#endif
106
107/*
99 * Default maximum number of active map areas, this limits the number of vmas 108 * Default maximum number of active map areas, this limits the number of vmas
100 * per mm struct. Users can overwrite this number by sysctl but there is a 109 * per mm struct. Users can overwrite this number by sysctl but there is a
101 * problem. 110 * problem.
@@ -1431,7 +1440,13 @@ void account_page_cleaned(struct page *page, struct address_space *mapping,
1431 struct bdi_writeback *wb); 1440 struct bdi_writeback *wb);
1432int set_page_dirty(struct page *page); 1441int set_page_dirty(struct page *page);
1433int set_page_dirty_lock(struct page *page); 1442int set_page_dirty_lock(struct page *page);
1434void cancel_dirty_page(struct page *page); 1443void __cancel_dirty_page(struct page *page);
1444static inline void cancel_dirty_page(struct page *page)
1445{
1446 /* Avoid atomic ops, locking, etc. when not actually needed. */
1447 if (PageDirty(page))
1448 __cancel_dirty_page(page);
1449}
1435int clear_page_dirty_for_io(struct page *page); 1450int clear_page_dirty_for_io(struct page *page);
1436 1451
1437int get_cmdline(struct task_struct *task, char *buffer, int buflen); 1452int get_cmdline(struct task_struct *task, char *buffer, int buflen);
@@ -1599,26 +1614,32 @@ static inline int __p4d_alloc(struct mm_struct *mm, pgd_t *pgd,
1599int __p4d_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address); 1614int __p4d_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
1600#endif 1615#endif
1601 1616
1602#ifdef __PAGETABLE_PUD_FOLDED 1617#if defined(__PAGETABLE_PUD_FOLDED) || !defined(CONFIG_MMU)
1603static inline int __pud_alloc(struct mm_struct *mm, p4d_t *p4d, 1618static inline int __pud_alloc(struct mm_struct *mm, p4d_t *p4d,
1604 unsigned long address) 1619 unsigned long address)
1605{ 1620{
1606 return 0; 1621 return 0;
1607} 1622}
1623static inline void mm_inc_nr_puds(struct mm_struct *mm) {}
1624static inline void mm_dec_nr_puds(struct mm_struct *mm) {}
1625
1608#else 1626#else
1609int __pud_alloc(struct mm_struct *mm, p4d_t *p4d, unsigned long address); 1627int __pud_alloc(struct mm_struct *mm, p4d_t *p4d, unsigned long address);
1610#endif
1611 1628
1612#if defined(__PAGETABLE_PMD_FOLDED) || !defined(CONFIG_MMU) 1629static inline void mm_inc_nr_puds(struct mm_struct *mm)
1613static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
1614 unsigned long address)
1615{ 1630{
1616 return 0; 1631 atomic_long_add(PTRS_PER_PUD * sizeof(pud_t), &mm->pgtables_bytes);
1617} 1632}
1618 1633
1619static inline void mm_nr_pmds_init(struct mm_struct *mm) {} 1634static inline void mm_dec_nr_puds(struct mm_struct *mm)
1635{
1636 atomic_long_sub(PTRS_PER_PUD * sizeof(pud_t), &mm->pgtables_bytes);
1637}
1638#endif
1620 1639
1621static inline unsigned long mm_nr_pmds(struct mm_struct *mm) 1640#if defined(__PAGETABLE_PMD_FOLDED) || !defined(CONFIG_MMU)
1641static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
1642 unsigned long address)
1622{ 1643{
1623 return 0; 1644 return 0;
1624} 1645}
@@ -1629,25 +1650,47 @@ static inline void mm_dec_nr_pmds(struct mm_struct *mm) {}
1629#else 1650#else
1630int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address); 1651int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
1631 1652
1632static inline void mm_nr_pmds_init(struct mm_struct *mm) 1653static inline void mm_inc_nr_pmds(struct mm_struct *mm)
1633{ 1654{
1634 atomic_long_set(&mm->nr_pmds, 0); 1655 atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
1635} 1656}
1636 1657
1637static inline unsigned long mm_nr_pmds(struct mm_struct *mm) 1658static inline void mm_dec_nr_pmds(struct mm_struct *mm)
1638{ 1659{
1639 return atomic_long_read(&mm->nr_pmds); 1660 atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes);
1640} 1661}
1662#endif
1641 1663
1642static inline void mm_inc_nr_pmds(struct mm_struct *mm) 1664#ifdef CONFIG_MMU
1665static inline void mm_pgtables_bytes_init(struct mm_struct *mm)
1643{ 1666{
1644 atomic_long_inc(&mm->nr_pmds); 1667 atomic_long_set(&mm->pgtables_bytes, 0);
1645} 1668}
1646 1669
1647static inline void mm_dec_nr_pmds(struct mm_struct *mm) 1670static inline unsigned long mm_pgtables_bytes(const struct mm_struct *mm)
1671{
1672 return atomic_long_read(&mm->pgtables_bytes);
1673}
1674
1675static inline void mm_inc_nr_ptes(struct mm_struct *mm)
1676{
1677 atomic_long_add(PTRS_PER_PTE * sizeof(pte_t), &mm->pgtables_bytes);
1678}
1679
1680static inline void mm_dec_nr_ptes(struct mm_struct *mm)
1648{ 1681{
1649 atomic_long_dec(&mm->nr_pmds); 1682 atomic_long_sub(PTRS_PER_PTE * sizeof(pte_t), &mm->pgtables_bytes);
1650} 1683}
1684#else
1685
1686static inline void mm_pgtables_bytes_init(struct mm_struct *mm) {}
1687static inline unsigned long mm_pgtables_bytes(const struct mm_struct *mm)
1688{
1689 return 0;
1690}
1691
1692static inline void mm_inc_nr_ptes(struct mm_struct *mm) {}
1693static inline void mm_dec_nr_ptes(struct mm_struct *mm) {}
1651#endif 1694#endif
1652 1695
1653int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address); 1696int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address);
@@ -2002,6 +2045,12 @@ extern int __meminit __early_pfn_to_nid(unsigned long pfn,
2002 struct mminit_pfnnid_cache *state); 2045 struct mminit_pfnnid_cache *state);
2003#endif 2046#endif
2004 2047
2048#ifdef CONFIG_HAVE_MEMBLOCK
2049void zero_resv_unavail(void);
2050#else
2051static inline void zero_resv_unavail(void) {}
2052#endif
2053
2005extern void set_dma_reserve(unsigned long new_dma_reserve); 2054extern void set_dma_reserve(unsigned long new_dma_reserve);
2006extern void memmap_init_zone(unsigned long, int, unsigned long, 2055extern void memmap_init_zone(unsigned long, int, unsigned long,
2007 unsigned long, enum memmap_context); 2056 unsigned long, enum memmap_context);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index c85f11dafd56..cfd0ac4e5e0e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -48,8 +48,10 @@ struct page {
48 * inode address_space, or NULL. 48 * inode address_space, or NULL.
49 * If page mapped as anonymous 49 * If page mapped as anonymous
50 * memory, low bit is set, and 50 * memory, low bit is set, and
51 * it points to anon_vma object: 51 * it points to anon_vma object
52 * see PAGE_MAPPING_ANON below. 52 * or KSM private structure. See
53 * PAGE_MAPPING_ANON and
54 * PAGE_MAPPING_KSM.
53 */ 55 */
54 void *s_mem; /* slab first object */ 56 void *s_mem; /* slab first object */
55 atomic_t compound_mapcount; /* first tail page */ 57 atomic_t compound_mapcount; /* first tail page */
@@ -207,14 +209,6 @@ struct page {
207 not kmapped, ie. highmem) */ 209 not kmapped, ie. highmem) */
208#endif /* WANT_PAGE_VIRTUAL */ 210#endif /* WANT_PAGE_VIRTUAL */
209 211
210#ifdef CONFIG_KMEMCHECK
211 /*
212 * kmemcheck wants to track the status of each byte in a page; this
213 * is a pointer to such a status block. NULL if not tracked.
214 */
215 void *shadow;
216#endif
217
218#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS 212#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
219 int _last_cpupid; 213 int _last_cpupid;
220#endif 214#endif
@@ -399,9 +393,8 @@ struct mm_struct {
399 */ 393 */
400 atomic_t mm_count; 394 atomic_t mm_count;
401 395
402 atomic_long_t nr_ptes; /* PTE page table pages */ 396#ifdef CONFIG_MMU
403#if CONFIG_PGTABLE_LEVELS > 2 397 atomic_long_t pgtables_bytes; /* PTE page table pages */
404 atomic_long_t nr_pmds; /* PMD page table pages */
405#endif 398#endif
406 int map_count; /* number of VMAs */ 399 int map_count; /* number of VMAs */
407 400
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
index 2cf1c3c807f6..b25dc9db19fc 100644
--- a/include/linux/mmu_notifier.h
+++ b/include/linux/mmu_notifier.h
@@ -156,7 +156,8 @@ struct mmu_notifier_ops {
156 * shared page-tables, it not necessary to implement the 156 * shared page-tables, it not necessary to implement the
157 * invalidate_range_start()/end() notifiers, as 157 * invalidate_range_start()/end() notifiers, as
158 * invalidate_range() alread catches the points in time when an 158 * invalidate_range() alread catches the points in time when an
159 * external TLB range needs to be flushed. 159 * external TLB range needs to be flushed. For more in depth
160 * discussion on this see Documentation/vm/mmu_notifier.txt
160 * 161 *
161 * The invalidate_range() function is called under the ptl 162 * The invalidate_range() function is called under the ptl
162 * spin-lock and not allowed to sleep. 163 * spin-lock and not allowed to sleep.
@@ -213,7 +214,8 @@ extern void __mmu_notifier_change_pte(struct mm_struct *mm,
213extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm, 214extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
214 unsigned long start, unsigned long end); 215 unsigned long start, unsigned long end);
215extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm, 216extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm,
216 unsigned long start, unsigned long end); 217 unsigned long start, unsigned long end,
218 bool only_end);
217extern void __mmu_notifier_invalidate_range(struct mm_struct *mm, 219extern void __mmu_notifier_invalidate_range(struct mm_struct *mm,
218 unsigned long start, unsigned long end); 220 unsigned long start, unsigned long end);
219 221
@@ -267,7 +269,14 @@ static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm,
267 unsigned long start, unsigned long end) 269 unsigned long start, unsigned long end)
268{ 270{
269 if (mm_has_notifiers(mm)) 271 if (mm_has_notifiers(mm))
270 __mmu_notifier_invalidate_range_end(mm, start, end); 272 __mmu_notifier_invalidate_range_end(mm, start, end, false);
273}
274
275static inline void mmu_notifier_invalidate_range_only_end(struct mm_struct *mm,
276 unsigned long start, unsigned long end)
277{
278 if (mm_has_notifiers(mm))
279 __mmu_notifier_invalidate_range_end(mm, start, end, true);
271} 280}
272 281
273static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, 282static inline void mmu_notifier_invalidate_range(struct mm_struct *mm,
@@ -438,6 +447,11 @@ static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm,
438{ 447{
439} 448}
440 449
450static inline void mmu_notifier_invalidate_range_only_end(struct mm_struct *mm,
451 unsigned long start, unsigned long end)
452{
453}
454
441static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, 455static inline void mmu_notifier_invalidate_range(struct mm_struct *mm,
442 unsigned long start, unsigned long end) 456 unsigned long start, unsigned long end)
443{ 457{
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index a507f43ad221..67f2e3c38939 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -700,7 +700,8 @@ typedef struct pglist_data {
700 * is the first PFN that needs to be initialised. 700 * is the first PFN that needs to be initialised.
701 */ 701 */
702 unsigned long first_deferred_pfn; 702 unsigned long first_deferred_pfn;
703 unsigned long static_init_size; 703 /* Number of non-deferred pages */
704 unsigned long static_init_pgcnt;
704#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ 705#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
705 706
706#ifdef CONFIG_TRANSPARENT_HUGEPAGE 707#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -712,12 +713,6 @@ typedef struct pglist_data {
712 /* Fields commonly accessed by the page reclaim scanner */ 713 /* Fields commonly accessed by the page reclaim scanner */
713 struct lruvec lruvec; 714 struct lruvec lruvec;
714 715
715 /*
716 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
717 * this node's LRU. Maintained by the pageout code.
718 */
719 unsigned int inactive_ratio;
720
721 unsigned long flags; 716 unsigned long flags;
722 717
723 ZONE_PADDING(_pad2_) 718 ZONE_PADDING(_pad2_)
diff --git a/include/linux/net.h b/include/linux/net.h
index d97d80d7fdf8..caeb159abda5 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -22,7 +22,6 @@
22#include <linux/random.h> 22#include <linux/random.h>
23#include <linux/wait.h> 23#include <linux/wait.h>
24#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */ 24#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */
25#include <linux/kmemcheck.h>
26#include <linux/rcupdate.h> 25#include <linux/rcupdate.h>
27#include <linux/once.h> 26#include <linux/once.h>
28#include <linux/fs.h> 27#include <linux/fs.h>
@@ -111,9 +110,7 @@ struct socket_wq {
111struct socket { 110struct socket {
112 socket_state state; 111 socket_state state;
113 112
114 kmemcheck_bitfield_begin(type);
115 short type; 113 short type;
116 kmemcheck_bitfield_end(type);
117 114
118 unsigned long flags; 115 unsigned long flags;
119 116
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index de1c50b93c61..15cab3967d6d 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -104,7 +104,9 @@ extern nodemask_t _unused_nodemask_arg_;
104 * 104 *
105 * Can be used to provide arguments for '%*pb[l]' when printing a nodemask. 105 * Can be used to provide arguments for '%*pb[l]' when printing a nodemask.
106 */ 106 */
107#define nodemask_pr_args(maskp) MAX_NUMNODES, (maskp)->bits 107#define nodemask_pr_args(maskp) \
108 ((maskp) != NULL) ? MAX_NUMNODES : 0, \
109 ((maskp) != NULL) ? (maskp)->bits : NULL
108 110
109/* 111/*
110 * The inline keyword gives the compiler room to decide to inline, or 112 * The inline keyword gives the compiler room to decide to inline, or
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 584b14c774c1..3ec44e27aa9d 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -18,7 +18,7 @@
18 * Various page->flags bits: 18 * Various page->flags bits:
19 * 19 *
20 * PG_reserved is set for special pages, which can never be swapped out. Some 20 * PG_reserved is set for special pages, which can never be swapped out. Some
21 * of them might not even exist (eg empty_bad_page)... 21 * of them might not even exist...
22 * 22 *
23 * The PG_private bitflag is set on pagecache pages if they contain filesystem 23 * The PG_private bitflag is set on pagecache pages if they contain filesystem
24 * specific data (which is normally at page->private). It can be used by 24 * specific data (which is normally at page->private). It can be used by
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 05a04e603686..cdad58bbfd8b 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -31,7 +31,7 @@ static inline bool is_migrate_isolate(int migratetype)
31#endif 31#endif
32 32
33bool has_unmovable_pages(struct zone *zone, struct page *page, int count, 33bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
34 bool skip_hwpoisoned_pages); 34 int migratetype, bool skip_hwpoisoned_pages);
35void set_pageblock_migratetype(struct page *page, int migratetype); 35void set_pageblock_migratetype(struct page *page, int migratetype);
36int move_freepages_block(struct zone *zone, struct page *page, 36int move_freepages_block(struct zone *zone, struct page *page,
37 int migratetype, int *num_movable); 37 int migratetype, int *num_movable);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index e08b5339023c..34ce3ebf97d5 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -16,6 +16,8 @@
16#include <linux/hardirq.h> /* for in_interrupt() */ 16#include <linux/hardirq.h> /* for in_interrupt() */
17#include <linux/hugetlb_inline.h> 17#include <linux/hugetlb_inline.h>
18 18
19struct pagevec;
20
19/* 21/*
20 * Bits in mapping->flags. 22 * Bits in mapping->flags.
21 */ 23 */
@@ -116,7 +118,7 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
116 m->gfp_mask = mask; 118 m->gfp_mask = mask;
117} 119}
118 120
119void release_pages(struct page **pages, int nr, bool cold); 121void release_pages(struct page **pages, int nr);
120 122
121/* 123/*
122 * speculatively take a reference to a page. 124 * speculatively take a reference to a page.
@@ -232,15 +234,9 @@ static inline struct page *page_cache_alloc(struct address_space *x)
232 return __page_cache_alloc(mapping_gfp_mask(x)); 234 return __page_cache_alloc(mapping_gfp_mask(x));
233} 235}
234 236
235static inline struct page *page_cache_alloc_cold(struct address_space *x)
236{
237 return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD);
238}
239
240static inline gfp_t readahead_gfp_mask(struct address_space *x) 237static inline gfp_t readahead_gfp_mask(struct address_space *x)
241{ 238{
242 return mapping_gfp_mask(x) | 239 return mapping_gfp_mask(x) | __GFP_NORETRY | __GFP_NOWARN;
243 __GFP_COLD | __GFP_NORETRY | __GFP_NOWARN;
244} 240}
245 241
246typedef int filler_t(void *, struct page *); 242typedef int filler_t(void *, struct page *);
@@ -366,8 +362,16 @@ static inline unsigned find_get_pages(struct address_space *mapping,
366} 362}
367unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start, 363unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
368 unsigned int nr_pages, struct page **pages); 364 unsigned int nr_pages, struct page **pages);
369unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, 365unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index,
370 int tag, unsigned int nr_pages, struct page **pages); 366 pgoff_t end, int tag, unsigned int nr_pages,
367 struct page **pages);
368static inline unsigned find_get_pages_tag(struct address_space *mapping,
369 pgoff_t *index, int tag, unsigned int nr_pages,
370 struct page **pages)
371{
372 return find_get_pages_range_tag(mapping, index, (pgoff_t)-1, tag,
373 nr_pages, pages);
374}
371unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start, 375unsigned find_get_entries_tag(struct address_space *mapping, pgoff_t start,
372 int tag, unsigned int nr_entries, 376 int tag, unsigned int nr_entries,
373 struct page **entries, pgoff_t *indices); 377 struct page **entries, pgoff_t *indices);
@@ -616,6 +620,8 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
616extern void delete_from_page_cache(struct page *page); 620extern void delete_from_page_cache(struct page *page);
617extern void __delete_from_page_cache(struct page *page, void *shadow); 621extern void __delete_from_page_cache(struct page *page, void *shadow);
618int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask); 622int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
623void delete_from_page_cache_batch(struct address_space *mapping,
624 struct pagevec *pvec);
619 625
620/* 626/*
621 * Like add_to_page_cache_locked, but used to add newly allocated pages: 627 * Like add_to_page_cache_locked, but used to add newly allocated pages:
diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
index 2636c0c0f279..5fb6580f7f23 100644
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -17,7 +17,7 @@ struct address_space;
17 17
18struct pagevec { 18struct pagevec {
19 unsigned long nr; 19 unsigned long nr;
20 unsigned long cold; 20 bool percpu_pvec_drained;
21 struct page *pages[PAGEVEC_SIZE]; 21 struct page *pages[PAGEVEC_SIZE];
22}; 22};
23 23
@@ -38,14 +38,22 @@ static inline unsigned pagevec_lookup(struct pagevec *pvec,
38 return pagevec_lookup_range(pvec, mapping, start, (pgoff_t)-1); 38 return pagevec_lookup_range(pvec, mapping, start, (pgoff_t)-1);
39} 39}
40 40
41unsigned pagevec_lookup_tag(struct pagevec *pvec, 41unsigned pagevec_lookup_range_tag(struct pagevec *pvec,
42 struct address_space *mapping, pgoff_t *index, int tag, 42 struct address_space *mapping, pgoff_t *index, pgoff_t end,
43 unsigned nr_pages); 43 int tag);
44unsigned pagevec_lookup_range_nr_tag(struct pagevec *pvec,
45 struct address_space *mapping, pgoff_t *index, pgoff_t end,
46 int tag, unsigned max_pages);
47static inline unsigned pagevec_lookup_tag(struct pagevec *pvec,
48 struct address_space *mapping, pgoff_t *index, int tag)
49{
50 return pagevec_lookup_range_tag(pvec, mapping, index, (pgoff_t)-1, tag);
51}
44 52
45static inline void pagevec_init(struct pagevec *pvec, int cold) 53static inline void pagevec_init(struct pagevec *pvec)
46{ 54{
47 pvec->nr = 0; 55 pvec->nr = 0;
48 pvec->cold = cold; 56 pvec->percpu_pvec_drained = false;
49} 57}
50 58
51static inline void pagevec_reinit(struct pagevec *pvec) 59static inline void pagevec_reinit(struct pagevec *pvec)
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 567ebb5eaab0..0ca448c1cb42 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -301,18 +301,17 @@ void *__radix_tree_lookup(const struct radix_tree_root *, unsigned long index,
301void *radix_tree_lookup(const struct radix_tree_root *, unsigned long); 301void *radix_tree_lookup(const struct radix_tree_root *, unsigned long);
302void __rcu **radix_tree_lookup_slot(const struct radix_tree_root *, 302void __rcu **radix_tree_lookup_slot(const struct radix_tree_root *,
303 unsigned long index); 303 unsigned long index);
304typedef void (*radix_tree_update_node_t)(struct radix_tree_node *, void *); 304typedef void (*radix_tree_update_node_t)(struct radix_tree_node *);
305void __radix_tree_replace(struct radix_tree_root *, struct radix_tree_node *, 305void __radix_tree_replace(struct radix_tree_root *, struct radix_tree_node *,
306 void __rcu **slot, void *entry, 306 void __rcu **slot, void *entry,
307 radix_tree_update_node_t update_node, void *private); 307 radix_tree_update_node_t update_node);
308void radix_tree_iter_replace(struct radix_tree_root *, 308void radix_tree_iter_replace(struct radix_tree_root *,
309 const struct radix_tree_iter *, void __rcu **slot, void *entry); 309 const struct radix_tree_iter *, void __rcu **slot, void *entry);
310void radix_tree_replace_slot(struct radix_tree_root *, 310void radix_tree_replace_slot(struct radix_tree_root *,
311 void __rcu **slot, void *entry); 311 void __rcu **slot, void *entry);
312void __radix_tree_delete_node(struct radix_tree_root *, 312void __radix_tree_delete_node(struct radix_tree_root *,
313 struct radix_tree_node *, 313 struct radix_tree_node *,
314 radix_tree_update_node_t update_node, 314 radix_tree_update_node_t update_node);
315 void *private);
316void radix_tree_iter_delete(struct radix_tree_root *, 315void radix_tree_iter_delete(struct radix_tree_root *,
317 struct radix_tree_iter *iter, void __rcu **slot); 316 struct radix_tree_iter *iter, void __rcu **slot);
318void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *); 317void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *);
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index fa6ace66fea5..289e4d54e3e0 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -2,7 +2,6 @@
2#ifndef _LINUX_RING_BUFFER_H 2#ifndef _LINUX_RING_BUFFER_H
3#define _LINUX_RING_BUFFER_H 3#define _LINUX_RING_BUFFER_H
4 4
5#include <linux/kmemcheck.h>
6#include <linux/mm.h> 5#include <linux/mm.h>
7#include <linux/seq_file.h> 6#include <linux/seq_file.h>
8#include <linux/poll.h> 7#include <linux/poll.h>
@@ -14,9 +13,7 @@ struct ring_buffer_iter;
14 * Don't refer to this struct directly, use functions below. 13 * Don't refer to this struct directly, use functions below.
15 */ 14 */
16struct ring_buffer_event { 15struct ring_buffer_event {
17 kmemcheck_bitfield_begin(bitfield);
18 u32 type_len:5, time_delta:27; 16 u32 type_len:5, time_delta:27;
19 kmemcheck_bitfield_end(bitfield);
20 17
21 u32 array[]; 18 u32 array[];
22}; 19};
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 54fe91183a8e..ed06e1c28fc7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -15,7 +15,6 @@
15#define _LINUX_SKBUFF_H 15#define _LINUX_SKBUFF_H
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/kmemcheck.h>
19#include <linux/compiler.h> 18#include <linux/compiler.h>
20#include <linux/time.h> 19#include <linux/time.h>
21#include <linux/bug.h> 20#include <linux/bug.h>
@@ -711,7 +710,6 @@ struct sk_buff {
711 /* Following fields are _not_ copied in __copy_skb_header() 710 /* Following fields are _not_ copied in __copy_skb_header()
712 * Note that queue_mapping is here mostly to fill a hole. 711 * Note that queue_mapping is here mostly to fill a hole.
713 */ 712 */
714 kmemcheck_bitfield_begin(flags1);
715 __u16 queue_mapping; 713 __u16 queue_mapping;
716 714
717/* if you move cloned around you also must adapt those constants */ 715/* if you move cloned around you also must adapt those constants */
@@ -730,7 +728,6 @@ struct sk_buff {
730 head_frag:1, 728 head_frag:1,
731 xmit_more:1, 729 xmit_more:1,
732 __unused:1; /* one bit hole */ 730 __unused:1; /* one bit hole */
733 kmemcheck_bitfield_end(flags1);
734 731
735 /* fields enclosed in headers_start/headers_end are copied 732 /* fields enclosed in headers_start/headers_end are copied
736 * using a single memcpy() in __copy_skb_header() 733 * using a single memcpy() in __copy_skb_header()
@@ -2664,7 +2661,7 @@ static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,
2664 * 4. __GFP_MEMALLOC is ignored if __GFP_NOMEMALLOC is set due to 2661 * 4. __GFP_MEMALLOC is ignored if __GFP_NOMEMALLOC is set due to
2665 * code in gfp_to_alloc_flags that should be enforcing this. 2662 * code in gfp_to_alloc_flags that should be enforcing this.
2666 */ 2663 */
2667 gfp_mask |= __GFP_COLD | __GFP_COMP | __GFP_MEMALLOC; 2664 gfp_mask |= __GFP_COMP | __GFP_MEMALLOC;
2668 2665
2669 return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order); 2666 return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
2670} 2667}
diff --git a/include/linux/slab.h b/include/linux/slab.h
index af5aa65c7c18..50697a1d6621 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -21,13 +21,20 @@
21 * Flags to pass to kmem_cache_create(). 21 * Flags to pass to kmem_cache_create().
22 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set. 22 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
23 */ 23 */
24#define SLAB_CONSISTENCY_CHECKS 0x00000100UL /* DEBUG: Perform (expensive) checks on alloc/free */ 24/* DEBUG: Perform (expensive) checks on alloc/free */
25#define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */ 25#define SLAB_CONSISTENCY_CHECKS ((slab_flags_t __force)0x00000100U)
26#define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */ 26/* DEBUG: Red zone objs in a cache */
27#define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */ 27#define SLAB_RED_ZONE ((slab_flags_t __force)0x00000400U)
28#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ 28/* DEBUG: Poison objects */
29#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ 29#define SLAB_POISON ((slab_flags_t __force)0x00000800U)
30#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ 30/* Align objs on cache lines */
31#define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U)
32/* Use GFP_DMA memory */
33#define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U)
34/* DEBUG: Store the last owner for bug hunting */
35#define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U)
36/* Panic if kmem_cache_create() fails */
37#define SLAB_PANIC ((slab_flags_t __force)0x00040000U)
31/* 38/*
32 * SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS! 39 * SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS!
33 * 40 *
@@ -65,44 +72,45 @@
65 * 72 *
66 * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU. 73 * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU.
67 */ 74 */
68#define SLAB_TYPESAFE_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ 75/* Defer freeing slabs to RCU */
69#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 76#define SLAB_TYPESAFE_BY_RCU ((slab_flags_t __force)0x00080000U)
70#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 77/* Spread some memory over cpuset */
78#define SLAB_MEM_SPREAD ((slab_flags_t __force)0x00100000U)
79/* Trace allocations and frees */
80#define SLAB_TRACE ((slab_flags_t __force)0x00200000U)
71 81
72/* Flag to prevent checks on free */ 82/* Flag to prevent checks on free */
73#ifdef CONFIG_DEBUG_OBJECTS 83#ifdef CONFIG_DEBUG_OBJECTS
74# define SLAB_DEBUG_OBJECTS 0x00400000UL 84# define SLAB_DEBUG_OBJECTS ((slab_flags_t __force)0x00400000U)
75#else 85#else
76# define SLAB_DEBUG_OBJECTS 0x00000000UL 86# define SLAB_DEBUG_OBJECTS 0
77#endif 87#endif
78 88
79#define SLAB_NOLEAKTRACE 0x00800000UL /* Avoid kmemleak tracing */ 89/* Avoid kmemleak tracing */
90#define SLAB_NOLEAKTRACE ((slab_flags_t __force)0x00800000U)
80 91
81/* Don't track use of uninitialized memory */ 92/* Fault injection mark */
82#ifdef CONFIG_KMEMCHECK
83# define SLAB_NOTRACK 0x01000000UL
84#else
85# define SLAB_NOTRACK 0x00000000UL
86#endif
87#ifdef CONFIG_FAILSLAB 93#ifdef CONFIG_FAILSLAB
88# define SLAB_FAILSLAB 0x02000000UL /* Fault injection mark */ 94# define SLAB_FAILSLAB ((slab_flags_t __force)0x02000000U)
89#else 95#else
90# define SLAB_FAILSLAB 0x00000000UL 96# define SLAB_FAILSLAB 0
91#endif 97#endif
98/* Account to memcg */
92#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) 99#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
93# define SLAB_ACCOUNT 0x04000000UL /* Account to memcg */ 100# define SLAB_ACCOUNT ((slab_flags_t __force)0x04000000U)
94#else 101#else
95# define SLAB_ACCOUNT 0x00000000UL 102# define SLAB_ACCOUNT 0
96#endif 103#endif
97 104
98#ifdef CONFIG_KASAN 105#ifdef CONFIG_KASAN
99#define SLAB_KASAN 0x08000000UL 106#define SLAB_KASAN ((slab_flags_t __force)0x08000000U)
100#else 107#else
101#define SLAB_KASAN 0x00000000UL 108#define SLAB_KASAN 0
102#endif 109#endif
103 110
104/* The following flags affect the page allocator grouping pages by mobility */ 111/* The following flags affect the page allocator grouping pages by mobility */
105#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 112/* Objects are reclaimable */
113#define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0x00020000U)
106#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ 114#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
107/* 115/*
108 * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. 116 * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
@@ -128,7 +136,7 @@ void __init kmem_cache_init(void);
128bool slab_is_available(void); 136bool slab_is_available(void);
129 137
130struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, 138struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
131 unsigned long, 139 slab_flags_t,
132 void (*)(void *)); 140 void (*)(void *));
133void kmem_cache_destroy(struct kmem_cache *); 141void kmem_cache_destroy(struct kmem_cache *);
134int kmem_cache_shrink(struct kmem_cache *); 142int kmem_cache_shrink(struct kmem_cache *);
@@ -459,9 +467,6 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
459 * Also it is possible to set different flags by OR'ing 467 * Also it is possible to set different flags by OR'ing
460 * in one or more of the following additional @flags: 468 * in one or more of the following additional @flags:
461 * 469 *
462 * %__GFP_COLD - Request cache-cold pages instead of
463 * trying to return cache-warm pages.
464 *
465 * %__GFP_HIGH - This allocation has high priority and may use emergency pools. 470 * %__GFP_HIGH - This allocation has high priority and may use emergency pools.
466 * 471 *
467 * %__GFP_NOFAIL - Indicate that this allocation is in no way allowed to fail 472 * %__GFP_NOFAIL - Indicate that this allocation is in no way allowed to fail
@@ -636,6 +641,22 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
636#define kmalloc_track_caller(size, flags) \ 641#define kmalloc_track_caller(size, flags) \
637 __kmalloc_track_caller(size, flags, _RET_IP_) 642 __kmalloc_track_caller(size, flags, _RET_IP_)
638 643
644static inline void *kmalloc_array_node(size_t n, size_t size, gfp_t flags,
645 int node)
646{
647 if (size != 0 && n > SIZE_MAX / size)
648 return NULL;
649 if (__builtin_constant_p(n) && __builtin_constant_p(size))
650 return kmalloc_node(n * size, flags, node);
651 return __kmalloc_node(n * size, flags, node);
652}
653
654static inline void *kcalloc_node(size_t n, size_t size, gfp_t flags, int node)
655{
656 return kmalloc_array_node(n, size, flags | __GFP_ZERO, node);
657}
658
659
639#ifdef CONFIG_NUMA 660#ifdef CONFIG_NUMA
640extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long); 661extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
641#define kmalloc_node_track_caller(size, flags, node) \ 662#define kmalloc_node_track_caller(size, flags, node) \
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 8f7d2b1656d2..072e46e9e1d5 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -20,7 +20,7 @@ struct kmem_cache {
20 struct reciprocal_value reciprocal_buffer_size; 20 struct reciprocal_value reciprocal_buffer_size;
21/* 2) touched by every alloc & free from the backend */ 21/* 2) touched by every alloc & free from the backend */
22 22
23 unsigned int flags; /* constant flags */ 23 slab_flags_t flags; /* constant flags */
24 unsigned int num; /* # of objs per slab */ 24 unsigned int num; /* # of objs per slab */
25 25
26/* 3) cache_grow/shrink */ 26/* 3) cache_grow/shrink */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 39fa09bcde23..0adae162dc8f 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -82,7 +82,7 @@ struct kmem_cache_order_objects {
82struct kmem_cache { 82struct kmem_cache {
83 struct kmem_cache_cpu __percpu *cpu_slab; 83 struct kmem_cache_cpu __percpu *cpu_slab;
84 /* Used for retriving partial slabs etc */ 84 /* Used for retriving partial slabs etc */
85 unsigned long flags; 85 slab_flags_t flags;
86 unsigned long min_partial; 86 unsigned long min_partial;
87 int size; /* The size of an object including meta data */ 87 int size; /* The size of an object including meta data */
88 int object_size; /* The size of an object without meta data */ 88 int object_size; /* The size of an object without meta data */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index f02fb5db8914..c2b8128799c1 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -171,8 +171,9 @@ enum {
171 SWP_AREA_DISCARD = (1 << 8), /* single-time swap area discards */ 171 SWP_AREA_DISCARD = (1 << 8), /* single-time swap area discards */
172 SWP_PAGE_DISCARD = (1 << 9), /* freed swap page-cluster discards */ 172 SWP_PAGE_DISCARD = (1 << 9), /* freed swap page-cluster discards */
173 SWP_STABLE_WRITES = (1 << 10), /* no overwrite PG_writeback pages */ 173 SWP_STABLE_WRITES = (1 << 10), /* no overwrite PG_writeback pages */
174 SWP_SYNCHRONOUS_IO = (1 << 11), /* synchronous IO is efficient */
174 /* add others here before... */ 175 /* add others here before... */
175 SWP_SCANNING = (1 << 11), /* refcount in scan_swap_map */ 176 SWP_SCANNING = (1 << 12), /* refcount in scan_swap_map */
176}; 177};
177 178
178#define SWAP_CLUSTER_MAX 32UL 179#define SWAP_CLUSTER_MAX 32UL
@@ -297,7 +298,18 @@ struct vma_swap_readahead {
297void *workingset_eviction(struct address_space *mapping, struct page *page); 298void *workingset_eviction(struct address_space *mapping, struct page *page);
298bool workingset_refault(void *shadow); 299bool workingset_refault(void *shadow);
299void workingset_activation(struct page *page); 300void workingset_activation(struct page *page);
300void workingset_update_node(struct radix_tree_node *node, void *private); 301
302/* Do not use directly, use workingset_lookup_update */
303void workingset_update_node(struct radix_tree_node *node);
304
305/* Returns workingset_update_node() if the mapping has shadow entries. */
306#define workingset_lookup_update(mapping) \
307({ \
308 radix_tree_update_node_t __helper = workingset_update_node; \
309 if (dax_mapping(mapping) || shmem_mapping(mapping)) \
310 __helper = NULL; \
311 __helper; \
312})
301 313
302/* linux/mm/page_alloc.c */ 314/* linux/mm/page_alloc.c */
303extern unsigned long totalram_pages; 315extern unsigned long totalram_pages;
@@ -462,9 +474,11 @@ extern unsigned int count_swap_pages(int, int);
462extern sector_t map_swap_page(struct page *, struct block_device **); 474extern sector_t map_swap_page(struct page *, struct block_device **);
463extern sector_t swapdev_block(int, pgoff_t); 475extern sector_t swapdev_block(int, pgoff_t);
464extern int page_swapcount(struct page *); 476extern int page_swapcount(struct page *);
477extern int __swap_count(struct swap_info_struct *si, swp_entry_t entry);
465extern int __swp_swapcount(swp_entry_t entry); 478extern int __swp_swapcount(swp_entry_t entry);
466extern int swp_swapcount(swp_entry_t entry); 479extern int swp_swapcount(swp_entry_t entry);
467extern struct swap_info_struct *page_swap_info(struct page *); 480extern struct swap_info_struct *page_swap_info(struct page *);
481extern struct swap_info_struct *swp_swap_info(swp_entry_t entry);
468extern bool reuse_swap_page(struct page *, int *); 482extern bool reuse_swap_page(struct page *, int *);
469extern int try_to_free_swap(struct page *); 483extern int try_to_free_swap(struct page *);
470struct backing_dev_info; 484struct backing_dev_info;
@@ -473,6 +487,16 @@ extern void exit_swap_address_space(unsigned int type);
473 487
474#else /* CONFIG_SWAP */ 488#else /* CONFIG_SWAP */
475 489
490static inline int swap_readpage(struct page *page, bool do_poll)
491{
492 return 0;
493}
494
495static inline struct swap_info_struct *swp_swap_info(swp_entry_t entry)
496{
497 return NULL;
498}
499
476#define swap_address_space(entry) (NULL) 500#define swap_address_space(entry) (NULL)
477#define get_nr_swap_pages() 0L 501#define get_nr_swap_pages() 0L
478#define total_swap_pages 0L 502#define total_swap_pages 0L
@@ -486,7 +510,7 @@ extern void exit_swap_address_space(unsigned int type);
486#define free_page_and_swap_cache(page) \ 510#define free_page_and_swap_cache(page) \
487 put_page(page) 511 put_page(page)
488#define free_pages_and_swap_cache(pages, nr) \ 512#define free_pages_and_swap_cache(pages, nr) \
489 release_pages((pages), (nr), false); 513 release_pages((pages), (nr));
490 514
491static inline void show_swap_cache_info(void) 515static inline void show_swap_cache_info(void)
492{ 516{
@@ -577,6 +601,11 @@ static inline int page_swapcount(struct page *page)
577 return 0; 601 return 0;
578} 602}
579 603
604static inline int __swap_count(struct swap_info_struct *si, swp_entry_t entry)
605{
606 return 0;
607}
608
580static inline int __swp_swapcount(swp_entry_t entry) 609static inline int __swp_swapcount(swp_entry_t entry)
581{ 610{
582 return 0; 611 return 0;
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 4bcdf00c110f..34f053a150a9 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -44,10 +44,9 @@ enum {
44#endif 44#endif
45 45
46#if IS_ENABLED(CONFIG_DEBUG_STACK_USAGE) || IS_ENABLED(CONFIG_DEBUG_KMEMLEAK) 46#if IS_ENABLED(CONFIG_DEBUG_STACK_USAGE) || IS_ENABLED(CONFIG_DEBUG_KMEMLEAK)
47# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK | \ 47# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_ZERO)
48 __GFP_ZERO)
49#else 48#else
50# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK) 49# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT)
51#endif 50#endif
52 51
53/* 52/*
diff --git a/include/linux/types.h b/include/linux/types.h
index 34fce54e4f1b..c94d59ef96cc 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -156,6 +156,7 @@ typedef u32 dma_addr_t;
156#endif 156#endif
157 157
158typedef unsigned __bitwise gfp_t; 158typedef unsigned __bitwise gfp_t;
159typedef unsigned __bitwise slab_flags_t;
159typedef unsigned __bitwise fmode_t; 160typedef unsigned __bitwise fmode_t;
160 161
161#ifdef CONFIG_PHYS_ADDR_T_64BIT 162#ifdef CONFIG_PHYS_ADDR_T_64BIT
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 1e0cb72e0598..1779c9817b39 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -7,9 +7,19 @@
7#include <linux/mmzone.h> 7#include <linux/mmzone.h>
8#include <linux/vm_event_item.h> 8#include <linux/vm_event_item.h>
9#include <linux/atomic.h> 9#include <linux/atomic.h>
10#include <linux/static_key.h>
10 11
11extern int sysctl_stat_interval; 12extern int sysctl_stat_interval;
12 13
14#ifdef CONFIG_NUMA
15#define ENABLE_NUMA_STAT 1
16#define DISABLE_NUMA_STAT 0
17extern int sysctl_vm_numa_stat;
18DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
19extern int sysctl_vm_numa_stat_handler(struct ctl_table *table,
20 int write, void __user *buffer, size_t *length, loff_t *ppos);
21#endif
22
13#ifdef CONFIG_VM_EVENT_COUNTERS 23#ifdef CONFIG_VM_EVENT_COUNTERS
14/* 24/*
15 * Light weight per cpu counter implementation. 25 * Light weight per cpu counter implementation.
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 2135c9ba6ac3..39efb968b7a4 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -17,7 +17,6 @@
17#define _INET_SOCK_H 17#define _INET_SOCK_H
18 18
19#include <linux/bitops.h> 19#include <linux/bitops.h>
20#include <linux/kmemcheck.h>
21#include <linux/string.h> 20#include <linux/string.h>
22#include <linux/types.h> 21#include <linux/types.h>
23#include <linux/jhash.h> 22#include <linux/jhash.h>
@@ -84,7 +83,6 @@ struct inet_request_sock {
84#define ireq_state req.__req_common.skc_state 83#define ireq_state req.__req_common.skc_state
85#define ireq_family req.__req_common.skc_family 84#define ireq_family req.__req_common.skc_family
86 85
87 kmemcheck_bitfield_begin(flags);
88 u16 snd_wscale : 4, 86 u16 snd_wscale : 4,
89 rcv_wscale : 4, 87 rcv_wscale : 4,
90 tstamp_ok : 1, 88 tstamp_ok : 1,
@@ -94,7 +92,6 @@ struct inet_request_sock {
94 acked : 1, 92 acked : 1,
95 no_srccheck: 1, 93 no_srccheck: 1,
96 smc_ok : 1; 94 smc_ok : 1;
97 kmemcheck_bitfield_end(flags);
98 u32 ir_mark; 95 u32 ir_mark;
99 union { 96 union {
100 struct ip_options_rcu __rcu *ireq_opt; 97 struct ip_options_rcu __rcu *ireq_opt;
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 6a75d67a30fd..1356fa6a7566 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -15,8 +15,6 @@
15#ifndef _INET_TIMEWAIT_SOCK_ 15#ifndef _INET_TIMEWAIT_SOCK_
16#define _INET_TIMEWAIT_SOCK_ 16#define _INET_TIMEWAIT_SOCK_
17 17
18
19#include <linux/kmemcheck.h>
20#include <linux/list.h> 18#include <linux/list.h>
21#include <linux/timer.h> 19#include <linux/timer.h>
22#include <linux/types.h> 20#include <linux/types.h>
@@ -69,14 +67,12 @@ struct inet_timewait_sock {
69 /* Socket demultiplex comparisons on incoming packets. */ 67 /* Socket demultiplex comparisons on incoming packets. */
70 /* these three are in inet_sock */ 68 /* these three are in inet_sock */
71 __be16 tw_sport; 69 __be16 tw_sport;
72 kmemcheck_bitfield_begin(flags);
73 /* And these are ours. */ 70 /* And these are ours. */
74 unsigned int tw_kill : 1, 71 unsigned int tw_kill : 1,
75 tw_transparent : 1, 72 tw_transparent : 1,
76 tw_flowlabel : 20, 73 tw_flowlabel : 20,
77 tw_pad : 2, /* 2 bits hole */ 74 tw_pad : 2, /* 2 bits hole */
78 tw_tos : 8; 75 tw_tos : 8;
79 kmemcheck_bitfield_end(flags);
80 struct timer_list tw_timer; 76 struct timer_list tw_timer;
81 struct inet_bind_bucket *tw_tb; 77 struct inet_bind_bucket *tw_tb;
82}; 78};
diff --git a/include/net/sock.h b/include/net/sock.h
index f8715c5af37d..79e1a2c7912c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -440,7 +440,6 @@ struct sock {
440#define SK_FL_TYPE_MASK 0xffff0000 440#define SK_FL_TYPE_MASK 0xffff0000
441#endif 441#endif
442 442
443 kmemcheck_bitfield_begin(flags);
444 unsigned int sk_padding : 1, 443 unsigned int sk_padding : 1,
445 sk_kern_sock : 1, 444 sk_kern_sock : 1,
446 sk_no_check_tx : 1, 445 sk_no_check_tx : 1,
@@ -449,8 +448,6 @@ struct sock {
449 sk_protocol : 8, 448 sk_protocol : 8,
450 sk_type : 16; 449 sk_type : 16;
451#define SK_PROTOCOL_MAX U8_MAX 450#define SK_PROTOCOL_MAX U8_MAX
452 kmemcheck_bitfield_end(flags);
453
454 u16 sk_gso_max_segs; 451 u16 sk_gso_max_segs;
455 u8 sk_pacing_shift; 452 u8 sk_pacing_shift;
456 unsigned long sk_lingertime; 453 unsigned long sk_lingertime;
@@ -1114,7 +1111,7 @@ struct proto {
1114 1111
1115 struct kmem_cache *slab; 1112 struct kmem_cache *slab;
1116 unsigned int obj_size; 1113 unsigned int obj_size;
1117 int slab_flags; 1114 slab_flags_t slab_flags;
1118 1115
1119 struct percpu_counter *orphan_count; 1116 struct percpu_counter *orphan_count;
1120 1117
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 285feeadac39..eb57e3037deb 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -172,24 +172,21 @@ TRACE_EVENT(mm_page_free,
172 172
173TRACE_EVENT(mm_page_free_batched, 173TRACE_EVENT(mm_page_free_batched,
174 174
175 TP_PROTO(struct page *page, int cold), 175 TP_PROTO(struct page *page),
176 176
177 TP_ARGS(page, cold), 177 TP_ARGS(page),
178 178
179 TP_STRUCT__entry( 179 TP_STRUCT__entry(
180 __field( unsigned long, pfn ) 180 __field( unsigned long, pfn )
181 __field( int, cold )
182 ), 181 ),
183 182
184 TP_fast_assign( 183 TP_fast_assign(
185 __entry->pfn = page_to_pfn(page); 184 __entry->pfn = page_to_pfn(page);
186 __entry->cold = cold;
187 ), 185 ),
188 186
189 TP_printk("page=%p pfn=%lu order=0 cold=%d", 187 TP_printk("page=%p pfn=%lu order=0",
190 pfn_to_page(__entry->pfn), 188 pfn_to_page(__entry->pfn),
191 __entry->pfn, 189 __entry->pfn)
192 __entry->cold)
193); 190);
194 191
195TRACE_EVENT(mm_page_alloc, 192TRACE_EVENT(mm_page_alloc,
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 648cbf603736..dbe1bb058c09 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -32,7 +32,6 @@
32 {(unsigned long)__GFP_ATOMIC, "__GFP_ATOMIC"}, \ 32 {(unsigned long)__GFP_ATOMIC, "__GFP_ATOMIC"}, \
33 {(unsigned long)__GFP_IO, "__GFP_IO"}, \ 33 {(unsigned long)__GFP_IO, "__GFP_IO"}, \
34 {(unsigned long)__GFP_FS, "__GFP_FS"}, \ 34 {(unsigned long)__GFP_FS, "__GFP_FS"}, \
35 {(unsigned long)__GFP_COLD, "__GFP_COLD"}, \
36 {(unsigned long)__GFP_NOWARN, "__GFP_NOWARN"}, \ 35 {(unsigned long)__GFP_NOWARN, "__GFP_NOWARN"}, \
37 {(unsigned long)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \ 36 {(unsigned long)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \
38 {(unsigned long)__GFP_NOFAIL, "__GFP_NOFAIL"}, \ 37 {(unsigned long)__GFP_NOFAIL, "__GFP_NOFAIL"}, \
@@ -46,7 +45,6 @@
46 {(unsigned long)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \ 45 {(unsigned long)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \
47 {(unsigned long)__GFP_MOVABLE, "__GFP_MOVABLE"}, \ 46 {(unsigned long)__GFP_MOVABLE, "__GFP_MOVABLE"}, \
48 {(unsigned long)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \ 47 {(unsigned long)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \
49 {(unsigned long)__GFP_NOTRACK, "__GFP_NOTRACK"}, \
50 {(unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \ 48 {(unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \
51 {(unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \ 49 {(unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \
52 {(unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\ 50 {(unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\