)]}'
{
  "commit": "36de6437866bbb1d37e2312ff4f95ee4ed6d2b61",
  "tree": "5e77ff1af2ccaaeaba09d9aa0d9f10732207e865",
  "parents": [
    "33f2ef89f8e181486b63fdbdc97c6afa6ca9f34b"
  ],
  "author": {
    "name": "Arnaldo Carvalho de Melo",
    "email": "acme@mandriva.com",
    "time": "Wed Dec 06 20:33:42 2006 -0800"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@woody.osdl.org",
    "time": "Thu Dec 07 08:39:25 2006 -0800"
  },
  "message": "[PATCH] Save some bytes in struct mm_struct\n\nBefore:\n[acme@newtoy net-2.6.20]$ pahole --cacheline 32 kernel/sched.o mm_struct\n\n/* include2/asm/processor.h:542 */\nstruct mm_struct {\n        struct vm_area_struct *    mmap;                 /*     0     4 */\n        struct rb_root             mm_rb;                /*     4     4 */\n        struct vm_area_struct *    mmap_cache;           /*     8     4 */\n        long unsigned int          (*get_unmapped_area)(); /*    12     4 */\n        void                       (*unmap_area)();      /*    16     4 */\n        long unsigned int          mmap_base;            /*    20     4 */\n        long unsigned int          task_size;            /*    24     4 */\n        long unsigned int          cached_hole_size;     /*    28     4 */\n        /* ---------- cacheline 1 boundary ---------- */\n        long unsigned int          free_area_cache;      /*    32     4 */\n        pgd_t *                    pgd;                  /*    36     4 */\n        atomic_t                   mm_users;             /*    40     4 */\n        atomic_t                   mm_count;             /*    44     4 */\n        int                        map_count;            /*    48     4 */\n        struct rw_semaphore        mmap_sem;             /*    52    64 */\n        spinlock_t                 page_table_lock;      /*   116    40 */\n        struct list_head           mmlist;               /*   156     8 */\n        mm_counter_t               _file_rss;            /*   164     4 */\n        mm_counter_t               _anon_rss;            /*   168     4 */\n        long unsigned int          hiwater_rss;          /*   172     4 */\n        long unsigned int          hiwater_vm;           /*   176     4 */\n        long unsigned int          total_vm;             /*   180     4 */\n        long unsigned int          locked_vm;            /*   184     4 */\n        long unsigned int          shared_vm;            /*   188     4 */\n        /* ---------- cacheline 6 boundary ---------- */\n        long unsigned int          exec_vm;              /*   192     4 */\n        long unsigned int          stack_vm;             /*   196     4 */\n        long unsigned int          reserved_vm;          /*   200     4 */\n        long unsigned int          def_flags;            /*   204     4 */\n        long unsigned int          nr_ptes;              /*   208     4 */\n        long unsigned int          start_code;           /*   212     4 */\n        long unsigned int          end_code;             /*   216     4 */\n        long unsigned int          start_data;           /*   220     4 */\n        /* ---------- cacheline 7 boundary ---------- */\n        long unsigned int          end_data;             /*   224     4 */\n        long unsigned int          start_brk;            /*   228     4 */\n        long unsigned int          brk;                  /*   232     4 */\n        long unsigned int          start_stack;          /*   236     4 */\n        long unsigned int          arg_start;            /*   240     4 */\n        long unsigned int          arg_end;              /*   244     4 */\n        long unsigned int          env_start;            /*   248     4 */\n        long unsigned int          env_end;              /*   252     4 */\n        /* ---------- cacheline 8 boundary ---------- */\n        long unsigned int          saved_auxv[44];       /*   256   176 */\n        unsigned int               dumpable:2;           /*   432     4 */\n        cpumask_t                  cpu_vm_mask;          /*   436     4 */\n        mm_context_t               context;              /*   440    68 */\n        long unsigned int          swap_token_time;      /*   508     4 */\n        /* ---------- cacheline 16 boundary ---------- */\n        char                       recent_pagein;        /*   512     1 */\n\n        /* XXX 3 bytes hole, try to pack */\n\n        int                        core_waiters;         /*   516     4 */\n        struct completion *        core_startup_done;    /*   520     4 */\n        struct completion          core_done;            /*   524    52 */\n        rwlock_t                   ioctx_list_lock;      /*   576    36 */\n        struct kioctx *            ioctx_list;           /*   612     4 */\n}; /* size: 616, sum members: 613, holes: 1, sum holes: 3, cachelines: 20,\n      last cacheline: 8 bytes */\n\nAfter:\n\n[acme@newtoy net-2.6.20]$ pahole --cacheline 32 kernel/sched.o mm_struct\n/* include2/asm/processor.h:542 */\nstruct mm_struct {\n        struct vm_area_struct *    mmap;                 /*     0     4 */\n        struct rb_root             mm_rb;                /*     4     4 */\n        struct vm_area_struct *    mmap_cache;           /*     8     4 */\n        long unsigned int          (*get_unmapped_area)(); /*    12     4 */\n        void                       (*unmap_area)();      /*    16     4 */\n        long unsigned int          mmap_base;            /*    20     4 */\n        long unsigned int          task_size;            /*    24     4 */\n        long unsigned int          cached_hole_size;     /*    28     4 */\n        /* ---------- cacheline 1 boundary ---------- */\n        long unsigned int          free_area_cache;      /*    32     4 */\n        pgd_t *                    pgd;                  /*    36     4 */\n        atomic_t                   mm_users;             /*    40     4 */\n        atomic_t                   mm_count;             /*    44     4 */\n        int                        map_count;            /*    48     4 */\n        struct rw_semaphore        mmap_sem;             /*    52    64 */\n        spinlock_t                 page_table_lock;      /*   116    40 */\n        struct list_head           mmlist;               /*   156     8 */\n        mm_counter_t               _file_rss;            /*   164     4 */\n        mm_counter_t               _anon_rss;            /*   168     4 */\n        long unsigned int          hiwater_rss;          /*   172     4 */\n        long unsigned int          hiwater_vm;           /*   176     4 */\n        long unsigned int          total_vm;             /*   180     4 */\n        long unsigned int          locked_vm;            /*   184     4 */\n        long unsigned int          shared_vm;            /*   188     4 */\n        /* ---------- cacheline 6 boundary ---------- */\n        long unsigned int          exec_vm;              /*   192     4 */\n        long unsigned int          stack_vm;             /*   196     4 */\n        long unsigned int          reserved_vm;          /*   200     4 */\n        long unsigned int          def_flags;            /*   204     4 */\n        long unsigned int          nr_ptes;              /*   208     4 */\n        long unsigned int          start_code;           /*   212     4 */\n        long unsigned int          end_code;             /*   216     4 */\n        long unsigned int          start_data;           /*   220     4 */\n        /* ---------- cacheline 7 boundary ---------- */\n        long unsigned int          end_data;             /*   224     4 */\n        long unsigned int          start_brk;            /*   228     4 */\n        long unsigned int          brk;                  /*   232     4 */\n        long unsigned int          start_stack;          /*   236     4 */\n        long unsigned int          arg_start;            /*   240     4 */\n        long unsigned int          arg_end;              /*   244     4 */\n        long unsigned int          env_start;            /*   248     4 */\n        long unsigned int          env_end;              /*   252     4 */\n        /* ---------- cacheline 8 boundary ---------- */\n        long unsigned int          saved_auxv[44];       /*   256   176 */\n        cpumask_t                  cpu_vm_mask;          /*   432     4 */\n        mm_context_t               context;              /*   436    68 */\n        long unsigned int          swap_token_time;      /*   504     4 */\n        char                       recent_pagein;        /*   508     1 */\n        unsigned char              dumpable:2;           /*   509     1 */\n\n        /* XXX 2 bytes hole, try to pack */\n\n        int                        core_waiters;         /*   512     4 */\n        struct completion *        core_startup_done;    /*   516     4 */\n        struct completion          core_done;            /*   520    52 */\n        rwlock_t                   ioctx_list_lock;      /*   572    36 */\n        struct kioctx *            ioctx_list;           /*   608     4 */\n}; /* size: 612, sum members: 610, holes: 1, sum holes: 2, cachelines: 20,\n      last cacheline: 4 bytes */\n\n[acme@newtoy net-2.6.20]$ codiff -V /tmp/sched.o.before kernel/sched.o\n/pub/scm/linux/kernel/git/acme/net-2.6.20/kernel/sched.c:\n  struct mm_struct |   -4\n    dumpable:2;\n     from: unsigned int          /*   432(30)    4(2) */\n     to:   unsigned char         /*   509(6)     1(2) */\n\u003c SNIP other offset changes \u003e\n 1 struct changed\n[acme@newtoy net-2.6.20]$\n\nI\u0027m not aware of any problem about using 2 byte wide bitfields where\npreviously a 4 byte wide one was, holler if there is any, I wouldn\u0027t be\nsurprised, bitfields are things from hell.\n\nFor the curious, 432(30) means: at offset 432 from the struct start, at\noffset 30 in the bitfield (yeah, it comes backwards, hellish, huh?) ditto\nfor 509(6), while 4(2) and 1(2) means \"struct field size(bitfield size)\".\n\nNow we have a 2 bytes hole and are using only 4 bytes of the last 32\nbytes cacheline, any takers? :-)\n\nSigned-off-by: Arnaldo Carvalho de Melo \u003cacme@mandriva.com\u003e\nSigned-off-by: Andrew Morton \u003cakpm@osdl.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@osdl.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "cad6a16260f76f9115a3e893a804d0b3eb711c10",
      "old_mode": 33188,
      "old_path": "include/linux/sched.h",
      "new_id": "acfd2e15c5f27be9215dd5202a0cb93bc153d8d4",
      "new_mode": 33188,
      "new_path": "include/linux/sched.h"
    }
  ]
}
