From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin LaHaise Subject: [PATCH] get_empty_filp tweaks, inline epoll_init_file() Date: Mon, 23 Jan 2006 21:28:20 -0800 Message-ID: <20060124052820.GA16694@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from fmr22.intel.com ([143.183.121.14]:50307 "EHLO scsfmr002.sc.intel.com") by vger.kernel.org with ESMTP id S932435AbWAXFhR (ORCPT ); Tue, 24 Jan 2006 00:37:17 -0500 To: akpm@osdl.org Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 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) {}