mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dave Korn" <dave.korn@artimi.com>
To: "'Denis Vlasenko'" <vda@port.imtp.ilyichevsk.odessa.ua>,
	"'Christophe Saout'" <christophe@saout.de>
Cc: "'Andrew Morton'" <akpm@osdl.org>,
	"'Jan Hubicka'" <hubicka@ucw.cz>,
	"'Gerold Jury'" <gerold.ml@inode.at>, <jakub@redhat.com>,
	"'Linux Kernel Mailing List'" <linux-kernel@vger.kernel.org>,
	<gcc@gcc.gnu.org>
Subject: RE: [BUG mm] "fixed" i386 memcpy inlining buggy
Date: Wed, 6 Apr 2005 12:05:56 +0100	[thread overview]
Message-ID: <SERRANOI8jsnNSe8xFY00000079@SERRANO.CAM.ARTIMI.COM> (raw)
In-Reply-To: <200504061314.27740.vda@port.imtp.ilyichevsk.odessa.ua>

----Original Message----
>From: Denis Vlasenko
>Sent: 06 April 2005 11:14

  Is this someone's idea of an April Fool's joke?  Because if it is, I've
suffered a serious sense-of-humour failure.

> Oh shit. I was trying to be too clever. I still run with this patch,
> so it must be happening very rarely.

  The kernel is way too important for cross-your-fingers-and-hope
engineering techniques to be applied.  This patch should never have been
permitted.  How on earth could anything like this hope to make it through a
strict review?

> Does this one compile ok?

> 	{
> 		/* load esi/edi */
> 		__asm__ __volatile__(
> 			""
> 			: "=&D" (edi), "=&S" (esi)
> 			: "0" ((long) to),"1" ((long) from)
> 			: "memory"
> 		);
> 	}
> 	if (n >= 5*4) {
> 		/* large block: use rep prefix */
> 		int ecx;
> 		__asm__ __volatile__(
> 			"rep ; movsl"
> 			: "=&c" (ecx), "=&D" (edi), "=&S" (esi)
> 			: "0" (n/4), "1" (edi),"2" (esi)
> 			: "memory"
> 		);


  It doesn't matter if it compiles or not, it's still *utterly* invalid.
You can NOT make assumptions about registers keeping their values between
one asm block and another.  Immediately after the closing quote of the first
asm, the compiler can do ANYTHING IT WANTS and to just _hope_ that it won't
use the registers you want is voodoo programming.  Even if it works when you
try it once, there are zero guarantees that another version or revision of
the compiler or even just a tiny change to the source that affects the
behaviour of the scheduler when compiling the function won't produce
something completely different, meaning that this code is appallingly
fragile.  This code should be completely discarded and rewritten properly.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


  reply	other threads:[~2005-04-06 11:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-29 14:37 memcpy(a,b,CONST) is not inlined by gcc 3.4.1 in Linux kernel Denis Vlasenko
2005-03-29 15:06 ` Richard Guenther
2005-03-29 15:08 ` Nathan Sidwell
2005-03-29 15:13 ` Jakub Jelinek
2005-03-29 15:42   ` Andrew Pinski
2005-03-30  2:27     ` Gerold Jury
2005-03-30  6:15       ` Denis Vlasenko
2005-04-01 21:43         ` Jan Hubicka
2005-04-02 12:18           ` Denis Vlasenko
2005-04-02 12:26             ` Denis Vlasenko
2005-04-05 16:34               ` [BUG mm] "fixed" i386 memcpy inlining buggy Christophe Saout
2005-04-06 10:14                 ` Denis Vlasenko
2005-04-06 11:05                   ` Dave Korn [this message]
2005-04-06 11:13                     ` Dave Korn
2005-04-06 11:53                       ` Dave Korn
2005-04-06 11:56                         ` Dave Korn
2005-04-06 13:18                         ` Richard B. Johnson
2005-04-06 14:16                           ` Denis Vlasenko
2005-04-06 12:05                   ` Christophe Saout
2005-04-06 12:36                     ` Andrew Haley
2005-04-06 15:18                     ` Paolo Bonzini
2005-04-06 16:11                 ` Denis Vlasenko
2005-03-29 20:22 ` [PATCH] fix i386 memcpy Denis Vlasenko
2005-03-29 20:24   ` Denis 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=SERRANOI8jsnNSe8xFY00000079@SERRANO.CAM.ARTIMI.COM \
    --to=dave.korn@artimi.com \
    --cc=akpm@osdl.org \
    --cc=christophe@saout.de \
    --cc=gcc@gcc.gnu.org \
    --cc=gerold.ml@inode.at \
    --cc=hubicka@ucw.cz \
    --cc=jakub@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vda@port.imtp.ilyichevsk.odessa.ua \
    /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®