From: Vasiliy Ulyanov Date: Wed, 9 Dec 2015 14:00:38 +0000 (+0300) Subject: x86, pat: workaround to force PAT usage X-Git-Tag: submit/tizen/20160422.055611~1^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=129fe163319ffaa9a82ab05e3534c625b341af96;p=sdk%2Femulator%2Femulator-kernel.git x86, pat: workaround to force PAT usage When run under haxm certain CPU features appear inaccesible from guest and at the moment there seems to be no proper way to set them up from the host side. The patch allows to forcefully enable x86 Page Attribute Table and therefore use different memory caching policies at the page level granularity. PAT significantly improves performance when mmaped device buffers are accessed. WARNING: once a proper solution is figured out for haxm case the patch should be reverted. Currently it is more like a hack to avoid terrible performance on certain scenarios like decoding high resolution video directly into the mmaped video buffer. Change-Id: Ie810a29d61379e57ed10efc0697f9fc010f85f33 Signed-off-by: Vasiliy Ulyanov (cherry picked from commit 7aaf8838c358d7e745727e0281ae3acbd9e81afd) --- diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 657438858e83..913cd1947d64 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -54,6 +54,14 @@ static inline void pat_disable(const char *reason) } #endif +static int __read_mostly force_pat; + +static int __init force_pat_setup(char *str) +{ + force_pat = 1; + return 0; +} +early_param("force_pat", force_pat_setup); int pat_debug_enable; @@ -85,9 +93,18 @@ void pat_init(void) if (!pat_enabled) return; +force_retry: if (!cpu_has_pat) { if (!boot_pat_state) { - pat_disable("PAT not supported by CPU."); + if (force_pat) { + printk(KERN_WARNING "Force x86 PAT on cpu %d\n", + smp_processor_id()); + setup_force_cpu_cap(X86_FEATURE_PAT); + force_pat = 0; + goto force_retry; + } else { + pat_disable("PAT not supported by CPU."); + } return; } else { /*