@@ -2957,6 +2957,25 @@ static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns,
}
#endif /* CONFIG_STACKLEAK_METRICS */
+static ssize_t madvise_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct task_struct *task;
+
+ task = get_proc_task(file_inode(file));
+ if (!task)
+ return -ESRCH;
+
+ put_task_struct(task);
+
+ return count;
+}
+
+static const struct file_operations proc_madvise_operations = {
+ .write = madvise_write,
+ .llseek = noop_llseek,
+};
+
/*
* Thread groups
*/
@@ -3061,6 +3080,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_STACKLEAK_METRICS
ONE("stack_depth", S_IRUGO, proc_stack_depth),
#endif
+ REG("madvise", S_IRUGO|S_IWUSR, proc_madvise_operations),
};
static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
Add a write-only /proc/<pid>/madvise file to handle remote madvise operations. For now, this is just a soother that does nothing. Signed-off-by: Oleksandr Natalenko <oleksandr@redhat.com> --- fs/proc/base.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)