All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: arjanv@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] introduce setup_timer() helper
Date: Mon, 19 Sep 2005 19:11:59 +0400	[thread overview]
Message-ID: <432ED53F.EE8DEC5E@tv-sign.ru> (raw)
In-Reply-To: 20050918130613.5bbe9344.akpm@osdl.org

Andrew Morton wrote:
> 
> Oleg Nesterov <oleg@tv-sign.ru> wrote:
> >
> > I think this can save a couple of cpu cycles. The init_timer()
> >  is not inline, gcc can't reorder exprx() and init_timer() calls.
> >
> >  Ok, I do not want to persist very much, I can resend this patch.
> >
> >  Andrew, should I?
> 
> Try both, see which one generates the shorter code?

The code:

	void *expr(void);

	void tst(struct timer_list *timer)
	{
		setup_timer(timer, expr(), 0);
	}

Asm output:

     1  tst:
     2          pushl   %ebp
     3          movl    %esp, %ebp
     4          pushl   %ebx
     5          movl    8(%ebp), %ebx
     6          call    expr
     7          movl    %eax, 16(%ebx)
     8          movl    %ebx, %eax
     9          movl    $0, 20(%ebx)
    10          call    init_timer
    11          popl    %ebx
    12          popl    %ebp
    13          ret

After the Arjan proposed change:

     1  tst:
     2          pushl   %ebp
     3          movl    %esp, %ebp
     4          subl    $8, %esp
     5          movl    %ebx, (%esp)
     6          movl    8(%ebp), %ebx
     7          movl    %esi, 4(%esp)
     8          call    expr
     9          movl    %eax, %esi
    10          movl    %ebx, %eax
    11          call    init_timer
    12          movl    %esi, 16(%ebx)
    13          movl    $0, 20(%ebx)
    14          movl    (%esp), %ebx
    15          movl    4(%esp), %esi
    16          movl    %ebp, %esp
    17          popl    %ebp
    18          ret

I don't think we'll see any difference in practice, but still...

Oleg.

      reply	other threads:[~2005-09-19 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-18 13:51 [PATCH] introduce setup_timer() helper Oleg Nesterov
2005-09-18 15:12 ` Arjan van de Ven
2005-09-18 15:51   ` Oleg Nesterov
2005-09-18 15:43     ` Arjan van de Ven
2005-09-18 16:22       ` Oleg Nesterov
2005-09-18 20:06         ` Andrew Morton
2005-09-19 15:11           ` Oleg Nesterov [this message]

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=432ED53F.EE8DEC5E@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=arjanv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.