|
@@ -9,6 +9,7 @@
|
|
|
#include <linux/proc_fs.h>
|
|
|
#include <linux/seq_file.h>
|
|
|
#include <linux/hugetlb.h>
|
|
|
+#include <linux/memcontrol.h>
|
|
|
#include <linux/kernel-page-flags.h>
|
|
|
#include <asm/uaccess.h>
|
|
|
#include "internal.h"
|
|
@@ -225,10 +226,62 @@ static const struct file_operations proc_kpageflags_operations = {
|
|
|
.read = kpageflags_read,
|
|
|
};
|
|
|
|
|
|
+#ifdef CONFIG_MEMCG
|
|
|
+static ssize_t kpagecgroup_read(struct file *file, char __user *buf,
|
|
|
+ size_t count, loff_t *ppos)
|
|
|
+{
|
|
|
+ u64 __user *out = (u64 __user *)buf;
|
|
|
+ struct page *ppage;
|
|
|
+ unsigned long src = *ppos;
|
|
|
+ unsigned long pfn;
|
|
|
+ ssize_t ret = 0;
|
|
|
+ u64 ino;
|
|
|
+
|
|
|
+ pfn = src / KPMSIZE;
|
|
|
+ count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
|
|
|
+ if (src & KPMMASK || count & KPMMASK)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ while (count > 0) {
|
|
|
+ if (pfn_valid(pfn))
|
|
|
+ ppage = pfn_to_page(pfn);
|
|
|
+ else
|
|
|
+ ppage = NULL;
|
|
|
+
|
|
|
+ if (ppage)
|
|
|
+ ino = page_cgroup_ino(ppage);
|
|
|
+ else
|
|
|
+ ino = 0;
|
|
|
+
|
|
|
+ if (put_user(ino, out)) {
|
|
|
+ ret = -EFAULT;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pfn++;
|
|
|
+ out++;
|
|
|
+ count -= KPMSIZE;
|
|
|
+ }
|
|
|
+
|
|
|
+ *ppos += (char __user *)out - buf;
|
|
|
+ if (!ret)
|
|
|
+ ret = (char __user *)out - buf;
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static const struct file_operations proc_kpagecgroup_operations = {
|
|
|
+ .llseek = mem_lseek,
|
|
|
+ .read = kpagecgroup_read,
|
|
|
+};
|
|
|
+#endif /* CONFIG_MEMCG */
|
|
|
+
|
|
|
static int __init proc_page_init(void)
|
|
|
{
|
|
|
proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations);
|
|
|
proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations);
|
|
|
+#ifdef CONFIG_MEMCG
|
|
|
+ proc_create("kpagecgroup", S_IRUSR, NULL, &proc_kpagecgroup_operations);
|
|
|
+#endif
|
|
|
return 0;
|
|
|
}
|
|
|
fs_initcall(proc_page_init);
|