mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: hpa@zytor.com, andi@firstfloor.org, gcosta@redhat.com,
	patches@x86-64.org, linux-kernel@vger.kernel.org
Subject: [PATCH] [14/45] x86: Create clflush() inline, remove hardcoded wbinvd
Date: Fri, 21 Sep 2007 22:44:55 +0200 (CEST)	[thread overview]
Message-ID: <20070921204455.C68D714EFF@wotan.suse.de> (raw)
In-Reply-To: <200709211044.901175000@suse.de>


From: "H. Peter Anvin" <hpa@zytor.com>
Create an inline function for clflush(), with the proper arguments,
and use it instead of hard-coding the instruction.

This also removes one instance of hard-coded wbinvd, based on a patch
by Bauder de Oliveira Costa.

Cc: Andi Kleen <andi@firstfloor.org>
Cc: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/i386/mm/pageattr.c         |    4 ++--
 arch/x86_64/kernel/tce.c        |    4 ++--
 arch/x86_64/mm/pageattr.c       |    2 +-
 drivers/char/agp/efficeon-agp.c |   11 ++++++-----
 include/asm-i386/system.h       |    4 ++++
 include/asm-x86_64/system.h     |    5 +++++
 6 files changed, 20 insertions(+), 10 deletions(-)

Index: linux/arch/i386/mm/pageattr.c
===================================================================
--- linux.orig/arch/i386/mm/pageattr.c
+++ linux/arch/i386/mm/pageattr.c
@@ -70,10 +70,10 @@ static struct page *split_large_page(uns
 
 static void cache_flush_page(struct page *p)
 { 
-	unsigned long adr = (unsigned long)page_address(p);
+	void *adr = page_address(p);
 	int i;
 	for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
-		asm volatile("clflush (%0)" :: "r" (adr + i));
+		clflush(adr+i);
 }
 
 static void flush_kernel_map(void *arg)
Index: linux/arch/x86_64/kernel/tce.c
===================================================================
--- linux.orig/arch/x86_64/kernel/tce.c
+++ linux/arch/x86_64/kernel/tce.c
@@ -40,9 +40,9 @@ static inline void flush_tce(void* tcead
 {
 	/* a single tce can't cross a cache line */
 	if (cpu_has_clflush)
-		asm volatile("clflush (%0)" :: "r" (tceaddr));
+		clflush(tceaddr);
 	else
-		asm volatile("wbinvd":::"memory");
+		wbinvd();
 }
 
 void tce_build(struct iommu_table *tbl, unsigned long index,
Index: linux/arch/x86_64/mm/pageattr.c
===================================================================
--- linux.orig/arch/x86_64/mm/pageattr.c
+++ linux/arch/x86_64/mm/pageattr.c
@@ -65,7 +65,7 @@ static void cache_flush_page(void *adr)
 {
 	int i;
 	for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
-		asm volatile("clflush (%0)" :: "r" (adr + i));
+		clflush(adr+i);
 }
 
 static void flush_kernel_map(void *arg)
Index: linux/drivers/char/agp/efficeon-agp.c
===================================================================
--- linux.orig/drivers/char/agp/efficeon-agp.c
+++ linux/drivers/char/agp/efficeon-agp.c
@@ -221,7 +221,7 @@ static int efficeon_create_gatt_table(st
 		SetPageReserved(virt_to_page((char *)page));
 
 		for (offset = 0; offset < PAGE_SIZE; offset += clflush_chunk)
-			asm volatile("clflush %0" : : "m" (*(char *)(page+offset)));
+			clflush((char *)page+offset);
 
 		efficeon_private.l1_table[index] = page;
 
@@ -268,15 +268,16 @@ static int efficeon_insert_memory(struct
 		*page = insert;
 
 		/* clflush is slow, so don't clflush until we have to */
-		if ( last_page &&
-		     ((unsigned long)page^(unsigned long)last_page) & clflush_mask )
-		    asm volatile("clflush %0" : : "m" (*last_page));
+		if (last_page &&
+		    (((unsigned long)page^(unsigned long)last_page) &
+		     clflush_mask))
+			clflush(last_page);
 
 		last_page = page;
 	}
 
 	if ( last_page )
-		asm volatile("clflush %0" : : "m" (*last_page));
+		clflush(last_page);
 
 	agp_bridge->driver->tlb_flush(mem);
 	return 0;
Index: linux/include/asm-i386/system.h
===================================================================
--- linux.orig/include/asm-i386/system.h
+++ linux/include/asm-i386/system.h
@@ -160,6 +160,10 @@ static inline void native_wbinvd(void)
 	asm volatile("wbinvd": : :"memory");
 }
 
+static inline void clflush(volatile void *__p)
+{
+	asm volatile("clflush %0" : "+m" (*(char __force *)__p));
+}
 
 #ifdef CONFIG_PARAVIRT
 #include <asm/paravirt.h>
Index: linux/include/asm-x86_64/system.h
===================================================================
--- linux.orig/include/asm-x86_64/system.h
+++ linux/include/asm-x86_64/system.h
@@ -137,6 +137,11 @@ static inline void write_cr8(unsigned lo
 
 #endif	/* __KERNEL__ */
 
+static inline void clflush(volatile void *__p)
+{
+	asm volatile("clflush %0" : "+m" (*(char __force *)__p));
+}
+
 #define nop() __asm__ __volatile__ ("nop")
 
 #ifdef CONFIG_SMP

  parent reply	other threads:[~2007-09-21 20:49 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21 20:44 [PATCH] [0/45] x86 2.6.24 patches review I Andi Kleen
2007-09-21 20:44 ` [PATCH] [1/45] x86: misc. constifications Andi Kleen
2007-09-21 20:44 ` [PATCH] [2/45] x86: constify stacktrace_ops Andi Kleen
2007-09-21 20:44 ` [PATCH] [3/45] x86: Separate checking of unsynchronized and unstable TSC Andi Kleen
2007-09-21 20:44 ` [PATCH] [4/45] i386: Rewrite sched_clock Andi Kleen
2007-09-21 20:44 ` [PATCH] [5/45] x86_64: Use new shared sched_clock in x86-64 too Andi Kleen
2007-09-21 20:44 ` [PATCH] [6/45] x86: Unify i386 and x86-64 early quirks Andi Kleen
2007-09-21 20:44 ` [PATCH] [7/45] x86_64: Replace nvidia timer override quirk with pci id list and unify quirks Andi Kleen
2007-09-21 20:44 ` [PATCH] [8/45] x86_64: Use string instruction memcpy on AMD Fam11h Andi Kleen
2007-09-22  9:29   ` Jan Engelhardt
2007-09-21 20:44 ` [PATCH] [9/45] i386: Clean up duplicate includes in arch/i386/kernel/ Andi Kleen
2007-09-21 20:44 ` [PATCH] [10/45] x86_64: x86_64 Sanitize user specified e820 memmap values Andi Kleen
2007-09-21 20:44 ` [PATCH] [11/45] x86_64: Remove rogue default m in drivers/video/Kconfig Andi Kleen
2007-09-22  3:15   ` Len Brown
2007-09-21 20:44 ` [PATCH] [12/45] i386: Fix arch/i386/kernel/nmi.c - 'unknown_nmi_panic_callback' declared 'static' but never defined warning Andi Kleen
2007-09-21 21:08   ` Dave Jones
2007-09-21 20:44 ` [PATCH] [13/45] x86_64: Increase VDSO_TEXT_OFFSET for ancient binutils Andi Kleen
2007-11-14  0:21   ` CaT
2007-11-14  0:25     ` Andi Kleen
2007-09-21 20:44 ` Andi Kleen [this message]
2007-09-21 20:44 ` [PATCH] [15/45] i386: i386 add AMD64 Barcelona PMU MSR definitions to msr.h Andi Kleen
2007-09-21 20:44 ` [PATCH] [16/45] i386: do not BUG_ON() when MSR is unknown Andi Kleen
2007-09-21 20:44 ` [PATCH] [17/45] i386: make Oprofile call shutdown() only once per session Andi Kleen
2007-09-21 20:44 ` [PATCH] [18/45] x86_64: 0 -> NULL, for arch/x86_64 Andi Kleen
2007-09-21 20:45 ` [PATCH] [19/45] x86_64: Always accumulate compiler options in CFLAGS Andi Kleen
2007-09-21 20:45 ` [PATCH] [20/45] x86_64: Use 8 byte stack alignment when possible Andi Kleen
2007-09-21 21:13   ` Dave Jones
2007-09-21 22:34     ` Andi Kleen
2007-09-21 22:52       ` Dave Jones
2007-09-21 21:19   ` Jakub Jelinek
2007-09-30 22:07     ` Andi Kleen
2007-09-21 20:45 ` [PATCH] [21/45] x86_64: Some cleanups for pci gart code Andi Kleen
2007-09-21 20:45 ` [PATCH] [22/45] x86_64: Enable iommu_merge by default Andi Kleen
2007-09-21 20:45 ` [PATCH] [23/45] i386: Make callgraph use dump_trace() on i386/x86_64 Andi Kleen
2007-09-21 20:45 ` [PATCH] [24/45] x86: Introduce frame_pointer() and stack_pointer() Andi Kleen
2007-09-22  9:26   ` Christoph Hellwig
2007-10-01 16:48     ` Andi Kleen
2007-09-21 20:45 ` [PATCH] [25/45] x86_64: remove sync_Arb_IDs Andi Kleen
2007-09-21 20:45 ` [PATCH] [26/45] x86_64: clear IO_APIC before enabing apic error vector Andi Kleen
2007-09-21 20:45 ` [PATCH] [27/45] x86_64: convert mm_context_t semaphore to a mutex Andi Kleen
2007-09-21 20:45 ` [PATCH] [28/45] x86_64: clean up apicid_to_node declaration Andi Kleen
2007-09-21 20:45 ` [PATCH] [29/45] i386: Consolidate show_regs and show_registers for i386 Andi Kleen
2007-09-21 20:45 ` [PATCH] [30/45] i386: Remove local CPU logic in MTRR call to smp_call_function_single Andi Kleen
2007-09-21 20:45 ` [PATCH] [31/45] i386: make struct apic_probe static Andi Kleen
2007-09-21 20:45 ` [PATCH] [32/45] x86_64: hide cond_syscall behind __KERNEL__ Andi Kleen
2007-09-22  9:30   ` Christoph Hellwig
2007-09-21 20:45 ` [PATCH] [33/45] i386: es7000 minor cleanups Andi Kleen
2007-09-21 20:45 ` [PATCH] [34/45] i386: no need to make enable_cpu_hotplug a variable Andi Kleen
2007-09-21 20:45 ` [PATCH] [35/45] i386: make some variables static Andi Kleen
2007-09-21 20:45 ` [PATCH] [36/45] x86_64: kmalloc + memset conversion to kzalloc Andi Kleen
2007-09-21 20:45 ` [PATCH] [37/45] i386: remove -maccumulate-outgoing-args Andi Kleen
2007-09-21 20:45 ` [PATCH] [38/45] i386: setup_trampoline() must be __cpuinit Andi Kleen
2007-09-21 20:45 ` [PATCH] [39/45] x86_64: block irq balancing for timer Andi Kleen
2007-09-21 20:45 ` [PATCH] [40/45] i386: deactivate the test for the dead CONFIG_DEBUG_PAGE_TYPE Andi Kleen
2007-09-21 20:45 ` [PATCH] [41/45] i386: remove unnecessary code Andi Kleen
2007-09-21 20:45 ` [PATCH] [42/45] x86_64: use descriptor's functions instead of inline assembly Andi Kleen
2007-09-21 20:45 ` [PATCH] [43/45] i386: Clean up duplicate includes in arch/i386/xen/ Andi Kleen
2007-09-21 20:45 ` [PATCH] [44/45] i386: simplify smp_call_function_single() call sequence in cpuid Andi Kleen
2007-09-21 20:45 ` [PATCH] [45/45] i386: simplify smp_call_function_single() call sequence Andi Kleen

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=20070921204455.C68D714EFF@wotan.suse.de \
    --to=ak@suse.de \
    --cc=andi@firstfloor.org \
    --cc=gcosta@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@x86-64.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

Powered by JetHome