Re: [PATCH] introduce setup_timer() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Morton wrote:
> 
> Oleg Nesterov <[email protected]> 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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux