aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2007-05-08 03:23:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:14:58 -0400
commit97dc32cdb1b53832801159d5f634b41aad9d0a23 (patch)
tree438f59c84d3528de5f68583d312beceb1aa32659 /include/linux/sched.h
parent4d7bf11d649c72621ca31b8ea12b9c94af380e63 (diff)
reduce size of task_struct on 64-bit machines
This past week I was playing around with that pahole tool (http://oops.ghostprotocols.net:81/acme/dwarves/) and looking at the size of various struct in the kernel. I was surprised by the size of the task_struct on x86_64, approaching 4K. I looked through the fields in task_struct and found that a number of them were declared as "unsigned long" rather than "unsigned int" despite them appearing okay as 32-bit sized fields. On x86_64 "unsigned long" ends up being 8 bytes in size and forces 8 byte alignment. Is there a reason there a reason they are "unsigned long"? The patch below drops the size of the struct from 3808 bytes (60 64-byte cachelines) to 3760 bytes (59 64-byte cachelines). A couple other fields in the task struct take a signficant amount of space: struct thread_struct thread; 688 struct held_lock held_locks[30]; 1680 CONFIG_LOCKDEP is turned on in the .config [akpm@linux-foundation.org: fix printk warnings] Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a1707583de49..d9acbbb39f96 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -801,8 +801,8 @@ struct task_struct {
801 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ 801 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
802 struct thread_info *thread_info; 802 struct thread_info *thread_info;
803 atomic_t usage; 803 atomic_t usage;
804 unsigned long flags; /* per process flags, defined below */ 804 unsigned int flags; /* per process flags, defined below */
805 unsigned long ptrace; 805 unsigned int ptrace;
806 806
807 int lock_depth; /* BKL lock depth */ 807 int lock_depth; /* BKL lock depth */
808 808
@@ -825,7 +825,7 @@ struct task_struct {
825 unsigned long long sched_time; /* sched_clock time spent running */ 825 unsigned long long sched_time; /* sched_clock time spent running */
826 enum sleep_type sleep_type; 826 enum sleep_type sleep_type;
827 827
828 unsigned long policy; 828 unsigned int policy;
829 cpumask_t cpus_allowed; 829 cpumask_t cpus_allowed;
830 unsigned int time_slice, first_time_slice; 830 unsigned int time_slice, first_time_slice;
831 831
@@ -845,11 +845,11 @@ struct task_struct {
845 845
846/* task state */ 846/* task state */
847 struct linux_binfmt *binfmt; 847 struct linux_binfmt *binfmt;
848 long exit_state; 848 int exit_state;
849 int exit_code, exit_signal; 849 int exit_code, exit_signal;
850 int pdeath_signal; /* The signal sent when the parent dies */ 850 int pdeath_signal; /* The signal sent when the parent dies */
851 /* ??? */ 851 /* ??? */
852 unsigned long personality; 852 unsigned int personality;
853 unsigned did_exec:1; 853 unsigned did_exec:1;
854 pid_t pid; 854 pid_t pid;
855 pid_t tgid; 855 pid_t tgid;
@@ -881,7 +881,7 @@ struct task_struct {
881 int __user *set_child_tid; /* CLONE_CHILD_SETTID */ 881 int __user *set_child_tid; /* CLONE_CHILD_SETTID */
882 int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */ 882 int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
883 883
884 unsigned long rt_priority; 884 unsigned int rt_priority;
885 cputime_t utime, stime; 885 cputime_t utime, stime;
886 unsigned long nvcsw, nivcsw; /* context switch counts */ 886 unsigned long nvcsw, nivcsw; /* context switch counts */
887 struct timespec start_time; 887 struct timespec start_time;