PERFORCE change 181870 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu Aug 5 16:01:53 UTC 2010
http://p4web.freebsd.org/@@181870?ac=10
Change 181870 by trasz at trasz_victim on 2010/08/05 16:01:06
Add SDT probes for containers.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#23 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#23 (text+ko) ====
@@ -33,6 +33,7 @@
__FBSDID("$FreeBSD$");
#include "opt_hrl.h"
+#include "opt_kdtrace.h"
#include <sys/container.h>
#include <sys/param.h>
@@ -42,6 +43,7 @@
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
+#include <sys/sdt.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/systm.h>
@@ -55,6 +57,17 @@
static void container_sub(struct container *dest, const struct container *src);
+SDT_PROVIDER_DEFINE(container);
+SDT_PROBE_DEFINE3(container, kernel, rusage, add, "struct proc *", "int", "uint64_t");
+SDT_PROBE_DEFINE3(container, kernel, rusage, add_failure, "struct proc *", "int", "uint64_t");
+SDT_PROBE_DEFINE3(container, kernel, rusage, set, "struct proc *", "int", "uint64_t");
+SDT_PROBE_DEFINE3(container, kernel, rusage, set_failure, "struct proc *", "int", "uint64_t");
+SDT_PROBE_DEFINE3(container, kernel, rusage, sub, "struct proc *", "int", "uint64_t");
+SDT_PROBE_DEFINE1(container, kernel, container, create, "struct container *");
+SDT_PROBE_DEFINE1(container, kernel, container, destroy, "struct container *");
+SDT_PROBE_DEFINE2(container, kernel, container, join, "struct container *", "struct container *");
+SDT_PROBE_DEFINE2(container, kernel, container, join_failure, "struct container *", "struct container *");
+SDT_PROBE_DEFINE2(container, kernel, container, leave, "struct container *", "struct container *");
static int
container_resource_reclaimable(int resource)
@@ -159,6 +172,8 @@
{
int i, error;
+ SDT_PROBE(container, kernel, container, join, child, parent, 0, 0, 0);
+
mtx_assert(&container_lock, MA_OWNED);
KASSERT(child != NULL, ("child != NULL"));
KASSERT(parent != NULL, ("parent != NULL"));
@@ -168,9 +183,10 @@
("container already joined"));
if (child->c_parents[i] == NULL) {
error = container_add(parent, child);
- if (error)
+ if (error) {
+ SDT_PROBE(container, kernel, container, join_failure, child, parent, 0, 0, 0);
return (error);
-
+ }
child->c_parents[i] = parent;
return (0);
}
@@ -195,6 +211,8 @@
{
int i;
+ SDT_PROBE(container, kernel, container, leave, child, parent, 0, 0, 0);
+
mtx_assert(&container_lock, MA_OWNED);
KASSERT(child != NULL, ("child != NULL"));
KASSERT(parent != NULL, ("parent != NULL"));
@@ -239,6 +257,8 @@
{
int i;
+ SDT_PROBE(container, kernel, container, create, container, 0, 0, 0, 0);
+
for (i = 0; i <= RUSAGE_MAX; i++)
KASSERT(container->c_resources[i] == 0,
("container->c_resources[%d] != NULL", i));
@@ -252,6 +272,8 @@
{
int i;
+ SDT_PROBE(container, kernel, container, destroy, container, 0, 0, 0, 0);
+
mtx_assert(&container_lock, MA_OWNED);
KASSERT(container != NULL, ("NULL container"));
@@ -347,9 +369,7 @@
if (p->p_flag & P_SYSTEM)
return (0);
-#if 0
- printf("rusage_add: allocating %ju of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid);
-#endif
+ SDT_PROBE(container, kernel, rusage, add, p, resource, amount, 0, 0);
KASSERT(amount > 0, ("rusage_add: invalid amount for resource %d: %ju",
resource, amount));
@@ -358,6 +378,7 @@
#ifdef HRL
error = hrl_enforce_proc(p, resource, amount);
if (error) {
+ SDT_PROBE(container, kernel, rusage, add_failure, p, resource, amount, 0, 0);
mtx_unlock(&container_lock);
return (error);
}
@@ -379,12 +400,11 @@
if (p->p_flag & P_SYSTEM)
return (0);
-#if 0
- printf("rusage_set: allocated %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid);
-#endif
+ SDT_PROBE(container, kernel, rusage, set, p, resource, amount, 0, 0);
KASSERT(amount >= 0, ("rusage_set: invalid amount for resource %d: %ju",
resource, amount));
+
diff = amount - p->p_container.c_resources[resource];
#ifdef notyet
KASSERT(diff >= 0 || container_resource_reclaimable(resource),
@@ -394,8 +414,10 @@
#ifdef HRL
if (diff > 0) {
error = hrl_enforce_proc(p, resource, diff);
- if (error)
+ if (error) {
+ SDT_PROBE(container, kernel, rusage, set_failure, p, resource, amount, 0, 0);
return (error);
+ }
}
#endif
container_alloc_resource(&p->p_container, resource, diff);
@@ -431,9 +453,8 @@
if (p->p_flag & P_SYSTEM)
return;
-#if 0
- printf("rusage_sub: freeing %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid);
-#endif
+
+ SDT_PROBE(container, kernel, rusage, sub, p, resource, amount, 0, 0);
KASSERT(amount > 0, ("rusage_sub: invalid amount for resource %d: %ju",
resource, amount));
More information about the p4-projects
mailing list