[PATCH 2/2] UBUNTU: SAUCE: ATOP additional statistical counters for process-accounting

Tim Gardner tim.gardner at canonical.com
Fri Jun 25 13:25:18 UTC 2010


On 06/24/2010 01:16 PM, john.johansen at canonical.com wrote:
> From: John Johansen<john.johansen at canonical.com>
>
> ATOP patchset request by server team currently out of tree.
>
> OriginalAuthor: Marko Zagožen
> OriginalLocation: http://www.atoptool.nl/download/atoppatch-kernel-2.6.33.tar.gz
>
>    02patch-2.6.33_atopacct
>          This patch takes care that the additional statistical
>          counters are added to the process-accounting record (yes,
>          this means an incompatible layout of this record).
>
>          Notice that this patch is an extension of the 01XXX_atopcnt
>          patch! This patch can not be installed on its own.
>
>          When this patch is installed, ATOP automatically shows
>          the additional counters for terminated processes as well.
>          Since the pid of processes is also stored in the modified
>          process-accounting record, matching this info with the
>          formerly running process is less time-consuming compared to
>          the conventional process-accounting record.
>
>     Gerlof Langeveld<gerlof at atoptool.nl>
>     Credits for this specific port: Marko Zagožen
>
> Signed-off-by: John Johansen<john.johansen at canonical.com>
> ---
>   include/linux/acct.h |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   kernel/acct.c        |   26 ++++++++++++++++++++++-
>   2 files changed, 80 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/acct.h b/include/linux/acct.h
> index 3e4737f..d448e07 100644
> --- a/include/linux/acct.h
> +++ b/include/linux/acct.h
> @@ -97,6 +97,54 @@ struct acct_v3
>   	char		ac_comm[ACCT_COMM];	/* Command Name */
>   };
>
> +struct acct_atop
> +{
> +	char		ac_flag;		/* Flags */
> +	char		ac_version;		/* Always set to ACCT_VERSION */
> +	__u32		ac_pid;			/* Process ID */
> +	__u32		ac_ppid;		/* Parent Process ID */
> +	__u16		ac_uid16;		/* LSB of Real User ID */
> +	__u16		ac_gid16;		/* LSB of Real Group ID */
> +	__u16		ac_tty;			/* Control Terminal */
> +	__u32		ac_btime;		/* Process Creation Time */
> +	comp_t		ac_utime;		/* User Time */
> +	comp_t		ac_stime;		/* System Time */
> +	comp_t		ac_etime;		/* Elapsed Time */
> +	comp_t		ac_mem;			/* Virtual  Memory */
> +	comp_t		ac_rss;			/* Resident Memory */
> +	comp_t		ac_io;			/* Chars Transferred */
> +	comp_t		ac_rw;			/* Blocks Read or Written */
> +	comp_t		ac_bread;		/* Blocks Read */
> +	comp_t		ac_bwrite;		/* Blocks Written */
> +	comp2_t		ac_dskrsz;		/* Cum. blocks read */
> +	comp2_t		ac_dskwsz;		/* Cum. blocks written */
> +	comp_t		ac_tcpsnd;		/* TCP send requests */
> +	comp_t		ac_tcprcv;		/* TCP recv requests */
> +	comp2_t		ac_tcpssz;		/* TCP cum. length   */
> +	comp2_t		ac_tcprsz;		/* TCP cum. length   */
> +	comp_t		ac_udpsnd;		/* UDP send requests */
> +	comp_t		ac_udprcv;		/* UDP recv requests */
> +	comp2_t		ac_udpssz;		/* UDP cum. length   */
> +	comp2_t		ac_udprsz;		/* UDP cum. length   */
> +	comp_t		ac_rawsnd;		/* RAW send requests */
> +	comp_t		ac_rawrcv;		/* RAW recv requests */
> +	comp_t		ac_minflt;		/* Minor Pagefaults */
> +	comp_t		ac_majflt;		/* Major Pagefaults */
> +	comp_t		ac_swaps;		/* Number of Swaps */
> +/* m68k had no padding here. */
> +#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
> +	__u16		ac_ahz;			/* AHZ */
> +#endif
> +	__u32		ac_exitcode;		/* Exitcode */
> +	char		ac_comm[ACCT_COMM + 1];	/* Command Name */
> +	__u8		ac_etime_hi;		/* Elapsed Time MSB */
> +	__u16		ac_etime_lo;		/* Elapsed Time LSB */
> +	__u32		ac_uid;			/* Real User ID */
> +	__u32		ac_gid;			/* Real Group ID */
> +};
> +
> +
> +
>   /*
>    *  accounting flags
>    */
> @@ -145,7 +193,13 @@ extern void acct_exit_ns(struct pid_namespace *);
>    * 5: new binary incompatible format (128 bytes, second half)
>    *
>    */
> +#define CONFIG_PROCESS_ACCT_ATOP
>
> +#ifdef CONFIG_PROCESS_ACCT_ATOP
> +#define ACCT_VERSION	6
> +#define AHZ		(USER_HZ)
> +typedef struct acct_atop acct_t;
> +#else
>   #ifdef CONFIG_BSD_PROCESS_ACCT_V3
>   #define ACCT_VERSION	3
>   #define AHZ		100
> @@ -159,6 +213,7 @@ typedef struct acct_v3 acct_t;
>   #define AHZ		(USER_HZ)
>   typedef struct acct acct_t;
>   #endif
> +#endif
>
>   #else
>   #define ACCT_VERSION	2
> diff --git a/kernel/acct.c b/kernel/acct.c
> index 87cfa24..93333c9 100644
> --- a/kernel/acct.c
> +++ b/kernel/acct.c
> @@ -396,7 +396,7 @@ static comp_t encode_comp_t(unsigned long value)
>   	return exp;
>   }
>
> -#if ACCT_VERSION==1 || ACCT_VERSION==2
> +#if ACCT_VERSION==1 || ACCT_VERSION==2 || ACCT_VERSION==6
>   /*
>    * encode an u64 into a comp2_t (24 bits)
>    *
> @@ -543,6 +543,30 @@ static void do_acct_process(struct bsd_acct_struct *acct,
>   	ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), ns);
>   	rcu_read_unlock();
>   #endif
> +#if ACCT_VERSION==6        /* ATOP */
> +	ac.ac_pid    = current->pid;
> +	ac.ac_ppid   = current->parent->pid;
> +       ac.ac_uid16  = ac.ac_uid;
> +       ac.ac_gid16  = ac.ac_gid;
> +	ac.ac_ahz    = AHZ;
> +	ac.ac_bread  = encode_comp_t(current->stat.dsk_rio);
> +	ac.ac_bwrite = encode_comp_t(current->stat.dsk_wio);
> +	ac.ac_dskrsz = encode_comp2_t(current->stat.dsk_rsz);
> +	ac.ac_dskwsz = encode_comp2_t(current->stat.dsk_wsz);
> +	ac.ac_tcpsnd = encode_comp_t(current->stat.tcp_snd);
> +	ac.ac_tcprcv = encode_comp_t(current->stat.tcp_rcv);
> +	ac.ac_tcpssz = encode_comp2_t(current->stat.tcp_ssz);
> +	ac.ac_tcprsz = encode_comp2_t(current->stat.tcp_rsz);
> +	ac.ac_udpsnd = encode_comp_t(current->stat.udp_snd);
> +	ac.ac_udprcv = encode_comp_t(current->stat.udp_rcv);
> +	ac.ac_udpssz = encode_comp2_t(current->stat.udp_ssz);
> +	ac.ac_udprsz = encode_comp2_t(current->stat.udp_rsz);
> +	ac.ac_rawsnd = encode_comp_t(current->stat.raw_snd);
> +	ac.ac_rawrcv = encode_comp_t(current->stat.raw_rcv);
> +	ac.ac_rss    = current->mm ?
> +		encode_comp_t(get_mm_rss(current->mm)<<(PAGE_SHIFT-10)) :
> +		encode_comp_t(0);
> +#endif
>
>   	spin_lock_irq(&current->sighand->siglock);
>   	tty = current->signal->tty;	/* Safe as we hold the siglock */

One of the issues that I have with this patch set (besides the butt ugly 
'/* ATOP */' scattered everywhere) is that it precludes 
CONFIG_BSD_PROCESS_ACCT_V3 if CONFIG_PROCESS_ACCT_ATOP is enabled.

What applications do we have that depend on CONFIG_BSD_PROCESS_ACCT_V3 ?

rtg
-- 
Tim Gardner tim.gardner at canonical.com




More information about the kernel-team mailing list