提交 f4ae5da0 编写于 作者: T Thomas Gleixner 提交者: Ingo Molnar

x86: cpa, check if we changed anything and tlb flushing is necessary

Flush tlbs only when there was a real change.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 72e458df
...@@ -21,6 +21,7 @@ struct cpa_data { ...@@ -21,6 +21,7 @@ struct cpa_data {
int numpages; int numpages;
pgprot_t mask_set; pgprot_t mask_set;
pgprot_t mask_clr; pgprot_t mask_clr;
int flushtlb;
}; };
static inline int static inline int
...@@ -329,11 +330,19 @@ static int __change_page_attr(unsigned long address, struct cpa_data *cpa) ...@@ -329,11 +330,19 @@ static int __change_page_attr(unsigned long address, struct cpa_data *cpa)
* not the memory it points to * not the memory it points to
*/ */
new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot)); new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot));
/*
* Do we really change anything ?
*/
if (pte_val(old_pte) != pte_val(new_pte)) {
set_pte_atomic(kpte, new_pte); set_pte_atomic(kpte, new_pte);
cpa->flushtlb = 1;
}
} else { } else {
err = split_large_page(kpte, address); err = split_large_page(kpte, address);
if (!err) if (!err)
goto repeat; goto repeat;
cpa->flushtlb = 1;
} }
return err; return err;
} }
...@@ -438,9 +447,16 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages, ...@@ -438,9 +447,16 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
cpa.numpages = numpages; cpa.numpages = numpages;
cpa.mask_set = mask_set; cpa.mask_set = mask_set;
cpa.mask_clr = mask_clr; cpa.mask_clr = mask_clr;
cpa.flushtlb = 0;
ret = __change_page_attr_set_clr(&cpa); ret = __change_page_attr_set_clr(&cpa);
/*
* Check whether we really changed something:
*/
if (!cpa.flushtlb)
return ret;
/* /*
* No need to flush, when we did not set any of the caching * No need to flush, when we did not set any of the caching
* attributes: * attributes:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册