summaryrefslogtreecommitdiff
path: root/fs/proc/task_nommu.c
blob: 8f68827ed10e250d9635a6854dfa5fc0b953768f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

#include <linux/mm.h>
#include <linux/file.h>
#include <linux/mount.h>
#include <linux/seq_file.h>
#include "internal.h"

/*
 * Logic: we've got two memory sums for each process, "shared", and
 * "non-shared". Shared memory may get counted more then once, for
 * each process that owns it. Non-shared memory is counted
 * accurately.
 */
char *task_mem(struct mm_struct *mm, char *buffer)
{
	struct vm_list_struct *vml;
	unsigned long bytes = 0, sbytes = 0, slack = 0;
        
	down_read(&mm->mmap_sem);
	for (vml = mm->context.vmlist; vml; vml = vml->next) {
		if (!vml->vma)
			continue;

		bytes += kobjsize(vml);
		if (atomic_read(&mm->mm_count) > 1 ||
		    atomic_read(&vml->vma->vm_usage) > 1
		    ) {
			sbytes += kobjsize((void *) vml->vma->vm_start);
			sbytes += kobjsize(vml->vma);
		} else {
			bytes += kobjsize((void *) vml->vma->vm_start);
			bytes += kobjsize(vml->vma);
			slack += kobjsize((void *) vml->vma->vm_start) -
				(vml->vma->vm_end - vml->vma->vm_start);
		}
	}

	if (atomic_read(&mm->mm_count) > 1)
		sbytes += kobjsize(mm);
	else
		bytes += kobjsize(mm);
	
	if (current->fs && atomic_read(&current->fs->count) > 1)
		sbytes += kobjsize(current->fs);
	else
		bytes += kobjsize(current->fs);

	if (current->files && atomic_read(&current->files->count) > 1)
		sbytes += kobjsize(current->files);
	else
		bytes += kobjsize(current->files);

	if (current->sighand && atomic_read(&current->sighand->count) > 1)
		sbytes += kobjsize(current->sighand);
	else
		bytes += kobjsize(current->sighand);

	bytes += kobjsize(current); /* includes kernel stack */

	buffer += sprintf(buffer,
		"Mem:\t%8lu bytes\n"
		"Slack:\t%8lu bytes\n"
		"Shared:\t%8lu bytes\n",
		bytes, slack, sbytes);

	up_read(&mm->mmap_sem);
	return buffer;
}

unsigned long task_vsize(struct mm_struct *mm)
{
	struct vm_list_struct *tbp;
	unsigned long vsize = 0;

	down_read(&mm->mmap_sem);
	for (tbp = mm->context.vmlist; tbp; tbp = tbp->next) {
		if (tbp->vma)
			vsize += kobjsize((void *) tbp->vma->vm_start);
	}
	up_read(&mm->mmap_sem);
	return vsize;
}

int task_statm(struct mm_struct *mm, int *shared, int *text,
	       int *data, int *resident)
{
	struct vm_list_struct *tbp;
	int size = kobjsize(mm);

	down_read(&mm->mmap_sem);
	for (tbp = mm->context.vmlist; tbp; tbp = tbp->next) {
		size += kobjsize(tbp);
		if (tbp->vma) {
			size += kobjsize(tbp->vma);
			size += kobjsize((void *) tbp->vma->vm_start);
		}
	}

	size += (*text = mm->end_code - mm->start_code);
	size += (*data = mm->start_stack - mm->start_data);
	up_read(&mm->mmap_sem);
	*resident = size;
	return size;
}

int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
{
	struct vm_list_struct *vml;
	struct vm_area_struct *vma;
	struct task_struct *task = proc_task(inode);
	struct mm_struct *mm = get_task_mm(task);
	int result = -ENOENT;

	if (!mm)
		goto out;
	down_read(&mm->mmap_sem);

	vml = mm->context.vmlist;
	vma = NULL;
	while (vml) {
		if ((vml->vma->vm_flags & VM_EXECUTABLE) && vml->vma->vm_file) {
			vma = vml->vma;
			break;
		}
		vml = vml->next;
	}

	if (vma) {
		*mnt = mntget(vma->vm_file->f_vfsmnt);
		*dentry = dget(vma->vm_file->f_dentry);
		result = 0;
	}

	up_read(&mm->mmap_sem);
	mmput(mm);
out:
	return result;
}

/*
 * Albert D. Cahalan suggested to fake entries for the traditional
 * sections here.  This might be worth investigating.
 */
static int show_map(struct seq_file *m, void *v)
{
	return 0;
}
static void *m_start(struct seq_file *m, loff_t *pos)
{
	return NULL;
}
static void m_stop(struct seq_file *m, void *v)
{
}
static void *m_next(struct seq_file *m, void *v, loff_t *pos)
{
	return NULL;
}
struct seq_operations proc_pid_maps_op = {
	.start	= m_start,
	.next	= m_next,
	.stop	= m_stop,
	.show	= show_map
};
-1'>libreoffice-7-1 Unnamed repository; edit this file to name it for gitweb.root
summaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2021-03-23update translations for 7.1.2 rc2libreoffice-7-1-2Christian Lohmaier314-6617/+9417
2021-03-10Branch libreoffice-7-1-2Christian Lohmaier0-0/+0
2021-03-10update translations for 7.1.2 rc1Christian Lohmaier766-16529/+15597
2021-02-24update translations for 7.1.1 rc2Christian Lohmaier325-12581/+9846
2021-02-10update translations for 7.1.1 rc1Christian Lohmaier472-10839/+13987
2021-01-30update translations for 7.1Christian Lohmaier2614-713524/+714656
2021-01-27update translations for 7.1.0 rc3Christian Lohmaier698-9947/+12515
2021-01-14update translations for 7.1.0 rc2Christian Lohmaier1483-41838/+33401
2021-01-12Updated Slovenian translationAndras Timar18-89/+89
2020-12-19Updated Slovenian translationAndras Timar26-207/+268
2020-12-17update translations for 7.1.0 rc1Christian Lohmaier375-8997/+19667
2020-12-16Updated Slovenian translationAndras Timar39-12377/+13041
2020-12-15update translations for master/7.1.0 rc1Christian Lohmaier842-16052/+21543
2020-12-08update translations for master/7.1Christian Lohmaier1659-79133/+67947
2020-11-22Branch libreoffice-7-1Christian Lohmaier0-0/+0
2020-11-22update translations for master/7.1 beta1libreoffice-7-1-branch-pointChristian Lohmaier1523-114197/+182451
2020-11-16update translations for masterChristian Lohmaier4191-1762909/+1833287
2020-11-15Updated Slovenian translationAndras Timar36-885/+976
2020-11-15Updated Slovenian translationAndras Timar79-22199/+47451
2020-11-11Typos for an_ES.poJulien Nabet1-1/+1
2020-10-27update translations for masterChristian Lohmaier837-30560/+27273
2020-10-27update translations for master / 7.1.0.0 alpha1Christian Lohmaier