Release 4.11 fs/proc/task_nommu.c
#include <linux/mm.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/fs_struct.h>
#include <linux/mount.h>
#include <linux/ptrace.h>
#include <linux/slab.h>
#include <linux/seq_file.h>
#include <linux/sched/mm.h>
#include "internal.h"
/*
* Logic: we've got two memory sums for each process, "shared", and
* "non-shared". Shared memory may get counted more than once, for
* each process that owns it. Non-shared memory is counted
* accurately.
*/
void task_mem(struct seq_file *m, struct mm_struct *mm)
{
struct vm_area_struct *vma;
struct vm_region *region;
struct rb_node *p;
unsigned long bytes = 0, sbytes = 0, slack = 0, size;
down_read(&mm->mmap_sem);
for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
vma = rb_entry(p, struct vm_area_struct, vm_rb);
bytes += kobjsize(vma);
region = vma->vm_region;
if (region) {
size = kobjsize(region);
size += region->vm_end - region->vm_start;
} else {
size = vma->vm_end - vma->vm_start;
}
if (atomic_read(&mm->mm_count) > 1 ||
vma->vm_flags & VM_MAYSHARE) {
sbytes += size;
} else {
bytes += size;
if (region)
slack = region->vm_end - vma->vm_end;
}
}
if (atomic_read(&mm->mm_count) > 1)
sbytes += kobjsize(mm);
else
bytes += kobjsize(mm);
if (current->fs && current->fs->users > 1)
sbytes += kobjsize(current->fs);
else
bytes += kobjsize(current->fs);
if (current->files && atomic_read(¤t->files->count) > 1)
sbytes += kobjsize(current->files);
else
bytes += kobjsize(current->files);
if (current->sighand && atomic_read(¤t->sighand->count) > 1)
sbytes += kobjsize(current->sighand);
else
bytes += kobjsize(current->sighand);
bytes += kobjsize(current); /* includes kernel stack */
seq_printf(m,
"Mem:\t%8lu bytes\n"
"Slack:\t%8lu bytes\n"
"Shared:\t%8lu bytes\n",
bytes, slack, sbytes);
up_read(&mm->mmap_sem);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christoph Hellwig | 234 | 67.24% | 1 | 12.50% |
David Howells | 101 | 29.02% | 4 | 50.00% |
Eric W. Biedermann | 8 | 2.30% | 1 | 12.50% |
Greg Ungerer | 4 | 1.15% | 1 | 12.50% |
Al Viro | 1 | 0.29% | 1 | 12.50% |
Total | 348 | 100.00% | 8 | 100.00% |
unsigned long task_vsize(struct mm_struct *mm)
{
struct vm_area_struct *vma;
struct rb_node *p;
unsigned long vsize = 0;
down_read(&mm->mmap_sem);
for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
vma = rb_entry(p, struct vm_area_struct, vm_rb);
vsize += vma->vm_end - vma->vm_start;
}
up_read(&mm->mmap_sem);
return vsize;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 37 | 40.66% | 2 | 40.00% |
Christoph Hellwig | 36 | 39.56% | 1 | 20.00% |
William Lee Irwin III | 16 | 17.58% | 1 | 20.00% |
Greg Ungerer | 2 | 2.20% | 1 | 20.00% |
Total | 91 | 100.00% | 5 | 100.00% |
unsigned long task_statm(struct mm_struct *mm,
unsigned long *shared, unsigned long *text,
unsigned long *data, unsigned long *resident)
{
struct vm_area_struct *vma;
struct vm_region *region;
struct rb_node *p;
unsigned long size = kobjsize(mm);
down_read(&mm->mmap_sem);
for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
vma = rb_entry(p, struct vm_area_struct, vm_rb);
size += kobjsize(vma);
region = vma->vm_region;
if (region) {
size += kobjsize(region);
size += region->vm_end - region->vm_start;
}
}
*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
>> PAGE_SHIFT;
*data = (PAGE_ALIGN(mm->start_stack) - (mm->start_data & PAGE_MASK))
>> PAGE_SHIFT;
up_read(&mm->mmap_sem);
size >>= PAGE_SHIFT;
size += *text + *data;
*resident = size;
return size;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christoph Hellwig | 87 | 42.23% | 1 | 12.50% |
David Howells | 57 | 27.67% | 3 | 37.50% |
Steven J. Magnani | 32 | 15.53% | 1 | 12.50% |
William Lee Irwin III | 16 | 7.77% | 1 | 12.50% |
Alexey Dobriyan | 12 | 5.83% | 1 | 12.50% |
Greg Ungerer | 2 | 0.97% | 1 | 12.50% |
Total | 206 | 100.00% | 8 | 100.00% |
static int is_stack(struct proc_maps_private *priv,
struct vm_area_struct *vma)
{
struct mm_struct *mm = vma->vm_mm;
/*
* We make no effort to guess what a given thread considers to be
* its "stack". It's not even well-defined for programs written
* languages like Go.
*/
return vma->vm_start <= mm->start_stack &&
vma->vm_end >= mm->start_stack;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johannes Weiner | 25 | 58.14% | 1 | 33.33% |
Oleg Nesterov | 16 | 37.21% | 1 | 33.33% |
Andrew Lutomirski | 2 | 4.65% | 1 | 33.33% |
Total | 43 | 100.00% | 3 | 100.00% |
/*
* display a single VMA to a sequenced file
*/
static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
int is_pid)
{
struct mm_struct *mm = vma->vm_mm;
struct proc_maps_private *priv = m->private;
unsigned long ino = 0;
struct file *file;
dev_t dev = 0;
int flags;
unsigned long long pgoff = 0;
flags = vma->vm_flags;
file = vma->vm_file;
if (file) {
struct inode *inode = file_inode(vma->vm_file);
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
}
seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_printf(m,
"%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
vma->vm_start,
vma->vm_end,
flags & VM_READ ? 'r' : '-',
flags & VM_WRITE ? 'w' : '-',
flags & VM_EXEC ? 'x' : '-',
flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
pgoff,
MAJOR(dev), MINOR(dev), ino);
if (file) {
seq_pad(m, ' ');
seq_file_path(m, file, "");
} else if (mm && is_stack(priv, vma)) {
seq_pad(m, ' ');
seq_printf(m, "[stack]");
}
seq_putc(m, '\n');
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 170 | 64.89% | 1 | 11.11% |
Siddhesh Poyarekar | 26 | 9.92% | 1 | 11.11% |
Tetsuo Handa | 22 | 8.40% | 1 | 11.11% |
Mike Frysinger | 19 | 7.25% | 1 | 11.11% |
Kamezawa Hiroyuki | 18 | 6.87% | 1 | 11.11% |
Al Viro | 3 | 1.15% | 1 | 11.11% |
Johannes Weiner | 2 | 0.76% | 1 | 11.11% |
Miklos Szeredi | 1 | 0.38% | 1 | 11.11% |
Nobuhiro Iwamatsu | 1 | 0.38% | 1 | 11.11% |
Total | 262 | 100.00% | 9 | 100.00% |
/*
* display mapping lines for a particular process's /proc/pid/maps
*/
static int show_map(struct seq_file *m, void *_p, int is_pid)
{
struct rb_node *p = _p;
return nommu_vma_show(m, rb_entry(p, struct vm_area_struct, vm_rb),
is_pid);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 21 | 48.84% | 2 | 40.00% |
Andrew Morton | 10 | 23.26% | 1 | 20.00% |
Siddhesh Poyarekar | 8 | 18.60% | 1 | 20.00% |
Christoph Hellwig | 4 | 9.30% | 1 | 20.00% |
Total | 43 | 100.00% | 5 | 100.00% |
static int show_pid_map(struct seq_file *m, void *_p)
{
return show_map(m, _p, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Siddhesh Poyarekar | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
static int show_tid_map(struct seq_file *m, void *_p)
{
return show_map(m, _p, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Siddhesh Poyarekar | 22 | 88.00% | 1 | 33.33% |
Andrew Morton | 2 | 8.00% | 1 | 33.33% |
David Howells | 1 | 4.00% | 1 | 33.33% |
Total | 25 | 100.00% | 3 | 100.00% |
static void *m_start(struct seq_file *m, loff_t *pos)
{
struct proc_maps_private *priv = m->private;
struct mm_struct *mm;
struct rb_node *p;
loff_t n = *pos;
/* pin the task and mm whilst we play with them */
priv->task = get_proc_task(priv->inode);
if (!priv->task)
return ERR_PTR(-ESRCH);
mm = priv->mm;
if (!mm || !mmget_not_zero(mm))
return NULL;
down_read(&mm->mmap_sem);
/* start from the Nth VMA */
for (p = rb_first(&mm->mm_rb); p; p = rb_next(p))
if (n-- == 0)
return p;
up_read(&mm->mmap_sem);
mmput(mm);
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 88 | 61.54% | 2 | 20.00% |
Oleg Nesterov | 26 | 18.18% | 4 | 40.00% |
Andrew Morton | 16 | 11.19% | 1 | 10.00% |
Al Viro | 9 | 6.29% | 1 | 10.00% |
Christoph Hellwig | 3 | 2.10% | 1 | 10.00% |
Vegard Nossum | 1 | 0.70% | 1 | 10.00% |
Total | 143 | 100.00% | 10 | 100.00% |
static void m_stop(struct seq_file *m, void *_vml)
{
struct proc_maps_private *priv = m->private;
if (!IS_ERR_OR_NULL(_vml)) {
up_read(&priv->mm->mmap_sem);
mmput(priv->mm);
}
if (priv->task) {
put_task_struct(priv->task);
priv->task = NULL;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 37 | 51.39% | 1 | 25.00% |
Oleg Nesterov | 23 | 31.94% | 1 | 25.00% |
Andrew Morton | 10 | 13.89% | 1 | 25.00% |
Christoph Hellwig | 2 | 2.78% | 1 | 25.00% |
Total | 72 | 100.00% | 4 | 100.00% |
static void *m_next(struct seq_file *m, void *_p, loff_t *pos)
{
struct rb_node *p = _p;
(*pos)++;
return p ? rb_next(p) : NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 21 | 48.84% | 2 | 50.00% |
Andrew Morton | 14 | 32.56% | 1 | 25.00% |
Christoph Hellwig | 8 | 18.60% | 1 | 25.00% |
Total | 43 | 100.00% | 4 | 100.00% |
static const struct seq_operations proc_pid_maps_ops = {
.start = m_start,
.next = m_next,
.stop = m_stop,
.show = show_pid_map
};
static const struct seq_operations proc_tid_maps_ops = {
.start = m_start,
.next = m_next,
.stop = m_stop,
.show = show_tid_map
};
static int maps_open(struct inode *inode, struct file *file,
const struct seq_operations *ops)
{
struct proc_maps_private *priv;
priv = __seq_open_private(file, ops, sizeof(*priv));
if (!priv)
return -ENOMEM;
priv->inode = inode;
priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
if (IS_ERR(priv->mm)) {
int err = PTR_ERR(priv->mm);
seq_release_private(inode, file);
return err;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oleg Nesterov | 56 | 54.90% | 3 | 50.00% |
David Howells | 22 | 21.57% | 1 | 16.67% |
Eric W. Biedermann | 18 | 17.65% | 1 | 16.67% |
Siddhesh Poyarekar | 6 | 5.88% | 1 | 16.67% |
Total | 102 | 100.00% | 6 | 100.00% |
static int map_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = file->private_data;
struct proc_maps_private *priv = seq->private;
if (priv->mm)
mmdrop(priv->mm);
return seq_release_private(inode, file);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oleg Nesterov | 55 | 100.00% | 1 | 100.00% |
Total | 55 | 100.00% | 1 | 100.00% |
static int pid_maps_open(struct inode *inode, struct file *file)
{
return maps_open(inode, file, &proc_pid_maps_ops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Siddhesh Poyarekar | 27 | 100.00% | 1 | 100.00% |
Total | 27 | 100.00% | 1 | 100.00% |
static int tid_maps_open(struct inode *inode, struct file *file)
{
return maps_open(inode, file, &proc_tid_maps_ops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Siddhesh Poyarekar | 27 | 100.00% | 1 | 100.00% |
Total | 27 | 100.00% | 1 | 100.00% |
const struct file_operations proc_pid_maps_operations = {
.open = pid_maps_open,
.read = seq_read,
.llseek = seq_lseek,
.release = map_release,
};
const struct file_operations proc_tid_maps_operations = {
.open = tid_maps_open,
.read = seq_read,
.llseek = seq_lseek,
.release = map_release,
};
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Howells | 564 | 34.08% | 5 | 12.50% |
Christoph Hellwig | 377 | 22.78% | 1 | 2.50% |
Siddhesh Poyarekar | 198 | 11.96% | 1 | 2.50% |
Oleg Nesterov | 178 | 10.76% | 6 | 15.00% |
Andrew Morton | 79 | 4.77% | 1 | 2.50% |
Eric W. Biedermann | 50 | 3.02% | 2 | 5.00% |
Steven J. Magnani | 32 | 1.93% | 1 | 2.50% |
William Lee Irwin III | 32 | 1.93% | 2 | 5.00% |
Johannes Weiner | 27 | 1.63% | 1 | 2.50% |
Tetsuo Handa | 22 | 1.33% | 1 | 2.50% |
Mike Frysinger | 19 | 1.15% | 1 | 2.50% |
Kamezawa Hiroyuki | 18 | 1.09% | 1 | 2.50% |
Al Viro | 16 | 0.97% | 4 | 10.00% |
Alexey Dobriyan | 12 | 0.73% | 1 | 2.50% |
Greg Ungerer | 11 | 0.66% | 1 | 2.50% |
Kees Cook | 3 | 0.18% | 1 | 2.50% |
Bryan Wu | 3 | 0.18% | 1 | 2.50% |
Ingo Molnar | 3 | 0.18% | 1 | 2.50% |
Tejun Heo | 3 | 0.18% | 1 | 2.50% |
Andrew Lutomirski | 2 | 0.12% | 1 | 2.50% |
Jan Engelhardt | 1 | 0.06% | 1 | 2.50% |
Nobuhiro Iwamatsu | 1 | 0.06% | 1 | 2.50% |
Arjan van de Ven | 1 | 0.06% | 1 | 2.50% |
Frederik Schwarzer | 1 | 0.06% | 1 | 2.50% |
Vegard Nossum | 1 | 0.06% | 1 | 2.50% |
Miklos Szeredi | 1 | 0.06% | 1 | 2.50% |
Total | 1655 | 100.00% | 40 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.