* [PATCH] get_empty_filp tweaks, inline epoll_init_file()
@ 2006-01-24 5:28 Benjamin LaHaise
2006-01-24 5:44 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin LaHaise @ 2006-01-24 5:28 UTC (permalink / raw)
To: akpm; +Cc: linux-fsdevel
This patch eliminates a handful of cache references by keeping current
in a register instead of reloading (helps x86) and avoiding the overhead
of a function call. Inlining eventpoll_init_file() saves 24 bytes. Also
reorder file initialization to make writes occur more sequentially.
Signed-off-by: Benjamin LaHaise <bcrl@linux.intel.com>
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 4284cd3..e536e79 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -451,15 +451,6 @@ static void ep_poll_safewake(struct poll
}
-/* Used to initialize the epoll bits inside the "struct file" */
-void eventpoll_init_file(struct file *file)
-{
-
- INIT_LIST_HEAD(&file->f_ep_links);
- spin_lock_init(&file->f_ep_lock);
-}
-
-
/*
* This is called from eventpoll_release() to unlink files from the eventpoll
* interface. We need to have this facility to cleanup correctly files that are
diff --git a/fs/file_table.c b/fs/file_table.c
index 768b581..67c4106 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -72,6 +72,7 @@ static inline void file_free(struct file
*/
struct file *get_empty_filp(void)
{
+ struct task_struct *tsk;
static int old_max;
struct file * f;
@@ -90,13 +91,14 @@ struct file *get_empty_filp(void)
if (security_file_alloc(f))
goto fail_sec;
- eventpoll_init_file(f);
+ tsk = current;
+ INIT_LIST_HEAD(&f->f_u.fu_list);
atomic_set(&f->f_count, 1);
- f->f_uid = current->fsuid;
- f->f_gid = current->fsgid;
rwlock_init(&f->f_owner.lock);
+ f->f_uid = tsk->fsuid;
+ f->f_gid = tsk->fsgid;
+ eventpoll_init_file(f);
/* f->f_version: 0 */
- INIT_LIST_HEAD(&f->f_u.fu_list);
return f;
over:
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index 1289f0e..1e4bdfc 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -52,7 +52,12 @@ struct file;
#ifdef CONFIG_EPOLL
/* Used to initialize the epoll bits inside the "struct file" */
-void eventpoll_init_file(struct file *file);
+static inline void eventpoll_init_file(struct file *file)
+{
+ INIT_LIST_HEAD(&file->f_ep_links);
+ spin_lock_init(&file->f_ep_lock);
+}
+
/* Used to release the epoll bits inside the "struct file" */
void eventpoll_release_file(struct file *file);
@@ -85,7 +90,6 @@ static inline void eventpoll_release(str
eventpoll_release_file(file);
}
-
#else
static inline void eventpoll_init_file(struct file *file) {}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] get_empty_filp tweaks, inline epoll_init_file()
2006-01-24 5:28 [PATCH] get_empty_filp tweaks, inline epoll_init_file() Benjamin LaHaise
@ 2006-01-24 5:44 ` Andrew Morton
2006-01-24 5:49 ` Benjamin LaHaise
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-01-24 5:44 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: linux-fsdevel
Benjamin LaHaise <bcrl@linux.intel.com> wrote:
>
> This patch eliminates a handful of cache references by keeping current
> in a register instead of reloading (helps x86)
Are you sure it helps? I was checking that the other day and found that the
compiler caches current quite competently.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] get_empty_filp tweaks, inline epoll_init_file()
2006-01-24 5:44 ` Andrew Morton
@ 2006-01-24 5:49 ` Benjamin LaHaise
0 siblings, 0 replies; 3+ messages in thread
From: Benjamin LaHaise @ 2006-01-24 5:49 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-fsdevel
On Mon, Jan 23, 2006 at 09:44:51PM -0800, Andrew Morton wrote:
> Benjamin LaHaise <bcrl@linux.intel.com> wrote:
> >
> > This patch eliminates a handful of cache references by keeping current
> > in a register instead of reloading (helps x86)
>
> Are you sure it helps? I was checking that the other day and found that the
> compiler caches current quite competently.
I was looking at the code on x86-64 where it reloads from %gs:0, but x86
reloads current too.
0xc015599b <get_empty_filp+105>: mov $0xfffff000,%eax
0xc01559a0 <get_empty_filp+110>: and %esp,%eax
- eax is current_thread_info()
0xc01559a2 <get_empty_filp+112>: mov (%eax),%edx
- dereference to get current
0xc01559a4 <get_empty_filp+114>: mov 0x174(%edx),%edx
- load current->fsuid
0xc01559aa <get_empty_filp+120>: mov %edx,0x48(%esi)
- store in file->f_uid
0xc01559ad <get_empty_filp+123>: mov (%eax),%eax
- reload current
0xc01559af <get_empty_filp+125>: mov 0x184(%eax),%eax
- load current->fsgid
0xc01559b5 <get_empty_filp+131>: mov %eax,0x4c(%esi)
- store in file->f_gid
-ben
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-24 5:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-24 5:28 [PATCH] get_empty_filp tweaks, inline epoll_init_file() Benjamin LaHaise
2006-01-24 5:44 ` Andrew Morton
2006-01-24 5:49 ` Benjamin LaHaise
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).