mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Andi Kleen <ak@suse.de>
Cc: discuss@x86-64.org, linux-kernel@vger.kernel.org, jh@suse.cz
Subject: Re: [discuss] [PATCH] x86-64: memset optimization
Date: Mon, 20 Aug 2007 08:52:53 -0700	[thread overview]
Message-ID: <20070820085253.5f589e58@freepuppy.rosehill.hemminger.net> (raw)
In-Reply-To: <200708192024.24864.ak@suse.de>

On Sun, 19 Aug 2007 20:24:24 +0200
Andi Kleen <ak@suse.de> wrote:

> 
> > I am looking at current source, built with current (non-experimental) GCC
> > from Fedora Core 7. If I dissassemble ether_setup, which is
> > 
> > void ether_setup(struct net_device *dev)
> > {
> > ...
> > 
> > 	memset(dev->broadcast, 0xFF, ETH_ALEN);
> > }
> > 
> > I see a tail recursion (jmp) to memset which is the code in arch/x86_64/lib/memset.S
> 
> That is likely gcc then deciding it can't use an inline memset for some reason.
> It does that for example if it can't figure out the alignment or similar.
> Honza (cc'ed) can probably give you more details why it happens, especially if you
> give him a preprocessed self contained test case.
> 
> A simple example like
> char x[6];
> 
> f()
> {
>         memset(x, 1, 6);
> }
> 
> gives with gcc 4.1:
> 
>         .text
>         .p2align 4,,15
> .globl f
>         .type   f, @function
> f:
> .LFB2:
>         movl    $16843009, x(%rip)
>         movw    $257, x+4(%rip)
>         ret
> .LFE2:
> 
> -Andi

The problem is with the optimization flags: passing -Os causes the compiler
to be stupid and not inline any memset/memcpy functions.


-- 
Stephen Hemminger <shemminger@linux-foundation.org>

  reply	other threads:[~2007-08-20 15:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17 23:34 Stephen Hemminger
2007-08-18  7:17 ` Eric Dumazet
2007-08-18  9:46 ` Andi Kleen
2007-08-18 14:56   ` Stephen Hemminger
2007-08-18 18:55     ` Andi Kleen
2007-08-19  5:04       ` Stephen Hemminger
2007-08-19 18:24         ` [discuss] " Andi Kleen
2007-08-20 15:52           ` Stephen Hemminger [this message]
2007-08-20 15:51             ` Arjan van de Ven
2007-08-20 17:03               ` Roland Dreier
2007-08-20 18:16                 ` Andi Kleen
2007-08-20 18:56                 ` Jan Hubicka
2007-08-21 10:16                   ` Denys Vlasenko

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=20070820085253.5f589e58@freepuppy.rosehill.hemminger.net \
    --to=shemminger@linux-foundation.org \
    --cc=ak@suse.de \
    --cc=discuss@x86-64.org \
    --cc=jh@suse.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®