Skip to content

Commit b37a05c

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "18 fixes" [ The 18 fixes turned into 17 commits, because one of the fixes was a fix for another patch in the series that I just folded in by editing the patch manually - hopefully correctly - Linus ] * emailed patches from Andrew Morton <[email protected]>: mm: fix memory leak in copy_huge_pmd() drivers/hwspinlock: fix race between radix tree insertion and lookup radix-tree: fix race in gang lookup mm/vmpressure.c: fix subtree pressure detection mm: polish virtual memory accounting mm: warn about VmData over RLIMIT_DATA Documentation: cgroup-v2: add memory.stat::sock description mm: memcontrol: drop superfluous entry in the per-memcg stats array drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration proc: revert /proc/<pid>/maps [stack:TID] annotation numa: fix /proc/<pid>/numa_maps for hugetlbfs on s390 MAINTAINERS: update Seth email ocfs2/cluster: fix memory leak in o2hb_region_release lib/test-string_helpers.c: fix and improve string_get_size() tests thp: limit number of object to scan on deferred_split_scan() thp: change deferred_split_count() to return number of THP in queue thp: make split_queue per-node
2 parents d5bfb96 + 12c9d70 commit b37a05c

File tree

22 files changed

+269
-193
lines changed

22 files changed

+269
-193
lines changed

Documentation/cgroup-v2.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,10 @@ PAGE_SIZE multiple when read back.
843843
Amount of memory used to cache filesystem data,
844844
including tmpfs and shared memory.
845845

846+
sock
847+
848+
Amount of memory used in network transmission buffers
849+
846850
file_mapped
847851

848852
Amount of cached filesystem data mapped with mmap()

Documentation/filesystems/proc.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ Table 1-2: Contents of the status files (as of 4.1)
240240
RssFile size of resident file mappings
241241
RssShmem size of resident shmem memory (includes SysV shm,
242242
mapping of tmpfs and shared anonymous mappings)
243-
VmData size of data, stack, and text segments
244-
VmStk size of data, stack, and text segments
243+
VmData size of private data segments
244+
VmStk size of stack segments
245245
VmExe size of text segment
246246
VmLib size of shared library code
247247
VmPTE size of page table entries
@@ -356,7 +356,7 @@ address perms offset dev inode pathname
356356
a7cb1000-a7cb2000 ---p 00000000 00:00 0
357357
a7cb2000-a7eb2000 rw-p 00000000 00:00 0
358358
a7eb2000-a7eb3000 ---p 00000000 00:00 0
359-
a7eb3000-a7ed5000 rw-p 00000000 00:00 0 [stack:1001]
359+
a7eb3000-a7ed5000 rw-p 00000000 00:00 0
360360
a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6
361361
a8008000-a800a000 r--p 00133000 03:00 4222 /lib/libc.so.6
362362
a800a000-a800b000 rw-p 00135000 03:00 4222 /lib/libc.so.6
@@ -388,18 +388,15 @@ is not associated with a file:
388388

389389
[heap] = the heap of the program
390390
[stack] = the stack of the main process
391-
[stack:1001] = the stack of the thread with tid 1001
392391
[vdso] = the "virtual dynamic shared object",
393392
the kernel system call handler
394393

395394
or if empty, the mapping is anonymous.
396395

397396
The /proc/PID/task/TID/maps is a view of the virtual memory from the viewpoint
398397
of the individual tasks of a process. In this file you will see a mapping marked
399-
as [stack] if that task sees it as a stack. This is a key difference from the
400-
content of /proc/PID/maps, where you will see all mappings that are being used
401-
as stack by all of those tasks. Hence, for the example above, the task-level
402-
map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this:
398+
as [stack] if that task sees it as a stack. Hence, for the example above, the
399+
task-level map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this:
403400

404401
08048000-08049000 r-xp 00000000 03:00 8312 /opt/test
405402
08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test

Documentation/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
14961496
could change it dynamically, usually by
14971497
/sys/module/printk/parameters/ignore_loglevel.
14981498

1499+
ignore_rlimit_data
1500+
Ignore RLIMIT_DATA setting for data mappings,
1501+
print warning at first misuse. Can be changed via
1502+
/sys/module/kernel/parameters/ignore_rlimit_data.
1503+
14991504
ihash_entries= [KNL]
15001505
Set number of hash buckets for inode cache.
15011506

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12150,7 +12150,7 @@ F: drivers/net/hamradio/*scc.c
1215012150
F: drivers/net/hamradio/z8530.h
1215112151

1215212152
ZBUD COMPRESSED PAGE ALLOCATOR
12153-
M: Seth Jennings <[email protected]>
12153+
M: Seth Jennings <[email protected]>
1215412154
1215512155
S: Maintained
1215612156
F: mm/zbud.c
@@ -12205,7 +12205,7 @@ F: include/linux/zsmalloc.h
1220512205
F: Documentation/vm/zsmalloc.txt
1220612206

1220712207
ZSWAP COMPRESSED SWAP CACHING
12208-
M: Seth Jennings <[email protected]>
12208+
M: Seth Jennings <[email protected]>
1220912209
1221012210
S: Maintained
1221112211
F: mm/zswap.c

drivers/hwspinlock/hwspinlock_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ int of_hwspin_lock_get_id(struct device_node *np, int index)
313313
hwlock = radix_tree_deref_slot(slot);
314314
if (unlikely(!hwlock))
315315
continue;
316+
if (radix_tree_is_indirect_ptr(hwlock)) {
317+
slot = radix_tree_iter_retry(&iter);
318+
continue;
319+
}
316320

317321
if (hwlock->bank->dev->of_node == args.np) {
318322
ret = 0;

drivers/scsi/sg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
12611261
}
12621262

12631263
sfp->mmap_called = 1;
1264-
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
1264+
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
12651265
vma->vm_private_data = sfp;
12661266
vma->vm_ops = &sg_mmap_vm_ops;
12671267
return 0;

fs/ocfs2/cluster/heartbeat.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,15 +1254,15 @@ static const struct file_operations o2hb_debug_fops = {
12541254

12551255
void o2hb_exit(void)
12561256
{
1257-
kfree(o2hb_db_livenodes);
1258-
kfree(o2hb_db_liveregions);
1259-
kfree(o2hb_db_quorumregions);
1260-
kfree(o2hb_db_failedregions);
12611257
debugfs_remove(o2hb_debug_failedregions);
12621258
debugfs_remove(o2hb_debug_quorumregions);
12631259
debugfs_remove(o2hb_debug_liveregions);
12641260
debugfs_remove(o2hb_debug_livenodes);
12651261
debugfs_remove(o2hb_debug_dir);
1262+
kfree(o2hb_db_livenodes);
1263+
kfree(o2hb_db_liveregions);
1264+
kfree(o2hb_db_quorumregions);
1265+
kfree(o2hb_db_failedregions);
12661266
}
12671267

12681268
static struct dentry *o2hb_debug_create(const char *name, struct dentry *dir,
@@ -1438,13 +1438,15 @@ static void o2hb_region_release(struct config_item *item)
14381438

14391439
kfree(reg->hr_slots);
14401440

1441-
kfree(reg->hr_db_regnum);
1442-
kfree(reg->hr_db_livenodes);
14431441
debugfs_remove(reg->hr_debug_livenodes);
14441442
debugfs_remove(reg->hr_debug_regnum);
14451443
debugfs_remove(reg->hr_debug_elapsed_time);
14461444
debugfs_remove(reg->hr_debug_pinned);
14471445
debugfs_remove(reg->hr_debug_dir);
1446+
kfree(reg->hr_db_livenodes);
1447+
kfree(reg->hr_db_regnum);
1448+
kfree(reg->hr_debug_elapsed_time);
1449+
kfree(reg->hr_debug_pinned);
14481450

14491451
spin_lock(&o2hb_live_lock);
14501452
list_del(&reg->hr_all_item);

fs/proc/task_mmu.c

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,29 @@ static int do_maps_open(struct inode *inode, struct file *file,
259259
sizeof(struct proc_maps_private));
260260
}
261261

262-
static pid_t pid_of_stack(struct proc_maps_private *priv,
263-
struct vm_area_struct *vma, bool is_pid)
262+
/*
263+
* Indicate if the VMA is a stack for the given task; for
264+
* /proc/PID/maps that is the stack of the main task.
265+
*/
266+
static int is_stack(struct proc_maps_private *priv,
267+
struct vm_area_struct *vma, int is_pid)
264268
{
265-
struct inode *inode = priv->inode;
266-
struct task_struct *task;
267-
pid_t ret = 0;
269+
int stack = 0;
270+
271+
if (is_pid) {
272+
stack = vma->vm_start <= vma->vm_mm->start_stack &&
273+
vma->vm_end >= vma->vm_mm->start_stack;
274+
} else {
275+
struct inode *inode = priv->inode;
276+
struct task_struct *task;
268277

269-
rcu_read_lock();
270-
task = pid_task(proc_pid(inode), PIDTYPE_PID);
271-
if (task) {
272-
task = task_of_stack(task, vma, is_pid);
278+
rcu_read_lock();
279+
task = pid_task(proc_pid(inode), PIDTYPE_PID);
273280
if (task)
274-
ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info);
281+
stack = vma_is_stack_for_task(vma, task);
282+
rcu_read_unlock();
275283
}
276-
rcu_read_unlock();
277-
278-
return ret;
284+
return stack;
279285
}
280286

281287
static void
@@ -335,8 +341,6 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
335341

336342
name = arch_vma_name(vma);
337343
if (!name) {
338-
pid_t tid;
339-
340344
if (!mm) {
341345
name = "[vdso]";
342346
goto done;
@@ -348,21 +352,8 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
348352
goto done;
349353
}
350354

351-
tid = pid_of_stack(priv, vma, is_pid);
352-
if (tid != 0) {
353-
/*
354-
* Thread stack in /proc/PID/task/TID/maps or
355-
* the main process stack.
356-
*/
357-
if (!is_pid || (vma->vm_start <= mm->start_stack &&
358-
vma->vm_end >= mm->start_stack)) {
359-
name = "[stack]";
360-
} else {
361-
/* Thread stack in /proc/PID/maps */
362-
seq_pad(m, ' ');
363-
seq_printf(m, "[stack:%d]", tid);
364-
}
365-
}
355+
if (is_stack(priv, vma, is_pid))
356+
name = "[stack]";
366357
}
367358

368359
done:
@@ -1552,18 +1543,19 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
15521543
static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask,
15531544
unsigned long addr, unsigned long end, struct mm_walk *walk)
15541545
{
1546+
pte_t huge_pte = huge_ptep_get(pte);
15551547
struct numa_maps *md;
15561548
struct page *page;
15571549

1558-
if (!pte_present(*pte))
1550+
if (!pte_present(huge_pte))
15591551
return 0;
15601552

1561-
page = pte_page(*pte);
1553+
page = pte_page(huge_pte);
15621554
if (!page)
15631555
return 0;
15641556

15651557
md = walk->private;
1566-
gather_stats(page, md, pte_dirty(*pte), 1);
1558+
gather_stats(page, md, pte_dirty(huge_pte), 1);
15671559
return 0;
15681560
}
15691561

@@ -1617,19 +1609,8 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
16171609
seq_file_path(m, file, "\n\t= ");
16181610
} else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
16191611
seq_puts(m, " heap");
1620-
} else {
1621-
pid_t tid = pid_of_stack(proc_priv, vma, is_pid);
1622-
if (tid != 0) {
1623-
/*
1624-
* Thread stack in /proc/PID/task/TID/maps or
1625-
* the main process stack.
1626-
*/
1627-
if (!is_pid || (vma->vm_start <= mm->start_stack &&
1628-
vma->vm_end >= mm->start_stack))
1629-
seq_puts(m, " stack");
1630-
else
1631-
seq_printf(m, " stack:%d", tid);
1632-
}
1612+
} else if (is_stack(proc_priv, vma, is_pid)) {
1613+
seq_puts(m, " stack");
16331614
}
16341615

16351616
if (is_vm_hugetlb_page(vma))

fs/proc/task_nommu.c

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,26 @@ unsigned long task_statm(struct mm_struct *mm,
123123
return size;
124124
}
125125

126-
static pid_t pid_of_stack(struct proc_maps_private *priv,
127-
struct vm_area_struct *vma, bool is_pid)
126+
static int is_stack(struct proc_maps_private *priv,
127+
struct vm_area_struct *vma, int is_pid)
128128
{
129-
struct inode *inode = priv->inode;
130-
struct task_struct *task;
131-
pid_t ret = 0;
132-
133-
rcu_read_lock();
134-
task = pid_task(proc_pid(inode), PIDTYPE_PID);
135-
if (task) {
136-
task = task_of_stack(task, vma, is_pid);
129+
struct mm_struct *mm = vma->vm_mm;
130+
int stack = 0;
131+
132+
if (is_pid) {
133+
stack = vma->vm_start <= mm->start_stack &&
134+
vma->vm_end >= mm->start_stack;
135+
} else {
136+
struct inode *inode = priv->inode;
137+
struct task_struct *task;
138+
139+
rcu_read_lock();
140+
task = pid_task(proc_pid(inode), PIDTYPE_PID);
137141
if (task)
138-
ret = task_pid_nr_ns(task, inode->i_sb->s_fs_info);
142+
stack = vma_is_stack_for_task(vma, task);
143+
rcu_read_unlock();
139144
}
140-
rcu_read_unlock();
141-
142-
return ret;
145+
return stack;
143146
}
144147

145148
/*
@@ -181,21 +184,9 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
181184
if (file) {
182185
seq_pad(m, ' ');
183186
seq_file_path(m, file, "");
184-
} else if (mm) {
185-
pid_t tid = pid_of_stack(priv, vma, is_pid);
186-
187-
if (tid != 0) {
188-
seq_pad(m, ' ');
189-
/*
190-
* Thread stack in /proc/PID/task/TID/maps or
191-
* the main process stack.
192-
*/
193-
if (!is_pid || (vma->vm_start <= mm->start_stack &&
194-
vma->vm_end >= mm->start_stack))
195-
seq_printf(m, "[stack]");
196-
else
197-
seq_printf(m, "[stack:%d]", tid);
198-
}
187+
} else if (mm && is_stack(priv, vma, is_pid)) {
188+
seq_pad(m, ' ');
189+
seq_printf(m, "[stack]");
199190
}
200191

201192
seq_putc(m, '\n');

include/linux/memcontrol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ enum mem_cgroup_stat_index {
5151
MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */
5252
MEM_CGROUP_STAT_NSTATS,
5353
/* default hierarchy stats */
54-
MEMCG_SOCK,
54+
MEMCG_SOCK = MEM_CGROUP_STAT_NSTATS,
5555
MEMCG_NR_STAT,
5656
};
5757

include/linux/mm.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,13 @@ extern unsigned int kobjsize(const void *objp);
201201
#endif
202202

203203
#ifdef CONFIG_STACK_GROWSUP
204-
#define VM_STACK_FLAGS (VM_GROWSUP | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
204+
#define VM_STACK VM_GROWSUP
205205
#else
206-
#define VM_STACK_FLAGS (VM_GROWSDOWN | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
206+
#define VM_STACK VM_GROWSDOWN
207207
#endif
208208

209+
#define VM_STACK_FLAGS (VM_STACK | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
210+
209211
/*
210212
* Special vmas that are non-mergable, non-mlock()able.
211213
* Note: mm/huge_memory.c VM_NO_THP depends on this definition.
@@ -1341,8 +1343,7 @@ static inline int stack_guard_page_end(struct vm_area_struct *vma,
13411343
!vma_growsup(vma->vm_next, addr);
13421344
}
13431345

1344-
extern struct task_struct *task_of_stack(struct task_struct *task,
1345-
struct vm_area_struct *vma, bool in_group);
1346+
int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t);
13461347

13471348
extern unsigned long move_page_tables(struct vm_area_struct *vma,
13481349
unsigned long old_addr, struct vm_area_struct *new_vma,

include/linux/mm_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ struct mm_struct {
424424
unsigned long total_vm; /* Total pages mapped */
425425
unsigned long locked_vm; /* Pages that have PG_mlocked set */
426426
unsigned long pinned_vm; /* Refcount permanently increased */
427-
unsigned long data_vm; /* VM_WRITE & ~VM_SHARED/GROWSDOWN */
428-
unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE */
429-
unsigned long stack_vm; /* VM_GROWSUP/DOWN */
427+
unsigned long data_vm; /* VM_WRITE & ~VM_SHARED & ~VM_STACK */
428+
unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE & ~VM_STACK */
429+
unsigned long stack_vm; /* VM_STACK */
430430
unsigned long def_flags;
431431
unsigned long start_code, end_code, start_data, end_data;
432432
unsigned long start_brk, brk, start_stack;

include/linux/mmzone.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,12 @@ typedef struct pglist_data {
682682
*/
683683
unsigned long first_deferred_pfn;
684684
#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
685+
686+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
687+
spinlock_t split_queue_lock;
688+
struct list_head split_queue;
689+
unsigned long split_queue_len;
690+
#endif
685691
} pg_data_t;
686692

687693
#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)

0 commit comments

Comments
 (0)