All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
	davem@davemloft.net
Subject: Re: [3/10 PATCH] inline wake_up_bit
Date: Wed, 25 Jun 2008 14:36:13 +0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0806251031330.7542@engineering.redhat.com> (raw)
In-Reply-To: <200806251617.40871.vda.linux@googlemail.com>

On Wed, 25 Jun 2008, Denys Vlasenko wrote:

> On Tuesday 24 June 2008 07:57, Mikulas Patocka wrote:
>> Inline wake_up_bit. The function just pases arguments around.
>>
>> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
>>
>>   int __wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned);
>> -void wake_up_bit(void *, int);
>>   int out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned);
>
>> +static __always_inline void wake_up_bit(void *word, int bit)
>> +{
>> +	__wake_up_bit(bit_waitqueue(word, bit), word, bit);
>> +}
>
> So now every call to wake_up_bit(word, bit) now is converted to:
>
> __wake_up_bit(bit_waitqueue(word, bit), word, bit);
>
> which is in turn converted to (looking into your next patch):
>
> {
>       wait_queue_head_t *wq = bit_waitqueue(word, bit);
>       struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
>       if (waitqueue_active(wq))
>               __wake_up(wq, TASK_NORMAL, 1, &key);
> }
>
> which is in turn converted to (looking into your other patch):
>
> {
>       wait_queue_head_t *wq = bit_waitqueue(word, bit);
>       struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
>       if (waitqueue_active(wq))
>               {
>                      unsigned long flags;
>                      spin_lock_irqsave(&qw->lock, flags);
>                      __wake_up_common(wq, TASK_NORMAL, 1, 0, &key);
>                      spin_unlock_irqrestore(&wq->lock, flags);
>               }
> }
>
> And you know what? This is likely not the end yet! It's possible
> spin_lock_irqXXX, __wake_up_common, waitqueue_active or bit_waitqueue
> are inlines - I didn't check.
> --
> vda

Yes, that's 0.2% code size increase (or none increase, if drop 
inline-__wake_up_bit.patch and apply only the other patches). To me it 
seems crazy, how this code was refactored again and again over time, up to 
8 levels of functions (including passing a pointer to a method). In 2.0.x 
kernel series, it was just a single call to wake up a queue.

Mikulas

WARNING: multiple messages have this Message-ID (diff)
From: Mikulas Patocka <mpatocka@redhat.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
	davem@davemloft.net
Subject: Re: [3/10 PATCH] inline wake_up_bit
Date: Wed, 25 Jun 2008 10:36:13 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0806251031330.7542@engineering.redhat.com> (raw)
In-Reply-To: <200806251617.40871.vda.linux@googlemail.com>

On Wed, 25 Jun 2008, Denys Vlasenko wrote:

> On Tuesday 24 June 2008 07:57, Mikulas Patocka wrote:
>> Inline wake_up_bit. The function just pases arguments around.
>>
>> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
>>
>>   int __wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, int (*)(void *), unsigned);
>> -void wake_up_bit(void *, int);
>>   int out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned);
>
>> +static __always_inline void wake_up_bit(void *word, int bit)
>> +{
>> +	__wake_up_bit(bit_waitqueue(word, bit), word, bit);
>> +}
>
> So now every call to wake_up_bit(word, bit) now is converted to:
>
> __wake_up_bit(bit_waitqueue(word, bit), word, bit);
>
> which is in turn converted to (looking into your next patch):
>
> {
>       wait_queue_head_t *wq = bit_waitqueue(word, bit);
>       struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
>       if (waitqueue_active(wq))
>               __wake_up(wq, TASK_NORMAL, 1, &key);
> }
>
> which is in turn converted to (looking into your other patch):
>
> {
>       wait_queue_head_t *wq = bit_waitqueue(word, bit);
>       struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
>       if (waitqueue_active(wq))
>               {
>                      unsigned long flags;
>                      spin_lock_irqsave(&qw->lock, flags);
>                      __wake_up_common(wq, TASK_NORMAL, 1, 0, &key);
>                      spin_unlock_irqrestore(&wq->lock, flags);
>               }
> }
>
> And you know what? This is likely not the end yet! It's possible
> spin_lock_irqXXX, __wake_up_common, waitqueue_active or bit_waitqueue
> are inlines - I didn't check.
> --
> vda

Yes, that's 0.2% code size increase (or none increase, if drop 
inline-__wake_up_bit.patch and apply only the other patches). To me it 
seems crazy, how this code was refactored again and again over time, up to 
8 levels of functions (including passing a pointer to a method). In 2.0.x 
kernel series, it was just a single call to wake up a queue.

Mikulas

  reply	other threads:[~2008-06-25 14:36 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24  5:54 [10 PATCHES] inline functions to avoid stack overflow Mikulas Patocka
2008-06-24  5:54 ` Mikulas Patocka
2008-06-24  5:55 ` [1/10 PATCH] inline __queue_work Mikulas Patocka
2008-06-24  5:55   ` Mikulas Patocka
2008-06-24  5:56   ` [2/10 PATCH] inline inline-generic_writepages.patch Mikulas Patocka
2008-06-24  5:56     ` Mikulas Patocka
2008-06-24  5:57   ` [3/10 PATCH] inline wake_up_bit Mikulas Patocka
2008-06-24  5:57     ` Mikulas Patocka
2008-06-25 14:17     ` Denys Vlasenko
2008-06-25 14:17       ` Denys Vlasenko
2008-06-25 14:36       ` Mikulas Patocka [this message]
2008-06-25 14:36         ` Mikulas Patocka
2008-06-25 15:24         ` Denys Vlasenko
2008-06-25 15:24           ` Denys Vlasenko
2008-06-25 16:01           ` Mikulas Patocka
2008-06-25 16:01             ` Mikulas Patocka
2008-06-25 20:37             ` Denys Vlasenko
2008-06-25 20:37               ` Denys Vlasenko
2008-06-26  0:28               ` David Miller
2008-06-26  0:28                 ` David Miller
2008-06-26  3:35                 ` Denys Vlasenko
2008-06-26  3:35                   ` Denys Vlasenko
2008-06-26  4:18                   ` David Miller
2008-06-26  4:18                     ` David Miller
2008-06-26 18:22                 ` Pavel Machek
2008-06-26 18:22                   ` Pavel Machek
2008-06-25 22:23           ` David Miller
2008-06-25 22:23             ` David Miller
2008-06-25 22:30       ` David Miller
2008-06-25 22:30         ` David Miller
2008-06-24  5:57   ` [4/10 PATCH] inline __wake_up_bit Mikulas Patocka
2008-06-24  5:57     ` Mikulas Patocka
2008-06-24  5:58   ` [5/10 PATCH] inline __wake_up Mikulas Patocka
2008-06-24  5:58     ` Mikulas Patocka
2008-06-24  5:59   ` [6/10 PATCH] inline default_wake_function Mikulas Patocka
2008-06-24  5:59     ` Mikulas Patocka
2008-06-24  5:59   ` [6/10 PATCH] inline autoremove_wake_function Mikulas Patocka
2008-06-24  5:59     ` Mikulas Patocka
2008-06-24  6:01   ` [8/10 PATCH] inline filemap_fdatawrite Mikulas Patocka
2008-06-24  6:01     ` Mikulas Patocka
2008-06-24  6:01   ` [9/10 PATCH] inline dm-kcopyd-inline-wake.patch Mikulas Patocka
2008-06-24  6:01     ` Mikulas Patocka
2008-06-24  6:03   ` [10/10 PATCH] inline dispatch_job Mikulas Patocka
2008-06-24  6:03     ` Mikulas Patocka
2008-06-24  6:06 ` [PATCH] limit irq nesting Mikulas Patocka
2008-06-24  6:06   ` Mikulas Patocka
2008-06-24  7:01 ` [10 PATCHES] inline functions to avoid stack overflow Ingo Molnar
2008-06-24  7:01   ` Ingo Molnar
     [not found] ` <486216E7.8000002@aitel.hist.no>
2008-06-25 12:53   ` Mikulas Patocka
2008-06-25 12:53     ` Mikulas Patocka
2008-06-25 22:09     ` David Miller
2008-06-25 22:09       ` David Miller
2008-06-26  6:32       ` Bart Van Assche
2008-06-26  6:32         ` Bart Van Assche
2008-06-26  9:06         ` David Miller
2008-06-26  9:06           ` David Miller
2008-07-02  4:39       ` Mikulas Patocka
2008-07-02  4:39         ` Mikulas Patocka
2008-07-02  4:45         ` David Miller
2008-07-02  4:45           ` David Miller
2008-07-03 21:12           ` Mikulas Patocka
2008-07-03 21:12             ` Mikulas Patocka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0806251031330.7542@engineering.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=vda.linux@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.