aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2007-05-08 03:26:15 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:03 -0400
commitc5141e6d64ab5c48a5e31413c7a6cdda84ac1d52 (patch)
tree95a93ed2f56e98f6b6659ab906faee7abb252a49
parentd9a2f4a4945ebff54c9a011e4dc6e92d899ae26d (diff)
procfs: reorder struct pid_dentry to save space on 64bit archs, and constify them
Change the order of fields of struct pid_entry (file fs/proc/base.c) in order to avoid a hole on 64bit archs. (8 bytes saved per object) Also change all pid_entry arrays to be const qualified, to make clear they must not be modified. Before (on x86_64) : # size fs/proc/base.o text data bss dec hex filename 15549 2192 0 17741 454d fs/proc/base.o After : # size fs/proc/base.o text data bss dec hex filename 17229 176 0 17405 43fd fs/proc/base.o Thats 336 bytes saved on kernel size on x86_64 Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/proc/base.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 17f7a7ee6c5e..be94ddebb413 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -91,8 +91,8 @@
91#define PROC_NUMBUF 13 91#define PROC_NUMBUF 13
92 92
93struct pid_entry { 93struct pid_entry {
94 int len;
95 char *name; 94 char *name;
95 int len;
96 mode_t mode; 96 mode_t mode;
97 const struct inode_operations *iop; 97 const struct inode_operations *iop;
98 const struct file_operations *fop; 98 const struct file_operations *fop;
@@ -100,8 +100,8 @@ struct pid_entry {
100}; 100};
101 101
102#define NOD(NAME, MODE, IOP, FOP, OP) { \ 102#define NOD(NAME, MODE, IOP, FOP, OP) { \
103 .len = sizeof(NAME) - 1, \
104 .name = (NAME), \ 103 .name = (NAME), \
104 .len = sizeof(NAME) - 1, \
105 .mode = MODE, \ 105 .mode = MODE, \
106 .iop = IOP, \ 106 .iop = IOP, \
107 .fop = FOP, \ 107 .fop = FOP, \
@@ -1159,7 +1159,8 @@ static struct dentry_operations pid_dentry_operations =
1159 1159
1160/* Lookups */ 1160/* Lookups */
1161 1161
1162typedef struct dentry *instantiate_t(struct inode *, struct dentry *, struct task_struct *, void *); 1162typedef struct dentry *instantiate_t(struct inode *, struct dentry *,
1163 struct task_struct *, const void *);
1163 1164
1164/* 1165/*
1165 * Fill a directory entry. 1166 * Fill a directory entry.
@@ -1175,7 +1176,7 @@ typedef struct dentry *instantiate_t(struct inode *, struct dentry *, struct tas
1175 */ 1176 */
1176static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir, 1177static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
1177 char *name, int len, 1178 char *name, int len,
1178 instantiate_t instantiate, struct task_struct *task, void *ptr) 1179 instantiate_t instantiate, struct task_struct *task, const void *ptr)
1179{ 1180{
1180 struct dentry *child, *dir = filp->f_path.dentry; 1181 struct dentry *child, *dir = filp->f_path.dentry;
1181 struct inode *inode; 1182 struct inode *inode;
@@ -1310,9 +1311,9 @@ static struct dentry_operations tid_fd_dentry_operations =
1310}; 1311};
1311 1312
1312static struct dentry *proc_fd_instantiate(struct inode *dir, 1313static struct dentry *proc_fd_instantiate(struct inode *dir,
1313 struct dentry *dentry, struct task_struct *task, void *ptr) 1314 struct dentry *dentry, struct task_struct *task, const void *ptr)
1314{ 1315{
1315 unsigned fd = *(unsigned *)ptr; 1316 unsigned fd = *(const unsigned *)ptr;
1316 struct file *file; 1317 struct file *file;
1317 struct files_struct *files; 1318 struct files_struct *files;
1318 struct inode *inode; 1319 struct inode *inode;
@@ -1478,9 +1479,9 @@ static const struct inode_operations proc_fd_inode_operations = {
1478}; 1479};
1479 1480
1480static struct dentry *proc_pident_instantiate(struct inode *dir, 1481static struct dentry *proc_pident_instantiate(struct inode *dir,
1481 struct dentry *dentry, struct task_struct *task, void *ptr) 1482 struct dentry *dentry, struct task_struct *task, const void *ptr)
1482{ 1483{
1483 struct pid_entry *p = ptr; 1484 const struct pid_entry *p = ptr;
1484 struct inode *inode; 1485 struct inode *inode;
1485 struct proc_inode *ei; 1486 struct proc_inode *ei;
1486 struct dentry *error = ERR_PTR(-EINVAL); 1487 struct dentry *error = ERR_PTR(-EINVAL);
@@ -1509,13 +1510,13 @@ out:
1509 1510
1510static struct dentry *proc_pident_lookup(struct inode *dir, 1511static struct dentry *proc_pident_lookup(struct inode *dir,
1511 struct dentry *dentry, 1512 struct dentry *dentry,
1512 struct pid_entry *ents, 1513 const struct pid_entry *ents,
1513 unsigned int nents) 1514 unsigned int nents)
1514{ 1515{
1515 struct inode *inode; 1516 struct inode *inode;
1516 struct dentry *error; 1517 struct dentry *error;
1517 struct task_struct *task = get_proc_task(dir); 1518 struct task_struct *task = get_proc_task(dir);
1518 struct pid_entry *p, *last; 1519 const struct pid_entry *p, *last;
1519 1520
1520 error = ERR_PTR(-ENOENT); 1521 error = ERR_PTR(-ENOENT);
1521 inode = NULL; 1522 inode = NULL;
@@ -1544,8 +1545,8 @@ out_no_task:
1544 return error; 1545 return error;
1545} 1546}
1546 1547
1547static int proc_pident_fill_cache(struct file *filp, void *dirent, filldir_t filldir, 1548static int proc_pident_fill_cache(struct file *filp, void *dirent,
1548 struct task_struct *task, struct pid_entry *p) 1549 filldir_t filldir, struct task_struct *task, const struct pid_entry *p)
1549{ 1550{
1550 return proc_fill_cache(filp, dirent, filldir, p->name, p->len, 1551 return proc_fill_cache(filp, dirent, filldir, p->name, p->len,
1551 proc_pident_instantiate, task, p); 1552 proc_pident_instantiate, task, p);
@@ -1553,14 +1554,14 @@ static int proc_pident_fill_cache(struct file *filp, void *dirent, filldir_t fil
1553 1554
1554static int proc_pident_readdir(struct file *filp, 1555static int proc_pident_readdir(struct file *filp,
1555 void *dirent, filldir_t filldir, 1556 void *dirent, filldir_t filldir,
1556 struct pid_entry *ents, unsigned int nents) 1557 const struct pid_entry *ents, unsigned int nents)
1557{ 1558{
1558 int i; 1559 int i;
1559 int pid; 1560 int pid;
1560 struct dentry *dentry = filp->f_path.dentry; 1561 struct dentry *dentry = filp->f_path.dentry;
1561 struct inode *inode = dentry->d_inode; 1562 struct inode *inode = dentry->d_inode;
1562 struct task_struct *task = get_proc_task(inode); 1563 struct task_struct *task = get_proc_task(inode);
1563 struct pid_entry *p, *last; 1564 const struct pid_entry *p, *last;
1564 ino_t ino; 1565 ino_t ino;
1565 int ret; 1566 int ret;
1566 1567
@@ -1675,7 +1676,7 @@ static const struct file_operations proc_pid_attr_operations = {
1675 .write = proc_pid_attr_write, 1676 .write = proc_pid_attr_write,
1676}; 1677};
1677 1678
1678static struct pid_entry attr_dir_stuff[] = { 1679static const struct pid_entry attr_dir_stuff[] = {
1679 REG("current", S_IRUGO|S_IWUGO, pid_attr), 1680 REG("current", S_IRUGO|S_IWUGO, pid_attr),
1680 REG("prev", S_IRUGO, pid_attr), 1681 REG("prev", S_IRUGO, pid_attr),
1681 REG("exec", S_IRUGO|S_IWUGO, pid_attr), 1682 REG("exec", S_IRUGO|S_IWUGO, pid_attr),
@@ -1741,7 +1742,7 @@ static const struct inode_operations proc_self_inode_operations = {
1741 * that properly belong to the /proc filesystem, as they describe 1742 * that properly belong to the /proc filesystem, as they describe
1742 * describe something that is process related. 1743 * describe something that is process related.
1743 */ 1744 */
1744static struct pid_entry proc_base_stuff[] = { 1745static const struct pid_entry proc_base_stuff[] = {
1745 NOD("self", S_IFLNK|S_IRWXUGO, 1746 NOD("self", S_IFLNK|S_IRWXUGO,
1746 &proc_self_inode_operations, NULL, {}), 1747 &proc_self_inode_operations, NULL, {}),
1747}; 1748};
@@ -1770,9 +1771,9 @@ static struct dentry_operations proc_base_dentry_operations =
1770}; 1771};
1771 1772
1772static struct dentry *proc_base_instantiate(struct inode *dir, 1773static struct dentry *proc_base_instantiate(struct inode *dir,
1773 struct dentry *dentry, struct task_struct *task, void *ptr) 1774 struct dentry *dentry, struct task_struct *task, const void *ptr)
1774{ 1775{
1775 struct pid_entry *p = ptr; 1776 const struct pid_entry *p = ptr;
1776 struct inode *inode; 1777 struct inode *inode;
1777 struct proc_inode *ei; 1778 struct proc_inode *ei;
1778 struct dentry *error = ERR_PTR(-EINVAL); 1779 struct dentry *error = ERR_PTR(-EINVAL);
@@ -1820,7 +1821,7 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
1820{ 1821{
1821 struct dentry *error; 1822 struct dentry *error;
1822 struct task_struct *task = get_proc_task(dir); 1823 struct task_struct *task = get_proc_task(dir);
1823 struct pid_entry *p, *last; 1824 const struct pid_entry *p, *last;
1824 1825
1825 error = ERR_PTR(-ENOENT); 1826 error = ERR_PTR(-ENOENT);
1826 1827
@@ -1846,8 +1847,8 @@ out_no_task:
1846 return error; 1847 return error;
1847} 1848}
1848 1849
1849static int proc_base_fill_cache(struct file *filp, void *dirent, filldir_t filldir, 1850static int proc_base_fill_cache(struct file *filp, void *dirent,
1850 struct task_struct *task, struct pid_entry *p) 1851 filldir_t filldir, struct task_struct *task, const struct pid_entry *p)
1851{ 1852{
1852 return proc_fill_cache(filp, dirent, filldir, p->name, p->len, 1853 return proc_fill_cache(filp, dirent, filldir, p->name, p->len,
1853 proc_base_instantiate, task, p); 1854 proc_base_instantiate, task, p);
@@ -1884,7 +1885,7 @@ static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
1884static const struct file_operations proc_task_operations; 1885static const struct file_operations proc_task_operations;
1885static const struct inode_operations proc_task_inode_operations; 1886static const struct inode_operations proc_task_inode_operations;
1886 1887
1887static struct pid_entry tgid_base_stuff[] = { 1888static const struct pid_entry tgid_base_stuff[] = {
1888 DIR("task", S_IRUGO|S_IXUGO, task), 1889 DIR("task", S_IRUGO|S_IXUGO, task),
1889 DIR("fd", S_IRUSR|S_IXUSR, fd), 1890 DIR("fd", S_IRUSR|S_IXUSR, fd),
1890 INF("environ", S_IRUSR, pid_environ), 1891 INF("environ", S_IRUSR, pid_environ),
@@ -2027,7 +2028,7 @@ out:
2027 2028
2028static struct dentry *proc_pid_instantiate(struct inode *dir, 2029static struct dentry *proc_pid_instantiate(struct inode *dir,
2029 struct dentry * dentry, 2030 struct dentry * dentry,
2030 struct task_struct *task, void *ptr) 2031 struct task_struct *task, const void *ptr)
2031{ 2032{
2032 struct dentry *error = ERR_PTR(-ENOENT); 2033 struct dentry *error = ERR_PTR(-ENOENT);
2033 struct inode *inode; 2034 struct inode *inode;
@@ -2142,7 +2143,7 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
2142 goto out_no_task; 2143 goto out_no_task;
2143 2144
2144 for (; nr < ARRAY_SIZE(proc_base_stuff); filp->f_pos++, nr++) { 2145 for (; nr < ARRAY_SIZE(proc_base_stuff); filp->f_pos++, nr++) {
2145 struct pid_entry *p = &proc_base_stuff[nr]; 2146 const struct pid_entry *p = &proc_base_stuff[nr];
2146 if (proc_base_fill_cache(filp, dirent, filldir, reaper, p) < 0) 2147 if (proc_base_fill_cache(filp, dirent, filldir, reaper, p) < 0)
2147 goto out; 2148 goto out;
2148 } 2149 }
@@ -2168,7 +2169,7 @@ out_no_task:
2168/* 2169/*
2169 * Tasks 2170 * Tasks
2170 */ 2171 */
2171static struct pid_entry tid_base_stuff[] = { 2172static const struct pid_entry tid_base_stuff[] = {
2172 DIR("fd", S_IRUSR|S_IXUSR, fd), 2173 DIR("fd", S_IRUSR|S_IXUSR, fd),
2173 INF("environ", S_IRUSR, pid_environ), 2174 INF("environ", S_IRUSR, pid_environ),
2174 INF("auxv", S_IRUSR, pid_auxv), 2175 INF("auxv", S_IRUSR, pid_auxv),
@@ -2238,7 +2239,7 @@ static const struct inode_operations proc_tid_base_inode_operations = {
2238}; 2239};
2239 2240
2240static struct dentry *proc_task_instantiate(struct inode *dir, 2241static struct dentry *proc_task_instantiate(struct inode *dir,
2241 struct dentry *dentry, struct task_struct *task, void *ptr) 2242 struct dentry *dentry, struct task_struct *task, const void *ptr)
2242{ 2243{
2243 struct dentry *error = ERR_PTR(-ENOENT); 2244 struct dentry *error = ERR_PTR(-ENOENT);
2244 struct inode *inode; 2245 struct inode *inode;