Module Name: src
Committed By: mlelstv
Date: Mon Mar 28 17:23:47 UTC 2016
Modified Files:
src/sys/miscfs/procfs: procfs_linux.c
Log Message:
Align /proc/<pid>/statm data with /proc/<pid>/stat and
provide RSS information. There is no data about shared
pages.
Helps PR 50801.
To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/miscfs/procfs/procfs_linux.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/miscfs/procfs/procfs_linux.c
diff -u src/sys/miscfs/procfs/procfs_linux.c:1.71 src/sys/miscfs/procfs/procfs_linux.c:1.72
--- src/sys/miscfs/procfs/procfs_linux.c:1.71 Fri Jul 24 13:02:52 2015
+++ src/sys/miscfs/procfs/procfs_linux.c Mon Mar 28 17:23:47 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_linux.c,v 1.71 2015/07/24 13:02:52 maxv Exp $ */
+/* $NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.71 2015/07/24 13:02:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -366,10 +366,10 @@ procfs_do_pid_statm(struct lwp *curl, st
{
struct vmspace *vm;
struct proc *p = l->l_proc;
- struct rusage *ru = &p->p_stats->p_ru;
char *bf;
int error;
int len;
+ struct kinfo_proc2 ki;
bf = malloc(LBFSZ, M_TEMP, M_WAITOK);
@@ -379,18 +379,27 @@ procfs_do_pid_statm(struct lwp *curl, st
goto out;
}
- len = snprintf(bf, LBFSZ,
- "%lu %lu %lu %lu %lu %lu %lu\n",
- (unsigned long)(vm->vm_tsize + vm->vm_dsize + vm->vm_ssize), /* size */
- (unsigned long)(vm->vm_rssize), /* resident */
- (unsigned long)(ru->ru_ixrss), /* shared */
- (unsigned long)(vm->vm_tsize), /* text size in pages */
- (unsigned long)(vm->vm_dsize), /* data size in pages */
- (unsigned long)(vm->vm_ssize), /* stack size in pages */
- (unsigned long) 0);
+ mutex_enter(proc_lock);
+ mutex_enter(p->p_lock);
+
+ /* retrieve RSS size */
+ fill_kproc2(p, &ki, false);
+
+ mutex_exit(p->p_lock);
+ mutex_exit(proc_lock);
uvmspace_free(vm);
+ len = snprintf(bf, LBFSZ,
+ "%lu %lu %lu %lu %lu %lu %lu\n",
+ (unsigned long)(ki.p_vm_msize), /* size */
+ (unsigned long)(ki.p_vm_rssize),/* resident */
+ (unsigned long)(ki.p_uru_ixrss),/* shared */
+ (unsigned long)(ki.p_vm_tsize), /* text */
+ (unsigned long) 0, /* library (unused) */
+ (unsigned long)(ki.p_vm_dsize + ki.p_vm_ssize), /* data+stack */
+ (unsigned long) 0); /* dirty */
+
if (len == 0)
goto out;