All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] taskstats-fork: Add Documentation for taskstats fork notification
@ 2009-07-21  5:02 Nikanth Karthikesan
  0 siblings, 0 replies; only message in thread
From: Nikanth Karthikesan @ 2009-07-21  5:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: balbir

Add documentation for the new taskstats command to receive notification of new
processes being spawned.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index aa73e72..fcbec43 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -69,12 +69,13 @@ struct msgtemplate {
 	char buf[MAX_MSG_SIZE];
 };
 
-char cpumask[100+6*MAX_CPUS];
+char fork_cpumask[100+6*MAX_CPUS];
+char exit_cpumask[100+6*MAX_CPUS];
 
 static void usage(void)
 {
 	fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
-			"[-m cpumask] [-t tgid] [-p pid]\n");
+			"[-e cpumask] [-f cpumask] [-t tgid] [-p pid]\n");
 	fprintf(stderr, "  -d: print delayacct stats\n");
 	fprintf(stderr, "  -i: print IO accounting (works only with -p)\n");
 	fprintf(stderr, "  -l: listen forever\n");
@@ -260,7 +261,8 @@ int main(int argc, char *argv[])
 	int fd = 0;
 	int count = 0;
 	int write_file = 0;
-	int maskset = 0;
+	int fork_maskset = 0;
+	int exit_maskset = 0;
 	char *logfile = NULL;
 	int loop = 0;
 	int containerset = 0;
@@ -270,7 +272,7 @@ int main(int argc, char *argv[])
 	struct msgtemplate msg;
 
 	while (1) {
-		c = getopt(argc, argv, "qdiw:r:m:t:p:vlC:");
+		c = getopt(argc, argv, "qdiw:r:e:f:t:p:vlC:");
 		if (c < 0)
 			break;
 
@@ -302,10 +304,15 @@ int main(int argc, char *argv[])
 			if (rcvbufsz < 0)
 				err(1, "Invalid rcv buf size\n");
 			break;
-		case 'm':
-			strncpy(cpumask, optarg, sizeof(cpumask));
-			maskset = 1;
-			printf("cpumask %s maskset %d\n", cpumask, maskset);
+		case 'f':
+			strncpy(fork_cpumask, optarg, sizeof(fork_cpumask));
+			fork_maskset = 1;
+			printf("fork_cpumask %s maskset %d\n", fork_cpumask, fork_maskset);
+			break;
+		case 'e':
+			strncpy(exit_cpumask, optarg, sizeof(exit_cpumask));
+			exit_maskset = 1;
+			printf("exit_cpumask %s maskset %d\n", exit_cpumask, exit_maskset);
 			break;
 		case 't':
 			tid = atoi(optarg);
@@ -354,10 +361,21 @@ int main(int argc, char *argv[])
 	}
 	PRINTF("family id %d\n", id);
 
-	if (maskset) {
+	if (fork_maskset) {
+		rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
+			      TASKSTATS_CMD_ATTR_REGISTER_FORK_CPUMASK,
+			      &fork_cpumask, strlen(fork_cpumask) + 1);
+		PRINTF("Sent register fork cpumask, retval %d\n", rc);
+		if (rc < 0) {
+			fprintf(stderr, "error sending register fork cpumask\n");
+			goto err;
+		}
+	}
+
+	if (exit_maskset) {
 		rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
 			      TASKSTATS_CMD_ATTR_REGISTER_CPUMASK,
-			      &cpumask, strlen(cpumask) + 1);
+			      &exit_cpumask, strlen(exit_cpumask) + 1);
 		PRINTF("Sent register cpumask, retval %d\n", rc);
 		if (rc < 0) {
 			fprintf(stderr, "error sending register cpumask\n");
@@ -393,7 +411,7 @@ int main(int argc, char *argv[])
 			goto err;
 		}
 	}
-	if (!maskset && !tid && !containerset) {
+	if (!fork_maskset && !exit_maskset && !tid && !containerset) {
 		usage();
 		goto err;
 	}
@@ -429,6 +447,9 @@ int main(int argc, char *argv[])
 		while (len < rep_len) {
 			len += NLA_ALIGN(na->nla_len);
 			switch (na->nla_type) {
+			case TASKSTATS_TYPE_PID_TGID:
+				printf("New Task: \n");
+				/* Fall through */
 			case TASKSTATS_TYPE_AGGR_TGID:
 				/* Fall through */
 			case TASKSTATS_TYPE_AGGR_PID:
@@ -488,10 +509,18 @@ int main(int argc, char *argv[])
 		}
 	} while (loop);
 done:
-	if (maskset) {
+	if (fork_maskset) {
+		rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
+			      TASKSTATS_CMD_ATTR_DEREGISTER_FORK_CPUMASK,
+			      &fork_cpumask, strlen(fork_cpumask) + 1);
+		printf("Sent deregister fork mask, retval %d\n", rc);
+		if (rc < 0)
+			err(rc, "error sending deregister fork cpumask\n");
+	}
+	if (exit_maskset) {
 		rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
 			      TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK,
-			      &cpumask, strlen(cpumask) + 1);
+			      &exit_cpumask, strlen(exit_cpumask) + 1);
 		printf("Sent deregister mask, retval %d\n", rc);
 		if (rc < 0)
 			err(rc, "error sending deregister cpumask\n");


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-21  5:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21  5:02 [PATCH 3/3] taskstats-fork: Add Documentation for taskstats fork notification Nikanth Karthikesan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.