Skip to content

Commit 05e28f9

Browse files
davem330David S. Miller
authored andcommitted
[SPARC64]: No need to D-cache color page tables any longer.
Unlike the virtual page tables, the new TSB scheme does not require this ugly hack. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 74bf431 commit 05e28f9

3 files changed

Lines changed: 55 additions & 122 deletions

File tree

‎arch/sparc64/mm/init.c‎

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,19 @@ int bigkernel = 0;
145145
#define PGT_CACHE_LOW 25
146146
#define PGT_CACHE_HIGH 50
147147

148+
#ifndef CONFIG_SMP
149+
struct pgtable_cache_struct pgt_quicklists;
150+
#endif
151+
148152
void check_pgt_cache(void)
149153
{
150154
preempt_disable();
151155
if (pgtable_cache_size > PGT_CACHE_HIGH) {
152156
do {
153157
if (pgd_quicklist)
154158
free_pgd_slow(get_pgd_fast());
155-
if (pte_quicklist[0])
156-
free_pte_slow(pte_alloc_one_fast(NULL, 0));
157-
if (pte_quicklist[1])
158-
free_pte_slow(pte_alloc_one_fast(NULL, 1 << (PAGE_SHIFT + 10)));
159+
if (pte_quicklist)
160+
free_pte_slow(pte_alloc_one_fast());
159161
} while (pgtable_cache_size > PGT_CACHE_LOW);
160162
}
161163
preempt_enable();
@@ -962,67 +964,6 @@ void get_new_mmu_context(struct mm_struct *mm)
962964
spin_unlock(&ctx_alloc_lock);
963965
}
964966

965-
#ifndef CONFIG_SMP
966-
struct pgtable_cache_struct pgt_quicklists;
967-
#endif
968-
969-
/* XXX We don't need to color these things in the D-cache any longer. */
970-
#ifdef DCACHE_ALIASING_POSSIBLE
971-
#define DC_ALIAS_SHIFT 1
972-
#else
973-
#define DC_ALIAS_SHIFT 0
974-
#endif
975-
pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
976-
{
977-
struct page *page;
978-
unsigned long color;
979-
980-
{
981-
pte_t *ptep = pte_alloc_one_fast(mm, address);
982-
983-
if (ptep)
984-
return ptep;
985-
}
986-
987-
color = VPTE_COLOR(address);
988-
page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, DC_ALIAS_SHIFT);
989-
if (page) {
990-
unsigned long *to_free;
991-
unsigned long paddr;
992-
pte_t *pte;
993-
994-
#ifdef DCACHE_ALIASING_POSSIBLE
995-
set_page_count(page, 1);
996-
ClearPageCompound(page);
997-
998-
set_page_count((page + 1), 1);
999-
ClearPageCompound(page + 1);
1000-
#endif
1001-
paddr = (unsigned long) page_address(page);
1002-
memset((char *)paddr, 0, (PAGE_SIZE << DC_ALIAS_SHIFT));
1003-
1004-
if (!color) {
1005-
pte = (pte_t *) paddr;
1006-
to_free = (unsigned long *) (paddr + PAGE_SIZE);
1007-
} else {
1008-
pte = (pte_t *) (paddr + PAGE_SIZE);
1009-
to_free = (unsigned long *) paddr;
1010-
}
1011-
1012-
#ifdef DCACHE_ALIASING_POSSIBLE
1013-
/* Now free the other one up, adjust cache size. */
1014-
preempt_disable();
1015-
*to_free = (unsigned long) pte_quicklist[color ^ 0x1];
1016-
pte_quicklist[color ^ 0x1] = to_free;
1017-
pgtable_cache_size++;
1018-
preempt_enable();
1019-
#endif
1020-
1021-
return pte;
1022-
}
1023-
return NULL;
1024-
}
1025-
1026967
void sparc_ultra_dump_itlb(void)
1027968
{
1028969
int slot;

‎include/asm-sparc64/cpudata.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ typedef struct {
2020
/* Dcache line 2 */
2121
unsigned int pgcache_size;
2222
unsigned int __pad1;
23-
unsigned long *pte_cache[2];
23+
unsigned long *pte_cache;
2424
unsigned long *pgd_cache;
25+
unsigned long __pad2;
2526

2627
/* Dcache line 3, rarely used */
2728
unsigned int dcache_size;
@@ -30,8 +31,8 @@ typedef struct {
3031
unsigned int icache_line_size;
3132
unsigned int ecache_size;
3233
unsigned int ecache_line_size;
33-
unsigned int __pad2;
3434
unsigned int __pad3;
35+
unsigned int __pad4;
3536
} cpuinfo_sparc;
3637

3738
DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);

‎include/asm-sparc64/pgalloc.h‎

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
#else
2020
extern struct pgtable_cache_struct {
2121
unsigned long *pgd_cache;
22-
unsigned long *pte_cache[2];
22+
unsigned long *pte_cache;
2323
unsigned int pgcache_size;
2424
} pgt_quicklists;
2525
#endif
2626
#define pgd_quicklist (pgt_quicklists.pgd_cache)
27-
#define pmd_quicklist ((unsigned long *)0)
2827
#define pte_quicklist (pgt_quicklists.pte_cache)
2928
#define pgtable_cache_size (pgt_quicklists.pgcache_size)
3029

31-
static __inline__ void free_pgd_fast(pgd_t *pgd)
30+
static inline void free_pgd_fast(pgd_t *pgd)
3231
{
3332
preempt_disable();
3433
*(unsigned long *)pgd = (unsigned long) pgd_quicklist;
@@ -37,7 +36,7 @@ static __inline__ void free_pgd_fast(pgd_t *pgd)
3736
preempt_enable();
3837
}
3938

40-
static __inline__ pgd_t *get_pgd_fast(void)
39+
static inline pgd_t *get_pgd_fast(void)
4140
{
4241
unsigned long *ret;
4342

@@ -56,66 +55,52 @@ static __inline__ pgd_t *get_pgd_fast(void)
5655
return (pgd_t *)ret;
5756
}
5857

59-
static __inline__ void free_pgd_slow(pgd_t *pgd)
58+
static inline void free_pgd_slow(pgd_t *pgd)
6059
{
6160
free_page((unsigned long)pgd);
6261
}
6362

64-
/* XXX This crap can die, no longer using virtual page tables... */
65-
#ifdef DCACHE_ALIASING_POSSIBLE
66-
#define VPTE_COLOR(address) (((address) >> (PAGE_SHIFT + 10)) & 1UL)
67-
#define DCACHE_COLOR(address) (((address) >> PAGE_SHIFT) & 1UL)
68-
#else
69-
#define VPTE_COLOR(address) 0
70-
#define DCACHE_COLOR(address) 0
71-
#endif
72-
7363
#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7464

75-
static __inline__ pmd_t *pmd_alloc_one_fast(struct mm_struct *mm, unsigned long address)
65+
static inline pmd_t *pmd_alloc_one_fast(void)
7666
{
7767
unsigned long *ret;
78-
int color = 0;
7968

8069
preempt_disable();
81-
if (pte_quicklist[color] == NULL)
82-
color = 1;
83-
84-
if((ret = (unsigned long *)pte_quicklist[color]) != NULL) {
85-
pte_quicklist[color] = (unsigned long *)(*ret);
70+
ret = (unsigned long *) pte_quicklist;
71+
if (likely(ret)) {
72+
pte_quicklist = (unsigned long *)(*ret);
8673
ret[0] = 0;
8774
pgtable_cache_size--;
8875
}
8976
preempt_enable();
9077

91-
return (pmd_t *)ret;
78+
return (pmd_t *) ret;
9279
}
9380

94-
static __inline__ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
81+
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
9582
{
9683
pmd_t *pmd;
9784

98-
pmd = pmd_alloc_one_fast(mm, address);
99-
if (!pmd) {
85+
pmd = pmd_alloc_one_fast();
86+
if (unlikely(!pmd)) {
10087
pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
10188
if (pmd)
10289
memset(pmd, 0, PAGE_SIZE);
10390
}
10491
return pmd;
10592
}
10693

107-
static __inline__ void free_pmd_fast(pmd_t *pmd)
94+
static inline void free_pmd_fast(pmd_t *pmd)
10895
{
109-
unsigned long color = DCACHE_COLOR((unsigned long)pmd);
110-
11196
preempt_disable();
112-
*(unsigned long *)pmd = (unsigned long) pte_quicklist[color];
113-
pte_quicklist[color] = (unsigned long *) pmd;
97+
*(unsigned long *)pmd = (unsigned long) pte_quicklist;
98+
pte_quicklist = (unsigned long *) pmd;
11499
pgtable_cache_size++;
115100
preempt_enable();
116101
}
117102

118-
static __inline__ void free_pmd_slow(pmd_t *pmd)
103+
static inline void free_pmd_slow(pmd_t *pmd)
119104
{
120105
free_page((unsigned long)pmd);
121106
}
@@ -124,48 +109,54 @@ static __inline__ void free_pmd_slow(pmd_t *pmd)
124109
#define pmd_populate(MM,PMD,PTE_PAGE) \
125110
pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
126111

127-
extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address);
128-
129-
static inline struct page *
130-
pte_alloc_one(struct mm_struct *mm, unsigned long addr)
131-
{
132-
pte_t *pte = pte_alloc_one_kernel(mm, addr);
133-
134-
if (pte)
135-
return virt_to_page(pte);
136-
137-
return NULL;
138-
}
139-
140-
static __inline__ pte_t *pte_alloc_one_fast(struct mm_struct *mm, unsigned long address)
112+
static inline pte_t *pte_alloc_one_fast(void)
141113
{
142-
unsigned long color = VPTE_COLOR(address);
143114
unsigned long *ret;
144115

145116
preempt_disable();
146-
if((ret = (unsigned long *)pte_quicklist[color]) != NULL) {
147-
pte_quicklist[color] = (unsigned long *)(*ret);
117+
ret = (unsigned long *) pte_quicklist;
118+
if (likely(ret)) {
119+
pte_quicklist = (unsigned long *)(*ret);
148120
ret[0] = 0;
149121
pgtable_cache_size--;
150122
}
151123
preempt_enable();
152-
return (pte_t *)ret;
124+
125+
return (pte_t *) ret;
126+
}
127+
128+
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
129+
{
130+
pte_t *ptep = pte_alloc_one_fast();
131+
132+
if (likely(ptep))
133+
return ptep;
134+
135+
return (pte_t *) get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
153136
}
154137

155-
static __inline__ void free_pte_fast(pte_t *pte)
138+
static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long addr)
156139
{
157-
unsigned long color = DCACHE_COLOR((unsigned long)pte);
140+
pte_t *pte = pte_alloc_one_fast();
158141

142+
if (likely(pte))
143+
return virt_to_page(pte);
144+
145+
return alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
146+
}
147+
148+
static inline void free_pte_fast(pte_t *pte)
149+
{
159150
preempt_disable();
160-
*(unsigned long *)pte = (unsigned long) pte_quicklist[color];
161-
pte_quicklist[color] = (unsigned long *) pte;
151+
*(unsigned long *)pte = (unsigned long) pte_quicklist;
152+
pte_quicklist = (unsigned long *) pte;
162153
pgtable_cache_size++;
163154
preempt_enable();
164155
}
165156

166-
static __inline__ void free_pte_slow(pte_t *pte)
157+
static inline void free_pte_slow(pte_t *pte)
167158
{
168-
free_page((unsigned long)pte);
159+
free_page((unsigned long) pte);
169160
}
170161

171162
static inline void pte_free_kernel(pte_t *pte)

0 commit comments

Comments
 (0)