Skip to content

Commit 849c498

Browse files
committed
sparc64: Handle extremely large kernel TSB range flushes sanely.
If the number of pages we are flushing is more than twice the number of entries in the TSB, just scan the TSB table for matches rather than probing each and every page in the range. Based upon a patch and report by James Clarke. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9d9fa23 commit 849c498

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

arch/sparc/mm/tsb.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ static inline int tag_compare(unsigned long tag, unsigned long vaddr)
2727
return (tag == (vaddr >> 22));
2828
}
2929

30+
static void flush_tsb_kernel_range_scan(unsigned long start, unsigned long end)
31+
{
32+
unsigned long idx;
33+
34+
for (idx = 0; idx < KERNEL_TSB_NENTRIES; idx++) {
35+
struct tsb *ent = &swapper_tsb[idx];
36+
unsigned long match = idx << 13;
37+
38+
match |= (ent->tag << 22);
39+
if (match >= start && match < end)
40+
ent->tag = (1UL << TSB_TAG_INVALID_BIT);
41+
}
42+
}
43+
3044
/* TSB flushes need only occur on the processor initiating the address
3145
* space modification, not on each cpu the address space has run on.
3246
* Only the TLB flush needs that treatment.
@@ -36,6 +50,9 @@ void flush_tsb_kernel_range(unsigned long start, unsigned long end)
3650
{
3751
unsigned long v;
3852

53+
if ((end - start) >> PAGE_SHIFT >= 2 * KERNEL_TSB_NENTRIES)
54+
return flush_tsb_kernel_range_scan(start, end);
55+
3956
for (v = start; v < end; v += PAGE_SIZE) {
4057
unsigned long hash = tsb_hash(v, PAGE_SHIFT,
4158
KERNEL_TSB_NENTRIES);

0 commit comments

Comments
 (0)