Commit 9659cc89 authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] reduce number of parameters to __wait_on_bit() and __wait_on_bit_lock()

Some of the parameters to __wait_on_bit() and __wait_on_bit_lock() are
redundant, as the wait_bit_queue parameter holds the flags word and the bit
number.  This patch updates __wait_on_bit() and __wait_on_bit_lock() to
fetch that information from the wait_bit_queue passed to them and so reduce
the number of parameters so that -mregparm may be more effective.

Incremental atop the complete out-of-lining of the contention cases and the
fastcall and wait_on_bit_lock()/test_and_set_bit() fixes.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bc341c61
...@@ -261,8 +261,8 @@ __writeback_single_inode(struct inode *inode, ...@@ -261,8 +261,8 @@ __writeback_single_inode(struct inode *inode,
do { do {
__iget(inode); __iget(inode);
spin_unlock(&inode_lock); spin_unlock(&inode_lock);
__wait_on_bit(wqh, &wq, &inode->i_state, __I_LOCK, __wait_on_bit(wqh, &wq, inode_wait,
inode_wait, TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
iput(inode); iput(inode);
spin_lock(&inode_lock); spin_lock(&inode_lock);
} while (inode->i_state & I_LOCK); } while (inode->i_state & I_LOCK);
......
...@@ -140,8 +140,8 @@ void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *k ...@@ -140,8 +140,8 @@ void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *k
extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode)); extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr)); extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
void FASTCALL(__wake_up_bit(wait_queue_head_t *, void *, int)); void FASTCALL(__wake_up_bit(wait_queue_head_t *, void *, int));
int FASTCALL(__wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, void *, int, int (*)(void *), unsigned)); int FASTCALL(__wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned));
int FASTCALL(__wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, void *, int, int (*)(void *), unsigned)); int FASTCALL(__wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned));
void FASTCALL(wake_up_bit(void *, int)); void FASTCALL(wake_up_bit(void *, int));
int FASTCALL(out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned)); int FASTCALL(out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned));
int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned)); int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned));
......
...@@ -152,13 +152,15 @@ EXPORT_SYMBOL(wake_bit_function); ...@@ -152,13 +152,15 @@ EXPORT_SYMBOL(wake_bit_function);
*/ */
int __sched fastcall int __sched fastcall
__wait_on_bit(wait_queue_head_t *wq, struct wait_bit_queue *q, __wait_on_bit(wait_queue_head_t *wq, struct wait_bit_queue *q,
void *word, int bit, int (*action)(void *), unsigned mode) int (*action)(void *), unsigned mode)
{ {
int ret = 0; int ret = 0;
do {
prepare_to_wait(wq, &q->wait, mode); prepare_to_wait(wq, &q->wait, mode);
if (test_bit(bit, word)) if (test_bit(q->key.bit_nr, q->key.flags))
ret = (*action)(word); ret = (*action)(q->key.flags);
} while (test_bit(q->key.bit_nr, q->key.flags) && !ret);
finish_wait(wq, &q->wait); finish_wait(wq, &q->wait);
return ret; return ret;
} }
...@@ -170,23 +172,23 @@ int __sched fastcall out_of_line_wait_on_bit(void *word, int bit, ...@@ -170,23 +172,23 @@ int __sched fastcall out_of_line_wait_on_bit(void *word, int bit,
wait_queue_head_t *wq = bit_waitqueue(word, bit); wait_queue_head_t *wq = bit_waitqueue(word, bit);
DEFINE_WAIT_BIT(wait, word, bit); DEFINE_WAIT_BIT(wait, word, bit);
return __wait_on_bit(wq, &wait, word, bit, action, mode); return __wait_on_bit(wq, &wait, action, mode);
} }
EXPORT_SYMBOL(out_of_line_wait_on_bit); EXPORT_SYMBOL(out_of_line_wait_on_bit);
int __sched fastcall int __sched fastcall
__wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q, __wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
void *word, int bit, int (*action)(void *), unsigned mode) int (*action)(void *), unsigned mode)
{ {
int ret = 0; int ret = 0;
do { do {
prepare_to_wait_exclusive(wq, &q->wait, mode); prepare_to_wait_exclusive(wq, &q->wait, mode);
if (test_bit(bit, word)) { if (test_bit(q->key.bit_nr, q->key.flags)) {
if ((ret = (*action)(word))) if ((ret = (*action)(q->key.flags)))
break; break;
} }
} while (test_and_set_bit(bit, word)); } while (test_and_set_bit(q->key.bit_nr, q->key.flags));
finish_wait(wq, &q->wait); finish_wait(wq, &q->wait);
return ret; return ret;
} }
...@@ -198,7 +200,7 @@ int __sched fastcall out_of_line_wait_on_bit_lock(void *word, int bit, ...@@ -198,7 +200,7 @@ int __sched fastcall out_of_line_wait_on_bit_lock(void *word, int bit,
wait_queue_head_t *wq = bit_waitqueue(word, bit); wait_queue_head_t *wq = bit_waitqueue(word, bit);
DEFINE_WAIT_BIT(wait, word, bit); DEFINE_WAIT_BIT(wait, word, bit);
return __wait_on_bit_lock(wq, &wait, word, bit, action, mode); return __wait_on_bit_lock(wq, &wait, action, mode);
} }
EXPORT_SYMBOL(out_of_line_wait_on_bit_lock); EXPORT_SYMBOL(out_of_line_wait_on_bit_lock);
......
...@@ -381,8 +381,8 @@ void fastcall wait_on_page_bit(struct page *page, int bit_nr) ...@@ -381,8 +381,8 @@ void fastcall wait_on_page_bit(struct page *page, int bit_nr)
DEFINE_WAIT_BIT(wait, &page->flags, bit_nr); DEFINE_WAIT_BIT(wait, &page->flags, bit_nr);
if (test_bit(bit_nr, &page->flags)) if (test_bit(bit_nr, &page->flags))
__wait_on_bit(page_waitqueue(page), &wait, wait.key.flags, __wait_on_bit(page_waitqueue(page), &wait, sync_page,
bit_nr, sync_page, TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
} }
EXPORT_SYMBOL(wait_on_page_bit); EXPORT_SYMBOL(wait_on_page_bit);
...@@ -440,8 +440,8 @@ void fastcall __lock_page(struct page *page) ...@@ -440,8 +440,8 @@ void fastcall __lock_page(struct page *page)
{ {
DEFINE_WAIT_BIT(wait, &page->flags, PG_locked); DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
__wait_on_bit_lock(page_waitqueue(page), &wait, wait.key.flags, __wait_on_bit_lock(page_waitqueue(page), &wait, sync_page,
PG_locked, sync_page, TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
} }
EXPORT_SYMBOL(__lock_page); EXPORT_SYMBOL(__lock_page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment