Commit 8be8f54b authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Ingo Molnar

x86: CPA: avoid split of alias mappings

avoid over-eager large page splitup.

When the target area needs to be split or is split already (ioremap)
then the current code enforces the split of large mappings in the alias
regions even if we could avoid it.

Use a separate variable processed in the cpa_data structure to carry
the number of pages which have been processed instead of reusing the
numpages variable. This keeps numpages intact and gives the alias code
a chance to keep large mappings intact.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 757265b8
...@@ -26,6 +26,7 @@ struct cpa_data { ...@@ -26,6 +26,7 @@ struct cpa_data {
pgprot_t mask_set; pgprot_t mask_set;
pgprot_t mask_clr; pgprot_t mask_clr;
int numpages; int numpages;
int processed;
int flushtlb; int flushtlb;
unsigned long pfn; unsigned long pfn;
}; };
...@@ -290,8 +291,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, ...@@ -290,8 +291,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
*/ */
nextpage_addr = (address + psize) & pmask; nextpage_addr = (address + psize) & pmask;
numpages = (nextpage_addr - address) >> PAGE_SHIFT; numpages = (nextpage_addr - address) >> PAGE_SHIFT;
if (numpages < cpa->numpages) if (numpages < cpa->processed)
cpa->numpages = numpages; cpa->processed = numpages;
/* /*
* We are safe now. Check whether the new pgprot is the same: * We are safe now. Check whether the new pgprot is the same:
...@@ -318,7 +319,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, ...@@ -318,7 +319,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
*/ */
addr = address + PAGE_SIZE; addr = address + PAGE_SIZE;
pfn++; pfn++;
for (i = 1; i < cpa->numpages; i++, addr += PAGE_SIZE, pfn++) { for (i = 1; i < cpa->processed; i++, addr += PAGE_SIZE, pfn++) {
pgprot_t chk_prot = static_protections(new_prot, addr, pfn); pgprot_t chk_prot = static_protections(new_prot, addr, pfn);
if (pgprot_val(chk_prot) != pgprot_val(new_prot)) if (pgprot_val(chk_prot) != pgprot_val(new_prot))
...@@ -342,7 +343,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, ...@@ -342,7 +343,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
* that we limited the number of possible pages already to * that we limited the number of possible pages already to
* the number of pages in the large page. * the number of pages in the large page.
*/ */
if (address == (nextpage_addr - psize) && cpa->numpages == numpages) { if (address == (nextpage_addr - psize) && cpa->processed == numpages) {
/* /*
* The address is aligned and the number of pages * The address is aligned and the number of pages
* covers the full page. * covers the full page.
...@@ -572,7 +573,7 @@ static int __change_page_attr(struct cpa_data *cpa, int primary) ...@@ -572,7 +573,7 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
set_pte_atomic(kpte, new_pte); set_pte_atomic(kpte, new_pte);
cpa->flushtlb = 1; cpa->flushtlb = 1;
} }
cpa->numpages = 1; cpa->processed = 1;
return 0; return 0;
} }
...@@ -583,7 +584,7 @@ static int __change_page_attr(struct cpa_data *cpa, int primary) ...@@ -583,7 +584,7 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
do_split = try_preserve_large_page(kpte, address, cpa); do_split = try_preserve_large_page(kpte, address, cpa);
/* /*
* When the range fits into the existing large page, * When the range fits into the existing large page,
* return. cp->numpages and cpa->tlbflush have been updated in * return. cp->processed and cpa->tlbflush have been updated in
* try_large_page: * try_large_page:
*/ */
if (do_split <= 0) if (do_split <= 0)
...@@ -662,7 +663,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) ...@@ -662,7 +663,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
* Store the remaining nr of pages for the large page * Store the remaining nr of pages for the large page
* preservation check. * preservation check.
*/ */
cpa->numpages = numpages; cpa->numpages = cpa->processed = numpages;
ret = __change_page_attr(cpa, checkalias); ret = __change_page_attr(cpa, checkalias);
if (ret) if (ret)
...@@ -679,9 +680,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) ...@@ -679,9 +680,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
* CPA operation. Either a large page has been * CPA operation. Either a large page has been
* preserved or a single page update happened. * preserved or a single page update happened.
*/ */
BUG_ON(cpa->numpages > numpages); BUG_ON(cpa->processed > numpages);
numpages -= cpa->numpages; numpages -= cpa->processed;
cpa->vaddr += cpa->numpages * PAGE_SIZE; cpa->vaddr += cpa->processed * PAGE_SIZE;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment