public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PPC64] Use slbie, not slbia in hugepage code
@ 2004-05-04 10:08 David Gibson
  0 siblings, 0 replies; only message in thread
From: David Gibson @ 2004-05-04 10:08 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton
  Cc: Anton Blanchard, linux-kernel, linuxppc64-dev

Linus, please apply:

On PPC64, when we prepare segments below 4G for use with hugepages, we
need to flush their entries from the SLB, in case SLB entries
specifying normal pages were already present.

Previously we did that by flushing the entire SLB, the patch below
changes this to individually flush each necessary segment with slbie.
The new version may well be slightly faster, but the real reason for
it is so that this code path doesn't need to be changed to reinstate
any bolted SLB entries, if we add them.  The existing version has
already caused problems (read, crashes) when combined with some
patches that add bolted SLB entries.

Index: working-2.6/arch/ppc64/mm/hugetlbpage.c
===================================================================
--- working-2.6.orig/arch/ppc64/mm/hugetlbpage.c	2004-05-04 16:35:55.000000000 +1000
+++ working-2.6/arch/ppc64/mm/hugetlbpage.c	2004-05-04 20:07:00.023964800 +1000
@@ -245,9 +245,20 @@
 	return 0;
 }
 
-static void do_slbia(void *unused)
+static void flush_segments(void *parm)
 {
-	asm volatile ("isync; slbia; isync":::"memory");
+	u16 segs = (unsigned long) parm;
+	unsigned long i;
+
+	asm volatile("isync" : : : "memory");
+
+	for (i = 0; i < 16; i++) {
+		if (! (segs & (1U << i)))
+			continue;
+		asm volatile("slbie %0" : : "r" (i << SID_SHIFT));
+	}
+
+	asm volatile("isync" : : : "memory");
 }
 
 static int prepare_low_seg_for_htlb(struct mm_struct *mm, unsigned long seg)
@@ -316,10 +327,10 @@
 				return -EBUSY;
 
 	mm->context.htlb_segs |= newsegs;
-	/* the context change must make it to memory before the slbia,
+	/* the context change must make it to memory before the flush,
 	 * so that further SLB misses do the right thing. */
 	mb();
-	on_each_cpu(do_slbia, NULL, 0, 1);
+	on_each_cpu(flush_segments, (void *)(unsigned long)newsegs, 0, 1);
 
 	return 0;
 }


-- 
David Gibson			| For every complex problem there is a
david AT gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-05-04 10:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-04 10:08 [PPC64] Use slbie, not slbia in hugepage code David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox