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: <1465811233-21136-4-git-send-email-liang.z.li@intel.com>
Date:	Mon, 13 Jun 2016 17:47:10 +0800
From:	Liang Li <liang.z.li@...el.com>
To:	kvm@...r.kernel.org
Cc:	virtio-dev@...ts.oasis-open.org, qemu-devel@...gun.org,
	linux-kernel@...r.kernel.org, mst@...hat.com,
	Liang Li <liang.z.li@...el.com>,
	Paolo Bonzini <pbonzini@...hat.com>,
	Cornelia Huck <cornelia.huck@...ibm.com>,
	Amit Shah <amit.shah@...hat.com>,
	Alexander Viro <viro@...iv.linux.org.uk>
Subject: [PATCH 3/6] mm:split the drop cache operation into a function

Put the drop caches operation in a new function and export it, then
wen can reuse it later.

Signed-off-by: Liang Li <liang.z.li@...el.com>
Cc: Michael S. Tsirkin <mst@...hat.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Cornelia Huck <cornelia.huck@...ibm.com>
Cc: Amit Shah <amit.shah@...hat.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk> 
---
 fs/drop_caches.c   | 22 ++++++++++++++--------
 include/linux/mm.h |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d72d52b..977dc71 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -50,14 +50,7 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write,
 	if (write) {
 		static int stfu;
 
-		if (sysctl_drop_caches & 1) {
-			iterate_supers(drop_pagecache_sb, NULL);
-			count_vm_event(DROP_PAGECACHE);
-		}
-		if (sysctl_drop_caches & 2) {
-			drop_slab();
-			count_vm_event(DROP_SLAB);
-		}
+		drop_caches(sysctl_drop_caches);
 		if (!stfu) {
 			pr_info("%s (%d): drop_caches: %d\n",
 				current->comm, task_pid_nr(current),
@@ -67,3 +60,16 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write,
 	}
 	return 0;
 }
+
+void drop_caches(int drop_ctl)
+{
+	if (drop_ctl & 1) {
+		iterate_supers(drop_pagecache_sb, NULL);
+		count_vm_event(DROP_PAGECACHE);
+	}
+	if (drop_ctl & 2) {
+		drop_slab();
+		count_vm_event(DROP_SLAB);
+	}
+}
+EXPORT_SYMBOL_GPL(drop_caches);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5df5feb..e22e315 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2263,6 +2263,7 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr)
 extern int sysctl_drop_caches;
 int drop_caches_sysctl_handler(struct ctl_table *, int,
 					void __user *, size_t *, loff_t *);
+void drop_caches(int drop_ctl);
 #endif
 
 void drop_slab(void);
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ