lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1336485790-30902-8-git-send-email-alex.shi@intel.com>
Date:	Tue,  8 May 2012 22:03:10 +0800
From:	Alex Shi <alex.shi@...el.com>
To:	mgorman@...e.de, npiggin@...il.com, tglx@...utronix.de,
	mingo@...hat.com, hpa@...or.com, arnd@...db.de,
	rostedt@...dmis.org, fweisbec@...il.com
Cc:	jeremy@...p.org, gregkh@...uxfoundation.org, glommer@...hat.com,
	riel@...hat.com, luto@....edu, alex.shi@...el.com, avi@...hat.com,
	len.brown@...el.com, dhowells@...hat.com, fenghua.yu@...el.com,
	borislav.petkov@....com, yinghai@...nel.org, ak@...ux.intel.com,
	cpw@....com, steiner@....com, akpm@...ux-foundation.org,
	penberg@...nel.org, hughd@...gle.com, rientjes@...gle.com,
	kosaki.motohiro@...fujitsu.com, n-horiguchi@...jp.nec.com,
	paul.gortmaker@...driver.com, trenn@...e.de, tj@...nel.org,
	oleg@...hat.com, axboe@...nel.dk, a.p.zijlstra@...llo.nl,
	kamezawa.hiroyu@...fujitsu.com, viro@...iv.linux.org.uk,
	linux-kernel@...r.kernel.org
Subject: [PATCH v3 7/7] x86/tlb: add tlb_flushall_factor into sysfs for user change

kernel will replace cr3 rewrite with invlpg when
	tlb flush entries <= 1/tlb_flushall_factor
if tlb_flushall_factor is 0, kernel won't do this replace.

User can modify its value according to specific applications.

Signed-off-by: Alex Shi <alex.shi@...el.com>
---
 arch/x86/kernel/cpu/intel.c |   35 +++++++++++++++++++++++++++++++++++
 drivers/base/cpu.c          |    2 ++
 include/linux/cpu.h         |    2 ++
 3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 42480c6..8a14081 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -662,6 +662,41 @@ void intel_cpu_detect_tlb(struct cpuinfo_x86 *c)
 	intel_tlb_flushall_factor_set(c);
 }
 
+static ssize_t __tlb_flushall_factor_store(const char *buf,
+					size_t count, int smt)
+{
+	unsigned int factor = 0;
+
+	if (sscanf(buf, "%u", &factor) != 1)
+		return -EINVAL;
+
+	tlb_flushall_factor = factor;
+
+	return count;
+}
+
+static ssize_t tlb_flushall_factor_show(struct device *dev,
+					   struct device_attribute *attr,
+					   char *buf)
+{
+	return sprintf(buf, "%u\n", tlb_flushall_factor);
+}
+static ssize_t tlb_flushall_factor_store(struct device *dev,
+					    struct device_attribute *attr,
+					    const char *buf, size_t count)
+{
+	return __tlb_flushall_factor_store(buf, count, 0);
+}
+
+static DEVICE_ATTR(tlb_flushall_factor, 0644,
+		   tlb_flushall_factor_show,
+		   tlb_flushall_factor_store);
+
+int __init create_sysfs_tlb_flushall_factor(struct device *dev)
+{
+	return device_create_file(dev, &dev_attr_tlb_flushall_factor);
+}
+
 static const struct cpu_dev __cpuinitconst intel_cpu_dev = {
 	.c_vendor	= "Intel",
 	.c_ident	= { "GenuineIntel" },
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index adf937b..b46e1b9 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -331,6 +331,8 @@ void __init cpu_dev_init(void)
 
 	cpu_dev_register_generic();
 
+	create_sysfs_tlb_flushall_factor(cpu_subsys.dev_root);
+
 #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
 	sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root);
 #endif
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index ee28844..5c953b0 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -36,6 +36,8 @@ extern void cpu_remove_dev_attr(struct device_attribute *attr);
 extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
 extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
 
+extern int create_sysfs_tlb_flushall_factor(struct device *dev);
+
 extern int sched_create_sysfs_power_savings_entries(struct device *dev);
 
 #ifdef CONFIG_HOTPLUG_CPU
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ