summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorPatrick Mooney <pmooney@pfmooney.com>2019-10-25 11:22:51 +0100
committerJohn Levon <john.levon@joyent.com>2019-10-29 14:41:10 +0000
commita0ee54468d6e6b136d1ca470a03bb44165c66e6e (patch)
treea7892f84ee7b37a46ce185c6edb6bad769c06fea /usr
parentfdfb6e575f06007c35263fbcdc483157ef62d712 (diff)
downloadillumos-joyent-a0ee54468d6e6b136d1ca470a03bb44165c66e6e.tar.gz
11871 smatch should not hammer linux procfs path
Reviewed by: John Levon <john.levon@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/tools/smatch/Makefile6
-rw-r--r--usr/src/tools/smatch/src/Makefile2
-rw-r--r--usr/src/tools/smatch/src/smatch_mem_tracker.c27
3 files changed, 20 insertions, 15 deletions
diff --git a/usr/src/tools/smatch/Makefile b/usr/src/tools/smatch/Makefile
index dad195adc8..1ed525bce7 100644
--- a/usr/src/tools/smatch/Makefile
+++ b/usr/src/tools/smatch/Makefile
@@ -8,19 +8,19 @@
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
-# Copyright (c) 2019, Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
#
#
# The src/ sub-directory is un-modified copy of
-# https://github.com/illumos/smatch/tree/0.5.1-il-5
+# https://github.com/illumos/smatch/tree/0.5.1-il-6
#
# This Makefile installs just enough for us to be able to run smatch
# locally.
#
PROG = smatch
-SPARSE_VERSION = 0.5.1-il-5
+SPARSE_VERSION = 0.5.1-il-6
include ../Makefile.tools
diff --git a/usr/src/tools/smatch/src/Makefile b/usr/src/tools/smatch/src/Makefile
index 388f5900a1..43e67cd759 100644
--- a/usr/src/tools/smatch/src/Makefile
+++ b/usr/src/tools/smatch/src/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.5.1-il-5
+VERSION=0.5.1-il-6
# Generating file version.h if current version has changed
SPARSE_VERSION:=$(shell git describe 2>/dev/null || echo '$(VERSION)')
diff --git a/usr/src/tools/smatch/src/smatch_mem_tracker.c b/usr/src/tools/smatch/src/smatch_mem_tracker.c
index c10ee90587..4f659a722e 100644
--- a/usr/src/tools/smatch/src/smatch_mem_tracker.c
+++ b/usr/src/tools/smatch/src/smatch_mem_tracker.c
@@ -16,27 +16,32 @@
*/
#include "smatch.h"
+#include <fcntl.h>
#include <unistd.h>
+#include <sys/procfs.h>
static int my_id;
+static int my_fd = -2;
static unsigned long max_size;
unsigned long get_mem_kb(void)
{
- FILE *file;
- char buf[1024];
- unsigned long size;
+ prpsinfo_t pbuf;
- file = fopen("/proc/self/statm", "r");
- if (!file)
- return 0;
- fread(buf, 1, sizeof(buf), file);
- fclose(file);
+ if (my_fd == -2) {
+ /* Do not repeatedly attempt this if it fails. */
+ my_fd = open("/proc/self/psinfo", O_RDONLY);
+ }
+ if (my_fd == -1) {
+ return (0);
+ }
+
+ if (pread(my_fd, &pbuf, sizeof (pbuf), 0) != sizeof (pbuf)) {
+ return (0);
+ }
- size = strtoul(buf, NULL, 10);
- size = size * sysconf(_SC_PAGESIZE) / 1024;
- return size;
+ return (pbuf.pr_rssize);
}
static void match_end_func(struct symbol *sym)