Skip to contentSkip to conversation

add CSA accounting to taskstats

PATCH In review Jay Lan 3 participants 7 messages Jul 31, 2006 – Aug 16, 2006 Taskstats statistics interface

lore
Share & tools
lore

Jay Lan

author
#0 lore raw

PATCH 2/3 add CSA accounting to taskstats

This patch add CSA accounting fields to the taskstats struct and a kernel/csa.c to fill the data on exit.

include/linux/taskstats.h +15 -0
Index: linux/include/linux/taskstats.h
===================================================================
@@ -107,6 +107,21 @@ struct taskstats {
 	__u64	ac_utime;		/* User CPU time [usec] */
 	__u64	ac_stime;		/* SYstem CPU time [usec] */
 	/* Basic Accounting Fields end */
+
+ 	/* CSA accounting fields start */
+ 	__u16	csa_revision;		/* CSA Revision */
+ 	__u16	csa_pad[3];		/* Unused */
+ 	__u64	acct_rss_mem1;		/* accumulated rss usage */
+ 	__u64	acct_vm_mem1;		/* accumulated virtual memory usage */
+ 	__u64	hiwater_rss;		/* High-watermark of RSS usage */
+ 	__u64	hiwater_vm;		/* High-water virtual memory usage */
+ 	__u64	ac_minflt;		/* Minor Page Fault */
+ 	__u64	ac_majflt;		/* Major Page Fault */
+ 	__u64	ac_chr;			/* bytes read */
+ 	__u64	ac_chw;			/* bytes written */
+ 	__u64	ac_scr;			/* read syscalls */
+ 	__u64	ac_scw;			/* write syscalls */
+ 	/* CSA accounting fields end */
 };
 
 
init/Kconfig +25 -0
Index: linux/init/Kconfig
===================================================================
@@ -182,6 +182,31 @@ config TASK_DELAY_ACCT
 
 	  Say N if unsure.
 
+config CSA_ACCT
+	bool "Enable CSA Job Accounting (EXPERIMENTAL)"
+	depends on TASKSTATS
+	help
+	  Comprehensive System Accounting (CSA) provides job level
+	  accounting of resource usage.  The accounting records are
+	  written by the kernel into a file.  CSA user level scripts
+	  and commands process the binary accounting records and
+	  combine them by job identifier within system boot uptime
+	  periods.  These accounting records are then used to produce
+	  reports and charge fees to users.
+
+	  Say Y here if you want job level accounting to be compiled
+	  into the kernel.  Say M here if you want the writing of
+	  accounting records portion of this feature to be a loadable
+	  module.  Say N here if you do not want job level accounting
+	  (the default).
+
+	  The CSA commands and scripts package needs to be installed
+	  to process the CSA accounting records.  See
+	  http://oss.sgi.com/projects/csa for further information
+	  about CSA and download instructions for the CSA commands
+	  package and documentation.
+
+
 config SYSCTL
 	bool "Sysctl support" if EMBEDDED
 	default y
kernel/Makefile +1 -0
Index: linux/kernel/Makefile
===================================================================
@@ -50,6 +50,7 @@ obj-$(CONFIG_RCU_TORTURE_TEST) += rcutor
 obj-$(CONFIG_RELAY) += relay.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o
+obj-$(CONFIG_CSA_ACCT) += csa.o
 
 ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/csa.c new file +46 -0

46 lines not on this page · raw message

kernel/taskstats.c +4 -0
Index: linux/kernel/taskstats.c
===================================================================
@@ -21,6 +21,7 @@
 #include <linux/taskstats_kern.h>
 #include <linux/acct.h>
 #include <linux/delayacct.h>
+#include <linux/csa_kern.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
 #include <net/genetlink.h>
@@ -252,6 +253,9 @@ static int fill_pid(pid_t pid, struct ta
 	/* fill in basic acct fields */
 	bacct_add_tsk(stats, tsk);
 
+	/* fill in csa fields */
+	csa_add_tsk(stats, tsk);
+
 	/* Define err: label here if needed */
 	put_task_struct(tsk);
 	return rc;
include/linux/csa_kern.h new file +31 -0
Index: linux/include/linux/csa_kern.h
===================================================================
@@ -0,0 +1,31 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */
+
+#ifndef _CSA_KERN_H
+#define _CSA_KERN_H
+
+#ifdef CONFIG_CSA_ACCT
+extern void csa_add_tsk(struct taskstats *, struct task_struct *);
+#else
+#define csa_add_tsk(x)		do { } while (0)
+#endif
+
+/*
+ * Record revision levels.
+ *
+ * These are incremented to indicate that a record's format has changed since
+ * a previous release.
+ *
+ * History:     05000   The first rev in Linux
+ *              06000   Major rework to clean up unused fields and features.
+ *                      No binary compatibility with earlier rev.
+ *		07000	Convert to taskstats interface
+ */
+#define REV_CSA		07000	/* Kernel: CSA base record */
+
+#endif	/* _CSA_KERN_H */
#1 lore raw
Quoted 14 lines · Jay Lan

This patch add CSA accounting fields to the taskstats struct and a kernel/csa.c to fill the data on exit.

------------------------------------------------------------------------

Index: linux/include/linux/taskstats.h
===================================================================

include/linux/taskstats.h struct taskstats { · line 112

Quoted 6 lines
include/linux/taskstats.h +3 -0
@@ -107,6 +107,21 @@ struct taskstats {
 	__u64	ac_utime;		/* User CPU time [usec] */
 	__u64	ac_stime;		/* SYstem CPU time [usec] */
 	/* Basic Accounting Fields end */
+
+ 	/* CSA accounting fields start */
+ 	__u16	csa_revision;		/* CSA Revision */

May be helpful to add a note here that every time csa_revision is changed, TASKSTATS_VERSION also needs to be bumped up.

include/linux/taskstats.h struct taskstats {

Quoted 11 lines
include/linux/taskstats.h +7 -0
+ 	__u16	csa_pad[3];		/* Unused */
 
 
+ 	__u64	acct_rss_mem1;		/* accumulated rss usage */
+ 	__u64	acct_vm_mem1;		/* accumulated virtual memory usage */
+ 	__u64	hiwater_rss;		/* High-watermark of RSS usage */
+ 	__u64	hiwater_vm;		/* High-water virtual memory usage */
 
 
+ 	__u64	ac_minflt;		/* Minor Page Fault */
+ 	__u64	ac_majflt;		/* Major Page Fault */

Can the number of prefixes be reduced ? In the space of a few fields, we have ac_*, csa_*, acct_* and plain (for hiwater_rss/vm)

include/linux/taskstats.h struct taskstats { · line 123

Quoted 4 lines
include/linux/taskstats.h +4 -0
+ 	__u64	ac_chr;			/* bytes read */
+ 	__u64	ac_chw;			/* bytes written */
+ 	__u64	ac_scr;			/* read syscalls */
+ 	__u64	ac_scw;			/* write syscalls */

read_char,
write_char,
read_syscalls,
write_syscalls,

perhaps (esp. if you're dropping the ac_ prefix) ?

Quoted 21 lines
include/linux/taskstats.h +1 -0
+ 	/* CSA accounting fields end */
 };

Index: linux/init/Kconfig
===================================================================

init/Kconfig +7 -0
@@ -182,6 +182,31 @@ config TASK_DELAY_ACCT
 
 	  Say N if unsure.
 
+config CSA_ACCT
+	bool "Enable CSA Job Accounting (EXPERIMENTAL)"
+	depends on TASKSTATS
+	help
+	  Comprehensive System Accounting (CSA) provides job level
+	  accounting of resource usage.  The accounting records are
+	  written by the kernel into a file.  CSA user level scripts

init/Kconfig config TASK_DELAY_ACCT · line 201

Quoted 10 lines
init/Kconfig +10 -0
+	  and commands process the binary accounting records and
+	  combine them by job identifier within system boot uptime
+	  periods.  These accounting records are then used to produce
+	  reports and charge fees to users.
+
+	  Say Y here if you want job level accounting to be compiled
+	  into the kernel.  Say M here if you want the writing of
+	  accounting records portion of this feature to be a loadable
+	  module.  Say N here if you do not want job level accounting
+	  (the default).

The description above is tied to jobs which don't exist in the kernel. There's no dependency of CSA on kernel-visible jobs anymore, right ? Perhaps the blurb can clarify that jobs are defined in user space.

Quoted 35 lines
init/Kconfig +8 -0
+
+	  The CSA commands and scripts package needs to be installed
+	  to process the CSA accounting records.  See
+	  http://oss.sgi.com/projects/csa for further information
+	  about CSA and download instructions for the CSA commands
+	  package and documentation.
+
+
 config SYSCTL
 	bool "Sysctl support" if EMBEDDED
 	default y

Index: linux/kernel/Makefile
===================================================================

kernel/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_RCU_TORTURE_TEST) += rcutor
 obj-$(CONFIG_RELAY) += relay.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o
+obj-$(CONFIG_CSA_ACCT) += csa.o
 
 ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is

Index: linux/kernel/csa.c
===================================================================

kernel/csa.c new file +7 -0
@@ -0,0 +1,46 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */

kernel/csa.c line 17

Quoted 10 lines
kernel/csa.c new file +10 -0
+
+
+/*
+ *  CSA (Comprehensive System Accounting)
+ *  Job Accounting for Linux
+ *
+ *  This header file contains the definitions needed for job
+ *  accounting. The kernel CSA accounting module code and all
+ *  user-level programs that try to write or process the binary job
+ *  accounting data must include this file.

Again, job dependency might need some clarification.

kernel/csa.c line 23

Quoted 6 lines
kernel/csa.c new file +6 -0
+ *
+ *  This kernel header file and the csa.h in the csa userland source
+ *  rpm share same data struct declaration and #define's. Do not modify
+ *  one without modify the other one as well. The compatibility between
+ *  userland and the kernel is ensured by using the 'ah_revision' field
+ *  of struct achead.

Leftover from older documentation ?

Quoted 55 lines
kernel/csa.c new file +23 -0
+ *
+ */
+
+#include <linux/taskstats.h>
+#include <linux/csa_kern.h>
+#include <linux/sched.h>
+
+void csa_add_tsk(struct taskstats *stats, struct task_struct *p)
+{
+	stats->csa_revision = REV_CSA;
+	stats->acct_rss_mem1 = p->acct_rss_mem1;
+	stats->acct_vm_mem1  = p->acct_vm_mem1;
+	if (p->mm) {
+		stats->hiwater_rss   = p->mm->hiwater_rss;
+		stats->hiwater_vm    = p->mm->hiwater_vm;
+	}
+	stats->ac_minflt = p->min_flt;
+	stats->ac_majflt = p->maj_flt;
+	stats->ac_chr	= p->rchar;
+	stats->ac_chw	= p->wchar;
+	stats->ac_scr	= p->syscr;
+	stats->ac_scw	= p->syscw;
+}

Index: linux/kernel/taskstats.c
===================================================================

kernel/taskstats.c +4 -0
@@ -21,6 +21,7 @@
 #include <linux/taskstats_kern.h>
 #include <linux/acct.h>
 #include <linux/delayacct.h>
+#include <linux/csa_kern.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
 #include <net/genetlink.h>
@@ -252,6 +253,9 @@ static int fill_pid(pid_t pid, struct ta
 	/* fill in basic acct fields */
 	bacct_add_tsk(stats, tsk);
 
+	/* fill in csa fields */
+	csa_add_tsk(stats, tsk);
+
 	/* Define err: label here if needed */
 	put_task_struct(tsk);
 	return rc;

Index: linux/include/linux/csa_kern.h
===================================================================

include/linux/csa_kern.h new file +5 -0
@@ -0,0 +1,31 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *

include/linux/csa_kern.h line 15

Quoted 10 lines
include/linux/csa_kern.h new file +10 -0
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */
+
+#ifndef _CSA_KERN_H
+#define _CSA_KERN_H
+
+#ifdef CONFIG_CSA_ACCT
+extern void csa_add_tsk(struct taskstats *, struct task_struct *);
+#else
+#define csa_add_tsk(x)		do { } while (0)

This won't compile right...number of args differ.

Quoted 17 lines
include/linux/csa_kern.h new file +16 -0
+#endif
+
+/*
+ * Record revision levels.
+ *
+ * These are incremented to indicate that a record's format has changed since
+ * a previous release.
+ *
+ * History:     05000   The first rev in Linux
+ *              06000   Major rework to clean up unused fields and features.
+ *                      No binary compatibility with earlier rev.
+ *		07000	Convert to taskstats interface
+ */
+#define REV_CSA		07000	/* Kernel: CSA base record */
+
+#endif	/* _CSA_KERN_H */
author
#2 lore raw
Quoted 11 lines · Shailabh Nagar
Quoted 9 lines · Jay Lan

This patch add CSA accounting fields to the taskstats struct and a kernel/csa.c to fill the data on exit.

------------------------------------------------------------------------

Quoted 15 lines

include/linux/taskstats.h struct taskstats { · line 112

Quoted 11 lines

Index: linux/include/linux/taskstats.h
===================================================================

include/linux/taskstats.h +3 -0
@@ -107,6 +107,21 @@ struct taskstats {
 	__u64	ac_utime;		/* User CPU time [usec] */
 	__u64	ac_stime;		/* SYstem CPU time [usec] */
 	/* Basic Accounting Fields end */
+
+ 	/* CSA accounting fields start */
+ 	__u16	csa_revision;		/* CSA Revision */

May be helpful to add a note here that every time csa_revision is changed, TASKSTATS_VERSION also needs to be bumped up.

Certainly! Thanks!

Quoted 13 lines
Quoted 10 lines
include/linux/taskstats.h +5 -0
+ 	__u16	csa_pad[3];		/* Unused */
 
 
 
+ 	__u64	acct_rss_mem1;		/* accumulated rss usage */
+ 	__u64	acct_vm_mem1;		/* accumulated virtual memory usage */
+ 	__u64	hiwater_rss;		/* High-watermark of RSS usage */
+ 	__u64	hiwater_vm;		/* High-water virtual memory usage */
Quoted 6 lines

include/linux/taskstats.h struct taskstats { · line 119

Quoted 2 lines
include/linux/taskstats.h +2 -0
+ 	__u64	ac_minflt;		/* Minor Page Fault */
+ 	__u64	ac_majflt;		/* Major Page Fault */

Can the number of prefixes be reduced ? In the space of a few fields, we have ac_*, csa_*, acct_* and plain (for hiwater_rss/vm)

Will do better in next round. I will see if people like to do away the pre_ completely. Otherwise, i will keep ac_ for basic and plain for CSA specific fields.

Quoted 9 lines

include/linux/taskstats.h struct taskstats { · line 123

Quoted 7 lines
include/linux/taskstats.h +4 -0
+ 	__u64	ac_chr;			/* bytes read */
+ 	__u64	ac_chw;			/* bytes written */
+ 	__u64	ac_scr;			/* read syscalls */
+ 	__u64	ac_scw;			/* write syscalls */
Quoted 4 lines

read_char,
write_char,
read_syscalls,
write_syscalls,

Mmm, those are from task_struct.

Regards,
- jay

Quoted 193 lines

perhaps (esp. if you're dropping the ac_ prefix) ?

Quoted 22 lines
include/linux/taskstats.h +1 -0
+ 	/* CSA accounting fields end */

};

Index: linux/init/Kconfig
===================================================================

init/Kconfig +7 -0
@@ -182,6 +182,31 @@ config TASK_DELAY_ACCT
 
 	  Say N if unsure.
 
+config CSA_ACCT
+	bool "Enable CSA Job Accounting (EXPERIMENTAL)"
+	depends on TASKSTATS
+	help
+	  Comprehensive System Accounting (CSA) provides job level
+	  accounting of resource usage.  The accounting records are
+	  written by the kernel into a file.  CSA user level scripts

init/Kconfig config TASK_DELAY_ACCT · line 201

Quoted 10 lines
init/Kconfig +10 -0
+	  and commands process the binary accounting records and
+	  combine them by job identifier within system boot uptime
+	  periods.  These accounting records are then used to produce
+	  reports and charge fees to users.
+
+	  Say Y here if you want job level accounting to be compiled
+	  into the kernel.  Say M here if you want the writing of
+	  accounting records portion of this feature to be a loadable
+	  module.  Say N here if you do not want job level accounting
+	  (the default).

The description above is tied to jobs which don't exist in the kernel. There's no dependency of CSA on kernel-visible jobs anymore, right ? Perhaps the blurb can clarify that jobs are defined in user space.

Quoted 35 lines
init/Kconfig +8 -0
+
+	  The CSA commands and scripts package needs to be installed
+	  to process the CSA accounting records.  See
+	  http://oss.sgi.com/projects/csa for further information
+	  about CSA and download instructions for the CSA commands
+	  package and documentation.
+
+

config SYSCTL
bool "Sysctl support" if EMBEDDED
default y
Index: linux/kernel/Makefile
===================================================================

kernel/Makefile +0 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_RCU_TORTURE_TEST) += rcutor

obj-$(CONFIG_RELAY) += relay.o
obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
obj-$(CONFIG_TASKSTATS) += taskstats.o
+obj-$(CONFIG_CSA_ACCT) += csa.o

ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
# According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
Index: linux/kernel/csa.c
===================================================================

kernel/csa.c new file +7 -0
@@ -0,0 +1,46 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */

kernel/csa.c line 17

Quoted 10 lines
kernel/csa.c new file +10 -0
+
+
+/*
+ *  CSA (Comprehensive System Accounting)
+ *  Job Accounting for Linux
+ *
+ *  This header file contains the definitions needed for job
+ *  accounting. The kernel CSA accounting module code and all
+ *  user-level programs that try to write or process the binary job
+ *  accounting data must include this file.

Again, job dependency might need some clarification.

kernel/csa.c line 23

Quoted 6 lines
kernel/csa.c new file +6 -0
+ *
+ *  This kernel header file and the csa.h in the csa userland source
+ *  rpm share same data struct declaration and #define's. Do not modify
+ *  one without modify the other one as well. The compatibility between
+ *  userland and the kernel is ensured by using the 'ah_revision' field
+ *  of struct achead.

Leftover from older documentation ?

Quoted 55 lines
kernel/csa.c new file +23 -0
+ *
+ */
+
+#include <linux/taskstats.h>
+#include <linux/csa_kern.h>
+#include <linux/sched.h>
+
+void csa_add_tsk(struct taskstats *stats, struct task_struct *p)
+{
+	stats->csa_revision = REV_CSA;
+	stats->acct_rss_mem1 = p->acct_rss_mem1;
+	stats->acct_vm_mem1  = p->acct_vm_mem1;
+	if (p->mm) {
+		stats->hiwater_rss   = p->mm->hiwater_rss;
+		stats->hiwater_vm    = p->mm->hiwater_vm;
+	}
+	stats->ac_minflt = p->min_flt;
+	stats->ac_majflt = p->maj_flt;
+	stats->ac_chr	= p->rchar;
+	stats->ac_chw	= p->wchar;
+	stats->ac_scr	= p->syscr;
+	stats->ac_scw	= p->syscw;
+}

Index: linux/kernel/taskstats.c
===================================================================

kernel/taskstats.c +4 -0
@@ -21,6 +21,7 @@
 #include <linux/taskstats_kern.h>
 #include <linux/acct.h>
 #include <linux/delayacct.h>
+#include <linux/csa_kern.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
 #include <net/genetlink.h>
@@ -252,6 +253,9 @@ static int fill_pid(pid_t pid, struct ta
 	/* fill in basic acct fields */
 	bacct_add_tsk(stats, tsk);
 
+	/* fill in csa fields */
+	csa_add_tsk(stats, tsk);
+
 	/* Define err: label here if needed */
 	put_task_struct(tsk);
 	return rc;

Index: linux/include/linux/csa_kern.h
===================================================================

include/linux/csa_kern.h new file +5 -0
@@ -0,0 +1,31 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *

include/linux/csa_kern.h line 15

Quoted 10 lines
include/linux/csa_kern.h new file +10 -0
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */
+
+#ifndef _CSA_KERN_H
+#define _CSA_KERN_H
+
+#ifdef CONFIG_CSA_ACCT
+extern void csa_add_tsk(struct taskstats *, struct task_struct *);
+#else
+#define csa_add_tsk(x)		do { } while (0)

This won't compile right...number of args differ.

Quoted 17 lines
include/linux/csa_kern.h new file +16 -0
+#endif
+
+/*
+ * Record revision levels.
+ *
+ * These are incremented to indicate that a record's format has changed since
+ * a previous release.
+ *
+ * History:     05000   The first rev in Linux
+ *              06000   Major rework to clean up unused fields and features.
+ *                      No binary compatibility with earlier rev.
+ *		07000	Convert to taskstats interface
+ */
+#define REV_CSA		07000	/* Kernel: CSA base record */
+
+#endif	/* _CSA_KERN_H */
author
#4 lore raw
In reply to Shailabh Nagar
Quoted 1 line · Shailabh Nagar

Jay Lan wrote:

Sorry, my last reply was not complete.

Quoted 1 line

<snip>

Quoted 24 lines
Quoted 24 lines

Index: linux/init/Kconfig
===================================================================

init/Kconfig +14 -0
@@ -182,6 +182,31 @@ config TASK_DELAY_ACCT
 
 	  Say N if unsure.
 
+config CSA_ACCT
+	bool "Enable CSA Job Accounting (EXPERIMENTAL)"
+	depends on TASKSTATS
+	help
+	  Comprehensive System Accounting (CSA) provides job level
+	  accounting of resource usage.  The accounting records are
+	  written by the kernel into a file.  CSA user level scripts
+	  and commands process the binary accounting records and
+	  combine them by job identifier within system boot uptime
+	  periods.  These accounting records are then used to produce
+	  reports and charge fees to users.
+
+	  Say Y here if you want job level accounting to be compiled
+	  into the kernel.  Say M here if you want the writing of
Quoted 8 lines

init/Kconfig config TASK_DELAY_ACCT · line 201

Quoted 3 lines
init/Kconfig +3 -0
+	  accounting records portion of this feature to be a loadable
+	  module.  Say N here if you do not want job level accounting
+	  (the default).

The description above is tied to jobs which don't exist in the kernel. There's no dependency of CSA on kernel-visible jobs anymore, right ? Perhaps the blurb can clarify that jobs are defined in user space.

Will redo this part.

Quoted 60 lines
Quoted 37 lines
init/Kconfig +8 -0
+
+	  The CSA commands and scripts package needs to be installed
+	  to process the CSA accounting records.  See
+	  http://oss.sgi.com/projects/csa for further information
+	  about CSA and download instructions for the CSA commands
+	  package and documentation.
+
+

config SYSCTL
bool "Sysctl support" if EMBEDDED
default y
Index: linux/kernel/Makefile
===================================================================

kernel/Makefile +0 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_RCU_TORTURE_TEST) += rcutor

obj-$(CONFIG_RELAY) += relay.o
obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
obj-$(CONFIG_TASKSTATS) += taskstats.o
+obj-$(CONFIG_CSA_ACCT) += csa.o

ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
# According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
Index: linux/kernel/csa.c
===================================================================

kernel/csa.c new file +7 -0
@@ -0,0 +1,46 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */

kernel/csa.c line 17

Quoted 10 lines
kernel/csa.c new file +10 -0
+
+
+/*
+ *  CSA (Comprehensive System Accounting)
+ *  Job Accounting for Linux
+ *
+ *  This header file contains the definitions needed for job
+ *  accounting. The kernel CSA accounting module code and all
+ *  user-level programs that try to write or process the binary job
+ *  accounting data must include this file.

Again, job dependency might need some clarification.

kernel/csa.c line 23

Quoted 6 lines
kernel/csa.c new file +6 -0
+ *
+ *  This kernel header file and the csa.h in the csa userland source
+ *  rpm share same data struct declaration and #define's. Do not modify
+ *  one without modify the other one as well. The compatibility between
+ *  userland and the kernel is ensured by using the 'ah_revision' field
+ *  of struct achead.
Quoted 1 line

Leftover from older documentation ?

Will redo the above two sections.

Quoted 62 lines
Quoted 62 lines
kernel/csa.c new file +23 -0
+ *
+ */
+
+#include <linux/taskstats.h>
+#include <linux/csa_kern.h>
+#include <linux/sched.h>
+
+void csa_add_tsk(struct taskstats *stats, struct task_struct *p)
+{
+	stats->csa_revision = REV_CSA;
+	stats->acct_rss_mem1 = p->acct_rss_mem1;
+	stats->acct_vm_mem1  = p->acct_vm_mem1;
+	if (p->mm) {
+		stats->hiwater_rss   = p->mm->hiwater_rss;
+		stats->hiwater_vm    = p->mm->hiwater_vm;
+	}
+	stats->ac_minflt = p->min_flt;
+	stats->ac_majflt = p->maj_flt;
+	stats->ac_chr	= p->rchar;
+	stats->ac_chw	= p->wchar;
+	stats->ac_scr	= p->syscr;
+	stats->ac_scw	= p->syscw;
+}

Index: linux/kernel/taskstats.c
===================================================================

kernel/taskstats.c +4 -0
@@ -21,6 +21,7 @@
 #include <linux/taskstats_kern.h>
 #include <linux/acct.h>
 #include <linux/delayacct.h>
+#include <linux/csa_kern.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
 #include <net/genetlink.h>
@@ -252,6 +253,9 @@ static int fill_pid(pid_t pid, struct ta
 	/* fill in basic acct fields */
 	bacct_add_tsk(stats, tsk);
 
+	/* fill in csa fields */
+	csa_add_tsk(stats, tsk);
+
 	/* Define err: label here if needed */
 	put_task_struct(tsk);
 	return rc;

Index: linux/include/linux/csa_kern.h
===================================================================

include/linux/csa_kern.h new file +10 -0
@@ -0,0 +1,31 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2006 Silicon Graphics, Inc All Rights Reserved.
+ */
+
+#ifndef _CSA_KERN_H
+#define _CSA_KERN_H
Quoted 8 lines

include/linux/csa_kern.h line 15

Quoted 5 lines
include/linux/csa_kern.h new file +5 -0
+
+#ifdef CONFIG_CSA_ACCT
+extern void csa_add_tsk(struct taskstats *, struct task_struct *);
+#else
+#define csa_add_tsk(x)		do { } while (0)

This won't compile right...number of args differ.

Sorry i did not catch this one. Thanks!

Regards,
- jay

Quoted 21 lines
Quoted 19 lines
include/linux/csa_kern.h new file +16 -0
+#endif
+
+/*
+ * Record revision levels.
+ *
+ * These are incremented to indicate that a record's format has changed since
+ * a previous release.
+ *
+ * History:     05000   The first rev in Linux
+ *              06000   Major rework to clean up unused fields and features.
+ *                      No binary compatibility with earlier rev.
+ *		07000	Convert to taskstats interface
+ */
+#define REV_CSA		07000	/* Kernel: CSA base record */
+
+#endif	/* _CSA_KERN_H */
author
#3 lore raw
In reply to Jay Lan
Quoted 2 lines · Jay Lan

Shailabh Nagar wrote:

<clip>

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
include/linux/taskstats.h +4 -0
+     __u64    ac_chr;            /* bytes read */
+     __u64    ac_chw;            /* bytes written */
+     __u64    ac_scr;            /* read syscalls */
+     __u64    ac_scw;            /* write syscalls */
Quoted 7 lines
Quoted 4 lines

read_char,
write_char,
read_syscalls,
write_syscalls,

Mmm, those are from task_struct.

Ooops, i was wrong. They were not from task_struct. Will change to meaningful names as you suggested.

Regards,
- jay

Quoted 5 lines

Regards,
- jay

#5 lore raw
In reply to Jay Lan

Hi!

Quoted 8 lines

Index: linux/include/linux/taskstats.h
===================================================================

include/linux/taskstats.h struct taskstats { · line 113

Quoted 7 lines
include/linux/taskstats.h +4 -0
@@ -107,6 +107,21 @@ struct taskstats {
 	__u64	ac_utime;		/* User CPU time [usec] */
 	__u64	ac_stime;		/* SYstem CPU time [usec] */
 	/* Basic Accounting Fields end */
+
+ 	/* CSA accounting fields start */
+ 	__u16	csa_revision;		/* CSA Revision */
+ 	__u16	csa_pad[3];		/* Unused */

I guess you have way too many TLAs here...

include/linux/taskstats.h struct taskstats { · line 117

Quoted 4 lines
include/linux/taskstats.h +4 -0
+config CSA_ACCT
+	bool "Enable CSA Job Accounting (EXPERIMENTAL)"
+	depends on TASKSTATS
+	help

"Enable Comprehensive System Accounting Job Accounting" . Ouch. So you do not even know how to use those accronyms correctly.

I guess you should invent some better naming.

Quoted 9 lines
include/linux/taskstats.h +9 -0
+	  Comprehensive System Accounting (CSA) provides job level
+	  accounting of resource usage.  The accounting records are
+	  written by the kernel into a file.  CSA user level scripts
+	  and commands process the binary accounting records and
+	  combine them by job identifier within system boot uptime
+	  periods.  These accounting records are then used to produce
+	  reports and charge fees to users.
+
+	  Say Y here if you want job level accounting to be compiled

include/linux/taskstats.h struct taskstats {

Quoted 10 lines
include/linux/taskstats.h +10 -0
+	  into the kernel.  Say M here if you want the writing of
+	  accounting records portion of this feature to be a loadable
+	  module.  Say N here if you do not want job level accounting
+	  (the default).
+
+	  The CSA commands and scripts package needs to be installed
+	  to process the CSA accounting records.  See
+	  http://oss.sgi.com/projects/csa for further information
+	  about CSA and download instructions for the CSA commands
+	  package and documentation.

...long text and it *still* does not tell me what it is good for.

include/linux/taskstats.h

Quoted 12 lines
include/linux/taskstats.h +12 -0
+/*
+ * Record revision levels.
+ *
+ * These are incremented to indicate that a record's format has changed since
+ * a previous release.
+ *
+ * History:     05000   The first rev in Linux
+ *              06000   Major rework to clean up unused fields and features.
+ *                      No binary compatibility with earlier rev.
+ *		07000	Convert to taskstats interface
+ */
+#define REV_CSA		07000	/* Kernel: CSA base record */

We normally drop back compatibility at merge...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
author
#6 lore raw
Quoted 1 line · Pavel Machek

Hi!

Hi Pavel,

Thanks much for your feedback.

However, the patchset you commented on was replaced by a new patchset posted on 8/03:
http://marc.theaimsgroup.com/?l=linux-kernel&m=115457888801994&w=2

Thanks,
- jay

Quoted 76 lines
Quoted 10 lines

Index: linux/include/linux/taskstats.h
===================================================================

include/linux/taskstats.h struct taskstats { · line 113

Quoted 7 lines
include/linux/taskstats.h +4 -0
@@ -107,6 +107,21 @@ struct taskstats {
 	__u64	ac_utime;		/* User CPU time [usec] */
 	__u64	ac_stime;		/* SYstem CPU time [usec] */
 	/* Basic Accounting Fields end */
+
+ 	/* CSA accounting fields start */
+ 	__u16	csa_revision;		/* CSA Revision */
+ 	__u16	csa_pad[3];		/* Unused */

I guess you have way too many TLAs here...

include/linux/taskstats.h struct taskstats { · line 117

Quoted 4 lines
include/linux/taskstats.h +4 -0
+config CSA_ACCT
+	bool "Enable CSA Job Accounting (EXPERIMENTAL)"
+	depends on TASKSTATS
+	help

"Enable Comprehensive System Accounting Job Accounting" . Ouch. So you do not even know how to use those accronyms correctly.

I guess you should invent some better naming.

Quoted 9 lines
include/linux/taskstats.h +9 -0
+	  Comprehensive System Accounting (CSA) provides job level
+	  accounting of resource usage.  The accounting records are
+	  written by the kernel into a file.  CSA user level scripts
+	  and commands process the binary accounting records and
+	  combine them by job identifier within system boot uptime
+	  periods.  These accounting records are then used to produce
+	  reports and charge fees to users.
+
+	  Say Y here if you want job level accounting to be compiled

include/linux/taskstats.h struct taskstats {

Quoted 10 lines
include/linux/taskstats.h +10 -0
+	  into the kernel.  Say M here if you want the writing of
+	  accounting records portion of this feature to be a loadable
+	  module.  Say N here if you do not want job level accounting
+	  (the default).
+
+	  The CSA commands and scripts package needs to be installed
+	  to process the CSA accounting records.  See
+	  http://oss.sgi.com/projects/csa for further information
+	  about CSA and download instructions for the CSA commands
+	  package and documentation.

...long text and it *still* does not tell me what it is good for.

include/linux/taskstats.h

Quoted 12 lines
include/linux/taskstats.h +12 -0
+/*
+ * Record revision levels.
+ *
+ * These are incremented to indicate that a record's format has changed since
+ * a previous release.
+ *
+ * History:     05000   The first rev in Linux
+ *              06000   Major rework to clean up unused fields and features.
+ *                      No binary compatibility with earlier rev.
+ *		07000	Convert to taskstats interface
+ */
+#define REV_CSA		07000	/* Kernel: CSA base record */

We normally drop back compatibility at merge...
Pavel