This commit is contained in:
parent
3dfac40fc1
commit
9fee45a158
@ -1,14 +1,25 @@
|
||||
--- pmap.c
|
||||
+++ pmap.c 2007-06-11 17:22:37.794874038 +0200
|
||||
@@ -16,6 +16,7 @@
|
||||
+++ pmap.c 2008-03-28 11:35:48.682190503 +0100
|
||||
@@ -12,10 +12,13 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
+#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
+#include <sys/utsname.h>
|
||||
+#include <unistd.h>
|
||||
|
||||
#include "proc/readproc.h"
|
||||
#include "proc/version.h"
|
||||
@@ -30,6 +31,7 @@ struct smap {
|
||||
@@ -26,18 +29,26 @@
|
||||
struct smap {
|
||||
unsigned long size;
|
||||
unsigned long rss;
|
||||
+ unsigned long pss;
|
||||
unsigned long shared_clean;
|
||||
unsigned long shared_dirty;
|
||||
unsigned long private_clean;
|
||||
unsigned long private_dirty;
|
||||
@ -16,22 +27,45 @@
|
||||
};
|
||||
|
||||
static unsigned long mapped;
|
||||
@@ -37,7 +39,9 @@ static unsigned long shared;
|
||||
static unsigned long shared;
|
||||
static unsigned long private;
|
||||
static unsigned long rss;
|
||||
+static unsigned long pss;
|
||||
static unsigned long dirty;
|
||||
+static unsigned long referenced;
|
||||
static FILE *smaps_fp;
|
||||
+static int maj, min, patch;
|
||||
+static int maj, min, patch, dopss, noref;
|
||||
+static long lbits;
|
||||
+#define BLK ((lbits==64)?" ":"")
|
||||
+#define WDT ((lbits==64)?16:8)
|
||||
|
||||
static void usage(const char *cmd)
|
||||
{
|
||||
@@ -123,6 +127,19 @@ static int get_smap_data(struct smap *sm
|
||||
@@ -85,6 +96,18 @@ static int get_smap_data(struct smap *sm
|
||||
smap->rss = data;
|
||||
rss += data;
|
||||
|
||||
+ if (dopss) {
|
||||
+ /* get pss */
|
||||
+ if (!fgets(buff, BUFFERSIZE, smaps_fp))
|
||||
+ return 1;
|
||||
+
|
||||
+ assigned = sscanf(buff, "Pss: %lld", &data);
|
||||
+ if (assigned != 1)
|
||||
+ return 1;
|
||||
+ smap->pss = data;
|
||||
+ pss += data;
|
||||
+ }
|
||||
+
|
||||
/* get shared clean */
|
||||
if (!fgets(buff, BUFFERSIZE, smaps_fp))
|
||||
return 1;
|
||||
@@ -123,6 +146,19 @@ static int get_smap_data(struct smap *sm
|
||||
smap->private_dirty = data;
|
||||
dirty += data;
|
||||
|
||||
+ if ((maj < 2) || ((maj == 2) && ((min < 6) || ((min == 6) && (patch < 22)))))
|
||||
+ return 0;
|
||||
+ if (noref)
|
||||
+ goto out;
|
||||
+
|
||||
+ /* get referenced */
|
||||
+ if (!fgets(buff, BUFFERSIZE, smaps_fp))
|
||||
@ -42,32 +76,101 @@
|
||||
+ return 1;
|
||||
+ smap->referenced = data;
|
||||
+ referenced += data;
|
||||
+
|
||||
+out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -181,8 +198,12 @@ int main(int argc, char *argv[])
|
||||
@@ -130,7 +166,7 @@ static void parse_line(pid_t pid, const
|
||||
{
|
||||
unsigned long long low, high, size, offset;
|
||||
unsigned long major, minor;
|
||||
- struct smap smap = { .rss = 0 };
|
||||
+ struct smap smap = { .rss = 0, .pss = 0 };
|
||||
int assigned;
|
||||
char read_perm, write_perm, exec_perm, access_type;
|
||||
char obj_buff[OBJECTSIZE] = "[anon]";
|
||||
@@ -159,17 +195,19 @@ static void parse_line(pid_t pid, const
|
||||
else if (access_type == 'p' && write_perm == 'w')
|
||||
private += size;
|
||||
|
||||
- printf("%08llx %6lluK ", low, size);
|
||||
+ printf("%0*llx %6lluK ", WDT, low, size);
|
||||
|
||||
if (smaps_fp) {
|
||||
printf("%6luK ", smap.rss);
|
||||
+ if (dopss)
|
||||
+ printf("%6luK ", smap.pss);
|
||||
printf("%6luK ", smap.private_dirty + smap.shared_dirty);
|
||||
}
|
||||
|
||||
printf("%c%c%c%c ", read_perm, write_perm, exec_perm, access_type);
|
||||
|
||||
if (show_devices)
|
||||
- printf("%08llx %02lx:%02lx ", offset, major, minor);
|
||||
+ printf("%0*llx %02lx:%02lx ", WDT, offset, major, minor);
|
||||
|
||||
printf("%s\n", obj_buff);
|
||||
}
|
||||
@@ -181,8 +219,25 @@ int main(int argc, char *argv[])
|
||||
char path[PATH_MAX];
|
||||
char buff[BUFFERSIZE];
|
||||
int o, show_devices = 0, quiet = 0;
|
||||
+ struct utsname uts;
|
||||
pid_t pid;
|
||||
|
||||
+ if (uname(&uts) == 0)
|
||||
+ if (uname(&uts) < 0) {
|
||||
+ fprintf(stderr, "error getting information about current kernel: %m\n");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ sscanf(uts.release, "%d.%d.%d", &maj, &min, &patch);
|
||||
+
|
||||
+ if ((maj > 2) || ((maj == 2) && ((min > 6) || ((min == 6) && (patch >= 25)))))
|
||||
+ dopss++;
|
||||
+ if ((maj < 2) || ((maj == 2) && ((min < 6) || ((min == 6) && (patch < 22)))))
|
||||
+ noref++;
|
||||
+
|
||||
+ if ((lbits = sysconf(_SC_LONG_BIT)) < 0) {
|
||||
+ fprintf(stderr, "error getting information about current kernel: %m\n");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
struct option longopts[] = {
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "version", 0, NULL, 'V' },
|
||||
@@ -264,8 +285,12 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
@@ -242,10 +297,12 @@ int main(int argc, char *argv[])
|
||||
smaps_fp = fopen(path, "r");
|
||||
|
||||
if (!quiet) {
|
||||
- printf("START SIZE ");
|
||||
+ printf("START%s SIZE ", BLK);
|
||||
|
||||
if (smaps_fp) {
|
||||
printf(" RSS ");
|
||||
+ if (dopss)
|
||||
+ printf(" PSS ");
|
||||
printf(" DIRTY ");
|
||||
}
|
||||
|
||||
@@ -259,13 +316,20 @@ int main(int argc, char *argv[])
|
||||
parse_line(pid, buff, show_devices);
|
||||
|
||||
if (!quiet) {
|
||||
- if (smaps_fp)
|
||||
- printf("Total: %6luK %6luK %6luK\n\n", mapped, rss, dirty);
|
||||
- else
|
||||
+ if (smaps_fp) {
|
||||
+ if (dopss)
|
||||
+ printf("Total:%s %6luK %6luK %6luK %6luK\n\n", BLK, mapped, rss, pss, dirty);
|
||||
+ else
|
||||
+ printf("Total:%s %6luK %6luK %6luK\n\n", BLK, mapped, rss, dirty);
|
||||
+ } else
|
||||
printf("mapped: %luK ", mapped);
|
||||
|
||||
- printf("%luK writable-private, %luK readonly-private, and %luK shared\n",
|
||||
- private, mapped - private - shared, shared);
|
||||
+ if ((maj < 2) || ((maj == 2) && ((min < 6) || ((min == 6) && (patch < 22)))))
|
||||
+ if (noref)
|
||||
+ printf("%luK writable-private, %luK readonly-private, and %luK shared\n",
|
||||
+ private, mapped - private - shared, shared, referenced);
|
||||
+ private, mapped - private - shared, shared);
|
||||
+ else
|
||||
+ printf("%luK writable-private, %luK readonly-private, %luK shared, and %luK referenced\n",
|
||||
+ private, mapped - private - shared, shared, referenced);
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 28 11:42:02 CET 2008 - werner@suse.de
|
||||
|
||||
- Handle new Pss entry in smaps (bnc#374236)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 14 12:06:17 CET 2008 - werner@suse.de
|
||||
|
||||
|
@ -19,7 +19,7 @@ Group: System/Monitoring
|
||||
PreReq: %fillup_prereq %insserv_prereq
|
||||
AutoReqProv: on
|
||||
Version: 3.2.7
|
||||
Release: 93
|
||||
Release: 102
|
||||
Summary: ps utilities for /proc
|
||||
Provides: ps
|
||||
Obsoletes: ps
|
||||
@ -159,6 +159,8 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%_mandir/man8/sysctl.8.gz
|
||||
|
||||
%changelog
|
||||
* Fri Mar 28 2008 werner@suse.de
|
||||
- Handle new Pss entry in smaps (bnc#374236)
|
||||
* Thu Feb 14 2008 werner@suse.de
|
||||
- Also ignore empty proc files in sysctl (bnc #347322, #361049)
|
||||
* Wed Feb 06 2008 werner@suse.de
|
||||
|
Loading…
x
Reference in New Issue
Block a user