]> git.hungrycats.org Git - linux/commitdiff
[PATCH] shrink task_struct by removing per_cpu utime and stime
authorAndrew Morton <akpm@digeo.com>
Tue, 26 Nov 2002 01:56:58 +0000 (17:56 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Tue, 26 Nov 2002 01:56:58 +0000 (17:56 -0800)
Patch from Bill Irwin.  It has the potential to break userspace
monitoring tools a little bit, and I'm a rater uncertain about
how useful the per-process per-cpu accounting is.

Bill sent this out as an RFC on July 29:

"These statistics severely bloat the task_struct and nothing in
 userspace can rely on them as they're conditional on CONFIG_SMP.  If
 anyone is using them (or just wants them around), please speak up."

And nobody spoke up.

If we apply this, the contents of /proc/783/cpu will go from

cpu  1 1
cpu0 0 0
cpu1 0 0
cpu2 1 1
cpu3 0 0

to

cpu  1 1

And we shall save 256 bytes from the ia32 task_struct.

On my SMP build with NR_CPUS=32:

Without this patch, sizeof(task_struct) is 1824, slab uses a 1-order
allocation and we are getting 2 task_structs per page.

With this patch, sizeof(task_struct) is 1568, slab uses a 2-order
allocation and we are getting 2.5 task_structs per page.

So it seems worthwhile.

(Maybe this highlights a shortcoming in slab.  For the 1824-byte case
it could have used a 0-order allocation)

fs/proc/array.c
fs/proc/base.c
include/linux/sched.h
kernel/fork.c
kernel/timer.c

index 00e80906b170fed4099861bd9bbbe2dcc5caca01..2fa25e95712df88addf634bcb05a853325fbae2b 100644 (file)
@@ -597,25 +597,3 @@ out_free1:
 out:
        return retval;
 }
-
-#ifdef CONFIG_SMP
-int proc_pid_cpu(struct task_struct *task, char * buffer)
-{
-       int i, len;
-
-       len = sprintf(buffer,
-               "cpu  %lu %lu\n",
-               jiffies_to_clock_t(task->utime),
-               jiffies_to_clock_t(task->stime));
-               
-       for (i = 0 ; i < NR_CPUS; i++) {
-               if (cpu_online(i))
-               len += sprintf(buffer + len, "cpu%d %lu %lu\n",
-                       i,
-                       jiffies_to_clock_t(task->per_cpu_utime[i]),
-                       jiffies_to_clock_t(task->per_cpu_stime[i]));
-
-       }
-       return len;
-}
-#endif
index 71d9984ad1dcf2ff1892671fb866710da76ece0c..27035201576f7f53f427647069ec24e46f147535 100644 (file)
@@ -54,7 +54,6 @@ enum pid_directory_inos {
        PROC_PID_STAT,
        PROC_PID_STATM,
        PROC_PID_MAPS,
-       PROC_PID_CPU,
        PROC_PID_MOUNTS,
        PROC_PID_WCHAN,
        PROC_PID_FD_DIR = 0x8000,       /* 0x8000-0xffff */
@@ -75,9 +74,6 @@ static struct pid_entry base_stuff[] = {
   E(PROC_PID_CMDLINE,  "cmdline",      S_IFREG|S_IRUGO),
   E(PROC_PID_STAT,     "stat",         S_IFREG|S_IRUGO),
   E(PROC_PID_STATM,    "statm",        S_IFREG|S_IRUGO),
-#ifdef CONFIG_SMP
-  E(PROC_PID_CPU,      "cpu",          S_IFREG|S_IRUGO),
-#endif
   E(PROC_PID_MAPS,     "maps",         S_IFREG|S_IRUGO),
   E(PROC_PID_MEM,      "mem",          S_IFREG|S_IRUSR|S_IWUSR),
   E(PROC_PID_CWD,      "cwd",          S_IFLNK|S_IRWXUGO),
@@ -1029,12 +1025,7 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
                case PROC_PID_MAPS:
                        inode->i_fop = &proc_maps_operations;
                        break;
-#ifdef CONFIG_SMP
-               case PROC_PID_CPU:
-                       inode->i_fop = &proc_info_file_operations;
-                       ei->op.proc_read = proc_pid_cpu;
-                       break;
-#endif
+
                case PROC_PID_MEM:
                        inode->i_op = &proc_mem_inode_operations;
                        inode->i_fop = &proc_mem_operations;
index facb0f80d0a85f0cdfe52b55d34100699ed33e0e..82fa39d201f5a6922371673a370473d59c301dec 100644 (file)
@@ -342,7 +342,6 @@ struct task_struct {
        struct timer_list real_timer;
        unsigned long utime, stime, cutime, cstime;
        unsigned long start_time;
-       long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS];
 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
        unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
        int swappable:1;
index 27cf572cedf867d747e8966341a6b9045ab016b6..9cc9718f4e3944a0373be6938188bb4d1cd88448 100644 (file)
@@ -795,15 +795,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
        p->tty_old_pgrp = 0;
        p->utime = p->stime = 0;
        p->cutime = p->cstime = 0;
-#ifdef CONFIG_SMP
-       {
-               int i;
-
-               /* ?? should we just memset this ?? */
-               for(i = 0; i < NR_CPUS; i++)
-                       p->per_cpu_utime[i] = p->per_cpu_stime[i] = 0;
-       }
-#endif
        p->array = NULL;
        p->lock_depth = -1;             /* -1 = no lock */
        p->start_time = jiffies;
index 19e4296c72bddbc5aef57e88df45380c35bf1e53..0b9913aad53b0ab05460642044e0eb867a78616d 100644 (file)
@@ -694,8 +694,6 @@ static inline void do_it_prof(struct task_struct *p)
 void update_one_process(struct task_struct *p, unsigned long user,
                        unsigned long system, int cpu)
 {
-       p->per_cpu_utime[cpu] += user;
-       p->per_cpu_stime[cpu] += system;
        do_process_times(p, user, system);
        do_it_virt(p, user);
        do_it_prof(p);