Skip to contentSkip to conversation

Delay accounting: Connector interface

PATCH In review Shailabh Nagar 1 participant 1 message Nov 15, 2005 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 Delay accounting: Connector interface

delayacct-connector.patch

Creates a connector interface for getting delay and cpu statistics of tasks during their lifetime and when they exit. The cpu stats are available only if CONFIG_SCHEDSTATS is enabled.

Userspace can send commands containing a pid and receive the corresponding task's statistics during its lifetime. After a task exits, its final stats are sent to userspace. This last feature is the primary motivation, besides efficiency, for the connector interface being preferred over a /proc interface.

 drivers/connector/Kconfig    |    9 +
 drivers/connector/Makefile   |    1
 drivers/connector/cn_stats.c |  199 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/cn_stats.h     |  105 ++++++++++++++++++++++
 include/linux/connector.h    |    4
 kernel/exit.c                |    2
 6 files changed, 320 insertions(+)
drivers/connector/Kconfig +9 -0
Index: linux-2.6.14/drivers/connector/Kconfig
===================================================================
@@ -10,4 +10,13 @@ config CONNECTOR
 	  Connector support can also be built as a module.  If so, the module
 	  will be called cn.ko.
 
+config STATS_CONNECTOR
+	bool "Report per-task delay statistics to userspace"
+	depends on CONNECTOR=y && DELAY_ACCT
+	---help---
+	  Provide a connector interface that reports per-task statistics to
+	  userspace. While a task is running, userspace can get the stats by
+	  sending a command to the connector. At task exit, the final value of
+	  the stats is sent automatically.
+
 endmenu
drivers/connector/Makefile +1 -0
Index: linux-2.6.14/drivers/connector/Makefile
===================================================================
@@ -1,3 +1,4 @@
 obj-$(CONFIG_CONNECTOR)		+= cn.o
+obj-$(CONFIG_STATS_CONNECTOR)	+= cn_stats.o
 
 cn-y				+= cn_queue.o connector.o
include/linux/cn_stats.h new file +105 -0

105 lines not on this page · raw message

include/linux/connector.h +4 -0
Index: linux-2.6.14/include/linux/connector.h
===================================================================
@@ -27,6 +27,10 @@
 #define CN_IDX_CONNECTOR		0xffffffff
 #define CN_VAL_CONNECTOR		0xffffffff
 
+/* Statistics connector ids */
+#define CN_IDX_STATS			0x2
+#define CN_VAL_STATS			0x2
+
 #define CN_NETLINK_USERS		1
 
 /*
drivers/connector/cn_stats.c new file +199 -0

199 lines not on this page · raw message

kernel/exit.c +2 -0
Index: linux-2.6.14/kernel/exit.c
===================================================================
@@ -28,6 +28,7 @@
 #include <linux/cpuset.h>
 #include <linux/syscalls.h>
 #include <linux/signal.h>
+#include <linux/cn_stats.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -864,6 +865,7 @@ fastcall NORET_TYPE void do_exit(long co
 		module_put(tsk->binfmt->module);
 
 	tsk->exit_code = code;
+	cnstats_exit_connector(tsk);
 	exit_notify(tsk);
 #ifdef CONFIG_NUMA
 	mpol_free(tsk->mempolicy);