[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.0.999.0707241236020.3607@woody.linux-foundation.org>
Date: Tue, 24 Jul 2007 12:39:32 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Trent Piepho <xyzzy@...akeasy.org>
cc: Nick Piggin <nickpiggin@...oo.com.au>,
Satyam Sharma <ssatyam@....iitk.ac.in>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
David Howells <dhowells@...hat.com>, Andi Kleen <ak@...e.de>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobbered
unnecessarily
On Tue, 24 Jul 2007, Trent Piepho wrote:
>
> Speaking of that, why are all the asm functions in arch/i386/lib/string.c
> defined as having a memory clobber, even those which don't modify memory
> like strcmp, strchr, strlen and so on?
That's because the memory clobber will serialize the inline asm with
anything else that reads or writes memory.
So even if we don't actually change any memory, if we cannot describe what
we *read*, then we need to tell gcc to not re-order us wrt things that
could *write*. And the simplest way to do that is to say that you clobber
memory, even if you don't.
So as a more concrete example: imagine that we're doing a "strlen()" on
some local variable. We need to tell gcc that that variable has to be
updated in memory before it schedules the asm. The memory clobber does
that.
(Yes, the "asm volatile" may do so too, but it's very unclear what the
"volatile" on the asm actually does, so ..)
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists