aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-08 00:38:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-08 00:38:00 -0400
commitb66484cd74706fa8681d051840fe4b18a3da40ff (patch)
treee8215e7c25661d25f84abc4b98140c2062d6d5de /include/linux
parentc913fc4146ba7c280e074558d0a461e5c6f07c8a (diff)
parent05fd007e46296afb24d15c7d589d535e5a5b9d5c (diff)
Merge branch 'akpm' (patches from Andrew)
Merge updates from Andrew Morton: - fsnotify updates - ocfs2 updates - all of MM * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (127 commits) console: don't prefer first registered if DT specifies stdout-path cred: simpler, 1D supplementary groups CREDITS: update Pavel's information, add GPG key, remove snail mail address mailmap: add Johan Hovold .gitattributes: set git diff driver for C source code files uprobes: remove function declarations from arch/{mips,s390} spelling.txt: "modeled" is spelt correctly nmi_backtrace: generate one-line reports for idle cpus arch/tile: adopt the new nmi_backtrace framework nmi_backtrace: do a local dump_stack() instead of a self-NMI nmi_backtrace: add more trigger_*_cpu_backtrace() methods min/max: remove sparse warnings when they're nested Documentation/filesystems/proc.txt: add more description for maps/smaps mm, proc: fix region lost in /proc/self/smaps proc: fix timerslack_ns CAP_SYS_NICE check when adjusting self proc: add LSM hook checks to /proc/<tid>/timerslack_ns proc: relax /proc/<tid>/timerslack_ns capability requirements meminfo: break apart a very long seq_printf with #ifdefs seq/proc: modify seq_put_decimal_[u]ll to take a const char *, not char proc: faster /proc/*/status ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bitops.h36
-rw-r--r--include/linux/bootmem.h9
-rw-r--r--include/linux/compaction.h40
-rw-r--r--include/linux/console.h6
-rw-r--r--include/linux/cpu.h5
-rw-r--r--include/linux/cred.h11
-rw-r--r--include/linux/fsnotify_backend.h3
-rw-r--r--include/linux/huge_mm.h15
-rw-r--r--include/linux/hugetlb.h8
-rw-r--r--include/linux/jiffies.h4
-rw-r--r--include/linux/kernel.h48
-rw-r--r--include/linux/memblock.h1
-rw-r--r--include/linux/memcontrol.h21
-rw-r--r--include/linux/mm.h44
-rw-r--r--include/linux/mm_types.h2
-rw-r--r--include/linux/nmi.h31
-rw-r--r--include/linux/oom.h46
-rw-r--r--include/linux/page_ext.h8
-rw-r--r--include/linux/page_owner.h2
-rw-r--r--include/linux/pagemap.h14
-rw-r--r--include/linux/sched.h22
-rw-r--r--include/linux/seq_file.h4
-rw-r--r--include/linux/swap.h11
-rw-r--r--include/linux/writeback.h1
24 files changed, 240 insertions, 152 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 299e76b59fe9..a83c822c35c2 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -65,16 +65,6 @@ static inline int get_bitmask_order(unsigned int count)
65 return order; /* We could be slightly more clever with -1 here... */ 65 return order; /* We could be slightly more clever with -1 here... */
66} 66}
67 67
68static inline int get_count_order(unsigned int count)
69{
70 int order;
71
72 order = fls(count) - 1;
73 if (count & (count - 1))
74 order++;
75 return order;
76}
77
78static __always_inline unsigned long hweight_long(unsigned long w) 68static __always_inline unsigned long hweight_long(unsigned long w)
79{ 69{
80 return sizeof(w) == 4 ? hweight32(w) : hweight64(w); 70 return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
@@ -191,6 +181,32 @@ static inline unsigned fls_long(unsigned long l)
191 return fls64(l); 181 return fls64(l);
192} 182}
193 183
184static inline int get_count_order(unsigned int count)
185{
186 int order;
187
188 order = fls(count) - 1;
189 if (count & (count - 1))
190 order++;
191 return order;
192}
193
194/**
195 * get_count_order_long - get order after rounding @l up to power of 2
196 * @l: parameter
197 *
198 * it is same as get_count_order() but with long type parameter
199 */
200static inline int get_count_order_long(unsigned long l)
201{
202 if (l == 0UL)
203 return -1;
204 else if (l & (l - 1UL))
205 return (int)fls_long(l);
206 else
207 return (int)fls_long(l) - 1;
208}
209
194/** 210/**
195 * __ffs64 - find first set bit in a 64 bit word 211 * __ffs64 - find first set bit in a 64 bit word
196 * @word: The 64 bit word 212 * @word: The 64 bit word
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index f9be32691718..962164d36506 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -7,6 +7,7 @@
7#include <linux/mmzone.h> 7#include <linux/mmzone.h>
8#include <linux/mm_types.h> 8#include <linux/mm_types.h>
9#include <asm/dma.h> 9#include <asm/dma.h>
10#include <asm/processor.h>
10 11
11/* 12/*
12 * simple boot-time physical memory area allocator. 13 * simple boot-time physical memory area allocator.
@@ -119,6 +120,10 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
119#define BOOTMEM_LOW_LIMIT __pa(MAX_DMA_ADDRESS) 120#define BOOTMEM_LOW_LIMIT __pa(MAX_DMA_ADDRESS)
120#endif 121#endif
121 122
123#ifndef ARCH_LOW_ADDRESS_LIMIT
124#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
125#endif
126
122#define alloc_bootmem(x) \ 127#define alloc_bootmem(x) \
123 __alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT) 128 __alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
124#define alloc_bootmem_align(x, align) \ 129#define alloc_bootmem_align(x, align) \
@@ -180,10 +185,6 @@ static inline void * __init memblock_virt_alloc_nopanic(
180 NUMA_NO_NODE); 185 NUMA_NO_NODE);
181} 186}
182 187
183#ifndef ARCH_LOW_ADDRESS_LIMIT
184#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
185#endif
186
187static inline void * __init memblock_virt_alloc_low( 188static inline void * __init memblock_virt_alloc_low(
188 phys_addr_t size, phys_addr_t align) 189 phys_addr_t size, phys_addr_t align)
189{ 190{
diff --git a/include/linux/compaction.h b/include/linux/compaction.h
index d4e106b5dc27..0d8415820fc3 100644
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -6,8 +6,10 @@
6 * Lower value means higher priority, analogically to reclaim priority. 6 * Lower value means higher priority, analogically to reclaim priority.
7 */ 7 */
8enum compact_priority { 8enum compact_priority {
9 COMPACT_PRIO_SYNC_FULL,
10 MIN_COMPACT_PRIORITY = COMPACT_PRIO_SYNC_FULL,
9 COMPACT_PRIO_SYNC_LIGHT, 11 COMPACT_PRIO_SYNC_LIGHT,
10 MIN_COMPACT_PRIORITY = COMPACT_PRIO_SYNC_LIGHT, 12 MIN_COMPACT_COSTLY_PRIORITY = COMPACT_PRIO_SYNC_LIGHT,
11 DEF_COMPACT_PRIORITY = COMPACT_PRIO_SYNC_LIGHT, 13 DEF_COMPACT_PRIORITY = COMPACT_PRIO_SYNC_LIGHT,
12 COMPACT_PRIO_ASYNC, 14 COMPACT_PRIO_ASYNC,
13 INIT_COMPACT_PRIORITY = COMPACT_PRIO_ASYNC 15 INIT_COMPACT_PRIORITY = COMPACT_PRIO_ASYNC
@@ -49,14 +51,37 @@ enum compact_result {
49 COMPACT_CONTENDED, 51 COMPACT_CONTENDED,
50 52
51 /* 53 /*
52 * direct compaction partially compacted a zone and there might be 54 * direct compaction terminated after concluding that the allocation
53 * suitable pages 55 * should now succeed
54 */ 56 */
55 COMPACT_PARTIAL, 57 COMPACT_SUCCESS,
56}; 58};
57 59
58struct alloc_context; /* in mm/internal.h */ 60struct alloc_context; /* in mm/internal.h */
59 61
62/*
63 * Number of free order-0 pages that should be available above given watermark
64 * to make sure compaction has reasonable chance of not running out of free
65 * pages that it needs to isolate as migration target during its work.
66 */
67static inline unsigned long compact_gap(unsigned int order)
68{
69 /*
70 * Although all the isolations for migration are temporary, compaction
71 * free scanner may have up to 1 << order pages on its list and then
72 * try to split an (order - 1) free page. At that point, a gap of
73 * 1 << order might not be enough, so it's safer to require twice that
74 * amount. Note that the number of pages on the list is also
75 * effectively limited by COMPACT_CLUSTER_MAX, as that's the maximum
76 * that the migrate scanner can have isolated on migrate list, and free
77 * scanner is only invoked when the number of isolated free pages is
78 * lower than that. But it's not worth to complicate the formula here
79 * as a bigger gap for higher orders than strictly necessary can also
80 * improve chances of compaction success.
81 */
82 return 2UL << order;
83}
84
60#ifdef CONFIG_COMPACTION 85#ifdef CONFIG_COMPACTION
61extern int sysctl_compact_memory; 86extern int sysctl_compact_memory;
62extern int sysctl_compaction_handler(struct ctl_table *table, int write, 87extern int sysctl_compaction_handler(struct ctl_table *table, int write,
@@ -70,7 +95,6 @@ extern int fragmentation_index(struct zone *zone, unsigned int order);
70extern enum compact_result try_to_compact_pages(gfp_t gfp_mask, 95extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
71 unsigned int order, unsigned int alloc_flags, 96 unsigned int order, unsigned int alloc_flags,
72 const struct alloc_context *ac, enum compact_priority prio); 97 const struct alloc_context *ac, enum compact_priority prio);
73extern void compact_pgdat(pg_data_t *pgdat, int order);
74extern void reset_isolation_suitable(pg_data_t *pgdat); 98extern void reset_isolation_suitable(pg_data_t *pgdat);
75extern enum compact_result compaction_suitable(struct zone *zone, int order, 99extern enum compact_result compaction_suitable(struct zone *zone, int order,
76 unsigned int alloc_flags, int classzone_idx); 100 unsigned int alloc_flags, int classzone_idx);
@@ -89,7 +113,7 @@ static inline bool compaction_made_progress(enum compact_result result)
89 * that the compaction successfully isolated and migrated some 113 * that the compaction successfully isolated and migrated some
90 * pageblocks. 114 * pageblocks.
91 */ 115 */
92 if (result == COMPACT_PARTIAL) 116 if (result == COMPACT_SUCCESS)
93 return true; 117 return true;
94 118
95 return false; 119 return false;
@@ -154,10 +178,6 @@ extern void kcompactd_stop(int nid);
154extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx); 178extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx);
155 179
156#else 180#else
157static inline void compact_pgdat(pg_data_t *pgdat, int order)
158{
159}
160
161static inline void reset_isolation_suitable(pg_data_t *pgdat) 181static inline void reset_isolation_suitable(pg_data_t *pgdat)
162{ 182{
163} 183}
diff --git a/include/linux/console.h b/include/linux/console.h
index d530c4627e54..3672809234a7 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -173,6 +173,12 @@ static inline void console_sysfs_notify(void)
173#endif 173#endif
174extern bool console_suspend_enabled; 174extern bool console_suspend_enabled;
175 175
176#ifdef CONFIG_OF
177extern void console_set_by_of(void);
178#else
179static inline void console_set_by_of(void) {}
180#endif
181
176/* Suspend and resume console messages over PM events */ 182/* Suspend and resume console messages over PM events */
177extern void suspend_console(void); 183extern void suspend_console(void);
178extern void resume_console(void); 184extern void resume_console(void);
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 7572d9e9dced..b886dc17f2f3 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -231,6 +231,11 @@ void cpu_startup_entry(enum cpuhp_state state);
231 231
232void cpu_idle_poll_ctrl(bool enable); 232void cpu_idle_poll_ctrl(bool enable);
233 233
234/* Attach to any functions which should be considered cpuidle. */
235#define __cpuidle __attribute__((__section__(".cpuidle.text")))
236
237bool cpu_in_idle(unsigned long pc);
238
234void arch_cpu_idle(void); 239void arch_cpu_idle(void);
235void arch_cpu_idle_prepare(void); 240void arch_cpu_idle_prepare(void);
236void arch_cpu_idle_enter(void); 241void arch_cpu_idle_enter(void);
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 257db64562e5..f0e70a1bb3ac 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -26,15 +26,10 @@ struct inode;
26/* 26/*
27 * COW Supplementary groups list 27 * COW Supplementary groups list
28 */ 28 */
29#define NGROUPS_SMALL 32
30#define NGROUPS_PER_BLOCK ((unsigned int)(PAGE_SIZE / sizeof(kgid_t)))
31
32struct group_info { 29struct group_info {
33 atomic_t usage; 30 atomic_t usage;
34 int ngroups; 31 int ngroups;
35 int nblocks; 32 kgid_t gid[0];
36 kgid_t small_block[NGROUPS_SMALL];
37 kgid_t *blocks[0];
38}; 33};
39 34
40/** 35/**
@@ -88,10 +83,6 @@ extern void set_groups(struct cred *, struct group_info *);
88extern int groups_search(const struct group_info *, kgid_t); 83extern int groups_search(const struct group_info *, kgid_t);
89extern bool may_setgroups(void); 84extern bool may_setgroups(void);
90 85
91/* access the groups "array" with this macro */
92#define GROUP_AT(gi, i) \
93 ((gi)->blocks[(i) / NGROUPS_PER_BLOCK][(i) % NGROUPS_PER_BLOCK])
94
95/* 86/*
96 * The security context of a task 87 * The security context of a task
97 * 88 *
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 7268ed076be8..79467b239fcf 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -135,7 +135,7 @@ struct fsnotify_group {
135 const struct fsnotify_ops *ops; /* how this group handles things */ 135 const struct fsnotify_ops *ops; /* how this group handles things */
136 136
137 /* needed to send notification to userspace */ 137 /* needed to send notification to userspace */
138 struct mutex notification_mutex; /* protect the notification_list */ 138 spinlock_t notification_lock; /* protect the notification_list */
139 struct list_head notification_list; /* list of event_holder this group needs to send to userspace */ 139 struct list_head notification_list; /* list of event_holder this group needs to send to userspace */
140 wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */ 140 wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */
141 unsigned int q_len; /* events on the queue */ 141 unsigned int q_len; /* events on the queue */
@@ -177,7 +177,6 @@ struct fsnotify_group {
177 struct fanotify_group_private_data { 177 struct fanotify_group_private_data {
178#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS 178#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
179 /* allows a group to block waiting for a userspace response */ 179 /* allows a group to block waiting for a userspace response */
180 spinlock_t access_lock;
181 struct list_head access_list; 180 struct list_head access_list;
182 wait_queue_head_t access_waitq; 181 wait_queue_head_t access_waitq;
183#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ 182#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 6f14de45b5ce..9b9f65d99873 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -87,6 +87,10 @@ extern bool is_vma_temporary_stack(struct vm_area_struct *vma);
87 87
88extern unsigned long transparent_hugepage_flags; 88extern unsigned long transparent_hugepage_flags;
89 89
90extern unsigned long thp_get_unmapped_area(struct file *filp,
91 unsigned long addr, unsigned long len, unsigned long pgoff,
92 unsigned long flags);
93
90extern void prep_transhuge_page(struct page *page); 94extern void prep_transhuge_page(struct page *page);
91extern void free_transhuge_page(struct page *page); 95extern void free_transhuge_page(struct page *page);
92 96
@@ -152,8 +156,8 @@ static inline bool is_huge_zero_pmd(pmd_t pmd)
152 return is_huge_zero_page(pmd_page(pmd)); 156 return is_huge_zero_page(pmd_page(pmd));
153} 157}
154 158
155struct page *get_huge_zero_page(void); 159struct page *mm_get_huge_zero_page(struct mm_struct *mm);
156void put_huge_zero_page(void); 160void mm_put_huge_zero_page(struct mm_struct *mm);
157 161
158#define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot)) 162#define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot))
159 163
@@ -169,6 +173,9 @@ void put_huge_zero_page(void);
169static inline void prep_transhuge_page(struct page *page) {} 173static inline void prep_transhuge_page(struct page *page) {}
170 174
171#define transparent_hugepage_flags 0UL 175#define transparent_hugepage_flags 0UL
176
177#define thp_get_unmapped_area NULL
178
172static inline int 179static inline int
173split_huge_page_to_list(struct page *page, struct list_head *list) 180split_huge_page_to_list(struct page *page, struct list_head *list)
174{ 181{
@@ -213,9 +220,9 @@ static inline bool is_huge_zero_page(struct page *page)
213 return false; 220 return false;
214} 221}
215 222
216static inline void put_huge_zero_page(void) 223static inline void mm_put_huge_zero_page(struct mm_struct *mm)
217{ 224{
218 BUILD_BUG(); 225 return;
219} 226}
220 227
221static inline struct page *follow_devmap_pmd(struct vm_area_struct *vma, 228static inline struct page *follow_devmap_pmd(struct vm_area_struct *vma,
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index c26d4638f665..48c76d612d40 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -90,7 +90,7 @@ int dequeue_hwpoisoned_huge_page(struct page *page);
90bool isolate_huge_page(struct page *page, struct list_head *list); 90bool isolate_huge_page(struct page *page, struct list_head *list);
91void putback_active_hugepage(struct page *page); 91void putback_active_hugepage(struct page *page);
92void free_huge_page(struct page *page); 92void free_huge_page(struct page *page);
93void hugetlb_fix_reserve_counts(struct inode *inode, bool restore_reserve); 93void hugetlb_fix_reserve_counts(struct inode *inode);
94extern struct mutex *hugetlb_fault_mutex_table; 94extern struct mutex *hugetlb_fault_mutex_table;
95u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm, 95u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
96 struct vm_area_struct *vma, 96 struct vm_area_struct *vma,
@@ -450,8 +450,8 @@ static inline pgoff_t basepage_index(struct page *page)
450 return __basepage_index(page); 450 return __basepage_index(page);
451} 451}
452 452
453extern void dissolve_free_huge_pages(unsigned long start_pfn, 453extern int dissolve_free_huge_pages(unsigned long start_pfn,
454 unsigned long end_pfn); 454 unsigned long end_pfn);
455static inline bool hugepage_migration_supported(struct hstate *h) 455static inline bool hugepage_migration_supported(struct hstate *h)
456{ 456{
457#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION 457#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
@@ -518,7 +518,7 @@ static inline pgoff_t basepage_index(struct page *page)
518{ 518{
519 return page->index; 519 return page->index;
520} 520}
521#define dissolve_free_huge_pages(s, e) do {} while (0) 521#define dissolve_free_huge_pages(s, e) 0
522#define hugepage_migration_supported(h) false 522#define hugepage_migration_supported(h) false
523 523
524static inline spinlock_t *huge_pte_lockptr(struct hstate *h, 524static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 5fdc55312334..589d14e970ad 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -150,15 +150,19 @@ static inline u64 get_jiffies_64(void)
150 150
151/* time_is_before_jiffies(a) return true if a is before jiffies */ 151/* time_is_before_jiffies(a) return true if a is before jiffies */
152#define time_is_before_jiffies(a) time_after(jiffies, a) 152#define time_is_before_jiffies(a) time_after(jiffies, a)
153#define time_is_before_jiffies64(a) time_after64(get_jiffies_64(), a)
153 154
154/* time_is_after_jiffies(a) return true if a is after jiffies */ 155/* time_is_after_jiffies(a) return true if a is after jiffies */
155#define time_is_after_jiffies(a) time_before(jiffies, a) 156#define time_is_after_jiffies(a) time_before(jiffies, a)
157#define time_is_after_jiffies64(a) time_before64(get_jiffies_64(), a)
156 158
157/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/ 159/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/
158#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a) 160#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
161#define time_is_before_eq_jiffies64(a) time_after_eq64(get_jiffies_64(), a)
159 162
160/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/ 163/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/
161#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a) 164#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
165#define time_is_after_eq_jiffies64(a) time_before_eq64(get_jiffies_64(), a)
162 166
163/* 167/*
164 * Have the 32 bit jiffies value wrap 5 minutes after boot 168 * Have the 32 bit jiffies value wrap 5 minutes after boot
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 74fd6f05bc5b..bc6ed52a39b9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -733,17 +733,25 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
733 * strict type-checking.. See the 733 * strict type-checking.. See the
734 * "unnecessary" pointer comparison. 734 * "unnecessary" pointer comparison.
735 */ 735 */
736#define min(x, y) ({ \ 736#define __min(t1, t2, min1, min2, x, y) ({ \
737 typeof(x) _min1 = (x); \ 737 t1 min1 = (x); \
738 typeof(y) _min2 = (y); \ 738 t2 min2 = (y); \
739 (void) (&_min1 == &_min2); \ 739 (void) (&min1 == &min2); \
740 _min1 < _min2 ? _min1 : _min2; }) 740 min1 < min2 ? min1 : min2; })
741 741#define min(x, y) \
742#define max(x, y) ({ \ 742 __min(typeof(x), typeof(y), \
743 typeof(x) _max1 = (x); \ 743 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
744 typeof(y) _max2 = (y); \ 744 x, y)
745 (void) (&_max1 == &_max2); \ 745
746 _max1 > _max2 ? _max1 : _max2; }) 746#define __max(t1, t2, max1, max2, x, y) ({ \
747 t1 max1 = (x); \
748 t2 max2 = (y); \
749 (void) (&max1 == &max2); \
750 max1 > max2 ? max1 : max2; })
751#define max(x, y) \
752 __max(typeof(x), typeof(y), \
753 __UNIQUE_ID(max1_), __UNIQUE_ID(max2_), \
754 x, y)
747 755
748#define min3(x, y, z) min((typeof(x))min(x, y), z) 756#define min3(x, y, z) min((typeof(x))min(x, y), z)
749#define max3(x, y, z) max((typeof(x))max(x, y), z) 757#define max3(x, y, z) max((typeof(x))max(x, y), z)
@@ -775,15 +783,15 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
775 * 783 *
776 * Or not use min/max/clamp at all, of course. 784 * Or not use min/max/clamp at all, of course.
777 */ 785 */
778#define min_t(type, x, y) ({ \ 786#define min_t(type, x, y) \
779 type __min1 = (x); \ 787 __min(type, type, \
780 type __min2 = (y); \ 788 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
781 __min1 < __min2 ? __min1: __min2; }) 789 x, y)
782 790
783#define max_t(type, x, y) ({ \ 791#define max_t(type, x, y) \
784 type __max1 = (x); \ 792 __max(type, type, \
785 type __max2 = (y); \ 793 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
786 __max1 > __max2 ? __max1: __max2; }) 794 x, y)
787 795
788/** 796/**
789 * clamp_t - return a value clamped to a given range using a given type 797 * clamp_t - return a value clamped to a given range using a given type
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 2925da23505d..5b759c9acf97 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -328,6 +328,7 @@ phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align,
328phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align, 328phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align,
329 phys_addr_t max_addr); 329 phys_addr_t max_addr);
330phys_addr_t memblock_phys_mem_size(void); 330phys_addr_t memblock_phys_mem_size(void);
331phys_addr_t memblock_reserved_size(void);
331phys_addr_t memblock_mem_size(unsigned long limit_pfn); 332phys_addr_t memblock_mem_size(unsigned long limit_pfn);
332phys_addr_t memblock_start_of_DRAM(void); 333phys_addr_t memblock_start_of_DRAM(void);
333phys_addr_t memblock_end_of_DRAM(void); 334phys_addr_t memblock_end_of_DRAM(void);
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 5d8ca6e02e39..61d20c17f3b7 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -366,6 +366,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
366 struct mem_cgroup *, 366 struct mem_cgroup *,
367 struct mem_cgroup_reclaim_cookie *); 367 struct mem_cgroup_reclaim_cookie *);
368void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *); 368void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *);
369int mem_cgroup_scan_tasks(struct mem_cgroup *,
370 int (*)(struct task_struct *, void *), void *);
369 371
370static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) 372static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg)
371{ 373{
@@ -446,6 +448,8 @@ unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
446 448
447void mem_cgroup_handle_over_high(void); 449void mem_cgroup_handle_over_high(void);
448 450
451unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg);
452
449void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, 453void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
450 struct task_struct *p); 454 struct task_struct *p);
451 455
@@ -639,6 +643,12 @@ static inline void mem_cgroup_iter_break(struct mem_cgroup *root,
639{ 643{
640} 644}
641 645
646static inline int mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
647 int (*fn)(struct task_struct *, void *), void *arg)
648{
649 return 0;
650}
651
642static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) 652static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg)
643{ 653{
644 return 0; 654 return 0;
@@ -669,6 +679,11 @@ mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
669 return 0; 679 return 0;
670} 680}
671 681
682static inline unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg)
683{
684 return 0;
685}
686
672static inline void 687static inline void
673mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) 688mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
674{ 689{
@@ -758,13 +773,13 @@ static inline void mem_cgroup_wb_stats(struct bdi_writeback *wb,
758#endif /* CONFIG_CGROUP_WRITEBACK */ 773#endif /* CONFIG_CGROUP_WRITEBACK */
759 774
760struct sock; 775struct sock;
761void sock_update_memcg(struct sock *sk);
762void sock_release_memcg(struct sock *sk);
763bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages); 776bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages);
764void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages); 777void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages);
765#ifdef CONFIG_MEMCG 778#ifdef CONFIG_MEMCG
766extern struct static_key_false memcg_sockets_enabled_key; 779extern struct static_key_false memcg_sockets_enabled_key;
767#define mem_cgroup_sockets_enabled static_branch_unlikely(&memcg_sockets_enabled_key) 780#define mem_cgroup_sockets_enabled static_branch_unlikely(&memcg_sockets_enabled_key)
781void mem_cgroup_sk_alloc(struct sock *sk);
782void mem_cgroup_sk_free(struct sock *sk);
768static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) 783static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
769{ 784{
770 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg->tcpmem_pressure) 785 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg->tcpmem_pressure)
@@ -777,6 +792,8 @@ static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
777} 792}
778#else 793#else
779#define mem_cgroup_sockets_enabled 0 794#define mem_cgroup_sockets_enabled 0
795static inline void mem_cgroup_sk_alloc(struct sock *sk) { };
796static inline void mem_cgroup_sk_free(struct sock *sk) { };
780static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) 797static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
781{ 798{
782 return false; 799 return false;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5f14534f0c90..e9caec6a51e9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -126,7 +126,7 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
126#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) 126#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
127 127
128/* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ 128/* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */
129#define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)addr, PAGE_SIZE) 129#define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)
130 130
131/* 131/*
132 * Linux kernel virtual memory manager primitives. 132 * Linux kernel virtual memory manager primitives.
@@ -1048,28 +1048,16 @@ struct address_space *page_file_mapping(struct page *page)
1048 return page->mapping; 1048 return page->mapping;
1049} 1049}
1050 1050
1051/*
1052 * Return the pagecache index of the passed page. Regular pagecache pages
1053 * use ->index whereas swapcache pages use ->private
1054 */
1055static inline pgoff_t page_index(struct page *page)
1056{
1057 if (unlikely(PageSwapCache(page)))
1058 return page_private(page);
1059 return page->index;
1060}
1061
1062extern pgoff_t __page_file_index(struct page *page); 1051extern pgoff_t __page_file_index(struct page *page);
1063 1052
1064/* 1053/*
1065 * Return the file index of the page. Regular pagecache pages use ->index 1054 * Return the pagecache index of the passed page. Regular pagecache pages
1066 * whereas swapcache pages use swp_offset(->private) 1055 * use ->index whereas swapcache pages use swp_offset(->private)
1067 */ 1056 */
1068static inline pgoff_t page_file_index(struct page *page) 1057static inline pgoff_t page_index(struct page *page)
1069{ 1058{
1070 if (unlikely(PageSwapCache(page))) 1059 if (unlikely(PageSwapCache(page)))
1071 return __page_file_index(page); 1060 return __page_file_index(page);
1072
1073 return page->index; 1061 return page->index;
1074} 1062}
1075 1063
@@ -1197,10 +1185,10 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
1197 * @pte_hole: if set, called for each hole at all levels 1185 * @pte_hole: if set, called for each hole at all levels
1198 * @hugetlb_entry: if set, called for each hugetlb entry 1186 * @hugetlb_entry: if set, called for each hugetlb entry
1199 * @test_walk: caller specific callback function to determine whether 1187 * @test_walk: caller specific callback function to determine whether
1200 * we walk over the current vma or not. A positive returned 1188 * we walk over the current vma or not. Returning 0
1201 * value means "do page table walk over the current vma," 1189 * value means "do page table walk over the current vma,"
1202 * and a negative one means "abort current page table walk 1190 * and a negative one means "abort current page table walk
1203 * right now." 0 means "skip the current vma." 1191 * right now." 1 means "skip the current vma."
1204 * @mm: mm_struct representing the target process of page table walk 1192 * @mm: mm_struct representing the target process of page table walk
1205 * @vma: vma currently walked (NULL if walking outside vmas) 1193 * @vma: vma currently walked (NULL if walking outside vmas)
1206 * @private: private data for callbacks' usage 1194 * @private: private data for callbacks' usage
@@ -1529,7 +1517,7 @@ static inline int pte_devmap(pte_t pte)
1529} 1517}
1530#endif 1518#endif
1531 1519
1532int vma_wants_writenotify(struct vm_area_struct *vma); 1520int vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot);
1533 1521
1534extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr, 1522extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
1535 spinlock_t **ptl); 1523 spinlock_t **ptl);
@@ -1924,10 +1912,12 @@ extern void show_mem(unsigned int flags);
1924extern long si_mem_available(void); 1912extern long si_mem_available(void);
1925extern void si_meminfo(struct sysinfo * val); 1913extern void si_meminfo(struct sysinfo * val);
1926extern void si_meminfo_node(struct sysinfo *val, int nid); 1914extern void si_meminfo_node(struct sysinfo *val, int nid);
1915#ifdef __HAVE_ARCH_RESERVED_KERNEL_PAGES
1916extern unsigned long arch_reserved_kernel_pages(void);
1917#endif
1927 1918
1928extern __printf(3, 4) 1919extern __printf(2, 3)
1929void warn_alloc_failed(gfp_t gfp_mask, unsigned int order, 1920void warn_alloc(gfp_t gfp_mask, const char *fmt, ...);
1930 const char *fmt, ...);
1931 1921
1932extern void setup_per_cpu_pageset(void); 1922extern void setup_per_cpu_pageset(void);
1933 1923
@@ -1977,8 +1967,14 @@ void anon_vma_interval_tree_verify(struct anon_vma_chain *node);
1977 1967
1978/* mmap.c */ 1968/* mmap.c */
1979extern int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin); 1969extern int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin);
1980extern int vma_adjust(struct vm_area_struct *vma, unsigned long start, 1970extern int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
1981 unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert); 1971 unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert,
1972 struct vm_area_struct *expand);
1973static inline int vma_adjust(struct vm_area_struct *vma, unsigned long start,
1974 unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert)
1975{
1976 return __vma_adjust(vma, start, end, pgoff, insert, NULL);
1977}
1982extern struct vm_area_struct *vma_merge(struct mm_struct *, 1978extern struct vm_area_struct *vma_merge(struct mm_struct *,
1983 struct vm_area_struct *prev, unsigned long addr, unsigned long end, 1979 struct vm_area_struct *prev, unsigned long addr, unsigned long end,
1984 unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t, 1980 unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t,
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 903200f4ec41..4a8acedf4b7d 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -515,9 +515,7 @@ struct mm_struct {
515#ifdef CONFIG_HUGETLB_PAGE 515#ifdef CONFIG_HUGETLB_PAGE
516 atomic_long_t hugetlb_usage; 516 atomic_long_t hugetlb_usage;
517#endif 517#endif
518#ifdef CONFIG_MMU
519 struct work_struct async_put_work; 518 struct work_struct async_put_work;
520#endif
521}; 519};
522 520
523static inline void mm_init_cpumask(struct mm_struct *mm) 521static inline void mm_init_cpumask(struct mm_struct *mm)
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 4630eeae18e0..a78c35cff1ae 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -35,21 +35,34 @@ static inline void hardlockup_detector_disable(void) {}
35 * base function. Return whether such support was available, 35 * base function. Return whether such support was available,
36 * to allow calling code to fall back to some other mechanism: 36 * to allow calling code to fall back to some other mechanism:
37 */ 37 */
38#ifdef arch_trigger_all_cpu_backtrace 38#ifdef arch_trigger_cpumask_backtrace
39static inline bool trigger_all_cpu_backtrace(void) 39static inline bool trigger_all_cpu_backtrace(void)
40{ 40{
41 arch_trigger_all_cpu_backtrace(true); 41 arch_trigger_cpumask_backtrace(cpu_online_mask, false);
42
43 return true; 42 return true;
44} 43}
44
45static inline bool trigger_allbutself_cpu_backtrace(void) 45static inline bool trigger_allbutself_cpu_backtrace(void)
46{ 46{
47 arch_trigger_all_cpu_backtrace(false); 47 arch_trigger_cpumask_backtrace(cpu_online_mask, true);
48 return true;
49}
50
51static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
52{
53 arch_trigger_cpumask_backtrace(mask, false);
54 return true;
55}
56
57static inline bool trigger_single_cpu_backtrace(int cpu)
58{
59 arch_trigger_cpumask_backtrace(cpumask_of(cpu), false);
48 return true; 60 return true;
49} 61}
50 62
51/* generic implementation */ 63/* generic implementation */
52void nmi_trigger_all_cpu_backtrace(bool include_self, 64void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
65 bool exclude_self,
53 void (*raise)(cpumask_t *mask)); 66 void (*raise)(cpumask_t *mask));
54bool nmi_cpu_backtrace(struct pt_regs *regs); 67bool nmi_cpu_backtrace(struct pt_regs *regs);
55 68
@@ -62,6 +75,14 @@ static inline bool trigger_allbutself_cpu_backtrace(void)
62{ 75{
63 return false; 76 return false;
64} 77}
78static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
79{
80 return false;
81}
82static inline bool trigger_single_cpu_backtrace(int cpu)
83{
84 return false;
85}
65#endif 86#endif
66 87
67#ifdef CONFIG_LOCKUP_DETECTOR 88#ifdef CONFIG_LOCKUP_DETECTOR
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 5bc0457ee3a8..b4e36e92bc87 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -34,23 +34,11 @@ struct oom_control {
34 * for display purposes. 34 * for display purposes.
35 */ 35 */
36 const int order; 36 const int order;
37};
38
39/*
40 * Types of limitations to the nodes from which allocations may occur
41 */
42enum oom_constraint {
43 CONSTRAINT_NONE,
44 CONSTRAINT_CPUSET,
45 CONSTRAINT_MEMORY_POLICY,
46 CONSTRAINT_MEMCG,
47};
48 37
49enum oom_scan_t { 38 /* Used by oom implementation, do not set */
50 OOM_SCAN_OK, /* scan thread and find its badness */ 39 unsigned long totalpages;
51 OOM_SCAN_CONTINUE, /* do not consider thread for oom kill */ 40 struct task_struct *chosen;
52 OOM_SCAN_ABORT, /* abort the iteration and return */ 41 unsigned long chosen_points;
53 OOM_SCAN_SELECT, /* always select this thread first */
54}; 42};
55 43
56extern struct mutex oom_lock; 44extern struct mutex oom_lock;
@@ -70,45 +58,27 @@ static inline bool oom_task_origin(const struct task_struct *p)
70 return p->signal->oom_flag_origin; 58 return p->signal->oom_flag_origin;
71} 59}
72 60
73extern void mark_oom_victim(struct task_struct *tsk); 61static inline bool tsk_is_oom_victim(struct task_struct * tsk)
74
75#ifdef CONFIG_MMU
76extern void wake_oom_reaper(struct task_struct *tsk);
77#else
78static inline void wake_oom_reaper(struct task_struct *tsk)
79{ 62{
63 return tsk->signal->oom_mm;
80} 64}
81#endif
82 65
83extern unsigned long oom_badness(struct task_struct *p, 66extern unsigned long oom_badness(struct task_struct *p,
84 struct mem_cgroup *memcg, const nodemask_t *nodemask, 67 struct mem_cgroup *memcg, const nodemask_t *nodemask,
85 unsigned long totalpages); 68 unsigned long totalpages);
86 69
87extern void oom_kill_process(struct oom_control *oc, struct task_struct *p,
88 unsigned int points, unsigned long totalpages,
89 const char *message);
90
91extern void check_panic_on_oom(struct oom_control *oc,
92 enum oom_constraint constraint);
93
94extern enum oom_scan_t oom_scan_process_thread(struct oom_control *oc,
95 struct task_struct *task);
96
97extern bool out_of_memory(struct oom_control *oc); 70extern bool out_of_memory(struct oom_control *oc);
98 71
99extern void exit_oom_victim(struct task_struct *tsk); 72extern void exit_oom_victim(void);
100 73
101extern int register_oom_notifier(struct notifier_block *nb); 74extern int register_oom_notifier(struct notifier_block *nb);
102extern int unregister_oom_notifier(struct notifier_block *nb); 75extern int unregister_oom_notifier(struct notifier_block *nb);
103 76
104extern bool oom_killer_disabled; 77extern bool oom_killer_disable(signed long timeout);
105extern bool oom_killer_disable(void);
106extern void oom_killer_enable(void); 78extern void oom_killer_enable(void);
107 79
108extern struct task_struct *find_lock_task_mm(struct task_struct *p); 80extern struct task_struct *find_lock_task_mm(struct task_struct *p);
109 81
110bool task_will_free_mem(struct task_struct *task);
111
112/* sysctls */ 82/* sysctls */
113extern int sysctl_oom_dump_tasks; 83extern int sysctl_oom_dump_tasks;
114extern int sysctl_oom_kill_allocating_task; 84extern int sysctl_oom_kill_allocating_task;
diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
index 03f2a3e7d76d..9298c393ddaa 100644
--- a/include/linux/page_ext.h
+++ b/include/linux/page_ext.h
@@ -7,6 +7,8 @@
7 7
8struct pglist_data; 8struct pglist_data;
9struct page_ext_operations { 9struct page_ext_operations {
10 size_t offset;
11 size_t size;
10 bool (*need)(void); 12 bool (*need)(void);
11 void (*init)(void); 13 void (*init)(void);
12}; 14};
@@ -42,12 +44,6 @@ enum page_ext_flags {
42 */ 44 */
43struct page_ext { 45struct page_ext {
44 unsigned long flags; 46 unsigned long flags;
45#ifdef CONFIG_PAGE_OWNER
46 unsigned int order;
47 gfp_t gfp_mask;
48 int last_migrate_reason;
49 depot_stack_handle_t handle;
50#endif
51}; 47};
52 48
53extern void pgdat_page_ext_init(struct pglist_data *pgdat); 49extern void pgdat_page_ext_init(struct pglist_data *pgdat);
diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h
index 30583ab0ffb1..2be728d156b5 100644
--- a/include/linux/page_owner.h
+++ b/include/linux/page_owner.h
@@ -14,6 +14,8 @@ extern void __split_page_owner(struct page *page, unsigned int order);
14extern void __copy_page_owner(struct page *oldpage, struct page *newpage); 14extern void __copy_page_owner(struct page *oldpage, struct page *newpage);
15extern void __set_page_owner_migrate_reason(struct page *page, int reason); 15extern void __set_page_owner_migrate_reason(struct page *page, int reason);
16extern void __dump_page_owner(struct page *page); 16extern void __dump_page_owner(struct page *page);
17extern void pagetypeinfo_showmixedcount_print(struct seq_file *m,
18 pg_data_t *pgdat, struct zone *zone);
17 19
18static inline void reset_page_owner(struct page *page, unsigned int order) 20static inline void reset_page_owner(struct page *page, unsigned int order)
19{ 21{
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 01e84436cddf..794dbcb91084 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -25,6 +25,8 @@ enum mapping_flags {
25 AS_MM_ALL_LOCKS = __GFP_BITS_SHIFT + 2, /* under mm_take_all_locks() */ 25 AS_MM_ALL_LOCKS = __GFP_BITS_SHIFT + 2, /* under mm_take_all_locks() */
26 AS_UNEVICTABLE = __GFP_BITS_SHIFT + 3, /* e.g., ramdisk, SHM_LOCK */ 26 AS_UNEVICTABLE = __GFP_BITS_SHIFT + 3, /* e.g., ramdisk, SHM_LOCK */
27 AS_EXITING = __GFP_BITS_SHIFT + 4, /* final truncate in progress */ 27 AS_EXITING = __GFP_BITS_SHIFT + 4, /* final truncate in progress */
28 /* writeback related tags are not used */
29 AS_NO_WRITEBACK_TAGS = __GFP_BITS_SHIFT + 5,
28}; 30};
29 31
30static inline void mapping_set_error(struct address_space *mapping, int error) 32static inline void mapping_set_error(struct address_space *mapping, int error)
@@ -64,6 +66,16 @@ static inline int mapping_exiting(struct address_space *mapping)
64 return test_bit(AS_EXITING, &mapping->flags); 66 return test_bit(AS_EXITING, &mapping->flags);
65} 67}
66 68
69static inline void mapping_set_no_writeback_tags(struct address_space *mapping)
70{
71 set_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags);
72}
73
74static inline int mapping_use_writeback_tags(struct address_space *mapping)
75{
76 return !test_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags);
77}
78
67static inline gfp_t mapping_gfp_mask(struct address_space * mapping) 79static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
68{ 80{
69 return (__force gfp_t)mapping->flags & __GFP_BITS_MASK; 81 return (__force gfp_t)mapping->flags & __GFP_BITS_MASK;
@@ -396,7 +408,7 @@ static inline loff_t page_offset(struct page *page)
396 408
397static inline loff_t page_file_offset(struct page *page) 409static inline loff_t page_file_offset(struct page *page)
398{ 410{
399 return ((loff_t)page_file_index(page)) << PAGE_SHIFT; 411 return ((loff_t)page_index(page)) << PAGE_SHIFT;
400} 412}
401 413
402extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, 414extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 7543a476178b..348f51b0ec92 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -524,8 +524,9 @@ static inline int get_dumpable(struct mm_struct *mm)
524 524
525#define MMF_HAS_UPROBES 19 /* has uprobes */ 525#define MMF_HAS_UPROBES 19 /* has uprobes */
526#define MMF_RECALC_UPROBES 20 /* MMF_HAS_UPROBES can be wrong */ 526#define MMF_RECALC_UPROBES 20 /* MMF_HAS_UPROBES can be wrong */
527#define MMF_OOM_REAPED 21 /* mm has been already reaped */ 527#define MMF_OOM_SKIP 21 /* mm is of no interest for the OOM killer */
528#define MMF_OOM_NOT_REAPABLE 22 /* mm couldn't be reaped */ 528#define MMF_UNSTABLE 22 /* mm is unstable for copy_from_user */
529#define MMF_HUGE_ZERO_PAGE 23 /* mm has ever used the global huge zero page */
529 530
530#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK) 531#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
531 532
@@ -673,7 +674,6 @@ struct signal_struct {
673 atomic_t sigcnt; 674 atomic_t sigcnt;
674 atomic_t live; 675 atomic_t live;
675 int nr_threads; 676 int nr_threads;
676 atomic_t oom_victims; /* # of TIF_MEDIE threads in this thread group */
677 struct list_head thread_head; 677 struct list_head thread_head;
678 678
679 wait_queue_head_t wait_chldexit; /* for wait4() */ 679 wait_queue_head_t wait_chldexit; /* for wait4() */
@@ -806,6 +806,8 @@ struct signal_struct {
806 short oom_score_adj; /* OOM kill score adjustment */ 806 short oom_score_adj; /* OOM kill score adjustment */
807 short oom_score_adj_min; /* OOM kill score adjustment min value. 807 short oom_score_adj_min; /* OOM kill score adjustment min value.
808 * Only settable by CAP_SYS_RESOURCE. */ 808 * Only settable by CAP_SYS_RESOURCE. */
809 struct mm_struct *oom_mm; /* recorded mm when the thread group got
810 * killed by the oom killer */
809 811
810 struct mutex cred_guard_mutex; /* guard against foreign influences on 812 struct mutex cred_guard_mutex; /* guard against foreign influences on
811 * credential calculations 813 * credential calculations
@@ -2876,6 +2878,20 @@ static inline void mmdrop(struct mm_struct *mm)
2876 __mmdrop(mm); 2878 __mmdrop(mm);
2877} 2879}
2878 2880
2881static inline void mmdrop_async_fn(struct work_struct *work)
2882{
2883 struct mm_struct *mm = container_of(work, struct mm_struct, async_put_work);
2884 __mmdrop(mm);
2885}
2886
2887static inline void mmdrop_async(struct mm_struct *mm)
2888{
2889 if (unlikely(atomic_dec_and_test(&mm->mm_count))) {
2890 INIT_WORK(&mm->async_put_work, mmdrop_async_fn);
2891 schedule_work(&mm->async_put_work);
2892 }
2893}
2894
2879static inline bool mmget_not_zero(struct mm_struct *mm) 2895static inline bool mmget_not_zero(struct mm_struct *mm)
2880{ 2896{
2881 return atomic_inc_not_zero(&mm->mm_users); 2897 return atomic_inc_not_zero(&mm->mm_users);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index f3d45dd42695..e305b66a9fb9 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -117,9 +117,9 @@ __printf(2, 3)
117void seq_printf(struct seq_file *m, const char *fmt, ...); 117void seq_printf(struct seq_file *m, const char *fmt, ...);
118void seq_putc(struct seq_file *m, char c); 118void seq_putc(struct seq_file *m, char c);
119void seq_puts(struct seq_file *m, const char *s); 119void seq_puts(struct seq_file *m, const char *s);
120void seq_put_decimal_ull(struct seq_file *m, char delimiter, 120void seq_put_decimal_ull(struct seq_file *m, const char *delimiter,
121 unsigned long long num); 121 unsigned long long num);
122void seq_put_decimal_ll(struct seq_file *m, char delimiter, long long num); 122void seq_put_decimal_ll(struct seq_file *m, const char *delimiter, long long num);
123void seq_escape(struct seq_file *m, const char *s, const char *esc); 123void seq_escape(struct seq_file *m, const char *s, const char *esc);
124 124
125void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type, 125void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
diff --git a/include/linux/swap.h b/include/linux/swap.h
index e1d761463243..a56523cefb9b 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -191,6 +191,11 @@ struct percpu_cluster {
191 unsigned int next; /* Likely next allocation offset */ 191 unsigned int next; /* Likely next allocation offset */
192}; 192};
193 193
194struct swap_cluster_list {
195 struct swap_cluster_info head;
196 struct swap_cluster_info tail;
197};
198
194/* 199/*
195 * The in-memory structure used to track swap areas. 200 * The in-memory structure used to track swap areas.
196 */ 201 */
@@ -203,8 +208,7 @@ struct swap_info_struct {
203 unsigned int max; /* extent of the swap_map */ 208 unsigned int max; /* extent of the swap_map */
204 unsigned char *swap_map; /* vmalloc'ed array of usage counts */ 209 unsigned char *swap_map; /* vmalloc'ed array of usage counts */
205 struct swap_cluster_info *cluster_info; /* cluster info. Only for SSD */ 210 struct swap_cluster_info *cluster_info; /* cluster info. Only for SSD */
206 struct swap_cluster_info free_cluster_head; /* free cluster list head */ 211 struct swap_cluster_list free_clusters; /* free clusters list */
207 struct swap_cluster_info free_cluster_tail; /* free cluster list tail */
208 unsigned int lowest_bit; /* index of first free in swap_map */ 212 unsigned int lowest_bit; /* index of first free in swap_map */
209 unsigned int highest_bit; /* index of last free in swap_map */ 213 unsigned int highest_bit; /* index of last free in swap_map */
210 unsigned int pages; /* total of usable pages of swap */ 214 unsigned int pages; /* total of usable pages of swap */
@@ -235,8 +239,7 @@ struct swap_info_struct {
235 * first. 239 * first.
236 */ 240 */
237 struct work_struct discard_work; /* discard worker */ 241 struct work_struct discard_work; /* discard worker */
238 struct swap_cluster_info discard_cluster_head; /* list head of discard clusters */ 242 struct swap_cluster_list discard_clusters; /* discard clusters list */
239 struct swap_cluster_info discard_cluster_tail; /* list tail of discard clusters */
240}; 243};
241 244
242/* linux/mm/workingset.c */ 245/* linux/mm/workingset.c */
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index fc1e16c25a29..797100e10010 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -319,7 +319,6 @@ void laptop_mode_timer_fn(unsigned long data);
319#else 319#else
320static inline void laptop_sync_completion(void) { } 320static inline void laptop_sync_completion(void) { }
321#endif 321#endif
322void throttle_vm_writeout(gfp_t gfp_mask);
323bool node_dirty_ok(struct pglist_data *pgdat); 322bool node_dirty_ok(struct pglist_data *pgdat);
324int wb_domain_init(struct wb_domain *dom, gfp_t gfp); 323int wb_domain_init(struct wb_domain *dom, gfp_t gfp);
325#ifdef CONFIG_CGROUP_WRITEBACK 324#ifdef CONFIG_CGROUP_WRITEBACK