public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	Glauber de Oliveira Costa <gcosta@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: Create clflush() inline, remove hardcoded wbinvd
Date: Sat, 21 Jul 2007 15:24:31 -0700	[thread overview]
Message-ID: <46A2879F.5050702@zytor.com> (raw)
In-Reply-To: <46A28425.2010202@zytor.com>

H. Peter Anvin wrote:
> Muli Ben-Yehuda wrote:
>> Ok, let's try again:
>>
>> You're changing this (pageattr.c)
>>
>>                 asm volatile("clflush (%0)" :: "r" (adr + i));
>>
>> into this:
>>
>> 		asm volatile("clflush %0" : "+m" (*(char __force*)(adr + i)));
>>
>> The original one calls clflush with (adr + i), the new one with (*(adr
>> + i)). Are these calls equivalent?
> 
> Yes, they are.  The parentheses which are part of the old assembly
> string has the same effect as the asterisk operator in C.
> 
> The difference between the two is that the latter form allows the C
> compiler to select the addressing mode, which allows the full range of
> addressing modes, whereas the former forces it to use a single register
> indirect.
> 

Just to be absolutely obvious about it:

: tazenda 15 ; cat demo.c
#define __force

static inline void clflush1(volatile void *__p)
{
        asm volatile("clflush %0" : "+m" (*(char __force *)__p));
}

static inline void clflush2(volatile void *__p)
{
        asm volatile("clflush (%0)" :: "r" (__p));
}

void demo(void *q)
{
        clflush1(q);
        clflush2(q);
}
: tazenda 16 ; gcc -m32 -O3 -S demo.c
: tazenda 17 ; cat demo.s
        .file   "demo.c"
        .text
        .p2align 4,,15
.globl demo
        .type   demo, @function
demo:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
#APP
        clflush (%eax)
        clflush (%eax)
#NO_APP
        popl    %ebp
        ret
        .size   demo, .-demo
        .ident  "GCC: (GNU) 4.1.2 20070626 (Red Hat 4.1.2-13)"
        .section        .note.GNU-stack,"",@progbits

  reply	other threads:[~2007-07-21 22:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-19 22:55 [PATCH] Use wbinvd() macro instead of raw inline assembly in .c files Glauber de Oliveira Costa
2007-07-20 11:43 ` Andi Kleen
2007-07-20 17:22   ` H. Peter Anvin
2007-07-21  7:32     ` Muli Ben-Yehuda
2007-07-20 21:19 ` [PATCH] x86: Create clflush() inline, remove hardcoded wbinvd H. Peter Anvin
2007-07-20 21:27   ` Andi Kleen
2007-07-20 21:33     ` H. Peter Anvin
2007-07-22  9:18       ` Andi Kleen
2007-07-22 18:05         ` H. Peter Anvin
2007-07-22 19:55           ` Andi Kleen
2007-07-22 20:02             ` H. Peter Anvin
2007-07-20 23:37   ` Glauber de Oliveira Costa
2007-07-20 23:43     ` H. Peter Anvin
2007-07-21 18:11   ` Muli Ben-Yehuda
2007-07-21 19:52     ` H. Peter Anvin
2007-07-21 20:16       ` Muli Ben-Yehuda
2007-07-21 20:18         ` H. Peter Anvin
2007-07-21 20:44           ` Muli Ben-Yehuda
2007-07-21 22:09             ` H. Peter Anvin
2007-07-21 22:24               ` H. Peter Anvin [this message]
2007-07-22  4:20               ` Muli Ben-Yehuda

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=46A2879F.5050702@zytor.com \
    --to=hpa@zytor.com \
    --cc=andi@firstfloor.org \
    --cc=gcosta@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muli@il.ibm.com \
    /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