Skip to content

Commit 9f45efb

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc updates from Andrew Morton: - a few hotfixes - various misc updates - ocfs2 updates - most of MM * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (108 commits) mm, memory_hotplug: move movable_node to the hotplug proper mm, memory_hotplug: drop CONFIG_MOVABLE_NODE mm, memory_hotplug: drop artificial restriction on online/offline mm: memcontrol: account slab stats per lruvec mm: memcontrol: per-lruvec stats infrastructure mm: memcontrol: use generic mod_memcg_page_state for kmem pages mm: memcontrol: use the node-native slab memory counters mm: vmstat: move slab statistics from zone to node counters mm/zswap.c: delete an error message for a failed memory allocation in zswap_dstmem_prepare() mm/zswap.c: improve a size determination in zswap_frontswap_init() mm/zswap.c: delete an error message for a failed memory allocation in zswap_pool_create() mm/swapfile.c: sort swap entries before free mm/oom_kill: count global and memory cgroup oom kills mm: per-cgroup memory reclaim stats mm: kmemleak: treat vm_struct as alternative reference to vmalloc'ed objects mm: kmemleak: factor object reference updating out of scan_block() mm: kmemleak: slightly reduce the size of some structures on 64-bit architectures mm, mempolicy: don't check cpuset seqlock where it doesn't matter mm, cpuset: always use seqlock when changing task's nodemask mm, mempolicy: simplify rebinding mempolicies when updating cpusets ...
2 parents dc50214 + 4932381 commit 9f45efb

131 files changed

Lines changed: 3093 additions & 1723 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,8 +2315,11 @@
23152315
that the amount of memory usable for all allocations
23162316
is not too small.
23172317

2318-
movable_node [KNL] Boot-time switch to enable the effects
2319-
of CONFIG_MOVABLE_NODE=y. See mm/Kconfig for details.
2318+
movable_node [KNL] Boot-time switch to make hotplugable memory
2319+
NUMA nodes to be movable. This means that the memory
2320+
of such nodes will be usable only for movable
2321+
allocations which rules out almost all kernel
2322+
allocations. Use with caution!
23202323

23212324
MTD_Partition= [MTD]
23222325
Format: <name>,<region-number>,<size>,<offset>
@@ -3772,8 +3775,14 @@
37723775
slab_nomerge [MM]
37733776
Disable merging of slabs with similar size. May be
37743777
necessary if there is some reason to distinguish
3775-
allocs to different slabs. Debug options disable
3776-
merging on their own.
3778+
allocs to different slabs, especially in hardened
3779+
environments where the risk of heap overflows and
3780+
layout control by attackers can usually be
3781+
frustrated by disabling merging. This will reduce
3782+
most of the exposure of a heap attack to a single
3783+
cache (risks via metadata attacks are mostly
3784+
unchanged). Debug options disable merging on their
3785+
own.
37773786
For more information see Documentation/vm/slub.txt.
37783787

37793788
slab_max_order= [MM, SLAB]

‎Documentation/cgroup-v2.txt‎

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,25 @@ PAGE_SIZE multiple when read back.
852852

853853
The number of times the cgroup's memory usage was
854854
about to go over the max boundary. If direct reclaim
855-
fails to bring it down, the OOM killer is invoked.
855+
fails to bring it down, the cgroup goes to OOM state.
856856

857857
oom
858858

859-
The number of times the OOM killer has been invoked in
860-
the cgroup. This may not exactly match the number of
861-
processes killed but should generally be close.
859+
The number of time the cgroup's memory usage was
860+
reached the limit and allocation was about to fail.
861+
862+
Depending on context result could be invocation of OOM
863+
killer and retrying allocation or failing alloction.
864+
865+
Failed allocation in its turn could be returned into
866+
userspace as -ENOMEM or siletly ignored in cases like
867+
disk readahead. For now OOM in memory cgroup kills
868+
tasks iff shortage has happened inside page fault.
869+
870+
oom_kill
871+
872+
The number of processes belonging to this cgroup
873+
killed by any kind of OOM killer.
862874

863875
memory.stat
864876

@@ -956,6 +968,34 @@ PAGE_SIZE multiple when read back.
956968

957969
Number of times a shadow node has been reclaimed
958970

971+
pgrefill
972+
973+
Amount of scanned pages (in an active LRU list)
974+
975+
pgscan
976+
977+
Amount of scanned pages (in an inactive LRU list)
978+
979+
pgsteal
980+
981+
Amount of reclaimed pages
982+
983+
pgactivate
984+
985+
Amount of pages moved to the active LRU list
986+
987+
pgdeactivate
988+
989+
Amount of pages moved to the inactive LRU lis
990+
991+
pglazyfree
992+
993+
Amount of pages postponed to be freed under memory pressure
994+
995+
pglazyfreed
996+
997+
Amount of reclaimed lazyfree pages
998+
959999
memory.swap.current
9601000

9611001
A read-only single value file which exists on non-root

‎Documentation/dev-tools/kmemleak.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ See the include/linux/kmemleak.h header for the functions prototype.
150150
- ``kmemleak_init`` - initialize kmemleak
151151
- ``kmemleak_alloc`` - notify of a memory block allocation
152152
- ``kmemleak_alloc_percpu`` - notify of a percpu memory block allocation
153+
- ``kmemleak_vmalloc`` - notify of a vmalloc() memory allocation
153154
- ``kmemleak_free`` - notify of a memory block freeing
154155
- ``kmemleak_free_part`` - notify of a partial memory block freeing
155156
- ``kmemleak_free_percpu`` - notify of a percpu memory block freeing

‎Documentation/vm/ksm.txt‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,50 @@ use_zero_pages - specifies whether empty pages (i.e. allocated pages
9898
it is only effective for pages merged after the change.
9999
Default: 0 (normal KSM behaviour as in earlier releases)
100100

101+
max_page_sharing - Maximum sharing allowed for each KSM page. This
102+
enforces a deduplication limit to avoid the virtual
103+
memory rmap lists to grow too large. The minimum
104+
value is 2 as a newly created KSM page will have at
105+
least two sharers. The rmap walk has O(N)
106+
complexity where N is the number of rmap_items
107+
(i.e. virtual mappings) that are sharing the page,
108+
which is in turn capped by max_page_sharing. So
109+
this effectively spread the the linear O(N)
110+
computational complexity from rmap walk context
111+
over different KSM pages. The ksmd walk over the
112+
stable_node "chains" is also O(N), but N is the
113+
number of stable_node "dups", not the number of
114+
rmap_items, so it has not a significant impact on
115+
ksmd performance. In practice the best stable_node
116+
"dup" candidate will be kept and found at the head
117+
of the "dups" list. The higher this value the
118+
faster KSM will merge the memory (because there
119+
will be fewer stable_node dups queued into the
120+
stable_node chain->hlist to check for pruning) and
121+
the higher the deduplication factor will be, but
122+
the slowest the worst case rmap walk could be for
123+
any given KSM page. Slowing down the rmap_walk
124+
means there will be higher latency for certain
125+
virtual memory operations happening during
126+
swapping, compaction, NUMA balancing and page
127+
migration, in turn decreasing responsiveness for
128+
the caller of those virtual memory operations. The
129+
scheduler latency of other tasks not involved with
130+
the VM operations doing the rmap walk is not
131+
affected by this parameter as the rmap walks are
132+
always schedule friendly themselves.
133+
134+
stable_node_chains_prune_millisecs - How frequently to walk the whole
135+
list of stable_node "dups" linked in the
136+
stable_node "chains" in order to prune stale
137+
stable_nodes. Smaller milllisecs values will free
138+
up the KSM metadata with lower latency, but they
139+
will make ksmd use more CPU during the scan. This
140+
only applies to the stable_node chains so it's a
141+
noop if not a single KSM page hit the
142+
max_page_sharing yet (there would be no stable_node
143+
chains in such case).
144+
101145
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
102146

103147
pages_shared - how many shared pages are being used
@@ -106,10 +150,29 @@ pages_unshared - how many pages unique but repeatedly checked for merging
106150
pages_volatile - how many pages changing too fast to be placed in a tree
107151
full_scans - how many times all mergeable areas have been scanned
108152

153+
stable_node_chains - number of stable node chains allocated, this is
154+
effectively the number of KSM pages that hit the
155+
max_page_sharing limit
156+
stable_node_dups - number of stable node dups queued into the
157+
stable_node chains
158+
109159
A high ratio of pages_sharing to pages_shared indicates good sharing, but
110160
a high ratio of pages_unshared to pages_sharing indicates wasted effort.
111161
pages_volatile embraces several different kinds of activity, but a high
112162
proportion there would also indicate poor use of madvise MADV_MERGEABLE.
113163

164+
The maximum possible page_sharing/page_shared ratio is limited by the
165+
max_page_sharing tunable. To increase the ratio max_page_sharing must
166+
be increased accordingly.
167+
168+
The stable_node_dups/stable_node_chains ratio is also affected by the
169+
max_page_sharing tunable, and an high ratio may indicate fragmentation
170+
in the stable_node dups, which could be solved by introducing
171+
fragmentation algorithms in ksmd which would refile rmap_items from
172+
one stable_node dup to another stable_node dup, in order to freeup
173+
stable_node "dups" with few rmap_items in them, but that may increase
174+
the ksmd CPU usage and possibly slowdown the readonly computations on
175+
the KSM pages of the applications.
176+
114177
Izik Eidus,
115178
Hugh Dickins, 17 Nov 2009

‎arch/arm64/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ config ARM64
1313
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
1414
select ARCH_HAS_ELF_RANDOMIZE
1515
select ARCH_HAS_GCOV_PROFILE_ALL
16-
select ARCH_HAS_GIGANTIC_PAGE
16+
select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
1717
select ARCH_HAS_KCOV
1818
select ARCH_HAS_SET_MEMORY
1919
select ARCH_HAS_SG_CHAIN

‎arch/arm64/include/asm/hugetlb.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@ extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
8383
extern void huge_ptep_clear_flush(struct vm_area_struct *vma,
8484
unsigned long addr, pte_t *ptep);
8585

86+
#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
87+
static inline bool gigantic_page_supported(void) { return true; }
88+
#endif
89+
8690
#endif /* __ASM_HUGETLB_H */

‎arch/arm64/mm/hugetlbpage.c‎

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ int pud_huge(pud_t pud)
4242
}
4343

4444
static int find_num_contig(struct mm_struct *mm, unsigned long addr,
45-
pte_t *ptep, pte_t pte, size_t *pgsize)
45+
pte_t *ptep, size_t *pgsize)
4646
{
4747
pgd_t *pgd = pgd_offset(mm, addr);
4848
pud_t *pud;
4949
pmd_t *pmd;
5050

5151
*pgsize = PAGE_SIZE;
52-
if (!pte_cont(pte))
53-
return 1;
5452
pud = pud_offset(pgd, addr);
5553
pmd = pmd_offset(pud, addr);
5654
if ((pte_t *)pmd == ptep) {
@@ -65,15 +63,16 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
6563
{
6664
size_t pgsize;
6765
int i;
68-
int ncontig = find_num_contig(mm, addr, ptep, pte, &pgsize);
66+
int ncontig;
6967
unsigned long pfn;
7068
pgprot_t hugeprot;
7169

72-
if (ncontig == 1) {
70+
if (!pte_cont(pte)) {
7371
set_pte_at(mm, addr, ptep, pte);
7472
return;
7573
}
7674

75+
ncontig = find_num_contig(mm, addr, ptep, &pgsize);
7776
pfn = pte_pfn(pte);
7877
hugeprot = __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
7978
for (i = 0; i < ncontig; i++) {
@@ -132,7 +131,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
132131
return pte;
133132
}
134133

135-
pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
134+
pte_t *huge_pte_offset(struct mm_struct *mm,
135+
unsigned long addr, unsigned long sz)
136136
{
137137
pgd_t *pgd;
138138
pud_t *pud;
@@ -184,21 +184,19 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
184184
if (pte_cont(*ptep)) {
185185
int ncontig, i;
186186
size_t pgsize;
187-
pte_t *cpte;
188187
bool is_dirty = false;
189188

190-
cpte = huge_pte_offset(mm, addr);
191-
ncontig = find_num_contig(mm, addr, cpte, *cpte, &pgsize);
189+
ncontig = find_num_contig(mm, addr, ptep, &pgsize);
192190
/* save the 1st pte to return */
193-
pte = ptep_get_and_clear(mm, addr, cpte);
191+
pte = ptep_get_and_clear(mm, addr, ptep);
194192
for (i = 1, addr += pgsize; i < ncontig; ++i, addr += pgsize) {
195193
/*
196194
* If HW_AFDBM is enabled, then the HW could
197195
* turn on the dirty bit for any of the page
198196
* in the set, so check them all.
199197
*/
200-
++cpte;
201-
if (pte_dirty(ptep_get_and_clear(mm, addr, cpte)))
198+
++ptep;
199+
if (pte_dirty(ptep_get_and_clear(mm, addr, ptep)))
202200
is_dirty = true;
203201
}
204202
if (is_dirty)
@@ -214,8 +212,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
214212
unsigned long addr, pte_t *ptep,
215213
pte_t pte, int dirty)
216214
{
217-
pte_t *cpte;
218-
219215
if (pte_cont(pte)) {
220216
int ncontig, i, changed = 0;
221217
size_t pgsize = 0;
@@ -225,12 +221,11 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
225221
__pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^
226222
pte_val(pte));
227223

228-
cpte = huge_pte_offset(vma->vm_mm, addr);
229-
pfn = pte_pfn(*cpte);
230-
ncontig = find_num_contig(vma->vm_mm, addr, cpte,
231-
*cpte, &pgsize);
232-
for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize) {
233-
changed |= ptep_set_access_flags(vma, addr, cpte,
224+
pfn = pte_pfn(pte);
225+
ncontig = find_num_contig(vma->vm_mm, addr, ptep,
226+
&pgsize);
227+
for (i = 0; i < ncontig; ++i, ++ptep, addr += pgsize) {
228+
changed |= ptep_set_access_flags(vma, addr, ptep,
234229
pfn_pte(pfn,
235230
hugeprot),
236231
dirty);
@@ -247,13 +242,11 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm,
247242
{
248243
if (pte_cont(*ptep)) {
249244
int ncontig, i;
250-
pte_t *cpte;
251245
size_t pgsize = 0;
252246

253-
cpte = huge_pte_offset(mm, addr);
254-
ncontig = find_num_contig(mm, addr, cpte, *cpte, &pgsize);
255-
for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize)
256-
ptep_set_wrprotect(mm, addr, cpte);
247+
ncontig = find_num_contig(mm, addr, ptep, &pgsize);
248+
for (i = 0; i < ncontig; ++i, ++ptep, addr += pgsize)
249+
ptep_set_wrprotect(mm, addr, ptep);
257250
} else {
258251
ptep_set_wrprotect(mm, addr, ptep);
259252
}
@@ -264,14 +257,12 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma,
264257
{
265258
if (pte_cont(*ptep)) {
266259
int ncontig, i;
267-
pte_t *cpte;
268260
size_t pgsize = 0;
269261

270-
cpte = huge_pte_offset(vma->vm_mm, addr);
271-
ncontig = find_num_contig(vma->vm_mm, addr, cpte,
272-
*cpte, &pgsize);
273-
for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize)
274-
ptep_clear_flush(vma, addr, cpte);
262+
ncontig = find_num_contig(vma->vm_mm, addr, ptep,
263+
&pgsize);
264+
for (i = 0; i < ncontig; ++i, ++ptep, addr += pgsize)
265+
ptep_clear_flush(vma, addr, ptep);
275266
} else {
276267
ptep_clear_flush(vma, addr, ptep);
277268
}

‎arch/hexagon/include/asm/pgtable.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
/*
2525
* Page table definitions for Qualcomm Hexagon processor.
2626
*/
27-
#include <linux/swap.h>
2827
#include <asm/page.h>
2928
#define __ARCH_USE_5LEVEL_HACK
3029
#include <asm-generic/pgtable-nopmd.h>

‎arch/hexagon/kernel/asm-offsets.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/compat.h>
2626
#include <linux/types.h>
2727
#include <linux/sched.h>
28-
#include <linux/mm.h>
2928
#include <linux/interrupt.h>
3029
#include <linux/kbuild.h>
3130
#include <asm/ptrace.h>

‎arch/hexagon/mm/vm_tlb.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* be instantiated for it, differently from a native build.
2525
*/
2626
#include <linux/mm.h>
27+
#include <linux/sched.h>
2728
#include <asm/page.h>
2829
#include <asm/hexagon_vm.h>
2930

0 commit comments

Comments
 (0)