All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikanth Karthikesan <knikanth@suse.de>
To: linux-kernel@vger.kernel.org
Cc: balbir@linux.vnet.ibm.com
Subject: [PATCH 3/3] taskstats-fork: Add Documentation for taskstats fork notification
Date: Tue, 21 Jul 2009 10:32:04 +0530	[thread overview]
Message-ID: <200907211032.04871.knikanth@suse.de> (raw)

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");


                 reply	other threads:[~2009-07-21  5:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200907211032.04871.knikanth@suse.de \
    --to=knikanth@suse.de \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.