summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2013-06-06 22:30:51 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2013-06-06 22:30:51 +0000
commit991584549f5ec4e58b99b5880d8dfdfea8a6304e (patch)
tree34e3bbdb39ad8a36d51d22f76ac4a1a4536d5d1c
parent6894643977d666a82959ea9ba553453a36392a3c (diff)
downloadillumos-joyent-991584549f5ec4e58b99b5880d8dfdfea8a6304e.tar.gz
OS-2280 zonememstat reports 0 rss for kvm-branded zones
-rw-r--r--usr/src/cmd/zoneadmd/mcap.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/usr/src/cmd/zoneadmd/mcap.c b/usr/src/cmd/zoneadmd/mcap.c
index e0c2683e4a..9f5d61dada 100644
--- a/usr/src/cmd/zoneadmd/mcap.c
+++ b/usr/src/cmd/zoneadmd/mcap.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Copyright 2011, 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2013, Joyent, Inc. All rights reserved.
*/
/*
@@ -950,6 +950,53 @@ done:
zonecfg_fini_handle(handle);
}
+/* ARGSUSED */
+static int
+chk_proc_fs(void *data, const char *spec, const char *dir,
+ const char *fstype, const char *opt)
+{
+ if (spec != NULL && strcmp(spec, "/proc") == 0)
+ *((boolean_t *)data) = B_TRUE;
+
+ return (0);
+}
+
+static boolean_t
+has_proc()
+{
+ brand_handle_t bh;
+ boolean_t fnd = B_FALSE;
+
+ if ((bh = brand_open(brand_name)) != NULL) {
+ (void) brand_platform_iter_mounts(bh, chk_proc_fs, &fnd);
+ }
+
+ brand_close(bh);
+ return (fnd);
+}
+
+/*
+ * We run this loop for brands with no /proc to simply update the RSS, using the
+ * expensive sycall, every 5 minutes.
+ */
+static void
+no_procfs()
+{
+ uint64_t n;
+ zsd_vmusage64_t buf;
+
+ (void) sleep_shutdown(30);
+ while (!shutting_down) {
+ buf.vmu_id = zid;
+ n = 1;
+
+ (void) syscall(SYS_rusagesys, _RUSAGESYS_GETVMUSAGE,
+ VMUSAGE_A_ZONE, 60, (uintptr_t)&buf, (uintptr_t)&n);
+
+ (void) sleep_shutdown(300);
+ }
+}
+
/*
* Thread that checks zone's memory usage and when over the cap, goes through
* the zone's process list trying to pageout processes to get under the cap.
@@ -966,6 +1013,17 @@ mcap_zone()
get_mcap_tunables();
/*
+ * If the zone has no /proc filesystem, we can't use the fast algorithm
+ * to check RSS or pageout any processes. All we can do is periodically
+ * update it's RSS kstat using the expensive sycall.
+ */
+ if (!has_proc()) {
+ no_procfs();
+ debug("thread shutdown\n");
+ return;
+ }
+
+ /*
* When first starting it is likely lots of other zones are starting
* too because the system is booting. Since we just started the zone
* we're not worried about being over the cap right away, so we let