public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: linux-ia64@vger.kernel.org
Subject: gcc builtin memcpy is bogus?
Date: Mon, 08 Dec 2003 16:01:24 +0000	[thread overview]
Message-ID: <marc-linux-ia64-107090003129207@msgid-missing> (raw)


This is a fun one ... I don't know what to blame for this.

struct rfd {
        u16 status;
        u16 command;
        u32 link;
        u32 rbd;
        u16 actual_size;
        u16 size;
};

static void e100_rx_rfa_add_tail(struct nic *nic, struct rx_list *curr)
{
        struct rfd *rfd = (struct rfd *)curr->skb->data;
        
        memcpy(rfd, &nic->blank_rfd, sizeof(struct rfd));
}

I'm using gcc (GCC) 3.3.2 (Debian) for this.

The kernel doesn't use -fno-builtin or -fno-builtin-memcpy so it attempts
to optimise this by doing 4-byte loads and stores.  Problem is, the
destination is misaligned (deliberately), so the kernel emits unaligned
messages.  Adding -fno-builtin to the command line turns this back into
a call to memcpy.

So how should this be fixed?

 - Improve gcc's builtin memcpy to work on non-aligned structs (unlikely)?
 - Somehow tag the pointer or the struct that it's unaligned?
 - Compile with -fno-builtin-memcpy (and probably a few others too)?

Other suggestions?

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

             reply	other threads:[~2003-12-08 16:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-08 16:01 Matthew Wilcox [this message]
2003-12-08 16:25 ` gcc builtin memcpy is bogus? Andreas Schwab
2003-12-08 17:29 ` David Mosberger
2003-12-08 20:27 ` Matthew Wilcox

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=marc-linux-ia64-107090003129207@msgid-missing \
    --to=willy@debian.org \
    --cc=linux-ia64@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