drop_caches.c (a09ed5e00084448453c8bada4dcd31e5fbfc2f21) drop_caches.c (1495f230fa7750479c79e3656286b9183d662077)
1/*
2 * Implement the manual drop-all-pagecache function
3 */
4
5#include <linux/kernel.h>
6#include <linux/mm.h>
7#include <linux/fs.h>
8#include <linux/writeback.h>

--- 28 unchanged lines hidden (view full) ---

37 iput(toput_inode);
38}
39
40static void drop_slab(void)
41{
42 int nr_objects;
43 struct shrink_control shrink = {
44 .gfp_mask = GFP_KERNEL,
1/*
2 * Implement the manual drop-all-pagecache function
3 */
4
5#include <linux/kernel.h>
6#include <linux/mm.h>
7#include <linux/fs.h>
8#include <linux/writeback.h>

--- 28 unchanged lines hidden (view full) ---

37 iput(toput_inode);
38}
39
40static void drop_slab(void)
41{
42 int nr_objects;
43 struct shrink_control shrink = {
44 .gfp_mask = GFP_KERNEL,
45 .nr_scanned = 1000,
46 };
47
48 do {
45 };
46
47 do {
49 nr_objects = shrink_slab(&shrink, 1000);
48 nr_objects = shrink_slab(&shrink, 1000, 1000);
50 } while (nr_objects > 10);
51}
52
53int drop_caches_sysctl_handler(ctl_table *table, int write,
54 void __user *buffer, size_t *length, loff_t *ppos)
55{
56 int ret;
57
58 ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
59 if (ret)
60 return ret;
61 if (write) {
62 if (sysctl_drop_caches & 1)
63 iterate_supers(drop_pagecache_sb, NULL);
64 if (sysctl_drop_caches & 2)
65 drop_slab();
66 }
67 return 0;
68}
49 } while (nr_objects > 10);
50}
51
52int drop_caches_sysctl_handler(ctl_table *table, int write,
53 void __user *buffer, size_t *length, loff_t *ppos)
54{
55 int ret;
56
57 ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
58 if (ret)
59 return ret;
60 if (write) {
61 if (sysctl_drop_caches & 1)
62 iterate_supers(drop_pagecache_sb, NULL);
63 if (sysctl_drop_caches & 2)
64 drop_slab();
65 }
66 return 0;
67}